@economic/taco 2.26.6 → 2.26.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -10923,55 +10923,57 @@ function useTableStyleGrid(tableId, table, fontSize) {
10923
10923
  const globalMinSize = getCellMinWidth(fontSize);
10924
10924
  // header body ?footer
10925
10925
  const gridTemplateRows = table.getRowModel().rows.length ? 'min-content 1fr min-content' : 'min-content 1fr';
10926
- let printGridTemplateColumns = '';
10927
- const printHiddenColumns = [];
10928
- const gridTemplateColumns = allVisibleColumns.reduce((accum, column, index) => {
10929
- var _column$columnDef$min, _column$columnDef$met;
10930
- if (table.options.enableGrouping && column.getIsGrouped()) {
10931
- return accum;
10932
- }
10933
- const minSize = (_column$columnDef$min = column.columnDef.minSize) !== null && _column$columnDef$min !== void 0 ? _column$columnDef$min : globalMinSize;
10934
- const width = columnSizing[column.id];
10935
- let size;
10936
- let printSize;
10937
- if (column.id === '__actions') {
10938
- const minWidth = tableMeta.rowActions.rowActionsLength * 32 + 8; /* button margins l+r */
10939
- size = `minmax(${minWidth}px, auto)`;
10940
- } else if (width !== undefined) {
10941
- const isLastColumn = index === allVisibleColumns.length - 1;
10942
- if (width === 'grow' || Number.isNaN(width) && !isLastColumn) {
10943
- size = `minmax(max-content, 1fr)`;
10944
- } else {
10945
- const minWidth = width < minSize ? minSize : width;
10946
- if (isLastColumn) {
10947
- size = `minmax(${minWidth}px, auto)`;
10926
+ return React__default.useMemo(() => {
10927
+ let printGridTemplateColumns = '';
10928
+ const printHiddenColumns = [];
10929
+ const gridTemplateColumns = allVisibleColumns.reduce((accum, column, index) => {
10930
+ var _column$columnDef$min, _column$columnDef$met;
10931
+ if (table.options.enableGrouping && column.getIsGrouped()) {
10932
+ return accum;
10933
+ }
10934
+ const minSize = (_column$columnDef$min = column.columnDef.minSize) !== null && _column$columnDef$min !== void 0 ? _column$columnDef$min : globalMinSize;
10935
+ const width = columnSizing[column.id];
10936
+ let size;
10937
+ let printSize;
10938
+ if (column.id === '__actions') {
10939
+ const minWidth = tableMeta.rowActions.rowActionsLength * 32 + 8; /* button margins l+r */
10940
+ size = `minmax(${minWidth}px, auto)`;
10941
+ } else if (width !== undefined) {
10942
+ const isLastColumn = index === allVisibleColumns.length - 1;
10943
+ if (width === 'grow' || Number.isNaN(width) && !isLastColumn) {
10944
+ size = `minmax(max-content, 1fr)`;
10948
10945
  } else {
10949
- size = `${minWidth}px`;
10946
+ const minWidth = width < minSize ? minSize : width;
10947
+ if (isLastColumn) {
10948
+ size = `minmax(${minWidth}px, auto)`;
10949
+ } else {
10950
+ size = `${minWidth}px`;
10951
+ }
10950
10952
  }
10953
+ } else {
10954
+ size = `minmax(max-content, auto)`;
10951
10955
  }
10952
- } else {
10953
- size = `minmax(max-content, auto)`;
10954
- }
10955
- if (((_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.enablePrinting) === false) {
10956
- printSize = '';
10957
- printHiddenColumns.push(column.id);
10958
- } else {
10959
- printSize = 'auto';
10960
- }
10961
- printGridTemplateColumns = `${printGridTemplateColumns} ${printSize}`.trim();
10962
- return `${accum} ${size}`.trim();
10963
- }, '');
10964
- // we have to be specific so that nested tables don't inherit the same css
10965
- const hiddenColumns = printHiddenColumns.map(id => `table[data-taco^='table']#${tableId} > thead > tr > th[data-cell-id='${id}']\n,table[data-taco^='table']#${tableId} > tbody > tr > td[data-cell-id='${id}']\n`).join(',');
10966
- const style = {
10967
- gridTemplateColumns,
10968
- gridTemplateRows
10969
- };
10970
- const stylesheet = `@media print { table[data-taco^='table']#${tableId} { grid-template-columns: ${printGridTemplateColumns}; } ${hiddenColumns ? `${hiddenColumns} { display: none; }` : ''}}`;
10971
- return {
10972
- style,
10973
- stylesheet
10974
- };
10956
+ if (((_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.enablePrinting) === false) {
10957
+ printSize = '';
10958
+ printHiddenColumns.push(column.id);
10959
+ } else {
10960
+ printSize = 'auto';
10961
+ }
10962
+ printGridTemplateColumns = `${printGridTemplateColumns} ${printSize}`.trim();
10963
+ return `${accum} ${size}`.trim();
10964
+ }, '');
10965
+ // we have to be specific so that nested tables don't inherit the same css
10966
+ const hiddenColumns = printHiddenColumns.map(id => `table[data-taco^='table']#${tableId} > thead > tr > th[data-cell-id='${id}']\n,table[data-taco^='table']#${tableId} > tbody > tr > td[data-cell-id='${id}']\n`).join(',');
10967
+ const style = {
10968
+ gridTemplateColumns,
10969
+ gridTemplateRows
10970
+ };
10971
+ const stylesheet = `@media print { table[data-taco^='table']#${tableId} { grid-template-columns: ${printGridTemplateColumns}; } ${hiddenColumns ? `${hiddenColumns} { display: none; }` : ''}}`;
10972
+ return {
10973
+ style,
10974
+ stylesheet
10975
+ };
10976
+ }, [allVisibleColumns, columnSizing, globalMinSize, tableMeta.rowActions.rowActionsLength]);
10975
10977
  }
10976
10978
 
10977
10979
  function useTableStyleColumnFreezing(tableId, table) {