@snack-uikit/table 0.37.20-preview-cccab544.0 → 0.37.20
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/CHANGELOG.md +8 -0
- 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/constants.d.ts +3 -0
- package/dist/cjs/constants.js +4 -1
- package/dist/cjs/exportTable.js +3 -3
- package/dist/cjs/helperComponents/Cells/HeaderCell/ResizeHandle.js +1 -1
- package/dist/cjs/helperComponents/ExportButton/ExportButton.js +6 -2
- package/dist/cjs/helperComponents/hooks.js +2 -2
- package/dist/esm/constants.d.ts +3 -0
- package/dist/esm/constants.js +3 -0
- package/dist/esm/helperComponents/ExportButton/ExportButton.js +4 -1
- package/package.json +5 -5
- package/src/constants.ts +3 -0
- package/src/helperComponents/ExportButton/ExportButton.tsx +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## <small>0.37.20 (2025-11-27)</small>
|
|
7
|
+
|
|
8
|
+
* fix(HCE-284): add data-test-id to export table ([2093390](https://github.com/cloud-ru-tech/snack-uikit/commit/2093390))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## <small>0.37.19 (2025-11-26)</small>
|
|
7
15
|
|
|
8
16
|
* fix(PDS-3189): fix selection with shift key for single row selection mode ([2cdfb64](https://github.com/cloud-ru-tech/snack-uikit/commit/2cdfb64))
|
|
@@ -304,7 +304,7 @@ function Table(_a) {
|
|
|
304
304
|
vars[flexKey] = '100%';
|
|
305
305
|
} else {
|
|
306
306
|
const originalColumnDefSize = originalColDef === null || originalColDef === void 0 ? void 0 : originalColDef.size;
|
|
307
|
-
let initSize = originalColumnDefSize ?
|
|
307
|
+
let initSize = originalColumnDefSize ? `${originalColumnDefSize}px` : '100%';
|
|
308
308
|
const prevSize = (_a = columnSizeVarsRef.current) === null || _a === void 0 ? void 0 : _a[sizeKey];
|
|
309
309
|
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;
|
|
310
310
|
if (isResizeSavedToStore) {
|
|
@@ -323,7 +323,7 @@ function Table(_a) {
|
|
|
323
323
|
if (currentSize !== colDefSize || i < resizedColumnIndex && prevSize === '100%') {
|
|
324
324
|
const realSize = prevSize === '100%' ? (0, utils_3.getCurrentlyConfiguredHeaderWidth)(header.id) : currentSize;
|
|
325
325
|
realSizes[header.id] = realSize;
|
|
326
|
-
size =
|
|
326
|
+
size = `${realSize}px`;
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
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/constants.d.ts
CHANGED
|
@@ -34,6 +34,9 @@ export declare const TEST_IDS: {
|
|
|
34
34
|
statusIndicator: string;
|
|
35
35
|
statusLabel: string;
|
|
36
36
|
toolbar: string;
|
|
37
|
+
exportIcon: string;
|
|
38
|
+
exportCsvAction: string;
|
|
39
|
+
exportXlsxAction: string;
|
|
37
40
|
};
|
|
38
41
|
export declare const SORT_FN: {
|
|
39
42
|
readonly DateTime: "datetime";
|
package/dist/cjs/constants.js
CHANGED
|
@@ -40,7 +40,10 @@ exports.TEST_IDS = {
|
|
|
40
40
|
},
|
|
41
41
|
statusIndicator: 'table__status-indicator',
|
|
42
42
|
statusLabel: 'table__status-label',
|
|
43
|
-
toolbar: 'table__toolbar'
|
|
43
|
+
toolbar: 'table__toolbar',
|
|
44
|
+
exportIcon: 'table__export-icon',
|
|
45
|
+
exportCsvAction: 'table__export-csv__action',
|
|
46
|
+
exportXlsxAction: 'table__export-xlsx__action'
|
|
44
47
|
};
|
|
45
48
|
exports.SORT_FN = {
|
|
46
49
|
DateTime: 'datetime',
|
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
|
});
|
|
@@ -10,6 +10,7 @@ const button_1 = require("@snack-uikit/button");
|
|
|
10
10
|
const icons_1 = require("@snack-uikit/icons");
|
|
11
11
|
const list_1 = require("@snack-uikit/list");
|
|
12
12
|
const locale_1 = require("@snack-uikit/locale");
|
|
13
|
+
const constants_1 = require("../../constants");
|
|
13
14
|
function ExportButton(_ref) {
|
|
14
15
|
let {
|
|
15
16
|
settings,
|
|
@@ -52,7 +53,8 @@ function ExportButton(_ref) {
|
|
|
52
53
|
});
|
|
53
54
|
setIsOpen(false);
|
|
54
55
|
},
|
|
55
|
-
hidden: !settings.exportToCSV
|
|
56
|
+
hidden: !settings.exportToCSV,
|
|
57
|
+
'data-test-id': constants_1.TEST_IDS.exportCsvAction
|
|
56
58
|
}, {
|
|
57
59
|
content: {
|
|
58
60
|
option: t('export') + 'XLSX'
|
|
@@ -66,10 +68,12 @@ function ExportButton(_ref) {
|
|
|
66
68
|
});
|
|
67
69
|
setIsOpen(false);
|
|
68
70
|
},
|
|
69
|
-
hidden: !settings.exportToXLSX
|
|
71
|
+
hidden: !settings.exportToXLSX,
|
|
72
|
+
'data-test-id': constants_1.TEST_IDS.exportXlsxAction
|
|
70
73
|
}],
|
|
71
74
|
children: (0, jsx_runtime_1.jsx)(button_1.ButtonFunction, {
|
|
72
75
|
size: 'm',
|
|
76
|
+
"data-test-id": constants_1.TEST_IDS.exportIcon,
|
|
73
77
|
icon: (0, jsx_runtime_1.jsx)(icons_1.DownloadSVG, {})
|
|
74
78
|
})
|
|
75
79
|
});
|
|
@@ -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/dist/esm/constants.d.ts
CHANGED
|
@@ -34,6 +34,9 @@ export declare const TEST_IDS: {
|
|
|
34
34
|
statusIndicator: string;
|
|
35
35
|
statusLabel: string;
|
|
36
36
|
toolbar: string;
|
|
37
|
+
exportIcon: string;
|
|
38
|
+
exportCsvAction: string;
|
|
39
|
+
exportXlsxAction: string;
|
|
37
40
|
};
|
|
38
41
|
export declare const SORT_FN: {
|
|
39
42
|
readonly DateTime: "datetime";
|
package/dist/esm/constants.js
CHANGED
|
@@ -35,6 +35,9 @@ export const TEST_IDS = {
|
|
|
35
35
|
statusIndicator: 'table__status-indicator',
|
|
36
36
|
statusLabel: 'table__status-label',
|
|
37
37
|
toolbar: 'table__toolbar',
|
|
38
|
+
exportIcon: 'table__export-icon',
|
|
39
|
+
exportCsvAction: 'table__export-csv__action',
|
|
40
|
+
exportXlsxAction: 'table__export-xlsx__action',
|
|
38
41
|
};
|
|
39
42
|
export const SORT_FN = {
|
|
40
43
|
DateTime: 'datetime',
|
|
@@ -4,6 +4,7 @@ import { ButtonFunction } from '@snack-uikit/button';
|
|
|
4
4
|
import { DownloadSVG } from '@snack-uikit/icons';
|
|
5
5
|
import { Droplist } from '@snack-uikit/list';
|
|
6
6
|
import { useLocale } from '@snack-uikit/locale';
|
|
7
|
+
import { TEST_IDS } from '../../constants';
|
|
7
8
|
export function ExportButton({ settings, data, columnDefinitions, topRows, centerRows, }) {
|
|
8
9
|
const [isOpen, setIsOpen] = useState(false);
|
|
9
10
|
const { t } = useLocale('Table');
|
|
@@ -24,6 +25,7 @@ export function ExportButton({ settings, data, columnDefinitions, topRows, cente
|
|
|
24
25
|
setIsOpen(false);
|
|
25
26
|
},
|
|
26
27
|
hidden: !settings.exportToCSV,
|
|
28
|
+
'data-test-id': TEST_IDS.exportCsvAction,
|
|
27
29
|
},
|
|
28
30
|
{
|
|
29
31
|
content: { option: t('export') + 'XLSX' },
|
|
@@ -33,6 +35,7 @@ export function ExportButton({ settings, data, columnDefinitions, topRows, cente
|
|
|
33
35
|
setIsOpen(false);
|
|
34
36
|
},
|
|
35
37
|
hidden: !settings.exportToXLSX,
|
|
38
|
+
'data-test-id': TEST_IDS.exportXlsxAction,
|
|
36
39
|
},
|
|
37
|
-
], children: _jsx(ButtonFunction, { size: 'm', icon: _jsx(DownloadSVG, {}) }) }));
|
|
40
|
+
], children: _jsx(ButtonFunction, { size: 'm', "data-test-id": TEST_IDS.exportIcon, icon: _jsx(DownloadSVG, {}) }) }));
|
|
38
41
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Table",
|
|
7
|
-
"version": "0.37.20
|
|
7
|
+
"version": "0.37.20",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -42,15 +42,15 @@
|
|
|
42
42
|
"@dnd-kit/sortable": "10.0.0",
|
|
43
43
|
"@dnd-kit/utilities": "3.2.2",
|
|
44
44
|
"@snack-uikit/button": "0.19.16",
|
|
45
|
-
"@snack-uikit/chips": "0.28.
|
|
45
|
+
"@snack-uikit/chips": "0.28.8",
|
|
46
46
|
"@snack-uikit/icons": "0.27.3",
|
|
47
47
|
"@snack-uikit/info-block": "0.6.33",
|
|
48
|
-
"@snack-uikit/list": "0.32.
|
|
48
|
+
"@snack-uikit/list": "0.32.7",
|
|
49
49
|
"@snack-uikit/pagination": "0.10.20",
|
|
50
50
|
"@snack-uikit/scroll": "0.10.5",
|
|
51
51
|
"@snack-uikit/skeleton": "0.6.9",
|
|
52
52
|
"@snack-uikit/toggles": "0.13.22",
|
|
53
|
-
"@snack-uikit/toolbar": "0.14.
|
|
53
|
+
"@snack-uikit/toolbar": "0.14.10",
|
|
54
54
|
"@snack-uikit/truncate-string": "0.7.4",
|
|
55
55
|
"@snack-uikit/typography": "0.8.11",
|
|
56
56
|
"@snack-uikit/utils": "4.0.0",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"@snack-uikit/locale": "*"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "b8c1f0b0f22c324815afb893a1272d62795d9091"
|
|
69
69
|
}
|
package/src/constants.ts
CHANGED
|
@@ -38,6 +38,9 @@ export const TEST_IDS = {
|
|
|
38
38
|
statusIndicator: 'table__status-indicator',
|
|
39
39
|
statusLabel: 'table__status-label',
|
|
40
40
|
toolbar: 'table__toolbar',
|
|
41
|
+
exportIcon: 'table__export-icon',
|
|
42
|
+
exportCsvAction: 'table__export-csv__action',
|
|
43
|
+
exportXlsxAction: 'table__export-xlsx__action',
|
|
41
44
|
};
|
|
42
45
|
|
|
43
46
|
export const SORT_FN = {
|
|
@@ -6,6 +6,7 @@ import { DownloadSVG } from '@snack-uikit/icons';
|
|
|
6
6
|
import { Droplist } from '@snack-uikit/list';
|
|
7
7
|
import { useLocale } from '@snack-uikit/locale';
|
|
8
8
|
|
|
9
|
+
import { TEST_IDS } from '../../constants';
|
|
9
10
|
import { ColumnDefinition } from '../../types';
|
|
10
11
|
|
|
11
12
|
type ExportProps<TData> = { fileName: string; columnDefinitions: ColumnDefinition<TData>[]; data: TData[] };
|
|
@@ -70,6 +71,7 @@ export function ExportButton<TData extends object>({
|
|
|
70
71
|
setIsOpen(false);
|
|
71
72
|
},
|
|
72
73
|
hidden: !settings.exportToCSV,
|
|
74
|
+
'data-test-id': TEST_IDS.exportCsvAction,
|
|
73
75
|
},
|
|
74
76
|
{
|
|
75
77
|
content: { option: t('export') + 'XLSX' },
|
|
@@ -78,10 +80,11 @@ export function ExportButton<TData extends object>({
|
|
|
78
80
|
setIsOpen(false);
|
|
79
81
|
},
|
|
80
82
|
hidden: !settings.exportToXLSX,
|
|
83
|
+
'data-test-id': TEST_IDS.exportXlsxAction,
|
|
81
84
|
},
|
|
82
85
|
]}
|
|
83
86
|
>
|
|
84
|
-
<ButtonFunction size='m' icon={<DownloadSVG />} />
|
|
87
|
+
<ButtonFunction size='m' data-test-id={TEST_IDS.exportIcon} icon={<DownloadSVG />} />
|
|
85
88
|
</Droplist>
|
|
86
89
|
);
|
|
87
90
|
}
|