@ant-design/pro-components 3.1.0-0 → 3.1.1-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.es-PR.md +1 -3
- package/README.md +8 -10
- package/README.zh-CN.md +11 -11
- package/dist/pro-components.min.js +1 -1
- package/es/card/ProCard.js +8 -10
- package/es/card/components/Actions/index.js +25 -25
- package/es/card/components/Actions/style.js +79 -71
- package/es/card/components/Card/index.js +157 -142
- package/es/card/components/Card/style.js +249 -192
- package/es/card/components/CheckCard/Group.js +94 -115
- package/es/card/components/CheckCard/index.js +85 -79
- package/es/card/components/CheckCard/style.js +184 -168
- package/es/card/components/Divider/index.js +19 -15
- package/es/card/components/Divider/style.js +32 -29
- package/es/card/components/Loading/index.js +19 -16
- package/es/card/components/Loading/style.js +34 -31
- package/es/card/components/Operation/index.js +16 -13
- package/es/card/components/Operation/style.js +19 -18
- package/es/card/components/Statistic/index.js +46 -41
- package/es/card/components/Statistic/style.js +89 -70
- package/es/card/components/StatisticCard/index.js +46 -41
- package/es/card/components/StatisticCard/style.js +37 -35
- package/es/descriptions/index.js +214 -225
- package/es/descriptions/useFetchData.js +53 -91
- package/es/field/AllProField.js +265 -216
- package/es/field/FieldHOC/index.js +9 -14
- package/es/field/PureProField.js +82 -80
- package/es/field/ValueTypeToComponent.js +517 -618
- package/es/field/components/Cascader/index.d.ts +3 -3
- package/es/field/components/Cascader/index.js +66 -84
- package/es/field/components/Checkbox/index.d.ts +2 -2
- package/es/field/components/Checkbox/index.js +75 -72
- package/es/field/components/Code/index.js +40 -39
- package/es/field/components/ColorPicker/index.d.ts +2 -2
- package/es/field/components/ColorPicker/index.js +38 -32
- package/es/field/components/DatePicker/index.d.ts +2 -2
- package/es/field/components/DatePicker/index.js +49 -53
- package/es/field/components/Digit/index.js +41 -42
- package/es/field/components/DigitRange/index.js +71 -77
- package/es/field/components/FromNow/index.js +27 -25
- package/es/field/components/Image/index.js +28 -24
- package/es/field/components/IndexColumn/index.js +22 -16
- package/es/field/components/Money/index.js +107 -116
- package/es/field/components/Options/index.js +34 -33
- package/es/field/components/Password/index.js +35 -38
- package/es/field/components/Percent/index.js +40 -44
- package/es/field/components/Percent/util.js +3 -5
- package/es/field/components/Progress/index.js +29 -27
- package/es/field/components/Radio/index.d.ts +1 -1
- package/es/field/components/Radio/index.js +61 -62
- package/es/field/components/RangePicker/index.d.ts +2 -2
- package/es/field/components/RangePicker/index.js +52 -63
- package/es/field/components/Rate/index.js +24 -21
- package/es/field/components/Second/index.js +36 -33
- package/es/field/components/Segmented/index.d.ts +1 -1
- package/es/field/components/Segmented/index.js +37 -46
- package/es/field/components/Select/LightSelect/index.d.ts +1 -1
- package/es/field/components/Select/LightSelect/index.js +102 -109
- package/es/field/components/Select/SearchSelect/index.js +129 -155
- package/es/field/components/Select/index.d.ts +2 -2
- package/es/field/components/Select/index.js +193 -219
- package/es/field/components/Slider/index.js +25 -22
- package/es/field/components/Status/index.js +67 -78
- package/es/field/components/Switch/index.d.ts +1 -1
- package/es/field/components/Switch/index.js +32 -30
- package/es/field/components/Text/index.js +34 -37
- package/es/field/components/TextArea/index.js +26 -21
- package/es/field/components/TextArea/readonly.js +24 -21
- package/es/field/components/TimePicker/index.js +96 -105
- package/es/field/components/TreeSelect/index.d.ts +3 -3
- package/es/field/components/TreeSelect/index.js +107 -125
- package/es/form/BaseForm/BaseForm.js +416 -502
- package/es/form/BaseForm/EditOrReadOnlyContext.js +1 -1
- package/es/form/BaseForm/LightWrapper/index.js +56 -65
- package/es/form/BaseForm/LightWrapper/style.js +17 -13
- package/es/form/BaseForm/Submitter/index.js +44 -43
- package/es/form/FieldContext.js +1 -1
- package/es/form/components/Captcha/index.js +74 -134
- package/es/form/components/Cascader/index.d.ts +1 -1
- package/es/form/components/Cascader/index.js +26 -28
- package/es/form/components/Checkbox/index.js +60 -61
- package/es/form/components/ColorPicker/index.d.ts +1 -1
- package/es/form/components/ColorPicker/index.js +24 -26
- package/es/form/components/DatePicker/BaseDatePicker.js +32 -30
- package/es/form/components/DatePicker/DatePicker.js +14 -13
- package/es/form/components/DatePicker/DateTimePicker.js +11 -12
- package/es/form/components/DatePicker/MonthPicker.js +14 -13
- package/es/form/components/DatePicker/QuarterPicker.js +14 -13
- package/es/form/components/DatePicker/TimePicker.js +26 -27
- package/es/form/components/DatePicker/WeekPicker.js +14 -13
- package/es/form/components/DatePicker/YearPicker.js +14 -13
- package/es/form/components/DatePicker/index.js +1 -1
- package/es/form/components/DateRangePicker/BaseDateRanger.js +34 -34
- package/es/form/components/DateRangePicker/DateMonthRangePicker.js +15 -16
- package/es/form/components/DateRangePicker/DateQuarterRangePicker.js +15 -16
- package/es/form/components/DateRangePicker/DateTimeRangePicker.js +15 -16
- package/es/form/components/DateRangePicker/DateWeekRangePicker.js +15 -16
- package/es/form/components/DateRangePicker/DateYearRangePicker.js +15 -16
- package/es/form/components/DateRangePicker/TimeRangePicker.js +26 -29
- package/es/form/components/DateRangePicker/index.js +15 -16
- package/es/form/components/Dependency/index.js +31 -34
- package/es/form/components/Digit/DigitRange.d.ts +2 -2
- package/es/form/components/Digit/DigitRange.js +23 -24
- package/es/form/components/Digit/index.d.ts +1 -1
- package/es/form/components/Digit/index.js +27 -29
- package/es/form/components/Field/index.js +55 -63
- package/es/form/components/FieldSet/index.js +68 -76
- package/es/form/components/FormItem/FormItemRender/index.js +58 -48
- package/es/form/components/FormItem/Group/index.js +95 -95
- package/es/form/components/FormItem/Group/style.js +46 -40
- package/es/form/components/FormItem/index.js +135 -141
- package/es/form/components/FormItem/warpField.js +165 -149
- package/es/form/components/List/ListContainer.js +98 -189
- package/es/form/components/List/ListItem.js +151 -198
- package/es/form/components/List/index.js +97 -107
- package/es/form/components/List/style.js +71 -47
- package/es/form/components/Money/index.d.ts +1 -1
- package/es/form/components/Money/index.js +28 -30
- package/es/form/components/Radio/index.d.ts +2 -2
- package/es/form/components/Radio/index.js +45 -49
- package/es/form/components/Rate/index.d.ts +1 -1
- package/es/form/components/Rate/index.js +17 -20
- package/es/form/components/SchemaForm/index.js +58 -72
- package/es/form/components/SchemaForm/layoutType/Embed.js +5 -6
- package/es/form/components/SchemaForm/layoutType/StepsForm.js +22 -26
- package/es/form/components/SchemaForm/valueType/dependency.js +11 -11
- package/es/form/components/SchemaForm/valueType/divider.js +4 -5
- package/es/form/components/SchemaForm/valueType/field.js +45 -44
- package/es/form/components/SchemaForm/valueType/formList.js +8 -7
- package/es/form/components/SchemaForm/valueType/formSet.js +8 -7
- package/es/form/components/SchemaForm/valueType/group.js +7 -8
- package/es/form/components/SchemaForm/valueType/ignore.js +2 -2
- package/es/form/components/SchemaForm/valueType/index.js +5 -5
- package/es/form/components/Segmented/index.js +20 -23
- package/es/form/components/Select/index.js +69 -73
- package/es/form/components/Slider/index.d.ts +1 -1
- package/es/form/components/Slider/index.js +33 -35
- package/es/form/components/Switch/index.js +24 -26
- package/es/form/components/Text/index.js +75 -86
- package/es/form/components/TextArea/index.d.ts +1 -1
- package/es/form/components/TextArea/index.js +17 -20
- package/es/form/components/TreeSelect/index.js +20 -23
- package/es/form/components/UploadButton/index.js +56 -103
- package/es/form/components/UploadDragger/index.js +37 -44
- package/es/form/helpers/grid.js +65 -67
- package/es/form/layouts/DrawerForm/index.js +150 -241
- package/es/form/layouts/DrawerForm/style.js +26 -25
- package/es/form/layouts/LightFilter/index.d.ts +12 -1
- package/es/form/layouts/LightFilter/index.js +158 -140
- package/es/form/layouts/LightFilter/style.js +52 -48
- package/es/form/layouts/LoginForm/index.js +44 -47
- package/es/form/layouts/LoginForm/style.js +71 -67
- package/es/form/layouts/LoginFormPage/index.js +45 -48
- package/es/form/layouts/LoginFormPage/style.js +136 -126
- package/es/form/layouts/ModalForm/index.js +119 -203
- package/es/form/layouts/ProForm/index.d.ts +2 -2
- package/es/form/layouts/ProForm/index.js +5 -5
- package/es/form/layouts/QueryFilter/Actions.js +23 -22
- package/es/form/layouts/QueryFilter/index.js +178 -203
- package/es/form/layouts/QueryFilter/style.js +45 -37
- package/es/form/layouts/StepsForm/StepForm.d.ts +2 -3
- package/es/form/layouts/StepsForm/StepForm.js +50 -71
- package/es/form/layouts/StepsForm/index.js +175 -217
- package/es/form/layouts/StepsForm/style.js +30 -28
- package/es/form/layouts/index.js +1 -1
- package/es/layout/ProLayout.js +281 -292
- package/es/layout/WrapContent.js +16 -12
- package/es/layout/assert/Logo.js +95 -97
- package/es/layout/components/AppsLogoComponents/AppsLogo.js +10 -12
- package/es/layout/components/AppsLogoComponents/DefaultContent.js +17 -16
- package/es/layout/components/AppsLogoComponents/SimpleContent.js +19 -18
- package/es/layout/components/AppsLogoComponents/index.js +33 -38
- package/es/layout/components/AppsLogoComponents/style/default.js +2 -2
- package/es/layout/components/AppsLogoComponents/style/index.js +52 -50
- package/es/layout/components/AppsLogoComponents/style/simple.js +1 -1
- package/es/layout/components/CollapsedIcon/index.js +18 -15
- package/es/layout/components/CollapsedIcon/style.js +40 -40
- package/es/layout/components/Footer.js +22 -21
- package/es/layout/components/FooterToolbar/index.js +58 -52
- package/es/layout/components/FooterToolbar/style/index.js +38 -37
- package/es/layout/components/FooterToolbar/style/stylish.js +11 -9
- package/es/layout/components/GlobalFooter/index.js +25 -25
- package/es/layout/components/GlobalFooter/style.js +31 -30
- package/es/layout/components/GlobalHeader/ActionsContent.js +62 -78
- package/es/layout/components/GlobalHeader/index.js +59 -47
- package/es/layout/components/GlobalHeader/rightContentStyle.js +49 -49
- package/es/layout/components/GlobalHeader/style.js +58 -54
- package/es/layout/components/GridContent/index.js +24 -19
- package/es/layout/components/GridContent/style.js +14 -13
- package/es/layout/components/Header/index.js +63 -57
- package/es/layout/components/Header/style/header.js +49 -47
- package/es/layout/components/Header/style/stylish.js +15 -11
- package/es/layout/components/Help/AsyncContentPanel.js +13 -18
- package/es/layout/components/Help/HelpProvide.js +1 -1
- package/es/layout/components/Help/ProHelpContentPanel.js +64 -83
- package/es/layout/components/Help/ProHelpDrawer.js +25 -31
- package/es/layout/components/Help/ProHelpModal.d.ts +1 -1
- package/es/layout/components/Help/ProHelpModal.js +24 -27
- package/es/layout/components/Help/ProHelpPanel.js +86 -94
- package/es/layout/components/Help/ProHelpPopover.js +18 -16
- package/es/layout/components/Help/RenderContentPanel.js +34 -24
- package/es/layout/components/Help/Search.js +52 -78
- package/es/layout/components/Help/index.js +9 -11
- package/es/layout/components/Help/style.js +82 -75
- package/es/layout/components/PageContainer/index.js +168 -149
- package/es/layout/components/PageContainer/style/index.js +95 -78
- package/es/layout/components/PageContainer/style/stylish.js +11 -9
- package/es/layout/components/PageHeader/index.js +96 -97
- package/es/layout/components/PageHeader/style/index.js +142 -122
- package/es/layout/components/PageLoading/index.js +17 -20
- package/es/layout/components/SettingDrawer/BlockCheckbox.js +29 -32
- package/es/layout/components/SettingDrawer/LayoutChange.js +22 -22
- package/es/layout/components/SettingDrawer/RegionalChange.js +14 -15
- package/es/layout/components/SettingDrawer/ThemeColor.js +32 -35
- package/es/layout/components/SettingDrawer/index.js +137 -168
- package/es/layout/components/SettingDrawer/style/index.js +141 -137
- package/es/layout/components/SiderMenu/BaseMenu.js +235 -221
- package/es/layout/components/SiderMenu/SiderMenu.js +125 -115
- package/es/layout/components/SiderMenu/index.js +47 -42
- package/es/layout/components/SiderMenu/style/index.js +179 -161
- package/es/layout/components/SiderMenu/style/menu.js +148 -110
- package/es/layout/components/SiderMenu/style/stylish.js +15 -11
- package/es/layout/components/TopNavHeader/index.js +71 -60
- package/es/layout/components/TopNavHeader/style.js +64 -63
- package/es/layout/context/RouteContext.js +1 -1
- package/es/layout/defaultSettings.js +1 -1
- package/es/layout/getPageTitle.js +23 -24
- package/es/layout/locales/en-US.js +3 -2
- package/es/layout/locales/index.js +5 -5
- package/es/layout/locales/it-IT.js +3 -2
- package/es/layout/locales/ko-KR.js +3 -2
- package/es/layout/locales/zh-CN.js +3 -2
- package/es/layout/locales/zh-TW.js +3 -2
- package/es/layout/style/index.js +48 -42
- package/es/layout/utils/getBreadcrumbProps.js +60 -60
- package/es/layout/utils/getMenuData.js +7 -11
- package/es/layout/utils/pathTools.js +2 -6
- package/es/layout/utils/useCurrentMenuLayoutProps.js +4 -9
- package/es/layout/utils/utils.js +15 -17
- package/es/list/Item.js +157 -137
- package/es/list/ListView.js +106 -115
- package/es/list/constants.js +2 -2
- package/es/list/index.js +72 -70
- package/es/list/style/index.js +281 -213
- package/es/provider/index.js +122 -115
- package/es/provider/intl.js +53 -55
- package/es/provider/typing/layoutToken.js +26 -23
- package/es/provider/useStyle/index.js +51 -59
- package/es/provider/utils/merge.js +10 -12
- package/es/skeleton/components/Descriptions/index.js +211 -229
- package/es/skeleton/components/List/index.js +208 -223
- package/es/skeleton/components/Result/index.js +45 -47
- package/es/skeleton/index.js +13 -10
- package/es/table/Store/Provide.d.ts +4 -4
- package/es/table/Store/Provide.js +102 -117
- package/es/table/Table.d.ts +5 -2
- package/es/table/Table.js +526 -691
- package/es/table/TableSearch.d.ts +24 -0
- package/es/table/TableSearch.js +54 -0
- package/es/table/TableToolbar.d.ts +22 -0
- package/es/table/TableToolbar.js +47 -0
- package/es/table/components/Alert/index.js +41 -40
- package/es/table/components/Alert/style.js +28 -27
- package/es/table/components/ColumnSetting/index.js +228 -223
- package/es/table/components/ColumnSetting/style.js +86 -71
- package/es/table/components/DragSortTable/index.js +65 -79
- package/es/table/components/DragSortTable/style.js +20 -19
- package/es/table/components/Dropdown/index.js +42 -47
- package/es/table/components/EditableTable/CellEditorTable.js +24 -32
- package/es/table/components/EditableTable/RowEditorTable.js +23 -28
- package/es/table/components/EditableTable/index.js +295 -329
- package/es/table/components/Form/FormRender.js +99 -103
- package/es/table/components/Form/index.d.ts +4 -19
- package/es/table/components/Form/index.js +112 -159
- package/es/table/components/ListToolBar/HeaderMenu.js +44 -52
- package/es/table/components/ListToolBar/index.js +122 -147
- package/es/table/components/ListToolBar/style.js +127 -117
- package/es/table/components/ToolBar/DensityIcon.js +10 -9
- package/es/table/components/ToolBar/FullscreenIcon.js +5 -9
- package/es/table/components/ToolBar/index.d.ts +2 -8
- package/es/table/components/ToolBar/index.js +155 -195
- package/es/table/style/index.js +144 -112
- package/es/table/typing.d.ts +4 -0
- package/es/table/useFetchData.js +199 -338
- package/es/table/utils/cellRenderToFromItem.js +105 -119
- package/es/table/utils/columnRender.js +63 -54
- package/es/table/utils/columnSort.js +22 -22
- package/es/table/utils/genProColumnToColumn.d.ts +13 -9
- package/es/table/utils/genProColumnToColumn.js +121 -98
- package/es/table/utils/index.d.ts +10 -0
- package/es/table/utils/index.js +112 -178
- package/es/table/utils/useDragSort.d.ts +1 -1
- package/es/table/utils/useDragSort.js +99 -92
- package/es/table/utils/usePageInfo.d.ts +6 -0
- package/es/table/utils/usePageInfo.js +55 -0
- package/es/utils/components/DropdownFooter/index.js +23 -21
- package/es/utils/components/DropdownFooter/style.js +16 -15
- package/es/utils/components/ErrorBoundary/index.js +27 -50
- package/es/utils/components/FieldLabel/index.js +70 -70
- package/es/utils/components/FieldLabel/style.js +104 -81
- package/es/utils/components/FilterDropdown/index.d.ts +11 -0
- package/es/utils/components/FilterDropdown/index.js +43 -32
- package/es/utils/components/FilterDropdown/style.js +19 -16
- package/es/utils/components/InlineErrorFormItem/index.js +78 -78
- package/es/utils/components/InlineErrorFormItem/style.js +56 -49
- package/es/utils/components/LabelIconTip/index.js +30 -31
- package/es/utils/components/LabelIconTip/style.js +36 -35
- package/es/utils/components/ProFormContext/index.js +1 -1
- package/es/utils/conversionMomentValue/index.js +19 -22
- package/es/utils/dateArrayFormatter/index.js +9 -14
- package/es/utils/genCopyable/index.js +74 -32
- package/es/utils/getFieldPropsOrFormItemProps/index.js +1 -1
- package/es/utils/hooks/useDebounceFn/index.js +18 -51
- package/es/utils/hooks/useDebounceValue/index.js +7 -16
- package/es/utils/hooks/useDeepCompareEffect/index.js +6 -18
- package/es/utils/hooks/useDocumentTitle/index.js +2 -2
- package/es/utils/hooks/useFetchData/index.js +36 -65
- package/es/utils/hooks/useForceRender/index.js +2 -9
- package/es/utils/hooks/useLatest/index.js +2 -2
- package/es/utils/hooks/usePrevious/index.js +3 -3
- package/es/utils/hooks/useReactiveRef/index.js +2 -2
- package/es/utils/hooks/useRefCallback/index.js +3 -3
- package/es/utils/hooks/useRefFunction/index.js +4 -9
- package/es/utils/index.d.ts +1 -2
- package/es/utils/index.js +1 -2
- package/es/utils/isBrowser/index.js +2 -2
- package/es/utils/isDeepEqualReact/index.js +9 -44
- package/es/utils/isDropdownValueType/index.js +2 -2
- package/es/utils/isNil/index.js +1 -3
- package/es/utils/isUrl/index.js +2 -2
- package/es/utils/merge/index.js +10 -12
- package/es/utils/nanoid/index.js +5 -6
- package/es/utils/omitBoolean/index.js +1 -1
- package/es/utils/omitUndefined/index.js +3 -3
- package/es/utils/omitUndefinedAndEmptyArr/index.js +4 -5
- package/es/utils/parseValueToMoment/index.js +3 -7
- package/es/utils/pickProFormItemProps/index.js +3 -3
- package/es/utils/pickProProps/index.js +6 -7
- package/es/utils/proFieldParsingText/index.js +85 -98
- package/es/utils/runFunction/index.js +2 -5
- package/es/utils/stringify/index.js +1 -1
- package/es/utils/transformKeySubmitValue/index.js +99 -116
- package/es/utils/useEditableArray/index.d.ts +6 -1
- package/es/utils/useEditableArray/index.js +579 -735
- package/es/utils/useEditableMap/index.d.ts +1 -1
- package/es/utils/useEditableMap/index.js +89 -135
- package/es/utils/useMediaQuery/index.d.ts +2 -2
- package/es/utils/useMediaQuery/index.js +37 -34
- package/es/utils/useMediaQuery/query.js +7 -17
- package/es/version.js +1 -1
- package/guidelines/Guidelines.md +33 -0
- package/guidelines/components/drawer-form.md +90 -0
- package/guidelines/components/editable-pro-table.md +150 -0
- package/guidelines/components/modal-form.md +88 -0
- package/guidelines/components/pro-card.md +90 -0
- package/guidelines/components/pro-form.md +96 -0
- package/guidelines/components/pro-layout.md +84 -0
- package/guidelines/components/pro-table.md +142 -0
- package/guidelines/components/steps-form.md +105 -0
- package/guidelines/design-tokens/colors.md +58 -0
- package/guidelines/design-tokens/layout.md +53 -0
- package/guidelines/design-tokens/typography.md +49 -0
- package/guidelines/overview-components.md +55 -0
- package/guidelines/overview-icons.md +23 -0
- package/lib/card/ProCard.js +8 -10
- package/lib/card/components/Actions/index.js +25 -25
- package/lib/card/components/Actions/style.js +79 -72
- package/lib/card/components/Card/index.js +154 -139
- package/lib/card/components/Card/style.js +249 -193
- package/lib/card/components/CheckCard/Group.js +97 -115
- package/lib/card/components/CheckCard/index.js +85 -78
- package/lib/card/components/CheckCard/style.js +184 -169
- package/lib/card/components/Divider/index.js +20 -16
- package/lib/card/components/Divider/style.js +32 -30
- package/lib/card/components/Loading/index.js +19 -16
- package/lib/card/components/Loading/style.js +34 -32
- package/lib/card/components/Operation/index.js +16 -14
- package/lib/card/components/Operation/style.js +19 -19
- package/lib/card/components/Statistic/index.js +46 -42
- package/lib/card/components/Statistic/style.js +89 -71
- package/lib/card/components/StatisticCard/index.js +46 -41
- package/lib/card/components/StatisticCard/style.js +37 -36
- package/lib/card/index.js +4 -4
- package/lib/descriptions/index.js +219 -225
- package/lib/descriptions/useFetchData.js +51 -90
- package/lib/field/AllProField.js +267 -217
- package/lib/field/FieldHOC/index.js +9 -15
- package/lib/field/PureProField.js +84 -82
- package/lib/field/ValueTypeToComponent.js +517 -618
- package/lib/field/components/Cascader/index.d.ts +2 -2
- package/lib/field/components/Cascader/index.js +66 -85
- package/lib/field/components/Checkbox/index.d.ts +1 -1
- package/lib/field/components/Checkbox/index.js +75 -73
- package/lib/field/components/Code/index.js +40 -39
- package/lib/field/components/ColorPicker/index.js +38 -33
- package/lib/field/components/DatePicker/index.d.ts +1 -1
- package/lib/field/components/DatePicker/index.js +49 -53
- package/lib/field/components/Digit/index.js +41 -43
- package/lib/field/components/DigitRange/index.js +69 -76
- package/lib/field/components/FromNow/index.js +27 -25
- package/lib/field/components/Image/index.js +28 -24
- package/lib/field/components/IndexColumn/index.js +22 -17
- package/lib/field/components/Money/index.js +106 -116
- package/lib/field/components/Options/index.js +34 -34
- package/lib/field/components/Password/index.js +35 -38
- package/lib/field/components/Percent/index.js +40 -45
- package/lib/field/components/Percent/util.js +3 -6
- package/lib/field/components/Progress/index.js +29 -28
- package/lib/field/components/Radio/index.d.ts +1 -1
- package/lib/field/components/Radio/index.js +61 -63
- package/lib/field/components/RangePicker/index.d.ts +1 -1
- package/lib/field/components/RangePicker/index.js +52 -63
- package/lib/field/components/Rate/index.js +24 -21
- package/lib/field/components/Second/index.js +36 -33
- package/lib/field/components/Segmented/index.d.ts +1 -1
- package/lib/field/components/Segmented/index.js +37 -48
- package/lib/field/components/Select/LightSelect/index.d.ts +1 -1
- package/lib/field/components/Select/LightSelect/index.js +103 -110
- package/lib/field/components/Select/SearchSelect/index.js +133 -156
- package/lib/field/components/Select/index.d.ts +1 -1
- package/lib/field/components/Select/index.js +194 -218
- package/lib/field/components/Slider/index.js +25 -22
- package/lib/field/components/Status/index.js +69 -79
- package/lib/field/components/Switch/index.d.ts +1 -1
- package/lib/field/components/Switch/index.js +32 -31
- package/lib/field/components/Text/index.js +34 -38
- package/lib/field/components/TextArea/index.js +26 -21
- package/lib/field/components/TextArea/readonly.js +24 -22
- package/lib/field/components/TimePicker/index.js +96 -105
- package/lib/field/components/TreeSelect/index.d.ts +2 -2
- package/lib/field/components/TreeSelect/index.js +105 -124
- package/lib/field/index.js +34 -34
- package/lib/form/BaseForm/BaseForm.js +413 -499
- package/lib/form/BaseForm/EditOrReadOnlyContext.js +1 -1
- package/lib/form/BaseForm/LightWrapper/index.js +57 -66
- package/lib/form/BaseForm/LightWrapper/style.js +17 -14
- package/lib/form/BaseForm/Submitter/index.js +44 -44
- package/lib/form/BaseForm/index.js +3 -3
- package/lib/form/FieldContext.js +1 -1
- package/lib/form/components/Captcha/index.js +74 -135
- package/lib/form/components/Cascader/index.js +26 -29
- package/lib/form/components/Checkbox/index.js +60 -61
- package/lib/form/components/ColorPicker/index.js +24 -26
- package/lib/form/components/DatePicker/BaseDatePicker.js +32 -30
- package/lib/form/components/DatePicker/DatePicker.js +14 -13
- package/lib/form/components/DatePicker/DateTimePicker.js +11 -12
- package/lib/form/components/DatePicker/MonthPicker.js +14 -13
- package/lib/form/components/DatePicker/QuarterPicker.js +14 -13
- package/lib/form/components/DatePicker/TimePicker.js +26 -27
- package/lib/form/components/DatePicker/WeekPicker.js +14 -13
- package/lib/form/components/DatePicker/YearPicker.js +14 -13
- package/lib/form/components/DatePicker/index.js +1 -1
- package/lib/form/components/DateRangePicker/BaseDateRanger.js +34 -34
- package/lib/form/components/DateRangePicker/DateMonthRangePicker.js +15 -16
- package/lib/form/components/DateRangePicker/DateQuarterRangePicker.js +15 -16
- package/lib/form/components/DateRangePicker/DateTimeRangePicker.js +15 -16
- package/lib/form/components/DateRangePicker/DateWeekRangePicker.js +15 -16
- package/lib/form/components/DateRangePicker/DateYearRangePicker.js +15 -16
- package/lib/form/components/DateRangePicker/TimeRangePicker.js +26 -29
- package/lib/form/components/DateRangePicker/index.js +15 -16
- package/lib/form/components/Dependency/index.js +31 -35
- package/lib/form/components/Digit/DigitRange.js +23 -24
- package/lib/form/components/Digit/index.js +27 -29
- package/lib/form/components/Field/index.js +55 -63
- package/lib/form/components/FieldSet/index.js +68 -76
- package/lib/form/components/FormItem/FormItemRender/index.js +58 -48
- package/lib/form/components/FormItem/Group/index.js +95 -95
- package/lib/form/components/FormItem/Group/style.js +46 -41
- package/lib/form/components/FormItem/index.js +135 -141
- package/lib/form/components/FormItem/warpField.js +165 -149
- package/lib/form/components/List/ListContainer.js +100 -191
- package/lib/form/components/List/ListItem.js +153 -200
- package/lib/form/components/List/index.js +97 -107
- package/lib/form/components/List/style.js +71 -48
- package/lib/form/components/Money/index.js +28 -30
- package/lib/form/components/Radio/index.js +45 -49
- package/lib/form/components/Rate/index.js +17 -21
- package/lib/form/components/SchemaForm/index.js +54 -68
- package/lib/form/components/SchemaForm/layoutType/Embed.js +5 -6
- package/lib/form/components/SchemaForm/layoutType/StepsForm.js +22 -26
- package/lib/form/components/SchemaForm/layoutType/index.js +2 -2
- package/lib/form/components/SchemaForm/valueType/dependency.js +13 -12
- package/lib/form/components/SchemaForm/valueType/divider.js +6 -7
- package/lib/form/components/SchemaForm/valueType/field.js +47 -45
- package/lib/form/components/SchemaForm/valueType/formList.js +10 -9
- package/lib/form/components/SchemaForm/valueType/formSet.js +10 -8
- package/lib/form/components/SchemaForm/valueType/group.js +9 -10
- package/lib/form/components/SchemaForm/valueType/ignore.js +4 -3
- package/lib/form/components/SchemaForm/valueType/index.js +7 -6
- package/lib/form/components/Segmented/index.js +20 -24
- package/lib/form/components/Select/index.js +69 -73
- package/lib/form/components/Slider/index.js +33 -35
- package/lib/form/components/Switch/index.js +24 -26
- package/lib/form/components/Text/index.js +73 -84
- package/lib/form/components/TextArea/index.js +17 -21
- package/lib/form/components/TreeSelect/index.js +20 -23
- package/lib/form/components/UploadButton/index.js +56 -103
- package/lib/form/components/UploadDragger/index.js +37 -44
- package/lib/form/components/index.js +42 -42
- package/lib/form/helpers/grid.js +68 -69
- package/lib/form/helpers/index.js +1 -1
- package/lib/form/index.js +8 -8
- package/lib/form/layouts/DrawerForm/index.js +149 -241
- package/lib/form/layouts/DrawerForm/style.js +26 -26
- package/lib/form/layouts/LightFilter/index.d.ts +12 -1
- package/lib/form/layouts/LightFilter/index.js +158 -141
- package/lib/form/layouts/LightFilter/style.js +52 -49
- package/lib/form/layouts/LoginForm/index.js +44 -48
- package/lib/form/layouts/LoginForm/style.js +71 -68
- package/lib/form/layouts/LoginFormPage/index.js +45 -49
- package/lib/form/layouts/LoginFormPage/style.js +136 -127
- package/lib/form/layouts/ModalForm/index.js +118 -203
- package/lib/form/layouts/ProForm/index.d.ts +1 -1
- package/lib/form/layouts/ProForm/index.js +5 -5
- package/lib/form/layouts/QueryFilter/Actions.js +23 -22
- package/lib/form/layouts/QueryFilter/index.js +177 -202
- package/lib/form/layouts/QueryFilter/style.js +45 -38
- package/lib/form/layouts/StepsForm/StepForm.d.ts +2 -3
- package/lib/form/layouts/StepsForm/StepForm.js +50 -72
- package/lib/form/layouts/StepsForm/index.js +174 -216
- package/lib/form/layouts/StepsForm/style.js +30 -29
- package/lib/form/layouts/index.js +9 -9
- package/lib/index.js +11 -11
- package/lib/layout/ProLayout.js +281 -292
- package/lib/layout/WrapContent.js +18 -14
- package/lib/layout/assert/Logo.js +96 -97
- package/lib/layout/components/AppsLogoComponents/AppsLogo.js +11 -12
- package/lib/layout/components/AppsLogoComponents/DefaultContent.js +19 -17
- package/lib/layout/components/AppsLogoComponents/SimpleContent.js +22 -19
- package/lib/layout/components/AppsLogoComponents/index.js +36 -40
- package/lib/layout/components/AppsLogoComponents/style/default.js +4 -3
- package/lib/layout/components/AppsLogoComponents/style/index.js +52 -51
- package/lib/layout/components/AppsLogoComponents/style/simple.js +3 -2
- package/lib/layout/components/CollapsedIcon/index.js +20 -17
- package/lib/layout/components/CollapsedIcon/style.js +40 -41
- package/lib/layout/components/Footer.js +23 -22
- package/lib/layout/components/FooterToolbar/index.js +59 -53
- package/lib/layout/components/FooterToolbar/style/index.js +38 -38
- package/lib/layout/components/FooterToolbar/style/stylish.js +11 -10
- package/lib/layout/components/GlobalFooter/index.js +27 -27
- package/lib/layout/components/GlobalFooter/style.js +31 -31
- package/lib/layout/components/GlobalHeader/ActionsContent.js +65 -81
- package/lib/layout/components/GlobalHeader/index.js +61 -49
- package/lib/layout/components/GlobalHeader/rightContentStyle.js +49 -50
- package/lib/layout/components/GlobalHeader/style.js +58 -55
- package/lib/layout/components/GridContent/index.js +26 -21
- package/lib/layout/components/GridContent/style.js +14 -14
- package/lib/layout/components/Header/index.js +65 -59
- package/lib/layout/components/Header/style/header.js +49 -48
- package/lib/layout/components/Header/style/stylish.js +15 -12
- package/lib/layout/components/Help/AsyncContentPanel.js +15 -20
- package/lib/layout/components/Help/HelpProvide.js +1 -1
- package/lib/layout/components/Help/ProHelpContentPanel.js +66 -85
- package/lib/layout/components/Help/ProHelpDrawer.js +27 -32
- package/lib/layout/components/Help/ProHelpModal.d.ts +1 -1
- package/lib/layout/components/Help/ProHelpModal.js +26 -28
- package/lib/layout/components/Help/ProHelpPanel.js +86 -94
- package/lib/layout/components/Help/ProHelpPopover.js +20 -18
- package/lib/layout/components/Help/RenderContentPanel.js +36 -26
- package/lib/layout/components/Help/Search.js +55 -80
- package/lib/layout/components/Help/index.js +19 -20
- package/lib/layout/components/Help/style.js +82 -76
- package/lib/layout/components/PageContainer/index.js +172 -151
- package/lib/layout/components/PageContainer/style/index.js +95 -79
- package/lib/layout/components/PageContainer/style/stylish.js +11 -10
- package/lib/layout/components/PageHeader/index.js +99 -99
- package/lib/layout/components/PageHeader/style/index.js +142 -123
- package/lib/layout/components/PageLoading/index.js +18 -20
- package/lib/layout/components/SettingDrawer/BlockCheckbox.js +31 -34
- package/lib/layout/components/SettingDrawer/LayoutChange.js +25 -23
- package/lib/layout/components/SettingDrawer/RegionalChange.js +16 -16
- package/lib/layout/components/SettingDrawer/ThemeColor.js +34 -36
- package/lib/layout/components/SettingDrawer/index.js +138 -168
- package/lib/layout/components/SettingDrawer/style/index.js +141 -138
- package/lib/layout/components/SiderMenu/BaseMenu.js +235 -221
- package/lib/layout/components/SiderMenu/SiderMenu.js +128 -117
- package/lib/layout/components/SiderMenu/index.js +49 -44
- package/lib/layout/components/SiderMenu/style/index.js +179 -162
- package/lib/layout/components/SiderMenu/style/menu.js +148 -111
- package/lib/layout/components/SiderMenu/style/stylish.js +15 -12
- package/lib/layout/components/TopNavHeader/index.js +73 -62
- package/lib/layout/components/TopNavHeader/style.js +64 -64
- package/lib/layout/context/RouteContext.js +1 -1
- package/lib/layout/defaultSettings.js +1 -1
- package/lib/layout/getPageTitle.js +27 -26
- package/lib/layout/index.js +16 -16
- package/lib/layout/locales/en-US.js +3 -2
- package/lib/layout/locales/index.js +8 -6
- package/lib/layout/locales/it-IT.js +3 -2
- package/lib/layout/locales/ko-KR.js +3 -2
- package/lib/layout/locales/zh-CN.js +3 -2
- package/lib/layout/locales/zh-TW.js +3 -2
- package/lib/layout/style/index.js +48 -43
- package/lib/layout/utils/getBreadcrumbProps.js +65 -62
- package/lib/layout/utils/getMenuData.js +9 -13
- package/lib/layout/utils/pathTools.js +2 -6
- package/lib/layout/utils/useCurrentMenuLayoutProps.js +6 -11
- package/lib/layout/utils/utils.js +16 -18
- package/lib/list/Item.js +155 -136
- package/lib/list/ListView.js +110 -119
- package/lib/list/constants.js +2 -2
- package/lib/list/index.js +72 -70
- package/lib/list/style/index.js +281 -214
- package/lib/provider/index.js +128 -118
- package/lib/provider/intl.js +56 -56
- package/lib/provider/typing/layoutToken.js +28 -25
- package/lib/provider/useStyle/index.js +55 -60
- package/lib/provider/utils/merge.js +12 -14
- package/lib/skeleton/components/Descriptions/index.js +213 -229
- package/lib/skeleton/components/List/index.js +211 -221
- package/lib/skeleton/components/Result/index.js +45 -47
- package/lib/skeleton/index.js +23 -19
- package/lib/table/Store/Provide.d.ts +4 -4
- package/lib/table/Store/Provide.js +103 -117
- package/lib/table/Table.d.ts +5 -2
- package/lib/table/Table.js +524 -689
- package/lib/table/TableSearch.d.ts +24 -0
- package/lib/table/TableSearch.js +61 -0
- package/lib/table/TableToolbar.d.ts +22 -0
- package/lib/table/TableToolbar.js +55 -0
- package/lib/table/components/Alert/index.js +41 -40
- package/lib/table/components/Alert/style.js +28 -28
- package/lib/table/components/ColumnSetting/index.js +228 -224
- package/lib/table/components/ColumnSetting/style.js +86 -72
- package/lib/table/components/DragSortTable/index.js +64 -78
- package/lib/table/components/DragSortTable/style.js +20 -20
- package/lib/table/components/Dropdown/index.js +42 -48
- package/lib/table/components/EditableTable/CellEditorTable.js +24 -32
- package/lib/table/components/EditableTable/RowEditorTable.js +23 -28
- package/lib/table/components/EditableTable/index.js +293 -327
- package/lib/table/components/Form/FormRender.js +99 -104
- package/lib/table/components/Form/index.d.ts +4 -19
- package/lib/table/components/Form/index.js +113 -159
- package/lib/table/components/ListToolBar/HeaderMenu.js +42 -51
- package/lib/table/components/ListToolBar/index.js +123 -148
- package/lib/table/components/ListToolBar/style.js +127 -118
- package/lib/table/components/ToolBar/DensityIcon.js +10 -9
- package/lib/table/components/ToolBar/FullscreenIcon.js +5 -10
- package/lib/table/components/ToolBar/index.d.ts +2 -8
- package/lib/table/components/ToolBar/index.js +154 -194
- package/lib/table/index.js +27 -27
- package/lib/table/style/index.js +144 -113
- package/lib/table/typing.d.ts +4 -0
- package/lib/table/useFetchData.js +197 -337
- package/lib/table/utils/cellRenderToFromItem.js +106 -120
- package/lib/table/utils/columnRender.js +65 -54
- package/lib/table/utils/columnSort.js +24 -23
- package/lib/table/utils/genProColumnToColumn.d.ts +13 -9
- package/lib/table/utils/genProColumnToColumn.js +121 -99
- package/lib/table/utils/index.d.ts +10 -0
- package/lib/table/utils/index.js +127 -181
- package/lib/table/utils/useDragSort.d.ts +1 -1
- package/lib/table/utils/useDragSort.js +99 -93
- package/lib/table/utils/usePageInfo.d.ts +6 -0
- package/lib/table/utils/usePageInfo.js +61 -0
- package/lib/utils/components/DropdownFooter/index.js +25 -23
- package/lib/utils/components/DropdownFooter/style.js +16 -16
- package/lib/utils/components/ErrorBoundary/index.js +28 -50
- package/lib/utils/components/FieldLabel/index.js +70 -71
- package/lib/utils/components/FieldLabel/style.js +104 -82
- package/lib/utils/components/FilterDropdown/index.d.ts +11 -0
- package/lib/utils/components/FilterDropdown/index.js +44 -33
- package/lib/utils/components/FilterDropdown/style.js +19 -17
- package/lib/utils/components/InlineErrorFormItem/index.js +80 -80
- package/lib/utils/components/InlineErrorFormItem/style.js +56 -50
- package/lib/utils/components/LabelIconTip/index.js +30 -32
- package/lib/utils/components/LabelIconTip/style.js +36 -36
- package/lib/utils/components/ProFormContext/index.js +1 -1
- package/lib/utils/conversionMomentValue/index.js +22 -23
- package/lib/utils/dateArrayFormatter/index.js +11 -15
- package/lib/utils/genCopyable/index.js +75 -33
- package/lib/utils/getFieldPropsOrFormItemProps/index.js +3 -2
- package/lib/utils/hooks/useDebounceFn/index.js +18 -52
- package/lib/utils/hooks/useDebounceValue/index.js +7 -17
- package/lib/utils/hooks/useDeepCompareEffect/index.js +7 -19
- package/lib/utils/hooks/useDocumentTitle/index.js +2 -2
- package/lib/utils/hooks/useFetchData/index.js +36 -65
- package/lib/utils/hooks/useForceRender/index.js +2 -10
- package/lib/utils/hooks/useLatest/index.js +4 -3
- package/lib/utils/hooks/usePrevious/index.js +5 -4
- package/lib/utils/hooks/useReactiveRef/index.js +2 -2
- package/lib/utils/hooks/useRefCallback/index.js +3 -3
- package/lib/utils/hooks/useRefFunction/index.js +6 -11
- package/lib/utils/index.d.ts +1 -2
- package/lib/utils/index.js +57 -65
- package/lib/utils/isBrowser/index.js +4 -3
- package/lib/utils/isDeepEqualReact/index.js +9 -45
- package/lib/utils/isDropdownValueType/index.js +4 -3
- package/lib/utils/isNil/index.js +2 -3
- package/lib/utils/isUrl/index.js +4 -3
- package/lib/utils/merge/index.js +12 -14
- package/lib/utils/nanoid/index.js +7 -7
- package/lib/utils/omitBoolean/index.js +3 -2
- package/lib/utils/omitUndefined/index.js +5 -4
- package/lib/utils/omitUndefinedAndEmptyArr/index.js +6 -6
- package/lib/utils/parseValueToMoment/index.js +5 -8
- package/lib/utils/pickProFormItemProps/index.js +3 -3
- package/lib/utils/pickProProps/index.js +6 -7
- package/lib/utils/proFieldParsingText/index.js +89 -99
- package/lib/utils/runFunction/index.js +2 -5
- package/lib/utils/stringify/index.js +2 -2
- package/lib/utils/transformKeySubmitValue/index.js +101 -117
- package/lib/utils/useEditableArray/index.d.ts +6 -1
- package/lib/utils/useEditableArray/index.js +582 -735
- package/lib/utils/useEditableMap/index.d.ts +1 -1
- package/lib/utils/useEditableMap/index.js +88 -135
- package/lib/utils/useMediaQuery/index.js +40 -35
- package/lib/utils/useMediaQuery/query.js +7 -18
- package/lib/version.js +1 -1
- package/package.json +20 -31
- package/es/utils/useMountMergeState/index.d.ts +0 -2
- package/es/utils/useMountMergeState/index.js +0 -2
- package/lib/utils/useMountMergeState/index.d.ts +0 -2
- package/lib/utils/useMountMergeState/index.js +0 -12
|
@@ -1,46 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = void 0;
|
|
8
|
-
var
|
|
9
|
-
var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
|
|
10
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
13
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
14
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
7
|
+
var _util = require("@rc-component/util");
|
|
15
8
|
var _react = require("react");
|
|
16
9
|
var _utils = require("../utils");
|
|
17
10
|
var _index = require("./utils/index");
|
|
18
|
-
var
|
|
19
|
-
/**
|
|
20
|
-
* 组合用户的配置和默认值
|
|
21
|
-
*
|
|
22
|
-
* @param param0
|
|
23
|
-
*/
|
|
24
|
-
var mergeOptionAndPageInfo = function mergeOptionAndPageInfo(_ref) {
|
|
25
|
-
var pageInfo = _ref.pageInfo;
|
|
26
|
-
if (pageInfo) {
|
|
27
|
-
var current = pageInfo.current,
|
|
28
|
-
defaultCurrent = pageInfo.defaultCurrent,
|
|
29
|
-
pageSize = pageInfo.pageSize,
|
|
30
|
-
defaultPageSize = pageInfo.defaultPageSize;
|
|
31
|
-
return {
|
|
32
|
-
current: current || defaultCurrent || 1,
|
|
33
|
-
total: 0,
|
|
34
|
-
pageSize: pageSize || defaultPageSize || 20
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
return {
|
|
38
|
-
current: 1,
|
|
39
|
-
total: 0,
|
|
40
|
-
pageSize: 20
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
|
|
11
|
+
var _usePageInfo = require("./utils/usePageInfo");
|
|
44
12
|
/**
|
|
45
13
|
* useFetchData hook 用来获取数据并控制数据的状态和分页
|
|
46
14
|
* @template T
|
|
@@ -50,18 +18,13 @@ var mergeOptionAndPageInfo = function mergeOptionAndPageInfo(_ref) {
|
|
|
50
18
|
* @param {UseFetchProps} options - 配置项,包括了默认的分页参数、格式化数据的函数等
|
|
51
19
|
* @returns {UseFetchDataAction} 返回一个对象,包含当前的数据列表、loading 状态、error、以及可控制的分页参数等
|
|
52
20
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* 用于保存组件是否被卸载的状态的引用
|
|
57
|
-
* @type {React.MutableRefObject<boolean>}
|
|
58
|
-
*/
|
|
59
|
-
var umountRef = (0, _react.useRef)(false);
|
|
21
|
+
const useFetchData = (getData, defaultData, options) => {
|
|
22
|
+
const umountRef = (0, _react.useRef)(false);
|
|
60
23
|
/**
|
|
61
24
|
* 用于保存 AbortController 实例的引用,方便需要时进行请求的取消操作
|
|
62
25
|
* @type {React.MutableRefObject<AbortController | null>}
|
|
63
26
|
*/
|
|
64
|
-
|
|
27
|
+
const abortRef = (0, _react.useRef)(null);
|
|
65
28
|
/**
|
|
66
29
|
* useFetchData 钩子的配置项
|
|
67
30
|
* @typedef {object} UseFetchProps
|
|
@@ -71,82 +34,65 @@ var useFetchData = function useFetchData(getData, defaultData, options) {
|
|
|
71
34
|
* @property {function} [onRequestError] 请求错误的回调函数
|
|
72
35
|
* @property {number} [debounceTime=20] 防抖时间,单位为毫秒,默认为 20ms
|
|
73
36
|
*/
|
|
74
|
-
|
|
75
|
-
onLoad
|
|
76
|
-
manual
|
|
77
|
-
polling
|
|
78
|
-
onRequestError
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
effects = _ref2$effects === void 0 ? [] : _ref2$effects;
|
|
37
|
+
const {
|
|
38
|
+
onLoad,
|
|
39
|
+
manual,
|
|
40
|
+
polling,
|
|
41
|
+
onRequestError,
|
|
42
|
+
debounceTime = 20,
|
|
43
|
+
effects = []
|
|
44
|
+
} = options || {};
|
|
83
45
|
|
|
84
46
|
/** 是否首次加载的指示器 */
|
|
85
|
-
|
|
47
|
+
const manualRequestRef = (0, _react.useRef)(manual);
|
|
86
48
|
|
|
87
49
|
/** 轮询的setTime ID 存储 */
|
|
88
|
-
|
|
50
|
+
const pollingSetTimeRef = (0, _react.useRef)();
|
|
89
51
|
|
|
90
52
|
/**
|
|
91
53
|
* 用于存储最新的数据,这样可以在切换的时候保持数据的一致性
|
|
92
54
|
*/
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
55
|
+
const [tableDataList, setTableDataListInner] = (0, _util.useControlledState)(defaultData, options?.dataSource);
|
|
56
|
+
const setTableDataList = (0, _react.useCallback)(updater => {
|
|
57
|
+
setTableDataListInner(prev => {
|
|
58
|
+
const next = typeof updater === 'function' ? updater(prev) : updater;
|
|
59
|
+
options?.onDataSourceChange?.(next);
|
|
60
|
+
return next;
|
|
61
|
+
});
|
|
62
|
+
}, [options?.onDataSourceChange]);
|
|
100
63
|
|
|
101
64
|
/**
|
|
102
65
|
* 表格的加载状态
|
|
103
66
|
*/
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
67
|
+
const tableLoadingValue = typeof options?.loading === 'object' ? options?.loading?.spinning : options?.loading;
|
|
68
|
+
const [tableLoading, setTableLoadingInner] = (0, _util.useControlledState)(false, tableLoadingValue);
|
|
69
|
+
const setTableLoading = (0, _react.useCallback)(updater => {
|
|
70
|
+
setTableLoadingInner(prev => {
|
|
71
|
+
const next = typeof updater === 'function' ? updater(prev) : updater;
|
|
72
|
+
options?.onLoadingChange?.(next);
|
|
73
|
+
return next;
|
|
74
|
+
});
|
|
75
|
+
}, [options?.onLoadingChange]);
|
|
111
76
|
|
|
112
77
|
/**
|
|
113
|
-
* 表示页面信息的类型
|
|
78
|
+
* 表示页面信息的类型
|
|
114
79
|
* @typedef {object} PageInfo
|
|
115
80
|
* @property {number} current 当前页码
|
|
116
81
|
* @property {number} pageSize 页面大小
|
|
117
82
|
* @property {number} total 数据总量
|
|
118
83
|
* @type {[PageInfo, React.Dispatch<React.SetStateAction<PageInfo>>]}
|
|
119
84
|
*/
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}, {
|
|
123
|
-
onChange: options === null || options === void 0 ? void 0 : options.onPageInfoChange
|
|
124
|
-
}),
|
|
125
|
-
_useMountMergeState6 = (0, _slicedToArray2.default)(_useMountMergeState5, 2),
|
|
126
|
-
pageInfo = _useMountMergeState6[0],
|
|
127
|
-
setPageInfoState = _useMountMergeState6[1];
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* 用于比较并设置页面信息和回调函数的引用更新
|
|
131
|
-
* @type {React.MutableRefObject<(changePageInfo: PageInfo) => void>}
|
|
132
|
-
*/
|
|
133
|
-
var _setPageInfo = (0, _utils.useRefFunction)(function (changePageInfo) {
|
|
134
|
-
if (changePageInfo.current !== pageInfo.current || changePageInfo.pageSize !== pageInfo.pageSize || changePageInfo.total !== pageInfo.total) {
|
|
135
|
-
setPageInfoState(changePageInfo);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
var _useMountMergeState7 = (0, _utils.useMountMergeState)(false),
|
|
139
|
-
_useMountMergeState8 = (0, _slicedToArray2.default)(_useMountMergeState7, 2),
|
|
140
|
-
pollingLoading = _useMountMergeState8[0],
|
|
141
|
-
setPollingLoading = _useMountMergeState8[1];
|
|
85
|
+
const [pageInfo, setPageInfo] = (0, _usePageInfo.usePageInfo)(options);
|
|
86
|
+
const [pollingLoading, setPollingLoading] = (0, _react.useState)(false);
|
|
142
87
|
|
|
143
88
|
// Batching update https://github.com/facebook/react/issues/14259
|
|
144
|
-
|
|
89
|
+
const setDataAndLoading = (newData, dataTotal) => {
|
|
145
90
|
setTableDataList(newData);
|
|
146
|
-
if (
|
|
147
|
-
|
|
91
|
+
if (pageInfo?.total !== dataTotal) {
|
|
92
|
+
setPageInfo({
|
|
93
|
+
...pageInfo,
|
|
148
94
|
total: dataTotal || newData.length
|
|
149
|
-
})
|
|
95
|
+
});
|
|
150
96
|
}
|
|
151
97
|
};
|
|
152
98
|
|
|
@@ -154,109 +100,85 @@ var useFetchData = function useFetchData(getData, defaultData, options) {
|
|
|
154
100
|
* 上一页的页码
|
|
155
101
|
* @type {number}
|
|
156
102
|
*/
|
|
157
|
-
|
|
103
|
+
const prePage = (0, _utils.usePrevious)(pageInfo?.current);
|
|
158
104
|
|
|
159
105
|
/**
|
|
160
106
|
* 上一页的页面大小
|
|
161
107
|
* @type {number}
|
|
162
108
|
*/
|
|
163
|
-
|
|
109
|
+
const prePageSize = (0, _utils.usePrevious)(pageInfo?.pageSize);
|
|
164
110
|
|
|
165
111
|
/**
|
|
166
112
|
* 上一页的轮询时间
|
|
167
113
|
* @type {number|boolean}
|
|
168
114
|
*/
|
|
169
|
-
|
|
115
|
+
const prePolling = (0, _utils.usePrevious)(polling);
|
|
170
116
|
|
|
171
117
|
/**
|
|
172
118
|
* 不这样做会导致状态不更新
|
|
173
119
|
* https://github.com/ant-design/pro-components/issues/4390
|
|
174
120
|
*/
|
|
175
|
-
|
|
121
|
+
const requestFinally = (0, _utils.useRefFunction)(() => {
|
|
176
122
|
setTableLoading(false);
|
|
177
123
|
setPollingLoading(false);
|
|
178
124
|
});
|
|
179
125
|
/** 请求数据 */
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
if (!(onRequestError === undefined)) {
|
|
237
|
-
_context.next = 31;
|
|
238
|
-
break;
|
|
239
|
-
}
|
|
240
|
-
throw new Error(_context.t1);
|
|
241
|
-
case 31:
|
|
242
|
-
if (tableDataList === undefined) setTableDataList([]);
|
|
243
|
-
onRequestError(_context.t1);
|
|
244
|
-
case 33:
|
|
245
|
-
_context.prev = 33;
|
|
246
|
-
requestFinally();
|
|
247
|
-
return _context.finish(33);
|
|
248
|
-
case 36:
|
|
249
|
-
return _context.abrupt("return", []);
|
|
250
|
-
case 37:
|
|
251
|
-
case "end":
|
|
252
|
-
return _context.stop();
|
|
253
|
-
}
|
|
254
|
-
}, _callee, null, [[5, 27, 33, 36]]);
|
|
255
|
-
}));
|
|
256
|
-
return function fetchList(_x) {
|
|
257
|
-
return _ref3.apply(this, arguments);
|
|
258
|
-
};
|
|
259
|
-
}();
|
|
126
|
+
const fetchList = async (isPolling, signal) => {
|
|
127
|
+
// 需要手动触发的首次请求
|
|
128
|
+
if (manualRequestRef.current) {
|
|
129
|
+
manualRequestRef.current = false;
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (!isPolling) {
|
|
133
|
+
setTableLoading(true);
|
|
134
|
+
} else {
|
|
135
|
+
setPollingLoading(true);
|
|
136
|
+
}
|
|
137
|
+
const {
|
|
138
|
+
pageSize,
|
|
139
|
+
current
|
|
140
|
+
} = pageInfo || {};
|
|
141
|
+
try {
|
|
142
|
+
const pageParams = options?.pageInfo !== false ? {
|
|
143
|
+
current,
|
|
144
|
+
pageSize
|
|
145
|
+
} : undefined;
|
|
146
|
+
const {
|
|
147
|
+
data = [],
|
|
148
|
+
success,
|
|
149
|
+
total = 0,
|
|
150
|
+
...rest
|
|
151
|
+
} = (await getData?.(pageParams)) || {};
|
|
152
|
+
// 如果被取消了,直接返回
|
|
153
|
+
if (signal?.aborted) {
|
|
154
|
+
return [];
|
|
155
|
+
}
|
|
156
|
+
// 如果失败了,直接返回,不走剩下的逻辑了
|
|
157
|
+
if (success === false) return [];
|
|
158
|
+
const responseData = (0, _index.postDataPipeline)(data, [options.postData].filter(item => item));
|
|
159
|
+
// 设置表格数据
|
|
160
|
+
if (signal?.aborted) {
|
|
161
|
+
return [];
|
|
162
|
+
}
|
|
163
|
+
setDataAndLoading(responseData, total);
|
|
164
|
+
onLoad?.(responseData, rest);
|
|
165
|
+
return responseData;
|
|
166
|
+
} catch (e) {
|
|
167
|
+
// 如果被取消了,直接返回
|
|
168
|
+
if (signal?.aborted) {
|
|
169
|
+
return [];
|
|
170
|
+
}
|
|
171
|
+
// 如果没有传递这个方法的话,需要把错误抛出去,以免吞掉错误
|
|
172
|
+
if (onRequestError === undefined) throw new Error(e);
|
|
173
|
+
if (tableDataList === undefined) setTableDataList([]);
|
|
174
|
+
onRequestError(e);
|
|
175
|
+
} finally {
|
|
176
|
+
if (!signal?.aborted) {
|
|
177
|
+
requestFinally();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return [];
|
|
181
|
+
};
|
|
260
182
|
|
|
261
183
|
/**
|
|
262
184
|
* 该函数用于进行数据请求,可以用于轮询或单次请求。
|
|
@@ -264,118 +186,96 @@ var useFetchData = function useFetchData(getData, defaultData, options) {
|
|
|
264
186
|
* 若需要轮询,则在一定时间后再次调用该函数,最小时间为 200ms,避免一直处于 loading 状态。
|
|
265
187
|
* 如果请求被取消,则返回空。
|
|
266
188
|
*/
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
return _context2.abrupt("return", msg);
|
|
317
|
-
case 16:
|
|
318
|
-
_context2.prev = 16;
|
|
319
|
-
_context2.t0 = _context2["catch"](5);
|
|
320
|
-
if (!(_context2.t0 === 'aborted')) {
|
|
321
|
-
_context2.next = 20;
|
|
322
|
-
break;
|
|
323
|
-
}
|
|
324
|
-
return _context2.abrupt("return");
|
|
325
|
-
case 20:
|
|
326
|
-
throw _context2.t0;
|
|
327
|
-
case 21:
|
|
328
|
-
case "end":
|
|
329
|
-
return _context2.stop();
|
|
330
|
-
}
|
|
331
|
-
}, _callee2, null, [[5, 16]]);
|
|
332
|
-
}));
|
|
333
|
-
return function (_x2) {
|
|
334
|
-
return _ref6.apply(this, arguments);
|
|
335
|
-
};
|
|
336
|
-
}(), debounceTime || 30);
|
|
189
|
+
const fetchListDebounce = (0, _utils.useDebounceFn)(async isPolling => {
|
|
190
|
+
if (pollingSetTimeRef.current) {
|
|
191
|
+
clearTimeout(pollingSetTimeRef.current);
|
|
192
|
+
}
|
|
193
|
+
if (!getData) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const abort = new AbortController();
|
|
197
|
+
abortRef.current = abort;
|
|
198
|
+
try {
|
|
199
|
+
/**
|
|
200
|
+
* 这段代码使用了 Promise.race,同时发起了两个异步请求。
|
|
201
|
+
* fetchList 函数发起一个数据请求,而第二个 Promise 是等待通过 AbortSignal 取得一个信号。
|
|
202
|
+
* 如果第二个 Promise 得到了一个 AbortSignal 的信号,就会触发 reject,Promise.race 的结果也会结束。
|
|
203
|
+
* 这样,就达到了取消请求的目的。如果 fetchList 函数先返回了结果,那么该结果就是 Promise.race 的结果,
|
|
204
|
+
* 此时第二个 Promise 就会被取消。
|
|
205
|
+
*/
|
|
206
|
+
const msg = await Promise.race([fetchList(isPolling, abort.signal), new Promise((_, reject) => {
|
|
207
|
+
abortRef.current?.signal?.addEventListener?.('abort', () => {
|
|
208
|
+
reject('aborted');
|
|
209
|
+
// 结束请求,并且清空loading控制
|
|
210
|
+
fetchListDebounce.cancel();
|
|
211
|
+
requestFinally();
|
|
212
|
+
});
|
|
213
|
+
})]);
|
|
214
|
+
if (abort.signal.aborted) return;
|
|
215
|
+
// 放到请求前面会导致数据是上一次的
|
|
216
|
+
const needPolling = (0, _utils.runFunction)(polling, msg);
|
|
217
|
+
|
|
218
|
+
/*
|
|
219
|
+
* 这段代码是用于控制轮询的。其中,needPolling 参数表明当前是否需要进行轮询,umountRef 是一个 ref,用来记录组件是否被卸载。
|
|
220
|
+
* 如果需要轮询并且组件没有被卸载,就会调用 setTimeout,等待一定的时间,然后再次调用 fetchListDebounce 函数,并传入需要轮询的时间参数。
|
|
221
|
+
* 其中 Math.max(needPolling, 2000) 用于确定最小的轮询时间为 2000ms,避免频繁请求导致一直处于 loading 状态。
|
|
222
|
+
*/
|
|
223
|
+
if (needPolling && !umountRef.current) {
|
|
224
|
+
pollingSetTimeRef.current = setTimeout(() => {
|
|
225
|
+
fetchListDebounce.run(needPolling);
|
|
226
|
+
// 这里判断最小要2000ms,不然一直loading
|
|
227
|
+
}, Math.max(needPolling, 2000));
|
|
228
|
+
}
|
|
229
|
+
return msg;
|
|
230
|
+
} catch (error) {
|
|
231
|
+
if (error === 'aborted') {
|
|
232
|
+
return [];
|
|
233
|
+
}
|
|
234
|
+
throw error;
|
|
235
|
+
}
|
|
236
|
+
}, debounceTime || 30);
|
|
337
237
|
|
|
338
238
|
/**
|
|
339
239
|
* 取消请求
|
|
340
240
|
*/
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
(_abortRef$current2 = abortRef.current) === null || _abortRef$current2 === void 0 || _abortRef$current2.abort();
|
|
241
|
+
const abortFetch = () => {
|
|
242
|
+
abortRef.current?.abort();
|
|
344
243
|
fetchListDebounce.cancel();
|
|
345
244
|
requestFinally();
|
|
346
245
|
};
|
|
347
246
|
|
|
348
247
|
// 如果轮询结束了,直接销毁定时器
|
|
349
|
-
(0, _react.useEffect)(
|
|
248
|
+
(0, _react.useEffect)(() => {
|
|
350
249
|
if (!polling) {
|
|
351
250
|
clearTimeout(pollingSetTimeRef.current);
|
|
352
251
|
}
|
|
353
252
|
if (!prePolling && polling) {
|
|
354
253
|
fetchListDebounce.run(true);
|
|
355
254
|
}
|
|
356
|
-
return
|
|
255
|
+
return () => {
|
|
357
256
|
clearTimeout(pollingSetTimeRef.current);
|
|
358
257
|
};
|
|
359
258
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
360
259
|
}, [polling]);
|
|
361
|
-
(0, _react.useEffect)(
|
|
260
|
+
(0, _react.useEffect)(() => {
|
|
362
261
|
umountRef.current = false;
|
|
363
|
-
return
|
|
262
|
+
return () => {
|
|
364
263
|
umountRef.current = true;
|
|
365
264
|
};
|
|
366
265
|
}, []);
|
|
367
266
|
|
|
368
267
|
/** PageIndex 改变的时候自动刷新 */
|
|
369
|
-
(0, _react.useEffect)(
|
|
370
|
-
|
|
371
|
-
current
|
|
372
|
-
pageSize
|
|
268
|
+
(0, _react.useEffect)(() => {
|
|
269
|
+
const {
|
|
270
|
+
current,
|
|
271
|
+
pageSize
|
|
272
|
+
} = pageInfo || {};
|
|
373
273
|
// 如果上次的页码为空或者两次页码等于是没必要查询的
|
|
374
274
|
// 如果 pageSize 发生变化是需要查询的,所以又加了 prePageSize
|
|
375
275
|
if ((!prePage || prePage === current) && (!prePageSize || prePageSize === pageSize)) {
|
|
376
276
|
return;
|
|
377
277
|
}
|
|
378
|
-
if (options.pageInfo && tableDataList &&
|
|
278
|
+
if (options.pageInfo && tableDataList && tableDataList?.length > pageSize || 0) {
|
|
379
279
|
return;
|
|
380
280
|
}
|
|
381
281
|
|
|
@@ -389,24 +289,24 @@ var useFetchData = function useFetchData(getData, defaultData, options) {
|
|
|
389
289
|
fetchListDebounce.run(false);
|
|
390
290
|
}
|
|
391
291
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
392
|
-
}, [pageInfo
|
|
292
|
+
}, [pageInfo?.current]);
|
|
393
293
|
|
|
394
294
|
// pageSize 修改后返回第一页
|
|
395
|
-
(0, _react.useEffect)(
|
|
295
|
+
(0, _react.useEffect)(() => {
|
|
396
296
|
if (!prePageSize) {
|
|
397
297
|
return;
|
|
398
298
|
}
|
|
399
299
|
abortFetch();
|
|
400
300
|
fetchListDebounce.run(false);
|
|
401
301
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
402
|
-
}, [pageInfo
|
|
302
|
+
}, [pageInfo?.pageSize]);
|
|
403
303
|
|
|
404
304
|
/**
|
|
405
305
|
* 检查是否有正在进行的请求需要被中止。如果是,则使用 abortRef 中的方法来中止请求。
|
|
406
306
|
* 接下来,使用名为 fetchListDebounce 的防抖函数并传入 false 参数。这个函数可以防止请求过于频繁地发出,通过延迟执行传递给它的函数来实现。
|
|
407
307
|
* 最后,检查是否有正在进行的请求,如果有,则中止它。
|
|
408
308
|
*/
|
|
409
|
-
(0, _utils.useDeepCompareEffect)(
|
|
309
|
+
(0, _utils.useDeepCompareEffect)(() => {
|
|
410
310
|
abortFetch();
|
|
411
311
|
fetchListDebounce.run(false);
|
|
412
312
|
if (!manual) {
|
|
@@ -414,10 +314,10 @@ var useFetchData = function useFetchData(getData, defaultData, options) {
|
|
|
414
314
|
// 用于跟踪当前的请求是否是手动发起的。
|
|
415
315
|
manualRequestRef.current = false;
|
|
416
316
|
}
|
|
417
|
-
return
|
|
317
|
+
return () => {
|
|
418
318
|
abortFetch();
|
|
419
319
|
};
|
|
420
|
-
}, [
|
|
320
|
+
}, [...effects, manual]);
|
|
421
321
|
return {
|
|
422
322
|
/**
|
|
423
323
|
* 表格的数据列表。
|
|
@@ -434,40 +334,24 @@ var useFetchData = function useFetchData(getData, defaultData, options) {
|
|
|
434
334
|
* 表示表格是否正在加载数据的标志。
|
|
435
335
|
* @type {boolean}
|
|
436
336
|
*/
|
|
437
|
-
loading:
|
|
337
|
+
loading: typeof options?.loading === 'object' ? {
|
|
338
|
+
...options?.loading,
|
|
438
339
|
spinning: tableLoading
|
|
439
|
-
}
|
|
340
|
+
} : tableLoading,
|
|
440
341
|
/**
|
|
441
342
|
* 重新加载表格数据的函数。
|
|
442
343
|
* @type {function}
|
|
443
344
|
* @async
|
|
444
345
|
* @returns {Promise<boolean>} - 数据重新加载完成后解决为 true 的 Promise。
|
|
445
346
|
*/
|
|
446
|
-
reload:
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
manualRequestRef.current = false;
|
|
455
|
-
_context3.next = 4;
|
|
456
|
-
return fetchListDebounce.run(false);
|
|
457
|
-
case 4:
|
|
458
|
-
result = _context3.sent;
|
|
459
|
-
return _context3.abrupt("return", result);
|
|
460
|
-
case 6:
|
|
461
|
-
case "end":
|
|
462
|
-
return _context3.stop();
|
|
463
|
-
}
|
|
464
|
-
}, _callee3);
|
|
465
|
-
}));
|
|
466
|
-
function reload() {
|
|
467
|
-
return _reload.apply(this, arguments);
|
|
468
|
-
}
|
|
469
|
-
return reload;
|
|
470
|
-
}(),
|
|
347
|
+
reload: async () => {
|
|
348
|
+
abortFetch();
|
|
349
|
+
// 对于手动 reload,我们需要强制执行请求,即使在 manualRequest 模式下
|
|
350
|
+
manualRequestRef.current = false;
|
|
351
|
+
const result = await fetchListDebounce.run(false);
|
|
352
|
+
// 如果之前是手动模式,不要重置为 true,因为用户已经手动触发了请求
|
|
353
|
+
return result;
|
|
354
|
+
},
|
|
471
355
|
/**
|
|
472
356
|
* 当前的分页信息。
|
|
473
357
|
* @type {Object}
|
|
@@ -475,43 +359,33 @@ var useFetchData = function useFetchData(getData, defaultData, options) {
|
|
|
475
359
|
* @prop {number} total - 总数据数量。
|
|
476
360
|
* @prop {number} pageSize - 每页数据数量。
|
|
477
361
|
*/
|
|
478
|
-
pageInfo
|
|
362
|
+
pageInfo,
|
|
479
363
|
/**
|
|
480
364
|
* 表示表格是否正在进行轮询请求的标志。
|
|
481
365
|
* @type {boolean}
|
|
482
366
|
*/
|
|
483
|
-
pollingLoading
|
|
367
|
+
pollingLoading,
|
|
484
368
|
/**
|
|
485
369
|
* 重置分页信息为其初始值的函数。
|
|
486
370
|
* @type {function}
|
|
487
371
|
* @async
|
|
488
372
|
* @returns {Promise<void>} - 重置完成后解决的 Promise。
|
|
489
373
|
*/
|
|
490
|
-
reset:
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
case "end":
|
|
506
|
-
return _context4.stop();
|
|
507
|
-
}
|
|
508
|
-
}, _callee4);
|
|
509
|
-
}));
|
|
510
|
-
function reset() {
|
|
511
|
-
return _reset.apply(this, arguments);
|
|
512
|
-
}
|
|
513
|
-
return reset;
|
|
514
|
-
}(),
|
|
374
|
+
reset: async () => {
|
|
375
|
+
const {
|
|
376
|
+
pageInfo: optionPageInfo
|
|
377
|
+
} = options || {};
|
|
378
|
+
const {
|
|
379
|
+
defaultCurrent = 1,
|
|
380
|
+
defaultPageSize = 20
|
|
381
|
+
} = optionPageInfo || {};
|
|
382
|
+
const initialPageInfo = {
|
|
383
|
+
current: defaultCurrent,
|
|
384
|
+
total: 0,
|
|
385
|
+
pageSize: defaultPageSize
|
|
386
|
+
};
|
|
387
|
+
setPageInfo(initialPageInfo);
|
|
388
|
+
},
|
|
515
389
|
/**
|
|
516
390
|
* 更新分页信息的函数。
|
|
517
391
|
* @type {function}
|
|
@@ -522,23 +396,9 @@ var useFetchData = function useFetchData(getData, defaultData, options) {
|
|
|
522
396
|
* @prop {number} [pageSize] - 新的每页数据数量。
|
|
523
397
|
* @returns {Promise<void>} - 更新完成后解决的 Promise。
|
|
524
398
|
*/
|
|
525
|
-
setPageInfo:
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
529
|
-
case 0:
|
|
530
|
-
_setPageInfo((0, _objectSpread2.default)((0, _objectSpread2.default)({}, pageInfo), info));
|
|
531
|
-
case 1:
|
|
532
|
-
case "end":
|
|
533
|
-
return _context5.stop();
|
|
534
|
-
}
|
|
535
|
-
}, _callee5);
|
|
536
|
-
}));
|
|
537
|
-
function setPageInfo(_x3) {
|
|
538
|
-
return _setPageInfo2.apply(this, arguments);
|
|
539
|
-
}
|
|
540
|
-
return setPageInfo;
|
|
541
|
-
}()
|
|
399
|
+
setPageInfo: async info => {
|
|
400
|
+
setPageInfo(info);
|
|
401
|
+
}
|
|
542
402
|
};
|
|
543
403
|
};
|
|
544
404
|
var _default = exports.default = useFetchData;
|