@economic/taco 2.26.5 → 2.26.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,3 @@
1
- import React__default from 'react';
2
1
  import { getCellMinWidth } from '../../useTableManager/util/columns.js';
3
2
 
4
3
  function useTableStyleGrid(tableId, table, fontSize) {
@@ -8,57 +7,55 @@ function useTableStyleGrid(tableId, table, fontSize) {
8
7
  const globalMinSize = getCellMinWidth(fontSize);
9
8
  // header body ?footer
10
9
  const gridTemplateRows = table.getRowModel().rows.length ? 'min-content 1fr min-content' : 'min-content 1fr';
11
- return React__default.useMemo(() => {
12
- let printGridTemplateColumns = '';
13
- const printHiddenColumns = [];
14
- const gridTemplateColumns = allVisibleColumns.reduce((accum, column, index) => {
15
- var _column$columnDef$min, _column$columnDef$met;
16
- if (table.options.enableGrouping && column.getIsGrouped()) {
17
- return accum;
18
- }
19
- const minSize = (_column$columnDef$min = column.columnDef.minSize) !== null && _column$columnDef$min !== void 0 ? _column$columnDef$min : globalMinSize;
20
- const width = columnSizing[column.id];
21
- let size;
22
- let printSize;
23
- if (column.id === '__actions') {
24
- const minWidth = tableMeta.rowActions.rowActionsLength * 32 + 8; /* button margins l+r */
25
- size = `minmax(${minWidth}px, auto)`;
26
- } else if (width !== undefined) {
27
- const isLastColumn = index === allVisibleColumns.length - 1;
28
- if (width === 'grow' || Number.isNaN(width) && !isLastColumn) {
29
- size = `minmax(max-content, 1fr)`;
10
+ let printGridTemplateColumns = '';
11
+ const printHiddenColumns = [];
12
+ const gridTemplateColumns = allVisibleColumns.reduce((accum, column, index) => {
13
+ var _column$columnDef$min, _column$columnDef$met;
14
+ if (table.options.enableGrouping && column.getIsGrouped()) {
15
+ return accum;
16
+ }
17
+ const minSize = (_column$columnDef$min = column.columnDef.minSize) !== null && _column$columnDef$min !== void 0 ? _column$columnDef$min : globalMinSize;
18
+ const width = columnSizing[column.id];
19
+ let size;
20
+ let printSize;
21
+ if (column.id === '__actions') {
22
+ const minWidth = tableMeta.rowActions.rowActionsLength * 32 + 8; /* button margins l+r */
23
+ size = `minmax(${minWidth}px, auto)`;
24
+ } else if (width !== undefined) {
25
+ const isLastColumn = index === allVisibleColumns.length - 1;
26
+ if (width === 'grow' || Number.isNaN(width) && !isLastColumn) {
27
+ size = `minmax(max-content, 1fr)`;
28
+ } else {
29
+ const minWidth = width < minSize ? minSize : width;
30
+ if (isLastColumn) {
31
+ size = `minmax(${minWidth}px, auto)`;
30
32
  } else {
31
- const minWidth = width < minSize ? minSize : width;
32
- if (isLastColumn) {
33
- size = `minmax(${minWidth}px, auto)`;
34
- } else {
35
- size = `${minWidth}px`;
36
- }
33
+ size = `${minWidth}px`;
37
34
  }
38
- } else {
39
- size = `minmax(max-content, auto)`;
40
- }
41
- if (((_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.enablePrinting) === false) {
42
- printSize = '';
43
- printHiddenColumns.push(column.id);
44
- } else {
45
- printSize = 'auto';
46
35
  }
47
- printGridTemplateColumns = `${printGridTemplateColumns} ${printSize}`.trim();
48
- return `${accum} ${size}`.trim();
49
- }, '');
50
- // we have to be specific so that nested tables don't inherit the same css
51
- 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(',');
52
- const style = {
53
- gridTemplateColumns,
54
- gridTemplateRows
55
- };
56
- const stylesheet = `@media print { table[data-taco^='table']#${tableId} { grid-template-columns: ${printGridTemplateColumns}; } ${hiddenColumns ? `${hiddenColumns} { display: none; }` : ''}}`;
57
- return {
58
- style,
59
- stylesheet
60
- };
61
- }, [allVisibleColumns, columnSizing, globalMinSize, tableMeta.rowActions.rowActionsLength]);
36
+ } else {
37
+ size = `minmax(max-content, auto)`;
38
+ }
39
+ if (((_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.enablePrinting) === false) {
40
+ printSize = '';
41
+ printHiddenColumns.push(column.id);
42
+ } else {
43
+ printSize = 'auto';
44
+ }
45
+ printGridTemplateColumns = `${printGridTemplateColumns} ${printSize}`.trim();
46
+ return `${accum} ${size}`.trim();
47
+ }, '');
48
+ // we have to be specific so that nested tables don't inherit the same css
49
+ 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(',');
50
+ const style = {
51
+ gridTemplateColumns,
52
+ gridTemplateRows
53
+ };
54
+ const stylesheet = `@media print { table[data-taco^='table']#${tableId} { grid-template-columns: ${printGridTemplateColumns}; } ${hiddenColumns ? `${hiddenColumns} { display: none; }` : ''}}`;
55
+ return {
56
+ style,
57
+ stylesheet
58
+ };
62
59
  }
63
60
 
64
61
  export { useTableStyleGrid };
@@ -1 +1 @@
1
- {"version":3,"file":"useTableStyleGrid.js","sources":["../../../../../../../../../src/primitives/Table/Core/features/useTableStyleGrid.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { TableFontSize } from '../../types';\nimport { getCellMinWidth } from '../../useTableManager/util/columns';\n\nexport function useTableStyleGrid<TType = unknown>(tableId: string, table: ReactTable<TType>, fontSize: TableFontSize) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const allVisibleColumns = table.getVisibleLeafColumns();\n const columnSizing = table.getState().columnSizing;\n const globalMinSize = getCellMinWidth(fontSize);\n\n // header body ?footer\n const gridTemplateRows = table.getRowModel().rows.length ? 'min-content 1fr min-content' : 'min-content 1fr';\n\n return React.useMemo(() => {\n let printGridTemplateColumns = '';\n const printHiddenColumns: string[] = [];\n\n const gridTemplateColumns = allVisibleColumns.reduce((accum, column, index) => {\n if (table.options.enableGrouping && column.getIsGrouped()) {\n return accum;\n }\n\n const minSize = column.columnDef.minSize ?? globalMinSize;\n const width = columnSizing[column.id] as number | 'grow';\n\n let size;\n let printSize;\n\n if (column.id === '__actions') {\n const minWidth = tableMeta.rowActions.rowActionsLength * 32 + 8; /* button margins l+r */\n size = `minmax(${minWidth}px, auto)`;\n } else if (width !== undefined) {\n const isLastColumn = index === allVisibleColumns.length - 1;\n\n if (width === 'grow' || (Number.isNaN(width) && !isLastColumn)) {\n size = `minmax(max-content, 1fr)`;\n } else {\n const minWidth = width < minSize ? minSize : width;\n\n if (isLastColumn) {\n size = `minmax(${minWidth}px, auto)`;\n } else {\n size = `${minWidth}px`;\n }\n }\n } else {\n size = `minmax(max-content, auto)`;\n }\n\n if (column.columnDef.meta?.enablePrinting === false) {\n printSize = '';\n printHiddenColumns.push(column.id);\n } else {\n printSize = 'auto';\n }\n\n printGridTemplateColumns = `${printGridTemplateColumns} ${printSize}`.trim();\n\n return `${accum} ${size}`.trim();\n }, '');\n\n // we have to be specific so that nested tables don't inherit the same css\n const hiddenColumns = printHiddenColumns\n .map(\n id =>\n `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`\n )\n .join(',');\n\n const style: React.CSSProperties = {\n gridTemplateColumns,\n gridTemplateRows,\n };\n\n const stylesheet = `@media print { table[data-taco^='table']#${tableId} { grid-template-columns: ${printGridTemplateColumns}; } ${\n hiddenColumns ? `${hiddenColumns} { display: none; }` : ''\n }}`;\n\n return { style, stylesheet };\n }, [allVisibleColumns, columnSizing, globalMinSize, tableMeta.rowActions.rowActionsLength]);\n}\n"],"names":["useTableStyleGrid","tableId","table","fontSize","tableMeta","options","meta","allVisibleColumns","getVisibleLeafColumns","columnSizing","getState","globalMinSize","getCellMinWidth","gridTemplateRows","getRowModel","rows","length","React","useMemo","printGridTemplateColumns","printHiddenColumns","gridTemplateColumns","reduce","accum","column","index","enableGrouping","getIsGrouped","minSize","_column$columnDef$min","columnDef","width","id","size","printSize","minWidth","rowActions","rowActionsLength","undefined","isLastColumn","Number","isNaN","_column$columnDef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useTableStyleGrid.js","sources":["../../../../../../../../../src/primitives/Table/Core/features/useTableStyleGrid.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { TableFontSize } from '../../types';\nimport { getCellMinWidth } from '../../useTableManager/util/columns';\n\nexport function useTableStyleGrid<TType = unknown>(tableId: string, table: ReactTable<TType>, fontSize: TableFontSize) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const allVisibleColumns = table.getVisibleLeafColumns();\n const columnSizing = table.getState().columnSizing;\n const globalMinSize = getCellMinWidth(fontSize);\n\n // header body ?footer\n const gridTemplateRows = table.getRowModel().rows.length ? 'min-content 1fr min-content' : 'min-content 1fr';\n\n let printGridTemplateColumns = '';\n const printHiddenColumns: string[] = [];\n\n const gridTemplateColumns = allVisibleColumns.reduce((accum, column, index) => {\n if (table.options.enableGrouping && column.getIsGrouped()) {\n return accum;\n }\n\n const minSize = column.columnDef.minSize ?? globalMinSize;\n const width = columnSizing[column.id] as number | 'grow';\n\n let size;\n let printSize;\n\n if (column.id === '__actions') {\n const minWidth = tableMeta.rowActions.rowActionsLength * 32 + 8; /* button margins l+r */\n size = `minmax(${minWidth}px, auto)`;\n } else if (width !== undefined) {\n const isLastColumn = index === allVisibleColumns.length - 1;\n\n if (width === 'grow' || (Number.isNaN(width) && !isLastColumn)) {\n size = `minmax(max-content, 1fr)`;\n } else {\n const minWidth = width < minSize ? minSize : width;\n\n if (isLastColumn) {\n size = `minmax(${minWidth}px, auto)`;\n } else {\n size = `${minWidth}px`;\n }\n }\n } else {\n size = `minmax(max-content, auto)`;\n }\n\n if (column.columnDef.meta?.enablePrinting === false) {\n printSize = '';\n printHiddenColumns.push(column.id);\n } else {\n printSize = 'auto';\n }\n\n printGridTemplateColumns = `${printGridTemplateColumns} ${printSize}`.trim();\n\n return `${accum} ${size}`.trim();\n }, '');\n\n // we have to be specific so that nested tables don't inherit the same css\n const hiddenColumns = printHiddenColumns\n .map(\n id =>\n `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`\n )\n .join(',');\n\n const style: React.CSSProperties = {\n gridTemplateColumns,\n gridTemplateRows,\n };\n\n const stylesheet = `@media print { table[data-taco^='table']#${tableId} { grid-template-columns: ${printGridTemplateColumns}; } ${\n hiddenColumns ? `${hiddenColumns} { display: none; }` : ''\n }}`;\n\n return { style, stylesheet };\n}\n"],"names":["useTableStyleGrid","tableId","table","fontSize","tableMeta","options","meta","allVisibleColumns","getVisibleLeafColumns","columnSizing","getState","globalMinSize","getCellMinWidth","gridTemplateRows","getRowModel","rows","length","printGridTemplateColumns","printHiddenColumns","gridTemplateColumns","reduce","accum","column","index","enableGrouping","getIsGrouped","minSize","_column$columnDef$min","columnDef","width","id","size","printSize","minWidth","rowActions","rowActionsLength","undefined","isLastColumn","Number","isNaN","_column$columnDef$met","enablePrinting","push","trim","hiddenColumns","map","join","style","stylesheet"],"mappings":";;SAKgBA,iBAAiBA,CAAkBC,OAAe,EAAEC,KAAwB,EAAEC,QAAuB;EACjH,MAAMC,SAAS,GAAGF,KAAK,CAACG,OAAO,CAACC,IAA6B;EAC7D,MAAMC,iBAAiB,GAAGL,KAAK,CAACM,qBAAqB,EAAE;EACvD,MAAMC,YAAY,GAAGP,KAAK,CAACQ,QAAQ,EAAE,CAACD,YAAY;EAClD,MAAME,aAAa,GAAGC,eAAe,CAACT,QAAQ,CAAC;;EAG/C,MAAMU,gBAAgB,GAAGX,KAAK,CAACY,WAAW,EAAE,CAACC,IAAI,CAACC,MAAM,GAAG,6BAA6B,GAAG,iBAAiB;EAE5G,IAAIC,wBAAwB,GAAG,EAAE;EACjC,MAAMC,kBAAkB,GAAa,EAAE;EAEvC,MAAMC,mBAAmB,GAAGZ,iBAAiB,CAACa,MAAM,CAAC,CAACC,KAAK,EAAEC,MAAM,EAAEC,KAAK;;IACtE,IAAIrB,KAAK,CAACG,OA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