@cloud-ru/uikit-product-mobile-table 2.3.12 → 2.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md 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
+ ## 2.3.13 (2026-08-03)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **FF-8845:** pass columnPinning to MobileTable to keep pinned columns order ([8aa9471](https://github.com/cloud-ru-tech/uikit-product/commit/8aa9471f30e9fc2d1c059452142c11a4dd806f7f))
12
+
13
+
14
+
15
+
16
+
6
17
  ## 2.3.12 (2026-07-29)
7
18
 
8
19
  ### Only dependencies have been changed
@@ -48,6 +48,20 @@ function MobileTable(_a) {
48
48
  }, [rowSelectionProp]);
49
49
  const enableSelection = Boolean(rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.enable);
50
50
  const pinnedGroups = (0, react_1.useMemo)(() => (0, table_1.getPinnedGroups)(columnDefinitions), [columnDefinitions]);
51
+ // columnOrder не содержит закреплённых колонок, поэтому без columnPinning они уезжают в конец карточки
52
+ const columnPinning = (0, react_1.useMemo)(() => {
53
+ const getColumnIds = (columnDefinitions) => columnDefinitions.reduce((accArr, colDef) => {
54
+ const id = (0, utils_1.getColumnIdentifier)(colDef);
55
+ if (id) {
56
+ accArr.push(id);
57
+ }
58
+ return accArr;
59
+ }, []);
60
+ return {
61
+ left: getColumnIds(pinnedGroups.left),
62
+ right: getColumnIds(pinnedGroups.right),
63
+ };
64
+ }, [pinnedGroups]);
51
65
  const { enabledColumns, setEnabledColumns, getColumnsSettings, enabledTableColumns, enabledColumnsDefinitions, areColumnsSettingsEnabled, } = (0, table_1.useColumnSettings)({
52
66
  columnDefinitions,
53
67
  pinnedGroups,
@@ -70,13 +84,7 @@ function MobileTable(_a) {
70
84
  const hidden = new Set();
71
85
  columnDefinitions.forEach(colDef => {
72
86
  var _a;
73
- let columnId;
74
- if ('id' in colDef && colDef.id) {
75
- columnId = colDef.id;
76
- }
77
- else if ('accessorKey' in colDef && colDef.accessorKey) {
78
- columnId = String(colDef.accessorKey);
79
- }
87
+ const columnId = (0, utils_1.getColumnIdentifier)(colDef);
80
88
  if (columnId) {
81
89
  const colDefWithSettings = colDef;
82
90
  if (((_a = colDefWithSettings.columnSettings) === null || _a === void 0 ? void 0 : _a.mode) === 'hidden') {
@@ -115,6 +123,7 @@ function MobileTable(_a) {
115
123
  globalFilter,
116
124
  sorting,
117
125
  rowSelection,
126
+ columnPinning,
118
127
  columnOrder: enableColumnsOrderSortByDrag ? columnOrder : undefined,
119
128
  },
120
129
  pageCount,
@@ -140,6 +149,7 @@ function MobileTable(_a) {
140
149
  const { loadingTable } = (0, hooks_1.useLoadingTable)({
141
150
  pageSize: constants_1.DEFAULT_PAGE_SIZE,
142
151
  columnDefinitions: enabledColumnsDefinitions,
152
+ columnPinning,
143
153
  });
144
154
  const tableRows = table.getRowModel().rows;
145
155
  const loadingTableRows = loadingTable.getRowModel().rows;
@@ -1,10 +1,12 @@
1
+ import { ColumnPinningState } from '@tanstack/react-table';
1
2
  import { FiltersState } from '@cloud-ru/uikit-product-mobile-chips';
2
3
  import { TableProps } from '@snack-uikit/table';
3
4
  type UseLoadingTableProps<TData extends object, TFilters extends FiltersState> = {
4
5
  columnDefinitions: TableProps<TData, TFilters>['columnDefinitions'];
5
6
  pageSize: number;
7
+ columnPinning: ColumnPinningState;
6
8
  };
7
- export declare function useLoadingTable<TData extends object, TFilters extends FiltersState>({ pageSize, columnDefinitions, }: UseLoadingTableProps<TData, TFilters>): {
9
+ export declare function useLoadingTable<TData extends object, TFilters extends FiltersState>({ pageSize, columnDefinitions, columnPinning, }: UseLoadingTableProps<TData, TFilters>): {
8
10
  loadingTable: import("@tanstack/react-table").Table<TData>;
9
11
  };
10
12
  export {};
@@ -6,7 +6,7 @@ const react_table_1 = require("@tanstack/react-table");
6
6
  const react_1 = require("react");
7
7
  const skeleton_1 = require("@snack-uikit/skeleton");
8
8
  const constants_1 = require("../../../constants");
9
- function useLoadingTable({ pageSize, columnDefinitions, }) {
9
+ function useLoadingTable({ pageSize, columnDefinitions, columnPinning, }) {
10
10
  const data = (0, react_1.useMemo)(() => (Array.from({ length: pageSize }).map(() => ({})) || []), [pageSize]);
11
11
  const columns = (0, react_1.useMemo)(() => columnDefinitions
12
12
  .filter(column => column.id !== constants_1.ROW_ACTIONS_COLUMN_ID)
@@ -14,6 +14,9 @@ function useLoadingTable({ pageSize, columnDefinitions, }) {
14
14
  const loadingTable = (0, react_table_1.useReactTable)({
15
15
  data,
16
16
  columns,
17
+ state: {
18
+ columnPinning,
19
+ },
17
20
  getCoreRowModel: (0, react_table_1.getCoreRowModel)(),
18
21
  });
19
22
  return { loadingTable };
@@ -0,0 +1,6 @@
1
+ import { ColumnDefinition } from '@snack-uikit/table';
2
+ /**
3
+ * Возвращает идентификатор колонки: `id`, либо `accessorKey`, если `id` не задан
4
+ * @function getColumnIdentifier
5
+ */
6
+ export declare function getColumnIdentifier<TData extends object>(colDef: ColumnDefinition<TData>): string | undefined;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getColumnIdentifier = getColumnIdentifier;
4
+ /**
5
+ * Возвращает идентификатор колонки: `id`, либо `accessorKey`, если `id` не задан
6
+ * @function getColumnIdentifier
7
+ */
8
+ function getColumnIdentifier(colDef) {
9
+ if ('id' in colDef && colDef.id) {
10
+ return colDef.id;
11
+ }
12
+ if ('accessorKey' in colDef && colDef.accessorKey) {
13
+ return String(colDef.accessorKey);
14
+ }
15
+ return undefined;
16
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './fuzzyFilter';
2
+ export * from './getColumnIdentifier';
2
3
  export * from './saveTableState';
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./fuzzyFilter"), exports);
18
+ __exportStar(require("./getColumnIdentifier"), exports);
18
19
  __exportStar(require("./saveTableState"), exports);
@@ -22,7 +22,7 @@ import { DEFAULT_PAGE_SIZE } from '../../constants';
22
22
  import { ColumnsSettings, getRowActionsColumnDef, getStatusColumnDef, TableCard, TableEmptyState, TablePagination, TableSorting, useEmptyState, } from '../../helperComponents';
23
23
  import { useFilters, useLoadingTable, useStateControl } from './hooks';
24
24
  import styles from './styles.module.css';
25
- import { fuzzyFilter, getPersistedStateValidator, mapPaginationToRequestPayload, mapPaginationToTableState, mapSortToRequestPayload, mapSortToTableState, } from './utils';
25
+ import { fuzzyFilter, getColumnIdentifier, getPersistedStateValidator, mapPaginationToRequestPayload, mapPaginationToTableState, mapSortToRequestPayload, mapSortToTableState, } from './utils';
26
26
  export function MobileTable(_a) {
27
27
  var { data, columnDefinitions, headlineId, suppressPagination = false, suppressHeader = false, suppressToolbar = false, suppressSearch = false, enableFuzzySearch = false, search, onRefresh, toolbarAfter, moreActions, columnFilters, className, headerBackground = 'default', noDataState, noResultsState, errorDataState, loading, dataError, dataFiltered, pagination: paginationProp, pageCount, sorting: sortingProp, manualSorting = false, manualPagination = false, manualFiltering = false, autoResetPageIndex = false, getRowId, rowSelection: rowSelectionProp, bulkActions: bulkActionsProp, columnsSettings: columnsSettingsProp, savedState, toolbarCheckBoxMode } = _a, rest = __rest(_a, ["data", "columnDefinitions", "headlineId", "suppressPagination", "suppressHeader", "suppressToolbar", "suppressSearch", "enableFuzzySearch", "search", "onRefresh", "toolbarAfter", "moreActions", "columnFilters", "className", "headerBackground", "noDataState", "noResultsState", "errorDataState", "loading", "dataError", "dataFiltered", "pagination", "pageCount", "sorting", "manualSorting", "manualPagination", "manualFiltering", "autoResetPageIndex", "getRowId", "rowSelection", "bulkActions", "columnsSettings", "savedState", "toolbarCheckBoxMode"]);
28
28
  const defaultPaginationState = useMemo(() => ({ pageIndex: 0, pageSize: DEFAULT_PAGE_SIZE }), []);
@@ -42,6 +42,20 @@ export function MobileTable(_a) {
42
42
  }, [rowSelectionProp]);
43
43
  const enableSelection = Boolean(rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.enable);
44
44
  const pinnedGroups = useMemo(() => getPinnedGroups(columnDefinitions), [columnDefinitions]);
45
+ // columnOrder не содержит закреплённых колонок, поэтому без columnPinning они уезжают в конец карточки
46
+ const columnPinning = useMemo(() => {
47
+ const getColumnIds = (columnDefinitions) => columnDefinitions.reduce((accArr, colDef) => {
48
+ const id = getColumnIdentifier(colDef);
49
+ if (id) {
50
+ accArr.push(id);
51
+ }
52
+ return accArr;
53
+ }, []);
54
+ return {
55
+ left: getColumnIds(pinnedGroups.left),
56
+ right: getColumnIds(pinnedGroups.right),
57
+ };
58
+ }, [pinnedGroups]);
45
59
  const { enabledColumns, setEnabledColumns, getColumnsSettings, enabledTableColumns, enabledColumnsDefinitions, areColumnsSettingsEnabled, } = useColumnSettings({
46
60
  columnDefinitions,
47
61
  pinnedGroups,
@@ -64,13 +78,7 @@ export function MobileTable(_a) {
64
78
  const hidden = new Set();
65
79
  columnDefinitions.forEach(colDef => {
66
80
  var _a;
67
- let columnId;
68
- if ('id' in colDef && colDef.id) {
69
- columnId = colDef.id;
70
- }
71
- else if ('accessorKey' in colDef && colDef.accessorKey) {
72
- columnId = String(colDef.accessorKey);
73
- }
81
+ const columnId = getColumnIdentifier(colDef);
74
82
  if (columnId) {
75
83
  const colDefWithSettings = colDef;
76
84
  if (((_a = colDefWithSettings.columnSettings) === null || _a === void 0 ? void 0 : _a.mode) === 'hidden') {
@@ -109,6 +117,7 @@ export function MobileTable(_a) {
109
117
  globalFilter,
110
118
  sorting,
111
119
  rowSelection,
120
+ columnPinning,
112
121
  columnOrder: enableColumnsOrderSortByDrag ? columnOrder : undefined,
113
122
  },
114
123
  pageCount,
@@ -134,6 +143,7 @@ export function MobileTable(_a) {
134
143
  const { loadingTable } = useLoadingTable({
135
144
  pageSize: DEFAULT_PAGE_SIZE,
136
145
  columnDefinitions: enabledColumnsDefinitions,
146
+ columnPinning,
137
147
  });
138
148
  const tableRows = table.getRowModel().rows;
139
149
  const loadingTableRows = loadingTable.getRowModel().rows;
@@ -1,10 +1,12 @@
1
+ import { ColumnPinningState } from '@tanstack/react-table';
1
2
  import { FiltersState } from '@cloud-ru/uikit-product-mobile-chips';
2
3
  import { TableProps } from '@snack-uikit/table';
3
4
  type UseLoadingTableProps<TData extends object, TFilters extends FiltersState> = {
4
5
  columnDefinitions: TableProps<TData, TFilters>['columnDefinitions'];
5
6
  pageSize: number;
7
+ columnPinning: ColumnPinningState;
6
8
  };
7
- export declare function useLoadingTable<TData extends object, TFilters extends FiltersState>({ pageSize, columnDefinitions, }: UseLoadingTableProps<TData, TFilters>): {
9
+ export declare function useLoadingTable<TData extends object, TFilters extends FiltersState>({ pageSize, columnDefinitions, columnPinning, }: UseLoadingTableProps<TData, TFilters>): {
8
10
  loadingTable: import("@tanstack/react-table").Table<TData>;
9
11
  };
10
12
  export {};
@@ -3,7 +3,7 @@ import { getCoreRowModel, useReactTable } from '@tanstack/react-table';
3
3
  import { useMemo } from 'react';
4
4
  import { SkeletonText } from '@snack-uikit/skeleton';
5
5
  import { ROW_ACTIONS_COLUMN_ID } from '../../../constants';
6
- export function useLoadingTable({ pageSize, columnDefinitions, }) {
6
+ export function useLoadingTable({ pageSize, columnDefinitions, columnPinning, }) {
7
7
  const data = useMemo(() => (Array.from({ length: pageSize }).map(() => ({})) || []), [pageSize]);
8
8
  const columns = useMemo(() => columnDefinitions
9
9
  .filter(column => column.id !== ROW_ACTIONS_COLUMN_ID)
@@ -11,6 +11,9 @@ export function useLoadingTable({ pageSize, columnDefinitions, }) {
11
11
  const loadingTable = useReactTable({
12
12
  data,
13
13
  columns,
14
+ state: {
15
+ columnPinning,
16
+ },
14
17
  getCoreRowModel: getCoreRowModel(),
15
18
  });
16
19
  return { loadingTable };
@@ -0,0 +1,6 @@
1
+ import { ColumnDefinition } from '@snack-uikit/table';
2
+ /**
3
+ * Возвращает идентификатор колонки: `id`, либо `accessorKey`, если `id` не задан
4
+ * @function getColumnIdentifier
5
+ */
6
+ export declare function getColumnIdentifier<TData extends object>(colDef: ColumnDefinition<TData>): string | undefined;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Возвращает идентификатор колонки: `id`, либо `accessorKey`, если `id` не задан
3
+ * @function getColumnIdentifier
4
+ */
5
+ export function getColumnIdentifier(colDef) {
6
+ if ('id' in colDef && colDef.id) {
7
+ return colDef.id;
8
+ }
9
+ if ('accessorKey' in colDef && colDef.accessorKey) {
10
+ return String(colDef.accessorKey);
11
+ }
12
+ return undefined;
13
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './fuzzyFilter';
2
+ export * from './getColumnIdentifier';
2
3
  export * from './saveTableState';
@@ -1,2 +1,3 @@
1
1
  export * from './fuzzyFilter';
2
+ export * from './getColumnIdentifier';
2
3
  export * from './saveTableState';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloud-ru/uikit-product-mobile-table",
3
3
  "title": "Mobile Table",
4
- "version": "2.3.12",
4
+ "version": "2.3.13",
5
5
  "sideEffects": [
6
6
  "*.css",
7
7
  "*.woff",
@@ -67,5 +67,5 @@
67
67
  "devDependencies": {
68
68
  "@types/lodash.debounce": "4.0.9"
69
69
  },
70
- "gitHead": "3e6ad33138de88a09e13fded80d9d93cc50a7277"
70
+ "gitHead": "b6b9745c3b517af126c5fb15af62cba8b1c56a45"
71
71
  }
@@ -1,4 +1,5 @@
1
1
  import {
2
+ ColumnPinningState,
2
3
  getCoreRowModel,
3
4
  getFilteredRowModel,
4
5
  getPaginationRowModel,
@@ -41,6 +42,7 @@ import styles from './styles.module.scss';
41
42
  import { MobileTableProps } from './types';
42
43
  import {
43
44
  fuzzyFilter,
45
+ getColumnIdentifier,
44
46
  getPersistedStateValidator,
45
47
  mapPaginationToRequestPayload,
46
48
  mapPaginationToTableState,
@@ -117,6 +119,23 @@ export function MobileTable<TData extends object, TFilters extends FiltersState
117
119
 
118
120
  const pinnedGroups = useMemo(() => getPinnedGroups(columnDefinitions), [columnDefinitions]);
119
121
 
122
+ // columnOrder не содержит закреплённых колонок, поэтому без columnPinning они уезжают в конец карточки
123
+ const columnPinning = useMemo<Required<ColumnPinningState>>(() => {
124
+ const getColumnIds = (columnDefinitions: MobileTableProps<TData, TFilters>['columnDefinitions']) =>
125
+ columnDefinitions.reduce((accArr: string[], colDef) => {
126
+ const id = getColumnIdentifier(colDef);
127
+ if (id) {
128
+ accArr.push(id);
129
+ }
130
+ return accArr;
131
+ }, []);
132
+
133
+ return {
134
+ left: getColumnIds(pinnedGroups.left),
135
+ right: getColumnIds(pinnedGroups.right),
136
+ };
137
+ }, [pinnedGroups]);
138
+
120
139
  const {
121
140
  enabledColumns,
122
141
  setEnabledColumns,
@@ -148,12 +167,7 @@ export function MobileTable<TData extends object, TFilters extends FiltersState
148
167
 
149
168
  const hidden = new Set<string>();
150
169
  columnDefinitions.forEach(colDef => {
151
- let columnId: string | undefined;
152
- if ('id' in colDef && colDef.id) {
153
- columnId = colDef.id;
154
- } else if ('accessorKey' in colDef && colDef.accessorKey) {
155
- columnId = String(colDef.accessorKey);
156
- }
170
+ const columnId = getColumnIdentifier(colDef);
157
171
 
158
172
  if (columnId) {
159
173
  const colDefWithSettings = colDef as typeof colDef & {
@@ -197,6 +211,7 @@ export function MobileTable<TData extends object, TFilters extends FiltersState
197
211
  globalFilter,
198
212
  sorting,
199
213
  rowSelection,
214
+ columnPinning,
200
215
  columnOrder: enableColumnsOrderSortByDrag ? columnOrder : undefined,
201
216
  },
202
217
  pageCount,
@@ -228,6 +243,7 @@ export function MobileTable<TData extends object, TFilters extends FiltersState
228
243
  const { loadingTable } = useLoadingTable<TData, TFilters>({
229
244
  pageSize: DEFAULT_PAGE_SIZE,
230
245
  columnDefinitions: enabledColumnsDefinitions,
246
+ columnPinning,
231
247
  });
232
248
 
233
249
  const tableRows = table.getRowModel().rows;
@@ -1,4 +1,4 @@
1
- import { getCoreRowModel, useReactTable } from '@tanstack/react-table';
1
+ import { ColumnPinningState, getCoreRowModel, useReactTable } from '@tanstack/react-table';
2
2
  import { useMemo } from 'react';
3
3
 
4
4
  import { FiltersState } from '@cloud-ru/uikit-product-mobile-chips';
@@ -10,11 +10,13 @@ import { ROW_ACTIONS_COLUMN_ID } from '../../../constants';
10
10
  type UseLoadingTableProps<TData extends object, TFilters extends FiltersState> = {
11
11
  columnDefinitions: TableProps<TData, TFilters>['columnDefinitions'];
12
12
  pageSize: number;
13
+ columnPinning: ColumnPinningState;
13
14
  };
14
15
 
15
16
  export function useLoadingTable<TData extends object, TFilters extends FiltersState>({
16
17
  pageSize,
17
18
  columnDefinitions,
19
+ columnPinning,
18
20
  }: UseLoadingTableProps<TData, TFilters>) {
19
21
  const data = useMemo(() => (Array.from({ length: pageSize }).map(() => ({})) || []) as TData[], [pageSize]);
20
22
  const columns = useMemo(
@@ -32,6 +34,10 @@ export function useLoadingTable<TData extends object, TFilters extends FiltersSt
32
34
  data,
33
35
  columns,
34
36
 
37
+ state: {
38
+ columnPinning,
39
+ },
40
+
35
41
  getCoreRowModel: getCoreRowModel(),
36
42
  });
37
43
 
@@ -0,0 +1,17 @@
1
+ import { ColumnDefinition } from '@snack-uikit/table';
2
+
3
+ /**
4
+ * Возвращает идентификатор колонки: `id`, либо `accessorKey`, если `id` не задан
5
+ * @function getColumnIdentifier
6
+ */
7
+ export function getColumnIdentifier<TData extends object>(colDef: ColumnDefinition<TData>): string | undefined {
8
+ if ('id' in colDef && colDef.id) {
9
+ return colDef.id;
10
+ }
11
+
12
+ if ('accessorKey' in colDef && colDef.accessorKey) {
13
+ return String(colDef.accessorKey);
14
+ }
15
+
16
+ return undefined;
17
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './fuzzyFilter';
2
+ export * from './getColumnIdentifier';
2
3
  export * from './saveTableState';