@snack-uikit/table 0.37.35 → 0.37.36

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 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.37.36 (2026-02-20)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **PDS-3571:** fix table row selection from toolbar with pinned rows ([bfa48f1](https://github.com/cloud-ru-tech/snack-uikit/commit/bfa48f1cfd8db63b3f06eb8647a7dd19b5887ef9))
12
+
13
+
14
+
15
+
16
+
6
17
  ## <small>0.37.35 (2026-02-18)</small>
7
18
 
8
19
  ### Only dependencies have been changed
@@ -175,8 +175,8 @@ function Table(_a) {
175
175
  if ((rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.enable) !== undefined) {
176
176
  isCurrentRowSelected = typeof rowSelectionProp.enable === 'boolean' ? rowSelectionProp.enable : rowSelectionProp.enable(row);
177
177
  }
178
- return isParentSelected && isCurrentRowSelected;
179
- }, [rowSelectionProp]);
178
+ return isParentSelected && isCurrentRowSelected && (row.getIsPinned() && enableSelectPinned || !row.getIsPinned());
179
+ }, [rowSelectionProp, enableSelectPinned]);
180
180
  const table = (0, react_table_1.useReactTable)({
181
181
  data,
182
182
  columns: enabledTableColumns,
@@ -266,22 +266,11 @@ function Table(_a) {
266
266
  })) : undefined, [bulkActionsProp, enableSelection, table]);
267
267
  const isAllRowsMode = toolbarCheckBoxMode === types_1.ToolbarCheckBoxMode.AllRows;
268
268
  const handleOnToolbarCheck = (0, react_1.useCallback)(() => {
269
- if (!loading && !enableSelectPinned && table.getTopRows().length) {
270
- const centerRows = table.getCenterRows();
271
- const isSomeRowsSelected = isAllRowsMode ? table.getIsSomeRowsSelected() : table.getIsSomePageRowsSelected();
272
- const isAllCenterRowsSelected = centerRows.every(row => row.getIsSelected());
273
- if (isAllCenterRowsSelected) {
274
- table.resetRowSelection();
275
- return;
276
- }
277
- centerRows.forEach(row => row.toggleSelected(isSomeRowsSelected ? true : undefined));
278
- return;
279
- }
280
269
  if (!loading && (rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow)) {
281
270
  isAllRowsMode ? table.toggleAllRowsSelected() : table.toggleAllPageRowsSelected();
282
271
  return;
283
272
  }
284
- }, [isAllRowsMode, loading, rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow, table, enableSelectPinned]);
273
+ }, [isAllRowsMode, loading, rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow, table]);
285
274
  const columnSizeVarsRef = (0, react_1.useRef)();
286
275
  const headers = table.getFlatHeaders();
287
276
  const columnSizes = (0, react_1.useMemo)(() => {
@@ -493,7 +482,7 @@ function Table(_a) {
493
482
  rowAutoHeight: rowAutoHeight,
494
483
  columnOrder: columnOrder,
495
484
  enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag,
496
- disabledRowAppearance: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.appearance
485
+ disabledRowAppearance: types_1.RowAppearance.HideToggler
497
486
  }, row.id))
