@cloud-ru/uikit-product-mobile-table 0.12.0 → 0.13.1
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 +22 -0
- package/dist/cjs/components/AdaptiveTable/AdaptiveTable.d.ts +2 -1
- package/dist/cjs/components/AdaptiveTable/AdaptiveTable.js +6 -1
- package/dist/cjs/components/MobileTable.d.ts +1 -0
- package/dist/cjs/components/MobileTable.js +1 -0
- package/dist/cjs/helperComponents/StatusColumnDef/StatusColumnDef.d.ts +29 -0
- package/dist/cjs/helperComponents/StatusColumnDef/StatusColumnDef.js +28 -0
- package/dist/cjs/helperComponents/StatusColumnDef/index.d.ts +1 -0
- package/dist/cjs/helperComponents/StatusColumnDef/index.js +17 -0
- package/dist/cjs/helperComponents/index.d.ts +1 -0
- package/dist/cjs/helperComponents/index.js +1 -0
- package/dist/esm/components/AdaptiveTable/AdaptiveTable.d.ts +2 -1
- package/dist/esm/components/AdaptiveTable/AdaptiveTable.js +4 -0
- package/dist/esm/components/MobileTable.d.ts +1 -0
- package/dist/esm/components/MobileTable.js +2 -1
- package/dist/esm/helperComponents/StatusColumnDef/StatusColumnDef.d.ts +29 -0
- package/dist/esm/helperComponents/StatusColumnDef/StatusColumnDef.js +25 -0
- package/dist/esm/helperComponents/StatusColumnDef/index.d.ts +1 -0
- package/dist/esm/helperComponents/StatusColumnDef/index.js +1 -0
- package/dist/esm/helperComponents/index.d.ts +1 -0
- package/dist/esm/helperComponents/index.js +1 -0
- package/package.json +5 -4
- package/src/components/AdaptiveTable/AdaptiveTable.tsx +9 -1
- package/src/components/MobileTable.tsx +2 -0
- package/src/helperComponents/StatusColumnDef/StatusColumnDef.tsx +69 -0
- package/src/helperComponents/StatusColumnDef/index.ts +1 -0
- package/src/helperComponents/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 0.13.1 (2025-11-24)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **FF-7578:** fix status column ([a1314f5](https://gitverse.ru/cloud-ru-tech/uikit-product/commits/a1314f5c6017dc3ab34aa63067031ab466e7d7dc))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# 0.13.0 (2025-11-23)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **FF-7560:** add status column support to mobile table ([2589830](https://gitverse.ru/cloud-ru-tech/uikit-product/commits/2589830b331efbc93ca22cbf91009a1e1be0745f))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
# 0.12.0 (2025-11-21)
|
|
7
29
|
|
|
8
30
|
|
|
@@ -5,4 +5,5 @@ import { MobileTableProps } from '../MobileTable';
|
|
|
5
5
|
export type AdaptiveTableProps<TData extends object, TFilters extends FiltersState> = TableProps<TData, TFilters> & MobileTableProps<TData, TFilters>;
|
|
6
6
|
export declare function AdaptiveTable<TState extends object, TFilters extends FiltersState>({ layoutType, ...props }: WithLayoutType<AdaptiveTableProps<TState, TFilters>>): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export declare const useAdaptiveGetRowActionsColumnDef: ({ layoutType }: WithLayoutType) => typeof DesktopTable.getRowActionsColumnDef;
|
|
8
|
-
export
|
|
8
|
+
export declare const useAdaptiveGetStatusColumnDef: ({ layoutType }: WithLayoutType) => typeof DesktopTable.getStatusColumnDef;
|
|
9
|
+
export type { CellContext, ColumnDefinition, TableProps };
|
|
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.useAdaptiveGetRowActionsColumnDef = void 0;
|
|
14
|
+
exports.useAdaptiveGetStatusColumnDef = exports.useAdaptiveGetRowActionsColumnDef = void 0;
|
|
15
15
|
exports.AdaptiveTable = AdaptiveTable;
|
|
16
16
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
17
17
|
const table_1 = require("@snack-uikit/table");
|
|
@@ -26,3 +26,8 @@ const useAdaptiveGetRowActionsColumnDef = ({ layoutType }) => {
|
|
|
26
26
|
return (isMobile ? MobileTable_1.MobileTable.getRowActionsColumnDef : table_1.Table.getRowActionsColumnDef);
|
|
27
27
|
};
|
|
28
28
|
exports.useAdaptiveGetRowActionsColumnDef = useAdaptiveGetRowActionsColumnDef;
|
|
29
|
+
const useAdaptiveGetStatusColumnDef = ({ layoutType }) => {
|
|
30
|
+
const isMobile = layoutType === 'mobile';
|
|
31
|
+
return (isMobile ? MobileTable_1.MobileTable.getStatusColumnDef : table_1.Table.getStatusColumnDef);
|
|
32
|
+
};
|
|
33
|
+
exports.useAdaptiveGetStatusColumnDef = useAdaptiveGetStatusColumnDef;
|
|
@@ -9,4 +9,5 @@ export type MobileTableProps<TData extends object, TFilters extends FiltersState
|
|
|
9
9
|
export declare function MobileTable<TData extends object, TFilters extends FiltersState = Record<string, unknown>>({ data, columnDefinitions, headlineId, suppressPagination, suppressToolbar, suppressSearch, enableFuzzySearch, search, onRefresh, toolbarAfter, moreActions, columnFilters, className, headerBackground, noDataState, noResultsState, errorDataState, loading, dataError, dataFiltered, pagination: paginationProp, pageCount, sorting: sortingProp, manualSorting, manualPagination, manualFiltering, getRowId, rowSelection: rowSelectionProp, bulkActions: bulkActionsProp, ...rest }: MobileTableProps<TData, TFilters>): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export declare namespace MobileTable {
|
|
11
11
|
var getRowActionsColumnDef: typeof import("../helperComponents").getRowActionsColumnDef;
|
|
12
|
+
var getStatusColumnDef: typeof import("../helperComponents").getStatusColumnDef;
|
|
12
13
|
}
|
|
@@ -114,3 +114,4 @@ function MobileTable(_a) {
|
|
|
114
114
|
}, onRefresh: onRefresh ? handleOnRefresh : undefined, outline: true, filterRow: columnFilters, after: toolbarAfter, moreActions: moreActions, bulkActions: bulkActions, selectedCount: table.getSelectedRowModel().rows.length, selectionMode: selectionMode, onCheck: enableSelection ? handleOnToolbarCheck : undefined, checked: table.getIsAllPageRowsSelected(), indeterminate: table.getIsSomePageRowsSelected() }) })), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.table, children: loading ? ((0, jsx_runtime_1.jsx)(skeleton_1.SkeletonContextProvider, { loading: true, children: loadingTableRows.map((row, index) => ((0, jsx_runtime_1.jsx)(helperComponents_1.TableCard, { headlineId: headlineId, row: row, table: loadingTable, selection: 'none' }, index))) })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [tableRows.map((row, index) => ((0, jsx_runtime_1.jsx)(helperComponents_1.TableCard, { headlineId: headlineId, row: row, table: table, selection: enableSelection ? selectionMode : 'none' }, index))), (0, jsx_runtime_1.jsx)(helperComponents_1.TableEmptyState, { emptyStates: emptyStates, dataError: dataError, dataFiltered: dataFiltered || Boolean(table.getState().globalFilter), tableRowsLength: tableRows.length })] })) }), !suppressPagination && (0, jsx_runtime_1.jsx)(helperComponents_1.TablePagination, { table: table })] })));
|
|
115
115
|
}
|
|
116
116
|
MobileTable.getRowActionsColumnDef = helperComponents_1.getRowActionsColumnDef;
|
|
117
|
+
MobileTable.getStatusColumnDef = helperComponents_1.getStatusColumnDef;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { HeaderContext } from '@tanstack/react-table';
|
|
2
|
+
import { FiltersState } from '@cloud-ru/uikit-product-mobile-chips';
|
|
3
|
+
import { StatusProps } from '@snack-uikit/status';
|
|
4
|
+
import { MobileTableProps } from '../../components';
|
|
5
|
+
export type StatusAppearance = StatusProps['appearance'];
|
|
6
|
+
export type StatusColumnDefProps<TData extends object> = {
|
|
7
|
+
/** Ключ для доступа к значению статуса в данных */
|
|
8
|
+
accessorKey: keyof TData;
|
|
9
|
+
/** Маппинг значений статусов на appearance */
|
|
10
|
+
mapStatusToAppearance: (value: string | number) => StatusAppearance;
|
|
11
|
+
/** Заголовок колонки */
|
|
12
|
+
header?: string | ((ctx: HeaderContext<TData, unknown>) => React.ReactNode);
|
|
13
|
+
/** Функция для рендеринга описания статуса (опционально) */
|
|
14
|
+
renderDescription?: (value: string) => string;
|
|
15
|
+
/** Размер колонки */
|
|
16
|
+
size?: number;
|
|
17
|
+
/** Минимальный размер колонки */
|
|
18
|
+
minSize?: number;
|
|
19
|
+
/** Максимальный размер колонки */
|
|
20
|
+
maxSize?: number;
|
|
21
|
+
/** Закрепление колонки */
|
|
22
|
+
pinned?: 'left' | 'right';
|
|
23
|
+
/** Включить сортировку */
|
|
24
|
+
enableSorting?: boolean;
|
|
25
|
+
/** Включить изменение размера */
|
|
26
|
+
enableResizing?: boolean;
|
|
27
|
+
};
|
|
28
|
+
/** Вспомогательная функция для создания колонки со статусами */
|
|
29
|
+
export declare function getStatusColumnDef<TData extends object, TFilters extends FiltersState>({ accessorKey, mapStatusToAppearance, header, renderDescription, size, minSize, maxSize, pinned, enableSorting, enableResizing, }: StatusColumnDefProps<TData>): MobileTableProps<TData, TFilters>['columnDefinitions'][0];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStatusColumnDef = getStatusColumnDef;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const status_1 = require("@snack-uikit/status");
|
|
6
|
+
const constants_1 = require("../../constants");
|
|
7
|
+
/** Вспомогательная функция для создания колонки со статусами */
|
|
8
|
+
function getStatusColumnDef({ accessorKey, mapStatusToAppearance, header = 'Статус', renderDescription, size = 150, minSize, maxSize, pinned, enableSorting = true, enableResizing = true, }) {
|
|
9
|
+
return {
|
|
10
|
+
id: String(accessorKey),
|
|
11
|
+
accessorKey: String(accessorKey),
|
|
12
|
+
header,
|
|
13
|
+
size,
|
|
14
|
+
minSize,
|
|
15
|
+
maxSize,
|
|
16
|
+
pinned,
|
|
17
|
+
enableSorting,
|
|
18
|
+
enableResizing,
|
|
19
|
+
cell: (cell) => {
|
|
20
|
+
const statusValue = cell.getValue();
|
|
21
|
+
if (!statusValue)
|
|
22
|
+
return null;
|
|
23
|
+
const appearance = mapStatusToAppearance(statusValue) || 'neutral';
|
|
24
|
+
const label = renderDescription ? renderDescription(statusValue) : statusValue;
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)(status_1.Status, { label: label, appearance: appearance, size: 's', hasBackground: true, "data-test-id": constants_1.TEST_IDS.statusLabel }));
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './StatusColumnDef';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./StatusColumnDef"), exports);
|
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./RowActionsCell"), exports);
|
|
18
|
+
__exportStar(require("./StatusColumnDef"), exports);
|
|
18
19
|
__exportStar(require("./TableCard"), exports);
|
|
19
20
|
__exportStar(require("./TablePagination"), exports);
|
|
20
21
|
__exportStar(require("./TableEmptyState"), exports);
|
|
@@ -5,4 +5,5 @@ import { MobileTableProps } from '../MobileTable';
|
|
|
5
5
|
export type AdaptiveTableProps<TData extends object, TFilters extends FiltersState> = TableProps<TData, TFilters> & MobileTableProps<TData, TFilters>;
|
|
6
6
|
export declare function AdaptiveTable<TState extends object, TFilters extends FiltersState>({ layoutType, ...props }: WithLayoutType<AdaptiveTableProps<TState, TFilters>>): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export declare const useAdaptiveGetRowActionsColumnDef: ({ layoutType }: WithLayoutType) => typeof DesktopTable.getRowActionsColumnDef;
|
|
8
|
-
export
|
|
8
|
+
export declare const useAdaptiveGetStatusColumnDef: ({ layoutType }: WithLayoutType) => typeof DesktopTable.getStatusColumnDef;
|
|
9
|
+
export type { CellContext, ColumnDefinition, TableProps };
|
|
@@ -21,3 +21,7 @@ export const useAdaptiveGetRowActionsColumnDef = ({ layoutType }) => {
|
|
|
21
21
|
const isMobile = layoutType === 'mobile';
|
|
22
22
|
return (isMobile ? MobileTable.getRowActionsColumnDef : DesktopTable.getRowActionsColumnDef);
|
|
23
23
|
};
|
|
24
|
+
export const useAdaptiveGetStatusColumnDef = ({ layoutType }) => {
|
|
25
|
+
const isMobile = layoutType === 'mobile';
|
|
26
|
+
return (isMobile ? MobileTable.getStatusColumnDef : DesktopTable.getStatusColumnDef);
|
|
27
|
+
};
|
|
@@ -9,4 +9,5 @@ export type MobileTableProps<TData extends object, TFilters extends FiltersState
|
|
|
9
9
|
export declare function MobileTable<TData extends object, TFilters extends FiltersState = Record<string, unknown>>({ data, columnDefinitions, headlineId, suppressPagination, suppressToolbar, suppressSearch, enableFuzzySearch, search, onRefresh, toolbarAfter, moreActions, columnFilters, className, headerBackground, noDataState, noResultsState, errorDataState, loading, dataError, dataFiltered, pagination: paginationProp, pageCount, sorting: sortingProp, manualSorting, manualPagination, manualFiltering, getRowId, rowSelection: rowSelectionProp, bulkActions: bulkActionsProp, ...rest }: MobileTableProps<TData, TFilters>): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export declare namespace MobileTable {
|
|
11
11
|
var getRowActionsColumnDef: typeof import("../helperComponents").getRowActionsColumnDef;
|
|
12
|
+
var getStatusColumnDef: typeof import("../helperComponents").getStatusColumnDef;
|
|
12
13
|
}
|
|
@@ -17,7 +17,7 @@ import { useLocale } from '@cloud-ru/uikit-product-locale';
|
|
|
17
17
|
import { MobileToolbar } from '@cloud-ru/uikit-product-mobile-toolbar';
|
|
18
18
|
import { extractSupportProps } from '@cloud-ru/uikit-product-utils';
|
|
19
19
|
import { SkeletonContextProvider } from '@snack-uikit/skeleton';
|
|
20
|
-
import { getRowActionsColumnDef, TableCard, TableEmptyState, TablePagination, useEmptyState, } from '../helperComponents';
|
|
20
|
+
import { getRowActionsColumnDef, getStatusColumnDef, TableCard, TableEmptyState, TablePagination, useEmptyState, } from '../helperComponents';
|
|
21
21
|
import { DEFAULT_PAGE_SIZE } from './constants';
|
|
22
22
|
import { useLoadingTable, useStateControl } from './hooks';
|
|
23
23
|
import styles from './styles.module.css';
|
|
@@ -108,3 +108,4 @@ export function MobileTable(_a) {
|
|
|
108
108
|
}, onRefresh: onRefresh ? handleOnRefresh : undefined, outline: true, filterRow: columnFilters, after: toolbarAfter, moreActions: moreActions, bulkActions: bulkActions, selectedCount: table.getSelectedRowModel().rows.length, selectionMode: selectionMode, onCheck: enableSelection ? handleOnToolbarCheck : undefined, checked: table.getIsAllPageRowsSelected(), indeterminate: table.getIsSomePageRowsSelected() }) })), _jsx("div", { className: styles.table, children: loading ? (_jsx(SkeletonContextProvider, { loading: true, children: loadingTableRows.map((row, index) => (_jsx(TableCard, { headlineId: headlineId, row: row, table: loadingTable, selection: 'none' }, index))) })) : (_jsxs(_Fragment, { children: [tableRows.map((row, index) => (_jsx(TableCard, { headlineId: headlineId, row: row, table: table, selection: enableSelection ? selectionMode : 'none' }, index))), _jsx(TableEmptyState, { emptyStates: emptyStates, dataError: dataError, dataFiltered: dataFiltered || Boolean(table.getState().globalFilter), tableRowsLength: tableRows.length })] })) }), !suppressPagination && _jsx(TablePagination, { table: table })] })));
|
|
109
109
|
}
|
|
110
110
|
MobileTable.getRowActionsColumnDef = getRowActionsColumnDef;
|
|
111
|
+
MobileTable.getStatusColumnDef = getStatusColumnDef;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { HeaderContext } from '@tanstack/react-table';
|
|
2
|
+
import { FiltersState } from '@cloud-ru/uikit-product-mobile-chips';
|
|
3
|
+
import { StatusProps } from '@snack-uikit/status';
|
|
4
|
+
import { MobileTableProps } from '../../components';
|
|
5
|
+
export type StatusAppearance = StatusProps['appearance'];
|
|
6
|
+
export type StatusColumnDefProps<TData extends object> = {
|
|
7
|
+
/** Ключ для доступа к значению статуса в данных */
|
|
8
|
+
accessorKey: keyof TData;
|
|
9
|
+
/** Маппинг значений статусов на appearance */
|
|
10
|
+
mapStatusToAppearance: (value: string | number) => StatusAppearance;
|
|
11
|
+
/** Заголовок колонки */
|
|
12
|
+
header?: string | ((ctx: HeaderContext<TData, unknown>) => React.ReactNode);
|
|
13
|
+
/** Функция для рендеринга описания статуса (опционально) */
|
|
14
|
+
renderDescription?: (value: string) => string;
|
|
15
|
+
/** Размер колонки */
|
|
16
|
+
size?: number;
|
|
17
|
+
/** Минимальный размер колонки */
|
|
18
|
+
minSize?: number;
|
|
19
|
+
/** Максимальный размер колонки */
|
|
20
|
+
maxSize?: number;
|
|
21
|
+
/** Закрепление колонки */
|
|
22
|
+
pinned?: 'left' | 'right';
|
|
23
|
+
/** Включить сортировку */
|
|
24
|
+
enableSorting?: boolean;
|
|
25
|
+
/** Включить изменение размера */
|
|
26
|
+
enableResizing?: boolean;
|
|
27
|
+
};
|
|
28
|
+
/** Вспомогательная функция для создания колонки со статусами */
|
|
29
|
+
export declare function getStatusColumnDef<TData extends object, TFilters extends FiltersState>({ accessorKey, mapStatusToAppearance, header, renderDescription, size, minSize, maxSize, pinned, enableSorting, enableResizing, }: StatusColumnDefProps<TData>): MobileTableProps<TData, TFilters>['columnDefinitions'][0];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Status } from '@snack-uikit/status';
|
|
3
|
+
import { TEST_IDS } from '../../constants';
|
|
4
|
+
/** Вспомогательная функция для создания колонки со статусами */
|
|
5
|
+
export function getStatusColumnDef({ accessorKey, mapStatusToAppearance, header = 'Статус', renderDescription, size = 150, minSize, maxSize, pinned, enableSorting = true, enableResizing = true, }) {
|
|
6
|
+
return {
|
|
7
|
+
id: String(accessorKey),
|
|
8
|
+
accessorKey: String(accessorKey),
|
|
9
|
+
header,
|
|
10
|
+
size,
|
|
11
|
+
minSize,
|
|
12
|
+
maxSize,
|
|
13
|
+
pinned,
|
|
14
|
+
enableSorting,
|
|
15
|
+
enableResizing,
|
|
16
|
+
cell: (cell) => {
|
|
17
|
+
const statusValue = cell.getValue();
|
|
18
|
+
if (!statusValue)
|
|
19
|
+
return null;
|
|
20
|
+
const appearance = mapStatusToAppearance(statusValue) || 'neutral';
|
|
21
|
+
const label = renderDescription ? renderDescription(statusValue) : statusValue;
|
|
22
|
+
return (_jsx(Status, { label: label, appearance: appearance, size: 's', hasBackground: true, "data-test-id": TEST_IDS.statusLabel }));
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './StatusColumnDef';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './StatusColumnDef';
|
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": "0.
|
|
4
|
+
"version": "0.13.1",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"*.css",
|
|
7
7
|
"*.woff",
|
|
@@ -37,14 +37,15 @@
|
|
|
37
37
|
"scripts": {},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@cloud-ru/uikit-product-icons": "15.1.4",
|
|
40
|
-
"@cloud-ru/uikit-product-mobile-chips": "0.8.
|
|
40
|
+
"@cloud-ru/uikit-product-mobile-chips": "0.8.40",
|
|
41
41
|
"@cloud-ru/uikit-product-mobile-dropdown": "0.9.24",
|
|
42
|
-
"@cloud-ru/uikit-product-mobile-toolbar": "0.4.
|
|
42
|
+
"@cloud-ru/uikit-product-mobile-toolbar": "0.4.7",
|
|
43
43
|
"@cloud-ru/uikit-product-utils": "7.0.3",
|
|
44
44
|
"@snack-uikit/button": "0.19.15",
|
|
45
45
|
"@snack-uikit/info-block": "0.6.31",
|
|
46
46
|
"@snack-uikit/pagination": "0.10.18",
|
|
47
47
|
"@snack-uikit/skeleton": "0.6.8",
|
|
48
|
+
"@snack-uikit/status": "0.10.0",
|
|
48
49
|
"@snack-uikit/table": "0.37.16",
|
|
49
50
|
"@snack-uikit/toggles": "0.13.20",
|
|
50
51
|
"@tanstack/match-sorter-utils": "8.19.4",
|
|
@@ -59,5 +60,5 @@
|
|
|
59
60
|
"devDependencies": {
|
|
60
61
|
"@types/lodash.debounce": "4.0.9"
|
|
61
62
|
},
|
|
62
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "cc31bd43bfbff65cd3db647895681383453d7d37"
|
|
63
64
|
}
|
|
@@ -23,4 +23,12 @@ export const useAdaptiveGetRowActionsColumnDef = ({ layoutType }: WithLayoutType
|
|
|
23
23
|
) as typeof DesktopTable.getRowActionsColumnDef;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
export
|
|
26
|
+
export const useAdaptiveGetStatusColumnDef = ({ layoutType }: WithLayoutType) => {
|
|
27
|
+
const isMobile = layoutType === 'mobile';
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
isMobile ? MobileTable.getStatusColumnDef : DesktopTable.getStatusColumnDef
|
|
31
|
+
) as typeof DesktopTable.getStatusColumnDef;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type { CellContext, ColumnDefinition, TableProps };
|
|
@@ -20,6 +20,7 @@ import { PaginationState, TableProps } from '@snack-uikit/table';
|
|
|
20
20
|
|
|
21
21
|
import {
|
|
22
22
|
getRowActionsColumnDef,
|
|
23
|
+
getStatusColumnDef,
|
|
23
24
|
TableCard,
|
|
24
25
|
TableEmptyState,
|
|
25
26
|
TablePagination,
|
|
@@ -270,3 +271,4 @@ export function MobileTable<TData extends object, TFilters extends FiltersState
|
|
|
270
271
|
}
|
|
271
272
|
|
|
272
273
|
MobileTable.getRowActionsColumnDef = getRowActionsColumnDef;
|
|
274
|
+
MobileTable.getStatusColumnDef = getStatusColumnDef;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { CellContext, HeaderContext } from '@tanstack/react-table';
|
|
2
|
+
|
|
3
|
+
import { FiltersState } from '@cloud-ru/uikit-product-mobile-chips';
|
|
4
|
+
import { Status, StatusProps } from '@snack-uikit/status';
|
|
5
|
+
|
|
6
|
+
import { MobileTableProps } from '../../components';
|
|
7
|
+
import { TEST_IDS } from '../../constants';
|
|
8
|
+
|
|
9
|
+
export type StatusAppearance = StatusProps['appearance'];
|
|
10
|
+
|
|
11
|
+
export type StatusColumnDefProps<TData extends object> = {
|
|
12
|
+
/** Ключ для доступа к значению статуса в данных */
|
|
13
|
+
accessorKey: keyof TData;
|
|
14
|
+
/** Маппинг значений статусов на appearance */
|
|
15
|
+
mapStatusToAppearance: (value: string | number) => StatusAppearance;
|
|
16
|
+
/** Заголовок колонки */
|
|
17
|
+
header?: string | ((ctx: HeaderContext<TData, unknown>) => React.ReactNode);
|
|
18
|
+
/** Функция для рендеринга описания статуса (опционально) */
|
|
19
|
+
renderDescription?: (value: string) => string;
|
|
20
|
+
/** Размер колонки */
|
|
21
|
+
size?: number;
|
|
22
|
+
/** Минимальный размер колонки */
|
|
23
|
+
minSize?: number;
|
|
24
|
+
/** Максимальный размер колонки */
|
|
25
|
+
maxSize?: number;
|
|
26
|
+
/** Закрепление колонки */
|
|
27
|
+
pinned?: 'left' | 'right';
|
|
28
|
+
/** Включить сортировку */
|
|
29
|
+
enableSorting?: boolean;
|
|
30
|
+
/** Включить изменение размера */
|
|
31
|
+
enableResizing?: boolean;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** Вспомогательная функция для создания колонки со статусами */
|
|
35
|
+
export function getStatusColumnDef<TData extends object, TFilters extends FiltersState>({
|
|
36
|
+
accessorKey,
|
|
37
|
+
mapStatusToAppearance,
|
|
38
|
+
header = 'Статус',
|
|
39
|
+
renderDescription,
|
|
40
|
+
size = 150,
|
|
41
|
+
minSize,
|
|
42
|
+
maxSize,
|
|
43
|
+
pinned,
|
|
44
|
+
enableSorting = true,
|
|
45
|
+
enableResizing = true,
|
|
46
|
+
}: StatusColumnDefProps<TData>): MobileTableProps<TData, TFilters>['columnDefinitions'][0] {
|
|
47
|
+
return {
|
|
48
|
+
id: String(accessorKey),
|
|
49
|
+
accessorKey: String(accessorKey),
|
|
50
|
+
header,
|
|
51
|
+
size,
|
|
52
|
+
minSize,
|
|
53
|
+
maxSize,
|
|
54
|
+
pinned,
|
|
55
|
+
enableSorting,
|
|
56
|
+
enableResizing,
|
|
57
|
+
cell: (cell: CellContext<TData, unknown>) => {
|
|
58
|
+
const statusValue = cell.getValue<string>();
|
|
59
|
+
if (!statusValue) return null;
|
|
60
|
+
|
|
61
|
+
const appearance = mapStatusToAppearance(statusValue) || 'neutral';
|
|
62
|
+
const label = renderDescription ? renderDescription(statusValue) : statusValue;
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<Status label={label} appearance={appearance} size='s' hasBackground data-test-id={TEST_IDS.statusLabel} />
|
|
66
|
+
);
|
|
67
|
+
},
|
|
68
|
+
} as MobileTableProps<TData, TFilters>['columnDefinitions'][0];
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './StatusColumnDef';
|