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.
Files changed (39) hide show
  1. package/es/grid-component/CheckboxFilter.js +4 -0
  2. package/es/grid-component/CheckboxFilter2.d.ts +20 -0
  3. package/es/grid-component/CheckboxFilter2.js +248 -0
  4. package/es/grid-component/ContextMenu.js +1 -0
  5. package/es/grid-component/InternalTable.js +37 -3
  6. package/es/grid-component/TableGrid.d.ts +3 -0
  7. package/es/grid-component/TableGrid.js +69 -7
  8. package/es/grid-component/hooks/columns/index.js +14 -45
  9. package/es/grid-component/hooks/content/HeaderContent.js +54 -58
  10. package/es/grid-component/hooks/useColumns.js +22 -8
  11. package/es/grid-component/hooks/utils.d.ts +8 -0
  12. package/es/grid-component/hooks/utils.js +257 -1
  13. package/es/grid-component/number-range/index.d.ts +10 -0
  14. package/es/grid-component/number-range/index.js +59 -0
  15. package/es/grid-component/table/Grid.d.ts +3 -0
  16. package/es/grid-component/table/GridEdit.js +281 -62
  17. package/es/grid-component/table/Group.d.ts +1 -0
  18. package/es/grid-component/table/Group.js +1 -1
  19. package/es/grid-component/type.d.ts +2 -1
  20. package/lib/grid-component/CheckboxFilter.js +4 -0
  21. package/lib/grid-component/CheckboxFilter2.d.ts +20 -0
  22. package/lib/grid-component/CheckboxFilter2.js +257 -0
  23. package/lib/grid-component/ContextMenu.js +1 -0
  24. package/lib/grid-component/InternalTable.js +31 -2
  25. package/lib/grid-component/TableGrid.d.ts +3 -0
  26. package/lib/grid-component/TableGrid.js +67 -7
  27. package/lib/grid-component/hooks/columns/index.js +14 -45
  28. package/lib/grid-component/hooks/content/HeaderContent.js +53 -55
  29. package/lib/grid-component/hooks/useColumns.js +22 -8
  30. package/lib/grid-component/hooks/utils.d.ts +8 -0
  31. package/lib/grid-component/hooks/utils.js +270 -3
  32. package/lib/grid-component/number-range/index.d.ts +10 -0
  33. package/lib/grid-component/number-range/index.js +67 -0
  34. package/lib/grid-component/table/Grid.d.ts +3 -0
  35. package/lib/grid-component/table/GridEdit.js +281 -62
  36. package/lib/grid-component/table/Group.d.ts +1 -0
  37. package/lib/grid-component/table/Group.js +1 -1
  38. package/lib/grid-component/type.d.ts +2 -1
  39. package/package.json +109 -108
@@ -24,10 +24,12 @@ var _hooks = require("../hooks");
24
24
  var _Message = _interopRequireDefault(require("../../Message/Message"));
25
25
  var _rcMasterUi = require("rc-master-ui");
26
26
  var _useMergedState = _interopRequireDefault(require("rc-util/lib/hooks/useMergedState"));
27
+ var _becoxyIcons = require("becoxy-icons");
27
28
  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); }
28
29
  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; }
29
30
  // import Command from "../Command";
30
31
 
32
+ // import {ContextInfo, ContextMenuItem} from "../type";
31
33
  // import useLazyKVMap from "rc-master-ui/es/table/hooks/useLazyKVMap";
32
34
 
33
35
  _dayjs.default.extend(_customParseFormat.default);
@@ -90,6 +92,7 @@ const GridEdit = props => {
90
92
  }];
91
93
  const [form] = _antd.Form.useForm();
92
94
  const [editingKey, setEditingKey] = (0, _react.useState)('');
95
+ const [isFilter, setIsFilter] = _react.default.useState(false);
93
96
  const [selectedCells, setSelectedCells] = (0, _react.useState)(new Set());
94
97
  const [pasteCells, setPasteCells] = (0, _react.useState)(new Set());
95
98
  const [cellEditing, setCellEditing] = (0, _react.useState)(null);
