@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.
Files changed (173) hide show
  1. package/components/DataGrid/Body/Body.d.ts +1 -98
  2. package/components/DataGrid/Body/Body.js +3 -15
  3. package/components/DataGrid/Body/index.d.ts +1 -0
  4. package/components/DataGrid/Body/index.js +1 -0
  5. package/components/DataGrid/Body/types.d.ts +110 -0
  6. package/components/DataGrid/Body/types.js +1 -0
  7. package/components/DataGrid/DataGrid.js +30 -5
  8. package/components/DataGrid/Head/Head.d.ts +4 -0
  9. package/components/DataGrid/Head/Head.js +3 -2
  10. package/components/DataGrid/Loader/Loader.js +2 -2
  11. package/components/DataGrid/Loader/styles.js +4 -2
  12. package/components/DataGrid/PinnedSections/PinnedSections.d.ts +35 -0
  13. package/components/DataGrid/PinnedSections/PinnedSections.js +11 -0
  14. package/components/DataGrid/PinnedSections/Section/Section.d.ts +3 -0
  15. package/components/DataGrid/PinnedSections/Section/Section.js +17 -0
  16. package/components/DataGrid/PinnedSections/Section/index.d.ts +1 -0
  17. package/components/DataGrid/PinnedSections/Section/index.js +1 -0
  18. package/components/DataGrid/PinnedSections/Section/styles.d.ts +5 -0
  19. package/components/DataGrid/PinnedSections/Section/styles.js +100 -0
  20. package/components/DataGrid/PinnedSections/Section/types.d.ts +26 -0
  21. package/components/DataGrid/PinnedSections/Section/types.js +1 -0
  22. package/components/DataGrid/PinnedSections/Section/useLogic/useLogic.d.ts +9 -0
  23. package/components/DataGrid/PinnedSections/Section/useLogic/useLogic.js +16 -0
  24. package/components/DataGrid/PinnedSections/index.d.ts +1 -0
  25. package/components/DataGrid/PinnedSections/index.js +1 -0
  26. package/components/DataGrid/PinnedSections/styles.d.ts +7 -0
  27. package/components/DataGrid/PinnedSections/styles.js +18 -0
  28. package/components/DataGrid/PinnedSections/types.d.ts +5 -0
  29. package/components/DataGrid/PinnedSections/types.js +1 -0
  30. package/components/DataGrid/PinnedSections/useLogic/index.js +1 -0
  31. package/components/DataGrid/PinnedSections/useLogic/useLogic.d.ts +9 -0
  32. package/components/DataGrid/PinnedSections/useLogic/useLogic.js +19 -0
  33. package/components/DataGrid/Row/NestedChildren/NestedChildren.js +2 -2
  34. package/components/DataGrid/Row/Row.d.ts +1 -94
  35. package/components/DataGrid/Row/Row.js +23 -8
  36. package/components/DataGrid/Row/constants.d.ts +3 -1
  37. package/components/DataGrid/Row/constants.js +3 -1
  38. package/components/DataGrid/Row/styles.js +9 -8
  39. package/components/DataGrid/Row/types.d.ts +118 -0
  40. package/components/DataGrid/Row/types.js +1 -0
  41. package/components/DataGrid/Row/useLogic/useLogic.d.ts +3 -2
  42. package/components/DataGrid/Row/useLogic/useLogic.js +14 -2
  43. package/components/DataGrid/constants.d.ts +7 -0
  44. package/components/DataGrid/constants.js +7 -0
  45. package/components/DataGrid/hooks/index.d.ts +1 -0
  46. package/components/DataGrid/hooks/index.js +1 -0
  47. package/components/DataGrid/hooks/useRowHover/index.d.ts +1 -0
  48. package/components/DataGrid/hooks/useRowHover/index.js +1 -0
  49. package/components/DataGrid/hooks/useRowHover/useRowHover.d.ts +15 -0
  50. package/components/DataGrid/hooks/useRowHover/useRowHover.js +93 -0
  51. package/components/DataGrid/styles.js +17 -0
  52. package/components/DataGrid/types.d.ts +4 -0
  53. package/components/DataGrid/useLogic/hooks/index.d.ts +2 -0
  54. package/components/DataGrid/useLogic/hooks/index.js +2 -0
  55. package/components/DataGrid/useLogic/hooks/useClassnames/index.d.ts +1 -0
  56. package/components/DataGrid/useLogic/hooks/useClassnames/index.js +1 -0
  57. package/components/DataGrid/useLogic/hooks/useClassnames/useClassnames.d.ts +12 -0
  58. package/components/DataGrid/useLogic/hooks/useClassnames/useClassnames.js +14 -0
  59. package/components/DataGrid/useLogic/hooks/usePinnedColumns/index.d.ts +1 -0
  60. package/components/DataGrid/useLogic/hooks/usePinnedColumns/index.js +1 -0
  61. package/components/DataGrid/useLogic/hooks/usePinnedColumns/usePinnedColumns.d.ts +18 -0
  62. package/components/DataGrid/useLogic/hooks/usePinnedColumns/usePinnedColumns.js +43 -0
  63. package/components/DataGrid/useLogic/useLogic.d.ts +30 -4
  64. package/components/DataGrid/useLogic/useLogic.js +55 -16
  65. package/components/DataGrid/useLogic/utils/getColumnSections/getColumnSections.d.ts +17 -0
  66. package/components/DataGrid/useLogic/utils/getColumnSections/getColumnSections.js +45 -0
  67. package/components/DataGrid/useLogic/utils/getColumnSections/index.d.ts +1 -0
  68. package/components/DataGrid/useLogic/utils/getColumnSections/index.js +1 -0
  69. package/components/DataGrid/useLogic/utils/index.d.ts +2 -1
  70. package/components/DataGrid/useLogic/utils/index.js +2 -1
  71. package/components/DataGrid/useLogic/utils/syncRowsHeight/index.d.ts +1 -0
  72. package/components/DataGrid/useLogic/utils/syncRowsHeight/index.js +1 -0
  73. package/components/DataGrid/useLogic/utils/syncRowsHeight/syncRowsHeight.d.ts +5 -0
  74. package/components/DataGrid/useLogic/utils/syncRowsHeight/syncRowsHeight.js +21 -0
  75. package/components/DataGrid/utils/index.d.ts +1 -0
  76. package/components/DataGrid/utils/index.js +1 -0
  77. package/components/DataGridInfinite/useLogic/useLogic.js +1 -1
  78. package/node/components/DataGrid/Body/Body.d.ts +1 -98
  79. package/node/components/DataGrid/Body/Body.js +3 -15
  80. package/node/components/DataGrid/Body/index.d.ts +1 -0
  81. package/node/components/DataGrid/Body/index.js +1 -0
  82. package/node/components/DataGrid/Body/types.d.ts +110 -0
  83. package/node/components/DataGrid/Body/types.js +2 -0
  84. package/node/components/DataGrid/DataGrid.js +29 -4
  85. package/node/components/DataGrid/Head/Head.d.ts +4 -0
  86. package/node/components/DataGrid/Head/Head.js +3 -2
  87. package/node/components/DataGrid/Loader/Loader.js +1 -1
  88. package/node/components/DataGrid/Loader/styles.js +4 -2
  89. package/node/components/DataGrid/PinnedSections/PinnedSections.d.ts +35 -0
  90. package/node/components/DataGrid/PinnedSections/PinnedSections.js +15 -0
  91. package/node/components/DataGrid/PinnedSections/Section/Section.d.ts +3 -0
  92. package/node/components/DataGrid/PinnedSections/Section/Section.js +21 -0
  93. package/node/components/DataGrid/PinnedSections/Section/index.d.ts +1 -0
  94. package/node/components/DataGrid/PinnedSections/Section/index.js +17 -0
  95. package/node/components/DataGrid/PinnedSections/Section/styles.d.ts +5 -0
  96. package/node/components/DataGrid/PinnedSections/Section/styles.js +103 -0
  97. package/node/components/DataGrid/PinnedSections/Section/types.d.ts +26 -0
  98. package/node/components/DataGrid/PinnedSections/Section/types.js +2 -0
  99. package/node/components/DataGrid/PinnedSections/Section/useLogic/index.d.ts +1 -0
  100. package/node/components/DataGrid/PinnedSections/Section/useLogic/useLogic.d.ts +9 -0
  101. package/node/components/DataGrid/PinnedSections/Section/useLogic/useLogic.js +20 -0
  102. package/node/components/DataGrid/PinnedSections/index.d.ts +1 -0
  103. package/node/components/DataGrid/PinnedSections/index.js +17 -0
  104. package/node/components/DataGrid/PinnedSections/styles.d.ts +7 -0
  105. package/node/components/DataGrid/PinnedSections/styles.js +21 -0
  106. package/node/components/DataGrid/PinnedSections/types.d.ts +5 -0
  107. package/node/components/DataGrid/PinnedSections/types.js +2 -0
  108. package/node/components/DataGrid/PinnedSections/useLogic/index.d.ts +1 -0
  109. package/node/components/DataGrid/PinnedSections/useLogic/index.js +17 -0
  110. package/node/components/DataGrid/PinnedSections/useLogic/useLogic.d.ts +9 -0
  111. package/node/components/DataGrid/PinnedSections/useLogic/useLogic.js +23 -0
  112. package/node/components/DataGrid/Row/NestedChildren/NestedChildren.js +1 -1
  113. package/node/components/DataGrid/Row/Row.d.ts +1 -94
  114. package/node/components/DataGrid/Row/Row.js +23 -8
  115. package/node/components/DataGrid/Row/constants.d.ts +3 -1
  116. package/node/components/DataGrid/Row/constants.js +4 -2
  117. package/node/components/DataGrid/Row/styles.js +8 -7
  118. package/node/components/DataGrid/Row/types.d.ts +118 -0
  119. package/node/components/DataGrid/Row/types.js +2 -0
  120. package/node/components/DataGrid/Row/useLogic/useLogic.d.ts +3 -2
  121. package/node/components/DataGrid/Row/useLogic/useLogic.js +13 -1
  122. package/node/components/DataGrid/constants.d.ts +7 -0
  123. package/node/components/DataGrid/constants.js +7 -0
  124. package/node/components/DataGrid/hooks/index.d.ts +1 -0
  125. package/node/components/DataGrid/hooks/index.js +17 -0
  126. package/node/components/DataGrid/hooks/useRowHover/index.d.ts +1 -0
  127. package/node/components/DataGrid/hooks/useRowHover/index.js +17 -0
  128. package/node/components/DataGrid/hooks/useRowHover/useRowHover.d.ts +15 -0
  129. package/node/components/DataGrid/hooks/useRowHover/useRowHover.js +97 -0
  130. package/node/components/DataGrid/styles.js +17 -0
  131. package/node/components/DataGrid/types.d.ts +4 -0
  132. package/node/components/DataGrid/useLogic/hooks/index.d.ts +2 -0
  133. package/node/components/DataGrid/useLogic/hooks/index.js +18 -0
  134. package/node/components/DataGrid/useLogic/hooks/useClassnames/index.d.ts +1 -0
  135. package/node/components/DataGrid/useLogic/hooks/useClassnames/index.js +17 -0
  136. package/node/components/DataGrid/useLogic/hooks/useClassnames/useClassnames.d.ts +12 -0
  137. package/node/components/DataGrid/useLogic/hooks/useClassnames/useClassnames.js +18 -0
  138. package/node/components/DataGrid/useLogic/hooks/usePinnedColumns/index.d.ts +1 -0
  139. package/node/components/DataGrid/useLogic/hooks/usePinnedColumns/index.js +17 -0
  140. package/node/components/DataGrid/useLogic/hooks/usePinnedColumns/usePinnedColumns.d.ts +18 -0
  141. package/node/components/DataGrid/useLogic/hooks/usePinnedColumns/usePinnedColumns.js +47 -0
  142. package/node/components/DataGrid/useLogic/useLogic.d.ts +30 -4
  143. package/node/components/DataGrid/useLogic/useLogic.js +53 -14
  144. package/node/components/DataGrid/useLogic/utils/getColumnSections/getColumnSections.d.ts +17 -0
  145. package/node/components/DataGrid/useLogic/utils/getColumnSections/getColumnSections.js +50 -0
  146. package/node/components/DataGrid/useLogic/utils/getColumnSections/index.d.ts +1 -0
  147. package/node/components/DataGrid/useLogic/utils/getColumnSections/index.js +17 -0
  148. package/node/components/DataGrid/useLogic/utils/index.d.ts +2 -1
  149. package/node/components/DataGrid/useLogic/utils/index.js +5 -3
  150. package/node/components/DataGrid/useLogic/utils/syncRowsHeight/index.d.ts +1 -0
  151. package/node/components/DataGrid/useLogic/utils/syncRowsHeight/index.js +17 -0
  152. package/node/components/DataGrid/useLogic/utils/syncRowsHeight/syncRowsHeight.d.ts +5 -0
  153. package/node/components/DataGrid/useLogic/utils/syncRowsHeight/syncRowsHeight.js +25 -0
  154. package/node/components/DataGrid/utils/index.d.ts +1 -0
  155. package/node/components/DataGrid/utils/index.js +3 -1
  156. package/node/components/DataGridInfinite/useLogic/useLogic.js +1 -1
  157. package/package.json +1 -1
  158. package/components/DataGrid/Body/useLogic/useLogic.d.ts +0 -12
  159. package/components/DataGrid/Body/useLogic/useLogic.js +0 -11
  160. package/node/components/DataGrid/Body/useLogic/useLogic.d.ts +0 -12
  161. package/node/components/DataGrid/Body/useLogic/useLogic.js +0 -15
  162. /package/components/DataGrid/{Body → PinnedSections/Section}/useLogic/index.d.ts +0 -0
  163. /package/components/DataGrid/{Body → PinnedSections/Section}/useLogic/index.js +0 -0
  164. /package/{node/components/DataGrid/Body → components/DataGrid/PinnedSections}/useLogic/index.d.ts +0 -0
  165. /package/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/getGridTemplateColumns.d.ts +0 -0
  166. /package/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/getGridTemplateColumns.js +0 -0
  167. /package/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/index.d.ts +0 -0
  168. /package/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/index.js +0 -0
  169. /package/node/components/DataGrid/{Body → PinnedSections/Section}/useLogic/index.js +0 -0
  170. /package/node/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/getGridTemplateColumns.d.ts +0 -0
  171. /package/node/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/getGridTemplateColumns.js +0 -0
  172. /package/node/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/index.d.ts +0 -0
  173. /package/node/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/index.js +0 -0
