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