@zat-design/sisyphus-react 3.6.5 → 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/components/RenderField/index.js +65 -45
- package/es/ProEditTable/index.js +32 -55
- package/es/ProEditTable/propsType.d.ts +6 -0
- package/es/ProEditTable/utils/index.js +1 -1
- package/es/ProForm/components/base/InputNumber/index.js +20 -11
- package/es/ProForm/index.d.ts +3 -2
- package/es/ProForm/index.js +3 -17
- package/es/ProForm/utils/useShouldUpdate.js +9 -1
- package/es/ProForm/utils/useWatch.d.ts +7 -0
- package/es/ProForm/utils/useWatch.js +77 -0
- package/es/ProTable/utils.js +1 -1
- package/es/ProTree/components/ProTreeSelect/index.js +15 -4
- 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 +65 -45
- package/lib/ProEditTable/index.js +31 -52
- package/lib/ProEditTable/propsType.d.ts +6 -0
- package/lib/ProEditTable/utils/index.js +1 -1
- package/lib/ProForm/components/base/InputNumber/index.js +20 -11
- package/lib/ProForm/index.d.ts +3 -2
- package/lib/ProForm/index.js +2 -16
- package/lib/ProForm/utils/useShouldUpdate.js +9 -1
- package/lib/ProForm/utils/useWatch.d.ts +7 -0
- package/lib/ProForm/utils/useWatch.js +87 -0
- package/lib/ProTable/utils.js +1 -1
- package/lib/ProTree/components/ProTreeSelect/index.js +15 -4
- package/package.json +5 -3
|
@@ -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"));
|
|
@@ -30,7 +30,7 @@ var _useListChanged3 = require("../../../ProForm/utils/useListChanged");
|
|
|
30
30
|
var _useRules = _interopRequireDefault(require("../../../ProForm/utils/useRules"));
|
|
31
31
|
var _utils = require("../../../ProForm/utils");
|
|
32
32
|
var _ConfirmWrapper = _interopRequireDefault(require("../../../ProForm/components/render/ConfirmWrapper"));
|
|
33
|
-
var _excluded = ["type", "valueType", "names", "fieldProps", "labelRequired", "editRender", "component", "viewRender", "title", "originTitle", "label", "dataIndex", "formItemProps", "isEditable", "required", "rules", "equalWith", "className", "trim", "confirm"];
|
|
33
|
+
var _excluded = ["type", "valueType", "names", "fieldProps", "labelRequired", "editRender", "component", "viewRender", "title", "originTitle", "label", "dataIndex", "formItemProps", "isEditable", "required", "rules", "equalWith", "className", "trim", "confirm", "validateTrigger"];
|
|
34
34
|
/* eslint-disable prefer-destructuring */
|
|
35
35
|
/* eslint-disable prefer-const */
|
|
36
36
|
var RenderField = function RenderField(_ref) {
|
|
@@ -63,6 +63,8 @@ var RenderField = function RenderField(_ref) {
|
|
|
63
63
|
className = column.className,
|
|
64
64
|
trim = column.trim,
|
|
65
65
|
confirm = column.confirm,
|
|
66
|
+
_column$validateTrigg = column.validateTrigger,
|
|
67
|
+
validateTrigger = _column$validateTrigg === void 0 ? ['onChange', 'onBlur', 'onSumbit'] : _column$validateTrigg,
|
|
66
68
|
resetProps = (0, _objectWithoutProperties2.default)(column, _excluded);
|
|
67
69
|
// editRender弃用使用component同ProForm
|
|
68
70
|
var _editRender = component || editRender;
|
|
@@ -161,7 +163,9 @@ var RenderField = function RenderField(_ref) {
|
|
|
161
163
|
// 分离form item参数,防止对于参数透传(如onChange,防止重复触发)并优先级高于 _fieldProps 内部参数
|
|
162
164
|
var formItemChildProps = (0, _objectSpread2.default)({}, _fieldProps);
|
|
163
165
|
// 允许formItem的属性放在column最外层
|
|
164
|
-
var _formItemProps = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, resetProps), internalRule)
|
|
166
|
+
var _formItemProps = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, resetProps), internalRule), {}, {
|
|
167
|
+
validateTrigger: validateTrigger
|
|
168
|
+
});
|
|
165
169
|
if (['Switch', 'SwitchCheckbox'].includes(type)) {
|
|
166
170
|
_formItemProps.valuePropName = 'checked';
|
|
167
171
|
valueType = 'switch';
|
|
@@ -321,6 +325,12 @@ var RenderField = function RenderField(_ref) {
|
|
|
321
325
|
return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
|
|
322
326
|
while (1) switch (_context.prev = _context.next) {
|
|
323
327
|
case 0:
|
|
328
|
+
if (!(!onFieldChange && !onChange)) {
|
|
329
|
+
_context.next = 2;
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
return _context.abrupt("return", null);
|
|
333
|
+
case 2:
|
|
324
334
|
for (_len2 = _args2.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
325
335
|
args[_key2] = _args2[_key2];
|
|
326
336
|
}
|
|
@@ -329,58 +339,60 @@ var RenderField = function RenderField(_ref) {
|
|
|
329
339
|
row = form.getFieldValue(rowPath, true); // if (type === 'InputNumber' && column.name) row[column.name] = args[0];
|
|
330
340
|
orgRow = (0, _lodash.cloneDeep)(row);
|
|
331
341
|
if (!onFieldChange) {
|
|
332
|
-
_context.next =
|
|
342
|
+
_context.next = 20;
|
|
333
343
|
break;
|
|
334
344
|
}
|
|
335
345
|
_args = formatArgs(args);
|
|
336
346
|
_args[1] = row;
|
|
337
347
|
_context.t0 = (_TargetComponent = TargetComponent) === null || _TargetComponent === void 0 ? void 0 : (_TargetComponent$prop = _TargetComponent.props) === null || _TargetComponent$prop === void 0 ? void 0 : _TargetComponent$prop.onFieldChange;
|
|
338
348
|
if (!_context.t0) {
|
|
339
|
-
_context.next =
|
|
349
|
+
_context.next = 14;
|
|
340
350
|
break;
|
|
341
351
|
}
|
|
342
|
-
_context.next =
|
|
352
|
+
_context.next = 14;
|
|
343
353
|
return (_TargetComponent$prop2 = TargetComponent.props).onFieldChange.apply(_TargetComponent$prop2, (0, _toConsumableArray2.default)(_args));
|
|
344
|
-
case
|
|
354
|
+
case 14:
|
|
345
355
|
_context.t1 = onFieldChange;
|
|
346
356
|
if (!_context.t1) {
|
|
347
|
-
_context.next =
|
|
357
|
+
_context.next = 18;
|
|
348
358
|
break;
|
|
349
359
|
}
|
|
350
|
-
_context.next =
|
|
360
|
+
_context.next = 18;
|
|
351
361
|
return onFieldChange.apply(void 0, (0, _toConsumableArray2.default)(_args));
|
|
352
|
-
case 16:
|
|
353
|
-
_context.next = 27;
|
|
354
|
-
break;
|
|
355
362
|
case 18:
|
|
363
|
+
_context.next = 29;
|
|
364
|
+
break;
|
|
365
|
+
case 20:
|
|
356
366
|
_args = _args.concat([row, index, form]);
|
|
357
367
|
_context.t2 = (_TargetComponent2 = TargetComponent) === null || _TargetComponent2 === void 0 ? void 0 : (_TargetComponent2$pro = _TargetComponent2.props) === null || _TargetComponent2$pro === void 0 ? void 0 : _TargetComponent2$pro.onChange;
|
|
358
368
|
if (!_context.t2) {
|
|
359
|
-
_context.next =
|
|
369
|
+
_context.next = 25;
|
|
360
370
|
break;
|
|
361
371
|
}
|
|
362
|
-
_context.next =
|
|
372
|
+
_context.next = 25;
|
|
363
373
|
return (_TargetComponent$prop3 = TargetComponent.props).onChange.apply(_TargetComponent$prop3, (0, _toConsumableArray2.default)(_args));
|
|
364
|
-
case
|
|
374
|
+
case 25:
|
|
365
375
|
_context.t3 = onChange;
|
|
366
376
|
if (!_context.t3) {
|
|
367
|
-
_context.next =
|
|
377
|
+
_context.next = 29;
|
|
368
378
|
break;
|
|
369
379
|
}
|
|
370
|
-
_context.next =
|
|
380
|
+
_context.next = 29;
|
|
371
381
|
return onChange.apply(void 0, (0, _toConsumableArray2.default)(_args));
|
|
372
|
-
case
|
|
382
|
+
case 29:
|
|
373
383
|
// 判断属性是否变动
|
|
374
384
|
form.setFieldValue(rowPath, row);
|
|
375
|
-
if (
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
385
|
+
if (validateTrigger && validateTrigger.includes('onChange')) {
|
|
386
|
+
if (!(0, _lodash.isEqual)(orgRow, row)) {
|
|
387
|
+
diff = (0, _tools.difference)(row, orgRow) || {};
|
|
388
|
+
validateFieldKeys = (_Object$keys = Object.keys(diff)) === null || _Object$keys === void 0 ? void 0 : (_Object$keys$map = _Object$keys.map) === null || _Object$keys$map === void 0 ? void 0 : _Object$keys$map.call(_Object$keys, function (key) {
|
|
389
|
+
return [].concat((0, _toConsumableArray2.default)(rowPath), [key]);
|
|
390
|
+
});
|
|
391
|
+
if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
|
|
392
|
+
setTimeout(function () {
|
|
393
|
+
form.validateFields(validateFieldKeys);
|
|
394
|
+
}, 100);
|
|
395
|
+
}
|
|
384
396
|
}
|
|
385
397
|
}
|
|
386
398
|
setState({
|
|
@@ -388,7 +400,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
388
400
|
d: Date.now()
|
|
389
401
|
}
|
|
390
402
|
});
|
|
391
|
-
case
|
|
403
|
+
case 32:
|
|
392
404
|
case "end":
|
|
393
405
|
return _context.stop();
|
|
394
406
|
}
|
|
@@ -412,6 +424,12 @@ var RenderField = function RenderField(_ref) {
|
|
|
412
424
|
return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
|
|
413
425
|
while (1) switch (_context2.prev = _context2.next) {
|
|
414
426
|
case 0:
|
|
427
|
+
if (onBlur) {
|
|
428
|
+
_context2.next = 2;
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
return _context2.abrupt("return", null);
|
|
432
|
+
case 2:
|
|
415
433
|
for (_len3 = _args3.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
416
434
|
args[_key3] = _args3[_key3];
|
|
417
435
|
}
|
|
@@ -422,49 +440,51 @@ var RenderField = function RenderField(_ref) {
|
|
|
422
440
|
_args[1] = row;
|
|
423
441
|
_context2.t0 = (_TargetComponent3 = TargetComponent) === null || _TargetComponent3 === void 0 ? void 0 : (_TargetComponent3$pro = _TargetComponent3.props) === null || _TargetComponent3$pro === void 0 ? void 0 : _TargetComponent3$pro.onBlur;
|
|
424
442
|
if (!_context2.t0) {
|
|
425
|
-
_context2.next =
|
|
443
|
+
_context2.next = 12;
|
|
426
444
|
break;
|
|
427
445
|
}
|
|
428
|
-
_context2.next =
|
|
446
|
+
_context2.next = 12;
|
|
429
447
|
return (_TargetComponent$prop4 = TargetComponent.props).onBlur.apply(_TargetComponent$prop4, (0, _toConsumableArray2.default)(_args));
|
|
430
|
-
case
|
|
448
|
+
case 12:
|
|
431
449
|
_context2.t1 = onBlur;
|
|
432
450
|
if (!_context2.t1) {
|
|
433
|
-
_context2.next =
|
|
451
|
+
_context2.next = 16;
|
|
434
452
|
break;
|
|
435
453
|
}
|
|
436
|
-
_context2.next =
|
|
454
|
+
_context2.next = 16;
|
|
437
455
|
return onBlur.apply(void 0, (0, _toConsumableArray2.default)(_args));
|
|
438
|
-
case
|
|
456
|
+
case 16:
|
|
439
457
|
// 判断属性是否变动
|
|
440
458
|
form.setFieldValue(rowPath, row);
|
|
441
|
-
if (
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
459
|
+
if (validateTrigger && validateTrigger.includes('onBlur')) {
|
|
460
|
+
if (!(0, _lodash.isEqual)(orgRow, row)) {
|
|
461
|
+
diff = (0, _tools.difference)(row, orgRow) || {};
|
|
462
|
+
validateFieldKeys = (_Object$keys2 = Object.keys(diff)) === null || _Object$keys2 === void 0 ? void 0 : (_Object$keys2$map = _Object$keys2.map) === null || _Object$keys2$map === void 0 ? void 0 : _Object$keys2$map.call(_Object$keys2, function (key) {
|
|
463
|
+
return [].concat((0, _toConsumableArray2.default)(rowPath), [key]);
|
|
464
|
+
});
|
|
465
|
+
if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
|
|
466
|
+
debounceValidate(validateFieldKeys);
|
|
467
|
+
}
|
|
448
468
|
}
|
|
449
469
|
}
|
|
450
470
|
if (!isCell) {
|
|
451
|
-
_context2.next =
|
|
471
|
+
_context2.next = 22;
|
|
452
472
|
break;
|
|
453
473
|
}
|
|
454
|
-
_context2.next =
|
|
474
|
+
_context2.next = 21;
|
|
455
475
|
return form.validateFields([cellName]);
|
|
456
|
-
case
|
|
476
|
+
case 21:
|
|
457
477
|
setState({
|
|
458
478
|
cellNamePath: []
|
|
459
479
|
});
|
|
460
|
-
case
|
|
480
|
+
case 22:
|
|
461
481
|
// 单行编辑时需要 强制更新视图
|
|
462
482
|
setState({
|
|
463
483
|
forceUpdate: {
|
|
464
484
|
d: Date.now()
|
|
465
485
|
}
|
|
466
486
|
});
|
|
467
|
-
case
|
|
487
|
+
case 23:
|
|
468
488
|
case "end":
|
|
469
489
|
return _context2.stop();
|
|
470
490
|
}
|
|
@@ -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,
|