@ant-design/pro-components 3.1.1-0 → 3.1.2-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/descriptions/index.d.ts +0 -2
- package/es/descriptions/index.js +1 -5
- package/es/field/components/Cascader/index.d.ts +2 -2
- package/es/field/components/Cascader/index.js +8 -7
- package/es/field/components/Checkbox/index.d.ts +1 -1
- package/es/field/components/ColorPicker/index.d.ts +1 -1
- package/es/field/components/DatePicker/index.d.ts +2 -2
- package/es/field/components/Percent/util.d.ts +1 -1
- package/es/field/components/Radio/index.d.ts +1 -1
- package/es/field/components/RangePicker/index.d.ts +2 -2
- package/es/field/components/Segmented/index.d.ts +1 -1
- package/es/field/components/Select/LightSelect/index.d.ts +1 -1
- package/es/field/components/Select/index.d.ts +2 -2
- package/es/field/components/Select/index.js +0 -2
- package/es/field/components/Switch/index.d.ts +1 -1
- package/es/field/components/TreeSelect/index.d.ts +2 -2
- package/es/form/components/DateRangePicker/DateTimeRangePicker.d.ts +1 -1
- package/es/form/components/Digit/DigitRange.d.ts +1 -1
- package/es/form/layouts/ProForm/index.d.ts +1 -1
- package/es/layout/components/SiderMenu/BaseMenu.js +0 -2
- package/es/list/ListView.js +3 -3
- 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/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/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.js +21 -16
- 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 +61 -0
- 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/descriptions/index.d.ts +0 -2
- package/lib/descriptions/index.js +1 -5
- package/lib/field/components/Cascader/index.js +8 -7
- package/lib/field/components/Select/index.js +0 -2
- package/lib/form/components/DateRangePicker/DateTimeRangePicker.d.ts +1 -1
- package/lib/layout/components/SiderMenu/BaseMenu.js +0 -2
- package/lib/list/ListView.js +4 -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/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/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/useMediaQuery/index.js +21 -16
- 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 +68 -0
- package/package.json +6 -5
package/es/descriptions/index.js
CHANGED
|
@@ -9,8 +9,6 @@ import ProSkeleton from "../skeleton";
|
|
|
9
9
|
import { ErrorBoundary, InlineErrorFormItem, LabelIconTip, genCopyable, getFieldPropsOrFormItemProps, stringify, useEditableMap } from "../utils";
|
|
10
10
|
import useFetchData from "./useFetchData";
|
|
11
11
|
|
|
12
|
-
// todo remove it
|
|
13
|
-
|
|
14
12
|
/**
|
|
15
13
|
* 定义列表属性的类型定义,用于定义列表的一列
|
|
16
14
|
* @typedef {Object} ProDescriptionsItemProps
|
|
@@ -297,7 +295,6 @@ const ProDescriptions = props => {
|
|
|
297
295
|
actionRef,
|
|
298
296
|
onRequestError,
|
|
299
297
|
emptyText,
|
|
300
|
-
contentStyle,
|
|
301
298
|
...rest
|
|
302
299
|
} = props;
|
|
303
300
|
const proContext = useContext(ProConfigContext);
|
|
@@ -415,8 +412,7 @@ const ProDescriptions = props => {
|
|
|
415
412
|
...rest,
|
|
416
413
|
styles: {
|
|
417
414
|
content: {
|
|
418
|
-
minWidth: 0
|
|
419
|
-
...(contentStyle || {})
|
|
415
|
+
minWidth: 0
|
|
420
416
|
}
|
|
421
417
|
},
|
|
422
418
|
extra: rest.extra ? /*#__PURE__*/_jsxs(Space, {
|
|
@@ -11,7 +11,7 @@ declare const _default: React.ForwardRefExoticComponent<import("../../../provide
|
|
|
11
11
|
options?: (string | number | import("antd").CheckboxOptionType<any>)[] | undefined;
|
|
12
12
|
radioType?: "button" | "radio" | undefined;
|
|
13
13
|
placeholder?: string | undefined;
|
|
14
|
-
variant?: "outlined" | "
|
|
14
|
+
variant?: "outlined" | "filled" | "borderless" | undefined;
|
|
15
15
|
} & {
|
|
16
16
|
text: string;
|
|
17
17
|
valueEnum?: import("src/utils/typing").ProFieldValueEnumType | undefined;
|
|
@@ -19,7 +19,7 @@ declare const _default: React.ForwardRefExoticComponent<import("../../../provide
|
|
|
19
19
|
request?: import("src/utils/typing").ProFieldRequestData | undefined;
|
|
20
20
|
params?: any;
|
|
21
21
|
fieldProps?: any;
|
|
22
|
-
variant?: "outlined" | "
|
|
22
|
+
variant?: "outlined" | "filled" | "borderless" | undefined;
|
|
23
23
|
id?: string | undefined;
|
|
24
24
|
defaultKeyWords?: string | undefined;
|
|
25
25
|
} & import("../../PureProField").ProFieldLightProps & React.RefAttributes<any>>;
|
|
@@ -77,25 +77,26 @@ const FieldCascader = ({
|
|
|
77
77
|
return dom;
|
|
78
78
|
}
|
|
79
79
|
if (mode === 'edit') {
|
|
80
|
+
const fieldProps = rest.fieldProps || {};
|
|
80
81
|
let dom = /*#__PURE__*/_jsx(Cascader, {
|
|
81
82
|
variant: !light ? variant : 'borderless',
|
|
82
83
|
ref: cascaderRef,
|
|
83
84
|
open: open,
|
|
84
85
|
suffixIcon: loading ? /*#__PURE__*/_jsx(LoadingOutlined, {}) : undefined,
|
|
85
86
|
placeholder: placeholder || intl.getMessage('tableForm.selectPlaceholder', '请选择'),
|
|
86
|
-
allowClear:
|
|
87
|
-
...
|
|
87
|
+
allowClear: fieldProps?.allowClear !== false,
|
|
88
|
+
...fieldProps,
|
|
88
89
|
onOpenChange: isOpen => {
|
|
89
|
-
|
|
90
|
+
fieldProps?.onOpenChange?.(isOpen);
|
|
90
91
|
setOpen(isOpen);
|
|
91
92
|
},
|
|
92
|
-
className: clsx(
|
|
93
|
+
className: clsx(fieldProps?.className, layoutClassName),
|
|
93
94
|
options: options
|
|
94
95
|
});
|
|
95
96
|
if (formItemRender) {
|
|
96
97
|
dom = formItemRender(rest.text, {
|
|
97
98
|
mode,
|
|
98
|
-
...
|
|
99
|
+
...fieldProps,
|
|
99
100
|
options,
|
|
100
101
|
loading
|
|
101
102
|
}, dom) ?? null;
|
|
@@ -104,7 +105,7 @@ const FieldCascader = ({
|
|
|
104
105
|
const {
|
|
105
106
|
disabled,
|
|
106
107
|
value
|
|
107
|
-
} =
|
|
108
|
+
} = fieldProps;
|
|
108
109
|
const notEmpty = !!value && value?.length !== 0;
|
|
109
110
|
return /*#__PURE__*/_jsx(FieldLabel, {
|
|
110
111
|
label: label,
|
|
@@ -118,7 +119,7 @@ const FieldCascader = ({
|
|
|
118
119
|
downIcon: notEmpty || open ? false : undefined,
|
|
119
120
|
onClick: () => {
|
|
120
121
|
setOpen(true);
|
|
121
|
-
|
|
122
|
+
fieldProps?.onOpenChange?.(true);
|
|
122
123
|
}
|
|
123
124
|
});
|
|
124
125
|
}
|
|
@@ -15,7 +15,7 @@ declare const _default: React.ForwardRefExoticComponent<import("src/provider").B
|
|
|
15
15
|
request?: import("src/utils/typing").ProFieldRequestData | undefined;
|
|
16
16
|
params?: any;
|
|
17
17
|
fieldProps?: any;
|
|
18
|
-
variant?: "outlined" | "
|
|
18
|
+
variant?: "outlined" | "filled" | "borderless" | undefined;
|
|
19
19
|
id?: string | undefined;
|
|
20
20
|
defaultKeyWords?: string | undefined;
|
|
21
21
|
} & import("../../PureProField").ProFieldLightProps & React.RefAttributes<any>>;
|
|
@@ -2,6 +2,6 @@ import type { ColorPickerProps } from 'antd';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
declare const _default: React.ForwardRefExoticComponent<import("src/provider").BaseProFieldFC & import("src/provider").ProRenderFieldPropsType & {
|
|
4
4
|
text: string;
|
|
5
|
-
mode?: "
|
|
5
|
+
mode?: "update" | "read" | "edit" | undefined;
|
|
6
6
|
} & Partial<Omit<ColorPickerProps, "value" | "mode">> & React.RefAttributes<any>>;
|
|
7
7
|
export default _default;
|
|
@@ -4,7 +4,7 @@ declare const _default: React.ForwardRefExoticComponent<import("../../../provide
|
|
|
4
4
|
text: string | number;
|
|
5
5
|
format?: string | undefined;
|
|
6
6
|
showTime?: boolean | undefined;
|
|
7
|
-
variant?: "outlined" | "
|
|
8
|
-
picker?: "
|
|
7
|
+
variant?: "outlined" | "filled" | "borderless" | "underlined" | undefined;
|
|
8
|
+
picker?: "time" | "date" | "month" | "week" | "year" | "quarter" | undefined;
|
|
9
9
|
} & ProFieldLightProps & React.RefAttributes<any>>;
|
|
10
10
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** 获取展示符号 */
|
|
2
2
|
export declare function getSymbolByRealValue(realValue: number): "-" | "+" | null;
|
|
3
3
|
/** 获取颜色 */
|
|
4
|
-
export declare function getColorByRealValue(realValue: number /** ,color: string */): "#
|
|
4
|
+
export declare function getColorByRealValue(realValue: number /** ,color: string */): "#595959" | "#52c41a" | "#ff4d4f";
|
|
5
5
|
/** 获取到最后展示的数字 */
|
|
6
6
|
export declare function getRealTextWithPrecision(realValue: number, precision?: number): string | number;
|
|
7
7
|
/**
|
|
@@ -15,7 +15,7 @@ declare const _default: React.ForwardRefExoticComponent<import("src/provider").B
|
|
|
15
15
|
request?: import("src/utils/typing").ProFieldRequestData | undefined;
|
|
16
16
|
params?: any;
|
|
17
17
|
fieldProps?: any;
|
|
18
|
-
variant?: "outlined" | "
|
|
18
|
+
variant?: "outlined" | "filled" | "borderless" | undefined;
|
|
19
19
|
id?: string | undefined;
|
|
20
20
|
defaultKeyWords?: string | undefined;
|
|
21
21
|
} & import("../../PureProField").ProFieldLightProps & React.RefAttributes<any>>;
|
|
@@ -3,8 +3,8 @@ import type { ProFieldLightProps } from '../../PureProField';
|
|
|
3
3
|
declare const _default: React.ForwardRefExoticComponent<import("../../../provider").BaseProFieldFC & import("../../../provider").ProRenderFieldPropsType & {
|
|
4
4
|
text: string[];
|
|
5
5
|
format?: string | undefined;
|
|
6
|
-
variant?: "outlined" | "
|
|
6
|
+
variant?: "outlined" | "filled" | "borderless" | "underlined" | undefined;
|
|
7
7
|
showTime?: boolean | undefined;
|
|
8
|
-
picker?: "
|
|
8
|
+
picker?: "time" | "date" | "month" | "week" | "year" | "quarter" | undefined;
|
|
9
9
|
} & ProFieldLightProps & React.RefAttributes<any>>;
|
|
10
10
|
export default _default;
|
|
@@ -9,7 +9,7 @@ declare const _default: React.ForwardRefExoticComponent<import("src/provider").B
|
|
|
9
9
|
request?: import("src/utils/typing").ProFieldRequestData | undefined;
|
|
10
10
|
params?: any;
|
|
11
11
|
fieldProps?: any;
|
|
12
|
-
variant?: "outlined" | "
|
|
12
|
+
variant?: "outlined" | "filled" | "borderless" | undefined;
|
|
13
13
|
id?: string | undefined;
|
|
14
14
|
defaultKeyWords?: string | undefined;
|
|
15
15
|
} & import("../../PureProField").ProFieldLightProps & React.RefAttributes<any>>;
|
|
@@ -30,6 +30,6 @@ declare const _default: React.ForwardRefExoticComponent<SelectProps<any, import(
|
|
|
30
30
|
*/
|
|
31
31
|
fetchDataOnSearch?: boolean | undefined;
|
|
32
32
|
/** 变体类型 */
|
|
33
|
-
variant?: "outlined" | "
|
|
33
|
+
variant?: "outlined" | "filled" | "borderless" | "underlined" | undefined;
|
|
34
34
|
} & ProFieldLightProps & SelectProps<any, import("antd/es/select").DefaultOptionType> & React.RefAttributes<any>>;
|
|
35
35
|
export default _default;
|
|
@@ -43,9 +43,9 @@ declare const _default: React.ForwardRefExoticComponent<import("../../../provide
|
|
|
43
43
|
params?: any;
|
|
44
44
|
/** 组件的全局设置 */
|
|
45
45
|
fieldProps?: any;
|
|
46
|
-
variant?: "outlined" | "
|
|
46
|
+
variant?: "outlined" | "filled" | "borderless" | undefined;
|
|
47
47
|
id?: string | undefined;
|
|
48
48
|
/** 默认搜素条件 */
|
|
49
49
|
defaultKeyWords?: string | undefined;
|
|
50
|
-
} & ProFieldLightProps & Pick<SelectProps<any, import("antd/es/select").DefaultOptionType>, "
|
|
50
|
+
} & ProFieldLightProps & Pick<SelectProps<any, import("antd/es/select").DefaultOptionType>, "className" | "style" | "fieldNames"> & React.RefAttributes<any>>;
|
|
51
51
|
export default _default;
|
|
@@ -182,10 +182,8 @@ export const useFieldFetchData = props => {
|
|
|
182
182
|
keyWords: kw
|
|
183
183
|
}, props), {
|
|
184
184
|
revalidateIfStale: !cacheForSwr,
|
|
185
|
-
// 打开 cacheForSwr 的时候才应该支持两个功能
|
|
186
185
|
revalidateOnReconnect: cacheForSwr,
|
|
187
186
|
shouldRetryOnError: false,
|
|
188
|
-
// @todo 这个功能感觉应该搞个API出来
|
|
189
187
|
revalidateOnFocus: false
|
|
190
188
|
});
|
|
191
189
|
const resOptions = useMemo(() => {
|
|
@@ -3,6 +3,6 @@ import React from 'react';
|
|
|
3
3
|
declare const _default: React.ForwardRefExoticComponent<import("../../../provider").BaseProFieldFC & import("../../../provider").ProRenderFieldPropsType & {
|
|
4
4
|
text: boolean;
|
|
5
5
|
fieldProps?: SwitchProps | undefined;
|
|
6
|
-
variant?: "outlined" | "
|
|
6
|
+
variant?: "outlined" | "filled" | "borderless" | undefined;
|
|
7
7
|
} & React.RefAttributes<any>>;
|
|
8
8
|
export default _default;
|
|
@@ -17,7 +17,7 @@ export type TreeSelectFieldProps = TreeSelectProps<any> & {
|
|
|
17
17
|
declare const _default: React.ForwardRefExoticComponent<import("../../../provider").BaseProFieldFC & import("../../../provider").ProRenderFieldPropsType & {
|
|
18
18
|
options?: (string | number | import("antd").CheckboxOptionType<any>)[] | undefined;
|
|
19
19
|
radioType?: "button" | "radio" | undefined;
|
|
20
|
-
variant?: "outlined" | "
|
|
20
|
+
variant?: "outlined" | "filled" | "borderless" | undefined;
|
|
21
21
|
} & {
|
|
22
22
|
text: string;
|
|
23
23
|
valueEnum?: import("src/utils/typing").ProFieldValueEnumType | undefined;
|
|
@@ -25,7 +25,7 @@ declare const _default: React.ForwardRefExoticComponent<import("../../../provide
|
|
|
25
25
|
request?: import("src/utils/typing").ProFieldRequestData | undefined;
|
|
26
26
|
params?: any;
|
|
27
27
|
fieldProps?: any;
|
|
28
|
-
variant?: "outlined" | "
|
|
28
|
+
variant?: "outlined" | "filled" | "borderless" | undefined;
|
|
29
29
|
id?: string | undefined;
|
|
30
30
|
defaultKeyWords?: string | undefined;
|
|
31
31
|
} & import("../../PureProField").ProFieldLightProps & React.RefAttributes<any>>;
|
|
@@ -13,7 +13,7 @@ export type ProFormDigitRangeProps = ProFormFieldItemProps<RangeInputNumberProps
|
|
|
13
13
|
separatorWidth?: number;
|
|
14
14
|
};
|
|
15
15
|
declare const ForwardRefProFormDigit: React.ForwardRefExoticComponent<{
|
|
16
|
-
fieldProps?: Partial<import("../../typing").FieldProps<any> & Omit<InputNumberProps<number>, "
|
|
16
|
+
fieldProps?: Partial<import("../../typing").FieldProps<any> & Omit<InputNumberProps<number>, "defaultValue" | "onChange" | "value" | "placeholder"> & {
|
|
17
17
|
value?: ValuePair | undefined;
|
|
18
18
|
defaultValue?: ValuePair | undefined;
|
|
19
19
|
onChange?: ((value?: ValuePair) => void) | undefined;
|
|
@@ -14,7 +14,7 @@ declare namespace ProForm {
|
|
|
14
14
|
var Provider: React.FC<import("antd/es/form/context").FormProviderProps>;
|
|
15
15
|
var useFormInstance: typeof import("antd/es/form/hooks/useFormInstance").default;
|
|
16
16
|
var EditOrReadOnlyContext: React.Context<{
|
|
17
|
-
mode: "
|
|
17
|
+
mode: "update" | "read" | "edit";
|
|
18
18
|
}>;
|
|
19
19
|
}
|
|
20
20
|
export { ProForm };
|
|
@@ -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";
|
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 外面卡片的设置
|
|
@@ -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 筛选数据
|
|
@@ -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;
|
|
@@ -1,33 +1,38 @@
|
|
|
1
|
+
import { theme } from 'antd';
|
|
1
2
|
import { useEffect, useState } from 'react';
|
|
2
3
|
import useMediaQuery from "./query";
|
|
4
|
+
const {
|
|
5
|
+
getDesignToken
|
|
6
|
+
} = theme;
|
|
7
|
+
const token = getDesignToken();
|
|
3
8
|
export const MediaQueryEnum = {
|
|
4
9
|
xs: {
|
|
5
|
-
maxWidth:
|
|
6
|
-
matchMedia:
|
|
10
|
+
maxWidth: token.screenXSMax,
|
|
11
|
+
matchMedia: `(max-width: ${token.screenXSMax}px)`
|
|
7
12
|
},
|
|
8
13
|
sm: {
|
|
9
|
-
minWidth:
|
|
10
|
-
maxWidth:
|
|
11
|
-
matchMedia:
|
|
14
|
+
minWidth: token.screenSMMin,
|
|
15
|
+
maxWidth: token.screenSMMax,
|
|
16
|
+
matchMedia: `(min-width: ${token.screenSMMin}px) and (max-width: ${token.screenSMMax}px)`
|
|
12
17
|
},
|
|
13
18
|
md: {
|
|
14
|
-
minWidth:
|
|
15
|
-
maxWidth:
|
|
16
|
-
matchMedia:
|
|
19
|
+
minWidth: token.screenMDMin,
|
|
20
|
+
maxWidth: token.screenMDMax,
|
|
21
|
+
matchMedia: `(min-width: ${token.screenMDMin}px) and (max-width: ${token.screenMDMax}px)`
|
|
17
22
|
},
|
|
18
23
|
lg: {
|
|
19
|
-
minWidth:
|
|
20
|
-
maxWidth:
|
|
21
|
-
matchMedia:
|
|
24
|
+
minWidth: token.screenLGMin,
|
|
25
|
+
maxWidth: token.screenLGMax,
|
|
26
|
+
matchMedia: `(min-width: ${token.screenLGMin}px) and (max-width: ${token.screenLGMax}px)`
|
|
22
27
|
},
|
|
23
28
|
xl: {
|
|
24
|
-
minWidth:
|
|
25
|
-
maxWidth:
|
|
26
|
-
matchMedia:
|
|
29
|
+
minWidth: token.screenXLMin,
|
|
30
|
+
maxWidth: token.screenXLMax,
|
|
31
|
+
matchMedia: `(min-width: ${token.screenXLMin}px) and (max-width: ${token.screenXLMax}px)`
|
|
27
32
|
},
|
|
28
33
|
xxl: {
|
|
29
|
-
minWidth:
|
|
30
|
-
matchMedia:
|
|
34
|
+
minWidth: token.screenXXLMin,
|
|
35
|
+
matchMedia: `(min-width: ${token.screenXXLMin}px)`
|
|
31
36
|
}
|
|
32
37
|
};
|
|
33
38
|
/**
|
|
@@ -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;
|