es-grid-template 1.8.79 → 1.8.81

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.
@@ -130,6 +130,7 @@ export type ColumnTemplate<RecordType> = {
130
130
  export type GetRowKey<RecordType> = (record: RecordType, index?: number) => Key;
131
131
  export type ColumnTable<RecordType = AnyObject> = {
132
132
  field: string;
133
+ fieldOrigin?: string;
133
134
  width?: number;
134
135
  maxWidth?: number;
135
136
  minWidth?: number;
@@ -248,6 +249,7 @@ export type TableProps<RecordType = AnyObject> = {
248
249
  contextMenuOpen?: (args: Omit<ContextInfo<RecordType>, 'item'>) => void;
249
250
  contextMenuClick?: (args: ContextInfo<RecordType>) => void;
250
251
  recordDoubleClick?: (args: RecordDoubleClickEventArgs<RecordType>) => void;
252
+ recordClick?: (args: RecordDoubleClickEventArgs<RecordType>) => void;
251
253
  toolbarItems?: ToolbarItem[];
252
254
  showColumnChoose?: boolean;
253
255
  showAdvanceFilter?: boolean;
@@ -159,6 +159,7 @@ export declare const removeColumns: <RecordType>(columns: ColumnTable<RecordType
159
159
  export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordType>[], fixedFields: string[]) => {
160
160
  fixed: string;
161
161
  field: string;
162
+ fieldOrigin?: string;
162
163
  width?: number;
163
164
  maxWidth?: number;
164
165
  minWidth?: number;
@@ -211,9 +212,9 @@ export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordTyp
211
212
  ellipsis?: boolean;
212
213
  allowResizing?: boolean;
213
214
  allowSelection?: boolean | ((rowData: RecordType) => boolean);
214
- onCellStyles?: Omit<CSSProperties, "width" | "display" | "right" | "left" | "position" | "minWidth"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "width" | "display" | "right" | "left" | "position" | "minWidth">);
215
- onCellHeaderStyles?: Omit<CSSProperties, "width" | "display" | "right" | "left" | "position" | "minWidth"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "width" | "display" | "right" | "left" | "position" | "minWidth">);
216
- onCellFooterStyles?: Omit<CSSProperties, "width" | "display" | "right" | "left" | "position" | "minWidth"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "width" | "display" | "right" | "left" | "position" | "minWidth">);
215
+ onCellStyles?: Omit<CSSProperties, "left" | "right" | "display" | "width" | "minWidth" | "position"> | ((cellValue: any, cell: import("@tanstack/react-table").Cell<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "display" | "width" | "minWidth" | "position">);
216
+ onCellHeaderStyles?: Omit<CSSProperties, "left" | "right" | "display" | "width" | "minWidth" | "position"> | ((cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "display" | "width" | "minWidth" | "position">);
217
+ onCellFooterStyles?: Omit<CSSProperties, "left" | "right" | "display" | "width" | "minWidth" | "position"> | ((cellValue: any, cell: import("@tanstack/react-table").Header<RecordType, unknown>) => Omit<CSSProperties, "left" | "right" | "display" | "width" | "minWidth" | "position">);
217
218
  sumGroup?: boolean;
218
219
  onCell?: (rowData: RecordType, index: number) => import("react").TdHTMLAttributes<HTMLTableCellElement>;
219
220
  }[];
@@ -74,6 +74,7 @@ const TableContainer = props => {
74
74
  dataSourceFilter,
75
75
  onExpandClick,
76
76
  setIsExpandClick,
77
+ recordClick,
77
78
  ...rest
78
79
  } = props;
79
80
  const [paginationLocal] = useLocale('Pagination');
@@ -94,12 +95,27 @@ const TableContainer = props => {
94
95
  }
95
96
  }, [id, height, editAble, minHeight]);
