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