@snack-uikit/table 0.37.31 → 0.37.33-preview-d75faeae.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/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.32 (2026-02-03)</small>
7
+
8
+ * feat(PDS-3472): add HideToggler appearance mode for disabled rows ([802be3d](https://github.com/cloud-ru-tech/snack-uikit/commit/802be3d))
9
+
10
+
11
+
12
+
13
+
6
14
  ## <small>0.37.31 (2026-01-19)</small>
7
15
 
8
16
  * chore(FF-6693): migrate tests from TestCafe to Playwright ([f32aff8](https://github.com/cloud-ru-tech/snack-uikit/commit/f32aff8))
package/README.md CHANGED
@@ -96,6 +96,10 @@ const columnDefinitions: ColumnDefinition<TableData>[] = [
96
96
  enable: true, // false выключает выбор всех строк (состояние disabled)
97
97
  // или можно передать функцию для вычисления
98
98
  // enable: row => !['Pending', 'Loading'].includes(row.original.status),
99
+
100
+
101
+ // appearance: RowAppearance.Disabled, // по умолчанию: серый фон, скрыты actions
102
+ // appearance: RowAppearance.HideToggler, // обычный фон, видны actions, скрыт только чекбокс
99
103
  onChange: handleRowSelection,
100
104
  }}
101
105
  />
@@ -165,6 +169,7 @@ const columnDefinitions: ColumnDefinition<TableData>[] = [
165
169
  | name | type | default value | description |
166
170
  |------|------|---------------|-------------|
167
171
  | filter | `FiltersState` | - | |
172
+ | ordering | `FieldSort[]` | - | |
168
173
  | search | `string` | - | |
169
174
  | pagination | `PaginationState \| PaginationParams` | - | |
170
175
  | sorting | `SortingState` | - | |
@@ -217,6 +222,7 @@ const columnDefinitions: ColumnDefinition<TableData>[] = [
217
222
  | infiniteLoading | `boolean` | - | Режим работы "бесконечной" загрузки |
218
223
  | suppressPagination | `boolean` | - | Отключение пагинации |
219
224
  | manualPagination | `boolean` | - | |
225
+ | toolbarCheckBoxStrategy | enum ToolbarCheckBoxStrategy: `"pageRows"`, `"allRows"` | - | Определение как должен работать чекбокс в тулбаре (по всем страницам или по текущей) |
220
226
  ## Table.getStatusColumnDef
221
227
  Вспомогательная функция для создания ячейки со статусом
222
228
  ### Props
@@ -283,6 +289,7 @@ const columnDefinitions: ColumnDefinition<TableData>[] = [
283
289
  | suppressPagination | `boolean` | - | Отключение пагинации |
284
290
  | manualPagination | `boolean` | true | |
285
291
  | infiniteLoading | `never` | - | |
292
+ | toolbarCheckBoxStrategy | enum ToolbarCheckBoxStrategy: `"pageRows"`, `"allRows"` | - | Определение как должен работать чекбокс в тулбаре (по всем страницам или по текущей) |
286
293
  | items | `TData[]` | - | Данные для отрисовки |
287
294
  | total | `number` | 10 | Общее кол-во строк |
288
295
  | limit | `number` | 10 | Кол-во строк на страницу |
@@ -1,7 +1,7 @@
1
1
  import { FiltersState } from '@snack-uikit/chips';
2
2
  import { TableProps } from '../types';
3
3
  /** Компонент таблицы */
4
- export declare function Table<TData extends object, TFilters extends FiltersState = Record<string, unknown>>({ data, rowPinning, columnDefinitions, keepPinnedRows, copyPinnedRows, enableSelectPinned, rowSelection: rowSelectionProp, search, sorting: sortingProp, columnFilters, pagination: paginationProp, className, onRowClick, onRefresh, pageSize, pageCount, loading, infiniteLoading, outline, moreActions, exportSettings, dataFiltered, dataError, noDataState, noResultsState, errorDataState, suppressToolbar, suppressSearch, toolbarAfter, suppressPagination, manualSorting, manualPagination: manualPaginationProp, manualFiltering, autoResetPageIndex, scrollRef, scrollContainerRef, getRowId, enableFuzzySearch, savedState, expanding, bulkActions: bulkActionsProp, rowAutoHeight, columnsSettings: columnsSettingsProp, getRowBackgroundColor, ...rest }: TableProps<TData, TFilters>): import("react/jsx-runtime").JSX.Element;
4
+ export declare function Table<TData extends object, TFilters extends FiltersState = Record<string, unknown>>({ data, rowPinning, columnDefinitions, keepPinnedRows, copyPinnedRows, enableSelectPinned, rowSelection: rowSelectionProp, search, sorting: sortingProp, columnFilters, pagination: paginationProp, className, onRowClick, onRefresh, pageSize, pageCount, loading, infiniteLoading, outline, moreActions, exportSettings, dataFiltered, dataError, noDataState, noResultsState, errorDataState, suppressToolbar, suppressSearch, toolbarAfter, suppressPagination, manualSorting, manualPagination: manualPaginationProp, manualFiltering, autoResetPageIndex, scrollRef, scrollContainerRef, getRowId, enableFuzzySearch, savedState, expanding, bulkActions: bulkActionsProp, rowAutoHeight, columnsSettings: columnsSettingsProp, getRowBackgroundColor, toolbarCheckBoxStrategy, ...rest }: TableProps<TData, TFilters>): import("react/jsx-runtime").JSX.Element;
5
5
  export declare namespace Table {
6
6
  var getStatusColumnDef: typeof import("../../helperComponents").getStatusColumnDef;
7
7
  var statusAppearances: {
@@ -32,6 +32,7 @@ const constants_1 = require("../../constants");
32
32
  const contexts_1 = require("../../contexts");
33
33
  const helperComponents_1 = require("../../helperComponents");
34
34
  const utils_2 = require("../../utils");
35
+ const types_1 = require("../types");
35
36
  const hooks_1 = require("./hooks");
36
37
  const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
37
38
  const utils_3 = require("./utils");
@@ -85,9 +86,10 @@ function Table(_a) {
85
86
  bulkActions: bulkActionsProp,
86
87
  rowAutoHeight,
87
88
  columnsSettings: columnsSettingsProp,
88
- getRowBackgroundColor
89
+ getRowBackgroundColor,
90
+ toolbarCheckBoxStrategy
89
91
  } = _a,
90
- rest = __rest(_a, ["data", "rowPinning", "columnDefinitions", "keepPinnedRows", "copyPinnedRows", "enableSelectPinned", "rowSelection", "search", "sorting", "columnFilters", "pagination", "className", "onRowClick", "onRefresh", "pageSize", "pageCount", "loading", "infiniteLoading", "outline", "moreActions", "exportSettings", "dataFiltered", "dataError", "noDataState", "noResultsState", "errorDataState", "suppressToolbar", "suppressSearch", "toolbarAfter", "suppressPagination", "manualSorting", "manualPagination", "manualFiltering", "autoResetPageIndex", "scrollRef", "scrollContainerRef", "getRowId", "enableFuzzySearch", "savedState", "expanding", "bulkActions", "rowAutoHeight", "columnsSettings", "getRowBackgroundColor"]);
92
+ rest = __rest(_a, ["data", "rowPinning", "columnDefinitions", "keepPinnedRows", "copyPinnedRows", "enableSelectPinned", "rowSelection", "search", "sorting", "columnFilters", "pagination", "className", "onRowClick", "onRefresh", "pageSize", "pageCount", "loading", "infiniteLoading", "outline", "moreActions", "exportSettings", "dataFiltered", "dataError", "noDataState", "noResultsState", "errorDataState", "suppressToolbar", "suppressSearch", "toolbarAfter", "suppressPagination", "manualSorting", "manualPagination", "manualFiltering", "autoResetPageIndex", "scrollRef", "scrollContainerRef", "getRowId", "enableFuzzySearch", "savedState", "expanding", "bulkActions", "rowAutoHeight", "columnsSettings", "getRowBackgroundColor", "toolbarCheckBoxStrategy"]);
91
93
  const [globalFilter, onGlobalFilterChange] = (0, hooks_1.useStateControl)(search, '');
92
94
  const [rowSelection, onRowSelectionChange] = (0, hooks_1.useStateControl)(rowSelectionProp, constants_1.DEFAULT_ROW_SELECTION);
93
95
  const defaultPaginationState = (0, react_1.useMemo)(() => ({
@@ -265,7 +267,7 @@ function Table(_a) {
265
267
  const handleOnToolbarCheck = (0, react_1.useCallback)(() => {
266
268
  if (!loading && !enableSelectPinned && table.getTopRows().length) {
267
269
  const centerRows = table.getCenterRows();
268
- const isSomeRowsSelected = table.getIsSomePageRowsSelected();
270
+ const isSomeRowsSelected = toolbarCheckBoxStrategy === types_1.ToolbarCheckBoxStrategy.AllRows ? table.getIsSomeRowsSelected() : table.getIsSomePageRowsSelected();
269
271
  const isAllCenterRowsSelected = centerRows.every(row => row.getIsSelected());
270
272
  if (isAllCenterRowsSelected) {
271
273
  table.resetRowSelection();
@@ -275,10 +277,14 @@ function Table(_a) {
275
277
  return;
276
278
  }
277
279
  if (!loading && (rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow)) {
278
- table.toggleAllPageRowsSelected();
280
+ if (toolbarCheckBoxStrategy === types_1.ToolbarCheckBoxStrategy.AllRows) {
281
+ table.toggleAllRowsSelected();
282
+ } else {
283
+ table.toggleAllPageRowsSelected();
284
+ }
279
285
  return;
280
286
  }
281
- }, [loading, rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow, table, enableSelectPinned]);
287
+ }, [toolbarCheckBoxStrategy, loading, rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow, table, enableSelectPinned]);
282
288
  const columnSizeVarsRef = (0, react_1.useRef)();
283
289
  const headers = table.getFlatHeaders();
284
290
  const columnSizes = (0, react_1.useMemo)(() => {
@@ -380,6 +386,16 @@ function Table(_a) {
380
386
  } = (0, contexts_1.useCellAutoResizeController)(table);
381
387
  const showToolbar = !suppressToolbar;
382
388
  const showPagination = !infiniteLoading && !suppressPagination;
389
+ const {
390
+ checked,
391
+ indeterminate
392
+ } = toolbarCheckBoxStrategy === types_1.ToolbarCheckBoxStrategy.AllRows ? {
393
+ checked: table.getIsAllRowsSelected(),
394
+ indeterminate: table.getIsSomeRowsSelected()
395
+ } : {
396
+ checked: table.getIsAllPageRowsSelected(),
397
+ indeterminate: table.getIsSomePageRowsSelected()
398
+ };
383
399
  return (0, jsx_runtime_1.jsxs)("div", Object.assign({
384
400
  className: (0, classnames_1.default)(styles_module_scss_1.default.wrapper, className),
385
401
  "data-with-toolbar": showToolbar || undefined
@@ -417,8 +433,8 @@ function Table(_a) {
417
433
  } : undefined,
418
434
  bulkActions: bulkActions,
419
435
  selectionMode: (rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow) ? 'multiple' : 'single',
420
- checked: table.getIsAllPageRowsSelected(),
421
- indeterminate: table.getIsSomePageRowsSelected(),
436
+ checked: checked,
437
+ indeterminate: indeterminate,
422
438
  onCheck: enableSelection ? handleOnToolbarCheck : undefined,
423
439
  outline: outline,
424
440
  after: toolbarAfter || exportSettings || areColumnsSettingsEnabled ? (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, {
@@ -8,7 +8,6 @@ export declare function useFilters<TData extends object, TFilters extends Record
8
8
  onChange: (filter: TFilters) => void;
9
9
  visibleFilters: string[];
10
10
  onVisibleFiltersChange: import("@tanstack/react-table").OnChangeFn<string[]>;
11
- className?: string | undefined;
12
11
  "aria-activedescendant"?: string | undefined | undefined;
13
12
  "aria-atomic"?: (boolean | "true" | "false") | undefined;
14
13
  "aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined | undefined;
@@ -64,6 +63,7 @@ export declare function useFilters<TData extends object, TFilters extends Record
64
63
  "aria-valuetext"?: string | undefined | undefined;
65
64
  defaultValue?: Partial<TFilters> | undefined;
66
65
  filters: import("@snack-uikit/chips").ChipChoiceRowFilter[];
66
+ className?: string | undefined;
67
67
  showClearButton?: boolean | undefined;
68
68
  showAddButton?: boolean | undefined;
69
69
  open: boolean;
@@ -14,6 +14,10 @@ export declare enum RowAppearance {
14
14
  Disabled = "disabled",
15
15
  HideToggler = "hide-toggler"
16
16
  }
17
+ export declare enum ToolbarCheckBoxStrategy {
18
+ PageRows = "pageRows",
19
+ AllRows = "allRows"
20
+ }
17
21
  type BaseTableProps<TData extends object, TFilters extends FiltersState = Record<string, unknown>> = WithSupportProps<{
18
22
  /** Данные для отрисовки */
19
23
  data: TData[];
@@ -162,6 +166,7 @@ export type InfiniteTableProps<TData extends object, TFilters extends FiltersSta
162
166
  /** Отключение пагинации */
163
167
  suppressPagination?: never;
164
168
  manualPagination?: never;
169
+ toolbarCheckBoxStrategy?: never;
165
170
  };
166
171
  export type ClientTableProps<TData extends object, TFilters extends FiltersState = Record<string, unknown>> = BaseTableProps<TData, TFilters> & {
167
172
  /** Параметры отвечают за пагинацию в таблице <br>
@@ -187,6 +192,10 @@ export type ClientTableProps<TData extends object, TFilters extends FiltersState
187
192
  suppressPagination?: boolean;
188
193
  manualPagination?: boolean;
189
194
  infiniteLoading?: never;
195
+ /**
196
+ * Определение как должен работать чекбокс в тулбаре (по всем страницам или по текущей)
197
+ */
198
+ toolbarCheckBoxStrategy?: ToolbarCheckBoxStrategy;
190
199
  };
191
200
  export type TableProps<TData extends object, TFilters extends FiltersState = Record<string, unknown>> = InfiniteTableProps<TData, TFilters> | ClientTableProps<TData, TFilters>;
192
201
  export type ServerTableProps<TData extends object, TFilters extends FiltersState = Record<string, unknown>> = Omit<ClientTableProps<TData, TFilters>, 'pageSize' | 'pageCount' | 'pagination' | 'search' | 'data'> & {
@@ -3,9 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.RowAppearance = void 0;
6
+ exports.ToolbarCheckBoxStrategy = exports.RowAppearance = void 0;
7
7
  var RowAppearance;
8
8
  (function (RowAppearance) {
9
9
  RowAppearance["Disabled"] = "disabled";
10
10
  RowAppearance["HideToggler"] = "hide-toggler";
11
- })(RowAppearance || (exports.RowAppearance = RowAppearance = {}));
11
+ })(RowAppearance || (exports.RowAppearance = RowAppearance = {}));
12
+ var ToolbarCheckBoxStrategy;
13
+ (function (ToolbarCheckBoxStrategy) {
14
+ ToolbarCheckBoxStrategy["PageRows"] = "pageRows";
15
+ ToolbarCheckBoxStrategy["AllRows"] = "allRows";
16
+ })(ToolbarCheckBoxStrategy || (exports.ToolbarCheckBoxStrategy = ToolbarCheckBoxStrategy = {}));
@@ -14,6 +14,7 @@ const react_1 = require("react");
14
14
  const button_1 = require("@snack-uikit/button");
15
15
  const icons_1 = require("@snack-uikit/icons");
16
16
  const list_1 = require("@snack-uikit/list");
17
+ const types_1 = require("../../../components/types");
17
18
  const constants_1 = require("../../../constants");
18
19
  const contexts_1 = require("../../contexts");
19
20
  const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
@@ -24,7 +25,8 @@ function RowActionsCell(_ref) {
24
25
  } = _ref;
25
26
  const {
26
27
  dropListOpened,
27
- setDropListOpen
28
+ setDropListOpen,
29
+ disabledRowAppearance
28
30
  } = (0, contexts_1.useRowContext)();
29
31
  const patchItem = (0, react_1.useCallback)((item, cb) => {
30
32
  if ((0, list_1.isBaseItemProps)(item)) {
@@ -40,7 +42,8 @@ function RowActionsCell(_ref) {
40
42
  items: item.items.map(i => patchItem(i, cb))
41
43
  });
42
44
  }, []);
43
- const disabled = !row.getCanSelect();
45
+ const canSelect = row.getCanSelect();
46
+ const shouldShowActions = canSelect || disabledRowAppearance !== types_1.RowAppearance.Disabled;
44
47
  const stopPropagationClick = e => {
45
48
  e.stopPropagation();
46
49
  };
@@ -51,7 +54,7 @@ function RowActionsCell(_ref) {
51
54
  onClick: stopPropagationClick,
52
55
  className: styles_module_scss_1.default.rowActionsCellWrap,
53
56
  "data-open": dropListOpened || undefined,
54
- children: !disabled && Boolean(actions.length) && (0, jsx_runtime_1.jsx)(list_1.Droplist, {
57
+ children: shouldShowActions && Boolean(actions.length) && (0, jsx_runtime_1.jsx)(list_1.Droplist, {
55
58
  trigger: 'click',
56
59
  open: dropListOpened,
57
60
  onOpenChange: setDropListOpen,
@@ -40,7 +40,7 @@ function BodyRow(_ref) {
40
40
  getRowBackgroundColor
41
41
  } = (0, contexts_1.useTableContext)();
42
42
  const handleRowClick = e => {
43
- if (disabled) return;
43
+ if (disabled && disabledRowAppearance === components_1.RowAppearance.Disabled) return;
44
44
  onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(e, {
45
45
  id: row.id,
46
46
  data: row.original,
@@ -53,7 +53,8 @@ function BodyRow(_ref) {
53
53
  return (0, jsx_runtime_1.jsx)(contexts_1.RowContext.Provider, {
54
54
  value: {
55
55
  dropListOpened,
56
- setDropListOpen
56
+ setDropListOpen,
57
+ disabledRowAppearance
57
58
  },
58
59
  children: (0, jsx_runtime_1.jsxs)(Row_1.Row, {
59
60
  onClick: handleRowClick,
@@ -1,10 +1,12 @@
1
1
  import { Table } from '@tanstack/react-table';
2
2
  import { Dispatch, SetStateAction } from 'react';
3
3
  import { ValueOf } from '@snack-uikit/utils';
4
+ import { RowAppearance } from '../components/types';
4
5
  import { TABLE_ROW_COLOR } from '../constants';
5
6
  type RowContext = {
6
7
  dropListOpened: boolean;
7
8
  setDropListOpen: Dispatch<SetStateAction<boolean>>;
9
+ disabledRowAppearance: RowAppearance;
8
10
  };
9
11
  export declare const RowContext: import("react").Context<RowContext>;
10
12
  export declare const useRowContext: () => RowContext;
@@ -5,9 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useTableContext = exports.TableContext = exports.useRowContext = exports.RowContext = void 0;
7
7
  const react_1 = require("react");
8
+ const types_1 = require("../components/types");
8
9
  exports.RowContext = (0, react_1.createContext)({
9
10
  dropListOpened: false,
10
- setDropListOpen() {}
11
+ setDropListOpen() {},
12
+ disabledRowAppearance: types_1.RowAppearance.Disabled
11
13
  });
12
14
  const useRowContext = () => (0, react_1.useContext)(exports.RowContext);
13
15
  exports.useRowContext = useRowContext;
@@ -1,7 +1,7 @@
1
1
  import { FiltersState } from '@snack-uikit/chips';
2
2
  import { TableProps } from '../types';
3
3
  /** Компонент таблицы */
4
- export declare function Table<TData extends object, TFilters extends FiltersState = Record<string, unknown>>({ data, rowPinning, columnDefinitions, keepPinnedRows, copyPinnedRows, enableSelectPinned, rowSelection: rowSelectionProp, search, sorting: sortingProp, columnFilters, pagination: paginationProp, className, onRowClick, onRefresh, pageSize, pageCount, loading, infiniteLoading, outline, moreActions, exportSettings, dataFiltered, dataError, noDataState, noResultsState, errorDataState, suppressToolbar, suppressSearch, toolbarAfter, suppressPagination, manualSorting, manualPagination: manualPaginationProp, manualFiltering, autoResetPageIndex, scrollRef, scrollContainerRef, getRowId, enableFuzzySearch, savedState, expanding, bulkActions: bulkActionsProp, rowAutoHeight, columnsSettings: columnsSettingsProp, getRowBackgroundColor, ...rest }: TableProps<TData, TFilters>): import("react/jsx-runtime").JSX.Element;
4
+ export declare function Table<TData extends object, TFilters extends FiltersState = Record<string, unknown>>({ data, rowPinning, columnDefinitions, keepPinnedRows, copyPinnedRows, enableSelectPinned, rowSelection: rowSelectionProp, search, sorting: sortingProp, columnFilters, pagination: paginationProp, className, onRowClick, onRefresh, pageSize, pageCount, loading, infiniteLoading, outline, moreActions, exportSettings, dataFiltered, dataError, noDataState, noResultsState, errorDataState, suppressToolbar, suppressSearch, toolbarAfter, suppressPagination, manualSorting, manualPagination: manualPaginationProp, manualFiltering, autoResetPageIndex, scrollRef, scrollContainerRef, getRowId, enableFuzzySearch, savedState, expanding, bulkActions: bulkActionsProp, rowAutoHeight, columnsSettings: columnsSettingsProp, getRowBackgroundColor, toolbarCheckBoxStrategy, ...rest }: TableProps<TData, TFilters>): import("react/jsx-runtime").JSX.Element;
5
5
  export declare namespace Table {
6
6
  var getStatusColumnDef: typeof import("../../helperComponents").getStatusColumnDef;
7
7
  var statusAppearances: {
@@ -24,6 +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 { ToolbarCheckBoxStrategy } from '../types';
27
28
  import { useColumnOrderByDrag, useColumnSettings, useFilters, useLoadingTable, usePageReset, useStateControl, } from './hooks';
28
29
  import styles from './styles.module.css';
29
30
  import { getColumnStyleVars, getCurrentlyConfiguredHeaderWidth, getInitColumnSizeFromLocalStorage, getPinnedGroups, getTableColumnsDefinitions, saveStateToLocalStorage, } from './utils';
@@ -33,7 +34,7 @@ import { validateFilter, validatePaging, validateSorting } from './utils/saveTab
33
34
  export function Table(_a) {
34
35
  var { data, rowPinning = {
35
36
  top: [],
36
- }, columnDefinitions, keepPinnedRows = false, copyPinnedRows = false, enableSelectPinned = false, rowSelection: rowSelectionProp, search, sorting: sortingProp, columnFilters, pagination: paginationProp, className, onRowClick, onRefresh, pageSize = DEFAULT_PAGE_SIZE, pageCount, loading = false, infiniteLoading = false, outline = false, moreActions, exportSettings, dataFiltered, dataError, noDataState, noResultsState, errorDataState, suppressToolbar = false, suppressSearch = false, toolbarAfter, suppressPagination = false, manualSorting = false, manualPagination: manualPaginationProp = false, manualFiltering = false, autoResetPageIndex = false, scrollRef, scrollContainerRef, getRowId, enableFuzzySearch, savedState, expanding, bulkActions: bulkActionsProp, rowAutoHeight, columnsSettings: columnsSettingsProp, getRowBackgroundColor } = _a, rest = __rest(_a, ["data", "rowPinning", "columnDefinitions", "keepPinnedRows", "copyPinnedRows", "enableSelectPinned", "rowSelection", "search", "sorting", "columnFilters", "pagination", "className", "onRowClick", "onRefresh", "pageSize", "pageCount", "loading", "infiniteLoading", "outline", "moreActions", "exportSettings", "dataFiltered", "dataError", "noDataState", "noResultsState", "errorDataState", "suppressToolbar", "suppressSearch", "toolbarAfter", "suppressPagination", "manualSorting", "manualPagination", "manualFiltering", "autoResetPageIndex", "scrollRef", "scrollContainerRef", "getRowId", "enableFuzzySearch", "savedState", "expanding", "bulkActions", "rowAutoHeight", "columnsSettings", "getRowBackgroundColor"]);
37
+ }, columnDefinitions, keepPinnedRows = false, copyPinnedRows = false, enableSelectPinned = false, rowSelection: rowSelectionProp, search, sorting: sortingProp, columnFilters, pagination: paginationProp, className, onRowClick, onRefresh, pageSize = DEFAULT_PAGE_SIZE, pageCount, loading = false, infiniteLoading = false, outline = false, moreActions, exportSettings, dataFiltered, dataError, noDataState, noResultsState, errorDataState, suppressToolbar = false, suppressSearch = false, toolbarAfter, suppressPagination = false, manualSorting = false, manualPagination: manualPaginationProp = false, manualFiltering = false, autoResetPageIndex = false, scrollRef, scrollContainerRef, getRowId, enableFuzzySearch, savedState, expanding, bulkActions: bulkActionsProp, rowAutoHeight, columnsSettings: columnsSettingsProp, getRowBackgroundColor, toolbarCheckBoxStrategy } = _a, rest = __rest(_a, ["data", "rowPinning", "columnDefinitions", "keepPinnedRows", "copyPinnedRows", "enableSelectPinned", "rowSelection", "search", "sorting", "columnFilters", "pagination", "className", "onRowClick", "onRefresh", "pageSize", "pageCount", "loading", "infiniteLoading", "outline", "moreActions", "exportSettings", "dataFiltered", "dataError", "noDataState", "noResultsState", "errorDataState", "suppressToolbar", "suppressSearch", "toolbarAfter", "suppressPagination", "manualSorting", "manualPagination", "manualFiltering", "autoResetPageIndex", "scrollRef", "scrollContainerRef", "getRowId", "enableFuzzySearch", "savedState", "expanding", "bulkActions", "rowAutoHeight", "columnsSettings", "getRowBackgroundColor", "toolbarCheckBoxStrategy"]);
37
38
  const [globalFilter, onGlobalFilterChange] = useStateControl(search, '');
38
39
  const [rowSelection, onRowSelectionChange] = useStateControl(rowSelectionProp, DEFAULT_ROW_SELECTION);
39
40
  const defaultPaginationState = useMemo(() => ({
@@ -181,7 +182,9 @@ export function Table(_a) {
181
182
  const handleOnToolbarCheck = useCallback(() => {
182
183
  if (!loading && !enableSelectPinned && table.getTopRows().length) {
183
184
  const centerRows = table.getCenterRows();
184
- const isSomeRowsSelected = table.getIsSomePageRowsSelected();
185
+ const isSomeRowsSelected = toolbarCheckBoxStrategy === ToolbarCheckBoxStrategy.AllRows
186
+ ? table.getIsSomeRowsSelected()
187
+ : table.getIsSomePageRowsSelected();
185
188
  const isAllCenterRowsSelected = centerRows.every(row => row.getIsSelected());
186
189
  if (isAllCenterRowsSelected) {
187
190
  table.resetRowSelection();
@@ -191,10 +194,15 @@ export function Table(_a) {
191
194
  return;
192
195
  }
193
196
  if (!loading && (rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow)) {
194
- table.toggleAllPageRowsSelected();
197
+ if (toolbarCheckBoxStrategy === ToolbarCheckBoxStrategy.AllRows) {
198
+ table.toggleAllRowsSelected();
199
+ }
200
+ else {
201
+ table.toggleAllPageRowsSelected();
202
+ }
195
203
  return;
196
204
  }
197
- }, [loading, rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow, table, enableSelectPinned]);
205
+ }, [toolbarCheckBoxStrategy, loading, rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow, table, enableSelectPinned]);
198
206
  const columnSizeVarsRef = useRef();
199
207
  const headers = table.getFlatHeaders();
200
208
  const columnSizes = useMemo(() => {
@@ -277,6 +285,9 @@ export function Table(_a) {
277
285
  const { updateCellMap } = useCellAutoResizeController(table);
278
286
  const showToolbar = !suppressToolbar;
279
287
  const showPagination = !infiniteLoading && !suppressPagination;
288
+ const { checked, indeterminate } = toolbarCheckBoxStrategy === ToolbarCheckBoxStrategy.AllRows
289
+ ? { checked: table.getIsAllRowsSelected(), indeterminate: table.getIsSomeRowsSelected() }
290
+ : { checked: table.getIsAllPageRowsSelected(), indeterminate: table.getIsSomePageRowsSelected() };
280
291
  return (_jsxs("div", Object.assign({ className: cn(styles.wrapper, className), "data-with-toolbar": showToolbar || undefined }, extractSupportProps(rest), { children: [showToolbar && (_jsx("div", { className: styles.header, children: _jsx(Toolbar, { search: suppressSearch
281
292
  ? undefined
282
293
  : {
@@ -305,7 +316,7 @@ export function Table(_a) {
305
316
  }
306
317
  },
307
318
  }
308
- : undefined, bulkActions: bulkActions, selectionMode: (rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.multiRow) ? 'multiple' : 'single', checked: table.getIsAllPageRowsSelected(), indeterminate: table.getIsSomePageRowsSelected(), 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 }))] })));
319
+ : 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 }))] })));
309
320
  }
310
321
  Table.getStatusColumnDef = getStatusColumnDef;
311
322
  Table.statusAppearances = STATUS_APPEARANCE;
@@ -8,7 +8,6 @@ export declare function useFilters<TData extends object, TFilters extends Record
8
8
  onChange: (filter: TFilters) => void;
9
9
  visibleFilters: string[];
10
10
  onVisibleFiltersChange: import("@tanstack/react-table").OnChangeFn<string[]>;
11
- className?: string | undefined;
12
11
  "aria-activedescendant"?: string | undefined | undefined;
13
12
  "aria-atomic"?: (boolean | "true" | "false") | undefined;
14
13
  "aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined | undefined;
@@ -64,6 +63,7 @@ export declare function useFilters<TData extends object, TFilters extends Record
64
63
  "aria-valuetext"?: string | undefined | undefined;
65
64
  defaultValue?: Partial<TFilters> | undefined;
66
65
  filters: import("@snack-uikit/chips").ChipChoiceRowFilter[];
66
+ className?: string | undefined;
67
67
  showClearButton?: boolean | undefined;
68
68
  showAddButton?: boolean | undefined;
69
69
  open: boolean;
@@ -14,6 +14,10 @@ export declare enum RowAppearance {
14
14
  Disabled = "disabled",
15
15
  HideToggler = "hide-toggler"
16
16
  }
17
+ export declare enum ToolbarCheckBoxStrategy {
18
+ PageRows = "pageRows",
19
+ AllRows = "allRows"
20
+ }
17
21
  type BaseTableProps<TData extends object, TFilters extends FiltersState = Record<string, unknown>> = WithSupportProps<{
18
22
  /** Данные для отрисовки */
19
23
  data: TData[];
@@ -162,6 +166,7 @@ export type InfiniteTableProps<TData extends object, TFilters extends FiltersSta
162
166
  /** Отключение пагинации */
163
167
  suppressPagination?: never;
164
168
  manualPagination?: never;
169
+ toolbarCheckBoxStrategy?: never;
165
170
  };
166
171
  export type ClientTableProps<TData extends object, TFilters extends FiltersState = Record<string, unknown>> = BaseTableProps<TData, TFilters> & {
167
172
  /** Параметры отвечают за пагинацию в таблице <br>
@@ -187,6 +192,10 @@ export type ClientTableProps<TData extends object, TFilters extends FiltersState
187
192
  suppressPagination?: boolean;
188
193
  manualPagination?: boolean;
189
194
  infiniteLoading?: never;
195
+ /**
196
+ * Определение как должен работать чекбокс в тулбаре (по всем страницам или по текущей)
197
+ */
198
+ toolbarCheckBoxStrategy?: ToolbarCheckBoxStrategy;
190
199
  };
191
200
  export type TableProps<TData extends object, TFilters extends FiltersState = Record<string, unknown>> = InfiniteTableProps<TData, TFilters> | ClientTableProps<TData, TFilters>;
192
201
  export type ServerTableProps<TData extends object, TFilters extends FiltersState = Record<string, unknown>> = Omit<ClientTableProps<TData, TFilters>, 'pageSize' | 'pageCount' | 'pagination' | 'search' | 'data'> & {
@@ -3,3 +3,8 @@ export var RowAppearance;
3
3
  RowAppearance["Disabled"] = "disabled";
4
4
  RowAppearance["HideToggler"] = "hide-toggler";
5
5
  })(RowAppearance || (RowAppearance = {}));
6
+ export var ToolbarCheckBoxStrategy;
7
+ (function (ToolbarCheckBoxStrategy) {
8
+ ToolbarCheckBoxStrategy["PageRows"] = "pageRows";
9
+ ToolbarCheckBoxStrategy["AllRows"] = "allRows";
10
+ })(ToolbarCheckBoxStrategy || (ToolbarCheckBoxStrategy = {}));
@@ -3,11 +3,12 @@ import { useCallback, useMemo } from 'react';
3
3
  import { ButtonFunction } from '@snack-uikit/button';
4
4
  import { MoreSVG } from '@snack-uikit/icons';
5
5
  import { Droplist, isBaseItemProps } from '@snack-uikit/list';
6
+ import { RowAppearance } from '../../../components/types';
6
7
  import { COLUMN_PIN_POSITION, DefaultColumns, TEST_IDS } from '../../../constants';
7
8
  import { useRowContext } from '../../contexts';
8
9
  import styles from './styles.module.css';
9
10
  function RowActionsCell({ row, actions }) {
10
- const { dropListOpened, setDropListOpen } = useRowContext();
11
+ const { dropListOpened, setDropListOpen, disabledRowAppearance } = useRowContext();
11
12
  const patchItem = useCallback((item, cb) => {
12
13
  if (isBaseItemProps(item)) {
13
14
  return Object.assign(Object.assign({}, item), { onClick(e) {
@@ -18,14 +19,15 @@ function RowActionsCell({ row, actions }) {
18
19
  }
19
20
  return Object.assign(Object.assign({}, item), { items: item.items.map(i => patchItem(i, cb)) });
20
21
  }, []);
21
- const disabled = !row.getCanSelect();
22
+ const canSelect = row.getCanSelect();
23
+ const shouldShowActions = canSelect || disabledRowAppearance !== RowAppearance.Disabled;
22
24
  const stopPropagationClick = (e) => {
23
25
  e.stopPropagation();
24
26
  };
25
27
  const patchedItems = useMemo(() => actions.map(item => patchItem(item, () => setDropListOpen(false))), [actions, patchItem, setDropListOpen]);
26
28
  return (
27
29
  // eslint-disable-next-line jsx-a11y/no-static-element-interactions
28
- _jsx("div", { onClick: stopPropagationClick, className: styles.rowActionsCellWrap, "data-open": dropListOpened || undefined, children: !disabled && Boolean(actions.length) && (_jsx(Droplist, { trigger: 'click', open: dropListOpened, onOpenChange: setDropListOpen, placement: 'bottom-end', size: 'm', "data-test-id": TEST_IDS.rowActions.droplist, items: patchedItems, children: _jsx(ButtonFunction, { icon: _jsx(MoreSVG, { size: 24 }), "data-test-id": TEST_IDS.rowActions.droplistTrigger }) })) }));
30
+ _jsx("div", { onClick: stopPropagationClick, className: styles.rowActionsCellWrap, "data-open": dropListOpened || undefined, children: shouldShowActions && Boolean(actions.length) && (_jsx(Droplist, { trigger: 'click', open: dropListOpened, onOpenChange: setDropListOpen, placement: 'bottom-end', size: 'm', "data-test-id": TEST_IDS.rowActions.droplist, items: patchedItems, children: _jsx(ButtonFunction, { icon: _jsx(MoreSVG, { size: 24 }), "data-test-id": TEST_IDS.rowActions.droplistTrigger }) })) }));
29
31
  }
30
32
  /** Вспомогательная функция для создания ячейки с дополнительными действиями у строки */
31
33
  export function getRowActionsColumnDef({ actionsGenerator, pinned, }) {
@@ -15,7 +15,7 @@ export function BodyRow({ row, onRowClick, rowAutoHeight, columnOrder, enableCol
15
15
  const disabled = !row.getCanSelect();
16
16
  const { getRowBackgroundColor } = useTableContext();
17
17
  const handleRowClick = (e) => {
18
- if (disabled)
18
+ if (disabled && disabledRowAppearance === RowAppearance.Disabled)
19
19
  return;
20
20
  onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(e, {
21
21
  id: row.id,
@@ -26,5 +26,5 @@ export function BodyRow({ row, onRowClick, rowAutoHeight, columnOrder, enableCol
26
26
  };
27
27
  const isSelected = row.getIsSelected() || (row.getIsSomeSelected() && !row.getCanMultiSelect() && !row.getIsExpanded());
28
28
  const rowBackgroundColor = getRowBackgroundColor === null || getRowBackgroundColor === void 0 ? void 0 : getRowBackgroundColor(row.original);
29
- return (_jsx(RowContext.Provider, { value: { dropListOpened, setDropListOpen }, children: _jsxs(Row, { onClick: handleRowClick, "data-clickable": Boolean(onRowClick) || undefined, "data-disabled": disabled || undefined, "data-row-appearance": disabled ? disabledRowAppearance : undefined, "data-selected": isSelected || undefined, "data-actions-opened": dropListOpened || undefined, "data-test-id": TEST_IDS.bodyRow, "data-row-id": row.id, "data-row-bg-appearance": rowBackgroundColor && !disabled && !isSelected ? rowBackgroundColor : undefined, className: styles.bodyRow, rowAutoHeight: rowAutoHeight, children: [leftPinned && (_jsx(PinnedCells, { position: COLUMN_PIN_POSITION.Left, children: leftPinned.map(cell => (_jsx(BodyCell, { cell: cell, rowAutoHeight: rowAutoHeight }, cell.id))) })), unpinned.map(cell => (_jsx(SortableContext, { items: columnOrder, strategy: horizontalListSortingStrategy, children: _jsx(BodyCell, { cell: cell, rowAutoHeight: rowAutoHeight, isDraggable: enableColumnsOrderSortByDrag }, cell.id) }, cell.id))), rightPinned && (_jsx(PinnedCells, { position: COLUMN_PIN_POSITION.Right, children: rightPinned.map(cell => (_jsx(BodyCell, { cell: cell, rowAutoHeight: rowAutoHeight, isDraggable: enableColumnsOrderSortByDrag }, cell.id))) }))] }) }));
29
+ return (_jsx(RowContext.Provider, { value: { dropListOpened, setDropListOpen, disabledRowAppearance }, children: _jsxs(Row, { onClick: handleRowClick, "data-clickable": Boolean(onRowClick) || undefined, "data-disabled": disabled || undefined, "data-row-appearance": disabled ? disabledRowAppearance : undefined, "data-selected": isSelected || undefined, "data-actions-opened": dropListOpened || undefined, "data-test-id": TEST_IDS.bodyRow, "data-row-id": row.id, "data-row-bg-appearance": rowBackgroundColor && !disabled && !isSelected ? rowBackgroundColor : undefined, className: styles.bodyRow, rowAutoHeight: rowAutoHeight, children: [leftPinned && (_jsx(PinnedCells, { position: COLUMN_PIN_POSITION.Left, children: leftPinned.map(cell => (_jsx(BodyCell, { cell: cell, rowAutoHeight: rowAutoHeight }, cell.id))) })), unpinned.map(cell => (_jsx(SortableContext, { items: columnOrder, strategy: horizontalListSortingStrategy, children: _jsx(BodyCell, { cell: cell, rowAutoHeight: rowAutoHeight, isDraggable: enableColumnsOrderSortByDrag }, cell.id) }, cell.id))), rightPinned && (_jsx(PinnedCells, { position: COLUMN_PIN_POSITION.Right, children: rightPinned.map(cell => (_jsx(BodyCell, { cell: cell, rowAutoHeight: rowAutoHeight, isDraggable: enableColumnsOrderSortByDrag }, cell.id))) }))] }) }));
30
30
  }
@@ -1,10 +1,12 @@
1
1
  import { Table } from '@tanstack/react-table';
2
2
  import { Dispatch, SetStateAction } from 'react';
3
3
  import { ValueOf } from '@snack-uikit/utils';
4
+ import { RowAppearance } from '../components/types';
4
5
  import { TABLE_ROW_COLOR } from '../constants';
5
6
  type RowContext = {
6
7
  dropListOpened: boolean;
7
8
  setDropListOpen: Dispatch<SetStateAction<boolean>>;
9
+ disabledRowAppearance: RowAppearance;
8
10
  };
9
11
  export declare const RowContext: import("react").Context<RowContext>;
10
12
  export declare const useRowContext: () => RowContext;
@@ -1,7 +1,9 @@
1
1
  import { createContext, useContext } from 'react';
2
+ import { RowAppearance } from '../components/types';
2
3
  export const RowContext = createContext({
3
4
  dropListOpened: false,
4
5
  setDropListOpen() { },
6
+ disabledRowAppearance: RowAppearance.Disabled,
5
7
  });
6
8
  export const useRowContext = () => useContext(RowContext);
7
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Table",
7
- "version": "0.37.31",
7
+ "version": "0.37.33-preview-d75faeae.0",
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": "84371bbf91915f650a852df849cd71d416c5b7b2"
68
+ "gitHead": "013bf859d7032b7ca88f3425f359b8c03c75dec5"
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 } from '../types';
53
+ import { TableProps, ToolbarCheckBoxStrategy } from '../types';
54
54
  import {
55
55
  useColumnOrderByDrag,
56
56
  useColumnSettings,
@@ -124,6 +124,7 @@ export function Table<TData extends object, TFilters extends FiltersState = Reco
124
124
  rowAutoHeight,
125
125
  columnsSettings: columnsSettingsProp,
126
126
  getRowBackgroundColor,
127
+ toolbarCheckBoxStrategy,
127
128
  ...rest
128
129
  }: TableProps<TData, TFilters>) {
129
130
  const [globalFilter, onGlobalFilterChange] = useStateControl<string>(search, '');
@@ -331,7 +332,10 @@ export function Table<TData extends object, TFilters extends FiltersState = Reco
331
332
  const handleOnToolbarCheck = useCallback(() => {
332
333
  if (!loading && !enableSelectPinned && table.getTopRows().length) {
333
334
  const centerRows = table.getCenterRows();
334
- const isSomeRowsSelected = table.getIsSomePageRowsSelected();
335
+ const isSomeRowsSelected =
336
+ toolbarCheckBoxStrategy === ToolbarCheckBoxStrategy.AllRows
337
+ ? table.getIsSomeRowsSelected()
338
+ : table.getIsSomePageRowsSelected();
335
339
  const isAllCenterRowsSelected = centerRows.every(row => row.getIsSelected());
336
340
 
337
341
  if (isAllCenterRowsSelected) {
@@ -344,10 +348,14 @@ export function Table<TData extends object, TFilters extends FiltersState = Reco
344
348
  }
345
349
 
346
350
  if (!loading && rowSelectionProp?.multiRow) {
347
- table.toggleAllPageRowsSelected();
351
+ if (toolbarCheckBoxStrategy === ToolbarCheckBoxStrategy.AllRows) {
352
+ table.toggleAllRowsSelected();
353
+ } else {
354
+ table.toggleAllPageRowsSelected();
355
+ }
348
356
  return;
349
357
  }
350
- }, [loading, rowSelectionProp?.multiRow, table, enableSelectPinned]);
358
+ }, [toolbarCheckBoxStrategy, loading, rowSelectionProp?.multiRow, table, enableSelectPinned]);
351
359
 
352
360
  const columnSizeVarsRef = useRef<Record<string, string>>();
353
361
  const headers = table.getFlatHeaders();
@@ -450,6 +458,11 @@ export function Table<TData extends object, TFilters extends FiltersState = Reco
450
458
  const showToolbar = !suppressToolbar;
451
459
  const showPagination = !infiniteLoading && !suppressPagination;
452
460
 
461
+ const { checked, indeterminate } =
462
+ toolbarCheckBoxStrategy === ToolbarCheckBoxStrategy.AllRows
463
+ ? { checked: table.getIsAllRowsSelected(), indeterminate: table.getIsSomeRowsSelected() }
464
+ : { checked: table.getIsAllPageRowsSelected(), indeterminate: table.getIsSomePageRowsSelected() };
465
+
453
466
  return (
454
467
  <div
455
468
  className={cn(styles.wrapper, className)}
@@ -497,8 +510,8 @@ export function Table<TData extends object, TFilters extends FiltersState = Reco
497
510
  }
498
511
  bulkActions={bulkActions}
499
512
  selectionMode={rowSelectionProp?.multiRow ? 'multiple' : 'single'}
500
- checked={table.getIsAllPageRowsSelected()}
501
- indeterminate={table.getIsSomePageRowsSelected()}
513
+ checked={checked}
514
+ indeterminate={indeterminate}
502
515
  onCheck={enableSelection ? handleOnToolbarCheck : undefined}
503
516
  outline={outline}
504
517
  after={
@@ -27,6 +27,11 @@ export enum RowAppearance {
27
27
  HideToggler = 'hide-toggler',
28
28
  }
29
29
 
30
+ export enum ToolbarCheckBoxStrategy {
31
+ PageRows = 'pageRows',
32
+ AllRows = 'allRows',
33
+ }
34
+
30
35
  type BaseTableProps<TData extends object, TFilters extends FiltersState = Record<string, unknown>> = WithSupportProps<{
31
36
  /** Данные для отрисовки */
32
37
  data: TData[];
@@ -202,6 +207,8 @@ export type InfiniteTableProps<
202
207
  suppressPagination?: never;
203
208
 
204
209
  manualPagination?: never;
210
+
211
+ toolbarCheckBoxStrategy?: never;
205
212
  };
206
213
 
207
214
  export type ClientTableProps<
@@ -236,6 +243,11 @@ export type ClientTableProps<
236
243
  manualPagination?: boolean;
237
244
 
238
245
  infiniteLoading?: never;
246
+
247
+ /**
248
+ * Определение как должен работать чекбокс в тулбаре (по всем страницам или по текущей)
249
+ */
250
+ toolbarCheckBoxStrategy?: ToolbarCheckBoxStrategy;
239
251
  };
240
252
 
241
253
  export type TableProps<TData extends object, TFilters extends FiltersState = Record<string, unknown>> =
@@ -5,6 +5,7 @@ import { ButtonFunction } from '@snack-uikit/button';
5
5
  import { MoreSVG } from '@snack-uikit/icons';
6
6
  import { Droplist, DroplistProps, isBaseItemProps, ItemProps } from '@snack-uikit/list';
7
7
 
8
+ import { RowAppearance } from '../../../components/types';
8
9
  import { COLUMN_PIN_POSITION, DefaultColumns, TEST_IDS } from '../../../constants';
9
10
  import { ColumnDefinition } from '../../../types';
10
11
  import { useRowContext } from '../../contexts';
@@ -16,7 +17,7 @@ type RowActionsCellProps<TData> = {
16
17
  };
17
18
 
18
19
  function RowActionsCell<TData>({ row, actions }: RowActionsCellProps<TData>) {
19
- const { dropListOpened, setDropListOpen } = useRowContext();
20
+ const { dropListOpened, setDropListOpen, disabledRowAppearance } = useRowContext();
20
21
 
21
22
  const patchItem = useCallback((item: ItemProps, cb: MouseEventHandler): ItemProps => {
22
23
  if (isBaseItemProps(item)) {
@@ -32,7 +33,8 @@ function RowActionsCell<TData>({ row, actions }: RowActionsCellProps<TData>) {
32
33
  return { ...item, items: item.items.map(i => patchItem(i, cb)) };
33
34
  }, []);
34
35
 
35
- const disabled = !row.getCanSelect();
36
+ const canSelect = row.getCanSelect();
37
+ const shouldShowActions = canSelect || disabledRowAppearance !== RowAppearance.Disabled;
36
38
 
37
39
  const stopPropagationClick = (e: MouseEvent<HTMLDivElement>) => {
38
40
  e.stopPropagation();
@@ -46,7 +48,7 @@ function RowActionsCell<TData>({ row, actions }: RowActionsCellProps<TData>) {
46
48
  return (
47
49
  // eslint-disable-next-line jsx-a11y/no-static-element-interactions
48
50
  <div onClick={stopPropagationClick} className={styles.rowActionsCellWrap} data-open={dropListOpened || undefined}>
49
- {!disabled && Boolean(actions.length) && (
51
+ {shouldShowActions && Boolean(actions.length) && (
50
52
  <Droplist
51
53
  trigger='click'
52
54
  open={dropListOpened}
@@ -46,7 +46,7 @@ export function BodyRow<TData>({
46
46
  const { getRowBackgroundColor } = useTableContext();
47
47
 
48
48
  const handleRowClick = (e: MouseEvent<HTMLDivElement>) => {
49
- if (disabled) return;
49
+ if (disabled && disabledRowAppearance === RowAppearance.Disabled) return;
50
50
 
51
51
  onRowClick?.(e, {
52
52
  id: row.id,
@@ -62,7 +62,7 @@ export function BodyRow<TData>({
62
62
  const rowBackgroundColor = getRowBackgroundColor?.(row.original);
63
63
 
64
64
  return (
65
- <RowContext.Provider value={{ dropListOpened, setDropListOpen }}>
65
+ <RowContext.Provider value={{ dropListOpened, setDropListOpen, disabledRowAppearance }}>
66
66
  <Row
67
67
  onClick={handleRowClick}
68
68
  data-clickable={Boolean(onRowClick) || undefined}
@@ -3,16 +3,19 @@ import { createContext, Dispatch, SetStateAction, useContext } from 'react';
3
3
 
4
4
  import { ValueOf } from '@snack-uikit/utils';
5
5
 
6
+ import { RowAppearance } from '../components/types';
6
7
  import { TABLE_ROW_COLOR } from '../constants';
7
8
 
8
9
  type RowContext = {
9
10
  dropListOpened: boolean;
10
11
  setDropListOpen: Dispatch<SetStateAction<boolean>>;
12
+ disabledRowAppearance: RowAppearance;
11
13
  };
12
14
 
13
15
  export const RowContext = createContext<RowContext>({
14
16
  dropListOpened: false,
15
17
  setDropListOpen() {},
18
+ disabledRowAppearance: RowAppearance.Disabled,
16
19
  });
17
20
 
18
21
  export const useRowContext = () => useContext(RowContext);