es-grid-template 1.1.8 → 1.2.1
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/assets/index.css +679 -0
- package/assets/index.scss +1006 -0
- package/es/grid-component/ColumnsChoose.d.ts +1 -0
- package/es/grid-component/ColumnsChoose.js +64 -29
- package/es/grid-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/es/grid-component/ColumnsGroup/ColumnsGroup.js +223 -0
- package/es/grid-component/ColumnsGroup/index.d.ts +1 -0
- package/es/grid-component/ColumnsGroup/index.js +1 -0
- package/es/grid-component/ConvertColumnTable.d.ts +7 -0
- package/es/grid-component/ConvertColumnTable.js +143 -0
- package/es/grid-component/EditableCell.js +1 -1
- package/es/grid-component/GridStyle.js +1 -1
- package/es/grid-component/InternalTable.js +148 -244
- package/es/grid-component/TableGrid.d.ts +7 -2
- package/es/grid-component/TableGrid.js +33 -55
- package/es/grid-component/hooks/{useColumns → columns}/index.d.ts +2 -2
- package/es/grid-component/hooks/{useColumns → columns}/index.js +20 -16
- package/es/grid-component/hooks/content/HeaderContent.d.ts +11 -0
- package/es/grid-component/hooks/content/HeaderContent.js +80 -0
- package/es/grid-component/hooks/content/TooltipContent.d.ts +13 -0
- package/es/grid-component/hooks/content/TooltipContent.js +74 -0
- package/es/grid-component/hooks/useColumns.d.ts +16 -0
- package/es/grid-component/hooks/useColumns.js +272 -0
- package/es/grid-component/hooks/utils.d.ts +50 -1
- package/es/grid-component/hooks/utils.js +782 -2
- package/es/grid-component/index.js +3 -1
- package/es/grid-component/styles.scss +354 -63
- package/es/grid-component/table/Grid.d.ts +5 -0
- package/es/grid-component/table/Grid.js +1 -7
- package/es/grid-component/table/GridEdit.d.ts +4 -1
- package/es/grid-component/table/GridEdit.js +768 -264
- package/es/grid-component/table/Group.d.ts +13 -0
- package/es/grid-component/table/Group.js +154 -0
- package/es/grid-component/type.d.ts +43 -2
- package/lib/grid-component/ColumnsChoose.d.ts +1 -0
- package/lib/grid-component/ColumnsChoose.js +63 -28
- package/lib/grid-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/lib/grid-component/ColumnsGroup/ColumnsGroup.js +234 -0
- package/lib/grid-component/ColumnsGroup/index.d.ts +1 -0
- package/lib/grid-component/ColumnsGroup/index.js +16 -0
- package/lib/grid-component/ConvertColumnTable.d.ts +7 -0
- package/lib/grid-component/ConvertColumnTable.js +152 -0
- package/lib/grid-component/EditableCell.js +1 -1
- package/lib/grid-component/GridStyle.js +1 -1
- package/lib/grid-component/InternalTable.js +142 -244
- package/lib/grid-component/TableGrid.d.ts +7 -2
- package/lib/grid-component/TableGrid.js +27 -53
- package/lib/grid-component/hooks/{useColumns → columns}/index.d.ts +2 -2
- package/lib/grid-component/hooks/{useColumns → columns}/index.js +20 -16
- package/lib/grid-component/hooks/content/HeaderContent.d.ts +11 -0
- package/lib/grid-component/hooks/content/HeaderContent.js +87 -0
- package/lib/grid-component/hooks/content/TooltipContent.d.ts +13 -0
- package/lib/grid-component/hooks/content/TooltipContent.js +81 -0
- package/lib/grid-component/hooks/useColumns.d.ts +16 -0
- package/lib/grid-component/hooks/useColumns.js +283 -0
- package/lib/grid-component/hooks/utils.d.ts +50 -1
- package/lib/grid-component/hooks/utils.js +809 -5
- package/lib/grid-component/index.js +2 -1
- package/lib/grid-component/styles.scss +354 -63
- package/lib/grid-component/table/Grid.d.ts +5 -0
- package/lib/grid-component/table/Grid.js +1 -7
- package/lib/grid-component/table/GridEdit.d.ts +4 -1
- package/lib/grid-component/table/GridEdit.js +764 -261
- package/lib/grid-component/table/Group.d.ts +13 -0
- package/lib/grid-component/table/Group.js +163 -0
- package/lib/grid-component/type.d.ts +43 -2
- package/package.json +106 -105
|
@@ -12,7 +12,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
12
12
|
var _antd = require("antd");
|
|
13
13
|
var _reactHookForm = require("react-hook-form");
|
|
14
14
|
var _reactHotToast = require("react-hot-toast");
|
|
15
|
-
var
|
|
15
|
+
var _columns = require("../hooks/columns");
|
|
16
16
|
var _EditableCell = _interopRequireDefault(require("../EditableCell"));
|
|
17
17
|
var _GridStyle = require("../GridStyle");
|
|
18
18
|
var _useContext = require("../useContext");
|
|
@@ -22,10 +22,14 @@ require("dayjs/locale/vi");
|
|
|
22
22
|
var _TableGrid = _interopRequireDefault(require("../TableGrid"));
|
|
23
23
|
var _hooks = require("../hooks");
|
|
24
24
|
var _Message = _interopRequireDefault(require("../../Message/Message"));
|
|
25
|
+
var _rcMasterUi = require("rc-master-ui");
|
|
26
|
+
var _useMergedState = _interopRequireDefault(require("rc-util/lib/hooks/useMergedState"));
|
|
25
27
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
26
28
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
27
29
|
// import Command from "../Command";
|
|
28
30
|
|
|
31
|
+
// import useLazyKVMap from "rc-master-ui/es/table/hooks/useLazyKVMap";
|
|
32
|
+
|
|
29
33
|
_dayjs.default.extend(_customParseFormat.default);
|
|
30
34
|
const toast = 'top-right';
|
|
31
35
|
const GridEdit = props => {
|
|
@@ -40,34 +44,268 @@ const GridEdit = props => {
|
|
|
40
44
|
selectionSettings,
|
|
41
45
|
height,
|
|
42
46
|
format,
|
|
43
|
-
// onDataChange,
|
|
44
47
|
triggerChangeData,
|
|
48
|
+
triggerChangeColumns,
|
|
45
49
|
onCellPaste,
|
|
46
50
|
onCellChange,
|
|
51
|
+
triggerPaste,
|
|
47
52
|
style,
|
|
48
53
|
getRowKey,
|
|
49
54
|
className,
|
|
55
|
+
toolbarItems,
|
|
56
|
+
defaultValue,
|
|
57
|
+
expandable,
|
|
58
|
+
onCellClick,
|
|
50
59
|
...rest
|
|
51
60
|
} = props;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
const {
|
|
62
|
+
mode,
|
|
63
|
+
type,
|
|
64
|
+
// checkboxOnly,
|
|
65
|
+
// hideSelectAll,
|
|
66
|
+
columnWidth
|
|
67
|
+
// selectedRowKeys,
|
|
68
|
+
// defaultSelectedRowKeys
|
|
69
|
+
} = selectionSettings || {};
|
|
56
70
|
const isSelecting = (0, _react.useRef)(false);
|
|
57
71
|
const startCell = (0, _react.useRef)(null);
|
|
72
|
+
const childrenColumnName = 'children';
|
|
58
73
|
const isSelectingRow = (0, _react.useRef)(false);
|
|
59
74
|
const rowStart = (0, _react.useRef)(null);
|
|
75
|
+
|
|
76
|
+
// const [getRecordByKey] = useLazyKVMap(dataSource, childrenColumnName, getRowKey);
|
|
77
|
+
|
|
78
|
+
const itemsAdd = [{
|
|
79
|
+
key: '10',
|
|
80
|
+
label: '10 rows'
|
|
81
|
+
}, {
|
|
82
|
+
key: '50',
|
|
83
|
+
label: '50 rows'
|
|
84
|
+
}, {
|
|
85
|
+
key: '100',
|
|
86
|
+
label: '100 rows'
|
|
87
|
+
}];
|
|
60
88
|
const [form] = _antd.Form.useForm();
|
|
61
89
|
const [editingKey, setEditingKey] = (0, _react.useState)('');
|
|
62
90
|
const [selectedCells, setSelectedCells] = (0, _react.useState)(new Set());
|
|
91
|
+
const [pasteCells, setPasteCells] = (0, _react.useState)(new Set());
|
|
92
|
+
const [isSelectDragging, setSelectIsDragging] = (0, _react.useState)(false);
|
|
93
|
+
const [isPasteDragging, setIsPasteDragging] = (0, _react.useState)(false);
|
|
94
|
+
|
|
95
|
+
// const [showDraggingPoint, setShowDraggingPoint] = useState(false);
|
|
96
|
+
|
|
63
97
|
const [rowsSelected, setRowsSelected] = (0, _react.useState)(new Set());
|
|
64
|
-
const [
|
|
98
|
+
const [startSelectedCells, setStartSelectedCell] = (0, _react.useState)(null);
|
|
99
|
+
const [innerExpandedKeys, setInnerExpandedKeys] = _react.default.useState(() => {
|
|
100
|
+
// if (defaultExpandedRowKeys) {
|
|
101
|
+
// return defaultExpandedRowKeys;
|
|
102
|
+
// }
|
|
103
|
+
// if (defaultExpandAllRows) {
|
|
104
|
+
return (0, _hooks.findAllChildrenKeys)(dataSource, getRowKey, childrenColumnName) ?? [];
|
|
105
|
+
// }
|
|
106
|
+
// return [];
|
|
107
|
+
});
|
|
108
|
+
const mergedExpandedKeys = _react.default.useMemo(() => new Set(innerExpandedKeys || []), [innerExpandedKeys]);
|
|
109
|
+
const [mergedSelectedKeys, setMergedSelectedKeys] = (0, _useMergedState.default)([], {
|
|
110
|
+
value: []
|
|
111
|
+
});
|
|
112
|
+
const rowsFocus = _react.default.useMemo(() => {
|
|
113
|
+
return [...new Set(Array.from(selectedCells).map(item => parseInt(item.split('-')[0])))] ?? [];
|
|
114
|
+
}, [selectedCells]);
|
|
115
|
+
const onTriggerExpand = _react.default.useCallback(record => {
|
|
116
|
+
const key = getRowKey(record, dataSource.indexOf(record));
|
|
117
|
+
let newExpandedKeys;
|
|
118
|
+
const hasKey = mergedExpandedKeys.has(key);
|
|
119
|
+
if (hasKey) {
|
|
120
|
+
mergedExpandedKeys.delete(key);
|
|
121
|
+
newExpandedKeys = [...mergedExpandedKeys];
|
|
122
|
+
} else {
|
|
123
|
+
newExpandedKeys = [...mergedExpandedKeys, key];
|
|
124
|
+
}
|
|
125
|
+
setInnerExpandedKeys(newExpandedKeys);
|
|
126
|
+
}, [getRowKey, mergedExpandedKeys, dataSource]);
|
|
127
|
+
const handleAddSingle = item => {
|
|
128
|
+
const defaultRowValue = (0, _hooks.getDefaultValue)(defaultValue);
|
|
129
|
+
const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : (0, _hooks.newGuid)();
|
|
130
|
+
if (item.onClick) {
|
|
131
|
+
item.onClick({
|
|
132
|
+
toolbar: item
|
|
133
|
+
});
|
|
134
|
+
} else {
|
|
135
|
+
const newData = [...dataSource, defaultValue ? {
|
|
136
|
+
...defaultRowValue,
|
|
137
|
+
id: undefined,
|
|
138
|
+
rowId
|
|
139
|
+
} : {
|
|
140
|
+
id: undefined,
|
|
141
|
+
rowId
|
|
142
|
+
}];
|
|
143
|
+
triggerChangeData?.(newData, 'Add');
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const handleAddMulti = (item, e) => {
|
|
147
|
+
if (item.onClick) {
|
|
148
|
+
item.onClick({
|
|
149
|
+
toolbar: item
|
|
150
|
+
});
|
|
151
|
+
} else {
|
|
152
|
+
const defaultRowValue = (0, _hooks.getDefaultValue)(defaultValue);
|
|
153
|
+
const newRows = Array.from({
|
|
154
|
+
length: Number(e.key)
|
|
155
|
+
}).map(() => defaultRowValue ? {
|
|
156
|
+
...defaultRowValue,
|
|
157
|
+
id: undefined,
|
|
158
|
+
rowId: (0, _hooks.newGuid)()
|
|
159
|
+
} : {
|
|
160
|
+
id: undefined,
|
|
161
|
+
rowId: (0, _hooks.newGuid)()
|
|
162
|
+
});
|
|
163
|
+
const newData = dataSource.concat(newRows);
|
|
164
|
+
triggerChangeData?.(newData, 'Add');
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
const handleDuplicate = () => {
|
|
168
|
+
console.log('rowsFocus', rowsFocus);
|
|
169
|
+
};
|
|
170
|
+
const handleInsertBefore = item => {
|
|
171
|
+
const defaultRowValue = (0, _hooks.getDefaultValue)(defaultValue);
|
|
172
|
+
const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : (0, _hooks.newGuid)();
|
|
173
|
+
const record = (0, _hooks.flattenData)(childrenColumnName, dataSource)[rowsFocus[rowsFocus.length - 1]];
|
|
174
|
+
if (item.onClick) {
|
|
175
|
+
item.onClick({
|
|
176
|
+
toolbar: item
|
|
177
|
+
});
|
|
178
|
+
} else {
|
|
179
|
+
if (!record.parentId) {
|
|
180
|
+
// Cập nhật data mới
|
|
181
|
+
const newData = [...dataSource];
|
|
182
|
+
const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
183
|
+
newData.splice(index, 0, {
|
|
184
|
+
...defaultRowValue,
|
|
185
|
+
rowId,
|
|
186
|
+
parentId: null
|
|
187
|
+
});
|
|
188
|
+
triggerChangeData?.(newData, 'INSERT_BEFORE');
|
|
189
|
+
} else {
|
|
190
|
+
const newData = [...dataSource];
|
|
191
|
+
const parent = (0, _hooks.findItemByKey)(newData, rowKey, record.parentId);
|
|
192
|
+
|
|
193
|
+
// Cập nhật childData mới
|
|
194
|
+
const childData = parent?.children ? [...parent.children] : [];
|
|
195
|
+
const index = childData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
196
|
+
childData.splice(index, 0, {
|
|
197
|
+
...defaultRowValue,
|
|
198
|
+
rowId,
|
|
199
|
+
parentId: record.parentId
|
|
200
|
+
});
|
|
201
|
+
const newRowData = {
|
|
202
|
+
...parent,
|
|
203
|
+
children: childData
|
|
204
|
+
};
|
|
205
|
+
const newDataSource = (0, _hooks.updateArrayByKey)(newData, newRowData, rowKey);
|
|
206
|
+
triggerChangeData?.(newDataSource, 'INSERT_BEFORE');
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
const handleInsertAfter = item => {
|
|
211
|
+
const defaultRowValue = (0, _hooks.getDefaultValue)(defaultValue);
|
|
212
|
+
const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : (0, _hooks.newGuid)();
|
|
213
|
+
const record = (0, _hooks.flattenData)(childrenColumnName, dataSource)[rowsFocus[rowsFocus.length - 1]];
|
|
214
|
+
|
|
215
|
+
// const record = getRecordByKey()
|
|
216
|
+
|
|
217
|
+
if (item.onClick) {
|
|
218
|
+
item.onClick({
|
|
219
|
+
toolbar: item
|
|
220
|
+
});
|
|
221
|
+
} else {
|
|
222
|
+
if (!record.parentId) {
|
|
223
|
+
// Cập nhật data mới
|
|
224
|
+
const newData = [...dataSource];
|
|
225
|
+
const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
226
|
+
newData.splice(index + 1, 0, {
|
|
227
|
+
...defaultRowValue,
|
|
228
|
+
rowId,
|
|
229
|
+
parentId: null
|
|
230
|
+
});
|
|
231
|
+
triggerChangeData?.(newData, 'INSERT_AFTER');
|
|
232
|
+
} else {
|
|
233
|
+
const newData = [...dataSource];
|
|
234
|
+
const parent = (0, _hooks.findItemByKey)(newData, rowKey, record.parentId);
|
|
235
|
+
|
|
236
|
+
// Cập nhật childData mới
|
|
237
|
+
const childData = parent?.children ? [...parent.children] : [];
|
|
238
|
+
const index = childData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
239
|
+
childData.splice(index + 1, 0, {
|
|
240
|
+
...defaultRowValue,
|
|
241
|
+
rowId,
|
|
242
|
+
parentId: record.parentId
|
|
243
|
+
});
|
|
244
|
+
const newRowData = {
|
|
245
|
+
...parent,
|
|
246
|
+
children: childData
|
|
247
|
+
};
|
|
248
|
+
const newDataSource = (0, _hooks.updateArrayByKey)(newData, newRowData, rowKey);
|
|
249
|
+
triggerChangeData?.(newDataSource, 'INSERT_BEFORE');
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
const handleDeleteAll = () => {};
|
|
254
|
+
const toolbarItemsBottom = (0, _react.useMemo)(() => {
|
|
255
|
+
return toolbarItems?.filter(it => it.position === 'Bottom').map(item => {
|
|
256
|
+
return {
|
|
257
|
+
...item,
|
|
258
|
+
template: () => {
|
|
259
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, item.key === 'ADD' && /*#__PURE__*/_react.default.createElement("div", {
|
|
260
|
+
className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
|
|
261
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Dropdown.Button, {
|
|
262
|
+
className: 'toolbar-button',
|
|
263
|
+
menu: {
|
|
264
|
+
items: itemsAdd,
|
|
265
|
+
onClick: e => handleAddMulti(item, e)
|
|
266
|
+
}
|
|
267
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
268
|
+
onClick: () => handleAddSingle(item)
|
|
269
|
+
}, item.title ? t ? t(item.title) : item.title : t ? t('Add item') : 'Add item'))), item.key === 'DUPLICATE' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
270
|
+
className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
|
|
271
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Button, {
|
|
272
|
+
color: "green",
|
|
273
|
+
variant: 'outlined',
|
|
274
|
+
onClick: handleDuplicate,
|
|
275
|
+
className: "d-flex toolbar-button"
|
|
276
|
+
}, item.title ? t ? t(item.title) : item.title : t ? t('Duplicate') : 'Duplicate')), item.key === 'INSERT_BEFORE' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
277
|
+
className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
|
|
278
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Button, {
|
|
279
|
+
color: "green",
|
|
280
|
+
variant: 'outlined',
|
|
281
|
+
onClick: () => handleInsertBefore(item),
|
|
282
|
+
className: "d-flex toolbar-button"
|
|
283
|
+
}, item.title ? t ? t(item.title) : item.title : t ? t('Insert item before') : 'Insert item before')), item.key === 'INSERT_AFTER' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
284
|
+
className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
|
|
285
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Button, {
|
|
286
|
+
color: "green",
|
|
287
|
+
variant: 'outlined',
|
|
288
|
+
onClick: () => handleInsertAfter(item),
|
|
289
|
+
className: "d-flex toolbar-button"
|
|
290
|
+
}, item.title ? t ? t(item.title) : item.title : t ? t('Insert item after') : 'Insert item after')), item.key === 'DELETE' && item.visible !== false && /*#__PURE__*/_react.default.createElement("div", {
|
|
291
|
+
className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
|
|
292
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Button, {
|
|
293
|
+
color: "primary",
|
|
294
|
+
variant: 'outlined',
|
|
295
|
+
onClick: handleDeleteAll,
|
|
296
|
+
className: "d-flex toolbar-button"
|
|
297
|
+
}, item.title ? t ? t(item.title) : item.title : t ? t('Delete all item') : 'Delete all item')));
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
});
|
|
301
|
+
}, [handleAddMulti, handleAddSingle, itemsAdd, rowsFocus.length, t, toolbarItems]);
|
|
65
302
|
const {
|
|
66
303
|
control,
|
|
67
304
|
handleSubmit,
|
|
68
305
|
setValue,
|
|
69
306
|
trigger,
|
|
70
|
-
getValues
|
|
307
|
+
getValues,
|
|
308
|
+
reset
|
|
71
309
|
// formState: { errors }
|
|
72
310
|
} = (0, _reactHookForm.useForm)({
|
|
73
311
|
mode: 'onChange'
|
|
@@ -79,13 +317,16 @@ const GridEdit = props => {
|
|
|
79
317
|
const isEditing = record => record[rowKey] === editingKey;
|
|
80
318
|
(0, _react.useEffect)(() => {
|
|
81
319
|
const handleClickOutside = event => {
|
|
82
|
-
const tableBodies = document.getElementsByClassName("ui-rc-table-tbody");
|
|
83
320
|
const element = event.target;
|
|
321
|
+
const tableBodies = document.getElementsByClassName("ui-rc-table-tbody");
|
|
84
322
|
const container = document.querySelector(".be-popup-container");
|
|
85
323
|
// const containerHidden = document.querySelector(".be-popup-container.ant-picker-dropdown-hidden")
|
|
86
324
|
|
|
325
|
+
// const toolbarContainer = document.getElementsByClassName("ui-rc-toolbar");
|
|
326
|
+
const itemContainer = document.querySelector(".ui-rc-toolbar-selection-overflow-item");
|
|
87
327
|
const isInsideContainer = element.closest(".be-popup-container") && container;
|
|
88
|
-
|
|
328
|
+
const isInsideToolbar = element.closest(".ui-rc-toolbar-selection-overflow-item") && itemContainer;
|
|
329
|
+
if (isInsideContainer || isInsideToolbar) {
|
|
89
330
|
return;
|
|
90
331
|
}
|
|
91
332
|
if (tableBodies.length > 0) {
|
|
@@ -93,9 +334,10 @@ const GridEdit = props => {
|
|
|
93
334
|
|
|
94
335
|
if (!tableBody.contains(event.target)) {
|
|
95
336
|
setEditingKey('');
|
|
96
|
-
|
|
97
|
-
|
|
337
|
+
isSelecting.current = false;
|
|
338
|
+
startCell.current = null;
|
|
98
339
|
setSelectedCells(new Set());
|
|
340
|
+
setRowsSelected(new Set());
|
|
99
341
|
} else {}
|
|
100
342
|
}
|
|
101
343
|
};
|
|
@@ -104,36 +346,170 @@ const GridEdit = props => {
|
|
|
104
346
|
document.removeEventListener("click", handleClickOutside);
|
|
105
347
|
};
|
|
106
348
|
}, []);
|
|
107
|
-
const handleMouseDown = (row, col, e) => {
|
|
349
|
+
const handleMouseDown = (record, row, col, e) => {
|
|
108
350
|
if (e.button === 2) {
|
|
109
351
|
e.stopPropagation();
|
|
110
352
|
return;
|
|
111
353
|
}
|
|
112
|
-
|
|
113
|
-
row,
|
|
114
|
-
col
|
|
115
|
-
});
|
|
354
|
+
setSelectIsDragging(true);
|
|
116
355
|
isSelecting.current = true;
|
|
117
356
|
startCell.current = {
|
|
118
357
|
row,
|
|
119
358
|
col
|
|
120
359
|
};
|
|
121
|
-
|
|
122
|
-
|
|
360
|
+
if (!isPasteDragging) {
|
|
361
|
+
setStartSelectedCell({
|
|
362
|
+
row,
|
|
363
|
+
col
|
|
364
|
+
});
|
|
365
|
+
setSelectedCells(new Set([`${row}-${col}`]));
|
|
366
|
+
setRowsSelected(new Set());
|
|
367
|
+
// setShowDraggingPoint(true)
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// if (record[rowKey] !== editingKey && (editingKey !== '')) {
|
|
371
|
+
// setEditingKey('')
|
|
372
|
+
// }
|
|
373
|
+
};
|
|
374
|
+
const handlePointEnter = e => {
|
|
375
|
+
if (e.button === 2) {
|
|
376
|
+
e.stopPropagation();
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
setIsPasteDragging(true);
|
|
380
|
+
};
|
|
381
|
+
const handlePointLeave = () => {
|
|
382
|
+
if (isPasteDragging && !isSelectDragging) {
|
|
383
|
+
setIsPasteDragging(false);
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
const handleMouseUp = () => {
|
|
387
|
+
isSelecting.current = false;
|
|
388
|
+
startCell.current = null;
|
|
389
|
+
isSelectingRow.current = false;
|
|
390
|
+
rowStart.current = null;
|
|
391
|
+
setIsPasteDragging(false);
|
|
392
|
+
setSelectIsDragging(false);
|
|
393
|
+
if (pasteCells.size > 0) {
|
|
394
|
+
console.log('');
|
|
395
|
+
const mergedSet = new Set([...selectedCells, ...pasteCells]);
|
|
396
|
+
setSelectedCells(mergedSet);
|
|
397
|
+
setPasteCells(new Set());
|
|
398
|
+
const selectedArray = Array.from(selectedCells).map(key => {
|
|
399
|
+
const [row, col] = key.split("-").map(Number);
|
|
400
|
+
// @ts-ignore
|
|
401
|
+
const columnKey = columns[col].field;
|
|
402
|
+
|
|
403
|
+
// @ts-ignore
|
|
404
|
+
return {
|
|
405
|
+
row,
|
|
406
|
+
col,
|
|
407
|
+
value: (0, _hooks.flattenData)(childrenColumnName, dataSource)[row][columnKey]
|
|
408
|
+
};
|
|
409
|
+
// return { row, col, value: '' };
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
// Xác định min/max row và col để sắp xếp dữ liệu
|
|
413
|
+
const minRow = Math.min(...selectedArray.map(cell => cell.row));
|
|
414
|
+
const maxRow = Math.max(...selectedArray.map(cell => cell.row));
|
|
415
|
+
const minCol = Math.min(...selectedArray.map(cell => cell.col));
|
|
416
|
+
const maxCol = Math.max(...selectedArray.map(cell => cell.col));
|
|
417
|
+
|
|
418
|
+
// Tạo dữ liệu dạng bảng (mảng 2D)
|
|
419
|
+
const table = Array.from({
|
|
420
|
+
length: maxRow - minRow + 1
|
|
421
|
+
}, () => Array(maxCol - minCol + 1).fill(""));
|
|
422
|
+
|
|
423
|
+
// Gán giá trị vào bảng
|
|
424
|
+
selectedArray.forEach(({
|
|
425
|
+
row,
|
|
426
|
+
col,
|
|
427
|
+
value
|
|
428
|
+
}) => {
|
|
429
|
+
table[row - minRow][col - minCol] = value;
|
|
430
|
+
});
|
|
431
|
+
const aaaa = (0, _hooks.addRows8)(table, (0, _hooks.getRowsPasteIndex)(pasteCells).length);
|
|
432
|
+
const record = (0, _hooks.flattenData)(childrenColumnName, dataSource)[(0, _hooks.getFirstSelectCell)(pasteCells).row];
|
|
433
|
+
if (!record.parentId) {
|
|
434
|
+
// Cập nhật data mới
|
|
435
|
+
const newData = [...dataSource];
|
|
436
|
+
|
|
437
|
+
// Lấy vị trí bắt đầu
|
|
438
|
+
// const { row: startRow, col: startCol } = selectedCell;
|
|
439
|
+
const startRow = (0, _hooks.getFirstSelectCell)(pasteCells).row;
|
|
440
|
+
const startCol = (0, _hooks.getFirstSelectCell)(selectedCells).col;
|
|
441
|
+
const pastedRows = [];
|
|
442
|
+
const pastedColumns = new Set();
|
|
443
|
+
aaaa.addedRows.forEach((rowValues, rowIndex) => {
|
|
444
|
+
const targetRow = startRow + rowIndex;
|
|
445
|
+
|
|
446
|
+
// Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
447
|
+
if (targetRow >= newData.length) {
|
|
448
|
+
// @ts-ignore
|
|
449
|
+
newData.push({
|
|
450
|
+
id: undefined,
|
|
451
|
+
rowId: (0, _hooks.newGuid)()
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
rowValues.forEach((cellValue, colIndex) => {
|
|
455
|
+
const targetCol = startCol + colIndex;
|
|
456
|
+
if (targetCol >= columns.length) {
|
|
457
|
+
// Không vượt quá số cột
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// @ts-ignore
|
|
462
|
+
const columnKey = columns[targetCol].field;
|
|
463
|
+
|
|
464
|
+
// @ts-ignore
|
|
465
|
+
newData[targetRow] = {
|
|
466
|
+
...newData[targetRow],
|
|
467
|
+
[columnKey]: typeof cellValue === 'string' ? cellValue.trim() : cellValue
|
|
468
|
+
};
|
|
469
|
+
pastedColumns.add(columnKey);
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
// Lưu dòng được paste
|
|
473
|
+
pastedRows.push(newData[targetRow]);
|
|
474
|
+
});
|
|
475
|
+
const pastedColumnsArray = Array.from(pastedColumns) ?? [];
|
|
476
|
+
triggerPaste?.(pastedRows, pastedColumnsArray, newData);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
123
479
|
};
|
|
124
480
|
const handleMouseEnter = (row, col) => {
|
|
125
|
-
if (!isSelecting.current || !startCell.current)
|
|
481
|
+
if (!isSelecting.current || !startCell.current) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
126
484
|
const {
|
|
127
485
|
row: startRow,
|
|
128
486
|
col: startCol
|
|
129
487
|
} = startCell.current;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
for (let
|
|
133
|
-
|
|
488
|
+
if (!isPasteDragging) {
|
|
489
|
+
const newSelectedCells = new Set();
|
|
490
|
+
for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
|
|
491
|
+
for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
|
|
492
|
+
newSelectedCells.add(`${r}-${c}`);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
setSelectedCells(newSelectedCells);
|
|
496
|
+
} else {
|
|
497
|
+
const newSelectedCells = new Set();
|
|
498
|
+
for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
|
|
499
|
+
for (let c = Math.min(startCol, col); c <= Math.max(startCol, col); c++) {
|
|
500
|
+
newSelectedCells.add(`${r}-${c}`);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
const colStart = (0, _hooks.getFirstSelectCell)(selectedCells).col;
|
|
504
|
+
const colEnd = (0, _hooks.getLastSelectCell)(selectedCells).col;
|
|
505
|
+
const newPasteCells = new Set();
|
|
506
|
+
for (let r = Math.min(startRow, row) + 1; r <= Math.max(startRow, row); r++) {
|
|
507
|
+
for (let c = Math.min(colStart, col); c <= Math.max(colStart, colEnd); c++) {
|
|
508
|
+
newPasteCells.add(`${r}-${c}`);
|
|
509
|
+
}
|
|
134
510
|
}
|
|
511
|
+
setPasteCells(newPasteCells);
|
|
135
512
|
}
|
|
136
|
-
setSelectedCells(newSelectedCells);
|
|
137
513
|
};
|
|
138
514
|
const handleClickRowHeader = (row, col) => {
|
|
139
515
|
const newSelectedCells = new Set();
|
|
@@ -202,23 +578,46 @@ const GridEdit = props => {
|
|
|
202
578
|
setRowsSelected(newSelectedRows);
|
|
203
579
|
setSelectedCells(newSelectedCells);
|
|
204
580
|
};
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
581
|
+
const handleCellClick = (indexRow, record, column) => {
|
|
582
|
+
const cellClickCallback = newOptions => {
|
|
583
|
+
if (newOptions) {
|
|
584
|
+
const newElem = {
|
|
585
|
+
...column,
|
|
586
|
+
editSelectSettings: {
|
|
587
|
+
...(column?.editSelectSettings ? {
|
|
588
|
+
...column?.editSelectSettings
|
|
589
|
+
} : {}),
|
|
590
|
+
options: newOptions
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
const rrr = (0, _hooks.updateArrayByKey)([...columns], newElem, 'field');
|
|
594
|
+
triggerChangeColumns?.(rrr, 'click');
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
if (onCellClick) {
|
|
598
|
+
onCellClick({
|
|
599
|
+
index: indexRow,
|
|
600
|
+
rowId: record.rowId,
|
|
601
|
+
cellValue: record[record.field],
|
|
602
|
+
type: "Editing",
|
|
603
|
+
field: column.field,
|
|
604
|
+
rowData: record
|
|
605
|
+
}, cellClickCallback);
|
|
606
|
+
}
|
|
210
607
|
};
|
|
211
608
|
const handleCopy = e => {
|
|
212
609
|
const selectedArray = Array.from(selectedCells).map(key => {
|
|
213
610
|
const [row, col] = key.split("-").map(Number);
|
|
214
611
|
// @ts-ignore
|
|
215
|
-
const columnKey = columns[col].
|
|
612
|
+
const columnKey = columns[col].field;
|
|
613
|
+
|
|
216
614
|
// @ts-ignore
|
|
217
615
|
return {
|
|
218
616
|
row,
|
|
219
617
|
col,
|
|
220
|
-
value: dataSource[row][columnKey]
|
|
618
|
+
value: (0, _hooks.flattenData)(childrenColumnName, dataSource)[row][columnKey]
|
|
221
619
|
};
|
|
620
|
+
// return { row, col, value: '' };
|
|
222
621
|
});
|
|
223
622
|
|
|
224
623
|
// Xác định min/max row và col để sắp xếp dữ liệu
|
|
@@ -249,133 +648,131 @@ const GridEdit = props => {
|
|
|
249
648
|
e.clipboardData.setData("text/plain", copyText);
|
|
250
649
|
(0, _Message.default)(t ? t('CopySuccessful') : 'Copy Successful');
|
|
251
650
|
};
|
|
252
|
-
const handlePaste = (
|
|
651
|
+
const handlePaste = (record, indexCol, rowNumber, e) => {
|
|
253
652
|
// const clipboard: any = (e.clipboardData || (window && window?.Clipboard)).getData("text")
|
|
254
653
|
const pasteData = e.clipboardData.getData("text/plain").trim();
|
|
255
654
|
|
|
256
655
|
// Chuyển đổi dữ liệu từ clipboard thành mảng
|
|
257
656
|
const rows = pasteData.split("\n").map(row => row.replace(/\r/g, "").split("\t"));
|
|
657
|
+
if (!record.parentId) {
|
|
658
|
+
// Cập nhật data mới
|
|
659
|
+
const newData = [...dataSource];
|
|
258
660
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
const startRow = indexRow;
|
|
262
|
-
const startCol = indexCol;
|
|
661
|
+
// @ts-ignore
|
|
662
|
+
const indexRows = newData.findIndex(it => it[rowKey] === record[rowKey]);
|
|
263
663
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
rows.forEach((rowValues, rowIndex) => {
|
|
269
|
-
const targetRow = startRow + rowIndex;
|
|
664
|
+
// Lấy vị trí bắt đầu
|
|
665
|
+
// const { row: startRow, col: startCol } = selectedCell;
|
|
666
|
+
const startRow = indexRows;
|
|
667
|
+
const startCol = indexCol;
|
|
270
668
|
|
|
271
|
-
//
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
669
|
+
// const flattData = flattenArray(newData);
|
|
670
|
+
|
|
671
|
+
const pastedRows = [];
|
|
672
|
+
const pastedColumns = new Set();
|
|
673
|
+
rows.forEach((rowValues, rowIndex) => {
|
|
674
|
+
const targetRow = startRow + rowIndex;
|
|
675
|
+
|
|
676
|
+
// Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
677
|
+
if (targetRow >= newData.length) {
|
|
678
|
+
// @ts-ignore
|
|
679
|
+
// newData.push({ id: newGuid()});
|
|
680
|
+
newData.push({
|
|
681
|
+
id: undefined,
|
|
682
|
+
rowId: (0, _hooks.newGuid)()
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
rowValues.forEach((cellValue, colIndex) => {
|
|
686
|
+
const targetCol = startCol + colIndex;
|
|
687
|
+
if (targetCol >= columns.length) {
|
|
688
|
+
// Không vượt quá số cột
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
// @ts-ignore
|
|
693
|
+
const columnKey = columns[targetCol].field;
|
|
694
|
+
|
|
695
|
+
// @ts-ignore
|
|
696
|
+
newData[targetRow] = {
|
|
697
|
+
...newData[targetRow],
|
|
698
|
+
[columnKey]: cellValue.trim()
|
|
699
|
+
};
|
|
700
|
+
pastedColumns.add(columnKey);
|
|
277
701
|
});
|
|
278
|
-
}
|
|
279
|
-
rowValues.forEach((cellValue, colIndex) => {
|
|
280
|
-
const targetCol = startCol + colIndex;
|
|
281
|
-
if (targetCol >= columns.length) return; // Không vượt quá số cột
|
|
282
702
|
|
|
283
|
-
//
|
|
284
|
-
|
|
285
|
-
// @ts-ignore
|
|
286
|
-
newData[targetRow] = {
|
|
287
|
-
...newData[targetRow],
|
|
288
|
-
[columnKey]: cellValue.trim()
|
|
289
|
-
};
|
|
290
|
-
pastedColumns.add(columnKey);
|
|
703
|
+
// Lưu dòng được paste
|
|
704
|
+
pastedRows.push(newData[targetRow]);
|
|
291
705
|
});
|
|
706
|
+
const pastedColumnsArray = Array.from(pastedColumns) ?? [];
|
|
707
|
+
triggerPaste?.(pastedRows, pastedColumnsArray, newData);
|
|
708
|
+
} else {
|
|
709
|
+
// Cập nhật data mới
|
|
710
|
+
const newData = [...dataSource];
|
|
711
|
+
const parent = (0, _hooks.findItemByKey)(newData, rowKey, record.parentId);
|
|
292
712
|
|
|
293
|
-
//
|
|
294
|
-
|
|
295
|
-
});
|
|
296
|
-
const pastedColumnsArray = Array.from(pastedColumns) ?? [];
|
|
297
|
-
console.log(pastedColumnsArray);
|
|
298
|
-
console.log(pastedRows);
|
|
713
|
+
// Cập nhật childData mới
|
|
714
|
+
const childData = parent?.children ? [...parent.children] : [];
|
|
299
715
|
|
|
300
|
-
|
|
716
|
+
// Lấy vị trí bắt đầu
|
|
717
|
+
// const { row: startRow, col: startCol } = selectedCell;
|
|
718
|
+
const startRow = childData.findIndex(it => it[rowKey] === record[rowKey]);
|
|
719
|
+
const startCol = indexCol;
|
|
720
|
+
const pastedRows = [];
|
|
721
|
+
const pastedColumns = new Set();
|
|
722
|
+
rows.forEach((rowValues, rowIndex) => {
|
|
723
|
+
const targetRow = startRow + rowIndex;
|
|
301
724
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
725
|
+
// Nếu vượt quá số dòng hiện có, thêm dòng mới
|
|
726
|
+
if (targetRow >= childData.length) {
|
|
727
|
+
childData.push({
|
|
728
|
+
id: undefined,
|
|
729
|
+
rowId: (0, _hooks.newGuid)(),
|
|
730
|
+
parentId: parent[rowKey ?? 'id']
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
rowValues.forEach((cellValue, colIndex) => {
|
|
734
|
+
const targetCol = startCol + colIndex;
|
|
735
|
+
if (targetCol >= columns.length) {
|
|
736
|
+
// Không vượt quá số cột
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
// @ts-ignore
|
|
741
|
+
const columnKey = columns[targetCol].field;
|
|
742
|
+
|
|
743
|
+
// @ts-ignore
|
|
744
|
+
childData[targetRow] = {
|
|
745
|
+
...childData[targetRow],
|
|
746
|
+
[columnKey]: cellValue.trim()
|
|
747
|
+
};
|
|
748
|
+
pastedColumns.add(columnKey);
|
|
749
|
+
});
|
|
750
|
+
|
|
751
|
+
// Lưu dòng được paste
|
|
752
|
+
pastedRows.push(childData[targetRow]);
|
|
753
|
+
});
|
|
754
|
+
const pastedColumnsArray = Array.from(pastedColumns) ?? [];
|
|
755
|
+
const newRowData = {
|
|
756
|
+
...parent,
|
|
757
|
+
children: childData
|
|
758
|
+
};
|
|
759
|
+
const newDataSource = (0, _hooks.updateArrayByKey)(newData, newRowData, rowKey);
|
|
760
|
+
triggerPaste?.(pastedRows, pastedColumnsArray, newDataSource);
|
|
761
|
+
}
|
|
337
762
|
};
|
|
338
763
|
const onSubmit = formData => {
|
|
339
|
-
console.log('onSubmit', formData);
|
|
340
764
|
try {
|
|
341
765
|
// const record = (await form.validateFields()) as RecordType;
|
|
342
766
|
const row = {
|
|
343
767
|
...formData
|
|
344
768
|
};
|
|
345
|
-
// const rowData = { ...record };
|
|
346
|
-
|
|
347
|
-
// columns.forEach(column => {
|
|
348
|
-
//
|
|
349
|
-
// // @ts-ignore
|
|
350
|
-
// if (column.editType === 'date' && rowData[column.dataIndex]) {
|
|
351
|
-
// // @ts-ignore
|
|
352
|
-
// rowData[column.dataIndex] = !isEmpty(record[column.dataIndex]) ? moment(row[column.dataIndex]).format() : null
|
|
353
|
-
// }
|
|
354
|
-
// });
|
|
355
|
-
|
|
356
769
|
const newData = [...dataSource];
|
|
770
|
+
|
|
357
771
|
// @ts-ignore
|
|
358
772
|
const index = newData.findIndex(item => formData[rowKey] === item[rowKey]);
|
|
359
|
-
|
|
360
|
-
// setIsManualUpdate(true);
|
|
361
|
-
|
|
773
|
+
const rs = (0, _hooks.updateArrayByKey)(dataSource, row, rowKey);
|
|
362
774
|
if (index > -1) {
|
|
363
|
-
|
|
364
|
-
newData.splice(index, 1, {
|
|
365
|
-
...item,
|
|
366
|
-
...row
|
|
367
|
-
});
|
|
368
|
-
triggerChangeData?.(newData, 'onChange');
|
|
369
|
-
|
|
370
|
-
// trigger DataChange
|
|
371
|
-
// setData(newData);
|
|
372
|
-
// onDataChange?.(newData)
|
|
373
|
-
} else {
|
|
374
|
-
newData.push(row);
|
|
375
|
-
// trigger DataChange
|
|
376
|
-
|
|
377
|
-
// setData(newData);
|
|
378
|
-
// onDataChange?.(newData)
|
|
775
|
+
triggerChangeData?.(rs, 'onChange');
|
|
379
776
|
}
|
|
380
777
|
} catch (errInfo) {
|
|
381
778
|
console.log('Validate Failed:', errInfo);
|
|
@@ -384,29 +781,18 @@ const GridEdit = props => {
|
|
|
384
781
|
const handleCellChange = args => {
|
|
385
782
|
const {
|
|
386
783
|
record,
|
|
387
|
-
type,
|
|
784
|
+
type: changeType,
|
|
388
785
|
newState,
|
|
389
786
|
prevState,
|
|
390
787
|
option,
|
|
391
788
|
field
|
|
392
789
|
} = args;
|
|
393
790
|
|
|
394
|
-
// console.log('newState', newState)
|
|
395
|
-
//
|
|
396
|
-
// console.log('getValues()', getValues())
|
|
397
|
-
|
|
398
791
|
// const newRecord = getValues()
|
|
399
792
|
|
|
400
|
-
if (
|
|
401
|
-
|
|
402
|
-
}
|
|
403
|
-
if (type === 'blur') {
|
|
404
|
-
// onCellChange
|
|
405
|
-
|
|
793
|
+
if (changeType === 'enter') {}
|
|
794
|
+
if (changeType === 'blur') {
|
|
406
795
|
const handleChangeCallback = callbackData => {
|
|
407
|
-
// const newDataUpdate = updateData(data, callbackData, rowKey as any)
|
|
408
|
-
|
|
409
|
-
console.log('callbackData', callbackData);
|
|
410
796
|
const callbackRecord = callbackData;
|
|
411
797
|
Object.entries(callbackRecord).forEach(([name, value]) => {
|
|
412
798
|
setValue(name, value);
|
|
@@ -415,7 +801,6 @@ const GridEdit = props => {
|
|
|
415
801
|
};
|
|
416
802
|
if (onCellChange) {
|
|
417
803
|
if (onCellChange.length > 1) {
|
|
418
|
-
console.log('onCellChange Callback');
|
|
419
804
|
onCellChange({
|
|
420
805
|
field,
|
|
421
806
|
indexCol: 1,
|
|
@@ -429,7 +814,6 @@ const GridEdit = props => {
|
|
|
429
814
|
sumValue: []
|
|
430
815
|
}, handleChangeCallback);
|
|
431
816
|
} else {
|
|
432
|
-
console.log('onCellChange');
|
|
433
817
|
onCellChange({
|
|
434
818
|
field,
|
|
435
819
|
indexCol: 1,
|
|
@@ -445,16 +829,15 @@ const GridEdit = props => {
|
|
|
445
829
|
onSubmit(record);
|
|
446
830
|
}
|
|
447
831
|
}
|
|
448
|
-
console.log('aaaaaa blur');
|
|
449
832
|
}
|
|
450
|
-
if (prevState && newState && prevState !== newState &&
|
|
451
|
-
console.log('enter');
|
|
833
|
+
if (prevState && newState && prevState !== newState && changeType === 'enter') {
|
|
452
834
|
onSubmit(record);
|
|
453
835
|
}
|
|
454
836
|
};
|
|
455
837
|
const handleEdit = (record, col, editType, e) => {
|
|
456
838
|
// @ts-ignore
|
|
457
839
|
setEditingKey(record[rowKey]);
|
|
840
|
+
reset();
|
|
458
841
|
|
|
459
842
|
// const formattedRecord = { ...record };
|
|
460
843
|
|
|
@@ -484,19 +867,20 @@ const GridEdit = props => {
|
|
|
484
867
|
// });
|
|
485
868
|
|
|
486
869
|
if (e.key === 'Enter' || editType === 'date' || e.type === 'dblclick') {} else {
|
|
487
|
-
setValue(col.dataIndex, e.key);
|
|
870
|
+
setValue(col.dataIndex, editType === 'numeric' ? !isNaN(Number(e.key)) ? Number(e.key) : '' : e.key);
|
|
871
|
+
// setValue(col.dataIndex, e.key)
|
|
488
872
|
}
|
|
489
873
|
if (editType === 'select') {
|
|
490
874
|
// setSearchValue(e.key)
|
|
491
875
|
// setOpen(true)
|
|
492
876
|
}
|
|
493
|
-
if (
|
|
877
|
+
if (startSelectedCells?.row !== undefined && startSelectedCells?.col !== undefined) {
|
|
494
878
|
setTimeout(() => {
|
|
495
879
|
// const input = document.querySelector(`.ui-rc-table-row[data-row-key="${selectedCell.row}"] .cell-editing[data-col-index="${selectedCell.col}"] input`) as HTMLInputElement;
|
|
496
|
-
const input = document.querySelector(`.ui-rc-table-row .cell-editing[data-row-index="${
|
|
880
|
+
const input = document.querySelector(`.ui-rc-table-row .cell-editing[data-row-index="${startSelectedCells.row}"].cell-editing[data-col-index="${startSelectedCells.col}"] input`);
|
|
497
881
|
// const input = document.getElementById(`col${selectedCell.col}-record${selectedCell.row}`) as HTMLInputElement;
|
|
498
882
|
|
|
499
|
-
const select = document.querySelector(`div.cell-editing[tabindex="${
|
|
883
|
+
const select = document.querySelector(`div.cell-editing[tabindex="${startSelectedCells?.col}"] .ant-select-selection-search input`);
|
|
500
884
|
if (input) {
|
|
501
885
|
input.focus();
|
|
502
886
|
}
|
|
@@ -509,18 +893,21 @@ const GridEdit = props => {
|
|
|
509
893
|
}, 0);
|
|
510
894
|
}
|
|
511
895
|
};
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
}
|
|
521
|
-
|
|
896
|
+
|
|
897
|
+
// useEffect(() => {
|
|
898
|
+
// const tableBody = document.querySelector(".ui-rc-table-tbody");
|
|
899
|
+
// const tableHeader = document.querySelector(".ui-rc-table-header");
|
|
900
|
+
//
|
|
901
|
+
// if (tableBody && tableHeader) {
|
|
902
|
+
// tableBody.addEventListener("scroll", () => {
|
|
903
|
+
// tableHeader.scrollLeft = tableBody.scrollLeft;
|
|
904
|
+
// });
|
|
905
|
+
// }
|
|
906
|
+
// }, []);
|
|
907
|
+
|
|
908
|
+
const scrollToCell = (rowIndex, colIndex, cell, scrollType) => {
|
|
522
909
|
const fixedWidth = (0, _hooks.totalFixedWidth)(columns, 'left', selectionSettings);
|
|
523
|
-
if (
|
|
910
|
+
if (scrollType === 'horizontal') {
|
|
524
911
|
if (tableRef.current) {
|
|
525
912
|
tableRef.current.scrollTo({
|
|
526
913
|
left: cell.offsetLeft - fixedWidth,
|
|
@@ -540,15 +927,12 @@ const GridEdit = props => {
|
|
|
540
927
|
});
|
|
541
928
|
}
|
|
542
929
|
};
|
|
543
|
-
const handleFocusCell = (rowIndex, colIndex, col,
|
|
930
|
+
const handleFocusCell = (rowIndex, colIndex, col, scrollType, e) => {
|
|
544
931
|
const isEdit = editingKey !== '';
|
|
545
|
-
// const cellEdit: any = document.querySelector(`.ui-rc-table-row[data-row-key="${rowIndex}"] .cell-editing[data-col-index="${colIndex}"]`);
|
|
546
|
-
// const cell: any = document.querySelector(`.ui-rc-table-row[data-row-key="${rowIndex}"] .cell-editable[data-col-index="${colIndex}"]`);
|
|
547
|
-
|
|
548
932
|
const cellEdit = document.querySelector(`.ui-rc-table-row .cell-editing[data-row-index="${rowIndex}"].cell-editing[data-col-index="${colIndex}"]`);
|
|
549
933
|
const cell = document.querySelector(`.ui-rc-table-row .cell-editable[data-row-index="${rowIndex}"].cell-editable[data-col-index="${colIndex}"]`);
|
|
550
934
|
const updateSelection = () => {
|
|
551
|
-
|
|
935
|
+
setStartSelectedCell({
|
|
552
936
|
row: rowIndex,
|
|
553
937
|
col: colIndex
|
|
554
938
|
});
|
|
@@ -561,10 +945,10 @@ const GridEdit = props => {
|
|
|
561
945
|
cellEdit.focus();
|
|
562
946
|
}
|
|
563
947
|
}
|
|
564
|
-
if (
|
|
948
|
+
if (scrollType === 'horizontal' && cellEdit) {
|
|
565
949
|
scrollToCell(rowIndex, colIndex, cellEdit, 'horizontal');
|
|
566
950
|
}
|
|
567
|
-
if (
|
|
951
|
+
if (scrollType === 'vertical' && cell) {
|
|
568
952
|
setEditingKey('');
|
|
569
953
|
updateSelection();
|
|
570
954
|
scrollToCell(rowIndex, colIndex, cellEdit, 'vertical');
|
|
@@ -580,11 +964,38 @@ const GridEdit = props => {
|
|
|
580
964
|
}
|
|
581
965
|
}
|
|
582
966
|
if (cell) {
|
|
583
|
-
scrollToCell(rowIndex, colIndex, cell,
|
|
967
|
+
scrollToCell(rowIndex, colIndex, cell, scrollType);
|
|
584
968
|
}
|
|
585
969
|
}
|
|
586
970
|
};
|
|
587
|
-
const
|
|
971
|
+
const getCellClass = (record, rowIndex, colIndex) => {
|
|
972
|
+
const cellKey = `${rowIndex}-${colIndex}`;
|
|
973
|
+
const topCellKey = `${rowIndex + 1}-${colIndex}`;
|
|
974
|
+
const leftCellKey = `${rowIndex}-${colIndex + 1}`;
|
|
975
|
+
const rightCellKey = `${rowIndex}-${colIndex - 1}`;
|
|
976
|
+
const isSelected = selectedCells.has(cellKey);
|
|
977
|
+
const isTopSelected = selectedCells.has(topCellKey);
|
|
978
|
+
const isLeftSelected = selectedCells.has(leftCellKey);
|
|
979
|
+
const isRightSelected = selectedCells.has(rightCellKey);
|
|
980
|
+
const cellClass = isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable';
|
|
981
|
+
const prevRecordEditing = (0, _hooks.flattenData)(childrenColumnName, dataSource)[rowIndex + 1];
|
|
982
|
+
const cellStart = (0, _hooks.getFirstSelectCell)(selectedCells);
|
|
983
|
+
const cellEnd = (0, _hooks.getLastSelectCell)(selectedCells);
|
|
984
|
+
if (!isSelected) {
|
|
985
|
+
const isTop = prevRecordEditing && !isEditing(prevRecordEditing) && rowIndex === Math.min(cellStart.row - 1, cellEnd?.row);
|
|
986
|
+
const isLeft = colIndex + 1 === Math.min(cellStart.col, cellEnd?.col);
|
|
987
|
+
const isRight = colIndex - 1 === Math.max(cellStart.col, cellEnd?.col);
|
|
988
|
+
return isTopSelected || isLeftSelected || isRightSelected ? `${cellClass} ${isTop ? `cell-border-top` : ''} ${isLeft ? `cell-border-left` : ''} ${isRight ? `next-cell-border-left` : ''}` : cellClass;
|
|
989
|
+
}
|
|
990
|
+
const isBottom = cellEnd && rowIndex === Math.max(cellStart.row, cellEnd.row);
|
|
991
|
+
const isRight = cellEnd && colIndex === Math.max(cellStart.col, cellEnd.col);
|
|
992
|
+
const isLeft = colIndex === Math.min(cellStart.col, cellEnd?.col);
|
|
993
|
+
|
|
994
|
+
// return `${cellClass} ${isBottom ? `cell-border-bottom` : ''} ${isRight ? `cell-border-right` : '' } ${isBottom && isRight ? `cell-border-end` : '' }
|
|
995
|
+
return `${cellClass} ${isBottom ? `cell-border-bottom` : ''} ${isRight ? `cell-border-right` : ''} ${isLeft ? `fixed-cell-border-left` : ''} ${isBottom && isRight ? `cell-border-end` : ''}
|
|
996
|
+
`;
|
|
997
|
+
};
|
|
998
|
+
const convertColumns = (0, _columns.flatColumns2)(columns).map((column, colIndex) => {
|
|
588
999
|
if (!column?.field && !column?.key) {
|
|
589
1000
|
return column;
|
|
590
1001
|
}
|
|
@@ -593,109 +1004,140 @@ const GridEdit = props => {
|
|
|
593
1004
|
...column,
|
|
594
1005
|
className: 'rc-ui-cell-editable',
|
|
595
1006
|
render: (value, record, rowIndex) => {
|
|
1007
|
+
const rowNumber = (0, _hooks.getRowNumber)(dataSource, record[rowKey], rowKey);
|
|
596
1008
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
597
1009
|
className: (0, _classnames.default)('ui-rc_cell-content ui-rc_cell-content--index', {
|
|
598
|
-
selected: rowsSelected.has(`${
|
|
599
|
-
focus: selectedCells && Array.from(selectedCells).some(item => item.startsWith(`${
|
|
1010
|
+
selected: rowsSelected.has(`${rowNumber}-${colIndex}`),
|
|
1011
|
+
focus: selectedCells && Array.from(selectedCells).some(item => item.startsWith(`${rowNumber}-`))
|
|
600
1012
|
}),
|
|
601
|
-
onMouseDown: event => handleMouseDownColIndex(
|
|
602
|
-
onMouseEnter: event => handleMouseEnterColIndex(
|
|
603
|
-
onClick: () => handleClickRowHeader(
|
|
1013
|
+
onMouseDown: event => handleMouseDownColIndex(rowNumber, colIndex, event),
|
|
1014
|
+
onMouseEnter: event => handleMouseEnterColIndex(rowNumber, colIndex, event),
|
|
1015
|
+
onClick: () => handleClickRowHeader(rowNumber, colIndex)
|
|
604
1016
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
605
1017
|
className: 'ui-rc_content'
|
|
606
1018
|
}, rowIndex + 1));
|
|
607
1019
|
}
|
|
608
1020
|
};
|
|
609
1021
|
}
|
|
1022
|
+
if ((column.key || column.field) === 'command') {
|
|
1023
|
+
return {
|
|
1024
|
+
...column
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
610
1027
|
return {
|
|
611
1028
|
...column,
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
1029
|
+
onCell: (record, rowIndex) => {
|
|
1030
|
+
const rowNumber = (0, _hooks.getRowNumber)(dataSource, record[rowKey], rowKey);
|
|
1031
|
+
return {
|
|
1032
|
+
onKeyDown: event => {
|
|
1033
|
+
const key = getRowKey(record, dataSource.indexOf(record));
|
|
1034
|
+
if (event.key.length === 1 && !event.ctrlKey && !event.metaKey || event.key === 'Enter') {
|
|
1035
|
+
if (!isEditing(record) && record[rowKey] !== editingKey) {
|
|
1036
|
+
handleEdit(record, column, column.editType, event);
|
|
1037
|
+
handleCellClick(rowNumber, record, column);
|
|
1038
|
+
const hasKey = mergedExpandedKeys.has(key);
|
|
1039
|
+
if (hasKey) {
|
|
1040
|
+
// mergedExpandedKeys.delete(key);
|
|
1041
|
+
// newExpandedKeys = [...mergedExpandedKeys];
|
|
1042
|
+
} else {
|
|
1043
|
+
onTriggerExpand(record);
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
if (editingKey && editingKey !== '' && (rowNumber ?? 0) + 1 < (0, _hooks.flattenArray)(dataSource).length && event.key === 'Enter') {
|
|
1047
|
+
handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event);
|
|
1048
|
+
}
|
|
618
1049
|
}
|
|
619
|
-
if (
|
|
620
|
-
|
|
1050
|
+
if (event.key === 'Tab') {
|
|
1051
|
+
if (colIndex + 1 !== columns.length) {
|
|
1052
|
+
handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
|
|
1053
|
+
} else {
|
|
1054
|
+
event.stopPropagation();
|
|
1055
|
+
event.preventDefault();
|
|
1056
|
+
}
|
|
621
1057
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
} else {
|
|
627
|
-
event.stopPropagation();
|
|
628
|
-
event.preventDefault();
|
|
1058
|
+
if (event.key === 'ArrowRight' && colIndex + 1 !== columns.length) {
|
|
1059
|
+
if (editingKey !== '') {} else {
|
|
1060
|
+
handleFocusCell(rowNumber, colIndex + 1, column, 'horizontal', event);
|
|
1061
|
+
}
|
|
629
1062
|
}
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
1063
|
+
if (event.key === 'ArrowLeft' && colIndex > 0) {
|
|
1064
|
+
if (!column.dataIndex && !column.key || column.field === 'index' || column.field === '#' || column.dataIndex === 'index' || column.dataIndex === '#') {
|
|
1065
|
+
event.stopPropagation();
|
|
1066
|
+
event.preventDefault();
|
|
1067
|
+
} else {
|
|
1068
|
+
if (editingKey !== '') {} else {
|
|
1069
|
+
handleFocusCell(rowNumber, colIndex - 1, column, 'horizontal', event);
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
634
1072
|
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
1073
|
+
if (event.key === 'ArrowDown' && (rowNumber ?? 0) + 1 < (0, _hooks.flattenArray)(dataSource).length) {
|
|
1074
|
+
handleFocusCell((rowNumber ?? 0) + 1, colIndex, column, 'vertical', event);
|
|
1075
|
+
}
|
|
1076
|
+
if (event.key === 'ArrowUp' && (rowNumber ?? 0) > 0) {
|
|
1077
|
+
handleFocusCell((rowNumber ?? 0) - 1, colIndex, column, 'vertical', event);
|
|
1078
|
+
}
|
|
1079
|
+
},
|
|
1080
|
+
onPaste: event => {
|
|
1081
|
+
if (editingKey === '') {
|
|
1082
|
+
handlePaste(record, colIndex, rowNumber, event);
|
|
639
1083
|
event.preventDefault();
|
|
640
|
-
} else {
|
|
641
|
-
if (editingKey !== '') {} else {
|
|
642
|
-
handleFocusCell(rowIndex, colIndex - 1, column, 'horizontal', event);
|
|
643
|
-
}
|
|
644
1084
|
}
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
dataIndex: column.dataIndex,
|
|
680
|
-
title: column.title,
|
|
681
|
-
'data-col-index': colIndex,
|
|
682
|
-
'data-row-index': rowIndex,
|
|
683
|
-
// colIndex: colIndex,
|
|
684
|
-
indexCol: colIndex,
|
|
685
|
-
indexRow: rowIndex,
|
|
686
|
-
editing: isEditing(record),
|
|
687
|
-
tabIndex: (rowIndex ?? 0) * columns.length + colIndex
|
|
688
|
-
}),
|
|
1085
|
+
},
|
|
1086
|
+
onCopy: e => {
|
|
1087
|
+
if (editingKey === '') {
|
|
1088
|
+
handleCopy(e);
|
|
1089
|
+
e.preventDefault();
|
|
1090
|
+
}
|
|
1091
|
+
},
|
|
1092
|
+
onDoubleClick: event => {
|
|
1093
|
+
if (!isEditing(record) && record[rowKey] !== editingKey) {
|
|
1094
|
+
handleEdit(record, column, (0, _hooks.getEditType)(column, record), event);
|
|
1095
|
+
handleCellClick(rowNumber, record, column);
|
|
1096
|
+
}
|
|
1097
|
+
},
|
|
1098
|
+
onClick: () => {
|
|
1099
|
+
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
1100
|
+
setEditingKey('');
|
|
1101
|
+
}
|
|
1102
|
+
},
|
|
1103
|
+
// className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable',
|
|
1104
|
+
className: getCellClass(record, rowNumber, colIndex),
|
|
1105
|
+
record,
|
|
1106
|
+
column: column,
|
|
1107
|
+
editType: (0, _hooks.getEditType)(column, record),
|
|
1108
|
+
dataIndex: column.dataIndex,
|
|
1109
|
+
title: (0, _columns.getValueCell)(column, record[column.field], format),
|
|
1110
|
+
'data-col-index': colIndex,
|
|
1111
|
+
'data-row-index': rowNumber,
|
|
1112
|
+
editing: isEditing(record),
|
|
1113
|
+
tabIndex: (rowIndex ?? 0) * columns.length + colIndex,
|
|
1114
|
+
style: isPasteDragging ? {
|
|
1115
|
+
cursor: "crosshair"
|
|
1116
|
+
} : {}
|
|
1117
|
+
};
|
|
1118
|
+
},
|
|
689
1119
|
render: (value, record, rowIndex) => {
|
|
1120
|
+
const rowNumber = (0, _hooks.getRowNumber)(dataSource, record[rowKey], rowKey);
|
|
690
1121
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
691
1122
|
className: (0, _classnames.default)('ui-rc_cell-content', {
|
|
692
|
-
selected: selectedCells.has(`${
|
|
1123
|
+
// selected: selectedCells.has(`${record[rowKey]}-${colIndex}`)
|
|
1124
|
+
selected: selectedCells.has(`${rowNumber}-${colIndex}`)
|
|
693
1125
|
}),
|
|
694
|
-
onMouseDown: event => handleMouseDown(
|
|
695
|
-
onMouseEnter: () => handleMouseEnter(
|
|
1126
|
+
onMouseDown: event => handleMouseDown(record, rowNumber, colIndex, event),
|
|
1127
|
+
onMouseEnter: () => handleMouseEnter(rowNumber, colIndex),
|
|
1128
|
+
onMouseUp: () => handleMouseUp()
|
|
696
1129
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
697
1130
|
className: 'ui-rc_content'
|
|
698
|
-
}, (0,
|
|
1131
|
+
}, (0, _columns.renderContent)(column, value, record, rowIndex, format)), (0, _hooks.getLastSelectCell)(selectedCells).row === rowNumber && (0, _hooks.getLastSelectCell)(selectedCells).col === colIndex && !isSelectDragging &&
|
|
1132
|
+
/*#__PURE__*/
|
|
1133
|
+
// showDraggingPoint &&
|
|
1134
|
+
_react.default.createElement("span", {
|
|
1135
|
+
className: 'dragging-point',
|
|
1136
|
+
onMouseEnter: event => handlePointEnter(event),
|
|
1137
|
+
onMouseLeave: () => handlePointLeave()
|
|
1138
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
1139
|
+
className: 'dot-point'
|
|
1140
|
+
})));
|
|
699
1141
|
}
|
|
700
1142
|
};
|
|
701
1143
|
});
|
|
@@ -722,6 +1164,26 @@ const GridEdit = props => {
|
|
|
722
1164
|
});
|
|
723
1165
|
}, [convertColumns]);
|
|
724
1166
|
const mergedColumns = _react.default.useMemo(() => transformColumns(columns ?? []), [transformColumns, columns]);
|
|
1167
|
+
const bottomToolbar = () => {
|
|
1168
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
1169
|
+
className: 'ui-rc-toolbar-bottom',
|
|
1170
|
+
style: {
|
|
1171
|
+
borderBottom: '1px solid #e0e0e0'
|
|
1172
|
+
}
|
|
1173
|
+
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar, {
|
|
1174
|
+
style: {
|
|
1175
|
+
width: '100%'
|
|
1176
|
+
},
|
|
1177
|
+
items: toolbarItemsBottom ?? [],
|
|
1178
|
+
mode: 'scroll'
|
|
1179
|
+
// onClick={({ item }) => {
|
|
1180
|
+
// console.log('item', item)
|
|
1181
|
+
// }}
|
|
1182
|
+
}));
|
|
1183
|
+
};
|
|
1184
|
+
const onSelectChange = keys => {
|
|
1185
|
+
setMergedSelectedKeys(keys);
|
|
1186
|
+
};
|
|
725
1187
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_GridStyle.GridStyle, {
|
|
726
1188
|
heightTable: height,
|
|
727
1189
|
style: {
|
|
@@ -753,20 +1215,61 @@ const GridEdit = props => {
|
|
|
753
1215
|
},
|
|
754
1216
|
className: (0, _classnames.default)(className, 'grid-editable'),
|
|
755
1217
|
rowKey: rowKey,
|
|
1218
|
+
getRowKey: getRowKey,
|
|
756
1219
|
columns: mergedColumns,
|
|
757
1220
|
showSorterTooltip: {
|
|
758
1221
|
target: 'sorter-icon'
|
|
759
1222
|
},
|
|
760
1223
|
format: format,
|
|
1224
|
+
toolbarItems: toolbarItems,
|
|
761
1225
|
selectionSettings: selectionSettings ? {
|
|
762
1226
|
...selectionSettings,
|
|
763
1227
|
checkboxOnly: true
|
|
764
1228
|
} : undefined,
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
1229
|
+
rowHoverable: false,
|
|
1230
|
+
bottomToolbar: bottomToolbar,
|
|
1231
|
+
expandable: {
|
|
1232
|
+
...expandable,
|
|
1233
|
+
expandedRowKeys: innerExpandedKeys,
|
|
1234
|
+
expandIcon: args => {
|
|
1235
|
+
const {
|
|
1236
|
+
record,
|
|
1237
|
+
expanded
|
|
1238
|
+
} = args;
|
|
1239
|
+
|
|
1240
|
+
// @ts-ignore
|
|
1241
|
+
if (record?.children?.length > 0 || record?.isChildren) {
|
|
1242
|
+
return expanded ? /*#__PURE__*/_react.default.createElement("button", {
|
|
1243
|
+
onClick: e => {
|
|
1244
|
+
e.preventDefault();
|
|
1245
|
+
e.stopPropagation();
|
|
1246
|
+
onTriggerExpand(record);
|
|
1247
|
+
// onExpand(record, e)
|
|
1248
|
+
},
|
|
1249
|
+
className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded'
|
|
1250
|
+
}) : /*#__PURE__*/_react.default.createElement("button", {
|
|
1251
|
+
onClick: e => {
|
|
1252
|
+
e.preventDefault();
|
|
1253
|
+
e.stopPropagation();
|
|
1254
|
+
onTriggerExpand(record);
|
|
1255
|
+
// onExpand(record, e)
|
|
1256
|
+
},
|
|
1257
|
+
className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed'
|
|
1258
|
+
});
|
|
1259
|
+
} else {
|
|
1260
|
+
return /*#__PURE__*/_react.default.createElement("button", {
|
|
1261
|
+
className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced'
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
768
1265
|
},
|
|
769
|
-
|
|
1266
|
+
rowSelection: columns && columns.length === 0 ? undefined : {
|
|
1267
|
+
type: mode === 'checkbox' || type === 'multiple' ? 'checkbox' : "radio",
|
|
1268
|
+
columnWidth: !mode ? 0.0000001 : columnWidth ?? 50,
|
|
1269
|
+
onChange: onSelectChange,
|
|
1270
|
+
selectedRowKeys: mergedSelectedKeys,
|
|
1271
|
+
preserveSelectedRowKeys: true
|
|
1272
|
+
}
|
|
770
1273
|
}))))), /*#__PURE__*/_react.default.createElement(_reactHotToast.Toaster, {
|
|
771
1274
|
position: toast,
|
|
772
1275
|
toastOptions: {
|