@snack-uikit/table 0.38.4 → 0.38.5-preview-bf2b6776.0
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.
- package/dist/cjs/components/Table/Table.js +2 -2
- package/dist/cjs/components/Table/hooks/useColumnOrderByDrag/utils/prepareInitialState.js +1 -1
- package/dist/cjs/components/Table/hooks/useColumnSettings/useColumnSettings.js +1 -1
- package/dist/cjs/components/Table/utils/columnSize.js +2 -2
- package/dist/cjs/components/Table/utils/getColumnStyleVars.js +2 -2
- package/dist/cjs/components/Table/utils/getCurrentlyConfiguredHeaderWidth.js +1 -1
- package/dist/cjs/exportTable.js +3 -3
- package/dist/cjs/helperComponents/Cells/HeaderCell/ResizeHandle.js +1 -1
- package/dist/cjs/helperComponents/hooks.js +2 -2
- package/package.json +7 -7
|
@@ -296,7 +296,7 @@ function Table(_a) {
|
|
|
296
296
|
vars[flexKey] = '100%';
|
|
297
297
|
} else {
|
|
298
298
|
const originalColumnDefSize = originalColDef === null || originalColDef === void 0 ? void 0 : originalColDef.size;
|
|
299
|
-
let initSize = originalColumnDefSize ?
|
|
299
|
+
let initSize = originalColumnDefSize ? `${originalColumnDefSize}px` : '100%';
|
|
300
300
|
const prevSize = (_a = columnSizeVarsRef.current) === null || _a === void 0 ? void 0 : _a[sizeKey];
|
|
301
301
|
const isResizeSavedToStore = (originalColDef === null || originalColDef === void 0 ? void 0 : originalColDef.enableResizing) && (savedState === null || savedState === void 0 ? void 0 : savedState.id) && (savedState === null || savedState === void 0 ? void 0 : savedState.resize) !== false;
|
|
302
302
|
if (isResizeSavedToStore) {
|
|
@@ -315,7 +315,7 @@ function Table(_a) {
|
|
|
315
315
|
if (currentSize !== colDefSize || i < resizedColumnIndex && prevSize === '100%') {
|
|
316
316
|
const realSize = prevSize === '100%' ? (0, utils_3.getCurrentlyConfiguredHeaderWidth)(header.id) : currentSize;
|
|
317
317
|
realSizes[header.id] = realSize;
|
|
318
|
-
size =
|
|
318
|
+
size = `${realSize}px`;
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
321
|
if (isResizeSavedToStore) {
|
|
@@ -7,7 +7,7 @@ exports.getLocalStorageColumnOrderKey = void 0;
|
|
|
7
7
|
exports.prepareInitialState = prepareInitialState;
|
|
8
8
|
const utils_1 = require("@snack-uikit/utils");
|
|
9
9
|
const utils_2 = require("../../../utils");
|
|
10
|
-
const getLocalStorageColumnOrderKey = id =>
|
|
10
|
+
const getLocalStorageColumnOrderKey = id => `${id}_columnOrder`;
|
|
11
11
|
exports.getLocalStorageColumnOrderKey = getLocalStorageColumnOrderKey;
|
|
12
12
|
function prepareInitialState(tableColumns, savedState) {
|
|
13
13
|
const columnOrder = tableColumns.filter(column => column.pinned !== 'left' && column.pinned !== 'right').map(utils_2.getColumnIdentifier);
|
|
@@ -22,7 +22,7 @@ function useColumnSettings(_ref) {
|
|
|
22
22
|
const {
|
|
23
23
|
t
|
|
24
24
|
} = (0, locale_1.useLocale)('Table');
|
|
25
|
-
const localStorageKey =
|
|
25
|
+
const localStorageKey = `${savedState === null || savedState === void 0 ? void 0 : savedState.id}_columnSettings`;
|
|
26
26
|
const configurableColumns = (0, react_1.useMemo)(() => columnDefinitions.filter(utils_3.isColumnVisibilityConfigurable), [columnDefinitions]);
|
|
27
27
|
const [enabledColumns, setEnabledColumns] = (0, react_1.useState)(() => (0, utils_3.getEnabledColumnsInitialState)(configurableColumns, savedState, localStorageKey));
|
|
28
28
|
const setEnabledColumnsOuter = (0, react_1.useCallback)(value => {
|
|
@@ -18,7 +18,7 @@ function getInitColumnSizeFromLocalStorage(_ref) {
|
|
|
18
18
|
if (!savedStateFromStorage) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
return (_a = savedStateFromStorage.resizeState) === null || _a === void 0 ? void 0 : _a[
|
|
21
|
+
return (_a = savedStateFromStorage.resizeState) === null || _a === void 0 ? void 0 : _a[`${RESIZED_KEY}-${columnId}`];
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
function saveStateToLocalStorage(_ref2) {
|
|
@@ -30,7 +30,7 @@ function saveStateToLocalStorage(_ref2) {
|
|
|
30
30
|
if ((0, utils_1.isBrowser)()) {
|
|
31
31
|
const savedStateFromStorage = JSON.parse(localStorage.getItem(id) || 'null');
|
|
32
32
|
const newResizeState = (savedStateFromStorage === null || savedStateFromStorage === void 0 ? void 0 : savedStateFromStorage.resizeState) || {};
|
|
33
|
-
newResizeState[
|
|
33
|
+
newResizeState[`${RESIZED_KEY}-${columnId}`] = size;
|
|
34
34
|
localStorage.setItem(id, JSON.stringify(Object.assign(Object.assign({}, savedStateFromStorage || {}), {
|
|
35
35
|
resizeState: newResizeState
|
|
36
36
|
})));
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getColumnStyleVars = getColumnStyleVars;
|
|
7
7
|
function getColumnStyleVars(id) {
|
|
8
8
|
return {
|
|
9
|
-
sizeKey:
|
|
10
|
-
flexKey:
|
|
9
|
+
sizeKey: `--table-column-${id}-size`,
|
|
10
|
+
flexKey: `--table-column-${id}-flex`
|
|
11
11
|
};
|
|
12
12
|
}
|
|
@@ -7,7 +7,7 @@ exports.getCurrentlyConfiguredHeaderWidth = getCurrentlyConfiguredHeaderWidth;
|
|
|
7
7
|
const utils_1 = require("@snack-uikit/utils");
|
|
8
8
|
function getCurrentlyConfiguredHeaderWidth(id) {
|
|
9
9
|
if ((0, utils_1.isBrowser)()) {
|
|
10
|
-
const cell = document.querySelector(
|
|
10
|
+
const cell = document.querySelector(`[data-header-id="${id}"]`);
|
|
11
11
|
const resizeHandler = cell === null || cell === void 0 ? void 0 : cell.querySelector('[data-test-id="table__header-cell-resize-handle-moving-part"]');
|
|
12
12
|
if (cell) {
|
|
13
13
|
const {
|
package/dist/cjs/exportTable.js
CHANGED
|
@@ -67,9 +67,9 @@ function exportToCSV(_ref2) {
|
|
|
67
67
|
const table = [headers, ...xlsxData];
|
|
68
68
|
const csv = table.map(line => line.map(el => {
|
|
69
69
|
if (Array.isArray(el)) {
|
|
70
|
-
return "
|
|
70
|
+
return `"${el.join(', ')}"`;
|
|
71
71
|
}
|
|
72
|
-
return el === undefined ? "
|
|
72
|
+
return el === undefined ? `""` : `"${el}"`;
|
|
73
73
|
}).join(',')).join('\n');
|
|
74
74
|
const utf8Prefix = new Uint8Array([0xef, 0xbb, 0xbf]);
|
|
75
75
|
const blob = new Blob([utf8Prefix, csv], {
|
|
@@ -126,6 +126,6 @@ function exportToXLSX(_ref3) {
|
|
|
126
126
|
worksheet['!cols'] = getColumnsWidth(worksheetData);
|
|
127
127
|
}
|
|
128
128
|
xlsx_1.utils.book_append_sheet(workbook, worksheet);
|
|
129
|
-
(0, xlsx_1.writeFileXLSX)(workbook,
|
|
129
|
+
(0, xlsx_1.writeFileXLSX)(workbook, `${fileName}.xlsx`);
|
|
130
130
|
return worksheet;
|
|
131
131
|
}
|
|
@@ -72,7 +72,7 @@ function ResizeHandle(_ref2) {
|
|
|
72
72
|
"data-test-id": 'table__header-cell-resize-handle-moving-part',
|
|
73
73
|
className: styles_module_scss_1.default.tableHeaderResizeIndicator,
|
|
74
74
|
style: {
|
|
75
|
-
'--offset':
|
|
75
|
+
'--offset': `${offset}px`
|
|
76
76
|
}
|
|
77
77
|
})]
|
|
78
78
|
});
|
|
@@ -75,8 +75,8 @@ function useCellSizes(element, options) {
|
|
|
75
75
|
});
|
|
76
76
|
const minWidth = column.columnDef.minSize;
|
|
77
77
|
const maxWidth = column.columnDef.maxSize;
|
|
78
|
-
const width =
|
|
79
|
-
const flexShrink =
|
|
78
|
+
const width = `var(--table-column-${column.id}-size)`;
|
|
79
|
+
const flexShrink = `var(--table-column-${column.id}-flex)`;
|
|
80
80
|
const isHeaderCell = 'headerGroup' in element;
|
|
81
81
|
return (0, react_1.useMemo)(() => {
|
|
82
82
|
const styles = {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Table",
|
|
7
|
-
"version": "0.38.
|
|
7
|
+
"version": "0.38.5-preview-bf2b6776.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -42,16 +42,16 @@
|
|
|
42
42
|
"@dnd-kit/sortable": "10.0.0",
|
|
43
43
|
"@dnd-kit/utilities": "3.2.2",
|
|
44
44
|
"@snack-uikit/button": "0.19.17",
|
|
45
|
-
"@snack-uikit/chips": "0.28.
|
|
45
|
+
"@snack-uikit/chips": "0.28.18-preview-bf2b6776.0",
|
|
46
46
|
"@snack-uikit/icons": "0.27.7",
|
|
47
|
-
"@snack-uikit/info-block": "0.6.
|
|
48
|
-
"@snack-uikit/list": "0.32.
|
|
47
|
+
"@snack-uikit/info-block": "0.6.40-preview-bf2b6776.0",
|
|
48
|
+
"@snack-uikit/list": "0.32.17-preview-bf2b6776.0",
|
|
49
49
|
"@snack-uikit/pagination": "0.10.24",
|
|
50
50
|
"@snack-uikit/scroll": "0.10.8",
|
|
51
51
|
"@snack-uikit/skeleton": "0.6.10",
|
|
52
52
|
"@snack-uikit/toggles": "0.13.26",
|
|
53
|
-
"@snack-uikit/toolbar": "0.14.
|
|
54
|
-
"@snack-uikit/truncate-string": "0.7.
|
|
53
|
+
"@snack-uikit/toolbar": "0.14.22-preview-bf2b6776.0",
|
|
54
|
+
"@snack-uikit/truncate-string": "0.7.11-preview-bf2b6776.0",
|
|
55
55
|
"@snack-uikit/typography": "0.8.12",
|
|
56
56
|
"@snack-uikit/utils": "4.0.1",
|
|
57
57
|
"@tanstack/match-sorter-utils": "8.11.8",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"@snack-uikit/locale": "*"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "8bd281dded73549f18334e96434af37cf809f683"
|
|
69
69
|
}
|