@cloud-ru/ds-table 1.0.2-preview-ad4a761f.0 → 1.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 +4 -0
- package/README.md +3 -3
- package/dist/cjs/components/Table/Table.js +4 -12
- package/dist/cjs/components/Table/hooks/useColumnOrderByDrag/useColumnOrderByDrag.d.ts +0 -2
- package/dist/cjs/components/Table/hooks/useColumnOrderByDrag/useColumnOrderByDrag.js +3 -20
- package/dist/cjs/components/Table/hooks/useColumnSettings/utils/createColumnsSettingsOption.d.ts +2 -2
- package/dist/cjs/components/Table/hooks/useColumnSettings/utils/createColumnsSettingsOption.js +2 -2
- package/dist/cjs/components/Table/hooks/useColumnSettings/utils/index.d.ts +0 -1
- package/dist/cjs/components/Table/hooks/useColumnSettings/utils/index.js +0 -1
- package/dist/cjs/components/Table/hooks/useColumnSettings/utils/isColumnEnabledInitially.js +4 -3
- package/dist/cjs/components/Table/hooks/useColumnSettings/utils/isColumnVisibilityConfigurable.js +15 -3
- package/dist/cjs/components/Table/hooks/useColumnSettings/utils/isFilterableColumn.js +2 -4
- package/dist/cjs/components/Table/hooks/useTableScroll.js +1 -15
- package/dist/cjs/components/Table/styles.module.css +1 -19
- package/dist/cjs/components/Table/utils/index.d.ts +0 -1
- package/dist/cjs/components/Table/utils/index.js +0 -1
- package/dist/cjs/constants.d.ts +1 -1
- package/dist/cjs/constants.js +1 -1
- package/dist/cjs/helperComponents/Cells/BodyCell/BodyCell.d.ts +1 -3
- package/dist/cjs/helperComponents/Cells/BodyCell/BodyCell.js +10 -9
- package/dist/cjs/helperComponents/Cells/HeaderCell/HeaderCell.js +6 -7
- package/dist/cjs/helperComponents/Cells/HeaderCell/ResizeHandle.js +1 -1
- package/dist/cjs/helperComponents/Cells/styles.module.css +0 -3
- package/dist/cjs/helperComponents/Rows/BodyRow.js +2 -1
- package/dist/cjs/helperComponents/Rows/styles.module.css +0 -4
- package/dist/cjs/helperComponents/TableEmptyState/hooks.js +1 -0
- package/dist/cjs/helperComponents/TableEmptyState/styles.module.css +1 -3
- package/dist/cjs/hooks/index.d.ts +0 -1
- package/dist/cjs/hooks/index.js +0 -1
- package/dist/cjs/hooks/useCellSizes.d.ts +1 -0
- package/dist/cjs/hooks/useCellSizes.js +4 -1
- package/dist/cjs/locale/index.d.ts +4 -0
- package/dist/cjs/locale/index.js +2 -0
- package/dist/cjs/style.css +2 -29
- package/dist/cjs/types.d.ts +0 -1
- package/dist/esm/components/Table/Table.js +7 -15
- package/dist/esm/components/Table/hooks/useColumnOrderByDrag/useColumnOrderByDrag.d.ts +0 -2
- package/dist/esm/components/Table/hooks/useColumnOrderByDrag/useColumnOrderByDrag.js +4 -21
- package/dist/esm/components/Table/hooks/useColumnSettings/utils/createColumnsSettingsOption.d.ts +2 -2
- package/dist/esm/components/Table/hooks/useColumnSettings/utils/createColumnsSettingsOption.js +2 -2
- package/dist/esm/components/Table/hooks/useColumnSettings/utils/index.d.ts +0 -1
- package/dist/esm/components/Table/hooks/useColumnSettings/utils/index.js +0 -1
- package/dist/esm/components/Table/hooks/useColumnSettings/utils/isColumnEnabledInitially.js +4 -3
- package/dist/esm/components/Table/hooks/useColumnSettings/utils/isColumnVisibilityConfigurable.js +15 -3
- package/dist/esm/components/Table/hooks/useColumnSettings/utils/isFilterableColumn.js +2 -4
- package/dist/esm/components/Table/hooks/useTableScroll.js +1 -15
- package/dist/esm/components/Table/styles.module.css +1 -19
- package/dist/esm/components/Table/utils/index.d.ts +0 -1
- package/dist/esm/components/Table/utils/index.js +0 -1
- package/dist/esm/constants.d.ts +1 -1
- package/dist/esm/constants.js +1 -1
- package/dist/esm/helperComponents/Cells/BodyCell/BodyCell.d.ts +1 -3
- package/dist/esm/helperComponents/Cells/BodyCell/BodyCell.js +11 -10
- package/dist/esm/helperComponents/Cells/HeaderCell/HeaderCell.js +6 -7
- package/dist/esm/helperComponents/Cells/HeaderCell/ResizeHandle.js +1 -1
- package/dist/esm/helperComponents/Cells/styles.module.css +0 -3
- package/dist/esm/helperComponents/Rows/BodyRow.js +2 -1
- package/dist/esm/helperComponents/Rows/styles.module.css +0 -4
- package/dist/esm/helperComponents/TableEmptyState/hooks.js +1 -0
- package/dist/esm/helperComponents/TableEmptyState/styles.module.css +1 -3
- package/dist/esm/hooks/index.d.ts +0 -1
- package/dist/esm/hooks/index.js +0 -1
- package/dist/esm/hooks/useCellSizes.d.ts +1 -0
- package/dist/esm/hooks/useCellSizes.js +4 -1
- package/dist/esm/locale/index.d.ts +4 -0
- package/dist/esm/locale/index.js +2 -0
- package/dist/esm/style.css +2 -29
- package/dist/esm/types.d.ts +0 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +20 -21
- package/src/components/Table/Table.tsx +26 -53
- package/src/components/Table/hooks/useColumnOrderByDrag/useColumnOrderByDrag.ts +7 -31
- package/src/components/Table/hooks/useColumnSettings/utils/createColumnsSettingsOption.ts +2 -2
- package/src/components/Table/hooks/useColumnSettings/utils/index.ts +0 -1
- package/src/components/Table/hooks/useColumnSettings/utils/isColumnEnabledInitially.ts +5 -3
- package/src/components/Table/hooks/useColumnSettings/utils/isColumnVisibilityConfigurable.ts +18 -3
- package/src/components/Table/hooks/useColumnSettings/utils/isFilterableColumn.ts +2 -4
- package/src/components/Table/hooks/useTableScroll.ts +1 -21
- package/src/components/Table/styles.module.scss +1 -23
- package/src/components/Table/utils/index.ts +0 -1
- package/src/constants.ts +1 -1
- package/src/helperComponents/Cells/BodyCell/BodyCell.tsx +15 -18
- package/src/helperComponents/Cells/HeaderCell/HeaderCell.tsx +7 -10
- package/src/helperComponents/Cells/HeaderCell/ResizeHandle.tsx +2 -1
- package/src/helperComponents/Cells/styles.module.scss +0 -11
- package/src/helperComponents/Rows/BodyRow.tsx +10 -9
- package/src/helperComponents/Rows/styles.module.scss +0 -5
- package/src/helperComponents/TableEmptyState/hooks.ts +1 -0
- package/src/helperComponents/TableEmptyState/styles.module.scss +1 -5
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useCellSizes.ts +5 -1
- package/src/locale/index.ts +2 -0
- package/src/types.ts +5 -3
- package/dist/cjs/components/Table/hooks/useColumnSettings/utils/getColumnSettingsMode.d.ts +0 -8
- package/dist/cjs/components/Table/hooks/useColumnSettings/utils/getColumnSettingsMode.js +0 -15
- package/dist/cjs/components/Table/utils/alignOverlayToHeader.d.ts +0 -6
- package/dist/cjs/components/Table/utils/alignOverlayToHeader.js +0 -28
- package/dist/cjs/hooks/useColumnDragTransform.d.ts +0 -15
- package/dist/cjs/hooks/useColumnDragTransform.js +0 -38
- package/dist/esm/components/Table/hooks/useColumnSettings/utils/getColumnSettingsMode.d.ts +0 -8
- package/dist/esm/components/Table/hooks/useColumnSettings/utils/getColumnSettingsMode.js +0 -11
- package/dist/esm/components/Table/utils/alignOverlayToHeader.d.ts +0 -6
- package/dist/esm/components/Table/utils/alignOverlayToHeader.js +0 -24
- package/dist/esm/hooks/useColumnDragTransform.d.ts +0 -15
- package/dist/esm/hooks/useColumnDragTransform.js +0 -35
- package/src/components/Table/hooks/useColumnSettings/utils/getColumnSettingsMode.ts +0 -18
- package/src/components/Table/utils/alignOverlayToHeader.ts +0 -36
- package/src/hooks/useColumnDragTransform.ts +0 -52
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
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
|
+
## 1.0.2 (2026-08-20)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @ds/table
|
|
9
|
+
|
|
6
10
|
## 1.0.1 (2026-08-18)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @ds/table
|
package/README.md
CHANGED
|
@@ -254,13 +254,13 @@ Bulk-бар в тулбаре (чекбокс «выбрать все» и сч
|
|
|
254
254
|
- `enableDrag` — переупорядочивание колонок: перетаскивание заголовков в таблице и строк в меню настроек (через `onItemsReorder` у `@cloud-ru/ds-list`). Оба канала пишут в один и тот же `columnOrder`.
|
|
255
255
|
- `enableSettingsMenu` — меню видимости колонок в тулбаре.
|
|
256
256
|
|
|
257
|
-
Поведение колонки в меню задаётся на самой колонке через `columnSettings.mode` (ось `COLUMN_SETTINGS_MODE`)
|
|
257
|
+
Поведение колонки в меню задаётся на самой колонке через `columnSettings.mode` (ось `COLUMN_SETTINGS_MODE`):
|
|
258
258
|
|
|
259
259
|
- `locked` — колонка есть в меню, но строка disabled (всегда видима, свитч нельзя выключить).
|
|
260
|
-
- `defaultVisible` — в меню, по умолчанию включена.
|
|
260
|
+
- `defaultVisible` — в меню, по умолчанию включена.
|
|
261
261
|
- `defaultHidden` — в меню, по умолчанию выключена.
|
|
262
262
|
|
|
263
|
-
`columnSettings.label` — название колонки в меню
|
|
263
|
+
`columnSettings.label` — название колонки в меню настроек. Колонки без `columnSettings` тоже показываются в меню (disabled, label из `header`); исключение — служебные `selection` / `rowActions`.
|
|
264
264
|
|
|
265
265
|
`savedState` сохраняет состояние таблицы в localStorage и query-параметрах: `id` обязан быть уникальным в рамках приложения; `resize` / `columnSettings` включают сохранение ширин и видимости колонок; `serializer` / `parser` / `filterQueryKey` настраивают сериализацию фильтров.
|
|
266
266
|
|
|
@@ -8,11 +8,9 @@ exports.Table = Table;
|
|
|
8
8
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
9
|
const core_1 = require("@dnd-kit/core");
|
|
10
10
|
const adaptive_1 = require("@cloud-ru/ds-adaptive");
|
|
11
|
-
const drag_and_drop_1 = require("@cloud-ru/ds-drag-and-drop");
|
|
12
11
|
const materials_1 = require("@cloud-ru/ds-materials");
|
|
13
12
|
const theme_1 = require("@cloud-ru/ds-theme");
|
|
14
13
|
const utils_1 = require("@cloud-ru/ds-utils");
|
|
15
|
-
const react_table_1 = require("@tanstack/react-table");
|
|
16
14
|
const classnames_1 = __importDefault(require("classnames"));
|
|
17
15
|
const react_1 = require("react");
|
|
18
16
|
const constants_1 = require("../../constants");
|
|
@@ -107,7 +105,7 @@ function Table({ data, rowPinning = {
|
|
|
107
105
|
onSortingChange([]);
|
|
108
106
|
}
|
|
109
107
|
}, [areColumnsSettingsEnabled, enabledColumns, hideableColumnIds, onSortingChange, sorting]);
|
|
110
|
-
const { columnOrder, setColumnOrder, dndContextProps, enableColumnsOrderSortByDrag
|
|
108
|
+
const { columnOrder, setColumnOrder, dndContextProps, enableColumnsOrderSortByDrag } = (0, hooks_1.useColumnOrderByDrag)({
|
|
111
109
|
tableColumns: allTableColumns,
|
|
112
110
|
savedState,
|
|
113
111
|
columnSettings: columnsSettingsProp,
|
|
@@ -266,12 +264,6 @@ function Table({ data, rowPinning = {
|
|
|
266
264
|
// но скрывает при dataError. Загрузка и непустое тело — шапка всегда.
|
|
267
265
|
const showTableHeader = showHeader &&
|
|
268
266
|
(isLoadingState || centerRows.length > 0 || filteredTopRows.length > 0 || (isEmptyBody && !dataError));
|
|
269
|
-
const draggingHeader = draggingColumnId
|
|
270
|
-
? table.getFlatHeaders().find(header => header.column.id === draggingColumnId)
|
|
271
|
-
: undefined;
|
|
272
|
-
// Копия колонки едет за курсором в портале: внутри скролла она растила бы его ширину
|
|
273
|
-
// и ныряла под закреплённые колонки.
|
|
274
|
-
const draggingColumnPreview = ((0, jsx_runtime_1.jsx)(core_1.DragOverlay, { dropAnimation: null, modifiers: [utils_3.alignOverlayToHeader], children: draggingHeader ? ((0, jsx_runtime_1.jsx)(drag_and_drop_1.DragPreview, { className: styles_module_scss_1.default.columnDragPreview, style: { width: `var(${constants_1.TABLE_COLUMN_CSS_VARS.size(draggingHeader.column.id)})` }, children: (0, react_table_1.flexRender)(draggingHeader.column.columnDef.header, draggingHeader.getContext()) })) : null }));
|
|
275
267
|
const tableHeaderElement = showTableHeader ? ((0, jsx_runtime_1.jsx)(helperComponents_1.HeaderRow, { rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, suppressSticky: usePageStickyHeader })) : null;
|
|
276
268
|
const tableRowsContent = ((0, jsx_runtime_1.jsx)(TableRowsBody_1.TableRowsBody, { filteredTopRows: filteredTopRows, centerRows: centerRows, rowVirtualizer: rowVirtualizer, columnOrder: columnOrder, rowAutoHeight: rowAutoHeight, onRowClick: onRowClick, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, rowSelectionAppearance: rowSelectionProp?.appearance, emptyState: tableEmptyState, showInfiniteLoadingTail: showInfiniteLoadingTail, loadingTableRows: loadingTableRows, loadMoreButton: loadMoreButtonNode }));
|
|
277
269
|
const cardsContentBody = ((0, jsx_runtime_1.jsx)(TableCardsBody_1.TableCardsBody, { filteredTopRows: filteredTopRows, centerRows: centerRows, table: table, headlineId: headlineId, cardSelection: cardSelection, rowSelectionAppearance: rowSelectionProp?.appearance, suppressHeader: suppressHeader, onRowClick: onRowClick, renderCard: renderCard, cardsListProps: cardsListProps, emptyState: tableEmptyState, showInfiniteLoadingTail: showInfiniteLoadingTail, loadingTableRows: loadingTableRows, loadingTable: loadingTable, loadMoreButton: loadMoreButtonNode }));
|
|
@@ -308,8 +300,8 @@ function Table({ data, rowPinning = {
|
|
|
308
300
|
const themeClassName = (0, theme_1.useThemeClassnames)({ density: isMobile ? 'comfort' : 'compact' });
|
|
309
301
|
const controlsAcrylic = (0, react_1.useMemo)(() => (isStickyControls ? (0, helperComponents_1.getControlsAcrylicAttrs)(stickyControlsBackgroundPredefined) : null), [isStickyControls, stickyControlsBackgroundPredefined]);
|
|
310
302
|
const scrollPaddingAbsolute = isStickyControls && !isCardsView;
|
|
311
|
-
const tableScrollContent = ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.body, "data-empty-body": isEmptyBody || undefined, style: columnSizes.vars, children: (0, jsx_runtime_1.jsx)(contexts_1.CellAutoResizeContext.Provider, { value: { updateCellMap, removeCellFromMap }, children: tableScrollRows }) }));
|
|
312
|
-
const tableContentWithProviders = ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.body, "data-empty-body": isEmptyBody || undefined, style: columnSizes.vars, children: (0, jsx_runtime_1.jsx)(contexts_1.CellAutoResizeContext.Provider, { value: { updateCellMap, removeCellFromMap }, children: tableBody }) }));
|
|
303
|
+
const tableScrollContent = ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.body, "data-empty-body": isEmptyBody || undefined, style: columnSizes.vars, children: (0, jsx_runtime_1.jsx)(contexts_1.CellAutoResizeContext.Provider, { value: { updateCellMap, removeCellFromMap }, children: (0, jsx_runtime_1.jsx)(core_1.DndContext, { ...dndContextProps, children: tableScrollRows }) }) }));
|
|
304
|
+
const tableContentWithProviders = ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.body, "data-empty-body": isEmptyBody || undefined, style: columnSizes.vars, children: (0, jsx_runtime_1.jsx)(contexts_1.CellAutoResizeContext.Provider, { value: { updateCellMap, removeCellFromMap }, children: (0, jsx_runtime_1.jsx)(core_1.DndContext, { ...dndContextProps, children: tableBody }) }) }));
|
|
313
305
|
let scrollContent = tableContentWithProviders;
|
|
314
306
|
if (isMobile && isCardsView) {
|
|
315
307
|
scrollContent = tableBody;
|
|
@@ -337,7 +329,7 @@ function Table({ data, rowPinning = {
|
|
|
337
329
|
paginationChrome =
|
|
338
330
|
isStickyControls && controlsAcrylic ? ((0, jsx_runtime_1.jsx)(TableChrome_1.TableChrome, { variant: 'footer', acrylic: controlsAcrylic, children: pagination })) : (pagination);
|
|
339
331
|
}
|
|
340
|
-
return ((0, jsx_runtime_1.jsx)("div", { ref: wrapperRef, className: (0, classnames_1.default)(styles_module_scss_1.default.wrapper, className, themeClassName), "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.
|
|
332
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: wrapperRef, className: (0, classnames_1.default)(styles_module_scss_1.default.wrapper, className, themeClassName), "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.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 }), !isCardsView && outline ? (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.contentBorder, "aria-hidden": true }) : null] }), paginationChrome] })] }) }));
|
|
341
333
|
}
|
|
342
334
|
Table.getStatusColumnDef = helperComponents_1.getStatusColumnDef;
|
|
343
335
|
Table.statusAppearances = helperComponents_1.STATUS_APPEARANCE;
|
|
@@ -12,7 +12,5 @@ export declare function useColumnOrderByDrag<TData extends object>({ tableColumn
|
|
|
12
12
|
setColumnOrder: Dispatch<SetStateAction<string[]>>;
|
|
13
13
|
dndContextProps: DndContextProps;
|
|
14
14
|
enableColumnsOrderSortByDrag: boolean;
|
|
15
|
-
/** Колонка под курсором прямо сейчас: по ней рендерится копия в портале. */
|
|
16
|
-
draggingColumnId?: string;
|
|
17
15
|
};
|
|
18
16
|
export {};
|
|
@@ -15,7 +15,6 @@ const draggingOptions = {
|
|
|
15
15
|
};
|
|
16
16
|
function useColumnOrderByDrag({ tableColumns, savedState, columnSettings, }) {
|
|
17
17
|
const [columnOrder, setColumnOrderState] = (0, react_1.useState)(() => (0, prepareInitialState_1.prepareInitialState)(tableColumns, savedState));
|
|
18
|
-
const [draggingColumnId, setDraggingColumnId] = (0, react_1.useState)();
|
|
19
18
|
(0, react_1.useEffect)(() => {
|
|
20
19
|
setColumnOrderState(prev => {
|
|
21
20
|
const currentIds = tableColumns
|
|
@@ -43,14 +42,7 @@ function useColumnOrderByDrag({ tableColumns, savedState, columnSettings, }) {
|
|
|
43
42
|
}
|
|
44
43
|
setColumnOrderState(updatedOrder);
|
|
45
44
|
}, [columnOrder, savedState]);
|
|
46
|
-
const handleDragStart = (0, react_1.useCallback)(({ active }) => {
|
|
47
|
-
setDraggingColumnId(String(active.id));
|
|
48
|
-
}, []);
|
|
49
|
-
const handleDragCancel = (0, react_1.useCallback)(() => {
|
|
50
|
-
setDraggingColumnId(undefined);
|
|
51
|
-
}, []);
|
|
52
45
|
const handleDragEnd = (0, react_1.useCallback)(({ active, over }) => {
|
|
53
|
-
setDraggingColumnId(undefined);
|
|
54
46
|
if (!active || !over) {
|
|
55
47
|
return;
|
|
56
48
|
}
|
|
@@ -68,32 +60,23 @@ function useColumnOrderByDrag({ tableColumns, savedState, columnSettings, }) {
|
|
|
68
60
|
return (0, sortable_1.arrayMove)(columnOrder, oldIndex, newIndex);
|
|
69
61
|
});
|
|
70
62
|
}, [columnOrder, setColumnOrder]);
|
|
71
|
-
|
|
72
|
-
// возвращается на место. Держим `over` внутри колонок сортировки.
|
|
73
|
-
const collisionDetection = (0, react_1.useCallback)(args => (0, core_1.closestCenter)({
|
|
74
|
-
...args,
|
|
75
|
-
droppableContainers: args.droppableContainers.filter(container => columnOrder.includes(String(container.id))),
|
|
76
|
-
}), [columnOrder]);
|
|
77
|
-
const sensors = (0, core_1.useSensors)((0, core_1.useSensor)(core_1.MouseSensor, draggingOptions), (0, core_1.useSensor)(core_1.TouchSensor, {}));
|
|
63
|
+
const sensors = (0, core_1.useSensors)((0, core_1.useSensor)(core_1.MouseSensor, draggingOptions), (0, core_1.useSensor)(core_1.TouchSensor, {}), (0, core_1.useSensor)(core_1.KeyboardSensor, {}));
|
|
78
64
|
const enableColumnsOrderSortByDrag = Boolean(columnSettings?.enableDrag);
|
|
79
65
|
const dndContextProps = (0, react_1.useMemo)(() => {
|
|
80
66
|
if (!enableColumnsOrderSortByDrag) {
|
|
81
67
|
return {};
|
|
82
68
|
}
|
|
83
69
|
return {
|
|
84
|
-
collisionDetection,
|
|
70
|
+
collisionDetection: core_1.closestCenter,
|
|
85
71
|
modifiers: [modifiers_1.restrictToHorizontalAxis],
|
|
86
|
-
onDragStart: handleDragStart,
|
|
87
|
-
onDragCancel: handleDragCancel,
|
|
88
72
|
onDragEnd: handleDragEnd,
|
|
89
73
|
sensors,
|
|
90
74
|
};
|
|
91
|
-
}, [
|
|
75
|
+
}, [enableColumnsOrderSortByDrag, handleDragEnd, sensors]);
|
|
92
76
|
return {
|
|
93
77
|
columnOrder,
|
|
94
78
|
setColumnOrder,
|
|
95
79
|
dndContextProps,
|
|
96
80
|
enableColumnsOrderSortByDrag,
|
|
97
|
-
draggingColumnId,
|
|
98
81
|
};
|
|
99
82
|
}
|
package/dist/cjs/components/Table/hooks/useColumnSettings/utils/createColumnsSettingsOption.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { SimpleItem } from '@cloud-ru/ds-list';
|
|
|
2
2
|
import { ColumnDefinition } from '../../../../../types';
|
|
3
3
|
/**
|
|
4
4
|
* Колонка попадает в меню настроек: есть id/accessorKey и это не selection/row-actions.
|
|
5
|
-
* Включая `mode: locked` (
|
|
5
|
+
* Включая `mode: locked` и колонки без `columnSettings` (они рендерятся disabled).
|
|
6
6
|
*/
|
|
7
7
|
export declare function isColumnsSettingsMenuItem<TData extends object>(colDef: ColumnDefinition<TData>): boolean;
|
|
8
8
|
/**
|
|
9
|
-
* Пункт меню настроек колонок. Неактивные (`mode: locked`
|
|
9
|
+
* Пункт меню настроек колонок. Неактивные (нет `columnSettings` / `mode: locked`) —
|
|
10
10
|
* `disabled` + всегда включённый switch (`checked: true`); драг при этом остаётся
|
|
11
11
|
* доступным. Видимость через `enabledColumns` не управляется.
|
|
12
12
|
*/
|
package/dist/cjs/components/Table/hooks/useColumnSettings/utils/createColumnsSettingsOption.js
CHANGED
|
@@ -10,7 +10,7 @@ const isFilterableColumn_1 = require("./isFilterableColumn");
|
|
|
10
10
|
const SETTINGS_MENU_EXCLUDED_IDS = new Set([constants_1.DefaultColumns.Selection, constants_1.DefaultColumns.RowActions]);
|
|
11
11
|
/**
|
|
12
12
|
* Колонка попадает в меню настроек: есть id/accessorKey и это не selection/row-actions.
|
|
13
|
-
* Включая `mode: locked` (
|
|
13
|
+
* Включая `mode: locked` и колонки без `columnSettings` (они рендерятся disabled).
|
|
14
14
|
*/
|
|
15
15
|
function isColumnsSettingsMenuItem(colDef) {
|
|
16
16
|
if (!('id' in colDef || 'accessorKey' in colDef)) {
|
|
@@ -31,7 +31,7 @@ function getColumnsSettingsOptionLabel(columnDefinition) {
|
|
|
31
31
|
return (0, utils_1.getColumnIdentifier)(columnDefinition);
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* Пункт меню настроек колонок. Неактивные (`mode: locked`
|
|
34
|
+
* Пункт меню настроек колонок. Неактивные (нет `columnSettings` / `mode: locked`) —
|
|
35
35
|
* `disabled` + всегда включённый switch (`checked: true`); драг при этом остаётся
|
|
36
36
|
* доступным. Видимость через `enabledColumns` не управляется.
|
|
37
37
|
*/
|
|
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./getColumnSettingsMode"), exports);
|
|
18
17
|
__exportStar(require("./isFilterableColumn"), exports);
|
|
19
18
|
__exportStar(require("./isColumnEnabledInitially"), exports);
|
|
20
19
|
__exportStar(require("./isColumnVisibilityConfigurable"), exports);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isColumnEnabledInitially = isColumnEnabledInitially;
|
|
4
|
-
const constants_1 = require("../../../../../constants");
|
|
5
|
-
const getColumnSettingsMode_1 = require("./getColumnSettingsMode");
|
|
6
4
|
/**
|
|
7
5
|
* Проверка на то, должна ли колонка быть включена по умолчанию
|
|
8
6
|
* @function isColumnEnabledInitially
|
|
9
7
|
*/
|
|
10
8
|
function isColumnEnabledInitially(colDef) {
|
|
11
|
-
|
|
9
|
+
if ('columnSettings' in colDef && colDef.columnSettings !== undefined) {
|
|
10
|
+
return colDef.columnSettings?.mode !== 'defaultHidden';
|
|
11
|
+
}
|
|
12
|
+
return true;
|
|
12
13
|
}
|
package/dist/cjs/components/Table/hooks/useColumnSettings/utils/isColumnVisibilityConfigurable.js
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isColumnVisibilityConfigurable = isColumnVisibilityConfigurable;
|
|
4
|
-
const constants_1 = require("../../../../../constants");
|
|
5
|
-
const getColumnSettingsMode_1 = require("./getColumnSettingsMode");
|
|
6
4
|
/**
|
|
7
5
|
* Проверка на то, должна ли колонка отображаться в настройках колонок
|
|
8
6
|
* @function isColumnVisibilityConfigurable
|
|
9
7
|
*/
|
|
10
8
|
function isColumnVisibilityConfigurable(colDef) {
|
|
11
|
-
|
|
9
|
+
if ('columnSettings' in colDef && colDef.columnSettings !== undefined) {
|
|
10
|
+
const { mode } = colDef.columnSettings;
|
|
11
|
+
if (!mode) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
switch (mode) {
|
|
15
|
+
case 'locked':
|
|
16
|
+
return false;
|
|
17
|
+
case 'defaultVisible':
|
|
18
|
+
case 'defaultHidden':
|
|
19
|
+
default:
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
12
24
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isFilterableColumn = isFilterableColumn;
|
|
4
|
-
const constants_1 = require("../../../../../constants");
|
|
5
|
-
const getColumnSettingsMode_1 = require("./getColumnSettingsMode");
|
|
6
4
|
/**
|
|
7
5
|
* Проверка на то, должна ли колонка отображаться в таблице
|
|
8
6
|
* @function isFilterableColumn
|
|
9
7
|
*/
|
|
10
8
|
function isFilterableColumn(colDef) {
|
|
11
9
|
return (('id' in colDef || 'accessorKey' in colDef) &&
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
'columnSettings' in colDef &&
|
|
11
|
+
colDef.columnSettings?.mode !== 'locked');
|
|
14
12
|
}
|
|
@@ -34,6 +34,7 @@ function useTableScroll({ usePageStickyHeader, isStickyControls, stickyControlsO
|
|
|
34
34
|
const wrapper = wrapperRef.current;
|
|
35
35
|
if (!usePageStickyHeader) {
|
|
36
36
|
wrapper?.style.removeProperty(constants_1.TABLE_CSS_VARS.headerScrollLeft);
|
|
37
|
+
wrapper?.style.removeProperty(constants_1.TABLE_CSS_VARS.viewportWidth);
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
40
|
const viewport = internalScrollRef.current;
|
|
@@ -45,21 +46,6 @@ function useTableScroll({ usePageStickyHeader, isStickyControls, stickyControlsO
|
|
|
45
46
|
observer.observe(viewport);
|
|
46
47
|
return () => observer.disconnect();
|
|
47
48
|
}, [usePageStickyHeader, isScrollReady, columnSizeVars, syncHeaderHorizontalScroll, view, isLoadingState]);
|
|
48
|
-
// Ширина вьюпорта нужна не только sticky-шапке: по ней центрируется пустое состояние.
|
|
49
|
-
(0, utils_1.useLayoutEffect)(() => {
|
|
50
|
-
const wrapper = wrapperRef.current;
|
|
51
|
-
const viewport = internalScrollRef.current;
|
|
52
|
-
if (!wrapper || !viewport) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const syncViewportWidth = () => {
|
|
56
|
-
wrapper.style.setProperty(constants_1.TABLE_CSS_VARS.viewportWidth, `${viewport.clientWidth}px`);
|
|
57
|
-
};
|
|
58
|
-
syncViewportWidth();
|
|
59
|
-
const observer = new ResizeObserver(syncViewportWidth);
|
|
60
|
-
observer.observe(viewport);
|
|
61
|
-
return () => observer.disconnect();
|
|
62
|
-
}, [isScrollReady, usePageStickyHeader, view, isCardsView, isLoadingState]);
|
|
63
49
|
(0, utils_1.useLayoutEffect)(() => {
|
|
64
50
|
if (!usePageStickyHeader || !showToolbar) {
|
|
65
51
|
wrapperRef.current?.style.removeProperty(constants_1.TABLE_CSS_VARS.stickyToolbarOffset);
|
|
@@ -442,8 +442,7 @@
|
|
|
442
442
|
flex:1 1 auto;
|
|
443
443
|
flex-direction:column;
|
|
444
444
|
width:100%;
|
|
445
|
-
min-width
|
|
446
|
-
min-width:max-content;
|
|
445
|
+
min-width:0;
|
|
447
446
|
min-height:100%;
|
|
448
447
|
}
|
|
449
448
|
|
|
@@ -576,21 +575,4 @@
|
|
|
576
575
|
flex:1 1 auto;
|
|
577
576
|
width:100%;
|
|
578
577
|
max-width:100%;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
.columnDragPreview{
|
|
582
|
-
display:flex;
|
|
583
|
-
align-items:center;
|
|
584
|
-
box-sizing:border-box;
|
|
585
|
-
height:var(--sn-table-anatomy-content-tableCell-minHeight, var(--sn-primitive-dimension-40, 40px));
|
|
586
|
-
padding:var(--sn-table-anatomy-content-tableHead-paddingTop, var(--sn-primitive-dimension-6, 6px)) var(--sn-table-anatomy-content-tableHead-paddingRight, var(--sn-primitive-dimension-12, 12px)) var(--sn-table-anatomy-content-tableHead-paddingBottom, var(--sn-primitive-dimension-6, 6px)) var(--sn-table-anatomy-content-tableHead-paddingLeft, var(--sn-primitive-dimension-12, 12px));
|
|
587
|
-
border-radius:var(--sn-table-anatomy-content-borderRadius, var(--sn-brand-anatomy-radius-table-m, var(--sn-primitive-dimension-4, 4px)));
|
|
588
|
-
color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(65, 66, 78, 0.5490196078)));
|
|
589
|
-
white-space:nowrap;
|
|
590
|
-
font-family:var(--sn-regular-body-m-fontFamily, var(--sn-brand-font-fontFamily-regular-body, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
|
|
591
|
-
font-weight:var(--sn-regular-body-m-fontWeight, var(--sn-theme-typography-fontWeight-regular-body-m, var(--sn-brand-font-fontWeight-light-regular-body-m, var(--sn-primitive-font-fontWeightValue-400, 400))));
|
|
592
|
-
line-height:var(--sn-regular-body-m-lineHeight, var(--sn-density-typography-roleBody-lineHeightM, var(--sn-primitive-font-lineHeight-by16, 24px)));
|
|
593
|
-
font-size:var(--sn-regular-body-m-fontSize, var(--sn-density-typography-roleBody-fontSizeM, var(--sn-primitive-font-fontSize-16, 16px)));
|
|
594
|
-
letter-spacing:var(--sn-regular-body-m-letterSpacing, var(--sn-primitive-font-letterSpacing-m, 0.1px));
|
|
595
|
-
paragraph-spacing:var(--sn-regular-body-m-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize14, 7px));
|
|
596
578
|
}
|
|
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./alignOverlayToHeader"), exports);
|
|
18
17
|
__exportStar(require("./columnSize"), exports);
|
|
19
18
|
__exportStar(require("./getColumnIdentifier"), exports);
|
|
20
19
|
__exportStar(require("./getColumnStyleVars"), exports);
|
package/dist/cjs/constants.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare const COLUMN_ALIGN: {
|
|
|
10
10
|
export declare const COLUMN_SETTINGS_MODE: {
|
|
11
11
|
/** В меню настроек `Switch` заблокирован, колонка всегда видима */
|
|
12
12
|
readonly Locked: "locked";
|
|
13
|
-
/** В меню, по умолчанию
|
|
13
|
+
/** В меню, по умолчанию включена */
|
|
14
14
|
readonly DefaultVisible: "defaultVisible";
|
|
15
15
|
/** В меню, по умолчанию выключена */
|
|
16
16
|
readonly DefaultHidden: "defaultHidden";
|
package/dist/cjs/constants.js
CHANGED
|
@@ -12,7 +12,7 @@ exports.COLUMN_ALIGN = {
|
|
|
12
12
|
exports.COLUMN_SETTINGS_MODE = {
|
|
13
13
|
/** В меню настроек `Switch` заблокирован, колонка всегда видима */
|
|
14
14
|
Locked: 'locked',
|
|
15
|
-
/** В меню, по умолчанию
|
|
15
|
+
/** В меню, по умолчанию включена */
|
|
16
16
|
DefaultVisible: 'defaultVisible',
|
|
17
17
|
/** В меню, по умолчанию выключена */
|
|
18
18
|
DefaultHidden: 'defaultHidden',
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { Cell as TableCell } from '@tanstack/react-table';
|
|
2
|
-
import { ColumnOrder } from '../../../types';
|
|
3
2
|
import { CellProps } from '../Cell';
|
|
4
3
|
type BodyCellProps<TData> = Omit<CellProps, 'style' | 'children'> & {
|
|
5
4
|
cell: TableCell<TData, unknown>;
|
|
6
5
|
rowAutoHeight?: boolean;
|
|
7
6
|
isDraggable?: boolean;
|
|
8
|
-
columnOrder?: ColumnOrder;
|
|
9
7
|
};
|
|
10
|
-
export declare function BodyCell<TData>({ isDraggable,
|
|
8
|
+
export declare function BodyCell<TData>({ isDraggable, ...props }: BodyCellProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
11
9
|
export {};
|
|
@@ -5,28 +5,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.BodyCell = BodyCell;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const sortable_1 = require("@dnd-kit/sortable");
|
|
8
9
|
const react_table_1 = require("@tanstack/react-table");
|
|
9
10
|
const classnames_1 = __importDefault(require("classnames"));
|
|
10
11
|
const constants_1 = require("../../../constants");
|
|
11
12
|
const hooks_1 = require("../../../hooks");
|
|
12
13
|
const Cell_1 = require("../Cell");
|
|
13
14
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
14
|
-
function BodyCellView({ cell, className, rowAutoHeight, style,
|
|
15
|
+
function BodyCellView({ cell, className, rowAutoHeight, style, setNodeRef, ...props }) {
|
|
15
16
|
const columnDef = cell.column.columnDef;
|
|
16
|
-
return ((0, jsx_runtime_1.jsx)(Cell_1.Cell, { ...props, style: style, className: (0, classnames_1.default)(styles_module_scss_1.default.tableBodyCell, className, columnDef.cellClassName), "data-row-auto-height": rowAutoHeight || undefined, "data-align": columnDef.align, "data-no-padding": columnDef.noBodyCellPadding || undefined, "data-column-id": cell.column.id, "data-
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(Cell_1.Cell, { ...props, ref: setNodeRef, style: style, className: (0, classnames_1.default)(styles_module_scss_1.default.tableBodyCell, className, columnDef.cellClassName), "data-row-auto-height": rowAutoHeight || undefined, "data-align": columnDef.align, "data-no-padding": columnDef.noBodyCellPadding || undefined, "data-column-id": cell.column.id, "data-test-id": constants_1.TEST_IDS.bodyCell, children: (0, react_table_1.flexRender)(columnDef.cell, cell.getContext()) }));
|
|
17
18
|
}
|
|
18
19
|
function StaticBodyCell(props) {
|
|
19
20
|
const style = (0, hooks_1.useCellSizes)(props.cell);
|
|
20
21
|
return (0, jsx_runtime_1.jsx)(BodyCellView, { ...props, style: style });
|
|
21
22
|
}
|
|
22
|
-
function DraggableBodyCell(
|
|
23
|
-
const {
|
|
24
|
-
const style = (0, hooks_1.useCellSizes)(props.cell, { isDraggable: true, transform });
|
|
25
|
-
return (0, jsx_runtime_1.jsx)(BodyCellView, { ...props, style: style,
|
|
23
|
+
function DraggableBodyCell(props) {
|
|
24
|
+
const { setNodeRef, isDragging, transform } = (0, sortable_1.useSortable)({ id: props.cell.column.id });
|
|
25
|
+
const style = (0, hooks_1.useCellSizes)(props.cell, { isDraggable: true, isDragging, transform });
|
|
26
|
+
return (0, jsx_runtime_1.jsx)(BodyCellView, { ...props, style: style, setNodeRef: setNodeRef });
|
|
26
27
|
}
|
|
27
|
-
function BodyCell({ isDraggable,
|
|
28
|
-
if (isDraggable
|
|
29
|
-
return (0, jsx_runtime_1.jsx)(DraggableBodyCell, { ...props
|
|
28
|
+
function BodyCell({ isDraggable, ...props }) {
|
|
29
|
+
if (isDraggable) {
|
|
30
|
+
return (0, jsx_runtime_1.jsx)(DraggableBodyCell, { ...props });
|
|
30
31
|
}
|
|
31
32
|
return (0, jsx_runtime_1.jsx)(StaticBodyCell, { ...props });
|
|
32
33
|
}
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.HeaderCell = HeaderCell;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const sortable_1 = require("@dnd-kit/sortable");
|
|
9
|
-
const drag_and_drop_1 = require("@cloud-ru/ds-drag-and-drop");
|
|
10
9
|
const truncate_string_1 = require("@cloud-ru/ds-truncate-string");
|
|
11
10
|
const react_table_1 = require("@tanstack/react-table");
|
|
12
11
|
const classnames_1 = __importDefault(require("classnames"));
|
|
@@ -27,8 +26,8 @@ function HeaderCell({ header, pinPosition, className, rowAutoHeight, isDraggable
|
|
|
27
26
|
const columnSizingInfo = header.getContext().table.getState().columnSizingInfo;
|
|
28
27
|
const isSomeColumnResizing = columnSizingInfo.isResizingColumn;
|
|
29
28
|
const columnDef = header.column.columnDef;
|
|
30
|
-
const { listeners, setNodeRef, isDragging, transform } = (0, sortable_1.useSortable)({ id: header.column.id });
|
|
31
|
-
const style = (0, hooks_1.useCellSizes)(header, { isDraggable, transform });
|
|
29
|
+
const { attributes, listeners, setNodeRef, isDragging, transform } = (0, sortable_1.useSortable)({ id: header.column.id });
|
|
30
|
+
const style = (0, hooks_1.useCellSizes)(header, { isDraggable, isDragging, transform });
|
|
32
31
|
const sortingHandler = (e) => {
|
|
33
32
|
if (isSomeColumnResizing)
|
|
34
33
|
return;
|
|
@@ -39,12 +38,12 @@ function HeaderCell({ header, pinPosition, className, rowAutoHeight, isDraggable
|
|
|
39
38
|
if (!isDraggable || constants_1.DEFAULT_COLUMNS.includes(header.column.id)) {
|
|
40
39
|
return {};
|
|
41
40
|
}
|
|
42
|
-
return listeners;
|
|
43
|
-
}, [header.column.id, isDraggable, listeners]);
|
|
44
|
-
return ((0, jsx_runtime_1.jsxs)(Cell_1.Cell, { style: style, onClick: sortingHandler, "data-sortable": isSortable || undefined, "data-draggable": isDraggable || undefined, "data-no-padding": columnDef.noHeaderCellPadding || undefined, "data-no-offset": columnDef.noHeaderCellBorderOffset || undefined, "data-test-id": constants_1.TEST_IDS.headerCell, "data-header-id": header.id, "data-resizing": isResizing || undefined, "data-
|
|
41
|
+
return { ...attributes, ...listeners };
|
|
42
|
+
}, [attributes, header.column.id, isDraggable, listeners]);
|
|
43
|
+
return ((0, jsx_runtime_1.jsxs)(Cell_1.Cell, { style: style, onClick: sortingHandler, "data-sortable": isSortable || undefined, "data-draggable": isDraggable || undefined, "data-no-padding": columnDef.noHeaderCellPadding || undefined, "data-no-offset": columnDef.noHeaderCellBorderOffset || undefined, "data-test-id": constants_1.TEST_IDS.headerCell, "data-header-id": header.id, "data-resizing": isResizing || undefined, "data-pin-position": pinPosition || undefined, "data-row-auto-height": rowAutoHeight || undefined, role: 'columnheader', className: (0, classnames_1.default)(styles_module_scss_1.default.tableHeaderCell, className, columnDef.headerClassName), ref: element => {
|
|
45
44
|
if (isDraggable) {
|
|
46
45
|
setNodeRef(element);
|
|
47
46
|
}
|
|
48
47
|
cellRef.current = element;
|
|
49
|
-
}, children: [(0, jsx_runtime_1.jsx)(
|
|
48
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.tableHeaderCellDragWrapper, "data-dragging": (isDraggable && isDragging) || undefined, ...draggableProps, children: (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.tableHeaderCellMain, "data-align": columnDef.headerAlign || undefined, children: [columnDef.header && ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.tableHeaderCellName, children: rowAutoHeight || typeof renderedHeader !== 'string' ? (renderedHeader) : ((0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: renderedHeader })) })), Boolean(sortIcon) && ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.tableHeaderIcon, "data-sort-direction": sortDirection, "data-test-id": constants_1.TEST_IDS.headerSortIndicator, children: sortIcon }))] }) }), Boolean(isResizable) && (0, jsx_runtime_1.jsx)(ResizeHandle_1.ResizeHandle, { header: header, cellRef: cellRef })] }));
|
|
50
49
|
}
|
|
@@ -37,5 +37,5 @@ function ResizeHandle({ header, cellRef }) {
|
|
|
37
37
|
resizeHandler(event);
|
|
38
38
|
};
|
|
39
39
|
const offset = isResizing ? getResizeIndicatorOffset({ header, cellRef }) : 0;
|
|
40
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", {
|
|
40
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { role: 'button', tabIndex: 0, className: (0, classnames_1.default)(styles_module_scss_1.default.tableHeaderIcon, styles_module_scss_1.default.tableHeaderResizeHandle), "data-resizing": isResizing || undefined, onMouseDown: handleMouseDown, onTouchStart: resizeHandler, onMouseUp: helpers_1.stopEventPropagation }), isResizing && ((0, jsx_runtime_1.jsx)("div", { "data-test-id": constants_1.TEST_IDS.headerResizeHandleMovingPart, className: styles_module_scss_1.default.tableHeaderResizeIndicator, style: { '--offset': `${offset}px` } }))] }));
|
|
41
41
|
}
|
|
@@ -10,7 +10,4 @@
|
|
|
10
10
|
box-sizing:border-box;
|
|
11
11
|
width:100%;
|
|
12
12
|
background-color:transparent;
|
|
13
|
-
}
|
|
14
|
-
.tableCell[data-dragging]{
|
|
15
|
-
box-shadow:inset var(--sn-table-anatomy-content-tableLine-background-interaction-borderVerticalWidth, var(--sn-primitive-strokeWeight-strokeRegular, 1px)) 0 0 0 var(--sn-theme-color-available-borderColor, var(--sn-brand-color-state-neutralBorder-forLightMode-default-borderColor, rgba(159, 166, 198, 0.3019607843))), inset calc(-1 * var(--sn-table-anatomy-content-tableLine-background-interaction-borderVerticalWidth, var(--sn-primitive-strokeWeight-strokeRegular, 1px))) 0 0 0 var(--sn-theme-color-available-borderColor, var(--sn-brand-color-state-neutralBorder-forLightMode-default-borderColor, rgba(159, 166, 198, 0.3019607843)));
|
|
16
13
|
}
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.BodyRow = BodyRow;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const sortable_1 = require("@dnd-kit/sortable");
|
|
8
9
|
const react_1 = require("react");
|
|
9
10
|
const components_1 = require("../../components");
|
|
10
11
|
const constants_1 = require("../../constants");
|
|
@@ -32,5 +33,5 @@ function BodyRow({ row, onRowClick, rowAutoHeight, columnOrder, enableColumnsOrd
|
|
|
32
33
|
};
|
|
33
34
|
const isSelected = row.getIsSelected() || (row.getIsSomeSelected() && !row.getCanMultiSelect() && !row.getIsExpanded());
|
|
34
35
|
const rowBackgroundColor = getRowBackgroundColor?.(row.original);
|
|
35
|
-
return ((0, jsx_runtime_1.jsx)(contexts_1.RowContext.Provider, { value: { dropListOpened, setDropListOpen, disabledRowAppearance }, children: (0, jsx_runtime_1.jsxs)(Row_1.Row, { onClick: handleRowClick, clickable: Boolean(onRowClick) && !(disabled && disabledRowAppearance === components_1.RowAppearance.Disabled), "data-clickable": Boolean(onRowClick) || undefined, "data-disabled": disabled || undefined, "data-row-appearance": disabled ? disabledRowAppearance : undefined, "data-selected": isSelected || undefined, "data-actions-opened": dropListOpened || undefined, "data-test-id": constants_1.TEST_IDS.bodyRow, "data-row-id": row.id, "data-row-bg-appearance": rowBackgroundColor && !disabled && !isSelected ? rowBackgroundColor : undefined, className: styles_module_scss_1.default.bodyRow, rowAutoHeight: rowAutoHeight, children: [leftPinned && ((0, jsx_runtime_1.jsx)(PinnedCells_1.PinnedCells, { position: constants_1.COLUMN_PIN_POSITION.Left, children: leftPinned.map(cell => ((0, jsx_runtime_1.jsx)(Cells_1.BodyCell, { cell: cell, rowAutoHeight: rowAutoHeight }, cell.id))) })), columnVirtualPadding && columnVirtualPadding.left > 0 && ((0, jsx_runtime_1.jsx)("div", { "aria-hidden": true, style: { width: columnVirtualPadding.left, flexShrink: 0 } })), unpinned.map(cell => ((0, jsx_runtime_1.jsx)(Cells_1.BodyCell, { cell: cell, rowAutoHeight: rowAutoHeight, isDraggable:
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)(contexts_1.RowContext.Provider, { value: { dropListOpened, setDropListOpen, disabledRowAppearance }, children: (0, jsx_runtime_1.jsxs)(Row_1.Row, { onClick: handleRowClick, clickable: Boolean(onRowClick) && !(disabled && disabledRowAppearance === components_1.RowAppearance.Disabled), "data-clickable": Boolean(onRowClick) || undefined, "data-disabled": disabled || undefined, "data-row-appearance": disabled ? disabledRowAppearance : undefined, "data-selected": isSelected || undefined, "data-actions-opened": dropListOpened || undefined, "data-test-id": constants_1.TEST_IDS.bodyRow, "data-row-id": row.id, "data-row-bg-appearance": rowBackgroundColor && !disabled && !isSelected ? rowBackgroundColor : undefined, className: styles_module_scss_1.default.bodyRow, rowAutoHeight: rowAutoHeight, children: [leftPinned && ((0, jsx_runtime_1.jsx)(PinnedCells_1.PinnedCells, { position: constants_1.COLUMN_PIN_POSITION.Left, children: leftPinned.map(cell => ((0, jsx_runtime_1.jsx)(Cells_1.BodyCell, { cell: cell, rowAutoHeight: rowAutoHeight }, cell.id))) })), columnVirtualPadding && columnVirtualPadding.left > 0 && ((0, jsx_runtime_1.jsx)("div", { "aria-hidden": true, style: { width: columnVirtualPadding.left, flexShrink: 0 } })), enableColumnsOrderSortByDrag ? ((0, jsx_runtime_1.jsx)(sortable_1.SortableContext, { items: columnOrder, strategy: sortable_1.horizontalListSortingStrategy, children: unpinned.map(cell => ((0, jsx_runtime_1.jsx)(Cells_1.BodyCell, { cell: cell, rowAutoHeight: rowAutoHeight, isDraggable: true }, cell.id))) })) : (unpinned.map(cell => (0, jsx_runtime_1.jsx)(Cells_1.BodyCell, { cell: cell, rowAutoHeight: rowAutoHeight }, cell.id))), columnVirtualPadding && columnVirtualPadding.right > 0 && ((0, jsx_runtime_1.jsx)("div", { "aria-hidden": true, style: { width: columnVirtualPadding.right, flexShrink: 0 } })), rightPinned && ((0, jsx_runtime_1.jsx)(PinnedCells_1.PinnedCells, { position: constants_1.COLUMN_PIN_POSITION.Right, children: rightPinned.map(cell => ((0, jsx_runtime_1.jsx)(Cells_1.BodyCell, { cell: cell, rowAutoHeight: rowAutoHeight, isDraggable: enableColumnsOrderSortByDrag }, cell.id))) }))] }) }));
|
|
36
37
|
}
|
|
@@ -43,10 +43,6 @@
|
|
|
43
43
|
width:var(--sn-table-anatomy-content-tableLine-background-interaction-borderVerticalWidth, var(--sn-primitive-strokeWeight-strokeRegular, 1px));
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
.tableHeader .rowPinnedCells::after{
|
|
47
|
-
bottom:0;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
46
|
.rowPinnedCells[data-position=left]{
|
|
51
47
|
left:0;
|
|
52
48
|
}
|
|
@@ -10,6 +10,7 @@ function useEmptyState({ noDataState: noDataStateProp, noResultsState: noResults
|
|
|
10
10
|
const noDataState = {
|
|
11
11
|
icon: { icon: system_1.SearchSVG, appearance: 'neutral', background: true },
|
|
12
12
|
title: t('noData.title'),
|
|
13
|
+
content: t('noData.content'),
|
|
13
14
|
...noDataStateProp,
|
|
14
15
|
};
|
|
15
16
|
const noResultsState = {
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
.tableEmptyStateWrapper{
|
|
2
|
-
position:sticky;
|
|
3
|
-
left:0;
|
|
4
2
|
display:flex;
|
|
5
3
|
flex:1 1 auto;
|
|
6
4
|
flex-direction:column;
|
|
7
5
|
align-items:center;
|
|
8
6
|
justify-content:center;
|
|
9
7
|
box-sizing:border-box;
|
|
10
|
-
width:
|
|
8
|
+
width:100%;
|
|
11
9
|
min-height:304px;
|
|
12
10
|
padding:var(--sn-primitive-dimension-24, 24px);
|
|
13
11
|
}
|
package/dist/cjs/hooks/index.js
CHANGED
|
@@ -15,7 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./useCellSizes"), exports);
|
|
18
|
-
__exportStar(require("./useColumnDragTransform"), exports);
|
|
19
18
|
__exportStar(require("./useColumnsSettingsToolbarSlot"), exports);
|
|
20
19
|
__exportStar(require("./useExportToolbarSlot"), exports);
|
|
21
20
|
__exportStar(require("./useHeaderGroups"), exports);
|
|
@@ -3,6 +3,7 @@ import { Cell, Header } from '@tanstack/react-table';
|
|
|
3
3
|
import { CSSProperties } from 'react';
|
|
4
4
|
type CellSizesOptions = {
|
|
5
5
|
isDraggable?: boolean;
|
|
6
|
+
isDragging?: boolean;
|
|
6
7
|
transform?: Transform | null;
|
|
7
8
|
};
|
|
8
9
|
export declare function useCellSizes<TData>(element: Cell<TData, unknown> | Header<TData, unknown>, options?: CellSizesOptions): CSSProperties;
|
|
@@ -6,6 +6,7 @@ const react_1 = require("react");
|
|
|
6
6
|
const constants_1 = require("../constants");
|
|
7
7
|
function useCellSizes(element, options) {
|
|
8
8
|
const column = element.column;
|
|
9
|
+
const isDragging = options?.isDragging ?? false;
|
|
9
10
|
const transform = options?.transform ?? null;
|
|
10
11
|
const minWidth = column.columnDef.minSize;
|
|
11
12
|
const maxWidth = column.columnDef.maxSize;
|
|
@@ -20,12 +21,14 @@ function useCellSizes(element, options) {
|
|
|
20
21
|
flexShrink,
|
|
21
22
|
};
|
|
22
23
|
if (options?.isDraggable) {
|
|
24
|
+
styles.opacity = isDragging ? 0.8 : 1;
|
|
23
25
|
styles.position = 'relative';
|
|
24
26
|
styles.transform = utilities_1.CSS.Translate.toString(transform);
|
|
27
|
+
styles.zIndex = isDragging ? 1 : undefined;
|
|
25
28
|
if (isHeaderCell) {
|
|
26
29
|
styles.whiteSpace = 'nowrap';
|
|
27
30
|
}
|
|
28
31
|
}
|
|
29
32
|
return styles;
|
|
30
|
-
}, [options?.isDraggable, flexShrink, isHeaderCell, maxWidth, minWidth, transform, width]);
|
|
33
|
+
}, [options?.isDraggable, flexShrink, isDragging, isHeaderCell, maxWidth, minWidth, transform, width]);
|
|
31
34
|
}
|