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