@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.
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableStyleGrid.js +46 -49
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableStyleGrid.js.map +1 -1
- package/dist/primitives/Table/Core/features/useTableStyle.d.ts +60 -60
- package/dist/taco.cjs.development.js +46 -48
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +2 -2
@@ -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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
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
|
-
|
48
|
-
|
49
|
-
}
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
}
|
56
|
-
|
57
|
-
return {
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
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 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,OAAO,CAACmB,cAAc,IAAIF,MAAM,CAACG,YAAY,EAAE,EAAE;MACvD,OAAOJ,KAAK;;IAGhB,MAAMK,OAAO,IAAAC,qBAAA,GAAGL,MAAM,CAACM,SAAS,CAACF,OAAO,cAAAC,qBAAA,cAAAA,qBAAA,GAAIhB,aAAa;IACzD,MAAMkB,KAAK,GAAGpB,YAAY,CAACa,MAAM,CAACQ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