@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
package/es/table/Table.js
CHANGED
|
@@ -1,183 +1,156 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
5
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
6
|
-
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
7
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
8
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
9
|
-
var _excluded = ["rowKey", "tableClassName", "defaultClassName", "action", "tableColumn", "type", "pagination", "rowSelection", "size", "defaultSize", "tableStyle", "toolbarDom", "hideToolbar", "searchNode", "style", "cardProps", "alertDom", "name", "onSortChange", "onFilterChange", "options", "isLightFilter", "className", "cardBordered", "editableUtils", "getRowKey", "tableRef"],
|
|
10
|
-
_excluded2 = ["cardBordered", "request", "className", "params", "defaultData", "headerTitle", "postData", "ghost", "pagination", "actionRef", "columns", "toolBarRender", "optionsRender", "onLoad", "onRequestError", "style", "cardProps", "tableStyle", "tableClassName", "options", "search", "name", "onLoadingChange", "rowSelection", "beforeSearchSubmit", "tableAlertRender", "defaultClassName", "formRef", "type", "columnEmptyText", "toolbar", "rowKey", "manualRequest", "polling", "tooltip", "revalidateOnFocus", "searchFormRender"];
|
|
1
|
+
import { useControlledState } from '@rc-component/util';
|
|
11
2
|
import { ConfigProvider, Table } from 'antd';
|
|
12
|
-
import
|
|
3
|
+
import { clsx } from 'clsx';
|
|
13
4
|
import isEmpty from 'lodash-es/isEmpty';
|
|
14
5
|
import isEqual from 'lodash-es/isEqual';
|
|
15
|
-
import React, {
|
|
6
|
+
import React, { useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
16
7
|
import ProCard from "../card";
|
|
17
8
|
import ValueTypeToComponent from "../field/ValueTypeToComponent";
|
|
18
9
|
import ProForm, { GridContext } from "../form";
|
|
19
10
|
import ProConfigContext, { ProConfigProvider, proTheme, useIntl } from "../provider";
|
|
20
|
-
import {
|
|
11
|
+
import { editableRowByKey, ErrorBoundary, omitUndefined, recordKeyToString, stringify, useDeepCompareEffect, useDeepCompareEffectDebounce, useEditableArray, useRefFunction } from "../utils";
|
|
21
12
|
import Alert from "./components/Alert";
|
|
22
|
-
import FormRender from "./components/Form";
|
|
23
|
-
import Toolbar from "./components/ToolBar";
|
|
24
13
|
import { Container, TableContext } from "./Store/Provide";
|
|
25
14
|
import { useStyle } from "./style";
|
|
15
|
+
import { TableSearch } from "./TableSearch";
|
|
16
|
+
import { TableToolbar } from "./TableToolbar";
|
|
26
17
|
import useFetchData from "./useFetchData";
|
|
27
18
|
import { flattenColumns, genColumnKey, getServerFilterResult, getServerSorterResult, isBordered, mergePagination, parseServerDefaultColumnConfig, useActionType } from "./utils";
|
|
28
19
|
import { columnSort } from "./utils/columnSort";
|
|
29
20
|
import { genProColumnToColumn } from "./utils/genProColumnToColumn";
|
|
21
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
30
22
|
import { createElement as _createElement } from "react";
|
|
31
23
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
32
24
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
var insertIndex = pageConfig.current * pageConfig.pageSize - 1;
|
|
73
|
-
baseData.splice(insertIndex, 0, defaultValue);
|
|
25
|
+
function getEditableDataSource({
|
|
26
|
+
dataSource,
|
|
27
|
+
editableUtils,
|
|
28
|
+
pagination,
|
|
29
|
+
getRowKey,
|
|
30
|
+
childrenColumnName
|
|
31
|
+
}) {
|
|
32
|
+
const baseData = Array.isArray(dataSource) ? [...dataSource] : [];
|
|
33
|
+
const newLineConfig = editableUtils?.newLineRecord;
|
|
34
|
+
const defaultValue = newLineConfig?.defaultValue;
|
|
35
|
+
if (!newLineConfig || !defaultValue) {
|
|
36
|
+
return baseData;
|
|
37
|
+
}
|
|
38
|
+
const {
|
|
39
|
+
options: newLineOptions
|
|
40
|
+
} = newLineConfig;
|
|
41
|
+
const childrenName = childrenColumnName || 'children';
|
|
42
|
+
if (newLineOptions?.parentKey) {
|
|
43
|
+
const newRow = {
|
|
44
|
+
...defaultValue,
|
|
45
|
+
map_row_parentKey: recordKeyToString(newLineOptions.parentKey)?.toString()
|
|
46
|
+
};
|
|
47
|
+
const actionProps = {
|
|
48
|
+
data: baseData,
|
|
49
|
+
getRowKey,
|
|
50
|
+
row: newRow,
|
|
51
|
+
key: newLineOptions?.recordKey ?? getRowKey(newRow, -1),
|
|
52
|
+
childrenColumnName: childrenName
|
|
53
|
+
};
|
|
54
|
+
return editableRowByKey(actionProps, newLineOptions?.position === 'top' ? 'top' : 'update');
|
|
55
|
+
}
|
|
56
|
+
if (newLineOptions?.position === 'top') {
|
|
57
|
+
return [defaultValue, ...baseData];
|
|
58
|
+
}
|
|
59
|
+
const pageConfig = pagination && typeof pagination === 'object' ? pagination : undefined;
|
|
60
|
+
if (pageConfig?.current && pageConfig?.pageSize) {
|
|
61
|
+
if (pageConfig.pageSize > baseData.length) {
|
|
62
|
+
baseData.push(defaultValue);
|
|
74
63
|
return baseData;
|
|
75
64
|
}
|
|
76
|
-
|
|
65
|
+
const insertIndex = pageConfig.current * pageConfig.pageSize - 1;
|
|
66
|
+
baseData.splice(insertIndex, 0, defaultValue);
|
|
77
67
|
return baseData;
|
|
78
|
-
}
|
|
68
|
+
}
|
|
69
|
+
baseData.push(defaultValue);
|
|
70
|
+
return baseData;
|
|
79
71
|
}
|
|
80
|
-
function
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
if (toolbarDom) {
|
|
97
|
-
return {
|
|
98
|
-
paddingBlockStart: 0
|
|
99
|
-
};
|
|
100
|
-
}
|
|
72
|
+
function getTableCardBodyStyle({
|
|
73
|
+
propsCardProps,
|
|
74
|
+
notNeedCardDom,
|
|
75
|
+
name,
|
|
76
|
+
hideToolbar,
|
|
77
|
+
toolbarDom
|
|
78
|
+
}) {
|
|
79
|
+
// cardProps === false 或存在 name 的场景不需要额外 padding 处理
|
|
80
|
+
if (propsCardProps === false || notNeedCardDom || !!name) {
|
|
81
|
+
return {};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// 显式隐藏 toolbar 时,统一不留 padding(避免误用 paddingBlockStart)
|
|
85
|
+
if (hideToolbar) {
|
|
101
86
|
return {
|
|
102
87
|
padding: 0
|
|
103
88
|
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (editable && !name) {
|
|
116
|
-
var _editable$formProps;
|
|
117
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
118
|
-
children: [toolbarDom, alertDom, /*#__PURE__*/_createElement(ProForm, _objectSpread(_objectSpread({}, editable.formProps), {}, {
|
|
119
|
-
formRef: (_editable$formProps = editable.formProps) === null || _editable$formProps === void 0 ? void 0 : _editable$formProps.formRef,
|
|
120
|
-
component: false,
|
|
121
|
-
form: editable.form,
|
|
122
|
-
onValuesChange: editableOnValuesChange,
|
|
123
|
-
key: "table",
|
|
124
|
-
submitter: false,
|
|
125
|
-
omitNil: false,
|
|
126
|
-
dateFormatter: dateFormatter
|
|
127
|
-
}), tableDom)]
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
131
|
-
children: [toolbarDom, alertDom, tableDom]
|
|
132
|
-
});
|
|
133
|
-
}, [alertDom, dateFormatter, editable, editableOnValuesChange, name, tableDom, toolbarDom]);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// 有 toolbar 的场景,需要让 ProCard body 顶部与 toolbar 对齐
|
|
92
|
+
if (toolbarDom) {
|
|
93
|
+
return {
|
|
94
|
+
paddingBlockStart: 0
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
padding: 0
|
|
99
|
+
};
|
|
134
100
|
}
|
|
135
|
-
function useRowKey(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
101
|
+
function useRowKey({
|
|
102
|
+
rowKey,
|
|
103
|
+
name
|
|
104
|
+
}) {
|
|
105
|
+
return useMemo(() => {
|
|
139
106
|
if (typeof rowKey === 'function') {
|
|
140
107
|
return rowKey;
|
|
141
108
|
}
|
|
142
|
-
return
|
|
143
|
-
var _ref5;
|
|
109
|
+
return (record, index) => {
|
|
144
110
|
if (index === -1) {
|
|
145
|
-
return record
|
|
111
|
+
return record?.[rowKey];
|
|
146
112
|
}
|
|
147
113
|
if (name) {
|
|
148
|
-
return index
|
|
114
|
+
return index?.toString();
|
|
149
115
|
}
|
|
150
|
-
return
|
|
116
|
+
return record?.[rowKey] ?? index?.toString();
|
|
151
117
|
};
|
|
152
118
|
}, [name, rowKey]);
|
|
153
119
|
}
|
|
154
|
-
function useMergedPagination(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
120
|
+
function useMergedPagination({
|
|
121
|
+
propsPagination,
|
|
122
|
+
action,
|
|
123
|
+
intl,
|
|
124
|
+
request,
|
|
125
|
+
type
|
|
126
|
+
}) {
|
|
127
|
+
return useMemo(() => {
|
|
128
|
+
const newPropsPagination = propsPagination === false ? false : {
|
|
129
|
+
...(propsPagination || {})
|
|
130
|
+
};
|
|
131
|
+
const pageConfig = {
|
|
132
|
+
...action.pageInfo,
|
|
133
|
+
setPageInfo: ({
|
|
134
|
+
pageSize,
|
|
135
|
+
current
|
|
136
|
+
}) => {
|
|
137
|
+
const {
|
|
138
|
+
pageInfo
|
|
139
|
+
} = action;
|
|
167
140
|
if (pageSize === pageInfo.pageSize || pageInfo.current === 1) {
|
|
168
141
|
action.setPageInfo({
|
|
169
|
-
pageSize
|
|
170
|
-
current
|
|
142
|
+
pageSize,
|
|
143
|
+
current
|
|
171
144
|
});
|
|
172
145
|
return;
|
|
173
146
|
}
|
|
174
147
|
if (request) action.setDataSource([]);
|
|
175
148
|
action.setPageInfo({
|
|
176
|
-
pageSize
|
|
149
|
+
pageSize,
|
|
177
150
|
current: type === 'list' ? current : 1
|
|
178
151
|
});
|
|
179
152
|
}
|
|
180
|
-
}
|
|
153
|
+
};
|
|
181
154
|
if (request && newPropsPagination) {
|
|
182
155
|
delete newPropsPagination.onChange;
|
|
183
156
|
delete newPropsPagination.onShowSizeChange;
|
|
@@ -185,101 +158,15 @@ function useMergedPagination(_ref6) {
|
|
|
185
158
|
return mergePagination(newPropsPagination, pageConfig, intl);
|
|
186
159
|
}, [action, intl, propsPagination, request, type]);
|
|
187
160
|
}
|
|
188
|
-
function
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
onReset = _ref8.onReset,
|
|
198
|
-
onSubmit = _ref8.onSubmit,
|
|
199
|
-
loading = _ref8.loading,
|
|
200
|
-
manualRequest = _ref8.manualRequest,
|
|
201
|
-
form = _ref8.form,
|
|
202
|
-
formRef = _ref8.formRef,
|
|
203
|
-
cardBordered = _ref8.cardBordered,
|
|
204
|
-
dateFormatter = _ref8.dateFormatter,
|
|
205
|
-
searchFormRender = _ref8.searchFormRender,
|
|
206
|
-
proTableProps = _ref8.proTableProps;
|
|
207
|
-
return useMemo(function () {
|
|
208
|
-
var node = search === false && type !== 'form' ? null : /*#__PURE__*/_jsx(FormRender, {
|
|
209
|
-
pagination: pagination,
|
|
210
|
-
beforeSearchSubmit: beforeSearchSubmit,
|
|
211
|
-
action: actionRef,
|
|
212
|
-
columns: columns,
|
|
213
|
-
onFormSearchSubmit: function onFormSearchSubmit(values) {
|
|
214
|
-
_onFormSearchSubmit(values);
|
|
215
|
-
},
|
|
216
|
-
ghost: ghost,
|
|
217
|
-
onReset: onReset,
|
|
218
|
-
onSubmit: onSubmit,
|
|
219
|
-
loading: loading,
|
|
220
|
-
manualRequest: manualRequest,
|
|
221
|
-
search: search,
|
|
222
|
-
form: form,
|
|
223
|
-
formRef: formRef,
|
|
224
|
-
type: type || 'table',
|
|
225
|
-
cardBordered: cardBordered,
|
|
226
|
-
dateFormatter: dateFormatter
|
|
227
|
-
});
|
|
228
|
-
if (searchFormRender && node) {
|
|
229
|
-
return /*#__PURE__*/_jsx(_Fragment, {
|
|
230
|
-
children: searchFormRender(proTableProps, node)
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
return node;
|
|
234
|
-
}, [actionRef, beforeSearchSubmit, cardBordered, columns, dateFormatter, form, formRef, ghost, loading, manualRequest, _onFormSearchSubmit, onReset, onSubmit, pagination, proTableProps, search, searchFormRender, type]);
|
|
235
|
-
}
|
|
236
|
-
function useToolbarDom(context) {
|
|
237
|
-
var toolBarRender = context.toolBarRender,
|
|
238
|
-
headerTitle = context.headerTitle,
|
|
239
|
-
hideToolbar = context.hideToolbar,
|
|
240
|
-
selectedRows = context.selectedRows,
|
|
241
|
-
selectedRowKeys = context.selectedRowKeys,
|
|
242
|
-
tableColumn = context.tableColumn,
|
|
243
|
-
tooltip = context.tooltip,
|
|
244
|
-
toolbar = context.toolbar,
|
|
245
|
-
isLightFilter = context.isLightFilter,
|
|
246
|
-
searchNode = context.searchNode,
|
|
247
|
-
options = context.options,
|
|
248
|
-
optionsRender = context.optionsRender,
|
|
249
|
-
actionRef = context.actionRef,
|
|
250
|
-
setFormSearch = context.setFormSearch,
|
|
251
|
-
formSearch = context.formSearch;
|
|
252
|
-
return useMemo(function () {
|
|
253
|
-
if (toolBarRender === false) {
|
|
254
|
-
return null;
|
|
255
|
-
}
|
|
256
|
-
return /*#__PURE__*/_jsx(Toolbar, {
|
|
257
|
-
headerTitle: headerTitle,
|
|
258
|
-
hideToolbar: hideToolbar,
|
|
259
|
-
selectedRows: selectedRows,
|
|
260
|
-
selectedRowKeys: selectedRowKeys,
|
|
261
|
-
tableColumn: tableColumn,
|
|
262
|
-
tooltip: tooltip,
|
|
263
|
-
toolbar: toolbar,
|
|
264
|
-
onFormSearchSubmit: function onFormSearchSubmit(newValues) {
|
|
265
|
-
setFormSearch(_objectSpread(_objectSpread({}, formSearch || {}), newValues));
|
|
266
|
-
},
|
|
267
|
-
searchNode: isLightFilter ? searchNode : null,
|
|
268
|
-
options: options,
|
|
269
|
-
optionsRender: optionsRender,
|
|
270
|
-
actionRef: actionRef,
|
|
271
|
-
toolBarRender: toolBarRender
|
|
272
|
-
});
|
|
273
|
-
}, [actionRef, formSearch, headerTitle, hideToolbar, isLightFilter, options, optionsRender, searchNode, selectedRowKeys, selectedRows, setFormSearch, tableColumn, toolBarRender, tooltip, toolbar]);
|
|
274
|
-
}
|
|
275
|
-
function useAlertDom(_ref9) {
|
|
276
|
-
var propsRowSelection = _ref9.propsRowSelection,
|
|
277
|
-
selectedRowKeys = _ref9.selectedRowKeys,
|
|
278
|
-
selectedRows = _ref9.selectedRows,
|
|
279
|
-
onCleanSelected = _ref9.onCleanSelected,
|
|
280
|
-
tableAlertOptionRender = _ref9.tableAlertOptionRender,
|
|
281
|
-
tableAlertRender = _ref9.tableAlertRender;
|
|
282
|
-
return useMemo(function () {
|
|
161
|
+
function useAlertDom({
|
|
162
|
+
propsRowSelection,
|
|
163
|
+
selectedRowKeys,
|
|
164
|
+
selectedRows,
|
|
165
|
+
onCleanSelected,
|
|
166
|
+
tableAlertOptionRender,
|
|
167
|
+
tableAlertRender
|
|
168
|
+
}) {
|
|
169
|
+
return useMemo(() => {
|
|
283
170
|
if (propsRowSelection === false) {
|
|
284
171
|
return null;
|
|
285
172
|
}
|
|
@@ -289,385 +176,195 @@ function useAlertDom(_ref9) {
|
|
|
289
176
|
onCleanSelected: onCleanSelected,
|
|
290
177
|
alertOptionRender: tableAlertOptionRender,
|
|
291
178
|
alertInfoRender: tableAlertRender,
|
|
292
|
-
alwaysShowAlert: propsRowSelection
|
|
179
|
+
alwaysShowAlert: propsRowSelection?.alwaysShowAlert
|
|
293
180
|
});
|
|
294
181
|
}, [onCleanSelected, propsRowSelection, selectedRowKeys, selectedRows, tableAlertOptionRender, tableAlertRender]);
|
|
295
182
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
if (config && config.show === false) {
|
|
343
|
-
return false;
|
|
344
|
-
}
|
|
345
|
-
if (item.children) {
|
|
346
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
347
|
-
children: loopFilter(item.children)
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
return item;
|
|
351
|
-
}).filter(Boolean);
|
|
352
|
-
};
|
|
353
|
-
return loopFilter(tableColumns);
|
|
354
|
-
}, [counter.columnsMap, tableColumns]);
|
|
355
|
-
|
|
356
|
-
// 需要进行筛选的列
|
|
357
|
-
var useFilterColumns = useMemo(function () {
|
|
358
|
-
var _columns = flattenColumns(columns);
|
|
359
|
-
return _columns.filter(function (column) {
|
|
360
|
-
return !!column.filters;
|
|
361
|
-
});
|
|
362
|
-
}, [columns]);
|
|
363
|
-
var getTableProps = function getTableProps() {
|
|
364
|
-
return _objectSpread(_objectSpread({}, rest), {}, {
|
|
365
|
-
size: size,
|
|
366
|
-
rowSelection: rowSelection === false ? undefined : rowSelection,
|
|
367
|
-
className: tableClassName,
|
|
368
|
-
style: tableStyle,
|
|
369
|
-
columns: columns,
|
|
370
|
-
loading: action.loading,
|
|
371
|
-
dataSource: mergedDataSource,
|
|
372
|
-
pagination: pagination,
|
|
373
|
-
onChange: function onChange(changePagination, filters, sorter, extra) {
|
|
374
|
-
var _rest$onChange;
|
|
375
|
-
(_rest$onChange = rest.onChange) === null || _rest$onChange === void 0 || _rest$onChange.call(rest, changePagination, filters, sorter, extra);
|
|
376
|
-
|
|
377
|
-
// 传递服务端筛选数据
|
|
378
|
-
var serverFilter = getServerFilterResult(filters, useFilterColumns);
|
|
379
|
-
onFilterChange(omitUndefined(serverFilter));
|
|
380
|
-
|
|
381
|
-
// 传递服务端排序数据
|
|
382
|
-
var serverSorter = getServerSorterResult(sorter);
|
|
383
|
-
onSortChange(omitUndefined(serverSorter));
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* 是否需要 card 来包裹
|
|
390
|
-
*/
|
|
391
|
-
var notNeedCardDom = useMemo(function () {
|
|
392
|
-
if (props.search === false && !props.headerTitle && props.toolBarRender === false) {
|
|
393
|
-
return true;
|
|
394
|
-
}
|
|
395
|
-
return false;
|
|
396
|
-
}, []);
|
|
397
|
-
|
|
398
|
-
/** 默认的 table dom,如果是编辑模式,外面还要包个 form */
|
|
399
|
-
var baseTableDom = /*#__PURE__*/_jsx(GridContext.Provider, {
|
|
400
|
-
value: {
|
|
401
|
-
grid: false,
|
|
402
|
-
colProps: undefined,
|
|
403
|
-
rowProps: undefined
|
|
404
|
-
},
|
|
405
|
-
children: /*#__PURE__*/_jsx(Table, _objectSpread(_objectSpread({}, getTableProps()), {}, {
|
|
406
|
-
rowKey: rowKey,
|
|
407
|
-
ref: tableRef
|
|
408
|
-
}))
|
|
409
|
-
});
|
|
183
|
+
const emptyObj = {};
|
|
184
|
+
const ProTable = props => {
|
|
185
|
+
const {
|
|
186
|
+
cardBordered,
|
|
187
|
+
request,
|
|
188
|
+
className: propsClassName,
|
|
189
|
+
params = emptyObj,
|
|
190
|
+
defaultData,
|
|
191
|
+
headerTitle,
|
|
192
|
+
postData,
|
|
193
|
+
ghost,
|
|
194
|
+
pagination: propsPagination,
|
|
195
|
+
actionRef: propsActionRef,
|
|
196
|
+
toolBarRender,
|
|
197
|
+
optionsRender,
|
|
198
|
+
onLoad,
|
|
199
|
+
onRequestError,
|
|
200
|
+
style,
|
|
201
|
+
cardProps,
|
|
202
|
+
tableStyle,
|
|
203
|
+
tableClassName,
|
|
204
|
+
options,
|
|
205
|
+
search,
|
|
206
|
+
name: isEditorTable,
|
|
207
|
+
onLoadingChange,
|
|
208
|
+
rowSelection: propsRowSelection = false,
|
|
209
|
+
beforeSearchSubmit,
|
|
210
|
+
tableAlertRender,
|
|
211
|
+
defaultClassName,
|
|
212
|
+
formRef: propRef,
|
|
213
|
+
type = 'table',
|
|
214
|
+
columnEmptyText = '-',
|
|
215
|
+
toolbar,
|
|
216
|
+
rowKey,
|
|
217
|
+
manualRequest,
|
|
218
|
+
polling,
|
|
219
|
+
tooltip,
|
|
220
|
+
revalidateOnFocus = false,
|
|
221
|
+
searchFormRender,
|
|
222
|
+
...rest
|
|
223
|
+
} = props;
|
|
224
|
+
const {
|
|
225
|
+
wrapSSR,
|
|
226
|
+
hashId
|
|
227
|
+
} = useStyle(props.defaultClassName);
|
|
228
|
+
const className = clsx(defaultClassName, propsClassName, hashId);
|
|
410
229
|
|
|
411
|
-
/**
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
toolbarDom: toolbarDom,
|
|
419
|
-
alertDom: alertDom,
|
|
420
|
-
tableDom: tableDom,
|
|
421
|
-
dateFormatter: props.dateFormatter,
|
|
422
|
-
editableOnValuesChange: editableUtils.onValuesChange
|
|
423
|
-
});
|
|
424
|
-
var cardBodyStyle = useTableCardBodyStyle({
|
|
425
|
-
propsCardProps: propsCardProps,
|
|
426
|
-
notNeedCardDom: notNeedCardDom,
|
|
427
|
-
name: props.name,
|
|
428
|
-
hideToolbar: hideToolbar,
|
|
429
|
-
toolbarDom: toolbarDom,
|
|
430
|
-
pagination: pagination
|
|
431
|
-
});
|
|
230
|
+
/** 通用的来操作子节点的工具类 */
|
|
231
|
+
const actionRef = useRef();
|
|
232
|
+
// antd Table 实例 ref(仅用于转发 scrollTo 能力)
|
|
233
|
+
const antTableRef = useRef(null);
|
|
234
|
+
const defaultFormRef = useRef();
|
|
235
|
+
const formRef = propRef || defaultFormRef;
|
|
236
|
+
useImperativeHandle(propsActionRef, () => actionRef.current);
|
|
432
237
|
|
|
433
|
-
/**
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
body: cardBodyStyle
|
|
441
|
-
}
|
|
442
|
-
}, propsCardProps), {}, {
|
|
443
|
-
children: tableContentDom
|
|
444
|
-
}));
|
|
445
|
-
var renderTable = function renderTable() {
|
|
446
|
-
if (props.tableRender) {
|
|
447
|
-
return props.tableRender(props, tableAreaDom, {
|
|
448
|
-
toolbar: toolbarDom || undefined,
|
|
449
|
-
alert: alertDom || undefined,
|
|
450
|
-
table: tableDom || undefined
|
|
451
|
-
});
|
|
238
|
+
/** 单选多选的相关逻辑 */
|
|
239
|
+
const [selectedRowKeys, setSelectedRowKeys] = useControlledState(propsRowSelection ? propsRowSelection?.defaultSelectedRowKeys || [] : undefined, propsRowSelection ? propsRowSelection.selectedRowKeys : undefined);
|
|
240
|
+
const [formSearch, setFormSearch] = useState(() => {
|
|
241
|
+
// 如果手动模式,或者 search 不存在的时候设置为 undefined
|
|
242
|
+
// undefined 就不会触发首次加载
|
|
243
|
+
if (manualRequest || search !== false) {
|
|
244
|
+
return undefined;
|
|
452
245
|
}
|
|
453
|
-
return
|
|
454
|
-
};
|
|
455
|
-
var proTableDom = /*#__PURE__*/_jsxs("div", {
|
|
456
|
-
className: classNames(className, _defineProperty({}, "".concat(defaultClassName, "-polling"), action.pollingLoading)),
|
|
457
|
-
style: style,
|
|
458
|
-
ref: counter.rootDomRef,
|
|
459
|
-
children: [isLightFilter ? null : searchNode, type !== 'form' && props.tableExtraRender && /*#__PURE__*/_jsx("div", {
|
|
460
|
-
className: classNames(className, "".concat(defaultClassName, "-extra")),
|
|
461
|
-
children: props.tableExtraRender(props, action.dataSource || [])
|
|
462
|
-
}), type !== 'form' && renderTable()]
|
|
246
|
+
return {};
|
|
463
247
|
});
|
|
464
248
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
}
|
|
476
|
-
var emptyObj = {};
|
|
477
|
-
var ProTable = function ProTable(props) {
|
|
478
|
-
var _props$expandable2, _counter$rootDomRef;
|
|
479
|
-
var cardBordered = props.cardBordered,
|
|
480
|
-
request = props.request,
|
|
481
|
-
propsClassName = props.className,
|
|
482
|
-
_props$params = props.params,
|
|
483
|
-
params = _props$params === void 0 ? emptyObj : _props$params,
|
|
484
|
-
defaultData = props.defaultData,
|
|
485
|
-
headerTitle = props.headerTitle,
|
|
486
|
-
postData = props.postData,
|
|
487
|
-
ghost = props.ghost,
|
|
488
|
-
propsPagination = props.pagination,
|
|
489
|
-
propsActionRef = props.actionRef,
|
|
490
|
-
_props$columns = props.columns,
|
|
491
|
-
propsColumns = _props$columns === void 0 ? [] : _props$columns,
|
|
492
|
-
toolBarRender = props.toolBarRender,
|
|
493
|
-
optionsRender = props.optionsRender,
|
|
494
|
-
onLoad = props.onLoad,
|
|
495
|
-
onRequestError = props.onRequestError,
|
|
496
|
-
style = props.style,
|
|
497
|
-
cardProps = props.cardProps,
|
|
498
|
-
tableStyle = props.tableStyle,
|
|
499
|
-
tableClassName = props.tableClassName,
|
|
500
|
-
options = props.options,
|
|
501
|
-
search = props.search,
|
|
502
|
-
isEditorTable = props.name,
|
|
503
|
-
onLoadingChange = props.onLoadingChange,
|
|
504
|
-
_props$rowSelection = props.rowSelection,
|
|
505
|
-
propsRowSelection = _props$rowSelection === void 0 ? false : _props$rowSelection,
|
|
506
|
-
beforeSearchSubmit = props.beforeSearchSubmit,
|
|
507
|
-
tableAlertRender = props.tableAlertRender,
|
|
508
|
-
defaultClassName = props.defaultClassName,
|
|
509
|
-
propRef = props.formRef,
|
|
510
|
-
_props$type = props.type,
|
|
511
|
-
type = _props$type === void 0 ? 'table' : _props$type,
|
|
512
|
-
_props$columnEmptyTex = props.columnEmptyText,
|
|
513
|
-
columnEmptyText = _props$columnEmptyTex === void 0 ? '-' : _props$columnEmptyTex,
|
|
514
|
-
toolbar = props.toolbar,
|
|
515
|
-
rowKey = props.rowKey,
|
|
516
|
-
manualRequest = props.manualRequest,
|
|
517
|
-
polling = props.polling,
|
|
518
|
-
tooltip = props.tooltip,
|
|
519
|
-
_props$revalidateOnFo = props.revalidateOnFocus,
|
|
520
|
-
revalidateOnFocus = _props$revalidateOnFo === void 0 ? false : _props$revalidateOnFo,
|
|
521
|
-
searchFormRender = props.searchFormRender,
|
|
522
|
-
rest = _objectWithoutProperties(props, _excluded2);
|
|
523
|
-
var _useStyle = useStyle(props.defaultClassName),
|
|
524
|
-
wrapSSR = _useStyle.wrapSSR,
|
|
525
|
-
hashId = _useStyle.hashId;
|
|
526
|
-
var className = classNames(defaultClassName, propsClassName, hashId);
|
|
527
|
-
|
|
528
|
-
/** 通用的来操作子节点的工具类 */
|
|
529
|
-
var actionRef = useRef();
|
|
530
|
-
// antd Table 实例 ref(仅用于转发 scrollTo 能力)
|
|
531
|
-
var antTableRef = useRef(null);
|
|
532
|
-
var defaultFormRef = useRef();
|
|
533
|
-
var formRef = propRef || defaultFormRef;
|
|
534
|
-
useImperativeHandle(propsActionRef, function () {
|
|
535
|
-
return actionRef.current;
|
|
249
|
+
/**
|
|
250
|
+
* `actionRef.current?.reset()` 会在同一事件循环里同步调用 `action.reload()`。
|
|
251
|
+
* 由于 React state 更新是异步的,如果仅 setState,reload 可能仍读取到旧的 formSearch。
|
|
252
|
+
* 使用 ref 作为请求参数的同步来源,保证 reset/toolbar 等场景下参数与表单展示一致。
|
|
253
|
+
*/
|
|
254
|
+
const formSearchRef = useRef(formSearch);
|
|
255
|
+
const setFormSearchWithRef = useRefFunction(next => {
|
|
256
|
+
const nextValue = typeof next === 'function' ? next(formSearchRef.current) : next;
|
|
257
|
+
formSearchRef.current = nextValue;
|
|
258
|
+
setFormSearch(nextValue);
|
|
536
259
|
});
|
|
260
|
+
const {
|
|
261
|
+
columns: propsColumns = [],
|
|
262
|
+
columnsState
|
|
263
|
+
} = props;
|
|
264
|
+
const {
|
|
265
|
+
defaultProFilter,
|
|
266
|
+
defaultProSort
|
|
267
|
+
} = useMemo(() => {
|
|
268
|
+
const {
|
|
269
|
+
sort,
|
|
270
|
+
filter
|
|
271
|
+
} = parseServerDefaultColumnConfig(flattenColumns(propsColumns));
|
|
272
|
+
return {
|
|
273
|
+
defaultProFilter: filter,
|
|
274
|
+
defaultProSort: sort
|
|
275
|
+
};
|
|
276
|
+
}, [propsColumns]);
|
|
277
|
+
const [proFilter, setProFilter] = useState(defaultProFilter);
|
|
278
|
+
const [proSort, setProSort] = useState(defaultProSort);
|
|
537
279
|
|
|
538
|
-
/**
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
// undefined 就不会触发首次加载
|
|
548
|
-
if (manualRequest || search !== false) {
|
|
549
|
-
return undefined;
|
|
550
|
-
}
|
|
551
|
-
return {};
|
|
552
|
-
}),
|
|
553
|
-
_useMountMergeState4 = _slicedToArray(_useMountMergeState3, 2),
|
|
554
|
-
formSearch = _useMountMergeState4[0],
|
|
555
|
-
setFormSearch = _useMountMergeState4[1];
|
|
556
|
-
var _useMemo = useMemo(function () {
|
|
557
|
-
var _parseServerDefaultCo = parseServerDefaultColumnConfig(flattenColumns(propsColumns)),
|
|
558
|
-
sort = _parseServerDefaultCo.sort,
|
|
559
|
-
filter = _parseServerDefaultCo.filter;
|
|
560
|
-
return {
|
|
561
|
-
defaultProFilter: filter,
|
|
562
|
-
defaultProSort: sort
|
|
563
|
-
};
|
|
564
|
-
}, [propsColumns]),
|
|
565
|
-
defaultProFilter = _useMemo.defaultProFilter,
|
|
566
|
-
defaultProSort = _useMemo.defaultProSort;
|
|
567
|
-
var _useMountMergeState5 = useMountMergeState(defaultProFilter),
|
|
568
|
-
_useMountMergeState6 = _slicedToArray(_useMountMergeState5, 2),
|
|
569
|
-
proFilter = _useMountMergeState6[0],
|
|
570
|
-
setProFilter = _useMountMergeState6[1];
|
|
571
|
-
var _useMountMergeState7 = useMountMergeState(defaultProSort),
|
|
572
|
-
_useMountMergeState8 = _slicedToArray(_useMountMergeState7, 2),
|
|
573
|
-
proSort = _useMountMergeState8[0],
|
|
574
|
-
setProSort = _useMountMergeState8[1];
|
|
575
|
-
var intl = useIntl();
|
|
280
|
+
/**
|
|
281
|
+
* 只有在 proColumns 变化的时候,才会重新更新 proFilter 和 proSort
|
|
282
|
+
* 这样可以避免 columns 变化的时候,filter 和 sort 被重置
|
|
283
|
+
*/
|
|
284
|
+
useDeepCompareEffect(() => {
|
|
285
|
+
setProFilter(defaultProFilter);
|
|
286
|
+
setProSort(defaultProSort);
|
|
287
|
+
}, [defaultProFilter, defaultProSort]);
|
|
288
|
+
const intl = useIntl();
|
|
576
289
|
|
|
577
290
|
/** 需要初始化 不然默认可能报错 这里取了 defaultCurrent 和 current 为了保证不会重复刷新 */
|
|
578
|
-
|
|
291
|
+
const fetchPagination = typeof propsPagination === 'object' ? propsPagination : {
|
|
579
292
|
defaultCurrent: 1,
|
|
580
293
|
defaultPageSize: 20,
|
|
581
294
|
pageSize: 20,
|
|
582
295
|
current: 1
|
|
583
296
|
};
|
|
584
|
-
|
|
297
|
+
const counter = useContext(TableContext);
|
|
585
298
|
|
|
586
299
|
// ============================ useFetchData ============================
|
|
587
|
-
|
|
300
|
+
const fetchData = useMemo(() => {
|
|
588
301
|
if (!request) return undefined;
|
|
589
|
-
return
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
case 0:
|
|
595
|
-
actionParams = _objectSpread(_objectSpread(_objectSpread({}, pageParams || {}), formSearch), params); // eslint-disable-next-line no-underscore-dangle
|
|
596
|
-
delete actionParams._timestamp;
|
|
597
|
-
_context.next = 4;
|
|
598
|
-
return request(actionParams, proSort, proFilter);
|
|
599
|
-
case 4:
|
|
600
|
-
response = _context.sent;
|
|
601
|
-
return _context.abrupt("return", response);
|
|
602
|
-
case 6:
|
|
603
|
-
case "end":
|
|
604
|
-
return _context.stop();
|
|
605
|
-
}
|
|
606
|
-
}, _callee);
|
|
607
|
-
}));
|
|
608
|
-
return function (_x) {
|
|
609
|
-
return _ref10.apply(this, arguments);
|
|
302
|
+
return async pageParams => {
|
|
303
|
+
const actionParams = {
|
|
304
|
+
...(pageParams || {}),
|
|
305
|
+
...(formSearchRef.current || {}),
|
|
306
|
+
...params
|
|
610
307
|
};
|
|
611
|
-
|
|
308
|
+
|
|
309
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
310
|
+
delete actionParams._timestamp;
|
|
311
|
+
const response = await request(actionParams, proSort, proFilter);
|
|
312
|
+
return response;
|
|
313
|
+
};
|
|
612
314
|
}, [formSearch, params, proFilter, proSort, request]);
|
|
613
|
-
|
|
315
|
+
const action = useFetchData(fetchData, defaultData, {
|
|
614
316
|
pageInfo: propsPagination === false ? false : fetchPagination,
|
|
615
317
|
loading: props.loading,
|
|
616
318
|
dataSource: props.dataSource,
|
|
617
319
|
onDataSourceChange: props.onDataSourceChange,
|
|
618
|
-
onLoad
|
|
619
|
-
onLoadingChange
|
|
620
|
-
onRequestError
|
|
621
|
-
postData
|
|
622
|
-
revalidateOnFocus
|
|
320
|
+
onLoad,
|
|
321
|
+
onLoadingChange,
|
|
322
|
+
onRequestError,
|
|
323
|
+
postData,
|
|
324
|
+
revalidateOnFocus,
|
|
623
325
|
manual: formSearch === undefined,
|
|
624
|
-
polling
|
|
326
|
+
polling,
|
|
625
327
|
effects: [stringify(params), stringify(formSearch), stringify(proFilter), stringify(proSort)],
|
|
626
328
|
debounceTime: props.debounceTime,
|
|
627
|
-
onPageInfoChange:
|
|
628
|
-
var _propsPagination$onCh, _propsPagination$onSh;
|
|
329
|
+
onPageInfoChange: pageInfo => {
|
|
629
330
|
if (!propsPagination || !fetchData) return;
|
|
630
331
|
|
|
631
332
|
// 总是触发一下 onChange 和 onShowSizeChange
|
|
632
333
|
// 目前只有 List 和 Table 支持分页, List 有分页的时候打断 Table 的分页
|
|
633
|
-
propsPagination
|
|
634
|
-
propsPagination
|
|
334
|
+
propsPagination?.onChange?.(pageInfo.current, pageInfo.pageSize);
|
|
335
|
+
propsPagination?.onShowSizeChange?.(pageInfo.current, pageInfo.pageSize);
|
|
635
336
|
}
|
|
636
337
|
});
|
|
637
338
|
// ============================ END ============================
|
|
638
339
|
|
|
639
340
|
/** 聚焦的时候重新请求数据,这样可以保证数据都是最新的。 */
|
|
640
|
-
useEffect(
|
|
641
|
-
var _props$form;
|
|
341
|
+
useEffect(() => {
|
|
642
342
|
// 手动模式和 request 为空都不生效
|
|
643
|
-
if (props.manualRequest || !props.request || !revalidateOnFocus ||
|
|
343
|
+
if (props.manualRequest || !props.request || !revalidateOnFocus || props.form?.ignoreRules) return;
|
|
644
344
|
|
|
645
345
|
// 聚焦时重新请求事件
|
|
646
|
-
|
|
346
|
+
const visibilitychange = () => {
|
|
647
347
|
if (document.visibilityState === 'visible') {
|
|
648
348
|
action.reload();
|
|
649
349
|
}
|
|
650
350
|
};
|
|
651
351
|
document.addEventListener('visibilitychange', visibilitychange);
|
|
652
|
-
return
|
|
653
|
-
return document.removeEventListener('visibilitychange', visibilitychange);
|
|
654
|
-
};
|
|
352
|
+
return () => document.removeEventListener('visibilitychange', visibilitychange);
|
|
655
353
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
656
354
|
}, []);
|
|
657
355
|
|
|
658
356
|
/** SelectedRowKeys受控处理selectRows */
|
|
659
|
-
|
|
357
|
+
const preserveRecordsRef = React.useRef(new Map());
|
|
660
358
|
|
|
661
359
|
// ============================ RowKey ============================
|
|
662
|
-
|
|
663
|
-
rowKey
|
|
360
|
+
const getRowKey = useRowKey({
|
|
361
|
+
rowKey,
|
|
664
362
|
name: props.name
|
|
665
363
|
});
|
|
666
|
-
useMemo(
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
var dataRowKey = getRowKey(data, -1);
|
|
364
|
+
useMemo(() => {
|
|
365
|
+
if (action.dataSource?.length) {
|
|
366
|
+
const keys = action.dataSource.map(data => {
|
|
367
|
+
const dataRowKey = getRowKey(data, -1);
|
|
671
368
|
preserveRecordsRef.current.set(dataRowKey, data);
|
|
672
369
|
return dataRowKey;
|
|
673
370
|
});
|
|
@@ -677,17 +374,26 @@ var ProTable = function ProTable(props) {
|
|
|
677
374
|
}, [action.dataSource, getRowKey]);
|
|
678
375
|
|
|
679
376
|
/** 页面编辑的计算 */
|
|
680
|
-
|
|
681
|
-
propsPagination
|
|
682
|
-
action
|
|
683
|
-
intl
|
|
684
|
-
request
|
|
685
|
-
type
|
|
377
|
+
const pagination = useMergedPagination({
|
|
378
|
+
propsPagination,
|
|
379
|
+
action,
|
|
380
|
+
intl,
|
|
381
|
+
request,
|
|
382
|
+
type
|
|
686
383
|
});
|
|
687
|
-
|
|
688
|
-
|
|
384
|
+
|
|
385
|
+
// 监听 pagination 的变化,修正 pageSize
|
|
386
|
+
useDeepCompareEffect(() => {
|
|
387
|
+
if (pagination && (pagination.current !== action.pageInfo.current || pagination.pageSize !== action.pageInfo.pageSize)) {
|
|
388
|
+
action.setPageInfo({
|
|
389
|
+
current: pagination.current,
|
|
390
|
+
pageSize: pagination.pageSize
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
}, [pagination]);
|
|
394
|
+
useDeepCompareEffect(() => {
|
|
689
395
|
// request 存在且params不为空,且已经请求过数据才需要设置。
|
|
690
|
-
if (props.request && !isEmpty(params) && action.dataSource && !isEqual(action.dataSource, defaultData) &&
|
|
396
|
+
if (props.request && !isEmpty(params) && action.dataSource && !isEqual(action.dataSource, defaultData) && action?.pageInfo?.current !== 1) {
|
|
691
397
|
action.setPageInfo({
|
|
692
398
|
current: 1
|
|
693
399
|
});
|
|
@@ -698,62 +404,66 @@ var ProTable = function ProTable(props) {
|
|
|
698
404
|
// 设置 name 到 store 中,里面用了 ref ,所以不用担心直接 set
|
|
699
405
|
counter.setPrefixName(props.name);
|
|
700
406
|
|
|
407
|
+
// 设置 columnsState 到 store 中(仅在受控 value 时同步,避免在仅传 onChange 时用 {} 覆盖默认 state 导致多余 onChange)
|
|
408
|
+
useEffect(() => {
|
|
409
|
+
if (columnsState?.value !== undefined) {
|
|
410
|
+
counter.setColumnsMap(columnsState.value);
|
|
411
|
+
}
|
|
412
|
+
}, [columnsState?.value]);
|
|
413
|
+
|
|
701
414
|
/** 清空所有的选中项 */
|
|
702
|
-
|
|
415
|
+
const onCleanSelected = useRefFunction(() => {
|
|
703
416
|
if (propsRowSelection && propsRowSelection.onChange) {
|
|
704
417
|
propsRowSelection.onChange([], [], {
|
|
705
418
|
type: 'none'
|
|
706
419
|
});
|
|
707
420
|
}
|
|
708
421
|
setSelectedRowKeys([]);
|
|
709
|
-
}
|
|
422
|
+
});
|
|
710
423
|
counter.propsRef.current = props;
|
|
711
424
|
|
|
712
425
|
/** 可编辑行的相关配置 */
|
|
713
|
-
|
|
426
|
+
const editableUtils = useEditableArray({
|
|
427
|
+
...props.editable,
|
|
714
428
|
tableName: props.name,
|
|
715
|
-
getRowKey
|
|
716
|
-
childrenColumnName:
|
|
429
|
+
getRowKey,
|
|
430
|
+
childrenColumnName: props.expandable?.childrenColumnName || 'children',
|
|
717
431
|
dataSource: action.dataSource || [],
|
|
718
|
-
setDataSource:
|
|
719
|
-
|
|
720
|
-
(_props$editable = props.editable) === null || _props$editable === void 0 || (_props$editable$onVal = _props$editable.onValuesChange) === null || _props$editable$onVal === void 0 || _props$editable$onVal.call(_props$editable, undefined, data);
|
|
432
|
+
setDataSource: data => {
|
|
433
|
+
props.editable?.onValuesChange?.(undefined, data);
|
|
721
434
|
action.setDataSource(data);
|
|
722
435
|
}
|
|
723
|
-
})
|
|
436
|
+
});
|
|
724
437
|
|
|
725
438
|
// ============================ Render ============================
|
|
726
|
-
|
|
727
|
-
token
|
|
439
|
+
const {
|
|
440
|
+
token
|
|
441
|
+
} = proTheme?.useToken();
|
|
728
442
|
|
|
729
443
|
/** 绑定 action */
|
|
730
444
|
useActionType(actionRef, action, {
|
|
731
|
-
nativeElement:
|
|
732
|
-
focus:
|
|
733
|
-
var _counter$rootDomRef2;
|
|
445
|
+
nativeElement: counter.rootDomRef?.current || undefined,
|
|
446
|
+
focus: () => {
|
|
734
447
|
// 聚焦到表格根元素
|
|
735
|
-
|
|
448
|
+
counter.rootDomRef?.current?.focus();
|
|
736
449
|
},
|
|
737
|
-
fullScreen:
|
|
738
|
-
|
|
739
|
-
if (!((_counter$rootDomRef3 = counter.rootDomRef) !== null && _counter$rootDomRef3 !== void 0 && _counter$rootDomRef3.current) || !document.fullscreenEnabled) {
|
|
450
|
+
fullScreen: () => {
|
|
451
|
+
if (!counter.rootDomRef?.current || !document.fullscreenEnabled) {
|
|
740
452
|
return;
|
|
741
453
|
}
|
|
742
454
|
if (document.fullscreenElement) {
|
|
743
455
|
document.exitFullscreen();
|
|
744
456
|
} else {
|
|
745
|
-
|
|
746
|
-
(_counter$rootDomRef4 = counter.rootDomRef) === null || _counter$rootDomRef4 === void 0 || _counter$rootDomRef4.current.requestFullscreen();
|
|
457
|
+
counter.rootDomRef?.current.requestFullscreen();
|
|
747
458
|
}
|
|
748
459
|
},
|
|
749
|
-
onCleanSelected:
|
|
460
|
+
onCleanSelected: () => {
|
|
750
461
|
// 清空选中行
|
|
751
|
-
|
|
462
|
+
onCleanSelected();
|
|
752
463
|
},
|
|
753
|
-
resetAll:
|
|
754
|
-
var _formRef$current;
|
|
464
|
+
resetAll: () => {
|
|
755
465
|
// 清空选中行
|
|
756
|
-
|
|
466
|
+
onCleanSelected();
|
|
757
467
|
|
|
758
468
|
// 清空 toolbar 搜索
|
|
759
469
|
counter.setKeyWords(undefined);
|
|
@@ -768,58 +478,61 @@ var ProTable = function ProTable(props) {
|
|
|
768
478
|
setProSort(defaultProSort);
|
|
769
479
|
|
|
770
480
|
// 重置表单
|
|
771
|
-
formRef
|
|
481
|
+
formRef?.current?.resetFields();
|
|
482
|
+
|
|
483
|
+
// 同步更新请求参数,避免 resetFields 后请求仍使用旧的 formSearch
|
|
484
|
+
const resetValues = formRef?.current?.getFieldsFormatValue?.(true) ?? formRef?.current?.getFieldsValue?.(true) ?? {};
|
|
485
|
+
const nextSearch = beforeSearchSubmit ? beforeSearchSubmit(resetValues) : resetValues;
|
|
486
|
+
setFormSearchWithRef(nextSearch ?? {});
|
|
772
487
|
},
|
|
773
|
-
editableUtils
|
|
774
|
-
scrollTo:
|
|
775
|
-
var _current, _current$scrollTo;
|
|
776
|
-
return antTableRef === null || antTableRef === void 0 || (_current = antTableRef.current) === null || _current === void 0 || (_current$scrollTo = _current.scrollTo) === null || _current$scrollTo === void 0 ? void 0 : _current$scrollTo.call(_current, arg);
|
|
777
|
-
}
|
|
488
|
+
editableUtils,
|
|
489
|
+
scrollTo: arg => antTableRef?.current?.scrollTo?.(arg)
|
|
778
490
|
});
|
|
779
491
|
|
|
780
492
|
/** 同步 action */
|
|
781
493
|
counter.setAction(actionRef.current);
|
|
782
494
|
|
|
783
495
|
// ---------- 列计算相关 start -----------------
|
|
784
|
-
|
|
785
|
-
|
|
496
|
+
const tableColumn = useMemo(() => {
|
|
497
|
+
const columnContext = {
|
|
498
|
+
counter,
|
|
499
|
+
columnEmptyText,
|
|
500
|
+
type,
|
|
501
|
+
editableUtils,
|
|
502
|
+
marginSM: token.marginSM,
|
|
503
|
+
rowKey: rowKey ?? 'id',
|
|
504
|
+
childrenColumnName: props.expandable?.childrenColumnName ?? 'children',
|
|
505
|
+
proFilter,
|
|
506
|
+
proSort
|
|
507
|
+
};
|
|
786
508
|
return genProColumnToColumn({
|
|
787
509
|
columns: propsColumns,
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
type: type,
|
|
791
|
-
marginSM: token.marginSM,
|
|
792
|
-
editableUtils: editableUtils,
|
|
793
|
-
rowKey: rowKey,
|
|
794
|
-
childrenColumnName: (_props$expandable3 = props.expandable) === null || _props$expandable3 === void 0 ? void 0 : _props$expandable3.childrenColumnName,
|
|
795
|
-
proFilter: proFilter,
|
|
796
|
-
proSort: proSort
|
|
797
|
-
}).sort(columnSort(counter.columnsMap));
|
|
510
|
+
context: columnContext
|
|
511
|
+
}).sort(columnSort(counter.columnsMap ?? {}));
|
|
798
512
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
799
|
-
}, [propsColumns, counter
|
|
513
|
+
}, [propsColumns, counter?.sortKeyColumns, counter?.columnsMap, columnEmptyText, type,
|
|
800
514
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
801
515
|
editableUtils.editableKeys && editableUtils.editableKeys.join(','), proFilter, proSort]);
|
|
802
516
|
|
|
803
517
|
/** Table Column 变化的时候更新一下,这个参数将会用于渲染 */
|
|
804
|
-
useDeepCompareEffectDebounce(
|
|
518
|
+
useDeepCompareEffectDebounce(() => {
|
|
805
519
|
if (tableColumn && tableColumn.length > 0) {
|
|
806
520
|
// 重新生成key的字符串用于排序
|
|
807
|
-
|
|
808
|
-
return genColumnKey(item.key, item.index);
|
|
809
|
-
});
|
|
521
|
+
const columnKeys = tableColumn.map(item => genColumnKey(item.key, item.index));
|
|
810
522
|
counter.setSortKeyColumns(columnKeys);
|
|
811
523
|
}
|
|
812
524
|
}, [tableColumn], ['render', 'formItemRender'], 100);
|
|
813
525
|
|
|
814
526
|
/** 同步 Pagination,支持受控的 页码 和 pageSize */
|
|
815
|
-
useDeepCompareEffect(
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
pageSize =
|
|
822
|
-
|
|
527
|
+
useDeepCompareEffect(() => {
|
|
528
|
+
const {
|
|
529
|
+
pageInfo
|
|
530
|
+
} = action;
|
|
531
|
+
const {
|
|
532
|
+
current = pageInfo?.current,
|
|
533
|
+
pageSize = pageInfo?.pageSize
|
|
534
|
+
} = propsPagination || {};
|
|
535
|
+
if (propsPagination && (current || pageSize) && (pageSize !== pageInfo?.pageSize || current !== pageInfo?.current)) {
|
|
823
536
|
action.setPageInfo({
|
|
824
537
|
pageSize: pageSize || pageInfo.pageSize,
|
|
825
538
|
current: current || pageInfo.current
|
|
@@ -828,44 +541,45 @@ var ProTable = function ProTable(props) {
|
|
|
828
541
|
}, [propsPagination && propsPagination.pageSize, propsPagination && propsPagination.current]);
|
|
829
542
|
|
|
830
543
|
/** 行选择相关的问题 */
|
|
831
|
-
|
|
832
|
-
selectedRowKeys
|
|
833
|
-
|
|
834
|
-
onChange:
|
|
544
|
+
const rowSelection = {
|
|
545
|
+
selectedRowKeys,
|
|
546
|
+
...propsRowSelection,
|
|
547
|
+
onChange: (keys, rows, info) => {
|
|
835
548
|
if (propsRowSelection && propsRowSelection.onChange) {
|
|
836
549
|
propsRowSelection.onChange(keys, rows, info);
|
|
837
550
|
}
|
|
838
551
|
setSelectedRowKeys(keys);
|
|
839
552
|
}
|
|
840
|
-
}
|
|
553
|
+
};
|
|
841
554
|
|
|
842
555
|
/** 是不是 LightFilter, LightFilter 有一些特殊的处理 */
|
|
843
|
-
|
|
844
|
-
|
|
556
|
+
const isLightFilter = search !== false && search?.filterType === 'light';
|
|
557
|
+
const onFormSearchSubmit = useRefFunction(values => {
|
|
845
558
|
// 判断search.onSearch返回值决定是否更新formSearch
|
|
846
559
|
if (options && options.search) {
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
name = _ref12$name === void 0 ? 'keyword' : _ref12$name;
|
|
560
|
+
const {
|
|
561
|
+
name = 'keyword'
|
|
562
|
+
} = options.search === true ? {} : options.search;
|
|
851
563
|
|
|
852
564
|
/** 如果传入的 onSearch 返回值为 false,则不要把options.search.name对应的值set到formSearch */
|
|
853
|
-
|
|
565
|
+
const success = options.search?.onSearch?.(counter.keyWords);
|
|
854
566
|
if (success !== false) {
|
|
855
|
-
|
|
567
|
+
setFormSearchWithRef({
|
|
568
|
+
...values,
|
|
569
|
+
[name]: counter.keyWords
|
|
570
|
+
});
|
|
856
571
|
return;
|
|
857
572
|
}
|
|
858
573
|
}
|
|
859
|
-
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
if (
|
|
863
|
-
|
|
864
|
-
return ((_action$loading = action.loading) === null || _action$loading === void 0 ? void 0 : _action$loading.spinning) || false;
|
|
574
|
+
setFormSearchWithRef(values);
|
|
575
|
+
});
|
|
576
|
+
const loading = useMemo(() => {
|
|
577
|
+
if (typeof action.loading === 'object') {
|
|
578
|
+
return action.loading?.spinning || false;
|
|
865
579
|
}
|
|
866
580
|
return action.loading;
|
|
867
581
|
}, [action.loading]);
|
|
868
|
-
|
|
582
|
+
const searchNode = /*#__PURE__*/_jsx(TableSearch, {
|
|
869
583
|
search: search,
|
|
870
584
|
type: type,
|
|
871
585
|
pagination: pagination,
|
|
@@ -885,16 +599,9 @@ var ProTable = function ProTable(props) {
|
|
|
885
599
|
searchFormRender: searchFormRender,
|
|
886
600
|
proTableProps: props
|
|
887
601
|
});
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
return (_preserveRecordsRef$c = preserveRecordsRef.current) === null || _preserveRecordsRef$c === void 0 ? void 0 : _preserveRecordsRef$c.get(key);
|
|
892
|
-
});
|
|
893
|
-
}, [action.dataSource, selectedRowKeys]);
|
|
894
|
-
var hideToolbar = useMemo(function () {
|
|
895
|
-
return options === false && !headerTitle && !toolBarRender && !toolbar && !isLightFilter;
|
|
896
|
-
}, [options, headerTitle, toolBarRender, toolbar, isLightFilter]);
|
|
897
|
-
var toolbarDom = useToolbarDom({
|
|
602
|
+
const selectedRows = useMemo(() => selectedRowKeys?.map(key => preserveRecordsRef.current?.get(key)), [action.dataSource, selectedRowKeys]);
|
|
603
|
+
const hideToolbar = useMemo(() => options === false && !headerTitle && !toolBarRender && !toolbar && !isLightFilter, [options, headerTitle, toolBarRender, toolbar, isLightFilter]);
|
|
604
|
+
const toolbarDom = /*#__PURE__*/_jsx(TableToolbar, {
|
|
898
605
|
toolBarRender: toolBarRender,
|
|
899
606
|
headerTitle: headerTitle,
|
|
900
607
|
hideToolbar: hideToolbar,
|
|
@@ -908,44 +615,159 @@ var ProTable = function ProTable(props) {
|
|
|
908
615
|
options: options,
|
|
909
616
|
optionsRender: optionsRender,
|
|
910
617
|
actionRef: actionRef,
|
|
911
|
-
setFormSearch:
|
|
618
|
+
setFormSearch: setFormSearchWithRef,
|
|
912
619
|
formSearch: formSearch
|
|
913
620
|
});
|
|
914
|
-
|
|
915
|
-
propsRowSelection
|
|
916
|
-
selectedRowKeys
|
|
917
|
-
selectedRows
|
|
918
|
-
onCleanSelected
|
|
621
|
+
const alertDom = useAlertDom({
|
|
622
|
+
propsRowSelection,
|
|
623
|
+
selectedRowKeys,
|
|
624
|
+
selectedRows,
|
|
625
|
+
onCleanSelected,
|
|
919
626
|
tableAlertOptionRender: rest.tableAlertOptionRender,
|
|
920
|
-
tableAlertRender
|
|
627
|
+
tableAlertRender
|
|
921
628
|
});
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
629
|
+
const mergedDataSource = useMemo(() => {
|
|
630
|
+
return getEditableDataSource({
|
|
631
|
+
dataSource: action.dataSource,
|
|
632
|
+
editableUtils,
|
|
633
|
+
pagination,
|
|
634
|
+
getRowKey,
|
|
635
|
+
childrenColumnName: props.expandable?.childrenColumnName || 'children'
|
|
636
|
+
});
|
|
637
|
+
}, [action.dataSource, editableUtils?.newLineRecord, getRowKey, pagination, props.expandable?.childrenColumnName]);
|
|
638
|
+
const columns = useMemo(() => {
|
|
639
|
+
const loopFilter = column => {
|
|
640
|
+
return column.map(item => {
|
|
641
|
+
const columnKey = genColumnKey(item.key, item.index);
|
|
642
|
+
const config = counter.columnsMap?.[columnKey];
|
|
643
|
+
if (config && config.show === false) {
|
|
644
|
+
return false;
|
|
645
|
+
}
|
|
646
|
+
if (item.children) {
|
|
647
|
+
return {
|
|
648
|
+
...item,
|
|
649
|
+
children: loopFilter(item.children)
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
return item;
|
|
653
|
+
}).filter(Boolean);
|
|
654
|
+
};
|
|
655
|
+
return loopFilter(tableColumn);
|
|
656
|
+
}, [counter.columnsMap, tableColumn]);
|
|
657
|
+
const useFilterColumns = useMemo(() => {
|
|
658
|
+
const _columns = flattenColumns(columns);
|
|
659
|
+
return _columns.filter(column => !!column.filters);
|
|
660
|
+
}, [columns]);
|
|
661
|
+
const onSortChange = sortConfig => {
|
|
662
|
+
if (isEqual(sortConfig, proSort)) return;
|
|
663
|
+
setProSort(sortConfig ?? {});
|
|
664
|
+
};
|
|
665
|
+
const onFilterChange = filterConfig => {
|
|
666
|
+
if (isEqual(filterConfig, proFilter)) return;
|
|
667
|
+
setProFilter(filterConfig ?? {});
|
|
668
|
+
};
|
|
669
|
+
const getTableProps = () => ({
|
|
670
|
+
...rest,
|
|
925
671
|
size: counter.tableSize,
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
672
|
+
rowSelection: propsRowSelection === false ? undefined : rowSelection,
|
|
673
|
+
className: tableClassName,
|
|
674
|
+
style: tableStyle,
|
|
675
|
+
columns,
|
|
676
|
+
loading: action.loading,
|
|
677
|
+
dataSource: mergedDataSource,
|
|
678
|
+
pagination,
|
|
679
|
+
onChange: (changePagination, filters, sorter, extra) => {
|
|
680
|
+
rest.onChange?.(changePagination, filters, sorter, extra);
|
|
681
|
+
const serverFilter = getServerFilterResult(filters, useFilterColumns);
|
|
682
|
+
onFilterChange(omitUndefined(serverFilter));
|
|
683
|
+
const serverSorter = getServerSorterResult(sorter);
|
|
684
|
+
onSortChange(omitUndefined(serverSorter));
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
const notNeedCardDom = search === false && !headerTitle && !toolBarRender;
|
|
688
|
+
const baseTableDom = /*#__PURE__*/_jsx(GridContext.Provider, {
|
|
689
|
+
value: {
|
|
690
|
+
grid: false,
|
|
691
|
+
colProps: undefined,
|
|
692
|
+
rowProps: undefined
|
|
940
693
|
},
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
694
|
+
children: /*#__PURE__*/_jsx(Table, {
|
|
695
|
+
...getTableProps(),
|
|
696
|
+
rowKey: rowKey,
|
|
697
|
+
ref: antTableRef
|
|
698
|
+
})
|
|
699
|
+
});
|
|
700
|
+
const tableDom = props.tableViewRender ? props.tableViewRender({
|
|
701
|
+
...getTableProps(),
|
|
702
|
+
rowSelection: propsRowSelection !== false ? rowSelection : undefined
|
|
703
|
+
}, baseTableDom) : baseTableDom;
|
|
704
|
+
const tableContentDom = props.editable && !isEditorTable ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
705
|
+
children: [toolbarDom, alertDom, /*#__PURE__*/_createElement(ProForm, {
|
|
706
|
+
...props.editable.formProps,
|
|
707
|
+
formRef: props.editable.formProps?.formRef,
|
|
708
|
+
component: false,
|
|
709
|
+
form: props.editable.form,
|
|
710
|
+
onValuesChange: editableUtils.onValuesChange,
|
|
711
|
+
key: "table",
|
|
712
|
+
submitter: false,
|
|
713
|
+
omitNil: false,
|
|
714
|
+
dateFormatter: props.dateFormatter
|
|
715
|
+
}, tableDom)]
|
|
716
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
717
|
+
children: [toolbarDom, alertDom, tableDom]
|
|
718
|
+
});
|
|
719
|
+
const cardBodyStyle = getTableCardBodyStyle({
|
|
720
|
+
propsCardProps: cardProps,
|
|
721
|
+
notNeedCardDom,
|
|
722
|
+
name: props.name,
|
|
723
|
+
hideToolbar,
|
|
724
|
+
toolbarDom
|
|
725
|
+
});
|
|
726
|
+
const tableAreaDom = cardProps === false || notNeedCardDom || !!props.name ? tableContentDom : /*#__PURE__*/_jsx(ProCard, {
|
|
727
|
+
ghost: ghost,
|
|
728
|
+
variant: isBordered('table', cardBordered) ? 'outlined' : 'borderless',
|
|
729
|
+
styles: {
|
|
730
|
+
body: {
|
|
731
|
+
...cardBodyStyle,
|
|
732
|
+
...(cardProps && typeof cardProps === 'object' ? cardProps.styles?.body || cardProps.bodyStyle : {})
|
|
733
|
+
},
|
|
734
|
+
...(cardProps && typeof cardProps === 'object' && (cardProps.styles?.header || cardProps.headStyle) ? {
|
|
735
|
+
header: cardProps.styles?.header || cardProps.headStyle
|
|
736
|
+
} : {})
|
|
737
|
+
},
|
|
738
|
+
...cardProps,
|
|
739
|
+
children: tableContentDom
|
|
740
|
+
});
|
|
741
|
+
const renderTable = () => {
|
|
742
|
+
if (props.tableRender) {
|
|
743
|
+
return props.tableRender(props, tableAreaDom, {
|
|
744
|
+
toolbar: toolbarDom || undefined,
|
|
745
|
+
alert: alertDom || undefined,
|
|
746
|
+
table: tableDom || undefined
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
return tableAreaDom;
|
|
750
|
+
};
|
|
751
|
+
const proTableDom = /*#__PURE__*/_jsxs("div", {
|
|
752
|
+
className: clsx(className, {
|
|
753
|
+
[`${defaultClassName}-polling`]: action.pollingLoading
|
|
754
|
+
}),
|
|
755
|
+
style: style,
|
|
756
|
+
ref: counter.rootDomRef,
|
|
757
|
+
children: [isLightFilter ? null : searchNode, type !== 'form' && props.tableExtraRender && /*#__PURE__*/_jsx("div", {
|
|
758
|
+
className: clsx(className, `${defaultClassName}-extra`),
|
|
759
|
+
children: props.tableExtraRender(props, action.dataSource || [])
|
|
760
|
+
}), type !== 'form' && renderTable()]
|
|
761
|
+
});
|
|
762
|
+
if (!options || !options?.fullScreen) {
|
|
763
|
+
return wrapSSR(proTableDom);
|
|
764
|
+
}
|
|
765
|
+
return wrapSSR( /*#__PURE__*/_jsx(ConfigProvider, {
|
|
766
|
+
getPopupContainer: () => {
|
|
767
|
+
return counter.rootDomRef.current || document.body;
|
|
944
768
|
},
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
tableRef: antTableRef
|
|
948
|
-
})));
|
|
769
|
+
children: proTableDom
|
|
770
|
+
}));
|
|
949
771
|
};
|
|
950
772
|
|
|
951
773
|
/**
|
|
@@ -953,20 +775,33 @@ var ProTable = function ProTable(props) {
|
|
|
953
775
|
*
|
|
954
776
|
* @param props
|
|
955
777
|
*/
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
getPrefixCls
|
|
959
|
-
|
|
960
|
-
|
|
778
|
+
const ProviderTableContainer = props => {
|
|
779
|
+
const {
|
|
780
|
+
getPrefixCls
|
|
781
|
+
} = useContext(ConfigProvider.ConfigContext);
|
|
782
|
+
const ErrorComponent = props.ErrorBoundary === false ? React.Fragment : props.ErrorBoundary || ErrorBoundary;
|
|
783
|
+
const context = useContext(ProConfigContext);
|
|
961
784
|
return /*#__PURE__*/_jsx(Container, {
|
|
962
|
-
initValue:
|
|
785
|
+
initValue: {
|
|
786
|
+
...props,
|
|
787
|
+
columnsState: props.columnsState,
|
|
788
|
+
columns: props.columns,
|
|
789
|
+
onColumnsStateChange: props.onColumnsStateChange,
|
|
790
|
+
onSizeChange: props.onSizeChange,
|
|
791
|
+
size: props.size,
|
|
792
|
+
defaultSize: props.defaultSize
|
|
793
|
+
},
|
|
963
794
|
children: /*#__PURE__*/_jsx(ProConfigProvider, {
|
|
964
|
-
valueTypeMap:
|
|
795
|
+
valueTypeMap: {
|
|
796
|
+
...context.valueTypeMap,
|
|
797
|
+
...ValueTypeToComponent
|
|
798
|
+
},
|
|
965
799
|
needDeps: true,
|
|
966
800
|
children: /*#__PURE__*/_jsx(ErrorComponent, {
|
|
967
|
-
children: /*#__PURE__*/_jsx(ProTable,
|
|
968
|
-
defaultClassName:
|
|
969
|
-
|
|
801
|
+
children: /*#__PURE__*/_jsx(ProTable, {
|
|
802
|
+
defaultClassName: `${getPrefixCls('pro-table')}`,
|
|
803
|
+
...props
|
|
804
|
+
})
|
|
970
805
|
})
|
|
971
806
|
})
|
|
972
807
|
});
|