@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.
Files changed (195) hide show
  1. package/components/ComplianceStatus/ComplianceStatus.d.ts +1 -43
  2. package/components/ComplianceStatus/ComplianceStatus.js +17 -2
  3. package/components/ComplianceStatus/constants.d.ts +14 -0
  4. package/components/ComplianceStatus/constants.js +18 -0
  5. package/components/ComplianceStatus/index.d.ts +2 -1
  6. package/components/ComplianceStatus/index.js +1 -1
  7. package/components/ComplianceStatus/public.d.ts +2 -1
  8. package/components/ComplianceStatus/public.js +1 -1
  9. package/components/ComplianceStatus/styles.d.ts +0 -5
  10. package/components/ComplianceStatus/styles.js +21 -3
  11. package/components/ComplianceStatus/types.d.ts +42 -0
  12. package/components/ComplianceStatus/types.js +1 -0
  13. package/components/DataGrid/Body/Body.d.ts +1 -98
  14. package/components/DataGrid/Body/Body.js +3 -15
  15. package/components/DataGrid/Body/index.d.ts +1 -0
  16. package/components/DataGrid/Body/index.js +1 -0
  17. package/components/DataGrid/Body/types.d.ts +110 -0
  18. package/components/DataGrid/Body/types.js +1 -0
  19. package/components/DataGrid/DataGrid.js +30 -5
  20. package/components/DataGrid/Head/Head.d.ts +4 -0
  21. package/components/DataGrid/Head/Head.js +3 -2
  22. package/components/DataGrid/Loader/Loader.js +2 -2
  23. package/components/DataGrid/Loader/styles.js +4 -2
  24. package/components/DataGrid/PinnedSections/PinnedSections.d.ts +35 -0
  25. package/components/DataGrid/PinnedSections/PinnedSections.js +11 -0
  26. package/components/DataGrid/PinnedSections/Section/Section.d.ts +3 -0
  27. package/components/DataGrid/PinnedSections/Section/Section.js +17 -0
  28. package/components/DataGrid/PinnedSections/Section/index.d.ts +1 -0
  29. package/components/DataGrid/PinnedSections/Section/index.js +1 -0
  30. package/components/DataGrid/PinnedSections/Section/styles.d.ts +5 -0
  31. package/components/DataGrid/PinnedSections/Section/styles.js +100 -0
  32. package/components/DataGrid/PinnedSections/Section/types.d.ts +26 -0
  33. package/components/DataGrid/PinnedSections/Section/types.js +1 -0
  34. package/components/DataGrid/PinnedSections/Section/useLogic/useLogic.d.ts +9 -0
  35. package/components/DataGrid/PinnedSections/Section/useLogic/useLogic.js +16 -0
  36. package/components/DataGrid/PinnedSections/index.d.ts +1 -0
  37. package/components/DataGrid/PinnedSections/index.js +1 -0
  38. package/components/DataGrid/PinnedSections/styles.d.ts +7 -0
  39. package/components/DataGrid/PinnedSections/styles.js +18 -0
  40. package/components/DataGrid/PinnedSections/types.d.ts +5 -0
  41. package/components/DataGrid/PinnedSections/types.js +1 -0
  42. package/components/DataGrid/PinnedSections/useLogic/index.js +1 -0
  43. package/components/DataGrid/PinnedSections/useLogic/useLogic.d.ts +9 -0
  44. package/components/DataGrid/PinnedSections/useLogic/useLogic.js +19 -0
  45. package/components/DataGrid/Row/NestedChildren/NestedChildren.js +2 -2
  46. package/components/DataGrid/Row/Row.d.ts +1 -94
  47. package/components/DataGrid/Row/Row.js +23 -8
  48. package/components/DataGrid/Row/constants.d.ts +3 -1
  49. package/components/DataGrid/Row/constants.js +3 -1
  50. package/components/DataGrid/Row/styles.js +9 -8
  51. package/components/DataGrid/Row/types.d.ts +118 -0
  52. package/components/DataGrid/Row/types.js +1 -0
  53. package/components/DataGrid/Row/useLogic/useLogic.d.ts +3 -2
  54. package/components/DataGrid/Row/useLogic/useLogic.js +14 -2
  55. package/components/DataGrid/constants.d.ts +7 -0
  56. package/components/DataGrid/constants.js +7 -0
  57. package/components/DataGrid/hooks/index.d.ts +1 -0
  58. package/components/DataGrid/hooks/index.js +1 -0
  59. package/components/DataGrid/hooks/useRowHover/index.d.ts +1 -0
  60. package/components/DataGrid/hooks/useRowHover/index.js +1 -0
  61. package/components/DataGrid/hooks/useRowHover/useRowHover.d.ts +15 -0
  62. package/components/DataGrid/hooks/useRowHover/useRowHover.js +93 -0
  63. package/components/DataGrid/styles.js +17 -0
  64. package/components/DataGrid/types.d.ts +4 -0
  65. package/components/DataGrid/useLogic/hooks/index.d.ts +2 -0
  66. package/components/DataGrid/useLogic/hooks/index.js +2 -0
  67. package/components/DataGrid/useLogic/hooks/useClassnames/index.d.ts +1 -0
  68. package/components/DataGrid/useLogic/hooks/useClassnames/index.js +1 -0
  69. package/components/DataGrid/useLogic/hooks/useClassnames/useClassnames.d.ts +12 -0
  70. package/components/DataGrid/useLogic/hooks/useClassnames/useClassnames.js +14 -0
  71. package/components/DataGrid/useLogic/hooks/usePinnedColumns/index.d.ts +1 -0
  72. package/components/DataGrid/useLogic/hooks/usePinnedColumns/index.js +1 -0
  73. package/components/DataGrid/useLogic/hooks/usePinnedColumns/usePinnedColumns.d.ts +18 -0
  74. package/components/DataGrid/useLogic/hooks/usePinnedColumns/usePinnedColumns.js +43 -0
  75. package/components/DataGrid/useLogic/useLogic.d.ts +30 -4
  76. package/components/DataGrid/useLogic/useLogic.js +55 -16
  77. package/components/DataGrid/useLogic/utils/getColumnSections/getColumnSections.d.ts +17 -0
  78. package/components/DataGrid/useLogic/utils/getColumnSections/getColumnSections.js +45 -0
  79. package/components/DataGrid/useLogic/utils/getColumnSections/index.d.ts +1 -0
  80. package/components/DataGrid/useLogic/utils/getColumnSections/index.js +1 -0
  81. package/components/DataGrid/useLogic/utils/index.d.ts +2 -1
  82. package/components/DataGrid/useLogic/utils/index.js +2 -1
  83. package/components/DataGrid/useLogic/utils/syncRowsHeight/index.d.ts +1 -0
  84. package/components/DataGrid/useLogic/utils/syncRowsHeight/index.js +1 -0
  85. package/components/DataGrid/useLogic/utils/syncRowsHeight/syncRowsHeight.d.ts +5 -0
  86. package/components/DataGrid/useLogic/utils/syncRowsHeight/syncRowsHeight.js +21 -0
  87. package/components/DataGrid/utils/index.d.ts +1 -0
  88. package/components/DataGrid/utils/index.js +1 -0
  89. package/components/DataGridInfinite/useLogic/useLogic.js +1 -1
  90. package/node/components/ComplianceStatus/ComplianceStatus.d.ts +1 -43
  91. package/node/components/ComplianceStatus/ComplianceStatus.js +17 -2
  92. package/node/components/ComplianceStatus/constants.d.ts +14 -0
  93. package/node/components/ComplianceStatus/constants.js +21 -0
  94. package/node/components/ComplianceStatus/index.d.ts +2 -1
  95. package/node/components/ComplianceStatus/public.d.ts +2 -1
  96. package/node/components/ComplianceStatus/styles.d.ts +0 -5
  97. package/node/components/ComplianceStatus/styles.js +21 -3
  98. package/node/components/ComplianceStatus/types.d.ts +42 -0
  99. package/node/components/ComplianceStatus/types.js +2 -0
  100. package/node/components/DataGrid/Body/Body.d.ts +1 -98
  101. package/node/components/DataGrid/Body/Body.js +3 -15
  102. package/node/components/DataGrid/Body/index.d.ts +1 -0
  103. package/node/components/DataGrid/Body/index.js +1 -0
  104. package/node/components/DataGrid/Body/types.d.ts +110 -0
  105. package/node/components/DataGrid/Body/types.js +2 -0
  106. package/node/components/DataGrid/DataGrid.js +29 -4
  107. package/node/components/DataGrid/Head/Head.d.ts +4 -0
  108. package/node/components/DataGrid/Head/Head.js +3 -2
  109. package/node/components/DataGrid/Loader/Loader.js +1 -1
  110. package/node/components/DataGrid/Loader/styles.js +4 -2
  111. package/node/components/DataGrid/PinnedSections/PinnedSections.d.ts +35 -0
  112. package/node/components/DataGrid/PinnedSections/PinnedSections.js +15 -0
  113. package/node/components/DataGrid/PinnedSections/Section/Section.d.ts +3 -0
  114. package/node/components/DataGrid/PinnedSections/Section/Section.js +21 -0
  115. package/node/components/DataGrid/PinnedSections/Section/index.d.ts +1 -0
  116. package/node/components/DataGrid/PinnedSections/Section/index.js +17 -0
  117. package/node/components/DataGrid/PinnedSections/Section/styles.d.ts +5 -0
  118. package/node/components/DataGrid/PinnedSections/Section/styles.js +103 -0
  119. package/node/components/DataGrid/PinnedSections/Section/types.d.ts +26 -0
  120. package/node/components/DataGrid/PinnedSections/Section/types.js +2 -0
  121. package/node/components/DataGrid/PinnedSections/Section/useLogic/index.d.ts +1 -0
  122. package/node/components/DataGrid/PinnedSections/Section/useLogic/useLogic.d.ts +9 -0
  123. package/node/components/DataGrid/PinnedSections/Section/useLogic/useLogic.js +20 -0
  124. package/node/components/DataGrid/PinnedSections/index.d.ts +1 -0
  125. package/node/components/DataGrid/PinnedSections/index.js +17 -0
  126. package/node/components/DataGrid/PinnedSections/styles.d.ts +7 -0
  127. package/node/components/DataGrid/PinnedSections/styles.js +21 -0
  128. package/node/components/DataGrid/PinnedSections/types.d.ts +5 -0
  129. package/node/components/DataGrid/PinnedSections/types.js +2 -0
  130. package/node/components/DataGrid/PinnedSections/useLogic/index.d.ts +1 -0
  131. package/node/components/DataGrid/PinnedSections/useLogic/index.js +17 -0
  132. package/node/components/DataGrid/PinnedSections/useLogic/useLogic.d.ts +9 -0
  133. package/node/components/DataGrid/PinnedSections/useLogic/useLogic.js +23 -0
  134. package/node/components/DataGrid/Row/NestedChildren/NestedChildren.js +1 -1
  135. package/node/components/DataGrid/Row/Row.d.ts +1 -94
  136. package/node/components/DataGrid/Row/Row.js +23 -8
  137. package/node/components/DataGrid/Row/constants.d.ts +3 -1
  138. package/node/components/DataGrid/Row/constants.js +4 -2
  139. package/node/components/DataGrid/Row/styles.js +8 -7
  140. package/node/components/DataGrid/Row/types.d.ts +118 -0
  141. package/node/components/DataGrid/Row/types.js +2 -0
  142. package/node/components/DataGrid/Row/useLogic/useLogic.d.ts +3 -2
  143. package/node/components/DataGrid/Row/useLogic/useLogic.js +13 -1
  144. package/node/components/DataGrid/constants.d.ts +7 -0
  145. package/node/components/DataGrid/constants.js +7 -0
  146. package/node/components/DataGrid/hooks/index.d.ts +1 -0
  147. package/node/components/DataGrid/hooks/index.js +17 -0
  148. package/node/components/DataGrid/hooks/useRowHover/index.d.ts +1 -0
  149. package/node/components/DataGrid/hooks/useRowHover/index.js +17 -0
  150. package/node/components/DataGrid/hooks/useRowHover/useRowHover.d.ts +15 -0
  151. package/node/components/DataGrid/hooks/useRowHover/useRowHover.js +97 -0
  152. package/node/components/DataGrid/styles.js +17 -0
  153. package/node/components/DataGrid/types.d.ts +4 -0
  154. package/node/components/DataGrid/useLogic/hooks/index.d.ts +2 -0
  155. package/node/components/DataGrid/useLogic/hooks/index.js +18 -0
  156. package/node/components/DataGrid/useLogic/hooks/useClassnames/index.d.ts +1 -0
  157. package/node/components/DataGrid/useLogic/hooks/useClassnames/index.js +17 -0
  158. package/node/components/DataGrid/useLogic/hooks/useClassnames/useClassnames.d.ts +12 -0
  159. package/node/components/DataGrid/useLogic/hooks/useClassnames/useClassnames.js +18 -0
  160. package/node/components/DataGrid/useLogic/hooks/usePinnedColumns/index.d.ts +1 -0
  161. package/node/components/DataGrid/useLogic/hooks/usePinnedColumns/index.js +17 -0
  162. package/node/components/DataGrid/useLogic/hooks/usePinnedColumns/usePinnedColumns.d.ts +18 -0
  163. package/node/components/DataGrid/useLogic/hooks/usePinnedColumns/usePinnedColumns.js +47 -0
  164. package/node/components/DataGrid/useLogic/useLogic.d.ts +30 -4
  165. package/node/components/DataGrid/useLogic/useLogic.js +53 -14
  166. package/node/components/DataGrid/useLogic/utils/getColumnSections/getColumnSections.d.ts +17 -0
  167. package/node/components/DataGrid/useLogic/utils/getColumnSections/getColumnSections.js +50 -0
  168. package/node/components/DataGrid/useLogic/utils/getColumnSections/index.d.ts +1 -0
  169. package/node/components/DataGrid/useLogic/utils/getColumnSections/index.js +17 -0
  170. package/node/components/DataGrid/useLogic/utils/index.d.ts +2 -1
  171. package/node/components/DataGrid/useLogic/utils/index.js +5 -3
  172. package/node/components/DataGrid/useLogic/utils/syncRowsHeight/index.d.ts +1 -0
  173. package/node/components/DataGrid/useLogic/utils/syncRowsHeight/index.js +17 -0
  174. package/node/components/DataGrid/useLogic/utils/syncRowsHeight/syncRowsHeight.d.ts +5 -0
  175. package/node/components/DataGrid/useLogic/utils/syncRowsHeight/syncRowsHeight.js +25 -0
  176. package/node/components/DataGrid/utils/index.d.ts +1 -0
  177. package/node/components/DataGrid/utils/index.js +3 -1
  178. package/node/components/DataGridInfinite/useLogic/useLogic.js +1 -1
  179. package/package.json +2 -1
  180. package/components/DataGrid/Body/useLogic/useLogic.d.ts +0 -12
  181. package/components/DataGrid/Body/useLogic/useLogic.js +0 -11
  182. package/node/components/DataGrid/Body/useLogic/useLogic.d.ts +0 -12
  183. package/node/components/DataGrid/Body/useLogic/useLogic.js +0 -15
  184. /package/components/DataGrid/{Body → PinnedSections/Section}/useLogic/index.d.ts +0 -0
  185. /package/components/DataGrid/{Body → PinnedSections/Section}/useLogic/index.js +0 -0
  186. /package/{node/components/DataGrid/Body → components/DataGrid/PinnedSections}/useLogic/index.d.ts +0 -0
  187. /package/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/getGridTemplateColumns.d.ts +0 -0
  188. /package/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/getGridTemplateColumns.js +0 -0
  189. /package/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/index.d.ts +0 -0
  190. /package/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/index.js +0 -0
  191. /package/node/components/DataGrid/{Body → PinnedSections/Section}/useLogic/index.js +0 -0
  192. /package/node/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/getGridTemplateColumns.d.ts +0 -0
  193. /package/node/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/getGridTemplateColumns.js +0 -0
  194. /package/node/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/index.d.ts +0 -0
  195. /package/node/components/DataGrid/{useLogic/utils → utils}/getGridTemplateColumns/index.js +0 -0
