@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,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);
|
|
@@ -11,7 +11,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
11
11
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
12
12
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
13
13
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
14
|
-
var _excluded = ["type", "valueType", "names", "fieldProps", "labelRequired", "editRender", "component", "viewRender", "title", "originTitle", "label", "dataIndex", "formItemProps", "isEditable", "required", "rules", "equalWith", "className", "trim", "confirm"];
|
|
14
|
+
var _excluded = ["type", "valueType", "names", "fieldProps", "labelRequired", "editRender", "component", "viewRender", "title", "originTitle", "label", "dataIndex", "formItemProps", "isEditable", "required", "rules", "equalWith", "className", "trim", "confirm", "validateTrigger"];
|
|
15
15
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
16
|
/* eslint-disable prefer-destructuring */
|
|
17
17
|
/* eslint-disable prefer-const */
|
|
@@ -60,6 +60,8 @@ var RenderField = function RenderField(_ref) {
|
|
|
60
60
|
className = column.className,
|
|
61
61
|
trim = column.trim,
|
|
62
62
|
confirm = column.confirm,
|
|
63
|
+
_column$validateTrigg = column.validateTrigger,
|
|
64
|
+
validateTrigger = _column$validateTrigg === void 0 ? ['onChange', 'onBlur', 'onSumbit'] : _column$validateTrigg,
|
|
63
65
|
resetProps = _objectWithoutProperties(column, _excluded);
|
|
64
66
|
// editRender弃用使用component同ProForm
|
|
65
67
|
var _editRender = component || editRender;
|
|
@@ -158,7 +160,9 @@ var RenderField = function RenderField(_ref) {
|
|
|
158
160
|
// 分离form item参数,防止对于参数透传(如onChange,防止重复触发)并优先级高于 _fieldProps 内部参数
|
|
159
161
|
var formItemChildProps = _objectSpread({}, _fieldProps);
|
|
160
162
|
// 允许formItem的属性放在column最外层
|
|
161
|
-
var _formItemProps = _objectSpread(_objectSpread({}, resetProps), internalRule)
|
|
163
|
+
var _formItemProps = _objectSpread(_objectSpread(_objectSpread({}, resetProps), internalRule), {}, {
|
|
164
|
+
validateTrigger: validateTrigger
|
|
165
|
+
});
|
|
162
166
|
if (['Switch', 'SwitchCheckbox'].includes(type)) {
|
|
163
167
|
_formItemProps.valuePropName = 'checked';
|
|
164
168
|
valueType = 'switch';
|
|
@@ -318,6 +322,12 @@ var RenderField = function RenderField(_ref) {
|
|
|
318
322
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
319
323
|
while (1) switch (_context.prev = _context.next) {
|
|
320
324
|
case 0:
|
|
325
|
+
if (!(!onFieldChange && !onChange)) {
|
|
326
|
+
_context.next = 2;
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
return _context.abrupt("return", null);
|
|
330
|
+
case 2:
|
|
321
331
|
for (_len2 = _args2.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
322
332
|
args[_key2] = _args2[_key2];
|
|
323
333
|
}
|
|
@@ -326,58 +336,60 @@ var RenderField = function RenderField(_ref) {
|
|
|
326
336
|
row = form.getFieldValue(rowPath, true); // if (type === 'InputNumber' && column.name) row[column.name] = args[0];
|
|
327
337
|
orgRow = cloneDeep(row);
|
|
328
338
|
if (!onFieldChange) {
|
|
329
|
-
_context.next =
|
|
339
|
+
_context.next = 20;
|
|
330
340
|
break;
|
|
331
341
|
}
|
|
332
342
|
_args = formatArgs(args);
|
|
333
343
|
_args[1] = row;
|
|
334
344
|
_context.t0 = (_TargetComponent = TargetComponent) === null || _TargetComponent === void 0 ? void 0 : (_TargetComponent$prop = _TargetComponent.props) === null || _TargetComponent$prop === void 0 ? void 0 : _TargetComponent$prop.onFieldChange;
|
|
335
345
|
if (!_context.t0) {
|
|
336
|
-
_context.next =
|
|
346
|
+
_context.next = 14;
|
|
337
347
|
break;
|
|
338
348
|
}
|
|
339
|
-
_context.next =
|
|
349
|
+
_context.next = 14;
|
|
340
350
|
return (_TargetComponent$prop2 = TargetComponent.props).onFieldChange.apply(_TargetComponent$prop2, _toConsumableArray(_args));
|
|
341
|
-
case
|
|
351
|
+
case 14:
|
|
342
352
|
_context.t1 = onFieldChange;
|
|
343
353
|
if (!_context.t1) {
|
|
344
|
-
_context.next =
|
|
354
|
+
_context.next = 18;
|
|
345
355
|
break;
|
|
346
356
|
}
|
|
347
|
-
_context.next =
|
|
357
|
+
_context.next = 18;
|
|
348
358
|
return onFieldChange.apply(void 0, _toConsumableArray(_args));
|
|
349
|
-
case 16:
|
|
350
|
-
_context.next = 27;
|
|
351
|
-
break;
|
|
352
359
|
case 18:
|
|
360
|
+
_context.next = 29;
|
|
361
|
+
break;
|
|
362
|
+
case 20:
|
|
353
363
|
_args = _args.concat([row, index, form]);
|
|
354
364
|
_context.t2 = (_TargetComponent2 = TargetComponent) === null || _TargetComponent2 === void 0 ? void 0 : (_TargetComponent2$pro = _TargetComponent2.props) === null || _TargetComponent2$pro === void 0 ? void 0 : _TargetComponent2$pro.onChange;
|
|
355
365
|
if (!_context.t2) {
|
|
356
|
-
_context.next =
|
|
366
|
+
_context.next = 25;
|
|
357
367
|
break;
|
|
358
368
|
}
|
|
359
|
-
_context.next =
|
|
369
|
+
_context.next = 25;
|
|
360
370
|
return (_TargetComponent$prop3 = TargetComponent.props).onChange.apply(_TargetComponent$prop3, _toConsumableArray(_args));
|
|
361
|
-
case
|
|
371
|
+
case 25:
|
|
362
372
|
_context.t3 = onChange;
|
|
363
373
|
if (!_context.t3) {
|
|
364
|
-
_context.next =
|
|
374
|
+
_context.next = 29;
|
|
365
375
|
break;
|
|
366
376
|
}
|
|
367
|
-
_context.next =
|
|
377
|
+
_context.next = 29;
|
|
368
378
|
return onChange.apply(void 0, _toConsumableArray(_args));
|
|
369
|
-
case
|
|
379
|
+
case 29:
|
|
370
380
|
// 判断属性是否变动
|
|
371
381
|
form.setFieldValue(rowPath, row);
|
|
372
|
-
if (
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
382
|
+
if (validateTrigger && validateTrigger.includes('onChange')) {
|
|
383
|
+
if (!isEqual(orgRow, row)) {
|
|
384
|
+
diff = difference(row, orgRow) || {};
|
|
385
|
+
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) {
|
|
386
|
+
return [].concat(_toConsumableArray(rowPath), [key]);
|
|
387
|
+
});
|
|
388
|
+
if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
|
|
389
|
+
setTimeout(function () {
|
|
390
|
+
form.validateFields(validateFieldKeys);
|
|
391
|
+
}, 100);
|
|
392
|
+
}
|
|
381
393
|
}
|
|
382
394
|
}
|
|
383
395
|
setState({
|
|
@@ -385,7 +397,7 @@ var RenderField = function RenderField(_ref) {
|
|
|
385
397
|
d: Date.now()
|
|
386
398
|
}
|
|
387
399
|
});
|
|
388
|
-
case
|
|
400
|
+
case 32:
|
|
389
401
|
case "end":
|
|
390
402
|
return _context.stop();
|
|
391
403
|
}
|
|
@@ -409,6 +421,12 @@ var RenderField = function RenderField(_ref) {
|
|
|
409
421
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
410
422
|
while (1) switch (_context2.prev = _context2.next) {
|
|
411
423
|
case 0:
|
|
424
|
+
if (onBlur) {
|
|
425
|
+
_context2.next = 2;
|
|
426
|
+
break;
|
|
427
|
+
}
|
|
428
|
+
return _context2.abrupt("return", null);
|
|
429
|
+
case 2:
|
|
412
430
|
for (_len3 = _args3.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
413
431
|
args[_key3] = _args3[_key3];
|
|
414
432
|
}
|
|
@@ -419,49 +437,51 @@ var RenderField = function RenderField(_ref) {
|
|
|
419
437
|
_args[1] = row;
|
|
420
438
|
_context2.t0 = (_TargetComponent3 = TargetComponent) === null || _TargetComponent3 === void 0 ? void 0 : (_TargetComponent3$pro = _TargetComponent3.props) === null || _TargetComponent3$pro === void 0 ? void 0 : _TargetComponent3$pro.onBlur;
|
|
421
439
|
if (!_context2.t0) {
|
|
422
|
-
_context2.next =
|
|
440
|
+
_context2.next = 12;
|
|
423
441
|
break;
|
|
424
442
|
}
|
|
425
|
-
_context2.next =
|
|
443
|
+
_context2.next = 12;
|
|
426
444
|
return (_TargetComponent$prop4 = TargetComponent.props).onBlur.apply(_TargetComponent$prop4, _toConsumableArray(_args));
|
|
427
|
-
case
|
|
445
|
+
case 12:
|
|
428
446
|
_context2.t1 = onBlur;
|
|
429
447
|
if (!_context2.t1) {
|
|
430
|
-
_context2.next =
|
|
448
|
+
_context2.next = 16;
|
|
431
449
|
break;
|
|
432
450
|
}
|
|
433
|
-
_context2.next =
|
|
451
|
+
_context2.next = 16;
|
|
434
452
|
return onBlur.apply(void 0, _toConsumableArray(_args));
|
|
435
|
-
case
|
|
453
|
+
case 16:
|
|
436
454
|
// 判断属性是否变动
|
|
437
455
|
form.setFieldValue(rowPath, row);
|
|
438
|
-
if (
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
456
|
+
if (validateTrigger && validateTrigger.includes('onBlur')) {
|
|
457
|
+
if (!isEqual(orgRow, row)) {
|
|
458
|
+
diff = difference(row, orgRow) || {};
|
|
459
|
+
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) {
|
|
460
|
+
return [].concat(_toConsumableArray(rowPath), [key]);
|
|
461
|
+
});
|
|
462
|
+
if (validateFieldKeys === null || validateFieldKeys === void 0 ? void 0 : validateFieldKeys.length) {
|
|
463
|
+
debounceValidate(validateFieldKeys);
|
|
464
|
+
}
|
|
445
465
|
}
|
|
446
466
|
}
|
|
447
467
|
if (!isCell) {
|
|
448
|
-
_context2.next =
|
|
468
|
+
_context2.next = 22;
|
|
449
469
|
break;
|
|
450
470
|
}
|
|
451
|
-
_context2.next =
|
|
471
|
+
_context2.next = 21;
|
|
452
472
|
return form.validateFields([cellName]);
|
|
453
|
-
case
|
|
473
|
+
case 21:
|
|
454
474
|
setState({
|
|
455
475
|
cellNamePath: []
|
|
456
476
|
});
|
|
457
|
-
case
|
|
477
|
+
case 22:
|
|
458
478
|
// 单行编辑时需要 强制更新视图
|
|
459
479
|
setState({
|
|
460
480
|
forceUpdate: {
|
|
461
481
|
d: Date.now()
|
|
462
482
|
}
|
|
463
483
|
});
|
|
464
|
-
case
|
|
484
|
+
case 23:
|
|
465
485
|
case "end":
|
|
466
486
|
return _context2.stop();
|
|
467
487
|
}
|