@cloud-ru/uikit-product-mobile-table 0.15.0 → 0.16.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 +24 -0
- package/dist/cjs/components/MobileTable.js +1 -1
- package/dist/cjs/helperComponents/TableCard/TableCard.d.ts +3 -1
- package/dist/cjs/helperComponents/TableCard/TableCard.js +10 -3
- package/dist/esm/components/MobileTable.js +1 -1
- package/dist/esm/helperComponents/TableCard/TableCard.d.ts +3 -1
- package/dist/esm/helperComponents/TableCard/TableCard.js +10 -3
- package/package.json +7 -7
- package/src/components/MobileTable.tsx +1 -0
- package/src/helperComponents/TableCard/TableCard.tsx +21 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
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.16.1 (2025-12-08)
|
|
7
|
+
|
|
8
|
+
### Only dependencies have been changed
|
|
9
|
+
* [@cloud-ru/uikit-product-icons@16.0.1](https://gitverse.ru/cloud-ru-tech/uikit-product/-/blob/master/packages/icons/CHANGELOG.md)
|
|
10
|
+
* [@cloud-ru/uikit-product-mobile-chips@0.8.45](https://gitverse.ru/cloud-ru-tech/uikit-product/-/blob/master/packages/mobile-chips/CHANGELOG.md)
|
|
11
|
+
* [@cloud-ru/uikit-product-mobile-dropdown@0.9.29](https://gitverse.ru/cloud-ru-tech/uikit-product/-/blob/master/packages/mobile-dropdown/CHANGELOG.md)
|
|
12
|
+
* [@cloud-ru/uikit-product-mobile-toolbar@0.4.12](https://gitverse.ru/cloud-ru-tech/uikit-product/-/blob/master/packages/mobile-toolbar/CHANGELOG.md)
|
|
13
|
+
* [@cloud-ru/uikit-product-utils@8.0.2](https://gitverse.ru/cloud-ru-tech/uikit-product/-/blob/master/packages/utils/CHANGELOG.md)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# 0.16.0 (2025-12-03)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* **FF-7473:** add disabled state and HideToggler support for row selection in mobile table ([f0f7517](https://gitverse.ru/cloud-ru-tech/uikit-product/commits/f0f7517d45ef8f5580865951790238426b96fc16))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
6
30
|
# 0.15.0 (2025-12-03)
|
|
7
31
|
|
|
8
32
|
|
|
@@ -187,7 +187,7 @@ function MobileTable(_a) {
|
|
|
187
187
|
onChange: onGlobalFilterChange,
|
|
188
188
|
loading: search === null || search === void 0 ? void 0 : search.loading,
|
|
189
189
|
placeholder: (search === null || search === void 0 ? void 0 : search.placeholder) || t('searchPlaceholder'),
|
|
190
|
-
}, onRefresh: onRefresh ? handleOnRefresh : undefined, outline: true, filterRow: columnFilters, after: toolbarAfter || shouldShowSorting || (areColumnsSettingsEnabled && columnsSettings) ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [toolbarAfter, shouldShowSorting && ((0, jsx_runtime_1.jsx)(helperComponents_1.TableSorting, { table: table, columnDefinitions: columnDefinitions, enabledColumns: areColumnsSettingsEnabled ? enabledColumns : undefined, areColumnsSettingsEnabled: areColumnsSettingsEnabled })), areColumnsSettingsEnabled && columnsSettings && ((0, jsx_runtime_1.jsx)(ColumnsSettings_1.ColumnsSettings, { columnsSettings: columnsSettings, enabledColumns: enabledColumns, setEnabledColumns: setEnabledColumns }))] })) : undefined, 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 })] })));
|
|
190
|
+
}, onRefresh: onRefresh ? handleOnRefresh : undefined, outline: true, filterRow: columnFilters, after: toolbarAfter || shouldShowSorting || (areColumnsSettingsEnabled && columnsSettings) ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [toolbarAfter, shouldShowSorting && ((0, jsx_runtime_1.jsx)(helperComponents_1.TableSorting, { table: table, columnDefinitions: columnDefinitions, enabledColumns: areColumnsSettingsEnabled ? enabledColumns : undefined, areColumnsSettingsEnabled: areColumnsSettingsEnabled })), areColumnsSettingsEnabled && columnsSettings && ((0, jsx_runtime_1.jsx)(ColumnsSettings_1.ColumnsSettings, { columnsSettings: columnsSettings, enabledColumns: enabledColumns, setEnabledColumns: setEnabledColumns }))] })) : undefined, 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, selectionAppearance: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.appearance, 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 })] })));
|
|
191
191
|
}
|
|
192
192
|
MobileTable.getRowActionsColumnDef = helperComponents_1.getRowActionsColumnDef;
|
|
193
193
|
MobileTable.getStatusColumnDef = helperComponents_1.getStatusColumnDef;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Row, Table } from '@tanstack/react-table';
|
|
2
|
+
import { RowAppearance } from '@snack-uikit/table';
|
|
2
3
|
type TableCardProps<TData extends object> = {
|
|
3
4
|
headlineId?: string;
|
|
4
5
|
row: Row<TData>;
|
|
5
6
|
table: Table<TData>;
|
|
6
7
|
selection: 'multiple' | 'single' | 'none';
|
|
8
|
+
selectionAppearance?: RowAppearance;
|
|
7
9
|
};
|
|
8
|
-
export declare function TableCard<TData extends object>({ headlineId, table, row, selection }: TableCardProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function TableCard<TData extends object>({ headlineId, table, row, selection, selectionAppearance, }: TableCardProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
9
11
|
export {};
|
|
@@ -7,22 +7,27 @@ exports.TableCard = TableCard;
|
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_table_1 = require("@tanstack/react-table");
|
|
9
9
|
const react_1 = require("react");
|
|
10
|
+
const table_1 = require("@snack-uikit/table");
|
|
10
11
|
const toggles_1 = require("@snack-uikit/toggles");
|
|
11
12
|
const constants_1 = require("../../constants");
|
|
12
13
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
13
|
-
function TableCard({ headlineId, table, row, selection }) {
|
|
14
|
+
function TableCard({ headlineId, table, row, selection, selectionAppearance = table_1.RowAppearance.Disabled, }) {
|
|
14
15
|
const headerGroups = table.getHeaderGroups();
|
|
15
16
|
const headerCell = row._getAllCellsByColumnId()[headlineId !== null && headlineId !== void 0 ? headlineId : ''];
|
|
16
17
|
const headerColumn = table.getFlatHeaders().find(header => header.id === headlineId);
|
|
17
18
|
const actionsCell = row._getAllCellsByColumnId()[constants_1.ROW_ACTIONS_COLUMN_ID];
|
|
18
19
|
const actionsColumn = table.getFlatHeaders().find(header => header.id === constants_1.ROW_ACTIONS_COLUMN_ID);
|
|
19
20
|
const isSelected = row.getIsSelected();
|
|
21
|
+
const canSelect = row.getCanSelect();
|
|
22
|
+
const isDisabled = !canSelect;
|
|
20
23
|
const handleSelection = (0, react_1.useCallback)(() => {
|
|
24
|
+
if (isDisabled)
|
|
25
|
+
return;
|
|
21
26
|
if (selection === 'single')
|
|
22
27
|
row.toggleSelected(true);
|
|
23
28
|
if (selection === 'multiple')
|
|
24
29
|
row.toggleSelected(!isSelected);
|
|
25
|
-
}, [isSelected, row, selection]);
|
|
30
|
+
}, [isDisabled, isSelected, row, selection]);
|
|
26
31
|
return (
|
|
27
32
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
28
33
|
(0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.card, "data-is-selected": isSelected !== null && isSelected !== void 0 ? isSelected : undefined, "data-selection-mode": selection, onClick: handleSelection, children: [(0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.content, children: [headerCell && headerColumn && ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.headline, children: (0, react_table_1.flexRender)(headerColumn.column.columnDef.cell, headerCell.getContext()) })), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.body, children: headerGroups.map(group => group.headers.map((header, index) => {
|
|
@@ -32,5 +37,7 @@ function TableCard({ headlineId, table, row, selection }) {
|
|
|
32
37
|
const column = header.column.columnDef;
|
|
33
38
|
const cell = row._getAllCellsByColumnId()[header.column.id];
|
|
34
39
|
return ((0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.cardRow, children: [(0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.cardRowHeader, children: (0, react_table_1.flexRender)(column.header, header.getContext()) }), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.cardRowContent, children: (0, react_table_1.flexRender)(column.cell, cell.getContext()) })] }, header.id || index));
|
|
35
|
-
})) })] }), selection === 'single' &&
|
|
40
|
+
})) })] }), selection === 'single' &&
|
|
41
|
+
(isDisabled && selectionAppearance === table_1.RowAppearance.HideToggler ? null : ((0, jsx_runtime_1.jsx)(toggles_1.Radio, { size: 'm', className: styles_module_scss_1.default.selectionController, checked: isSelected, disabled: isDisabled }))), selection === 'multiple' &&
|
|
42
|
+
(isDisabled && selectionAppearance === table_1.RowAppearance.HideToggler ? null : ((0, jsx_runtime_1.jsx)(toggles_1.Checkbox, { size: 'm', className: styles_module_scss_1.default.selectionController, checked: isSelected, disabled: isDisabled }))), actionsCell && actionsColumn && ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.button, children: (0, react_table_1.flexRender)(actionsColumn.column.columnDef.cell, actionsCell.getContext()) }))] }));
|
|
36
43
|
}
|
|
@@ -181,7 +181,7 @@ export function MobileTable(_a) {
|
|
|
181
181
|
onChange: onGlobalFilterChange,
|
|
182
182
|
loading: search === null || search === void 0 ? void 0 : search.loading,
|
|
183
183
|
placeholder: (search === null || search === void 0 ? void 0 : search.placeholder) || t('searchPlaceholder'),
|
|
184
|
-
}, onRefresh: onRefresh ? handleOnRefresh : undefined, outline: true, filterRow: columnFilters, after: toolbarAfter || shouldShowSorting || (areColumnsSettingsEnabled && columnsSettings) ? (_jsxs(_Fragment, { children: [toolbarAfter, shouldShowSorting && (_jsx(TableSorting, { table: table, columnDefinitions: columnDefinitions, enabledColumns: areColumnsSettingsEnabled ? enabledColumns : undefined, areColumnsSettingsEnabled: areColumnsSettingsEnabled })), areColumnsSettingsEnabled && columnsSettings && (_jsx(ColumnsSettings, { columnsSettings: columnsSettings, enabledColumns: enabledColumns, setEnabledColumns: setEnabledColumns }))] })) : undefined, 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 })] })));
|
|
184
|
+
}, onRefresh: onRefresh ? handleOnRefresh : undefined, outline: true, filterRow: columnFilters, after: toolbarAfter || shouldShowSorting || (areColumnsSettingsEnabled && columnsSettings) ? (_jsxs(_Fragment, { children: [toolbarAfter, shouldShowSorting && (_jsx(TableSorting, { table: table, columnDefinitions: columnDefinitions, enabledColumns: areColumnsSettingsEnabled ? enabledColumns : undefined, areColumnsSettingsEnabled: areColumnsSettingsEnabled })), areColumnsSettingsEnabled && columnsSettings && (_jsx(ColumnsSettings, { columnsSettings: columnsSettings, enabledColumns: enabledColumns, setEnabledColumns: setEnabledColumns }))] })) : undefined, 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, selectionAppearance: rowSelectionProp === null || rowSelectionProp === void 0 ? void 0 : rowSelectionProp.appearance, 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 })] })));
|
|
185
185
|
}
|
|
186
186
|
MobileTable.getRowActionsColumnDef = getRowActionsColumnDef;
|
|
187
187
|
MobileTable.getStatusColumnDef = getStatusColumnDef;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Row, Table } from '@tanstack/react-table';
|
|
2
|
+
import { RowAppearance } from '@snack-uikit/table';
|
|
2
3
|
type TableCardProps<TData extends object> = {
|
|
3
4
|
headlineId?: string;
|
|
4
5
|
row: Row<TData>;
|
|
5
6
|
table: Table<TData>;
|
|
6
7
|
selection: 'multiple' | 'single' | 'none';
|
|
8
|
+
selectionAppearance?: RowAppearance;
|
|
7
9
|
};
|
|
8
|
-
export declare function TableCard<TData extends object>({ headlineId, table, row, selection }: TableCardProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function TableCard<TData extends object>({ headlineId, table, row, selection, selectionAppearance, }: TableCardProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
9
11
|
export {};
|
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { flexRender } from '@tanstack/react-table';
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
|
+
import { RowAppearance } from '@snack-uikit/table';
|
|
4
5
|
import { Checkbox, Radio } from '@snack-uikit/toggles';
|
|
5
6
|
import { ROW_ACTIONS_COLUMN_ID } from '../../constants';
|
|
6
7
|
import styles from './styles.module.css';
|
|
7
|
-
export function TableCard({ headlineId, table, row, selection }) {
|
|
8
|
+
export function TableCard({ headlineId, table, row, selection, selectionAppearance = RowAppearance.Disabled, }) {
|
|
8
9
|
const headerGroups = table.getHeaderGroups();
|
|
9
10
|
const headerCell = row._getAllCellsByColumnId()[headlineId !== null && headlineId !== void 0 ? headlineId : ''];
|
|
10
11
|
const headerColumn = table.getFlatHeaders().find(header => header.id === headlineId);
|
|
11
12
|
const actionsCell = row._getAllCellsByColumnId()[ROW_ACTIONS_COLUMN_ID];
|
|
12
13
|
const actionsColumn = table.getFlatHeaders().find(header => header.id === ROW_ACTIONS_COLUMN_ID);
|
|
13
14
|
const isSelected = row.getIsSelected();
|
|
15
|
+
const canSelect = row.getCanSelect();
|
|
16
|
+
const isDisabled = !canSelect;
|
|
14
17
|
const handleSelection = useCallback(() => {
|
|
18
|
+
if (isDisabled)
|
|
19
|
+
return;
|
|
15
20
|
if (selection === 'single')
|
|
16
21
|
row.toggleSelected(true);
|
|
17
22
|
if (selection === 'multiple')
|
|
18
23
|
row.toggleSelected(!isSelected);
|
|
19
|
-
}, [isSelected, row, selection]);
|
|
24
|
+
}, [isDisabled, isSelected, row, selection]);
|
|
20
25
|
return (
|
|
21
26
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
22
27
|
_jsxs("div", { className: styles.card, "data-is-selected": isSelected !== null && isSelected !== void 0 ? isSelected : undefined, "data-selection-mode": selection, onClick: handleSelection, children: [_jsxs("div", { className: styles.content, children: [headerCell && headerColumn && (_jsx("div", { className: styles.headline, children: flexRender(headerColumn.column.columnDef.cell, headerCell.getContext()) })), _jsx("div", { className: styles.body, children: headerGroups.map(group => group.headers.map((header, index) => {
|
|
@@ -26,5 +31,7 @@ export function TableCard({ headlineId, table, row, selection }) {
|
|
|
26
31
|
const column = header.column.columnDef;
|
|
27
32
|
const cell = row._getAllCellsByColumnId()[header.column.id];
|
|
28
33
|
return (_jsxs("div", { className: styles.cardRow, children: [_jsx("div", { className: styles.cardRowHeader, children: flexRender(column.header, header.getContext()) }), _jsx("div", { className: styles.cardRowContent, children: flexRender(column.cell, cell.getContext()) })] }, header.id || index));
|
|
29
|
-
})) })] }), selection === 'single' &&
|
|
34
|
+
})) })] }), selection === 'single' &&
|
|
35
|
+
(isDisabled && selectionAppearance === RowAppearance.HideToggler ? null : (_jsx(Radio, { size: 'm', className: styles.selectionController, checked: isSelected, disabled: isDisabled }))), selection === 'multiple' &&
|
|
36
|
+
(isDisabled && selectionAppearance === RowAppearance.HideToggler ? null : (_jsx(Checkbox, { size: 'm', className: styles.selectionController, checked: isSelected, disabled: isDisabled }))), actionsCell && actionsColumn && (_jsx("div", { className: styles.button, children: flexRender(actionsColumn.column.columnDef.cell, actionsCell.getContext()) }))] }));
|
|
30
37
|
}
|
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.16.1",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"*.css",
|
|
7
7
|
"*.woff",
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
},
|
|
37
37
|
"scripts": {},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@cloud-ru/uikit-product-icons": "16.0.
|
|
40
|
-
"@cloud-ru/uikit-product-mobile-chips": "0.8.
|
|
41
|
-
"@cloud-ru/uikit-product-mobile-dropdown": "0.9.
|
|
42
|
-
"@cloud-ru/uikit-product-mobile-toolbar": "0.4.
|
|
43
|
-
"@cloud-ru/uikit-product-utils": "8.0.
|
|
39
|
+
"@cloud-ru/uikit-product-icons": "16.0.1",
|
|
40
|
+
"@cloud-ru/uikit-product-mobile-chips": "0.8.45",
|
|
41
|
+
"@cloud-ru/uikit-product-mobile-dropdown": "0.9.29",
|
|
42
|
+
"@cloud-ru/uikit-product-mobile-toolbar": "0.4.12",
|
|
43
|
+
"@cloud-ru/uikit-product-utils": "8.0.2",
|
|
44
44
|
"@snack-uikit/button": "0.19.16",
|
|
45
45
|
"@snack-uikit/figma-tokens": "18.0.1",
|
|
46
46
|
"@snack-uikit/icons": "0.27.4",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@types/lodash.debounce": "4.0.9"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "ab61e93fe6f723c522e95a7c5540b3080de6b2de"
|
|
67
67
|
}
|
|
@@ -385,6 +385,7 @@ export function MobileTable<TData extends object, TFilters extends FiltersState
|
|
|
385
385
|
headlineId={headlineId}
|
|
386
386
|
row={row}
|
|
387
387
|
table={table}
|
|
388
|
+
selectionAppearance={rowSelectionProp?.appearance}
|
|
388
389
|
selection={enableSelection ? selectionMode : 'none'}
|
|
389
390
|
/>
|
|
390
391
|
))}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { flexRender, Row, Table } from '@tanstack/react-table';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
|
|
4
|
+
import { RowAppearance } from '@snack-uikit/table';
|
|
4
5
|
import { Checkbox, Radio } from '@snack-uikit/toggles';
|
|
5
6
|
|
|
6
7
|
import { ROW_ACTIONS_COLUMN_ID } from '../../constants';
|
|
@@ -11,9 +12,16 @@ type TableCardProps<TData extends object> = {
|
|
|
11
12
|
row: Row<TData>;
|
|
12
13
|
table: Table<TData>;
|
|
13
14
|
selection: 'multiple' | 'single' | 'none';
|
|
15
|
+
selectionAppearance?: RowAppearance;
|
|
14
16
|
};
|
|
15
17
|
|
|
16
|
-
export function TableCard<TData extends object>({
|
|
18
|
+
export function TableCard<TData extends object>({
|
|
19
|
+
headlineId,
|
|
20
|
+
table,
|
|
21
|
+
row,
|
|
22
|
+
selection,
|
|
23
|
+
selectionAppearance = RowAppearance.Disabled,
|
|
24
|
+
}: TableCardProps<TData>) {
|
|
17
25
|
const headerGroups = table.getHeaderGroups();
|
|
18
26
|
|
|
19
27
|
const headerCell = row._getAllCellsByColumnId()[headlineId ?? ''];
|
|
@@ -23,11 +31,14 @@ export function TableCard<TData extends object>({ headlineId, table, row, select
|
|
|
23
31
|
const actionsColumn = table.getFlatHeaders().find(header => header.id === ROW_ACTIONS_COLUMN_ID);
|
|
24
32
|
|
|
25
33
|
const isSelected = row.getIsSelected();
|
|
34
|
+
const canSelect = row.getCanSelect();
|
|
35
|
+
const isDisabled = !canSelect;
|
|
26
36
|
|
|
27
37
|
const handleSelection = useCallback(() => {
|
|
38
|
+
if (isDisabled) return;
|
|
28
39
|
if (selection === 'single') row.toggleSelected(true);
|
|
29
40
|
if (selection === 'multiple') row.toggleSelected(!isSelected);
|
|
30
|
-
}, [isSelected, row, selection]);
|
|
41
|
+
}, [isDisabled, isSelected, row, selection]);
|
|
31
42
|
|
|
32
43
|
return (
|
|
33
44
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
@@ -65,8 +76,14 @@ export function TableCard<TData extends object>({ headlineId, table, row, select
|
|
|
65
76
|
</div>
|
|
66
77
|
</div>
|
|
67
78
|
|
|
68
|
-
{selection === 'single' &&
|
|
69
|
-
|
|
79
|
+
{selection === 'single' &&
|
|
80
|
+
(isDisabled && selectionAppearance === RowAppearance.HideToggler ? null : (
|
|
81
|
+
<Radio size='m' className={styles.selectionController} checked={isSelected} disabled={isDisabled} />
|
|
82
|
+
))}
|
|
83
|
+
{selection === 'multiple' &&
|
|
84
|
+
(isDisabled && selectionAppearance === RowAppearance.HideToggler ? null : (
|
|
85
|
+
<Checkbox size='m' className={styles.selectionController} checked={isSelected} disabled={isDisabled} />
|
|
86
|
+
))}
|
|
70
87
|
{actionsCell && actionsColumn && (
|
|
71
88
|
<div className={styles.button}>{flexRender(actionsColumn.column.columnDef.cell, actionsCell.getContext())}</div>
|
|
72
89
|
)}
|