@@ -2,35 +2,30 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useLogic = void 0;
4
4
  const react_1 = require("react");
5
+ const ConfigProvider_1 = require("../../ConfigProvider");
5
6
  const useFirstMountState_1 = require("../../useFirstMountState");
6
7
  const prop_1 = require("../../utils/prop");
7
8
  const uniqueBy_1 = require("../../utils/uniqueBy");
8
9
  const enums_1 = require("../enums");
10
+ const getGridTemplateColumns_1 = require("../utils/getGridTemplateColumns");
11
+ const hooks_1 = require("./hooks");
9
12
  const utils_1 = require("./utils");
10
- const useLogic = ({ keyId, columns, rows = [], variant, tree, subrows, selectedRows = [], isLoading, isDisabled, onSelectRow, isHideSelectAll, isHideHeaderIfNoData = false, }) => {
13
+ const useLogic = ({ keyId, columns, rows = [], variant, tree, subrows, selectedRows = [], isLoading, isDisabled, onSelectRow, isError, onRetry, errorMsg, isHideSelectAll, isHideHeaderIfNoData = false, sorting, className, onSort, }) => {
11
14
  const isFirstRender = (0, useFirstMountState_1.useFirstMountState)();
12
15
  const isSelectable = Boolean(onSelectRow);
13
16
  const isDataGridDisabled = isLoading || isDisabled;
17
+ const { imagesMap } = (0, react_1.useContext)(ConfigProvider_1.ConfigContext);
14
18
  // Реф добавлен для избежания замыкания selectedRows в handleSelectRow (иначе в handleSelectRow приходят некорректные значения selectedRows).
15
19
  const selectedRowsRef = (0, react_1.useRef)(selectedRows);
16
20
  (0, react_1.useEffect)(() => {
17
21
  selectedRowsRef.current = selectedRows;
18
22
  }, [selectedRows]);
19
- const treeRenderConfig = Object.is(variant, enums_1.Variant.Subrows)
20
- ? { ...subrows, isInitialExpanded: true }
21
- : tree;
22
- const availableRows = rows.filter((row) => !(row.options?.isDisabled || row.options?.isNotSelectable));
23
23
  const prevRowsRef = (0, react_1.useRef)([]);
24
24
  (0, react_1.useEffect)(() => {
25
25
  if (!isLoading) {
26
26
  prevRowsRef.current = rows;
27
27
  }
28
28
  }, [rows, isLoading]);
29
- const gridColumns = (0, utils_1.getGridTemplateColumns)(columns);
30
- const isAllowHorizontalScroll = (0, utils_1.getIsAllowHorizontalScroll)(columns);
31
- const uncheckedRowsCount = (0, react_1.useMemo)(() => {
32
- return availableRows.filter((row) => !selectedRows.find((selectedRow) => selectedRow[keyId] === row[keyId])).length;
33
- }, [availableRows, selectedRows, keyId]);
34
29
  const processedColumns = (0, react_1.useCallback)(() => {
35
30
  if (rows.length <= 1) {
36
31
  return columns.map((column) => ({ ...column, sortable: false }));
@@ -38,6 +33,26 @@ const useLogic = ({ keyId, columns, rows = [], variant, tree, subrows, selectedR
38
33
  return columns;
39
34
  }, [columns, rows]);
40
35
  const renderRows = isLoading ? prevRowsRef.current : rows;
36
+ const isNoData = !renderRows.length;
37
+ const { containerRef, rowHoverProps, sections, hasPinnedColumns } = (0, hooks_1.usePinnedColumns)({
38
+ isLoading,
39
+ columns: processedColumns(),
40
+ });
41
+ const { pinnedSectionsClassname, dataGridClassname, bodyClassName } = (0, hooks_1.useClassnames)({
42
+ isDataGridDisabled,
43
+ dataGridClassName: className,
44
+ hasPinnedColumns,
45
+ isNoData,
46
+ });
47
+ const treeRenderConfig = Object.is(variant, enums_1.Variant.Subrows)
48
+ ? { ...subrows, isInitialExpanded: true }
49
+ : tree;
50
+ const availableRows = rows.filter((row) => !(row.options?.isDisabled || row.options?.isNotSelectable));
51
+ const gridColumns = (0, getGridTemplateColumns_1.getGridTemplateColumns)(columns);
52
+ const isAllowHorizontalScroll = (0, utils_1.getIsAllowHorizontalScroll)(columns);
53
+ const uncheckedRowsCount = (0, react_1.useMemo)(() => {
54
+ return availableRows.filter((row) => !selectedRows.find((selectedRow) => selectedRow[keyId] === row[keyId])).length;
55
+ }, [availableRows, selectedRows, keyId]);
41
56
  const handleSelectAllRows = (event) => {
42
57
  if (!onSelectRow) {
43
58
  return;
@@ -58,27 +73,51 @@ const useLogic = ({ keyId, columns, rows = [], variant, tree, subrows, selectedR
58
73
  }
59
74
  onSelectRow(selectedRowsRef.current.filter((selectedRow) => selectedRow[keyId] !== row[keyId]));
60
75
  };
61
- const isHideHead = isHideHeaderIfNoData && rows.length === 0;
76
+ const isHideHead = isHideHeaderIfNoData && isNoData;
77
+ const contentStateProps = (0, react_1.useMemo)(() => {
78
+ return {
79
+ isLoading: isLoading && isNoData,
80
+ isError: isError && isNoData,
81
+ loadingTitle: 'Загрузка данных',
82
+ errorState: {
83
+ imgAlt: 'Что-то пошло не так',
84
+ errorList: [errorMsg || ''],
85
+ imgSrc: imagesMap.defaultErrorImgSrc,
86
+ onRetry,
87
+ },
88
+ isSmoothLoading: false,
89
+ };
90
+ }, [isLoading, isError, isNoData, errorMsg, onRetry, imagesMap]);
62
91
  return {
92
+ pinnedSectionsClassname,
93
+ dataGridClassname,
63
94
  isDataGridDisabled,
64
95
  treeRenderConfig,
65
96
  renderRows,
66
97
  isAllowHorizontalScroll,
67
98
  isHideHead,
99
+ hasPinnedColumns,
100
+ contentStateProps,
101
+ rowHoverProps,
102
+ containerRef,
103
+ gridColumns,
104
+ isNoData,
105
+ headColumns: processedColumns(),
68
106
  headProps: {
69
107
  rowsCount: availableRows.length,
70
108
  uncheckedRowsCount,
71
- gridColumns,
72
109
  isSelectable,
73
- columns: processedColumns(),
74
110
  onSelectAllRows: handleSelectAllRows,
75
111
  isHideSelectAll,
112
+ sorting,
113
+ onSort,
76
114
  },
77
115
  bodyProps: {
78
- gridColumns,
79
116
  isSelectable,
80
117
  onSelectRow: handleSelectRow,
81
118
  },
119
+ bodyClassName,
120
+ sections,
82
121
  loaderProps: {
83
122
  isLoading: !isFirstRender && isLoading,
84
123
  isVisibleDivider: Boolean(rows.length),
@@ -0,0 +1,17 @@
1
+ import type { PinnedSection } from '../../../PinnedSections/types';
2
+ import type { DataGridColumns, DataGridRow } from '../../../types';
3
+ /**
4
+ * Валидирует корректность комбинаций закрепления колонок.
5
+ * Выбрасывает ошибку, если колонки с pinned="right" не идут непрерывным блоком в конце
6
+ * или колонки с pinned="left" не идут непрерывным блоком в начале.
7
+ */
8
+ export declare const validatePinnedColumns: (positions: ('left' | 'right' | 'center')[]) => void;
9
+ /**
10
+ * Группирует колонки DataGrid по закреплённым позициям (pinned):
11
+ * - left (закреплены слева)
12
+ * - center (обычные, не закреплённые)
13
+ * - right (закреплены справа)
14
+ */
15
+ export declare const getColumnSections: <TData extends Record<string, unknown> = DataGridRow>(columns: DataGridColumns<TData>[]) => {
16
+ sections: PinnedSection<TData>[];
17
+ };
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getColumnSections = exports.validatePinnedColumns = void 0;
4
+ /**
5
+ * Валидирует корректность комбинаций закрепления колонок.
6
+ * Выбрасывает ошибку, если колонки с pinned="right" не идут непрерывным блоком в конце
7
+ * или колонки с pinned="left" не идут непрерывным блоком в начале.
8
+ */
9
+ const validatePinnedColumns = (positions) => {
10
+ const firstRight = positions.indexOf('right');
11
+ if (firstRight !== -1 &&
12
+ positions.slice(firstRight).some((p) => p !== 'right')) {
13
+ // biome-ignore lint/suspicious/noConsole: Сообщение для интеграторов
14
+ console.error('DataGrid: Колонки с pinned="right" должны идти непрерывным блоком в конце');
15
+ }
16
+ // left: должны быть в начале
17
+ const lastLeft = positions.lastIndexOf('left');
18
+ if (lastLeft !== -1 &&
19
+ positions.slice(0, lastLeft + 1).some((p) => p !== 'left')) {
20
+ // biome-ignore lint/suspicious/noConsole: Сообщение для интеграторов
21
+ console.error('DataGrid: Колонки с pinned="left" должны идти непрерывным блоком в начале');
22
+ }
23
+ };
24
+ exports.validatePinnedColumns = validatePinnedColumns;
25
+ /**
26
+ * Группирует колонки DataGrid по закреплённым позициям (pinned):
27
+ * - left (закреплены слева)
28
+ * - center (обычные, не закреплённые)
29
+ * - right (закреплены справа)
30
+ */
31
+ const getColumnSections = (columns) => {
32
+ const groups = columns.reduce((acc, col) => {
33
+ const position = col.pinned ?? 'center';
34
+ if (!acc[position]) {
35
+ acc[position] = [];
36
+ }
37
+ acc[position].push(col);
38
+ return acc;
39
+ }, {});
40
+ const positions = columns.map((c) => c.pinned ?? 'center');
41
+ (0, exports.validatePinnedColumns)(positions);
42
+ return {
43
+ sections: [
44
+ { position: 'left', columns: groups.left },
45
+ { position: 'center', columns: groups.center },
46
+ { position: 'right', columns: groups.right },
47
+ ],
48
+ };
49
+ };
50
+ exports.getColumnSections = getColumnSections;
@@ -0,0 +1 @@
1
+ export * from './getColumnSections';
@@ -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("./getColumnSections"), exports);
@@ -1,2 +1,3 @@
1
- export { getGridTemplateColumns } from './getGridTemplateColumns';
2
1
  export { getIsAllowHorizontalScroll } from './getIsAllowHorizontalScroll';
2
+ export { syncRowsHeight } from './syncRowsHeight';
3
+ export { getColumnSections } from './getColumnSections';
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getIsAllowHorizontalScroll = exports.getGridTemplateColumns = void 0;
4
- var getGridTemplateColumns_1 = require("./getGridTemplateColumns");
5
- Object.defineProperty(exports, "getGridTemplateColumns", { enumerable: true, get: function () { return getGridTemplateColumns_1.getGridTemplateColumns; } });
3
+ exports.getColumnSections = exports.syncRowsHeight = exports.getIsAllowHorizontalScroll = void 0;
6
4
  var getIsAllowHorizontalScroll_1 = require("./getIsAllowHorizontalScroll");
7
5
  Object.defineProperty(exports, "getIsAllowHorizontalScroll", { enumerable: true, get: function () { return getIsAllowHorizontalScroll_1.getIsAllowHorizontalScroll; } });
6
+ var syncRowsHeight_1 = require("./syncRowsHeight");
7
+ Object.defineProperty(exports, "syncRowsHeight", { enumerable: true, get: function () { return syncRowsHeight_1.syncRowsHeight; } });
8
+ var getColumnSections_1 = require("./getColumnSections");
9
+ Object.defineProperty(exports, "getColumnSections", { enumerable: true, get: function () { return getColumnSections_1.getColumnSections; } });
@@ -0,0 +1 @@
1
+ export * from './syncRowsHeight';
@@ -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("./syncRowsHeight"), exports);
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Синхронизирует высоту строк DataGrid на основе высоты их содержимого.
3
+ * Каждая строка устанавливает высоту равной максимальной высоте всех своих ячеек.
4
+ */
5
+ export declare const syncRowsHeight: (rowsMap: Map<string, Set<HTMLElement>>) => void;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.syncRowsHeight = void 0;
4
+ /**
5
+ * Синхронизирует высоту строк DataGrid на основе высоты их содержимого.
6
+ * Каждая строка устанавливает высоту равной максимальной высоте всех своих ячеек.
7
+ */
8
+ const syncRowsHeight = (rowsMap) => {
9
+ rowsMap.forEach((elements) => {
10
+ let maxHeight = 0;
11
+ elements.forEach((el) => {
12
+ el.style.height = '';
13
+ });
14
+ elements.forEach((el) => {
15
+ const height = el.offsetHeight;
16
+ if (height > maxHeight) {
17
+ maxHeight = height;
18
+ }
19
+ });
20
+ elements.forEach((el) => {
21
+ el.style.height = `${maxHeight}px`;
22
+ });
23
+ });
24
+ };
25
+ exports.syncRowsHeight = syncRowsHeight;
@@ -1 +1,2 @@
1
1
  export { alignToJustifyContent } from './alignToJustifyContent';
2
+ export { getGridTemplateColumns } from './getGridTemplateColumns';
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.alignToJustifyContent = void 0;
3
+ exports.getGridTemplateColumns = exports.alignToJustifyContent = void 0;
4
4
  var alignToJustifyContent_1 = require("./alignToJustifyContent");
5
5
  Object.defineProperty(exports, "alignToJustifyContent", { enumerable: true, get: function () { return alignToJustifyContent_1.alignToJustifyContent; } });
6
+ var getGridTemplateColumns_1 = require("./getGridTemplateColumns");
7
+ Object.defineProperty(exports, "getGridTemplateColumns", { enumerable: true, get: function () { return getGridTemplateColumns_1.getGridTemplateColumns; } });
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useLogic = void 0;
4
4
  const react_1 = require("react");
5
5
  const enums_1 = require("../../DataGrid/enums");
6
- const utils_1 = require("../../DataGrid/useLogic/utils");
6
+ const utils_1 = require("../../DataGrid/utils");
7
7
  const useToggle_1 = require("../../useToggle");
8
8
  const prop_1 = require("../../utils/prop");
9
9
  const uniqueBy_1 = require("../../utils/uniqueBy");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/ui",
3
- "version": "4.45.0",
3
+ "version": "4.47.0",
4
4
  "browser": "./index.js",
5
5
  "main": "./node/index.js",
6
6
  "dependencies": {
@@ -12,6 +12,7 @@
12
12
  "@emotion/styled": "^11.13.5",
13
13
  "@mui/material": "5.13.0",
14
14
  "classnames": "^2.5.1",
15
+ "class-variance-authority": "^0.7.1",
15
16
  "colord": "^2.9.3",
16
17
  "dayjs": "^1.11.5",
17
18
  "react-imask": "6.4.2",
@@ -1,12 +0,0 @@
1
- import type { CellValue } from '../../types';
2
- import { type BodyProps } from '../Body';
3
- type UseLogicParams<TData extends Record<string, CellValue>> = BodyProps<TData>;
4
- export declare const useLogic: <TData extends Record<string, unknown>>({ isLoading, isError, rows, }: UseLogicParams<TData>) => {
5
- isNoData: boolean;
6
- contentStateProps: {
7
- isLoading: boolean | undefined;
8
- isError: boolean | undefined;
9
- loadingTitle: string;
10
- };
11
- };
12
- export {};
@@ -1,11 +0,0 @@
1
- export const useLogic = ({ isLoading, isError, rows, }) => {
2
- const isNoData = !rows.length;
3
- return {
4
- isNoData,
5
- contentStateProps: {
6
- isLoading: isLoading && isNoData,
7
- isError: isError && isNoData,
8
- loadingTitle: 'Загрузка данных',
9
- },
10
- };
11
- };
@@ -1,12 +0,0 @@
1
- import type { CellValue } from '../../types';
2
- import { type BodyProps } from '../Body';
3
- type UseLogicParams<TData extends Record<string, CellValue>> = BodyProps<TData>;
4
- export declare const useLogic: <TData extends Record<string, unknown>>({ isLoading, isError, rows, }: UseLogicParams<TData>) => {
5
- isNoData: boolean;
6
- contentStateProps: {
7
- isLoading: boolean | undefined;
8
- isError: boolean | undefined;
9
- loadingTitle: string;
10
- };
11
- };
12
- export {};
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useLogic = void 0;
4
- const useLogic = ({ isLoading, isError, rows, }) => {
5
- const isNoData = !rows.length;
6
- return {
7
- isNoData,
8
- contentStateProps: {
9
- isLoading: isLoading && isNoData,
10
- isError: isError && isNoData,
11
- loadingTitle: 'Загрузка данных',
12
- },
13
- };
14
- };
15
- exports.useLogic = useLogic;