es-grid-template 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/grid-component/CheckboxFilter.js +4 -0
- package/es/grid-component/CheckboxFilter2.d.ts +20 -0
- package/es/grid-component/CheckboxFilter2.js +248 -0
- package/es/grid-component/ContextMenu.js +1 -0
- package/es/grid-component/InternalTable.js +37 -3
- package/es/grid-component/TableGrid.d.ts +3 -0
- package/es/grid-component/TableGrid.js +69 -7
- package/es/grid-component/hooks/columns/index.js +14 -45
- package/es/grid-component/hooks/content/HeaderContent.js +54 -58
- package/es/grid-component/hooks/useColumns.js +22 -8
- package/es/grid-component/hooks/utils.d.ts +8 -0
- package/es/grid-component/hooks/utils.js +257 -1
- package/es/grid-component/number-range/index.d.ts +10 -0
- package/es/grid-component/number-range/index.js +59 -0
- package/es/grid-component/table/Grid.d.ts +3 -0
- package/es/grid-component/table/GridEdit.js +281 -62
- package/es/grid-component/table/Group.d.ts +1 -0
- package/es/grid-component/table/Group.js +1 -1
- package/es/grid-component/type.d.ts +2 -1
- package/lib/grid-component/CheckboxFilter.js +4 -0
- package/lib/grid-component/CheckboxFilter2.d.ts +20 -0
- package/lib/grid-component/CheckboxFilter2.js +257 -0
- package/lib/grid-component/ContextMenu.js +1 -0
- package/lib/grid-component/InternalTable.js +31 -2
- package/lib/grid-component/TableGrid.d.ts +3 -0
- package/lib/grid-component/TableGrid.js +67 -7
- package/lib/grid-component/hooks/columns/index.js +14 -45
- package/lib/grid-component/hooks/content/HeaderContent.js +53 -55
- package/lib/grid-component/hooks/useColumns.js +22 -8
- package/lib/grid-component/hooks/utils.d.ts +8 -0
- package/lib/grid-component/hooks/utils.js +270 -3
- package/lib/grid-component/number-range/index.d.ts +10 -0
- package/lib/grid-component/number-range/index.js +67 -0
- package/lib/grid-component/table/Grid.d.ts +3 -0
- package/lib/grid-component/table/GridEdit.js +281 -62
- package/lib/grid-component/table/Group.d.ts +1 -0
- package/lib/grid-component/table/Group.js +1 -1
- package/lib/grid-component/type.d.ts +2 -1
- package/package.json +109 -108
|
@@ -20,6 +20,8 @@ import Message from "../../Message/Message";
|
|
|
20
20
|
import { Toolbar, ConfigProvider } from "rc-master-ui";
|
|
21
21
|
import classnames from "classnames";
|
|
22
22
|
import useMergedState from "rc-util/es/hooks/useMergedState";
|
|
23
|
+
import { Plus, Trash2 } from "becoxy-icons";
|
|
24
|
+
// import {ContextInfo, ContextMenuItem} from "../type";
|
|
23
25
|
// import useLazyKVMap from "rc-master-ui/es/table/hooks/useLazyKVMap";
|
|
24
26
|
|
|
25
27
|
dayjs.extend(customParseFormat);
|
|
@@ -82,6 +84,7 @@ const GridEdit = props => {
|
|
|
82
84
|
}];
|
|
83
85
|
const [form] = Form.useForm();
|
|
84
86
|
const [editingKey, setEditingKey] = useState('');
|
|
87
|
+
const [isFilter, setIsFilter] = React.useState(false);
|
|
85
88
|
const [selectedCells, setSelectedCells] = useState(new Set());
|
|
86
89
|
const [pasteCells, setPasteCells] = useState(new Set());
|
|
87
90
|
const [cellEditing, setCellEditing] = useState(null);
|
|
@@ -106,6 +109,33 @@ const GridEdit = props => {
|
|
|
106
109
|
const rowsFocus = React.useMemo(() => {
|
|
107
110
|
return [...new Set(Array.from(selectedCells).map(item => parseInt(item.split('-')[0])))] ?? [];
|
|
108
111
|
}, [selectedCells]);
|
|
112
|
+
const contextMenuItems = React.useMemo(() => {
|
|
113
|
+
return [{
|
|
114
|
+
key: 'INSERT_BEFORE',
|
|
115
|
+
label: 'Thêm dòng bên trên',
|
|
116
|
+
icon: /*#__PURE__*/React.createElement(Plus, {
|
|
117
|
+
fontSize: 14
|
|
118
|
+
})
|
|
119
|
+
}, {
|
|
120
|
+
key: 'INSERT_AFTER',
|
|
121
|
+
label: 'Thêm dòng bên dưới',
|
|
122
|
+
icon: /*#__PURE__*/React.createElement(Plus, {
|
|
123
|
+
fontSize: 14
|
|
124
|
+
})
|
|
125
|
+
}, {
|
|
126
|
+
key: 'DELETE_CONTENT',
|
|
127
|
+
label: 'Xóa nội dung',
|
|
128
|
+
icon: /*#__PURE__*/React.createElement(Trash2, {
|
|
129
|
+
fontSize: 14
|
|
130
|
+
})
|
|
131
|
+
}, {
|
|
132
|
+
key: 'DELETE_ROWS',
|
|
133
|
+
label: 'Xóa dòng',
|
|
134
|
+
icon: /*#__PURE__*/React.createElement(Trash2, {
|
|
135
|
+
fontSize: 14
|
|
136
|
+
})
|
|
137
|
+
}];
|
|
138
|
+
}, []);
|
|
109
139
|
const onTriggerExpand = React.useCallback(record => {
|
|
110
140
|
const key = getRowKey(record, dataSource.indexOf(record));
|
|
111
141
|
let newExpandedKeys;
|
|
@@ -175,9 +205,12 @@ const GridEdit = props => {
|
|
|
175
205
|
const rs = [...newData.slice(0, insertAfter + 1), ...duplicatedItems, ...newData.slice(insertAfter + 1)];
|
|
176
206
|
triggerChangeData?.(rs, 'DUPLICATE');
|
|
177
207
|
};
|
|
178
|
-
|
|
208
|
+
|
|
209
|
+
// thêm n dòng bên trên
|
|
210
|
+
const handleInsertBefore = (item, n) => {
|
|
179
211
|
const defaultRowValue = getDefaultValue(defaultValue);
|
|
180
|
-
const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : newGuid()
|
|
212
|
+
// const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : newGuid()
|
|
213
|
+
|
|
181
214
|
const record = flattenData(childrenColumnName, dataSource)[rowsFocus[rowsFocus.length - 1]];
|
|
182
215
|
if (item.onClick) {
|
|
183
216
|
item.onClick({
|
|
@@ -187,27 +220,55 @@ const GridEdit = props => {
|
|
|
187
220
|
if (!record?.parentId) {
|
|
188
221
|
// Cập nhật data mới
|
|
189
222
|
const newData = [...dataSource];
|
|
190
|
-
const
|
|
191
|
-
|
|
223
|
+
const newRows = Array.from({
|
|
224
|
+
length: n
|
|
225
|
+
}).map(() => defaultRowValue ? isFilter ? {
|
|
226
|
+
...defaultRowValue,
|
|
227
|
+
id: undefined,
|
|
228
|
+
rowId: newGuid(),
|
|
229
|
+
isFilterState: true
|
|
230
|
+
} : {
|
|
192
231
|
...defaultRowValue,
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
232
|
+
id: undefined,
|
|
233
|
+
rowId: newGuid()
|
|
234
|
+
} : isFilter ? {
|
|
235
|
+
id: undefined,
|
|
236
|
+
rowId: newGuid(),
|
|
237
|
+
isFilterState: true
|
|
238
|
+
} : {
|
|
239
|
+
id: undefined,
|
|
240
|
+
rowId: newGuid()
|
|
196
241
|
});
|
|
242
|
+
const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
243
|
+
newData.splice(index, 0, ...newRows);
|
|
197
244
|
triggerChangeData?.(newData, 'INSERT_BEFORE');
|
|
198
245
|
} else {
|
|
199
246
|
const newData = [...dataSource];
|
|
247
|
+
const newRows = Array.from({
|
|
248
|
+
length: n
|
|
249
|
+
}).map(() => defaultRowValue ? isFilter ? {
|
|
250
|
+
...defaultRowValue,
|
|
251
|
+
id: undefined,
|
|
252
|
+
rowId: newGuid(),
|
|
253
|
+
isFilterState: true
|
|
254
|
+
} : {
|
|
255
|
+
...defaultRowValue,
|
|
256
|
+
id: undefined,
|
|
257
|
+
rowId: newGuid()
|
|
258
|
+
} : isFilter ? {
|
|
259
|
+
id: undefined,
|
|
260
|
+
rowId: newGuid(),
|
|
261
|
+
isFilterState: true
|
|
262
|
+
} : {
|
|
263
|
+
id: undefined,
|
|
264
|
+
rowId: newGuid()
|
|
265
|
+
});
|
|
200
266
|
const parent = findItemByKey(newData, rowKey, record.parentId);
|
|
201
267
|
|
|
202
268
|
// Cập nhật childData mới
|
|
203
269
|
const childData = parent?.children ? [...parent.children] : [];
|
|
204
270
|
const index = childData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
205
|
-
childData.splice(index, 0,
|
|
206
|
-
...defaultRowValue,
|
|
207
|
-
rowId,
|
|
208
|
-
parentId: record.parentId,
|
|
209
|
-
id: undefined
|
|
210
|
-
});
|
|
271
|
+
childData.splice(index, 0, ...newRows);
|
|
211
272
|
const newRowData = {
|
|
212
273
|
...parent,
|
|
213
274
|
children: childData
|
|
@@ -217,9 +278,13 @@ const GridEdit = props => {
|
|
|
217
278
|
}
|
|
218
279
|
}
|
|
219
280
|
};
|
|
220
|
-
|
|
281
|
+
|
|
282
|
+
//thêm 1 dòng bên dưới
|
|
283
|
+
const handleInsertAfter = (item, n) => {
|
|
221
284
|
const defaultRowValue = getDefaultValue(defaultValue);
|
|
222
|
-
|
|
285
|
+
|
|
286
|
+
// const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : newGuid()
|
|
287
|
+
|
|
223
288
|
const record = flattenData(childrenColumnName, dataSource)[rowsFocus[rowsFocus.length - 1]];
|
|
224
289
|
|
|
225
290
|
// const record = getRecordByKey()
|
|
@@ -232,25 +297,57 @@ const GridEdit = props => {
|
|
|
232
297
|
if (!record?.parentId) {
|
|
233
298
|
// Cập nhật data mới
|
|
234
299
|
const newData = [...dataSource];
|
|
235
|
-
const
|
|
236
|
-
|
|
300
|
+
const newRows = Array.from({
|
|
301
|
+
length: n
|
|
302
|
+
}).map(() => defaultRowValue ? isFilter ? {
|
|
303
|
+
...defaultRowValue,
|
|
304
|
+
id: undefined,
|
|
305
|
+
rowId: newGuid(),
|
|
306
|
+
isFilterState: true
|
|
307
|
+
} : {
|
|
237
308
|
...defaultRowValue,
|
|
238
|
-
|
|
239
|
-
|
|
309
|
+
id: undefined,
|
|
310
|
+
rowId: newGuid()
|
|
311
|
+
} : isFilter ? {
|
|
312
|
+
id: undefined,
|
|
313
|
+
rowId: newGuid(),
|
|
314
|
+
isFilterState: true
|
|
315
|
+
} : {
|
|
316
|
+
id: undefined,
|
|
317
|
+
rowId: newGuid()
|
|
240
318
|
});
|
|
319
|
+
const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
320
|
+
|
|
321
|
+
// newData.splice(index + 1, 0, { ...defaultRowValue, rowId, parentId: null })
|
|
322
|
+
newData.splice(index + 1, 0, ...newRows);
|
|
241
323
|
triggerChangeData?.(newData, 'INSERT_AFTER');
|
|
242
324
|
} else {
|
|
243
325
|
const newData = [...dataSource];
|
|
326
|
+
const newRows = Array.from({
|
|
327
|
+
length: n
|
|
328
|
+
}).map(() => defaultRowValue ? isFilter ? {
|
|
329
|
+
...defaultRowValue,
|
|
330
|
+
id: undefined,
|
|
331
|
+
rowId: newGuid(),
|
|
332
|
+
isFilterState: true
|
|
333
|
+
} : {
|
|
334
|
+
...defaultRowValue,
|
|
335
|
+
id: undefined,
|
|
336
|
+
rowId: newGuid()
|
|
337
|
+
} : isFilter ? {
|
|
338
|
+
id: undefined,
|
|
339
|
+
rowId: newGuid(),
|
|
340
|
+
isFilterState: true
|
|
341
|
+
} : {
|
|
342
|
+
id: undefined,
|
|
343
|
+
rowId: newGuid()
|
|
344
|
+
});
|
|
244
345
|
const parent = findItemByKey(newData, rowKey, record.parentId);
|
|
245
346
|
|
|
246
347
|
// Cập nhật childData mới
|
|
247
348
|
const childData = parent?.children ? [...parent.children] : [];
|
|
248
349
|
const index = childData.findIndex(obj => obj[rowKey] === record[rowKey]);
|
|
249
|
-
childData.splice(index + 1, 0,
|
|
250
|
-
...defaultRowValue,
|
|
251
|
-
rowId,
|
|
252
|
-
parentId: record.parentId
|
|
253
|
-
});
|
|
350
|
+
childData.splice(index + 1, 0, ...newRows);
|
|
254
351
|
const newRowData = {
|
|
255
352
|
...parent,
|
|
256
353
|
children: childData
|
|
@@ -302,12 +399,49 @@ const GridEdit = props => {
|
|
|
302
399
|
setInnerExpandedKeys(newExpandedKeys);
|
|
303
400
|
}
|
|
304
401
|
};
|
|
402
|
+
const handleDeleteRows = item => {
|
|
403
|
+
if (item.onClick) {
|
|
404
|
+
item.onClick({
|
|
405
|
+
toolbar: item
|
|
406
|
+
});
|
|
407
|
+
} else {
|
|
408
|
+
const newData = [...dataSource];
|
|
409
|
+
const indexesToDelete = [...rowsFocus];
|
|
410
|
+
|
|
411
|
+
// Sắp xếp giảm dần để xóa từ cuối lên đầu
|
|
412
|
+
indexesToDelete.sort((a, b) => b - a).forEach(index => {
|
|
413
|
+
newData.splice(index, 1);
|
|
414
|
+
});
|
|
415
|
+
triggerChangeData?.([...newData], 'DELETE_ROWS');
|
|
416
|
+
}
|
|
417
|
+
};
|
|
305
418
|
const handleDeleteAll = () => {
|
|
306
419
|
triggerChangeData?.([], 'INSERT_BEFORE');
|
|
307
420
|
};
|
|
421
|
+
const handleDeleteContent = () => {
|
|
422
|
+
if (selectedCells.size > 0) {
|
|
423
|
+
const newData = [...dataSource];
|
|
424
|
+
|
|
425
|
+
// colIndex => field
|
|
426
|
+
const colIndexToField = flatColumns2(columns).map(col => col.field);
|
|
427
|
+
|
|
428
|
+
// Duyệt qua mỗi ô cần xóa
|
|
429
|
+
for (const cell of selectedCells) {
|
|
430
|
+
const [rowIndexStr, colIndexStr] = cell.split("-");
|
|
431
|
+
const rowIndex = Number(rowIndexStr);
|
|
432
|
+
const colIndex = Number(colIndexStr);
|
|
433
|
+
const field = colIndexToField[colIndex];
|
|
434
|
+
if (newData[rowIndex] && field && field in newData[rowIndex]) {
|
|
435
|
+
// @ts-ignore
|
|
436
|
+
newData[rowIndex][field] = '';
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
triggerChangeData?.([...newData], 'DELETE_CONTENT');
|
|
440
|
+
}
|
|
441
|
+
};
|
|
308
442
|
const toolbarItemsBottom = useMemo(() => {
|
|
309
443
|
if (!rowsFocus || rowsFocus.length === 0) {
|
|
310
|
-
return toolbarItems?.filter(it => it.position === 'Bottom' && it.visible !== false && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER' && it.key !== 'INSERT_CHILDREN').map(item => {
|
|
444
|
+
return toolbarItems?.filter(it => it.position === 'Bottom' && it.visible !== false && it.key !== 'DUPLICATE' && it.key !== 'INSERT_BEFORE' && it.key !== 'INSERT_AFTER' && it.key !== 'DELETE_ROWS' && it.key !== 'INSERT_CHILDREN').map(item => {
|
|
311
445
|
if (item.key === 'ADD') {
|
|
312
446
|
return {
|
|
313
447
|
...item,
|
|
@@ -315,6 +449,7 @@ const GridEdit = props => {
|
|
|
315
449
|
return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'ADD' && /*#__PURE__*/React.createElement("div", {
|
|
316
450
|
className: classnames(`be-toolbar-item`, item?.className)
|
|
317
451
|
}, /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
452
|
+
overlayClassName: 'be-popup-container',
|
|
318
453
|
style: {
|
|
319
454
|
color: '#28c76f',
|
|
320
455
|
borderColor: '#28c76f'
|
|
@@ -364,6 +499,7 @@ const GridEdit = props => {
|
|
|
364
499
|
return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'ADD' && /*#__PURE__*/React.createElement("div", {
|
|
365
500
|
className: classnames(`be-toolbar-item`, item?.className)
|
|
366
501
|
}, /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
502
|
+
overlayClassName: 'be-popup-container',
|
|
367
503
|
style: {
|
|
368
504
|
color: '#28c76f',
|
|
369
505
|
borderColor: '#28c76f'
|
|
@@ -404,17 +540,25 @@ const GridEdit = props => {
|
|
|
404
540
|
return {
|
|
405
541
|
...item,
|
|
406
542
|
template: () => {
|
|
407
|
-
return /*#__PURE__*/React.createElement(Fragment, null,
|
|
543
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
408
544
|
className: classnames(`be-toolbar-item`, item?.className)
|
|
409
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
545
|
+
}, /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
546
|
+
overlayClassName: 'be-popup-container',
|
|
410
547
|
style: {
|
|
411
548
|
color: '#28c76f',
|
|
412
549
|
borderColor: '#28c76f'
|
|
413
550
|
},
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
551
|
+
className: 'toolbar-button toolbar-dropdown-button',
|
|
552
|
+
menu: {
|
|
553
|
+
items: itemsAdd,
|
|
554
|
+
onClick: e => handleInsertBefore(item, Number(e.key))
|
|
555
|
+
}
|
|
556
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
557
|
+
style: {
|
|
558
|
+
color: '#28c76f'
|
|
559
|
+
},
|
|
560
|
+
onClick: () => handleInsertBefore(item, 1)
|
|
561
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Insert item before') : 'Insert item before'))));
|
|
418
562
|
}
|
|
419
563
|
};
|
|
420
564
|
}
|
|
@@ -422,17 +566,25 @@ const GridEdit = props => {
|
|
|
422
566
|
return {
|
|
423
567
|
...item,
|
|
424
568
|
template: () => {
|
|
425
|
-
return /*#__PURE__*/React.createElement(Fragment, null,
|
|
569
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
426
570
|
className: classnames(`be-toolbar-item`, item?.className)
|
|
427
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
571
|
+
}, /*#__PURE__*/React.createElement(Dropdown.Button, {
|
|
572
|
+
overlayClassName: 'be-popup-container',
|
|
428
573
|
style: {
|
|
429
574
|
color: '#28c76f',
|
|
430
575
|
borderColor: '#28c76f'
|
|
431
576
|
},
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
577
|
+
className: 'toolbar-button toolbar-dropdown-button',
|
|
578
|
+
menu: {
|
|
579
|
+
items: itemsAdd,
|
|
580
|
+
onClick: e => handleInsertAfter(item, Number(e.key))
|
|
581
|
+
}
|
|
582
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
583
|
+
style: {
|
|
584
|
+
color: '#28c76f'
|
|
585
|
+
},
|
|
586
|
+
onClick: () => handleInsertAfter(item, 1)
|
|
587
|
+
}, item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after'))));
|
|
436
588
|
}
|
|
437
589
|
};
|
|
438
590
|
}
|
|
@@ -472,6 +624,24 @@ const GridEdit = props => {
|
|
|
472
624
|
}
|
|
473
625
|
};
|
|
474
626
|
}
|
|
627
|
+
if (item.key === 'DELETE_ROWS') {
|
|
628
|
+
return {
|
|
629
|
+
...item,
|
|
630
|
+
template: () => {
|
|
631
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
632
|
+
className: classnames(`be-toolbar-item`, item?.className)
|
|
633
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
634
|
+
style: {
|
|
635
|
+
color: '#eb4619',
|
|
636
|
+
borderColor: '#eb4619'
|
|
637
|
+
},
|
|
638
|
+
variant: 'outlined',
|
|
639
|
+
onClick: () => handleDeleteRows(item),
|
|
640
|
+
className: "d-flex toolbar-button"
|
|
641
|
+
}, t ? `${t('Delete')} ${rowsFocus.length} ${t('row')}` : `Delete ${rowsFocus.length} item`));
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
}
|
|
475
645
|
return {
|
|
476
646
|
...item
|
|
477
647
|
};
|
|
@@ -505,15 +675,17 @@ const GridEdit = props => {
|
|
|
505
675
|
|
|
506
676
|
// const toolbarContainer = document.getElementsByClassName("ui-rc-toolbar");
|
|
507
677
|
const itemContainer = document.querySelector(`#${id} .ui-rc-toolbar-selection-overflow-item`);
|
|
678
|
+
const itemHeader = document.querySelector(`#${id} .ui-rc-table-thead`);
|
|
508
679
|
const isInsideContainer = element.closest(".be-popup-container") && container;
|
|
509
|
-
const isInsideToolbar = element.closest(
|
|
510
|
-
|
|
511
|
-
|
|
680
|
+
const isInsideToolbar = element.closest(`.ui-rc-toolbar-selection-overflow-item`) && itemContainer;
|
|
681
|
+
const isInsideHeader = itemHeader && itemHeader.contains(event.target);
|
|
682
|
+
if (isInsideContainer || isInsideToolbar || isInsideHeader) {
|
|
512
683
|
return;
|
|
513
684
|
}
|
|
514
685
|
|
|
515
686
|
// if (ref.current && !ref.current.contains(event.target)) {
|
|
516
687
|
// if (ref.current && tableId && !tableId.contains(event.target as Node)) {
|
|
688
|
+
|
|
517
689
|
if (ref.current && tableBody && !tableBody.contains(event.target)) {
|
|
518
690
|
setEditingKey('');
|
|
519
691
|
isSelecting.current = false;
|
|
@@ -784,25 +956,15 @@ const GridEdit = props => {
|
|
|
784
956
|
}
|
|
785
957
|
setSelectedCells(newSelectedCells);
|
|
786
958
|
};
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
// }
|
|
797
|
-
//
|
|
798
|
-
// // console.log('newSelectedCells', newSelectedCells)
|
|
799
|
-
// // setSelectedCells(newSelectedCells)
|
|
800
|
-
//
|
|
801
|
-
// setSelectedCells(new Set(newSelectedCells));
|
|
802
|
-
// // forceUpdate();
|
|
803
|
-
// setUpdateKey((prev) => prev + 1); // Cập nhật key để trigger re-render
|
|
804
|
-
// }
|
|
805
|
-
|
|
959
|
+
const handleClickColHeader = (column, indexColumn) => {
|
|
960
|
+
const newSelectedCells = new Set();
|
|
961
|
+
for (let r = Math.min(dataSource.length, 0); r <= Math.max(dataSource.length - 1, 0); r++) {
|
|
962
|
+
for (let c = Math.min(indexColumn, indexColumn); c <= Math.max(indexColumn, indexColumn); c++) {
|
|
963
|
+
newSelectedCells.add(`${r}-${c}`);
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
setSelectedCells(new Set(newSelectedCells));
|
|
967
|
+
};
|
|
806
968
|
const handleMouseDownColIndex = (row, col, e) => {
|
|
807
969
|
if (e.button === 2) {
|
|
808
970
|
e.stopPropagation();
|
|
@@ -835,7 +997,7 @@ const GridEdit = props => {
|
|
|
835
997
|
}
|
|
836
998
|
const newSelectedCells = new Set();
|
|
837
999
|
for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
|
|
838
|
-
for (let c = Math.min(columns.length, col) + 1; c <= Math.max(columns.length, col); c++) {
|
|
1000
|
+
for (let c = Math.min(editAbleColumns(columns).length, col) + 1; c <= Math.max(editAbleColumns(columns).length, col); c++) {
|
|
839
1001
|
newSelectedCells.add(`${r}-${c}`);
|
|
840
1002
|
}
|
|
841
1003
|
}
|
|
@@ -1406,6 +1568,9 @@ const GridEdit = props => {
|
|
|
1406
1568
|
if (event.key === 'ArrowUp' && (rowNumber ?? 0) > 0) {
|
|
1407
1569
|
handleFocusCell((rowNumber ?? 0) - 1, colIndex, column, 'vertical', event);
|
|
1408
1570
|
}
|
|
1571
|
+
if (event.key === 'Delete') {
|
|
1572
|
+
handleDeleteContent();
|
|
1573
|
+
}
|
|
1409
1574
|
},
|
|
1410
1575
|
onPaste: event => {
|
|
1411
1576
|
if (editingKey === '') {
|
|
@@ -1425,6 +1590,19 @@ const GridEdit = props => {
|
|
|
1425
1590
|
handleCellClick(rowNumber, record, column);
|
|
1426
1591
|
}
|
|
1427
1592
|
},
|
|
1593
|
+
onContextMenu: () => {
|
|
1594
|
+
// isSelecting.current = true;
|
|
1595
|
+
// startCell.current = { row: rowNumber, col: colIndex };
|
|
1596
|
+
|
|
1597
|
+
if (selectedCells.size === 0) {
|
|
1598
|
+
setStartSelectedCell({
|
|
1599
|
+
row: rowNumber,
|
|
1600
|
+
col: colIndex
|
|
1601
|
+
});
|
|
1602
|
+
setSelectedCells(new Set([`${rowNumber}-${colIndex}`]));
|
|
1603
|
+
setRowsSelected(new Set());
|
|
1604
|
+
}
|
|
1605
|
+
},
|
|
1428
1606
|
onClick: () => {
|
|
1429
1607
|
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
1430
1608
|
setEditingKey('');
|
|
@@ -1449,6 +1627,28 @@ const GridEdit = props => {
|
|
|
1449
1627
|
} : {}
|
|
1450
1628
|
};
|
|
1451
1629
|
},
|
|
1630
|
+
onHeaderCell: () => {
|
|
1631
|
+
return {
|
|
1632
|
+
onClick: () => {
|
|
1633
|
+
handleClickColHeader(column, colIndex);
|
|
1634
|
+
},
|
|
1635
|
+
onCopy: e => {
|
|
1636
|
+
if (editingKey === '') {
|
|
1637
|
+
handleCopy(e);
|
|
1638
|
+
e.preventDefault();
|
|
1639
|
+
}
|
|
1640
|
+
},
|
|
1641
|
+
onPaste: event => {
|
|
1642
|
+
if (editingKey === '') {
|
|
1643
|
+
handlePaste(dataSource[0], colIndex, 0, event);
|
|
1644
|
+
event.preventDefault();
|
|
1645
|
+
}
|
|
1646
|
+
},
|
|
1647
|
+
style: {
|
|
1648
|
+
userSelect: 'none'
|
|
1649
|
+
}
|
|
1650
|
+
};
|
|
1651
|
+
},
|
|
1452
1652
|
render: (value, record, rowIndex) => {
|
|
1453
1653
|
const rowNumber = getRowNumber(dataSource, record[rowKey], rowKey);
|
|
1454
1654
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -1462,7 +1662,7 @@ const GridEdit = props => {
|
|
|
1462
1662
|
onMouseUp: handleMouseUp
|
|
1463
1663
|
}, /*#__PURE__*/React.createElement("div", {
|
|
1464
1664
|
className: 'ui-rc_content'
|
|
1465
|
-
}, renderContent(column, value, record, rowIndex, format)), selectedCells && selectedCells.size > 0 && getLastSelectCell(selectedCells).row === rowNumber && getLastSelectCell(selectedCells).col === colIndex && isEditable(column, record) && !isSelectDragging &&
|
|
1665
|
+
}, renderContent(column, value, record, rowIndex, format)), selectedCells && selectedCells.size > 0 && getLastSelectCell(selectedCells).row === rowNumber && getLastSelectCell(selectedCells).col === colIndex && isEditable(column, record) && !isSelectDragging && rowIndex !== dataSource.length - 1 &&
|
|
1466
1666
|
/*#__PURE__*/
|
|
1467
1667
|
// showDraggingPoint &&
|
|
1468
1668
|
React.createElement("div", {
|
|
@@ -1523,6 +1723,20 @@ const GridEdit = props => {
|
|
|
1523
1723
|
const onSelectChange = keys => {
|
|
1524
1724
|
setMergedSelectedKeys(keys);
|
|
1525
1725
|
};
|
|
1726
|
+
const contextMenuClick = args => {
|
|
1727
|
+
if (args.item.key === 'INSERT_BEFORE') {
|
|
1728
|
+
handleInsertAfter(args.item, 1);
|
|
1729
|
+
}
|
|
1730
|
+
if (args.item.key === 'INSERT_AFTER') {
|
|
1731
|
+
handleInsertBefore(args.item, 1);
|
|
1732
|
+
}
|
|
1733
|
+
if (args.item.key === 'DELETE_ROWS') {
|
|
1734
|
+
handleDeleteRows(args.item);
|
|
1735
|
+
}
|
|
1736
|
+
if (args.item.key === 'DELETE_CONTENT') {
|
|
1737
|
+
handleDeleteContent();
|
|
1738
|
+
}
|
|
1739
|
+
};
|
|
1526
1740
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(GridStyle, {
|
|
1527
1741
|
heightTable: height,
|
|
1528
1742
|
style: {
|
|
@@ -1630,13 +1844,18 @@ const GridEdit = props => {
|
|
|
1630
1844
|
}
|
|
1631
1845
|
},
|
|
1632
1846
|
triggerChangeColumns: triggerChangeColumns,
|
|
1847
|
+
clickHeaderToSort: false,
|
|
1633
1848
|
rowSelection: columns && columns.length === 0 ? undefined : {
|
|
1634
1849
|
type: mode === 'checkbox' || type === 'multiple' ? 'checkbox' : "radio",
|
|
1635
1850
|
columnWidth: !mode ? 0.0000001 : columnWidth ?? 50,
|
|
1636
1851
|
onChange: onSelectChange,
|
|
1637
1852
|
selectedRowKeys: mergedSelectedKeys,
|
|
1638
1853
|
preserveSelectedRowKeys: true
|
|
1639
|
-
}
|
|
1854
|
+
},
|
|
1855
|
+
isFilter: isFilter,
|
|
1856
|
+
setIsFilter: setIsFilter,
|
|
1857
|
+
contextMenuItems: contextMenuItems,
|
|
1858
|
+
contextMenuClick: contextMenuClick
|
|
1640
1859
|
})))))), /*#__PURE__*/React.createElement(Toaster, {
|
|
1641
1860
|
position: toast,
|
|
1642
1861
|
toastOptions: {
|
|
@@ -8,6 +8,7 @@ type Props<T> = GridTableProps<T> & {
|
|
|
8
8
|
getRowKey: GetRowKey<T>;
|
|
9
9
|
triggerGroupColumns?: (groupedColumns: string[]) => void;
|
|
10
10
|
triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[]) => void;
|
|
11
|
+
triggerFilter?: (queries: any) => void;
|
|
11
12
|
};
|
|
12
13
|
declare const Group: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
|
|
13
14
|
export default Group;
|
|
@@ -67,7 +67,7 @@ const Group = props => {
|
|
|
67
67
|
gap: '10px',
|
|
68
68
|
marginRight: 10
|
|
69
69
|
}
|
|
70
|
-
}, /*#__PURE__*/React.createElement(ColumnsGroup, {
|
|
70
|
+
}, groupSetting?.showGroupIcon !== false && /*#__PURE__*/React.createElement(ColumnsGroup, {
|
|
71
71
|
t: t
|
|
72
72
|
// defaultGroupColumns={['name']}
|
|
73
73
|
,
|
|
@@ -18,7 +18,7 @@ export type ToolbarItem = Omit<RcToolbarItem, 'position' | 'align'> & {
|
|
|
18
18
|
align?: ITextAlign;
|
|
19
19
|
onClick?: (args: any) => void;
|
|
20
20
|
};
|
|
21
|
-
export type ContextMenuItem = ItemType
|
|
21
|
+
export type ContextMenuItem = ItemType;
|
|
22
22
|
export type ITemplateColumn = {
|
|
23
23
|
value: any;
|
|
24
24
|
column: any;
|
|
@@ -218,6 +218,7 @@ export type IGroupSetting = {
|
|
|
218
218
|
client?: boolean;
|
|
219
219
|
onGroup?: (props: IOnGroup) => void;
|
|
220
220
|
hiddenColumnGroup?: boolean;
|
|
221
|
+
showGroupIcon?: boolean;
|
|
221
222
|
unClearableLevel?: 1 | 2 | 3 | undefined;
|
|
222
223
|
};
|
|
223
224
|
type IOnGroup = {
|
|
@@ -88,6 +88,7 @@ const CheckboxFilter = props => {
|
|
|
88
88
|
|
|
89
89
|
// const [searchValue, setSearchValue] = React.useState('');
|
|
90
90
|
|
|
91
|
+
console.log('options', options);
|
|
91
92
|
const [openKeys, setOpenKeys] = React.useState([]);
|
|
92
93
|
|
|
93
94
|
// clear search value after close filter dropdown
|
|
@@ -180,6 +181,9 @@ const CheckboxFilter = props => {
|
|
|
180
181
|
onSelect?.(keys);
|
|
181
182
|
}
|
|
182
183
|
};
|
|
184
|
+
console.log('getTreeData({ filters: options })', getTreeData({
|
|
185
|
+
filters: options
|
|
186
|
+
}));
|
|
183
187
|
if (filterMode === 'tree') {
|
|
184
188
|
return /*#__PURE__*/React.createElement(React.Fragment, null, showFilter && /*#__PURE__*/React.createElement(_FilterSearch.default, {
|
|
185
189
|
filterSearch: filterSearch,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { TableLocale } from "rc-master-ui/es/table/interface";
|
|
3
|
+
type Props = {
|
|
4
|
+
options: any[];
|
|
5
|
+
filterSearch?: boolean;
|
|
6
|
+
open?: boolean;
|
|
7
|
+
tablePrefixCls?: string;
|
|
8
|
+
prefixCls?: string;
|
|
9
|
+
dropdownPrefixCls?: string;
|
|
10
|
+
filterMultiple: boolean;
|
|
11
|
+
showFilter?: boolean;
|
|
12
|
+
onSelect?: (value: any) => void;
|
|
13
|
+
selectedKeys: string[];
|
|
14
|
+
locale?: TableLocale;
|
|
15
|
+
filterMode?: 'menu' | 'tree';
|
|
16
|
+
searchValue: string;
|
|
17
|
+
setSearchValue: (value: any) => void;
|
|
18
|
+
};
|
|
19
|
+
declare const CheckboxFilter: (props: Props) => React.JSX.Element;
|
|
20
|
+
export default CheckboxFilter;
|