@snack-uikit/table 0.37.30 → 0.37.32

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,23 @@
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
+
14
+ ## <small>0.37.31 (2026-01-19)</small>
15
+
16
+ * chore(FF-6693): migrate tests from TestCafe to Playwright ([f32aff8](https://github.com/cloud-ru-tech/snack-uikit/commit/f32aff8))
17
+ * chore(FF-6693): tune test configs ([d194f4d](https://github.com/cloud-ru-tech/snack-uikit/commit/d194f4d))
18
+
19
+
20
+
21
+
22
+
6
23
  ## <small>0.37.30 (2026-01-19)</small>
7
24
 
8
25
  ### Only dependencies have been changed
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
  />
@@ -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,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;
@@ -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;
@@ -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.30",
7
+ "version": "0.37.32",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -41,19 +41,19 @@
41
41
  "@dnd-kit/modifiers": "9.0.0",
42
42
  "@dnd-kit/sortable": "10.0.0",
43
43
  "@dnd-kit/utilities": "3.2.2",
44
- "@snack-uikit/button": "0.19.16",
45
- "@snack-uikit/chips": "0.28.12",
46
- "@snack-uikit/icons": "0.27.4",
47
- "@snack-uikit/info-block": "0.6.35",
48
- "@snack-uikit/list": "0.32.11",
49
- "@snack-uikit/pagination": "0.10.21",
50
- "@snack-uikit/scroll": "0.10.5",
51
- "@snack-uikit/skeleton": "0.6.9",
52
- "@snack-uikit/toggles": "0.13.23",
53
- "@snack-uikit/toolbar": "0.14.16",
54
- "@snack-uikit/truncate-string": "0.7.6",
55
- "@snack-uikit/typography": "0.8.11",
56
- "@snack-uikit/utils": "4.0.0",
44
+ "@snack-uikit/button": "0.19.17",
45
+ "@snack-uikit/chips": "0.28.13",
46
+ "@snack-uikit/icons": "0.27.5",
47
+ "@snack-uikit/info-block": "0.6.36",
48
+ "@snack-uikit/list": "0.32.12",
49
+ "@snack-uikit/pagination": "0.10.22",
50
+ "@snack-uikit/scroll": "0.10.6",
51
+ "@snack-uikit/skeleton": "0.6.10",
52
+ "@snack-uikit/toggles": "0.13.24",
53
+ "@snack-uikit/toolbar": "0.14.17",
54
+ "@snack-uikit/truncate-string": "0.7.7",
55
+ "@snack-uikit/typography": "0.8.12",
56
+ "@snack-uikit/utils": "4.0.1",
57
57
  "@tanstack/match-sorter-utils": "8.11.8",
58
58
  "@tanstack/react-table": "8.12.0",
59
59
  "classnames": "2.5.1",
@@ -65,5 +65,5 @@
65
65
  "peerDependencies": {
66
66
  "@snack-uikit/locale": "*"
67
67
  },
68
- "gitHead": "2baa589b36417cff3006e42bee78144c8ec5e83a"
68
+ "gitHead": "ea7d4bcae5db6d2c049f9b7ecd04537dec0a014a"
69
69
  }
@@ -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);