@@ -114,6 +117,33 @@ const GridEdit = props => {
114
117
  const rowsFocus = _react.default.useMemo(() => {
115
118
  return [...new Set(Array.from(selectedCells).map(item => parseInt(item.split('-')[0])))] ?? [];
116
119
  }, [selectedCells]);
120
+ const contextMenuItems = _react.default.useMemo(() => {
121
+ return [{
122
+ key: 'INSERT_BEFORE',
123
+ label: 'Thêm dòng bên trên',
124
+ icon: /*#__PURE__*/_react.default.createElement(_becoxyIcons.Plus, {
125
+ fontSize: 14
126
+ })
127
+ }, {
128
+ key: 'INSERT_AFTER',
129
+ label: 'Thêm dòng bên dưới',
130
+ icon: /*#__PURE__*/_react.default.createElement(_becoxyIcons.Plus, {
131
+ fontSize: 14
132
+ })
133
+ }, {
134
+ key: 'DELETE_CONTENT',
135
+ label: 'Xóa nội dung',
136
+ icon: /*#__PURE__*/_react.default.createElement(_becoxyIcons.Trash2, {
137
+ fontSize: 14
138
+ })
139
+ }, {
140
+ key: 'DELETE_ROWS',
141
+ label: 'Xóa dòng',
142
+ icon: /*#__PURE__*/_react.default.createElement(_becoxyIcons.Trash2, {
143
+ fontSize: 14
144
+ })
145
+ }];
146
+ }, []);
117
147
  const onTriggerExpand = _react.default.useCallback(record => {
118
148
  const key = getRowKey(record, dataSource.indexOf(record));
119
149
  let newExpandedKeys;
@@ -183,9 +213,12 @@ const GridEdit = props => {
183
213
  const rs = [...newData.slice(0, insertAfter + 1), ...duplicatedItems, ...newData.slice(insertAfter + 1)];
184
214
  triggerChangeData?.(rs, 'DUPLICATE');
185
215
  };
186
- const handleInsertBefore = item => {
216
+
217
+ // thêm n dòng bên trên
218
+ const handleInsertBefore = (item, n) => {
187
219
  const defaultRowValue = (0, _hooks.getDefaultValue)(defaultValue);
188
- const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : (0, _hooks.newGuid)();
220
+ // const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : newGuid()
221
+
189
222
  const record = (0, _hooks.flattenData)(childrenColumnName, dataSource)[rowsFocus[rowsFocus.length - 1]];
190
223
  if (item.onClick) {
191
224
  item.onClick({
@@ -195,27 +228,55 @@ const GridEdit = props => {
195
228
  if (!record?.parentId) {
196
229
  // Cập nhật data mới
197
230
  const newData = [...dataSource];
198
- const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
199
- newData.splice(index, 0, {
231
+ const newRows = Array.from({
232
+ length: n
233
+ }).map(() => defaultRowValue ? isFilter ? {
234
+ ...defaultRowValue,
235
+ id: undefined,
236
+ rowId: (0, _hooks.newGuid)(),
237
+ isFilterState: true
238
+ } : {
200
239
  ...defaultRowValue,
201
- rowId,
202
- parentId: null,
203
- id: undefined
240
+ id: undefined,
241
+ rowId: (0, _hooks.newGuid)()
242
+ } : isFilter ? {
243
+ id: undefined,
244
+ rowId: (0, _hooks.newGuid)(),
245
+ isFilterState: true
246
+ } : {
247
+ id: undefined,
248
+ rowId: (0, _hooks.newGuid)()
204
249
  });
250
+ const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
251
+ newData.splice(index, 0, ...newRows);
205
252
  triggerChangeData?.(newData, 'INSERT_BEFORE');
206
253
  } else {
207
254
  const newData = [...dataSource];
255
+ const newRows = Array.from({
256
+ length: n
257
+ }).map(() => defaultRowValue ? isFilter ? {
258
+ ...defaultRowValue,
259
+ id: undefined,
260
+ rowId: (0, _hooks.newGuid)(),
261
+ isFilterState: true
262
+ } : {
263
+ ...defaultRowValue,
264
+ id: undefined,
265
+ rowId: (0, _hooks.newGuid)()
266
+ } : isFilter ? {
267
+ id: undefined,
268
+ rowId: (0, _hooks.newGuid)(),
269
+ isFilterState: true
270
+ } : {
271
+ id: undefined,
272
+ rowId: (0, _hooks.newGuid)()
273
+ });
208
274
  const parent = (0, _hooks.findItemByKey)(newData, rowKey, record.parentId);
209
275
 
210
276
  // Cập nhật childData mới
211
277
  const childData = parent?.children ? [...parent.children] : [];
212
278
  const index = childData.findIndex(obj => obj[rowKey] === record[rowKey]);
213
- childData.splice(index, 0, {
214
- ...defaultRowValue,
215
- rowId,
216
- parentId: record.parentId,
217
- id: undefined
218
- });
279
+ childData.splice(index, 0, ...newRows);
219
280
  const newRowData = {
220
281
  ...parent,
221
282
  children: childData
@@ -225,9 +286,13 @@ const GridEdit = props => {
225
286
  }
226
287
  }
227
288
  };
228
- const handleInsertAfter = item => {
289
+
290
+ //thêm 1 dòng bên dưới
291
+ const handleInsertAfter = (item, n) => {
229
292
  const defaultRowValue = (0, _hooks.getDefaultValue)(defaultValue);
230
- const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : (0, _hooks.newGuid)();
293
+
294
+ // const rowId = defaultRowValue && defaultRowValue.id ? defaultRowValue.id : newGuid()
295
+
231
296
  const record = (0, _hooks.flattenData)(childrenColumnName, dataSource)[rowsFocus[rowsFocus.length - 1]];
232
297
 
233
298
  // const record = getRecordByKey()
@@ -240,25 +305,57 @@ const GridEdit = props => {
240
305
  if (!record?.parentId) {
241
306
  // Cập nhật data mới
242
307
  const newData = [...dataSource];
243
- const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
244
- newData.splice(index + 1, 0, {
308
+ const newRows = Array.from({
309
+ length: n
310
+ }).map(() => defaultRowValue ? isFilter ? {
311
+ ...defaultRowValue,
312
+ id: undefined,
313
+ rowId: (0, _hooks.newGuid)(),
314
+ isFilterState: true
315
+ } : {
245
316
  ...defaultRowValue,
246
- rowId,
247
- parentId: null
317
+ id: undefined,
318
+ rowId: (0, _hooks.newGuid)()
319
+ } : isFilter ? {
320
+ id: undefined,
321
+ rowId: (0, _hooks.newGuid)(),
322
+ isFilterState: true
323
+ } : {
324
+ id: undefined,
325
+ rowId: (0, _hooks.newGuid)()
248
326
  });
327
+ const index = newData.findIndex(obj => obj[rowKey] === record[rowKey]);
328
+
329
+ // newData.splice(index + 1, 0, { ...defaultRowValue, rowId, parentId: null })
330
+ newData.splice(index + 1, 0, ...newRows);
249
331
  triggerChangeData?.(newData, 'INSERT_AFTER');
250
332
  } else {
251
333
  const newData = [...dataSource];
334
+ const newRows = Array.from({
335
+ length: n
336
+ }).map(() => defaultRowValue ? isFilter ? {
337
+ ...defaultRowValue,
338
+ id: undefined,
339
+ rowId: (0, _hooks.newGuid)(),
340
+ isFilterState: true
341
+ } : {
342
+ ...defaultRowValue,
343
+ id: undefined,
344
+ rowId: (0, _hooks.newGuid)()
345
+ } : isFilter ? {
346
+ id: undefined,
347
+ rowId: (0, _hooks.newGuid)(),
348
+ isFilterState: true
349
+ } : {
350
+ id: undefined,
351
+ rowId: (0, _hooks.newGuid)()
352
+ });
252
353
  const parent = (0, _hooks.findItemByKey)(newData, rowKey, record.parentId);
253
354
 
254
355
  // Cập nhật childData mới
255
356
  const childData = parent?.children ? [...parent.children] : [];
256
357
  const index = childData.findIndex(obj => obj[rowKey] === record[rowKey]);
257
- childData.splice(index + 1, 0, {
258
- ...defaultRowValue,
259
- rowId,
260
- parentId: record.parentId
261
- });
358
+ childData.splice(index + 1, 0, ...newRows);
262
359
  const newRowData = {
263
360
  ...parent,
264
361
  children: childData
@@ -310,12 +407,49 @@ const GridEdit = props => {
310
407
  setInnerExpandedKeys(newExpandedKeys);
311
408
  }
312
409
  };
410
+ const handleDeleteRows = item => {
411
+ if (item.onClick) {
412
+ item.onClick({
413
+ toolbar: item
414
+ });
415
+ } else {
416
+ const newData = [...dataSource];
417
+ const indexesToDelete = [...rowsFocus];
418
+
419
+ // Sắp xếp giảm dần để xóa từ cuối lên đầu
420
+ indexesToDelete.sort((a, b) => b - a).forEach(index => {
421
+ newData.splice(index, 1);
422
+ });
423
+ triggerChangeData?.([...newData], 'DELETE_ROWS');
424
+ }
425
+ };
313
426
  const handleDeleteAll = () => {
314
427
  triggerChangeData?.([], 'INSERT_BEFORE');
315
428
  };
429
+ const handleDeleteContent = () => {
430
+ if (selectedCells.size > 0) {
431
+ const newData = [...dataSource];
432
+
433
+ // colIndex => field
434
+ const colIndexToField = (0, _columns.flatColumns2)(columns).map(col => col.field);
435
+
436
+ // Duyệt qua mỗi ô cần xóa
437
+ for (const cell of selectedCells) {
438
+ const [rowIndexStr, colIndexStr] = cell.split("-");
439
+ const rowIndex = Number(rowIndexStr);
440
+ const colIndex = Number(colIndexStr);
441
+ const field = colIndexToField[colIndex];
442
+ if (newData[rowIndex] && field && field in newData[rowIndex]) {
443
+ // @ts-ignore
444
+ newData[rowIndex][field] = '';
445
+ }
446
+ }
447
+ triggerChangeData?.([...newData], 'DELETE_CONTENT');
448
+ }
449
+ };
316
450
  const toolbarItemsBottom = (0, _react.useMemo)(() => {
317
451
  if (!rowsFocus || rowsFocus.length === 0) {
318
- 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 => {
452
+ 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 => {
319
453
  if (item.key === 'ADD') {
320
454
  return {
321
455
  ...item,
@@ -323,6 +457,7 @@ const GridEdit = props => {
323
457
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, item.key === 'ADD' && /*#__PURE__*/_react.default.createElement("div", {
324
458
  className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
325
459
  }, /*#__PURE__*/_react.default.createElement(_antd.Dropdown.Button, {
460
+ overlayClassName: 'be-popup-container',
326
461
  style: {
327
462
  color: '#28c76f',
328
463
  borderColor: '#28c76f'
@@ -372,6 +507,7 @@ const GridEdit = props => {
372
507
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, item.key === 'ADD' && /*#__PURE__*/_react.default.createElement("div", {
373
508
  className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
374
509
  }, /*#__PURE__*/_react.default.createElement(_antd.Dropdown.Button, {
510
+ overlayClassName: 'be-popup-container',
375
511
  style: {
376
512
  color: '#28c76f',
377
513
  borderColor: '#28c76f'
@@ -412,17 +548,25 @@ const GridEdit = props => {
412
548
  return {
413
549
  ...item,
414
550
  template: () => {
415
- return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, item.key === 'INSERT_BEFORE' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
551
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
416
552
  className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
417
- }, /*#__PURE__*/_react.default.createElement(_antd.Button, {
553
+ }, /*#__PURE__*/_react.default.createElement(_antd.Dropdown.Button, {
554
+ overlayClassName: 'be-popup-container',
418
555
  style: {
419
556
  color: '#28c76f',
420
557
  borderColor: '#28c76f'
421
558
  },
422
- variant: 'outlined',
423
- onClick: () => handleInsertBefore(item),
424
- className: "d-flex toolbar-button"
425
- }, item.label ? t ? t(item.label) : item.label : t ? t('Insert item before') : 'Insert item before')));
559
+ className: 'toolbar-button toolbar-dropdown-button',
560
+ menu: {
561
+ items: itemsAdd,
562
+ onClick: e => handleInsertBefore(item, Number(e.key))
563
+ }
564
+ }, /*#__PURE__*/_react.default.createElement("span", {
565
+ style: {
566
+ color: '#28c76f'
567
+ },
568
+ onClick: () => handleInsertBefore(item, 1)
569
+ }, item.label ? t ? t(item.label) : item.label : t ? t('Insert item before') : 'Insert item before'))));
426
570
  }
427
571
  };
428
572
  }
@@ -430,17 +574,25 @@ const GridEdit = props => {
430
574
  return {
431
575
  ...item,
432
576
  template: () => {
433
- return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, item.key === 'INSERT_AFTER' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
577
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
434
578
  className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
435
- }, /*#__PURE__*/_react.default.createElement(_antd.Button, {
579
+ }, /*#__PURE__*/_react.default.createElement(_antd.Dropdown.Button, {
580
+ overlayClassName: 'be-popup-container',
436
581
  style: {
437
582
  color: '#28c76f',
438
583
  borderColor: '#28c76f'
439
584
  },
440
- variant: 'outlined',
441
- onClick: () => handleInsertAfter(item),
442
- className: "d-flex toolbar-button"
443
- }, item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after')));
585
+ className: 'toolbar-button toolbar-dropdown-button',
586
+ menu: {
587
+ items: itemsAdd,
588
+ onClick: e => handleInsertAfter(item, Number(e.key))
589
+ }
590
+ }, /*#__PURE__*/_react.default.createElement("span", {
591
+ style: {
592
+ color: '#28c76f'
593
+ },
594
+ onClick: () => handleInsertAfter(item, 1)
595
+ }, item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after'))));
444
596
  }
445
597
  };
446
598
  }
@@ -480,6 +632,24 @@ const GridEdit = props => {
480
632
  }
481
633
  };
482
634
  }
635
+ if (item.key === 'DELETE_ROWS') {
636
+ return {
637
+ ...item,
638
+ template: () => {
639
+ return /*#__PURE__*/_react.default.createElement("div", {
640
+ className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
641
+ }, /*#__PURE__*/_react.default.createElement(_antd.Button, {
642
+ style: {
643
+ color: '#eb4619',
644
+ borderColor: '#eb4619'
645
+ },
646
+ variant: 'outlined',
647
+ onClick: () => handleDeleteRows(item),
648
+ className: "d-flex toolbar-button"
649
+ }, t ? `${t('Delete')} ${rowsFocus.length} ${t('row')}` : `Delete ${rowsFocus.length} item`));
650
+ }
651
+ };
652
+ }
483
653
  return {
484
654
  ...item
485
655
  };
@@ -513,15 +683,17 @@ const GridEdit = props => {
513
683
 
514
684
  // const toolbarContainer = document.getElementsByClassName("ui-rc-toolbar");
515
685
  const itemContainer = document.querySelector(`#${id} .ui-rc-toolbar-selection-overflow-item`);
686
+ const itemHeader = document.querySelector(`#${id} .ui-rc-table-thead`);
516
687
  const isInsideContainer = element.closest(".be-popup-container") && container;
517
- const isInsideToolbar = element.closest(`#${id} .ui-rc-toolbar-selection-overflow-item`) && itemContainer;
518
- if (isInsideContainer || isInsideToolbar) {
519
- // console.log('ooooooooooooo')
688
+ const isInsideToolbar = element.closest(`.ui-rc-toolbar-selection-overflow-item`) && itemContainer;
689
+ const isInsideHeader = itemHeader && itemHeader.contains(event.target);
690
+ if (isInsideContainer || isInsideToolbar || isInsideHeader) {
520
691
  return;
521
692
  }
522
693
 
523
694
  // if (ref.current && !ref.current.contains(event.target)) {
524
695
  // if (ref.current && tableId && !tableId.contains(event.target as Node)) {
696
+
525
697
  if (ref.current && tableBody && !tableBody.contains(event.target)) {
526
698
  setEditingKey('');
527
699
  isSelecting.current = false;
@@ -792,25 +964,15 @@ const GridEdit = props => {
792
964
  }
793
965
  setSelectedCells(newSelectedCells);
794
966
  };
795
-
796
- // const handleClickColHeader = (column: ColumnTable, indexColumn: number) => {
797
- //
798
- // const newSelectedCells = new Set();
799
- //
800
- // for (let r = Math.min(dataSource.length, 0); r <= Math.max(dataSource.length - 1, 0); r++) {
801
- // for (let c = Math.min(indexColumn, indexColumn); c <= Math.max(indexColumn, indexColumn); c++) {
802
- // newSelectedCells.add(`${r}-${c}`)
803
- // }
804
- // }
805
- //
806
- // // console.log('newSelectedCells', newSelectedCells)
807
- // // setSelectedCells(newSelectedCells)
808
- //
809
- // setSelectedCells(new Set(newSelectedCells));
810
- // // forceUpdate();
811
- // setUpdateKey((prev) => prev + 1); // Cập nhật key để trigger re-render
812
- // }
813
-
967
+ const handleClickColHeader = (column, indexColumn) => {
968
+ const newSelectedCells = new Set();
969
+ for (let r = Math.min(dataSource.length, 0); r <= Math.max(dataSource.length - 1, 0); r++) {
970
+ for (let c = Math.min(indexColumn, indexColumn); c <= Math.max(indexColumn, indexColumn); c++) {
971
+ newSelectedCells.add(`${r}-${c}`);
972
+ }
973
+ }
974
+ setSelectedCells(new Set(newSelectedCells));
975
+ };
814
976
  const handleMouseDownColIndex = (row, col, e) => {
815
977
  if (e.button === 2) {
816
978
  e.stopPropagation();
@@ -843,7 +1005,7 @@ const GridEdit = props => {
843
1005
  }
844
1006
  const newSelectedCells = new Set();
845
1007
  for (let r = Math.min(startRow, row); r <= Math.max(startRow, row); r++) {
846
- for (let c = Math.min(columns.length, col) + 1; c <= Math.max(columns.length, col); c++) {
1008
+ for (let c = Math.min((0, _hooks.editAbleColumns)(columns).length, col) + 1; c <= Math.max((0, _hooks.editAbleColumns)(columns).length, col); c++) {
847
1009
  newSelectedCells.add(`${r}-${c}`);
848
1010
  }
849
1011
  }
@@ -1414,6 +1576,9 @@ const GridEdit = props => {
1414
1576
  if (event.key === 'ArrowUp' && (rowNumber ?? 0) > 0) {
1415
1577
  handleFocusCell((rowNumber ?? 0) - 1, colIndex, column, 'vertical', event);
1416
1578
  }
1579
+ if (event.key === 'Delete') {
1580
+ handleDeleteContent();
1581
+ }
1417
1582
  },
1418
1583
  onPaste: event => {
1419
1584
  if (editingKey === '') {
@@ -1433,6 +1598,19 @@ const GridEdit = props => {
1433
1598
  handleCellClick(rowNumber, record, column);
1434
1599
  }
1435
1600
  },
1601
+ onContextMenu: () => {
1602
+ // isSelecting.current = true;
1603
+ // startCell.current = { row: rowNumber, col: colIndex };
1604
+
1605
+ if (selectedCells.size === 0) {
1606
+ setStartSelectedCell({
1607
+ row: rowNumber,
1608
+ col: colIndex
1609
+ });
1610
+ setSelectedCells(new Set([`${rowNumber}-${colIndex}`]));
1611
+ setRowsSelected(new Set());
1612
+ }
1613
+ },
1436
1614
  onClick: () => {
1437
1615
  if (record[rowKey] !== editingKey && editingKey !== '') {
1438
1616
  setEditingKey('');
@@ -1457,6 +1635,28 @@ const GridEdit = props => {
1457
1635
  } : {}
1458
1636
  };
1459
1637
  },
1638
+ onHeaderCell: () => {
1639
+ return {
1640
+ onClick: () => {
1641
+ handleClickColHeader(column, colIndex);
1642
+ },
1643
+ onCopy: e => {
1644
+ if (editingKey === '') {
1645
+ handleCopy(e);
1646
+ e.preventDefault();
1647
+ }
1648
+ },
1649
+ onPaste: event => {
1650
+ if (editingKey === '') {
1651
+ handlePaste(dataSource[0], colIndex, 0, event);
1652
+ event.preventDefault();
1653
+ }
1654
+ },
1655
+ style: {
1656
+ userSelect: 'none'
1657
+ }
1658
+ };
1659
+ },
1460
1660
  render: (value, record, rowIndex) => {
1461
1661
  const rowNumber = (0, _hooks.getRowNumber)(dataSource, record[rowKey], rowKey);
1462
1662
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -1470,7 +1670,7 @@ const GridEdit = props => {
1470
1670
  onMouseUp: handleMouseUp
1471
1671
  }, /*#__PURE__*/_react.default.createElement("div", {
1472
1672
  className: 'ui-rc_content'
1473
- }, (0, _columns.renderContent)(column, value, record, rowIndex, format)), selectedCells && selectedCells.size > 0 && (0, _hooks.getLastSelectCell)(selectedCells).row === rowNumber && (0, _hooks.getLastSelectCell)(selectedCells).col === colIndex && (0, _hooks.isEditable)(column, record) && !isSelectDragging &&
1673
+ }, (0, _columns.renderContent)(column, value, record, rowIndex, format)), selectedCells && selectedCells.size > 0 && (0, _hooks.getLastSelectCell)(selectedCells).row === rowNumber && (0, _hooks.getLastSelectCell)(selectedCells).col === colIndex && (0, _hooks.isEditable)(column, record) && !isSelectDragging && rowIndex !== dataSource.length - 1 &&
1474
1674
  /*#__PURE__*/
1475
1675
  // showDraggingPoint &&
1476
1676
  _react.default.createElement("div", {
@@ -1531,6 +1731,20 @@ const GridEdit = props => {
1531
1731
  const onSelectChange = keys => {
1532
1732
  setMergedSelectedKeys(keys);
1533
1733
  };
1734
+ const contextMenuClick = args => {
1735
+ if (args.item.key === 'INSERT_BEFORE') {
1736
+ handleInsertAfter(args.item, 1);
1737
+ }
1738
+ if (args.item.key === 'INSERT_AFTER') {
1739
+ handleInsertBefore(args.item, 1);
1740
+ }
1741
+ if (args.item.key === 'DELETE_ROWS') {
1742
+ handleDeleteRows(args.item);
1743
+ }
1744
+ if (args.item.key === 'DELETE_CONTENT') {
1745
+ handleDeleteContent();
1746
+ }
1747
+ };
1534
1748
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_GridStyle.GridStyle, {
1535
1749
  heightTable: height,
1536
1750
  style: {
@@ -1638,13 +1852,18 @@ const GridEdit = props => {
1638
1852
  }
1639
1853
  },
1640
1854
  triggerChangeColumns: triggerChangeColumns,
1855
+ clickHeaderToSort: false,
1641
1856
  rowSelection: columns && columns.length === 0 ? undefined : {
1642
1857
  type: mode === 'checkbox' || type === 'multiple' ? 'checkbox' : "radio",
1643
1858
  columnWidth: !mode ? 0.0000001 : columnWidth ?? 50,
1644
1859
  onChange: onSelectChange,
1645
1860
  selectedRowKeys: mergedSelectedKeys,
1646
1861
  preserveSelectedRowKeys: true
1647
- }
1862
+ },
1863
+ isFilter: isFilter,
1864
+ setIsFilter: setIsFilter,
1865
+ contextMenuItems: contextMenuItems,
1866
+ contextMenuClick: contextMenuClick
1648
1867
  })))))), /*#__PURE__*/_react.default.createElement(_reactHotToast.Toaster, {
1649
1868
  position: toast,
1650
1869
  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;
@@ -76,7 +76,7 @@ const Group = props => {
76
76
  gap: '10px',
77
77
  marginRight: 10
78
78
  }
79
- }, /*#__PURE__*/_react.default.createElement(_ColumnsGroup.ColumnsGroup, {
79
+ }, groupSetting?.showGroupIcon !== false && /*#__PURE__*/_react.default.createElement(_ColumnsGroup.ColumnsGroup, {
80
80
  t: t
81
81
  // defaultGroupColumns={['name']}
82
82
  ,
@@ -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 = {