@ant-design/pro-components 3.1.1-1 → 3.1.3-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pro-components.min.js +1 -1
- package/es/card/components/Card/index.js +17 -3
- package/es/descriptions/index.d.ts +0 -2
- package/es/descriptions/index.js +1 -5
- package/es/descriptions/useFetchData.js +17 -2
- package/es/field/components/Cascader/index.d.ts +3 -3
- package/es/field/components/Cascader/index.js +0 -2
- package/es/field/components/Checkbox/index.d.ts +2 -2
- package/es/field/components/Checkbox/index.js +2 -0
- package/es/field/components/Code/index.js +1 -8
- package/es/field/components/ColorPicker/index.d.ts +2 -2
- package/es/field/components/DatePicker/index.d.ts +2 -2
- package/es/field/components/DatePicker/index.js +3 -5
- package/es/field/components/FromNow/index.d.ts +1 -0
- package/es/field/components/FromNow/index.js +2 -2
- package/es/field/components/Money/index.js +0 -1
- package/es/field/components/Progress/index.js +1 -2
- package/es/field/components/Radio/index.d.ts +1 -1
- package/es/field/components/RangePicker/index.d.ts +2 -2
- package/es/field/components/RangePicker/index.js +3 -11
- package/es/field/components/Segmented/index.d.ts +1 -1
- package/es/field/components/Select/LightSelect/index.d.ts +3 -1
- package/es/field/components/Select/LightSelect/index.js +3 -1
- package/es/field/components/Select/index.d.ts +2 -2
- package/es/field/components/Select/index.js +1 -4
- package/es/field/components/Switch/index.d.ts +1 -1
- package/es/field/components/Switch/index.js +2 -1
- package/es/field/components/TimePicker/index.d.ts +2 -0
- package/es/field/components/TimePicker/index.js +9 -8
- package/es/field/components/TreeSelect/index.d.ts +3 -3
- package/es/field/components/TreeSelect/index.js +2 -2
- package/es/form/BaseForm/BaseForm.js +16 -2
- package/es/form/BaseForm/LightWrapper/index.js +7 -1
- package/es/form/BaseForm/Submitter/index.js +2 -2
- package/es/form/components/Cascader/index.d.ts +1 -1
- package/es/form/components/ColorPicker/index.d.ts +1 -1
- package/es/form/components/DatePicker/DateTimePicker.js +1 -0
- package/es/form/components/DateRangePicker/DateTimeRangePicker.d.ts +1 -1
- package/es/form/components/DateRangePicker/DateTimeRangePicker.js +1 -3
- package/es/form/components/Digit/DigitRange.d.ts +2 -2
- package/es/form/components/Digit/index.d.ts +1 -1
- package/es/form/components/Field/index.d.ts +0 -1
- package/es/form/components/Field/index.js +3 -5
- package/es/form/components/FormItem/FormItemRender/index.d.ts +1 -0
- package/es/form/components/FormItem/Group/index.js +17 -3
- package/es/form/components/FormItem/index.d.ts +1 -0
- package/es/form/components/FormItem/index.js +16 -31
- package/es/form/components/FormItem/warpField.js +1 -0
- package/es/form/components/Money/index.d.ts +1 -1
- package/es/form/components/Radio/index.d.ts +2 -2
- package/es/form/components/Rate/index.d.ts +1 -1
- package/es/form/components/Slider/index.d.ts +1 -1
- package/es/form/components/TextArea/index.d.ts +1 -1
- package/es/form/helpers/grid.d.ts +7 -3
- package/es/form/helpers/grid.js +19 -4
- package/es/form/layouts/DrawerForm/index.js +16 -2
- package/es/form/layouts/LightFilter/index.js +7 -4
- package/es/form/layouts/ModalForm/index.js +17 -2
- package/es/form/layouts/ProForm/index.d.ts +1 -1
- package/es/form/layouts/QueryFilter/index.js +17 -3
- package/es/form/layouts/StepsForm/index.js +16 -2
- package/es/layout/ProLayout.js +33 -5
- package/es/layout/components/AppsLogoComponents/style/index.js +1 -0
- package/es/layout/components/SettingDrawer/index.js +33 -5
- package/es/layout/components/SiderMenu/BaseMenu.js +0 -2
- package/es/list/ListView.js +6 -3
- package/es/provider/index.d.ts +0 -4
- package/es/provider/index.js +1 -1
- package/es/table/Store/Provide.d.ts +0 -1
- package/es/table/Store/Provide.js +1 -1
- package/es/table/Table.js +0 -1
- package/es/table/typing.d.ts +0 -4
- package/es/table/useFetchData.js +16 -2
- package/es/table/utils/cellRenderToFromItem.d.ts +1 -1
- package/es/table/utils/columnRender.d.ts +1 -1
- package/es/table/utils/columnRender.js +1 -4
- package/es/table/utils/genProColumnToColumn.d.ts +2 -2
- package/es/table/utils/index.d.ts +0 -10
- package/es/table/utils/index.js +0 -12
- package/es/utils/components/FieldLabel/index.js +3 -3
- package/es/utils/components/FieldLabel/style.js +23 -4
- package/es/utils/components/FilterDropdown/index.js +1 -1
- package/es/utils/components/FilterDropdown/style.js +10 -0
- package/es/utils/pickProProps/index.js +1 -1
- package/es/utils/useEditableArray/index.d.ts +1 -1
- package/es/utils/useEditableArray/index.js +1 -1
- package/es/utils/useLazyKVMap.d.ts +5 -0
- package/es/utils/useLazyKVMap.js +28 -0
- package/es/utils/useMediaQuery/index.d.ts +2 -2
- package/es/utils/usePagination.d.ts +8 -0
- package/es/utils/usePagination.js +67 -0
- package/es/utils/useSelection.d.ts +19 -0
- package/es/utils/useSelection.js +86 -0
- package/lib/card/components/Card/index.js +16 -2
- package/lib/descriptions/index.d.ts +0 -2
- package/lib/descriptions/index.js +1 -5
- package/lib/descriptions/useFetchData.js +17 -2
- package/lib/field/components/Cascader/index.js +0 -2
- package/lib/field/components/Checkbox/index.js +2 -0
- package/lib/field/components/Code/index.js +1 -8
- package/lib/field/components/DatePicker/index.js +3 -5
- package/lib/field/components/FromNow/index.d.ts +1 -0
- package/lib/field/components/FromNow/index.js +2 -2
- package/lib/field/components/Money/index.js +0 -1
- package/lib/field/components/Progress/index.js +1 -2
- package/lib/field/components/RangePicker/index.js +3 -11
- package/lib/field/components/Select/LightSelect/index.d.ts +2 -0
- package/lib/field/components/Select/LightSelect/index.js +3 -1
- package/lib/field/components/Select/index.js +1 -4
- package/lib/field/components/Switch/index.js +2 -1
- package/lib/field/components/TimePicker/index.d.ts +2 -0
- package/lib/field/components/TimePicker/index.js +9 -8
- package/lib/field/components/TreeSelect/index.js +2 -2
- package/lib/form/BaseForm/BaseForm.js +16 -2
- package/lib/form/BaseForm/LightWrapper/index.js +7 -1
- package/lib/form/BaseForm/Submitter/index.js +2 -2
- package/lib/form/components/DatePicker/DateTimePicker.js +1 -0
- package/lib/form/components/DateRangePicker/DateTimeRangePicker.d.ts +1 -1
- package/lib/form/components/DateRangePicker/DateTimeRangePicker.js +1 -3
- package/lib/form/components/Field/index.d.ts +0 -1
- package/lib/form/components/Field/index.js +1 -3
- package/lib/form/components/FormItem/FormItemRender/index.d.ts +1 -0
- package/lib/form/components/FormItem/Group/index.js +16 -2
- package/lib/form/components/FormItem/index.d.ts +1 -0
- package/lib/form/components/FormItem/index.js +16 -31
- package/lib/form/components/FormItem/warpField.js +1 -0
- package/lib/form/helpers/grid.d.ts +7 -3
- package/lib/form/helpers/grid.js +20 -4
- package/lib/form/layouts/DrawerForm/index.js +16 -2
- package/lib/form/layouts/LightFilter/index.js +7 -4
- package/lib/form/layouts/ModalForm/index.js +17 -2
- package/lib/form/layouts/QueryFilter/index.js +16 -2
- package/lib/form/layouts/StepsForm/index.js +16 -2
- package/lib/layout/ProLayout.js +32 -4
- package/lib/layout/components/AppsLogoComponents/style/index.js +1 -0
- package/lib/layout/components/SettingDrawer/index.js +32 -4
- package/lib/layout/components/SiderMenu/BaseMenu.js +0 -2
- package/lib/list/ListView.js +7 -4
- package/lib/provider/index.d.ts +0 -4
- package/lib/provider/index.js +1 -1
- package/lib/table/Store/Provide.d.ts +0 -1
- package/lib/table/Store/Provide.js +1 -1
- package/lib/table/Table.js +0 -1
- package/lib/table/typing.d.ts +0 -4
- package/lib/table/useFetchData.js +16 -2
- package/lib/table/utils/cellRenderToFromItem.d.ts +1 -1
- package/lib/table/utils/columnRender.d.ts +1 -1
- package/lib/table/utils/columnRender.js +1 -4
- package/lib/table/utils/genProColumnToColumn.d.ts +2 -2
- package/lib/table/utils/index.d.ts +0 -10
- package/lib/table/utils/index.js +3 -15
- package/lib/utils/components/FieldLabel/index.js +3 -3
- package/lib/utils/components/FieldLabel/style.js +23 -4
- package/lib/utils/components/FilterDropdown/index.js +1 -1
- package/lib/utils/components/FilterDropdown/style.js +10 -0
- package/lib/utils/pickProProps/index.js +1 -1
- package/lib/utils/useEditableArray/index.d.ts +1 -1
- package/lib/utils/useEditableArray/index.js +2 -2
- package/lib/utils/useLazyKVMap.d.ts +5 -0
- package/lib/utils/useLazyKVMap.js +34 -0
- package/lib/utils/usePagination.d.ts +8 -0
- package/lib/utils/usePagination.js +74 -0
- package/lib/utils/useSelection.d.ts +19 -0
- package/lib/utils/useSelection.js +93 -0
- package/package.json +2 -1
package/es/layout/ProLayout.js
CHANGED
|
@@ -5,7 +5,7 @@ import { clsx } from 'clsx';
|
|
|
5
5
|
import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
6
6
|
import useSWR, { useSWRConfig } from 'swr';
|
|
7
7
|
import { ProConfigProvider, ProProvider, isNeedOpenHash } from "../provider";
|
|
8
|
-
import { isBrowser, useBreakpoint, useDocumentTitle } from "../utils";
|
|
8
|
+
import { isBrowser, useBreakpoint, useDocumentTitle, useRefFunction } from "../utils";
|
|
9
9
|
import { Logo } from "./assert/Logo";
|
|
10
10
|
import { DefaultFooter as Footer } from "./components/Footer";
|
|
11
11
|
import { DefaultHeader as Header } from "./components/Header";
|
|
@@ -165,13 +165,27 @@ const BaseProLayout = props => {
|
|
|
165
165
|
const context = useContext(ConfigProvider.ConfigContext);
|
|
166
166
|
const prefixCls = props.prefixCls ?? context.getPrefixCls('pro');
|
|
167
167
|
const [menuLoading, setMenuLoadingInner] = useControlledState(false, menu?.loading);
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* 使用 useRefFunction 包装回调,确保引用稳定
|
|
171
|
+
*/
|
|
172
|
+
const menuOnLoadingChange = useRefFunction(loading => {
|
|
173
|
+
menu?.onLoadingChange?.(loading);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* 包装 setMenuLoading,使用 queueMicrotask 延迟回调调用
|
|
178
|
+
* 避免在渲染阶段调用外部回调导致的 React 警告
|
|
179
|
+
*/
|
|
168
180
|
const setMenuLoading = useCallback(updater => {
|
|
169
181
|
setMenuLoadingInner(prev => {
|
|
170
182
|
const next = typeof updater === 'function' ? updater(prev) : updater;
|
|
171
|
-
|
|
183
|
+
queueMicrotask(() => {
|
|
184
|
+
menuOnLoadingChange(next);
|
|
185
|
+
});
|
|
172
186
|
return next;
|
|
173
187
|
});
|
|
174
|
-
}, [
|
|
188
|
+
}, [menuOnLoadingChange]);
|
|
175
189
|
|
|
176
190
|
// give a default key for swr
|
|
177
191
|
const [defaultId] = useState(() => {
|
|
@@ -272,13 +286,27 @@ const BaseProLayout = props => {
|
|
|
272
286
|
if (colSize === 'md') return true;
|
|
273
287
|
return false;
|
|
274
288
|
}, props.collapsed);
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* 使用 useRefFunction 包装回调,确保引用稳定
|
|
292
|
+
*/
|
|
293
|
+
const onCollapseCallback = useRefFunction(c => {
|
|
294
|
+
propsOnCollapse?.(c);
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* 使用 queueMicrotask 延迟回调调用,避免在渲染阶段调用外部回调导致的 React 警告
|
|
299
|
+
* "Cannot update a component while rendering a different component"
|
|
300
|
+
*/
|
|
275
301
|
const onCollapse = useCallback(updater => {
|
|
276
302
|
onCollapseInner(prev => {
|
|
277
303
|
const next = typeof updater === 'function' ? updater(prev) : updater;
|
|
278
|
-
|
|
304
|
+
queueMicrotask(() => {
|
|
305
|
+
onCollapseCallback(next);
|
|
306
|
+
});
|
|
279
307
|
return next;
|
|
280
308
|
});
|
|
281
|
-
}, [
|
|
309
|
+
}, [onCollapseCallback]);
|
|
282
310
|
|
|
283
311
|
// Splicing parameters, adding menuData and formatMessage in props
|
|
284
312
|
const defaultProps = omit({
|
|
@@ -22,6 +22,7 @@ const genAppsLogoComponentsStyle = token => {
|
|
|
22
22
|
backgroundColor: token.layout?.colorBgAppListIconHover
|
|
23
23
|
},
|
|
24
24
|
'&-active': {
|
|
25
|
+
borderRadius: token.borderRadius,
|
|
25
26
|
color: token.layout?.colorTextAppListIconHover,
|
|
26
27
|
backgroundColor: token.layout?.colorBgAppListIconHover
|
|
27
28
|
}
|
|
@@ -3,7 +3,7 @@ import { omit, useControlledState } from '@rc-component/util';
|
|
|
3
3
|
import { useUrlSearchParams } from '@umijs/use-params';
|
|
4
4
|
import { Alert, Button, Divider, Drawer, List, Switch, message } from 'antd';
|
|
5
5
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
6
|
-
import { isBrowser, merge } from "../../../utils";
|
|
6
|
+
import { isBrowser, merge, useRefFunction } from "../../../utils";
|
|
7
7
|
import { defaultSettings } from "../../defaultSettings";
|
|
8
8
|
import { gLocaleObject, getLanguage } from "../../locales";
|
|
9
9
|
import { genStringToTheme } from "../../utils/utils";
|
|
@@ -144,25 +144,53 @@ export const SettingDrawer = props => {
|
|
|
144
144
|
} = props;
|
|
145
145
|
const firstRender = useRef(true);
|
|
146
146
|
const [open, setOpenInner] = useControlledState(false, props.collapse);
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* 使用 useRefFunction 包装回调,确保引用稳定
|
|
150
|
+
*/
|
|
151
|
+
const onCollapseChangeCallback = useRefFunction(o => {
|
|
152
|
+
props.onCollapseChange?.(o);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* 使用 queueMicrotask 延迟回调调用,避免在渲染阶段调用外部回调导致的 React 警告
|
|
157
|
+
* "Cannot update a component while rendering a different component"
|
|
158
|
+
*/
|
|
147
159
|
const setOpen = useCallback(updater => {
|
|
148
160
|
setOpenInner(prev => {
|
|
149
161
|
const next = typeof updater === 'function' ? updater(prev) : updater;
|
|
150
|
-
|
|
162
|
+
queueMicrotask(() => {
|
|
163
|
+
onCollapseChangeCallback(next);
|
|
164
|
+
});
|
|
151
165
|
return next;
|
|
152
166
|
});
|
|
153
|
-
}, [
|
|
167
|
+
}, [onCollapseChangeCallback]);
|
|
154
168
|
const [language, setLanguage] = useState(getLanguage());
|
|
155
169
|
const [urlParams, setUrlParams] = useUrlSearchParams({}, {
|
|
156
170
|
disabled: disableUrlParams
|
|
157
171
|
});
|
|
158
172
|
const [settingState, setSettingStateInner] = useControlledState(() => getParamsFromUrl(urlParams, propsSettings || propsDefaultSettings), propsSettings);
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 使用 useRefFunction 包装回调,确保引用稳定
|
|
176
|
+
*/
|
|
177
|
+
const onSettingChangeCallback = useRefFunction(settings => {
|
|
178
|
+
onSettingChange?.(settings);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* 使用 queueMicrotask 延迟回调调用,避免在渲染阶段调用外部回调导致的 React 警告
|
|
183
|
+
* "Cannot update a component while rendering a different component"
|
|
184
|
+
*/
|
|
159
185
|
const setSettingState = useCallback(updater => {
|
|
160
186
|
setSettingStateInner(prev => {
|
|
161
187
|
const next = typeof updater === 'function' ? updater(prev) : updater;
|
|
162
|
-
|
|
188
|
+
queueMicrotask(() => {
|
|
189
|
+
onSettingChangeCallback(next);
|
|
190
|
+
});
|
|
163
191
|
return next;
|
|
164
192
|
});
|
|
165
|
-
}, [
|
|
193
|
+
}, [onSettingChangeCallback]);
|
|
166
194
|
const {
|
|
167
195
|
navTheme,
|
|
168
196
|
colorPrimary,
|
|
@@ -8,8 +8,6 @@ import { isImg, isUrl } from "../../../utils";
|
|
|
8
8
|
import { defaultSettings } from "../../defaultSettings";
|
|
9
9
|
import { getOpenKeysFromMenuData } from "../../utils/utils";
|
|
10
10
|
import { useStyle } from "./style/menu";
|
|
11
|
-
|
|
12
|
-
// todo
|
|
13
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
12
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
13
|
import { createElement as _createElement } from "react";
|
package/es/list/ListView.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { get } from '@rc-component/util';
|
|
2
2
|
import { ConfigProvider, List } from 'antd';
|
|
3
|
-
import useLazyKVMap from 'antd/lib/table/hooks/useLazyKVMap';
|
|
4
|
-
import usePagination from 'antd/lib/table/hooks/usePagination';
|
|
5
|
-
import useSelection from 'antd/lib/table/hooks/useSelection';
|
|
6
3
|
import { clsx } from 'clsx';
|
|
7
4
|
import React, { useContext } from 'react';
|
|
8
5
|
import { ProProvider } from "../provider";
|
|
6
|
+
import useLazyKVMap from "../utils/useLazyKVMap";
|
|
7
|
+
import usePagination from "../utils/usePagination";
|
|
8
|
+
import useSelection from "../utils/useSelection";
|
|
9
9
|
import { PRO_LIST_KEYS_MAP } from "./constants";
|
|
10
10
|
import ProListItem from "./Item";
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -169,6 +169,9 @@ function ListView(props) {
|
|
|
169
169
|
onChange: /*#__PURE__*/React.isValidElement(checkboxDom) ? changeChecked => {
|
|
170
170
|
return checkboxDom?.props?.onChange({
|
|
171
171
|
nativeEvent: {},
|
|
172
|
+
target: {
|
|
173
|
+
checked: changeChecked
|
|
174
|
+
},
|
|
172
175
|
changeChecked
|
|
173
176
|
});
|
|
174
177
|
} : undefined
|
package/es/provider/index.d.ts
CHANGED
package/es/provider/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCacheToken } from '@ant-design/cssinjs';
|
|
2
2
|
import { ConfigProvider as AntdConfigProvider, theme as antdTheme } from 'antd';
|
|
3
|
-
import zh_CN from 'antd/
|
|
3
|
+
import zh_CN from 'antd/es/locale/zh_CN';
|
|
4
4
|
import dayjs from 'dayjs';
|
|
5
5
|
import 'dayjs/locale/zh-cn';
|
|
6
6
|
import React, { useContext, useEffect, useMemo } from 'react';
|
|
@@ -13,7 +13,6 @@ export type ColumnsState = {
|
|
|
13
13
|
};
|
|
14
14
|
export type ProTableColumn<T> = ColumnsState & TableColumnType<T>;
|
|
15
15
|
export type UseContainerProps<T = any> = {
|
|
16
|
-
onColumnsStateChange?: (map: Record<string, ColumnsState>) => void;
|
|
17
16
|
size?: DensitySize;
|
|
18
17
|
defaultSize?: DensitySize;
|
|
19
18
|
onSizeChange?: (size: DensitySize) => void;
|
|
@@ -69,7 +69,7 @@ function useContainer(props = {}) {
|
|
|
69
69
|
}
|
|
70
70
|
return props.columnsState?.value || props.columnsState?.defaultValue || defaultColumnKeyMap;
|
|
71
71
|
}, props.columnsState?.value);
|
|
72
|
-
const onColumnsMapChange = props.columnsState?.onChange
|
|
72
|
+
const onColumnsMapChange = props.columnsState?.onChange;
|
|
73
73
|
const setColumnsMap = useCallback(updater => {
|
|
74
74
|
setColumnsMapInner(prev => {
|
|
75
75
|
const next = typeof updater === 'function' ? updater(prev) : updater;
|
package/es/table/Table.js
CHANGED
|
@@ -786,7 +786,6 @@ const ProviderTableContainer = props => {
|
|
|
786
786
|
...props,
|
|
787
787
|
columnsState: props.columnsState,
|
|
788
788
|
columns: props.columns,
|
|
789
|
-
onColumnsStateChange: props.onColumnsStateChange,
|
|
790
789
|
onSizeChange: props.onSizeChange,
|
|
791
790
|
size: props.size,
|
|
792
791
|
defaultSize: props.defaultSize
|
package/es/table/typing.d.ts
CHANGED
|
@@ -162,10 +162,6 @@ export type ProTableProps<DataSource, U, ValueType = 'text'> = {
|
|
|
162
162
|
params?: U;
|
|
163
163
|
/** @name 列状态的配置,可以用来操作列功能 */
|
|
164
164
|
columnsState?: ColumnStateType;
|
|
165
|
-
/**
|
|
166
|
-
* @deprecated 请使用 columnsState.onChange。保留兼容,后续版本将移除。
|
|
167
|
-
*/
|
|
168
|
-
onColumnsStateChange?: (map: Record<string, ColumnsState>) => void;
|
|
169
165
|
onSizeChange?: (size: DensitySize) => void;
|
|
170
166
|
/**
|
|
171
167
|
* @name table 外面卡片的设置
|
package/es/table/useFetchData.js
CHANGED
|
@@ -61,13 +61,27 @@ const useFetchData = (getData, defaultData, options) => {
|
|
|
61
61
|
*/
|
|
62
62
|
const tableLoadingValue = typeof options?.loading === 'object' ? options?.loading?.spinning : options?.loading;
|
|
63
63
|
const [tableLoading, setTableLoadingInner] = useControlledState(false, tableLoadingValue);
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 使用 useRefFunction 包装回调,确保引用稳定
|
|
67
|
+
*/
|
|
68
|
+
const onLoadingChange = useRefFunction(loading => {
|
|
69
|
+
options?.onLoadingChange?.(loading);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 包装 setTableLoading,使用 queueMicrotask 延迟回调调用
|
|
74
|
+
* 避免在渲染阶段调用外部回调导致的 React 警告
|
|
75
|
+
*/
|
|
64
76
|
const setTableLoading = useCallback(updater => {
|
|
65
77
|
setTableLoadingInner(prev => {
|
|
66
78
|
const next = typeof updater === 'function' ? updater(prev) : updater;
|
|
67
|
-
|
|
79
|
+
queueMicrotask(() => {
|
|
80
|
+
onLoadingChange(next);
|
|
81
|
+
});
|
|
68
82
|
return next;
|
|
69
83
|
});
|
|
70
|
-
}, [
|
|
84
|
+
}, [onLoadingChange]);
|
|
71
85
|
|
|
72
86
|
/**
|
|
73
87
|
* 表示页面信息的类型
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyObject } from 'antd/lib/_util/type';
|
|
1
|
+
import type { AnyObject } from 'antd/lib/_util/type';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { ProFieldEmptyText } from '../../field';
|
|
4
4
|
import type { ProSchemaComponentTypes, UseEditableUtilType } from '../../utils';
|
|
@@ -17,10 +17,7 @@ export const renderColumnsTitle = item => {
|
|
|
17
17
|
} = item;
|
|
18
18
|
const ellipsis = typeof item?.ellipsis === 'boolean' ? item?.ellipsis : item?.ellipsis?.showTitle;
|
|
19
19
|
if (title && typeof title === 'function') {
|
|
20
|
-
return title(item, 'table',
|
|
21
|
-
label: null,
|
|
22
|
-
tooltip: item.tooltip
|
|
23
|
-
}));
|
|
20
|
+
return title(item, 'table', null);
|
|
24
21
|
}
|
|
25
22
|
return /*#__PURE__*/_jsx(LabelIconTip, {
|
|
26
23
|
label: title,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TableColumnType, TableProps } from 'antd';
|
|
2
|
-
import { AnyObject } from 'antd/lib/_util/type';
|
|
3
|
-
import { SortOrder } from 'antd/lib/table/interface';
|
|
2
|
+
import type { AnyObject } from 'antd/lib/_util/type';
|
|
3
|
+
import type { SortOrder } from 'antd/lib/table/interface';
|
|
4
4
|
import type { ProFieldEmptyText } from '../../field';
|
|
5
5
|
import type { ProSchemaComponentTypes, UseEditableUtilType } from '../../utils';
|
|
6
6
|
import type { ContainerType } from '../Store/Provide';
|
|
@@ -75,22 +75,12 @@ export declare const flattenColumns: (data: any[]) => any[];
|
|
|
75
75
|
* @returns 是否为本地筛选
|
|
76
76
|
*/
|
|
77
77
|
export declare const isLocalFilter: <T>(filters: ProColumnType<T>['filters'], onFilter: ProColumnType<T>['onFilter']) => boolean;
|
|
78
|
-
/**
|
|
79
|
-
* @deprecated typo kept for backward compatibility
|
|
80
|
-
* use `isLocalFilter` instead
|
|
81
|
-
*/
|
|
82
|
-
export declare const isLocaleFilter: <T>(filters: ProColumnType<T>['filters'], onFilter: ProColumnType<T>['onFilter']) => boolean;
|
|
83
78
|
/**
|
|
84
79
|
* 判断是否为本地排序
|
|
85
80
|
* @param sorter 排序配置
|
|
86
81
|
* @returns 是否为本地排序
|
|
87
82
|
*/
|
|
88
83
|
export declare const isLocalSorter: <T>(sorter: ProSorter<T>) => boolean;
|
|
89
|
-
/**
|
|
90
|
-
* @deprecated typo kept for backward compatibility
|
|
91
|
-
* use `isLocalSorter` instead
|
|
92
|
-
*/
|
|
93
|
-
export declare const isLocaleSorter: <T>(sorter: ProSorter<T>) => boolean;
|
|
94
84
|
/**
|
|
95
85
|
* 获取服务端筛选数据
|
|
96
86
|
* @param filters 筛选数据
|
package/es/table/utils/index.js
CHANGED
|
@@ -170,12 +170,6 @@ export const isLocalFilter = (filters, onFilter) => {
|
|
|
170
170
|
return !!filters && !!onFilter;
|
|
171
171
|
};
|
|
172
172
|
|
|
173
|
-
/**
|
|
174
|
-
* @deprecated typo kept for backward compatibility
|
|
175
|
-
* use `isLocalFilter` instead
|
|
176
|
-
*/
|
|
177
|
-
export const isLocaleFilter = isLocalFilter;
|
|
178
|
-
|
|
179
173
|
/**
|
|
180
174
|
* 判断是否为本地排序
|
|
181
175
|
* @param sorter 排序配置
|
|
@@ -185,12 +179,6 @@ export const isLocalSorter = sorter => {
|
|
|
185
179
|
return typeof sorter === 'function' || typeof sorter === 'object' && typeof sorter.compare === 'function';
|
|
186
180
|
};
|
|
187
181
|
|
|
188
|
-
/**
|
|
189
|
-
* @deprecated typo kept for backward compatibility
|
|
190
|
-
* use `isLocalSorter` instead
|
|
191
|
-
*/
|
|
192
|
-
export const isLocaleSorter = isLocalSorter;
|
|
193
|
-
|
|
194
182
|
/**
|
|
195
183
|
* 获取服务端筛选数据
|
|
196
184
|
* @param filters 筛选数据
|
|
@@ -28,7 +28,6 @@ const FieldLabelFunction = (props, ref) => {
|
|
|
28
28
|
} = ConfigProvider?.useConfig?.() || {
|
|
29
29
|
componentSize: 'middle'
|
|
30
30
|
};
|
|
31
|
-
const size = componentSize;
|
|
32
31
|
const {
|
|
33
32
|
getPrefixCls
|
|
34
33
|
} = useContext(ConfigProvider.ConfigContext);
|
|
@@ -113,10 +112,11 @@ const FieldLabelFunction = (props, ref) => {
|
|
|
113
112
|
return aLabel || placeholder;
|
|
114
113
|
};
|
|
115
114
|
return wrapSSR( /*#__PURE__*/_jsxs("span", {
|
|
116
|
-
className: clsx(prefixCls, hashId, `${prefixCls}-${props.size ??
|
|
115
|
+
className: clsx(prefixCls, hashId, `${prefixCls}-${props.size ?? componentSize ?? 'middle'}`, {
|
|
116
|
+
[`${prefixCls}-${variant || 'borderless'}-active`]: (Array.isArray(value) ? value.length > 0 : !!value) || value === 0,
|
|
117
117
|
[`${prefixCls}-active`]: (Array.isArray(value) ? value.length > 0 : !!value) || value === 0,
|
|
118
118
|
[`${prefixCls}-disabled`]: disabled,
|
|
119
|
-
[`${prefixCls}-
|
|
119
|
+
[`${prefixCls}-outlined`]: variant === 'outlined',
|
|
120
120
|
[`${prefixCls}-allow-clear`]: allowClear
|
|
121
121
|
}, className),
|
|
122
122
|
style: style,
|
|
@@ -10,7 +10,8 @@ const genProStyle = token => {
|
|
|
10
10
|
paddingInline: 8,
|
|
11
11
|
fontSize: token.fontSize,
|
|
12
12
|
lineHeight: '30px',
|
|
13
|
-
borderRadius:
|
|
13
|
+
borderRadius: token.borderRadius,
|
|
14
|
+
cornerShape: 'squircle',
|
|
14
15
|
cursor: 'pointer',
|
|
15
16
|
'&:hover': {
|
|
16
17
|
backgroundColor: token.colorBgTextHover
|
|
@@ -18,7 +19,6 @@ const genProStyle = token => {
|
|
|
18
19
|
'&-active': {
|
|
19
20
|
paddingBlock: 0,
|
|
20
21
|
paddingInline: 8,
|
|
21
|
-
backgroundColor: token.colorBgTextHover,
|
|
22
22
|
[`&${token.componentCls}-allow-clear:hover:not(${token.componentCls}-disabled)`]: {
|
|
23
23
|
[`${token.componentCls}-arrow`]: {
|
|
24
24
|
display: 'none'
|
|
@@ -83,12 +83,31 @@ const genProStyle = token => {
|
|
|
83
83
|
fontSize: '6px'
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
|
-
'&-
|
|
86
|
+
'&-outlined': {
|
|
87
87
|
height: '32px',
|
|
88
88
|
paddingBlock: 0,
|
|
89
89
|
paddingInline: 8,
|
|
90
90
|
border: `${token.lineWidth}px solid ${token.colorBorder}`,
|
|
91
|
-
borderRadius:
|
|
91
|
+
borderRadius: token.borderRadius,
|
|
92
|
+
'&-active': {
|
|
93
|
+
backgroundColor: 'none'
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
'&-borderless': {
|
|
97
|
+
height: '32px',
|
|
98
|
+
'&-active': {
|
|
99
|
+
backgroundColor: token.colorBgTextHover
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
'&-filled': {
|
|
103
|
+
height: '32px',
|
|
104
|
+
paddingBlock: 0,
|
|
105
|
+
paddingInline: 8,
|
|
106
|
+
border: 'none',
|
|
107
|
+
borderRadius: token.borderRadius,
|
|
108
|
+
'&-active': {
|
|
109
|
+
backgroundColor: token.colorBgContainer
|
|
110
|
+
}
|
|
92
111
|
},
|
|
93
112
|
'&-bordered&-small': {
|
|
94
113
|
height: '24px',
|
|
@@ -4,6 +4,16 @@ const genProStyle = token => {
|
|
|
4
4
|
[`${token.componentCls}-label`]: {
|
|
5
5
|
cursor: 'pointer'
|
|
6
6
|
},
|
|
7
|
+
[`${token.componentCls}-label-bordered`]: {
|
|
8
|
+
display: 'inline-flex',
|
|
9
|
+
alignItems: 'center',
|
|
10
|
+
height: token.controlHeight,
|
|
11
|
+
paddingBlock: 0,
|
|
12
|
+
paddingInline: token.paddingSM,
|
|
13
|
+
border: `${token.lineWidth}px solid ${token.colorBorder}`,
|
|
14
|
+
borderRadius: token.borderRadius,
|
|
15
|
+
boxSizing: 'border-box'
|
|
16
|
+
},
|
|
7
17
|
[`${token.componentCls}-overlay`]: {
|
|
8
18
|
minWidth: '200px',
|
|
9
19
|
marginBlockStart: '4px'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const proFieldProps = `valueType request
|
|
1
|
+
const proFieldProps = `valueType request formItemRender render text formItemProps valueEnum`;
|
|
2
2
|
const proFormProps = `fieldProps isDefaultDom groupProps contentRender submitterProps submitter`;
|
|
3
3
|
export function pickProProps(props, customValueType = false) {
|
|
4
4
|
const propList = `${proFieldProps} ${proFormProps}`.split(/[\s\n]+/);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FormInstance, FormProps } from 'antd';
|
|
2
|
-
import { AnyObject } from 'antd/lib/_util/type';
|
|
2
|
+
import type { AnyObject } from 'antd/lib/_util/type';
|
|
3
3
|
import type { NamePath } from 'antd/lib/form/interface';
|
|
4
4
|
import type { GetRowKey } from 'antd/lib/table/interface';
|
|
5
5
|
import React from 'react';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* eslint-disable react-hooks/exhaustive-deps */import { LoadingOutlined } from '@ant-design/icons';
|
|
2
2
|
import { get, warning as rcWarning, set, useControlledState } from '@rc-component/util';
|
|
3
3
|
import { Form, Popconfirm, message } from 'antd';
|
|
4
|
-
import useLazyKVMap from 'antd/lib/table/hooks/useLazyKVMap';
|
|
5
4
|
import React, { createRef, forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
6
5
|
import { useDebounceFn, useRefFunction } from '..';
|
|
7
6
|
import { useIntl } from "../../provider";
|
|
@@ -9,6 +8,7 @@ import { ProFormContext } from "../components/ProFormContext";
|
|
|
9
8
|
import { useDeepCompareEffectDebounce } from "../hooks/useDeepCompareEffect";
|
|
10
9
|
import { usePrevious } from "../hooks/usePrevious";
|
|
11
10
|
import { merge } from "../merge";
|
|
11
|
+
import useLazyKVMap from "../useLazyKVMap";
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
const {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AnyObject } from 'antd/lib/_util/type';
|
|
2
|
+
import type { GetRowKey } from 'antd/lib/table/interface';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
declare const useLazyKVMap: <RecordType extends AnyObject = AnyObject>(data: readonly RecordType[], childrenColumnName: string, getRowKey: GetRowKey<RecordType>) => readonly [(key: React.Key) => RecordType | undefined];
|
|
5
|
+
export default useLazyKVMap;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
const useLazyKVMap = (data, childrenColumnName, getRowKey) => {
|
|
3
|
+
const mapCacheRef = useRef({});
|
|
4
|
+
function getRecordByKey(key) {
|
|
5
|
+
function dig(records, kv) {
|
|
6
|
+
records.forEach((record, index) => {
|
|
7
|
+
const rowKey = getRowKey(record, index);
|
|
8
|
+
kv.set(rowKey, record);
|
|
9
|
+
if (record && typeof record === 'object' && childrenColumnName in record) {
|
|
10
|
+
dig(record[childrenColumnName] || [], kv);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
if (!mapCacheRef.current || mapCacheRef.current.data !== data || mapCacheRef.current.childrenColumnName !== childrenColumnName || mapCacheRef.current.getRowKey !== getRowKey) {
|
|
15
|
+
const kvMap = new Map();
|
|
16
|
+
dig(data, kvMap);
|
|
17
|
+
mapCacheRef.current = {
|
|
18
|
+
data,
|
|
19
|
+
childrenColumnName,
|
|
20
|
+
kvMap,
|
|
21
|
+
getRowKey
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return mapCacheRef.current.kvMap?.get(key);
|
|
25
|
+
}
|
|
26
|
+
return [getRecordByKey];
|
|
27
|
+
};
|
|
28
|
+
export default useLazyKVMap;
|
|
@@ -35,6 +35,6 @@ export type MediaQueryKey = keyof typeof MediaQueryEnum;
|
|
|
35
35
|
* `Rendered more hooks than during the previous render.`
|
|
36
36
|
* So should use Array.forEach
|
|
37
37
|
*/
|
|
38
|
-
export declare const getScreenClassName: () => "
|
|
39
|
-
declare const useBreakpoint: () => "
|
|
38
|
+
export declare const getScreenClassName: () => "xxl" | "xl" | "lg" | "md" | "sm" | "xs" | undefined;
|
|
39
|
+
declare const useBreakpoint: () => "xxl" | "xl" | "lg" | "md" | "sm" | "xs" | undefined;
|
|
40
40
|
export { useBreakpoint };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TablePaginationConfig } from 'antd/es/table/interface';
|
|
2
|
+
export declare const DEFAULT_PAGE_SIZE = 10;
|
|
3
|
+
export declare function getPaginationParam(mergedPagination: TablePaginationConfig, pagination?: TablePaginationConfig | boolean): any;
|
|
4
|
+
declare function usePagination(total: number, onChange: (current: number, pageSize: number) => void, pagination?: TablePaginationConfig | false): readonly [
|
|
5
|
+
TablePaginationConfig,
|
|
6
|
+
(current?: number, pageSize?: number) => void
|
|
7
|
+
];
|
|
8
|
+
export default usePagination;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
export const DEFAULT_PAGE_SIZE = 10;
|
|
3
|
+
function extendsObject(base, override, extra = {}) {
|
|
4
|
+
return {
|
|
5
|
+
...base,
|
|
6
|
+
...override,
|
|
7
|
+
...extra
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export function getPaginationParam(mergedPagination, pagination) {
|
|
11
|
+
const param = {
|
|
12
|
+
current: mergedPagination.current,
|
|
13
|
+
pageSize: mergedPagination.pageSize
|
|
14
|
+
};
|
|
15
|
+
const paginationObj = pagination && typeof pagination === 'object' ? pagination : {};
|
|
16
|
+
Object.keys(paginationObj).forEach(pageProp => {
|
|
17
|
+
const value = mergedPagination[pageProp];
|
|
18
|
+
if (typeof value !== 'function') {
|
|
19
|
+
param[pageProp] = value;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return param;
|
|
23
|
+
}
|
|
24
|
+
function usePagination(total, onChange, pagination) {
|
|
25
|
+
const {
|
|
26
|
+
total: paginationTotal = 0,
|
|
27
|
+
...paginationObj
|
|
28
|
+
} = pagination && typeof pagination === 'object' ? pagination : {};
|
|
29
|
+
const [innerPagination, setInnerPagination] = useState(() => ({
|
|
30
|
+
current: 'defaultCurrent' in paginationObj ? paginationObj.defaultCurrent : 1,
|
|
31
|
+
pageSize: 'defaultPageSize' in paginationObj ? paginationObj.defaultPageSize : DEFAULT_PAGE_SIZE
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
// ============ Basic Pagination Config ============
|
|
35
|
+
const mergedPagination = extendsObject(innerPagination, paginationObj, {
|
|
36
|
+
total: paginationTotal > 0 ? paginationTotal : total
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Reset `current` if data length or pageSize changed
|
|
40
|
+
const pageSize = mergedPagination.pageSize || DEFAULT_PAGE_SIZE;
|
|
41
|
+
const maxPage = Math.ceil((paginationTotal || total) / pageSize);
|
|
42
|
+
if ((mergedPagination.current || 1) > maxPage) {
|
|
43
|
+
// Prevent a maximum page count of 0
|
|
44
|
+
mergedPagination.current = maxPage || 1;
|
|
45
|
+
}
|
|
46
|
+
const refreshPagination = (current, pageSizeArg) => {
|
|
47
|
+
setInnerPagination({
|
|
48
|
+
current: current ?? 1,
|
|
49
|
+
pageSize: pageSizeArg || mergedPagination.pageSize
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
const onInternalChange = (current, pageSizeArg) => {
|
|
53
|
+
if (pagination && typeof pagination === 'object') {
|
|
54
|
+
pagination.onChange?.(current, pageSizeArg);
|
|
55
|
+
}
|
|
56
|
+
refreshPagination(current, pageSizeArg);
|
|
57
|
+
onChange(current, pageSizeArg || mergedPagination.pageSize);
|
|
58
|
+
};
|
|
59
|
+
if (pagination === false) {
|
|
60
|
+
return [{}, () => {}];
|
|
61
|
+
}
|
|
62
|
+
return [{
|
|
63
|
+
...mergedPagination,
|
|
64
|
+
onChange: onInternalChange
|
|
65
|
+
}, refreshPagination];
|
|
66
|
+
}
|
|
67
|
+
export default usePagination;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { GetRowKey, TableRowSelection } from 'antd/lib/table/interface';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
type UseSelectionConfig<RecordType> = {
|
|
4
|
+
getRowKey: GetRowKey<RecordType>;
|
|
5
|
+
getRecordByKey: (key: React.Key) => RecordType | undefined;
|
|
6
|
+
prefixCls?: string;
|
|
7
|
+
data: RecordType[];
|
|
8
|
+
pageData: RecordType[];
|
|
9
|
+
expandType?: 'row' | 'nest';
|
|
10
|
+
childrenColumnName?: string;
|
|
11
|
+
locale?: any;
|
|
12
|
+
};
|
|
13
|
+
declare function useSelection<RecordType>(config: UseSelectionConfig<RecordType>, rowSelection?: TableRowSelection<RecordType>): readonly [
|
|
14
|
+
(columns?: any[]) => Array<{
|
|
15
|
+
render: (text: any, record: RecordType, index: number) => React.ReactElement;
|
|
16
|
+
}>,
|
|
17
|
+
Set<React.Key>
|
|
18
|
+
];
|
|
19
|
+
export default useSelection;
|