@snack-uikit/table 0.25.13-preview-03091779.0 → 0.25.13
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 +11 -0
- package/README.md +0 -6
- package/dist/cjs/components/Table/Table.d.ts +2 -2
- package/dist/cjs/components/Table/Table.js +23 -44
- package/dist/cjs/components/Table/styles.module.css +0 -3
- package/dist/cjs/components/Table/utils.d.ts +0 -10
- package/dist/cjs/components/Table/utils.js +0 -19
- package/dist/cjs/components/types.d.ts +1 -5
- package/dist/cjs/helperComponents/Rows/BodyRow.d.ts +2 -3
- package/dist/cjs/helperComponents/Rows/BodyRow.js +9 -20
- package/dist/cjs/helperComponents/Rows/Row.d.ts +5 -4
- package/dist/cjs/helperComponents/Rows/Row.js +3 -5
- package/dist/esm/components/Table/Table.d.ts +2 -2
- package/dist/esm/components/Table/Table.js +10 -24
- package/dist/esm/components/Table/styles.module.css +0 -3
- package/dist/esm/components/Table/utils.d.ts +0 -10
- package/dist/esm/components/Table/utils.js +0 -14
- package/dist/esm/components/types.d.ts +1 -5
- package/dist/esm/helperComponents/Rows/BodyRow.d.ts +2 -3
- package/dist/esm/helperComponents/Rows/BodyRow.js +4 -17
- package/dist/esm/helperComponents/Rows/Row.d.ts +5 -4
- package/dist/esm/helperComponents/Rows/Row.js +3 -4
- package/package.json +5 -7
- package/src/components/Table/Table.tsx +14 -44
- package/src/components/Table/styles.module.scss +0 -5
- package/src/components/Table/{utils.tsx → utils.ts} +0 -18
- package/src/components/types.ts +1 -9
- package/src/helperComponents/Rows/BodyRow.tsx +47 -53
- package/src/helperComponents/Rows/Row.tsx +9 -8
- package/dist/cjs/components/Table/hooks/useRowVirtualizer.d.ts +0 -2
- package/dist/cjs/components/Table/hooks/useRowVirtualizer.js +0 -45
- package/dist/cjs/helperComponents/Rows/VirtualRow.d.ts +0 -7
- package/dist/cjs/helperComponents/Rows/VirtualRow.js +0 -40
- package/dist/esm/components/Table/hooks/useRowVirtualizer.d.ts +0 -2
- package/dist/esm/components/Table/hooks/useRowVirtualizer.js +0 -29
- package/dist/esm/helperComponents/Rows/VirtualRow.d.ts +0 -7
- package/dist/esm/helperComponents/Rows/VirtualRow.js +0 -28
- package/src/components/Table/hooks/useRowVirtualizer.ts +0 -51
- package/src/helperComponents/Rows/VirtualRow.tsx +0 -31
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
## 0.25.13 (2024-12-12)
|
|
7
|
+
|
|
8
|
+
### Only dependencies have been changed
|
|
9
|
+
* [@snack-uikit/chips@0.22.2](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/chips/CHANGELOG.md)
|
|
10
|
+
* [@snack-uikit/list@0.21.9](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/list/CHANGELOG.md)
|
|
11
|
+
* [@snack-uikit/toolbar@0.9.11](https://github.com/cloud-ru-tech/snack-uikit/blob/master/packages/toolbar/CHANGELOG.md)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 0.25.12 (2024-12-04)
|
|
7
18
|
|
|
8
19
|
### Only dependencies have been changed
|
package/README.md
CHANGED
|
@@ -148,9 +148,6 @@ const columnDefinitions: ColumnDefinition<TableData>[] = [
|
|
|
148
148
|
| scrollContainerRef | `RefObject<HTMLElement>` | - | Ссылка на контейнер, который скроллится |
|
|
149
149
|
| rowPinning | `Pick<RowPinningState, "top">` | { top: [], } | Определение какие строки должны быть закреплены в таблице |
|
|
150
150
|
| savedState | `{ id: string; resize?: boolean; }` | - | Конфиг для сохранения состояния в localStorage. <br> Поле id должно быть уникальным для разных таблиц в рамках приложения. <br> Для корректной работы необходимо наличие id в конфиге columnDefinitions |
|
|
151
|
-
| enableRowVirtualization | `boolean` | - | |
|
|
152
|
-
| rowVirtualizerOptions | `PartialKeys<VirtualizerOptions<Element, Element>, "observeElementRect" \| "observeElementOffset" \| "scrollToFn">` | - | |
|
|
153
|
-
| rowVirtualizerInstanceRef | `MutableRefObject<Virtualizer<Element, Element>>` | - | |
|
|
154
151
|
## Table.getStatusColumnDef
|
|
155
152
|
Вспомогательная функция для создания ячейки со статусом
|
|
156
153
|
### Props
|
|
@@ -211,9 +208,6 @@ const columnDefinitions: ColumnDefinition<TableData>[] = [
|
|
|
211
208
|
| scrollContainerRef | `RefObject<HTMLElement>` | - | Ссылка на контейнер, который скроллится |
|
|
212
209
|
| rowPinning | `Pick<RowPinningState, "top">` | - | Определение какие строки должны быть закреплены в таблице |
|
|
213
210
|
| savedState | `{ id: string; resize?: boolean; }` | - | Конфиг для сохранения состояния в localStorage. <br> Поле id должно быть уникальным для разных таблиц в рамках приложения. <br> Для корректной работы необходимо наличие id в конфиге columnDefinitions |
|
|
214
|
-
| enableRowVirtualization | `boolean` | - | |
|
|
215
|
-
| rowVirtualizerOptions | `PartialKeys<VirtualizerOptions<Element, Element>, "observeElementRect" \| "observeElementOffset" \| "scrollToFn">` | - | |
|
|
216
|
-
| rowVirtualizerInstanceRef | `MutableRefObject<Virtualizer<Element, Element>>` | - | |
|
|
217
211
|
| items | `TData[]` | - | Данные для отрисовки |
|
|
218
212
|
| total | `number` | 10 | Общее кол-во строк |
|
|
219
213
|
| limit | `number` | 10 | Кол-во строк на страницу |
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TableProps } from '../types';
|
|
2
2
|
/** Компонент таблицы */
|
|
3
|
-
export declare function Table<TData extends object>({ data, rowPinning, columnDefinitions, keepPinnedRows, copyPinnedRows, enableSelectPinned, rowSelection: rowSelectionProp, search, sorting: sortingProp, columnFilters, pagination: paginationProp, className, onRowClick, onRefresh, onDelete, pageSize, pageCount, loading, outline, moreActions, exportSettings, dataFiltered, dataError, noDataState, noResultsState, errorDataState, suppressToolbar, toolbarBefore, toolbarAfter, suppressPagination, manualSorting, manualPagination, manualFiltering, autoResetPageIndex, scrollRef, scrollContainerRef, getRowId, enableFuzzySearch, savedState,
|
|
3
|
+
export declare function Table<TData extends object>({ data, rowPinning, columnDefinitions, keepPinnedRows, copyPinnedRows, enableSelectPinned, rowSelection: rowSelectionProp, search, sorting: sortingProp, columnFilters, pagination: paginationProp, className, onRowClick, onRefresh, onDelete, pageSize, pageCount, loading, outline, moreActions, exportSettings, dataFiltered, dataError, noDataState, noResultsState, errorDataState, suppressToolbar, toolbarBefore, toolbarAfter, suppressPagination, manualSorting, manualPagination, manualFiltering, autoResetPageIndex, scrollRef, scrollContainerRef, getRowId, enableFuzzySearch, savedState, ...rest }: TableProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export declare namespace Table {
|
|
5
5
|
var getStatusColumnDef: typeof import("../../helperComponents").getStatusColumnDef;
|
|
6
|
-
var getRowActionsColumnDef: typeof import("../../helperComponents").getRowActionsColumnDef;
|
|
7
6
|
var statusAppearances: Record<string, string>;
|
|
7
|
+
var getRowActionsColumnDef: typeof import("../../helperComponents").getRowActionsColumnDef;
|
|
8
8
|
}
|
|
@@ -20,25 +20,22 @@ exports.Table = Table;
|
|
|
20
20
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
21
21
|
const react_table_1 = require("@tanstack/react-table");
|
|
22
22
|
const classnames_1 = __importDefault(require("classnames"));
|
|
23
|
-
const merge_refs_1 = __importDefault(require("merge-refs"));
|
|
24
23
|
const react_1 = require("react");
|
|
25
24
|
const locale_1 = require("@snack-uikit/locale");
|
|
26
25
|
const scroll_1 = require("@snack-uikit/scroll");
|
|
27
26
|
const skeleton_1 = require("@snack-uikit/skeleton");
|
|
28
27
|
const toolbar_1 = require("@snack-uikit/toolbar");
|
|
28
|
+
const truncate_string_1 = require("@snack-uikit/truncate-string");
|
|
29
29
|
const utils_1 = require("@snack-uikit/utils");
|
|
30
30
|
const constants_1 = require("../../constants");
|
|
31
31
|
const helperComponents_1 = require("../../helperComponents");
|
|
32
|
-
const VirtualRow_1 = require("../../helperComponents/Rows/VirtualRow");
|
|
33
32
|
const utils_2 = require("../../utils");
|
|
34
33
|
const hooks_1 = require("./hooks");
|
|
35
34
|
const usePageReset_1 = require("./hooks/usePageReset");
|
|
36
|
-
const useRowVirtualizer_1 = require("./hooks/useRowVirtualizer");
|
|
37
35
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
38
36
|
const utils_3 = require("./utils");
|
|
39
37
|
/** Компонент таблицы */
|
|
40
38
|
function Table(_a) {
|
|
41
|
-
var _b;
|
|
42
39
|
var {
|
|
43
40
|
data,
|
|
44
41
|
rowPinning = {
|
|
@@ -80,12 +77,9 @@ function Table(_a) {
|
|
|
80
77
|
scrollContainerRef,
|
|
81
78
|
getRowId,
|
|
82
79
|
enableFuzzySearch,
|
|
83
|
-
savedState
|
|
84
|
-
enableRowVirtualization,
|
|
85
|
-
rowVirtualizerOptions,
|
|
86
|
-
rowVirtualizerInstanceRef
|
|
80
|
+
savedState
|
|
87
81
|
} = _a,
|
|
88
|
-
rest = __rest(_a, ["data", "rowPinning", "columnDefinitions", "keepPinnedRows", "copyPinnedRows", "enableSelectPinned", "rowSelection", "search", "sorting", "columnFilters", "pagination", "className", "onRowClick", "onRefresh", "onDelete", "pageSize", "pageCount", "loading", "outline", "moreActions", "exportSettings", "dataFiltered", "dataError", "noDataState", "noResultsState", "errorDataState", "suppressToolbar", "toolbarBefore", "toolbarAfter", "suppressPagination", "manualSorting", "manualPagination", "manualFiltering", "autoResetPageIndex", "scrollRef", "scrollContainerRef", "getRowId", "enableFuzzySearch", "savedState"
|
|
82
|
+
rest = __rest(_a, ["data", "rowPinning", "columnDefinitions", "keepPinnedRows", "copyPinnedRows", "enableSelectPinned", "rowSelection", "search", "sorting", "columnFilters", "pagination", "className", "onRowClick", "onRefresh", "onDelete", "pageSize", "pageCount", "loading", "outline", "moreActions", "exportSettings", "dataFiltered", "dataError", "noDataState", "noResultsState", "errorDataState", "suppressToolbar", "toolbarBefore", "toolbarAfter", "suppressPagination", "manualSorting", "manualPagination", "manualFiltering", "autoResetPageIndex", "scrollRef", "scrollContainerRef", "getRowId", "enableFuzzySearch", "savedState"]);
|
|
89
83
|
const {
|
|
90
84
|
state: globalFilter,
|
|
91
85
|
onStateChange: onGlobalFilterChange
|
|
@@ -107,7 +101,6 @@ function Table(_a) {
|
|
|
107
101
|
onStateChange: onPaginationChange
|
|
108
102
|
} = (0, hooks_1.useStateControl)(paginationProp, defaultPaginationState);
|
|
109
103
|
const enableSelection = Boolean(rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.enable);
|
|
110
|
-
const tableContainerRef = (0, react_1.useRef)(null);
|
|
111
104
|
const tableColumns = (0, react_1.useMemo)(() => {
|
|
112
105
|
let cols = columnDefinitions;
|
|
113
106
|
if (enableSelection) {
|
|
@@ -145,7 +138,10 @@ function Table(_a) {
|
|
|
145
138
|
enableSorting: false,
|
|
146
139
|
enableResizing: false,
|
|
147
140
|
minSize: 40,
|
|
148
|
-
cell:
|
|
141
|
+
cell: cell => (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, {
|
|
142
|
+
text: String(cell.getValue()),
|
|
143
|
+
maxLines: 1
|
|
144
|
+
})
|
|
149
145
|
},
|
|
150
146
|
manualSorting,
|
|
151
147
|
manualPagination,
|
|
@@ -168,12 +164,7 @@ function Table(_a) {
|
|
|
168
164
|
getPaginationRowModel: (0, react_table_1.getPaginationRowModel)(),
|
|
169
165
|
getCoreRowModel: (0, react_table_1.getCoreRowModel)(),
|
|
170
166
|
columnResizeMode: 'onEnd',
|
|
171
|
-
keepPinnedRows
|
|
172
|
-
meta: {
|
|
173
|
-
tableContainerRef,
|
|
174
|
-
rowVirtualizerInstanceRef,
|
|
175
|
-
rowVirtualizerOptions
|
|
176
|
-
}
|
|
167
|
+
keepPinnedRows
|
|
177
168
|
});
|
|
178
169
|
const {
|
|
179
170
|
loadingTable
|
|
@@ -213,13 +204,10 @@ function Table(_a) {
|
|
|
213
204
|
}, [loading, rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow, table, enableSelectPinned]);
|
|
214
205
|
const columnSizeVarsRef = (0, react_1.useRef)();
|
|
215
206
|
const headers = table.getFlatHeaders();
|
|
216
|
-
const
|
|
217
|
-
const cssSizeVars = (0, react_1.useMemo)(() => {
|
|
207
|
+
const columnSizeVars = (0, react_1.useMemo)(() => {
|
|
218
208
|
var _a;
|
|
219
209
|
const originalColumnDefs = table._getColumnDefs();
|
|
220
|
-
const colSizes =
|
|
221
|
-
height: `${rowVirtualizer.getTotalSize()}px`
|
|
222
|
-
} : {};
|
|
210
|
+
const colSizes = {};
|
|
223
211
|
for (let i = 0; i < headers.length; i++) {
|
|
224
212
|
const header = headers[i];
|
|
225
213
|
const {
|
|
@@ -279,8 +267,8 @@ function Table(_a) {
|
|
|
279
267
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
280
268
|
}, [table.getState().columnSizingInfo.isResizingColumn, headers, table.getTotalSize()]);
|
|
281
269
|
(0, react_1.useEffect)(() => {
|
|
282
|
-
columnSizeVarsRef.current =
|
|
283
|
-
}, [
|
|
270
|
+
columnSizeVarsRef.current = columnSizeVars;
|
|
271
|
+
}, [columnSizeVars]);
|
|
284
272
|
const tableRows = table.getRowModel().rows;
|
|
285
273
|
const tableCenterRows = table.getCenterRows();
|
|
286
274
|
const tableFilteredRows = table.getFilteredRowModel().rows;
|
|
@@ -302,9 +290,6 @@ function Table(_a) {
|
|
|
302
290
|
const tempPageSize = (!suppressPagination ? tablePagination === null || tablePagination === void 0 ? void 0 : tablePagination.pageSize : pageSize) + filteredTopRows.length;
|
|
303
291
|
return !tableRows.length ? Math.min(Math.max(tempPageSize, 5), constants_1.DEFAULT_PAGE_SIZE) : tempPageSize;
|
|
304
292
|
}, [filteredTopRows.length, pageSize, suppressPagination, tablePagination === null || tablePagination === void 0 ? void 0 : tablePagination.pageSize, tableRows.length]);
|
|
305
|
-
const tableCtx = (0, react_1.useMemo)(() => ({
|
|
306
|
-
table
|
|
307
|
-
}), [table]);
|
|
308
293
|
(0, usePageReset_1.usePageReset)({
|
|
309
294
|
manualPagination,
|
|
310
295
|
maximumAvailablePage: pageCount || data.length / pagination.pageSize,
|
|
@@ -357,12 +342,14 @@ function Table(_a) {
|
|
|
357
342
|
children: (0, jsx_runtime_1.jsxs)(scroll_1.Scroll, {
|
|
358
343
|
size: 's',
|
|
359
344
|
className: styles_module_scss_1.default.table,
|
|
360
|
-
ref:
|
|
345
|
+
ref: scrollContainerRef,
|
|
361
346
|
children: [(0, jsx_runtime_1.jsx)("div", {
|
|
362
347
|
className: styles_module_scss_1.default.tableContent,
|
|
363
|
-
style:
|
|
348
|
+
style: columnSizeVars,
|
|
364
349
|
children: (0, jsx_runtime_1.jsx)(helperComponents_1.TableContext.Provider, {
|
|
365
|
-
value:
|
|
350
|
+
value: {
|
|
351
|
+
table
|
|
352
|
+
},
|
|
366
353
|
children: loading ? (0, jsx_runtime_1.jsxs)(skeleton_1.SkeletonContextProvider, {
|
|
367
354
|
loading: true,
|
|
368
355
|
children: [(0, jsx_runtime_1.jsx)(helperComponents_1.HeaderRow, {}), loadingTableRows.map(row => (0, jsx_runtime_1.jsx)(helperComponents_1.BodyRow, {
|
|
@@ -375,18 +362,10 @@ function Table(_a) {
|
|
|
375
362
|
row: row,
|
|
376
363
|
onRowClick: onRowClick
|
|
377
364
|
}, row.id))
|
|
378
|
-
}) : null, (
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
"data-index": row.index,
|
|
383
|
-
virtualRow: (0, utils_3.isVirtualRow)(rowOrVirtualRow) ? rowOrVirtualRow : undefined,
|
|
384
|
-
children: (0, jsx_runtime_1.jsx)(helperComponents_1.BodyRow, {
|
|
385
|
-
row: row,
|
|
386
|
-
onRowClick: onRowClick
|
|
387
|
-
})
|
|
388
|
-
}, row.id);
|
|
389
|
-
}), (0, jsx_runtime_1.jsx)(helperComponents_1.TableEmptyState, {
|
|
365
|
+
}) : null, centerRows.map(row => (0, jsx_runtime_1.jsx)(helperComponents_1.BodyRow, {
|
|
366
|
+
row: row,
|
|
367
|
+
onRowClick: onRowClick
|
|
368
|
+
}, row.id)), (0, jsx_runtime_1.jsx)(helperComponents_1.TableEmptyState, {
|
|
390
369
|
emptyStates: emptyStates,
|
|
391
370
|
dataError: dataError,
|
|
392
371
|
dataFiltered: dataFiltered || Boolean(table.getState().globalFilter),
|
|
@@ -410,5 +389,5 @@ function Table(_a) {
|
|
|
410
389
|
});
|
|
411
390
|
}
|
|
412
391
|
Table.getStatusColumnDef = helperComponents_1.getStatusColumnDef;
|
|
413
|
-
Table.
|
|
414
|
-
Table.
|
|
392
|
+
Table.statusAppearances = helperComponents_1.STATUS_APPEARANCE;
|
|
393
|
+
Table.getRowActionsColumnDef = helperComponents_1.getRowActionsColumnDef;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
.table{
|
|
2
2
|
border-width:var(--border-width-table, 1px);
|
|
3
3
|
border-radius:var(--radius-table-container, 14px);
|
|
4
|
-
will-change:transform;
|
|
5
4
|
position:relative;
|
|
6
5
|
z-index:0;
|
|
7
|
-
contain:paint;
|
|
8
6
|
overflow:hidden !important;
|
|
9
7
|
display:flex;
|
|
10
8
|
box-sizing:border-box;
|
|
@@ -28,7 +26,6 @@
|
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
.tableContent{
|
|
31
|
-
content-visibility:auto;
|
|
32
29
|
min-width:-moz-max-content;
|
|
33
30
|
min-width:max-content;
|
|
34
31
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { CellContext } from '@tanstack/react-table';
|
|
2
|
-
import { VirtualItem } from '@tanstack/react-virtual';
|
|
3
1
|
export declare function getCurrentlyConfiguredHeaderWidth(id: string): number;
|
|
4
2
|
export declare function getColumnStyleVars(id: string): {
|
|
5
3
|
sizeKey: string;
|
|
@@ -16,12 +14,4 @@ type SaveStateToLocalStorageProps = {
|
|
|
16
14
|
size: string;
|
|
17
15
|
};
|
|
18
16
|
export declare function saveStateToLocalStorage({ id, columnId, size }: SaveStateToLocalStorageProps): void;
|
|
19
|
-
/**
|
|
20
|
-
* check the key, because index is contained in a common table row
|
|
21
|
-
*/
|
|
22
|
-
export declare function isVirtualRow(row: unknown): row is VirtualItem;
|
|
23
|
-
/**
|
|
24
|
-
* @description prevent permanent recreation of the function on rerender
|
|
25
|
-
*/
|
|
26
|
-
export declare function truncateCell<TData>(cell: CellContext<TData, unknown>): import("react/jsx-runtime").JSX.Element;
|
|
27
17
|
export {};
|
|
@@ -7,10 +7,6 @@ exports.getCurrentlyConfiguredHeaderWidth = getCurrentlyConfiguredHeaderWidth;
|
|
|
7
7
|
exports.getColumnStyleVars = getColumnStyleVars;
|
|
8
8
|
exports.getInitColumnSizeFromLocalStorage = getInitColumnSizeFromLocalStorage;
|
|
9
9
|
exports.saveStateToLocalStorage = saveStateToLocalStorage;
|
|
10
|
-
exports.isVirtualRow = isVirtualRow;
|
|
11
|
-
exports.truncateCell = truncateCell;
|
|
12
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
13
|
-
const truncate_string_1 = require("@snack-uikit/truncate-string");
|
|
14
10
|
const utils_1 = require("@snack-uikit/utils");
|
|
15
11
|
function getCurrentlyConfiguredHeaderWidth(id) {
|
|
16
12
|
if ((0, utils_1.isBrowser)()) {
|
|
@@ -57,19 +53,4 @@ function saveStateToLocalStorage(_ref2) {
|
|
|
57
53
|
localStorage.setItem(id, JSON.stringify(Object.assign(Object.assign({}, savedStateFromStorage || {}), {
|
|
58
54
|
resizeState: newResizeState
|
|
59
55
|
})));
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* check the key, because index is contained in a common table row
|
|
63
|
-
*/
|
|
64
|
-
function isVirtualRow(row) {
|
|
65
|
-
return typeof row === 'object' && row != null && 'key' in row;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* @description prevent permanent recreation of the function on rerender
|
|
69
|
-
*/
|
|
70
|
-
function truncateCell(cell) {
|
|
71
|
-
return (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, {
|
|
72
|
-
text: String(cell.getValue()),
|
|
73
|
-
maxLines: 1
|
|
74
|
-
});
|
|
75
56
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PaginationState, Row, RowPinningState, RowSelectionOptions, RowSelectionState, SortingState } from '@tanstack/react-table';
|
|
2
|
-
import {
|
|
3
|
-
import { MutableRefObject, ReactNode, RefObject } from 'react';
|
|
2
|
+
import { ReactNode, RefObject } from 'react';
|
|
4
3
|
import { ToolbarProps } from '@snack-uikit/toolbar';
|
|
5
4
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
6
5
|
import { EmptyStateProps, ExportButtonProps, RowClickHandler } from '../helperComponents';
|
|
@@ -130,9 +129,6 @@ export type TableProps<TData extends object> = WithSupportProps<{
|
|
|
130
129
|
id: string;
|
|
131
130
|
resize?: boolean;
|
|
132
131
|
};
|
|
133
|
-
enableRowVirtualization?: boolean;
|
|
134
|
-
rowVirtualizerOptions?: Parameters<typeof useVirtualizer>[0];
|
|
135
|
-
rowVirtualizerInstanceRef?: MutableRefObject<Virtualizer<Element, Element> | null>;
|
|
136
132
|
}>;
|
|
137
133
|
export type ServerTableProps<TData extends object> = Omit<TableProps<TData>, 'pageSize' | 'pageCount' | 'pagination' | 'search' | 'data'> & {
|
|
138
134
|
/** Данные для отрисовки */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Row as TableRow } from '@tanstack/react-table';
|
|
2
|
-
import {
|
|
2
|
+
import { MouseEvent } from 'react';
|
|
3
3
|
export type RowInfo<TData> = {
|
|
4
4
|
id: string;
|
|
5
5
|
data: TData;
|
|
@@ -10,7 +10,6 @@ export type RowClickHandler<TData> = (e: MouseEvent<HTMLDivElement>, row: RowInf
|
|
|
10
10
|
type BodyRowProps<TData> = {
|
|
11
11
|
row: TableRow<TData>;
|
|
12
12
|
onRowClick?: RowClickHandler<TData>;
|
|
13
|
-
style?: CSSProperties;
|
|
14
13
|
};
|
|
15
|
-
export declare
|
|
14
|
+
export declare function BodyRow<TData>({ row, onRowClick }: BodyRowProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
16
15
|
export {};
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
4
|
-
var t = {};
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
3
|
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
12
4
|
return mod && mod.__esModule ? mod : {
|
|
13
5
|
"default": mod
|
|
@@ -16,7 +8,7 @@ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
|
16
8
|
Object.defineProperty(exports, "__esModule", {
|
|
17
9
|
value: true
|
|
18
10
|
});
|
|
19
|
-
exports.BodyRow =
|
|
11
|
+
exports.BodyRow = BodyRow;
|
|
20
12
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
21
13
|
const react_1 = require("react");
|
|
22
14
|
const constants_1 = require("../../constants");
|
|
@@ -26,13 +18,11 @@ const hooks_1 = require("../hooks");
|
|
|
26
18
|
const PinnedCells_1 = require("./PinnedCells");
|
|
27
19
|
const Row_1 = require("./Row");
|
|
28
20
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} = _a,
|
|
35
|
-
attributes = __rest(_a, ["row", "onRowClick"]);
|
|
21
|
+
function BodyRow(_ref) {
|
|
22
|
+
let {
|
|
23
|
+
row,
|
|
24
|
+
onRowClick
|
|
25
|
+
} = _ref;
|
|
36
26
|
const {
|
|
37
27
|
pinnedLeft,
|
|
38
28
|
pinnedRight,
|
|
@@ -54,8 +44,7 @@ exports.BodyRow = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
54
44
|
dropListOpened,
|
|
55
45
|
setDropListOpen
|
|
56
46
|
},
|
|
57
|
-
children: (0, jsx_runtime_1.jsxs)(Row_1.Row,
|
|
58
|
-
ref: ref,
|
|
47
|
+
children: (0, jsx_runtime_1.jsxs)(Row_1.Row, {
|
|
59
48
|
onClick: handleRowClick,
|
|
60
49
|
"data-clickable": Boolean(onRowClick) || undefined,
|
|
61
50
|
"data-disabled": disabled || undefined,
|
|
@@ -77,6 +66,6 @@ exports.BodyRow = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
77
66
|
cell: cell
|
|
78
67
|
}, cell.id))
|
|
79
68
|
})]
|
|
80
|
-
})
|
|
69
|
+
})
|
|
81
70
|
});
|
|
82
|
-
}
|
|
71
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MouseEvent, ReactNode } from 'react';
|
|
2
2
|
import { DataAttributes } from '../types';
|
|
3
|
-
|
|
3
|
+
type RowProps = {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
onClick?(e: MouseEvent<HTMLDivElement>): void;
|
|
6
6
|
className?: string;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
} & DataAttributes;
|
|
8
|
+
export declare function Row({ onClick, children, className, ...attributes }: RowProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -16,12 +16,11 @@ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", {
|
|
17
17
|
value: true
|
|
18
18
|
});
|
|
19
|
-
exports.Row =
|
|
19
|
+
exports.Row = Row;
|
|
20
20
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
21
21
|
const classnames_1 = __importDefault(require("classnames"));
|
|
22
|
-
const react_1 = require("react");
|
|
23
22
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
24
|
-
|
|
23
|
+
function Row(_a) {
|
|
25
24
|
var {
|
|
26
25
|
onClick,
|
|
27
26
|
children,
|
|
@@ -31,7 +30,6 @@ exports.Row = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
31
30
|
return (
|
|
32
31
|
// eslint-disable-next-line jsx-a11y/interactive-supports-focus
|
|
33
32
|
(0, jsx_runtime_1.jsx)("div", Object.assign({
|
|
34
|
-
ref: ref,
|
|
35
33
|
onClick: onClick,
|
|
36
34
|
className: (0, classnames_1.default)(styles_module_scss_1.default.tableRow, className),
|
|
37
35
|
role: 'row'
|
|
@@ -39,4 +37,4 @@ exports.Row = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
39
37
|
children: children
|
|
40
38
|
}))
|
|
41
39
|
);
|
|
42
|
-
}
|
|
40
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TableProps } from '../types';
|
|
2
2
|
/** Компонент таблицы */
|
|
3
|
-
export declare function Table<TData extends object>({ data, rowPinning, columnDefinitions, keepPinnedRows, copyPinnedRows, enableSelectPinned, rowSelection: rowSelectionProp, search, sorting: sortingProp, columnFilters, pagination: paginationProp, className, onRowClick, onRefresh, onDelete, pageSize, pageCount, loading, outline, moreActions, exportSettings, dataFiltered, dataError, noDataState, noResultsState, errorDataState, suppressToolbar, toolbarBefore, toolbarAfter, suppressPagination, manualSorting, manualPagination, manualFiltering, autoResetPageIndex, scrollRef, scrollContainerRef, getRowId, enableFuzzySearch, savedState,
|
|
3
|
+
export declare function Table<TData extends object>({ data, rowPinning, columnDefinitions, keepPinnedRows, copyPinnedRows, enableSelectPinned, rowSelection: rowSelectionProp, search, sorting: sortingProp, columnFilters, pagination: paginationProp, className, onRowClick, onRefresh, onDelete, pageSize, pageCount, loading, outline, moreActions, exportSettings, dataFiltered, dataError, noDataState, noResultsState, errorDataState, suppressToolbar, toolbarBefore, toolbarAfter, suppressPagination, manualSorting, manualPagination, manualFiltering, autoResetPageIndex, scrollRef, scrollContainerRef, getRowId, enableFuzzySearch, savedState, ...rest }: TableProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export declare namespace Table {
|
|
5
5
|
var getStatusColumnDef: typeof import("../../helperComponents").getStatusColumnDef;
|
|
6
|
-
var getRowActionsColumnDef: typeof import("../../helperComponents").getRowActionsColumnDef;
|
|
7
6
|
var statusAppearances: Record<string, string>;
|
|
7
|
+
var getRowActionsColumnDef: typeof import("../../helperComponents").getRowActionsColumnDef;
|
|
8
8
|
}
|
|
@@ -12,28 +12,25 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { getCoreRowModel, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable, } from '@tanstack/react-table';
|
|
14
14
|
import cn from 'classnames';
|
|
15
|
-
import mergeRefs from 'merge-refs';
|
|
16
15
|
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
17
16
|
import { useLocale } from '@snack-uikit/locale';
|
|
18
17
|
import { Scroll } from '@snack-uikit/scroll';
|
|
19
18
|
import { SkeletonContextProvider } from '@snack-uikit/skeleton';
|
|
20
19
|
import { Toolbar } from '@snack-uikit/toolbar';
|
|
20
|
+
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
21
21
|
import { extractSupportProps } from '@snack-uikit/utils';
|
|
22
22
|
import { DEFAULT_PAGE_SIZE } from '../../constants';
|
|
23
23
|
import { BodyRow, ExportButton, getColumnId, getRowActionsColumnDef, getSelectionCellColumnDef, getStatusColumnDef, HeaderRow, STATUS_APPEARANCE, TableContext, TableEmptyState, TablePagination, useEmptyState, } from '../../helperComponents';
|
|
24
|
-
import { VirtualRow } from '../../helperComponents/Rows/VirtualRow';
|
|
25
24
|
import { fuzzyFilter } from '../../utils';
|
|
26
25
|
import { useLoadingTable, useStateControl } from './hooks';
|
|
27
26
|
import { usePageReset } from './hooks/usePageReset';
|
|
28
|
-
import { useRowVirtualizer } from './hooks/useRowVirtualizer';
|
|
29
27
|
import styles from './styles.module.css';
|
|
30
|
-
import { getColumnStyleVars, getCurrentlyConfiguredHeaderWidth, getInitColumnSizeFromLocalStorage,
|
|
28
|
+
import { getColumnStyleVars, getCurrentlyConfiguredHeaderWidth, getInitColumnSizeFromLocalStorage, saveStateToLocalStorage, } from './utils';
|
|
31
29
|
/** Компонент таблицы */
|
|
32
30
|
export function Table(_a) {
|
|
33
|
-
var _b;
|
|
34
31
|
var { data, rowPinning = {
|
|
35
32
|
top: [],
|
|
36
|
-
}, columnDefinitions, keepPinnedRows = false, copyPinnedRows = false, enableSelectPinned = false, rowSelection: rowSelectionProp, search, sorting: sortingProp, columnFilters, pagination: paginationProp, className, onRowClick, onRefresh, onDelete, pageSize = DEFAULT_PAGE_SIZE, pageCount, loading = false, outline = false, moreActions, exportSettings, dataFiltered, dataError, noDataState, noResultsState, errorDataState, suppressToolbar = false, toolbarBefore, toolbarAfter, suppressPagination = false, manualSorting = false, manualPagination = false, manualFiltering = false, autoResetPageIndex = false, scrollRef, scrollContainerRef, getRowId, enableFuzzySearch, savedState
|
|
33
|
+
}, columnDefinitions, keepPinnedRows = false, copyPinnedRows = false, enableSelectPinned = false, rowSelection: rowSelectionProp, search, sorting: sortingProp, columnFilters, pagination: paginationProp, className, onRowClick, onRefresh, onDelete, pageSize = DEFAULT_PAGE_SIZE, pageCount, loading = false, outline = false, moreActions, exportSettings, dataFiltered, dataError, noDataState, noResultsState, errorDataState, suppressToolbar = false, toolbarBefore, toolbarAfter, suppressPagination = false, manualSorting = false, manualPagination = false, manualFiltering = false, autoResetPageIndex = false, scrollRef, scrollContainerRef, getRowId, enableFuzzySearch, savedState } = _a, rest = __rest(_a, ["data", "rowPinning", "columnDefinitions", "keepPinnedRows", "copyPinnedRows", "enableSelectPinned", "rowSelection", "search", "sorting", "columnFilters", "pagination", "className", "onRowClick", "onRefresh", "onDelete", "pageSize", "pageCount", "loading", "outline", "moreActions", "exportSettings", "dataFiltered", "dataError", "noDataState", "noResultsState", "errorDataState", "suppressToolbar", "toolbarBefore", "toolbarAfter", "suppressPagination", "manualSorting", "manualPagination", "manualFiltering", "autoResetPageIndex", "scrollRef", "scrollContainerRef", "getRowId", "enableFuzzySearch", "savedState"]);
|
|
37
34
|
const { state: globalFilter, onStateChange: onGlobalFilterChange } = useStateControl(search, '');
|
|
38
35
|
const { state: rowSelection, onStateChange: onRowSelectionChange } = useStateControl(rowSelectionProp, {});
|
|
39
36
|
const defaultPaginationState = useMemo(() => ({
|
|
@@ -43,7 +40,6 @@ export function Table(_a) {
|
|
|
43
40
|
const { state: sorting, onStateChange: onSortingChange } = useStateControl(sortingProp, []);
|
|
44
41
|
const { state: pagination, onStateChange: onPaginationChange } = useStateControl(paginationProp, defaultPaginationState);
|
|
45
42
|
const enableSelection = Boolean(rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.enable);
|
|
46
|
-
const tableContainerRef = useRef(null);
|
|
47
43
|
const tableColumns = useMemo(() => {
|
|
48
44
|
let cols = columnDefinitions;
|
|
49
45
|
if (enableSelection) {
|
|
@@ -78,7 +74,7 @@ export function Table(_a) {
|
|
|
78
74
|
enableSorting: false,
|
|
79
75
|
enableResizing: false,
|
|
80
76
|
minSize: 40,
|
|
81
|
-
cell:
|
|
77
|
+
cell: (cell) => _jsx(TruncateString, { text: String(cell.getValue()), maxLines: 1 }),
|
|
82
78
|
},
|
|
83
79
|
manualSorting,
|
|
84
80
|
manualPagination,
|
|
@@ -102,11 +98,6 @@ export function Table(_a) {
|
|
|
102
98
|
getCoreRowModel: getCoreRowModel(),
|
|
103
99
|
columnResizeMode: 'onEnd',
|
|
104
100
|
keepPinnedRows,
|
|
105
|
-
meta: {
|
|
106
|
-
tableContainerRef,
|
|
107
|
-
rowVirtualizerInstanceRef,
|
|
108
|
-
rowVirtualizerOptions,
|
|
109
|
-
},
|
|
110
101
|
});
|
|
111
102
|
const { loadingTable } = useLoadingTable({
|
|
112
103
|
pageSize: Math.min(Math.max(pageSize, 5), DEFAULT_PAGE_SIZE),
|
|
@@ -144,11 +135,10 @@ export function Table(_a) {
|
|
|
144
135
|
}, [loading, rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow, table, enableSelectPinned]);
|
|
145
136
|
const columnSizeVarsRef = useRef();
|
|
146
137
|
const headers = table.getFlatHeaders();
|
|
147
|
-
const
|
|
148
|
-
const cssSizeVars = useMemo(() => {
|
|
138
|
+
const columnSizeVars = useMemo(() => {
|
|
149
139
|
var _a;
|
|
150
140
|
const originalColumnDefs = table._getColumnDefs();
|
|
151
|
-
const colSizes =
|
|
141
|
+
const colSizes = {};
|
|
152
142
|
for (let i = 0; i < headers.length; i++) {
|
|
153
143
|
const header = headers[i];
|
|
154
144
|
const { sizeKey, flexKey } = getColumnStyleVars(header.id);
|
|
@@ -199,8 +189,8 @@ export function Table(_a) {
|
|
|
199
189
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
200
190
|
}, [table.getState().columnSizingInfo.isResizingColumn, headers, table.getTotalSize()]);
|
|
201
191
|
useEffect(() => {
|
|
202
|
-
columnSizeVarsRef.current =
|
|
203
|
-
}, [
|
|
192
|
+
columnSizeVarsRef.current = columnSizeVars;
|
|
193
|
+
}, [columnSizeVars]);
|
|
204
194
|
const tableRows = table.getRowModel().rows;
|
|
205
195
|
const tableCenterRows = table.getCenterRows();
|
|
206
196
|
const tableFilteredRows = table.getFilteredRowModel().rows;
|
|
@@ -218,7 +208,6 @@ export function Table(_a) {
|
|
|
218
208
|
const tempPageSize = (!suppressPagination ? tablePagination === null || tablePagination === void 0 ? void 0 : tablePagination.pageSize : pageSize) + filteredTopRows.length;
|
|
219
209
|
return !tableRows.length ? Math.min(Math.max(tempPageSize, 5), DEFAULT_PAGE_SIZE) : tempPageSize;
|
|
220
210
|
}, [filteredTopRows.length, pageSize, suppressPagination, tablePagination === null || tablePagination === void 0 ? void 0 : tablePagination.pageSize, tableRows.length]);
|
|
221
|
-
const tableCtx = useMemo(() => ({ table }), [table]);
|
|
222
211
|
usePageReset({
|
|
223
212
|
manualPagination,
|
|
224
213
|
maximumAvailablePage: pageCount || data.length / pagination.pageSize,
|
|
@@ -233,11 +222,8 @@ export function Table(_a) {
|
|
|
233
222
|
onChange: onGlobalFilterChange,
|
|
234
223
|
loading: search === null || search === void 0 ? void 0 : search.loading,
|
|
235
224
|
placeholder: (search === null || search === void 0 ? void 0 : search.placeholder) || t('searchPlaceholder'),
|
|
236
|
-
}, checked: table.getIsAllPageRowsSelected(), indeterminate: table.getIsSomePageRowsSelected(), className: styles.toolbar, onRefresh: onRefresh ? handleOnRefresh : undefined, onDelete: enableSelection && onDelete ? handleOnDelete : undefined, onCheck: enableSelection ? handleOnCheck : undefined, outline: outline, selectionMode: (rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow) ? 'multiple' : 'single', before: toolbarBefore, after: toolbarAfter || exportSettings ? (_jsxs(_Fragment, { children: [toolbarAfter, exportSettings && (_jsx(ExportButton, { settings: exportSettings, columnDefinitions: columnDefinitions, data: data, topRows: filteredTopRows, centerRows: centerRows }))] })) : undefined, moreActions: moreActions }), columnFilters && _jsxs("div", { className: styles.filtersWrapper, children: [" ", columnFilters, " "] })] })), _jsx("div", { className: styles.scrollWrapper, "data-outline": outline || undefined, children: _jsxs(Scroll, { size: 's', className: styles.table, ref:
|
|
237
|
-
const row = isVirtualRow(rowOrVirtualRow) ? centerRows[rowOrVirtualRow.index] : centerRows[index];
|
|
238
|
-
return (_jsx(VirtualRow, { ref: rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.measureElement, "data-index": row.index, virtualRow: isVirtualRow(rowOrVirtualRow) ? rowOrVirtualRow : undefined, children: _jsx(BodyRow, { row: row, onRowClick: onRowClick }) }, row.id));
|
|
239
|
-
}), _jsx(TableEmptyState, { emptyStates: emptyStates, dataError: dataError, dataFiltered: dataFiltered || Boolean(table.getState().globalFilter), tableRowsLength: tableRows.length + filteredTopRows.length })] })) }) }), _jsx("div", { className: styles.scrollStub, ref: scrollRef })] }) }), !suppressPagination && (_jsx(TablePagination, { table: table, options: paginationProp === null || paginationProp === void 0 ? void 0 : paginationProp.options, optionsLabel: paginationProp === null || paginationProp === void 0 ? void 0 : paginationProp.optionsLabel, pageCount: pageCount, optionsRender: paginationProp === null || paginationProp === void 0 ? void 0 : paginationProp.optionsRender }))] })) }));
|
|
225
|
+
}, checked: table.getIsAllPageRowsSelected(), indeterminate: table.getIsSomePageRowsSelected(), className: styles.toolbar, onRefresh: onRefresh ? handleOnRefresh : undefined, onDelete: enableSelection && onDelete ? handleOnDelete : undefined, onCheck: enableSelection ? handleOnCheck : undefined, outline: outline, selectionMode: (rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow) ? 'multiple' : 'single', before: toolbarBefore, after: toolbarAfter || exportSettings ? (_jsxs(_Fragment, { children: [toolbarAfter, exportSettings && (_jsx(ExportButton, { settings: exportSettings, columnDefinitions: columnDefinitions, data: data, topRows: filteredTopRows, centerRows: centerRows }))] })) : undefined, moreActions: moreActions }), columnFilters && _jsxs("div", { className: styles.filtersWrapper, children: [" ", columnFilters, " "] })] })), _jsx("div", { className: styles.scrollWrapper, "data-outline": outline || undefined, children: _jsxs(Scroll, { size: 's', className: styles.table, ref: scrollContainerRef, children: [_jsx("div", { className: styles.tableContent, style: columnSizeVars, children: _jsx(TableContext.Provider, { value: { table }, children: loading ? (_jsxs(SkeletonContextProvider, { loading: true, children: [_jsx(HeaderRow, {}), loadingTableRows.map(row => (_jsx(BodyRow, { row: row }, row.id)))] })) : (_jsxs(_Fragment, { children: [centerRows.length || filteredTopRows.length ? _jsx(HeaderRow, {}) : null, filteredTopRows.length ? (_jsx("div", { className: styles.topRowWrapper, children: filteredTopRows.map(row => (_jsx(BodyRow, { row: row, onRowClick: onRowClick }, row.id))) })) : null, centerRows.map(row => (_jsx(BodyRow, { row: row, onRowClick: onRowClick }, row.id))), _jsx(TableEmptyState, { emptyStates: emptyStates, dataError: dataError, dataFiltered: dataFiltered || Boolean(table.getState().globalFilter), tableRowsLength: tableRows.length + filteredTopRows.length })] })) }) }), _jsx("div", { className: styles.scrollStub, ref: scrollRef })] }) }), !suppressPagination && (_jsx(TablePagination, { table: table, options: paginationProp === null || paginationProp === void 0 ? void 0 : paginationProp.options, optionsLabel: paginationProp === null || paginationProp === void 0 ? void 0 : paginationProp.optionsLabel, pageCount: pageCount, optionsRender: paginationProp === null || paginationProp === void 0 ? void 0 : paginationProp.optionsRender }))] })) }));
|
|
240
226
|
}
|
|
241
227
|
Table.getStatusColumnDef = getStatusColumnDef;
|
|
242
|
-
Table.getRowActionsColumnDef = getRowActionsColumnDef;
|
|
243
228
|
Table.statusAppearances = STATUS_APPEARANCE;
|
|
229
|
+
Table.getRowActionsColumnDef = getRowActionsColumnDef;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
.table{
|
|
2
2
|
border-width:var(--border-width-table, 1px);
|
|
3
3
|
border-radius:var(--radius-table-container, 14px);
|
|
4
|
-
will-change:transform;
|
|
5
4
|
position:relative;
|
|
6
5
|
z-index:0;
|
|
7
|
-
contain:paint;
|
|
8
6
|
overflow:hidden !important;
|
|
9
7
|
display:flex;
|
|
10
8
|
box-sizing:border-box;
|
|
@@ -28,7 +26,6 @@
|
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
.tableContent{
|
|
31
|
-
content-visibility:auto;
|
|
32
29
|
min-width:-moz-max-content;
|
|
33
30
|
min-width:max-content;
|
|
34
31
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { CellContext } from '@tanstack/react-table';
|
|
2
|
-
import { VirtualItem } from '@tanstack/react-virtual';
|
|
3
1
|
export declare function getCurrentlyConfiguredHeaderWidth(id: string): number;
|
|
4
2
|
export declare function getColumnStyleVars(id: string): {
|
|
5
3
|
sizeKey: string;
|
|
@@ -16,12 +14,4 @@ type SaveStateToLocalStorageProps = {
|
|
|
16
14
|
size: string;
|
|
17
15
|
};
|
|
18
16
|
export declare function saveStateToLocalStorage({ id, columnId, size }: SaveStateToLocalStorageProps): void;
|
|
19
|
-
/**
|
|
20
|
-
* check the key, because index is contained in a common table row
|
|
21
|
-
*/
|
|
22
|
-
export declare function isVirtualRow(row: unknown): row is VirtualItem;
|
|
23
|
-
/**
|
|
24
|
-
* @description prevent permanent recreation of the function on rerender
|
|
25
|
-
*/
|
|
26
|
-
export declare function truncateCell<TData>(cell: CellContext<TData, unknown>): import("react/jsx-runtime").JSX.Element;
|
|
27
17
|
export {};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { TruncateString } from '@snack-uikit/truncate-string';
|
|
3
1
|
import { isBrowser } from '@snack-uikit/utils';
|
|
4
2
|
export function getCurrentlyConfiguredHeaderWidth(id) {
|
|
5
3
|
if (isBrowser()) {
|
|
@@ -34,15 +32,3 @@ export function saveStateToLocalStorage({ id, columnId, size }) {
|
|
|
34
32
|
newResizeState[`${RESIZED_KEY}-${columnId}`] = size;
|
|
35
33
|
localStorage.setItem(id, JSON.stringify(Object.assign(Object.assign({}, (savedStateFromStorage || {})), { resizeState: newResizeState })));
|
|
36
34
|
}
|
|
37
|
-
/**
|
|
38
|
-
* check the key, because index is contained in a common table row
|
|
39
|
-
*/
|
|
40
|
-
export function isVirtualRow(row) {
|
|
41
|
-
return typeof row === 'object' && row != null && 'key' in row;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* @description prevent permanent recreation of the function on rerender
|
|
45
|
-
*/
|
|
46
|
-
export function truncateCell(cell) {
|
|
47
|
-
return _jsx(TruncateString, { text: String(cell.getValue()), maxLines: 1 });
|
|
48
|
-
}
|