From db7172f60c6faa4325087a634e9fbbcbf36f2866 Mon Sep 17 00:00:00 2001 From: qkiroc <30946345+qkiroc@users.noreply.github.com> Date: Thu, 9 Jan 2025 11:46:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20form=E5=A4=9A=E5=88=97=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=E5=AE=B9=E5=99=A8=E7=B1=BB=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A100%=20(#11468)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: form多列模式下容器类组件固定100% * 更新快照 * 更新快照 --- .../amis-ui/scss/components/form/_form.scss | 82 +++---------------- .../amis-ui/src/components/CollapseGroup.tsx | 1 + packages/amis-ui/src/components/Tabs.tsx | 1 + .../__snapshots__/disabled.test.tsx.snap | 1 + .../__snapshots__/crud.test.tsx.snap | 3 + .../__snapshots__/service.test.tsx.snap | 2 + .../form/__snapshots__/form.test.tsx.snap | 14 ++++ .../form/__snapshots__/range.test.tsx.snap | 1 + .../validateFormItem.test.tsx.snap | 6 ++ .../Form/__snapshots__/array.test.tsx.snap | 1 + .../Form/__snapshots__/button.test.tsx.snap | 2 + .../buttonGroupSelect.test.tsx.snap | 7 ++ .../__snapshots__/buttonToolBar.test.tsx.snap | 2 + .../__snapshots__/chainedSelect.test.tsx.snap | 1 + .../Form/__snapshots__/checkbox.test.tsx.snap | 3 + .../__snapshots__/checkboxes.test.tsx.snap | 19 +++++ .../Form/__snapshots__/combo.test.tsx.snap | 9 ++ .../conditionBuilder.test.tsx.snap | 1 + .../__snapshots__/container.test.tsx.snap | 2 + .../Form/__snapshots__/datetime.test.tsx.snap | 1 + .../Form/__snapshots__/fieldSet.test.tsx.snap | 5 ++ .../Form/__snapshots__/formitem.test.tsx.snap | 3 + .../Form/__snapshots__/formula.test.tsx.snap | 1 + .../Form/__snapshots__/grid.test.tsx.snap | 2 + .../Form/__snapshots__/group.test.tsx.snap | 1 + .../Form/__snapshots__/hbox.test.tsx.snap | 1 + .../__snapshots__/iconPicker.test.tsx.snap | 1 + .../Form/__snapshots__/index.test.tsx.snap | 9 ++ .../Form/__snapshots__/initData.test.tsx.snap | 1 + .../__snapshots__/inputArray.test.tsx.snap | 5 ++ .../__snapshots__/inputCity.test.tsx.snap | 2 + .../__snapshots__/inputDate.test.tsx.snap | 5 ++ .../__snapshots__/inputFormula.test.tsx.snap | 2 + .../__snapshots__/inputGroup.test.tsx.snap | 1 + .../inputMonthRange.test.tsx.snap | 1 + .../inputQuarterRange.test.tsx.snap | 1 + .../__snapshots__/inputSubForm.test.tsx.snap | 4 + .../__snapshots__/inputTable.test.tsx.snap | 6 ++ .../inputYearRange.test.tsx.snap | 1 + .../Form/__snapshots__/list.test.tsx.snap | 4 + .../__snapshots__/listSelect.test.tsx.snap | 2 + .../Form/__snapshots__/number.test.tsx.snap | 8 ++ .../Form/__snapshots__/panel.test.tsx.snap | 3 + .../Form/__snapshots__/radios.test.tsx.snap | 3 + .../Form/__snapshots__/range.test.tsx.snap | 7 ++ .../Form/__snapshots__/rating.test.tsx.snap | 6 ++ .../Form/__snapshots__/repeat.test.tsx.snap | 1 + .../Form/__snapshots__/select.test.tsx.snap | 13 +++ .../Form/__snapshots__/service.test.tsx.snap | 1 + .../Form/__snapshots__/static.test.tsx.snap | 2 + .../Form/__snapshots__/switch.test.tsx.snap | 2 + .../Form/__snapshots__/tabs.test.tsx.snap | 2 + .../__snapshots__/tabsTransfer.test.tsx.snap | 4 + .../tabsTransferPicker.test.tsx.snap | 3 + .../Form/__snapshots__/text.test.tsx.snap | 24 ++++++ .../Form/__snapshots__/textarea.test.tsx.snap | 4 + .../Form/__snapshots__/transfer.test.tsx.snap | 12 +++ .../transferPicker.test.tsx.snap | 1 + .../__snapshots__/usersSelect.test.tsx.snap | 1 + .../__snapshots__/valueFormula.test.tsx.snap | 1 + .../__snapshots__/AnchorNav.test.tsx.snap | 8 ++ .../__snapshots__/CRUD.test.tsx.snap | 5 ++ .../__snapshots__/Collapse.test.tsx.snap | 4 + .../__snapshots__/Container.test.tsx.snap | 1 + .../__snapshots__/Each.test.tsx.snap | 1 + .../__snapshots__/Flex.test.tsx.snap | 7 ++ .../__snapshots__/Image.test.tsx.snap | 1 + .../__snapshots__/List.test.tsx.snap | 1 + .../__snapshots__/Page.test.tsx.snap | 2 + .../__snapshots__/Picker.test.tsx.snap | 1 + .../__snapshots__/PopOver.test.tsx.snap | 2 + .../__snapshots__/Portlet.test.tsx.snap | 1 + .../__snapshots__/Progress.test.tsx.snap | 1 + .../__snapshots__/Tabs.test.tsx.snap | 14 ++++ .../__snapshots__/Tree.test.tsx.snap | 2 + .../__snapshots__/Wizard.test.tsx.snap | 1 + packages/amis/src/renderers/CRUD.tsx | 1 + packages/amis/src/renderers/CRUD2.tsx | 1 + packages/amis/src/renderers/Container.tsx | 1 + packages/amis/src/renderers/Flex.tsx | 1 + packages/amis/src/renderers/Grid.tsx | 1 + packages/amis/src/renderers/Panel.tsx | 1 + .../amis/src/renderers/SwitchContainer.tsx | 1 + 83 files changed, 302 insertions(+), 72 deletions(-) diff --git a/packages/amis-ui/scss/components/form/_form.scss b/packages/amis-ui/scss/components/form/_form.scss index 2dc8099d8e1..1e4c3b5ee85 100644 --- a/packages/amis-ui/scss/components/form/_form.scss +++ b/packages/amis-ui/scss/components/form/_form.scss @@ -531,80 +531,18 @@ } } -.#{$ns}Form--column-1 > .#{$ns}Form-item { - width: 100%; -} - -.#{$ns}Form--column-2 > .#{$ns}Form-item { - width: 50%; -} - -.#{$ns}Form--column-2 > .#{$ns}Form-item:nth-last-child(2) { - margin-bottom: 0; -} - -.#{$ns}Form--column-3 > .#{$ns}Form-item { - width: 33%; -} - -.#{$ns}Form--column-3 > .#{$ns}Form-item:nth-last-child(-n + 3) { - margin-bottom: 0; -} - -.#{$ns}Form--column-4 > .#{$ns}Form-item { - width: 25%; -} - -.#{$ns}Form--column-4 > .#{$ns}Form-item:nth-last-child(-n + 4) { - margin-bottom: 0; -} - -.#{$ns}Form--column-5 > .#{$ns}Form-item { - width: 20%; -} - -.#{$ns}Form--column-5 > .#{$ns}Form-item:nth-last-child(-n + 5) { - margin-bottom: 0; -} - -.#{$ns}Form--column-6 > .#{$ns}Form-item { - width: 16.6%; -} - -.#{$ns}Form--column-6 > .#{$ns}Form-item:nth-last-child(-n + 6) { - margin-bottom: 0; -} - -.#{$ns}Form--column-7 > .#{$ns}Form-item { - width: 14.2%; -} - -.#{$ns}Form--column-7 > .#{$ns}Form-item:nth-last-child(-n + 7) { - margin-bottom: 0; -} - -.#{$ns}Form--column-8 > .#{$ns}Form-item { - width: 12.5%; -} - -.#{$ns}Form--column-8 > .#{$ns}Form-item:nth-last-child(-n + 8) { - margin-bottom: 0; -} - -.#{$ns}Form-column-9 > .#{$ns}Form-item { - width: 11.1%; -} - -.#{$ns}Form--column-9 > .#{$ns}Form-item:nth-last-child(-n + 9) { - margin-bottom: 0; -} +@for $i from 1 through 10 { + .#{$ns}Form--column-#{$i} > .#{$ns}Form-item { + width: 100 / $i * 1%; + } -.#{$ns}Form-column-10 > .#{$ns}Form-item { - width: 10%; -} + .#{$ns}Form--column-#{$i} > [data-role*='container'] { + flex: 100%; + } -.#{$ns}Form--column-10 > .#{$ns}Form-item:nth-last-child(-n + 10) { - margin-bottom: 0; + .#{$ns}Form--column-#{$i} > .#{$ns}Form-item:nth-last-child(-n + #{$i}) { + margin-bottom: 0; + } } /* 移动端样式调整 */ diff --git a/packages/amis-ui/src/components/CollapseGroup.tsx b/packages/amis-ui/src/components/CollapseGroup.tsx index 6a8edd4be9d..df4e3b1d8d0 100644 --- a/packages/amis-ui/src/components/CollapseGroup.tsx +++ b/packages/amis-ui/src/components/CollapseGroup.tsx @@ -161,6 +161,7 @@ class CollapseGroup extends React.Component< className )} style={style} + data-role="container" > {this.getItems(children)} diff --git a/packages/amis-ui/src/components/Tabs.tsx b/packages/amis-ui/src/components/Tabs.tsx index 9a983953972..ce56e77580b 100644 --- a/packages/amis-ui/src/components/Tabs.tsx +++ b/packages/amis-ui/src/components/Tabs.tsx @@ -898,6 +898,7 @@ export class Tabs extends React.Component { )} style={style} {...testIdBuilder?.getTestId()} + data-role="container" > {!['vertical', 'sidebar', 'chrome'].includes(mode) ? (