@zat-design/sisyphus-react 4.4.1-beta.2 → 4.4.1-beta.4
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/ProConfigProvider/index.d.ts +1 -1
- package/es/ProConfigProvider/index.js +6 -7
- package/es/ProConfigProvider/propsType.d.ts +22 -0
- package/es/ProEditTable/components/RcTable/DraggableTable.js +18 -32
- package/es/ProEditTable/index.js +7 -1
- package/es/ProEditTable/style/index.less +0 -5
- package/es/ProEditTable/utils/config.js +2 -0
- package/es/ProEditTable/utils/index.d.ts +15 -1
- package/es/ProEditTable/utils/index.js +27 -15
- package/es/ProForm/components/combination/Group/utils/index.d.ts +9 -9
- package/es/ProForm/components/combination/ProNumberRange/style/index.less +13 -0
- package/es/ProForm/components/combination/ProTimeLimit/style/index.less +4 -0
- package/es/ProForm/utils/useWatch.d.ts +14 -4
- package/es/ProForm/utils/useWatch.js +48 -18
- package/es/ProTable/components/EditableCell/index.js +55 -22
- package/es/ProTable/components/EditableCell/propsType.d.ts +14 -0
- package/es/ProTable/components/FormatColumn/index.d.ts +4 -2
- package/es/ProTable/components/FormatColumn/index.js +13 -46
- package/es/ProTable/components/RcTable/components/BaseTable/index.d.ts +1 -8
- package/es/ProTable/components/RcTable/components/BaseTable/index.js +5 -4
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.d.ts +1 -1
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +19 -32
- package/es/ProTable/components/RcTable/components/DraggableTable/index.d.ts +1 -8
- package/es/ProTable/components/RcTable/components/DraggableTable/index.js +5 -4
- package/es/ProTable/components/RenderColumn/index.js +1 -17
- package/es/ProTable/index.d.ts +9 -8
- package/es/ProTable/index.js +151 -111
- package/es/ProTable/propsType.d.ts +21 -6
- package/es/ProTable/utils/columnStorage.d.ts +35 -0
- package/es/ProTable/utils/columnStorage.js +171 -0
- package/es/ProTable/utils/index.d.ts +16 -2
- package/es/ProTable/utils/index.js +34 -21
- package/es/hooks/useDraggableRow.d.ts +34 -0
- package/es/hooks/useDraggableRow.js +70 -0
- package/package.json +1 -3
- package/es/ProForm/components/base/DatePicker/useDateLimit.d.ts +0 -3
- package/es/ProForm/components/base/DatePicker/useDateLimit.js +0 -7
- package/es/ProForm/components/combination/FormList/components/BlockTitle.d.ts +0 -13
- package/es/ProForm/components/combination/FormList/components/BlockTitle.js +0 -31
|
@@ -3,16 +3,18 @@
|
|
|
3
3
|
* 重构优化:提取公共逻辑,修复 key prop 警告
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
|
+
import type { FormInstance } from 'antd/es/form/Form';
|
|
6
7
|
import type { ProTableColumnType } from '../../propsType';
|
|
7
|
-
export declare const formatColumn: ({ column, originalObj, rowKey, wrapToolTipProps, scroll,
|
|
8
|
+
export declare const formatColumn: ({ column, originalObj, rowKey, wrapToolTipProps, scroll, isInNewRow, diffConfig, editMode, sharedForm, }: {
|
|
8
9
|
column: ProTableColumnType;
|
|
9
10
|
originalObj: any;
|
|
10
11
|
rowKey: any;
|
|
11
12
|
wrapToolTipProps?: any;
|
|
12
13
|
scroll?: any;
|
|
13
|
-
onUpdateMinWidth?: any;
|
|
14
14
|
isInNewRow?: any;
|
|
15
15
|
diffConfig: any;
|
|
16
|
+
editMode?: 'per-cell-form' | 'shared-form';
|
|
17
|
+
sharedForm?: FormInstance;
|
|
16
18
|
}) => void;
|
|
17
19
|
/**
|
|
18
20
|
* 查找最近的父级className
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _omit from "lodash/omit";
|
|
2
2
|
import _isBoolean from "lodash/isBoolean";
|
|
3
|
-
import _isObject from "lodash/isObject";
|
|
4
3
|
import _isString from "lodash/isString";
|
|
5
4
|
import _isFunction from "lodash/isFunction";
|
|
6
5
|
import _isEqual from "lodash/isEqual";
|
|
@@ -11,19 +10,16 @@ import _isEqual from "lodash/isEqual";
|
|
|
11
10
|
import React, { isValidElement } from 'react';
|
|
12
11
|
import dayjs from 'dayjs';
|
|
13
12
|
import classnames from 'classnames';
|
|
14
|
-
import { createRoot } from 'react-dom/client';
|
|
15
13
|
import { Space } from 'antd';
|
|
16
14
|
import { tools } from '@zat-design/utils';
|
|
17
15
|
import TooltipTitle from "../TooltipTitle";
|
|
18
16
|
import RenderColumn from "../RenderColumn";
|
|
19
17
|
import EditableCell from "../EditableCell";
|
|
20
|
-
import { getDecimalDigits, getOriginalValue } from "../../utils";
|
|
18
|
+
import { getDecimalDigits, getOriginalValue, getRowKey as getRowKeyUtil } from "../../utils";
|
|
21
19
|
import { isEmpty } from "../../../utils";
|
|
22
20
|
import getEnumLabel from "../../../ProEnum/utils/getEnumLabel";
|
|
23
21
|
import { ProCascader } from "../../../ProForm/components";
|
|
24
22
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
25
|
-
const isReactElement = element => /*#__PURE__*/isValidElement(element);
|
|
26
|
-
|
|
27
23
|
// 需要从 otherProps 中排除的属性(不应传递给 RenderColumn)
|
|
28
24
|
const EXCLUDED_PROPS = ['key', 'render', 'children', 'onCell', 'onHeaderCell', 'editConfig'];
|
|
29
25
|
|
|
@@ -72,45 +68,16 @@ const createRenderColumn = ({
|
|
|
72
68
|
copyable: copyable
|
|
73
69
|
});
|
|
74
70
|
};
|
|
75
|
-
const calcMinWidth = ({
|
|
76
|
-
minWidth,
|
|
77
|
-
width,
|
|
78
|
-
title,
|
|
79
|
-
isMaxContentOverFlow,
|
|
80
|
-
callback
|
|
81
|
-
}) => {
|
|
82
|
-
if (!minWidth && !width && isMaxContentOverFlow) {
|
|
83
|
-
const tempEl = document.createElement('div');
|
|
84
|
-
tempEl.style.display = 'inline-block';
|
|
85
|
-
document.body.appendChild(tempEl);
|
|
86
|
-
let root = null;
|
|
87
|
-
if (_isFunction(title)) {
|
|
88
|
-
const component = title();
|
|
89
|
-
root = createRoot(tempEl);
|
|
90
|
-
root.render(component);
|
|
91
|
-
} else if (isReactElement(title)) {
|
|
92
|
-
root = createRoot(tempEl);
|
|
93
|
-
root.render(title);
|
|
94
|
-
} else {
|
|
95
|
-
tempEl.innerHTML = title;
|
|
96
|
-
}
|
|
97
|
-
requestAnimationFrame(() => {
|
|
98
|
-
const _width = tempEl.offsetWidth;
|
|
99
|
-
root?.unmount();
|
|
100
|
-
tempEl.remove();
|
|
101
|
-
callback(_width);
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
71
|
export const formatColumn = ({
|
|
106
72
|
column,
|
|
107
73
|
originalObj,
|
|
108
74
|
rowKey,
|
|
109
75
|
wrapToolTipProps,
|
|
110
76
|
scroll,
|
|
111
|
-
onUpdateMinWidth,
|
|
112
77
|
isInNewRow,
|
|
113
|
-
diffConfig
|
|
78
|
+
diffConfig,
|
|
79
|
+
editMode,
|
|
80
|
+
sharedForm
|
|
114
81
|
}) => {
|
|
115
82
|
const {
|
|
116
83
|
title,
|
|
@@ -132,14 +99,6 @@ export const formatColumn = ({
|
|
|
132
99
|
...otherProps
|
|
133
100
|
} = column;
|
|
134
101
|
otherProps.scroll = scroll;
|
|
135
|
-
const isMaxContentOverFlow = _isObject(scroll) ? scroll?.x === 'max-content' && Reflect.ownKeys(scroll).includes('y') : false;
|
|
136
|
-
calcMinWidth({
|
|
137
|
-
minWidth,
|
|
138
|
-
width,
|
|
139
|
-
title,
|
|
140
|
-
isMaxContentOverFlow,
|
|
141
|
-
callback: onUpdateMinWidth
|
|
142
|
-
});
|
|
143
102
|
const _toolTipProps = {
|
|
144
103
|
...toolTipProps,
|
|
145
104
|
...wrapToolTipProps
|
|
@@ -707,17 +666,25 @@ export const formatColumn = ({
|
|
|
707
666
|
}
|
|
708
667
|
};
|
|
709
668
|
const prevRender = column.render;
|
|
669
|
+
const isSharedForm = editMode === 'shared-form';
|
|
710
670
|
column.render = (value, record, index) => {
|
|
711
671
|
const displayContent = prevRender ? prevRender(value, record, index) : value ?? '-';
|
|
672
|
+
const sharedFieldName = isSharedForm ? ['__editable__', String(getRowKeyUtil(rowKey, record) ?? ''), ...(Array.isArray(dataIndex) ? dataIndex : [dataIndex])] : undefined;
|
|
712
673
|
return /*#__PURE__*/_jsx(EditableCell, {
|
|
713
674
|
value: value,
|
|
714
675
|
record: record,
|
|
715
676
|
index: index,
|
|
716
677
|
dataIndex: dataIndex,
|
|
717
678
|
editConfig: mergedEditConfig,
|
|
718
|
-
displayContent: displayContent
|
|
679
|
+
displayContent: displayContent,
|
|
680
|
+
editMode: editMode,
|
|
681
|
+
sharedForm: isSharedForm ? sharedForm : undefined,
|
|
682
|
+
sharedFieldName: sharedFieldName
|
|
719
683
|
});
|
|
720
684
|
};
|
|
685
|
+
if (isSharedForm && !column.shouldCellUpdate) {
|
|
686
|
+
column.shouldCellUpdate = (record, prevRecord) => record !== prevRecord;
|
|
687
|
+
}
|
|
721
688
|
}
|
|
722
689
|
};
|
|
723
690
|
|
|
@@ -1,10 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare const _default: import("react").
|
|
3
|
-
[x: string]: any;
|
|
4
|
-
dataSource: any;
|
|
5
|
-
tableProps: any;
|
|
6
|
-
draggableProps: any;
|
|
7
|
-
summaryProps: any;
|
|
8
|
-
emptyTextProps: any;
|
|
9
|
-
}) => import("react/jsx-runtime").JSX.Element>;
|
|
2
|
+
declare const _default: import("react").NamedExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<any>>;
|
|
10
3
|
export default _default;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Table } from 'antd';
|
|
2
|
-
import { memo } from 'react';
|
|
2
|
+
import { forwardRef, memo } from 'react';
|
|
3
3
|
import { RenderEmptyText, RenderSummary, TableResizable } from "../../../index";
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
const BaseTable = ({
|
|
5
|
+
const BaseTable = /*#__PURE__*/forwardRef(({
|
|
6
6
|
dataSource,
|
|
7
7
|
tableProps,
|
|
8
8
|
draggableProps,
|
|
9
9
|
summaryProps,
|
|
10
10
|
emptyTextProps,
|
|
11
11
|
...restProps
|
|
12
|
-
}) => {
|
|
12
|
+
}, ref) => {
|
|
13
13
|
const {
|
|
14
14
|
columns,
|
|
15
15
|
renderRowSelection,
|
|
@@ -23,6 +23,7 @@ const BaseTable = ({
|
|
|
23
23
|
return null;
|
|
24
24
|
};
|
|
25
25
|
return /*#__PURE__*/_jsx(Table, {
|
|
26
|
+
ref: ref,
|
|
26
27
|
components: renderComponents(),
|
|
27
28
|
columns: columns,
|
|
28
29
|
locale: {
|
|
@@ -35,5 +36,5 @@ const BaseTable = ({
|
|
|
35
36
|
rowSelection: renderRowSelection(),
|
|
36
37
|
...restProps
|
|
37
38
|
});
|
|
38
|
-
};
|
|
39
|
+
});
|
|
39
40
|
export default /*#__PURE__*/memo(BaseTable);
|
package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _isFunction from "lodash/isFunction";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import { arrayMove
|
|
5
|
-
import { CSS } from '@dnd-kit/utilities';
|
|
3
|
+
import { closestCorners } from '@dnd-kit/core';
|
|
4
|
+
import { arrayMove } from '@dnd-kit/sortable';
|
|
6
5
|
import dragSvg from "../../../../../../../assets/drag.svg";
|
|
7
6
|
import ProIcon from "../../../../../../../ProIcon";
|
|
8
7
|
import { addLevelAndParentId, treeNodeFind, transformTreeToArray, createTreeFromArray } from "./utils/index";
|
|
8
|
+
import { SortableTableContext, useDraggableRowState } from "../../../../../../../hooks/useDraggableRow";
|
|
9
9
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
10
|
export const Row = props => {
|
|
11
11
|
const {
|
|
@@ -13,34 +13,22 @@ export const Row = props => {
|
|
|
13
13
|
children,
|
|
14
14
|
...restProps
|
|
15
15
|
} = props;
|
|
16
|
-
const
|
|
16
|
+
const {
|
|
17
|
+
setNodeRef,
|
|
18
|
+
style,
|
|
19
|
+
listeners,
|
|
20
|
+
attributes
|
|
21
|
+
} = useDraggableRowState({
|
|
17
22
|
id: props['data-row-key'],
|
|
18
23
|
disabled
|
|
19
24
|
});
|
|
20
|
-
const {
|
|
21
|
-
attributes,
|
|
22
|
-
listeners,
|
|
23
|
-
setNodeRef,
|
|
24
|
-
transform,
|
|
25
|
-
transition,
|
|
26
|
-
isDragging
|
|
27
|
-
} = data;
|
|
28
|
-
const style = {
|
|
29
|
-
...props.style,
|
|
30
|
-
transform: CSS.Transform.toString(transform && {
|
|
31
|
-
...transform,
|
|
32
|
-
scaleY: 1
|
|
33
|
-
}),
|
|
34
|
-
transition,
|
|
35
|
-
...(isDragging ? {
|
|
36
|
-
position: 'relative',
|
|
37
|
-
zIndex: 2
|
|
38
|
-
} : {})
|
|
39
|
-
};
|
|
40
25
|
return /*#__PURE__*/_jsx("tr", {
|
|
41
26
|
...restProps,
|
|
42
27
|
ref: setNodeRef,
|
|
43
|
-
style:
|
|
28
|
+
style: {
|
|
29
|
+
...props.style,
|
|
30
|
+
...style
|
|
31
|
+
},
|
|
44
32
|
...attributes,
|
|
45
33
|
children: React.Children.map(children, (child, index) => {
|
|
46
34
|
// 在第一列(通常是rowSelection列)显示拖拽图标
|
|
@@ -150,15 +138,14 @@ const DndWrapper = ({
|
|
|
150
138
|
...item,
|
|
151
139
|
children: undefined
|
|
152
140
|
}));
|
|
153
|
-
return
|
|
141
|
+
return /*#__PURE__*/_jsx(SortableTableContext, {
|
|
142
|
+
draggable: draggable,
|
|
143
|
+
disabled: disabled,
|
|
144
|
+
items: flatTree?.[0]?.rowKey ? flatTree.map(i => i.rowKey) : [],
|
|
154
145
|
onDragStart: onDragStart,
|
|
155
146
|
onDragEnd: onDragEnd,
|
|
156
147
|
collisionDetection: closestCorners,
|
|
157
|
-
children:
|
|
158
|
-
|
|
159
|
-
strategy: verticalListSortingStrategy,
|
|
160
|
-
children: children
|
|
161
|
-
})
|
|
162
|
-
}) : children;
|
|
148
|
+
children: children
|
|
149
|
+
});
|
|
163
150
|
};
|
|
164
151
|
export default DndWrapper;
|
|
@@ -1,10 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare const _default: import("react").
|
|
3
|
-
[x: string]: any;
|
|
4
|
-
dataSource: any;
|
|
5
|
-
tableProps: any;
|
|
6
|
-
draggableProps: any;
|
|
7
|
-
summaryProps: any;
|
|
8
|
-
emptyTextProps: any;
|
|
9
|
-
}) => import("react/jsx-runtime").JSX.Element>;
|
|
2
|
+
declare const _default: import("react").NamedExoticComponent<Omit<any, "ref"> & import("react").RefAttributes<any>>;
|
|
10
3
|
export default _default;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Table } from 'antd';
|
|
2
|
-
import { memo } from 'react';
|
|
2
|
+
import { forwardRef, memo } from 'react';
|
|
3
3
|
import DndWrapper, { Row } from "./components/DndWrapper";
|
|
4
4
|
import { RenderEmptyText, RenderSummary } from "../../../index";
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
const DraggableTable = ({
|
|
6
|
+
const DraggableTable = /*#__PURE__*/forwardRef(({
|
|
7
7
|
dataSource,
|
|
8
8
|
tableProps,
|
|
9
9
|
draggableProps,
|
|
10
10
|
summaryProps,
|
|
11
11
|
emptyTextProps,
|
|
12
12
|
...restProps
|
|
13
|
-
}) => {
|
|
13
|
+
}, ref) => {
|
|
14
14
|
const {
|
|
15
15
|
columns,
|
|
16
16
|
renderRowSelection,
|
|
@@ -33,6 +33,7 @@ const DraggableTable = ({
|
|
|
33
33
|
onDragStartGuard: onDragStartGuard,
|
|
34
34
|
onDragEndGuard: onDragEndGuard,
|
|
35
35
|
children: /*#__PURE__*/_jsx(Table, {
|
|
36
|
+
ref: ref,
|
|
36
37
|
className: "pro-edit-table-drag",
|
|
37
38
|
components: {
|
|
38
39
|
body: {
|
|
@@ -51,5 +52,5 @@ const DraggableTable = ({
|
|
|
51
52
|
...restProps
|
|
52
53
|
})
|
|
53
54
|
});
|
|
54
|
-
};
|
|
55
|
+
});
|
|
55
56
|
export default /*#__PURE__*/memo(DraggableTable);
|
|
@@ -5,7 +5,6 @@ import { useSetState } from 'ahooks';
|
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import { CheckOutlined } from '@ant-design/icons';
|
|
7
7
|
import { ReactSVG } from 'react-svg';
|
|
8
|
-
import { parseWidth } from "../../utils";
|
|
9
8
|
import { isEmpty, isEllipsisActive } from "../../../utils";
|
|
10
9
|
import copySvg from "../../../assets/copy.svg";
|
|
11
10
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -35,20 +34,6 @@ const RenderColumn = props => {
|
|
|
35
34
|
}, setState] = useSetState({
|
|
36
35
|
tooltip: false
|
|
37
36
|
});
|
|
38
|
-
|
|
39
|
-
// 计算并更新宽度
|
|
40
|
-
const updateCalculatedWidth = element => {
|
|
41
|
-
if (!element) return null;
|
|
42
|
-
if (!textRef.current) return;
|
|
43
|
-
// 使用closest方法查找最近的tr
|
|
44
|
-
const tr = element.closest('tr');
|
|
45
|
-
if (!tr) return;
|
|
46
|
-
// 获取tr的宽度
|
|
47
|
-
const trWidth = tr.getBoundingClientRect().width;
|
|
48
|
-
// 计算实际宽度
|
|
49
|
-
const newWidth = parseWidth(width, trWidth);
|
|
50
|
-
return newWidth;
|
|
51
|
-
};
|
|
52
37
|
const cellDiffCls = classNames({
|
|
53
38
|
'varied-cell': props?.isChanged,
|
|
54
39
|
'add-cell': props?.isAddCell
|
|
@@ -228,7 +213,6 @@ const RenderColumn = props => {
|
|
|
228
213
|
children: "-"
|
|
229
214
|
});
|
|
230
215
|
}
|
|
231
|
-
const calculatedWidth = updateCalculatedWidth(textRef.current);
|
|
232
216
|
return /*#__PURE__*/_jsx(Tooltip, {
|
|
233
217
|
title: value,
|
|
234
218
|
destroyOnHidden: true,
|
|
@@ -243,7 +227,7 @@ const RenderColumn = props => {
|
|
|
243
227
|
children: /*#__PURE__*/_jsx(Text, {
|
|
244
228
|
ref: textRef,
|
|
245
229
|
style: {
|
|
246
|
-
width
|
|
230
|
+
width,
|
|
247
231
|
minWidth
|
|
248
232
|
},
|
|
249
233
|
ellipsis: true,
|
package/es/ProTable/index.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import type { ProTableType } from './propsType';
|
|
3
|
-
import useAntdTable from './hooks/useAntdTable';
|
|
4
|
-
export declare const TableContext:
|
|
3
|
+
import useAntdTable, { SELECTION_ALL, CURRENT_PAGE, UNCHECK_ALL } from './hooks/useAntdTable';
|
|
4
|
+
export declare const TableContext: React.Context<{}>;
|
|
5
5
|
export declare const defaultPage: {
|
|
6
6
|
pageNum: number;
|
|
7
7
|
pageSize: number;
|
|
8
8
|
};
|
|
9
|
-
declare const ProTable: {
|
|
10
|
-
(props: ProTableType): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare const ProTable: React.ForwardRefExoticComponent<ProTableType<any> & React.RefAttributes<any>> & {
|
|
11
10
|
useAntdTable: typeof useAntdTable;
|
|
12
|
-
SELECTION_ALL:
|
|
13
|
-
CURRENT_PAGE:
|
|
14
|
-
UNCHECK_ALL:
|
|
11
|
+
SELECTION_ALL: typeof SELECTION_ALL;
|
|
12
|
+
CURRENT_PAGE: typeof CURRENT_PAGE;
|
|
13
|
+
UNCHECK_ALL: typeof UNCHECK_ALL;
|
|
15
14
|
};
|
|
15
|
+
export { getColumnCache, setColumnCache, removeColumnCache } from './utils/columnStorage';
|
|
16
|
+
export type { StorageType, ColumnCacheEntry } from './utils/columnStorage';
|
|
16
17
|
export default ProTable;
|