96
97
  React.useEffect(() => {
97
- const handleClickOutside = () => {
98
- setFocusedCell(undefined);
99
- setIsSelectionChange(prev => ({
100
- ...prev,
101
- isChange: false
102
- }));
98
+ const handleClickOutside = event => {
99
+ const element = event.target;
100
+ const container = document.querySelector(".be-popup-container");
101
+ const containerContextMenu = document.querySelector(".popup-context-menu");
102
+ const tableBody = document.querySelector(`#${id} .ui-rc-grid-tbody`);
103
+ const itemContainer = document.querySelector(`#${id} .ui-rc-toolbar-selection-overflow-item`);
104
+ const itemHeader = document.querySelector(`#${id} .ui-rc-table-thead`);
105
+ const isInsideContainer = element.closest(".be-popup-container") && container;
106
+ const isInsideContainerContext = containerContextMenu && element.closest(".popup-context-menu");
107
+ const isInsideToolbar = element.closest(`.ui-rc-toolbar-selection-overflow-item`) && itemContainer;
108
+ const isInsideHeader = itemHeader && itemHeader.contains(event.target);
109
+ if (isInsideContainer || isInsideToolbar || isInsideHeader || isInsideContainerContext || element.id === id) {
110
+ return;
111
+ }
112
+ if (containerRef.current && tableBody && !tableBody.contains(event.target)) {
113
+ setFocusedCell(undefined);
114
+ setIsSelectionChange(prev => ({
115
+ ...prev,
116
+ isChange: false
117
+ }));
118
+ }
103
119
  };
104
120
  document.addEventListener('mousedown', handleClickOutside);
105
121
  return () => {
@@ -267,6 +283,7 @@ const TableContainer = props => {
267
283
  // triggerFilter,
268
284
  wrapSettings,
269
285
  recordDoubleClick,
286
+ recordClick,
270
287
  selectionSettings,
271
288
  isSelectionChange,
272
289
  setIsSelectionChange,
@@ -627,195 +627,11 @@ const TableContainerEdit = props => {
627
627
  if (!tableContainerRef.current) {
628
628
  return;
629
629
  }
630
-
631
- // const containerWidth = tableContainerRef.current.offsetWidth
632
- // const totalWidth = table.getTotalSize()
633
-
634
- // if (totalWidth && totalWidth <= containerWidth) {
635
-
636
- // return
637
-
638
- // }
639
-
640
630
  if (columnSizingInfo.isResizingColumn === false) {
641
631
  const aa = updateColumnWidthsRecursive(propsColumns, columnSizing);
642
632
  setColumns(aa);
643
-
644
- // requestAnimationFrame(() => {
645
-
646
- // columnVirtualizer.measure()
647
- // })
648
633
  }
649
634
  }, [columnSizingInfo]);
650
-
651
- // React.useEffect(() => {
652
-
653
- // // if (!containerRef.current || !tableContainerRef.current) {
654
- // if (!tableContainerRef.current) {
655
- // return
656
- // }
657
-
658
- // // const containerWidth = containerRef.current.offsetWidth - 1
659
- // // const containerWidth = tableContainerRef.current.offsetWidth
660
- // const containerWidth = tableContainerRef.current.offsetWidth - (tableContainerRef.current.scrollHeight > tableContainerRef.current.offsetHeight ? 15 : 0)
661
-
662
- // const totalWidth = table.getTotalSize() - (tableContainerRef.current.scrollHeight > tableContainerRef.current.offsetHeight ? 15 : 0)
663
-
664
- // if (totalWidth && totalWidth > 0 && totalWidth < containerWidth) {
665
-
666
- // const factor = containerWidth / totalWidth
667
-
668
- // const visibleCols = table.getVisibleLeafColumns()
669
-
670
- // const baseSizes = visibleCols.map(
671
- // (col) => col.getSize() || col.columnDef.size || 150
672
- // )
673
-
674
- // const scaledSizes = baseSizes.map((size) => size * factor)
675
- // const roundedSizes = scaledSizes.map((size) => Math.floor(size))
676
-
677
- // let diff = containerWidth - roundedSizes.reduce((a, b) => a + b, 0)
678
-
679
- // // phân bổ diff cho các cột từ trái qua phải
680
- // for (let i = 0; diff > 0; i = (i + 1) % roundedSizes.length) {
681
- // roundedSizes[i]++
682
- // diff--
683
- // }
684
-
685
- // const aaa = visibleCols.reduce((acc, col, idx) => {
686
- // acc[col.id] = roundedSizes[idx]
687
- // return acc
688
- // }, {} as Record<string, number>)
689
-
690
- // const aa = updateColumnWidthsRecursive(propsColumns, aaa)
691
-
692
- // // setColumns(aa)
693
-
694
- // // table.setColumnSizing(aaa)
695
-
696
- // requestAnimationFrame(() => {
697
-
698
- // columnVirtualizer.measure()
699
- // })
700
-
701
- // // setColumnSizing?.(aaa)
702
- // } else {
703
- // if (columnHidden) {
704
- // const abb = table.getVisibleLeafColumns()?.[0]
705
-
706
- // if (abb && Object.keys(columnSizingInfo).length === 0
707
- // ) {
708
- // // setColumnSizing({ "#": abb.getSize() })
709
- // table.setColumnSizing({ "#": abb.getSize() })
710
-
711
- // requestAnimationFrame(() => {
712
-
713
- // columnVirtualizer.measure()
714
- // })
715
- // }
716
- // }
717
-
718
- // }
719
-
720
- // }, [table.getTotalSize(), dataSource.length, windowSize.innerWidth, columnVirtualizer])
721
-
722
- // React.useEffect(() => {
723
-
724
- // if (!tableContainerRef.current) {
725
- // return
726
- // }
727
-
728
- // const containerWidth = tableContainerRef.current.offsetWidth
729
- // const totalWidth = table.getTotalSize()
730
-
731
- // if (totalWidth && totalWidth <= containerWidth) {
732
-
733
- // return
734
-
735
- // }
736
-
737
- // if (columnSizingInfo.isResizingColumn === false) {
738
-
739
- // const aa = updateColumnWidthsRecursive(propsColumns, columnSizing)
740
- // setColumns(aa)
741
-
742
- // }
743
-
744
- // }, [columnSizing, columnSizingInfo, propsColumns, setColumns])
745
-
746
- // React.useEffect(() => {
747
-
748
- // // if (!containerRef.current || !tableContainerRef.current) {
749
- // if (!tableContainerRef.current) {
750
- // return
751
- // }
752
-
753
- // // const containerWidth = containerRef.current.offsetWidth - 1
754
- // const containerWidth = tableContainerRef.current.offsetWidth - (tableContainerRef.current.scrollHeight > tableContainerRef.current.offsetHeight ? 15 : 0 )
755
-
756
- // const totalWidth = table.getTotalSize()
757
-
758
- // if (totalWidth && totalWidth < containerWidth) {
759
-
760
- // const factor = containerWidth / totalWidth
761
-
762
- // const visibleCols = table.getVisibleLeafColumns()
763
-
764
- // const baseSizes = visibleCols.map(
765
- // (col) => col.getSize() || col.columnDef.size || 150
766
- // )
767
-
768
- // const scaledSizes = baseSizes.map((size) => size * factor)
769
- // const roundedSizes = scaledSizes.map((size) => Math.floor(size))
770
-
771
- // let diff = containerWidth - roundedSizes.reduce((a, b) => a + b, 0)
772
-
773
- // // phân bổ diff cho các cột từ trái qua phải
774
- // for (let i = 0; diff > 0; i = (i + 1) % roundedSizes.length) {
775
- // roundedSizes[i]++
776
- // diff--
777
- // }
778
-
779
- // const aaa = visibleCols.reduce((acc, col, idx) => {
780
- // acc[col.id] = roundedSizes[idx]
781
- // return acc
782
- // }, {} as Record<string, number>)
783
-
784
- // const aa = updateColumnWidthsRecursive(propsColumns, aaa)
785
-
786
- // // setColumns(aa)
787
-
788
- // table.setColumnSizing(aaa)
789
-
790
- // // setColumnSizing?.(aaa)
791
- // }
792
-
793
- // }, [windowSize.innerWidth, tableContainerRef, propsColumns, table.getState().columnSizing])
794
- // // }, [windowSize.innerWidth, tableContainerRef, propsColumns, table.getState().columnSizing, dataSource.length])
795
- // // }, [table.getState().columnSizing, table.getTotalSize(), containerRef])
796
-
797
- // React.useEffect(() => {
798
-
799
- // if (!containerRef.current) return;
800
-
801
- // const containerWidth = containerRef.current.offsetWidth - 1;
802
- // const totalWidth = table.getTotalSize();
803
-
804
- // if (totalWidth && totalWidth < containerWidth) {
805
-
806
- // const factor = containerWidth / totalWidth;
807
-
808
- // table.setColumnSizing(
809
- // table.getVisibleLeafColumns().reduce((acc, col) => {
810
- // acc[col.id] = ((col.getSize() || col.columnDef.size || 150) * factor);
811
- // return acc;
812
- // }, {} as Record<string, number>)
813
- // );
814
- // }
815
-
816
- // }, [table.getTotalSize(), windowSize.innerWidth, table.getState().columnSizing])
817
- // // }, [table.getState().columnSizing, table.getTotalSize(), containerRef])
818
-
819
635
  React.useEffect(() => {
820
636
  // const totalHeight = minHeight ?? height
821
637
  const totalHeight = getTableHeight(height, minHeight);
@@ -1397,6 +1213,7 @@ const TableContainerEdit = props => {
1397
1213
  if (item.key === 'ADD') {
1398
1214
  return {
1399
1215
  ...item,
1216
+ label: item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item',
1400
1217
  template: () => {
1401
1218
  return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'ADD' && /*#__PURE__*/React.createElement("div", {
1402
1219
  className: classNames(`be-toolbar-item`, item?.className)
@@ -1424,6 +1241,7 @@ const TableContainerEdit = props => {
1424
1241
  if (item.key === 'DELETE') {
1425
1242
  return {
1426
1243
  ...item,
1244
+ label: item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item',
1427
1245
  template: () => {
1428
1246
  return /*#__PURE__*/React.createElement("div", {
1429
1247
  className: classNames(`be-toolbar-item`, item?.className)
@@ -1448,10 +1266,12 @@ const TableContainerEdit = props => {
1448
1266
  if (item.key === 'ADD') {
1449
1267
  return {
1450
1268
  ...item,
1269
+ label: item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item',
1451
1270
  template: () => {
1452
1271
  return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'ADD' && /*#__PURE__*/React.createElement("div", {
1453
1272
  className: classNames(`be-toolbar-item`, item?.className)
1454
1273
  }, /*#__PURE__*/React.createElement(Dropdown.Button, {
1274
+ title: "",
1455
1275
  overlayClassName: 'be-popup-container',
1456
1276
  style: {
1457
1277
  color: '#28c76f',
@@ -1474,6 +1294,7 @@ const TableContainerEdit = props => {
1474
1294
  if (item.key === 'DUPLICATE') {
1475
1295
  return {
1476
1296
  ...item,
1297
+ label: item.label ? t ? t(item.label) : item.label : t ? t('Duplicate') : 'Duplicate',
1477
1298
  template: () => {
1478
1299
  return /*#__PURE__*/React.createElement(Fragment, null, item.key === 'DUPLICATE' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/React.createElement("div", {
1479
1300
  className: classNames(`be-toolbar-item`, item?.className)
@@ -1492,6 +1313,7 @@ const TableContainerEdit = props => {
1492
1313
  if (item.key === 'INSERT_BEFORE') {
1493
1314
  return {
1494
1315
  ...item,
1316
+ label: item.label ? t ? t(item.label) : item.label : t ? t('Insert item before') : 'Insert item before',
1495
1317
  template: () => {
1496
1318
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
1497
1319
  className: classNames(`be-toolbar-item`, item?.className)
@@ -1518,6 +1340,7 @@ const TableContainerEdit = props => {
1518
1340
  if (item.key === 'INSERT_AFTER') {
1519
1341
  return {
1520
1342
  ...item,
1343
+ label: item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after',
1521
1344
  template: () => {
1522
1345
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
1523
1346
  className: classNames(`be-toolbar-item`, item?.className)
@@ -1544,6 +1367,7 @@ const TableContainerEdit = props => {
1544
1367
  if (item.key === 'INSERT_CHILDREN') {
1545
1368
  return {
1546
1369
  ...item,
1370
+ label: item.label ? t ? t(item.label) : item.label : t ? t('Insert item children') : 'Insert item children',
1547
1371
  template: () => {
1548
1372
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
1549
1373
  className: classNames(`be-toolbar-item`, item?.className)
@@ -1562,6 +1386,7 @@ const TableContainerEdit = props => {
1562
1386
  if (item.key === 'DELETE') {
1563
1387
  return {
1564
1388
  ...item,
1389
+ label: item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item',
1565
1390
  template: () => {
1566
1391
  return /*#__PURE__*/React.createElement("div", {
1567
1392
  className: classNames(`be-toolbar-item`, item?.className)
@@ -1580,6 +1405,7 @@ const TableContainerEdit = props => {
1580
1405
  if (item.key === 'DELETE_ROWS') {
1581
1406
  return {
1582
1407
  ...item,
1408
+ label: t ? `${t('Delete')} ${rowsFocus.length} ${t('row')}` : `Delete ${rowsFocus.length} item`,
1583
1409
  template: () => {
1584
1410
  return /*#__PURE__*/React.createElement("div", {
1585
1411
  className: classNames(`be-toolbar-item`, item?.className)
@@ -155,9 +155,9 @@ const TableBodyCell = props => {
155
155
  const {
156
156
  cell,
157
157
  commandClick,
158
- // tableId,
159
158
  table,
160
159
  isEditing
160
+ // rowVirtualizer
161
161
  } = props;
162
162
  const {
163
163
  id,
@@ -176,7 +176,8 @@ const TableBodyCell = props => {
176
176
  selectionSettings,
177
177
  wrapSettings,
178
178
  pagination,
179
- onExpandClick
179
+ onExpandClick,
180
+ recordClick
180
181
  // dataSource
181
182
  } = React.useContext(TableContext);
182
183
  const expandIconColumnIndex = expandable?.expandIconColumnIndex ?? 0;
@@ -397,6 +398,15 @@ const TableBodyCell = props => {
397
398
  colId: cell.column.id,
398
399
  rowId: nextId
399
400
  });
401
+
402
+ // if (rowNumber < flatRows.length - 5) {
403
+ // e.stopPropagation()
404
+ // e.preventDefault()
405
+ // rowVirtualizer.scrollToIndex(cell.row.index, {
406
+ // align: 'center', // 'start' | 'center' | 'end'
407
+ // })
408
+ // }
409
+
400
410
  const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
401
411
  const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
402
412
  if (cellFocus) {
@@ -428,6 +438,11 @@ const TableBodyCell = props => {
428
438
  }
429
439
  },
430
440
  onClick: e => {
441
+ recordClick?.({
442
+ e,
443
+ rowData: record,
444
+ rowIndex: rowNumber
445
+ });
431
446
  const selection = window.getSelection();
432
447
  const text = selection ? selection.toString() : "";
433
448
  if (text.length > 0 || enableClick === false) {} else {
@@ -101,9 +101,10 @@ export const renderFilter = args => {
101
101
 
102
102
  // onSelect={(val) => {
103
103
  // }}
104
- ,
105
104
 
106
- menuClassName: "rc-menu-popup",
105
+ // menuClassName="rc-menu-popup"
106
+ ,
107
+ menuClassName: "be-popup-container",
107
108
  placement: "auto"
108
109
  }))));
109
110
  case 'Week':
@@ -783,7 +783,8 @@ export const shouldInclude = (item, queries, ignoreAccents) => {
783
783
  // condition = isDateComparison ? compareDates(itemDate, queryDate) : (itemValue === value)
784
784
  break;
785
785
  case "notequal":
786
- condition = isDateComparison ? !compareDates(itemDate, queryDate) : itemValue !== value;
786
+ const abcN = ignoreAccents === false ? itemValue !== value : itemStr !== queryStr;
787
+ condition = isDateComparison ? !compareDates(itemDate, queryDate) : abcN;
787
788
  break;
788
789
  case "greaterthan":
789
790
  // @ts-ignore
@@ -1071,7 +1071,7 @@ $cell-index-focus-bg-Dark: #E6EFFD !default;
1071
1071
 
1072
1072
 
1073
1073
 
1074
- .rc-menu-popup {
1074
+ .be-popup-container {
1075
1075
  z-index: 1090 !important;
1076
1076
  }
1077
1077
 
@@ -19,6 +19,7 @@ export interface IContext<T> {
19
19
  setExpanded: Dispatch<SetStateAction<ExpandedState>>;
20
20
  expanded: ExpandedState;
21
21
  recordDoubleClick?: (args: RecordDoubleClickEventArgs<T>) => void;
22
+ recordClick?: (args: RecordDoubleClickEventArgs<T>) => void;
22
23
  selectionSettings?: SelectionSettings;
23
24
  isSelectionChange?: {
24
25
  isChange: boolean;
@@ -192,10 +192,12 @@ const TableWrapper = props => {
192
192
  contextMenuItems: contextMenuItems
193
193
  }, rest));
194
194
  }
195
- },
196
- defaultItemHeight: 37,
197
- fixedItemHeight: 37,
198
- itemSize: () => 37
195
+ }
196
+
197
+ // defaultItemHeight={37}
198
+ // fixedItemHeight={37}
199
+
200
+ // itemSize={() => 37}
199
201
 
200
202
  // overscan={{
201
203
  // main: 10,
@@ -130,6 +130,7 @@ export type ColumnTemplate<RecordType> = {
130
130
  export type GetRowKey<RecordType> = (record: RecordType, index?: number) => Key;
131
131
  export type ColumnTable<RecordType = AnyObject> = {
132
132
  field: string;
133
+ fieldOrigin?: string;
133
134
  width?: number;
134
135
  maxWidth?: number;
135
136
  minWidth?: number;
@@ -248,6 +249,7 @@ export type TableProps<RecordType = AnyObject> = {
248
249
  contextMenuOpen?: (args: Omit<ContextInfo<RecordType>, 'item'>) => void;
249
250
  contextMenuClick?: (args: ContextInfo<RecordType>) => void;
250
251
  recordDoubleClick?: (args: RecordDoubleClickEventArgs<RecordType>) => void;
252
+ recordClick?: (args: RecordDoubleClickEventArgs<RecordType>) => void;
251
253
  toolbarItems?: ToolbarItem[];
252
254
  showColumnChoose?: boolean;
253
255
  showAdvanceFilter?: boolean;
@@ -159,6 +159,7 @@ export declare const removeColumns: <RecordType>(columns: ColumnTable<RecordType
159
159
  export declare const fixColumnsLeft: <RecordType>(columns: ColumnTable<RecordType>[], fixedFields: string[]) => {
160
160
  fixed: string;
161
161
  field: string;
162
+ fieldOrigin?: string;
162
163
  width?: number;
163
164
  maxWidth?: number;
164
165
  minWidth?: number;
@@ -81,6 +81,7 @@ const TableContainer = props => {
81
81
  dataSourceFilter,
82
82
  onExpandClick,
83
83
  setIsExpandClick,
84
+ recordClick,
84
85
  ...rest
85
86
  } = props;
86
87
  const [paginationLocal] = (0, _locale.useLocale)('Pagination');
@@ -101,12 +102,27 @@ const TableContainer = props => {
101
102
  }
102
103
  }, [id, height, editAble, minHeight]);
103
104
  _react.default.useEffect(() => {
104
- const handleClickOutside = () => {
105
- setFocusedCell(undefined);
106
- setIsSelectionChange(prev => ({
107
- ...prev,
108
- isChange: false
109
- }));
105
+ const handleClickOutside = event => {
106
+ const element = event.target;
107
+ const container = document.querySelector(".be-popup-container");
108
+ const containerContextMenu = document.querySelector(".popup-context-menu");
109
+ const tableBody = document.querySelector(`#${id} .ui-rc-grid-tbody`);
110
+ const itemContainer = document.querySelector(`#${id} .ui-rc-toolbar-selection-overflow-item`);
111
+ const itemHeader = document.querySelector(`#${id} .ui-rc-table-thead`);
112
+ const isInsideContainer = element.closest(".be-popup-container") && container;
113
+ const isInsideContainerContext = containerContextMenu && element.closest(".popup-context-menu");
114
+ const isInsideToolbar = element.closest(`.ui-rc-toolbar-selection-overflow-item`) && itemContainer;
115
+ const isInsideHeader = itemHeader && itemHeader.contains(event.target);
116
+ if (isInsideContainer || isInsideToolbar || isInsideHeader || isInsideContainerContext || element.id === id) {
117
+ return;
118
+ }
119
+ if (containerRef.current && tableBody && !tableBody.contains(event.target)) {
120
+ setFocusedCell(undefined);
121
+ setIsSelectionChange(prev => ({
122
+ ...prev,
123
+ isChange: false
124
+ }));
125
+ }
110
126
  };
111
127
  document.addEventListener('mousedown', handleClickOutside);
112
128
  return () => {
@@ -274,6 +290,7 @@ const TableContainer = props => {
274
290
  // triggerFilter,
275
291
  wrapSettings,
276
292
  recordDoubleClick,
293
+ recordClick,
277
294
  selectionSettings,
278
295
  isSelectionChange,
279
296
  setIsSelectionChange,
@@ -634,195 +634,11 @@ const TableContainerEdit = props => {
634
634
  if (!tableContainerRef.current) {
635
635
  return;
636
636
  }
637
-
638
- // const containerWidth = tableContainerRef.current.offsetWidth
639
- // const totalWidth = table.getTotalSize()
640
-
641
- // if (totalWidth && totalWidth <= containerWidth) {
642
-
643
- // return
644
-
645
- // }
646
-
647
637
  if (columnSizingInfo.isResizingColumn === false) {
648
638
  const aa = (0, _utils.updateColumnWidthsRecursive)(propsColumns, columnSizing);
649
639
  setColumns(aa);
650
-
651
- // requestAnimationFrame(() => {
652
-
653
- // columnVirtualizer.measure()
654
- // })
655
640
  }
656
641
  }, [columnSizingInfo]);
657
-
658
- // React.useEffect(() => {
659
-
660
- // // if (!containerRef.current || !tableContainerRef.current) {
661
- // if (!tableContainerRef.current) {
662
- // return
663
- // }
664
-
665
- // // const containerWidth = containerRef.current.offsetWidth - 1
666
- // // const containerWidth = tableContainerRef.current.offsetWidth
667
- // const containerWidth = tableContainerRef.current.offsetWidth - (tableContainerRef.current.scrollHeight > tableContainerRef.current.offsetHeight ? 15 : 0)
668
-
669
- // const totalWidth = table.getTotalSize() - (tableContainerRef.current.scrollHeight > tableContainerRef.current.offsetHeight ? 15 : 0)
670
-
671
- // if (totalWidth && totalWidth > 0 && totalWidth < containerWidth) {
672
-
673
- // const factor = containerWidth / totalWidth
674
-
675
- // const visibleCols = table.getVisibleLeafColumns()
676
-
677
- // const baseSizes = visibleCols.map(
678
- // (col) => col.getSize() || col.columnDef.size || 150
679
- // )
680
-
681
- // const scaledSizes = baseSizes.map((size) => size * factor)
682
- // const roundedSizes = scaledSizes.map((size) => Math.floor(size))
683
-
684
- // let diff = containerWidth - roundedSizes.reduce((a, b) => a + b, 0)
685
-
686
- // // phân bổ diff cho các cột từ trái qua phải
687
- // for (let i = 0; diff > 0; i = (i + 1) % roundedSizes.length) {
688
- // roundedSizes[i]++
689
- // diff--
690
- // }
691
-
692
- // const aaa = visibleCols.reduce((acc, col, idx) => {
693
- // acc[col.id] = roundedSizes[idx]
694
- // return acc
695
- // }, {} as Record<string, number>)
696
-
697
- // const aa = updateColumnWidthsRecursive(propsColumns, aaa)
698
-
699
- // // setColumns(aa)
700
-
701
- // // table.setColumnSizing(aaa)
702
-
703
- // requestAnimationFrame(() => {
704
-
705
- // columnVirtualizer.measure()
706
- // })
707
-
708
- // // setColumnSizing?.(aaa)
709
- // } else {
710
- // if (columnHidden) {
711
- // const abb = table.getVisibleLeafColumns()?.[0]
712
-
713
- // if (abb && Object.keys(columnSizingInfo).length === 0
714
- // ) {
715
- // // setColumnSizing({ "#": abb.getSize() })
716
- // table.setColumnSizing({ "#": abb.getSize() })
717
-
718
- // requestAnimationFrame(() => {
719
-
720
- // columnVirtualizer.measure()
721
- // })
722
- // }
723
- // }
724
-
725
- // }
726
-
727
- // }, [table.getTotalSize(), dataSource.length, windowSize.innerWidth, columnVirtualizer])
728
-
729
- // React.useEffect(() => {
730
-
731
- // if (!tableContainerRef.current) {
732
- // return
733
- // }
734
-
735
- // const containerWidth = tableContainerRef.current.offsetWidth
736
- // const totalWidth = table.getTotalSize()
737
-
738
- // if (totalWidth && totalWidth <= containerWidth) {
739
-
740
- // return
741
-
742
- // }
743
-
744
- // if (columnSizingInfo.isResizingColumn === false) {
745
-
746
- // const aa = updateColumnWidthsRecursive(propsColumns, columnSizing)
747
- // setColumns(aa)
748
-
749
- // }
750
-
751
- // }, [columnSizing, columnSizingInfo, propsColumns, setColumns])
752
-
753
- // React.useEffect(() => {
754
-
755
- // // if (!containerRef.current || !tableContainerRef.current) {
756
- // if (!tableContainerRef.current) {
757
- // return
758
- // }
759
-
760
- // // const containerWidth = containerRef.current.offsetWidth - 1
761
- // const containerWidth = tableContainerRef.current.offsetWidth - (tableContainerRef.current.scrollHeight > tableContainerRef.current.offsetHeight ? 15 : 0 )
762
-
763
- // const totalWidth = table.getTotalSize()
764
-
765
- // if (totalWidth && totalWidth < containerWidth) {
766
-
767
- // const factor = containerWidth / totalWidth
768
-
769
- // const visibleCols = table.getVisibleLeafColumns()
770
-
771
- // const baseSizes = visibleCols.map(
772
- // (col) => col.getSize() || col.columnDef.size || 150
773
- // )
774
-
775
- // const scaledSizes = baseSizes.map((size) => size * factor)
776
- // const roundedSizes = scaledSizes.map((size) => Math.floor(size))
777
-
778
- // let diff = containerWidth - roundedSizes.reduce((a, b) => a + b, 0)
779
-
780
- // // phân bổ diff cho các cột từ trái qua phải
781
- // for (let i = 0; diff > 0; i = (i + 1) % roundedSizes.length) {
782
- // roundedSizes[i]++
783
- // diff--
784
- // }
785
-
786
- // const aaa = visibleCols.reduce((acc, col, idx) => {
787
- // acc[col.id] = roundedSizes[idx]
788
- // return acc
789
- // }, {} as Record<string, number>)
790
-
791
- // const aa = updateColumnWidthsRecursive(propsColumns, aaa)
792
-
793
- // // setColumns(aa)
794
-
795
- // table.setColumnSizing(aaa)
796
-
797
- // // setColumnSizing?.(aaa)
798
- // }
799
-
800
- // }, [windowSize.innerWidth, tableContainerRef, propsColumns, table.getState().columnSizing])
801
- // // }, [windowSize.innerWidth, tableContainerRef, propsColumns, table.getState().columnSizing, dataSource.length])
802
- // // }, [table.getState().columnSizing, table.getTotalSize(), containerRef])
803
-
804
- // React.useEffect(() => {
805
-
806
- // if (!containerRef.current) return;
807
-
808
- // const containerWidth = containerRef.current.offsetWidth - 1;
809
- // const totalWidth = table.getTotalSize();
810
-
811
- // if (totalWidth && totalWidth < containerWidth) {
812
-
813
- // const factor = containerWidth / totalWidth;
814
-
815
- // table.setColumnSizing(
816
- // table.getVisibleLeafColumns().reduce((acc, col) => {
817
- // acc[col.id] = ((col.getSize() || col.columnDef.size || 150) * factor);
818
- // return acc;
819
- // }, {} as Record<string, number>)
820
- // );
821
- // }
822
-
823
- // }, [table.getTotalSize(), windowSize.innerWidth, table.getState().columnSizing])
824
- // // }, [table.getState().columnSizing, table.getTotalSize(), containerRef])
825
-
826
642
  _react.default.useEffect(() => {
827
643
  // const totalHeight = minHeight ?? height
828
644
  const totalHeight = (0, _utils.getTableHeight)(height, minHeight);
@@ -1404,6 +1220,7 @@ const TableContainerEdit = props => {
1404
1220
  if (item.key === 'ADD') {
1405
1221
  return {
1406
1222
  ...item,
1223
+ label: item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item',
1407
1224
  template: () => {
1408
1225
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, item.key === 'ADD' && /*#__PURE__*/_react.default.createElement("div", {
1409
1226
  className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
@@ -1431,6 +1248,7 @@ const TableContainerEdit = props => {
1431
1248
  if (item.key === 'DELETE') {
1432
1249
  return {
1433
1250
  ...item,
1251
+ label: item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item',
1434
1252
  template: () => {
1435
1253
  return /*#__PURE__*/_react.default.createElement("div", {
1436
1254
  className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
@@ -1455,10 +1273,12 @@ const TableContainerEdit = props => {
1455
1273
  if (item.key === 'ADD') {
1456
1274
  return {
1457
1275
  ...item,
1276
+ label: item.label ? t ? t(item.label) : item.label : t ? t('Add item') : 'Add item',
1458
1277
  template: () => {
1459
1278
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, item.key === 'ADD' && /*#__PURE__*/_react.default.createElement("div", {
1460
1279
  className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
1461
1280
  }, /*#__PURE__*/_react.default.createElement(_antd.Dropdown.Button, {
1281
+ title: "",
1462
1282
  overlayClassName: 'be-popup-container',
1463
1283
  style: {
1464
1284
  color: '#28c76f',
@@ -1481,6 +1301,7 @@ const TableContainerEdit = props => {
1481
1301
  if (item.key === 'DUPLICATE') {
1482
1302
  return {
1483
1303
  ...item,
1304
+ label: item.label ? t ? t(item.label) : item.label : t ? t('Duplicate') : 'Duplicate',
1484
1305
  template: () => {
1485
1306
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, item.key === 'DUPLICATE' && item.visible !== false && rowsFocus.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
1486
1307
  className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
@@ -1499,6 +1320,7 @@ const TableContainerEdit = props => {
1499
1320
  if (item.key === 'INSERT_BEFORE') {
1500
1321
  return {
1501
1322
  ...item,
1323
+ label: item.label ? t ? t(item.label) : item.label : t ? t('Insert item before') : 'Insert item before',
1502
1324
  template: () => {
1503
1325
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1504
1326
  className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
@@ -1525,6 +1347,7 @@ const TableContainerEdit = props => {
1525
1347
  if (item.key === 'INSERT_AFTER') {
1526
1348
  return {
1527
1349
  ...item,
1350
+ label: item.label ? t ? t(item.label) : item.label : t ? t('Insert item after') : 'Insert item after',
1528
1351
  template: () => {
1529
1352
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1530
1353
  className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
@@ -1551,6 +1374,7 @@ const TableContainerEdit = props => {
1551
1374
  if (item.key === 'INSERT_CHILDREN') {
1552
1375
  return {
1553
1376
  ...item,
1377
+ label: item.label ? t ? t(item.label) : item.label : t ? t('Insert item children') : 'Insert item children',
1554
1378
  template: () => {
1555
1379
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1556
1380
  className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
@@ -1569,6 +1393,7 @@ const TableContainerEdit = props => {
1569
1393
  if (item.key === 'DELETE') {
1570
1394
  return {
1571
1395
  ...item,
1396
+ label: item.label ? t ? t(item.label) : item.label : t ? t('Delete all item') : 'Delete all item',
1572
1397
  template: () => {
1573
1398
  return /*#__PURE__*/_react.default.createElement("div", {
1574
1399
  className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
@@ -1587,6 +1412,7 @@ const TableContainerEdit = props => {
1587
1412
  if (item.key === 'DELETE_ROWS') {
1588
1413
  return {
1589
1414
  ...item,
1415
+ label: t ? `${t('Delete')} ${rowsFocus.length} ${t('row')}` : `Delete ${rowsFocus.length} item`,
1590
1416
  template: () => {
1591
1417
  return /*#__PURE__*/_react.default.createElement("div", {
1592
1418
  className: (0, _classnames.default)(`be-toolbar-item`, item?.className)
@@ -162,9 +162,9 @@ const TableBodyCell = props => {
162
162
  const {
163
163
  cell,
164
164
  commandClick,
165
- // tableId,
166
165
  table,
167
166
  isEditing
167
+ // rowVirtualizer
168
168
  } = props;
169
169
  const {
170
170
  id,
@@ -183,7 +183,8 @@ const TableBodyCell = props => {
183
183
  selectionSettings,
184
184
  wrapSettings,
185
185
  pagination,
186
- onExpandClick
186
+ onExpandClick,
187
+ recordClick
187
188
  // dataSource
188
189
  } = _react.default.useContext(_useContext.TableContext);
189
190
  const expandIconColumnIndex = expandable?.expandIconColumnIndex ?? 0;
@@ -404,6 +405,15 @@ const TableBodyCell = props => {
404
405
  colId: cell.column.id,
405
406
  rowId: nextId
406
407
  });
408
+
409
+ // if (rowNumber < flatRows.length - 5) {
410
+ // e.stopPropagation()
411
+ // e.preventDefault()
412
+ // rowVirtualizer.scrollToIndex(cell.row.index, {
413
+ // align: 'center', // 'start' | 'center' | 'end'
414
+ // })
415
+ // }
416
+
407
417
  const row = document.querySelector(`.ui-rc-grid-row[data-row-key="${nextId}"]`);
408
418
  const cellFocus = row?.querySelector('.ui-rc-grid-cell:not(.ui-rc-grid-cell-selection)');
409
419
  if (cellFocus) {
@@ -435,6 +445,11 @@ const TableBodyCell = props => {
435
445
  }
436
446
  },
437
447
  onClick: e => {
448
+ recordClick?.({
449
+ e,
450
+ rowData: record,
451
+ rowIndex: rowNumber
452
+ });
438
453
  const selection = window.getSelection();
439
454
  const text = selection ? selection.toString() : "";
440
455
  if (text.length > 0 || enableClick === false) {} else {
@@ -110,9 +110,10 @@ const renderFilter = args => {
110
110
 
111
111
  // onSelect={(val) => {
112
112
  // }}
113
- ,
114
113
 
115
- menuClassName: "rc-menu-popup",
114
+ // menuClassName="rc-menu-popup"
115
+ ,
116
+ menuClassName: "be-popup-container",
116
117
  placement: "auto"
117
118
  }))));
118
119
  case 'Week':
@@ -880,7 +880,8 @@ const shouldInclude = (item, queries, ignoreAccents) => {
880
880
  // condition = isDateComparison ? compareDates(itemDate, queryDate) : (itemValue === value)
881
881
  break;
882
882
  case "notequal":
883
- condition = isDateComparison ? !compareDates(itemDate, queryDate) : itemValue !== value;
883
+ const abcN = ignoreAccents === false ? itemValue !== value : itemStr !== queryStr;
884
+ condition = isDateComparison ? !compareDates(itemDate, queryDate) : abcN;
884
885
  break;
885
886
  case "greaterthan":
886
887
  // @ts-ignore
@@ -1071,7 +1071,7 @@ $cell-index-focus-bg-Dark: #E6EFFD !default;
1071
1071
 
1072
1072
 
1073
1073
 
1074
- .rc-menu-popup {
1074
+ .be-popup-container {
1075
1075
  z-index: 1090 !important;
1076
1076
  }
1077
1077
 
@@ -19,6 +19,7 @@ export interface IContext<T> {
19
19
  setExpanded: Dispatch<SetStateAction<ExpandedState>>;
20
20
  expanded: ExpandedState;
21
21
  recordDoubleClick?: (args: RecordDoubleClickEventArgs<T>) => void;
22
+ recordClick?: (args: RecordDoubleClickEventArgs<T>) => void;
22
23
  selectionSettings?: SelectionSettings;
23
24
  isSelectionChange?: {
24
25
  isChange: boolean;
@@ -198,10 +198,12 @@ const TableWrapper = props => {
198
198
  contextMenuItems: contextMenuItems
199
199
  }, rest));
200
200
  }
201
- },
202
- defaultItemHeight: 37,
203
- fixedItemHeight: 37,
204
- itemSize: () => 37
201
+ }
202
+
203
+ // defaultItemHeight={37}
204
+ // fixedItemHeight={37}
205
+
206
+ // itemSize={() => 37}
205
207
 
206
208
  // overscan={{
207
209
  // main: 10,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-grid-template",
3
- "version": "1.8.79",
3
+ "version": "1.8.81",
4
4
  "description": "es-grid-template",
5
5
  "keywords": [
6
6
  "react",