es-grid-template 1.8.25 → 1.8.26

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 (31) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +1 -1
  3. package/assets/index.scss +1170 -1170
  4. package/es/grid-component/hooks/constant.js +6 -6
  5. package/es/grid-component/styles.scss +1437 -1437
  6. package/es/table-component/TableContainerEdit.js +1 -1
  7. package/es/table-component/body/TableBodyCell.js +17 -9
  8. package/es/table-component/body/TableBodyRow.js +2 -2
  9. package/es/table-component/header/TableHeadCell2.js +1 -1
  10. package/es/table-component/hook/constant.js +6 -6
  11. package/es/table-component/hook/useColumns.js +5 -2
  12. package/es/table-component/hook/utils.d.ts +1 -1
  13. package/es/table-component/hook/utils.js +42 -7
  14. package/es/table-component/style.scss +1220 -1220
  15. package/es/table-component/table/Grid.js +4 -0
  16. package/es/table-component/type.d.ts +2 -0
  17. package/lib/grid-component/hooks/constant.js +6 -6
  18. package/lib/grid-component/styles.scss +1437 -1437
  19. package/lib/table-component/TableContainerEdit.js +1 -1
  20. package/lib/table-component/body/TableBodyCell.js +17 -9
  21. package/lib/table-component/body/TableBodyRow.js +2 -2
  22. package/lib/table-component/header/TableHeadCell2.js +1 -1
  23. package/lib/table-component/hook/constant.js +6 -6
  24. package/lib/table-component/hook/useColumns.js +5 -2
  25. package/lib/table-component/hook/utils.d.ts +1 -1
  26. package/lib/table-component/hook/utils.js +42 -7
  27. package/lib/table-component/style.scss +1220 -1220
  28. package/lib/table-component/table/Grid.js +4 -0
  29. package/lib/table-component/type.d.ts +2 -0
  30. package/package.json +116 -116
  31. package/CHANGELOG.md +0 -6
@@ -1164,7 +1164,7 @@ const TableContainerEdit = props => {
1164
1164
  // const newData = [...dataSource]
1165
1165
  const newData = [...originData];
1166
1166
  let newElement;
1167
- if (!record.children || record.children.length === 0) {
1167
+ if (!record?.children || record?.children && record.children.length === 0) {
1168
1168
  newElement = {
1169
1169
  ...record,
1170
1170
  children: [{
@@ -274,6 +274,8 @@ const TableBodyCell = props => {
274
274
  // maxWidth: cell.column.getSize(),
275
275
  ...getCommonPinningStyles(cell.column)
276
276
  }
277
+ }, /*#__PURE__*/React.createElement("div", {
278
+ className: classNames('ui-rc_cell-content', {})
277
279
  }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
278
280
  className: "ui-rc-table-row-expand-trigger",
279
281
  style: {
@@ -316,7 +318,7 @@ const TableBodyCell = props => {
316
318
  isDataTree,
317
319
  setExpanded,
318
320
  expandIconColumnIndex
319
- }));
321
+ })));
320
322
  }