498
487
  }) : null, centerRows.map(row => (0, jsx_runtime_1.jsx)(helperComponents_1.BodyRow, {
499
488
  row: row,
@@ -110,18 +110,18 @@
110
110
  .bodyRow[data-clickable]{
111
111
  cursor:pointer;
112
112
  }
113
- .bodyRow:not([data-disabled]):hover::before{
113
+ .bodyRow:not([data-row-appearance=disabled]):hover::before{
114
114
  height:0;
115
115
  }
116
- .bodyRow:not([data-disabled]):not([data-selected]):hover, .bodyRow:not([data-disabled]):not([data-selected])[data-actions-opened]{
116
+ .bodyRow:not([data-row-appearance=disabled]):not([data-selected]):hover, .bodyRow:not([data-row-appearance=disabled]):not([data-selected])[data-actions-opened]{
117
117
  background-color:color-mix(in srgb, var(--sys-neutral-accent-default, #787b8a), var(--snack-ui-table-row-background) calc((1 - var(--opacity-a008, 0.08)) * 100%));
118
118
  border-color:var(--sys-neutral-decor-hovered, #cfd2dc);
119
119
  }
120
- .bodyRow:not([data-disabled]):not([data-selected]):hover .rowPinnedCells, .bodyRow:not([data-disabled]):not([data-selected])[data-actions-opened] .rowPinnedCells{
120
+ .bodyRow:not([data-row-appearance=disabled]):not([data-selected]):hover .rowPinnedCells, .bodyRow:not([data-row-appearance=disabled]):not([data-selected])[data-actions-opened] .rowPinnedCells{
121
121
  background-color:color-mix(in srgb, var(--sys-neutral-accent-default, #787b8a), var(--snack-ui-table-row-background) calc((1 - var(--opacity-a008, 0.08)) * 100%));
122
122
  border-color:inherit;
123
123
  }
124
- .bodyRow:not([data-disabled]):hover + .bodyRow::before{
124
+ .bodyRow:not([data-row-appearance=disabled]):hover + .bodyRow::before{
125
125
  height:0;
126
126
  }
127
127
 
@@ -24,7 +24,7 @@ import { DEFAULT_EXPANDED, DEFAULT_PAGE_SIZE, DEFAULT_ROW_SELECTION, DEFAULT_SOR
24
24
  import { CellAutoResizeContext, useCellAutoResizeController } from '../../contexts';
25
25
  import { BodyRow, ColumnsSettings, ExportButton, getColumnId, getRowActionsColumnDef, getStatusColumnDef, HeaderRow, STATUS_APPEARANCE, TableContext, TableEmptyState, TablePagination, useEmptyState, } from '../../helperComponents';
26
26
  import { fuzzyFilter } from '../../utils';
27
- import { ToolbarCheckBoxMode } from '../types';
27
+ import { RowAppearance, ToolbarCheckBoxMode } from '../types';
28
28
  import { useColumnOrderByDrag, useColumnSettings, useFilters, useLoadingTable, usePageReset, useStateControl, } from './hooks';
29
29
  import styles from './styles.module.css';
30
30
  import { getColumnStyleVars, getCurrentlyConfiguredHeaderWidth, getInitColumnSizeFromLocalStorage, getPinnedGroups, getTableColumnsDefinitions, saveStateToLocalStorage, } from './utils';
@@ -100,8 +100,8 @@ export function Table(_a) {
100
100
  isCurrentRowSelected =
101
101
  typeof rowSelectionProp.enable === 'boolean' ? rowSelectionProp.enable : rowSelectionProp.enable(row);
102
102
  }
103
- return isParentSelected && isCurrentRowSelected;
104
- }, [rowSelectionProp]);
103
+ return (isParentSelected && isCurrentRowSelected && ((row.getIsPinned() && enableSelectPinned) || !row.getIsPinned()));
104
+ }, [rowSelectionProp, enableSelectPinned]);
105
105
  const table = useReactTable({
106
106
  data,
107
107
  columns: enabledTableColumns,
@@ -181,22 +181,11 @@ export function Table(_a) {
181
181
  : undefined, [bulkActionsProp, enableSelection, table]);
182
182
  const isAllRowsMode = toolbarCheckBoxMode === ToolbarCheckBoxMode.AllRows;
183
183
  const handleOnToolbarCheck = useCallback(() => {
184
- if (!loading && !enableSelectPinned && table.getTopRows().length) {
185
- const centerRows = table.getCenterRows();
186
- const isSomeRowsSelected = isAllRowsMode ? table.getIsSomeRowsSelected() : table.getIsSomePageRowsSelected();
187
- const isAllCenterRowsSelected = centerRows.every(row => row.getIsSelected());
188
- if (isAllCenterRowsSelected) {
189
- table.resetRowSelection();
190
- return;
191
- }
192
- centerRows.forEach(row => row.toggleSelected(isSomeRowsSelected ? true : undefined));
193
- return;
194
- }
195
184
  if (!loading && (rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow)) {
196
185
  isAllRowsMode ? table.toggleAllRowsSelected() : table.toggleAllPageRowsSelected();
197
186
  return;
198
187
  }
199
- }, [isAllRowsMode, loading, rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow, table, enableSelectPinned]);
188
+ }, [isAllRowsMode, loading, rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow, table]);
200
189
  const columnSizeVarsRef = useRef();
201
190
  const headers = table.getFlatHeaders();
202
191
  const columnSizes = useMemo(() => {
@@ -310,7 +299,7 @@ export function Table(_a) {
310
299
  }
311
300
  },
312
301
  }
313
- : undefined, bulkActions: bulkActions, selectionMode: (rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow) ? 'multiple' : 'single', checked: checked, indeterminate: indeterminate, onCheck: enableSelection ? handleOnToolbarCheck : undefined, outline: outline, after: toolbarAfter || exportSettings || areColumnsSettingsEnabled ? (_jsxs(_Fragment, { children: [toolbarAfter, exportSettings && (_jsx(ExportButton, { settings: exportSettings, columnDefinitions: columnDefinitions, data: data, topRows: filteredTopRows, centerRows: centerRows })), areColumnsSettingsEnabled && (_jsx(ColumnsSettings, { columnsSettings: columnsSettings, enabledColumns: enabledColumns, setEnabledColumns: setEnabledColumns }))] })) : undefined, moreActions: moreActions, filterRow: patchedFilter, "data-test-id": TEST_IDS.toolbar }) })), _jsxs(Scroll, { size: 's', className: styles.table, ref: scrollContainerRef, "data-outline": outline || undefined, children: [_jsx("div", { className: styles.tableContent, style: columnSizes.vars, children: _jsx(CellAutoResizeContext.Provider, { value: { updateCellMap }, children: _jsx(DndContext, Object.assign({}, dndContextProps, { children: _jsx(TableContext.Provider, { value: { table, getRowBackgroundColor }, children: (!infiniteLoading || !data.length) && loading ? (_jsxs(SkeletonContextProvider, { loading: true, children: [_jsx(HeaderRow, { rowAutoHeight: rowAutoHeight, columnOrder: columnOrder }), loadingTableRows.map(row => (_jsx(BodyRow, { row: row, rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, disabledRowAppearance: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.appearance }, row.id)))] })) : (_jsxs(_Fragment, { children: [centerRows.length || filteredTopRows.length ? (_jsx(HeaderRow, { rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag })) : null, filteredTopRows.length ? (_jsx("div", { className: styles.topRowWrapper, children: filteredTopRows.map(row => (_jsx(BodyRow, { row: row, onRowClick: onRowClick, rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.appearance }, row.id))) })) : null, centerRows.map(row => (_jsx(BodyRow, { row: row, onRowClick: onRowClick, rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.appearance }, row.id))), data.length > 0 && infiniteLoading && loading && !dataError && (_jsx(SkeletonContextProvider, { loading: true, children: loadingTableRows.slice(0, 3).map(row => (_jsx(BodyRow, { row: row, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.appearance }, 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 })] }), showPagination && (_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 }))] })));
302
+ : undefined, bulkActions: bulkActions, selectionMode: (rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow) ? 'multiple' : 'single', checked: checked, indeterminate: indeterminate, onCheck: enableSelection ? handleOnToolbarCheck : undefined, outline: outline, after: toolbarAfter || exportSettings || areColumnsSettingsEnabled ? (_jsxs(_Fragment, { children: [toolbarAfter, exportSettings && (_jsx(ExportButton, { settings: exportSettings, columnDefinitions: columnDefinitions, data: data, topRows: filteredTopRows, centerRows: centerRows })), areColumnsSettingsEnabled && (_jsx(ColumnsSettings, { columnsSettings: columnsSettings, enabledColumns: enabledColumns, setEnabledColumns: setEnabledColumns }))] })) : undefined, moreActions: moreActions, filterRow: patchedFilter, "data-test-id": TEST_IDS.toolbar }) })), _jsxs(Scroll, { size: 's', className: styles.table, ref: scrollContainerRef, "data-outline": outline || undefined, children: [_jsx("div", { className: styles.tableContent, style: columnSizes.vars, children: _jsx(CellAutoResizeContext.Provider, { value: { updateCellMap }, children: _jsx(DndContext, Object.assign({}, dndContextProps, { children: _jsx(TableContext.Provider, { value: { table, getRowBackgroundColor }, children: (!infiniteLoading || !data.length) && loading ? (_jsxs(SkeletonContextProvider, { loading: true, children: [_jsx(HeaderRow, { rowAutoHeight: rowAutoHeight, columnOrder: columnOrder }), loadingTableRows.map(row => (_jsx(BodyRow, { row: row, rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, disabledRowAppearance: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.appearance }, row.id)))] })) : (_jsxs(_Fragment, { children: [centerRows.length || filteredTopRows.length ? (_jsx(HeaderRow, { rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag })) : null, filteredTopRows.length ? (_jsx("div", { className: styles.topRowWrapper, children: filteredTopRows.map(row => (_jsx(BodyRow, { row: row, onRowClick: onRowClick, rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: RowAppearance.HideToggler }, row.id))) })) : null, centerRows.map(row => (_jsx(BodyRow, { row: row, onRowClick: onRowClick, rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.appearance }, row.id))), data.length > 0 && infiniteLoading && loading && !dataError && (_jsx(SkeletonContextProvider, { loading: true, children: loadingTableRows.slice(0, 3).map(row => (_jsx(BodyRow, { row: row, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.appearance }, 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 })] }), showPagination && (_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 }))] })));
314
303
  }
315
304
  Table.getStatusColumnDef = getStatusColumnDef;
316
305
  Table.statusAppearances = STATUS_APPEARANCE;
@@ -110,18 +110,18 @@
110
110
  .bodyRow[data-clickable]{
111
111
  cursor:pointer;
112
112
  }
113
- .bodyRow:not([data-disabled]):hover::before{
113
+ .bodyRow:not([data-row-appearance=disabled]):hover::before{
114
114
  height:0;
115
115
  }
116
- .bodyRow:not([data-disabled]):not([data-selected]):hover, .bodyRow:not([data-disabled]):not([data-selected])[data-actions-opened]{
116
+ .bodyRow:not([data-row-appearance=disabled]):not([data-selected]):hover, .bodyRow:not([data-row-appearance=disabled]):not([data-selected])[data-actions-opened]{
117
117
  background-color:color-mix(in srgb, var(--sys-neutral-accent-default, #787b8a), var(--snack-ui-table-row-background) calc((1 - var(--opacity-a008, 0.08)) * 100%));
118
118
  border-color:var(--sys-neutral-decor-hovered, #cfd2dc);
119
119
  }
120
- .bodyRow:not([data-disabled]):not([data-selected]):hover .rowPinnedCells, .bodyRow:not([data-disabled]):not([data-selected])[data-actions-opened] .rowPinnedCells{
120
+ .bodyRow:not([data-row-appearance=disabled]):not([data-selected]):hover .rowPinnedCells, .bodyRow:not([data-row-appearance=disabled]):not([data-selected])[data-actions-opened] .rowPinnedCells{
121
121
  background-color:color-mix(in srgb, var(--sys-neutral-accent-default, #787b8a), var(--snack-ui-table-row-background) calc((1 - var(--opacity-a008, 0.08)) * 100%));
122
122
  border-color:inherit;
123
123
  }
124
- .bodyRow:not([data-disabled]):hover + .bodyRow::before{
124
+ .bodyRow:not([data-row-appearance=disabled]):hover + .bodyRow::before{
125
125
  height:0;
126
126
  }
127
127
 
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Table",
7
- "version": "0.37.35",
7
+ "version": "0.37.36",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -65,5 +65,5 @@
65
65
  "peerDependencies": {
66
66
  "@snack-uikit/locale": "*"
67
67
  },
68
- "gitHead": "17b72086167d3d6503e4e74142358765230478c8"
68
+ "gitHead": "01cbc73996330f5ecfabdb474b338cf0de112a57"
69
69
  }
@@ -50,7 +50,7 @@ import {
50
50
  } from '../../helperComponents';
51
51
  import { ColumnDefinition } from '../../types';
52
52
  import { fuzzyFilter } from '../../utils';
53
- import { TableProps, ToolbarCheckBoxMode } from '../types';
53
+ import { RowAppearance, TableProps, ToolbarCheckBoxMode } from '../types';
54
54
  import {
55
55
  useColumnOrderByDrag,
56
56
  useColumnSettings,
@@ -232,9 +232,11 @@ export function Table<TData extends object, TFilters extends FiltersState = Reco
232
232
  isCurrentRowSelected =
233
233
  typeof rowSelectionProp.enable === 'boolean' ? rowSelectionProp.enable : rowSelectionProp.enable(row);
234
234
  }
235
- return isParentSelected && isCurrentRowSelected;
235
+ return (
236
+ isParentSelected && isCurrentRowSelected && ((row.getIsPinned() && enableSelectPinned) || !row.getIsPinned())
237
+ );
236
238
  },
237
- [rowSelectionProp],
239
+ [rowSelectionProp, enableSelectPinned],
238
240
  );
239
241
 
240
242
  const table = useReactTable<TData>({
@@ -332,25 +334,11 @@ export function Table<TData extends object, TFilters extends FiltersState = Reco
332
334
  const isAllRowsMode = toolbarCheckBoxMode === ToolbarCheckBoxMode.AllRows;
333
335
 
334
336
  const handleOnToolbarCheck = useCallback(() => {
335
- if (!loading && !enableSelectPinned && table.getTopRows().length) {
336
- const centerRows = table.getCenterRows();
337
- const isSomeRowsSelected = isAllRowsMode ? table.getIsSomeRowsSelected() : table.getIsSomePageRowsSelected();
338
- const isAllCenterRowsSelected = centerRows.every(row => row.getIsSelected());
339
-
340
- if (isAllCenterRowsSelected) {
341
- table.resetRowSelection();
342
- return;
343
- }
344
-
345
- centerRows.forEach(row => row.toggleSelected(isSomeRowsSelected ? true : undefined));
346
- return;
347
- }
348
-
349
337
  if (!loading && rowSelectionProp?.multiRow) {
350
338
  isAllRowsMode ? table.toggleAllRowsSelected() : table.toggleAllPageRowsSelected();
351
339
  return;
352
340
  }
353
- }, [isAllRowsMode, loading, rowSelectionProp?.multiRow, table, enableSelectPinned]);
341
+ }, [isAllRowsMode, loading, rowSelectionProp?.multiRow, table]);
354
342
 
355
343
  const columnSizeVarsRef = useRef<Record<string, string>>();
356
344
  const headers = table.getFlatHeaders();
@@ -576,7 +564,7 @@ export function Table<TData extends object, TFilters extends FiltersState = Reco
576
564
  rowAutoHeight={rowAutoHeight}
577
565
  columnOrder={columnOrder}
578
566
  enableColumnsOrderSortByDrag={enableColumnsOrderSortByDrag}
579
- disabledRowAppearance={rowSelectionProp?.appearance}
567
+ disabledRowAppearance={RowAppearance.HideToggler}
580
568
  />
581
569
  ))}
582
570
  </div>
@@ -154,7 +154,7 @@ $snack-ui-table-row-background: var(--snack-ui-table-row-background);
154
154
  cursor: pointer;
155
155
  }
156
156
 
157
- &:not([data-disabled]) {
157
+ &:not([data-row-appearance='disabled']) {
158
158
  &:hover {
159
159
  &::before {
160
160
  height: 0;