@ant-design/pro-components 3.1.0-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 +8 -10
- package/es/card/components/Actions/index.js +25 -25
- package/es/card/components/Actions/style.js +79 -71
- package/es/card/components/Card/index.js +157 -142
- package/es/card/components/Card/style.js +249 -192
- package/es/card/components/CheckCard/Group.js +94 -115
- package/es/card/components/CheckCard/index.js +85 -79
- package/es/card/components/CheckCard/style.js +184 -168
- package/es/card/components/Divider/index.js +19 -15
- package/es/card/components/Divider/style.js +32 -29
- package/es/card/components/Loading/index.js +19 -16
- package/es/card/components/Loading/style.js +34 -31
- package/es/card/components/Operation/index.js +16 -13
- package/es/card/components/Operation/style.js +19 -18
- package/es/card/components/Statistic/index.js +46 -41
- package/es/card/components/Statistic/style.js +89 -70
- package/es/card/components/StatisticCard/index.js +46 -41
- package/es/card/components/StatisticCard/style.js +37 -35
- 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 -2
- package/es/field/components/Cascader/index.js +65 -84
- package/es/field/components/Checkbox/index.d.ts +1 -1
- 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 +2 -2
- 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 -1
- 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 -1
- 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 -109
- package/es/field/components/Select/SearchSelect/index.js +129 -155
- package/es/field/components/Select/index.d.ts +1 -1
- package/es/field/components/Select/index.js +193 -219
- 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 -2
- package/es/field/components/TreeSelect/index.js +107 -125
- package/es/form/BaseForm/BaseForm.js +416 -502
- package/es/form/BaseForm/EditOrReadOnlyContext.js +1 -1
- package/es/form/BaseForm/LightWrapper/index.js +56 -65
- 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.js +74 -134
- 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 +32 -30
- 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 +34 -34
- 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.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.js +97 -107
- 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 +75 -86
- 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/layouts/DrawerForm/index.js +150 -241
- 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.js +52 -48
- package/es/form/layouts/LoginForm/index.js +44 -47
- package/es/form/layouts/LoginForm/style.js +71 -67
- package/es/form/layouts/LoginFormPage/index.js +45 -48
- package/es/form/layouts/LoginFormPage/style.js +136 -126
- package/es/form/layouts/ModalForm/index.js +119 -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.js +178 -203
- 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 +175 -217
- 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 +33 -38
- package/es/layout/components/AppsLogoComponents/style/default.js +2 -2
- 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.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.js +38 -37
- package/es/layout/components/FooterToolbar/style/stylish.js +11 -9
- package/es/layout/components/GlobalFooter/index.js +25 -25
- 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.js +49 -49
- package/es/layout/components/GlobalHeader/style.js +58 -54
- package/es/layout/components/GridContent/index.js +24 -19
- 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.js +49 -47
- 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.js +25 -31
- 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 +18 -16
- 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.js +82 -75
- package/es/layout/components/PageContainer/index.js +168 -149
- package/es/layout/components/PageContainer/style/index.js +95 -78
- 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.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 +137 -168
- package/es/layout/components/SettingDrawer/style/index.js +141 -137
- package/es/layout/components/SiderMenu/BaseMenu.js +235 -221
- package/es/layout/components/SiderMenu/SiderMenu.js +125 -115
- package/es/layout/components/SiderMenu/index.js +47 -42
- package/es/layout/components/SiderMenu/style/index.js +179 -161
- package/es/layout/components/SiderMenu/style/menu.js +148 -110
- 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.js +64 -63
- package/es/layout/context/RouteContext.js +1 -1
- 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.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.js +281 -213
- package/es/provider/index.js +122 -115
- package/es/provider/intl.js +53 -55
- package/es/provider/typing/layoutToken.js +26 -23
- package/es/provider/useStyle/index.js +51 -59
- 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 +526 -691
- 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.js +41 -40
- package/es/table/components/Alert/style.js +28 -27
- package/es/table/components/ColumnSetting/index.js +228 -223
- package/es/table/components/ColumnSetting/style.js +86 -71
- package/es/table/components/DragSortTable/index.js +65 -79
- 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 +295 -329
- 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.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.js +144 -112
- package/es/table/typing.d.ts +4 -0
- package/es/table/useFetchData.js +199 -338
- 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 +10 -0
- package/es/table/utils/index.js +112 -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.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.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.js +19 -16
- package/es/utils/components/InlineErrorFormItem/index.js +78 -78
- package/es/utils/components/InlineErrorFormItem/style.js +56 -49
- package/es/utils/components/LabelIconTip/index.js +30 -31
- 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 +85 -98
- 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/useEditableArray/index.d.ts +6 -1
- package/es/utils/useEditableArray/index.js +579 -735
- package/es/utils/useEditableMap/index.d.ts +1 -1
- package/es/utils/useEditableMap/index.js +89 -135
- package/es/utils/useMediaQuery/index.js +16 -18
- package/es/utils/useMediaQuery/query.js +7 -17
- package/es/version.js +1 -1
- package/lib/card/ProCard.js +8 -10
- package/lib/card/components/Actions/index.js +25 -25
- package/lib/card/components/Actions/style.js +79 -72
- package/lib/card/components/Card/index.js +154 -139
- package/lib/card/components/Card/style.js +249 -193
- package/lib/card/components/CheckCard/Group.js +97 -115
- package/lib/card/components/CheckCard/index.js +85 -78
- package/lib/card/components/CheckCard/style.js +184 -169
- package/lib/card/components/Divider/index.js +20 -16
- package/lib/card/components/Divider/style.js +32 -30
- package/lib/card/components/Loading/index.js +19 -16
- package/lib/card/components/Loading/style.js +34 -32
- package/lib/card/components/Operation/index.js +16 -14
- package/lib/card/components/Operation/style.js +19 -19
- package/lib/card/components/Statistic/index.js +46 -42
- package/lib/card/components/Statistic/style.js +89 -71
- package/lib/card/components/StatisticCard/index.js +46 -41
- package/lib/card/components/StatisticCard/style.js +37 -36
- package/lib/card/index.js +4 -4
- 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 -2
- package/lib/field/components/Cascader/index.js +65 -85
- package/lib/field/components/Checkbox/index.d.ts +1 -1
- 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 -1
- 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 -1
- 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 -110
- package/lib/field/components/Select/SearchSelect/index.js +133 -156
- package/lib/field/components/Select/index.d.ts +1 -1
- package/lib/field/components/Select/index.js +194 -218
- 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 -2
- package/lib/field/components/TreeSelect/index.js +105 -124
- package/lib/field/index.js +34 -34
- package/lib/form/BaseForm/BaseForm.js +413 -499
- package/lib/form/BaseForm/EditOrReadOnlyContext.js +1 -1
- package/lib/form/BaseForm/LightWrapper/index.js +57 -66
- 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.js +74 -135
- 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.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.js +97 -107
- 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 +73 -84
- 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.js +8 -8
- package/lib/form/layouts/DrawerForm/index.js +149 -241
- 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.js +52 -49
- package/lib/form/layouts/LoginForm/index.js +44 -48
- package/lib/form/layouts/LoginForm/style.js +71 -68
- package/lib/form/layouts/LoginFormPage/index.js +45 -49
- package/lib/form/layouts/LoginFormPage/style.js +136 -127
- package/lib/form/layouts/ModalForm/index.js +118 -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.js +177 -202
- 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 +174 -216
- 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 +36 -40
- package/lib/layout/components/AppsLogoComponents/style/default.js +4 -3
- 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.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.js +38 -38
- package/lib/layout/components/FooterToolbar/style/stylish.js +11 -10
- package/lib/layout/components/GlobalFooter/index.js +27 -27
- 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.js +49 -50
- package/lib/layout/components/GlobalHeader/style.js +58 -55
- package/lib/layout/components/GridContent/index.js +26 -21
- 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.js +49 -48
- 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.js +27 -32
- 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 +20 -18
- 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.js +82 -76
- package/lib/layout/components/PageContainer/index.js +172 -151
- package/lib/layout/components/PageContainer/style/index.js +95 -79
- 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.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 +138 -168
- package/lib/layout/components/SettingDrawer/style/index.js +141 -138
- package/lib/layout/components/SiderMenu/BaseMenu.js +235 -221
- package/lib/layout/components/SiderMenu/SiderMenu.js +128 -117
- package/lib/layout/components/SiderMenu/index.js +49 -44
- package/lib/layout/components/SiderMenu/style/index.js +179 -162
- package/lib/layout/components/SiderMenu/style/menu.js +148 -111
- 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.js +64 -64
- package/lib/layout/context/RouteContext.js +1 -1
- 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.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.js +281 -214
- package/lib/provider/index.js +128 -118
- package/lib/provider/intl.js +56 -56
- package/lib/provider/typing/layoutToken.js +28 -25
- package/lib/provider/useStyle/index.js +55 -60
- 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 +524 -689
- 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.js +41 -40
- package/lib/table/components/Alert/style.js +28 -28
- package/lib/table/components/ColumnSetting/index.js +228 -224
- package/lib/table/components/ColumnSetting/style.js +86 -72
- package/lib/table/components/DragSortTable/index.js +64 -78
- 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 +293 -327
- 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.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.js +144 -113
- package/lib/table/typing.d.ts +4 -0
- package/lib/table/useFetchData.js +197 -337
- 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 +10 -0
- package/lib/table/utils/index.js +127 -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.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.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.js +19 -17
- package/lib/utils/components/InlineErrorFormItem/index.js +80 -80
- package/lib/utils/components/InlineErrorFormItem/style.js +56 -50
- package/lib/utils/components/LabelIconTip/index.js +30 -32
- 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 +89 -99
- 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/useEditableArray/index.d.ts +6 -1
- package/lib/utils/useEditableArray/index.js +582 -735
- package/lib/utils/useEditableMap/index.d.ts +1 -1
- package/lib/utils/useEditableMap/index.js +88 -135
- package/lib/utils/useMediaQuery/index.js +19 -19
- package/lib/utils/useMediaQuery/query.js +7 -18
- package/lib/version.js +1 -1
- package/package.json +17 -28
- 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
|
@@ -6,13 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
12
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
-
var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
|
|
14
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
16
9
|
var _icons = require("@ant-design/icons");
|
|
17
10
|
var _util = require("@rc-component/util");
|
|
18
11
|
var _antd = require("antd");
|
|
@@ -23,73 +16,51 @@ var _utils = require("../../../utils");
|
|
|
23
16
|
var _useEditableArray = require("../../../utils/useEditableArray");
|
|
24
17
|
var _Table = _interopRequireDefault(require("../../Table"));
|
|
25
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
|
-
|
|
27
|
-
_excluded2 = ["onTableChange", "maxLength", "formItemProps", "recordCreatorProps", "rowKey", "controlled", "defaultValue", "onChange", "editableFormRef"];
|
|
28
|
-
var EditableTableActionContext = /*#__PURE__*/_react.default.createContext(undefined);
|
|
19
|
+
const EditableTableActionContext = /*#__PURE__*/_react.default.createContext(undefined);
|
|
29
20
|
|
|
30
21
|
/** 可编辑表格的按钮 */
|
|
31
22
|
function RecordCreator(props) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
return _context.abrupt("return");
|
|
55
|
-
case 5:
|
|
56
|
-
if (actionRef !== null && actionRef !== void 0 && actionRef.current) {
|
|
57
|
-
actionRef.current.addEditRecord(record, {
|
|
58
|
-
position: position,
|
|
59
|
-
newRecordType: newRecordType,
|
|
60
|
-
parentKey: parentKey
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
case 6:
|
|
64
|
-
case "end":
|
|
65
|
-
return _context.stop();
|
|
66
|
-
}
|
|
67
|
-
}, _callee);
|
|
68
|
-
}));
|
|
69
|
-
function onClick(_x) {
|
|
70
|
-
return _onClick.apply(this, arguments);
|
|
23
|
+
const {
|
|
24
|
+
children,
|
|
25
|
+
record,
|
|
26
|
+
position,
|
|
27
|
+
newRecordType,
|
|
28
|
+
parentKey
|
|
29
|
+
} = props;
|
|
30
|
+
const actionRef = (0, _react.useContext)(EditableTableActionContext);
|
|
31
|
+
return /*#__PURE__*/_react.default.cloneElement(children, {
|
|
32
|
+
...children.props,
|
|
33
|
+
onClick: async e => {
|
|
34
|
+
// 如果返回了false,接触掉默认行为
|
|
35
|
+
const isOk = await children.props.onClick?.(e);
|
|
36
|
+
if (isOk === false) return;
|
|
37
|
+
if (actionRef?.current) {
|
|
38
|
+
actionRef.current.addEditRecord(record, {
|
|
39
|
+
position,
|
|
40
|
+
newRecordType,
|
|
41
|
+
parentKey: parentKey
|
|
42
|
+
});
|
|
71
43
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}));
|
|
44
|
+
}
|
|
45
|
+
});
|
|
75
46
|
}
|
|
76
47
|
|
|
77
48
|
/**
|
|
78
49
|
* 处理嵌套行的新增
|
|
79
50
|
*/
|
|
80
51
|
function handleNestedRowInsert(baseData, defaultValue, newLineOptions, getRowKey, childrenColumnName) {
|
|
81
|
-
var _recordKeyToString;
|
|
82
52
|
if (!newLineOptions.recordKey) {
|
|
83
53
|
return baseData;
|
|
84
54
|
}
|
|
85
|
-
|
|
55
|
+
const actionProps = {
|
|
86
56
|
data: baseData,
|
|
87
|
-
getRowKey
|
|
88
|
-
row:
|
|
89
|
-
|
|
90
|
-
|
|
57
|
+
getRowKey,
|
|
58
|
+
row: {
|
|
59
|
+
...defaultValue,
|
|
60
|
+
map_row_parentKey: (0, _useEditableArray.recordKeyToString)(newLineOptions.parentKey)?.toString()
|
|
61
|
+
},
|
|
91
62
|
key: newLineOptions.recordKey,
|
|
92
|
-
childrenColumnName
|
|
63
|
+
childrenColumnName
|
|
93
64
|
};
|
|
94
65
|
return (0, _useEditableArray.editableRowByKey)(actionProps, newLineOptions.position === 'top' ? 'top' : 'update');
|
|
95
66
|
}
|
|
@@ -99,39 +70,42 @@ function handleNestedRowInsert(baseData, defaultValue, newLineOptions, getRowKey
|
|
|
99
70
|
*/
|
|
100
71
|
function handlePaginationInsert(baseData, defaultValue, pageConfig) {
|
|
101
72
|
if (pageConfig.pageSize > baseData.length) {
|
|
102
|
-
return [
|
|
73
|
+
return [...baseData, defaultValue];
|
|
103
74
|
}
|
|
104
|
-
|
|
105
|
-
|
|
75
|
+
const insertIndex = pageConfig.current * pageConfig.pageSize - 1;
|
|
76
|
+
const result = [...baseData];
|
|
106
77
|
result.splice(insertIndex, 0, defaultValue);
|
|
107
78
|
return result;
|
|
108
79
|
}
|
|
109
|
-
function useEditableDataSource(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
80
|
+
function useEditableDataSource({
|
|
81
|
+
actionDataSource,
|
|
82
|
+
editableUtils,
|
|
83
|
+
pagination,
|
|
84
|
+
getRowKey,
|
|
85
|
+
childrenColumnName
|
|
86
|
+
}) {
|
|
87
|
+
return (0, _react.useMemo)(() => {
|
|
88
|
+
const newLineConfig = editableUtils?.newLineRecord;
|
|
89
|
+
const baseData = Array.isArray(actionDataSource) ? [...actionDataSource] : [];
|
|
90
|
+
if (!newLineConfig?.defaultValue) {
|
|
119
91
|
return baseData;
|
|
120
92
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
93
|
+
const {
|
|
94
|
+
options: newLineOptions,
|
|
95
|
+
defaultValue
|
|
96
|
+
} = newLineConfig;
|
|
97
|
+
if (newLineOptions?.parentKey) {
|
|
124
98
|
return handleNestedRowInsert(baseData, defaultValue, newLineOptions, getRowKey, childrenColumnName || 'children');
|
|
125
99
|
}
|
|
126
|
-
if (
|
|
127
|
-
return [defaultValue
|
|
100
|
+
if (newLineOptions?.position === 'top') {
|
|
101
|
+
return [defaultValue, ...baseData];
|
|
128
102
|
}
|
|
129
|
-
|
|
130
|
-
if (pageConfig
|
|
103
|
+
const pageConfig = pagination && typeof pagination === 'object' ? pagination : undefined;
|
|
104
|
+
if (pageConfig?.current && pageConfig?.pageSize) {
|
|
131
105
|
return handlePaginationInsert(baseData, defaultValue, pageConfig);
|
|
132
106
|
}
|
|
133
|
-
return [
|
|
134
|
-
}, [actionDataSource, childrenColumnName, editableUtils
|
|
107
|
+
return [...baseData, defaultValue];
|
|
108
|
+
}, [actionDataSource, childrenColumnName, editableUtils?.newLineRecord, getRowKey, pagination]);
|
|
135
109
|
}
|
|
136
110
|
|
|
137
111
|
/**
|
|
@@ -148,29 +122,32 @@ function shouldShowCreatorButton(maxLength, valueLength, recordCreatorProps) {
|
|
|
148
122
|
* 创建按钮 DOM
|
|
149
123
|
*/
|
|
150
124
|
function createButtonDom(recordCreatorProps, value, intl) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
125
|
+
const {
|
|
126
|
+
record,
|
|
127
|
+
position,
|
|
128
|
+
creatorButtonText,
|
|
129
|
+
newRecordType,
|
|
130
|
+
parentKey,
|
|
131
|
+
style,
|
|
132
|
+
...restButtonProps
|
|
133
|
+
} = recordCreatorProps;
|
|
158
134
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(RecordCreator, {
|
|
159
|
-
record: (0, _utils.runFunction)(record, value
|
|
135
|
+
record: (0, _utils.runFunction)(record, value?.length, value) || {},
|
|
160
136
|
position: position,
|
|
161
|
-
parentKey: (0, _utils.runFunction)(parentKey, value
|
|
137
|
+
parentKey: (0, _utils.runFunction)(parentKey, value?.length, value),
|
|
162
138
|
newRecordType: newRecordType,
|
|
163
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button,
|
|
139
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
|
|
164
140
|
type: "dashed",
|
|
165
|
-
style:
|
|
141
|
+
style: {
|
|
166
142
|
display: 'block',
|
|
167
143
|
margin: '10px 0',
|
|
168
|
-
width: '100%'
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
144
|
+
width: '100%',
|
|
145
|
+
...style
|
|
146
|
+
},
|
|
147
|
+
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.PlusOutlined, {}),
|
|
148
|
+
...restButtonProps,
|
|
172
149
|
children: creatorButtonText || intl.getMessage('editableTable.action.add', '添加一行数据')
|
|
173
|
-
})
|
|
150
|
+
})
|
|
174
151
|
});
|
|
175
152
|
}
|
|
176
153
|
|
|
@@ -181,33 +158,32 @@ function createTopButtonProps(creatorButtonDom, columnsLength) {
|
|
|
181
158
|
return {
|
|
182
159
|
components: {
|
|
183
160
|
header: {
|
|
184
|
-
wrapper:
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
161
|
+
wrapper: ({
|
|
162
|
+
className,
|
|
163
|
+
children
|
|
164
|
+
}) => /*#__PURE__*/(0, _jsxRuntime.jsxs)("thead", {
|
|
165
|
+
className: className,
|
|
166
|
+
children: [children, /*#__PURE__*/(0, _jsxRuntime.jsxs)("tr", {
|
|
167
|
+
style: {
|
|
168
|
+
position: 'relative'
|
|
169
|
+
},
|
|
170
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("td", {
|
|
171
|
+
colSpan: 0,
|
|
172
|
+
style: {
|
|
173
|
+
visibility: 'hidden'
|
|
174
|
+
},
|
|
175
|
+
children: creatorButtonDom
|
|
176
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("td", {
|
|
190
177
|
style: {
|
|
191
|
-
position: '
|
|
178
|
+
position: 'absolute',
|
|
179
|
+
left: 0,
|
|
180
|
+
width: '100%'
|
|
192
181
|
},
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
style: {
|
|
196
|
-
visibility: 'hidden'
|
|
197
|
-
},
|
|
198
|
-
children: creatorButtonDom
|
|
199
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("td", {
|
|
200
|
-
style: {
|
|
201
|
-
position: 'absolute',
|
|
202
|
-
left: 0,
|
|
203
|
-
width: '100%'
|
|
204
|
-
},
|
|
205
|
-
colSpan: columnsLength,
|
|
206
|
-
children: creatorButtonDom
|
|
207
|
-
})]
|
|
182
|
+
colSpan: columnsLength,
|
|
183
|
+
children: creatorButtonDom
|
|
208
184
|
})]
|
|
209
|
-
})
|
|
210
|
-
}
|
|
185
|
+
})]
|
|
186
|
+
})
|
|
211
187
|
}
|
|
212
188
|
}
|
|
213
189
|
};
|
|
@@ -216,26 +192,24 @@ function createTopButtonProps(creatorButtonDom, columnsLength) {
|
|
|
216
192
|
/**
|
|
217
193
|
* 创建底部按钮的渲染属性
|
|
218
194
|
*/
|
|
219
|
-
function createBottomButtonProps(creatorButtonDom,
|
|
195
|
+
function createBottomButtonProps(creatorButtonDom, tableViewRender) {
|
|
220
196
|
return {
|
|
221
|
-
tableViewRender:
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
children: [(_tableViewRender2 = _tableViewRender === null || _tableViewRender === void 0 ? void 0 : _tableViewRender(_, dom)) !== null && _tableViewRender2 !== void 0 ? _tableViewRender2 : dom, creatorButtonDom]
|
|
225
|
-
});
|
|
226
|
-
}
|
|
197
|
+
tableViewRender: (_, dom) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
198
|
+
children: [tableViewRender?.(_, dom) ?? dom, creatorButtonDom]
|
|
199
|
+
})
|
|
227
200
|
};
|
|
228
201
|
}
|
|
229
|
-
function useCreatorButton(
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
202
|
+
function useCreatorButton({
|
|
203
|
+
recordCreatorProps,
|
|
204
|
+
maxLength,
|
|
205
|
+
value,
|
|
206
|
+
intl,
|
|
207
|
+
isTop,
|
|
208
|
+
columnsLength,
|
|
209
|
+
tableViewRender
|
|
210
|
+
}) {
|
|
211
|
+
const creatorButtonDom = (0, _react.useMemo)(() => {
|
|
212
|
+
if (!shouldShowCreatorButton(maxLength, value?.length || 0, recordCreatorProps)) {
|
|
239
213
|
return false;
|
|
240
214
|
}
|
|
241
215
|
if (!recordCreatorProps) {
|
|
@@ -243,16 +217,16 @@ function useCreatorButton(_ref3) {
|
|
|
243
217
|
}
|
|
244
218
|
return createButtonDom(recordCreatorProps, value, intl);
|
|
245
219
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
246
|
-
}, [maxLength, recordCreatorProps, value
|
|
247
|
-
|
|
220
|
+
}, [maxLength, recordCreatorProps, value?.length, intl]);
|
|
221
|
+
const buttonRenderProps = (0, _react.useMemo)(() => {
|
|
248
222
|
if (!creatorButtonDom) {
|
|
249
223
|
return {};
|
|
250
224
|
}
|
|
251
225
|
return isTop ? createTopButtonProps(creatorButtonDom, columnsLength) : createBottomButtonProps(creatorButtonDom, tableViewRender);
|
|
252
226
|
}, [columnsLength, creatorButtonDom, isTop, tableViewRender]);
|
|
253
227
|
return {
|
|
254
|
-
creatorButtonDom
|
|
255
|
-
buttonRenderProps
|
|
228
|
+
creatorButtonDom,
|
|
229
|
+
buttonRenderProps
|
|
256
230
|
};
|
|
257
231
|
}
|
|
258
232
|
|
|
@@ -262,30 +236,31 @@ function useCreatorButton(_ref3) {
|
|
|
262
236
|
* @param props
|
|
263
237
|
*/
|
|
264
238
|
function EditableTable(props) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
maxLength
|
|
269
|
-
formItemProps
|
|
270
|
-
recordCreatorProps
|
|
271
|
-
rowKey
|
|
272
|
-
controlled
|
|
273
|
-
defaultValue
|
|
274
|
-
onChange
|
|
275
|
-
editableFormRef
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
239
|
+
const intl = (0, _provider.useIntl)();
|
|
240
|
+
const {
|
|
241
|
+
onTableChange,
|
|
242
|
+
maxLength,
|
|
243
|
+
formItemProps,
|
|
244
|
+
recordCreatorProps,
|
|
245
|
+
rowKey,
|
|
246
|
+
controlled,
|
|
247
|
+
defaultValue,
|
|
248
|
+
onChange,
|
|
249
|
+
editableFormRef,
|
|
250
|
+
// @ts-ignore
|
|
251
|
+
autoFocus,
|
|
252
|
+
...rest
|
|
253
|
+
} = props;
|
|
254
|
+
const preData = (0, _react.useRef)(undefined);
|
|
255
|
+
const actionRef = (0, _react.useRef)();
|
|
256
|
+
const formRef = (0, _react.useRef)();
|
|
257
|
+
const form = _antd.Form.useFormInstance();
|
|
281
258
|
|
|
282
259
|
// 设置 ref
|
|
283
|
-
(0, _react.useImperativeHandle)(rest.actionRef,
|
|
284
|
-
return actionRef.current;
|
|
285
|
-
}, [actionRef.current]);
|
|
260
|
+
(0, _react.useImperativeHandle)(rest.actionRef, () => actionRef.current, [actionRef.current]);
|
|
286
261
|
|
|
287
262
|
// 在 name 模式下,如果没有传递 value prop,尝试从表单值中获取初始值
|
|
288
|
-
|
|
263
|
+
const getInitialValue = () => {
|
|
289
264
|
if (props.value) {
|
|
290
265
|
return props.value;
|
|
291
266
|
}
|
|
@@ -294,62 +269,59 @@ function EditableTable(props) {
|
|
|
294
269
|
}
|
|
295
270
|
// 如果使用了 name 且没有 value,尝试从表单获取初始值
|
|
296
271
|
if (props.name && form) {
|
|
297
|
-
|
|
298
|
-
|
|
272
|
+
const namePath = [props.name].flat(1).filter(Boolean);
|
|
273
|
+
const formValue = form.getFieldValue(namePath);
|
|
299
274
|
if (Array.isArray(formValue)) {
|
|
300
275
|
return formValue;
|
|
301
276
|
}
|
|
302
277
|
}
|
|
303
278
|
return [];
|
|
304
279
|
};
|
|
305
|
-
|
|
306
|
-
|
|
280
|
+
const [value, setValueInner] = (0, _util.useControlledState)(getInitialValue, props.value);
|
|
281
|
+
const onChangeFn = props.controlled ? props.onChange : undefined;
|
|
282
|
+
const setValue = (0, _react.useCallback)(updater => {
|
|
283
|
+
setValueInner(prev => {
|
|
284
|
+
const next = typeof updater === 'function' ? updater(prev) : updater;
|
|
307
285
|
// 在非受控模式下,onChange 应该在 onDataSourceChange 中触发
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
})
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
setValue = _useMergedState2[1];
|
|
314
|
-
var getRowKey = _react.default.useMemo(function () {
|
|
286
|
+
onChangeFn?.(next);
|
|
287
|
+
return next;
|
|
288
|
+
});
|
|
289
|
+
}, [onChangeFn]);
|
|
290
|
+
const getRowKey = _react.default.useMemo(() => {
|
|
315
291
|
if (typeof rowKey === 'function') {
|
|
316
292
|
return rowKey;
|
|
317
293
|
}
|
|
318
|
-
return
|
|
319
|
-
return record[rowKey] || index;
|
|
320
|
-
};
|
|
294
|
+
return (record, index) => record[rowKey] || index;
|
|
321
295
|
}, [rowKey]);
|
|
322
296
|
|
|
323
297
|
/**
|
|
324
298
|
* 创建编辑 keys 的 Set,用于快速查找
|
|
325
299
|
*/
|
|
326
|
-
|
|
327
|
-
return new Set((editingKeys || []).map(
|
|
328
|
-
return String(key);
|
|
329
|
-
}));
|
|
300
|
+
const createEditingKeysSet = (0, _utils.useRefFunction)(editingKeys => {
|
|
301
|
+
return new Set((editingKeys || []).map(key => String(key)));
|
|
330
302
|
});
|
|
331
303
|
|
|
332
304
|
/**
|
|
333
305
|
* 同步表单值,排除正在编辑的行
|
|
334
306
|
*/
|
|
335
|
-
|
|
307
|
+
const syncFormValuesExcludingEditing = (0, _utils.useRefFunction)((dataSource, editingKeysSet, namePath) => {
|
|
336
308
|
if (!formRef.current) return;
|
|
337
309
|
try {
|
|
338
310
|
if (namePath && namePath.length > 0) {
|
|
339
311
|
// name 模式:需要保留正在编辑的行
|
|
340
|
-
|
|
341
|
-
|
|
312
|
+
const currentFormValues = formRef.current.getFieldsValue() || {};
|
|
313
|
+
const currentList = (0, _util.get)(currentFormValues, namePath);
|
|
342
314
|
if (currentList && Array.isArray(currentList)) {
|
|
343
315
|
// 构建新的表单值,保留正在编辑的行
|
|
344
316
|
// 使用 Map 优化查找性能,将 O(n²) 降低到 O(n)
|
|
345
|
-
|
|
346
|
-
currentList.forEach(
|
|
347
|
-
|
|
317
|
+
const currentListMap = new Map();
|
|
318
|
+
currentList.forEach((item, idx) => {
|
|
319
|
+
const key = getRowKey(item, idx);
|
|
348
320
|
currentListMap.set(String(key), item);
|
|
349
321
|
});
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
322
|
+
const newList = dataSource.map((item, index) => {
|
|
323
|
+
const key = getRowKey(item, index);
|
|
324
|
+
const keyStr = String(key);
|
|
353
325
|
|
|
354
326
|
// 如果该行正在编辑,保留表单中的值
|
|
355
327
|
if (editingKeysSet.has(keyStr)) {
|
|
@@ -357,18 +329,18 @@ function EditableTable(props) {
|
|
|
357
329
|
}
|
|
358
330
|
return item;
|
|
359
331
|
});
|
|
360
|
-
|
|
332
|
+
const newValue = (0, _util.set)({}, namePath, newList);
|
|
361
333
|
formRef.current.setFieldsValue(newValue);
|
|
362
334
|
} else {
|
|
363
|
-
|
|
364
|
-
formRef.current.setFieldsValue(
|
|
335
|
+
const newValue = (0, _util.set)({}, namePath, dataSource);
|
|
336
|
+
formRef.current.setFieldsValue(newValue);
|
|
365
337
|
}
|
|
366
338
|
} else {
|
|
367
339
|
// 非 name 模式:直接设置值
|
|
368
|
-
|
|
369
|
-
dataSource.forEach(
|
|
370
|
-
|
|
371
|
-
|
|
340
|
+
const formValues = {};
|
|
341
|
+
dataSource.forEach((current, index) => {
|
|
342
|
+
const key = getRowKey(current, index);
|
|
343
|
+
const keyStr = String(key);
|
|
372
344
|
if (!editingKeysSet.has(keyStr)) {
|
|
373
345
|
formValues[keyStr] = current;
|
|
374
346
|
}
|
|
@@ -385,26 +357,23 @@ function EditableTable(props) {
|
|
|
385
357
|
/**
|
|
386
358
|
* 将数字索引转换为实际的 rowKey(非 name 模式)
|
|
387
359
|
*/
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
var dataLength = (_value$length = value === null || value === void 0 ? void 0 : value.length) !== null && _value$length !== void 0 ? _value$length : 0;
|
|
360
|
+
const convertIndexToRowKey = (0, _utils.useRefFunction)(index => {
|
|
361
|
+
const dataLength = value?.length ?? 0;
|
|
391
362
|
if (index >= dataLength) return index;
|
|
392
|
-
|
|
393
|
-
return getRowKey
|
|
363
|
+
const rowData = value?.[index];
|
|
364
|
+
return getRowKey?.(rowData, index);
|
|
394
365
|
});
|
|
395
366
|
|
|
396
367
|
/**
|
|
397
368
|
* 将 rowKey 转换为数字索引(name 模式)
|
|
398
369
|
*/
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
var dataLength = (_value$length2 = value === null || value === void 0 ? void 0 : value.length) !== null && _value$length2 !== void 0 ? _value$length2 : 0;
|
|
370
|
+
const convertRowKeyToIndex = (0, _utils.useRefFunction)(rowKey => {
|
|
371
|
+
const dataLength = value?.length ?? 0;
|
|
402
372
|
if (typeof rowKey === 'string' || rowKey >= dataLength) {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
return (getRowKey === null || getRowKey === void 0 || (_getRowKey = getRowKey(item, index)) === null || _getRowKey === void 0 ? void 0 : _getRowKey.toString()) === (rowKey === null || rowKey === void 0 ? void 0 : rowKey.toString());
|
|
373
|
+
const rowIndex = value.findIndex((item, index) => {
|
|
374
|
+
return getRowKey?.(item, index)?.toString() === rowKey?.toString();
|
|
406
375
|
});
|
|
407
|
-
if (
|
|
376
|
+
if (rowIndex !== -1) return rowIndex;
|
|
408
377
|
}
|
|
409
378
|
return rowKey;
|
|
410
379
|
});
|
|
@@ -412,7 +381,7 @@ function EditableTable(props) {
|
|
|
412
381
|
/**
|
|
413
382
|
* 根据不同的情况返回不同的 rowKey
|
|
414
383
|
*/
|
|
415
|
-
|
|
384
|
+
const coverRowKey = (0, _utils.useRefFunction)(finlayRowKey => {
|
|
416
385
|
if (typeof finlayRowKey === 'number' && !props.name) {
|
|
417
386
|
return convertIndexToRowKey(finlayRowKey);
|
|
418
387
|
}
|
|
@@ -425,76 +394,71 @@ function EditableTable(props) {
|
|
|
425
394
|
/**
|
|
426
395
|
* 构建表单字段路径
|
|
427
396
|
*/
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
return [props.name, (_rowKey$toString = rowKey === null || rowKey === void 0 ? void 0 : rowKey.toString()) !== null && _rowKey$toString !== void 0 ? _rowKey$toString : ''].flat(1).filter(Boolean);
|
|
397
|
+
const buildFormFieldPath = (0, _utils.useRefFunction)(rowKey => {
|
|
398
|
+
return [props.name, rowKey?.toString() ?? ''].flat(1).filter(Boolean);
|
|
431
399
|
});
|
|
432
400
|
|
|
433
401
|
/**
|
|
434
402
|
* 获取一行数据
|
|
435
403
|
*/
|
|
436
|
-
|
|
437
|
-
var _formRef$current;
|
|
404
|
+
const getRowData = (0, _utils.useRefFunction)(rowIndex => {
|
|
438
405
|
if (rowIndex == null) {
|
|
439
406
|
throw new Error('rowIndex is required');
|
|
440
407
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
return
|
|
408
|
+
const finlayRowKey = coverRowKey(rowIndex);
|
|
409
|
+
const rowKeyName = buildFormFieldPath(finlayRowKey);
|
|
410
|
+
return formRef.current?.getFieldValue(rowKeyName);
|
|
444
411
|
});
|
|
445
412
|
|
|
446
413
|
/**
|
|
447
414
|
* 获取整个表格的数据
|
|
448
415
|
*/
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
var rowKeyName = [props.name].flat(1).filter(Boolean);
|
|
416
|
+
const getRowsData = (0, _utils.useRefFunction)(() => {
|
|
417
|
+
const rowKeyName = [props.name].flat(1).filter(Boolean);
|
|
452
418
|
if (Array.isArray(rowKeyName) && rowKeyName.length === 0) {
|
|
453
|
-
|
|
454
|
-
var rowData = (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : _formRef$current2.getFieldsValue();
|
|
419
|
+
const rowData = formRef.current?.getFieldsValue();
|
|
455
420
|
if (Array.isArray(rowData)) return rowData;
|
|
456
|
-
return Object.keys(rowData).map(
|
|
457
|
-
return rowData[key];
|
|
458
|
-
});
|
|
421
|
+
return Object.keys(rowData).map(key => rowData[key]);
|
|
459
422
|
}
|
|
460
|
-
return
|
|
423
|
+
return formRef.current?.getFieldValue(rowKeyName);
|
|
461
424
|
});
|
|
462
425
|
|
|
463
426
|
/**
|
|
464
427
|
* 设置一行数据
|
|
465
428
|
*/
|
|
466
|
-
|
|
429
|
+
const setRowData = (0, _utils.useRefFunction)((rowIndex, data) => {
|
|
467
430
|
if (rowIndex == null) {
|
|
468
431
|
throw new Error('rowIndex is required');
|
|
469
432
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
433
|
+
const finlayRowKey = coverRowKey(rowIndex);
|
|
434
|
+
const rowKeyName = buildFormFieldPath(finlayRowKey);
|
|
435
|
+
const currentRowData = getRowData(rowIndex);
|
|
436
|
+
const newRowData = {
|
|
437
|
+
...currentRowData,
|
|
438
|
+
...(data || {})
|
|
439
|
+
};
|
|
474
440
|
|
|
475
441
|
// 在 name 模式下,需要更新整个数组
|
|
476
442
|
if (props.name) {
|
|
477
|
-
|
|
478
|
-
var tableName = [props.name].flat(1).filter(Boolean);
|
|
443
|
+
const tableName = [props.name].flat(1).filter(Boolean);
|
|
479
444
|
// 优先从 value prop 获取数据(受控模式),否则从表单值获取
|
|
480
|
-
|
|
445
|
+
let currentTableData = props.value || formRef.current?.getFieldValue(tableName);
|
|
481
446
|
if (Array.isArray(currentTableData)) {
|
|
482
447
|
// 找到要更新的行的索引
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
return rowKey === finlayRowKey ||
|
|
448
|
+
const rowIndexToUpdate = typeof finlayRowKey === 'number' ? finlayRowKey : currentTableData.findIndex((row, index) => {
|
|
449
|
+
const rowKey = getRowKey?.(row, index);
|
|
450
|
+
return rowKey === finlayRowKey || rowKey?.toString() === finlayRowKey?.toString();
|
|
486
451
|
});
|
|
487
452
|
if (rowIndexToUpdate >= 0 && rowIndexToUpdate < currentTableData.length) {
|
|
488
|
-
var _formRef$current5;
|
|
489
453
|
// 更新数组中的对应行
|
|
490
|
-
|
|
454
|
+
const updatedTableData = [...currentTableData];
|
|
491
455
|
updatedTableData[rowIndexToUpdate] = newRowData;
|
|
492
456
|
|
|
493
457
|
// 设置整个数组,使用 set 来构建正确的路径
|
|
494
458
|
// 使用与 syncFormValuesExcludingEditing 相同的路径格式(数组路径)
|
|
495
459
|
// 这样可以确保 getFieldValue 能正确获取值
|
|
496
|
-
|
|
497
|
-
|
|
460
|
+
const updateValues = (0, _util.set)({}, tableName, updatedTableData);
|
|
461
|
+
formRef.current?.setFieldsValue(updateValues);
|
|
498
462
|
|
|
499
463
|
// 在受控模式下,触发 onChange
|
|
500
464
|
if (props.controlled && props.onChange) {
|
|
@@ -502,27 +466,26 @@ function EditableTable(props) {
|
|
|
502
466
|
}
|
|
503
467
|
}
|
|
504
468
|
} else {
|
|
505
|
-
var _formRef$current6;
|
|
506
469
|
// 如果当前没有数据,直接设置单个字段
|
|
507
|
-
|
|
508
|
-
|
|
470
|
+
const updateValues = (0, _util.set)({}, rowKeyName, newRowData);
|
|
471
|
+
formRef.current?.setFieldsValue(updateValues);
|
|
509
472
|
}
|
|
510
473
|
} else {
|
|
511
|
-
var _formRef$current7;
|
|
512
474
|
// 非 name 模式下,直接设置单个字段
|
|
513
|
-
|
|
514
|
-
|
|
475
|
+
const updateValues = (0, _util.set)({}, rowKeyName, newRowData);
|
|
476
|
+
formRef.current?.setFieldsValue(updateValues);
|
|
515
477
|
}
|
|
516
478
|
return true;
|
|
517
479
|
});
|
|
518
480
|
|
|
519
481
|
// 设置 editableFormRef
|
|
520
|
-
(0, _react.useImperativeHandle)(editableFormRef,
|
|
521
|
-
return
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
482
|
+
(0, _react.useImperativeHandle)(editableFormRef, () => {
|
|
483
|
+
return {
|
|
484
|
+
...formRef.current,
|
|
485
|
+
getRowData,
|
|
486
|
+
getRowsData,
|
|
487
|
+
setRowData
|
|
488
|
+
};
|
|
526
489
|
}, [coverRowKey, props.name, getRowData, getRowsData, setRowData]);
|
|
527
490
|
|
|
528
491
|
/**
|
|
@@ -531,7 +494,7 @@ function EditableTable(props) {
|
|
|
531
494
|
* 使用深度比较优化性能,避免频繁的序列化操作
|
|
532
495
|
* 注意:只有当 value 明确传递时才同步,避免覆盖表单中的初始值
|
|
533
496
|
*/
|
|
534
|
-
(0, _utils.useDeepCompareEffect)(
|
|
497
|
+
(0, _utils.useDeepCompareEffect)(() => {
|
|
535
498
|
if (!props.controlled || !formRef.current) return;
|
|
536
499
|
|
|
537
500
|
// 在受控模式下,只有当 value 明确传递时才同步
|
|
@@ -543,15 +506,15 @@ function EditableTable(props) {
|
|
|
543
506
|
try {
|
|
544
507
|
if (props.name) {
|
|
545
508
|
// name 模式:直接设置整个数组
|
|
546
|
-
|
|
547
|
-
|
|
509
|
+
const namePath = [props.name].flat(1);
|
|
510
|
+
const newValue = (0, _util.set)({}, namePath, value);
|
|
548
511
|
formRef.current.setFieldsValue(newValue);
|
|
549
512
|
} else {
|
|
550
513
|
// 非 name 模式:直接设置值
|
|
551
|
-
|
|
552
|
-
value.forEach(
|
|
553
|
-
|
|
554
|
-
|
|
514
|
+
const formValues = {};
|
|
515
|
+
value.forEach((item, index) => {
|
|
516
|
+
const key = getRowKey(item, index);
|
|
517
|
+
const keyStr = String(key);
|
|
555
518
|
formValues[keyStr] = item;
|
|
556
519
|
});
|
|
557
520
|
if (Object.keys(formValues).length > 0) {
|
|
@@ -567,40 +530,40 @@ function EditableTable(props) {
|
|
|
567
530
|
* 同步表单实例引用
|
|
568
531
|
* 只在 name 模式下且 form 存在时更新
|
|
569
532
|
*/
|
|
570
|
-
(0, _react.useEffect)(
|
|
571
|
-
|
|
572
|
-
if (props.name && props !== null && props !== void 0 && (_props$editable = props.editable) !== null && _props$editable !== void 0 && _props$editable.form) {
|
|
533
|
+
(0, _react.useEffect)(() => {
|
|
534
|
+
if (props.name && props?.editable?.form) {
|
|
573
535
|
formRef.current = props.editable.form;
|
|
574
536
|
}
|
|
575
|
-
}, [
|
|
576
|
-
|
|
577
|
-
position
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
537
|
+
}, [props.editable?.form, props.name]);
|
|
538
|
+
const {
|
|
539
|
+
position
|
|
540
|
+
} = recordCreatorProps || {};
|
|
541
|
+
const isTop = position === 'top';
|
|
542
|
+
const {
|
|
543
|
+
creatorButtonDom,
|
|
544
|
+
buttonRenderProps
|
|
545
|
+
} = useCreatorButton({
|
|
546
|
+
recordCreatorProps,
|
|
547
|
+
maxLength,
|
|
548
|
+
value,
|
|
549
|
+
intl,
|
|
550
|
+
isTop,
|
|
551
|
+
columnsLength: rest.columns?.length,
|
|
552
|
+
tableViewRender: props.tableViewRender
|
|
553
|
+
});
|
|
590
554
|
|
|
591
555
|
/**
|
|
592
556
|
* 处理值变化回调
|
|
593
557
|
* 注意:受控模式下不调用 onChange,避免循环更新
|
|
594
558
|
* onChange 应该由外部控制,而不是在内部触发
|
|
595
559
|
*/
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
(_props$onValuesChange = props.onValuesChange) === null || _props$onValuesChange === void 0 || _props$onValuesChange.call(props, dataSource, r);
|
|
560
|
+
const handleValuesChange = (0, _utils.useRefFunction)((r, dataSource) => {
|
|
561
|
+
props.editable?.onValuesChange?.(r, dataSource);
|
|
562
|
+
props.onValuesChange?.(dataSource, r);
|
|
600
563
|
|
|
601
564
|
// 在受控模式下,当表单值变化时也应该触发 onChange
|
|
602
565
|
// 这样外部可以同步更新 value,实现真正的受控
|
|
603
|
-
if (props.controlled && props
|
|
566
|
+
if (props.controlled && props?.onChange) {
|
|
604
567
|
props.onChange(dataSource);
|
|
605
568
|
}
|
|
606
569
|
// 非受控模式下,onChange 应该在 onDataSourceChange 中触发
|
|
@@ -611,10 +574,11 @@ function EditableTable(props) {
|
|
|
611
574
|
* 构建可编辑属性
|
|
612
575
|
* 使用 useMemo 优化性能,避免不必要的重新创建
|
|
613
576
|
*/
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
577
|
+
const editableProps = (0, _react.useMemo)(() => {
|
|
578
|
+
const baseProps = {
|
|
579
|
+
...props.editable
|
|
580
|
+
};
|
|
581
|
+
const hasOnValuesChange = Boolean(props?.onValuesChange) || Boolean(props.editable?.onValuesChange) || Boolean(props.controlled && props?.onChange);
|
|
618
582
|
if (hasOnValuesChange) {
|
|
619
583
|
baseProps.onValuesChange = handleValuesChange;
|
|
620
584
|
}
|
|
@@ -623,23 +587,26 @@ function EditableTable(props) {
|
|
|
623
587
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
624
588
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(EditableTableActionContext.Provider, {
|
|
625
589
|
value: actionRef,
|
|
626
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.default,
|
|
590
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Table.default, {
|
|
627
591
|
search: false,
|
|
628
592
|
options: false,
|
|
629
593
|
pagination: false,
|
|
630
594
|
rowKey: rowKey,
|
|
631
|
-
revalidateOnFocus: false
|
|
632
|
-
|
|
595
|
+
revalidateOnFocus: false,
|
|
596
|
+
...rest,
|
|
597
|
+
...buttonRenderProps,
|
|
633
598
|
tableLayout: "fixed",
|
|
634
599
|
actionRef: actionRef,
|
|
635
600
|
onChange: onTableChange,
|
|
636
|
-
editable:
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
601
|
+
editable: {
|
|
602
|
+
...editableProps,
|
|
603
|
+
formProps: {
|
|
604
|
+
formRef,
|
|
605
|
+
...editableProps.formProps
|
|
606
|
+
}
|
|
607
|
+
},
|
|
641
608
|
dataSource: value,
|
|
642
|
-
onDataSourceChange:
|
|
609
|
+
onDataSourceChange: dataSource => {
|
|
643
610
|
// setValue 会触发 onChange,但我们需要确保数据已经正确更新
|
|
644
611
|
// 所以先设置数据,然后手动触发 onChange
|
|
645
612
|
setValue(dataSource);
|
|
@@ -650,10 +617,9 @@ function EditableTable(props) {
|
|
|
650
617
|
* 注意:不会覆盖正在编辑的行
|
|
651
618
|
*/
|
|
652
619
|
if (props.name && formRef.current) {
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
var namePath = [props.name].flat(1).filter(Boolean);
|
|
620
|
+
const editingKeys = props.editable?.editableKeys;
|
|
621
|
+
const editingKeysSet = createEditingKeysSet(editingKeys);
|
|
622
|
+
const namePath = [props.name].flat(1).filter(Boolean);
|
|
657
623
|
syncFormValuesExcludingEditing(dataSource, editingKeysSet, namePath);
|
|
658
624
|
}
|
|
659
625
|
|
|
@@ -663,17 +629,17 @@ function EditableTable(props) {
|
|
|
663
629
|
props.onChange(dataSource);
|
|
664
630
|
}
|
|
665
631
|
}
|
|
666
|
-
})
|
|
632
|
+
})
|
|
667
633
|
}), props.name ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_form.ProFormDependency, {
|
|
668
634
|
name: [props.name],
|
|
669
|
-
children:
|
|
635
|
+
children: changeValue => {
|
|
670
636
|
// 初始化 preData
|
|
671
637
|
if (!preData.current) {
|
|
672
638
|
preData.current = value;
|
|
673
639
|
return null;
|
|
674
640
|
}
|
|
675
|
-
|
|
676
|
-
|
|
641
|
+
const namePath = [props.name].flat(1);
|
|
642
|
+
const list = (0, _util.get)(changeValue, namePath);
|
|
677
643
|
|
|
678
644
|
// 添加空值检查,避免后续操作出错
|
|
679
645
|
if (!list || !Array.isArray(list)) {
|
|
@@ -683,20 +649,18 @@ function EditableTable(props) {
|
|
|
683
649
|
|
|
684
650
|
// 在更新 preData 之前找到变化的项
|
|
685
651
|
// 使用 findIndex 可以同时获取变化的项和索引
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
return !(0, _utils.isDeepEqualReact)(item, (_preData$current = preData.current) === null || _preData$current === void 0 ? void 0 : _preData$current[index]);
|
|
652
|
+
const changeIndex = list.findIndex((item, index) => {
|
|
653
|
+
return !(0, _utils.isDeepEqualReact)(item, preData.current?.[index]);
|
|
689
654
|
});
|
|
690
655
|
|
|
691
656
|
// 只有在找到变化项时才触发回调
|
|
692
657
|
if (changeIndex !== -1) {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
props === null || props === void 0 || (_props$editable6 = props.editable) === null || _props$editable6 === void 0 || (_props$editable6$onVa = _props$editable6.onValuesChange) === null || _props$editable6$onVa === void 0 || _props$editable6$onVa.call(_props$editable6, changeItem, list);
|
|
658
|
+
const changeItem = list[changeIndex];
|
|
659
|
+
props?.editable?.onValuesChange?.(changeItem, list);
|
|
696
660
|
}
|
|
697
661
|
|
|
698
662
|
// 在找到 changeItem 之后再更新 preData,确保后续比较正确
|
|
699
|
-
preData.current =
|
|
663
|
+
preData.current = list;
|
|
700
664
|
return null;
|
|
701
665
|
}
|
|
702
666
|
}) : null]
|
|
@@ -709,38 +673,40 @@ function EditableTable(props) {
|
|
|
709
673
|
* @param props
|
|
710
674
|
*/
|
|
711
675
|
function FieldEditableTable(props) {
|
|
712
|
-
|
|
713
|
-
if (!props.name) return /*#__PURE__*/(0, _jsxRuntime.jsx)(EditableTable,
|
|
676
|
+
const form = _form.default.useFormInstance();
|
|
677
|
+
if (!props.name) return /*#__PURE__*/(0, _jsxRuntime.jsx)(EditableTable, {
|
|
714
678
|
tableLayout: "fixed",
|
|
715
679
|
scroll: {
|
|
716
680
|
x: 'max-content'
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
|
|
681
|
+
},
|
|
682
|
+
...props
|
|
683
|
+
});
|
|
684
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Form.Item, {
|
|
720
685
|
style: {
|
|
721
686
|
maxWidth: '100%'
|
|
722
687
|
},
|
|
723
|
-
shouldUpdate:
|
|
724
|
-
|
|
688
|
+
shouldUpdate: (prev, next) => {
|
|
689
|
+
const name = [props.name].flat(1);
|
|
725
690
|
try {
|
|
726
691
|
return JSON.stringify((0, _util.get)(prev, name)) !== JSON.stringify((0, _util.get)(next, name));
|
|
727
692
|
} catch (error) {
|
|
728
693
|
return true;
|
|
729
694
|
}
|
|
730
|
-
}
|
|
731
|
-
|
|
695
|
+
},
|
|
696
|
+
...props?.formItemProps,
|
|
732
697
|
name: props.name,
|
|
733
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(EditableTable,
|
|
698
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(EditableTable, {
|
|
734
699
|
tableLayout: "fixed",
|
|
735
700
|
scroll: {
|
|
736
701
|
x: 'max-content'
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
editable:
|
|
702
|
+
},
|
|
703
|
+
...props,
|
|
704
|
+
editable: {
|
|
705
|
+
...props.editable,
|
|
740
706
|
form: form
|
|
741
|
-
}
|
|
742
|
-
})
|
|
743
|
-
})
|
|
707
|
+
}
|
|
708
|
+
})
|
|
709
|
+
});
|
|
744
710
|
}
|
|
745
711
|
FieldEditableTable.RecordCreator = RecordCreator;
|
|
746
712
|
var _default = exports.default = FieldEditableTable;
|