@zat-design/sisyphus-react 3.6.6-beta.1 → 3.6.6-beta.5
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/components/RenderField/index.js +1 -1
- package/es/ProEditTable/index.js +32 -55
- package/es/ProEditTable/propsType.d.ts +5 -0
- package/es/ProEditTable/utils/index.js +1 -1
- package/es/ProForm/components/combination/ProCascader/index.js +3 -1
- package/es/ProSelect/index.js +1 -1
- package/es/ProTable/propsType.d.ts +2 -1
- package/es/ProTable/useAntdTable.d.ts +2 -2
- package/es/ProTable/useAntdTable.js +17 -3
- 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/components/RenderField/index.js +1 -1
- package/lib/ProEditTable/index.js +31 -52
- package/lib/ProEditTable/propsType.d.ts +5 -0
- package/lib/ProEditTable/utils/index.js +1 -1
- package/lib/ProForm/components/combination/ProCascader/index.js +3 -1
- package/lib/ProSelect/index.js +1 -1
- package/lib/ProTable/propsType.d.ts +2 -1
- package/lib/ProTable/useAntdTable.d.ts +2 -2
- package/lib/ProTable/useAntdTable.js +16 -2
- 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);
|
|
@@ -591,7 +591,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
591
591
|
}) : null;
|
|
592
592
|
return _jsx(FieldProvider, {
|
|
593
593
|
value: (_componentProps2 = componentProps) === null || _componentProps2 === void 0 ? void 0 : _componentProps2.otherProps,
|
|
594
|
-
children: !
|
|
594
|
+
children: !originalTitle || ['FormList', 'ProEditTable'].includes(type) ? FormItem : _jsx(_Tooltip, {
|
|
595
595
|
title: originalTitle,
|
|
596
596
|
placement: "topLeft",
|
|
597
597
|
open: changed ? undefined : false,
|
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,
|
|
@@ -221,7 +221,9 @@ var ProCascader = function ProCascader(props) {
|
|
|
221
221
|
// 如果没有在当前层级的选项中找到匹配的 value,返回 null
|
|
222
222
|
return null;
|
|
223
223
|
};
|
|
224
|
-
var _selectedOptions =
|
|
224
|
+
var _selectedOptions = useMemo(function () {
|
|
225
|
+
return findSelectedOptions(service ? serviceData : realDataSource, addressValue);
|
|
226
|
+
}, [service, serviceData, realDataSource, addressValue]);
|
|
225
227
|
var handleAddressChange = function handleAddressChange(e) {
|
|
226
228
|
var cascaderValue = value === null || value === void 0 ? void 0 : value.slice(0, realLevel);
|
|
227
229
|
if (onChange) {
|
package/es/ProSelect/index.js
CHANGED
|
@@ -338,7 +338,7 @@ export var ProSelect = function ProSelect(props, ref) {
|
|
|
338
338
|
title: OptionRender(item),
|
|
339
339
|
children: OptionRender(item)
|
|
340
340
|
}) : _jsx("span", {
|
|
341
|
-
title: "".concat(item[code], "-").concat(item[label]),
|
|
341
|
+
title: selectProps.showCodeName ? "".concat(item[code], "-").concat(item[label]) : item[label],
|
|
342
342
|
children: selectProps.showCodeName ? "".concat(item[code], "-").concat(item[label]) : item[label]
|
|
343
343
|
})
|
|
344
344
|
}, item[code])
|
|
@@ -72,11 +72,12 @@ export interface PaginationProps {
|
|
|
72
72
|
pageNum: number;
|
|
73
73
|
pageSize: number;
|
|
74
74
|
}
|
|
75
|
+
type RowSelectionTypeWithPick = Pick<TableProps<any>, 'rowSelection'>['rowSelection'];
|
|
75
76
|
export interface RequestOptions<T, R> {
|
|
76
77
|
form?: FormInstance;
|
|
77
78
|
isResetQuery?: boolean;
|
|
78
79
|
rowKey?: string | GetRowKey<R>;
|
|
79
|
-
rowSelection?: boolean;
|
|
80
|
+
rowSelection?: boolean | RowSelectionTypeWithPick;
|
|
80
81
|
rowSelectType?: RowSelectionType;
|
|
81
82
|
rowSelections?: boolean;
|
|
82
83
|
extraParams?: Partial<T>;
|
|
@@ -11,7 +11,7 @@ declare function useAntdTable<I, R extends Record<string, any>, S extends Servic
|
|
|
11
11
|
selectedRowKeys: Key[];
|
|
12
12
|
onChange(rowKeys: Key[], rows: any[]): void;
|
|
13
13
|
onSelectAll: (selected: boolean) => void;
|
|
14
|
-
getCheckboxProps: () => {
|
|
14
|
+
getCheckboxProps: (record?: any) => {
|
|
15
15
|
className: string;
|
|
16
16
|
};
|
|
17
17
|
selections: boolean | ({
|
|
@@ -57,7 +57,7 @@ declare function useAntdTable<I, R extends Record<string, any>, S extends Servic
|
|
|
57
57
|
selectedRowKeys: Key[];
|
|
58
58
|
onChange(rowKeys: Key[], rows: any[]): void;
|
|
59
59
|
onSelectAll: (selected: boolean) => void;
|
|
60
|
-
getCheckboxProps: () => {
|
|
60
|
+
getCheckboxProps: (record?: any) => {
|
|
61
61
|
className: string;
|
|
62
62
|
};
|
|
63
63
|
selections: boolean | ({
|
|
@@ -9,7 +9,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
9
9
|
var _excluded = ["page", "filters", "sorter"];
|
|
10
10
|
import { useCallback, useMemo, useState } from 'react';
|
|
11
11
|
import { useRequest, useSetState, useDeepCompareEffect } from 'ahooks';
|
|
12
|
-
import { pickBy } from 'lodash';
|
|
12
|
+
import { pickBy, isObject, merge, set, isEqual } from 'lodash';
|
|
13
13
|
import { defaultPage } from './index';
|
|
14
14
|
import { isListResult } from './utils';
|
|
15
15
|
import locale, { formatMessage } from '../locale';
|
|
@@ -313,7 +313,7 @@ function useAntdTable(service, options, useRequestOptions) {
|
|
|
313
313
|
}));
|
|
314
314
|
}
|
|
315
315
|
}, [extraParams]);
|
|
316
|
-
var
|
|
316
|
+
var _rowSelection = {
|
|
317
317
|
fixed: true,
|
|
318
318
|
type: rowSelectType,
|
|
319
319
|
columnWidth: rowSelections ? 64 : undefined,
|
|
@@ -355,7 +355,7 @@ function useAntdTable(service, options, useRequestOptions) {
|
|
|
355
355
|
});
|
|
356
356
|
}
|
|
357
357
|
},
|
|
358
|
-
getCheckboxProps: function getCheckboxProps() {
|
|
358
|
+
getCheckboxProps: function getCheckboxProps(record) {
|
|
359
359
|
return {
|
|
360
360
|
className: allSelected && rowSelections ? 'checkbox-disabled' : ''
|
|
361
361
|
};
|
|
@@ -424,6 +424,20 @@ function useAntdTable(service, options, useRequestOptions) {
|
|
|
424
424
|
}()
|
|
425
425
|
}] : false
|
|
426
426
|
};
|
|
427
|
+
var rowSelection = isObject(returnRowSelection) ? merge(_rowSelection, returnRowSelection) : _rowSelection;
|
|
428
|
+
if (isObject(returnRowSelection) && !isEqual(rowSelection, _rowSelection)) {
|
|
429
|
+
// getCheckboxProps需要特殊兼容原有的逻辑,特殊处理
|
|
430
|
+
var isHasGetCheckboxProps = Reflect.ownKeys(returnRowSelection).includes('getCheckboxProps');
|
|
431
|
+
if (isHasGetCheckboxProps) {
|
|
432
|
+
set(rowSelection, 'getCheckboxProps', function (record) {
|
|
433
|
+
var _rowSelection$getChec;
|
|
434
|
+
var passReturnObjects = (_rowSelection$getChec = rowSelection.getCheckboxProps(record)) !== null && _rowSelection$getChec !== void 0 ? _rowSelection$getChec : {};
|
|
435
|
+
return _objectSpread({
|
|
436
|
+
className: allSelected && rowSelections ? 'checkbox-disabled' : ''
|
|
437
|
+
}, passReturnObjects);
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
}
|
|
427
441
|
var selectedTip = allSelected || selectedRowKeys.length ? formatMessage(locale === null || locale === void 0 ? void 0 : (_locale$ProTable5 = locale.ProTable) === null || _locale$ProTable5 === void 0 ? void 0 : _locale$ProTable5.selectAll, {
|
|
428
442
|
selectedNum: allSelected ? total : selectedRowKeys === null || selectedRowKeys === void 0 ? void 0 : selectedRowKeys.length
|
|
429
443
|
}) : null;
|