321
323
  return /*#__PURE__*/React.createElement("div", {
322
324
  key: cell.id,
@@ -362,8 +364,11 @@ const TableBodyCell = props => {
362
364
  if (e.target.firstChild?.clientWidth < e.target.firstChild?.scrollWidth) {
363
365
  setIsOpenTooltip(true);
364
366
  }
365
- },
366
- onMouseUp: () => {},
367
+ }
368
+
369
+ // onMouseUp={() => { }}
370
+ ,
371
+
367
372
  onKeyDown: e => {
368
373
  const flatRows = table.getRowModel().flatRows;
369
374
  if (e.key === 'ArrowDown' && rowNumber < flatRows.length - 1) {
@@ -406,12 +411,15 @@ const TableBodyCell = props => {
406
411
  onDoubleClick: () => {},
407
412
  onClick: e => {
408
413
  if (selectionSettings?.checkboxOnly !== true) {
409
- cell.row.getToggleSelectedHandler()(e);
410
- setIsSelectionChange({
411
- isChange: true,
412
- type: 'rowSelected',
413
- rowData: cell.row.original
414
- });
414
+ const isInsideCell = e.target.closest(".ui-rc-grid-cell");
415
+ if (isInsideCell) {
416
+ cell.row.getToggleSelectedHandler()(e);
417
+ setIsSelectionChange({
418
+ isChange: true,
419
+ type: 'rowSelected',
420
+ rowData: cell.row.original
421
+ });
422
+ }
415
423
  }
416
424
  }
417
425
  }, /*#__PURE__*/React.createElement("div", {
@@ -63,8 +63,8 @@ const TableBodyRow = ({
63
63
  // height: isEditing ? '36px' : undefined,
64
64
  gridTemplateColumns: `${templateColumns.map(n => `${n}fr`).join(" ")}`,
65
65
  // gridTemplateColumns: `repeat(${centerCOlumns.length + fixedLeftColumns.length + fixedRightColumns.length}, minmax(0, 1fr))`,
66
- height: isEditing ? virtualRow.size : undefined
67
- // minHeight: isEditing ? undefined : virtualRow.size
66
+ height: isEditing ? virtualRow.size : undefined,
67
+ minHeight: isEditing ? undefined : virtualRow.size
68
68
  },
69
69
  onDoubleClick: e => {
70
70
  recordDoubleClick?.({
@@ -173,7 +173,7 @@ const TableHeadCell2 = props => {
173
173
  marginBottom: 8
174
174
  }
175
175
  }, renderFilter({
176
- column: column,
176
+ column: column.columnDef,
177
177
  selectedKeys,
178
178
  setSelectedKeys
179
179
  // selectedKeys: (column.getFilterValue() ?? []) as string[],
@@ -213,16 +213,16 @@ export const optionFontSize = [{
213
213
  label: '48'
214
214
  }];
215
215
 
216
- /**
217
- * Sort order for BaseTable
216
+ /**
217
+ * Sort order for BaseTable
218
218
  */
219
219
  const SortOrder = {
220
- /**
221
- * Sort data in ascending order
220
+ /**
221
+ * Sort data in ascending order
222
222
  */
223
223
  ascend: 'Ascending',
224
- /**
225
- * Sort data in descending order
224
+ /**
225
+ * Sort data in descending order
226
226
  */
227
227
  descend: 'Descending'
228
228
  };
@@ -96,7 +96,8 @@ export function convertToTanStackColumns({
96
96
  allowResizing,
97
97
  minWidth,
98
98
  template,
99
- allowSorter
99
+ allowSorter,
100
+ allowFiltering
100
101
  } = col;
101
102
  const {
102
103
  children,
@@ -148,7 +149,9 @@ export function convertToTanStackColumns({
148
149
  sortDescFirst: false,
149
150
  minSize: minWidth,
150
151
  // maxSize: maxWidth,
151
- enableSorting: allowSorter !== false || col.sorter !== false
152
+ enableSorting: allowSorter !== false || col.sorter !== false,
153
+ // enableColumnFilter: allowFiltering !== false && !nonActionColumn.includes(field)
154
+ enableColumnFilter: allowFiltering !== false
152
155
  };
153
156
  if (children) {
154
157
  // @ts-ignore
@@ -137,7 +137,7 @@ export declare const convertToObjTrue: (arr: any) => {
137
137
  export declare const getDiffent2Array: (a: any[], b: any[]) => any[];
138
138
  export declare function isTree(arr: any[]): boolean;
139
139
  export declare function findFirst(items: Column<any>[]): Column<any, unknown>;
140
- export declare function isTreeArray(arr: any[]): boolean;
140
+ export declare function isTreeArray(arr: any[], options?: any): boolean;
141
141
  export declare function updateColumnWidthsRecursive(columns: any[], sizing: Record<string, number>): any[];
142
142
  export declare function updateWidthsByOther(source: any[], target: any[]): any[];
143
143
  export declare function findAllChildrenKeys2<RecordType>(data: readonly RecordType[], rowKey: any, childrenColumnName: string): Key[];
@@ -1935,14 +1935,49 @@ export function findFirst(items) {
1935
1935
  if (leftItem) return leftItem;
1936
1936
  return null;
1937
1937
  }
1938
- export function isTreeArray(arr) {
1939
- if (!Array.isArray(arr)) return false;
1940
- return arr.every(item => {
1941
- if ("children" in item) {
1942
- return Array.isArray(item.children) && item.children.length > 0;
1938
+
1939
+ // export function isTreeArray(arr: any[]): boolean {
1940
+
1941
+ // // if (!Array.isArray(arr)) return false;
1942
+
1943
+ // // return arr.every(item => {
1944
+ // // if ("children" in item) {
1945
+ // // return Array.isArray(item.children) && item.children.length > 0;
1946
+ // // }
1947
+ // // return true; // node lá thì hợp lệ
1948
+ // // });
1949
+
1950
+ // if (!Array.isArray(arr)) return false;
1951
+
1952
+ // return arr.every(item => {
1953
+ // if (typeof item !== "object" || item === null) return false;
1954
+
1955
+ // if ("children" in item) {
1956
+ // return Array.isArray(item.children);
1957
+ // }
1958
+
1959
+ // return false; // node lá thì hợp lệ
1960
+ // });
1961
+
1962
+ // }
1963
+
1964
+ export function isTreeArray(arr, options) {
1965
+ if (!Array.isArray(arr) || arr.length === 0) return false;
1966
+ const requireNonEmpty = options?.requireNonEmptyChildren ?? false;
1967
+ let hasParent = false;
1968
+ for (const item of arr) {
1969
+ if (typeof item !== 'object' || item === null) return false;
1970
+ if ('children' in item) {
1971
+ const children = item.children;
1972
+ if (!Array.isArray(children)) return false;
1973
+ if (requireNonEmpty) {
1974
+ if (children.length > 0) hasParent = true;
1975
+ } else {
1976
+ hasParent = true;
1977
+ }
1943
1978
  }
1944
- return true; // node lá thì hợp lệ
1945
- });
1979
+ }
1980
+ return hasParent;
1946
1981
  }
1947
1982
  export function updateColumnWidthsRecursive(columns, sizing) {
1948
1983
  return columns.map(col => {