@cloud-ru/ds-table 2.0.1-preview-7ecd2833.0 → 2.0.2
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 +8 -0
- package/dist/cjs/components/Table/Table.js +3 -3
- package/dist/cjs/components/Table/components/TableToolbar/TableToolbar.d.ts +1 -2
- package/dist/cjs/components/Table/components/TableToolbar/TableToolbar.js +2 -2
- package/dist/cjs/components/Table/hooks/useTableToolbar.d.ts +1 -0
- package/dist/cjs/components/Table/hooks/useTableToolbar.js +2 -1
- package/dist/cjs/constants.d.ts +1 -0
- package/dist/cjs/constants.js +1 -0
- package/dist/cjs/helpers/index.d.ts +1 -0
- package/dist/cjs/helpers/index.js +1 -0
- package/dist/cjs/helpers/renderTableSortingOverflowButton.d.ts +9 -0
- package/dist/cjs/helpers/renderTableSortingOverflowButton.js +20 -0
- package/dist/cjs/hooks/useTableSorting/useTableSorting.js +2 -5
- package/dist/cjs/hooks/useTableSortingToolbarSlot/useTableSortingToolbarSlot.d.ts +2 -4
- package/dist/cjs/hooks/useTableSortingToolbarSlot/useTableSortingToolbarSlot.js +25 -10
- package/dist/cjs/hooks/useTableSortingToolbarSlot/useTableSortingToolbarSlot.module.css +8 -0
- package/dist/cjs/style.css +8 -0
- package/dist/esm/components/Table/Table.js +3 -3
- package/dist/esm/components/Table/components/TableToolbar/TableToolbar.d.ts +1 -2
- package/dist/esm/components/Table/components/TableToolbar/TableToolbar.js +2 -2
- package/dist/esm/components/Table/hooks/useTableToolbar.d.ts +1 -0
- package/dist/esm/components/Table/hooks/useTableToolbar.js +2 -1
- package/dist/esm/constants.d.ts +1 -0
- package/dist/esm/constants.js +1 -0
- package/dist/esm/helpers/index.d.ts +1 -0
- package/dist/esm/helpers/index.js +1 -0
- package/dist/esm/helpers/renderTableSortingOverflowButton.d.ts +9 -0
- package/dist/esm/helpers/renderTableSortingOverflowButton.js +17 -0
- package/dist/esm/hooks/useTableSorting/useTableSorting.js +2 -5
- package/dist/esm/hooks/useTableSortingToolbarSlot/useTableSortingToolbarSlot.d.ts +2 -4
- package/dist/esm/hooks/useTableSortingToolbarSlot/useTableSortingToolbarSlot.js +22 -10
- package/dist/esm/hooks/useTableSortingToolbarSlot/useTableSortingToolbarSlot.module.css +8 -0
- package/dist/esm/style.css +8 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +20 -20
- package/src/components/Table/Table.tsx +8 -3
- package/src/components/Table/components/TableToolbar/TableToolbar.tsx +0 -3
- package/src/components/Table/hooks/useTableToolbar.ts +3 -1
- package/src/constants.ts +1 -0
- package/src/helpers/index.ts +1 -0
- package/src/helpers/renderTableSortingOverflowButton.tsx +33 -0
- package/src/hooks/useTableSorting/useTableSorting.tsx +2 -5
- package/src/hooks/useTableSortingToolbarSlot/useTableSortingToolbarSlot.module.scss +13 -0
- package/src/hooks/useTableSortingToolbarSlot/useTableSortingToolbarSlot.tsx +43 -25
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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.0.2 (2026-10-16)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @ds/table
|
|
9
|
+
|
|
10
|
+
## 2.0.1 (2026-10-16)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @ds/table
|
|
13
|
+
|
|
6
14
|
# 2.0.0 (2026-10-15)
|
|
7
15
|
|
|
8
16
|
### BREAKING CHANGES
|
|
@@ -198,7 +198,7 @@ function Table({ data, rowPinning = {
|
|
|
198
198
|
const multiRow = Boolean(rowSelectionProp?.multiRow);
|
|
199
199
|
const selectionMode = multiRow ? 'multiple' : 'single';
|
|
200
200
|
const cardSelection = enableSelection ? selectionMode : 'none';
|
|
201
|
-
const { tableToolbarPersistConfig, toolbarBulkProps, dataView, exportToolbarSlot, sortingToolbarSlot, columnsSettingsToolbarSlot, hasMobileToolbarMounts, searchPlaceholder, } = (0, hooks_1.useTableToolbar)({
|
|
201
|
+
const { tableToolbarPersistConfig, toolbarBulkProps, dataView, showToolbarSorting, exportToolbarSlot, sortingToolbarSlot, columnsSettingsToolbarSlot, hasMobileToolbarMounts, searchPlaceholder, } = (0, hooks_1.useTableToolbar)({
|
|
202
202
|
table,
|
|
203
203
|
columnDefinitions,
|
|
204
204
|
sortingProp,
|
|
@@ -322,7 +322,7 @@ function Table({ data, rowPinning = {
|
|
|
322
322
|
onChange: onGlobalFilterChange,
|
|
323
323
|
loading: search?.loading,
|
|
324
324
|
placeholder: search?.placeholder || searchPlaceholder,
|
|
325
|
-
}, onRefresh: onRefresh ? handleOnRefresh : undefined, persist: showToolbar ? tableToolbarPersistConfig : undefined, checked: toolbarBulkProps?.checked, indeterminate: toolbarBulkProps?.indeterminate, onCheck: toolbarBulkProps?.onCheck, bulkActions: toolbarBulkProps?.bulkActions, selectedCount: toolbarBulkProps?.selectedCount, totalCount: toolbarBulkProps?.totalCount, showBulkCheckbox: toolbarBulkProps?.showBulkCheckbox, outline: outline, dataView: dataView,
|
|
325
|
+
}, onRefresh: onRefresh ? handleOnRefresh : undefined, persist: showToolbar ? tableToolbarPersistConfig : undefined, checked: toolbarBulkProps?.checked, indeterminate: toolbarBulkProps?.indeterminate, onCheck: toolbarBulkProps?.onCheck, bulkActions: toolbarBulkProps?.bulkActions, selectedCount: toolbarBulkProps?.selectedCount, totalCount: toolbarBulkProps?.totalCount, showBulkCheckbox: toolbarBulkProps?.showBulkCheckbox, outline: outline, dataView: dataView, after: toolbarAfter || onExport || areColumnsSettingsEnabled || showToolbarSorting ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [toolbarAfter, exportToolbarSlot.afterContent, sortingToolbarSlot.afterContent, columnsSettingsToolbarSlot.afterContent] })) : undefined, moreActions: moreActions, filterRow: patchedFilter }));
|
|
326
326
|
let toolbarChrome = null;
|
|
327
327
|
if (showToolbar) {
|
|
328
328
|
const stickyToolbarChromeRef = isStickyControls ? stickyToolbarRef : undefined;
|
|
@@ -335,7 +335,7 @@ function Table({ data, rowPinning = {
|
|
|
335
335
|
paginationChrome =
|
|
336
336
|
isStickyControls && controlsAcrylic ? ((0, jsx_runtime_1.jsx)(TableChrome_1.TableChrome, { variant: 'footer', acrylic: controlsAcrylic, children: pagination })) : (pagination);
|
|
337
337
|
}
|
|
338
|
-
return ((0, jsx_runtime_1.jsx)("div", { ref: wrapperRef, className: (0, classnames_1.default)(styles_module_scss_1.default.wrapper, className), "data-view": view, "data-layout-type": layoutType, "data-sticky-controls": isStickyControls || undefined, "data-with-toolbar": showToolbar || undefined, "data-empty-body": isEmptyBody || undefined, "data-fit-content": !resolvedFullWidth || undefined, ...(0, utils_1.extractSupportProps)(rest), children: (0, jsx_runtime_1.jsxs)(contexts_1.TableContext.Provider, { value: tableContextValue, children: [toolbarChrome, (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.tableView, children: [(0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.content, "data-outline": !isCardsView && outline ? true : undefined, "data-page-sticky-header": !isCardsView && usePageStickyHeader ? true : undefined, ...(!isCardsView ? TABLE_CONTENT_ACRYLIC : {}), children: [!isCardsView ? (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.contentAcrylic, "data-acrylic-background": true, "aria-hidden": true }) : null, hasMobileToolbarMounts ? ((0, jsx_runtime_1.
|
|
338
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: wrapperRef, className: (0, classnames_1.default)(styles_module_scss_1.default.wrapper, className), "data-view": view, "data-layout-type": layoutType, "data-sticky-controls": isStickyControls || undefined, "data-with-toolbar": showToolbar || undefined, "data-empty-body": isEmptyBody || undefined, "data-fit-content": !resolvedFullWidth || undefined, ...(0, utils_1.extractSupportProps)(rest), children: (0, jsx_runtime_1.jsxs)(contexts_1.TableContext.Provider, { value: tableContextValue, children: [toolbarChrome, (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.tableView, children: [(0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.content, "data-outline": !isCardsView && outline ? true : undefined, "data-page-sticky-header": !isCardsView && usePageStickyHeader ? true : undefined, ...(!isCardsView ? TABLE_CONTENT_ACRYLIC : {}), children: [!isCardsView ? (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.contentAcrylic, "data-acrylic-background": true, "aria-hidden": true }) : null, hasMobileToolbarMounts ? ((0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.mobileToolbarMounts, children: [sortingToolbarSlot.mobileMount, columnsSettingsToolbarSlot.mobileMount] })) : null, (0, jsx_runtime_1.jsxs)(core_1.DndContext, { ...dndContextProps, children: [draggingColumnPreview, (0, jsx_runtime_1.jsx)(TableScrollHost_1.TableScrollHost, { view: view, isMobile: isMobile, isCardsView: isCardsView, usePageStickyHeader: usePageStickyHeader, scrollOverflow: scrollOverflow, scrollPaddingAbsolute: scrollPaddingAbsolute, internalScrollRef: internalScrollRef, scrollRef: scrollRef, scrollContainerRef: scrollContainerRef, handleScrollInitialized: handleScrollInitialized, syncHeaderHorizontalScroll: syncHeaderHorizontalScroll, tableHeaderElement: tableHeaderElement, columnSizeVars: columnSizes.vars, children: scrollContent })] }), loadMoreButtonNode, !isCardsView && outline ? (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.contentBorder, "aria-hidden": true }) : null] }), paginationChrome] })] }) }));
|
|
339
339
|
}
|
|
340
340
|
Table.getStatusColumnDef = helperComponents_1.getStatusColumnDef;
|
|
341
341
|
Table.statusAppearances = helperComponents_1.STATUS_APPEARANCE;
|
|
@@ -18,10 +18,9 @@ type TableToolbarProps<TFilters extends FiltersState> = {
|
|
|
18
18
|
value: 'list' | 'compact';
|
|
19
19
|
onChange: (value: 'list' | 'compact') => void;
|
|
20
20
|
};
|
|
21
|
-
pinnedAfter?: ReactNode;
|
|
22
21
|
after?: ReactNode;
|
|
23
22
|
moreActions?: TableProps<object>['moreActions'];
|
|
24
23
|
filterRow?: TableProps<object>['columnFilters'];
|
|
25
24
|
} & Partial<TableToolbarBulkProps>;
|
|
26
|
-
export declare function TableToolbar<TFilters extends FiltersState = Record<string, unknown>>({ search, onRefresh, persist, checked, indeterminate, onCheck, bulkActions, selectedCount, totalCount, showBulkCheckbox, outline, dataView,
|
|
25
|
+
export declare function TableToolbar<TFilters extends FiltersState = Record<string, unknown>>({ search, onRefresh, persist, checked, indeterminate, onCheck, bulkActions, selectedCount, totalCount, showBulkCheckbox, outline, dataView, after, moreActions, filterRow, }: TableToolbarProps<TFilters>): import("react/jsx-runtime").JSX.Element;
|
|
27
26
|
export {};
|
|
@@ -8,6 +8,6 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const toolbar_1 = require("@cloud-ru/ds-toolbar");
|
|
9
9
|
const constants_1 = require("../../../../constants");
|
|
10
10
|
const styles_module_scss_1 = __importDefault(require('../../styles.module.css'));
|
|
11
|
-
function TableToolbar({ search, onRefresh, persist, checked, indeterminate, onCheck, bulkActions, selectedCount, totalCount, showBulkCheckbox, outline, dataView,
|
|
12
|
-
return ((0, jsx_runtime_1.jsx)(toolbar_1.Toolbar, { search: search, className: styles_module_scss_1.default.toolbar, onRefresh: onRefresh, persist: persist, checked: checked, indeterminate: indeterminate, onCheck: onCheck, bulkActions: bulkActions, selectedCount: selectedCount, totalCount: totalCount, showBulkCheckbox: showBulkCheckbox, outline: outline, dataView: dataView,
|
|
11
|
+
function TableToolbar({ search, onRefresh, persist, checked, indeterminate, onCheck, bulkActions, selectedCount, totalCount, showBulkCheckbox, outline, dataView, after, moreActions, filterRow, }) {
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)(toolbar_1.Toolbar, { search: search, className: styles_module_scss_1.default.toolbar, onRefresh: onRefresh, persist: persist, checked: checked, indeterminate: indeterminate, onCheck: onCheck, bulkActions: bulkActions, selectedCount: selectedCount, totalCount: totalCount, showBulkCheckbox: showBulkCheckbox, outline: outline, dataView: dataView, after: after, moreActions: moreActions, filterRow: filterRow, "data-test-id": constants_1.TEST_IDS.toolbar }));
|
|
13
13
|
}
|
|
@@ -67,6 +67,7 @@ type UseTableToolbarResult<TFilters extends FiltersState> = {
|
|
|
67
67
|
value: ToolbarDataViewValue;
|
|
68
68
|
onChange: (value: ToolbarDataViewValue) => void;
|
|
69
69
|
};
|
|
70
|
+
showToolbarSorting: boolean;
|
|
70
71
|
exportToolbarSlot: ExportToolbarSlotResult;
|
|
71
72
|
sortingToolbarSlot: TableSortingToolbarSlotResult;
|
|
72
73
|
columnsSettingsToolbarSlot: ColumnsSettingsToolbarSlotResult;
|
|
@@ -106,11 +106,12 @@ function useTableToolbar({ table, columnDefinitions, sortingProp, savedState, co
|
|
|
106
106
|
setEnabledColumns,
|
|
107
107
|
setColumnOrder,
|
|
108
108
|
});
|
|
109
|
-
const hasMobileToolbarMounts = Boolean(columnsSettingsToolbarSlot.mobileMount);
|
|
109
|
+
const hasMobileToolbarMounts = Boolean(sortingToolbarSlot.mobileMount || columnsSettingsToolbarSlot.mobileMount);
|
|
110
110
|
return {
|
|
111
111
|
tableToolbarPersistConfig: tableToolbarPersistConfig,
|
|
112
112
|
toolbarBulkProps,
|
|
113
113
|
dataView,
|
|
114
|
+
showToolbarSorting,
|
|
114
115
|
exportToolbarSlot,
|
|
115
116
|
sortingToolbarSlot,
|
|
116
117
|
columnsSettingsToolbarSlot,
|
package/dist/cjs/constants.d.ts
CHANGED
|
@@ -100,6 +100,7 @@ export declare const TEST_IDS: {
|
|
|
100
100
|
readonly droplistTrigger: "table__view-sort__droplistTrigger";
|
|
101
101
|
readonly droplist: "table__view-sort__droplist";
|
|
102
102
|
readonly option: "table__view-sort__option";
|
|
103
|
+
readonly overflowTrigger: "table__view-sort__overflow-trigger";
|
|
103
104
|
};
|
|
104
105
|
};
|
|
105
106
|
export declare const DEFAULT_PAGE_SIZE = 10;
|
package/dist/cjs/constants.js
CHANGED
|
@@ -111,6 +111,7 @@ exports.TEST_IDS = {
|
|
|
111
111
|
droplistTrigger: 'table__view-sort__droplistTrigger',
|
|
112
112
|
droplist: 'table__view-sort__droplist',
|
|
113
113
|
option: 'table__view-sort__option',
|
|
114
|
+
overflowTrigger: 'table__view-sort__overflow-trigger',
|
|
114
115
|
},
|
|
115
116
|
};
|
|
116
117
|
exports.DEFAULT_PAGE_SIZE = 10;
|
|
@@ -4,5 +4,6 @@ export * from './rowSelectionState';
|
|
|
4
4
|
export * from './tryParseLocalStorage';
|
|
5
5
|
export * from './renderMasterSelectionToggle';
|
|
6
6
|
export * from './renderColumnsSettingsOverflowButton';
|
|
7
|
+
export * from './renderTableSortingOverflowButton';
|
|
7
8
|
export * from './renderToolbarAfterOverflowButton';
|
|
8
9
|
export * from './renderExportToolbarButton';
|
|
@@ -20,5 +20,6 @@ __exportStar(require("./rowSelectionState"), exports);
|
|
|
20
20
|
__exportStar(require("./tryParseLocalStorage"), exports);
|
|
21
21
|
__exportStar(require("./renderMasterSelectionToggle"), exports);
|
|
22
22
|
__exportStar(require("./renderColumnsSettingsOverflowButton"), exports);
|
|
23
|
+
__exportStar(require("./renderTableSortingOverflowButton"), exports);
|
|
23
24
|
__exportStar(require("./renderToolbarAfterOverflowButton"), exports);
|
|
24
25
|
__exportStar(require("./renderExportToolbarButton"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MouseEvent, ReactNode } from 'react';
|
|
2
|
+
type RenderTableSortingOverflowButtonParams = {
|
|
3
|
+
ariaLabel: string;
|
|
4
|
+
onClick: (event: MouseEvent<HTMLElement>) => void;
|
|
5
|
+
selectedSortId?: string;
|
|
6
|
+
currentSortDesc?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function renderTableSortingOverflowButton({ ariaLabel, onClick, selectedSortId, currentSortDesc, }: RenderTableSortingOverflowButtonParams): ReactNode;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderTableSortingOverflowButton = renderTableSortingOverflowButton;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const product_1 = require("@cloud-ru/ds-icons/interface/product");
|
|
6
|
+
const system_1 = require("@cloud-ru/ds-icons/interface/system");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const renderToolbarAfterOverflowButton_1 = require("./renderToolbarAfterOverflowButton");
|
|
9
|
+
function renderTableSortingOverflowButton({ ariaLabel, onClick, selectedSortId, currentSortDesc, }) {
|
|
10
|
+
let SortIcon = product_1.SortSVG;
|
|
11
|
+
if (selectedSortId) {
|
|
12
|
+
SortIcon = currentSortDesc ? system_1.ArrowDownSVG : system_1.ArrowUpSVG;
|
|
13
|
+
}
|
|
14
|
+
return (0, renderToolbarAfterOverflowButton_1.renderToolbarAfterOverflowButton)({
|
|
15
|
+
'aria-label': ariaLabel,
|
|
16
|
+
icon: (0, jsx_runtime_1.jsx)(SortIcon, {}),
|
|
17
|
+
onClick,
|
|
18
|
+
'data-test-id': constants_1.TEST_IDS.viewSort.overflowTrigger,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useTableSorting = useTableSorting;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const adaptive_1 = require("@cloud-ru/ds-adaptive");
|
|
9
8
|
const system_1 = require("@cloud-ru/ds-icons/interface/system");
|
|
10
9
|
const list_1 = require("@cloud-ru/ds-list");
|
|
11
10
|
const react_1 = require("react");
|
|
@@ -19,8 +18,6 @@ const utils_1 = require("./utils");
|
|
|
19
18
|
const SERVICE_COLUMN_IDS = new Set([constants_1.DefaultColumns.Selection, constants_1.DefaultColumns.RowActions, constants_2.TREE_CELL_ID]);
|
|
20
19
|
function useTableSorting({ table, sorting: sortingProp, columnDefinitions, enabledColumns, areColumnsSettingsEnabled = false, }) {
|
|
21
20
|
const { t } = locale_1.tableLocale.useTranslations();
|
|
22
|
-
const { layoutType } = (0, adaptive_1.useAdaptiveLayout)();
|
|
23
|
-
const isMobile = (0, adaptive_1.isMobileLayout)(layoutType);
|
|
24
21
|
const sorting = sortingProp ?? table.getState().sorting;
|
|
25
22
|
const columnDefMap = (0, react_1.useMemo)(() => (0, utils_1.createColumnDefMap)(columnDefinitions), [columnDefinitions]);
|
|
26
23
|
const hiddenColumnsBySettings = (0, react_1.useMemo)(() => {
|
|
@@ -164,14 +161,14 @@ function useTableSorting({ table, sorting: sortingProp, columnDefinitions, enabl
|
|
|
164
161
|
];
|
|
165
162
|
const mainGroup = {
|
|
166
163
|
type: list_1.ITEM_TYPE.Group,
|
|
167
|
-
label:
|
|
164
|
+
label: t('sort'),
|
|
168
165
|
items: groups,
|
|
169
166
|
};
|
|
170
167
|
return {
|
|
171
168
|
items: [mainGroup],
|
|
172
169
|
pinBottom: clearItem,
|
|
173
170
|
};
|
|
174
|
-
}, [groupSortableHeadersByPinned, createSortItem, sorting, handleClearSort, t
|
|
171
|
+
}, [groupSortableHeadersByPinned, createSortItem, sorting, handleClearSort, t]);
|
|
175
172
|
const handleSelectionChange = (0, react_1.useCallback)((selectedId) => {
|
|
176
173
|
const id = String(selectedId);
|
|
177
174
|
const match = id.match(/^sort-(.+)$/);
|
|
@@ -18,9 +18,7 @@ export type TableSortingToolbarSlotParams<TData extends object> = TableSortingPr
|
|
|
18
18
|
};
|
|
19
19
|
export type TableSortingToolbarSlotResult = {
|
|
20
20
|
afterContent: ReactNode;
|
|
21
|
+
mobileMount: ReactNode;
|
|
21
22
|
};
|
|
22
|
-
/**
|
|
23
|
-
* Слот сортировки в тулбаре: `afterContent` — в `pinnedAfter`, поэтому на mobile кнопка остаётся в строке
|
|
24
|
-
* тулбара. Список открывается в `BottomSheet` (surface-swap `Droplist`).
|
|
25
|
-
*/
|
|
23
|
+
/** Слот сортировки в тулбаре: `afterContent` — в `after`, `mobileMount` — BottomSheet вне строки тулбара. */
|
|
26
24
|
export declare function useTableSortingToolbarSlot<TData extends object>({ enabled, table, sorting, columnDefinitions, enabledColumns, areColumnsSettingsEnabled, }: TableSortingToolbarSlotParams<TData>): TableSortingToolbarSlotResult;
|
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.useTableSortingToolbarSlot = useTableSortingToolbarSlot;
|
|
4
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const adaptive_1 = require("@cloud-ru/ds-adaptive");
|
|
5
9
|
const button_1 = require("@cloud-ru/ds-button");
|
|
6
10
|
const product_1 = require("@cloud-ru/ds-icons/interface/product");
|
|
7
11
|
const system_1 = require("@cloud-ru/ds-icons/interface/system");
|
|
8
12
|
const list_1 = require("@cloud-ru/ds-list");
|
|
9
13
|
const react_1 = require("react");
|
|
10
14
|
const constants_1 = require("../../constants");
|
|
15
|
+
const helpers_1 = require("../../helpers");
|
|
11
16
|
const locale_1 = require("../../locale");
|
|
12
17
|
const useTableSorting_1 = require("../useTableSorting");
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* тулбара. Список открывается в `BottomSheet` (surface-swap `Droplist`).
|
|
16
|
-
*/
|
|
18
|
+
const useTableSortingToolbarSlot_module_scss_1 = __importDefault(require('./useTableSortingToolbarSlot.module.css'));
|
|
19
|
+
/** Слот сортировки в тулбаре: `afterContent` — в `after`, `mobileMount` — BottomSheet вне строки тулбара. */
|
|
17
20
|
function useTableSortingToolbarSlot({ enabled = true, table, sorting, columnDefinitions, enabledColumns, areColumnsSettingsEnabled = false, }) {
|
|
18
21
|
const { t } = locale_1.tableLocale.useTranslations();
|
|
22
|
+
const { layoutType } = (0, adaptive_1.useAdaptiveLayout)();
|
|
23
|
+
const isMobile = (0, adaptive_1.isMobileLayout)(layoutType);
|
|
19
24
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
20
25
|
const { items, pinBottom, selection, currentSort, selectedSortId, handleClearSort } = (0, useTableSorting_1.useTableSorting)({
|
|
21
26
|
table,
|
|
@@ -24,9 +29,6 @@ function useTableSortingToolbarSlot({ enabled = true, table, sorting, columnDefi
|
|
|
24
29
|
enabledColumns,
|
|
25
30
|
areColumnsSettingsEnabled,
|
|
26
31
|
});
|
|
27
|
-
if (!enabled) {
|
|
28
|
-
return { afterContent: null };
|
|
29
|
-
}
|
|
30
32
|
const handleClear = () => {
|
|
31
33
|
handleClearSort();
|
|
32
34
|
setOpen(false);
|
|
@@ -36,7 +38,20 @@ function useTableSortingToolbarSlot({ enabled = true, table, sorting, columnDefi
|
|
|
36
38
|
if (currentSort) {
|
|
37
39
|
SortIcon = currentSort.desc ? system_1.ArrowDownSVG : system_1.ArrowUpSVG;
|
|
38
40
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
const droplist = ((0, jsx_runtime_1.jsx)(list_1.Droplist, { scroll: true, items: items, selection: selection, virtualized: items.length > 10, pinBottom: clearItem, open: open, onOpenChange: setOpen, label: t('sort'), "data-test-id": constants_1.TEST_IDS.viewSort.droplist, children: isMobile ? ((0, jsx_runtime_1.jsx)("span", { className: useTableSortingToolbarSlot_module_scss_1.default.hiddenTrigger, "aria-hidden": true })) : ((0, jsx_runtime_1.jsx)(button_1.Button, { size: 'm', view: button_1.VIEW.Function, icon: (0, jsx_runtime_1.jsx)(SortIcon, {}), appearance: selectedSortId ? button_1.APPEARANCE.Primary : button_1.APPEARANCE.Neutral, "data-test-id": constants_1.TEST_IDS.viewSort.droplistTrigger })) }));
|
|
42
|
+
if (!enabled) {
|
|
43
|
+
return { afterContent: null, mobileMount: null };
|
|
44
|
+
}
|
|
45
|
+
if (isMobile) {
|
|
46
|
+
return {
|
|
47
|
+
afterContent: (0, helpers_1.renderTableSortingOverflowButton)({
|
|
48
|
+
ariaLabel: t('sort'),
|
|
49
|
+
onClick: () => setOpen(true),
|
|
50
|
+
selectedSortId,
|
|
51
|
+
currentSortDesc: currentSort?.desc,
|
|
52
|
+
}),
|
|
53
|
+
mobileMount: droplist,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return { afterContent: droplist, mobileMount: null };
|
|
42
57
|
}
|
package/dist/cjs/style.css
CHANGED
|
@@ -1642,4 +1642,12 @@
|
|
|
1642
1642
|
}
|
|
1643
1643
|
.clearSortItem[data-disabled=true] svg{
|
|
1644
1644
|
color:var(--sn-theme-color-available-version-textDisabled, var(--sn-brand-color-text-version-disabled, rgba(0, 0, 0, 0.3803921569)));
|
|
1645
|
+
}
|
|
1646
|
+
.hiddenTrigger{
|
|
1647
|
+
position:absolute;
|
|
1648
|
+
overflow:hidden;
|
|
1649
|
+
width:1px;
|
|
1650
|
+
height:1px;
|
|
1651
|
+
white-space:nowrap;
|
|
1652
|
+
clip-path:rect(0, 0, 0, 0);
|
|
1645
1653
|
}
|
|
@@ -191,7 +191,7 @@ export function Table({ data, rowPinning = {
|
|
|
191
191
|
const multiRow = Boolean(rowSelectionProp?.multiRow);
|
|
192
192
|
const selectionMode = multiRow ? 'multiple' : 'single';
|
|
193
193
|
const cardSelection = enableSelection ? selectionMode : 'none';
|
|
194
|
-
const { tableToolbarPersistConfig, toolbarBulkProps, dataView, exportToolbarSlot, sortingToolbarSlot, columnsSettingsToolbarSlot, hasMobileToolbarMounts, searchPlaceholder, } = useTableToolbar({
|
|
194
|
+
const { tableToolbarPersistConfig, toolbarBulkProps, dataView, showToolbarSorting, exportToolbarSlot, sortingToolbarSlot, columnsSettingsToolbarSlot, hasMobileToolbarMounts, searchPlaceholder, } = useTableToolbar({
|
|
195
195
|
table,
|
|
196
196
|
columnDefinitions,
|
|
197
197
|
sortingProp,
|
|
@@ -315,7 +315,7 @@ export function Table({ data, rowPinning = {
|
|
|
315
315
|
onChange: onGlobalFilterChange,
|
|
316
316
|
loading: search?.loading,
|
|
317
317
|
placeholder: search?.placeholder || searchPlaceholder,
|
|
318
|
-
}, onRefresh: onRefresh ? handleOnRefresh : undefined, persist: showToolbar ? tableToolbarPersistConfig : undefined, checked: toolbarBulkProps?.checked, indeterminate: toolbarBulkProps?.indeterminate, onCheck: toolbarBulkProps?.onCheck, bulkActions: toolbarBulkProps?.bulkActions, selectedCount: toolbarBulkProps?.selectedCount, totalCount: toolbarBulkProps?.totalCount, showBulkCheckbox: toolbarBulkProps?.showBulkCheckbox, outline: outline, dataView: dataView,
|
|
318
|
+
}, onRefresh: onRefresh ? handleOnRefresh : undefined, persist: showToolbar ? tableToolbarPersistConfig : undefined, checked: toolbarBulkProps?.checked, indeterminate: toolbarBulkProps?.indeterminate, onCheck: toolbarBulkProps?.onCheck, bulkActions: toolbarBulkProps?.bulkActions, selectedCount: toolbarBulkProps?.selectedCount, totalCount: toolbarBulkProps?.totalCount, showBulkCheckbox: toolbarBulkProps?.showBulkCheckbox, outline: outline, dataView: dataView, after: toolbarAfter || onExport || areColumnsSettingsEnabled || showToolbarSorting ? (_jsxs(_Fragment, { children: [toolbarAfter, exportToolbarSlot.afterContent, sortingToolbarSlot.afterContent, columnsSettingsToolbarSlot.afterContent] })) : undefined, moreActions: moreActions, filterRow: patchedFilter }));
|
|
319
319
|
let toolbarChrome = null;
|
|
320
320
|
if (showToolbar) {
|
|
321
321
|
const stickyToolbarChromeRef = isStickyControls ? stickyToolbarRef : undefined;
|
|
@@ -328,7 +328,7 @@ export function Table({ data, rowPinning = {
|
|
|
328
328
|
paginationChrome =
|
|
329
329
|
isStickyControls && controlsAcrylic ? (_jsx(TableChrome, { variant: 'footer', acrylic: controlsAcrylic, children: pagination })) : (pagination);
|
|
330
330
|
}
|
|
331
|
-
return (_jsx("div", { ref: wrapperRef, className: cn(styles.wrapper, className), "data-view": view, "data-layout-type": layoutType, "data-sticky-controls": isStickyControls || undefined, "data-with-toolbar": showToolbar || undefined, "data-empty-body": isEmptyBody || undefined, "data-fit-content": !resolvedFullWidth || undefined, ...extractSupportProps(rest), children: _jsxs(TableContext.Provider, { value: tableContextValue, children: [toolbarChrome, _jsxs("div", { className: styles.tableView, children: [_jsxs("div", { className: styles.content, "data-outline": !isCardsView && outline ? true : undefined, "data-page-sticky-header": !isCardsView && usePageStickyHeader ? true : undefined, ...(!isCardsView ? TABLE_CONTENT_ACRYLIC : {}), children: [!isCardsView ? _jsx("span", { className: styles.contentAcrylic, "data-acrylic-background": true, "aria-hidden": true }) : null, hasMobileToolbarMounts ? (
|
|
331
|
+
return (_jsx("div", { ref: wrapperRef, className: cn(styles.wrapper, className), "data-view": view, "data-layout-type": layoutType, "data-sticky-controls": isStickyControls || undefined, "data-with-toolbar": showToolbar || undefined, "data-empty-body": isEmptyBody || undefined, "data-fit-content": !resolvedFullWidth || undefined, ...extractSupportProps(rest), children: _jsxs(TableContext.Provider, { value: tableContextValue, children: [toolbarChrome, _jsxs("div", { className: styles.tableView, children: [_jsxs("div", { className: styles.content, "data-outline": !isCardsView && outline ? true : undefined, "data-page-sticky-header": !isCardsView && usePageStickyHeader ? true : undefined, ...(!isCardsView ? TABLE_CONTENT_ACRYLIC : {}), children: [!isCardsView ? _jsx("span", { className: styles.contentAcrylic, "data-acrylic-background": true, "aria-hidden": true }) : null, hasMobileToolbarMounts ? (_jsxs("div", { className: styles.mobileToolbarMounts, children: [sortingToolbarSlot.mobileMount, columnsSettingsToolbarSlot.mobileMount] })) : null, _jsxs(DndContext, { ...dndContextProps, children: [draggingColumnPreview, _jsx(TableScrollHost, { view: view, isMobile: isMobile, isCardsView: isCardsView, usePageStickyHeader: usePageStickyHeader, scrollOverflow: scrollOverflow, scrollPaddingAbsolute: scrollPaddingAbsolute, internalScrollRef: internalScrollRef, scrollRef: scrollRef, scrollContainerRef: scrollContainerRef, handleScrollInitialized: handleScrollInitialized, syncHeaderHorizontalScroll: syncHeaderHorizontalScroll, tableHeaderElement: tableHeaderElement, columnSizeVars: columnSizes.vars, children: scrollContent })] }), loadMoreButtonNode, !isCardsView && outline ? _jsx("span", { className: styles.contentBorder, "aria-hidden": true }) : null] }), paginationChrome] })] }) }));
|
|
332
332
|
}
|
|
333
333
|
Table.getStatusColumnDef = getStatusColumnDef;
|
|
334
334
|
Table.statusAppearances = STATUS_APPEARANCE;
|
|
@@ -18,10 +18,9 @@ type TableToolbarProps<TFilters extends FiltersState> = {
|
|
|
18
18
|
value: 'list' | 'compact';
|
|
19
19
|
onChange: (value: 'list' | 'compact') => void;
|
|
20
20
|
};
|
|
21
|
-
pinnedAfter?: ReactNode;
|
|
22
21
|
after?: ReactNode;
|
|
23
22
|
moreActions?: TableProps<object>['moreActions'];
|
|
24
23
|
filterRow?: TableProps<object>['columnFilters'];
|
|
25
24
|
} & Partial<TableToolbarBulkProps>;
|
|
26
|
-
export declare function TableToolbar<TFilters extends FiltersState = Record<string, unknown>>({ search, onRefresh, persist, checked, indeterminate, onCheck, bulkActions, selectedCount, totalCount, showBulkCheckbox, outline, dataView,
|
|
25
|
+
export declare function TableToolbar<TFilters extends FiltersState = Record<string, unknown>>({ search, onRefresh, persist, checked, indeterminate, onCheck, bulkActions, selectedCount, totalCount, showBulkCheckbox, outline, dataView, after, moreActions, filterRow, }: TableToolbarProps<TFilters>): import("react/jsx-runtime").JSX.Element;
|
|
27
26
|
export {};
|
|
@@ -2,6 +2,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Toolbar } from '@cloud-ru/ds-toolbar';
|
|
3
3
|
import { TEST_IDS } from '../../../../constants.js';
|
|
4
4
|
import styles from '../../styles.module.css';
|
|
5
|
-
export function TableToolbar({ search, onRefresh, persist, checked, indeterminate, onCheck, bulkActions, selectedCount, totalCount, showBulkCheckbox, outline, dataView,
|
|
6
|
-
return (_jsx(Toolbar, { search: search, className: styles.toolbar, onRefresh: onRefresh, persist: persist, checked: checked, indeterminate: indeterminate, onCheck: onCheck, bulkActions: bulkActions, selectedCount: selectedCount, totalCount: totalCount, showBulkCheckbox: showBulkCheckbox, outline: outline, dataView: dataView,
|
|
5
|
+
export function TableToolbar({ search, onRefresh, persist, checked, indeterminate, onCheck, bulkActions, selectedCount, totalCount, showBulkCheckbox, outline, dataView, after, moreActions, filterRow, }) {
|
|
6
|
+
return (_jsx(Toolbar, { search: search, className: styles.toolbar, onRefresh: onRefresh, persist: persist, checked: checked, indeterminate: indeterminate, onCheck: onCheck, bulkActions: bulkActions, selectedCount: selectedCount, totalCount: totalCount, showBulkCheckbox: showBulkCheckbox, outline: outline, dataView: dataView, after: after, moreActions: moreActions, filterRow: filterRow, "data-test-id": TEST_IDS.toolbar }));
|
|
7
7
|
}
|
|
@@ -67,6 +67,7 @@ type UseTableToolbarResult<TFilters extends FiltersState> = {
|
|
|
67
67
|
value: ToolbarDataViewValue;
|
|
68
68
|
onChange: (value: ToolbarDataViewValue) => void;
|
|
69
69
|
};
|
|
70
|
+
showToolbarSorting: boolean;
|
|
70
71
|
exportToolbarSlot: ExportToolbarSlotResult;
|
|
71
72
|
sortingToolbarSlot: TableSortingToolbarSlotResult;
|
|
72
73
|
columnsSettingsToolbarSlot: ColumnsSettingsToolbarSlotResult;
|
|
@@ -103,11 +103,12 @@ export function useTableToolbar({ table, columnDefinitions, sortingProp, savedSt
|
|
|
103
103
|
setEnabledColumns,
|
|
104
104
|
setColumnOrder,
|
|
105
105
|
});
|
|
106
|
-
const hasMobileToolbarMounts = Boolean(columnsSettingsToolbarSlot.mobileMount);
|
|
106
|
+
const hasMobileToolbarMounts = Boolean(sortingToolbarSlot.mobileMount || columnsSettingsToolbarSlot.mobileMount);
|
|
107
107
|
return {
|
|
108
108
|
tableToolbarPersistConfig: tableToolbarPersistConfig,
|
|
109
109
|
toolbarBulkProps,
|
|
110
110
|
dataView,
|
|
111
|
+
showToolbarSorting,
|
|
111
112
|
exportToolbarSlot,
|
|
112
113
|
sortingToolbarSlot,
|
|
113
114
|
columnsSettingsToolbarSlot,
|
package/dist/esm/constants.d.ts
CHANGED
|
@@ -100,6 +100,7 @@ export declare const TEST_IDS: {
|
|
|
100
100
|
readonly droplistTrigger: "table__view-sort__droplistTrigger";
|
|
101
101
|
readonly droplist: "table__view-sort__droplist";
|
|
102
102
|
readonly option: "table__view-sort__option";
|
|
103
|
+
readonly overflowTrigger: "table__view-sort__overflow-trigger";
|
|
103
104
|
};
|
|
104
105
|
};
|
|
105
106
|
export declare const DEFAULT_PAGE_SIZE = 10;
|
package/dist/esm/constants.js
CHANGED
|
@@ -108,6 +108,7 @@ export const TEST_IDS = {
|
|
|
108
108
|
droplistTrigger: 'table__view-sort__droplistTrigger',
|
|
109
109
|
droplist: 'table__view-sort__droplist',
|
|
110
110
|
option: 'table__view-sort__option',
|
|
111
|
+
overflowTrigger: 'table__view-sort__overflow-trigger',
|
|
111
112
|
},
|
|
112
113
|
};
|
|
113
114
|
export const DEFAULT_PAGE_SIZE = 10;
|
|
@@ -4,5 +4,6 @@ export * from './rowSelectionState.js';
|
|
|
4
4
|
export * from './tryParseLocalStorage.js';
|
|
5
5
|
export * from './renderMasterSelectionToggle.js';
|
|
6
6
|
export * from './renderColumnsSettingsOverflowButton.js';
|
|
7
|
+
export * from './renderTableSortingOverflowButton.js';
|
|
7
8
|
export * from './renderToolbarAfterOverflowButton.js';
|
|
8
9
|
export * from './renderExportToolbarButton.js';
|
|
@@ -4,5 +4,6 @@ export * from './rowSelectionState.js';
|
|
|
4
4
|
export * from './tryParseLocalStorage.js';
|
|
5
5
|
export * from './renderMasterSelectionToggle.js';
|
|
6
6
|
export * from './renderColumnsSettingsOverflowButton.js';
|
|
7
|
+
export * from './renderTableSortingOverflowButton.js';
|
|
7
8
|
export * from './renderToolbarAfterOverflowButton.js';
|
|
8
9
|
export * from './renderExportToolbarButton.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MouseEvent, ReactNode } from 'react';
|
|
2
|
+
type RenderTableSortingOverflowButtonParams = {
|
|
3
|
+
ariaLabel: string;
|
|
4
|
+
onClick: (event: MouseEvent<HTMLElement>) => void;
|
|
5
|
+
selectedSortId?: string;
|
|
6
|
+
currentSortDesc?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function renderTableSortingOverflowButton({ ariaLabel, onClick, selectedSortId, currentSortDesc, }: RenderTableSortingOverflowButtonParams): ReactNode;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { SortSVG } from '@cloud-ru/ds-icons/interface/product';
|
|
3
|
+
import { ArrowDownSVG, ArrowUpSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
4
|
+
import { TEST_IDS } from '../constants.js';
|
|
5
|
+
import { renderToolbarAfterOverflowButton } from './renderToolbarAfterOverflowButton.js';
|
|
6
|
+
export function renderTableSortingOverflowButton({ ariaLabel, onClick, selectedSortId, currentSortDesc, }) {
|
|
7
|
+
let SortIcon = SortSVG;
|
|
8
|
+
if (selectedSortId) {
|
|
9
|
+
SortIcon = currentSortDesc ? ArrowDownSVG : ArrowUpSVG;
|
|
10
|
+
}
|
|
11
|
+
return renderToolbarAfterOverflowButton({
|
|
12
|
+
'aria-label': ariaLabel,
|
|
13
|
+
icon: _jsx(SortIcon, {}),
|
|
14
|
+
onClick,
|
|
15
|
+
'data-test-id': TEST_IDS.viewSort.overflowTrigger,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { isMobileLayout, useAdaptiveLayout } from '@cloud-ru/ds-adaptive';
|
|
3
2
|
import { ArrowDownSVG, ArrowUpSVG, UpdateSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
4
3
|
import { ITEM_TYPE } from '@cloud-ru/ds-list';
|
|
5
4
|
import { useCallback, useMemo } from 'react';
|
|
@@ -13,8 +12,6 @@ import { createColumnDefMap, getHeaderLabel, groupHeadersByPinned } from './util
|
|
|
13
12
|
const SERVICE_COLUMN_IDS = new Set([DefaultColumns.Selection, DefaultColumns.RowActions, TREE_CELL_ID]);
|
|
14
13
|
export function useTableSorting({ table, sorting: sortingProp, columnDefinitions, enabledColumns, areColumnsSettingsEnabled = false, }) {
|
|
15
14
|
const { t } = tableLocale.useTranslations();
|
|
16
|
-
const { layoutType } = useAdaptiveLayout();
|
|
17
|
-
const isMobile = isMobileLayout(layoutType);
|
|
18
15
|
const sorting = sortingProp ?? table.getState().sorting;
|
|
19
16
|
const columnDefMap = useMemo(() => createColumnDefMap(columnDefinitions), [columnDefinitions]);
|
|
20
17
|
const hiddenColumnsBySettings = useMemo(() => {
|
|
@@ -158,14 +155,14 @@ export function useTableSorting({ table, sorting: sortingProp, columnDefinitions
|
|
|
158
155
|
];
|
|
159
156
|
const mainGroup = {
|
|
160
157
|
type: ITEM_TYPE.Group,
|
|
161
|
-
label:
|
|
158
|
+
label: t('sort'),
|
|
162
159
|
items: groups,
|
|
163
160
|
};
|
|
164
161
|
return {
|
|
165
162
|
items: [mainGroup],
|
|
166
163
|
pinBottom: clearItem,
|
|
167
164
|
};
|
|
168
|
-
}, [groupSortableHeadersByPinned, createSortItem, sorting, handleClearSort, t
|
|
165
|
+
}, [groupSortableHeadersByPinned, createSortItem, sorting, handleClearSort, t]);
|
|
169
166
|
const handleSelectionChange = useCallback((selectedId) => {
|
|
170
167
|
const id = String(selectedId);
|
|
171
168
|
const match = id.match(/^sort-(.+)$/);
|
|
@@ -18,9 +18,7 @@ export type TableSortingToolbarSlotParams<TData extends object> = TableSortingPr
|
|
|
18
18
|
};
|
|
19
19
|
export type TableSortingToolbarSlotResult = {
|
|
20
20
|
afterContent: ReactNode;
|
|
21
|
+
mobileMount: ReactNode;
|
|
21
22
|
};
|
|
22
|
-
/**
|
|
23
|
-
* Слот сортировки в тулбаре: `afterContent` — в `pinnedAfter`, поэтому на mobile кнопка остаётся в строке
|
|
24
|
-
* тулбара. Список открывается в `BottomSheet` (surface-swap `Droplist`).
|
|
25
|
-
*/
|
|
23
|
+
/** Слот сортировки в тулбаре: `afterContent` — в `after`, `mobileMount` — BottomSheet вне строки тулбара. */
|
|
26
24
|
export declare function useTableSortingToolbarSlot<TData extends object>({ enabled, table, sorting, columnDefinitions, enabledColumns, areColumnsSettingsEnabled, }: TableSortingToolbarSlotParams<TData>): TableSortingToolbarSlotResult;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { isMobileLayout, useAdaptiveLayout } from '@cloud-ru/ds-adaptive';
|
|
2
3
|
import { APPEARANCE, Button, VIEW as BUTTON_VIEW } from '@cloud-ru/ds-button';
|
|
3
4
|
import { SortSVG } from '@cloud-ru/ds-icons/interface/product';
|
|
4
5
|
import { ArrowDownSVG, ArrowUpSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
5
6
|
import { Droplist } from '@cloud-ru/ds-list';
|
|
6
7
|
import { useState } from 'react';
|
|
7
8
|
import { TEST_IDS } from '../../constants.js';
|
|
9
|
+
import { renderTableSortingOverflowButton } from '../../helpers/index.js';
|
|
8
10
|
import { tableLocale } from '../../locale/index.js';
|
|
9
11
|
import { useTableSorting } from '../useTableSorting/index.js';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* тулбара. Список открывается в `BottomSheet` (surface-swap `Droplist`).
|
|
13
|
-
*/
|
|
12
|
+
import styles from './useTableSortingToolbarSlot.module.css';
|
|
13
|
+
/** Слот сортировки в тулбаре: `afterContent` — в `after`, `mobileMount` — BottomSheet вне строки тулбара. */
|
|
14
14
|
export function useTableSortingToolbarSlot({ enabled = true, table, sorting, columnDefinitions, enabledColumns, areColumnsSettingsEnabled = false, }) {
|
|
15
15
|
const { t } = tableLocale.useTranslations();
|
|
16
|
+
const { layoutType } = useAdaptiveLayout();
|
|
17
|
+
const isMobile = isMobileLayout(layoutType);
|
|
16
18
|
const [open, setOpen] = useState(false);
|
|
17
19
|
const { items, pinBottom, selection, currentSort, selectedSortId, handleClearSort } = useTableSorting({
|
|
18
20
|
table,
|
|
@@ -21,9 +23,6 @@ export function useTableSortingToolbarSlot({ enabled = true, table, sorting, col
|
|
|
21
23
|
enabledColumns,
|
|
22
24
|
areColumnsSettingsEnabled,
|
|
23
25
|
});
|
|
24
|
-
if (!enabled) {
|
|
25
|
-
return { afterContent: null };
|
|
26
|
-
}
|
|
27
26
|
const handleClear = () => {
|
|
28
27
|
handleClearSort();
|
|
29
28
|
setOpen(false);
|
|
@@ -33,7 +32,20 @@ export function useTableSortingToolbarSlot({ enabled = true, table, sorting, col
|
|
|
33
32
|
if (currentSort) {
|
|
34
33
|
SortIcon = currentSort.desc ? ArrowDownSVG : ArrowUpSVG;
|
|
35
34
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
const droplist = (_jsx(Droplist, { scroll: true, items: items, selection: selection, virtualized: items.length > 10, pinBottom: clearItem, open: open, onOpenChange: setOpen, label: t('sort'), "data-test-id": TEST_IDS.viewSort.droplist, children: isMobile ? (_jsx("span", { className: styles.hiddenTrigger, "aria-hidden": true })) : (_jsx(Button, { size: 'm', view: BUTTON_VIEW.Function, icon: _jsx(SortIcon, {}), appearance: selectedSortId ? APPEARANCE.Primary : APPEARANCE.Neutral, "data-test-id": TEST_IDS.viewSort.droplistTrigger })) }));
|
|
36
|
+
if (!enabled) {
|
|
37
|
+
return { afterContent: null, mobileMount: null };
|
|
38
|
+
}
|
|
39
|
+
if (isMobile) {
|
|
40
|
+
return {
|
|
41
|
+
afterContent: renderTableSortingOverflowButton({
|
|
42
|
+
ariaLabel: t('sort'),
|
|
43
|
+
onClick: () => setOpen(true),
|
|
44
|
+
selectedSortId,
|
|
45
|
+
currentSortDesc: currentSort?.desc,
|
|
46
|
+
}),
|
|
47
|
+
mobileMount: droplist,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return { afterContent: droplist, mobileMount: null };
|
|
39
51
|
}
|
package/dist/esm/style.css
CHANGED
|
@@ -1642,4 +1642,12 @@
|
|
|
1642
1642
|
}
|
|
1643
1643
|
.clearSortItem[data-disabled=true] svg{
|
|
1644
1644
|
color:var(--sn-theme-color-available-version-textDisabled, var(--sn-brand-color-text-version-disabled, rgba(0, 0, 0, 0.3803921569)));
|
|
1645
|
+
}
|
|
1646
|
+
.hiddenTrigger{
|
|
1647
|
+
position:absolute;
|
|
1648
|
+
overflow:hidden;
|
|
1649
|
+
width:1px;
|
|
1650
|
+
height:1px;
|
|
1651
|
+
white-space:nowrap;
|
|
1652
|
+
clip-path:rect(0, 0, 0, 0);
|
|
1645
1653
|
}
|