@@ -0,0 +1,5 @@
1
+ import type { CellValue, DataGridColumns, DataGridRow } from '../types';
2
+ export type PinnedSection<TData extends Record<string, CellValue> = DataGridRow> = {
3
+ columns: DataGridColumns<TData>[];
4
+ position: 'left' | 'center' | 'right';
5
+ };
@@ -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 { dataGridClassnames } from '../constants';
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: dataGridClassnames.hidden,
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 { type ChangeEvent, type ReactNode } from 'react';
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
- ? [columns.length - 1]
28
+ ? [lastCellGlobalIndex]
28
29
  : undefined;
29
30
  return columns?.map((cell, index) => {
30
31
  const cellId = `${rowId}-${index}`;
31
- const isDisabledCell = checkIsDisabled(disabled, availableCellsByIndex, index);
32
- const isFirstCell = !index;
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
- }, [isOpen, columns, disabled, checkboxProps.checked]);
36
- 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 }, key)), [
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,4 +1,6 @@
1
1
  export declare const DISABLE_ROW_ATTR = "data-row-disable";
2
- export declare const dataGridClassnames: {
2
+ export declare const dataGridRowClassnames: {
3
3
  hidden: string;
4
+ hover: string;
5
+ hasPinnedColumns: string;
4
6
  };
@@ -1,5 +1,7 @@
1
1
  import { createUIKitClassname } from '../../utils/createUIKitClassname';
2
2
  export const DISABLE_ROW_ATTR = 'data-row-disable';
3
- export const dataGridClassnames = {
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 { dataGridClassnames } from './constants';
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
- &.${dataGridClassnames.hidden}::before {
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 { type RowProps } from '../Row';
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
  /**
@@ -0,0 +1,2 @@
1
+ export * from './usePinnedColumns';
2
+ export * from './useClassnames';