@astral/ui 4.45.0 → 4.47.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/ComplianceStatus/ComplianceStatus.d.ts +1 -43
- package/components/ComplianceStatus/ComplianceStatus.js +17 -2
- package/components/ComplianceStatus/constants.d.ts +14 -0
- package/components/ComplianceStatus/constants.js +18 -0
- package/components/ComplianceStatus/index.d.ts +2 -1
- package/components/ComplianceStatus/index.js +1 -1
- package/components/ComplianceStatus/public.d.ts +2 -1
- package/components/ComplianceStatus/public.js +1 -1
- package/components/ComplianceStatus/styles.d.ts +0 -5
- package/components/ComplianceStatus/styles.js +21 -3
- package/components/ComplianceStatus/types.d.ts +42 -0
- package/components/ComplianceStatus/types.js +1 -0
- 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/ComplianceStatus/ComplianceStatus.d.ts +1 -43
- package/node/components/ComplianceStatus/ComplianceStatus.js +17 -2
- package/node/components/ComplianceStatus/constants.d.ts +14 -0
- package/node/components/ComplianceStatus/constants.js +21 -0
- package/node/components/ComplianceStatus/index.d.ts +2 -1
- package/node/components/ComplianceStatus/public.d.ts +2 -1
- package/node/components/ComplianceStatus/styles.d.ts +0 -5
- package/node/components/ComplianceStatus/styles.js +21 -3
- package/node/components/ComplianceStatus/types.d.ts +42 -0
- package/node/components/ComplianceStatus/types.js +2 -0
- 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 +2 -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
|
@@ -11,7 +11,7 @@ exports.Wrapper = styled_1.styled.li `
|
|
|
11
11
|
position: relative;
|
|
12
12
|
|
|
13
13
|
&:not(:last-of-type)::before,
|
|
14
|
-
&.${constants_2.
|
|
14
|
+
&.${constants_2.dataGridRowClassnames.hidden}::before {
|
|
15
15
|
content: '';
|
|
16
16
|
|
|
17
17
|
position: absolute;
|
|
@@ -35,12 +35,6 @@ exports.ContentWrapper = styled_1.styled.div `
|
|
|
35
35
|
|
|
36
36
|
background-color: ${({ theme, $isSelected }) => $isSelected ? theme.palette.primary[100] : 'transparent'};
|
|
37
37
|
|
|
38
|
-
transition: ${({ theme }) => {
|
|
39
|
-
return theme.transitions.create(['background-color'], {
|
|
40
|
-
duration: theme.transitions.duration.short,
|
|
41
|
-
});
|
|
42
|
-
}};
|
|
43
|
-
|
|
44
38
|
&::before {
|
|
45
39
|
content: '';
|
|
46
40
|
|
|
@@ -61,6 +55,13 @@ exports.ContentWrapper = styled_1.styled.div `
|
|
|
61
55
|
&:hover {
|
|
62
56
|
cursor: ${({ $isHovered }) => ($isHovered ? 'pointer' : 'default')};
|
|
63
57
|
|
|
58
|
+
background-color: ${({ theme }) => theme.palette.background.elementHover};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
&.${constants_2.dataGridRowClassnames.hover} {
|
|
63
|
+
cursor: ${({ $isHovered }) => ($isHovered ? 'pointer' : 'default')};
|
|
64
|
+
|
|
64
65
|
background-color: ${({ theme, $isSelected }) => $isSelected
|
|
65
66
|
? theme.palette.primary[100]
|
|
66
67
|
: 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
|
+
};
|
|
@@ -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;
|
|
@@ -8,10 +8,21 @@ const enums_1 = require("../../enums");
|
|
|
8
8
|
const constants_1 = require("../constants");
|
|
9
9
|
const RowContext_1 = require("../RowContext");
|
|
10
10
|
const utils_1 = require("./utils");
|
|
11
|
-
const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, activeRowId, options, isInitialExpanded = false, expandedLevel, isSelectable, selectedRows, onSelectRow, onRowClick, isVisibleCollapseButton, }) => {
|
|
11
|
+
const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, activeRowId, options, isInitialExpanded = false, expandedLevel, isSelectable, selectedRows, onSelectRow, onRowClick, isVisibleCollapseButton, registerRowElement, unregisterRowElement, }) => {
|
|
12
12
|
const isDefaultExpanded = isInitialExpanded && level <= expandedLevel - 1 && nestedChildren?.length;
|
|
13
13
|
const { checkIsOpened, toggleOpenItems } = (0, react_1.useContext)(DataGridContext_1.DataGridContext);
|
|
14
14
|
const { isDisabled, disabledReason } = (0, react_1.useContext)(RowContext_1.RowContext);
|
|
15
|
+
const savedElementRef = (0, react_1.useRef)(null);
|
|
16
|
+
const rowRef = (element) => {
|
|
17
|
+
if (element) {
|
|
18
|
+
savedElementRef.current = element;
|
|
19
|
+
registerRowElement?.(rowId, element);
|
|
20
|
+
}
|
|
21
|
+
else if (savedElementRef.current) {
|
|
22
|
+
unregisterRowElement?.(rowId, savedElementRef.current);
|
|
23
|
+
savedElementRef.current = null;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
15
26
|
const [isVisibleTooltip, setVisibleTooltip] = (0, react_1.useState)(false);
|
|
16
27
|
const rowId = row[keyId];
|
|
17
28
|
const { isDisabled: isExternalDisabled, disabledReason: externalDisabledReason, href, target, } = options || {};
|
|
@@ -64,6 +75,7 @@ const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, activeR
|
|
|
64
75
|
isShowConnector,
|
|
65
76
|
childrenColumns,
|
|
66
77
|
rowId,
|
|
78
|
+
rowRef,
|
|
67
79
|
disabled,
|
|
68
80
|
isRenderCollapseButton,
|
|
69
81
|
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
|
};
|
|
@@ -13,4 +13,11 @@ exports.dataGridClassnames = {
|
|
|
13
13
|
root: (0, createUIKitClassname_1.createUIKitClassname)('data-grid'),
|
|
14
14
|
body: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__body'),
|
|
15
15
|
bodyEmpty: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__body_empty'),
|
|
16
|
+
disabled: (0, createUIKitClassname_1.createUIKitClassname)('data-grid_disabled'),
|
|
17
|
+
pinnedSectionNoData: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__pinned-section_no-data'),
|
|
18
|
+
dataGridHasPinnedSections: (0, createUIKitClassname_1.createUIKitClassname)('data-grid_has-pinned-sections'),
|
|
19
|
+
pinnedSections: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__pinned-sections'),
|
|
20
|
+
leftPinnedSection: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__left-pinned-section'),
|
|
21
|
+
rightPinnedSection: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__right-pinned-section'),
|
|
22
|
+
overflowed: (0, createUIKitClassname_1.createUIKitClassname)('data-grid_overflowed'),
|
|
16
23
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useRowHover';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useRowHover"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useRowHover';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useRowHover"), exports);
|
|
@@ -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,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useRowHover = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const constants_1 = require("../../Row/constants");
|
|
6
|
+
/**
|
|
7
|
+
* Хук для синхронизации hover-состояния строк DataGrid через прямую работу с DOM.
|
|
8
|
+
*/
|
|
9
|
+
const useRowHover = ({ hasPinnedColumns = false, }) => {
|
|
10
|
+
const rowsMapRef = (0, react_1.useRef)(new Map());
|
|
11
|
+
const hoveredRowIdRef = (0, react_1.useRef)(null);
|
|
12
|
+
const highlight = (0, react_1.useCallback)((rowId) => {
|
|
13
|
+
if (!hasPinnedColumns) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const elements = rowsMapRef.current.get(rowId);
|
|
17
|
+
if (!elements) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
elements.forEach((el) => {
|
|
21
|
+
if (!el.classList.contains(constants_1.dataGridRowClassnames.hover)) {
|
|
22
|
+
el.classList.add(constants_1.dataGridRowClassnames.hover);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}, [hasPinnedColumns]);
|
|
26
|
+
const unhighlight = (0, react_1.useCallback)((rowId) => {
|
|
27
|
+
if (!hasPinnedColumns) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const elements = rowsMapRef.current.get(rowId);
|
|
31
|
+
if (!elements) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
elements.forEach((el) => el.classList.remove(constants_1.dataGridRowClassnames.hover));
|
|
35
|
+
return;
|
|
36
|
+
}, [hasPinnedColumns]);
|
|
37
|
+
const registerRowElement = (0, react_1.useCallback)((rowId, el) => {
|
|
38
|
+
if (!hasPinnedColumns) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const map = rowsMapRef.current;
|
|
42
|
+
if (!map.has(rowId)) {
|
|
43
|
+
map.set(rowId, new Set());
|
|
44
|
+
}
|
|
45
|
+
map.get(rowId).add(el);
|
|
46
|
+
}, [hasPinnedColumns]);
|
|
47
|
+
const unregisterRowElement = (0, react_1.useCallback)((rowId, el) => {
|
|
48
|
+
if (!hasPinnedColumns) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const map = rowsMapRef.current;
|
|
52
|
+
const set = map.get(rowId);
|
|
53
|
+
if (!set) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
set.delete(el);
|
|
57
|
+
if (set.size === 0) {
|
|
58
|
+
map.delete(rowId);
|
|
59
|
+
}
|
|
60
|
+
}, [hasPinnedColumns]);
|
|
61
|
+
const onRowEnter = (0, react_1.useCallback)((rowId) => {
|
|
62
|
+
if (!hasPinnedColumns) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (hoveredRowIdRef.current === rowId) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (hoveredRowIdRef.current) {
|
|
69
|
+
unhighlight(hoveredRowIdRef.current);
|
|
70
|
+
}
|
|
71
|
+
highlight(rowId);
|
|
72
|
+
hoveredRowIdRef.current = rowId;
|
|
73
|
+
}, [hasPinnedColumns, highlight, unhighlight]);
|
|
74
|
+
/**
|
|
75
|
+
* Обрабатывает уход курсора со строки.
|
|
76
|
+
* Убирает hover, если курсор действительно покинул строку.
|
|
77
|
+
*/
|
|
78
|
+
const onRowLeave = (0, react_1.useCallback)((rowId, e) => {
|
|
79
|
+
if (!hasPinnedColumns) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const next = e.relatedTarget;
|
|
83
|
+
if (next?.closest(`[data-row-id="${rowId}"]`)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
unhighlight(rowId);
|
|
87
|
+
hoveredRowIdRef.current = null;
|
|
88
|
+
}, [hasPinnedColumns, unhighlight]);
|
|
89
|
+
return {
|
|
90
|
+
rowsMapRef,
|
|
91
|
+
registerRowElement,
|
|
92
|
+
unregisterRowElement,
|
|
93
|
+
onRowEnter,
|
|
94
|
+
onRowLeave,
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
exports.useRowHover = useRowHover;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DisabledDataGridWrapper = exports.DataGridWrapper = exports.Container = void 0;
|
|
4
4
|
const styled_1 = require("../styled");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
5
6
|
exports.Container = (0, styled_1.styled)('div', {
|
|
6
7
|
shouldForwardProp: (prop) => !['$maxHeight', '$isAllowHorizontalScroll'].includes(prop),
|
|
7
8
|
}) `
|
|
@@ -14,6 +15,22 @@ exports.Container = (0, styled_1.styled)('div', {
|
|
|
14
15
|
width: 100%;
|
|
15
16
|
height: 100%;
|
|
16
17
|
max-height: ${({ $maxHeight }) => $maxHeight ? `${$maxHeight}px` : 'initial'};
|
|
18
|
+
|
|
19
|
+
&.${constants_1.dataGridClassnames.dataGridHasPinnedSections} {
|
|
20
|
+
overflow: hidden;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@supports not (container-type: scroll-state) {
|
|
24
|
+
&.${constants_1.dataGridClassnames.overflowed} {
|
|
25
|
+
& .${constants_1.dataGridClassnames.rightPinnedSection} {
|
|
26
|
+
box-shadow: -3px 0 4px 0 #63636326;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
& .${constants_1.dataGridClassnames.leftPinnedSection} {
|
|
30
|
+
box-shadow: 3px 0 4px 0 #63636326;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
17
34
|
`;
|
|
18
35
|
exports.DataGridWrapper = (0, styled_1.styled)('div', {
|
|
19
36
|
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
|
/**
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./usePinnedColumns"), exports);
|
|
18
|
+
__exportStar(require("./useClassnames"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useClassnames';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useClassnames"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type UseClassnamesParams = {
|
|
2
|
+
isDataGridDisabled?: boolean;
|
|
3
|
+
dataGridClassName?: string;
|
|
4
|
+
hasPinnedColumns?: boolean;
|
|
5
|
+
isNoData?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const useClassnames: ({ isDataGridDisabled, dataGridClassName, hasPinnedColumns, isNoData, }: UseClassnamesParams) => {
|
|
8
|
+
pinnedSectionsClassname: string;
|
|
9
|
+
dataGridClassname: string;
|
|
10
|
+
bodyClassName: string;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useClassnames = void 0;
|
|
4
|
+
const classNames_1 = require("../../../../utils/classNames");
|
|
5
|
+
const constants_1 = require("../../../constants");
|
|
6
|
+
const useClassnames = ({ isDataGridDisabled, dataGridClassName, hasPinnedColumns, isNoData, }) => {
|
|
7
|
+
const pinnedSectionsClassname = (0, classNames_1.classNames)(constants_1.dataGridClassnames.pinnedSections, {
|
|
8
|
+
[constants_1.dataGridClassnames.disabled]: isDataGridDisabled,
|
|
9
|
+
});
|
|
10
|
+
const dataGridClassname = (0, classNames_1.classNames)(constants_1.dataGridClassnames.root, dataGridClassName, {
|
|
11
|
+
[constants_1.dataGridClassnames.dataGridHasPinnedSections]: hasPinnedColumns,
|
|
12
|
+
});
|
|
13
|
+
const bodyClassName = (0, classNames_1.classNames)(constants_1.dataGridClassnames.body, {
|
|
14
|
+
[constants_1.dataGridClassnames.bodyEmpty]: isNoData,
|
|
15
|
+
});
|
|
16
|
+
return { pinnedSectionsClassname, dataGridClassname, bodyClassName };
|
|
17
|
+
};
|
|
18
|
+
exports.useClassnames = useClassnames;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './usePinnedColumns';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./usePinnedColumns"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type CellValue, type DataGridColumns, type DataGridRow } from '../../../types';
|
|
3
|
+
type UsePinnedColumnsParams<TData extends Record<string, CellValue> = DataGridRow> = {
|
|
4
|
+
isLoading?: boolean;
|
|
5
|
+
columns: DataGridColumns<TData>[];
|
|
6
|
+
};
|
|
7
|
+
export declare const usePinnedColumns: <TData extends Record<string, unknown> = DataGridRow>({ isLoading, columns, }: UsePinnedColumnsParams<TData>) => {
|
|
8
|
+
containerRef: import("react").RefObject<HTMLDivElement | null>;
|
|
9
|
+
rowHoverProps: {
|
|
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
|
+
sections: import("../../../PinnedSections/types").PinnedSection<TData>[];
|
|
16
|
+
hasPinnedColumns: boolean;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePinnedColumns = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const constants_1 = require("../../../constants");
|
|
6
|
+
const useRowHover_1 = require("../../../hooks/useRowHover");
|
|
7
|
+
const getColumnSections_1 = require("../../utils/getColumnSections");
|
|
8
|
+
const syncRowsHeight_1 = require("../../utils/syncRowsHeight");
|
|
9
|
+
const usePinnedColumns = ({ isLoading, columns, }) => {
|
|
10
|
+
const containerRef = (0, react_1.useRef)(null);
|
|
11
|
+
const hasPinnedColumns = (0, react_1.useMemo)(() => columns.some((column) => column.pinned), [columns]);
|
|
12
|
+
const { rowsMapRef, ...rowHoverProps } = (0, useRowHover_1.useRowHover)({ hasPinnedColumns });
|
|
13
|
+
const isScrollStateSupported = CSS.supports('container-type', 'scroll-state');
|
|
14
|
+
const checkOverflow = (0, react_1.useCallback)((element) => {
|
|
15
|
+
if (element) {
|
|
16
|
+
return element.scrollWidth > element.clientWidth;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}, []);
|
|
20
|
+
const { sections } = (0, react_1.useMemo)(() => (0, getColumnSections_1.getColumnSections)(columns), [columns]);
|
|
21
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
22
|
+
if (isLoading || !hasPinnedColumns || typeof window === 'undefined') {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
26
|
+
(0, syncRowsHeight_1.syncRowsHeight)(rowsMapRef.current);
|
|
27
|
+
if (isScrollStateSupported) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (checkOverflow(containerRef.current)) {
|
|
31
|
+
containerRef.current?.classList.add(constants_1.dataGridClassnames.overflowed);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
containerRef.current?.classList.remove(constants_1.dataGridClassnames.overflowed);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
if (!containerRef.current) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
resizeObserver.observe(containerRef.current);
|
|
41
|
+
return () => {
|
|
42
|
+
resizeObserver.disconnect();
|
|
43
|
+
};
|
|
44
|
+
}, [hasPinnedColumns, isLoading]);
|
|
45
|
+
return { containerRef, rowHoverProps, sections, hasPinnedColumns };
|
|
46
|
+
};
|
|
47
|
+
exports.usePinnedColumns = usePinnedColumns;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type ChangeEvent } from 'react';
|
|
2
2
|
import type { CellValue, DataGridProps, DataGridRow } from '../types';
|
|
3
3
|
type UseLogicParams<TData extends Record<string, CellValue> = DataGridRow, TSortField extends keyof TData = keyof TData> = DataGridProps<TData, TSortField>;
|
|
4
|
-
export declare const useLogic: <TData extends Record<string, unknown> = DataGridRow, TSortField extends keyof TData = keyof TData>({ keyId, columns, rows, variant, tree, subrows, selectedRows, isLoading, isDisabled, onSelectRow, isHideSelectAll, isHideHeaderIfNoData, }: UseLogicParams<TData, TSortField>) => {
|
|
4
|
+
export declare const useLogic: <TData extends Record<string, unknown> = DataGridRow, TSortField extends keyof TData = keyof TData>({ keyId, columns, rows, variant, tree, subrows, selectedRows, isLoading, isDisabled, onSelectRow, isError, onRetry, errorMsg, isHideSelectAll, isHideHeaderIfNoData, sorting, className, onSort, }: UseLogicParams<TData, TSortField>) => {
|
|
5
|
+
pinnedSectionsClassname: string;
|
|
6
|
+
dataGridClassname: string;
|
|
5
7
|
isDataGridDisabled: boolean | undefined;
|
|
6
8
|
treeRenderConfig: {
|
|
7
9
|
isInitialExpanded?: boolean | undefined;
|
|
@@ -11,20 +13,44 @@ export declare const useLogic: <TData extends Record<string, unknown> = DataGrid
|
|
|
11
13
|
renderRows: TData[];
|
|
12
14
|
isAllowHorizontalScroll: boolean;
|
|
13
15
|
isHideHead: boolean;
|
|
16
|
+
hasPinnedColumns: boolean;
|
|
17
|
+
contentStateProps: {
|
|
18
|
+
isLoading: boolean | undefined;
|
|
19
|
+
isError: boolean | undefined;
|
|
20
|
+
loadingTitle: string;
|
|
21
|
+
errorState: {
|
|
22
|
+
imgAlt: string;
|
|
23
|
+
errorList: string[];
|
|
24
|
+
imgSrc: string;
|
|
25
|
+
onRetry: () => void;
|
|
26
|
+
};
|
|
27
|
+
isSmoothLoading: boolean;
|
|
28
|
+
};
|
|
29
|
+
rowHoverProps: {
|
|
30
|
+
registerRowElement: (rowId: string, el: HTMLElement) => void;
|
|
31
|
+
unregisterRowElement: (rowId: string, el: HTMLElement) => void;
|
|
32
|
+
onRowEnter: (rowId: string) => void;
|
|
33
|
+
onRowLeave: (rowId: string, e: PointerEvent) => void;
|
|
34
|
+
};
|
|
35
|
+
containerRef: import("react").RefObject<HTMLDivElement | null>;
|
|
36
|
+
gridColumns: string;
|
|
37
|
+
isNoData: boolean;
|
|
38
|
+
headColumns: import("../types").DataGridColumns<TData>[];
|
|
14
39
|
headProps: {
|
|
15
40
|
rowsCount: number;
|
|
16
41
|
uncheckedRowsCount: number;
|
|
17
|
-
gridColumns: string;
|
|
18
42
|
isSelectable: boolean;
|
|
19
|
-
columns: import("../types").DataGridColumns<TData>[];
|
|
20
43
|
onSelectAllRows: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
21
44
|
isHideSelectAll: boolean | undefined;
|
|
45
|
+
sorting: import("../types").DataGridSort<TSortField> | undefined;
|
|
46
|
+
onSort: ((sorting: import("../types").DataGridSort<TSortField> | undefined) => void) | undefined;
|
|
22
47
|
};
|
|
23
48
|
bodyProps: {
|
|
24
|
-
gridColumns: string;
|
|
25
49
|
isSelectable: boolean;
|
|
26
50
|
onSelectRow: (row: TData) => (event: ChangeEvent<HTMLInputElement>) => void;
|
|
27
51
|
};
|
|
52
|
+
bodyClassName: string;
|
|
53
|
+
sections: import("../PinnedSections/types").PinnedSection<TData>[];
|
|
28
54
|
loaderProps: {
|
|
29
55
|
isLoading: boolean | undefined;
|
|
30
56
|
isVisibleDivider: boolean;
|