@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,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
@@ -11,19 +11,10 @@ exports.defaultActionRender = defaultActionRender;
|
|
|
11
11
|
exports.editableRowByKey = editableRowByKey;
|
|
12
12
|
exports.recordKeyToString = void 0;
|
|
13
13
|
exports.useEditableArray = useEditableArray;
|
|
14
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
15
|
-
var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
|
|
16
|
-
var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
|
|
17
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
18
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
19
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
20
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
21
|
-
var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
22
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
23
14
|
var _icons = require("@ant-design/icons");
|
|
24
15
|
var _util = require("@rc-component/util");
|
|
25
16
|
var _antd = require("antd");
|
|
26
|
-
var
|
|
17
|
+
var _useLazyKVMap = _interopRequireDefault(require("antd/lib/table/hooks/useLazyKVMap"));
|
|
27
18
|
var _react = _interopRequireWildcard(require("react"));
|
|
28
19
|
var _ = require("..");
|
|
29
20
|
var _provider = require("../../provider");
|
|
@@ -31,128 +22,203 @@ var _ProFormContext = require("../components/ProFormContext");
|
|
|
31
22
|
var _useDeepCompareEffect = require("../hooks/useDeepCompareEffect");
|
|
32
23
|
var _usePrevious = require("../hooks/usePrevious");
|
|
33
24
|
var _merge = require("../merge");
|
|
34
|
-
var _useMountMergeState5 = require("../useMountMergeState");
|
|
35
25
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
36
|
-
var _excluded = ["map_row_parentKey"],
|
|
37
|
-
_excluded2 = ["map_row_parentKey", "map_row_key"],
|
|
38
|
-
_excluded3 = ["map_row_key"];
|
|
39
26
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
40
|
-
|
|
27
|
+
|
|
28
|
+
const {
|
|
29
|
+
noteOnce
|
|
30
|
+
} = _util.warning;
|
|
41
31
|
|
|
42
32
|
/**
|
|
43
33
|
* 显示警告信息
|
|
44
34
|
* @param messageStr
|
|
45
35
|
*/
|
|
46
|
-
|
|
36
|
+
const warning = messageStr => {
|
|
47
37
|
return _antd.message.warning(messageStr);
|
|
48
38
|
};
|
|
49
|
-
|
|
39
|
+
const recordKeyToString = rowKey => {
|
|
50
40
|
if (Array.isArray(rowKey)) return rowKey.join(',');
|
|
51
41
|
return rowKey;
|
|
52
42
|
};
|
|
43
|
+
|
|
53
44
|
/**
|
|
54
|
-
*
|
|
45
|
+
* Normalize antd Form `NamePath` segments.
|
|
55
46
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
47
|
+
* - Preserve `0` (number) and other falsy-but-valid segments
|
|
48
|
+
* - Flatten nested arrays (e.g. `name={['a','b']}`)
|
|
49
|
+
* - Convert number segments to string to align with `spellNamePath` behavior
|
|
58
50
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
dig(record[childrenColumnName] || [], recordKey, eachIndex);
|
|
82
|
-
}
|
|
83
|
-
var newRecord = (0, _objectSpread3.default)((0, _objectSpread3.default)({}, record), {}, {
|
|
84
|
-
map_row_key: recordKey,
|
|
85
|
-
children: undefined,
|
|
86
|
-
map_row_parentKey: map_row_parentKey
|
|
87
|
-
});
|
|
88
|
-
delete newRecord.children;
|
|
89
|
-
if (!map_row_parentKey) {
|
|
90
|
-
delete newRecord.map_row_parentKey;
|
|
91
|
-
}
|
|
92
|
-
kvMap.set(recordKey, newRecord);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
if (action === 'top') {
|
|
96
|
-
kvMap.set(key, (0, _objectSpread3.default)((0, _objectSpread3.default)({}, kvMap.get(key)), row));
|
|
97
|
-
}
|
|
98
|
-
dig(data);
|
|
99
|
-
if (action === 'update') {
|
|
100
|
-
kvMap.set(key, (0, _objectSpread3.default)((0, _objectSpread3.default)({}, kvMap.get(key)), row));
|
|
101
|
-
}
|
|
102
|
-
if (action === 'delete') {
|
|
103
|
-
kvMap.delete(key);
|
|
104
|
-
}
|
|
105
|
-
var fill = function fill(map) {
|
|
106
|
-
var kvArrayMap = new Map();
|
|
107
|
-
var kvSource = [];
|
|
108
|
-
var fillNewRecord = function fillNewRecord() {
|
|
109
|
-
var fillChildren = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
110
|
-
map.forEach(function (value) {
|
|
111
|
-
if (value.map_row_parentKey && !value.map_row_key) {
|
|
112
|
-
var map_row_parentKey = value.map_row_parentKey,
|
|
113
|
-
rest = (0, _objectWithoutProperties2.default)(value, _excluded);
|
|
114
|
-
if (!kvArrayMap.has(map_row_parentKey)) {
|
|
115
|
-
kvArrayMap.set(map_row_parentKey, []);
|
|
116
|
-
}
|
|
117
|
-
if (fillChildren) {
|
|
118
|
-
var _kvArrayMap$get;
|
|
119
|
-
(_kvArrayMap$get = kvArrayMap.get(map_row_parentKey)) === null || _kvArrayMap$get === void 0 || _kvArrayMap$get.push(rest);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
});
|
|
51
|
+
exports.recordKeyToString = recordKeyToString;
|
|
52
|
+
const normalizeNamePath = (...segments) => {
|
|
53
|
+
return segments.flat(1).filter(key => key !== undefined && key !== null).map(key => typeof key === 'number' ? key.toString() : key);
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* 扁平化记录树结构为 Map
|
|
57
|
+
*/
|
|
58
|
+
function flattenRecordsToMap(records, getRowKey, childrenColumnName, parentKey, parentIndex) {
|
|
59
|
+
const kvMap = new Map();
|
|
60
|
+
records.forEach((record, index) => {
|
|
61
|
+
const eachIndex = (parentIndex || 0) * 10 + index;
|
|
62
|
+
const recordKey = getRowKey(record, eachIndex).toString();
|
|
63
|
+
const hasChildren = record && typeof record === 'object' && childrenColumnName in record;
|
|
64
|
+
if (hasChildren) {
|
|
65
|
+
const children = record[childrenColumnName] || [];
|
|
66
|
+
const childrenMap = flattenRecordsToMap(children, getRowKey, childrenColumnName, recordKey, eachIndex);
|
|
67
|
+
childrenMap.forEach((value, key) => kvMap.set(key, value));
|
|
68
|
+
}
|
|
69
|
+
const newRecord = {
|
|
70
|
+
...record,
|
|
71
|
+
map_row_key: recordKey,
|
|
72
|
+
map_row_parentKey: parentKey
|
|
123
73
|
};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
74
|
+
delete newRecord.children;
|
|
75
|
+
if (!parentKey) {
|
|
76
|
+
delete newRecord.map_row_parentKey;
|
|
77
|
+
}
|
|
78
|
+
kvMap.set(recordKey, newRecord);
|
|
79
|
+
});
|
|
80
|
+
return kvMap;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 重建树结构
|
|
85
|
+
*/
|
|
86
|
+
function rebuildTreeStructure(map, childrenColumnName, action) {
|
|
87
|
+
const childrenMap = new Map();
|
|
88
|
+
const result = [];
|
|
89
|
+
const addNewRecordToChildren = fillChildren => {
|
|
90
|
+
map.forEach(value => {
|
|
91
|
+
if (value.map_row_parentKey != null && !value.map_row_key) {
|
|
92
|
+
const {
|
|
93
|
+
map_row_parentKey,
|
|
94
|
+
...rest
|
|
95
|
+
} = value;
|
|
96
|
+
const parentKeyStr = String(map_row_parentKey);
|
|
97
|
+
if (!childrenMap.has(parentKeyStr)) {
|
|
98
|
+
childrenMap.set(parentKeyStr, []);
|
|
133
99
|
}
|
|
134
|
-
if (
|
|
135
|
-
|
|
100
|
+
if (fillChildren) {
|
|
101
|
+
childrenMap.get(parentKeyStr)?.push(rest);
|
|
136
102
|
}
|
|
137
|
-
(_kvArrayMap$get2 = kvArrayMap.get(map_row_parentKey)) === null || _kvArrayMap$get2 === void 0 || _kvArrayMap$get2.push(rest);
|
|
138
103
|
}
|
|
139
104
|
});
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
105
|
+
};
|
|
106
|
+
addNewRecordToChildren(action === 'top');
|
|
107
|
+
|
|
108
|
+
// 第一步:将所有有 parentKey 的节点添加到 childrenMap
|
|
109
|
+
// 这一步不获取 children,只是添加节点到对应的父节点下
|
|
110
|
+
map.forEach(value => {
|
|
111
|
+
if (value.map_row_parentKey != null && value.map_row_key) {
|
|
112
|
+
const {
|
|
113
|
+
map_row_parentKey,
|
|
114
|
+
map_row_key,
|
|
115
|
+
isNewRecord,
|
|
116
|
+
...rest
|
|
117
|
+
} = value;
|
|
118
|
+
const record = {
|
|
119
|
+
...rest,
|
|
120
|
+
map_row_key
|
|
121
|
+
};
|
|
122
|
+
// 确保 parentKey 的类型转换与 flattenRecordsToMap 中的 recordKey 一致
|
|
123
|
+
// 在 flattenRecordsToMap 中,recordKey 被转换为字符串:getRowKey(record, eachIndex).toString()
|
|
124
|
+
// 所以这里也需要确保 parentKey 被转换为字符串,并且类型一致
|
|
125
|
+
const parentKeyStr = map_row_parentKey != null ? String(map_row_parentKey) : null;
|
|
126
|
+
if (!parentKeyStr) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (!childrenMap.has(parentKeyStr)) {
|
|
130
|
+
childrenMap.set(parentKeyStr, []);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// 如果是新记录且 action 为 'top',添加到数组开头;否则添加到末尾
|
|
134
|
+
if (isNewRecord && action === 'top') {
|
|
135
|
+
childrenMap.get(parentKeyStr)?.unshift(record);
|
|
136
|
+
} else {
|
|
137
|
+
childrenMap.get(parentKeyStr)?.push(record);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// 第二步:为所有节点获取 children
|
|
143
|
+
// 这一步确保所有子节点都已经被添加到 childrenMap,所以可以正确获取 children
|
|
144
|
+
map.forEach(value => {
|
|
145
|
+
if (value.map_row_parentKey != null && value.map_row_key) {
|
|
146
|
+
const {
|
|
147
|
+
map_row_parentKey,
|
|
148
|
+
map_row_key
|
|
149
|
+
} = value;
|
|
150
|
+
const parentKeyStr = map_row_parentKey != null ? String(map_row_parentKey) : null;
|
|
151
|
+
if (!parentKeyStr) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const children = childrenMap.get(parentKeyStr);
|
|
155
|
+
if (children && children.length > 0) {
|
|
156
|
+
// 找到对应的 record 并添加 children
|
|
157
|
+
const recordIndex = children.findIndex(r => {
|
|
158
|
+
// 比较时需要确保类型一致
|
|
159
|
+
const recordKey = r.map_row_key || r.id;
|
|
160
|
+
return String(recordKey) === String(map_row_key);
|
|
161
|
+
});
|
|
162
|
+
if (recordIndex >= 0 && childrenMap.has(map_row_key)) {
|
|
163
|
+
children[recordIndex] = {
|
|
164
|
+
...children[recordIndex],
|
|
165
|
+
[childrenColumnName]: childrenMap.get(map_row_key)
|
|
166
|
+
};
|
|
149
167
|
}
|
|
150
|
-
kvSource.push(rest);
|
|
151
168
|
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
addNewRecordToChildren(action === 'update');
|
|
172
|
+
map.forEach(value => {
|
|
173
|
+
if (!value.map_row_parentKey) {
|
|
174
|
+
const {
|
|
175
|
+
map_row_key,
|
|
176
|
+
...rest
|
|
177
|
+
} = value;
|
|
178
|
+
const record = map_row_key && childrenMap.has(map_row_key) ? {
|
|
179
|
+
...rest,
|
|
180
|
+
[childrenColumnName]: childrenMap.get(map_row_key)
|
|
181
|
+
} : rest;
|
|
182
|
+
result.push(record);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
return result;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* 使用map 来删除数据,性能一般 但是准确率比较高
|
|
190
|
+
*/
|
|
191
|
+
function editableRowByKey(keyProps, action) {
|
|
192
|
+
const {
|
|
193
|
+
getRowKey,
|
|
194
|
+
row,
|
|
195
|
+
data,
|
|
196
|
+
childrenColumnName = 'children'
|
|
197
|
+
} = keyProps;
|
|
198
|
+
const key = recordKeyToString(keyProps.key)?.toString();
|
|
199
|
+
const kvMap = flattenRecordsToMap(data, getRowKey, childrenColumnName);
|
|
200
|
+
if (action === 'delete') {
|
|
201
|
+
kvMap.delete(key);
|
|
202
|
+
} else if (action === 'top' || action === 'update') {
|
|
203
|
+
const existingRecord = kvMap.get(key);
|
|
204
|
+
if (existingRecord) {
|
|
205
|
+
kvMap.set(key, {
|
|
206
|
+
...existingRecord,
|
|
207
|
+
...row
|
|
208
|
+
});
|
|
209
|
+
} else {
|
|
210
|
+
// 如果记录不存在,创建一个新记录(用于新增场景)
|
|
211
|
+
// 保留 map_row_parentKey 以便正确处理嵌套子节点
|
|
212
|
+
// 添加标记以便在 rebuildTreeStructure 中识别新记录
|
|
213
|
+
kvMap.set(key, {
|
|
214
|
+
...row,
|
|
215
|
+
map_row_key: key,
|
|
216
|
+
map_row_parentKey: row.map_row_parentKey,
|
|
217
|
+
isNewRecord: true
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return rebuildTreeStructure(kvMap, childrenColumnName, action);
|
|
156
222
|
}
|
|
157
223
|
|
|
158
224
|
/**
|
|
@@ -160,99 +226,83 @@ function editableRowByKey(keyProps, action) {
|
|
|
160
226
|
*
|
|
161
227
|
* @param ActionRenderConfig
|
|
162
228
|
*/
|
|
163
|
-
function SaveEditableAction(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
setLoading(false);
|
|
210
|
-
return _context.abrupt("return", res);
|
|
211
|
-
case 16:
|
|
212
|
-
_context.prev = 16;
|
|
213
|
-
_context.t0 = _context["catch"](0);
|
|
214
|
-
setLoading(false);
|
|
215
|
-
throw _context.t0;
|
|
216
|
-
case 20:
|
|
217
|
-
case "end":
|
|
218
|
-
return _context.stop();
|
|
229
|
+
function SaveEditableAction({
|
|
230
|
+
recordKey,
|
|
231
|
+
onSave,
|
|
232
|
+
row,
|
|
233
|
+
children,
|
|
234
|
+
newLineConfig,
|
|
235
|
+
editorType,
|
|
236
|
+
tableName
|
|
237
|
+
}, ref) {
|
|
238
|
+
const context = (0, _react.useContext)(_ProFormContext.ProFormContext);
|
|
239
|
+
const form = _antd.Form.useFormInstance();
|
|
240
|
+
const [loading, setLoading] = (0, _react.useState)(false);
|
|
241
|
+
const save = (0, _.useRefFunction)(async () => {
|
|
242
|
+
try {
|
|
243
|
+
const isMapEditor = editorType === 'Map';
|
|
244
|
+
// 为了兼容类型为 array 的 dataIndex,当 recordKey 是一个数组时,用于获取表单值的 key 只取第一项,
|
|
245
|
+
// 从表单中获取回来之后,再根据 namepath 获取具体的某个字段并设置
|
|
246
|
+
const namePath = normalizeNamePath(tableName, Array.isArray(recordKey) ? recordKey[0] : recordKey);
|
|
247
|
+
setLoading(true);
|
|
248
|
+
try {
|
|
249
|
+
await form.validateFields(namePath, {
|
|
250
|
+
recursive: true
|
|
251
|
+
});
|
|
252
|
+
} catch (error) {
|
|
253
|
+
setLoading(false);
|
|
254
|
+
// 重新抛出验证错误,让表单显示错误信息
|
|
255
|
+
// validateFields 抛出错误时,表单会自动设置错误状态并显示错误
|
|
256
|
+
// 错误对象包含 errorFields,表单会根据这些字段显示错误
|
|
257
|
+
// 确保错误被正确传播,这样表单可以正确显示验证错误
|
|
258
|
+
throw error;
|
|
259
|
+
}
|
|
260
|
+
const fields = (() => {
|
|
261
|
+
// `getFieldFormatValue` will unwrap object results (by returning the first value),
|
|
262
|
+
// which breaks editable row save when `namePath` points to a row object.
|
|
263
|
+
// Prefer `getFieldFormatValueObject` and then pick the row by `namePath`.
|
|
264
|
+
const formattedObject = context?.getFieldFormatValueObject?.(namePath);
|
|
265
|
+
const formattedRow = formattedObject != null ? (0, _util.get)(formattedObject, namePath) : null;
|
|
266
|
+
return formattedRow ?? form.getFieldValue(namePath);
|
|
267
|
+
})();
|
|
268
|
+
// 处理 dataIndex 为数组的情况
|
|
269
|
+
if (Array.isArray(recordKey) && recordKey.length > 1) {
|
|
270
|
+
// 获取 namepath
|
|
271
|
+
const [, ...recordKeyPath] = recordKey;
|
|
272
|
+
// 将目标值获取出来并设置到 fields 当中
|
|
273
|
+
const curValue = (0, _util.get)(fields, recordKeyPath);
|
|
274
|
+
(0, _util.set)(fields, recordKeyPath, curValue);
|
|
219
275
|
}
|
|
220
|
-
|
|
221
|
-
|
|
276
|
+
const data = isMapEditor ? (0, _util.set)({}, namePath, fields) : fields;
|
|
277
|
+
|
|
278
|
+
// 获取数据并保存
|
|
279
|
+
const res = await onSave?.(recordKey,
|
|
280
|
+
// 如果是 map 模式,fields 就是一个值,所以需要set 到对象中
|
|
281
|
+
// 数据模式 fields 是一个对象,所以不需要
|
|
282
|
+
(0, _merge.merge)({}, row, data), row, newLineConfig);
|
|
283
|
+
setLoading(false);
|
|
284
|
+
return res;
|
|
285
|
+
} catch (error) {
|
|
286
|
+
setLoading(false);
|
|
287
|
+
throw error;
|
|
288
|
+
}
|
|
289
|
+
});
|
|
222
290
|
|
|
223
291
|
// 保存数据
|
|
224
|
-
(0, _react.useImperativeHandle)(ref,
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
};
|
|
228
|
-
}, [save]);
|
|
292
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
293
|
+
save
|
|
294
|
+
}), [save]);
|
|
229
295
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("a", {
|
|
230
|
-
onClick:
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
case 5:
|
|
241
|
-
_context2.next = 9;
|
|
242
|
-
break;
|
|
243
|
-
case 7:
|
|
244
|
-
_context2.prev = 7;
|
|
245
|
-
_context2.t0 = _context2["catch"](2);
|
|
246
|
-
case 9:
|
|
247
|
-
case "end":
|
|
248
|
-
return _context2.stop();
|
|
249
|
-
}
|
|
250
|
-
}, _callee2, null, [[2, 7]]);
|
|
251
|
-
}));
|
|
252
|
-
return function (_x) {
|
|
253
|
-
return _ref3.apply(this, arguments);
|
|
254
|
-
};
|
|
255
|
-
}()),
|
|
296
|
+
onClick: async e => {
|
|
297
|
+
e.stopPropagation();
|
|
298
|
+
e.preventDefault();
|
|
299
|
+
try {
|
|
300
|
+
await save();
|
|
301
|
+
} catch {
|
|
302
|
+
// 验证错误会被 form.validateFields 抛出,这里不需要处理
|
|
303
|
+
// 错误会被表单自动显示
|
|
304
|
+
}
|
|
305
|
+
},
|
|
256
306
|
children: [loading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.LoadingOutlined, {
|
|
257
307
|
style: {
|
|
258
308
|
marginInlineEnd: 8
|
|
@@ -265,52 +315,41 @@ function SaveEditableAction(_ref, ref) {
|
|
|
265
315
|
*
|
|
266
316
|
* @param ActionRenderConfig
|
|
267
317
|
*/
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
_context3.prev = 0;
|
|
287
|
-
setLoading(true);
|
|
288
|
-
_context3.next = 4;
|
|
289
|
-
return onDelete === null || onDelete === void 0 ? void 0 : onDelete(recordKey, row);
|
|
290
|
-
case 4:
|
|
291
|
-
res = _context3.sent;
|
|
292
|
-
setLoading(false);
|
|
293
|
-
return _context3.abrupt("return", res);
|
|
294
|
-
case 9:
|
|
295
|
-
_context3.prev = 9;
|
|
296
|
-
_context3.t0 = _context3["catch"](0);
|
|
297
|
-
setLoading(false);
|
|
298
|
-
return _context3.abrupt("return", null);
|
|
299
|
-
case 13:
|
|
300
|
-
_context3.prev = 13;
|
|
301
|
-
if (preEditRowRef) preEditRowRef.current = null;
|
|
302
|
-
return _context3.finish(13);
|
|
303
|
-
case 16:
|
|
304
|
-
case "end":
|
|
305
|
-
return _context3.stop();
|
|
318
|
+
const DeleteEditableAction = ({
|
|
319
|
+
recordKey,
|
|
320
|
+
onDelete,
|
|
321
|
+
preEditRowRef,
|
|
322
|
+
preEditRowRefs,
|
|
323
|
+
row,
|
|
324
|
+
children,
|
|
325
|
+
deletePopconfirmMessage
|
|
326
|
+
}) => {
|
|
327
|
+
const [loading, setLoading] = (0, _react.useState)(false);
|
|
328
|
+
const onConfirm = (0, _.useRefFunction)(async () => {
|
|
329
|
+
try {
|
|
330
|
+
setLoading(true);
|
|
331
|
+
const res = await onDelete?.(recordKey, row);
|
|
332
|
+
setLoading(false);
|
|
333
|
+
// 如果返回 false,阻止删除操作
|
|
334
|
+
if (res === false) {
|
|
335
|
+
return false;
|
|
306
336
|
}
|
|
307
|
-
|
|
308
|
-
|
|
337
|
+
return res;
|
|
338
|
+
} catch {
|
|
339
|
+
setLoading(false);
|
|
340
|
+
return null;
|
|
341
|
+
} finally {
|
|
342
|
+
const recordKeyStr = recordKeyToString(recordKey)?.toString();
|
|
343
|
+
if (recordKeyStr) {
|
|
344
|
+
preEditRowRefs?.current?.delete(recordKeyStr);
|
|
345
|
+
}
|
|
346
|
+
if (preEditRowRef) preEditRowRef.current = null;
|
|
347
|
+
}
|
|
348
|
+
});
|
|
309
349
|
return children !== false ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Popconfirm, {
|
|
310
|
-
title: deletePopconfirmMessage,
|
|
311
|
-
onConfirm:
|
|
312
|
-
|
|
313
|
-
},
|
|
350
|
+
title: deletePopconfirmMessage || '确定要删除这条记录吗?',
|
|
351
|
+
onConfirm: onConfirm,
|
|
352
|
+
getPopupContainer: triggerNode => triggerNode.parentElement || document.body,
|
|
314
353
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("a", {
|
|
315
354
|
children: [loading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.LoadingOutlined, {
|
|
316
355
|
style: {
|
|
@@ -320,86 +359,92 @@ var DeleteEditableAction = exports.DeleteEditableAction = function DeleteEditabl
|
|
|
320
359
|
})
|
|
321
360
|
}, "delete") : null;
|
|
322
361
|
};
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
362
|
+
exports.DeleteEditableAction = DeleteEditableAction;
|
|
363
|
+
const CancelEditableAction = props => {
|
|
364
|
+
const {
|
|
365
|
+
recordKey,
|
|
366
|
+
tableName,
|
|
367
|
+
newLineConfig,
|
|
368
|
+
editorType,
|
|
369
|
+
onCancel,
|
|
370
|
+
cancelEditable,
|
|
371
|
+
row,
|
|
372
|
+
cancelText,
|
|
373
|
+
preEditRowRef,
|
|
374
|
+
preEditRowRefs
|
|
375
|
+
} = props;
|
|
376
|
+
const context = (0, _react.useContext)(_ProFormContext.ProFormContext);
|
|
377
|
+
const form = _antd.Form.useFormInstance();
|
|
335
378
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
|
|
336
|
-
onClick:
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
return _ref6.apply(this, arguments);
|
|
377
|
-
};
|
|
378
|
-
}()),
|
|
379
|
+
onClick: async e => {
|
|
380
|
+
e.stopPropagation();
|
|
381
|
+
e.preventDefault();
|
|
382
|
+
const isMapEditor = editorType === 'Map';
|
|
383
|
+
const recordKeyStr = recordKeyToString(recordKey)?.toString();
|
|
384
|
+
const namePath = normalizeNamePath(tableName, recordKey);
|
|
385
|
+
const fields = (() => {
|
|
386
|
+
const formattedObject = context?.getFieldFormatValueObject?.(namePath);
|
|
387
|
+
const formattedRow = formattedObject != null ? (0, _util.get)(formattedObject, namePath) : null;
|
|
388
|
+
return formattedRow ?? form?.getFieldValue(namePath);
|
|
389
|
+
})();
|
|
390
|
+
const record = isMapEditor ? (0, _util.set)({}, namePath, fields) : fields;
|
|
391
|
+
|
|
392
|
+
// 在清理编辑态前,先捕获“编辑前快照”(多行编辑时必须按 key 取值)
|
|
393
|
+
const cachedPreEditRow = recordKeyStr != null ? preEditRowRefs?.current?.get(recordKeyStr) : undefined;
|
|
394
|
+
const isNewLineKeyMatch = (() => {
|
|
395
|
+
const newLineKey = newLineConfig?.options?.recordKey;
|
|
396
|
+
if (newLineKey == null || recordKey == null) return false;
|
|
397
|
+
const newLineKeyStr = recordKeyToString(newLineKey)?.toString();
|
|
398
|
+
const currentKeyStr = recordKeyToString(recordKey)?.toString();
|
|
399
|
+
if (!newLineKeyStr || !currentKeyStr) return false;
|
|
400
|
+
return newLineKeyStr === currentKeyStr;
|
|
401
|
+
})();
|
|
402
|
+
const res = await onCancel?.(recordKey, record, row, newLineConfig);
|
|
403
|
+
await cancelEditable(recordKey);
|
|
404
|
+
/** 重置为默认值,不然编辑的行会丢掉 */
|
|
405
|
+
const restoreRow = cachedPreEditRow ?? preEditRowRef?.current ?? row;
|
|
406
|
+
const shouldDeleteNewRow = cachedPreEditRow === null || cachedPreEditRow === undefined && preEditRowRef?.current === null && isNewLineKeyMatch;
|
|
407
|
+
if (shouldDeleteNewRow) {
|
|
408
|
+
// 如果不存在历史值,说明是新的行,干掉他
|
|
409
|
+
await props.onDelete?.(recordKey, row);
|
|
410
|
+
} else if (restoreRow != null) {
|
|
411
|
+
form.setFieldsValue((0, _util.set)({}, namePath, restoreRow));
|
|
412
|
+
}
|
|
413
|
+
if (recordKeyStr) {
|
|
414
|
+
preEditRowRefs?.current?.delete(recordKeyStr);
|
|
415
|
+
}
|
|
416
|
+
if (preEditRowRef) preEditRowRef.current = null;
|
|
417
|
+
return res;
|
|
418
|
+
},
|
|
379
419
|
children: cancelText || '取消'
|
|
380
420
|
}, "cancel");
|
|
381
421
|
};
|
|
382
422
|
function defaultActionRender(row, config) {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
423
|
+
const {
|
|
424
|
+
recordKey,
|
|
425
|
+
newLineConfig,
|
|
426
|
+
saveText,
|
|
427
|
+
deleteText
|
|
428
|
+
} = config;
|
|
429
|
+
const SaveEditableActionRef = /*#__PURE__*/(0, _react.forwardRef)(SaveEditableAction);
|
|
430
|
+
const saveRef = /*#__PURE__*/(0, _react.createRef)();
|
|
389
431
|
return {
|
|
390
|
-
save: /*#__PURE__*/(0, _jsxRuntime.jsx)(SaveEditableActionRef,
|
|
432
|
+
save: /*#__PURE__*/(0, _jsxRuntime.jsx)(SaveEditableActionRef, {
|
|
433
|
+
...config,
|
|
391
434
|
row: row,
|
|
392
435
|
ref: saveRef,
|
|
393
436
|
children: saveText
|
|
394
|
-
}
|
|
395
|
-
saveRef
|
|
396
|
-
delete:
|
|
437
|
+
}, 'save' + recordKey),
|
|
438
|
+
saveRef,
|
|
439
|
+
delete: newLineConfig?.options.recordKey !== recordKey ? /*#__PURE__*/(0, _jsxRuntime.jsx)(DeleteEditableAction, {
|
|
440
|
+
...config,
|
|
397
441
|
row: row,
|
|
398
442
|
children: deleteText
|
|
399
|
-
}
|
|
400
|
-
cancel: /*#__PURE__*/(0, _jsxRuntime.jsx)(CancelEditableAction,
|
|
443
|
+
}, 'delete' + recordKey) : undefined,
|
|
444
|
+
cancel: /*#__PURE__*/(0, _jsxRuntime.jsx)(CancelEditableAction, {
|
|
445
|
+
...config,
|
|
401
446
|
row: row
|
|
402
|
-
}
|
|
447
|
+
}, 'cancel' + recordKey)
|
|
403
448
|
};
|
|
404
449
|
}
|
|
405
450
|
|
|
@@ -410,470 +455,516 @@ function defaultActionRender(row, config) {
|
|
|
410
455
|
*/
|
|
411
456
|
function useEditableArray(props) {
|
|
412
457
|
// Internationalization
|
|
413
|
-
|
|
458
|
+
const intl = (0, _provider.useIntl)();
|
|
414
459
|
|
|
415
460
|
/**
|
|
416
461
|
* 点击开始编辑之前的保存数据用的
|
|
417
462
|
*/
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
463
|
+
const preEditRowRef = (0, _react.useRef)(null);
|
|
464
|
+
const preEditRowRefs = (0, _react.useRef)(new Map());
|
|
465
|
+
const [newLineRecordCache, setNewLineRecordCache] = (0, _react.useState)(undefined);
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* 构建数据源 key 索引映射表
|
|
469
|
+
*/
|
|
470
|
+
const buildDataSourceKeyIndexMap = (0, _.useRefFunction)(() => {
|
|
471
|
+
const map = new Map();
|
|
472
|
+
const traverseRecords = (records, parentKey) => {
|
|
473
|
+
records?.forEach((record, index) => {
|
|
474
|
+
const indexKey = parentKey == null ? index.toString() : `${parentKey}_${index}`;
|
|
475
|
+
const recordKey = recordKeyToString(props.getRowKey(record, -1));
|
|
476
|
+
|
|
477
|
+
// 如果 recordKey 是 undefined 或 null,跳过
|
|
478
|
+
if (recordKey == null) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
map.set(indexKey, recordKey);
|
|
482
|
+
map.set(recordKey.toString(), indexKey);
|
|
483
|
+
const children = props.childrenColumnName && record?.[props.childrenColumnName];
|
|
484
|
+
if (children) {
|
|
485
|
+
traverseRecords(children, indexKey);
|
|
434
486
|
}
|
|
435
487
|
});
|
|
436
488
|
};
|
|
437
|
-
|
|
489
|
+
traverseRecords(props.dataSource);
|
|
438
490
|
return map;
|
|
439
|
-
};
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
(0, _useDeepCompareEffect.useDeepCompareEffectDebounce)(function () {
|
|
446
|
-
dataSourceKeyIndexMapRef.current = resetMapRef();
|
|
491
|
+
});
|
|
492
|
+
const initDataSourceKeyIndexMap = (0, _react.useMemo)(() => buildDataSourceKeyIndexMap(), []);
|
|
493
|
+
const dataSourceKeyIndexMapRef = (0, _react.useRef)(initDataSourceKeyIndexMap);
|
|
494
|
+
const newLineRecordRef = (0, _react.useRef)(undefined);
|
|
495
|
+
(0, _useDeepCompareEffect.useDeepCompareEffectDebounce)(() => {
|
|
496
|
+
dataSourceKeyIndexMapRef.current = buildDataSourceKeyIndexMap();
|
|
447
497
|
}, [props.dataSource]);
|
|
448
498
|
|
|
449
499
|
// 这里这么做是为了存上次的状态,不然每次存一下再拿
|
|
450
500
|
newLineRecordRef.current = newLineRecordCache;
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
}),
|
|
470
|
-
_useMergedState2 = (0, _slicedToArray2.default)(_useMergedState, 2),
|
|
471
|
-
editableKeys = _useMergedState2[0],
|
|
472
|
-
setEditableRowKeys = _useMergedState2[1];
|
|
473
|
-
|
|
474
|
-
/** 一个用来标志的set 提供了方便的 api 来去重什么的 */
|
|
475
|
-
var editableKeysSet = (0, _react.useMemo)(function () {
|
|
476
|
-
var keys = editableType === 'single' ? editableKeys === null || editableKeys === void 0 ? void 0 : editableKeys.slice(0, 1) : editableKeys;
|
|
477
|
-
return new Set(keys);
|
|
478
|
-
}, [(editableKeys || []).join(','), editableType]);
|
|
479
|
-
var editableKeysRef = (0, _usePrevious.usePrevious)(editableKeys);
|
|
501
|
+
const editableType = props.type || 'single';
|
|
502
|
+
const [getRecordByKey] = (0, _useLazyKVMap.default)(props.dataSource, 'children', props.getRowKey);
|
|
503
|
+
const [editableKeys, setEditableRowKeysInner] = (0, _util.useControlledState)([], props.editableKeys);
|
|
504
|
+
const setEditableRowKeys = (0, _react.useCallback)(updater => {
|
|
505
|
+
setEditableRowKeysInner(prev => {
|
|
506
|
+
const next = typeof updater === 'function' ? updater(prev) : updater;
|
|
507
|
+
props?.onChange?.(next?.filter(key => key !== undefined) ?? [], next?.map(key => getRecordByKey(key)).filter(k => k !== undefined) ?? []);
|
|
508
|
+
return next;
|
|
509
|
+
});
|
|
510
|
+
}, [props.onChange, getRecordByKey]);
|
|
511
|
+
const editableKeysRef = (0, _usePrevious.usePrevious)(editableKeys);
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* 检查 key 是否在编辑列表中
|
|
515
|
+
*/
|
|
516
|
+
const checkKeyInEditableList = (0, _.useRefFunction)((key, keysList) => {
|
|
517
|
+
return keysList.includes(key);
|
|
518
|
+
});
|
|
480
519
|
|
|
481
520
|
/** 这行是不是编辑状态 */
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
// 都转化为了字符串,不然 number 和 string
|
|
490
|
-
var stringEditableKeys = editableKeys === null || editableKeys === void 0 ? void 0 : editableKeys.map(function (key) {
|
|
491
|
-
return key === null || key === void 0 ? void 0 : key.toString();
|
|
492
|
-
});
|
|
493
|
-
var stringEditableKeysRef = (editableKeysRef === null || editableKeysRef === void 0 ? void 0 : editableKeysRef.map(function (key) {
|
|
494
|
-
return key === null || key === void 0 ? void 0 : key.toString();
|
|
495
|
-
})) || [];
|
|
496
|
-
var preIsEditable = props.tableName && !!(stringEditableKeysRef !== null && stringEditableKeysRef !== void 0 && stringEditableKeysRef.includes(recordKey)) || !!(stringEditableKeysRef !== null && stringEditableKeysRef !== void 0 && stringEditableKeysRef.includes(recordKeyOrIndex));
|
|
521
|
+
const isEditable = (0, _.useRefFunction)(row => {
|
|
522
|
+
const recordKeyWithIndex = props.getRowKey(row, row.index)?.toString();
|
|
523
|
+
const recordKey = props.getRowKey(row, -1)?.toString();
|
|
524
|
+
const stringEditableKeys = editableKeys?.map(key => key?.toString()) || [];
|
|
525
|
+
const stringEditableKeysRef = editableKeysRef?.map(key => key?.toString()) || [];
|
|
526
|
+
const preIsEditable = checkKeyInEditableList(recordKey, stringEditableKeysRef) || checkKeyInEditableList(recordKeyWithIndex, stringEditableKeysRef);
|
|
497
527
|
return {
|
|
498
|
-
recordKey
|
|
499
|
-
isEditable:
|
|
500
|
-
preIsEditable
|
|
528
|
+
recordKey,
|
|
529
|
+
isEditable: checkKeyInEditableList(recordKey, stringEditableKeys) || checkKeyInEditableList(recordKeyWithIndex, stringEditableKeys),
|
|
530
|
+
preIsEditable
|
|
501
531
|
};
|
|
502
532
|
});
|
|
503
533
|
|
|
504
534
|
/**
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
* @param recordKey
|
|
535
|
+
* 验证是否可以开始编辑
|
|
508
536
|
*/
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
if (editableKeysSet.size > 0 && editableType === 'single' && props.onlyOneLineEditorAlertMessage !== false) {
|
|
537
|
+
const validateCanStartEdit = (0, _.useRefFunction)(() => {
|
|
538
|
+
const hasEditableKeys = editableKeys && editableKeys.length > 0;
|
|
539
|
+
if (hasEditableKeys && editableType === 'single' && props.onlyOneLineEditorAlertMessage !== false) {
|
|
513
540
|
warning(props.onlyOneLineEditorAlertMessage || intl.getMessage('editableTable.onlyOneLineEditor', '只能同时编辑一行'));
|
|
514
541
|
return false;
|
|
515
542
|
}
|
|
516
|
-
|
|
517
|
-
|
|
543
|
+
return true;
|
|
544
|
+
});
|
|
518
545
|
|
|
519
|
-
|
|
520
|
-
|
|
546
|
+
/**
|
|
547
|
+
* 查找记录
|
|
548
|
+
*/
|
|
549
|
+
const findRecordByKey = (0, _.useRefFunction)(recordKey => {
|
|
550
|
+
return props.dataSource?.find((recordData, index) => {
|
|
521
551
|
return props.getRowKey(recordData, index) === recordKey;
|
|
522
|
-
})
|
|
552
|
+
}) ?? null;
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* 进入编辑状态
|
|
557
|
+
*/
|
|
558
|
+
const startEditable = (0, _.useRefFunction)((recordKey, record) => {
|
|
559
|
+
if (!validateCanStartEdit()) {
|
|
560
|
+
return false;
|
|
561
|
+
}
|
|
562
|
+
const isAlreadyEditable = editableKeys?.some(key => key === recordKey || key?.toString() === recordKey?.toString());
|
|
563
|
+
if (!isAlreadyEditable) {
|
|
564
|
+
const newKeys = editableKeys ? [...editableKeys, recordKey] : [recordKey];
|
|
565
|
+
setEditableRowKeys(newKeys);
|
|
566
|
+
}
|
|
567
|
+
preEditRowRef.current = record ?? findRecordByKey(recordKey) ?? null;
|
|
568
|
+
const recordKeyStr = recordKeyToString(recordKey)?.toString();
|
|
569
|
+
if (recordKeyStr) {
|
|
570
|
+
preEditRowRefs.current.set(recordKeyStr, preEditRowRef.current);
|
|
571
|
+
}
|
|
523
572
|
return true;
|
|
524
573
|
});
|
|
525
574
|
|
|
575
|
+
/**
|
|
576
|
+
* 清理编辑状态
|
|
577
|
+
*/
|
|
578
|
+
const clearEditableState = (0, _.useRefFunction)(recordKey => {
|
|
579
|
+
const relayKey = recordKeyToString(recordKey);
|
|
580
|
+
const relayKeyStr = relayKey != null ? relayKey.toString() : null;
|
|
581
|
+
if (relayKeyStr == null) {
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
const newKeys = editableKeys?.filter(key => key?.toString() !== relayKeyStr && key !== relayKey) ?? [];
|
|
585
|
+
setEditableRowKeys(newKeys);
|
|
586
|
+
});
|
|
587
|
+
|
|
526
588
|
/**
|
|
527
589
|
* 退出编辑状态
|
|
528
|
-
*
|
|
529
|
-
* @param recordKey
|
|
530
590
|
*/
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
591
|
+
const cancelEditable = (0, _.useRefFunction)(async (recordKey, needReTry) => {
|
|
592
|
+
const relayKey = recordKeyToString(recordKey);
|
|
593
|
+
const relayKeyStr = relayKey != null ? relayKey.toString() : null;
|
|
594
|
+
const mappedKey = relayKeyStr != null ? dataSourceKeyIndexMapRef.current.get(relayKeyStr) : undefined;
|
|
595
|
+
const isInEditableSet = editableKeys?.some(key => {
|
|
596
|
+
if (relayKeyStr == null) return false;
|
|
597
|
+
return key?.toString() === relayKeyStr || key === relayKey;
|
|
598
|
+
});
|
|
599
|
+
if (!isInEditableSet && mappedKey && (needReTry ?? true) && props.tableName) {
|
|
600
|
+
return await cancelEditable(mappedKey, false);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
// 如果提供了 onCancel,尝试调用它(用于测试场景)
|
|
604
|
+
// 注意:在实际使用中,onCancel 应该在 CancelEditableAction 中被调用
|
|
605
|
+
if (props.onCancel && isInEditableSet) {
|
|
606
|
+
const keyForFind = Array.isArray(recordKey) ? recordKey[0] : recordKey;
|
|
607
|
+
const record = findRecordByKey(keyForFind);
|
|
608
|
+
const originRow = preEditRowRef.current;
|
|
609
|
+
// 比较 recordKey 时需要考虑类型转换
|
|
610
|
+
// newLineRecordCache.options.recordKey 是 addEditRecord 时设置的 recordKey
|
|
611
|
+
// 而 recordKey 是 cancelEditable 的参数,需要确保它们匹配
|
|
612
|
+
const cacheRecordKey = newLineRecordCache?.options?.recordKey;
|
|
613
|
+
const cacheKey = cacheRecordKey != null ? recordKeyToString(cacheRecordKey) : null;
|
|
614
|
+
const cacheKeyStr = cacheKey != null ? cacheKey.toString() : null;
|
|
615
|
+
// 检查 newLineRecordCache 是否匹配当前的 recordKey
|
|
616
|
+
const newLineConfig = newLineRecordCache != null && cacheRecordKey != null && (cacheRecordKey === recordKey || cacheKeyStr != null && relayKeyStr != null && cacheKeyStr === relayKeyStr || cacheRecordKey?.toString() === recordKey?.toString() || String(cacheRecordKey) === String(recordKey)) ? newLineRecordCache : undefined;
|
|
617
|
+
|
|
618
|
+
// 调用 onCancel,即使找不到记录(新行编辑场景)
|
|
619
|
+
// 对于新行编辑,record 可能为 null,但 newLineConfig 应该包含 defaultValue
|
|
620
|
+
try {
|
|
621
|
+
await props.onCancel(recordKey, record || newLineConfig?.defaultValue || {}, originRow || record || newLineConfig?.defaultValue || {}, newLineConfig);
|
|
622
|
+
} catch (error) {
|
|
623
|
+
// 如果 onCancel 抛出异常,仍然继续清理状态
|
|
624
|
+
console.error('onCancel error:', error);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
// 清理 newLineRecordCache,需要比较 recordKey(考虑类型转换)
|
|
629
|
+
if (newLineRecordCache) {
|
|
630
|
+
const cacheRecordKey = newLineRecordCache.options.recordKey;
|
|
631
|
+
// 重用之前计算的 relayKeyStr
|
|
632
|
+
const cacheKeyStr = cacheRecordKey != null ? recordKeyToString(cacheRecordKey)?.toString() : null;
|
|
633
|
+
if (cacheRecordKey === recordKey || cacheKeyStr != null && relayKeyStr != null && cacheKeyStr === relayKeyStr || cacheRecordKey?.toString() === recordKey?.toString() || String(cacheRecordKey) === String(recordKey)) {
|
|
634
|
+
setNewLineRecordCache(undefined);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
// 先清理 preEditRowRef 并重置表单字段,然后再清除编辑状态
|
|
639
|
+
// 这样在清除编辑状态前,表单字段已经被清除,表格重新渲染时就不会显示输入框
|
|
640
|
+
const originRow = preEditRowRef.current;
|
|
641
|
+
if (originRow && props.getRowKey(originRow, -1) === recordKey && isInEditableSet) {
|
|
642
|
+
try {
|
|
643
|
+
// 尝试通过 formProps.formRef 访问 form
|
|
644
|
+
const formRef = props.formProps?.formRef;
|
|
645
|
+
const form = formRef?.current || props.form;
|
|
646
|
+
if (form) {
|
|
647
|
+
if (props.tableName) {
|
|
648
|
+
// name 模式:重置为原始值
|
|
649
|
+
const namePath = normalizeNamePath(props.tableName, recordKey);
|
|
650
|
+
form.setFieldsValue((0, _util.set)({}, namePath, originRow));
|
|
651
|
+
} else {
|
|
652
|
+
// 非 name 模式:清除该行的所有表单字段
|
|
653
|
+
// 在非 name 模式下,表单字段路径是 [recordKey, columnDataIndex]
|
|
654
|
+
// 如 [624748504, 'title'],需要清除所有以 recordKey 开头的字段
|
|
655
|
+
const recordKeyStr = recordKeyToString(recordKey)?.toString();
|
|
656
|
+
if (recordKeyStr) {
|
|
657
|
+
try {
|
|
658
|
+
// 在非 name 模式下,表单字段以嵌套对象的形式存储
|
|
659
|
+
// 比如 { '624748504': { 'title': 'value', 'state': 'value' } }
|
|
660
|
+
// 需要清除整个嵌套对象
|
|
661
|
+
// 先使用 resetFields 清除字段状态
|
|
662
|
+
form.resetFields([[recordKeyStr]]);
|
|
663
|
+
|
|
664
|
+
// 然后使用 setFieldsValue 清除字段值
|
|
665
|
+
// 这样可以确保字段被完全清除,表格重新渲染时不会显示输入框
|
|
666
|
+
form.setFieldsValue({
|
|
667
|
+
[recordKeyStr]: undefined
|
|
668
|
+
});
|
|
669
|
+
} catch (error) {
|
|
670
|
+
// 如果清除失败,忽略错误
|
|
671
|
+
console.warn('Failed to clear form fields in cancelEditable:', error);
|
|
672
|
+
}
|
|
550
673
|
}
|
|
551
|
-
editableKeysSet.delete(relayKey);
|
|
552
|
-
editableKeysSet.delete(recordKeyToString(recordKey));
|
|
553
|
-
setEditableRowKeys(Array.from(editableKeysSet));
|
|
554
|
-
return _context5.abrupt("return", true);
|
|
555
|
-
case 10:
|
|
556
|
-
case "end":
|
|
557
|
-
return _context5.stop();
|
|
558
|
-
}
|
|
559
|
-
}, _callee5);
|
|
560
|
-
}));
|
|
561
|
-
return function (_x3, _x4) {
|
|
562
|
-
return _ref8.apply(this, arguments);
|
|
563
|
-
};
|
|
564
|
-
}());
|
|
565
|
-
var propsOnValuesChange = (0, _.useDebounceFn)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee6() {
|
|
566
|
-
var _props$onValuesChange;
|
|
567
|
-
var _len,
|
|
568
|
-
rest,
|
|
569
|
-
_key,
|
|
570
|
-
_args6 = arguments;
|
|
571
|
-
return (0, _regeneratorRuntime2.default)().wrap(function _callee6$(_context6) {
|
|
572
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
573
|
-
case 0:
|
|
574
|
-
for (_len = _args6.length, rest = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
575
|
-
rest[_key] = _args6[_key];
|
|
576
674
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
return _context6.stop();
|
|
675
|
+
}
|
|
676
|
+
} catch (error) {
|
|
677
|
+
// 如果访问 form 失败,忽略错误
|
|
678
|
+
console.warn('Failed to reset form fields in cancelEditable:', error);
|
|
582
679
|
}
|
|
583
|
-
|
|
584
|
-
})), 64);
|
|
585
|
-
var onValuesChange = (0, _.useRefFunction)(function (value, values) {
|
|
586
|
-
var _Object$keys$pop;
|
|
587
|
-
if (!props.onValuesChange) {
|
|
588
|
-
return;
|
|
680
|
+
preEditRowRef.current = null;
|
|
589
681
|
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
682
|
+
|
|
683
|
+
// 最后清除编辑状态,这样表格会重新渲染,输入框会消失
|
|
684
|
+
clearEditableState(recordKey);
|
|
685
|
+
return true;
|
|
686
|
+
});
|
|
687
|
+
const propsOnValuesChange = (0, _.useDebounceFn)(async (...rest) => {
|
|
688
|
+
//@ts-ignore
|
|
689
|
+
props.onValuesChange?.(...rest);
|
|
690
|
+
}, 64);
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* 构建表单字段路径
|
|
694
|
+
*/
|
|
695
|
+
const buildFormFieldPath = (0, _.useRefFunction)(recordKey => {
|
|
696
|
+
return [props.tableName || '', recordKey].flat(1).filter(key => key || key === 0);
|
|
697
|
+
});
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* 更新数据源中的编辑行
|
|
701
|
+
*/
|
|
702
|
+
const updateDataSourceWithEditableRows = (0, _.useRefFunction)((dataSource, values) => {
|
|
703
|
+
let updatedDataSource = dataSource;
|
|
704
|
+
editableKeys?.forEach(eachRecordKey => {
|
|
705
|
+
if (newLineRecordCache?.options.recordKey === eachRecordKey) {
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
const recordKey = eachRecordKey.toString();
|
|
709
|
+
const fieldPath = buildFormFieldPath(recordKey);
|
|
710
|
+
const editRow = (0, _util.get)(values, fieldPath);
|
|
711
|
+
if (!editRow) {
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
updatedDataSource = editableRowByKey({
|
|
715
|
+
data: updatedDataSource,
|
|
605
716
|
getRowKey: props.getRowKey,
|
|
606
717
|
row: editRow,
|
|
607
718
|
key: recordKey,
|
|
608
719
|
childrenColumnName: props.childrenColumnName || 'children'
|
|
609
720
|
}, 'update');
|
|
610
721
|
});
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
722
|
+
return updatedDataSource;
|
|
723
|
+
});
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* 获取当前编辑的行数据
|
|
727
|
+
*/
|
|
728
|
+
const getCurrentEditRow = (0, _.useRefFunction)((value, values, dataSource) => {
|
|
729
|
+
const valueKeys = Object.keys(value || {});
|
|
730
|
+
if (valueKeys.length === 0) {
|
|
731
|
+
return newLineRecordCache?.defaultValue || {};
|
|
732
|
+
}
|
|
733
|
+
const recordKey = valueKeys.pop()?.toString() || '';
|
|
734
|
+
if (!recordKey) {
|
|
735
|
+
return newLineRecordCache?.defaultValue || {};
|
|
736
|
+
}
|
|
737
|
+
const fieldPath = buildFormFieldPath(recordKey);
|
|
738
|
+
const newLineRecordData = {
|
|
739
|
+
...newLineRecordCache?.defaultValue,
|
|
740
|
+
...(0, _util.get)(values, fieldPath)
|
|
741
|
+
};
|
|
742
|
+
const existsInDataSource = dataSourceKeyIndexMapRef.current.has(recordKeyToString(recordKey));
|
|
743
|
+
if (existsInDataSource) {
|
|
744
|
+
const foundRow = dataSource.find((item, index) => {
|
|
745
|
+
const key = props.getRowKey(item, index)?.toString();
|
|
746
|
+
return key === recordKey;
|
|
747
|
+
});
|
|
748
|
+
return foundRow || newLineRecordData;
|
|
749
|
+
}
|
|
750
|
+
return newLineRecordData;
|
|
751
|
+
});
|
|
752
|
+
const onValuesChange = (0, _.useRefFunction)((value, values) => {
|
|
753
|
+
if (!props.onValuesChange) {
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
const updatedDataSource = updateDataSourceWithEditableRows(props.dataSource, values);
|
|
757
|
+
const editRow = getCurrentEditRow(value, values, updatedDataSource);
|
|
758
|
+
propsOnValuesChange.run(editRow, updatedDataSource);
|
|
626
759
|
});
|
|
627
|
-
|
|
628
|
-
(0, _react.useEffect)(
|
|
629
|
-
|
|
630
|
-
saveRefsMap.current.forEach(
|
|
631
|
-
if (!editableKeysSet.has(key)) {
|
|
760
|
+
const saveRefsMap = (0, _react.useRef)(new Map());
|
|
761
|
+
(0, _react.useEffect)(() => {
|
|
762
|
+
const editableKeysSet = new Set(editableKeys?.map(key => key?.toString()) ?? []);
|
|
763
|
+
saveRefsMap.current.forEach((ref, key) => {
|
|
764
|
+
if (!editableKeysSet.has(key?.toString())) {
|
|
632
765
|
saveRefsMap.current.delete(key);
|
|
633
766
|
}
|
|
634
767
|
});
|
|
635
|
-
}, [
|
|
768
|
+
}, [editableKeys]);
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* 获取保存引用
|
|
772
|
+
*/
|
|
773
|
+
const getSaveRef = (0, _.useRefFunction)(recordKey => {
|
|
774
|
+
const relayKey = recordKeyToString(recordKey);
|
|
775
|
+
return saveRefsMap.current.get(relayKey) || saveRefsMap.current.get(relayKey.toString());
|
|
776
|
+
});
|
|
777
|
+
|
|
636
778
|
/**
|
|
637
779
|
* 保存编辑行
|
|
638
|
-
*
|
|
639
|
-
* @param recordKey
|
|
640
|
-
* @param needReTry
|
|
641
780
|
*/
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
return _context7.abrupt("return", _context7.sent);
|
|
659
|
-
case 6:
|
|
660
|
-
saveRef = saveRefsMap.current.get(relayKey) || saveRefsMap.current.get(relayKey.toString());
|
|
661
|
-
_context7.prev = 7;
|
|
662
|
-
_context7.next = 10;
|
|
663
|
-
return saveRef === null || saveRef === void 0 || (_saveRef$current = saveRef.current) === null || _saveRef$current === void 0 ? void 0 : _saveRef$current.save();
|
|
664
|
-
case 10:
|
|
665
|
-
_context7.next = 15;
|
|
666
|
-
break;
|
|
667
|
-
case 12:
|
|
668
|
-
_context7.prev = 12;
|
|
669
|
-
_context7.t0 = _context7["catch"](7);
|
|
670
|
-
return _context7.abrupt("return", false);
|
|
671
|
-
case 15:
|
|
672
|
-
editableKeysSet.delete(relayKey);
|
|
673
|
-
editableKeysSet.delete(relayKey.toString());
|
|
674
|
-
setEditableRowKeys(Array.from(editableKeysSet));
|
|
675
|
-
return _context7.abrupt("return", true);
|
|
676
|
-
case 19:
|
|
677
|
-
case "end":
|
|
678
|
-
return _context7.stop();
|
|
679
|
-
}
|
|
680
|
-
}, _callee7, null, [[7, 12]]);
|
|
681
|
-
}));
|
|
682
|
-
return function (_x5, _x6) {
|
|
683
|
-
return _ref10.apply(this, arguments);
|
|
684
|
-
};
|
|
685
|
-
}());
|
|
781
|
+
const saveEditable = (0, _.useRefFunction)(async (recordKey, needReTry) => {
|
|
782
|
+
const relayKey = recordKeyToString(recordKey);
|
|
783
|
+
const relayKeyStr = relayKey.toString();
|
|
784
|
+
const mappedKey = dataSourceKeyIndexMapRef.current.get(relayKeyStr);
|
|
785
|
+
const isInEditableSet = editableKeys?.some(key => key?.toString() === relayKeyStr || key === relayKey);
|
|
786
|
+
if (!isInEditableSet && mappedKey && (needReTry ?? true) && props.tableName) {
|
|
787
|
+
return await saveEditable(mappedKey, false);
|
|
788
|
+
}
|
|
789
|
+
const saveRef = getSaveRef(recordKey);
|
|
790
|
+
if (!saveRef?.current) {
|
|
791
|
+
return false;
|
|
792
|
+
}
|
|
793
|
+
await saveRef.current.save();
|
|
794
|
+
clearEditableState(recordKey);
|
|
795
|
+
return true;
|
|
796
|
+
});
|
|
686
797
|
|
|
687
798
|
/**
|
|
688
|
-
*
|
|
689
|
-
*
|
|
690
|
-
* @param row
|
|
691
|
-
* @param options
|
|
692
|
-
* @name 增加新的行
|
|
799
|
+
* 验证是否可以新增记录
|
|
693
800
|
*/
|
|
694
|
-
|
|
695
|
-
if (options
|
|
696
|
-
console.warn("can't find record by key", options
|
|
801
|
+
const validateCanAddRecord = (0, _.useRefFunction)(options => {
|
|
802
|
+
if (options?.parentKey && !dataSourceKeyIndexMapRef.current.has(recordKeyToString(options?.parentKey).toString())) {
|
|
803
|
+
console.warn("can't find record by key", options?.parentKey);
|
|
697
804
|
return false;
|
|
698
805
|
}
|
|
699
|
-
// 暂时不支持多行新增
|
|
700
806
|
if (newLineRecordRef.current && props.onlyAddOneLineAlertMessage !== false) {
|
|
701
807
|
warning(props.onlyAddOneLineAlertMessage || intl.getMessage('editableTable.onlyAddOneLine', '只能新增一行'));
|
|
702
808
|
return false;
|
|
703
809
|
}
|
|
704
|
-
|
|
705
|
-
if (editableKeysSet.size > 0 && editableType === 'single' && props.onlyOneLineEditorAlertMessage !== false) {
|
|
706
|
-
warning(props.onlyOneLineEditorAlertMessage || intl.getMessage('editableTable.onlyOneLineEditor', '只能同时编辑一行'));
|
|
810
|
+
if (!validateCanStartEdit()) {
|
|
707
811
|
return false;
|
|
708
812
|
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
813
|
+
return true;
|
|
814
|
+
});
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* 验证记录 key 是否有效
|
|
818
|
+
*/
|
|
819
|
+
const validateRecordKey = (0, _.useRefFunction)(recordKey => {
|
|
820
|
+
if (recordKey == null && recordKey !== 0 && recordKey !== '') {
|
|
821
|
+
noteOnce(false, '请设置 recordCreatorProps.record 并返回一个唯一的key \n https://procomponents.ant.design/components/editable-table#editable-%E6%96%B0%E5%BB%BA%E8%A1%8C');
|
|
713
822
|
throw new Error('请设置 recordCreatorProps.record 并返回一个唯一的key');
|
|
714
823
|
}
|
|
715
|
-
|
|
716
|
-
|
|
824
|
+
});
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* 增加新的行
|
|
828
|
+
*/
|
|
829
|
+
const addEditRecord = (0, _.useRefFunction)((row, options) => {
|
|
830
|
+
if (!validateCanAddRecord(options)) {
|
|
831
|
+
return false;
|
|
832
|
+
}
|
|
833
|
+
const recordKey = props.getRowKey(row, -1);
|
|
834
|
+
validateRecordKey(recordKey);
|
|
835
|
+
const recordKeyStr = recordKeyToString(recordKey)?.toString();
|
|
836
|
+
if (recordKeyStr) {
|
|
837
|
+
// 新建行:用 null 作为快照标记,避免多行编辑取消时误删其他行
|
|
838
|
+
preEditRowRefs.current.set(recordKeyStr, null);
|
|
839
|
+
}
|
|
840
|
+
const isAlreadyEditable = editableKeys?.some(key => key === recordKey || key?.toString() === recordKey?.toString());
|
|
841
|
+
if (!isAlreadyEditable) {
|
|
842
|
+
const newKeys = editableKeys ? [...editableKeys, recordKey] : [recordKey];
|
|
843
|
+
setEditableRowKeys(newKeys);
|
|
844
|
+
}
|
|
717
845
|
|
|
718
|
-
//
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
if (
|
|
722
|
-
|
|
723
|
-
var actionProps = {
|
|
846
|
+
// 处理 parentKey:如果是函数,调用它
|
|
847
|
+
const parentKeyValue = typeof options?.parentKey === 'function' ? options.parentKey() : options?.parentKey;
|
|
848
|
+
const isDataSourceMode = options?.newRecordType === 'dataSource' || props.tableName && options?.newRecordType !== 'cache';
|
|
849
|
+
if (isDataSourceMode) {
|
|
850
|
+
const actionProps = {
|
|
724
851
|
data: props.dataSource,
|
|
725
852
|
getRowKey: props.getRowKey,
|
|
726
|
-
row:
|
|
727
|
-
|
|
728
|
-
|
|
853
|
+
row: {
|
|
854
|
+
...row,
|
|
855
|
+
map_row_parentKey: parentKeyValue ? recordKeyToString(parentKeyValue)?.toString() : undefined
|
|
856
|
+
},
|
|
729
857
|
key: recordKey,
|
|
730
858
|
childrenColumnName: props.childrenColumnName || 'children'
|
|
731
859
|
};
|
|
732
|
-
props.setDataSource(editableRowByKey(actionProps,
|
|
860
|
+
props.setDataSource(editableRowByKey(actionProps, options?.position === 'top' ? 'top' : 'update'));
|
|
733
861
|
} else {
|
|
734
862
|
setNewLineRecordCache({
|
|
735
863
|
defaultValue: row,
|
|
736
|
-
options:
|
|
737
|
-
|
|
738
|
-
|
|
864
|
+
options: {
|
|
865
|
+
...options,
|
|
866
|
+
parentKey: parentKeyValue,
|
|
867
|
+
recordKey
|
|
868
|
+
}
|
|
739
869
|
});
|
|
740
870
|
}
|
|
741
871
|
return true;
|
|
742
872
|
});
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
return function (_x7, _x8, _x9, _x10) {
|
|
793
|
-
return _ref11.apply(this, arguments);
|
|
794
|
-
};
|
|
795
|
-
}());
|
|
796
|
-
var actionDeleteRef = (0, _.useRefFunction)( /*#__PURE__*/function () {
|
|
797
|
-
var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee9(recordKey, editRow) {
|
|
798
|
-
var _props$onDelete2;
|
|
799
|
-
var actionProps, res;
|
|
800
|
-
return (0, _regeneratorRuntime2.default)().wrap(function _callee9$(_context9) {
|
|
801
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
802
|
-
case 0:
|
|
803
|
-
actionProps = {
|
|
804
|
-
data: props.dataSource,
|
|
805
|
-
getRowKey: props.getRowKey,
|
|
806
|
-
row: editRow,
|
|
807
|
-
key: recordKey,
|
|
808
|
-
childrenColumnName: props.childrenColumnName || 'children'
|
|
809
|
-
};
|
|
810
|
-
_context9.next = 3;
|
|
811
|
-
return props === null || props === void 0 || (_props$onDelete2 = props.onDelete) === null || _props$onDelete2 === void 0 ? void 0 : _props$onDelete2.call(props, recordKey, editRow);
|
|
812
|
-
case 3:
|
|
813
|
-
res = _context9.sent;
|
|
814
|
-
_context9.next = 6;
|
|
815
|
-
return cancelEditable(recordKey, false);
|
|
816
|
-
case 6:
|
|
817
|
-
props.setDataSource(editableRowByKey(actionProps, 'delete'));
|
|
818
|
-
return _context9.abrupt("return", res);
|
|
819
|
-
case 8:
|
|
820
|
-
case "end":
|
|
821
|
-
return _context9.stop();
|
|
822
|
-
}
|
|
823
|
-
}, _callee9);
|
|
824
|
-
}));
|
|
825
|
-
return function (_x11, _x12) {
|
|
826
|
-
return _ref13.apply(this, arguments);
|
|
827
|
-
};
|
|
828
|
-
}());
|
|
829
|
-
var actionCancelRef = (0, _.useRefFunction)( /*#__PURE__*/function () {
|
|
830
|
-
var _ref14 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee10(recordKey, editRow, originRow, newLine) {
|
|
831
|
-
var _props$onCancel;
|
|
832
|
-
var res;
|
|
833
|
-
return (0, _regeneratorRuntime2.default)().wrap(function _callee10$(_context10) {
|
|
834
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
835
|
-
case 0:
|
|
836
|
-
_context10.next = 2;
|
|
837
|
-
return props === null || props === void 0 || (_props$onCancel = props.onCancel) === null || _props$onCancel === void 0 ? void 0 : _props$onCancel.call(props, recordKey, editRow, originRow, newLine);
|
|
838
|
-
case 2:
|
|
839
|
-
res = _context10.sent;
|
|
840
|
-
return _context10.abrupt("return", res);
|
|
841
|
-
case 4:
|
|
842
|
-
case "end":
|
|
843
|
-
return _context10.stop();
|
|
844
|
-
}
|
|
845
|
-
}, _callee10);
|
|
846
|
-
}));
|
|
847
|
-
return function (_x13, _x14, _x15, _x16) {
|
|
848
|
-
return _ref14.apply(this, arguments);
|
|
873
|
+
const saveText = props?.saveText || intl.getMessage('editableTable.action.save', '保存');
|
|
874
|
+
const deleteText = props?.deleteText || intl.getMessage('editableTable.action.delete', '删除');
|
|
875
|
+
const cancelText = props?.cancelText || intl.getMessage('editableTable.action.cancel', '取消');
|
|
876
|
+
const actionSaveRef = (0, _.useRefFunction)(async (recordKey, editRow, originRow, newLine) => {
|
|
877
|
+
const res = await props?.onSave?.(recordKey, editRow, originRow, newLine);
|
|
878
|
+
|
|
879
|
+
// 如果 onSave 返回 false,阻止保存:不更新 dataSource,不触发 onChange
|
|
880
|
+
if (res === false) {
|
|
881
|
+
return res;
|
|
882
|
+
}
|
|
883
|
+
const {
|
|
884
|
+
options
|
|
885
|
+
} = newLine || newLineRecordRef.current || {};
|
|
886
|
+
const isNewLine = !options?.parentKey && options?.recordKey === recordKey;
|
|
887
|
+
if (isNewLine) {
|
|
888
|
+
if (options?.position === 'top') {
|
|
889
|
+
props.setDataSource([editRow, ...props.dataSource]);
|
|
890
|
+
} else {
|
|
891
|
+
props.setDataSource([...props.dataSource, editRow]);
|
|
892
|
+
}
|
|
893
|
+
} else {
|
|
894
|
+
const actionProps = {
|
|
895
|
+
data: props.dataSource,
|
|
896
|
+
getRowKey: props.getRowKey,
|
|
897
|
+
row: options ? {
|
|
898
|
+
...editRow,
|
|
899
|
+
map_row_parentKey: recordKeyToString(options?.parentKey ?? '')?.toString()
|
|
900
|
+
} : editRow,
|
|
901
|
+
key: recordKey,
|
|
902
|
+
childrenColumnName: props.childrenColumnName || 'children'
|
|
903
|
+
};
|
|
904
|
+
props.setDataSource(editableRowByKey(actionProps, options?.position === 'top' ? 'top' : 'update'));
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
// 保存时解除编辑模式,统一在这里调用一次
|
|
908
|
+
await cancelEditable(recordKey);
|
|
909
|
+
const recordKeyStr = recordKeyToString(recordKey)?.toString();
|
|
910
|
+
if (recordKeyStr) {
|
|
911
|
+
preEditRowRefs.current.delete(recordKeyStr);
|
|
912
|
+
}
|
|
913
|
+
return res;
|
|
914
|
+
});
|
|
915
|
+
const actionDeleteRef = (0, _.useRefFunction)(async (recordKey, editRow) => {
|
|
916
|
+
const actionProps = {
|
|
917
|
+
data: props.dataSource,
|
|
918
|
+
getRowKey: props.getRowKey,
|
|
919
|
+
row: editRow,
|
|
920
|
+
key: recordKey,
|
|
921
|
+
childrenColumnName: props.childrenColumnName || 'children'
|
|
849
922
|
};
|
|
850
|
-
|
|
923
|
+
const res = await props?.onDelete?.(recordKey, editRow);
|
|
924
|
+
// 如果 onDelete 返回 false,阻止删除操作
|
|
925
|
+
if (res === false) {
|
|
926
|
+
return false;
|
|
927
|
+
}
|
|
928
|
+
// 不传递 false时,重新form.setFieldsValue同一份静态数据,会导致该行始终处于不可编辑状态
|
|
929
|
+
await cancelEditable(recordKey, false);
|
|
930
|
+
props.setDataSource(editableRowByKey(actionProps, 'delete'));
|
|
931
|
+
const recordKeyStr = recordKeyToString(recordKey)?.toString();
|
|
932
|
+
if (recordKeyStr) {
|
|
933
|
+
preEditRowRefs.current.delete(recordKeyStr);
|
|
934
|
+
}
|
|
935
|
+
return res;
|
|
936
|
+
});
|
|
937
|
+
const actionCancelRef = (0, _.useRefFunction)(async (recordKey, editRow, originRow, newLine) => {
|
|
938
|
+
const res = await props?.onCancel?.(recordKey, editRow, originRow, newLine);
|
|
939
|
+
return res;
|
|
940
|
+
});
|
|
851
941
|
|
|
852
942
|
// 如果传入了自定义的actionRender,使用useRefFunction以确保内部的事件处理函数可以访问最新的state
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
saveText
|
|
860
|
-
cancelText
|
|
861
|
-
deleteText
|
|
862
|
-
addEditRecord
|
|
943
|
+
const existCustomActionRender = props.actionRender && typeof props.actionRender === 'function';
|
|
944
|
+
const customActionRender = existCustomActionRender ? props.actionRender : () => {};
|
|
945
|
+
const customActionRenderRef = (0, _.useRefFunction)(customActionRender);
|
|
946
|
+
const actionRender = row => {
|
|
947
|
+
const key = props.getRowKey(row, row.index);
|
|
948
|
+
const config = {
|
|
949
|
+
saveText,
|
|
950
|
+
cancelText,
|
|
951
|
+
deleteText,
|
|
952
|
+
addEditRecord,
|
|
863
953
|
recordKey: key,
|
|
864
|
-
cancelEditable
|
|
954
|
+
cancelEditable,
|
|
865
955
|
index: row.index,
|
|
866
956
|
tableName: props.tableName,
|
|
867
957
|
newLineConfig: newLineRecordCache,
|
|
868
958
|
onCancel: actionCancelRef,
|
|
869
959
|
onDelete: actionDeleteRef,
|
|
870
960
|
onSave: actionSaveRef,
|
|
871
|
-
editableKeys
|
|
872
|
-
setEditableRowKeys
|
|
873
|
-
preEditRowRef
|
|
874
|
-
|
|
961
|
+
editableKeys,
|
|
962
|
+
setEditableRowKeys,
|
|
963
|
+
preEditRowRef,
|
|
964
|
+
preEditRowRefs,
|
|
965
|
+
deletePopconfirmMessage: props.deletePopconfirmMessage || `${intl.getMessage('deleteThisLine', '删除此项')}?`
|
|
875
966
|
};
|
|
876
|
-
|
|
967
|
+
const renderResult = defaultActionRender(row, config);
|
|
877
968
|
// 缓存一下saveRef
|
|
878
969
|
if (props.tableName) {
|
|
879
970
|
saveRefsMap.current.set(dataSourceKeyIndexMapRef.current.get(recordKeyToString(key)) || recordKeyToString(key), renderResult.saveRef);
|
|
@@ -888,17 +979,17 @@ function useEditableArray(props) {
|
|
|
888
979
|
return [renderResult.save, renderResult.delete, renderResult.cancel];
|
|
889
980
|
};
|
|
890
981
|
return {
|
|
891
|
-
editableKeys
|
|
892
|
-
setEditableRowKeys
|
|
893
|
-
isEditable
|
|
894
|
-
actionRender
|
|
895
|
-
startEditable
|
|
896
|
-
cancelEditable
|
|
897
|
-
addEditRecord
|
|
898
|
-
saveEditable
|
|
982
|
+
editableKeys,
|
|
983
|
+
setEditableRowKeys,
|
|
984
|
+
isEditable,
|
|
985
|
+
actionRender,
|
|
986
|
+
startEditable,
|
|
987
|
+
cancelEditable,
|
|
988
|
+
addEditRecord,
|
|
989
|
+
saveEditable,
|
|
899
990
|
newLineRecord: newLineRecordCache,
|
|
900
991
|
preEditableKeys: editableKeysRef,
|
|
901
|
-
onValuesChange
|
|
992
|
+
onValuesChange,
|
|
902
993
|
getRealIndex: props.getRealIndex
|
|
903
994
|
};
|
|
904
995
|
}
|