@ant-design/pro-components 3.0.2-0 → 3.1.1-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.es-PR.md +1 -3
- package/README.md +8 -10
- package/README.zh-CN.md +11 -11
- package/dist/pro-components.min.js +1 -1
- package/es/card/ProCard.js +7 -7
- package/es/card/components/Actions/index.js +25 -25
- package/es/card/components/Actions/style.d.ts +1 -1
- package/es/card/components/Actions/style.js +79 -71
- package/es/card/components/Card/index.js +160 -141
- package/es/card/components/Card/style.d.ts +1 -1
- package/es/card/components/Card/style.js +249 -192
- package/es/card/components/CheckCard/Group.js +94 -115
- package/es/card/components/CheckCard/index.d.ts +6 -0
- package/es/card/components/CheckCard/index.js +85 -78
- package/es/card/components/CheckCard/style.d.ts +1 -1
- package/es/card/components/CheckCard/style.js +184 -168
- package/es/card/components/Divider/index.js +19 -15
- package/es/card/components/Divider/style.d.ts +1 -1
- package/es/card/components/Divider/style.js +32 -29
- package/es/card/components/Loading/index.js +19 -16
- package/es/card/components/Loading/style.d.ts +1 -1
- package/es/card/components/Loading/style.js +34 -31
- package/es/card/components/Operation/index.js +16 -13
- package/es/card/components/Operation/style.d.ts +1 -1
- package/es/card/components/Operation/style.js +19 -18
- package/es/card/components/Statistic/index.js +46 -41
- package/es/card/components/Statistic/style.d.ts +1 -1
- package/es/card/components/Statistic/style.js +89 -70
- package/es/card/components/StatisticCard/index.js +45 -38
- package/es/card/components/StatisticCard/style.d.ts +1 -1
- package/es/card/components/StatisticCard/style.js +37 -35
- package/es/card/typing.d.ts +5 -0
- package/es/descriptions/index.js +214 -225
- package/es/descriptions/useFetchData.js +53 -91
- package/es/field/AllProField.js +265 -216
- package/es/field/FieldHOC/index.js +9 -14
- package/es/field/PureProField.js +82 -80
- package/es/field/ValueTypeToComponent.js +517 -618
- package/es/field/components/Cascader/index.d.ts +2 -3
- package/es/field/components/Cascader/index.js +65 -84
- package/es/field/components/Checkbox/index.d.ts +2 -3
- package/es/field/components/Checkbox/index.js +75 -72
- package/es/field/components/Code/index.js +40 -39
- package/es/field/components/ColorPicker/index.d.ts +1 -1
- package/es/field/components/ColorPicker/index.js +38 -32
- package/es/field/components/DatePicker/index.d.ts +2 -2
- package/es/field/components/DatePicker/index.js +49 -53
- package/es/field/components/Digit/index.js +41 -42
- package/es/field/components/DigitRange/index.js +71 -77
- package/es/field/components/FromNow/index.js +27 -25
- package/es/field/components/Image/index.js +28 -24
- package/es/field/components/IndexColumn/index.js +22 -16
- package/es/field/components/Money/index.js +107 -116
- package/es/field/components/Options/index.js +34 -33
- package/es/field/components/Password/index.js +35 -38
- package/es/field/components/Percent/index.js +40 -44
- package/es/field/components/Percent/util.d.ts +1 -1
- package/es/field/components/Percent/util.js +3 -5
- package/es/field/components/Progress/index.js +29 -27
- package/es/field/components/Radio/index.d.ts +1 -2
- package/es/field/components/Radio/index.js +61 -62
- package/es/field/components/RangePicker/index.d.ts +2 -2
- package/es/field/components/RangePicker/index.js +52 -63
- package/es/field/components/Rate/index.js +24 -21
- package/es/field/components/Second/index.js +36 -33
- package/es/field/components/Segmented/index.d.ts +1 -2
- package/es/field/components/Segmented/index.js +37 -46
- package/es/field/components/Select/LightSelect/index.d.ts +1 -1
- package/es/field/components/Select/LightSelect/index.js +102 -110
- package/es/field/components/Select/SearchSelect/index.d.ts +6 -1
- package/es/field/components/Select/SearchSelect/index.js +189 -129
- package/es/field/components/Select/index.d.ts +2 -5
- package/es/field/components/Select/index.js +197 -221
- package/es/field/components/Slider/index.js +25 -22
- package/es/field/components/Status/index.js +67 -78
- package/es/field/components/Switch/index.d.ts +1 -1
- package/es/field/components/Switch/index.js +32 -30
- package/es/field/components/Text/index.js +34 -37
- package/es/field/components/TextArea/index.js +26 -21
- package/es/field/components/TextArea/readonly.js +24 -21
- package/es/field/components/TimePicker/index.js +96 -105
- package/es/field/components/TreeSelect/index.d.ts +2 -3
- package/es/field/components/TreeSelect/index.js +107 -125
- package/es/form/BaseForm/BaseForm.d.ts +3 -0
- package/es/form/BaseForm/BaseForm.js +418 -498
- package/es/form/BaseForm/EditOrReadOnlyContext.js +1 -1
- package/es/form/BaseForm/LightWrapper/index.js +56 -65
- package/es/form/BaseForm/LightWrapper/style.d.ts +1 -1
- package/es/form/BaseForm/LightWrapper/style.js +17 -13
- package/es/form/BaseForm/Submitter/index.js +44 -43
- package/es/form/FieldContext.js +1 -1
- package/es/form/components/Captcha/index.d.ts +8 -2
- package/es/form/components/Captcha/index.js +76 -128
- package/es/form/components/Cascader/index.js +26 -28
- package/es/form/components/Checkbox/index.js +60 -61
- package/es/form/components/ColorPicker/index.js +24 -26
- package/es/form/components/DatePicker/BaseDatePicker.js +33 -31
- package/es/form/components/DatePicker/DatePicker.js +14 -13
- package/es/form/components/DatePicker/DateTimePicker.js +11 -12
- package/es/form/components/DatePicker/MonthPicker.js +14 -13
- package/es/form/components/DatePicker/QuarterPicker.js +14 -13
- package/es/form/components/DatePicker/TimePicker.js +26 -27
- package/es/form/components/DatePicker/WeekPicker.js +14 -13
- package/es/form/components/DatePicker/YearPicker.js +14 -13
- package/es/form/components/DatePicker/index.js +1 -1
- package/es/form/components/DateRangePicker/BaseDateRanger.js +35 -35
- package/es/form/components/DateRangePicker/DateMonthRangePicker.js +15 -16
- package/es/form/components/DateRangePicker/DateQuarterRangePicker.js +15 -16
- package/es/form/components/DateRangePicker/DateTimeRangePicker.js +15 -16
- package/es/form/components/DateRangePicker/DateWeekRangePicker.js +15 -16
- package/es/form/components/DateRangePicker/DateYearRangePicker.js +15 -16
- package/es/form/components/DateRangePicker/TimeRangePicker.js +26 -29
- package/es/form/components/DateRangePicker/index.js +15 -16
- package/es/form/components/Dependency/index.js +31 -34
- package/es/form/components/Digit/DigitRange.js +23 -24
- package/es/form/components/Digit/index.js +27 -29
- package/es/form/components/Field/index.js +55 -63
- package/es/form/components/FieldSet/index.js +68 -76
- package/es/form/components/FormItem/FormItemRender/index.js +58 -48
- package/es/form/components/FormItem/Group/index.js +95 -95
- package/es/form/components/FormItem/Group/style.d.ts +1 -1
- package/es/form/components/FormItem/Group/style.js +46 -40
- package/es/form/components/FormItem/index.js +135 -141
- package/es/form/components/FormItem/warpField.js +165 -149
- package/es/form/components/List/ListContainer.js +98 -189
- package/es/form/components/List/ListItem.js +151 -198
- package/es/form/components/List/index.d.ts +1 -1
- package/es/form/components/List/index.js +97 -107
- package/es/form/components/List/style.d.ts +1 -1
- package/es/form/components/List/style.js +71 -47
- package/es/form/components/Money/index.js +28 -30
- package/es/form/components/Radio/index.js +45 -49
- package/es/form/components/Rate/index.js +17 -20
- package/es/form/components/SchemaForm/index.js +58 -72
- package/es/form/components/SchemaForm/layoutType/Embed.js +5 -6
- package/es/form/components/SchemaForm/layoutType/StepsForm.js +22 -26
- package/es/form/components/SchemaForm/valueType/dependency.js +11 -11
- package/es/form/components/SchemaForm/valueType/divider.js +4 -5
- package/es/form/components/SchemaForm/valueType/field.js +45 -44
- package/es/form/components/SchemaForm/valueType/formList.js +8 -7
- package/es/form/components/SchemaForm/valueType/formSet.js +8 -7
- package/es/form/components/SchemaForm/valueType/group.js +7 -8
- package/es/form/components/SchemaForm/valueType/ignore.js +2 -2
- package/es/form/components/SchemaForm/valueType/index.js +5 -5
- package/es/form/components/Segmented/index.js +20 -23
- package/es/form/components/Select/index.js +69 -73
- package/es/form/components/Slider/index.js +33 -35
- package/es/form/components/Switch/index.js +24 -26
- package/es/form/components/Text/index.js +79 -88
- package/es/form/components/TextArea/index.js +17 -20
- package/es/form/components/TreeSelect/index.js +20 -23
- package/es/form/components/UploadButton/index.js +56 -103
- package/es/form/components/UploadDragger/index.js +37 -44
- package/es/form/helpers/grid.js +65 -67
- package/es/form/index.d.ts +1 -0
- package/es/form/layouts/DrawerForm/index.d.ts +1 -1
- package/es/form/layouts/DrawerForm/index.js +152 -242
- package/es/form/layouts/DrawerForm/style.d.ts +1 -1
- package/es/form/layouts/DrawerForm/style.js +26 -25
- package/es/form/layouts/LightFilter/index.d.ts +12 -1
- package/es/form/layouts/LightFilter/index.js +158 -140
- package/es/form/layouts/LightFilter/style.d.ts +1 -1
- package/es/form/layouts/LightFilter/style.js +52 -48
- package/es/form/layouts/LoginForm/index.d.ts +1 -1
- package/es/form/layouts/LoginForm/index.js +44 -47
- package/es/form/layouts/LoginForm/style.d.ts +1 -1
- package/es/form/layouts/LoginForm/style.js +71 -67
- package/es/form/layouts/LoginFormPage/index.d.ts +1 -1
- package/es/form/layouts/LoginFormPage/index.js +45 -48
- package/es/form/layouts/LoginFormPage/style.d.ts +1 -1
- package/es/form/layouts/LoginFormPage/style.js +136 -126
- package/es/form/layouts/ModalForm/index.js +120 -203
- package/es/form/layouts/ProForm/index.d.ts +2 -2
- package/es/form/layouts/ProForm/index.js +5 -5
- package/es/form/layouts/QueryFilter/Actions.js +23 -22
- package/es/form/layouts/QueryFilter/index.d.ts +2 -1
- package/es/form/layouts/QueryFilter/index.js +178 -203
- package/es/form/layouts/QueryFilter/style.d.ts +1 -1
- package/es/form/layouts/QueryFilter/style.js +45 -37
- package/es/form/layouts/StepsForm/StepForm.d.ts +2 -3
- package/es/form/layouts/StepsForm/StepForm.js +50 -71
- package/es/form/layouts/StepsForm/index.js +187 -216
- package/es/form/layouts/StepsForm/style.d.ts +1 -1
- package/es/form/layouts/StepsForm/style.js +30 -28
- package/es/form/layouts/index.js +1 -1
- package/es/layout/ProLayout.js +281 -292
- package/es/layout/WrapContent.js +16 -12
- package/es/layout/assert/Logo.js +95 -97
- package/es/layout/components/AppsLogoComponents/AppsLogo.js +10 -12
- package/es/layout/components/AppsLogoComponents/DefaultContent.js +17 -16
- package/es/layout/components/AppsLogoComponents/SimpleContent.js +19 -18
- package/es/layout/components/AppsLogoComponents/index.js +34 -37
- package/es/layout/components/AppsLogoComponents/style/default.js +2 -2
- package/es/layout/components/AppsLogoComponents/style/index.d.ts +1 -1
- package/es/layout/components/AppsLogoComponents/style/index.js +52 -50
- package/es/layout/components/AppsLogoComponents/style/simple.js +1 -1
- package/es/layout/components/CollapsedIcon/index.js +18 -15
- package/es/layout/components/CollapsedIcon/style.d.ts +1 -1
- package/es/layout/components/CollapsedIcon/style.js +40 -40
- package/es/layout/components/Footer.js +22 -21
- package/es/layout/components/FooterToolbar/index.js +58 -52
- package/es/layout/components/FooterToolbar/style/index.d.ts +1 -1
- package/es/layout/components/FooterToolbar/style/index.js +38 -37
- package/es/layout/components/FooterToolbar/style/stylish.d.ts +1 -1
- package/es/layout/components/FooterToolbar/style/stylish.js +11 -9
- package/es/layout/components/GlobalFooter/index.d.ts +1 -1
- package/es/layout/components/GlobalFooter/index.js +25 -25
- package/es/layout/components/GlobalFooter/style.d.ts +1 -1
- package/es/layout/components/GlobalFooter/style.js +31 -30
- package/es/layout/components/GlobalHeader/ActionsContent.js +62 -78
- package/es/layout/components/GlobalHeader/index.js +59 -47
- package/es/layout/components/GlobalHeader/rightContentStyle.d.ts +1 -1
- package/es/layout/components/GlobalHeader/rightContentStyle.js +49 -49
- package/es/layout/components/GlobalHeader/style.d.ts +1 -1
- package/es/layout/components/GlobalHeader/style.js +58 -54
- package/es/layout/components/GridContent/index.js +24 -19
- package/es/layout/components/GridContent/style.d.ts +1 -1
- package/es/layout/components/GridContent/style.js +14 -13
- package/es/layout/components/Header/index.js +63 -57
- package/es/layout/components/Header/style/header.d.ts +1 -1
- package/es/layout/components/Header/style/header.js +49 -47
- package/es/layout/components/Header/style/stylish.d.ts +1 -1
- package/es/layout/components/Header/style/stylish.js +15 -11
- package/es/layout/components/Help/AsyncContentPanel.js +13 -18
- package/es/layout/components/Help/HelpProvide.js +1 -1
- package/es/layout/components/Help/ProHelpContentPanel.js +64 -83
- package/es/layout/components/Help/ProHelpDrawer.d.ts +1 -1
- package/es/layout/components/Help/ProHelpDrawer.js +25 -29
- package/es/layout/components/Help/ProHelpModal.d.ts +1 -1
- package/es/layout/components/Help/ProHelpModal.js +24 -27
- package/es/layout/components/Help/ProHelpPanel.js +86 -94
- package/es/layout/components/Help/ProHelpPopover.js +19 -17
- package/es/layout/components/Help/RenderContentPanel.js +34 -24
- package/es/layout/components/Help/Search.js +52 -78
- package/es/layout/components/Help/index.js +9 -11
- package/es/layout/components/Help/style.d.ts +1 -1
- package/es/layout/components/Help/style.js +82 -75
- package/es/layout/components/PageContainer/index.js +168 -149
- package/es/layout/components/PageContainer/style/index.d.ts +1 -1
- package/es/layout/components/PageContainer/style/index.js +95 -78
- package/es/layout/components/PageContainer/style/stylish.d.ts +1 -1
- package/es/layout/components/PageContainer/style/stylish.js +11 -9
- package/es/layout/components/PageHeader/index.js +96 -97
- package/es/layout/components/PageHeader/style/index.d.ts +1 -1
- package/es/layout/components/PageHeader/style/index.js +142 -122
- package/es/layout/components/PageLoading/index.js +17 -20
- package/es/layout/components/SettingDrawer/BlockCheckbox.js +29 -32
- package/es/layout/components/SettingDrawer/LayoutChange.js +22 -22
- package/es/layout/components/SettingDrawer/RegionalChange.js +14 -15
- package/es/layout/components/SettingDrawer/ThemeColor.js +32 -35
- package/es/layout/components/SettingDrawer/index.js +139 -170
- package/es/layout/components/SettingDrawer/style/index.d.ts +1 -1
- package/es/layout/components/SettingDrawer/style/index.js +141 -137
- package/es/layout/components/SiderMenu/BaseMenu.d.ts +1 -1
- package/es/layout/components/SiderMenu/BaseMenu.js +236 -222
- package/es/layout/components/SiderMenu/SiderMenu.js +127 -117
- package/es/layout/components/SiderMenu/index.js +51 -43
- package/es/layout/components/SiderMenu/style/index.d.ts +1 -1
- package/es/layout/components/SiderMenu/style/index.js +179 -161
- package/es/layout/components/SiderMenu/style/menu.d.ts +1 -1
- package/es/layout/components/SiderMenu/style/menu.js +148 -110
- package/es/layout/components/SiderMenu/style/stylish.d.ts +1 -1
- package/es/layout/components/SiderMenu/style/stylish.js +15 -11
- package/es/layout/components/TopNavHeader/index.js +71 -60
- package/es/layout/components/TopNavHeader/style.d.ts +1 -1
- package/es/layout/components/TopNavHeader/style.js +64 -63
- package/es/layout/context/RouteContext.js +1 -1
- package/es/layout/defaultSettings.d.ts +6 -0
- package/es/layout/defaultSettings.js +1 -1
- package/es/layout/getPageTitle.js +23 -24
- package/es/layout/locales/en-US.js +3 -2
- package/es/layout/locales/index.js +5 -5
- package/es/layout/locales/it-IT.js +3 -2
- package/es/layout/locales/ko-KR.js +3 -2
- package/es/layout/locales/zh-CN.js +3 -2
- package/es/layout/locales/zh-TW.js +3 -2
- package/es/layout/style/index.d.ts +1 -1
- package/es/layout/style/index.js +48 -42
- package/es/layout/utils/getBreadcrumbProps.js +60 -60
- package/es/layout/utils/getMenuData.js +7 -11
- package/es/layout/utils/pathTools.js +2 -6
- package/es/layout/utils/useCurrentMenuLayoutProps.js +4 -9
- package/es/layout/utils/utils.js +15 -17
- package/es/list/Item.js +157 -137
- package/es/list/ListView.js +106 -115
- package/es/list/constants.js +2 -2
- package/es/list/index.js +72 -70
- package/es/list/style/index.d.ts +1 -1
- package/es/list/style/index.js +281 -213
- package/es/provider/index.d.ts +1 -0
- package/es/provider/index.js +126 -114
- package/es/provider/intl.js +53 -55
- package/es/provider/typing/layoutToken.js +26 -23
- package/es/provider/useStyle/index.d.ts +2 -1
- package/es/provider/useStyle/index.js +60 -60
- package/es/provider/utils/merge.js +10 -12
- package/es/skeleton/components/Descriptions/index.js +211 -229
- package/es/skeleton/components/List/index.js +208 -223
- package/es/skeleton/components/Result/index.js +45 -47
- package/es/skeleton/index.js +13 -10
- package/es/table/Store/Provide.d.ts +4 -4
- package/es/table/Store/Provide.js +102 -117
- package/es/table/Table.d.ts +5 -2
- package/es/table/Table.js +593 -603
- package/es/table/TableSearch.d.ts +24 -0
- package/es/table/TableSearch.js +54 -0
- package/es/table/TableToolbar.d.ts +22 -0
- package/es/table/TableToolbar.js +47 -0
- package/es/table/components/Alert/index.d.ts +1 -1
- package/es/table/components/Alert/index.js +41 -40
- package/es/table/components/Alert/style.d.ts +1 -1
- package/es/table/components/Alert/style.js +28 -27
- package/es/table/components/ColumnSetting/index.d.ts +1 -1
- package/es/table/components/ColumnSetting/index.js +230 -223
- package/es/table/components/ColumnSetting/style.d.ts +1 -1
- package/es/table/components/ColumnSetting/style.js +86 -71
- package/es/table/components/DragSortTable/index.d.ts +1 -1
- package/es/table/components/DragSortTable/index.js +65 -79
- package/es/table/components/DragSortTable/style.d.ts +1 -1
- package/es/table/components/DragSortTable/style.js +20 -19
- package/es/table/components/Dropdown/index.js +42 -47
- package/es/table/components/EditableTable/CellEditorTable.js +24 -32
- package/es/table/components/EditableTable/RowEditorTable.js +23 -28
- package/es/table/components/EditableTable/index.js +601 -302
- package/es/table/components/Form/FormRender.js +99 -103
- package/es/table/components/Form/index.d.ts +4 -19
- package/es/table/components/Form/index.js +112 -159
- package/es/table/components/ListToolBar/HeaderMenu.js +44 -52
- package/es/table/components/ListToolBar/index.js +122 -147
- package/es/table/components/ListToolBar/style.d.ts +1 -1
- package/es/table/components/ListToolBar/style.js +127 -117
- package/es/table/components/ToolBar/DensityIcon.js +10 -9
- package/es/table/components/ToolBar/FullscreenIcon.js +5 -9
- package/es/table/components/ToolBar/index.d.ts +2 -8
- package/es/table/components/ToolBar/index.js +155 -195
- package/es/table/style/index.d.ts +1 -1
- package/es/table/style/index.js +144 -112
- package/es/table/typing.d.ts +13 -6
- package/es/table/useFetchData.js +204 -348
- package/es/table/utils/cellRenderToFromItem.js +105 -119
- package/es/table/utils/columnRender.js +63 -54
- package/es/table/utils/columnSort.js +22 -22
- package/es/table/utils/genProColumnToColumn.d.ts +13 -9
- package/es/table/utils/genProColumnToColumn.js +121 -98
- package/es/table/utils/index.d.ts +12 -0
- package/es/table/utils/index.js +114 -178
- package/es/table/utils/useDragSort.d.ts +1 -1
- package/es/table/utils/useDragSort.js +99 -92
- package/es/table/utils/usePageInfo.d.ts +6 -0
- package/es/table/utils/usePageInfo.js +55 -0
- package/es/utils/components/DropdownFooter/index.js +23 -21
- package/es/utils/components/DropdownFooter/style.d.ts +1 -1
- package/es/utils/components/DropdownFooter/style.js +16 -15
- package/es/utils/components/ErrorBoundary/index.js +27 -50
- package/es/utils/components/FieldLabel/index.js +70 -70
- package/es/utils/components/FieldLabel/style.d.ts +1 -1
- package/es/utils/components/FieldLabel/style.js +104 -81
- package/es/utils/components/FilterDropdown/index.d.ts +11 -0
- package/es/utils/components/FilterDropdown/index.js +43 -32
- package/es/utils/components/FilterDropdown/style.d.ts +1 -1
- package/es/utils/components/FilterDropdown/style.js +19 -16
- package/es/utils/components/InlineErrorFormItem/index.js +78 -78
- package/es/utils/components/InlineErrorFormItem/style.d.ts +1 -1
- package/es/utils/components/InlineErrorFormItem/style.js +56 -49
- package/es/utils/components/LabelIconTip/index.js +30 -31
- package/es/utils/components/LabelIconTip/style.d.ts +1 -1
- package/es/utils/components/LabelIconTip/style.js +36 -35
- package/es/utils/components/ProFormContext/index.js +1 -1
- package/es/utils/conversionMomentValue/index.js +19 -22
- package/es/utils/dateArrayFormatter/index.js +9 -14
- package/es/utils/genCopyable/index.js +74 -32
- package/es/utils/getFieldPropsOrFormItemProps/index.js +1 -1
- package/es/utils/hooks/useDebounceFn/index.js +18 -51
- package/es/utils/hooks/useDebounceValue/index.js +7 -16
- package/es/utils/hooks/useDeepCompareEffect/index.js +6 -18
- package/es/utils/hooks/useDocumentTitle/index.js +2 -2
- package/es/utils/hooks/useFetchData/index.js +36 -65
- package/es/utils/hooks/useForceRender/index.js +2 -9
- package/es/utils/hooks/useLatest/index.js +2 -2
- package/es/utils/hooks/usePrevious/index.js +3 -3
- package/es/utils/hooks/useReactiveRef/index.js +2 -2
- package/es/utils/hooks/useRefCallback/index.js +3 -3
- package/es/utils/hooks/useRefFunction/index.js +4 -9
- package/es/utils/index.d.ts +1 -2
- package/es/utils/index.js +1 -2
- package/es/utils/isBrowser/index.js +2 -2
- package/es/utils/isDeepEqualReact/index.js +9 -44
- package/es/utils/isDropdownValueType/index.js +2 -2
- package/es/utils/isNil/index.js +1 -3
- package/es/utils/isUrl/index.js +2 -2
- package/es/utils/merge/index.js +10 -12
- package/es/utils/nanoid/index.js +5 -6
- package/es/utils/omitBoolean/index.js +1 -1
- package/es/utils/omitUndefined/index.js +3 -3
- package/es/utils/omitUndefinedAndEmptyArr/index.js +4 -5
- package/es/utils/parseValueToMoment/index.js +3 -7
- package/es/utils/pickProFormItemProps/index.js +3 -3
- package/es/utils/pickProProps/index.js +6 -7
- package/es/utils/proFieldParsingText/index.js +86 -99
- package/es/utils/runFunction/index.js +2 -5
- package/es/utils/stringify/index.js +1 -1
- package/es/utils/transformKeySubmitValue/index.js +99 -116
- package/es/utils/typing.d.ts +1 -1
- package/es/utils/useEditableArray/index.d.ts +9 -7
- package/es/utils/useEditableArray/index.js +788 -700
- package/es/utils/useEditableMap/index.d.ts +1 -1
- package/es/utils/useEditableMap/index.js +148 -137
- package/es/utils/useMediaQuery/index.js +16 -18
- package/es/utils/useMediaQuery/query.js +15 -19
- package/es/version.js +1 -1
- package/lib/card/ProCard.js +7 -7
- package/lib/card/components/Actions/index.js +25 -25
- package/lib/card/components/Actions/style.d.ts +1 -1
- package/lib/card/components/Actions/style.js +79 -72
- package/lib/card/components/Card/index.js +157 -138
- package/lib/card/components/Card/style.d.ts +1 -1
- package/lib/card/components/Card/style.js +249 -193
- package/lib/card/components/CheckCard/Group.js +97 -115
- package/lib/card/components/CheckCard/index.d.ts +6 -0
- package/lib/card/components/CheckCard/index.js +85 -77
- package/lib/card/components/CheckCard/style.d.ts +1 -1
- package/lib/card/components/CheckCard/style.js +184 -169
- package/lib/card/components/Divider/index.js +20 -16
- package/lib/card/components/Divider/style.d.ts +1 -1
- package/lib/card/components/Divider/style.js +32 -30
- package/lib/card/components/Loading/index.js +19 -16
- package/lib/card/components/Loading/style.d.ts +1 -1
- package/lib/card/components/Loading/style.js +34 -32
- package/lib/card/components/Operation/index.js +16 -14
- package/lib/card/components/Operation/style.d.ts +1 -1
- package/lib/card/components/Operation/style.js +19 -19
- package/lib/card/components/Statistic/index.js +46 -42
- package/lib/card/components/Statistic/style.d.ts +1 -1
- package/lib/card/components/Statistic/style.js +89 -71
- package/lib/card/components/StatisticCard/index.js +45 -38
- package/lib/card/components/StatisticCard/style.d.ts +1 -1
- package/lib/card/components/StatisticCard/style.js +37 -36
- package/lib/card/index.js +4 -4
- package/lib/card/typing.d.ts +5 -0
- package/lib/descriptions/index.js +219 -225
- package/lib/descriptions/useFetchData.js +51 -90
- package/lib/field/AllProField.js +267 -217
- package/lib/field/FieldHOC/index.js +9 -15
- package/lib/field/PureProField.js +84 -82
- package/lib/field/ValueTypeToComponent.js +517 -618
- package/lib/field/components/Cascader/index.d.ts +2 -3
- package/lib/field/components/Cascader/index.js +65 -85
- package/lib/field/components/Checkbox/index.d.ts +1 -2
- package/lib/field/components/Checkbox/index.js +75 -73
- package/lib/field/components/Code/index.js +40 -39
- package/lib/field/components/ColorPicker/index.js +38 -33
- package/lib/field/components/DatePicker/index.d.ts +1 -1
- package/lib/field/components/DatePicker/index.js +49 -53
- package/lib/field/components/Digit/index.js +41 -43
- package/lib/field/components/DigitRange/index.js +69 -76
- package/lib/field/components/FromNow/index.js +27 -25
- package/lib/field/components/Image/index.js +28 -24
- package/lib/field/components/IndexColumn/index.js +22 -17
- package/lib/field/components/Money/index.js +106 -116
- package/lib/field/components/Options/index.js +34 -34
- package/lib/field/components/Password/index.js +35 -38
- package/lib/field/components/Percent/index.js +40 -45
- package/lib/field/components/Percent/util.js +3 -6
- package/lib/field/components/Progress/index.js +29 -28
- package/lib/field/components/Radio/index.d.ts +1 -2
- package/lib/field/components/Radio/index.js +61 -63
- package/lib/field/components/RangePicker/index.d.ts +1 -1
- package/lib/field/components/RangePicker/index.js +52 -63
- package/lib/field/components/Rate/index.js +24 -21
- package/lib/field/components/Second/index.js +36 -33
- package/lib/field/components/Segmented/index.d.ts +1 -2
- package/lib/field/components/Segmented/index.js +37 -48
- package/lib/field/components/Select/LightSelect/index.d.ts +1 -1
- package/lib/field/components/Select/LightSelect/index.js +103 -111
- package/lib/field/components/Select/SearchSelect/index.d.ts +6 -1
- package/lib/field/components/Select/SearchSelect/index.js +193 -130
- package/lib/field/components/Select/index.d.ts +1 -4
- package/lib/field/components/Select/index.js +198 -220
- package/lib/field/components/Slider/index.js +25 -22
- package/lib/field/components/Status/index.js +69 -79
- package/lib/field/components/Switch/index.d.ts +1 -1
- package/lib/field/components/Switch/index.js +32 -31
- package/lib/field/components/Text/index.js +34 -38
- package/lib/field/components/TextArea/index.js +26 -21
- package/lib/field/components/TextArea/readonly.js +24 -22
- package/lib/field/components/TimePicker/index.js +96 -105
- package/lib/field/components/TreeSelect/index.d.ts +2 -3
- package/lib/field/components/TreeSelect/index.js +105 -124
- package/lib/field/index.js +34 -34
- package/lib/form/BaseForm/BaseForm.d.ts +3 -0
- package/lib/form/BaseForm/BaseForm.js +415 -495
- package/lib/form/BaseForm/EditOrReadOnlyContext.js +1 -1
- package/lib/form/BaseForm/LightWrapper/index.js +57 -66
- package/lib/form/BaseForm/LightWrapper/style.d.ts +1 -1
- package/lib/form/BaseForm/LightWrapper/style.js +17 -14
- package/lib/form/BaseForm/Submitter/index.js +44 -44
- package/lib/form/BaseForm/index.js +3 -3
- package/lib/form/FieldContext.js +1 -1
- package/lib/form/components/Captcha/index.d.ts +8 -2
- package/lib/form/components/Captcha/index.js +76 -129
- package/lib/form/components/Cascader/index.js +26 -29
- package/lib/form/components/Checkbox/index.js +60 -61
- package/lib/form/components/ColorPicker/index.js +24 -26
- package/lib/form/components/DatePicker/BaseDatePicker.js +32 -30
- package/lib/form/components/DatePicker/DatePicker.js +14 -13
- package/lib/form/components/DatePicker/DateTimePicker.js +11 -12
- package/lib/form/components/DatePicker/MonthPicker.js +14 -13
- package/lib/form/components/DatePicker/QuarterPicker.js +14 -13
- package/lib/form/components/DatePicker/TimePicker.js +26 -27
- package/lib/form/components/DatePicker/WeekPicker.js +14 -13
- package/lib/form/components/DatePicker/YearPicker.js +14 -13
- package/lib/form/components/DatePicker/index.js +1 -1
- package/lib/form/components/DateRangePicker/BaseDateRanger.js +34 -34
- package/lib/form/components/DateRangePicker/DateMonthRangePicker.js +15 -16
- package/lib/form/components/DateRangePicker/DateQuarterRangePicker.js +15 -16
- package/lib/form/components/DateRangePicker/DateTimeRangePicker.js +15 -16
- package/lib/form/components/DateRangePicker/DateWeekRangePicker.js +15 -16
- package/lib/form/components/DateRangePicker/DateYearRangePicker.js +15 -16
- package/lib/form/components/DateRangePicker/TimeRangePicker.js +26 -29
- package/lib/form/components/DateRangePicker/index.js +15 -16
- package/lib/form/components/Dependency/index.js +31 -35
- package/lib/form/components/Digit/DigitRange.js +23 -24
- package/lib/form/components/Digit/index.js +27 -29
- package/lib/form/components/Field/index.js +55 -63
- package/lib/form/components/FieldSet/index.js +68 -76
- package/lib/form/components/FormItem/FormItemRender/index.js +58 -48
- package/lib/form/components/FormItem/Group/index.js +95 -95
- package/lib/form/components/FormItem/Group/style.d.ts +1 -1
- package/lib/form/components/FormItem/Group/style.js +46 -41
- package/lib/form/components/FormItem/index.js +135 -141
- package/lib/form/components/FormItem/warpField.js +165 -149
- package/lib/form/components/List/ListContainer.js +100 -191
- package/lib/form/components/List/ListItem.js +153 -200
- package/lib/form/components/List/index.d.ts +1 -1
- package/lib/form/components/List/index.js +97 -107
- package/lib/form/components/List/style.d.ts +1 -1
- package/lib/form/components/List/style.js +71 -48
- package/lib/form/components/Money/index.js +28 -30
- package/lib/form/components/Radio/index.js +45 -49
- package/lib/form/components/Rate/index.js +17 -21
- package/lib/form/components/SchemaForm/index.js +54 -68
- package/lib/form/components/SchemaForm/layoutType/Embed.js +5 -6
- package/lib/form/components/SchemaForm/layoutType/StepsForm.js +22 -26
- package/lib/form/components/SchemaForm/layoutType/index.js +2 -2
- package/lib/form/components/SchemaForm/valueType/dependency.js +13 -12
- package/lib/form/components/SchemaForm/valueType/divider.js +6 -7
- package/lib/form/components/SchemaForm/valueType/field.js +47 -45
- package/lib/form/components/SchemaForm/valueType/formList.js +10 -9
- package/lib/form/components/SchemaForm/valueType/formSet.js +10 -8
- package/lib/form/components/SchemaForm/valueType/group.js +9 -10
- package/lib/form/components/SchemaForm/valueType/ignore.js +4 -3
- package/lib/form/components/SchemaForm/valueType/index.js +7 -6
- package/lib/form/components/Segmented/index.js +20 -24
- package/lib/form/components/Select/index.js +69 -73
- package/lib/form/components/Slider/index.js +33 -35
- package/lib/form/components/Switch/index.js +24 -26
- package/lib/form/components/Text/index.js +77 -86
- package/lib/form/components/TextArea/index.js +17 -21
- package/lib/form/components/TreeSelect/index.js +20 -23
- package/lib/form/components/UploadButton/index.js +56 -103
- package/lib/form/components/UploadDragger/index.js +37 -44
- package/lib/form/components/index.js +42 -42
- package/lib/form/helpers/grid.js +68 -69
- package/lib/form/helpers/index.js +1 -1
- package/lib/form/index.d.ts +1 -0
- package/lib/form/index.js +8 -8
- package/lib/form/layouts/DrawerForm/index.d.ts +1 -1
- package/lib/form/layouts/DrawerForm/index.js +151 -242
- package/lib/form/layouts/DrawerForm/style.d.ts +1 -1
- package/lib/form/layouts/DrawerForm/style.js +26 -26
- package/lib/form/layouts/LightFilter/index.d.ts +12 -1
- package/lib/form/layouts/LightFilter/index.js +158 -141
- package/lib/form/layouts/LightFilter/style.d.ts +1 -1
- package/lib/form/layouts/LightFilter/style.js +52 -49
- package/lib/form/layouts/LoginForm/index.d.ts +1 -1
- package/lib/form/layouts/LoginForm/index.js +44 -48
- package/lib/form/layouts/LoginForm/style.d.ts +1 -1
- package/lib/form/layouts/LoginForm/style.js +71 -68
- package/lib/form/layouts/LoginFormPage/index.d.ts +1 -1
- package/lib/form/layouts/LoginFormPage/index.js +45 -49
- package/lib/form/layouts/LoginFormPage/style.d.ts +1 -1
- package/lib/form/layouts/LoginFormPage/style.js +136 -127
- package/lib/form/layouts/ModalForm/index.js +119 -203
- package/lib/form/layouts/ProForm/index.d.ts +1 -1
- package/lib/form/layouts/ProForm/index.js +5 -5
- package/lib/form/layouts/QueryFilter/Actions.js +23 -22
- package/lib/form/layouts/QueryFilter/index.d.ts +2 -1
- package/lib/form/layouts/QueryFilter/index.js +177 -202
- package/lib/form/layouts/QueryFilter/style.d.ts +1 -1
- package/lib/form/layouts/QueryFilter/style.js +45 -38
- package/lib/form/layouts/StepsForm/StepForm.d.ts +2 -3
- package/lib/form/layouts/StepsForm/StepForm.js +50 -72
- package/lib/form/layouts/StepsForm/index.js +186 -215
- package/lib/form/layouts/StepsForm/style.d.ts +1 -1
- package/lib/form/layouts/StepsForm/style.js +30 -29
- package/lib/form/layouts/index.js +9 -9
- package/lib/index.js +11 -11
- package/lib/layout/ProLayout.js +281 -292
- package/lib/layout/WrapContent.js +18 -14
- package/lib/layout/assert/Logo.js +96 -97
- package/lib/layout/components/AppsLogoComponents/AppsLogo.js +11 -12
- package/lib/layout/components/AppsLogoComponents/DefaultContent.js +19 -17
- package/lib/layout/components/AppsLogoComponents/SimpleContent.js +22 -19
- package/lib/layout/components/AppsLogoComponents/index.js +37 -39
- package/lib/layout/components/AppsLogoComponents/style/default.js +4 -3
- package/lib/layout/components/AppsLogoComponents/style/index.d.ts +1 -1
- package/lib/layout/components/AppsLogoComponents/style/index.js +52 -51
- package/lib/layout/components/AppsLogoComponents/style/simple.js +3 -2
- package/lib/layout/components/CollapsedIcon/index.js +20 -17
- package/lib/layout/components/CollapsedIcon/style.d.ts +1 -1
- package/lib/layout/components/CollapsedIcon/style.js +40 -41
- package/lib/layout/components/Footer.js +23 -22
- package/lib/layout/components/FooterToolbar/index.js +59 -53
- package/lib/layout/components/FooterToolbar/style/index.d.ts +1 -1
- package/lib/layout/components/FooterToolbar/style/index.js +38 -38
- package/lib/layout/components/FooterToolbar/style/stylish.d.ts +1 -1
- package/lib/layout/components/FooterToolbar/style/stylish.js +11 -10
- package/lib/layout/components/GlobalFooter/index.d.ts +1 -1
- package/lib/layout/components/GlobalFooter/index.js +27 -27
- package/lib/layout/components/GlobalFooter/style.d.ts +1 -1
- package/lib/layout/components/GlobalFooter/style.js +31 -31
- package/lib/layout/components/GlobalHeader/ActionsContent.js +65 -81
- package/lib/layout/components/GlobalHeader/index.js +61 -49
- package/lib/layout/components/GlobalHeader/rightContentStyle.d.ts +1 -1
- package/lib/layout/components/GlobalHeader/rightContentStyle.js +49 -50
- package/lib/layout/components/GlobalHeader/style.d.ts +1 -1
- package/lib/layout/components/GlobalHeader/style.js +58 -55
- package/lib/layout/components/GridContent/index.js +26 -21
- package/lib/layout/components/GridContent/style.d.ts +1 -1
- package/lib/layout/components/GridContent/style.js +14 -14
- package/lib/layout/components/Header/index.js +65 -59
- package/lib/layout/components/Header/style/header.d.ts +1 -1
- package/lib/layout/components/Header/style/header.js +49 -48
- package/lib/layout/components/Header/style/stylish.d.ts +1 -1
- package/lib/layout/components/Header/style/stylish.js +15 -12
- package/lib/layout/components/Help/AsyncContentPanel.js +15 -20
- package/lib/layout/components/Help/HelpProvide.js +1 -1
- package/lib/layout/components/Help/ProHelpContentPanel.js +66 -85
- package/lib/layout/components/Help/ProHelpDrawer.d.ts +1 -1
- package/lib/layout/components/Help/ProHelpDrawer.js +27 -30
- package/lib/layout/components/Help/ProHelpModal.d.ts +1 -1
- package/lib/layout/components/Help/ProHelpModal.js +26 -28
- package/lib/layout/components/Help/ProHelpPanel.js +86 -94
- package/lib/layout/components/Help/ProHelpPopover.js +21 -19
- package/lib/layout/components/Help/RenderContentPanel.js +36 -26
- package/lib/layout/components/Help/Search.js +55 -80
- package/lib/layout/components/Help/index.js +19 -20
- package/lib/layout/components/Help/style.d.ts +1 -1
- package/lib/layout/components/Help/style.js +82 -76
- package/lib/layout/components/PageContainer/index.js +172 -151
- package/lib/layout/components/PageContainer/style/index.d.ts +1 -1
- package/lib/layout/components/PageContainer/style/index.js +95 -79
- package/lib/layout/components/PageContainer/style/stylish.d.ts +1 -1
- package/lib/layout/components/PageContainer/style/stylish.js +11 -10
- package/lib/layout/components/PageHeader/index.js +99 -99
- package/lib/layout/components/PageHeader/style/index.d.ts +1 -1
- package/lib/layout/components/PageHeader/style/index.js +142 -123
- package/lib/layout/components/PageLoading/index.js +18 -20
- package/lib/layout/components/SettingDrawer/BlockCheckbox.js +31 -34
- package/lib/layout/components/SettingDrawer/LayoutChange.js +25 -23
- package/lib/layout/components/SettingDrawer/RegionalChange.js +16 -16
- package/lib/layout/components/SettingDrawer/ThemeColor.js +34 -36
- package/lib/layout/components/SettingDrawer/index.js +140 -170
- package/lib/layout/components/SettingDrawer/style/index.d.ts +1 -1
- package/lib/layout/components/SettingDrawer/style/index.js +141 -138
- package/lib/layout/components/SiderMenu/BaseMenu.d.ts +1 -1
- package/lib/layout/components/SiderMenu/BaseMenu.js +236 -222
- package/lib/layout/components/SiderMenu/SiderMenu.js +130 -119
- package/lib/layout/components/SiderMenu/index.js +53 -45
- package/lib/layout/components/SiderMenu/style/index.d.ts +1 -1
- package/lib/layout/components/SiderMenu/style/index.js +179 -162
- package/lib/layout/components/SiderMenu/style/menu.d.ts +1 -1
- package/lib/layout/components/SiderMenu/style/menu.js +148 -111
- package/lib/layout/components/SiderMenu/style/stylish.d.ts +1 -1
- package/lib/layout/components/SiderMenu/style/stylish.js +15 -12
- package/lib/layout/components/TopNavHeader/index.js +73 -62
- package/lib/layout/components/TopNavHeader/style.d.ts +1 -1
- package/lib/layout/components/TopNavHeader/style.js +64 -64
- package/lib/layout/context/RouteContext.js +1 -1
- package/lib/layout/defaultSettings.d.ts +6 -0
- package/lib/layout/defaultSettings.js +1 -1
- package/lib/layout/getPageTitle.js +27 -26
- package/lib/layout/index.js +16 -16
- package/lib/layout/locales/en-US.js +3 -2
- package/lib/layout/locales/index.js +8 -6
- package/lib/layout/locales/it-IT.js +3 -2
- package/lib/layout/locales/ko-KR.js +3 -2
- package/lib/layout/locales/zh-CN.js +3 -2
- package/lib/layout/locales/zh-TW.js +3 -2
- package/lib/layout/style/index.d.ts +1 -1
- package/lib/layout/style/index.js +48 -43
- package/lib/layout/utils/getBreadcrumbProps.js +65 -62
- package/lib/layout/utils/getMenuData.js +9 -13
- package/lib/layout/utils/pathTools.js +2 -6
- package/lib/layout/utils/useCurrentMenuLayoutProps.js +6 -11
- package/lib/layout/utils/utils.js +16 -18
- package/lib/list/Item.js +155 -136
- package/lib/list/ListView.js +110 -119
- package/lib/list/constants.js +2 -2
- package/lib/list/index.js +72 -70
- package/lib/list/style/index.d.ts +1 -1
- package/lib/list/style/index.js +281 -214
- package/lib/provider/index.d.ts +1 -0
- package/lib/provider/index.js +132 -117
- package/lib/provider/intl.js +56 -56
- package/lib/provider/typing/layoutToken.js +28 -25
- package/lib/provider/useStyle/index.d.ts +2 -1
- package/lib/provider/useStyle/index.js +64 -61
- package/lib/provider/utils/merge.js +12 -14
- package/lib/skeleton/components/Descriptions/index.js +213 -229
- package/lib/skeleton/components/List/index.js +211 -221
- package/lib/skeleton/components/Result/index.js +45 -47
- package/lib/skeleton/index.js +23 -19
- package/lib/table/Store/Provide.d.ts +4 -4
- package/lib/table/Store/Provide.js +103 -117
- package/lib/table/Table.d.ts +5 -2
- package/lib/table/Table.js +592 -602
- package/lib/table/TableSearch.d.ts +24 -0
- package/lib/table/TableSearch.js +61 -0
- package/lib/table/TableToolbar.d.ts +22 -0
- package/lib/table/TableToolbar.js +55 -0
- package/lib/table/components/Alert/index.d.ts +1 -1
- package/lib/table/components/Alert/index.js +41 -40
- package/lib/table/components/Alert/style.d.ts +1 -1
- package/lib/table/components/Alert/style.js +28 -28
- package/lib/table/components/ColumnSetting/index.d.ts +1 -1
- package/lib/table/components/ColumnSetting/index.js +230 -224
- package/lib/table/components/ColumnSetting/style.d.ts +1 -1
- package/lib/table/components/ColumnSetting/style.js +86 -72
- package/lib/table/components/DragSortTable/index.d.ts +1 -1
- package/lib/table/components/DragSortTable/index.js +64 -78
- package/lib/table/components/DragSortTable/style.d.ts +1 -1
- package/lib/table/components/DragSortTable/style.js +20 -20
- package/lib/table/components/Dropdown/index.js +42 -48
- package/lib/table/components/EditableTable/CellEditorTable.js +24 -32
- package/lib/table/components/EditableTable/RowEditorTable.js +23 -28
- package/lib/table/components/EditableTable/index.js +598 -299
- package/lib/table/components/Form/FormRender.js +99 -104
- package/lib/table/components/Form/index.d.ts +4 -19
- package/lib/table/components/Form/index.js +113 -159
- package/lib/table/components/ListToolBar/HeaderMenu.js +42 -51
- package/lib/table/components/ListToolBar/index.js +123 -148
- package/lib/table/components/ListToolBar/style.d.ts +1 -1
- package/lib/table/components/ListToolBar/style.js +127 -118
- package/lib/table/components/ToolBar/DensityIcon.js +10 -9
- package/lib/table/components/ToolBar/FullscreenIcon.js +5 -10
- package/lib/table/components/ToolBar/index.d.ts +2 -8
- package/lib/table/components/ToolBar/index.js +154 -194
- package/lib/table/index.js +27 -27
- package/lib/table/style/index.d.ts +1 -1
- package/lib/table/style/index.js +144 -113
- package/lib/table/typing.d.ts +13 -6
- package/lib/table/useFetchData.js +202 -347
- package/lib/table/utils/cellRenderToFromItem.js +106 -120
- package/lib/table/utils/columnRender.js +65 -54
- package/lib/table/utils/columnSort.js +24 -23
- package/lib/table/utils/genProColumnToColumn.d.ts +13 -9
- package/lib/table/utils/genProColumnToColumn.js +121 -99
- package/lib/table/utils/index.d.ts +12 -0
- package/lib/table/utils/index.js +129 -181
- package/lib/table/utils/useDragSort.d.ts +1 -1
- package/lib/table/utils/useDragSort.js +99 -93
- package/lib/table/utils/usePageInfo.d.ts +6 -0
- package/lib/table/utils/usePageInfo.js +61 -0
- package/lib/utils/components/DropdownFooter/index.js +25 -23
- package/lib/utils/components/DropdownFooter/style.d.ts +1 -1
- package/lib/utils/components/DropdownFooter/style.js +16 -16
- package/lib/utils/components/ErrorBoundary/index.js +28 -50
- package/lib/utils/components/FieldLabel/index.js +70 -71
- package/lib/utils/components/FieldLabel/style.d.ts +1 -1
- package/lib/utils/components/FieldLabel/style.js +104 -82
- package/lib/utils/components/FilterDropdown/index.d.ts +11 -0
- package/lib/utils/components/FilterDropdown/index.js +44 -33
- package/lib/utils/components/FilterDropdown/style.d.ts +1 -1
- package/lib/utils/components/FilterDropdown/style.js +19 -17
- package/lib/utils/components/InlineErrorFormItem/index.js +80 -80
- package/lib/utils/components/InlineErrorFormItem/style.d.ts +1 -1
- package/lib/utils/components/InlineErrorFormItem/style.js +56 -50
- package/lib/utils/components/LabelIconTip/index.js +30 -32
- package/lib/utils/components/LabelIconTip/style.d.ts +1 -1
- package/lib/utils/components/LabelIconTip/style.js +36 -36
- package/lib/utils/components/ProFormContext/index.js +1 -1
- package/lib/utils/conversionMomentValue/index.js +22 -23
- package/lib/utils/dateArrayFormatter/index.js +11 -15
- package/lib/utils/genCopyable/index.js +75 -33
- package/lib/utils/getFieldPropsOrFormItemProps/index.js +3 -2
- package/lib/utils/hooks/useDebounceFn/index.js +18 -52
- package/lib/utils/hooks/useDebounceValue/index.js +7 -17
- package/lib/utils/hooks/useDeepCompareEffect/index.js +7 -19
- package/lib/utils/hooks/useDocumentTitle/index.js +2 -2
- package/lib/utils/hooks/useFetchData/index.js +36 -65
- package/lib/utils/hooks/useForceRender/index.js +2 -10
- package/lib/utils/hooks/useLatest/index.js +4 -3
- package/lib/utils/hooks/usePrevious/index.js +5 -4
- package/lib/utils/hooks/useReactiveRef/index.js +2 -2
- package/lib/utils/hooks/useRefCallback/index.js +3 -3
- package/lib/utils/hooks/useRefFunction/index.js +6 -11
- package/lib/utils/index.d.ts +1 -2
- package/lib/utils/index.js +57 -65
- package/lib/utils/isBrowser/index.js +4 -3
- package/lib/utils/isDeepEqualReact/index.js +9 -45
- package/lib/utils/isDropdownValueType/index.js +4 -3
- package/lib/utils/isNil/index.js +2 -3
- package/lib/utils/isUrl/index.js +4 -3
- package/lib/utils/merge/index.js +12 -14
- package/lib/utils/nanoid/index.js +7 -7
- package/lib/utils/omitBoolean/index.js +3 -2
- package/lib/utils/omitUndefined/index.js +5 -4
- package/lib/utils/omitUndefinedAndEmptyArr/index.js +6 -6
- package/lib/utils/parseValueToMoment/index.js +5 -8
- package/lib/utils/pickProFormItemProps/index.js +3 -3
- package/lib/utils/pickProProps/index.js +6 -7
- package/lib/utils/proFieldParsingText/index.js +90 -100
- package/lib/utils/runFunction/index.js +2 -5
- package/lib/utils/stringify/index.js +2 -2
- package/lib/utils/transformKeySubmitValue/index.js +101 -117
- package/lib/utils/typing.d.ts +1 -1
- package/lib/utils/useEditableArray/index.d.ts +9 -7
- package/lib/utils/useEditableArray/index.js +791 -700
- package/lib/utils/useEditableMap/index.d.ts +1 -1
- package/lib/utils/useEditableMap/index.js +147 -137
- package/lib/utils/useMediaQuery/index.js +19 -19
- package/lib/utils/useMediaQuery/query.js +14 -19
- package/lib/version.js +1 -1
- package/package.json +34 -45
- package/es/utils/useMountMergeState/index.d.ts +0 -2
- package/es/utils/useMountMergeState/index.js +0 -2
- package/lib/utils/useMountMergeState/index.d.ts +0 -2
- package/lib/utils/useMountMergeState/index.js +0 -12
|
@@ -1,67 +1,227 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
5
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
6
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
7
|
-
var _excluded = ["onTableChange", "maxLength", "formItemProps", "recordCreatorProps", "rowKey", "controlled", "defaultValue", "onChange", "editableFormRef"],
|
|
8
|
-
_excluded2 = ["record", "position", "creatorButtonText", "newRecordType", "parentKey", "style"];
|
|
9
1
|
import { PlusOutlined } from '@ant-design/icons';
|
|
10
|
-
import { get, set,
|
|
2
|
+
import { get, set, useControlledState } from '@rc-component/util';
|
|
11
3
|
import { Button, Form } from 'antd';
|
|
12
|
-
import React, { useContext, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
|
|
4
|
+
import React, { useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
|
|
13
5
|
import ProForm, { ProFormDependency } from "../../../form";
|
|
14
6
|
import { useIntl } from "../../../provider";
|
|
15
|
-
import { isDeepEqualReact, runFunction,
|
|
7
|
+
import { isDeepEqualReact, runFunction, useDeepCompareEffect, useRefFunction } from "../../../utils";
|
|
8
|
+
import { editableRowByKey, recordKeyToString } from "../../../utils/useEditableArray";
|
|
16
9
|
import ProTable from "../../Table";
|
|
17
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
12
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
20
|
-
|
|
13
|
+
const EditableTableActionContext = /*#__PURE__*/React.createContext(undefined);
|
|
21
14
|
|
|
22
15
|
/** 可编辑表格的按钮 */
|
|
23
16
|
function RecordCreator(props) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
return _context.abrupt("return");
|
|
47
|
-
case 5:
|
|
48
|
-
actionRef === null || actionRef === void 0 || (_actionRef$current = actionRef.current) === null || _actionRef$current === void 0 || _actionRef$current.addEditRecord(record, {
|
|
49
|
-
position: position,
|
|
50
|
-
newRecordType: newRecordType,
|
|
51
|
-
parentKey: parentKey
|
|
52
|
-
});
|
|
53
|
-
case 6:
|
|
54
|
-
case "end":
|
|
55
|
-
return _context.stop();
|
|
56
|
-
}
|
|
57
|
-
}, _callee);
|
|
58
|
-
}));
|
|
59
|
-
function onClick(_x) {
|
|
60
|
-
return _onClick.apply(this, arguments);
|
|
17
|
+
const {
|
|
18
|
+
children,
|
|
19
|
+
record,
|
|
20
|
+
position,
|
|
21
|
+
newRecordType,
|
|
22
|
+
parentKey
|
|
23
|
+
} = props;
|
|
24
|
+
const actionRef = useContext(EditableTableActionContext);
|
|
25
|
+
return /*#__PURE__*/React.cloneElement(children, {
|
|
26
|
+
...children.props,
|
|
27
|
+
onClick: async e => {
|
|
28
|
+
// 如果返回了false,接触掉默认行为
|
|
29
|
+
const isOk = await children.props.onClick?.(e);
|
|
30
|
+
if (isOk === false) return;
|
|
31
|
+
if (actionRef?.current) {
|
|
32
|
+
actionRef.current.addEditRecord(record, {
|
|
33
|
+
position,
|
|
34
|
+
newRecordType,
|
|
35
|
+
parentKey: parentKey
|
|
36
|
+
});
|
|
61
37
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 处理嵌套行的新增
|
|
44
|
+
*/
|
|
45
|
+
function handleNestedRowInsert(baseData, defaultValue, newLineOptions, getRowKey, childrenColumnName) {
|
|
46
|
+
if (!newLineOptions.recordKey) {
|
|
47
|
+
return baseData;
|
|
48
|
+
}
|
|
49
|
+
const actionProps = {
|
|
50
|
+
data: baseData,
|
|
51
|
+
getRowKey,
|
|
52
|
+
row: {
|
|
53
|
+
...defaultValue,
|
|
54
|
+
map_row_parentKey: recordKeyToString(newLineOptions.parentKey)?.toString()
|
|
55
|
+
},
|
|
56
|
+
key: newLineOptions.recordKey,
|
|
57
|
+
childrenColumnName
|
|
58
|
+
};
|
|
59
|
+
return editableRowByKey(actionProps, newLineOptions.position === 'top' ? 'top' : 'update');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 处理分页场景下的新增
|
|
64
|
+
*/
|
|
65
|
+
function handlePaginationInsert(baseData, defaultValue, pageConfig) {
|
|
66
|
+
if (pageConfig.pageSize > baseData.length) {
|
|
67
|
+
return [...baseData, defaultValue];
|
|
68
|
+
}
|
|
69
|
+
const insertIndex = pageConfig.current * pageConfig.pageSize - 1;
|
|
70
|
+
const result = [...baseData];
|
|
71
|
+
result.splice(insertIndex, 0, defaultValue);
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
function useEditableDataSource({
|
|
75
|
+
actionDataSource,
|
|
76
|
+
editableUtils,
|
|
77
|
+
pagination,
|
|
78
|
+
getRowKey,
|
|
79
|
+
childrenColumnName
|
|
80
|
+
}) {
|
|
81
|
+
return useMemo(() => {
|
|
82
|
+
const newLineConfig = editableUtils?.newLineRecord;
|
|
83
|
+
const baseData = Array.isArray(actionDataSource) ? [...actionDataSource] : [];
|
|
84
|
+
if (!newLineConfig?.defaultValue) {
|
|
85
|
+
return baseData;
|
|
86
|
+
}
|
|
87
|
+
const {
|
|
88
|
+
options: newLineOptions,
|
|
89
|
+
defaultValue
|
|
90
|
+
} = newLineConfig;
|
|
91
|
+
if (newLineOptions?.parentKey) {
|
|
92
|
+
return handleNestedRowInsert(baseData, defaultValue, newLineOptions, getRowKey, childrenColumnName || 'children');
|
|
93
|
+
}
|
|
94
|
+
if (newLineOptions?.position === 'top') {
|
|
95
|
+
return [defaultValue, ...baseData];
|
|
96
|
+
}
|
|
97
|
+
const pageConfig = pagination && typeof pagination === 'object' ? pagination : undefined;
|
|
98
|
+
if (pageConfig?.current && pageConfig?.pageSize) {
|
|
99
|
+
return handlePaginationInsert(baseData, defaultValue, pageConfig);
|
|
100
|
+
}
|
|
101
|
+
return [...baseData, defaultValue];
|
|
102
|
+
}, [actionDataSource, childrenColumnName, editableUtils?.newLineRecord, getRowKey, pagination]);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 检查是否应该显示创建按钮
|
|
107
|
+
*/
|
|
108
|
+
function shouldShowCreatorButton(maxLength, valueLength, recordCreatorProps) {
|
|
109
|
+
if (typeof maxLength === 'number' && maxLength <= valueLength) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
return recordCreatorProps !== false;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 创建按钮 DOM
|
|
117
|
+
*/
|
|
118
|
+
function createButtonDom(recordCreatorProps, value, intl) {
|
|
119
|
+
const {
|
|
120
|
+
record,
|
|
121
|
+
position,
|
|
122
|
+
creatorButtonText,
|
|
123
|
+
newRecordType,
|
|
124
|
+
parentKey,
|
|
125
|
+
style,
|
|
126
|
+
...restButtonProps
|
|
127
|
+
} = recordCreatorProps;
|
|
128
|
+
return /*#__PURE__*/_jsx(RecordCreator, {
|
|
129
|
+
record: runFunction(record, value?.length, value) || {},
|
|
130
|
+
position: position,
|
|
131
|
+
parentKey: runFunction(parentKey, value?.length, value),
|
|
132
|
+
newRecordType: newRecordType,
|
|
133
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
134
|
+
type: "dashed",
|
|
135
|
+
style: {
|
|
136
|
+
display: 'block',
|
|
137
|
+
margin: '10px 0',
|
|
138
|
+
width: '100%',
|
|
139
|
+
...style
|
|
140
|
+
},
|
|
141
|
+
icon: /*#__PURE__*/_jsx(PlusOutlined, {}),
|
|
142
|
+
...restButtonProps,
|
|
143
|
+
children: creatorButtonText || intl.getMessage('editableTable.action.add', '添加一行数据')
|
|
144
|
+
})
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* 创建顶部按钮的渲染属性
|
|
150
|
+
*/
|
|
151
|
+
function createTopButtonProps(creatorButtonDom, columnsLength) {
|
|
152
|
+
return {
|
|
153
|
+
components: {
|
|
154
|
+
header: {
|
|
155
|
+
wrapper: ({
|
|
156
|
+
className,
|
|
157
|
+
children
|
|
158
|
+
}) => /*#__PURE__*/_jsxs("thead", {
|
|
159
|
+
className: className,
|
|
160
|
+
children: [children, /*#__PURE__*/_jsxs("tr", {
|
|
161
|
+
style: {
|
|
162
|
+
position: 'relative'
|
|
163
|
+
},
|
|
164
|
+
children: [/*#__PURE__*/_jsx("td", {
|
|
165
|
+
colSpan: 0,
|
|
166
|
+
style: {
|
|
167
|
+
visibility: 'hidden'
|
|
168
|
+
},
|
|
169
|
+
children: creatorButtonDom
|
|
170
|
+
}), /*#__PURE__*/_jsx("td", {
|
|
171
|
+
style: {
|
|
172
|
+
position: 'absolute',
|
|
173
|
+
left: 0,
|
|
174
|
+
width: '100%'
|
|
175
|
+
},
|
|
176
|
+
colSpan: columnsLength,
|
|
177
|
+
children: creatorButtonDom
|
|
178
|
+
})]
|
|
179
|
+
})]
|
|
180
|
+
})
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* 创建底部按钮的渲染属性
|
|
188
|
+
*/
|
|
189
|
+
function createBottomButtonProps(creatorButtonDom, tableViewRender) {
|
|
190
|
+
return {
|
|
191
|
+
tableViewRender: (_, dom) => /*#__PURE__*/_jsxs(_Fragment, {
|
|
192
|
+
children: [tableViewRender?.(_, dom) ?? dom, creatorButtonDom]
|
|
193
|
+
})
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function useCreatorButton({
|
|
197
|
+
recordCreatorProps,
|
|
198
|
+
maxLength,
|
|
199
|
+
value,
|
|
200
|
+
intl,
|
|
201
|
+
isTop,
|
|
202
|
+
columnsLength,
|
|
203
|
+
tableViewRender
|
|
204
|
+
}) {
|
|
205
|
+
const creatorButtonDom = useMemo(() => {
|
|
206
|
+
if (!shouldShowCreatorButton(maxLength, value?.length || 0, recordCreatorProps)) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
if (!recordCreatorProps) {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
return createButtonDom(recordCreatorProps, value, intl);
|
|
213
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
214
|
+
}, [maxLength, recordCreatorProps, value?.length, intl]);
|
|
215
|
+
const buttonRenderProps = useMemo(() => {
|
|
216
|
+
if (!creatorButtonDom) {
|
|
217
|
+
return {};
|
|
218
|
+
}
|
|
219
|
+
return isTop ? createTopButtonProps(creatorButtonDom, columnsLength) : createBottomButtonProps(creatorButtonDom, tableViewRender);
|
|
220
|
+
}, [columnsLength, creatorButtonDom, isTop, tableViewRender]);
|
|
221
|
+
return {
|
|
222
|
+
creatorButtonDom,
|
|
223
|
+
buttonRenderProps
|
|
224
|
+
};
|
|
65
225
|
}
|
|
66
226
|
|
|
67
227
|
/**
|
|
@@ -70,294 +230,431 @@ function RecordCreator(props) {
|
|
|
70
230
|
* @param props
|
|
71
231
|
*/
|
|
72
232
|
function EditableTable(props) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
maxLength
|
|
77
|
-
formItemProps
|
|
78
|
-
recordCreatorProps
|
|
79
|
-
rowKey
|
|
80
|
-
controlled
|
|
81
|
-
defaultValue
|
|
82
|
-
onChange
|
|
83
|
-
editableFormRef
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
233
|
+
const intl = useIntl();
|
|
234
|
+
const {
|
|
235
|
+
onTableChange,
|
|
236
|
+
maxLength,
|
|
237
|
+
formItemProps,
|
|
238
|
+
recordCreatorProps,
|
|
239
|
+
rowKey,
|
|
240
|
+
controlled,
|
|
241
|
+
defaultValue,
|
|
242
|
+
onChange,
|
|
243
|
+
editableFormRef,
|
|
244
|
+
// @ts-ignore
|
|
245
|
+
autoFocus,
|
|
246
|
+
...rest
|
|
247
|
+
} = props;
|
|
248
|
+
const preData = useRef(undefined);
|
|
249
|
+
const actionRef = useRef();
|
|
250
|
+
const formRef = useRef();
|
|
251
|
+
const form = Form.useFormInstance();
|
|
88
252
|
|
|
89
253
|
// 设置 ref
|
|
90
|
-
useImperativeHandle(rest.actionRef,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
254
|
+
useImperativeHandle(rest.actionRef, () => actionRef.current, [actionRef.current]);
|
|
255
|
+
|
|
256
|
+
// 在 name 模式下,如果没有传递 value prop,尝试从表单值中获取初始值
|
|
257
|
+
const getInitialValue = () => {
|
|
258
|
+
if (props.value) {
|
|
259
|
+
return props.value;
|
|
260
|
+
}
|
|
261
|
+
if (defaultValue) {
|
|
262
|
+
return defaultValue;
|
|
263
|
+
}
|
|
264
|
+
// 如果使用了 name 且没有 value,尝试从表单获取初始值
|
|
265
|
+
if (props.name && form) {
|
|
266
|
+
const namePath = [props.name].flat(1).filter(Boolean);
|
|
267
|
+
const formValue = form.getFieldValue(namePath);
|
|
268
|
+
if (Array.isArray(formValue)) {
|
|
269
|
+
return formValue;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return [];
|
|
273
|
+
};
|
|
274
|
+
const [value, setValueInner] = useControlledState(getInitialValue, props.value);
|
|
275
|
+
const onChangeFn = props.controlled ? props.onChange : undefined;
|
|
276
|
+
const setValue = useCallback(updater => {
|
|
277
|
+
setValueInner(prev => {
|
|
278
|
+
const next = typeof updater === 'function' ? updater(prev) : updater;
|
|
279
|
+
// 在非受控模式下,onChange 应该在 onDataSourceChange 中触发
|
|
280
|
+
onChangeFn?.(next);
|
|
281
|
+
return next;
|
|
282
|
+
});
|
|
283
|
+
}, [onChangeFn]);
|
|
284
|
+
const getRowKey = React.useMemo(() => {
|
|
103
285
|
if (typeof rowKey === 'function') {
|
|
104
286
|
return rowKey;
|
|
105
287
|
}
|
|
106
|
-
return
|
|
107
|
-
return record[rowKey] || index;
|
|
108
|
-
};
|
|
288
|
+
return (record, index) => record[rowKey] || index;
|
|
109
289
|
}, [rowKey]);
|
|
110
290
|
|
|
111
291
|
/**
|
|
112
|
-
*
|
|
113
|
-
* @param finlayRowKey
|
|
114
|
-
* @returns string | number
|
|
292
|
+
* 创建编辑 keys 的 Set,用于快速查找
|
|
115
293
|
*/
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
294
|
+
const createEditingKeysSet = useRefFunction(editingKeys => {
|
|
295
|
+
return new Set((editingKeys || []).map(key => String(key)));
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* 同步表单值,排除正在编辑的行
|
|
300
|
+
*/
|
|
301
|
+
const syncFormValuesExcludingEditing = useRefFunction((dataSource, editingKeysSet, namePath) => {
|
|
302
|
+
if (!formRef.current) return;
|
|
303
|
+
try {
|
|
304
|
+
if (namePath && namePath.length > 0) {
|
|
305
|
+
// name 模式:需要保留正在编辑的行
|
|
306
|
+
const currentFormValues = formRef.current.getFieldsValue() || {};
|
|
307
|
+
const currentList = get(currentFormValues, namePath);
|
|
308
|
+
if (currentList && Array.isArray(currentList)) {
|
|
309
|
+
// 构建新的表单值,保留正在编辑的行
|
|
310
|
+
// 使用 Map 优化查找性能,将 O(n²) 降低到 O(n)
|
|
311
|
+
const currentListMap = new Map();
|
|
312
|
+
currentList.forEach((item, idx) => {
|
|
313
|
+
const key = getRowKey(item, idx);
|
|
314
|
+
currentListMap.set(String(key), item);
|
|
315
|
+
});
|
|
316
|
+
const newList = dataSource.map((item, index) => {
|
|
317
|
+
const key = getRowKey(item, index);
|
|
318
|
+
const keyStr = String(key);
|
|
319
|
+
|
|
320
|
+
// 如果该行正在编辑,保留表单中的值
|
|
321
|
+
if (editingKeysSet.has(keyStr)) {
|
|
322
|
+
return currentListMap.get(keyStr) || item;
|
|
323
|
+
}
|
|
324
|
+
return item;
|
|
325
|
+
});
|
|
326
|
+
const newValue = set({}, namePath, newList);
|
|
327
|
+
formRef.current.setFieldsValue(newValue);
|
|
328
|
+
} else {
|
|
329
|
+
const newValue = set({}, namePath, dataSource);
|
|
330
|
+
formRef.current.setFieldsValue(newValue);
|
|
331
|
+
}
|
|
332
|
+
} else {
|
|
333
|
+
// 非 name 模式:直接设置值
|
|
334
|
+
const formValues = {};
|
|
335
|
+
dataSource.forEach((current, index) => {
|
|
336
|
+
const key = getRowKey(current, index);
|
|
337
|
+
const keyStr = String(key);
|
|
338
|
+
if (!editingKeysSet.has(keyStr)) {
|
|
339
|
+
formValues[keyStr] = current;
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
if (Object.keys(formValues).length > 0) {
|
|
343
|
+
formRef.current.setFieldsValue(formValues);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
} catch (error) {
|
|
347
|
+
console.warn('Failed to sync form values:', error);
|
|
124
348
|
}
|
|
349
|
+
});
|
|
125
350
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
351
|
+
/**
|
|
352
|
+
* 将数字索引转换为实际的 rowKey(非 name 模式)
|
|
353
|
+
*/
|
|
354
|
+
const convertIndexToRowKey = useRefFunction(index => {
|
|
355
|
+
const dataLength = value?.length ?? 0;
|
|
356
|
+
if (index >= dataLength) return index;
|
|
357
|
+
const rowData = value?.[index];
|
|
358
|
+
return getRowKey?.(rowData, index);
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* 将 rowKey 转换为数字索引(name 模式)
|
|
363
|
+
*/
|
|
364
|
+
const convertRowKeyToIndex = useRefFunction(rowKey => {
|
|
365
|
+
const dataLength = value?.length ?? 0;
|
|
366
|
+
if (typeof rowKey === 'string' || rowKey >= dataLength) {
|
|
367
|
+
const rowIndex = value.findIndex((item, index) => {
|
|
368
|
+
return getRowKey?.(item, index)?.toString() === rowKey?.toString();
|
|
133
369
|
});
|
|
134
|
-
if (
|
|
370
|
+
if (rowIndex !== -1) return rowIndex;
|
|
371
|
+
}
|
|
372
|
+
return rowKey;
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* 根据不同的情况返回不同的 rowKey
|
|
377
|
+
*/
|
|
378
|
+
const coverRowKey = useRefFunction(finlayRowKey => {
|
|
379
|
+
if (typeof finlayRowKey === 'number' && !props.name) {
|
|
380
|
+
return convertIndexToRowKey(finlayRowKey);
|
|
381
|
+
}
|
|
382
|
+
if (props.name) {
|
|
383
|
+
return convertRowKeyToIndex(finlayRowKey);
|
|
135
384
|
}
|
|
136
385
|
return finlayRowKey;
|
|
137
386
|
});
|
|
138
387
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
*/
|
|
146
|
-
var getRowData = function getRowData(rowIndex) {
|
|
147
|
-
var _finlayRowKey$toStrin, _formRef$current;
|
|
148
|
-
if (rowIndex == undefined) {
|
|
149
|
-
throw new Error('rowIndex is required');
|
|
150
|
-
}
|
|
151
|
-
var finlayRowKey = coverRowKey(rowIndex);
|
|
152
|
-
var rowKeyName = [props.name, (_finlayRowKey$toStrin = finlayRowKey === null || finlayRowKey === void 0 ? void 0 : finlayRowKey.toString()) !== null && _finlayRowKey$toStrin !== void 0 ? _finlayRowKey$toStrin : ''].flat(1).filter(Boolean);
|
|
153
|
-
return (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.getFieldValue(rowKeyName);
|
|
154
|
-
};
|
|
388
|
+
/**
|
|
389
|
+
* 构建表单字段路径
|
|
390
|
+
*/
|
|
391
|
+
const buildFormFieldPath = useRefFunction(rowKey => {
|
|
392
|
+
return [props.name, rowKey?.toString() ?? ''].flat(1).filter(Boolean);
|
|
393
|
+
});
|
|
155
394
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
var rowKeyName = [props.name].flat(1).filter(Boolean);
|
|
163
|
-
if (Array.isArray(rowKeyName) && rowKeyName.length === 0) {
|
|
164
|
-
var _formRef$current2;
|
|
165
|
-
var rowData = (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : _formRef$current2.getFieldsValue();
|
|
166
|
-
if (Array.isArray(rowData)) return rowData;
|
|
167
|
-
return Object.keys(rowData).map(function (key) {
|
|
168
|
-
return rowData[key];
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
return (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : _formRef$current3.getFieldValue(rowKeyName);
|
|
172
|
-
};
|
|
173
|
-
return _objectSpread(_objectSpread({}, formRef.current), {}, {
|
|
174
|
-
getRowData: getRowData,
|
|
175
|
-
getRowsData: getRowsData,
|
|
176
|
-
/**
|
|
177
|
-
* 设置一行的数据,会将数据进行简单的 merge
|
|
178
|
-
* @param rowIndex
|
|
179
|
-
* @param data
|
|
180
|
-
* @returns void
|
|
181
|
-
*/
|
|
182
|
-
setRowData: function setRowData(rowIndex, data) {
|
|
183
|
-
var _finlayRowKey$toStrin2, _formRef$current4;
|
|
184
|
-
if (rowIndex == undefined) {
|
|
185
|
-
throw new Error('rowIndex is required');
|
|
186
|
-
}
|
|
187
|
-
var finlayRowKey = coverRowKey(rowIndex);
|
|
188
|
-
var rowKeyName = [props.name, (_finlayRowKey$toStrin2 = finlayRowKey === null || finlayRowKey === void 0 ? void 0 : finlayRowKey.toString()) !== null && _finlayRowKey$toStrin2 !== void 0 ? _finlayRowKey$toStrin2 : ''].flat(1).filter(Boolean);
|
|
189
|
-
var newRowData = Object.assign({}, _objectSpread(_objectSpread({}, getRowData(rowIndex)), data || {}));
|
|
190
|
-
var updateValues = set({}, rowKeyName, newRowData);
|
|
191
|
-
(_formRef$current4 = formRef.current) === null || _formRef$current4 === void 0 || _formRef$current4.setFieldsValue(updateValues);
|
|
192
|
-
return true;
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}, [coverRowKey, props.name, formRef.current]);
|
|
196
|
-
useEffect(function () {
|
|
197
|
-
if (!props.controlled) return;
|
|
198
|
-
(value || []).forEach(function (current, index) {
|
|
199
|
-
var _formRef$current5;
|
|
200
|
-
(_formRef$current5 = formRef.current) === null || _formRef$current5 === void 0 || _formRef$current5.setFieldsValue(_defineProperty({}, "".concat(getRowKey(current, index)), current));
|
|
201
|
-
}, {});
|
|
202
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
203
|
-
}, [stringify(value), props.controlled]);
|
|
204
|
-
useEffect(function () {
|
|
205
|
-
if (props.name) {
|
|
206
|
-
var _props$editable;
|
|
207
|
-
formRef.current = props === null || props === void 0 || (_props$editable = props.editable) === null || _props$editable === void 0 ? void 0 : _props$editable.form;
|
|
395
|
+
/**
|
|
396
|
+
* 获取一行数据
|
|
397
|
+
*/
|
|
398
|
+
const getRowData = useRefFunction(rowIndex => {
|
|
399
|
+
if (rowIndex == null) {
|
|
400
|
+
throw new Error('rowIndex is required');
|
|
208
401
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
return
|
|
402
|
+
const finlayRowKey = coverRowKey(rowIndex);
|
|
403
|
+
const rowKeyName = buildFormFieldPath(finlayRowKey);
|
|
404
|
+
return formRef.current?.getFieldValue(rowKeyName);
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* 获取整个表格的数据
|
|
409
|
+
*/
|
|
410
|
+
const getRowsData = useRefFunction(() => {
|
|
411
|
+
const rowKeyName = [props.name].flat(1).filter(Boolean);
|
|
412
|
+
if (Array.isArray(rowKeyName) && rowKeyName.length === 0) {
|
|
413
|
+
const rowData = formRef.current?.getFieldsValue();
|
|
414
|
+
if (Array.isArray(rowData)) return rowData;
|
|
415
|
+
return Object.keys(rowData).map(key => rowData[key]);
|
|
222
416
|
}
|
|
223
|
-
return
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
margin: '10px 0',
|
|
233
|
-
width: '100%'
|
|
234
|
-
}, style),
|
|
235
|
-
icon: /*#__PURE__*/_jsx(PlusOutlined, {})
|
|
236
|
-
}, restButtonProps), {}, {
|
|
237
|
-
children: creatorButtonText || intl.getMessage('editableTable.action.add', '添加一行数据')
|
|
238
|
-
}))
|
|
239
|
-
});
|
|
240
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
241
|
-
}, [recordCreatorProps, maxLength, value === null || value === void 0 ? void 0 : value.length]);
|
|
242
|
-
var buttonRenderProps = useMemo(function () {
|
|
243
|
-
if (!creatorButtonDom) {
|
|
244
|
-
return {};
|
|
417
|
+
return formRef.current?.getFieldValue(rowKeyName);
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* 设置一行数据
|
|
422
|
+
*/
|
|
423
|
+
const setRowData = useRefFunction((rowIndex, data) => {
|
|
424
|
+
if (rowIndex == null) {
|
|
425
|
+
throw new Error('rowIndex is required');
|
|
245
426
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
427
|
+
const finlayRowKey = coverRowKey(rowIndex);
|
|
428
|
+
const rowKeyName = buildFormFieldPath(finlayRowKey);
|
|
429
|
+
const currentRowData = getRowData(rowIndex);
|
|
430
|
+
const newRowData = {
|
|
431
|
+
...currentRowData,
|
|
432
|
+
...(data || {})
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
// 在 name 模式下,需要更新整个数组
|
|
436
|
+
if (props.name) {
|
|
437
|
+
const tableName = [props.name].flat(1).filter(Boolean);
|
|
438
|
+
// 优先从 value prop 获取数据(受控模式),否则从表单值获取
|
|
439
|
+
let currentTableData = props.value || formRef.current?.getFieldValue(tableName);
|
|
440
|
+
if (Array.isArray(currentTableData)) {
|
|
441
|
+
// 找到要更新的行的索引
|
|
442
|
+
const rowIndexToUpdate = typeof finlayRowKey === 'number' ? finlayRowKey : currentTableData.findIndex((row, index) => {
|
|
443
|
+
const rowKey = getRowKey?.(row, index);
|
|
444
|
+
return rowKey === finlayRowKey || rowKey?.toString() === finlayRowKey?.toString();
|
|
445
|
+
});
|
|
446
|
+
if (rowIndexToUpdate >= 0 && rowIndexToUpdate < currentTableData.length) {
|
|
447
|
+
// 更新数组中的对应行
|
|
448
|
+
const updatedTableData = [...currentTableData];
|
|
449
|
+
updatedTableData[rowIndexToUpdate] = newRowData;
|
|
450
|
+
|
|
451
|
+
// 设置整个数组,使用 set 来构建正确的路径
|
|
452
|
+
// 使用与 syncFormValuesExcludingEditing 相同的路径格式(数组路径)
|
|
453
|
+
// 这样可以确保 getFieldValue 能正确获取值
|
|
454
|
+
const updateValues = set({}, tableName, updatedTableData);
|
|
455
|
+
formRef.current?.setFieldsValue(updateValues);
|
|
456
|
+
|
|
457
|
+
// 在受控模式下,触发 onChange
|
|
458
|
+
if (props.controlled && props.onChange) {
|
|
459
|
+
props.onChange(updatedTableData);
|
|
278
460
|
}
|
|
279
461
|
}
|
|
280
|
-
}
|
|
462
|
+
} else {
|
|
463
|
+
// 如果当前没有数据,直接设置单个字段
|
|
464
|
+
const updateValues = set({}, rowKeyName, newRowData);
|
|
465
|
+
formRef.current?.setFieldsValue(updateValues);
|
|
466
|
+
}
|
|
467
|
+
} else {
|
|
468
|
+
// 非 name 模式下,直接设置单个字段
|
|
469
|
+
const updateValues = set({}, rowKeyName, newRowData);
|
|
470
|
+
formRef.current?.setFieldsValue(updateValues);
|
|
281
471
|
}
|
|
472
|
+
return true;
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
// 设置 editableFormRef
|
|
476
|
+
useImperativeHandle(editableFormRef, () => {
|
|
282
477
|
return {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
478
|
+
...formRef.current,
|
|
479
|
+
getRowData,
|
|
480
|
+
getRowsData,
|
|
481
|
+
setRowData
|
|
482
|
+
};
|
|
483
|
+
}, [coverRowKey, props.name, getRowData, getRowsData, setRowData]);
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* 受控模式下同步表单值
|
|
487
|
+
* 在受控模式下,即使正在编辑的行也要同步更新,因为数据由外部完全控制
|
|
488
|
+
* 使用深度比较优化性能,避免频繁的序列化操作
|
|
489
|
+
* 注意:只有当 value 明确传递时才同步,避免覆盖表单中的初始值
|
|
490
|
+
*/
|
|
491
|
+
useDeepCompareEffect(() => {
|
|
492
|
+
if (!props.controlled || !formRef.current) return;
|
|
493
|
+
|
|
494
|
+
// 在受控模式下,只有当 value 明确传递时才同步
|
|
495
|
+
// 避免在 value 为 undefined 时覆盖表单中的初始值
|
|
496
|
+
if (value === undefined) return;
|
|
497
|
+
|
|
498
|
+
// 在受控模式下,同步所有值(包括正在编辑的行)
|
|
499
|
+
// 因为数据由外部完全控制,应该同步更新
|
|
500
|
+
try {
|
|
501
|
+
if (props.name) {
|
|
502
|
+
// name 模式:直接设置整个数组
|
|
503
|
+
const namePath = [props.name].flat(1);
|
|
504
|
+
const newValue = set({}, namePath, value);
|
|
505
|
+
formRef.current.setFieldsValue(newValue);
|
|
506
|
+
} else {
|
|
507
|
+
// 非 name 模式:直接设置值
|
|
508
|
+
const formValues = {};
|
|
509
|
+
value.forEach((item, index) => {
|
|
510
|
+
const key = getRowKey(item, index);
|
|
511
|
+
const keyStr = String(key);
|
|
512
|
+
formValues[keyStr] = item;
|
|
287
513
|
});
|
|
514
|
+
if (Object.keys(formValues).length > 0) {
|
|
515
|
+
formRef.current.setFieldsValue(formValues);
|
|
516
|
+
}
|
|
288
517
|
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
518
|
+
} catch (error) {
|
|
519
|
+
console.warn('Failed to sync form values in controlled mode:', error);
|
|
520
|
+
}
|
|
521
|
+
}, [value, props.controlled, props.name, getRowKey]);
|
|
293
522
|
|
|
294
523
|
/**
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
* >>>>>>为了性能好辛苦
|
|
524
|
+
* 同步表单实例引用
|
|
525
|
+
* 只在 name 模式下且 form 存在时更新
|
|
298
526
|
*/
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
(_props$onValuesChange = props.onValuesChange) === null || _props$onValuesChange === void 0 || _props$onValuesChange.call(props, dataSource, r);
|
|
303
|
-
if (props.controlled) {
|
|
304
|
-
var _props$onChange;
|
|
305
|
-
props === null || props === void 0 || (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, dataSource);
|
|
527
|
+
useEffect(() => {
|
|
528
|
+
if (props.name && props?.editable?.form) {
|
|
529
|
+
formRef.current = props.editable.form;
|
|
306
530
|
}
|
|
531
|
+
}, [props.editable?.form, props.name]);
|
|
532
|
+
const {
|
|
533
|
+
position
|
|
534
|
+
} = recordCreatorProps || {};
|
|
535
|
+
const isTop = position === 'top';
|
|
536
|
+
const {
|
|
537
|
+
creatorButtonDom,
|
|
538
|
+
buttonRenderProps
|
|
539
|
+
} = useCreatorButton({
|
|
540
|
+
recordCreatorProps,
|
|
541
|
+
maxLength,
|
|
542
|
+
value,
|
|
543
|
+
intl,
|
|
544
|
+
isTop,
|
|
545
|
+
columnsLength: rest.columns?.length,
|
|
546
|
+
tableViewRender: props.tableViewRender
|
|
307
547
|
});
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* 处理值变化回调
|
|
551
|
+
* 注意:受控模式下不调用 onChange,避免循环更新
|
|
552
|
+
* onChange 应该由外部控制,而不是在内部触发
|
|
553
|
+
*/
|
|
554
|
+
const handleValuesChange = useRefFunction((r, dataSource) => {
|
|
555
|
+
props.editable?.onValuesChange?.(r, dataSource);
|
|
556
|
+
props.onValuesChange?.(dataSource, r);
|
|
557
|
+
|
|
558
|
+
// 在受控模式下,当表单值变化时也应该触发 onChange
|
|
559
|
+
// 这样外部可以同步更新 value,实现真正的受控
|
|
560
|
+
if (props.controlled && props?.onChange) {
|
|
561
|
+
props.onChange(dataSource);
|
|
562
|
+
}
|
|
563
|
+
// 非受控模式下,onChange 应该在 onDataSourceChange 中触发
|
|
564
|
+
// 这样可以确保数据已经正确更新
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* 构建可编辑属性
|
|
569
|
+
* 使用 useMemo 优化性能,避免不必要的重新创建
|
|
570
|
+
*/
|
|
571
|
+
const editableProps = useMemo(() => {
|
|
572
|
+
const baseProps = {
|
|
573
|
+
...props.editable
|
|
574
|
+
};
|
|
575
|
+
const hasOnValuesChange = Boolean(props?.onValuesChange) || Boolean(props.editable?.onValuesChange) || Boolean(props.controlled && props?.onChange);
|
|
576
|
+
if (hasOnValuesChange) {
|
|
577
|
+
baseProps.onValuesChange = handleValuesChange;
|
|
578
|
+
}
|
|
579
|
+
return baseProps;
|
|
580
|
+
}, [props.editable, props.onValuesChange, props.controlled, props.onChange, handleValuesChange]);
|
|
313
581
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
314
582
|
children: [/*#__PURE__*/_jsx(EditableTableActionContext.Provider, {
|
|
315
583
|
value: actionRef,
|
|
316
|
-
children: /*#__PURE__*/_jsx(ProTable,
|
|
584
|
+
children: /*#__PURE__*/_jsx(ProTable, {
|
|
317
585
|
search: false,
|
|
318
586
|
options: false,
|
|
319
587
|
pagination: false,
|
|
320
588
|
rowKey: rowKey,
|
|
321
|
-
revalidateOnFocus: false
|
|
322
|
-
|
|
589
|
+
revalidateOnFocus: false,
|
|
590
|
+
...rest,
|
|
591
|
+
...buttonRenderProps,
|
|
323
592
|
tableLayout: "fixed",
|
|
324
593
|
actionRef: actionRef,
|
|
325
594
|
onChange: onTableChange,
|
|
326
|
-
editable:
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
595
|
+
editable: {
|
|
596
|
+
...editableProps,
|
|
597
|
+
formProps: {
|
|
598
|
+
formRef,
|
|
599
|
+
...editableProps.formProps
|
|
600
|
+
}
|
|
601
|
+
},
|
|
331
602
|
dataSource: value,
|
|
332
|
-
onDataSourceChange:
|
|
603
|
+
onDataSourceChange: dataSource => {
|
|
604
|
+
// setValue 会触发 onChange,但我们需要确保数据已经正确更新
|
|
605
|
+
// 所以先设置数据,然后手动触发 onChange
|
|
333
606
|
setValue(dataSource);
|
|
607
|
+
|
|
334
608
|
/**
|
|
335
|
-
* 如果是
|
|
609
|
+
* 如果是 name 模式,需要同步表单值
|
|
610
|
+
* 避免表单值和数据源不一致
|
|
611
|
+
* 注意:不会覆盖正在编辑的行
|
|
336
612
|
*/
|
|
337
|
-
if (props.name &&
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
613
|
+
if (props.name && formRef.current) {
|
|
614
|
+
const editingKeys = props.editable?.editableKeys;
|
|
615
|
+
const editingKeysSet = createEditingKeysSet(editingKeys);
|
|
616
|
+
const namePath = [props.name].flat(1).filter(Boolean);
|
|
617
|
+
syncFormValuesExcludingEditing(dataSource, editingKeysSet, namePath);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
// 在非受控模式下,通过 onDataSourceChange 触发 onChange
|
|
621
|
+
// 这样可以确保数据已经正确更新
|
|
622
|
+
if (!props.controlled && props.onChange) {
|
|
623
|
+
props.onChange(dataSource);
|
|
341
624
|
}
|
|
342
625
|
}
|
|
343
|
-
})
|
|
626
|
+
})
|
|
344
627
|
}), props.name ? /*#__PURE__*/_jsx(ProFormDependency, {
|
|
345
628
|
name: [props.name],
|
|
346
|
-
children:
|
|
347
|
-
|
|
629
|
+
children: changeValue => {
|
|
630
|
+
// 初始化 preData
|
|
348
631
|
if (!preData.current) {
|
|
349
632
|
preData.current = value;
|
|
350
633
|
return null;
|
|
351
634
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
635
|
+
const namePath = [props.name].flat(1);
|
|
636
|
+
const list = get(changeValue, namePath);
|
|
637
|
+
|
|
638
|
+
// 添加空值检查,避免后续操作出错
|
|
639
|
+
if (!list || !Array.isArray(list)) {
|
|
640
|
+
preData.current = value;
|
|
641
|
+
return null;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
// 在更新 preData 之前找到变化的项
|
|
645
|
+
// 使用 findIndex 可以同时获取变化的项和索引
|
|
646
|
+
const changeIndex = list.findIndex((item, index) => {
|
|
647
|
+
return !isDeepEqualReact(item, preData.current?.[index]);
|
|
356
648
|
});
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
649
|
+
|
|
650
|
+
// 只有在找到变化项时才触发回调
|
|
651
|
+
if (changeIndex !== -1) {
|
|
652
|
+
const changeItem = list[changeIndex];
|
|
653
|
+
props?.editable?.onValuesChange?.(changeItem, list);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// 在找到 changeItem 之后再更新 preData,确保后续比较正确
|
|
657
|
+
preData.current = list;
|
|
361
658
|
return null;
|
|
362
659
|
}
|
|
363
660
|
}) : null]
|
|
@@ -370,38 +667,40 @@ function EditableTable(props) {
|
|
|
370
667
|
* @param props
|
|
371
668
|
*/
|
|
372
669
|
function FieldEditableTable(props) {
|
|
373
|
-
|
|
374
|
-
if (!props.name) return /*#__PURE__*/_jsx(EditableTable,
|
|
670
|
+
const form = ProForm.useFormInstance();
|
|
671
|
+
if (!props.name) return /*#__PURE__*/_jsx(EditableTable, {
|
|
375
672
|
tableLayout: "fixed",
|
|
376
673
|
scroll: {
|
|
377
674
|
x: 'max-content'
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
|
|
675
|
+
},
|
|
676
|
+
...props
|
|
677
|
+
});
|
|
678
|
+
return /*#__PURE__*/_jsx(Form.Item, {
|
|
381
679
|
style: {
|
|
382
680
|
maxWidth: '100%'
|
|
383
681
|
},
|
|
384
|
-
shouldUpdate:
|
|
385
|
-
|
|
682
|
+
shouldUpdate: (prev, next) => {
|
|
683
|
+
const name = [props.name].flat(1);
|
|
386
684
|
try {
|
|
387
685
|
return JSON.stringify(get(prev, name)) !== JSON.stringify(get(next, name));
|
|
388
686
|
} catch (error) {
|
|
389
687
|
return true;
|
|
390
688
|
}
|
|
391
|
-
}
|
|
392
|
-
|
|
689
|
+
},
|
|
690
|
+
...props?.formItemProps,
|
|
393
691
|
name: props.name,
|
|
394
|
-
children: /*#__PURE__*/_jsx(EditableTable,
|
|
692
|
+
children: /*#__PURE__*/_jsx(EditableTable, {
|
|
395
693
|
tableLayout: "fixed",
|
|
396
694
|
scroll: {
|
|
397
695
|
x: 'max-content'
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
editable:
|
|
696
|
+
},
|
|
697
|
+
...props,
|
|
698
|
+
editable: {
|
|
699
|
+
...props.editable,
|
|
401
700
|
form: form
|
|
402
|
-
}
|
|
403
|
-
})
|
|
404
|
-
})
|
|
701
|
+
}
|
|
702
|
+
})
|
|
703
|
+
});
|
|
405
704
|
}
|
|
406
705
|
FieldEditableTable.RecordCreator = RecordCreator;
|
|
407
706
|
export default FieldEditableTable;
|