@snack-uikit/table 0.16.0 → 0.16.1-preview-e80dc58f.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/README.md CHANGED
@@ -160,6 +160,7 @@ const columnDefinitions: ColumnDefinition<TableData>[] = [
160
160
  |------|------|---------------|-------------|
161
161
  | actionsGenerator* | `ActionsGenerator<TData>` | - | Действия для строки |
162
162
  | pinned | `boolean` | - | Закрепление колонки справа в таблице |
163
+ | dataTestId | `string` | - | |
163
164
  ## ServerTable
164
165
  ### Props
165
166
  | name | type | default value | description |
@@ -205,6 +206,7 @@ const columnDefinitions: ColumnDefinition<TableData>[] = [
205
206
  |------|------|---------------|-------------|
206
207
  | actionsGenerator* | `ActionsGenerator<TData>` | - | Действия для строки |
207
208
  | pinned | `boolean` | - | Закрепление колонки справа в таблице |
209
+ | dataTestId | `string` | - | |
208
210
  ## ServerTable.getStatusColumnDef
209
211
  Вспомогательная функция для создания ячейки со статусом
210
212
  ### Props
@@ -20,6 +20,7 @@ export type RowActionsColumnDefProps<TData> = {
20
20
  actionsGenerator: ActionsGenerator<TData>;
21
21
  /** Закрепление колонки справа в таблице */
22
22
  pinned?: boolean;
23
+ dataTestId?: string;
23
24
  };
24
25
  /** Вспомогательная функция для создания ячейки с дополнительными действиями у строки */
25
- export declare function getRowActionsColumnDef<TData>({ actionsGenerator, pinned, }: RowActionsColumnDefProps<TData>): ColumnDefinition<TData>;
26
+ export declare function getRowActionsColumnDef<TData>({ actionsGenerator, pinned, dataTestId, }: RowActionsColumnDefProps<TData>): ColumnDefinition<TData>;
@@ -7,7 +7,7 @@ import { Tag } from '@snack-uikit/tag';
7
7
  import { COLUMN_PIN_POSITION, TEST_IDS } from '../../../constants';
8
8
  import { useRowContext } from '../../contexts';
9
9
  import styles from './styles.module.css';
10
- function RowActionsCell({ row, actions }) {
10
+ function RowActionsCell({ row, actions, dataTestId }) {
11
11
  const { droplistOpened, setDroplistOpen } = useRowContext();
12
12
  const triggerRef = useRef(null);
13
13
  const handleItemClick = (item) => (e) => {
@@ -33,10 +33,10 @@ function RowActionsCell({ row, actions }) {
33
33
  beforeContent: item.icon,
34
34
  afterContent: item.tagLabel ? _jsx(Tag, { label: item.tagLabel }) : undefined,
35
35
  'data-test-id': item['data-test-id'] || TEST_IDS.rowActions.option,
36
- })), children: _jsx("span", { className: styles.rowActionsCellTrigger, children: _jsx(ButtonFunction, { icon: _jsx(MoreSVG, { size: 24 }), "data-test-id": TEST_IDS.rowActions.droplistTrigger, ref: triggerRef }) }) })) }));
36
+ })), children: _jsx("span", { className: styles.rowActionsCellTrigger, children: _jsx(ButtonFunction, { icon: _jsx(MoreSVG, { size: 24 }), "data-test-id": dataTestId || TEST_IDS.rowActions.droplistTrigger, ref: triggerRef }) }) })) }));
37
37
  }
38
38
  /** Вспомогательная функция для создания ячейки с дополнительными действиями у строки */
39
- export function getRowActionsColumnDef({ actionsGenerator, pinned, }) {
39
+ export function getRowActionsColumnDef({ actionsGenerator, pinned, dataTestId, }) {
40
40
  return {
41
41
  id: 'rowActions',
42
42
  pinned: pinned ? COLUMN_PIN_POSITION.Right : undefined,
@@ -47,6 +47,6 @@ export function getRowActionsColumnDef({ actionsGenerator, pinned, }) {
47
47
  noBodyCellPadding: true,
48
48
  cellClassName: styles.rowActionsCell,
49
49
  enableResizing: false,
50
- cell: cell => _jsx(RowActionsCell, { row: cell.row, actions: actionsGenerator(cell) }),
50
+ cell: cell => _jsx(RowActionsCell, { row: cell.row, actions: actionsGenerator(cell), dataTestId: dataTestId }),
51
51
  };
52
52
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Table",
7
- "version": "0.16.0",
7
+ "version": "0.16.1-preview-e80dc58f.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -58,5 +58,5 @@
58
58
  "peerDependencies": {
59
59
  "@snack-uikit/locale": "*"
60
60
  },
61
- "gitHead": "baa0f9027fdf9f8f39673bb9fd403cb290b19bd3"
61
+ "gitHead": "1d4571726b733eb1e0b6725e83a95454ae1aa7a4"
62
62
  }
@@ -28,9 +28,10 @@ export type RowActionProps<TData> = Pick<BaseItemProps, 'content' | 'disabled' |
28
28
  type RowActionsCellProps<TData> = {
29
29
  actions: RowActionProps<TData>[];
30
30
  row: Row<TData>;
31
+ dataTestId?: string;
31
32
  };
32
33
 
33
- function RowActionsCell<TData>({ row, actions }: RowActionsCellProps<TData>) {
34
+ function RowActionsCell<TData>({ row, actions, dataTestId }: RowActionsCellProps<TData>) {
34
35
  const { droplistOpened, setDroplistOpen } = useRowContext();
35
36
  const triggerRef = useRef(null);
36
37
 
@@ -76,7 +77,7 @@ function RowActionsCell<TData>({ row, actions }: RowActionsCellProps<TData>) {
76
77
  <span className={styles.rowActionsCellTrigger}>
77
78
  <ButtonFunction
78
79
  icon={<MoreSVG size={24} />}
79
- data-test-id={TEST_IDS.rowActions.droplistTrigger}
80
+ data-test-id={dataTestId || TEST_IDS.rowActions.droplistTrigger}
80
81
  ref={triggerRef}
81
82
  />
82
83
  </span>
@@ -93,12 +94,14 @@ export type RowActionsColumnDefProps<TData> = {
93
94
  actionsGenerator: ActionsGenerator<TData>;
94
95
  /** Закрепление колонки справа в таблице */
95
96
  pinned?: boolean;
97
+ dataTestId?: string;
96
98
  };
97
99
 
98
100
  /** Вспомогательная функция для создания ячейки с дополнительными действиями у строки */
99
101
  export function getRowActionsColumnDef<TData>({
100
102
  actionsGenerator,
101
103
  pinned,
104
+ dataTestId,
102
105
  }: RowActionsColumnDefProps<TData>): ColumnDefinition<TData> {
103
106
  return {
104
107
  id: 'rowActions',
@@ -110,6 +113,6 @@ export function getRowActionsColumnDef<TData>({
110
113
  noBodyCellPadding: true,
111
114
  cellClassName: styles.rowActionsCell,
112
115
  enableResizing: false,
113
- cell: cell => <RowActionsCell row={cell.row} actions={actionsGenerator(cell)} />,
116
+ cell: cell => <RowActionsCell row={cell.row} actions={actionsGenerator(cell)} dataTestId={dataTestId} />,
114
117
  };
115
118
  }