@zat-design/sisyphus-react 4.5.8-beta.4 → 4.5.8-beta.6
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/index.esm.css +1 -1
- package/dist/less.esm.css +1 -1
- package/es/ProAction/components/CheckModalContent/index.d.ts +1 -2
- package/es/ProDownload/index.d.ts +1 -2
- package/es/ProEditTable/components/ActionButton/index.d.ts +1 -2
- package/es/ProEditTable/components/RcTable/BaseTable.d.ts +1 -1
- package/es/ProEditTable/components/RcTable/BaseTable.js +7 -6
- package/es/ProEditTable/components/RcTable/DraggableTable.d.ts +1 -1
- package/es/ProEditTable/components/RcTable/DraggableTable.js +4 -4
- package/es/ProEditTable/components/RenderField/index.d.ts +1 -1
- package/es/ProEditTable/components/RenderField/index.js +22 -21
- package/es/ProEditTable/components/RenderField/tools.d.ts +7 -0
- package/es/ProEditTable/components/RenderField/tools.js +29 -2
- package/es/ProEditTable/components/RenderToolbar/index.d.ts +1 -2
- package/es/ProEditTable/components/Summary/index.d.ts +1 -2
- package/es/ProEditTable/index.d.ts +1 -1
- package/es/ProEditTable/index.js +44 -38
- package/es/ProEditTable/propsType.d.ts +6 -0
- package/es/ProEditTable/utils/config.d.ts +1 -2
- package/es/ProEditTable/utils/index.js +3 -2
- package/es/ProEditTable/utils/useShouldUpdateForTable.js +11 -4
- package/es/ProEnum/components/Group.d.ts +1 -2
- package/es/ProEnum/components/Tag.d.ts +1 -2
- package/es/ProEnum/index.d.ts +2 -3
- package/es/ProEnum/utils/getEnumLabel.d.ts +1 -2
- package/es/ProForm/components/base/Input/index.d.ts +1 -2
- package/es/ProForm/components/combination/FormList/components/Empty.d.ts +1 -2
- package/es/ProForm/components/combination/ProCascader/index.d.ts +1 -1
- package/es/ProForm/hooks/useForm.d.ts +1 -1
- package/es/ProLayout/components/Layout/Menu/OpenMenu/index.d.ts +1 -2
- package/es/ProLayout/components/ProCollapse/index.d.ts +1 -2
- package/es/ProLayout/components/ProFooter/index.d.ts +1 -1
- package/es/ProLayout/components/ProHeader/components/Copy/index.d.ts +1 -2
- package/es/ProLayout/components/ProHeader/components/Describe/index.d.ts +3 -3
- package/es/ProLayout/components/ProHeader/index.d.ts +1 -1
- package/es/ProLayout/components/ProHeader/index.js +1 -0
- package/es/ProLayout/components/TabsManager/components/TabContextMenu.d.ts +1 -2
- package/es/ProLayout/components/TabsManager/components/TabsHeader.d.ts +1 -2
- package/es/ProLayout/index.d.ts +4 -4
- package/es/ProSelect/components/AdaptiveTooltip.d.ts +1 -2
- package/es/ProSelect/index.d.ts +1 -1
- package/es/ProStep/components/Anchor/index.d.ts +2 -2
- package/es/ProStep/components/Anchor/index.js +4 -3
- package/es/ProStep/components/Item/index.js +8 -5
- package/es/ProStep/components/Step/index.d.ts +6 -3
- package/es/ProStep/components/Step/index.js +5 -3
- package/es/ProStep/constants.d.ts +1 -0
- package/es/ProStep/constants.js +1 -0
- package/es/ProStep/index.js +102 -6
- package/es/ProStep/propsType.d.ts +12 -6
- package/es/ProStep/style/index.less +6 -3
- package/es/ProStep/utils/index.d.ts +5 -5
- package/es/ProStep/utils/index.js +35 -11
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.d.ts +1 -1
- package/es/ProTable/components/RenderFooter/index.d.ts +1 -2
- package/es/ProTable/components/RenderTableHeader/index.d.ts +1 -2
- package/es/ProTable/components/RenderTabs/index.d.ts +1 -1
- package/es/ProTable/components/TableResizable/index.d.ts +1 -2
- package/es/ProTabs/components/Card/index.d.ts +1 -2
- package/es/ProThemeTools/component/ProTools/index.d.ts +1 -2
- package/es/ProThemeTools/index.d.ts +1 -2
- package/es/ProTooltip/index.d.ts +1 -2
- package/es/ProTree/components/AdaptiveTooltip.d.ts +1 -2
- package/es/ProTree/components/CloseIcon.d.ts +1 -2
- package/es/ProTree/components/List.d.ts +1 -1
- package/es/ProTree/components/ProTree.d.ts +1 -2
- package/es/ProTree/components/ProTreeSelect/index.d.ts +1 -1
- package/es/ProTree/components/SearchTitle.d.ts +1 -1
- package/es/ProTree/components/Tree.d.ts +2 -2
- package/es/ProTree/index.d.ts +1 -2
- package/es/ProTreeModal/components/Cascader.d.ts +1 -1
- package/es/ProTreeModal/components/CloseIcon.d.ts +1 -2
- package/es/ProTreeModal/components/SearchTitle.d.ts +1 -1
- package/es/ProTreeModal/components/Trigger.d.ts +1 -1
- package/es/ProTreeModal/components/Trigger.js +4 -2
- package/es/ProTreeModal/index.d.ts +1 -2
- package/es/ProUpload/components/DraggableUploadListItem.d.ts +1 -2
- package/package.json +2 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import './index.less';
|
|
3
2
|
interface propsWithCheckModal {
|
|
4
3
|
errorTitle?: string;
|
|
5
4
|
list?: string[];
|
|
6
5
|
[key: string]: any;
|
|
7
6
|
}
|
|
8
|
-
declare const CheckModalContent: (props: propsWithCheckModal) => import("react").JSX.Element;
|
|
7
|
+
declare const CheckModalContent: (props: propsWithCheckModal) => import("react/jsx-runtime").JSX.Element;
|
|
9
8
|
export default CheckModalContent;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { ProDownloadType } from './propsType';
|
|
3
2
|
declare const ProDownload: {
|
|
4
|
-
(props: ProDownloadType): import("react").JSX.Element;
|
|
3
|
+
(props: ProDownloadType): import("react/jsx-runtime").JSX.Element;
|
|
5
4
|
downLoadRequest: import("./utils").DownloadRequestProps;
|
|
6
5
|
};
|
|
7
6
|
export default ProDownload;
|
|
@@ -27,6 +27,7 @@ const BaseTable = ({
|
|
|
27
27
|
isHideCheckBox,
|
|
28
28
|
rowDraggable,
|
|
29
29
|
pagination,
|
|
30
|
+
paginationValidationEnabled,
|
|
30
31
|
scroll,
|
|
31
32
|
summary,
|
|
32
33
|
page,
|
|
@@ -37,7 +38,7 @@ const BaseTable = ({
|
|
|
37
38
|
const [errorLength] = useEditTableError({
|
|
38
39
|
containerNode: tableRef.current,
|
|
39
40
|
className: 'ant-form-item-explain-error',
|
|
40
|
-
isEnabled:
|
|
41
|
+
isEnabled: paginationValidationEnabled
|
|
41
42
|
});
|
|
42
43
|
const getScroll = useCallback(() => {
|
|
43
44
|
if (!scroll) return null;
|
|
@@ -87,17 +88,17 @@ const BaseTable = ({
|
|
|
87
88
|
});
|
|
88
89
|
},
|
|
89
90
|
itemRender: (index, type, originalElement) => {
|
|
90
|
-
return type === 'page' && page.pageNum === index && errorLength ? /*#__PURE__*/_jsxs("div", {
|
|
91
|
+
return paginationValidationEnabled && type === 'page' && page.pageNum === index && errorLength ? /*#__PURE__*/_jsxs("div", {
|
|
91
92
|
className: "pro-edit-table-pagination-item-badge",
|
|
92
93
|
children: [/*#__PURE__*/_jsx(Badge, {
|
|
93
94
|
count: errorLength
|
|
94
95
|
}), originalElement]
|
|
95
96
|
}) : originalElement;
|
|
96
97
|
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
...(typeof pagination === 'object' ? pagination : {}),
|
|
99
|
+
current: (typeof pagination === 'object' ? pagination.current : undefined) ?? page.pageNum,
|
|
100
|
+
pageSize: (typeof pagination === 'object' ? pagination.pageSize : undefined) ?? page.pageSize,
|
|
101
|
+
onChange: handlePageChange
|
|
101
102
|
} : false,
|
|
102
103
|
scroll: getScroll()
|
|
103
104
|
};
|
|
@@ -165,8 +165,6 @@ const DraggableTable = ({
|
|
|
165
165
|
...resetProps,
|
|
166
166
|
rowKey: tableRowKey,
|
|
167
167
|
pagination: pagination ? {
|
|
168
|
-
current: page.pageNum,
|
|
169
|
-
pageSize: page.pageSize,
|
|
170
168
|
showSizeChanger: false,
|
|
171
169
|
showQuickJumper: true,
|
|
172
170
|
total: value?.length,
|
|
@@ -176,8 +174,10 @@ const DraggableTable = ({
|
|
|
176
174
|
total
|
|
177
175
|
});
|
|
178
176
|
},
|
|
179
|
-
|
|
180
|
-
|
|
177
|
+
...(typeof pagination === 'object' ? pagination : {}),
|
|
178
|
+
current: (typeof pagination === 'object' ? pagination.current : undefined) ?? page.pageNum,
|
|
179
|
+
pageSize: (typeof pagination === 'object' ? pagination.pageSize : undefined) ?? page.pageSize,
|
|
180
|
+
onChange: handlePageChange
|
|
181
181
|
} : false,
|
|
182
182
|
scroll: getScroll(),
|
|
183
183
|
summary
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
declare const _default: React.MemoExoticComponent<({ text: value, record, index, column, config }: any) =>
|
|
2
|
+
declare const _default: React.MemoExoticComponent<({ text: value, record, index, column, config }: any) => import("react/jsx-runtime").JSX.Element>;
|
|
3
3
|
export default _default;
|
|
@@ -25,7 +25,7 @@ import ConfirmWrapper from "../../../ProForm/components/render/ConfirmWrapper";
|
|
|
25
25
|
import { getDefaultProps } from "../../utils/getDefaultProps";
|
|
26
26
|
import ListChangedWrapper from "./ListChangedWrapper";
|
|
27
27
|
import useShouldUpdateForTable from "../../utils/useShouldUpdateForTable";
|
|
28
|
-
import { OMIT_FORM_ITEM_AND_DOM_KEYS, arePropsEqual } from "./tools";
|
|
28
|
+
import { OMIT_FORM_ITEM_AND_DOM_KEYS, arePropsEqual, hasRowFunctionDependency, mergeOnFieldChangeRow } from "./tools";
|
|
29
29
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
30
30
|
const RenderField = ({
|
|
31
31
|
text: value,
|
|
@@ -237,21 +237,7 @@ const RenderField = ({
|
|
|
237
237
|
// 因为这些函数依赖行数据,当行数据变化时需要重新计算
|
|
238
238
|
// 扩展到所有模式(single/multiple/cell),统一行为
|
|
239
239
|
// 注意:需要检查原始的 component/editRender,而不是处理后的 lastComponent
|
|
240
|
-
const hasFunctionDependency =
|
|
241
|
-
// disabled 是函数
|
|
242
|
-
_isFunction(fieldProps) ||
|
|
243
|
-
// fieldProps 是函数
|
|
244
|
-
_isFunction(required) ||
|
|
245
|
-
// required 是函数
|
|
246
|
-
_isFunction(rules) ||
|
|
247
|
-
// rules 是函数
|
|
248
|
-
_isFunction(column?.isEditable) ||
|
|
249
|
-
// isEditable 是函数
|
|
250
|
-
_isFunction(component) ||
|
|
251
|
-
// component 是函数
|
|
252
|
-
_isFunction(editRender) ||
|
|
253
|
-
// editRender 是函数
|
|
254
|
-
_isFunction(viewRender); // viewRender 是函数
|
|
240
|
+
const hasFunctionDependency = hasRowFunctionDependency(column);
|
|
255
241
|
|
|
256
242
|
// 移除 isSingleMode 限制,让所有模式都支持响应式更新
|
|
257
243
|
// 性能优化已通过 useShouldUpdateForTable hook 的缓存和防抖机制实现
|
|
@@ -349,8 +335,8 @@ const RenderField = ({
|
|
|
349
335
|
if (isView) {
|
|
350
336
|
// 存在viewRender覆盖默认值
|
|
351
337
|
if (typeof viewRender === 'function') {
|
|
352
|
-
|
|
353
|
-
const View = viewRender(
|
|
338
|
+
const latestCurrentValue = dataIndex ? rowData?.[dataIndex] : value;
|
|
339
|
+
const View = viewRender(latestCurrentValue, rowData || {}, options);
|
|
354
340
|
TargetComponent = /*#__PURE__*/_jsx(Container, {
|
|
355
341
|
viewEmpty: viewEmpty,
|
|
356
342
|
children: View
|
|
@@ -438,7 +424,20 @@ const RenderField = ({
|
|
|
438
424
|
TargetComponent?.props?.onFieldChange && (await TargetComponent.props.onFieldChange(...callArgs));
|
|
439
425
|
onFieldChange && (await onFieldChange(...callArgs));
|
|
440
426
|
|
|
441
|
-
//
|
|
427
|
+
// 原地修改 row 会改变 store 内的对象,但不会通知 Form 和只读单元格重新渲染。
|
|
428
|
+
// 只通知相对回调前真正变化的子字段,避免整行回写覆盖回调内显式 setFieldValue 的新值。
|
|
429
|
+
const latestStoreRow = form.getFieldValue(rowPath, true) || {};
|
|
430
|
+
const nextStoreRow = mergeOnFieldChangeRow(orgRow, row, latestStoreRow);
|
|
431
|
+
if (nextStoreRow !== latestStoreRow) {
|
|
432
|
+
// ProEditTable 注册在整个列表路径上,子行写入不会通知该 Form.Item。
|
|
433
|
+
// 以最新列表为底只替换当前行,确保其他行与显式 store 写入不被覆盖。
|
|
434
|
+
const latestList = form.getFieldValue(namePath, true) || [];
|
|
435
|
+
const nextList = [...latestList];
|
|
436
|
+
nextList[index] = nextStoreRow;
|
|
437
|
+
form.setFieldValue(namePath, nextList);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// 延后读取通知后的最新 store,统一处理联动校验与行刷新。
|
|
442
441
|
setTimeout(() => {
|
|
443
442
|
const rowAfter = form.getFieldValue(rowPath, true) ?? row;
|
|
444
443
|
if (validateTrigger && validateTrigger.includes('onChange')) {
|
|
@@ -597,7 +596,9 @@ const RenderField = ({
|
|
|
597
596
|
source: 'ProEditTable'
|
|
598
597
|
}
|
|
599
598
|
}), [cellName, lastFieldProps, TargetComponent?.props, namePath, index, lastDisabled, handleChange, handleBlur, confirm, lastDesensitization, names, originalName, viewEmpty, lastValueType, isView, otherProps?.desensitizationKey]);
|
|
600
|
-
componentProps = _omit(componentProps, ['onFieldChange', 'namePath', 'index',
|
|
599
|
+
componentProps = _omit(componentProps, ['onFieldChange', 'namePath', 'index',
|
|
600
|
+
// precision 是 InputNumber 的有效 fieldProps,仅在真正渲染原生 DOM 时过滤
|
|
601
|
+
...OMIT_FORM_ITEM_AND_DOM_KEYS.filter(key => key !== 'precision')]);
|
|
601
602
|
if (['Switch', 'SwitchCheckbox'].includes(type)) {
|
|
602
603
|
lastFormItemProps.valuePropName = 'checked';
|
|
603
604
|
}
|
|
@@ -751,7 +752,7 @@ const RenderField = ({
|
|
|
751
752
|
// 查看模式
|
|
752
753
|
if (latestIsView) {
|
|
753
754
|
if (typeof viewRender === 'function') {
|
|
754
|
-
const latestCurrentValue = dataIndex ? latestRowData?.[dataIndex] :
|
|
755
|
+
const latestCurrentValue = dataIndex ? latestRowData?.[dataIndex] : value;
|
|
755
756
|
const View = viewRender(latestCurrentValue, latestRowData || {}, options);
|
|
756
757
|
latestTargetComponent = /*#__PURE__*/_jsx(Container, {
|
|
757
758
|
viewEmpty: viewEmpty,
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { InternalNamePath, NamePath } from 'antd/lib/form/interface';
|
|
2
2
|
import { GetOriginalValueParams, RenderFieldComparableProps } from './propsType';
|
|
3
|
+
/** 判断列是否包含可能依赖整行数据的函数型配置。 */
|
|
4
|
+
export declare const hasRowFunctionDependency: (column: Record<string, any> | null | undefined) => boolean;
|
|
5
|
+
/**
|
|
6
|
+
* 将 onFieldChange 中原地修改的字段合并到最新 Form Store 行。
|
|
7
|
+
* Store 若已将同一字段显式写成其他值,则保留 Store 值。
|
|
8
|
+
*/
|
|
9
|
+
export declare const mergeOnFieldChangeRow: (beforeRow: Record<string, any> | null | undefined, mutatedRow: Record<string, any> | null | undefined, latestStoreRow: Record<string, any> | null | undefined) => Record<string, any>;
|
|
3
10
|
/** 列配置中不应透传到 Form.Item 或 DOM 的字段(与 ProForm Render 保持一致) */
|
|
4
11
|
export declare const OMIT_FORM_ITEM_AND_DOM_KEYS: string[];
|
|
5
12
|
/** 克隆子元素时需从 props 中剔除,避免透传到 div 等 DOM 导致 React 警告 */
|
|
@@ -4,6 +4,33 @@ import _isEqual from "lodash/isEqual";
|
|
|
4
4
|
import _get from "lodash/get";
|
|
5
5
|
import { customEqualForFunction } from "../../../utils";
|
|
6
6
|
import { getNamePath, isRecordShallowEqual } from "../../utils/tools";
|
|
7
|
+
const ROW_FUNCTION_DEPENDENCY_KEYS = ['component', 'editRender', 'fieldProps', 'rules', 'required', 'disabled', 'isEditable', 'valueType', 'viewRender'];
|
|
8
|
+
|
|
9
|
+
/** 判断列是否包含可能依赖整行数据的函数型配置。 */
|
|
10
|
+
export const hasRowFunctionDependency = column => ROW_FUNCTION_DEPENDENCY_KEYS.some(key => _isFunction(column?.[key]));
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 将 onFieldChange 中原地修改的字段合并到最新 Form Store 行。
|
|
14
|
+
* Store 若已将同一字段显式写成其他值,则保留 Store 值。
|
|
15
|
+
*/
|
|
16
|
+
export const mergeOnFieldChangeRow = (beforeRow, mutatedRow, latestStoreRow) => {
|
|
17
|
+
const before = beforeRow || {};
|
|
18
|
+
const mutated = mutatedRow || {};
|
|
19
|
+
const latest = latestStoreRow || {};
|
|
20
|
+
const changedKeys = Array.from(new Set([...Object.keys(before), ...Object.keys(mutated)])).filter(key => !_isEqual(before[key], mutated[key]));
|
|
21
|
+
let nextRow = latest;
|
|
22
|
+
changedKeys.forEach(key => {
|
|
23
|
+
const storeChangedExplicitly = !_isEqual(latest[key], before[key]) && !_isEqual(latest[key], mutated[key]);
|
|
24
|
+
if (!storeChangedExplicitly) {
|
|
25
|
+
nextRow = {
|
|
26
|
+
...nextRow,
|
|
27
|
+
[key]: mutated[key]
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return nextRow;
|
|
32
|
+
};
|
|
33
|
+
|
|
7
34
|
/** 列配置中不应透传到 Form.Item 或 DOM 的字段(与 ProForm Render 保持一致) */
|
|
8
35
|
export const OMIT_FORM_ITEM_AND_DOM_KEYS = ['format', 'toISOString', 'toCSTString', 'switchValue', 'precision', 'clearNotShow', 'dependNames', 'shouldCellUpdate' // 表格内部性能优化属性,不应传递给 Form.Item
|
|
9
36
|
];
|
|
@@ -91,9 +118,9 @@ export const arePropsEqual = (prevProps, nextProps) => {
|
|
|
91
118
|
config: nextConfig
|
|
92
119
|
} = nextProps;
|
|
93
120
|
|
|
94
|
-
// 函数型动态属性(component/editRender/fieldProps/rules/required/disabled/isEditable/valueType)
|
|
121
|
+
// 函数型动态属性(component/editRender/fieldProps/rules/required/disabled/isEditable/valueType/viewRender)
|
|
95
122
|
// 可能依赖行内兄弟字段;行对象为同引用(原地修改)时,浅比较无法区分,需强制重渲染
|
|
96
|
-
const hasFunctionDependency =
|
|
123
|
+
const hasFunctionDependency = hasRowFunctionDependency(prevColumn) || hasRowFunctionDependency(nextColumn);
|
|
97
124
|
if (hasFunctionDependency && prevRecord === nextRecord) {
|
|
98
125
|
return false;
|
|
99
126
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { ProEditTableSummaryColumnType } from '../../propsType';
|
|
3
2
|
interface SummaryProps<T = any> {
|
|
4
3
|
data: T[];
|
|
@@ -9,5 +8,5 @@ interface SummaryProps<T = any> {
|
|
|
9
8
|
};
|
|
10
9
|
rowSelection: any;
|
|
11
10
|
}
|
|
12
|
-
declare const Summary: ({ data, summary, rowSelection }: SummaryProps) => import("react").JSX.Element;
|
|
11
|
+
declare const Summary: ({ data, summary, rowSelection }: SummaryProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
12
|
export default Summary;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ProEditTableType } from './propsType';
|
|
3
|
-
declare const ForwardProEditTable: React.ForwardRefExoticComponent<Omit<ProEditTableType
|
|
3
|
+
declare const ForwardProEditTable: React.ForwardRefExoticComponent<Omit<ProEditTableType<any>, "ref"> & React.RefAttributes<import("./propsType").ProEditTableRefProps>>;
|
|
4
4
|
export default ForwardProEditTable;
|
package/es/ProEditTable/index.js
CHANGED
|
@@ -25,6 +25,7 @@ const ProEditTable = ({
|
|
|
25
25
|
className,
|
|
26
26
|
columns,
|
|
27
27
|
mode = 'multiple',
|
|
28
|
+
paginationMode = 'normal',
|
|
28
29
|
stripe = true,
|
|
29
30
|
draggable = false,
|
|
30
31
|
disabled = false,
|
|
@@ -118,6 +119,14 @@ const ProEditTable = ({
|
|
|
118
119
|
selectedRows,
|
|
119
120
|
page
|
|
120
121
|
} = state;
|
|
122
|
+
const paginationEnabled = Boolean(pagination);
|
|
123
|
+
const paginationValidationEnabled = paginationEnabled && paginationMode === 'validate';
|
|
124
|
+
const paginationConfig = typeof pagination === 'object' ? pagination : undefined;
|
|
125
|
+
const resolvedPage = useMemo(() => ({
|
|
126
|
+
pageNum: paginationConfig?.current ?? page.pageNum,
|
|
127
|
+
pageSize: paginationConfig?.pageSize ?? page.pageSize
|
|
128
|
+
}), [page.pageNum, page.pageSize, paginationConfig?.current, paginationConfig?.pageSize]);
|
|
129
|
+
const mergedSelectedRowKeys = rowSelection?.selectedRowKeys ?? selectedRowKeys;
|
|
121
130
|
const virtualRowName = getNamePath(_isArray(name) ? name : [name], virtualKey);
|
|
122
131
|
|
|
123
132
|
// 样式处理
|
|
@@ -166,31 +175,26 @@ const ProEditTable = ({
|
|
|
166
175
|
|
|
167
176
|
// 分页变更
|
|
168
177
|
const handlePageChange = useCallback(async (current, pageSize) => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
page: {
|
|
174
|
-
pageNum: current,
|
|
175
|
-
pageSize
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
178
|
+
if (!paginationEnabled) return;
|
|
179
|
+
const isPageSizeChange = pageSize !== resolvedPage.pageSize;
|
|
180
|
+
if (paginationValidationEnabled && !isPageSizeChange) {
|
|
181
|
+
try {
|
|
180
182
|
await form.validateFields([name], {
|
|
181
183
|
recursive: true
|
|
182
184
|
});
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
pageSize: pageSize ?? page.pageSize
|
|
187
|
-
}
|
|
188
|
-
});
|
|
185
|
+
} catch (error) {
|
|
186
|
+
handleScrollToError();
|
|
187
|
+
return;
|
|
189
188
|
}
|
|
190
|
-
} catch (error) {
|
|
191
|
-
handleScrollToError();
|
|
192
189
|
}
|
|
193
|
-
|
|
190
|
+
setState({
|
|
191
|
+
page: {
|
|
192
|
+
pageNum: current,
|
|
193
|
+
pageSize: pageSize ?? resolvedPage.pageSize
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
paginationConfig?.onChange?.(current, pageSize);
|
|
197
|
+
}, [form, name, paginationConfig?.onChange, paginationEnabled, paginationValidationEnabled, resolvedPage.pageSize]);
|
|
194
198
|
const config = useMemo(() => ({
|
|
195
199
|
form,
|
|
196
200
|
mode,
|
|
@@ -205,7 +209,7 @@ const ProEditTable = ({
|
|
|
205
209
|
actionProps,
|
|
206
210
|
toolbarProps,
|
|
207
211
|
setState,
|
|
208
|
-
selectedRowKeys,
|
|
212
|
+
selectedRowKeys: mergedSelectedRowKeys,
|
|
209
213
|
selectedRows,
|
|
210
214
|
onlyOneLineMsg,
|
|
211
215
|
deletePoConfirmMsg,
|
|
@@ -220,7 +224,7 @@ const ProEditTable = ({
|
|
|
220
224
|
tableRef,
|
|
221
225
|
max,
|
|
222
226
|
tableLength: value?.length,
|
|
223
|
-
page,
|
|
227
|
+
page: resolvedPage,
|
|
224
228
|
originalValues,
|
|
225
229
|
errorStore: errorStoreRef.current,
|
|
226
230
|
prefixCls,
|
|
@@ -236,7 +240,7 @@ const ProEditTable = ({
|
|
|
236
240
|
...resetProps
|
|
237
241
|
}), [actionDirection, actionProps, actionWidth, columns, deletePoConfirmMsg, diffConfig, editingKeys, emptyBtnText, form,
|
|
238
242
|
// forceUpdate 不应该作为依赖项,因为它是触发刷新的信号,而非用于比较的数据
|
|
239
|
-
getIsNew, handlePageChange, insertType, isView, max, mode, mulDeletePoConfirmMsg, name, namePath, onlyOneLineMsg, originalValues, prefixCls, requiredAlign, resetProps, rowDisabled,
|
|
243
|
+
getIsNew, handlePageChange, insertType, isView, max, mode, mulDeletePoConfirmMsg, name, namePath, onlyOneLineMsg, originalValues, prefixCls, requiredAlign, resetProps, rowDisabled, mergedSelectedRowKeys, selectedRows, shouldUpdateDebounce, tableRef, toolbarProps, value?.length, viewEmpty, virtualKey, resolvedPage]);
|
|
240
244
|
|
|
241
245
|
// 编辑行设置下样式
|
|
242
246
|
const _rowClassName = record => {
|
|
@@ -267,19 +271,12 @@ const ProEditTable = ({
|
|
|
267
271
|
}, [toolbarProps]);
|
|
268
272
|
|
|
269
273
|
// 是否隐藏勾选框
|
|
270
|
-
const isHideCheckBox = isForbiddenBtn('mulDelete');
|
|
274
|
+
const isHideCheckBox = !rowSelection && isForbiddenBtn('mulDelete');
|
|
271
275
|
|
|
272
276
|
// 复选框
|
|
273
277
|
const _rowSelection = {
|
|
274
278
|
fixed: true,
|
|
275
|
-
selectedRowKeys,
|
|
276
279
|
columnWidth: 48,
|
|
277
|
-
onChange: (selectedRowKeys, selectedRows) => {
|
|
278
|
-
setState({
|
|
279
|
-
selectedRowKeys,
|
|
280
|
-
selectedRows
|
|
281
|
-
});
|
|
282
|
-
},
|
|
283
280
|
getCheckboxProps: record => {
|
|
284
281
|
if (rowDisabled) {
|
|
285
282
|
const _disabled = rowDisabled(record);
|
|
@@ -290,7 +287,15 @@ const ProEditTable = ({
|
|
|
290
287
|
return {};
|
|
291
288
|
},
|
|
292
289
|
hideSelectAll: isHideCheckBox,
|
|
293
|
-
...rowSelection
|
|
290
|
+
...rowSelection,
|
|
291
|
+
selectedRowKeys: mergedSelectedRowKeys,
|
|
292
|
+
onChange: (nextSelectedRowKeys, nextSelectedRows, info) => {
|
|
293
|
+
setState({
|
|
294
|
+
selectedRowKeys: nextSelectedRowKeys,
|
|
295
|
+
selectedRows: nextSelectedRows
|
|
296
|
+
});
|
|
297
|
+
rowSelection?.onChange?.(nextSelectedRowKeys, nextSelectedRows, info);
|
|
298
|
+
}
|
|
294
299
|
};
|
|
295
300
|
|
|
296
301
|
// 空列表状态
|
|
@@ -411,13 +416,14 @@ const ProEditTable = ({
|
|
|
411
416
|
isHideCheckBox,
|
|
412
417
|
rowDraggable,
|
|
413
418
|
pagination,
|
|
419
|
+
paginationValidationEnabled,
|
|
414
420
|
scroll,
|
|
415
421
|
summary: _summary,
|
|
416
|
-
page,
|
|
422
|
+
page: resolvedPage,
|
|
417
423
|
formatMessage,
|
|
418
424
|
locale,
|
|
419
425
|
handlePageChange
|
|
420
|
-
}), [_className, _columns, _rowClassName, disabled, editingKeys, formatMessage, handlePageChange, headerRender, isHideCheckBox, locale,
|
|
426
|
+
}), [_className, _columns, _rowClassName, disabled, editingKeys, formatMessage, handlePageChange, headerRender, isHideCheckBox, locale, pagination, paginationValidationEnabled, renderRowSelection, rowDraggable, rowKey, tableRowKey, scroll, _summary, tableRef, enrichedValue, resolvedPage, virtualKey]);
|
|
421
427
|
|
|
422
428
|
// 拖拽排序后,enrichedValue 中含 _dragIndex/_rowIndex(内部字段),需清除后再传给外部 onChange
|
|
423
429
|
const handleDragChange = useCallback(newValue => {
|
|
@@ -446,20 +452,20 @@ const ProEditTable = ({
|
|
|
446
452
|
ref: affixRef,
|
|
447
453
|
..._toolbarSticky,
|
|
448
454
|
children: /*#__PURE__*/_jsx("div", {
|
|
449
|
-
className: `pro-edit-table-toolbar${
|
|
455
|
+
className: `pro-edit-table-toolbar${paginationEnabled ? ' pro-edit-table-toolbar-fixed' : ''}`,
|
|
450
456
|
children: /*#__PURE__*/_jsx(RenderToolbar, {
|
|
451
457
|
...config
|
|
452
458
|
})
|
|
453
459
|
})
|
|
454
460
|
}) : /*#__PURE__*/_jsx("div", {
|
|
455
|
-
className: `pro-edit-table-toolbar${
|
|
461
|
+
className: `pro-edit-table-toolbar${paginationEnabled ? ' pro-edit-table-toolbar-fixed' : ''}`,
|
|
456
462
|
children: /*#__PURE__*/_jsx(RenderToolbar, {
|
|
457
463
|
...config
|
|
458
464
|
})
|
|
459
465
|
}) : null, footerRender ? /*#__PURE__*/_jsx("div", {
|
|
460
466
|
className: "pro-edit-table-footer",
|
|
461
467
|
children: footerRender
|
|
462
|
-
}) : null,
|
|
468
|
+
}) : null, paginationValidationEnabled ? /*#__PURE__*/_jsx("div", {
|
|
463
469
|
id: `pro-edit-table-pagination-${Array.isArray(config.name) ? config.name.filter(Boolean).join('-') : config.name || 'default'}`,
|
|
464
470
|
onClick: () => {
|
|
465
471
|
onPageCheck({
|
|
@@ -467,7 +473,7 @@ const ProEditTable = ({
|
|
|
467
473
|
name,
|
|
468
474
|
value,
|
|
469
475
|
columns,
|
|
470
|
-
page,
|
|
476
|
+
page: resolvedPage,
|
|
471
477
|
pagination,
|
|
472
478
|
isView,
|
|
473
479
|
disabled,
|
|
@@ -232,6 +232,7 @@ export type ProEditTableRefType = ProEditTableRefProps;
|
|
|
232
232
|
*/
|
|
233
233
|
export type ProEditTableMode = 'single' | 'multiple';
|
|
234
234
|
export type ProEditTableModeType = ProEditTableMode;
|
|
235
|
+
export type ProEditTablePaginationMode = 'normal' | 'validate';
|
|
235
236
|
/**
|
|
236
237
|
* 表格插入类型
|
|
237
238
|
*/
|
|
@@ -268,6 +269,11 @@ export interface ProEditTableProps<T = any> extends Omit<TableProps<T>, 'onChang
|
|
|
268
269
|
* @default multiple
|
|
269
270
|
*/
|
|
270
271
|
mode?: ProEditTableMode;
|
|
272
|
+
/**
|
|
273
|
+
* 分页行为模式。normal 仅使用 antd 分页,validate 会在切页前校验当前表格
|
|
274
|
+
* @default normal
|
|
275
|
+
*/
|
|
276
|
+
paginationMode?: ProEditTablePaginationMode;
|
|
271
277
|
/**
|
|
272
278
|
* 必填对齐方式, 默认右对齐
|
|
273
279
|
* @default right
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
export declare const defaultBtnNameMap: {
|
|
3
2
|
add: any;
|
|
4
3
|
edit: any;
|
|
@@ -10,7 +9,7 @@ export declare const defaultBtnNameMap: {
|
|
|
10
9
|
custom: any;
|
|
11
10
|
};
|
|
12
11
|
export declare const iconMap: {
|
|
13
|
-
add: import("react").JSX.Element;
|
|
12
|
+
add: import("react/jsx-runtime").JSX.Element;
|
|
14
13
|
};
|
|
15
14
|
export declare const defaultSingleActionKeys: string[];
|
|
16
15
|
export declare const defaultMultipleActionKeys: string[];
|
|
@@ -12,6 +12,7 @@ import { customValidate, getNamePath, splitNames, handleScrollToError, cloneDeep
|
|
|
12
12
|
import { filterInternalFields } from "../../ProForm/utils";
|
|
13
13
|
import ProTooltip from "../../ProTooltip";
|
|
14
14
|
import { RenderField, ActionButton } from "../components";
|
|
15
|
+
import { hasRowFunctionDependency } from "../components/RenderField/tools";
|
|
15
16
|
import locale from "../../locale";
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -345,7 +346,7 @@ export const transformColumns = (columns = [], config, caches) => {
|
|
|
345
346
|
const hasComponent = _isFunction(item.component);
|
|
346
347
|
// 函数型动态属性会依赖整行数据(可能是当前列之外的兄弟字段),
|
|
347
348
|
// 这类列在行内任意字段变化时都需重渲染,不能只比对本列 dataIndex
|
|
348
|
-
const hasFunctionDependency =
|
|
349
|
+
const hasFunctionDependency = hasRowFunctionDependency(item);
|
|
349
350
|
const columnCacheKey = `${Array.isArray(name) ? name.join('.') : String(name)}::${String(columnName)}`;
|
|
350
351
|
|
|
351
352
|
// Fix 问题1:用原始列引用(克隆前)比对 dataSource
|
|
@@ -399,7 +400,7 @@ export const transformColumns = (columns = [], config, caches) => {
|
|
|
399
400
|
return true;
|
|
400
401
|
}
|
|
401
402
|
}
|
|
402
|
-
// 函数型动态属性(component/fieldProps/rules/required/disabled/isEditable/valueType)
|
|
403
|
+
// 函数型动态属性(component/fieldProps/rules/required/disabled/isEditable/valueType/viewRender)
|
|
403
404
|
// 可能依赖行内其他字段(兄弟字段),需比较整行;
|
|
404
405
|
// 同引用原地修改时 isEqual 恒为 true,无法感知,必须强制重渲染
|
|
405
406
|
if (hasFunctionDependency) {
|
|
@@ -24,7 +24,7 @@ const useShouldUpdateForTable = props => {
|
|
|
24
24
|
const isInitializedRef = useRef(false);
|
|
25
25
|
|
|
26
26
|
// 统一处理所有动态属性的更新
|
|
27
|
-
const processUpdate = params => {
|
|
27
|
+
const processUpdate = (params, forceFieldPropsUpdate = false) => {
|
|
28
28
|
let hasChange = false;
|
|
29
29
|
// 新格式:params = [values, { form, index, namePath }]
|
|
30
30
|
const [values, reactiveParams] = params;
|
|
@@ -65,7 +65,7 @@ const useShouldUpdateForTable = props => {
|
|
|
65
65
|
// fieldProps 处理
|
|
66
66
|
if (_isFunction(column.fieldProps)) {
|
|
67
67
|
const newFieldProps = column.fieldProps(values, reactiveParams);
|
|
68
|
-
if (!_isEqualWith(fieldPropsRef.current, newFieldProps, customEqualForFunction)) {
|
|
68
|
+
if (forceFieldPropsUpdate || !_isEqualWith(fieldPropsRef.current, newFieldProps, customEqualForFunction)) {
|
|
69
69
|
fieldPropsRef.current = newFieldProps;
|
|
70
70
|
hasChange = true;
|
|
71
71
|
}
|
|
@@ -131,15 +131,22 @@ const useShouldUpdateForTable = props => {
|
|
|
131
131
|
// 统一的属性处理逻辑
|
|
132
132
|
// 使用 ref 存储上一次的 rowParams,避免引用变化导致的重复调用
|
|
133
133
|
const prevRowParamsRef = useRef(null);
|
|
134
|
+
const currentFieldPropsFactory = _isFunction(column.fieldProps) ? column.fieldProps : undefined;
|
|
135
|
+
const prevFieldPropsFactoryRef = useRef(currentFieldPropsFactory);
|
|
136
|
+
const fieldPropsFactoryChanged = prevFieldPropsFactoryRef.current !== currentFieldPropsFactory;
|
|
137
|
+
prevFieldPropsFactoryRef.current = currentFieldPropsFactory;
|
|
134
138
|
|
|
135
139
|
// 行数据引用 + 行索引均不变时跳过深比较(虚拟滚动常见路径)
|
|
136
140
|
const prevRowParams = prevRowParamsRef.current;
|
|
137
141
|
const rowDataUnchanged = isInitializedRef.current && prevRowParams?.[0] === rowParams[0] && prevRowParams?.[1]?.index === rowParams[1]?.index;
|
|
138
|
-
const shouldProcess = !isInitializedRef.current || !rowDataUnchanged && !_isEqualWith(prevRowParams, rowParams, customEqualForFunction);
|
|
142
|
+
const shouldProcess = !isInitializedRef.current || fieldPropsFactoryChanged || !rowDataUnchanged && !_isEqualWith(prevRowParams, rowParams, customEqualForFunction);
|
|
139
143
|
if (shouldProcess) {
|
|
140
144
|
prevRowParamsRef.current = rowParams;
|
|
141
145
|
isInitializedRef.current = true;
|
|
142
|
-
if (
|
|
146
|
+
if (fieldPropsFactoryChanged) {
|
|
147
|
+
// 外部依赖变化会生成新的 fieldProps 函数,需要立即替换旧闭包缓存
|
|
148
|
+
processUpdate(rowParams, true);
|
|
149
|
+
} else if (shouldUpdateDebounce > 0 && debouncedUpdateRef.current) {
|
|
143
150
|
// 使用防抖延迟更新
|
|
144
151
|
pendingParamsRef.current = rowParams;
|
|
145
152
|
debouncedUpdateRef.current();
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { ProEnumType } from '../propsType';
|
|
3
2
|
interface Props extends Pick<ProEnumType, 'id' | 'value' | 'onChange' | 'dataSource'> {
|
|
4
3
|
fieldValue: string;
|
|
@@ -7,5 +6,5 @@ interface Props extends Pick<ProEnumType, 'id' | 'value' | 'onChange' | 'dataSou
|
|
|
7
6
|
allowClear?: boolean;
|
|
8
7
|
button?: boolean;
|
|
9
8
|
}
|
|
10
|
-
declare const Group: (props: Props) => import("react").JSX.Element;
|
|
9
|
+
declare const Group: (props: Props) => import("react/jsx-runtime").JSX.Element;
|
|
11
10
|
export default Group;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { ProEnumType } from '../propsType';
|
|
3
2
|
interface Props extends Pick<ProEnumType, 'id' | 'value' | 'onChange' | 'dataSource'> {
|
|
4
3
|
fieldValue: string;
|
|
5
4
|
fieldLabel: string;
|
|
6
5
|
}
|
|
7
|
-
declare const ProEnumTag: (props: Props) => import("react").JSX.Element;
|
|
6
|
+
declare const ProEnumTag: (props: Props) => import("react/jsx-runtime").JSX.Element;
|
|
8
7
|
export default ProEnumTag;
|
package/es/ProEnum/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import useEnum from './hooks/useEnum';
|
|
3
2
|
import getEnum from './utils/getEnum';
|
|
4
3
|
import type { ProEnumType } from './propsType';
|
|
5
4
|
declare const ProEnum: {
|
|
6
|
-
(props: ProEnumType):
|
|
7
|
-
getEnumLabel: (code: string | string[], value: any, compose?: boolean, fieldNameLabel?: string, fieldNameValue?: string) =>
|
|
5
|
+
(props: ProEnumType): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
getEnumLabel: (code: string | string[], value: any, compose?: boolean, fieldNameLabel?: string, fieldNameValue?: string) => import("react/jsx-runtime").JSX.Element;
|
|
8
7
|
useEnum: typeof useEnum;
|
|
9
8
|
getEnum: typeof getEnum;
|
|
10
9
|
};
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
declare const getEnumLabel: (code: string | string[], value: any, compose?: boolean, fieldNameLabel?: string, fieldNameValue?: string) => import("react").JSX.Element;
|
|
1
|
+
declare const getEnumLabel: (code: string | string[], value: any, compose?: boolean, fieldNameLabel?: string, fieldNameValue?: string) => import("react/jsx-runtime").JSX.Element;
|
|
3
2
|
export default getEnumLabel;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { FormInstance, FormListOperation } from 'antd';
|
|
3
2
|
import type { InternalNamePath } from 'antd/es/form/interface';
|
|
4
3
|
import type { ToolbarActionType } from '../propsType';
|
|
@@ -10,5 +9,5 @@ interface EmptyProps {
|
|
|
10
9
|
namePath?: InternalNamePath;
|
|
11
10
|
emptyBtnText?: string;
|
|
12
11
|
}
|
|
13
|
-
declare const Empty: ({ disabled, toolbarProps, operation, form, namePath, emptyBtnText }: EmptyProps) => import("react").JSX.Element;
|
|
12
|
+
declare const Empty: ({ disabled, toolbarProps, operation, form, namePath, emptyBtnText }: EmptyProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
13
|
export default Empty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ProCascaderType } from './propsType';
|
|
3
|
-
declare const _default: import("react").MemoExoticComponent<(props: ProCascaderType) => import("react").JSX.Element>;
|
|
3
|
+
declare const _default: import("react").MemoExoticComponent<(props: ProCascaderType) => import("react/jsx-runtime").JSX.Element>;
|
|
4
4
|
export default _default;
|