@astral/ui 4.45.0 → 4.46.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/components/DataGrid/Body/Body.d.ts +1 -98
- package/components/DataGrid/Body/Body.js +3 -15
- package/components/DataGrid/Body/index.d.ts +1 -0
- package/components/DataGrid/Body/index.js +1 -0
- package/components/DataGrid/Body/types.d.ts +110 -0
- package/components/DataGrid/Body/types.js +1 -0
- package/components/DataGrid/DataGrid.js +30 -5
- package/components/DataGrid/Head/Head.d.ts +4 -0
- package/components/DataGrid/Head/Head.js +3 -2
- package/components/DataGrid/Loader/Loader.js +2 -2
- package/components/DataGrid/Loader/styles.js +4 -2
- package/components/DataGrid/PinnedSections/PinnedSections.d.ts +35 -0
- package/components/DataGrid/PinnedSections/PinnedSections.js +11 -0
- package/components/DataGrid/PinnedSections/Section/Section.d.ts +3 -0
- package/components/DataGrid/PinnedSections/Section/Section.js +17 -0
- package/components/DataGrid/PinnedSections/Section/index.d.ts +1 -0
- package/components/DataGrid/PinnedSections/Section/index.js +1 -0
- package/components/DataGrid/PinnedSections/Section/styles.d.ts +5 -0
- package/components/DataGrid/PinnedSections/Section/styles.js +100 -0
- package/components/DataGrid/PinnedSections/Section/types.d.ts +26 -0
- package/components/DataGrid/PinnedSections/Section/types.js +1 -0
- package/components/DataGrid/PinnedSections/Section/useLogic/useLogic.d.ts +9 -0
- package/components/DataGrid/PinnedSections/Section/useLogic/useLogic.js +16 -0
- package/components/DataGrid/PinnedSections/index.d.ts +1 -0
- package/components/DataGrid/PinnedSections/index.js +1 -0
- package/components/DataGrid/PinnedSections/styles.d.ts +7 -0
- package/components/DataGrid/PinnedSections/styles.js +18 -0
- package/components/DataGrid/PinnedSections/types.d.ts +5 -0
- package/components/DataGrid/PinnedSections/types.js +1 -0
- package/components/DataGrid/PinnedSections/useLogic/index.js +1 -0
- package/components/DataGrid/PinnedSections/useLogic/useLogic.d.ts +9 -0
- package/components/DataGrid/PinnedSections/useLogic/useLogic.js +19 -0
- package/components/DataGrid/Row/NestedChildren/NestedChildren.js +2 -2
- package/components/DataGrid/Row/Row.d.ts +1 -94
- package/components/DataGrid/Row/Row.js +23 -8
- package/components/DataGrid/Row/constants.d.ts +3 -1
- package/components/DataGrid/Row/constants.js +3 -1
- package/components/DataGrid/Row/styles.js +9 -8
- package/components/DataGrid/Row/types.d.ts +118 -0
- package/components/DataGrid/Row/types.js +1 -0
- package/components/DataGrid/Row/useLogic/useLogic.d.ts +3 -2
- package/components/DataGrid/Row/useLogic/useLogic.js +14 -2
- package/components/DataGrid/constants.d.ts +7 -0
- package/components/DataGrid/constants.js +7 -0
- package/components/DataGrid/hooks/index.d.ts +1 -0
- package/components/DataGrid/hooks/index.js +1 -0
- package/components/DataGrid/hooks/useRowHover/index.d.ts +1 -0
- package/components/DataGrid/hooks/useRowHover/index.js +1 -0
- package/components/DataGrid/hooks/useRowHover/useRowHover.d.ts +15 -0
- package/components/DataGrid/hooks/useRowHover/useRowHover.js +93 -0
- package/components/DataGrid/styles.js +17 -0
- package/components/DataGrid/types.d.ts +4 -0
- package/components/DataGrid/useLogic/hooks/index.d.ts +2 -0
- package/components/DataGrid/useLogic/hooks/index.js +2 -0
- package/components/DataGrid/useLogic/hooks/useClassnames/index.d.ts +1 -0
- package/components/DataGrid/useLogic/hooks/useClassnames/index.js +1 -0
- package/components/DataGrid/useLogic/hooks/useClassnames/useClassnames.d.ts +12 -0
- package/components/DataGrid/useLogic/hooks/useClassnames/useClassnames.js +14 -0
- package/components/DataGrid/useLogic/hooks/usePinnedColumns/index.d.ts +1 -0
- package/components/DataGrid/useLogic/hooks/usePinnedColumns/index.js +1 -0
- package/components/DataGrid/useLogic/hooks/usePinnedColumns/usePinnedColumns.d.ts +18 -0
- package/components/DataGrid/useLogic/hooks/usePinnedColumns/usePinnedColumns.js +43 -0
- package/components/DataGrid/useLogic/useLogic.d.ts +30 -4
- package/components/DataGrid/useLogic/useLogic.js +55 -16
- package/components/DataGrid/useLogic/utils/getColumnSections/getColumnSections.d.ts +17 -0
- package/components/DataGrid/useLogic/utils/getColumnSections/getColumnSections.js +45 -0
- package/components/DataGrid/useLogic/utils/getColumnSections/index.d.ts +1 -0
- package/components/DataGrid/useLogic/utils/getColumnSections/index.js +1 -0
- package/components/DataGrid/useLogic/utils/index.d.ts +2 -1
- package/components/DataGrid/useLogic/utils/index.js +2 -1
- package/components/DataGrid/useLogic/utils/syncRowsHeight/index.d.ts +1 -0
- package/components/DataGrid/useLogic/utils/syncRowsHeight/index.js +1 -0
- package/components/DataGrid/useLogic/utils/syncRowsHeight/syncRowsHeight.d.ts +5 -0
- package/components/DataGrid/useLogic/utils/syncRowsHeight/syncRowsHeight.js +21 -0
- package/components/DataGrid/utils/index.d.ts +1 -0
- package/components/DataGrid/utils/index.js +1 -0
- package/components/DataGridInfinite/useLogic/useLogic.js +1 -1
- package/node/components/DataGrid/Body/Body.d.ts +1 -98
- package/node/components/DataGrid/Body/Body.js +3 -15
- package/node/components/DataGrid/Body/index.d.ts +1 -0
- package/node/components/DataGrid/Body/index.js +1 -0
- package/node/components/DataGrid/Body/types.d.ts +110 -0
- package/node/components/DataGrid/Body/types.js +2 -0
- package/node/components/DataGrid/DataGrid.js +29 -4
- package/node/components/DataGrid/Head/Head.d.ts +4 -0
- package/node/components/DataGrid/Head/Head.js +3 -2
- package/node/components/DataGrid/Loader/Loader.js +1 -1
- package/node/components/DataGrid/Loader/styles.js +4 -2
- package/node/components/DataGrid/PinnedSections/PinnedSections.d.ts +35 -0
- package/node/components/DataGrid/PinnedSections/PinnedSections.js +15 -0
- package/node/components/DataGrid/PinnedSections/Section/Section.d.ts +3 -0
- package/node/components/DataGrid/PinnedSections/Section/Section.js +21 -0
- package/node/components/DataGrid/PinnedSections/Section/index.d.ts +1 -0
- package/node/components/DataGrid/PinnedSections/Section/index.js +17 -0
- package/node/components/DataGrid/PinnedSections/Section/styles.d.ts +5 -0
- package/node/components/DataGrid/PinnedSections/Section/styles.js +103 -0
- package/node/components/DataGrid/PinnedSections/Section/types.d.ts +26 -0
- package/node/components/DataGrid/PinnedSections/Section/types.js +2 -0
- package/node/components/DataGrid/PinnedSections/Section/useLogic/index.d.ts +1 -0
- package/node/components/DataGrid/PinnedSections/Section/useLogic/useLogic.d.ts +9 -0
- package/node/components/DataGrid/PinnedSections/Section/useLogic/useLogic.js +20 -0
- package/node/components/DataGrid/PinnedSections/index.d.ts +1 -0
- package/node/components/DataGrid/PinnedSections/index.js +17 -0
- package/node/components/DataGrid/PinnedSections/styles.d.ts +7 -0
- package/node/components/DataGrid/PinnedSections/styles.js +21 -0
- package/node/components/DataGrid/PinnedSections/types.d.ts +5 -0
- package/node/components/DataGrid/PinnedSections/types.js +2 -0
- package/node/components/DataGrid/PinnedSections/useLogic/index.d.ts +1 -0
- package/node/components/DataGrid/PinnedSections/useLogic/index.js +17 -0
- package/node/components/DataGrid/PinnedSections/useLogic/useLogic.d.ts +9 -0
- package/node/components/DataGrid/PinnedSections/useLogic/useLogic.js +23 -0
- package/node/components/DataGrid/Row/NestedChildren/NestedChildren.js +1 -1
- package/node/components/DataGrid/Row/Row.d.ts +1 -94
- package/node/components/DataGrid/Row/Row.js +23 -8
- package/node/components/DataGrid/Row/constants.d.ts +3 -1
- package/node/components/DataGrid/Row/constants.js +4 -2
- package/node/components/DataGrid/Row/styles.js +8 -7
- package/node/components/DataGrid/Row/types.d.ts +118 -0
- package/node/components/DataGrid/Row/types.js +2 -0
- package/node/components/DataGrid/Row/useLogic/useLogic.d.ts +3 -2
- package/node/components/DataGrid/Row/useLogic/useLogic.js +13 -1
- package/node/components/DataGrid/constants.d.ts +7 -0
- package/node/components/DataGrid/constants.js +7 -0
- package/node/components/DataGrid/hooks/index.d.ts +1 -0
- package/node/components/DataGrid/hooks/index.js +17 -0
- package/node/components/DataGrid/hooks/useRowHover/index.d.ts +1 -0
- package/node/components/DataGrid/hooks/useRowHover/index.js +17 -0
- package/node/components/DataGrid/hooks/useRowHover/useRowHover.d.ts +15 -0
- package/node/components/DataGrid/hooks/useRowHover/useRowHover.js +97 -0
- package/node/components/DataGrid/styles.js +17 -0
- package/node/components/DataGrid/types.d.ts +4 -0
- package/node/components/DataGrid/useLogic/hooks/index.d.ts +2 -0
- package/node/components/DataGrid/useLogic/hooks/index.js +18 -0
- package/node/components/DataGrid/useLogic/hooks/useClassnames/index.d.ts +1 -0
- package/node/components/DataGrid/useLogic/hooks/useClassnames/index.js +17 -0
- package/node/components/DataGrid/useLogic/hooks/useClassnames/useClassnames.d.ts +12 -0
- package/node/components/DataGrid/useLogic/hooks/useClassnames/useClassnames.js +18 -0
- package/node/components/DataGrid/useLogic/hooks/usePinnedColumns/index.d.ts +1 -0
- package/node/components/DataGrid/useLogic/hooks/usePinnedColumns/index.js +17 -0
- package/node/components/DataGrid/useLogic/hooks/usePinnedColumns/usePinnedColumns.d.ts +18 -0
- package/node/components/DataGrid/useLogic/hooks/usePinnedColumns/usePinnedColumns.js +47 -0
- package/node/components/DataGrid/useLogic/useLogic.d.ts +30 -4
- package/node/components/DataGrid/useLogic/useLogic.js +53 -14
- package/node/components/DataGrid/useLogic/utils/getColumnSections/getColumnSections.d.ts +17 -0
- package/node/components/DataGrid/useLogic/utils/getColumnSections/getColumnSections.js +50 -0
- package/node/components/DataGrid/useLogic/utils/getColumnSections/index.d.ts +1 -0
- package/node/components/DataGrid/useLogic/utils/getColumnSections/index.js +17 -0
- package/node/components/DataGrid/useLogic/utils/index.d.ts +2 -1
- package/node/components/DataGrid/useLogic/utils/index.js +5 -3
- package/node/components/DataGrid/useLogic/utils/syncRowsHeight/index.d.ts +1 -0
- package/node/components/DataGrid/useLogic/utils/syncRowsHeight/index.js +17 -0
- package/node/components/DataGrid/useLogic/utils/syncRowsHeight/syncRowsHeight.d.ts +5 -0
- package/node/components/DataGrid/useLogic/utils/syncRowsHeight/syncRowsHeight.js +25 -0
- package/node/components/DataGrid/utils/index.d.ts +1 -0
- package/node/components/DataGrid/utils/index.js +3 -1
- package/node/components/DataGridInfinite/useLogic/useLogic.js +1 -1
- package/package.json +1 -1
- package/components/DataGrid/Body/useLogic/useLogic.d.ts +0 -12
- package/components/DataGrid/Body/useLogic/useLogic.js +0 -11
- package/node/components/DataGrid/Body/useLogic/useLogic.d.ts +0 -12
- package/node/components/DataGrid/Body/useLogic/useLogic.js +0 -15
- /package/components/DataGrid/{Body → PinnedSections/Section}/useLogic/index.d.ts +0 -0
- /package/components/DataGrid/{Body → PinnedSections/Section}/useLogic/index.js +0 -0
- /package/{node/components/DataGrid/Body → components/DataGrid/PinnedSections}/useLogic/index.d.ts +0 -0
- /package/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/getGridTemplateColumns.d.ts +0 -0
- /package/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/getGridTemplateColumns.js +0 -0
- /package/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/index.d.ts +0 -0
- /package/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/index.js +0 -0
- /package/node/components/DataGrid/{Body → PinnedSections/Section}/useLogic/index.js +0 -0
- /package/node/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/getGridTemplateColumns.d.ts +0 -0
- /package/node/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/getGridTemplateColumns.js +0 -0
- /package/node/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/index.d.ts +0 -0
- /package/node/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/index.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useLogic';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type CSSProperties } from 'react';
|
|
2
|
+
import { type CellValue, type DataGridRow } from '../../types';
|
|
3
|
+
import { type PinnedSectionsProps } from '../PinnedSections';
|
|
4
|
+
type UseLogicParams<TData extends Record<string, CellValue> = DataGridRow> = Pick<PinnedSectionsProps<TData>, 'sections'>;
|
|
5
|
+
export declare const useLogic: <TData extends Record<string, unknown> = DataGridRow>({ sections, }: UseLogicParams<TData>) => {
|
|
6
|
+
pinnedContainerStyles: CSSProperties;
|
|
7
|
+
sectionOffsets: Record<string, number>;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
export const useLogic = ({ sections, }) => {
|
|
3
|
+
const pinnedContainerStyles = {
|
|
4
|
+
'--left-columns-count': sections.find((section) => section.position === 'left')?.columns
|
|
5
|
+
?.length ?? 0,
|
|
6
|
+
'--right-columns-count': sections.find((section) => section.position === 'right')?.columns
|
|
7
|
+
?.length ?? 0,
|
|
8
|
+
};
|
|
9
|
+
const sectionOffsets = useMemo(() => {
|
|
10
|
+
const offsets = {};
|
|
11
|
+
let currentOffset = 0;
|
|
12
|
+
sections.forEach((section) => {
|
|
13
|
+
offsets[section.position] = currentOffset;
|
|
14
|
+
currentOffset += section.columns?.length ?? 0;
|
|
15
|
+
});
|
|
16
|
+
return offsets;
|
|
17
|
+
}, [sections]);
|
|
18
|
+
return { pinnedContainerStyles, sectionOffsets };
|
|
19
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { memo } from 'react';
|
|
3
3
|
import { Collapse } from '../../../Collapse';
|
|
4
|
-
import {
|
|
4
|
+
import { dataGridRowClassnames } from '../constants';
|
|
5
5
|
import { MoreButton, MoreButtonRow, NestedRows } from './styles';
|
|
6
6
|
import { useLogic } from './useLogic';
|
|
7
7
|
export const NestedChildren = memo((props) => {
|
|
@@ -27,7 +27,7 @@ export const NestedChildren = memo((props) => {
|
|
|
27
27
|
options,
|
|
28
28
|
nestedChildren: children,
|
|
29
29
|
level: nextLevel,
|
|
30
|
-
className:
|
|
30
|
+
className: dataGridRowClassnames.hidden,
|
|
31
31
|
});
|
|
32
32
|
}) }) }), isShowMoreButton && (_jsx(MoreButtonRow, { "$level": nextLevel, "$isShowConnector": isShowConnector, "$gridColumns": gridColumns, children: _jsx(MoreButton, { "$moreButtonColumnPosition": moreButtonColumnPosition, variant: "link", onClick: handleToggleShowAllChildren, children: isShowAllChildren ? 'Скрыть' : 'Показать все' }) }))] }))] }) }));
|
|
33
33
|
});
|
|
@@ -1,95 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { type Variant } from '../enums';
|
|
3
|
-
import type { CellValue, DataGridColumns, DataGridRowOptions } from '../types';
|
|
4
|
-
export type RowProps<TData extends Record<string, CellValue>> = {
|
|
5
|
-
/**
|
|
6
|
-
* Название класса, применяется к корневому компоненту
|
|
7
|
-
*/
|
|
8
|
-
className?: string;
|
|
9
|
-
/**
|
|
10
|
-
* Поле, которое будет использоваться в качестве ключа
|
|
11
|
-
*/
|
|
12
|
-
keyId: keyof TData;
|
|
13
|
-
/**
|
|
14
|
-
* Данные строки для отображения
|
|
15
|
-
*/
|
|
16
|
-
row: TData;
|
|
17
|
-
/**
|
|
18
|
-
* Конфигурация колонок для таблицы
|
|
19
|
-
*/
|
|
20
|
-
columns: DataGridColumns<TData>[];
|
|
21
|
-
/**
|
|
22
|
-
* Вариант отображения вложенных элементов
|
|
23
|
-
*/
|
|
24
|
-
variant: `${Variant}`;
|
|
25
|
-
/**
|
|
26
|
-
* Конфигурация ширины колонок
|
|
27
|
-
*/
|
|
28
|
-
gridColumns: string;
|
|
29
|
-
/**
|
|
30
|
-
* Уровень вложенности в дереве
|
|
31
|
-
*/
|
|
32
|
-
level: number;
|
|
33
|
-
/**
|
|
34
|
-
* Вложенные элементы
|
|
35
|
-
*/
|
|
36
|
-
nestedChildren: Array<TData & {
|
|
37
|
-
options?: DataGridRowOptions<TData>;
|
|
38
|
-
}>;
|
|
39
|
-
/**
|
|
40
|
-
* Идентификатор активного элемента массива rows. Выделяет активную строку в таблице
|
|
41
|
-
*/
|
|
42
|
-
activeRowId?: string;
|
|
43
|
-
/**
|
|
44
|
-
* Если true, то дерево будет раскрыто по умолчанию
|
|
45
|
-
*/
|
|
46
|
-
isInitialExpanded: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Уровень раскрытия дерева по умолчанию, при isInitialExpanded=true
|
|
49
|
-
*/
|
|
50
|
-
expandedLevel: number;
|
|
51
|
-
/**
|
|
52
|
-
* Количество отображаемых по умолчанию дочерних элементов
|
|
53
|
-
*/
|
|
54
|
-
initialVisibleChildrenCount: number;
|
|
55
|
-
/**
|
|
56
|
-
* Номер колонки, в которой будет расположена кнопка "Показать все"
|
|
57
|
-
* Работает только для `variant="subrows"`
|
|
58
|
-
*/
|
|
59
|
-
moreButtonColumnPosition: number;
|
|
60
|
-
/**
|
|
61
|
-
* Если false, кнопка разворачивания элементов не показывается
|
|
62
|
-
* Работает только для `variant="subrows"`
|
|
63
|
-
*/
|
|
64
|
-
isVisibleCollapseButton: boolean;
|
|
65
|
-
/**
|
|
66
|
-
* Если true, то будет отображаться чекбокс для выбора элемента
|
|
67
|
-
*/
|
|
68
|
-
isSelectable?: boolean;
|
|
69
|
-
/**
|
|
70
|
-
* Флаг выбора текущей строки
|
|
71
|
-
*/
|
|
72
|
-
isSelected?: boolean;
|
|
73
|
-
/**
|
|
74
|
-
* Массив выбранных строк
|
|
75
|
-
*/
|
|
76
|
-
selectedRows?: TData[];
|
|
77
|
-
/**
|
|
78
|
-
* Заглушка для пустых ячеек (если отсутствует field и filter и renderCell)
|
|
79
|
-
* @default '-'
|
|
80
|
-
*/
|
|
81
|
-
emptyCellValue?: ReactNode;
|
|
82
|
-
/**
|
|
83
|
-
* Дополнительные настройки строки
|
|
84
|
-
*/
|
|
85
|
-
options?: DataGridRowOptions<TData>;
|
|
86
|
-
/**
|
|
87
|
-
* Обработчик выбора строки
|
|
88
|
-
*/
|
|
89
|
-
onSelectRow: (row: TData) => (event: ChangeEvent<HTMLInputElement>) => void;
|
|
90
|
-
/**
|
|
91
|
-
* Обработчик клика строки таблицы
|
|
92
|
-
*/
|
|
93
|
-
onRowClick?: (row: TData) => void;
|
|
94
|
-
};
|
|
1
|
+
import type { RowProps } from './types';
|
|
95
2
|
export declare const Row: <TData extends Record<string, unknown>>(props: RowProps<TData>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,8 +10,8 @@ import { CellStyled, CheckboxCell, ChevronIcon, CollapseButton, CollapseCell, Co
|
|
|
10
10
|
import { useLogic } from './useLogic';
|
|
11
11
|
import { checkIsDisabled } from './utils';
|
|
12
12
|
const RowComponent = (props) => {
|
|
13
|
-
const { isOpen, isShowConnector, childrenColumns, rowId, handleToggle, checkboxProps, rowProps, tooltipProps, nestedChildrenProps, disabled, isRenderCollapseButton, } = useLogic(props);
|
|
14
|
-
const { className, row, options, variant, isSelectable, gridColumns, isInitialExpanded, expandedLevel, level, nestedChildren, initialVisibleChildrenCount, moreButtonColumnPosition, isVisibleCollapseButton, columns, emptyCellValue, selectedRows, activeRowId, keyId, onSelectRow, onRowClick,
|
|
13
|
+
const { isOpen, isShowConnector, childrenColumns, rowId, handleToggle, checkboxProps, rowProps, tooltipProps, nestedChildrenProps, disabled, isRenderCollapseButton, rowRef, } = useLogic(props);
|
|
14
|
+
const { className, row, options, variant, isSelectable, gridColumns, isInitialExpanded, expandedLevel, level, nestedChildren, initialVisibleChildrenCount, moreButtonColumnPosition, isVisibleCollapseButton, columns, emptyCellValue, selectedRows, activeRowId, keyId, onSelectRow, onRowClick, sectionOffset, totalColumnsCount, registerRowElement, unregisterRowElement, onRowEnter, onRowLeave,
|
|
15
15
|
// В этот rest-оператор попадают специфичные пропсы (атрибуты) virtuoso
|
|
16
16
|
// Необходимы для DataGridInfinite
|
|
17
17
|
...selfProps } = props;
|
|
@@ -23,17 +23,26 @@ const RowComponent = (props) => {
|
|
|
23
23
|
return (_jsxs(_Fragment, { children: [isRenderCollapseButton && (_jsx(CollapseCell, { children: _jsx(CollapseButton, { variant: "text", onClick: handleToggle, children: _jsx(ChevronIcon, { "$isActive": isOpen }) }) })), isSelectable && !isNotSelectable && (_jsx(CheckboxCell, { ...getInertProps(disabled), onClick: (event) => event.stopPropagation(), children: _jsx(Checkbox, { ...checkboxProps }) }))] }));
|
|
24
24
|
};
|
|
25
25
|
const renderCells = useCallback(() => {
|
|
26
|
+
const lastCellGlobalIndex = (totalColumnsCount ?? columns.length) - 1;
|
|
26
27
|
const availableCellsByIndex = !isDisabledLastCell
|
|
27
|
-
? [
|
|
28
|
+
? [lastCellGlobalIndex]
|
|
28
29
|
: undefined;
|
|
29
30
|
return columns?.map((cell, index) => {
|
|
30
31
|
const cellId = `${rowId}-${index}`;
|
|
31
|
-
const
|
|
32
|
-
const
|
|
32
|
+
const globalIndex = (sectionOffset ?? 0) + index;
|
|
33
|
+
const isDisabledCell = checkIsDisabled(disabled, availableCellsByIndex, globalIndex);
|
|
34
|
+
const isFirstCell = globalIndex === 0;
|
|
33
35
|
return (_jsx(CellStyled, { "$level": isFirstCell ? level : 0, row: row, cell: cell, emptyCellValue: emptyCellValue, startAdornment: isFirstCell && renderStartAdornment(), isDisabled: isDisabledCell, isHidePersonalData: cell.isHidePersonalData }, cellId));
|
|
34
36
|
});
|
|
35
|
-
}, [
|
|
36
|
-
|
|
37
|
+
}, [
|
|
38
|
+
isOpen,
|
|
39
|
+
columns,
|
|
40
|
+
disabled,
|
|
41
|
+
checkboxProps.checked,
|
|
42
|
+
totalColumnsCount,
|
|
43
|
+
sectionOffset,
|
|
44
|
+
]);
|
|
45
|
+
const renderRow = useCallback(({ key, ...nestedRowProps }) => (_jsx(Row, { keyId: keyId, ...nestedRowProps, variant: variant, isSelectable: isSelectable, selectedRows: selectedRows, gridColumns: gridColumns, isInitialExpanded: isInitialExpanded, expandedLevel: expandedLevel, initialVisibleChildrenCount: initialVisibleChildrenCount, moreButtonColumnPosition: moreButtonColumnPosition, isVisibleCollapseButton: isVisibleCollapseButton, activeRowId: activeRowId, columns: childrenColumns, onSelectRow: onSelectRow, onRowClick: onRowClick, totalColumnsCount: totalColumnsCount, registerRowElement: registerRowElement, unregisterRowElement: unregisterRowElement, onRowEnter: onRowEnter, onRowLeave: onRowLeave, sectionOffset: sectionOffset }, key)), [
|
|
37
46
|
keyId,
|
|
38
47
|
variant,
|
|
39
48
|
isSelectable,
|
|
@@ -43,12 +52,18 @@ const RowComponent = (props) => {
|
|
|
43
52
|
expandedLevel,
|
|
44
53
|
initialVisibleChildrenCount,
|
|
45
54
|
moreButtonColumnPosition,
|
|
55
|
+
sectionOffset,
|
|
56
|
+
totalColumnsCount,
|
|
46
57
|
activeRowId,
|
|
47
58
|
childrenColumns,
|
|
48
59
|
onSelectRow,
|
|
49
60
|
onRowClick,
|
|
61
|
+
registerRowElement,
|
|
62
|
+
unregisterRowElement,
|
|
63
|
+
onRowEnter,
|
|
64
|
+
onRowLeave,
|
|
50
65
|
]);
|
|
51
|
-
return (_jsxs(Wrapper, { "$level": level, "$isShowConnector": isShowConnector, className: className, ...selfProps, children: [_jsx(Tooltip, { followCursor: true, arrow: false, ...tooltipProps, children: _jsx(ContentWrapper, { "$level": level, "$isShowConnector": isShowConnector, "$gridColumns": gridColumns, [DISABLE_ROW_ATTR]: disabled, ...rowProps, children: renderCells() }) }), _jsx(NestedChildren, { ...nestedChildrenProps, data: nestedChildren, keyId: keyId, level: level, variant: variant, gridColumns: gridColumns, initialVisibleChildrenCount: initialVisibleChildrenCount, moreButtonColumnPosition: moreButtonColumnPosition,
|
|
66
|
+
return (_jsxs(Wrapper, { "$level": level, "$isShowConnector": isShowConnector, className: className, ...selfProps, children: [_jsx(Tooltip, { followCursor: true, arrow: false, ...tooltipProps, children: _jsx(ContentWrapper, { "$level": level, "data-row-id": rowId, ref: rowRef, onPointerEnter: () => onRowEnter?.(rowId), onPointerLeave: (event) => onRowLeave?.(rowId, event.nativeEvent), "$isShowConnector": isShowConnector, "$gridColumns": gridColumns, [DISABLE_ROW_ATTR]: disabled, ...rowProps, children: renderCells() }) }), _jsx(NestedChildren, { ...nestedChildrenProps, data: nestedChildren, keyId: keyId, level: level, variant: variant, gridColumns: gridColumns, initialVisibleChildrenCount: initialVisibleChildrenCount, moreButtonColumnPosition: moreButtonColumnPosition,
|
|
52
67
|
// biome-ignore lint/suspicious/noTsIgnore: <>
|
|
53
68
|
// @ts-ignore
|
|
54
69
|
renderRow: renderRow })] }));
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { createUIKitClassname } from '../../utils/createUIKitClassname';
|
|
2
2
|
export const DISABLE_ROW_ATTR = 'data-row-disable';
|
|
3
|
-
export const
|
|
3
|
+
export const dataGridRowClassnames = {
|
|
4
4
|
hidden: createUIKitClassname('data-grid__row_hidden'),
|
|
5
|
+
hover: createUIKitClassname('data-grid__row_hover'),
|
|
6
|
+
hasPinnedColumns: createUIKitClassname('data-grid__row_has-pinned-columns'),
|
|
5
7
|
};
|
|
@@ -3,12 +3,12 @@ import { IconButton } from '../../IconButton';
|
|
|
3
3
|
import { styled } from '../../styled';
|
|
4
4
|
import { Cell } from '../Cell';
|
|
5
5
|
import { ROOT_ACTION_CELL_WIDTH, TREE_LINE_WIDTH } from '../constants';
|
|
6
|
-
import {
|
|
6
|
+
import { dataGridRowClassnames } from './constants';
|
|
7
7
|
export const Wrapper = styled.li `
|
|
8
8
|
position: relative;
|
|
9
9
|
|
|
10
10
|
&:not(:last-of-type)::before,
|
|
11
|
-
&.${
|
|
11
|
+
&.${dataGridRowClassnames.hidden}::before {
|
|
12
12
|
content: '';
|
|
13
13
|
|
|
14
14
|
position: absolute;
|
|
@@ -32,12 +32,6 @@ export const ContentWrapper = styled.div `
|
|
|
32
32
|
|
|
33
33
|
background-color: ${({ theme, $isSelected }) => $isSelected ? theme.palette.primary[100] : 'transparent'};
|
|
34
34
|
|
|
35
|
-
transition: ${({ theme }) => {
|
|
36
|
-
return theme.transitions.create(['background-color'], {
|
|
37
|
-
duration: theme.transitions.duration.short,
|
|
38
|
-
});
|
|
39
|
-
}};
|
|
40
|
-
|
|
41
35
|
&::before {
|
|
42
36
|
content: '';
|
|
43
37
|
|
|
@@ -58,6 +52,13 @@ export const ContentWrapper = styled.div `
|
|
|
58
52
|
&:hover {
|
|
59
53
|
cursor: ${({ $isHovered }) => ($isHovered ? 'pointer' : 'default')};
|
|
60
54
|
|
|
55
|
+
background-color: ${({ theme }) => theme.palette.background.elementHover};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
&.${dataGridRowClassnames.hover} {
|
|
60
|
+
cursor: ${({ $isHovered }) => ($isHovered ? 'pointer' : 'default')};
|
|
61
|
+
|
|
61
62
|
background-color: ${({ theme, $isSelected }) => $isSelected
|
|
62
63
|
? theme.palette.primary[100]
|
|
63
64
|
: theme.palette.background.elementHover};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { type ChangeEvent, type ReactNode } from 'react';
|
|
2
|
+
import { type Variant } from '../enums';
|
|
3
|
+
import { type CellValue, type DataGridColumns, type DataGridRowOptions } from '../types';
|
|
4
|
+
export type RowProps<TData extends Record<string, CellValue>> = {
|
|
5
|
+
/**
|
|
6
|
+
* Название класса, применяется к корневому компоненту
|
|
7
|
+
*/
|
|
8
|
+
className?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Поле, которое будет использоваться в качестве ключа
|
|
11
|
+
*/
|
|
12
|
+
keyId: keyof TData;
|
|
13
|
+
/**
|
|
14
|
+
* Данные строки для отображения
|
|
15
|
+
*/
|
|
16
|
+
row: TData;
|
|
17
|
+
/**
|
|
18
|
+
* Конфигурация колонок для таблицы
|
|
19
|
+
*/
|
|
20
|
+
columns: DataGridColumns<TData>[];
|
|
21
|
+
/**
|
|
22
|
+
* Вариант отображения вложенных элементов
|
|
23
|
+
*/
|
|
24
|
+
variant: `${Variant}`;
|
|
25
|
+
/**
|
|
26
|
+
* Конфигурация ширины колонок
|
|
27
|
+
*/
|
|
28
|
+
gridColumns: string;
|
|
29
|
+
/**
|
|
30
|
+
* Уровень вложенности в дереве
|
|
31
|
+
*/
|
|
32
|
+
level: number;
|
|
33
|
+
/**
|
|
34
|
+
* Вложенные элементы
|
|
35
|
+
*/
|
|
36
|
+
nestedChildren: Array<TData & {
|
|
37
|
+
options?: DataGridRowOptions<TData>;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Идентификатор активного элемента массива rows. Выделяет активную строку в таблице
|
|
41
|
+
*/
|
|
42
|
+
activeRowId?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Если true, то дерево будет раскрыто по умолчанию
|
|
45
|
+
*/
|
|
46
|
+
isInitialExpanded: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Уровень раскрытия дерева по умолчанию, при isInitialExpanded=true
|
|
49
|
+
*/
|
|
50
|
+
expandedLevel: number;
|
|
51
|
+
/**
|
|
52
|
+
* Количество отображаемых по умолчанию дочерних элементов
|
|
53
|
+
*/
|
|
54
|
+
initialVisibleChildrenCount: number;
|
|
55
|
+
/**
|
|
56
|
+
* Номер колонки, в которой будет расположена кнопка "Показать все"
|
|
57
|
+
* Работает только для `variant="subrows"`
|
|
58
|
+
*/
|
|
59
|
+
moreButtonColumnPosition: number;
|
|
60
|
+
/**
|
|
61
|
+
* Если false, кнопка разворачивания элементов не показывается
|
|
62
|
+
* Работает только для `variant="subrows"`
|
|
63
|
+
*/
|
|
64
|
+
isVisibleCollapseButton: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Если true, то будет отображаться чекбокс для выбора элемента
|
|
67
|
+
*/
|
|
68
|
+
isSelectable?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Флаг выбора текущей строки
|
|
71
|
+
*/
|
|
72
|
+
isSelected?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Массив выбранных строк
|
|
75
|
+
*/
|
|
76
|
+
selectedRows?: TData[];
|
|
77
|
+
/**
|
|
78
|
+
* Заглушка для пустых ячеек (если отсутствует field и filter и renderCell)
|
|
79
|
+
* @default '-'
|
|
80
|
+
*/
|
|
81
|
+
emptyCellValue?: ReactNode;
|
|
82
|
+
/**
|
|
83
|
+
* Дополнительные настройки строки
|
|
84
|
+
*/
|
|
85
|
+
options?: DataGridRowOptions<TData>;
|
|
86
|
+
/**
|
|
87
|
+
* Обработчик выбора строки
|
|
88
|
+
*/
|
|
89
|
+
onSelectRow: (row: TData) => (event: ChangeEvent<HTMLInputElement>) => void;
|
|
90
|
+
/**
|
|
91
|
+
* Обработчик клика строки таблицы
|
|
92
|
+
*/
|
|
93
|
+
onRowClick?: (row: TData) => void;
|
|
94
|
+
/**
|
|
95
|
+
* Смещение секции
|
|
96
|
+
*/
|
|
97
|
+
sectionOffset?: number;
|
|
98
|
+
/**
|
|
99
|
+
* Общее количество колонок (для правильного определения последней ячейки)
|
|
100
|
+
*/
|
|
101
|
+
totalColumnsCount?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Регистрация элемента строки
|
|
104
|
+
*/
|
|
105
|
+
registerRowElement?: (rowId: string, el: HTMLElement) => void;
|
|
106
|
+
/**
|
|
107
|
+
* Отмена регистрации элемента строки
|
|
108
|
+
*/
|
|
109
|
+
unregisterRowElement?: (rowId: string, el: HTMLElement) => void;
|
|
110
|
+
/**
|
|
111
|
+
* Обработчик наведения на строку
|
|
112
|
+
*/
|
|
113
|
+
onRowEnter?: (rowId: string) => void;
|
|
114
|
+
/**
|
|
115
|
+
* Обработчик выхода из строки
|
|
116
|
+
*/
|
|
117
|
+
onRowLeave?: (rowId: string, event: PointerEvent) => void;
|
|
118
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { type MouseEvent, type SyntheticEvent } from 'react';
|
|
2
2
|
import type { CellValue } from '../../types';
|
|
3
|
-
import {
|
|
3
|
+
import type { RowProps } from '../types';
|
|
4
4
|
type UseLogicParams<TData extends Record<string, CellValue>> = RowProps<TData>;
|
|
5
|
-
export declare const useLogic: <TData extends Record<string, unknown>>({ keyId, columns, row, nestedChildren, level, variant, activeRowId, options, isInitialExpanded, expandedLevel, isSelectable, selectedRows, onSelectRow, onRowClick, isVisibleCollapseButton, }: UseLogicParams<TData>) => {
|
|
5
|
+
export declare const useLogic: <TData extends Record<string, unknown>>({ keyId, columns, row, nestedChildren, level, variant, activeRowId, options, isInitialExpanded, expandedLevel, isSelectable, selectedRows, onSelectRow, onRowClick, isVisibleCollapseButton, registerRowElement, unregisterRowElement, }: UseLogicParams<TData>) => {
|
|
6
6
|
isOpen: boolean;
|
|
7
7
|
isShowConnector: boolean;
|
|
8
8
|
childrenColumns: any[];
|
|
9
9
|
rowId: string;
|
|
10
|
+
rowRef: (element: HTMLElement | null) => void;
|
|
10
11
|
disabled: boolean | undefined;
|
|
11
12
|
isRenderCollapseButton: boolean;
|
|
12
13
|
handleToggle: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
import { useContext, useEffect, useMemo, useState, } from 'react';
|
|
1
|
+
import { useContext, useEffect, useMemo, useRef, useState, } from 'react';
|
|
2
2
|
import { redirectToLink } from '../../../utils/redirectToLink';
|
|
3
3
|
import { DataGridContext } from '../../DataGridContext';
|
|
4
4
|
import { Variant } from '../../enums';
|
|
5
5
|
import { DISABLE_ROW_ATTR } from '../constants';
|
|
6
6
|
import { RowContext } from '../RowContext';
|
|
7
7
|
import { mergeColumnsOptions } from './utils';
|
|
8
|
-
export const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, activeRowId, options, isInitialExpanded = false, expandedLevel, isSelectable, selectedRows, onSelectRow, onRowClick, isVisibleCollapseButton, }) => {
|
|
8
|
+
export const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, activeRowId, options, isInitialExpanded = false, expandedLevel, isSelectable, selectedRows, onSelectRow, onRowClick, isVisibleCollapseButton, registerRowElement, unregisterRowElement, }) => {
|
|
9
9
|
const isDefaultExpanded = isInitialExpanded && level <= expandedLevel - 1 && nestedChildren?.length;
|
|
10
10
|
const { checkIsOpened, toggleOpenItems } = useContext(DataGridContext);
|
|
11
11
|
const { isDisabled, disabledReason } = useContext(RowContext);
|
|
12
|
+
const savedElementRef = useRef(null);
|
|
13
|
+
const rowRef = (element) => {
|
|
14
|
+
if (element) {
|
|
15
|
+
savedElementRef.current = element;
|
|
16
|
+
registerRowElement?.(rowId, element);
|
|
17
|
+
}
|
|
18
|
+
else if (savedElementRef.current) {
|
|
19
|
+
unregisterRowElement?.(rowId, savedElementRef.current);
|
|
20
|
+
savedElementRef.current = null;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
12
23
|
const [isVisibleTooltip, setVisibleTooltip] = useState(false);
|
|
13
24
|
const rowId = row[keyId];
|
|
14
25
|
const { isDisabled: isExternalDisabled, disabledReason: externalDisabledReason, href, target, } = options || {};
|
|
@@ -61,6 +72,7 @@ export const useLogic = ({ keyId, columns, row, nestedChildren, level, variant,
|
|
|
61
72
|
isShowConnector,
|
|
62
73
|
childrenColumns,
|
|
63
74
|
rowId,
|
|
75
|
+
rowRef,
|
|
64
76
|
disabled,
|
|
65
77
|
isRenderCollapseButton,
|
|
66
78
|
handleToggle,
|
|
@@ -9,4 +9,11 @@ export declare const dataGridClassnames: {
|
|
|
9
9
|
root: string;
|
|
10
10
|
body: string;
|
|
11
11
|
bodyEmpty: string;
|
|
12
|
+
disabled: string;
|
|
13
|
+
pinnedSectionNoData: string;
|
|
14
|
+
dataGridHasPinnedSections: string;
|
|
15
|
+
pinnedSections: string;
|
|
16
|
+
leftPinnedSection: string;
|
|
17
|
+
rightPinnedSection: string;
|
|
18
|
+
overflowed: string;
|
|
12
19
|
};
|
|
@@ -10,4 +10,11 @@ export const dataGridClassnames = {
|
|
|
10
10
|
root: createUIKitClassname('data-grid'),
|
|
11
11
|
body: createUIKitClassname('data-grid__body'),
|
|
12
12
|
bodyEmpty: createUIKitClassname('data-grid__body_empty'),
|
|
13
|
+
disabled: createUIKitClassname('data-grid_disabled'),
|
|
14
|
+
pinnedSectionNoData: createUIKitClassname('data-grid__pinned-section_no-data'),
|
|
15
|
+
dataGridHasPinnedSections: createUIKitClassname('data-grid_has-pinned-sections'),
|
|
16
|
+
pinnedSections: createUIKitClassname('data-grid__pinned-sections'),
|
|
17
|
+
leftPinnedSection: createUIKitClassname('data-grid__left-pinned-section'),
|
|
18
|
+
rightPinnedSection: createUIKitClassname('data-grid__right-pinned-section'),
|
|
19
|
+
overflowed: createUIKitClassname('data-grid_overflowed'),
|
|
13
20
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useRowHover';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useRowHover';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useRowHover';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useRowHover';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type UseRowHoverParams = {
|
|
3
|
+
hasPinnedColumns?: boolean;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Хук для синхронизации hover-состояния строк DataGrid через прямую работу с DOM.
|
|
7
|
+
*/
|
|
8
|
+
export declare const useRowHover: ({ hasPinnedColumns, }: UseRowHoverParams) => {
|
|
9
|
+
rowsMapRef: import("react").RefObject<Map<string, Set<HTMLElement>>>;
|
|
10
|
+
registerRowElement: (rowId: string, el: HTMLElement) => void;
|
|
11
|
+
unregisterRowElement: (rowId: string, el: HTMLElement) => void;
|
|
12
|
+
onRowEnter: (rowId: string) => void;
|
|
13
|
+
onRowLeave: (rowId: string, e: PointerEvent) => void;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { useCallback, useRef } from 'react';
|
|
2
|
+
import { dataGridRowClassnames } from '../../Row/constants';
|
|
3
|
+
/**
|
|
4
|
+
* Хук для синхронизации hover-состояния строк DataGrid через прямую работу с DOM.
|
|
5
|
+
*/
|
|
6
|
+
export const useRowHover = ({ hasPinnedColumns = false, }) => {
|
|
7
|
+
const rowsMapRef = useRef(new Map());
|
|
8
|
+
const hoveredRowIdRef = useRef(null);
|
|
9
|
+
const highlight = useCallback((rowId) => {
|
|
10
|
+
if (!hasPinnedColumns) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const elements = rowsMapRef.current.get(rowId);
|
|
14
|
+
if (!elements) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
elements.forEach((el) => {
|
|
18
|
+
if (!el.classList.contains(dataGridRowClassnames.hover)) {
|
|
19
|
+
el.classList.add(dataGridRowClassnames.hover);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}, [hasPinnedColumns]);
|
|
23
|
+
const unhighlight = useCallback((rowId) => {
|
|
24
|
+
if (!hasPinnedColumns) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const elements = rowsMapRef.current.get(rowId);
|
|
28
|
+
if (!elements) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
elements.forEach((el) => el.classList.remove(dataGridRowClassnames.hover));
|
|
32
|
+
return;
|
|
33
|
+
}, [hasPinnedColumns]);
|
|
34
|
+
const registerRowElement = useCallback((rowId, el) => {
|
|
35
|
+
if (!hasPinnedColumns) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const map = rowsMapRef.current;
|
|
39
|
+
if (!map.has(rowId)) {
|
|
40
|
+
map.set(rowId, new Set());
|
|
41
|
+
}
|
|
42
|
+
map.get(rowId).add(el);
|
|
43
|
+
}, [hasPinnedColumns]);
|
|
44
|
+
const unregisterRowElement = useCallback((rowId, el) => {
|
|
45
|
+
if (!hasPinnedColumns) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const map = rowsMapRef.current;
|
|
49
|
+
const set = map.get(rowId);
|
|
50
|
+
if (!set) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
set.delete(el);
|
|
54
|
+
if (set.size === 0) {
|
|
55
|
+
map.delete(rowId);
|
|
56
|
+
}
|
|
57
|
+
}, [hasPinnedColumns]);
|
|
58
|
+
const onRowEnter = useCallback((rowId) => {
|
|
59
|
+
if (!hasPinnedColumns) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (hoveredRowIdRef.current === rowId) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (hoveredRowIdRef.current) {
|
|
66
|
+
unhighlight(hoveredRowIdRef.current);
|
|
67
|
+
}
|
|
68
|
+
highlight(rowId);
|
|
69
|
+
hoveredRowIdRef.current = rowId;
|
|
70
|
+
}, [hasPinnedColumns, highlight, unhighlight]);
|
|
71
|
+
/**
|
|
72
|
+
* Обрабатывает уход курсора со строки.
|
|
73
|
+
* Убирает hover, если курсор действительно покинул строку.
|
|
74
|
+
*/
|
|
75
|
+
const onRowLeave = useCallback((rowId, e) => {
|
|
76
|
+
if (!hasPinnedColumns) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const next = e.relatedTarget;
|
|
80
|
+
if (next?.closest(`[data-row-id="${rowId}"]`)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
unhighlight(rowId);
|
|
84
|
+
hoveredRowIdRef.current = null;
|
|
85
|
+
}, [hasPinnedColumns, unhighlight]);
|
|
86
|
+
return {
|
|
87
|
+
rowsMapRef,
|
|
88
|
+
registerRowElement,
|
|
89
|
+
unregisterRowElement,
|
|
90
|
+
onRowEnter,
|
|
91
|
+
onRowLeave,
|
|
92
|
+
};
|
|
93
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { styled } from '../styled';
|
|
2
|
+
import { dataGridClassnames } from './constants';
|
|
2
3
|
export const Container = styled('div', {
|
|
3
4
|
shouldForwardProp: (prop) => !['$maxHeight', '$isAllowHorizontalScroll'].includes(prop),
|
|
4
5
|
}) `
|
|
@@ -11,6 +12,22 @@ export const Container = styled('div', {
|
|
|
11
12
|
width: 100%;
|
|
12
13
|
height: 100%;
|
|
13
14
|
max-height: ${({ $maxHeight }) => $maxHeight ? `${$maxHeight}px` : 'initial'};
|
|
15
|
+
|
|
16
|
+
&.${dataGridClassnames.dataGridHasPinnedSections} {
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@supports not (container-type: scroll-state) {
|
|
21
|
+
&.${dataGridClassnames.overflowed} {
|
|
22
|
+
& .${dataGridClassnames.rightPinnedSection} {
|
|
23
|
+
box-shadow: -3px 0 4px 0 #63636326;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
& .${dataGridClassnames.leftPinnedSection} {
|
|
27
|
+
box-shadow: 3px 0 4px 0 #63636326;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
14
31
|
`;
|
|
15
32
|
export const DataGridWrapper = styled('div', {
|
|
16
33
|
shouldForwardProp: (prop) => !['$isAllowHorizontalScroll'].includes(prop),
|
|
@@ -232,6 +232,10 @@ export type DataGridColumns<TData extends Record<string, CellValue>> = {
|
|
|
232
232
|
* Принимает компонент DataGridColumnHintIcon - подсказка в шапке колонки
|
|
233
233
|
*/
|
|
234
234
|
columnHint?: ReactNode;
|
|
235
|
+
/**
|
|
236
|
+
* Закрепление колонки в таблице
|
|
237
|
+
*/
|
|
238
|
+
pinned?: 'left' | 'right';
|
|
235
239
|
};
|
|
236
240
|
export type DataGridRowOptionColumns<TData extends Record<string, CellValue>> = {
|
|
237
241
|
/**
|