@cloud-ru/ds-table 1.0.2 → 1.0.4-preview-bd263dc7.0
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 +7 -0
- package/README.md +3 -3
- package/dist/cjs/components/Table/Table.js +12 -4
- package/dist/cjs/components/Table/hooks/useColumnOrderByDrag/useColumnOrderByDrag.d.ts +2 -0
- package/dist/cjs/components/Table/hooks/useColumnOrderByDrag/useColumnOrderByDrag.js +20 -3
- 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/getColumnSettingsMode.d.ts +8 -0
- package/dist/cjs/components/Table/hooks/useColumnSettings/utils/getColumnSettingsMode.js +15 -0
- package/dist/cjs/components/Table/hooks/useColumnSettings/utils/index.d.ts +1 -0
- package/dist/cjs/components/Table/hooks/useColumnSettings/utils/index.js +1 -0
- package/dist/cjs/components/Table/hooks/useColumnSettings/utils/isColumnEnabledInitially.js +3 -4
- package/dist/cjs/components/Table/hooks/useColumnSettings/utils/isColumnVisibilityConfigurable.js +3 -15
- package/dist/cjs/components/Table/hooks/useColumnSettings/utils/isFilterableColumn.js +4 -2
- package/dist/cjs/components/Table/hooks/useTableScroll.js +15 -1
- package/dist/cjs/components/Table/styles.module.css +19 -1
- package/dist/cjs/components/Table/utils/alignOverlayToHeader.d.ts +6 -0
- package/dist/cjs/components/Table/utils/alignOverlayToHeader.js +28 -0
- package/dist/cjs/components/Table/utils/index.d.ts +1 -0
- package/dist/cjs/components/Table/utils/index.js +1 -0
- package/dist/cjs/constants.d.ts +1 -1
- package/dist/cjs/constants.js +1 -1
- package/dist/cjs/helperComponents/Cells/BodyCell/BodyCell.d.ts +3 -1
- package/dist/cjs/helperComponents/Cells/BodyCell/BodyCell.js +9 -10
- package/dist/cjs/helperComponents/Cells/HeaderCell/HeaderCell.js +7 -6
- package/dist/cjs/helperComponents/Cells/HeaderCell/ResizeHandle.js +1 -1
- package/dist/cjs/helperComponents/Cells/styles.module.css +3 -0
- package/dist/cjs/helperComponents/Rows/BodyRow.js +1 -2
- package/dist/cjs/helperComponents/Rows/styles.module.css +4 -0
- package/dist/cjs/helperComponents/TableEmptyState/hooks.js +0 -1
- package/dist/cjs/helperComponents/TableEmptyState/styles.module.css +3 -1
- package/dist/cjs/hooks/index.d.ts +1 -0
- package/dist/cjs/hooks/index.js +1 -0
- package/dist/cjs/hooks/useCellSizes.d.ts +0 -1
- package/dist/cjs/hooks/useCellSizes.js +1 -4
- package/dist/cjs/hooks/useColumnDragTransform.d.ts +15 -0
- package/dist/cjs/hooks/useColumnDragTransform.js +38 -0
- package/dist/cjs/locale/index.d.ts +0 -4
- package/dist/cjs/locale/index.js +0 -2
- package/dist/cjs/style.css +29 -2
- package/dist/cjs/types.d.ts +1 -0
- package/dist/esm/components/Table/Table.js +15 -7
- package/dist/esm/components/Table/hooks/useColumnOrderByDrag/useColumnOrderByDrag.d.ts +2 -0
- package/dist/esm/components/Table/hooks/useColumnOrderByDrag/useColumnOrderByDrag.js +21 -4
- 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/getColumnSettingsMode.d.ts +8 -0
- package/dist/esm/components/Table/hooks/useColumnSettings/utils/getColumnSettingsMode.js +11 -0
- package/dist/esm/components/Table/hooks/useColumnSettings/utils/index.d.ts +1 -0
- package/dist/esm/components/Table/hooks/useColumnSettings/utils/index.js +1 -0
- package/dist/esm/components/Table/hooks/useColumnSettings/utils/isColumnEnabledInitially.js +3 -4
- package/dist/esm/components/Table/hooks/useColumnSettings/utils/isColumnVisibilityConfigurable.js +3 -15
- package/dist/esm/components/Table/hooks/useColumnSettings/utils/isFilterableColumn.js +4 -2
- package/dist/esm/components/Table/hooks/useTableScroll.js +15 -1
- package/dist/esm/components/Table/styles.module.css +19 -1
- package/dist/esm/components/Table/utils/alignOverlayToHeader.d.ts +6 -0
- package/dist/esm/components/Table/utils/alignOverlayToHeader.js +24 -0
- package/dist/esm/components/Table/utils/index.d.ts +1 -0
- package/dist/esm/components/Table/utils/index.js +1 -0
- package/dist/esm/constants.d.ts +1 -1
- package/dist/esm/constants.js +1 -1
- package/dist/esm/helperComponents/Cells/BodyCell/BodyCell.d.ts +3 -1
- package/dist/esm/helperComponents/Cells/BodyCell/BodyCell.js +10 -11
- package/dist/esm/helperComponents/Cells/HeaderCell/HeaderCell.js +7 -6
- package/dist/esm/helperComponents/Cells/HeaderCell/ResizeHandle.js +1 -1
- package/dist/esm/helperComponents/Cells/styles.module.css +3 -0
- package/dist/esm/helperComponents/Rows/BodyRow.js +1 -2
- package/dist/esm/helperComponents/Rows/styles.module.css +4 -0
- package/dist/esm/helperComponents/TableEmptyState/hooks.js +0 -1
- package/dist/esm/helperComponents/TableEmptyState/styles.module.css +3 -1
- package/dist/esm/hooks/index.d.ts +1 -0
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/useCellSizes.d.ts +0 -1
- package/dist/esm/hooks/useCellSizes.js +1 -4
- package/dist/esm/hooks/useColumnDragTransform.d.ts +15 -0
- package/dist/esm/hooks/useColumnDragTransform.js +35 -0
- package/dist/esm/locale/index.d.ts +0 -4
- package/dist/esm/locale/index.js +0 -2
- package/dist/esm/style.css +29 -2
- package/dist/esm/types.d.ts +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +21 -20
- package/src/components/Table/Table.tsx +53 -26
- package/src/components/Table/hooks/useColumnOrderByDrag/useColumnOrderByDrag.ts +31 -7
- package/src/components/Table/hooks/useColumnSettings/utils/createColumnsSettingsOption.ts +2 -2
- package/src/components/Table/hooks/useColumnSettings/utils/getColumnSettingsMode.ts +18 -0
- package/src/components/Table/hooks/useColumnSettings/utils/index.ts +1 -0
- package/src/components/Table/hooks/useColumnSettings/utils/isColumnEnabledInitially.ts +3 -5
- package/src/components/Table/hooks/useColumnSettings/utils/isColumnVisibilityConfigurable.ts +3 -18
- package/src/components/Table/hooks/useColumnSettings/utils/isFilterableColumn.ts +4 -2
- package/src/components/Table/hooks/useTableScroll.ts +21 -1
- package/src/components/Table/styles.module.scss +23 -1
- package/src/components/Table/utils/alignOverlayToHeader.ts +36 -0
- package/src/components/Table/utils/index.ts +1 -0
- package/src/constants.ts +1 -1
- package/src/helperComponents/Cells/BodyCell/BodyCell.tsx +18 -15
- package/src/helperComponents/Cells/HeaderCell/HeaderCell.tsx +10 -7
- package/src/helperComponents/Cells/HeaderCell/ResizeHandle.tsx +1 -2
- package/src/helperComponents/Cells/styles.module.scss +11 -0
- package/src/helperComponents/Rows/BodyRow.tsx +9 -10
- package/src/helperComponents/Rows/styles.module.scss +5 -0
- package/src/helperComponents/TableEmptyState/hooks.ts +0 -1
- package/src/helperComponents/TableEmptyState/styles.module.scss +5 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useCellSizes.ts +1 -5
- package/src/hooks/useColumnDragTransform.ts +52 -0
- package/src/locale/index.ts +0 -2
- package/src/types.ts +3 -5
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
.tableEmptyStateWrapper{
|
|
2
|
+
position:sticky;
|
|
3
|
+
left:0;
|
|
2
4
|
display:flex;
|
|
3
5
|
flex:1 1 auto;
|
|
4
6
|
flex-direction:column;
|
|
5
7
|
align-items:center;
|
|
6
8
|
justify-content:center;
|
|
7
9
|
box-sizing:border-box;
|
|
8
|
-
width:100
|
|
10
|
+
width:var(--table-viewport-width, 100%);
|
|
9
11
|
min-height:304px;
|
|
10
12
|
padding:var(--sn-primitive-dimension-24, 24px);
|
|
11
13
|
}
|
package/dist/cjs/hooks/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./useCellSizes"), exports);
|
|
18
|
+
__exportStar(require("./useColumnDragTransform"), exports);
|
|
18
19
|
__exportStar(require("./useColumnsSettingsToolbarSlot"), exports);
|
|
19
20
|
__exportStar(require("./useExportToolbarSlot"), exports);
|
|
20
21
|
__exportStar(require("./useHeaderGroups"), exports);
|
|
@@ -3,7 +3,6 @@ import { Cell, Header } from '@tanstack/react-table';
|
|
|
3
3
|
import { CSSProperties } from 'react';
|
|
4
4
|
type CellSizesOptions = {
|
|
5
5
|
isDraggable?: boolean;
|
|
6
|
-
isDragging?: boolean;
|
|
7
6
|
transform?: Transform | null;
|
|
8
7
|
};
|
|
9
8
|
export declare function useCellSizes<TData>(element: Cell<TData, unknown> | Header<TData, unknown>, options?: CellSizesOptions): CSSProperties;
|
|
@@ -6,7 +6,6 @@ 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;
|
|
10
9
|
const transform = options?.transform ?? null;
|
|
11
10
|
const minWidth = column.columnDef.minSize;
|
|
12
11
|
const maxWidth = column.columnDef.maxSize;
|
|
@@ -21,14 +20,12 @@ function useCellSizes(element, options) {
|
|
|
21
20
|
flexShrink,
|
|
22
21
|
};
|
|
23
22
|
if (options?.isDraggable) {
|
|
24
|
-
styles.opacity = isDragging ? 0.8 : 1;
|
|
25
23
|
styles.position = 'relative';
|
|
26
24
|
styles.transform = utilities_1.CSS.Translate.toString(transform);
|
|
27
|
-
styles.zIndex = isDragging ? 1 : undefined;
|
|
28
25
|
if (isHeaderCell) {
|
|
29
26
|
styles.whiteSpace = 'nowrap';
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
29
|
return styles;
|
|
33
|
-
}, [options?.isDraggable, flexShrink,
|
|
30
|
+
}, [options?.isDraggable, flexShrink, isHeaderCell, maxWidth, minWidth, transform, width]);
|
|
34
31
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Transform } from '@dnd-kit/utilities';
|
|
2
|
+
import { ColumnOrder } from '../types';
|
|
3
|
+
type ColumnDragState = {
|
|
4
|
+
transform: Transform | null;
|
|
5
|
+
isDragging: boolean;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Сдвиг ячейки тела за колонкой, которую тянут за шапку.
|
|
9
|
+
*
|
|
10
|
+
* Не `useSortable`: он зарегистрировал бы ячейку в реестре dnd-kit под id колонки — тем же, что у
|
|
11
|
+
* шапки. Реестр ключуется по id, поэтому размонтирование строк удаляло запись колонки целиком и
|
|
12
|
+
* драг переставал работать.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useColumnDragTransform(columnId: string, columnOrder: ColumnOrder): ColumnDragState;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useColumnDragTransform = useColumnDragTransform;
|
|
4
|
+
const core_1 = require("@dnd-kit/core");
|
|
5
|
+
const sortable_1 = require("@dnd-kit/sortable");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
/**
|
|
8
|
+
* Сдвиг ячейки тела за колонкой, которую тянут за шапку.
|
|
9
|
+
*
|
|
10
|
+
* Не `useSortable`: он зарегистрировал бы ячейку в реестре dnd-kit под id колонки — тем же, что у
|
|
11
|
+
* шапки. Реестр ключуется по id, поэтому размонтирование строк удаляло запись колонки целиком и
|
|
12
|
+
* драг переставал работать.
|
|
13
|
+
*/
|
|
14
|
+
function useColumnDragTransform(columnId, columnOrder) {
|
|
15
|
+
const { active, over, activeNodeRect, droppableRects } = (0, core_1.useDndContext)();
|
|
16
|
+
const activeId = active ? String(active.id) : undefined;
|
|
17
|
+
const overId = over ? String(over.id) : undefined;
|
|
18
|
+
const transform = (0, react_1.useMemo)(() => {
|
|
19
|
+
if (!activeId) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const measured = columnOrder.filter(id => droppableRects.get(id));
|
|
23
|
+
const index = measured.indexOf(columnId);
|
|
24
|
+
const activeIndex = measured.indexOf(activeId);
|
|
25
|
+
if (index < 0 || activeIndex < 0) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const overIndex = overId ? measured.indexOf(overId) : -1;
|
|
29
|
+
return (0, sortable_1.horizontalListSortingStrategy)({
|
|
30
|
+
rects: measured.map(id => droppableRects.get(id)),
|
|
31
|
+
activeNodeRect,
|
|
32
|
+
activeIndex,
|
|
33
|
+
overIndex: overIndex < 0 ? activeIndex : overIndex,
|
|
34
|
+
index,
|
|
35
|
+
});
|
|
36
|
+
}, [activeId, overId, columnId, columnOrder, droppableRects, activeNodeRect]);
|
|
37
|
+
return { transform, isDragging: activeId === columnId };
|
|
38
|
+
}
|
|
@@ -13,7 +13,6 @@ declare const TABLE_MESSAGES: {
|
|
|
13
13
|
};
|
|
14
14
|
readonly noData: {
|
|
15
15
|
readonly title: "No data";
|
|
16
|
-
readonly content: "Try refreshing the page";
|
|
17
16
|
};
|
|
18
17
|
readonly noResults: {
|
|
19
18
|
readonly title: "Nothing found";
|
|
@@ -38,7 +37,6 @@ declare const TABLE_MESSAGES: {
|
|
|
38
37
|
};
|
|
39
38
|
readonly noData: {
|
|
40
39
|
readonly title: "Нет данных";
|
|
41
|
-
readonly content: "Обновите страницу";
|
|
42
40
|
};
|
|
43
41
|
readonly noResults: {
|
|
44
42
|
readonly title: "Ничего не найдено";
|
|
@@ -67,7 +65,6 @@ export declare const tableLocale: import("@cloud-ru/ds-locale").DefinedLocale<{
|
|
|
67
65
|
};
|
|
68
66
|
readonly noData: {
|
|
69
67
|
readonly title: "No data";
|
|
70
|
-
readonly content: "Try refreshing the page";
|
|
71
68
|
};
|
|
72
69
|
readonly noResults: {
|
|
73
70
|
readonly title: "Nothing found";
|
|
@@ -92,7 +89,6 @@ export declare const tableLocale: import("@cloud-ru/ds-locale").DefinedLocale<{
|
|
|
92
89
|
};
|
|
93
90
|
readonly noData: {
|
|
94
91
|
readonly title: "Нет данных";
|
|
95
|
-
readonly content: "Обновите страницу";
|
|
96
92
|
};
|
|
97
93
|
readonly noResults: {
|
|
98
94
|
readonly title: "Ничего не найдено";
|
package/dist/cjs/locale/index.js
CHANGED
|
@@ -17,7 +17,6 @@ const TABLE_MESSAGES = (0, locale_1.defineMessages)({
|
|
|
17
17
|
},
|
|
18
18
|
noData: {
|
|
19
19
|
title: 'No data',
|
|
20
|
-
content: 'Try refreshing the page',
|
|
21
20
|
},
|
|
22
21
|
noResults: {
|
|
23
22
|
title: 'Nothing found',
|
|
@@ -42,7 +41,6 @@ const TABLE_MESSAGES = (0, locale_1.defineMessages)({
|
|
|
42
41
|
},
|
|
43
42
|
noData: {
|
|
44
43
|
title: 'Нет данных',
|
|
45
|
-
content: 'Обновите страницу',
|
|
46
44
|
},
|
|
47
45
|
noResults: {
|
|
48
46
|
title: 'Ничего не найдено',
|
package/dist/cjs/style.css
CHANGED
|
@@ -442,7 +442,8 @@
|
|
|
442
442
|
flex:1 1 auto;
|
|
443
443
|
flex-direction:column;
|
|
444
444
|
width:100%;
|
|
445
|
-
min-width
|
|
445
|
+
min-width:-moz-max-content;
|
|
446
|
+
min-width:max-content;
|
|
446
447
|
min-height:100%;
|
|
447
448
|
}
|
|
448
449
|
|
|
@@ -576,6 +577,23 @@
|
|
|
576
577
|
width:100%;
|
|
577
578
|
max-width:100%;
|
|
578
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
|
+
}
|
|
579
597
|
.tableBodyCell{
|
|
580
598
|
gap:var(--sn-table-anatomy-content-tableCell-contentWrapper-slot-gap, var(--sn-primitive-dimension-2, 2px));
|
|
581
599
|
padding:calc(var(--sn-table-anatomy-content-tableCell-paddingTop, var(--sn-primitive-dimension-6, 6px)) + var(--sn-table-anatomy-content-tableCell-contentWrapper-paddingTop, var(--sn-primitive-dimension-2, 2px))) var(--sn-table-anatomy-content-tableCell-paddingRight, var(--sn-primitive-dimension-12, 12px)) calc(var(--sn-table-anatomy-content-tableCell-paddingBottom, var(--sn-primitive-dimension-6, 6px)) + var(--sn-table-anatomy-content-tableCell-contentWrapper-paddingBottom, var(--sn-primitive-dimension-2, 2px))) var(--sn-table-anatomy-content-tableCell-paddingLeft, var(--sn-primitive-dimension-12, 12px));
|
|
@@ -1005,6 +1023,9 @@
|
|
|
1005
1023
|
width:100%;
|
|
1006
1024
|
background-color:transparent;
|
|
1007
1025
|
}
|
|
1026
|
+
.tableCell[data-dragging]{
|
|
1027
|
+
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)));
|
|
1028
|
+
}
|
|
1008
1029
|
@charset "UTF-8";
|
|
1009
1030
|
.surface{
|
|
1010
1031
|
isolation:isolate;
|
|
@@ -1277,6 +1298,10 @@
|
|
|
1277
1298
|
width:var(--sn-table-anatomy-content-tableLine-background-interaction-borderVerticalWidth, var(--sn-primitive-strokeWeight-strokeRegular, 1px));
|
|
1278
1299
|
}
|
|
1279
1300
|
|
|
1301
|
+
.tableHeader .rowPinnedCells::after{
|
|
1302
|
+
bottom:0;
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1280
1305
|
.rowPinnedCells[data-position=left]{
|
|
1281
1306
|
left:0;
|
|
1282
1307
|
}
|
|
@@ -1525,13 +1550,15 @@
|
|
|
1525
1550
|
padding:0;
|
|
1526
1551
|
}
|
|
1527
1552
|
.tableEmptyStateWrapper{
|
|
1553
|
+
position:sticky;
|
|
1554
|
+
left:0;
|
|
1528
1555
|
display:flex;
|
|
1529
1556
|
flex:1 1 auto;
|
|
1530
1557
|
flex-direction:column;
|
|
1531
1558
|
align-items:center;
|
|
1532
1559
|
justify-content:center;
|
|
1533
1560
|
box-sizing:border-box;
|
|
1534
|
-
width:100
|
|
1561
|
+
width:var(--table-viewport-width, 100%);
|
|
1535
1562
|
min-height:304px;
|
|
1536
1563
|
padding:var(--sn-primitive-dimension-24, 24px);
|
|
1537
1564
|
}
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { DndContext } from '@dnd-kit/core';
|
|
2
|
+
import { DndContext, DragOverlay } from '@dnd-kit/core';
|
|
3
3
|
import { isMobileLayout, mergePresets, useAdaptiveLayout, useLayoutDefaults } from '@cloud-ru/ds-adaptive';
|
|
4
|
+
import { DragPreview } from '@cloud-ru/ds-drag-and-drop';
|
|
4
5
|
import { BACKGROUND_PREDEFINED_FILL } from '@cloud-ru/ds-materials';
|
|
5
6
|
import { useThemeClassnames } from '@cloud-ru/ds-theme';
|
|
6
7
|
import { extractSupportProps } from '@cloud-ru/ds-utils';
|
|
8
|
+
import { flexRender } from '@tanstack/react-table';
|
|
7
9
|
import cn from 'classnames';
|
|
8
10
|
import { useEffect, useMemo } from 'react';
|
|
9
|
-
import { DEFAULT_EXPANDED, DEFAULT_PAGE_SIZE, DEFAULT_ROW_SELECTION, DEFAULT_SORTING, DEFAULT_VIEW, VIEW, } from '../../constants.js';
|
|
11
|
+
import { DEFAULT_EXPANDED, DEFAULT_PAGE_SIZE, DEFAULT_ROW_SELECTION, DEFAULT_SORTING, DEFAULT_VIEW, TABLE_COLUMN_CSS_VARS, VIEW, } from '../../constants.js';
|
|
10
12
|
import { CellAutoResizeContext, TableContext, useCellAutoResizeController } from '../../contexts/index.js';
|
|
11
13
|
import { getControlsAcrylicAttrs, getRowActionsColumnDef, getStatusColumnDef, HeaderRow, LoadMoreButton, STATUS_APPEARANCE, TableEmptyState, TablePagination, useEmptyState, } from '../../helperComponents/index.js';
|
|
12
14
|
import { ToolbarCheckBoxMode } from '../types.js';
|
|
@@ -19,7 +21,7 @@ import { TableToolbar } from './components/TableToolbar/index.js';
|
|
|
19
21
|
import { buildAllTableColumns, buildColumnPinning, useColumnOrderByDrag, useColumnSettings, useColumnSizes, useColumnVirtualizer, useFilters, usePageReset, useRowVirtualizer, useStateControl, useTableInstance, useTableScroll, useTableToolbar, useTableView, } from './hooks/index.js';
|
|
20
22
|
import { isFilterableColumn } from './hooks/useColumnSettings/utils/index.js';
|
|
21
23
|
import styles from './styles.module.css';
|
|
22
|
-
import { getColumnIdentifier, getPinnedGroups } from './utils/index.js';
|
|
24
|
+
import { alignOverlayToHeader, getColumnIdentifier, getPinnedGroups } from './utils/index.js';
|
|
23
25
|
const TABLE_CONTENT_ACRYLIC = getControlsAcrylicAttrs(BACKGROUND_PREDEFINED_FILL.NeutralBackground1Level);
|
|
24
26
|
const BASE_STICKY_CONTROLS = {
|
|
25
27
|
enabled: false,
|
|
@@ -98,7 +100,7 @@ export function Table({ data, rowPinning = {
|
|
|
98
100
|
onSortingChange([]);
|
|
99
101
|
}
|
|
100
102
|
}, [areColumnsSettingsEnabled, enabledColumns, hideableColumnIds, onSortingChange, sorting]);
|
|
101
|
-
const { columnOrder, setColumnOrder, dndContextProps, enableColumnsOrderSortByDrag } = useColumnOrderByDrag({
|
|
103
|
+
const { columnOrder, setColumnOrder, dndContextProps, enableColumnsOrderSortByDrag, draggingColumnId } = useColumnOrderByDrag({
|
|
102
104
|
tableColumns: allTableColumns,
|
|
103
105
|
savedState,
|
|
104
106
|
columnSettings: columnsSettingsProp,
|
|
@@ -257,6 +259,12 @@ export function Table({ data, rowPinning = {
|
|
|
257
259
|
// но скрывает при dataError. Загрузка и непустое тело — шапка всегда.
|
|
258
260
|
const showTableHeader = showHeader &&
|
|
259
261
|
(isLoadingState || centerRows.length > 0 || filteredTopRows.length > 0 || (isEmptyBody && !dataError));
|
|
262
|
+
const draggingHeader = draggingColumnId
|
|
263
|
+
? table.getFlatHeaders().find(header => header.column.id === draggingColumnId)
|
|
264
|
+
: undefined;
|
|
265
|
+
// Копия колонки едет за курсором в портале: внутри скролла она растила бы его ширину
|
|
266
|
+
// и ныряла под закреплённые колонки.
|
|
267
|
+
const draggingColumnPreview = (_jsx(DragOverlay, { dropAnimation: null, modifiers: [alignOverlayToHeader], children: draggingHeader ? (_jsx(DragPreview, { className: styles.columnDragPreview, style: { width: `var(${TABLE_COLUMN_CSS_VARS.size(draggingHeader.column.id)})` }, children: flexRender(draggingHeader.column.columnDef.header, draggingHeader.getContext()) })) : null }));
|
|
260
268
|
const tableHeaderElement = showTableHeader ? (_jsx(HeaderRow, { rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, suppressSticky: usePageStickyHeader })) : null;
|
|
261
269
|
const tableRowsContent = (_jsx(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 }));
|
|
262
270
|
const cardsContentBody = (_jsx(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 }));
|
|
@@ -293,8 +301,8 @@ export function Table({ data, rowPinning = {
|
|
|
293
301
|
const themeClassName = useThemeClassnames({ density: isMobile ? 'comfort' : 'compact' });
|
|
294
302
|
const controlsAcrylic = useMemo(() => (isStickyControls ? getControlsAcrylicAttrs(stickyControlsBackgroundPredefined) : null), [isStickyControls, stickyControlsBackgroundPredefined]);
|
|
295
303
|
const scrollPaddingAbsolute = isStickyControls && !isCardsView;
|
|
296
|
-
const tableScrollContent = (_jsx("div", { className: styles.body, "data-empty-body": isEmptyBody || undefined, style: columnSizes.vars, children: _jsx(CellAutoResizeContext.Provider, { value: { updateCellMap, removeCellFromMap }, children:
|
|
297
|
-
const tableContentWithProviders = (_jsx("div", { className: styles.body, "data-empty-body": isEmptyBody || undefined, style: columnSizes.vars, children: _jsx(CellAutoResizeContext.Provider, { value: { updateCellMap, removeCellFromMap }, children:
|
|
304
|
+
const tableScrollContent = (_jsx("div", { className: styles.body, "data-empty-body": isEmptyBody || undefined, style: columnSizes.vars, children: _jsx(CellAutoResizeContext.Provider, { value: { updateCellMap, removeCellFromMap }, children: tableScrollRows }) }));
|
|
305
|
+
const tableContentWithProviders = (_jsx("div", { className: styles.body, "data-empty-body": isEmptyBody || undefined, style: columnSizes.vars, children: _jsx(CellAutoResizeContext.Provider, { value: { updateCellMap, removeCellFromMap }, children: tableBody }) }));
|
|
298
306
|
let scrollContent = tableContentWithProviders;
|
|
299
307
|
if (isMobile && isCardsView) {
|
|
300
308
|
scrollContent = tableBody;
|
|
@@ -322,7 +330,7 @@ export function Table({ data, rowPinning = {
|
|
|
322
330
|
paginationChrome =
|
|
323
331
|
isStickyControls && controlsAcrylic ? (_jsx(TableChrome, { variant: 'footer', acrylic: controlsAcrylic, children: pagination })) : (pagination);
|
|
324
332
|
}
|
|
325
|
-
return (_jsx("div", { ref: wrapperRef, className: cn(styles.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, ...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, _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 }), !isCardsView && outline ? _jsx("span", { className: styles.contentBorder, "aria-hidden": true }) : null] }), paginationChrome] })] }) }));
|
|
333
|
+
return (_jsx("div", { ref: wrapperRef, className: cn(styles.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, ...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 })] }), !isCardsView && outline ? _jsx("span", { className: styles.contentBorder, "aria-hidden": true }) : null] }), paginationChrome] })] }) }));
|
|
326
334
|
}
|
|
327
335
|
Table.getStatusColumnDef = getStatusColumnDef;
|
|
328
336
|
Table.statusAppearances = STATUS_APPEARANCE;
|
|
@@ -12,5 +12,7 @@ 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;
|
|
15
17
|
};
|
|
16
18
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { closestCenter,
|
|
1
|
+
import { closestCenter, MouseSensor, TouchSensor, useSensor, useSensors, } from '@dnd-kit/core';
|
|
2
2
|
import { restrictToHorizontalAxis } from '@dnd-kit/modifiers';
|
|
3
3
|
import { arrayMove } from '@dnd-kit/sortable';
|
|
4
4
|
import { isBrowser } from '@cloud-ru/ds-utils';
|
|
@@ -12,6 +12,7 @@ const draggingOptions = {
|
|
|
12
12
|
};
|
|
13
13
|
export function useColumnOrderByDrag({ tableColumns, savedState, columnSettings, }) {
|
|
14
14
|
const [columnOrder, setColumnOrderState] = useState(() => prepareInitialState(tableColumns, savedState));
|
|
15
|
+
const [draggingColumnId, setDraggingColumnId] = useState();
|
|
15
16
|
useEffect(() => {
|
|
16
17
|
setColumnOrderState(prev => {
|
|
17
18
|
const currentIds = tableColumns
|
|
@@ -39,7 +40,14 @@ export function useColumnOrderByDrag({ tableColumns, savedState, columnSettings,
|
|
|
39
40
|
}
|
|
40
41
|
setColumnOrderState(updatedOrder);
|
|
41
42
|
}, [columnOrder, savedState]);
|
|
43
|
+
const handleDragStart = useCallback(({ active }) => {
|
|
44
|
+
setDraggingColumnId(String(active.id));
|
|
45
|
+
}, []);
|
|
46
|
+
const handleDragCancel = useCallback(() => {
|
|
47
|
+
setDraggingColumnId(undefined);
|
|
48
|
+
}, []);
|
|
42
49
|
const handleDragEnd = useCallback(({ active, over }) => {
|
|
50
|
+
setDraggingColumnId(undefined);
|
|
43
51
|
if (!active || !over) {
|
|
44
52
|
return;
|
|
45
53
|
}
|
|
@@ -57,23 +65,32 @@ export function useColumnOrderByDrag({ tableColumns, savedState, columnSettings,
|
|
|
57
65
|
return arrayMove(columnOrder, oldIndex, newIndex);
|
|
58
66
|
});
|
|
59
67
|
}, [columnOrder, setColumnOrder]);
|
|
60
|
-
|
|
68
|
+
// `over` вне SortableContext сбрасывает transform'ы всей сортировки — колонка рывком
|
|
69
|
+
// возвращается на место. Держим `over` внутри колонок сортировки.
|
|
70
|
+
const collisionDetection = useCallback(args => closestCenter({
|
|
71
|
+
...args,
|
|
72
|
+
droppableContainers: args.droppableContainers.filter(container => columnOrder.includes(String(container.id))),
|
|
73
|
+
}), [columnOrder]);
|
|
74
|
+
const sensors = useSensors(useSensor(MouseSensor, draggingOptions), useSensor(TouchSensor, {}));
|
|
61
75
|
const enableColumnsOrderSortByDrag = Boolean(columnSettings?.enableDrag);
|
|
62
76
|
const dndContextProps = useMemo(() => {
|
|
63
77
|
if (!enableColumnsOrderSortByDrag) {
|
|
64
78
|
return {};
|
|
65
79
|
}
|
|
66
80
|
return {
|
|
67
|
-
collisionDetection
|
|
81
|
+
collisionDetection,
|
|
68
82
|
modifiers: [restrictToHorizontalAxis],
|
|
83
|
+
onDragStart: handleDragStart,
|
|
84
|
+
onDragCancel: handleDragCancel,
|
|
69
85
|
onDragEnd: handleDragEnd,
|
|
70
86
|
sensors,
|
|
71
87
|
};
|
|
72
|
-
}, [enableColumnsOrderSortByDrag, handleDragEnd, sensors]);
|
|
88
|
+
}, [collisionDetection, enableColumnsOrderSortByDrag, handleDragCancel, handleDragEnd, handleDragStart, sensors]);
|
|
73
89
|
return {
|
|
74
90
|
columnOrder,
|
|
75
91
|
setColumnOrder,
|
|
76
92
|
dndContextProps,
|
|
77
93
|
enableColumnsOrderSortByDrag,
|
|
94
|
+
draggingColumnId,
|
|
78
95
|
};
|
|
79
96
|
}
|
package/dist/esm/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.js';
|
|
3
3
|
/**
|
|
4
4
|
* Колонка попадает в меню настроек: есть id/accessorKey и это не selection/row-actions.
|
|
5
|
-
* Включая `mode: locked`
|
|
5
|
+
* Включая `mode: locked` (рендерится disabled).
|
|
6
6
|
*/
|
|
7
7
|
export declare function isColumnsSettingsMenuItem<TData extends object>(colDef: ColumnDefinition<TData>): boolean;
|
|
8
8
|
/**
|
|
9
|
-
* Пункт меню настроек колонок. Неактивные (
|
|
9
|
+
* Пункт меню настроек колонок. Неактивные (`mode: locked` и служебные колонки) —
|
|
10
10
|
* `disabled` + всегда включённый switch (`checked: true`); драг при этом остаётся
|
|
11
11
|
* доступным. Видимость через `enabledColumns` не управляется.
|
|
12
12
|
*/
|
package/dist/esm/components/Table/hooks/useColumnSettings/utils/createColumnsSettingsOption.js
CHANGED
|
@@ -5,7 +5,7 @@ import { isFilterableColumn } from './isFilterableColumn.js';
|
|
|
5
5
|
const SETTINGS_MENU_EXCLUDED_IDS = new Set([DefaultColumns.Selection, DefaultColumns.RowActions]);
|
|
6
6
|
/**
|
|
7
7
|
* Колонка попадает в меню настроек: есть id/accessorKey и это не selection/row-actions.
|
|
8
|
-
* Включая `mode: locked`
|
|
8
|
+
* Включая `mode: locked` (рендерится disabled).
|
|
9
9
|
*/
|
|
10
10
|
export function isColumnsSettingsMenuItem(colDef) {
|
|
11
11
|
if (!('id' in colDef || 'accessorKey' in colDef)) {
|
|
@@ -26,7 +26,7 @@ function getColumnsSettingsOptionLabel(columnDefinition) {
|
|
|
26
26
|
return getColumnIdentifier(columnDefinition);
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
* Пункт меню настроек колонок. Неактивные (
|
|
29
|
+
* Пункт меню настроек колонок. Неактивные (`mode: locked` и служебные колонки) —
|
|
30
30
|
* `disabled` + всегда включённый switch (`checked: true`); драг при этом остаётся
|
|
31
31
|
* доступным. Видимость через `enabledColumns` не управляется.
|
|
32
32
|
*/
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { COLUMN_SETTINGS_MODE } from '../../../../../constants.js';
|
|
2
|
+
import { ColumnDefinition } from '../../../../../types.js';
|
|
3
|
+
type ColumnSettingsMode = (typeof COLUMN_SETTINGS_MODE)[keyof typeof COLUMN_SETTINGS_MODE];
|
|
4
|
+
/** Служебные колонки (`selection` / `rowActions` / `status`) видимостью не управляются. */
|
|
5
|
+
export declare function isServiceColumn<TData extends object>(colDef: ColumnDefinition<TData>): boolean;
|
|
6
|
+
/** Режим колонки в меню настроек; без `columnSettings.mode` — `defaultVisible`. */
|
|
7
|
+
export declare function getColumnSettingsMode<TData extends object>(colDef: ColumnDefinition<TData>): ColumnSettingsMode;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { COLUMN_SETTINGS_MODE, DEFAULT_COLUMNS } from '../../../../../constants.js';
|
|
2
|
+
/** Служебные колонки (`selection` / `rowActions` / `status`) видимостью не управляются. */
|
|
3
|
+
export function isServiceColumn(colDef) {
|
|
4
|
+
const id = 'id' in colDef ? colDef.id : undefined;
|
|
5
|
+
return Boolean(id) && DEFAULT_COLUMNS.includes(String(id));
|
|
6
|
+
}
|
|
7
|
+
/** Режим колонки в меню настроек; без `columnSettings.mode` — `defaultVisible`. */
|
|
8
|
+
export function getColumnSettingsMode(colDef) {
|
|
9
|
+
const mode = 'columnSettings' in colDef ? colDef.columnSettings?.mode : undefined;
|
|
10
|
+
return mode ?? COLUMN_SETTINGS_MODE.DefaultVisible;
|
|
11
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { COLUMN_SETTINGS_MODE } from '../../../../../constants.js';
|
|
2
|
+
import { getColumnSettingsMode } from './getColumnSettingsMode.js';
|
|
1
3
|
/**
|
|
2
4
|
* Проверка на то, должна ли колонка быть включена по умолчанию
|
|
3
5
|
* @function isColumnEnabledInitially
|
|
4
6
|
*/
|
|
5
7
|
export function isColumnEnabledInitially(colDef) {
|
|
6
|
-
|
|
7
|
-
return colDef.columnSettings?.mode !== 'defaultHidden';
|
|
8
|
-
}
|
|
9
|
-
return true;
|
|
8
|
+
return getColumnSettingsMode(colDef) !== COLUMN_SETTINGS_MODE.DefaultHidden;
|
|
10
9
|
}
|
package/dist/esm/components/Table/hooks/useColumnSettings/utils/isColumnVisibilityConfigurable.js
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
|
+
import { COLUMN_SETTINGS_MODE } from '../../../../../constants.js';
|
|
2
|
+
import { getColumnSettingsMode } from './getColumnSettingsMode.js';
|
|
1
3
|
/**
|
|
2
4
|
* Проверка на то, должна ли колонка отображаться в настройках колонок
|
|
3
5
|
* @function isColumnVisibilityConfigurable
|
|
4
6
|
*/
|
|
5
7
|
export function isColumnVisibilityConfigurable(colDef) {
|
|
6
|
-
|
|
7
|
-
const { mode } = colDef.columnSettings;
|
|
8
|
-
if (!mode) {
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
switch (mode) {
|
|
12
|
-
case 'locked':
|
|
13
|
-
return false;
|
|
14
|
-
case 'defaultVisible':
|
|
15
|
-
case 'defaultHidden':
|
|
16
|
-
default:
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return true;
|
|
8
|
+
return getColumnSettingsMode(colDef) !== COLUMN_SETTINGS_MODE.Locked;
|
|
21
9
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { COLUMN_SETTINGS_MODE } from '../../../../../constants.js';
|
|
2
|
+
import { getColumnSettingsMode, isServiceColumn } from './getColumnSettingsMode.js';
|
|
1
3
|
/**
|
|
2
4
|
* Проверка на то, должна ли колонка отображаться в таблице
|
|
3
5
|
* @function isFilterableColumn
|
|
4
6
|
*/
|
|
5
7
|
export function isFilterableColumn(colDef) {
|
|
6
8
|
return (('id' in colDef || 'accessorKey' in colDef) &&
|
|
7
|
-
|
|
8
|
-
colDef
|
|
9
|
+
!isServiceColumn(colDef) &&
|
|
10
|
+
getColumnSettingsMode(colDef) !== COLUMN_SETTINGS_MODE.Locked);
|
|
9
11
|
}
|
|
@@ -31,7 +31,6 @@ export function useTableScroll({ usePageStickyHeader, isStickyControls, stickyCo
|
|
|
31
31
|
const wrapper = wrapperRef.current;
|
|
32
32
|
if (!usePageStickyHeader) {
|
|
33
33
|
wrapper?.style.removeProperty(TABLE_CSS_VARS.headerScrollLeft);
|
|
34
|
-
wrapper?.style.removeProperty(TABLE_CSS_VARS.viewportWidth);
|
|
35
34
|
return;
|
|
36
35
|
}
|
|
37
36
|
const viewport = internalScrollRef.current;
|
|
@@ -43,6 +42,21 @@ export function useTableScroll({ usePageStickyHeader, isStickyControls, stickyCo
|
|
|
43
42
|
observer.observe(viewport);
|
|
44
43
|
return () => observer.disconnect();
|
|
45
44
|
}, [usePageStickyHeader, isScrollReady, columnSizeVars, syncHeaderHorizontalScroll, view, isLoadingState]);
|
|
45
|
+
// Ширина вьюпорта нужна не только sticky-шапке: по ней центрируется пустое состояние.
|
|
46
|
+
useLayoutEffect(() => {
|
|
47
|
+
const wrapper = wrapperRef.current;
|
|
48
|
+
const viewport = internalScrollRef.current;
|
|
49
|
+
if (!wrapper || !viewport) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const syncViewportWidth = () => {
|
|
53
|
+
wrapper.style.setProperty(TABLE_CSS_VARS.viewportWidth, `${viewport.clientWidth}px`);
|
|
54
|
+
};
|
|
55
|
+
syncViewportWidth();
|
|
56
|
+
const observer = new ResizeObserver(syncViewportWidth);
|
|
57
|
+
observer.observe(viewport);
|
|
58
|
+
return () => observer.disconnect();
|
|
59
|
+
}, [isScrollReady, usePageStickyHeader, view, isCardsView, isLoadingState]);
|
|
46
60
|
useLayoutEffect(() => {
|
|
47
61
|
if (!usePageStickyHeader || !showToolbar) {
|
|
48
62
|
wrapperRef.current?.style.removeProperty(TABLE_CSS_VARS.stickyToolbarOffset);
|
|
@@ -442,7 +442,8 @@
|
|
|
442
442
|
flex:1 1 auto;
|
|
443
443
|
flex-direction:column;
|
|
444
444
|
width:100%;
|
|
445
|
-
min-width
|
|
445
|
+
min-width:-moz-max-content;
|
|
446
|
+
min-width:max-content;
|
|
446
447
|
min-height:100%;
|
|
447
448
|
}
|
|
448
449
|
|
|
@@ -575,4 +576,21 @@
|
|
|
575
576
|
flex:1 1 auto;
|
|
576
577
|
width:100%;
|
|
577
578
|
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));
|
|
578
596
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Modifier } from '@dnd-kit/core';
|
|
2
|
+
/**
|
|
3
|
+
* Копию тянет наверх к шапке: `useSortable` вызывают и ячейки тела с тем же id колонки,
|
|
4
|
+
* поэтому dnd-kit считает активным узлом последнюю из них и якорит оверлей по её строке.
|
|
5
|
+
*/
|
|
6
|
+
export declare const alignOverlayToHeader: Modifier;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isBrowser } from '@cloud-ru/ds-utils';
|
|
2
|
+
import { TEST_IDS } from '../../../constants.js';
|
|
3
|
+
function getHeaderCellTop(columnId) {
|
|
4
|
+
if (isBrowser()) {
|
|
5
|
+
const headerCell = document.querySelector(`[data-test-id="${TEST_IDS.headerCell}"][data-header-id="${CSS.escape(columnId)}"]`);
|
|
6
|
+
return headerCell?.getBoundingClientRect().top;
|
|
7
|
+
}
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Копию тянет наверх к шапке: `useSortable` вызывают и ячейки тела с тем же id колонки,
|
|
12
|
+
* поэтому dnd-kit считает активным узлом последнюю из них и якорит оверлей по её строке.
|
|
13
|
+
*/
|
|
14
|
+
export const alignOverlayToHeader = ({ transform, active, activeNodeRect }) => {
|
|
15
|
+
const columnId = active?.id;
|
|
16
|
+
if (!columnId || !activeNodeRect) {
|
|
17
|
+
return transform;
|
|
18
|
+
}
|
|
19
|
+
const headerTop = getHeaderCellTop(String(columnId));
|
|
20
|
+
if (headerTop === undefined) {
|
|
21
|
+
return transform;
|
|
22
|
+
}
|
|
23
|
+
return { ...transform, y: transform.y + headerTop - activeNodeRect.top };
|
|
24
|
+
};
|