diff --git a/packages/core/client/src/locale/zh-CN.json b/packages/core/client/src/locale/zh-CN.json index 6199385d4b..812e3cc6d2 100644 --- a/packages/core/client/src/locale/zh-CN.json +++ b/packages/core/client/src/locale/zh-CN.json @@ -1017,5 +1017,11 @@ "Left": "左", "Center": "居中", "Right": "右", - "Divider line color": "分割线颜色" + "Divider line color": "分割线颜色", + "Label align": "字段标题对齐方式", + "Label width": "字段标题宽度", + "When the Label exceeds the width": "字段标题超出宽度时", + "Line break": "换行", + "Ellipsis": "省略", + "Set block layout": "设置区块布局" } diff --git a/packages/core/client/src/modules/blocks/data-blocks/details-multi/detailsWithPaginationSettings.tsx b/packages/core/client/src/modules/blocks/data-blocks/details-multi/detailsWithPaginationSettings.tsx index e138d82281..9653bd2d82 100644 --- a/packages/core/client/src/modules/blocks/data-blocks/details-multi/detailsWithPaginationSettings.tsx +++ b/packages/core/client/src/modules/blocks/data-blocks/details-multi/detailsWithPaginationSettings.tsx @@ -16,13 +16,14 @@ import { useDetailsBlockContext } from '../../../../block-provider/DetailsBlockP import { useFormBlockContext } from '../../../../block-provider/FormBlockProvider'; import { useCollection_deprecated, useSortFields } from '../../../../collection-manager'; import { removeNullCondition, useDesignable } from '../../../../schema-component'; -import { SchemaSettingsLinkageRules, schemaSettingsLabelLayout } from '../../../../schema-settings'; +import { SchemaSettingsLinkageRules } from '../../../../schema-settings'; import { SchemaSettingsBlockHeightItem } from '../../../../schema-settings/SchemaSettingsBlockHeightItem'; import { SchemaSettingsBlockTitleItem } from '../../../../schema-settings/SchemaSettingsBlockTitleItem'; import { SchemaSettingsDataScope } from '../../../../schema-settings/SchemaSettingsDataScope'; import { SchemaSettingsTemplate } from '../../../../schema-settings/SchemaSettingsTemplate'; import { useBlockTemplateContext } from '../../../../schema-templates/BlockTemplateProvider'; import { setDataLoadingModeSettingsItem } from './setDataLoadingModeSettingsItem'; +import { SchemaSettingsLayoutItem } from '../../../../schema-settings/SchemaSettingsLayoutItem'; const commonItems: SchemaSettingsItemType[] = [ { @@ -212,7 +213,10 @@ const commonItems: SchemaSettingsItemType[] = [ }; }, }, - schemaSettingsLabelLayout, + { + name: 'setBlockLayout', + Component: SchemaSettingsLayoutItem, + }, { name: 'divider', type: 'divider', diff --git a/packages/core/client/src/modules/blocks/data-blocks/details-single/detailsBlockSettings.ts b/packages/core/client/src/modules/blocks/data-blocks/details-single/detailsBlockSettings.ts index 32ffeec36d..6d7f136c3c 100644 --- a/packages/core/client/src/modules/blocks/data-blocks/details-single/detailsBlockSettings.ts +++ b/packages/core/client/src/modules/blocks/data-blocks/details-single/detailsBlockSettings.ts @@ -11,14 +11,12 @@ import { useFieldSchema } from '@formily/react'; import { SchemaSettings } from '../../../../application/schema-settings/SchemaSettings'; import { SchemaSettingsItemType } from '../../../../application/schema-settings/types'; import { useCollection } from '../../../../data-source/collection/CollectionProvider'; -import { - SchemaSettingsFormItemTemplate, - SchemaSettingsLinkageRules, - schemaSettingsLabelLayout, -} from '../../../../schema-settings'; +import { SchemaSettingsFormItemTemplate, SchemaSettingsLinkageRules } from '../../../../schema-settings'; import { SchemaSettingsBlockHeightItem } from '../../../../schema-settings/SchemaSettingsBlockHeightItem'; import { SchemaSettingsBlockTitleItem } from '../../../../schema-settings/SchemaSettingsBlockTitleItem'; import { useBlockTemplateContext } from '../../../../schema-templates/BlockTemplateProvider'; +import { SchemaSettingsLayoutItem } from '../../../../schema-settings/SchemaSettingsLayoutItem'; + const commonItems: SchemaSettingsItemType[] = [ { name: 'title', @@ -56,7 +54,10 @@ const commonItems: SchemaSettingsItemType[] = [ }; }, }, - schemaSettingsLabelLayout, + { + name: 'setBlockLayout', + Component: SchemaSettingsLayoutItem, + }, { name: 'divider', type: 'divider', diff --git a/packages/core/client/src/modules/blocks/data-blocks/form/createFormBlockSettings.tsx b/packages/core/client/src/modules/blocks/data-blocks/form/createFormBlockSettings.tsx index b3c86d4fb7..3a5be113e0 100644 --- a/packages/core/client/src/modules/blocks/data-blocks/form/createFormBlockSettings.tsx +++ b/packages/core/client/src/modules/blocks/data-blocks/form/createFormBlockSettings.tsx @@ -16,11 +16,11 @@ import { SchemaSettingsDataTemplates, SchemaSettingsFormItemTemplate, SchemaSettingsLinkageRules, - schemaSettingsLabelLayout, } from '../../../../schema-settings'; import { SchemaSettingsBlockHeightItem } from '../../../../schema-settings/SchemaSettingsBlockHeightItem'; import { SchemaSettingsBlockTitleItem } from '../../../../schema-settings/SchemaSettingsBlockTitleItem'; import { useBlockTemplateContext } from '../../../../schema-templates/BlockTemplateProvider'; +import { SchemaSettingsLayoutItem } from '../../../../schema-settings/SchemaSettingsLayoutItem'; export const createFormBlockSettings = new SchemaSettings({ name: 'blockSettings:createForm', @@ -77,7 +77,10 @@ export const createFormBlockSettings = new SchemaSettings({ }; }, }, - schemaSettingsLabelLayout, + { + name: 'setBlockLayout', + Component: SchemaSettingsLayoutItem, + }, { name: 'divider2', type: 'divider', diff --git a/packages/core/client/src/modules/blocks/data-blocks/form/editFormBlockSettings.ts b/packages/core/client/src/modules/blocks/data-blocks/form/editFormBlockSettings.ts index fb7686c096..6b41165721 100644 --- a/packages/core/client/src/modules/blocks/data-blocks/form/editFormBlockSettings.ts +++ b/packages/core/client/src/modules/blocks/data-blocks/form/editFormBlockSettings.ts @@ -16,11 +16,11 @@ import { SchemaSettingsDataTemplates, SchemaSettingsFormItemTemplate, SchemaSettingsLinkageRules, - schemaSettingsLabelLayout, } from '../../../../schema-settings'; import { SchemaSettingsBlockHeightItem } from '../../../../schema-settings/SchemaSettingsBlockHeightItem'; import { SchemaSettingsBlockTitleItem } from '../../../../schema-settings/SchemaSettingsBlockTitleItem'; import { useBlockTemplateContext } from '../../../../schema-templates/BlockTemplateProvider'; +import { SchemaSettingsLayoutItem } from '../../../../schema-settings/SchemaSettingsLayoutItem'; export const editFormBlockSettings = new SchemaSettings({ name: 'blockSettings:editForm', @@ -77,7 +77,10 @@ export const editFormBlockSettings = new SchemaSettings({ }; }, }, - schemaSettingsLabelLayout, + { + name: 'setBlockLayout', + Component: SchemaSettingsLayoutItem, + }, { name: 'divider2', type: 'divider', diff --git a/packages/core/client/src/modules/blocks/data-blocks/grid-card/gridCardBlockSettings.ts b/packages/core/client/src/modules/blocks/data-blocks/grid-card/gridCardBlockSettings.ts index e2eac56a11..074ec0f60d 100644 --- a/packages/core/client/src/modules/blocks/data-blocks/grid-card/gridCardBlockSettings.ts +++ b/packages/core/client/src/modules/blocks/data-blocks/grid-card/gridCardBlockSettings.ts @@ -23,7 +23,7 @@ import { SchemaSettingsTemplate } from '../../../../schema-settings/SchemaSettin import { useBlockTemplateContext } from '../../../../schema-templates/BlockTemplateProvider'; import { setDataLoadingModeSettingsItem } from '../details-multi/setDataLoadingModeSettingsItem'; import { SetTheCountOfColumnsDisplayedInARow } from './SetTheCountOfColumnsDisplayedInARow'; -import { schemaSettingsLabelLayout } from '../../../../schema-settings'; +import { SchemaSettingsLayoutItem } from '../../../../schema-settings/SchemaSettingsLayoutItem'; export const gridCardBlockSettings = new SchemaSettings({ name: 'blockSettings:gridCard', @@ -222,7 +222,10 @@ export const gridCardBlockSettings = new SchemaSettings({ }; }, }, - schemaSettingsLabelLayout, + { + name: 'setBlockLayout', + Component: SchemaSettingsLayoutItem, + }, { name: 'divider', type: 'divider', diff --git a/packages/core/client/src/modules/blocks/data-blocks/list/listBlockSettings.ts b/packages/core/client/src/modules/blocks/data-blocks/list/listBlockSettings.ts index 64b627071d..f664cf58e2 100644 --- a/packages/core/client/src/modules/blocks/data-blocks/list/listBlockSettings.ts +++ b/packages/core/client/src/modules/blocks/data-blocks/list/listBlockSettings.ts @@ -21,7 +21,7 @@ import { SchemaSettingsDataScope } from '../../../../schema-settings/SchemaSetti import { SchemaSettingsTemplate } from '../../../../schema-settings/SchemaSettingsTemplate'; import { useBlockTemplateContext } from '../../../../schema-templates/BlockTemplateProvider'; import { setDataLoadingModeSettingsItem } from '../details-multi/setDataLoadingModeSettingsItem'; -import { schemaSettingsLabelLayout } from '../../../../schema-settings'; +import { SchemaSettingsLayoutItem } from '../../../../schema-settings/SchemaSettingsLayoutItem'; export const listBlockSettings = new SchemaSettings({ name: 'blockSettings:list', @@ -225,7 +225,10 @@ export const listBlockSettings = new SchemaSettings({ }; }, }, - schemaSettingsLabelLayout, + { + name: 'setBlockLayout', + Component: SchemaSettingsLayoutItem, + }, { name: 'divider', type: 'divider', diff --git a/packages/core/client/src/modules/blocks/data-blocks/table-selector/__e2e__/schemaSettings.test.ts b/packages/core/client/src/modules/blocks/data-blocks/table-selector/__e2e__/schemaSettings.test.ts index 73c3c514e6..f325942a51 100644 --- a/packages/core/client/src/modules/blocks/data-blocks/table-selector/__e2e__/schemaSettings.test.ts +++ b/packages/core/client/src/modules/blocks/data-blocks/table-selector/__e2e__/schemaSettings.test.ts @@ -103,7 +103,7 @@ test.describe('table data selector schema settings', () => { await page.getByRole('menuitem', { name: 'Delete' }).hover(); await page.mouse.move(-300, 0); - await page.getByLabel('block-item-CollectionField-').nth(1).click(); + await page.getByTestId('select-data-picker').first().click(); // 3. 创建 Table 区块 await page.getByLabel('schema-initializer-Grid-popup').hover(); diff --git a/packages/core/client/src/modules/blocks/filter-blocks/form/filterFormBlockSettings.ts b/packages/core/client/src/modules/blocks/filter-blocks/form/filterFormBlockSettings.ts index dd9839286d..64573a1b0f 100644 --- a/packages/core/client/src/modules/blocks/filter-blocks/form/filterFormBlockSettings.ts +++ b/packages/core/client/src/modules/blocks/filter-blocks/form/filterFormBlockSettings.ts @@ -13,15 +13,12 @@ import { SchemaSettings } from '../../../../application/schema-settings/SchemaSe import { useCollection_deprecated } from '../../../../collection-manager'; import { useCollection } from '../../../../data-source/collection/CollectionProvider'; import { FilterBlockType } from '../../../../filter-provider'; -import { - SchemaSettingsFormItemTemplate, - SchemaSettingsLinkageRules, - schemaSettingsLabelLayout, -} from '../../../../schema-settings'; +import { SchemaSettingsFormItemTemplate, SchemaSettingsLinkageRules } from '../../../../schema-settings'; import { SchemaSettingsBlockHeightItem } from '../../../../schema-settings/SchemaSettingsBlockHeightItem'; import { SchemaSettingsBlockTitleItem } from '../../../../schema-settings/SchemaSettingsBlockTitleItem'; import { SchemaSettingsConnectDataBlocks } from '../../../../schema-settings/SchemaSettingsConnectDataBlocks'; import { useBlockTemplateContext } from '../../../../schema-templates/BlockTemplateProvider'; +import { SchemaSettingsLayoutItem } from '../../../../schema-settings/SchemaSettingsLayoutItem'; export const filterFormBlockSettings = new SchemaSettings({ name: 'blockSettings:filterForm', @@ -71,7 +68,10 @@ export const filterFormBlockSettings = new SchemaSettings({ }; }, }, - schemaSettingsLabelLayout, + { + name: 'setBlockLayout', + Component: SchemaSettingsLayoutItem, + }, { name: 'divider', type: 'divider', diff --git a/packages/core/client/src/modules/fields/component/Nester/subformComponentFieldSettings.tsx b/packages/core/client/src/modules/fields/component/Nester/subformComponentFieldSettings.tsx index ca1ad52b99..4f25315cd5 100644 --- a/packages/core/client/src/modules/fields/component/Nester/subformComponentFieldSettings.tsx +++ b/packages/core/client/src/modules/fields/component/Nester/subformComponentFieldSettings.tsx @@ -21,7 +21,7 @@ import { useIsFormReadPretty, } from '../../../../schema-component/antd/form-item/FormItem.Settings'; import { linkageRules, setDefaultSortingRules } from '../SubTable/subTablePopoverComponentFieldSettings'; -import { schemaSettingsLabelLayout } from '../../../../schema-settings'; +import { SchemaSettingsLayoutItem } from '../../../../schema-settings/SchemaSettingsLayoutItem'; const allowMultiple: any = { name: 'allowMultiple', @@ -144,6 +144,9 @@ export const subformComponentFieldSettings = new SchemaSettings({ }, setDefaultSortingRules, linkageRules, - schemaSettingsLabelLayout, + { + name: 'setBlockLayout', + Component: SchemaSettingsLayoutItem, + }, ], }); diff --git a/packages/core/client/src/modules/fields/component/PopoverNester/subformPopoverComponentFieldSettings.tsx b/packages/core/client/src/modules/fields/component/PopoverNester/subformPopoverComponentFieldSettings.tsx index 732bf6a0e2..bf368ff7f7 100644 --- a/packages/core/client/src/modules/fields/component/PopoverNester/subformPopoverComponentFieldSettings.tsx +++ b/packages/core/client/src/modules/fields/component/PopoverNester/subformPopoverComponentFieldSettings.tsx @@ -20,7 +20,7 @@ import { useColumnSchema } from '../../../../schema-component/antd/table-v2/Tabl import { titleField } from '../Select/selectComponentFieldSettings'; import { linkageRules } from '../SubTable/subTablePopoverComponentFieldSettings'; -import { schemaSettingsLabelLayout } from '../../../../schema-settings'; +import { SchemaSettingsLayoutItem } from '../../../../schema-settings/SchemaSettingsLayoutItem'; const allowMultiple: any = { name: 'allowMultiple', @@ -106,5 +106,14 @@ const fieldComponent: any = { export const subformPopoverComponentFieldSettings = new SchemaSettings({ name: 'fieldSettings:component:PopoverNester', - items: [fieldComponent, allowMultiple, titleField, linkageRules, schemaSettingsLabelLayout], + items: [ + fieldComponent, + allowMultiple, + titleField, + linkageRules, + { + name: 'setBlockLayout', + Component: SchemaSettingsLayoutItem, + }, + ], }); diff --git a/packages/core/client/src/schema-component/antd/association-field/InternalNester.tsx b/packages/core/client/src/schema-component/antd/association-field/InternalNester.tsx index 7700594e59..c66d4d42fc 100644 --- a/packages/core/client/src/schema-component/antd/association-field/InternalNester.tsx +++ b/packages/core/client/src/schema-component/antd/association-field/InternalNester.tsx @@ -9,6 +9,7 @@ import { css, cx } from '@emotion/css'; import { FormLayout } from '@formily/antd-v5'; +import { theme } from 'antd'; import { RecursionField, observer, useField, useFieldSchema } from '@formily/react'; import React, { useEffect } from 'react'; import { ACLCollectionProvider, useACLActionParamsContext } from '../../../acl'; @@ -45,14 +46,25 @@ export const InternalNester = observer( const { options: collectionField } = useAssociationFieldContext(); const showTitle = fieldSchema['x-decorator-props']?.showTitle ?? true; const { actionName } = useACLActionParamsContext(); - const { layout = 'vertical' } = fieldSchema?.['x-component-props'] || {}; + const { token } = theme.useToken(); + const { + layout = 'vertical', + labelAlign = 'left', + labelWidth = 120, + labelWrap = true, + } = fieldSchema?.['x-component-props'] || {}; useEffect(() => { insertNester(schema.Nester); }, []); return ( - +
= (props) => { const f = useAttach(form.createVoidField({ ...field.props, basePath: '' })); const height = useFormBlockHeight(); const { token } = theme.useToken(); - const { layout = 'vertical' } = cardItemSchema?.['x-component-props'] || {}; + const { + layout = 'vertical', + labelAlign = 'left', + labelWidth = 120, + labelWrap = true, + } = cardItemSchema?.['x-component-props'] || {}; return ( - +
{ onChange: onPaginationChange, }; const cardItemSchema = getCardItemSchema?.(fieldSchema); - const { layout = 'vertical' } = cardItemSchema?.['x-component-props'] || {}; + const { + layout = 'vertical', + labelAlign = 'left', + labelWidth = 120, + labelWrap = true, + } = cardItemSchema?.['x-component-props'] || {}; return ( { `, )} > - + { [run, params], ); const cardItemSchema = getCardItemSchema?.(fieldSchema); - const { layout = 'vertical' } = cardItemSchema?.['x-component-props'] || {}; + const { + layout = 'vertical', + labelAlign = 'left', + labelWidth = 120, + labelWrap = true, + } = cardItemSchema?.['x-component-props'] || {}; const usePagination = () => { if (!count) { return { @@ -138,7 +143,12 @@ const InternalList = (props) => { )} >
- + { + const componentProps = fieldSchema['x-component-props'] || {}; + componentProps.layout = layout; + componentProps.labelAlign = labelAlign; + componentProps.labelWidth = layout === 'horizontal' ? labelWidth : null; + componentProps.labelWrap = labelWrap; + fieldSchema['x-component-props'] = componentProps; + field.componentProps.layout = layout; + field.componentProps.labelAlign = labelAlign; + field.componentProps.labelWidth = labelWidth; + field.componentProps.labelWrap = labelWrap; + dn.emit('patch', { + schema: { + ['x-uid']: fieldSchema['x-uid'], + 'x-component-props': fieldSchema['x-component-props'], + }, + }); + dn.refresh(); + }} + /> + ); +}; diff --git a/packages/core/client/src/schema-settings/index.ts b/packages/core/client/src/schema-settings/index.ts index 1a67832736..0202ecff16 100644 --- a/packages/core/client/src/schema-settings/index.ts +++ b/packages/core/client/src/schema-settings/index.ts @@ -25,6 +25,7 @@ export * from './setTheDataScopeSchemaSettingsItem'; export * from './SchemaSettingsRenderEngine'; export * from './hooks/useGetAriaLabelOfDesigner'; export * from './hooks/useIsAllowToSetDefaultValue'; +export * from './SchemaSettingsLayoutItem'; export { default as useParseDataScopeFilter } from './hooks/useParseDataScopeFilter'; export * from './isPatternDisabled'; export { SchemaSettingsPlugin } from './SchemaSettingsPlugin'; diff --git a/packages/plugins/@nocobase/plugin-kanban/src/client/Kanban.Card.tsx b/packages/plugins/@nocobase/plugin-kanban/src/client/Kanban.Card.tsx index e5d0f96a9e..9fe462e9b8 100644 --- a/packages/plugins/@nocobase/plugin-kanban/src/client/Kanban.Card.tsx +++ b/packages/plugins/@nocobase/plugin-kanban/src/client/Kanban.Card.tsx @@ -127,13 +127,23 @@ export const KanbanCard: any = observer( }; }, [popupSchema]); const cardItemSchema = getCardItemSchema?.(fieldSchema); - const { layout = 'vertical' } = cardItemSchema?.['x-component-props'] || {}; + const { + layout = 'vertical', + labelAlign = 'left', + labelWidth = 120, + labelWrap = true, + } = cardItemSchema?.['x-component-props'] || {}; return ( <> - + diff --git a/packages/plugins/@nocobase/plugin-kanban/src/client/Kanban.Settings.tsx b/packages/plugins/@nocobase/plugin-kanban/src/client/Kanban.Settings.tsx index d0a184c15e..aa6473c554 100644 --- a/packages/plugins/@nocobase/plugin-kanban/src/client/Kanban.Settings.tsx +++ b/packages/plugins/@nocobase/plugin-kanban/src/client/Kanban.Settings.tsx @@ -20,10 +20,11 @@ import { useCollection_deprecated, useDesignable, useFormBlockContext, - schemaSettingsLabelLayout, + SchemaSettingsLayoutItem, } from '@nocobase/client'; import { useTranslation } from 'react-i18next'; import { useKanbanBlockContext } from './KanbanBlockProvider'; + export const kanbanSettings = new SchemaSettings({ name: 'blockSettings:kanban', items: [ @@ -78,7 +79,6 @@ export const kanbanSettings = new SchemaSettings({ }; }, }, - schemaSettingsLabelLayout, { name: 'allowDragAndDrop', type: 'switch', @@ -105,6 +105,10 @@ export const kanbanSettings = new SchemaSettings({ }; }, }, + { + name: 'setBlockLayout', + Component: SchemaSettingsLayoutItem, + }, { name: 'divider', type: 'divider',