@zat-design/sisyphus-react 3.6.6-beta.1 → 3.6.6-beta.3
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/es/ProEditTable/components/RcTable/BaseTable.d.ts +6 -0
- package/es/ProEditTable/components/RcTable/BaseTable.js +75 -0
- package/es/ProEditTable/components/RcTable/DraggableTable.d.ts +7 -0
- package/es/ProEditTable/components/RcTable/DraggableTable.js +90 -0
- package/es/ProEditTable/components/RcTable/VirtualTable.d.ts +6 -0
- package/es/ProEditTable/components/RcTable/VirtualTable.js +166 -0
- package/es/ProEditTable/components/RcTable/index.d.ts +6 -0
- package/es/ProEditTable/components/RcTable/index.js +6 -0
- package/es/ProEditTable/index.js +32 -55
- package/es/ProEditTable/propsType.d.ts +5 -0
- package/es/ProEditTable/utils/index.js +1 -1
- package/lib/ProEditTable/components/RcTable/BaseTable.d.ts +6 -0
- package/lib/ProEditTable/components/RcTable/BaseTable.js +81 -0
- package/lib/ProEditTable/components/RcTable/DraggableTable.d.ts +7 -0
- package/lib/ProEditTable/components/RcTable/DraggableTable.js +96 -0
- package/lib/ProEditTable/components/RcTable/VirtualTable.d.ts +6 -0
- package/lib/ProEditTable/components/RcTable/VirtualTable.js +172 -0
- package/lib/ProEditTable/components/RcTable/index.d.ts +6 -0
- package/lib/ProEditTable/components/RcTable/index.js +27 -0
- package/lib/ProEditTable/index.js +31 -52
- package/lib/ProEditTable/propsType.d.ts +5 -0
- package/lib/ProEditTable/utils/index.js +1 -1
- package/package.json +5 -3
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import "antd/es/table/style";
|
|
3
|
+
import _Table from "antd/es/table";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
+
var _excluded = ["tableProps"];
|
|
6
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { memo } from 'react';
|
|
8
|
+
var BaseTable = function BaseTable(_ref) {
|
|
9
|
+
var _value$;
|
|
10
|
+
var tableProps = _ref.tableProps,
|
|
11
|
+
resetProps = _objectWithoutProperties(_ref, _excluded);
|
|
12
|
+
var value = tableProps.value,
|
|
13
|
+
headerRender = tableProps.headerRender,
|
|
14
|
+
tableRef = tableProps.tableRef,
|
|
15
|
+
className = tableProps.className,
|
|
16
|
+
columns = tableProps.columns,
|
|
17
|
+
renderRowSelection = tableProps.renderRowSelection,
|
|
18
|
+
rowClassName = tableProps.rowClassName,
|
|
19
|
+
disabled = tableProps.disabled,
|
|
20
|
+
virtualKey = tableProps.virtualKey,
|
|
21
|
+
editingKeys = tableProps.editingKeys,
|
|
22
|
+
isHideCheckBox = tableProps.isHideCheckBox,
|
|
23
|
+
rowDraggable = tableProps.rowDraggable,
|
|
24
|
+
pagination = tableProps.pagination,
|
|
25
|
+
scroll = tableProps.scroll,
|
|
26
|
+
summary = tableProps.summary,
|
|
27
|
+
page = tableProps.page,
|
|
28
|
+
formatMessage = tableProps.formatMessage,
|
|
29
|
+
locale = tableProps.locale,
|
|
30
|
+
handlePageChange = tableProps.handlePageChange;
|
|
31
|
+
return _jsxs(_Fragment, {
|
|
32
|
+
children: [headerRender ? _jsx("div", {
|
|
33
|
+
className: "pro-edit-table-header",
|
|
34
|
+
children: typeof headerRender === 'function' ? headerRender() : headerRender
|
|
35
|
+
}) : null, _jsx(_Table, _objectSpread(_objectSpread({
|
|
36
|
+
ref: tableRef,
|
|
37
|
+
className: className,
|
|
38
|
+
dataSource: (value === null || value === void 0 ? void 0 : (_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.rowKey) ? value : undefined,
|
|
39
|
+
columns: columns,
|
|
40
|
+
rowSelection: renderRowSelection(),
|
|
41
|
+
rowClassName: rowClassName,
|
|
42
|
+
onRow: function onRow() {
|
|
43
|
+
return {
|
|
44
|
+
disabled: disabled || virtualKey && !!editingKeys.length,
|
|
45
|
+
'data-hide': isHideCheckBox,
|
|
46
|
+
onClick: function onClick() {},
|
|
47
|
+
rowDraggable: rowDraggable
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}, resetProps), {}, {
|
|
51
|
+
pagination: pagination ? _objectSpread({
|
|
52
|
+
current: page.pageNum,
|
|
53
|
+
pageSize: page.pageSize,
|
|
54
|
+
showSizeChanger: false,
|
|
55
|
+
showQuickJumper: true,
|
|
56
|
+
total: value === null || value === void 0 ? void 0 : value.length,
|
|
57
|
+
showTotal: function showTotal(total) {
|
|
58
|
+
var _locale$ProEditTable;
|
|
59
|
+
if (!total) return;
|
|
60
|
+
return formatMessage(locale === null || locale === void 0 ? void 0 : (_locale$ProEditTable = locale.ProEditTable) === null || _locale$ProEditTable === void 0 ? void 0 : _locale$ProEditTable.total, {
|
|
61
|
+
total: total
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
onChange: handlePageChange
|
|
65
|
+
}, pagination) : false,
|
|
66
|
+
rowKey: "rowKey",
|
|
67
|
+
scroll: {
|
|
68
|
+
x: scroll === null || scroll === void 0 ? void 0 : scroll.x,
|
|
69
|
+
y: (value === null || value === void 0 ? void 0 : value.length) ? scroll === null || scroll === void 0 ? void 0 : scroll.y : undefined
|
|
70
|
+
},
|
|
71
|
+
summary: summary
|
|
72
|
+
}))]
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
export default /*#__PURE__*/memo(BaseTable);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import "antd/es/table/style";
|
|
3
|
+
import _Table from "antd/es/table";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
+
var _excluded = ["tableProps", "draggableProps"];
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { memo } from 'react';
|
|
8
|
+
import { DndWrapper, Row } from '../index';
|
|
9
|
+
var DraggableTable = function DraggableTable(_ref) {
|
|
10
|
+
var _value$;
|
|
11
|
+
var tableProps = _ref.tableProps,
|
|
12
|
+
draggableProps = _ref.draggableProps,
|
|
13
|
+
resetProps = _objectWithoutProperties(_ref, _excluded);
|
|
14
|
+
var value = tableProps.value,
|
|
15
|
+
headerRender = tableProps.headerRender,
|
|
16
|
+
tableRef = tableProps.tableRef,
|
|
17
|
+
className = tableProps.className,
|
|
18
|
+
columns = tableProps.columns,
|
|
19
|
+
renderRowSelection = tableProps.renderRowSelection,
|
|
20
|
+
rowClassName = tableProps.rowClassName,
|
|
21
|
+
disabled = tableProps.disabled,
|
|
22
|
+
virtualKey = tableProps.virtualKey,
|
|
23
|
+
editingKeys = tableProps.editingKeys,
|
|
24
|
+
isHideCheckBox = tableProps.isHideCheckBox,
|
|
25
|
+
rowDraggable = tableProps.rowDraggable,
|
|
26
|
+
pagination = tableProps.pagination,
|
|
27
|
+
scroll = tableProps.scroll,
|
|
28
|
+
summary = tableProps.summary,
|
|
29
|
+
page = tableProps.page,
|
|
30
|
+
formatMessage = tableProps.formatMessage,
|
|
31
|
+
locale = tableProps.locale,
|
|
32
|
+
handlePageChange = tableProps.handlePageChange;
|
|
33
|
+
var onChange = draggableProps.onChange,
|
|
34
|
+
onDrag = draggableProps.onDrag,
|
|
35
|
+
draggable = draggableProps.draggable;
|
|
36
|
+
return _jsxs(DndWrapper, {
|
|
37
|
+
value: value,
|
|
38
|
+
onChange: onChange,
|
|
39
|
+
onDrag: onDrag,
|
|
40
|
+
disabled: disabled,
|
|
41
|
+
draggable: draggable,
|
|
42
|
+
children: [headerRender ? _jsx("div", {
|
|
43
|
+
className: "pro-edit-table-header",
|
|
44
|
+
children: typeof headerRender === 'function' ? headerRender() : headerRender
|
|
45
|
+
}) : null, _jsx(_Table, _objectSpread(_objectSpread({
|
|
46
|
+
ref: tableRef,
|
|
47
|
+
className: className,
|
|
48
|
+
dataSource: (value === null || value === void 0 ? void 0 : (_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.rowKey) ? value : undefined,
|
|
49
|
+
columns: columns,
|
|
50
|
+
rowSelection: renderRowSelection(),
|
|
51
|
+
rowClassName: rowClassName,
|
|
52
|
+
components: {
|
|
53
|
+
body: {
|
|
54
|
+
row: Row
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
onRow: function onRow() {
|
|
58
|
+
return {
|
|
59
|
+
disabled: disabled || virtualKey && !!editingKeys.length,
|
|
60
|
+
'data-hide': isHideCheckBox,
|
|
61
|
+
onClick: function onClick() {},
|
|
62
|
+
rowDraggable: rowDraggable
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}, resetProps), {}, {
|
|
66
|
+
pagination: pagination ? _objectSpread({
|
|
67
|
+
current: page.pageNum,
|
|
68
|
+
pageSize: page.pageSize,
|
|
69
|
+
showSizeChanger: false,
|
|
70
|
+
showQuickJumper: true,
|
|
71
|
+
total: value === null || value === void 0 ? void 0 : value.length,
|
|
72
|
+
showTotal: function showTotal(total) {
|
|
73
|
+
var _locale$ProEditTable;
|
|
74
|
+
if (!total) return;
|
|
75
|
+
return formatMessage(locale === null || locale === void 0 ? void 0 : (_locale$ProEditTable = locale.ProEditTable) === null || _locale$ProEditTable === void 0 ? void 0 : _locale$ProEditTable.total, {
|
|
76
|
+
total: total
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
onChange: handlePageChange
|
|
80
|
+
}, pagination) : false,
|
|
81
|
+
rowKey: "rowKey",
|
|
82
|
+
scroll: {
|
|
83
|
+
x: scroll === null || scroll === void 0 ? void 0 : scroll.x,
|
|
84
|
+
y: (value === null || value === void 0 ? void 0 : value.length) ? scroll === null || scroll === void 0 ? void 0 : scroll.y : undefined
|
|
85
|
+
},
|
|
86
|
+
summary: summary
|
|
87
|
+
}))]
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
export default /*#__PURE__*/memo(DraggableTable);
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import "antd/es/table/style";
|
|
2
|
+
import _Table from "antd/es/table";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
6
|
+
var _excluded = ["tableProps"];
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { useEffect, useRef, useState, memo } from 'react';
|
|
9
|
+
import classNames from 'classnames';
|
|
10
|
+
import ResizeObserver from 'rc-resize-observer';
|
|
11
|
+
import { VariableSizeGrid } from 'react-window';
|
|
12
|
+
var VirtualTable = function VirtualTable(_ref) {
|
|
13
|
+
var _value$;
|
|
14
|
+
var tableProps = _ref.tableProps,
|
|
15
|
+
resetProps = _objectWithoutProperties(_ref, _excluded);
|
|
16
|
+
var value = tableProps.value,
|
|
17
|
+
headerRender = tableProps.headerRender,
|
|
18
|
+
tableRef = tableProps.tableRef,
|
|
19
|
+
className = tableProps.className,
|
|
20
|
+
columns = tableProps.columns,
|
|
21
|
+
renderRowSelection = tableProps.renderRowSelection,
|
|
22
|
+
rowClassName = tableProps.rowClassName,
|
|
23
|
+
disabled = tableProps.disabled,
|
|
24
|
+
virtualKey = tableProps.virtualKey,
|
|
25
|
+
editingKeys = tableProps.editingKeys,
|
|
26
|
+
isHideCheckBox = tableProps.isHideCheckBox,
|
|
27
|
+
rowDraggable = tableProps.rowDraggable,
|
|
28
|
+
scroll = tableProps.scroll,
|
|
29
|
+
summary = tableProps.summary;
|
|
30
|
+
var _useState = useState(0),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
tableWidth = _useState2[0],
|
|
33
|
+
setTableWidth = _useState2[1];
|
|
34
|
+
var widthColumnCount = columns.filter(function (_ref2) {
|
|
35
|
+
var width = _ref2.width;
|
|
36
|
+
return !width;
|
|
37
|
+
}).length;
|
|
38
|
+
var mergedColumns = columns.map(function (column) {
|
|
39
|
+
if (column.width) {
|
|
40
|
+
return column;
|
|
41
|
+
}
|
|
42
|
+
return _objectSpread(_objectSpread({}, column), {}, {
|
|
43
|
+
width: Math.floor(tableWidth / widthColumnCount)
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
var gridRef = useRef();
|
|
47
|
+
var _useState3 = useState(function () {
|
|
48
|
+
var obj = {};
|
|
49
|
+
Object.defineProperty(obj, 'scrollLeft', {
|
|
50
|
+
get: function get() {
|
|
51
|
+
if (gridRef.current) {
|
|
52
|
+
var _gridRef$current, _gridRef$current$stat;
|
|
53
|
+
return (_gridRef$current = gridRef.current) === null || _gridRef$current === void 0 ? void 0 : (_gridRef$current$stat = _gridRef$current.state) === null || _gridRef$current$stat === void 0 ? void 0 : _gridRef$current$stat.scrollLeft;
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
},
|
|
57
|
+
set: function set(scrollLeft) {
|
|
58
|
+
if (gridRef.current) {
|
|
59
|
+
gridRef.current.scrollTo({
|
|
60
|
+
scrollLeft: scrollLeft
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return obj;
|
|
66
|
+
}),
|
|
67
|
+
_useState4 = _slicedToArray(_useState3, 1),
|
|
68
|
+
connectObject = _useState4[0];
|
|
69
|
+
var resetVirtualGrid = function resetVirtualGrid() {
|
|
70
|
+
var _gridRef$current2;
|
|
71
|
+
(_gridRef$current2 = gridRef.current) === null || _gridRef$current2 === void 0 ? void 0 : _gridRef$current2.resetAfterIndices({
|
|
72
|
+
columnIndex: 0,
|
|
73
|
+
shouldForceUpdate: true
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
useEffect(function () {
|
|
77
|
+
return resetVirtualGrid;
|
|
78
|
+
}, [tableWidth]);
|
|
79
|
+
var renderVirtualList = function renderVirtualList(rawData, _ref3) {
|
|
80
|
+
var scrollbarSize = _ref3.scrollbarSize,
|
|
81
|
+
ref = _ref3.ref,
|
|
82
|
+
_onScroll = _ref3.onScroll;
|
|
83
|
+
ref.current = connectObject;
|
|
84
|
+
var totalHeight = rawData.length * 54;
|
|
85
|
+
return _jsx(VariableSizeGrid, {
|
|
86
|
+
ref: gridRef,
|
|
87
|
+
className: "virtual-grid",
|
|
88
|
+
columnCount: mergedColumns.length,
|
|
89
|
+
columnWidth: function columnWidth(index) {
|
|
90
|
+
var _width2;
|
|
91
|
+
var width = mergedColumns[index].width;
|
|
92
|
+
var _width = width;
|
|
93
|
+
if (typeof _width === 'string' && ((_width2 = _width) === null || _width2 === void 0 ? void 0 : _width2.includes('px'))) {
|
|
94
|
+
_width = parseInt(width, 10);
|
|
95
|
+
}
|
|
96
|
+
return totalHeight > scroll.y && index === mergedColumns.length - 1 ? _width - scrollbarSize - 1 : _width;
|
|
97
|
+
},
|
|
98
|
+
height: scroll.y,
|
|
99
|
+
rowCount: rawData.length,
|
|
100
|
+
rowHeight: function rowHeight() {
|
|
101
|
+
return 54;
|
|
102
|
+
},
|
|
103
|
+
width: tableWidth,
|
|
104
|
+
onScroll: function onScroll(_ref4) {
|
|
105
|
+
var scrollLeft = _ref4.scrollLeft;
|
|
106
|
+
_onScroll({
|
|
107
|
+
scrollLeft: scrollLeft
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
children: function children(_ref5) {
|
|
111
|
+
var columnIndex = _ref5.columnIndex,
|
|
112
|
+
rowIndex = _ref5.rowIndex,
|
|
113
|
+
style = _ref5.style;
|
|
114
|
+
return _jsx("div", {
|
|
115
|
+
className: classNames('virtual-table-cell', {
|
|
116
|
+
'virtual-table-cell-last': columnIndex === mergedColumns.length - 1
|
|
117
|
+
}),
|
|
118
|
+
style: style,
|
|
119
|
+
children: rawData[rowIndex][mergedColumns[columnIndex].dataIndex]
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
return _jsxs(ResizeObserver, {
|
|
125
|
+
onResize: function onResize(_ref6) {
|
|
126
|
+
var _width3;
|
|
127
|
+
var width = _ref6.width;
|
|
128
|
+
var _width = width;
|
|
129
|
+
if (typeof _width === 'string' && ((_width3 = _width) === null || _width3 === void 0 ? void 0 : _width3.includes('px'))) {
|
|
130
|
+
_width = parseInt(width, 10);
|
|
131
|
+
}
|
|
132
|
+
setTableWidth(_width);
|
|
133
|
+
},
|
|
134
|
+
children: [headerRender ? _jsx("div", {
|
|
135
|
+
className: "pro-edit-table-header",
|
|
136
|
+
children: typeof headerRender === 'function' ? headerRender() : headerRender
|
|
137
|
+
}) : null, _jsx(_Table, _objectSpread(_objectSpread({
|
|
138
|
+
ref: tableRef,
|
|
139
|
+
className: className,
|
|
140
|
+
dataSource: (value === null || value === void 0 ? void 0 : (_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.rowKey) ? value : undefined,
|
|
141
|
+
columns: mergedColumns,
|
|
142
|
+
rowSelection: renderRowSelection(),
|
|
143
|
+
rowClassName: rowClassName,
|
|
144
|
+
components: {
|
|
145
|
+
body: renderVirtualList
|
|
146
|
+
},
|
|
147
|
+
onRow: function onRow() {
|
|
148
|
+
return {
|
|
149
|
+
disabled: disabled || virtualKey && !!editingKeys.length,
|
|
150
|
+
'data-hide': isHideCheckBox,
|
|
151
|
+
onClick: function onClick() {},
|
|
152
|
+
rowDraggable: rowDraggable
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}, resetProps), {}, {
|
|
156
|
+
pagination: false,
|
|
157
|
+
rowKey: "rowKey",
|
|
158
|
+
scroll: {
|
|
159
|
+
x: scroll === null || scroll === void 0 ? void 0 : scroll.x,
|
|
160
|
+
y: (value === null || value === void 0 ? void 0 : value.length) ? scroll === null || scroll === void 0 ? void 0 : scroll.y : undefined
|
|
161
|
+
},
|
|
162
|
+
summary: summary
|
|
163
|
+
}))]
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
export default /*#__PURE__*/memo(VirtualTable);
|
package/es/ProEditTable/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import "antd/es/affix/style";
|
|
2
2
|
import _Affix from "antd/es/affix";
|
|
3
|
-
import "antd/es/table/style";
|
|
4
|
-
import _Table from "antd/es/table";
|
|
5
3
|
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
6
4
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
7
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
@@ -11,7 +9,7 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
11
9
|
import "antd/es/form/style";
|
|
12
10
|
import _Form from "antd/es/form";
|
|
13
11
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
14
|
-
var _excluded = ["value", "onChange", "onDrag", "className", "columns", "type", "mode", "stripe", "draggable", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "toolbarSticky", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "requiredAlign", "summary", "max", "headerRender", "pagination", "originalValues", "originalDiffTip", "rowKey", "rowDisabled", "rowDraggable", "footerRender", "scroll", "actionDirection"];
|
|
12
|
+
var _excluded = ["value", "onChange", "onDrag", "className", "columns", "type", "mode", "stripe", "draggable", "virtual", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "toolbarSticky", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "requiredAlign", "summary", "max", "headerRender", "pagination", "originalValues", "originalDiffTip", "rowKey", "rowDisabled", "rowDraggable", "footerRender", "scroll", "actionDirection"];
|
|
15
13
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
14
|
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
|
|
17
15
|
import { get, isArray, isBoolean } from 'lodash';
|
|
@@ -19,12 +17,13 @@ import { useDeepCompareEffect, useLocalStorageState, useSetState } from 'ahooks'
|
|
|
19
17
|
import classnames from 'classnames';
|
|
20
18
|
import { transformColumns } from './utils';
|
|
21
19
|
import { getRandom, getNamePath } from './utils/tools';
|
|
22
|
-
import {
|
|
20
|
+
import { Validator, Summary, RenderToolbar } from './components';
|
|
23
21
|
import ProForm from '../ProForm';
|
|
24
22
|
import Empty from '../assets/empty.png';
|
|
25
23
|
import locale, { formatMessage } from '../locale';
|
|
24
|
+
import { BaseTable, DraggableTable, VirtualTable } from './components/RcTable';
|
|
26
25
|
var ProEditTable = function ProEditTable(_ref, ref) {
|
|
27
|
-
var _resetProps$id, _resetProps$id$split, _themeConfig$data2
|
|
26
|
+
var _resetProps$id, _resetProps$id$split, _themeConfig$data2;
|
|
28
27
|
var value = _ref.value,
|
|
29
28
|
onChange = _ref.onChange,
|
|
30
29
|
onDrag = _ref.onDrag,
|
|
@@ -34,6 +33,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
|
34
33
|
mode = _ref.mode,
|
|
35
34
|
stripe = _ref.stripe,
|
|
36
35
|
draggable = _ref.draggable,
|
|
36
|
+
virtual = _ref.virtual,
|
|
37
37
|
disabled = _ref.disabled,
|
|
38
38
|
insertType = _ref.insertType,
|
|
39
39
|
emptyBtnText = _ref.emptyBtnText,
|
|
@@ -326,62 +326,38 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
|
326
326
|
rowSelection: renderRowSelection()
|
|
327
327
|
});
|
|
328
328
|
} : summary;
|
|
329
|
+
var TableComponent = draggable ? DraggableTable : virtual ? VirtualTable : BaseTable;
|
|
329
330
|
return _jsxs(_Fragment, {
|
|
330
331
|
children: [_jsxs(_ConfigProvider, {
|
|
331
332
|
renderEmpty: (value === null || value === void 0 ? void 0 : value.length) ? undefined : empty,
|
|
332
|
-
children: [
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
ref: tableRef,
|
|
333
|
+
children: [_jsx(TableComponent, _objectSpread(_objectSpread({}, resetProps), {}, {
|
|
334
|
+
draggableProps: {
|
|
335
|
+
onChange: onChange,
|
|
336
|
+
onDrag: onDrag,
|
|
337
|
+
draggable: draggable
|
|
338
|
+
},
|
|
339
|
+
tableProps: {
|
|
340
|
+
value: value,
|
|
341
|
+
headerRender: headerRender,
|
|
342
|
+
tableRef: tableRef,
|
|
343
343
|
className: _className,
|
|
344
|
-
dataSource: (value === null || value === void 0 ? void 0 : (_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.rowKey) ? value : undefined,
|
|
345
344
|
columns: _columns,
|
|
346
|
-
|
|
345
|
+
renderRowSelection: renderRowSelection,
|
|
347
346
|
rowClassName: _rowClassName,
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
pagination: pagination ? _objectSpread({
|
|
363
|
-
current: page.pageNum,
|
|
364
|
-
pageSize: page.pageSize,
|
|
365
|
-
showSizeChanger: false,
|
|
366
|
-
showQuickJumper: true,
|
|
367
|
-
total: value === null || value === void 0 ? void 0 : value.length,
|
|
368
|
-
showTotal: function showTotal(total) {
|
|
369
|
-
var _locale$ProEditTable;
|
|
370
|
-
if (!total) return;
|
|
371
|
-
return formatMessage(locale === null || locale === void 0 ? void 0 : (_locale$ProEditTable = locale.ProEditTable) === null || _locale$ProEditTable === void 0 ? void 0 : _locale$ProEditTable.total, {
|
|
372
|
-
total: total
|
|
373
|
-
});
|
|
374
|
-
},
|
|
375
|
-
onChange: handlePageChange
|
|
376
|
-
}, pagination) : false,
|
|
377
|
-
rowKey: "rowKey",
|
|
378
|
-
scroll: {
|
|
379
|
-
x: scroll === null || scroll === void 0 ? void 0 : scroll.x,
|
|
380
|
-
y: (value === null || value === void 0 ? void 0 : value.length) ? scroll === null || scroll === void 0 ? void 0 : scroll.y : undefined
|
|
381
|
-
},
|
|
382
|
-
summary: _summary
|
|
383
|
-
}))]
|
|
384
|
-
}), !isView && (value === null || value === void 0 ? void 0 : value.length) ? toolbarSticky ? _jsx(_Affix, _objectSpread(_objectSpread({
|
|
347
|
+
disabled: disabled,
|
|
348
|
+
virtualKey: virtualKey,
|
|
349
|
+
editingKeys: editingKeys,
|
|
350
|
+
isHideCheckBox: isHideCheckBox,
|
|
351
|
+
rowDraggable: rowDraggable,
|
|
352
|
+
pagination: pagination,
|
|
353
|
+
scroll: scroll,
|
|
354
|
+
summary: _summary,
|
|
355
|
+
page: page,
|
|
356
|
+
formatMessage: formatMessage,
|
|
357
|
+
locale: locale,
|
|
358
|
+
handlePageChange: handlePageChange
|
|
359
|
+
}
|
|
360
|
+
})), !isView && (value === null || value === void 0 ? void 0 : value.length) ? toolbarSticky ? _jsx(_Affix, _objectSpread(_objectSpread({
|
|
385
361
|
ref: affixRef
|
|
386
362
|
}, _toolbarSticky), {}, {
|
|
387
363
|
children: _jsx("div", {
|
|
@@ -414,6 +390,7 @@ ForwardProEditTable.defaultProps = {
|
|
|
414
390
|
toolbarProps: [],
|
|
415
391
|
disabled: false,
|
|
416
392
|
draggable: false,
|
|
393
|
+
virtual: false,
|
|
417
394
|
stripe: true,
|
|
418
395
|
emptyBtnText: locale.ProEditTable.clickAdd,
|
|
419
396
|
onlyOneLineMsg: locale.ProEditTable.onlyOneLineMsg,
|
|
@@ -192,6 +192,11 @@ export interface ProEditTableProps<T = any> extends Omit<TableProps<T>, 'onChang
|
|
|
192
192
|
* @default -
|
|
193
193
|
*/
|
|
194
194
|
draggable?: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* @description 是否开启虚拟列表(scroll,x,y必须为固定值)
|
|
197
|
+
* @default -
|
|
198
|
+
*/
|
|
199
|
+
virtual?: boolean;
|
|
195
200
|
/**
|
|
196
201
|
* @description 空列表状态时,自定义添加按钮
|
|
197
202
|
* @default 点击添加
|
|
@@ -121,7 +121,7 @@ var getActionColumn = function getActionColumn(config) {
|
|
|
121
121
|
case 20:
|
|
122
122
|
result = _context.sent;
|
|
123
123
|
case 21:
|
|
124
|
-
if (result && type !== 'custom') {
|
|
124
|
+
if (result !== false && type !== 'custom') {
|
|
125
125
|
actions[type](_objectSpread(_objectSpread({}, config), {}, {
|
|
126
126
|
rowName: [].concat(_toConsumableArray(name), [index]),
|
|
127
127
|
virtualRowName: rowName,
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
var _antd = require("antd");
|
|
12
|
+
var _react = require("react");
|
|
13
|
+
var _excluded = ["tableProps"];
|
|
14
|
+
var BaseTable = function BaseTable(_ref) {
|
|
15
|
+
var _value$;
|
|
16
|
+
var tableProps = _ref.tableProps,
|
|
17
|
+
resetProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
18
|
+
var value = tableProps.value,
|
|
19
|
+
headerRender = tableProps.headerRender,
|
|
20
|
+
tableRef = tableProps.tableRef,
|
|
21
|
+
className = tableProps.className,
|
|
22
|
+
columns = tableProps.columns,
|
|
23
|
+
renderRowSelection = tableProps.renderRowSelection,
|
|
24
|
+
rowClassName = tableProps.rowClassName,
|
|
25
|
+
disabled = tableProps.disabled,
|
|
26
|
+
virtualKey = tableProps.virtualKey,
|
|
27
|
+
editingKeys = tableProps.editingKeys,
|
|
28
|
+
isHideCheckBox = tableProps.isHideCheckBox,
|
|
29
|
+
rowDraggable = tableProps.rowDraggable,
|
|
30
|
+
pagination = tableProps.pagination,
|
|
31
|
+
scroll = tableProps.scroll,
|
|
32
|
+
summary = tableProps.summary,
|
|
33
|
+
page = tableProps.page,
|
|
34
|
+
formatMessage = tableProps.formatMessage,
|
|
35
|
+
locale = tableProps.locale,
|
|
36
|
+
handlePageChange = tableProps.handlePageChange;
|
|
37
|
+
return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
38
|
+
children: [headerRender ? (0, _jsxRuntime.jsx)("div", {
|
|
39
|
+
className: "pro-edit-table-header",
|
|
40
|
+
children: typeof headerRender === 'function' ? headerRender() : headerRender
|
|
41
|
+
}) : null, (0, _jsxRuntime.jsx)(_antd.Table, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
42
|
+
ref: tableRef,
|
|
43
|
+
className: className,
|
|
44
|
+
dataSource: (value === null || value === void 0 ? void 0 : (_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.rowKey) ? value : undefined,
|
|
45
|
+
columns: columns,
|
|
46
|
+
rowSelection: renderRowSelection(),
|
|
47
|
+
rowClassName: rowClassName,
|
|
48
|
+
onRow: function onRow() {
|
|
49
|
+
return {
|
|
50
|
+
disabled: disabled || virtualKey && !!editingKeys.length,
|
|
51
|
+
'data-hide': isHideCheckBox,
|
|
52
|
+
onClick: function onClick() {},
|
|
53
|
+
rowDraggable: rowDraggable
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}, resetProps), {}, {
|
|
57
|
+
pagination: pagination ? (0, _objectSpread2.default)({
|
|
58
|
+
current: page.pageNum,
|
|
59
|
+
pageSize: page.pageSize,
|
|
60
|
+
showSizeChanger: false,
|
|
61
|
+
showQuickJumper: true,
|
|
62
|
+
total: value === null || value === void 0 ? void 0 : value.length,
|
|
63
|
+
showTotal: function showTotal(total) {
|
|
64
|
+
var _locale$ProEditTable;
|
|
65
|
+
if (!total) return;
|
|
66
|
+
return formatMessage(locale === null || locale === void 0 ? void 0 : (_locale$ProEditTable = locale.ProEditTable) === null || _locale$ProEditTable === void 0 ? void 0 : _locale$ProEditTable.total, {
|
|
67
|
+
total: total
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
onChange: handlePageChange
|
|
71
|
+
}, pagination) : false,
|
|
72
|
+
rowKey: "rowKey",
|
|
73
|
+
scroll: {
|
|
74
|
+
x: scroll === null || scroll === void 0 ? void 0 : scroll.x,
|
|
75
|
+
y: (value === null || value === void 0 ? void 0 : value.length) ? scroll === null || scroll === void 0 ? void 0 : scroll.y : undefined
|
|
76
|
+
},
|
|
77
|
+
summary: summary
|
|
78
|
+
}))]
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(BaseTable);
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
var _antd = require("antd");
|
|
12
|
+
var _react = require("react");
|
|
13
|
+
var _index = require("../index");
|
|
14
|
+
var _excluded = ["tableProps", "draggableProps"];
|
|
15
|
+
var DraggableTable = function DraggableTable(_ref) {
|
|
16
|
+
var _value$;
|
|
17
|
+
var tableProps = _ref.tableProps,
|
|
18
|
+
draggableProps = _ref.draggableProps,
|
|
19
|
+
resetProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
20
|
+
var value = tableProps.value,
|
|
21
|
+
headerRender = tableProps.headerRender,
|
|
22
|
+
tableRef = tableProps.tableRef,
|
|
23
|
+
className = tableProps.className,
|
|
24
|
+
columns = tableProps.columns,
|
|
25
|
+
renderRowSelection = tableProps.renderRowSelection,
|
|
26
|
+
rowClassName = tableProps.rowClassName,
|
|
27
|
+
disabled = tableProps.disabled,
|
|
28
|
+
virtualKey = tableProps.virtualKey,
|
|
29
|
+
editingKeys = tableProps.editingKeys,
|
|
30
|
+
isHideCheckBox = tableProps.isHideCheckBox,
|
|
31
|
+
rowDraggable = tableProps.rowDraggable,
|
|
32
|
+
pagination = tableProps.pagination,
|
|
33
|
+
scroll = tableProps.scroll,
|
|
34
|
+
summary = tableProps.summary,
|
|
35
|
+
page = tableProps.page,
|
|
36
|
+
formatMessage = tableProps.formatMessage,
|
|
37
|
+
locale = tableProps.locale,
|
|
38
|
+
handlePageChange = tableProps.handlePageChange;
|
|
39
|
+
var onChange = draggableProps.onChange,
|
|
40
|
+
onDrag = draggableProps.onDrag,
|
|
41
|
+
draggable = draggableProps.draggable;
|
|
42
|
+
return (0, _jsxRuntime.jsxs)(_index.DndWrapper, {
|
|
43
|
+
value: value,
|
|
44
|
+
onChange: onChange,
|
|
45
|
+
onDrag: onDrag,
|
|
46
|
+
disabled: disabled,
|
|
47
|
+
draggable: draggable,
|
|
48
|
+
children: [headerRender ? (0, _jsxRuntime.jsx)("div", {
|
|
49
|
+
className: "pro-edit-table-header",
|
|
50
|
+
children: typeof headerRender === 'function' ? headerRender() : headerRender
|
|
51
|
+
}) : null, (0, _jsxRuntime.jsx)(_antd.Table, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
52
|
+
ref: tableRef,
|
|
53
|
+
className: className,
|
|
54
|
+
dataSource: (value === null || value === void 0 ? void 0 : (_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.rowKey) ? value : undefined,
|
|
55
|
+
columns: columns,
|
|
56
|
+
rowSelection: renderRowSelection(),
|
|
57
|
+
rowClassName: rowClassName,
|
|
58
|
+
components: {
|
|
59
|
+
body: {
|
|
60
|
+
row: _index.Row
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
onRow: function onRow() {
|
|
64
|
+
return {
|
|
65
|
+
disabled: disabled || virtualKey && !!editingKeys.length,
|
|
66
|
+
'data-hide': isHideCheckBox,
|
|
67
|
+
onClick: function onClick() {},
|
|
68
|
+
rowDraggable: rowDraggable
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}, resetProps), {}, {
|
|
72
|
+
pagination: pagination ? (0, _objectSpread2.default)({
|
|
73
|
+
current: page.pageNum,
|
|
74
|
+
pageSize: page.pageSize,
|
|
75
|
+
showSizeChanger: false,
|
|
76
|
+
showQuickJumper: true,
|
|
77
|
+
total: value === null || value === void 0 ? void 0 : value.length,
|
|
78
|
+
showTotal: function showTotal(total) {
|
|
79
|
+
var _locale$ProEditTable;
|
|
80
|
+
if (!total) return;
|
|
81
|
+
return formatMessage(locale === null || locale === void 0 ? void 0 : (_locale$ProEditTable = locale.ProEditTable) === null || _locale$ProEditTable === void 0 ? void 0 : _locale$ProEditTable.total, {
|
|
82
|
+
total: total
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
onChange: handlePageChange
|
|
86
|
+
}, pagination) : false,
|
|
87
|
+
rowKey: "rowKey",
|
|
88
|
+
scroll: {
|
|
89
|
+
x: scroll === null || scroll === void 0 ? void 0 : scroll.x,
|
|
90
|
+
y: (value === null || value === void 0 ? void 0 : value.length) ? scroll === null || scroll === void 0 ? void 0 : scroll.y : undefined
|
|
91
|
+
},
|
|
92
|
+
summary: summary
|
|
93
|
+
}))]
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(DraggableTable);
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
var _antd = require("antd");
|
|
13
|
+
var _react = require("react");
|
|
14
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
+
var _rcResizeObserver = _interopRequireDefault(require("rc-resize-observer"));
|
|
16
|
+
var _reactWindow = require("react-window");
|
|
17
|
+
var _excluded = ["tableProps"];
|
|
18
|
+
var VirtualTable = function VirtualTable(_ref) {
|
|
19
|
+
var _value$;
|
|
20
|
+
var tableProps = _ref.tableProps,
|
|
21
|
+
resetProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
22
|
+
var value = tableProps.value,
|
|
23
|
+
headerRender = tableProps.headerRender,
|
|
24
|
+
tableRef = tableProps.tableRef,
|
|
25
|
+
className = tableProps.className,
|
|
26
|
+
columns = tableProps.columns,
|
|
27
|
+
renderRowSelection = tableProps.renderRowSelection,
|
|
28
|
+
rowClassName = tableProps.rowClassName,
|
|
29
|
+
disabled = tableProps.disabled,
|
|
30
|
+
virtualKey = tableProps.virtualKey,
|
|
31
|
+
editingKeys = tableProps.editingKeys,
|
|
32
|
+
isHideCheckBox = tableProps.isHideCheckBox,
|
|
33
|
+
rowDraggable = tableProps.rowDraggable,
|
|
34
|
+
scroll = tableProps.scroll,
|
|
35
|
+
summary = tableProps.summary;
|
|
36
|
+
var _useState = (0, _react.useState)(0),
|
|
37
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
38
|
+
tableWidth = _useState2[0],
|
|
39
|
+
setTableWidth = _useState2[1];
|
|
40
|
+
var widthColumnCount = columns.filter(function (_ref2) {
|
|
41
|
+
var width = _ref2.width;
|
|
42
|
+
return !width;
|
|
43
|
+
}).length;
|
|
44
|
+
var mergedColumns = columns.map(function (column) {
|
|
45
|
+
if (column.width) {
|
|
46
|
+
return column;
|
|
47
|
+
}
|
|
48
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, column), {}, {
|
|
49
|
+
width: Math.floor(tableWidth / widthColumnCount)
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
var gridRef = (0, _react.useRef)();
|
|
53
|
+
var _useState3 = (0, _react.useState)(function () {
|
|
54
|
+
var obj = {};
|
|
55
|
+
Object.defineProperty(obj, 'scrollLeft', {
|
|
56
|
+
get: function get() {
|
|
57
|
+
if (gridRef.current) {
|
|
58
|
+
var _gridRef$current, _gridRef$current$stat;
|
|
59
|
+
return (_gridRef$current = gridRef.current) === null || _gridRef$current === void 0 ? void 0 : (_gridRef$current$stat = _gridRef$current.state) === null || _gridRef$current$stat === void 0 ? void 0 : _gridRef$current$stat.scrollLeft;
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
},
|
|
63
|
+
set: function set(scrollLeft) {
|
|
64
|
+
if (gridRef.current) {
|
|
65
|
+
gridRef.current.scrollTo({
|
|
66
|
+
scrollLeft: scrollLeft
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return obj;
|
|
72
|
+
}),
|
|
73
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 1),
|
|
74
|
+
connectObject = _useState4[0];
|
|
75
|
+
var resetVirtualGrid = function resetVirtualGrid() {
|
|
76
|
+
var _gridRef$current2;
|
|
77
|
+
(_gridRef$current2 = gridRef.current) === null || _gridRef$current2 === void 0 ? void 0 : _gridRef$current2.resetAfterIndices({
|
|
78
|
+
columnIndex: 0,
|
|
79
|
+
shouldForceUpdate: true
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
(0, _react.useEffect)(function () {
|
|
83
|
+
return resetVirtualGrid;
|
|
84
|
+
}, [tableWidth]);
|
|
85
|
+
var renderVirtualList = function renderVirtualList(rawData, _ref3) {
|
|
86
|
+
var scrollbarSize = _ref3.scrollbarSize,
|
|
87
|
+
ref = _ref3.ref,
|
|
88
|
+
_onScroll = _ref3.onScroll;
|
|
89
|
+
ref.current = connectObject;
|
|
90
|
+
var totalHeight = rawData.length * 54;
|
|
91
|
+
return (0, _jsxRuntime.jsx)(_reactWindow.VariableSizeGrid, {
|
|
92
|
+
ref: gridRef,
|
|
93
|
+
className: "virtual-grid",
|
|
94
|
+
columnCount: mergedColumns.length,
|
|
95
|
+
columnWidth: function columnWidth(index) {
|
|
96
|
+
var _width2;
|
|
97
|
+
var width = mergedColumns[index].width;
|
|
98
|
+
var _width = width;
|
|
99
|
+
if (typeof _width === 'string' && ((_width2 = _width) === null || _width2 === void 0 ? void 0 : _width2.includes('px'))) {
|
|
100
|
+
_width = parseInt(width, 10);
|
|
101
|
+
}
|
|
102
|
+
return totalHeight > scroll.y && index === mergedColumns.length - 1 ? _width - scrollbarSize - 1 : _width;
|
|
103
|
+
},
|
|
104
|
+
height: scroll.y,
|
|
105
|
+
rowCount: rawData.length,
|
|
106
|
+
rowHeight: function rowHeight() {
|
|
107
|
+
return 54;
|
|
108
|
+
},
|
|
109
|
+
width: tableWidth,
|
|
110
|
+
onScroll: function onScroll(_ref4) {
|
|
111
|
+
var scrollLeft = _ref4.scrollLeft;
|
|
112
|
+
_onScroll({
|
|
113
|
+
scrollLeft: scrollLeft
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
children: function children(_ref5) {
|
|
117
|
+
var columnIndex = _ref5.columnIndex,
|
|
118
|
+
rowIndex = _ref5.rowIndex,
|
|
119
|
+
style = _ref5.style;
|
|
120
|
+
return (0, _jsxRuntime.jsx)("div", {
|
|
121
|
+
className: (0, _classnames.default)('virtual-table-cell', {
|
|
122
|
+
'virtual-table-cell-last': columnIndex === mergedColumns.length - 1
|
|
123
|
+
}),
|
|
124
|
+
style: style,
|
|
125
|
+
children: rawData[rowIndex][mergedColumns[columnIndex].dataIndex]
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
return (0, _jsxRuntime.jsxs)(_rcResizeObserver.default, {
|
|
131
|
+
onResize: function onResize(_ref6) {
|
|
132
|
+
var _width3;
|
|
133
|
+
var width = _ref6.width;
|
|
134
|
+
var _width = width;
|
|
135
|
+
if (typeof _width === 'string' && ((_width3 = _width) === null || _width3 === void 0 ? void 0 : _width3.includes('px'))) {
|
|
136
|
+
_width = parseInt(width, 10);
|
|
137
|
+
}
|
|
138
|
+
setTableWidth(_width);
|
|
139
|
+
},
|
|
140
|
+
children: [headerRender ? (0, _jsxRuntime.jsx)("div", {
|
|
141
|
+
className: "pro-edit-table-header",
|
|
142
|
+
children: typeof headerRender === 'function' ? headerRender() : headerRender
|
|
143
|
+
}) : null, (0, _jsxRuntime.jsx)(_antd.Table, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
144
|
+
ref: tableRef,
|
|
145
|
+
className: className,
|
|
146
|
+
dataSource: (value === null || value === void 0 ? void 0 : (_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.rowKey) ? value : undefined,
|
|
147
|
+
columns: mergedColumns,
|
|
148
|
+
rowSelection: renderRowSelection(),
|
|
149
|
+
rowClassName: rowClassName,
|
|
150
|
+
components: {
|
|
151
|
+
body: renderVirtualList
|
|
152
|
+
},
|
|
153
|
+
onRow: function onRow() {
|
|
154
|
+
return {
|
|
155
|
+
disabled: disabled || virtualKey && !!editingKeys.length,
|
|
156
|
+
'data-hide': isHideCheckBox,
|
|
157
|
+
onClick: function onClick() {},
|
|
158
|
+
rowDraggable: rowDraggable
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}, resetProps), {}, {
|
|
162
|
+
pagination: false,
|
|
163
|
+
rowKey: "rowKey",
|
|
164
|
+
scroll: {
|
|
165
|
+
x: scroll === null || scroll === void 0 ? void 0 : scroll.x,
|
|
166
|
+
y: (value === null || value === void 0 ? void 0 : value.length) ? scroll === null || scroll === void 0 ? void 0 : scroll.y : undefined
|
|
167
|
+
},
|
|
168
|
+
summary: summary
|
|
169
|
+
}))]
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(VirtualTable);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "BaseTable", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _BaseTable.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "DraggableTable", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return _DraggableTable.default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "VirtualTable", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function get() {
|
|
22
|
+
return _VirtualTable.default;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
var _BaseTable = _interopRequireDefault(require("./BaseTable"));
|
|
26
|
+
var _DraggableTable = _interopRequireDefault(require("./DraggableTable"));
|
|
27
|
+
var _VirtualTable = _interopRequireDefault(require("./VirtualTable"));
|
|
@@ -23,9 +23,10 @@ var _components = require("./components");
|
|
|
23
23
|
var _ProForm = _interopRequireDefault(require("../ProForm"));
|
|
24
24
|
var _empty = _interopRequireDefault(require("../assets/empty.png"));
|
|
25
25
|
var _locale = _interopRequireWildcard(require("../locale"));
|
|
26
|
-
var
|
|
26
|
+
var _RcTable = require("./components/RcTable");
|
|
27
|
+
var _excluded = ["value", "onChange", "onDrag", "className", "columns", "type", "mode", "stripe", "draggable", "virtual", "disabled", "insertType", "emptyBtnText", "actionWidth", "actionProps", "toolbarProps", "toolbarSticky", "rowSelection", "onlyOneLineMsg", "deletePoConfirmMsg", "mulDeletePoConfirmMsg", "requiredAlign", "summary", "max", "headerRender", "pagination", "originalValues", "originalDiffTip", "rowKey", "rowDisabled", "rowDraggable", "footerRender", "scroll", "actionDirection"];
|
|
27
28
|
var ProEditTable = function ProEditTable(_ref, ref) {
|
|
28
|
-
var _resetProps$id, _resetProps$id$split, _themeConfig$data2
|
|
29
|
+
var _resetProps$id, _resetProps$id$split, _themeConfig$data2;
|
|
29
30
|
var value = _ref.value,
|
|
30
31
|
onChange = _ref.onChange,
|
|
31
32
|
onDrag = _ref.onDrag,
|
|
@@ -35,6 +36,7 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
|
35
36
|
mode = _ref.mode,
|
|
36
37
|
stripe = _ref.stripe,
|
|
37
38
|
draggable = _ref.draggable,
|
|
39
|
+
virtual = _ref.virtual,
|
|
38
40
|
disabled = _ref.disabled,
|
|
39
41
|
insertType = _ref.insertType,
|
|
40
42
|
emptyBtnText = _ref.emptyBtnText,
|
|
@@ -327,62 +329,38 @@ var ProEditTable = function ProEditTable(_ref, ref) {
|
|
|
327
329
|
rowSelection: renderRowSelection()
|
|
328
330
|
});
|
|
329
331
|
} : summary;
|
|
332
|
+
var TableComponent = draggable ? _RcTable.DraggableTable : virtual ? _RcTable.VirtualTable : _RcTable.BaseTable;
|
|
330
333
|
return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
331
334
|
children: [(0, _jsxRuntime.jsxs)(_antd.ConfigProvider, {
|
|
332
335
|
renderEmpty: (value === null || value === void 0 ? void 0 : value.length) ? undefined : empty,
|
|
333
|
-
children: [(0, _jsxRuntime.
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
ref: tableRef,
|
|
336
|
+
children: [(0, _jsxRuntime.jsx)(TableComponent, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, resetProps), {}, {
|
|
337
|
+
draggableProps: {
|
|
338
|
+
onChange: onChange,
|
|
339
|
+
onDrag: onDrag,
|
|
340
|
+
draggable: draggable
|
|
341
|
+
},
|
|
342
|
+
tableProps: {
|
|
343
|
+
value: value,
|
|
344
|
+
headerRender: headerRender,
|
|
345
|
+
tableRef: tableRef,
|
|
344
346
|
className: _className,
|
|
345
|
-
dataSource: (value === null || value === void 0 ? void 0 : (_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.rowKey) ? value : undefined,
|
|
346
347
|
columns: _columns,
|
|
347
|
-
|
|
348
|
+
renderRowSelection: renderRowSelection,
|
|
348
349
|
rowClassName: _rowClassName,
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
pagination: pagination ? (0, _objectSpread2.default)({
|
|
364
|
-
current: page.pageNum,
|
|
365
|
-
pageSize: page.pageSize,
|
|
366
|
-
showSizeChanger: false,
|
|
367
|
-
showQuickJumper: true,
|
|
368
|
-
total: value === null || value === void 0 ? void 0 : value.length,
|
|
369
|
-
showTotal: function showTotal(total) {
|
|
370
|
-
var _locale$ProEditTable;
|
|
371
|
-
if (!total) return;
|
|
372
|
-
return (0, _locale.formatMessage)(_locale.default === null || _locale.default === void 0 ? void 0 : (_locale$ProEditTable = _locale.default.ProEditTable) === null || _locale$ProEditTable === void 0 ? void 0 : _locale$ProEditTable.total, {
|
|
373
|
-
total: total
|
|
374
|
-
});
|
|
375
|
-
},
|
|
376
|
-
onChange: handlePageChange
|
|
377
|
-
}, pagination) : false,
|
|
378
|
-
rowKey: "rowKey",
|
|
379
|
-
scroll: {
|
|
380
|
-
x: scroll === null || scroll === void 0 ? void 0 : scroll.x,
|
|
381
|
-
y: (value === null || value === void 0 ? void 0 : value.length) ? scroll === null || scroll === void 0 ? void 0 : scroll.y : undefined
|
|
382
|
-
},
|
|
383
|
-
summary: _summary
|
|
384
|
-
}))]
|
|
385
|
-
}), !isView && (value === null || value === void 0 ? void 0 : value.length) ? toolbarSticky ? (0, _jsxRuntime.jsx)(_antd.Affix, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
350
|
+
disabled: disabled,
|
|
351
|
+
virtualKey: virtualKey,
|
|
352
|
+
editingKeys: editingKeys,
|
|
353
|
+
isHideCheckBox: isHideCheckBox,
|
|
354
|
+
rowDraggable: rowDraggable,
|
|
355
|
+
pagination: pagination,
|
|
356
|
+
scroll: scroll,
|
|
357
|
+
summary: _summary,
|
|
358
|
+
page: page,
|
|
359
|
+
formatMessage: _locale.formatMessage,
|
|
360
|
+
locale: _locale.default,
|
|
361
|
+
handlePageChange: handlePageChange
|
|
362
|
+
}
|
|
363
|
+
})), !isView && (value === null || value === void 0 ? void 0 : value.length) ? toolbarSticky ? (0, _jsxRuntime.jsx)(_antd.Affix, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
386
364
|
ref: affixRef
|
|
387
365
|
}, _toolbarSticky), {}, {
|
|
388
366
|
children: (0, _jsxRuntime.jsx)("div", {
|
|
@@ -415,6 +393,7 @@ ForwardProEditTable.defaultProps = {
|
|
|
415
393
|
toolbarProps: [],
|
|
416
394
|
disabled: false,
|
|
417
395
|
draggable: false,
|
|
396
|
+
virtual: false,
|
|
418
397
|
stripe: true,
|
|
419
398
|
emptyBtnText: _locale.default.ProEditTable.clickAdd,
|
|
420
399
|
onlyOneLineMsg: _locale.default.ProEditTable.onlyOneLineMsg,
|
|
@@ -192,6 +192,11 @@ export interface ProEditTableProps<T = any> extends Omit<TableProps<T>, 'onChang
|
|
|
192
192
|
* @default -
|
|
193
193
|
*/
|
|
194
194
|
draggable?: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* @description 是否开启虚拟列表(scroll,x,y必须为固定值)
|
|
197
|
+
* @default -
|
|
198
|
+
*/
|
|
199
|
+
virtual?: boolean;
|
|
195
200
|
/**
|
|
196
201
|
* @description 空列表状态时,自定义添加按钮
|
|
197
202
|
* @default 点击添加
|
|
@@ -125,7 +125,7 @@ var getActionColumn = function getActionColumn(config) {
|
|
|
125
125
|
case 20:
|
|
126
126
|
result = _context.sent;
|
|
127
127
|
case 21:
|
|
128
|
-
if (result && type !== 'custom') {
|
|
128
|
+
if (result !== false && type !== 'custom') {
|
|
129
129
|
_config.actions[type]((0, _objectSpread2.default)((0, _objectSpread2.default)({}, config), {}, {
|
|
130
130
|
rowName: [].concat((0, _toConsumableArray2.default)(name), [index]),
|
|
131
131
|
virtualRowName: rowName,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zat-design/sisyphus-react",
|
|
3
|
-
"version": "3.6.6-beta.
|
|
3
|
+
"version": "3.6.6-beta.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -58,15 +58,17 @@
|
|
|
58
58
|
"@dnd-kit/sortable": "^7.0.2",
|
|
59
59
|
"@dnd-kit/utilities": "^3.2.1",
|
|
60
60
|
"@pansy/react-watermark": "^3.1.13",
|
|
61
|
-
"@zat-design/utils": "^1.1.
|
|
61
|
+
"@zat-design/utils": "^1.1.31",
|
|
62
62
|
"ahooks": "3.7.4",
|
|
63
63
|
"antd": "4.24.8",
|
|
64
64
|
"big.js": "^6.2.1",
|
|
65
65
|
"classnames": "^2.3.1",
|
|
66
66
|
"lodash": "^4.17.21",
|
|
67
67
|
"moment": "^2.29.1",
|
|
68
|
+
"rc-resize-observer": "^1.4.0",
|
|
68
69
|
"react-resizable": "^3.0.4",
|
|
69
|
-
"react-svg": "^15.1.7"
|
|
70
|
+
"react-svg": "^15.1.7",
|
|
71
|
+
"react-window": "^1.8.10"
|
|
70
72
|
},
|
|
71
73
|
"peerDependencies": {
|
|
72
74
|
"antd": "^4.24.8",
|