@astral/ui 4.114.0 → 4.115.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 (151) hide show
  1. package/components/DataGrid/Body/Body.d.ts +1 -1
  2. package/components/DataGrid/Body/Body.js +7 -3
  3. package/components/DataGrid/Body/types.d.ts +11 -3
  4. package/components/DataGrid/DataGrid.js +0 -1
  5. package/components/DataGrid/PinnedSections/PinnedSections.js +2 -2
  6. package/components/DataGrid/PinnedSections/useLogic/useLogic.d.ts +1 -0
  7. package/components/DataGrid/PinnedSections/useLogic/useLogic.js +4 -3
  8. package/components/DataGrid/Row/Row.js +13 -9
  9. package/components/DataGrid/Row/RowContext/RowContext.d.ts +15 -4
  10. package/components/DataGrid/Row/RowContext/RowContext.js +3 -3
  11. package/components/DataGrid/Row/RowContext/RowProvider/RowProvider.d.ts +10 -1
  12. package/components/DataGrid/Row/RowContext/RowProvider/RowProvider.js +23 -17
  13. package/components/DataGrid/Row/types.d.ts +7 -3
  14. package/components/DataGrid/Row/useLogic/useLogic.d.ts +6 -4
  15. package/components/DataGrid/Row/useLogic/useLogic.js +21 -12
  16. package/components/DataGrid/RowBase/RowBase.js +5 -2
  17. package/components/DataGrid/RowBase/types.d.ts +9 -5
  18. package/components/DataGrid/RowBase/useLogic/useLogic.d.ts +5 -4
  19. package/components/DataGrid/RowBase/useLogic/useLogic.js +16 -10
  20. package/components/DataGrid/RowCheckbox/RowCheckbox.d.ts +5 -0
  21. package/components/DataGrid/RowCheckbox/RowCheckbox.js +13 -0
  22. package/components/DataGrid/RowCheckbox/constants.d.ts +4 -0
  23. package/components/DataGrid/RowCheckbox/constants.js +4 -0
  24. package/components/DataGrid/RowCheckbox/index.d.ts +1 -0
  25. package/components/DataGrid/RowCheckbox/index.js +1 -0
  26. package/components/DataGrid/RowCheckbox/types.d.ts +7 -0
  27. package/components/DataGrid/RowCheckbox/types.js +1 -0
  28. package/components/DataGrid/hooks/index.d.ts +1 -0
  29. package/components/DataGrid/hooks/index.js +1 -0
  30. package/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/index.d.ts +1 -0
  31. package/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/index.js +1 -0
  32. package/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/useWarnRowsWithoutDisabledReason.d.ts +5 -0
  33. package/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/useWarnRowsWithoutDisabledReason.js +17 -0
  34. package/components/DataGrid/index.d.ts +1 -1
  35. package/components/DataGrid/public.d.ts +1 -1
  36. package/components/DataGrid/tests/performance/testDataGridPerformance.d.ts +3 -1
  37. package/components/DataGrid/tests/performance/testDataGridPerformance.js +234 -2
  38. package/components/DataGrid/tests/selection/testDataGridSelection.d.ts +14 -0
  39. package/components/DataGrid/tests/selection/testDataGridSelection.js +562 -0
  40. package/components/DataGrid/types.d.ts +34 -1
  41. package/components/DataGrid/useLogic/useLogic.d.ts +6 -3
  42. package/components/DataGrid/useLogic/useLogic.js +15 -10
  43. package/components/DataGrid/utils/getRowDisabledState/getRowDisabledState.d.ts +31 -0
  44. package/components/DataGrid/utils/getRowDisabledState/getRowDisabledState.js +20 -0
  45. package/components/DataGrid/utils/getRowDisabledState/index.d.ts +1 -0
  46. package/components/DataGrid/utils/getRowDisabledState/index.js +1 -0
  47. package/components/DataGrid/utils/index.d.ts +3 -0
  48. package/components/DataGrid/utils/index.js +3 -0
  49. package/components/DataGrid/utils/resolveRowDisabled/index.d.ts +1 -0
  50. package/components/DataGrid/utils/resolveRowDisabled/index.js +1 -0
  51. package/components/DataGrid/utils/resolveRowDisabled/resolveRowDisabled.d.ts +5 -0
  52. package/components/DataGrid/utils/resolveRowDisabled/resolveRowDisabled.js +17 -0
  53. package/components/DataGrid/utils/resolveRowsDisabled/index.d.ts +1 -0
  54. package/components/DataGrid/utils/resolveRowsDisabled/index.js +1 -0
  55. package/components/DataGrid/utils/resolveRowsDisabled/resolveRowsDisabled.d.ts +16 -0
  56. package/components/DataGrid/utils/resolveRowsDisabled/resolveRowsDisabled.js +17 -0
  57. package/components/DataGridActionCell/hooks/useBlockingActions/useBlockingActions.js +3 -3
  58. package/components/DataGridCollapsibleRow/useLogic/useLogic.d.ts +3 -2
  59. package/components/DataGridCollapsibleRow/useLogic/useLogic.js +4 -3
  60. package/components/DataGridInfinite/DataGridInfinite.js +4 -4
  61. package/components/DataGridInfinite/DataGridInfiniteContext/DataGridInfiniteContext.d.ts +1 -1
  62. package/components/DataGridInfinite/DataGridInfiniteContext/DataGridInfiniteContext.js +1 -1
  63. package/components/DataGridInfinite/Footer/Footer.js +2 -2
  64. package/components/DataGridInfinite/Row/Row.js +2 -2
  65. package/components/DataGridInfinite/Row/index.d.ts +1 -0
  66. package/components/DataGridInfinite/Row/types.d.ts +17 -2
  67. package/components/DataGridInfinite/Row/useLogic/useLogic.d.ts +4 -2
  68. package/components/DataGridInfinite/Row/useLogic/useLogic.js +12 -4
  69. package/components/DataGridInfinite/constants.d.ts +2 -0
  70. package/components/DataGridInfinite/constants.js +2 -0
  71. package/components/DataGridInfinite/faker.d.ts +1 -5
  72. package/components/DataGridInfinite/faker.js +1 -2
  73. package/components/DataGridInfinite/useLogic/useLogic.d.ts +3 -2
  74. package/components/DataGridInfinite/useLogic/useLogic.js +25 -13
  75. package/components/index.d.ts +1 -1
  76. package/node/components/DataGrid/Body/Body.d.ts +1 -1
  77. package/node/components/DataGrid/Body/Body.js +7 -3
  78. package/node/components/DataGrid/Body/types.d.ts +11 -3
  79. package/node/components/DataGrid/DataGrid.js +0 -1
  80. package/node/components/DataGrid/PinnedSections/PinnedSections.js +2 -2
  81. package/node/components/DataGrid/PinnedSections/useLogic/useLogic.d.ts +1 -0
  82. package/node/components/DataGrid/PinnedSections/useLogic/useLogic.js +4 -3
  83. package/node/components/DataGrid/Row/Row.js +13 -9
  84. package/node/components/DataGrid/Row/RowContext/RowContext.d.ts +15 -4
  85. package/node/components/DataGrid/Row/RowContext/RowContext.js +3 -3
  86. package/node/components/DataGrid/Row/RowContext/RowProvider/RowProvider.d.ts +10 -1
  87. package/node/components/DataGrid/Row/RowContext/RowProvider/RowProvider.js +23 -17
  88. package/node/components/DataGrid/Row/types.d.ts +7 -3
  89. package/node/components/DataGrid/Row/useLogic/useLogic.d.ts +6 -4
  90. package/node/components/DataGrid/Row/useLogic/useLogic.js +23 -14
  91. package/node/components/DataGrid/RowBase/RowBase.js +5 -2
  92. package/node/components/DataGrid/RowBase/types.d.ts +9 -5
  93. package/node/components/DataGrid/RowBase/useLogic/useLogic.d.ts +5 -4
  94. package/node/components/DataGrid/RowBase/useLogic/useLogic.js +16 -10
  95. package/node/components/DataGrid/RowCheckbox/RowCheckbox.d.ts +5 -0
  96. package/node/components/DataGrid/RowCheckbox/RowCheckbox.js +17 -0
  97. package/node/components/DataGrid/RowCheckbox/constants.d.ts +4 -0
  98. package/node/components/DataGrid/RowCheckbox/constants.js +7 -0
  99. package/node/components/DataGrid/RowCheckbox/index.d.ts +1 -0
  100. package/node/components/DataGrid/RowCheckbox/index.js +17 -0
  101. package/node/components/DataGrid/RowCheckbox/types.d.ts +7 -0
  102. package/node/components/DataGrid/RowCheckbox/types.js +2 -0
  103. package/node/components/DataGrid/hooks/index.d.ts +1 -0
  104. package/node/components/DataGrid/hooks/index.js +1 -0
  105. package/node/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/index.d.ts +1 -0
  106. package/node/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/index.js +17 -0
  107. package/node/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/useWarnRowsWithoutDisabledReason.d.ts +5 -0
  108. package/node/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/useWarnRowsWithoutDisabledReason.js +21 -0
  109. package/node/components/DataGrid/index.d.ts +1 -1
  110. package/node/components/DataGrid/public.d.ts +1 -1
  111. package/node/components/DataGrid/tests/performance/testDataGridPerformance.d.ts +3 -1
  112. package/node/components/DataGrid/tests/performance/testDataGridPerformance.js +232 -0
  113. package/node/components/DataGrid/tests/selection/testDataGridSelection.d.ts +14 -0
  114. package/node/components/DataGrid/tests/selection/testDataGridSelection.js +566 -0
  115. package/node/components/DataGrid/types.d.ts +34 -1
  116. package/node/components/DataGrid/useLogic/useLogic.d.ts +6 -3
  117. package/node/components/DataGrid/useLogic/useLogic.js +17 -12
  118. package/node/components/DataGrid/utils/getRowDisabledState/getRowDisabledState.d.ts +31 -0
  119. package/node/components/DataGrid/utils/getRowDisabledState/getRowDisabledState.js +24 -0
  120. package/node/components/DataGrid/utils/getRowDisabledState/index.d.ts +1 -0
  121. package/node/components/DataGrid/utils/getRowDisabledState/index.js +5 -0
  122. package/node/components/DataGrid/utils/index.d.ts +3 -0
  123. package/node/components/DataGrid/utils/index.js +7 -1
  124. package/node/components/DataGrid/utils/resolveRowDisabled/index.d.ts +1 -0
  125. package/node/components/DataGrid/utils/resolveRowDisabled/index.js +5 -0
  126. package/node/components/DataGrid/utils/resolveRowDisabled/resolveRowDisabled.d.ts +5 -0
  127. package/node/components/DataGrid/utils/resolveRowDisabled/resolveRowDisabled.js +21 -0
  128. package/node/components/DataGrid/utils/resolveRowsDisabled/index.d.ts +1 -0
  129. package/node/components/DataGrid/utils/resolveRowsDisabled/index.js +5 -0
  130. package/node/components/DataGrid/utils/resolveRowsDisabled/resolveRowsDisabled.d.ts +16 -0
  131. package/node/components/DataGrid/utils/resolveRowsDisabled/resolveRowsDisabled.js +21 -0
  132. package/node/components/DataGridActionCell/hooks/useBlockingActions/useBlockingActions.js +3 -3
  133. package/node/components/DataGridCollapsibleRow/useLogic/useLogic.d.ts +3 -2
  134. package/node/components/DataGridCollapsibleRow/useLogic/useLogic.js +4 -3
  135. package/node/components/DataGridInfinite/DataGridInfinite.js +4 -4
  136. package/node/components/DataGridInfinite/DataGridInfiniteContext/DataGridInfiniteContext.d.ts +1 -1
  137. package/node/components/DataGridInfinite/DataGridInfiniteContext/DataGridInfiniteContext.js +1 -1
  138. package/node/components/DataGridInfinite/Footer/Footer.js +1 -1
  139. package/node/components/DataGridInfinite/Row/Row.js +2 -2
  140. package/node/components/DataGridInfinite/Row/index.d.ts +1 -0
  141. package/node/components/DataGridInfinite/Row/types.d.ts +17 -2
  142. package/node/components/DataGridInfinite/Row/useLogic/useLogic.d.ts +4 -2
  143. package/node/components/DataGridInfinite/Row/useLogic/useLogic.js +12 -4
  144. package/node/components/DataGridInfinite/constants.d.ts +2 -0
  145. package/node/components/DataGridInfinite/constants.js +2 -0
  146. package/node/components/DataGridInfinite/faker.d.ts +1 -5
  147. package/node/components/DataGridInfinite/faker.js +1 -2
  148. package/node/components/DataGridInfinite/useLogic/useLogic.d.ts +3 -2
  149. package/node/components/DataGridInfinite/useLogic/useLogic.js +26 -14
  150. package/node/components/index.d.ts +1 -1
  151. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
1
  import type { BodyProps } from './types';
2
- export declare const Body: <TData extends Record<string, unknown>>({ rows, selectedRows, minDisplayRows, keyId, noDataPlaceholder, className, renderRow, columns, isSelectable, onSelectRow, onRowEnter, onRowLeave, registerRowElement, unregisterRowElement, ...rowProps }: BodyProps<TData>) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const Body: <TData extends Record<string, unknown>>({ rows, selectedIds, rowsDisabled, getRowDisabled, minDisplayRows, keyId, noDataPlaceholder, className, renderRow, columns, isSelectable, onSelectRow, onRowEnter, onRowLeave, registerRowElement, unregisterRowElement, ...rowProps }: BodyProps<TData>) => import("react/jsx-runtime").JSX.Element;
@@ -18,13 +18,17 @@ const bodyCva = (0, cva_1.cva)(constants_1.bodyClassnames.root, {
18
18
  },
19
19
  },
20
20
  });
21
- const Body = ({ rows, selectedRows = [], minDisplayRows, keyId, noDataPlaceholder, className, renderRow, columns, isSelectable, onSelectRow, onRowEnter, onRowLeave, registerRowElement, unregisterRowElement, ...rowProps }) => {
21
+ const Body = ({ rows, selectedIds, rowsDisabled, getRowDisabled, minDisplayRows, keyId, noDataPlaceholder, className, renderRow, columns, isSelectable, onSelectRow, onRowEnter, onRowLeave, registerRowElement, unregisterRowElement, ...rowProps }) => {
22
22
  const { disableMinHeight, bodyCssVars } = (0, useLogic_1.useLogic)({ minDisplayRows });
23
23
  const renderedRows = rows.map((row, index) => {
24
24
  const rowId = row[keyId];
25
- const isSelected = Boolean(selectedRows?.find((selectedRow) => selectedRow[keyId] === rowId));
25
+ const isSelected = selectedIds.has(rowId);
26
+ const rowDisabled = rowsDisabled.get(rowId);
26
27
  const { children, options } = row;
27
- return ((0, jsx_runtime_1.jsx)(RowContext_1.RowContextProvider, { row: row, onSelectRow: onSelectRow, onRowEnter: onRowEnter, onRowLeave: onRowLeave, registerRowElement: registerRowElement, unregisterRowElement: unregisterRowElement, isSelectable: isSelectable, isSelected: isSelected, children: renderRow ? ((0, jsx_runtime_1.jsx)(CustomRowWrapper_1.CustomRowWrapper, { index: index, renderRow: renderRow, row: row })) : ((0, jsx_runtime_1.jsx)(Row_1.Row, { row: row, options: options, keyId: keyId, level: INITIAL_LEVEL, nestedChildren: children, isSelected: isSelected, columns: columns, isSelectable: isSelectable, onSelectRow: onSelectRow, onRowEnter: onRowEnter, onRowLeave: onRowLeave, registerRowElement: registerRowElement, unregisterRowElement: unregisterRowElement, ...rowProps }, rowId)) }, rowId));
28
+ const hasNestedChildren = Array.isArray(children) && children.length > 0;
29
+ return ((0, jsx_runtime_1.jsx)(RowContext_1.RowContextProvider, { row: row, onSelectRow: onSelectRow, onRowEnter: onRowEnter, onRowLeave: onRowLeave, registerRowElement: registerRowElement, unregisterRowElement: unregisterRowElement, isSelectable: isSelectable, isSelected: isSelected, disabledMode: rowDisabled?.mode, disabledReason: rowDisabled?.reason, children: renderRow ? ((0, jsx_runtime_1.jsx)(CustomRowWrapper_1.CustomRowWrapper, { index: index, renderRow: renderRow, row: row })) : ((0, jsx_runtime_1.jsx)(Row_1.Row, { row: row, options: options, keyId: keyId, level: INITIAL_LEVEL, nestedChildren: children, isSelected: isSelected,
30
+ // Функция нужна только для расчёта блокировки вложенных строк, остальным не передаём, чтобы не сбрасывать memo
31
+ getRowDisabled: hasNestedChildren ? getRowDisabled : undefined, columns: columns, isSelectable: isSelectable, onSelectRow: onSelectRow, onRowEnter: onRowEnter, onRowLeave: onRowLeave, registerRowElement: registerRowElement, unregisterRowElement: unregisterRowElement, ...rowProps }, rowId)) }, rowId));
28
32
  });
29
33
  return ((0, jsx_runtime_1.jsx)(styles_1.Wrapper, { className: (0, cn_1.cn)(className, bodyCva({ disableMinHeight })), style: bodyCssVars, children: rows.length ? renderedRows : noDataPlaceholder }));
30
34
  };
@@ -1,6 +1,6 @@
1
1
  import { type ChangeEvent, type ReactNode } from 'react';
2
2
  import { type Variant } from '../enums';
3
- import { type CellValue, type DataGridColumns, type DataGridRowOptions } from '../types';
3
+ import { type CellValue, type DataGridColumns, type DataGridProps, type DataGridRowDisabled, type DataGridRowOptions } from '../types';
4
4
  export type BodyProps<TData extends Record<string, CellValue>> = {
5
5
  /**
6
6
  * Конфигурация колонок для таблицы
@@ -46,9 +46,17 @@ export type BodyProps<TData extends Record<string, CellValue>> = {
46
46
  */
47
47
  isSelectable?: boolean;
48
48
  /**
49
- * Массив выбранных строк
49
+ * Идентификаторы выбранных строк
50
50
  */
51
- selectedRows?: TData[];
51
+ selectedIds: Set<unknown>;
52
+ /**
53
+ * Блокировки строк по идентификатору
54
+ */
55
+ rowsDisabled: Map<unknown, DataGridRowDisabled | undefined>;
56
+ /**
57
+ * Функция блокировки для вложенных строк
58
+ */
59
+ getRowDisabled?: DataGridProps<TData>['getRowDisabled'];
52
60
  /**
53
61
  * Массив данных для отображения
54
62
  */
@@ -82,7 +82,6 @@ const DataGrid = (props) => {
82
82
  const commonBodyProps = {
83
83
  ...bodyProps,
84
84
  keyId,
85
- selectedRows,
86
85
  minDisplayRows,
87
86
  rows: renderRows,
88
87
  variant,
@@ -7,9 +7,9 @@ const Section_1 = require("./Section");
7
7
  const styles_1 = require("./styles");
8
8
  const useLogic_1 = require("./useLogic");
9
9
  const PinnedSections = ({ gridColumns, className, isDisabled, headProps, bodyProps, sections, isNoData, }) => {
10
- const { pinnedContainerStyles, sectionOffsets } = (0, useLogic_1.useLogic)({ sections });
10
+ const { pinnedContainerStyles, sectionOffsets, totalColumnsCount } = (0, useLogic_1.useLogic)({ sections });
11
11
  return ((0, jsx_runtime_1.jsx)(styles_1.PinnedColumnsContainer, { "$gridColumns": gridColumns, className: className, ...(0, getInertProps_1.getInertProps)(isDisabled), style: pinnedContainerStyles, children: sections.map(({ columns, position }) => {
12
- return ((0, jsx_runtime_1.jsx)(Section_1.Section, { columns: columns, position: position, sectionOffset: sectionOffsets[position], bodyProps: bodyProps, headProps: headProps, isNoData: isNoData }, position));
12
+ return ((0, jsx_runtime_1.jsx)(Section_1.Section, { columns: columns, position: position, sectionOffset: sectionOffsets[position], bodyProps: { ...bodyProps, totalColumnsCount }, headProps: headProps, isNoData: isNoData }, position));
13
13
  }) }));
14
14
  };
15
15
  exports.PinnedSections = PinnedSections;
@@ -5,5 +5,6 @@ type UseLogicParams<TData extends Record<string, CellValue> = DataGridRow> = Pic
5
5
  export declare const useLogic: <TData extends Record<string, unknown> = DataGridRow>({ sections, }: UseLogicParams<TData>) => {
6
6
  pinnedContainerStyles: CSSProperties;
7
7
  sectionOffsets: Record<string, number>;
8
+ totalColumnsCount: number;
8
9
  };
9
10
  export {};
@@ -14,15 +14,16 @@ const useLogic = ({ sections, }) => {
14
14
  ? (0, utils_1.getFlattenColumns)(rightColumns).length
15
15
  : 0,
16
16
  };
17
- const sectionOffsets = (0, react_1.useMemo)(() => {
17
+ // Строка в секции видит только свои колонки, поэтому для поиска последней ячейки таблицы ей передаётся общее число колонок всех секций
18
+ const { sectionOffsets, totalColumnsCount } = (0, react_1.useMemo)(() => {
18
19
  const offsets = {};
19
20
  let currentOffset = 0;
20
21
  sections.forEach((section) => {
21
22
  offsets[section.position] = currentOffset;
22
23
  currentOffset += (0, utils_1.getFlattenColumns)(section.columns).length;
23
24
  });
24
- return offsets;
25
+ return { sectionOffsets: offsets, totalColumnsCount: currentOffset };
25
26
  }, [sections]);
26
- return { pinnedContainerStyles, sectionOffsets };
27
+ return { pinnedContainerStyles, sectionOffsets, totalColumnsCount };
27
28
  };
28
29
  exports.useLogic = useLogic;
@@ -4,12 +4,12 @@ exports.Row = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const BottomDrawer_1 = require("../../BottomDrawer");
7
- const Checkbox_1 = require("../../Checkbox");
8
7
  const Tooltip_1 = require("../../Tooltip");
9
8
  const cn_1 = require("../../utils/cn");
10
9
  const cva_1 = require("../../utils/cva");
11
10
  const getInertProps_1 = require("../../utils/getInertProps");
12
11
  const Cell_1 = require("../Cell");
12
+ const RowCheckbox_1 = require("../RowCheckbox");
13
13
  const utils_1 = require("../utils");
14
14
  const constants_1 = require("./constants");
15
15
  const NestedChildren_1 = require("./NestedChildren");
@@ -60,17 +60,17 @@ const singleCellCva = (0, cva_1.cva)(constants_1.dataGridRowCellClassnames.singl
60
60
  * который позволяет полностью контролировать рендер каждой строки.
61
61
  */
62
62
  const RowInner = (props) => {
63
- const { isOpen, isShowConnector, childrenColumns, rowId, handleToggle, checkboxProps, rowProps, isHovered, tooltipProps, nestedChildrenProps, disabled, isRenderCollapseButton, rowRef, rowStyles, drawerProps, disabledReasonText, isActive, isSelectable, mobileDisplayVariant, rootRowElement, rootRowRef, } = (0, useLogic_1.useLogic)(props);
64
- const { className, row, options, variant, gridColumns, isInitialExpanded, expandedLevel, level, nestedChildren, initialVisibleChildrenCount, moreButtonColumnPosition, isVisibleCollapseButton, columns, emptyCellValue, activeRowId, keyId, onSelectRow, onRowClick, sectionOffset, totalColumnsCount, registerRowElement, unregisterRowElement, onRowEnter, onRowLeave, style,
63
+ const { isOpen, isShowConnector, childrenColumns, rowId, handleToggle, checkboxProps, rowProps, isHovered, tooltipProps, nestedChildrenProps, isDisabled, isDisabledLastCell, isRenderCollapseButton, rowRef, rowStyles, drawerProps, disabledReason, isActive, isSelectable, mobileDisplayVariant, rootRowElement, rootRowRef, } = (0, useLogic_1.useLogic)(props);
64
+ const { className, row, options, variant, gridColumns, isInitialExpanded, expandedLevel, level, nestedChildren, initialVisibleChildrenCount, moreButtonColumnPosition, isVisibleCollapseButton, columns, emptyCellValue, activeRowId, keyId, onSelectRow, onRowClick, sectionOffset, totalColumnsCount, registerRowElement, unregisterRowElement, onRowEnter, onRowLeave, style, getRowDisabled, isNested,
65
65
  // В этот rest-оператор попадают специфичные пропсы (атрибуты) virtuoso
66
66
  // Необходимы для DataGridInfinite
67
67
  ...selfProps } = props;
68
- const { isDisabledLastCell = true, isNotSelectable, href, target, } = options || {};
68
+ const { isNotSelectable, href, target } = options || {};
69
69
  const renderStartAdornment = () => {
70
70
  if (!isRenderCollapseButton && (!isSelectable || isNotSelectable)) {
71
71
  return null;
72
72
  }
73
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isRenderCollapseButton && ((0, jsx_runtime_1.jsx)(styles_1.CollapseCell, { children: (0, jsx_runtime_1.jsx)(styles_1.CollapseButton, { variant: "text", onClick: handleToggle, children: (0, jsx_runtime_1.jsx)(styles_1.ChevronIcon, { "$isActive": isOpen }) }) })), isSelectable && !isNotSelectable && ((0, jsx_runtime_1.jsx)(styles_1.CheckboxCell, { ...(0, getInertProps_1.getInertProps)(disabled), onClick: (event) => event.stopPropagation(), className: constants_1.dataGridRowClassnames.checkbox, children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { ...checkboxProps }) }))] }));
73
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isRenderCollapseButton && ((0, jsx_runtime_1.jsx)(styles_1.CollapseCell, { children: (0, jsx_runtime_1.jsx)(styles_1.CollapseButton, { variant: "text", onClick: handleToggle, children: (0, jsx_runtime_1.jsx)(styles_1.ChevronIcon, { "$isActive": isOpen }) }) })), isSelectable && !isNotSelectable && ((0, jsx_runtime_1.jsx)(styles_1.CheckboxCell, { ...(0, getInertProps_1.getInertProps)(isDisabled), onClick: (event) => event.stopPropagation(), className: constants_1.dataGridRowClassnames.checkbox, children: (0, jsx_runtime_1.jsx)(RowCheckbox_1.RowCheckbox, { ...checkboxProps }) }))] }));
74
74
  };
75
75
  const renderCells = (0, react_1.useCallback)(() => {
76
76
  const lastCellGlobalIndex = (totalColumnsCount ?? columns.length) - 1;
@@ -80,7 +80,7 @@ const RowInner = (props) => {
80
80
  return columns?.map((cell, index) => {
81
81
  const cellId = `${rowId}-${index}`;
82
82
  const globalIndex = (sectionOffset ?? 0) + index;
83
- const isDisabledCell = (0, utils_2.checkIsDisabled)(disabled, availableCellsByIndex, globalIndex);
83
+ const isDisabledCell = (0, utils_2.checkIsDisabled)(isDisabled, availableCellsByIndex, globalIndex);
84
84
  const isFirstCell = globalIndex === 0;
85
85
  if ((0, utils_1.isGroupColumns)(cell)) {
86
86
  const { label, children, hideTitleOnMobile, isHideOnMobile } = cell;
@@ -98,13 +98,16 @@ const RowInner = (props) => {
98
98
  row,
99
99
  isOpen,
100
100
  columns,
101
- disabled,
101
+ isDisabled,
102
+ isDisabledLastCell,
102
103
  checkboxProps.checked,
104
+ checkboxProps.disabled,
105
+ checkboxProps.disabledReason,
103
106
  totalColumnsCount,
104
107
  sectionOffset,
105
108
  rootRowElement,
106
109
  ]);
107
- const renderRow = (0, react_1.useCallback)(({ key, ...nestedRowProps }) => ((0, jsx_runtime_1.jsx)(RowInner, { keyId: keyId, ...nestedRowProps, variant: variant, isSelectable: isSelectable, 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)), [
110
+ const renderRow = (0, react_1.useCallback)(({ key, ...nestedRowProps }) => ((0, jsx_runtime_1.jsx)(RowInner, { keyId: keyId, ...nestedRowProps, variant: variant, isSelectable: isSelectable, 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, getRowDisabled: getRowDisabled, isNested: true }, key)), [
108
111
  keyId,
109
112
  variant,
110
113
  isSelectable,
@@ -123,11 +126,12 @@ const RowInner = (props) => {
123
126
  unregisterRowElement,
124
127
  onRowEnter,
125
128
  onRowLeave,
129
+ getRowDisabled,
126
130
  ]);
127
131
  return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { className: (0, cn_1.cn)(className, rootCva({
128
132
  isShowConnector,
129
133
  mobileDisplayVariant,
130
134
  hasNestedChildren: Boolean(nestedChildren?.length),
131
- })), style: rowStyles, ...selfProps, ref: rootRowRef, children: [(0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { followCursor: true, arrow: false, ...tooltipProps, children: (0, jsx_runtime_1.jsx)(styles_1.ContentWrapper, { "data-row-id": rowId, ref: rowRef, onPointerEnter: () => onRowEnter?.(rowId), onPointerLeave: (event) => onRowLeave?.(rowId, event.nativeEvent), className: rowContentCva({ isHovered, isActive }), "$gridColumns": gridColumns, [constants_1.DISABLE_ROW_ATTR]: disabled, ...rowProps, children: renderCells() }) }), (0, jsx_runtime_1.jsx)(NestedChildren_1.NestedChildren, { ...nestedChildrenProps, data: nestedChildren, keyId: keyId, level: level, variant: variant, gridColumns: gridColumns, initialVisibleChildrenCount: initialVisibleChildrenCount, moreButtonColumnPosition: moreButtonColumnPosition, renderRow: renderRow }), (0, jsx_runtime_1.jsx)(BottomDrawer_1.BottomDrawer, { ...drawerProps, children: (0, jsx_runtime_1.jsx)(styles_1.BottomDrawerContent, { children: disabledReasonText }) })] }, `row-${rowId}`));
135
+ })), style: rowStyles, ...selfProps, ref: rootRowRef, children: [(0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { followCursor: true, arrow: false, ...tooltipProps, children: (0, jsx_runtime_1.jsx)(styles_1.ContentWrapper, { "data-row-id": rowId, ref: rowRef, onPointerEnter: () => onRowEnter?.(rowId), onPointerLeave: (event) => onRowLeave?.(rowId, event.nativeEvent), className: rowContentCva({ isHovered, isActive }), "$gridColumns": gridColumns, [constants_1.DISABLE_ROW_ATTR]: isDisabled, ...rowProps, children: renderCells() }) }), (0, jsx_runtime_1.jsx)(NestedChildren_1.NestedChildren, { ...nestedChildrenProps, data: nestedChildren, keyId: keyId, level: level, variant: variant, gridColumns: gridColumns, initialVisibleChildrenCount: initialVisibleChildrenCount, moreButtonColumnPosition: moreButtonColumnPosition, renderRow: renderRow }), (0, jsx_runtime_1.jsx)(BottomDrawer_1.BottomDrawer, { ...drawerProps, children: (0, jsx_runtime_1.jsx)(styles_1.BottomDrawerContent, { children: disabledReason }) })] }, `row-${rowId}`));
132
136
  };
133
137
  exports.Row = (0, react_1.memo)(RowInner);
@@ -1,10 +1,17 @@
1
1
  import { type ChangeEvent } from 'react';
2
+ import { type DataGridRowDisabled } from '../../types';
2
3
  export type RowContextProps = {
3
- isDisabled: boolean;
4
+ /**
5
+ * Если true, в строке выполняется блокирующее действие DataGridActionCell
6
+ */
7
+ hasBlockingAction: boolean;
8
+ /**
9
+ * Причина блокировки от блокирующего действия
10
+ */
11
+ blockingActionReason?: string;
12
+ addBlockingAction: (reason?: string) => void;
13
+ removeBlockingAction: () => void;
4
14
  isSelectable?: boolean;
5
- disabledReason?: string;
6
- addDisabledRow: (disabledReason?: string) => void;
7
- removeDisabledRow: () => void;
8
15
  row: Record<string, unknown>;
9
16
  onSelectRow: (row: Record<string, unknown>) => (event: ChangeEvent<HTMLInputElement>) => void;
10
17
  onRowEnter?: (rowId: string) => void;
@@ -13,5 +20,9 @@ export type RowContextProps = {
13
20
  unregisterRowElement?: (rowId: string, el: HTMLElement) => void;
14
21
  itemProps?: object;
15
22
  isSelected?: boolean;
23
+ /**
24
+ * Итоговая блокировка строки, рассчитанная resolveRowDisabled
25
+ */
26
+ rowDisabled?: DataGridRowDisabled;
16
27
  };
17
28
  export declare const RowContext: import("react").Context<RowContextProps>;
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RowContext = void 0;
4
4
  const react_1 = require("react");
5
5
  exports.RowContext = (0, react_1.createContext)({
6
- isDisabled: false,
6
+ hasBlockingAction: false,
7
7
  isSelectable: false,
8
- addDisabledRow: () => undefined,
9
- removeDisabledRow: () => undefined,
8
+ addBlockingAction: () => undefined,
9
+ removeBlockingAction: () => undefined,
10
10
  row: {},
11
11
  onSelectRow: () => () => undefined,
12
12
  onRowEnter: () => undefined,
@@ -1,7 +1,16 @@
1
1
  import { type ReactNode } from 'react';
2
+ import { type DataGridRowDisabled } from '../../../types';
2
3
  import { type RowContextProps } from '../RowContext';
3
4
  type RowContextProviderProps = Pick<RowContextProps, 'row' | 'itemProps' | 'onSelectRow' | 'onRowEnter' | 'onRowLeave' | 'registerRowElement' | 'unregisterRowElement' | 'isSelectable' | 'isSelected'> & {
5
+ /**
6
+ * Режим блокировки строки
7
+ */
8
+ disabledMode?: DataGridRowDisabled['mode'];
9
+ /**
10
+ * Причина блокировки строки
11
+ */
12
+ disabledReason?: string;
4
13
  children: ReactNode;
5
14
  };
6
- export declare const RowContextProvider: ({ row, itemProps, onSelectRow, onRowEnter, onRowLeave, registerRowElement, unregisterRowElement, children, isSelectable, isSelected, }: RowContextProviderProps) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const RowContextProvider: ({ row, itemProps, onSelectRow, onRowEnter, onRowLeave, registerRowElement, unregisterRowElement, children, isSelectable, isSelected, disabledMode, disabledReason, }: RowContextProviderProps) => import("react/jsx-runtime").JSX.Element;
7
16
  export {};
@@ -4,23 +4,27 @@ exports.RowContextProvider = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const RowContext_1 = require("../RowContext");
7
- const RowContextProvider = ({ row, itemProps, onSelectRow, onRowEnter, onRowLeave, registerRowElement, unregisterRowElement, children, isSelectable, isSelected, }) => {
8
- const [isDisabled, setDisabled] = (0, react_1.useState)(false);
9
- const [disabledReason, setDisabledReason] = (0, react_1.useState)();
10
- const addDisabledRow = (0, react_1.useCallback)((reason) => {
11
- setDisabled(true);
12
- setDisabledReason(reason);
7
+ const RowContextProvider = ({ row, itemProps, onSelectRow, onRowEnter, onRowLeave, registerRowElement, unregisterRowElement, children, isSelectable, isSelected, disabledMode, disabledReason, }) => {
8
+ const [hasBlockingAction, setHasBlockingAction] = (0, react_1.useState)(false);
9
+ const [blockingActionReason, setBlockingActionReason] = (0, react_1.useState)();
10
+ const addBlockingAction = (0, react_1.useCallback)((reason) => {
11
+ setHasBlockingAction(true);
12
+ setBlockingActionReason(reason);
13
13
  }, []);
14
- const removeDisabledRow = (0, react_1.useCallback)(() => {
15
- setDisabled(false);
16
- setDisabledReason(undefined);
14
+ const removeBlockingAction = (0, react_1.useCallback)(() => {
15
+ setHasBlockingAction(false);
16
+ setBlockingActionReason(undefined);
17
17
  }, []);
18
+ // Блокировка приходит примитивами, чтобы новый объект с тем же содержимым не обновлял контекст
19
+ const rowDisabled = (0, react_1.useMemo)(() => disabledMode
20
+ ? { mode: disabledMode, reason: disabledReason ?? '' }
21
+ : undefined, [disabledMode, disabledReason]);
18
22
  const contextValue = (0, react_1.useMemo)(() => ({
19
- isDisabled,
23
+ hasBlockingAction,
24
+ blockingActionReason,
25
+ addBlockingAction,
26
+ removeBlockingAction,
20
27
  isSelectable,
21
- disabledReason,
22
- addDisabledRow,
23
- removeDisabledRow,
24
28
  row,
25
29
  itemProps,
26
30
  onSelectRow,
@@ -29,12 +33,13 @@ const RowContextProvider = ({ row, itemProps, onSelectRow, onRowEnter, onRowLeav
29
33
  registerRowElement,
30
34
  unregisterRowElement,
31
35
  isSelected,
36
+ rowDisabled,
32
37
  }), [
33
- isDisabled,
38
+ hasBlockingAction,
39
+ blockingActionReason,
40
+ addBlockingAction,
41
+ removeBlockingAction,
34
42
  isSelectable,
35
- disabledReason,
36
- addDisabledRow,
37
- removeDisabledRow,
38
43
  row,
39
44
  itemProps,
40
45
  onSelectRow,
@@ -43,6 +48,7 @@ const RowContextProvider = ({ row, itemProps, onSelectRow, onRowEnter, onRowLeav
43
48
  registerRowElement,
44
49
  unregisterRowElement,
45
50
  isSelected,
51
+ rowDisabled,
46
52
  ]);
47
53
  return ((0, jsx_runtime_1.jsx)(RowContext_1.RowContext.Provider, { value: contextValue, children: children }));
48
54
  };
@@ -1,6 +1,6 @@
1
1
  import { type ChangeEvent, type CSSProperties, type ReactNode } from 'react';
2
2
  import { type Variant } from '../enums';
3
- import { type CellValue, type DataGridColumns, type DataGridRowOptions } from '../types';
3
+ import { type CellValue, type DataGridColumns, type DataGridProps, type DataGridRowOptions } from '../types';
4
4
  export type RowProps<TData extends Record<string, CellValue>> = {
5
5
  /**
6
6
  * Название класса, применяется к корневому компоненту
@@ -71,9 +71,13 @@ export type RowProps<TData extends Record<string, CellValue>> = {
71
71
  */
72
72
  isSelected?: boolean;
73
73
  /**
74
- * Массив выбранных строк
74
+ * Если true, строка вложенная и сама вычисляет блокировку
75
75
  */
76
- selectedRows?: TData[];
76
+ isNested?: boolean;
77
+ /**
78
+ * Функция блокировки для вложенных строк. Передаётся только строкам с дочерними элементами
79
+ */
80
+ getRowDisabled?: DataGridProps<TData>['getRowDisabled'];
77
81
  /**
78
82
  * Заглушка для пустых ячеек (если отсутствует field и filter и renderCell)
79
83
  * @default '-'
@@ -2,8 +2,8 @@ import { type MouseEvent, type SyntheticEvent } from 'react';
2
2
  import type { CellValue } from '../../types';
3
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, options, isInitialExpanded, expandedLevel, isSelectable, isSelected, onSelectRow, onRowClick, isVisibleCollapseButton, registerRowElement, unregisterRowElement, style, activeRowId, }: UseLogicParams<TData>) => {
6
- disabledReasonText: string | undefined;
5
+ export declare const useLogic: <TData extends Record<string, unknown>>({ keyId, columns, row, nestedChildren, level, variant, options, isInitialExpanded, expandedLevel, isSelectable, isSelected, getRowDisabled, isNested, onSelectRow, onRowClick, isVisibleCollapseButton, registerRowElement, unregisterRowElement, style, activeRowId, }: UseLogicParams<TData>) => {
6
+ disabledReason: string | undefined;
7
7
  rowStyles: {
8
8
  accentColor?: import("csstype").Property.AccentColor | undefined;
9
9
  alignContent?: import("csstype").Property.AlignContent | undefined;
@@ -869,7 +869,8 @@ export declare const useLogic: <TData extends Record<string, unknown>>({ keyId,
869
869
  childrenColumns: any[];
870
870
  rowId: string;
871
871
  rowRef: (element: HTMLElement | null) => void;
872
- disabled: boolean | undefined;
872
+ isDisabled: boolean;
873
+ isDisabledLastCell: boolean;
873
874
  isSelectable: boolean | undefined;
874
875
  isRenderCollapseButton: boolean;
875
876
  handleToggle: (event: MouseEvent<HTMLButtonElement>) => void;
@@ -895,7 +896,8 @@ export declare const useLogic: <TData extends Record<string, unknown>>({ keyId,
895
896
  };
896
897
  checkboxProps: {
897
898
  checked: boolean | undefined;
898
- disabled: boolean | undefined;
899
+ disabled: boolean;
900
+ disabledReason: string | undefined;
899
901
  onChange: (event: import("react").ChangeEvent<HTMLInputElement, Element>) => void;
900
902
  };
901
903
  nestedChildrenProps: {
@@ -4,11 +4,12 @@ exports.useLogic = void 0;
4
4
  const react_1 = require("react");
5
5
  const DataGridContext_1 = require("../../DataGridContext");
6
6
  const enums_1 = require("../../enums");
7
+ const utils_1 = require("../../utils");
7
8
  const constants_1 = require("../constants");
8
9
  const RowContext_1 = require("../RowContext");
9
10
  const hooks_1 = require("./hooks");
10
- const utils_1 = require("./utils");
11
- const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options, isInitialExpanded = false, expandedLevel, isSelectable, isSelected, onSelectRow, onRowClick, isVisibleCollapseButton, registerRowElement, unregisterRowElement, style, activeRowId, }) => {
11
+ const utils_2 = require("./utils");
12
+ const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options, isInitialExpanded = false, expandedLevel, isSelectable, isSelected, getRowDisabled, isNested = false, onSelectRow, onRowClick, isVisibleCollapseButton, registerRowElement, unregisterRowElement, style, activeRowId, }) => {
12
13
  const { isDrawerOpen, handleOpenDrawer, handleCloseDrawer } = (0, hooks_1.useMobileLogic)();
13
14
  const [rootRowElement, setRootRowElement] = (0, react_1.useState)(null);
14
15
  const rootRowRef = (0, react_1.useCallback)((element) => {
@@ -18,7 +19,7 @@ const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options
18
19
  }, []);
19
20
  const isDefaultExpanded = Boolean(isInitialExpanded && level <= expandedLevel - 1 && nestedChildren?.length);
20
21
  const { mobileDisplayVariant } = (0, react_1.useContext)(DataGridContext_1.DataGridContext);
21
- const { isDisabled, disabledReason } = (0, react_1.useContext)(RowContext_1.RowContext);
22
+ const { hasBlockingAction, blockingActionReason, rowDisabled: contextRowDisabled, } = (0, react_1.useContext)(RowContext_1.RowContext);
22
23
  const [isOpen, setIsOpen] = (0, react_1.useState)(isDefaultExpanded);
23
24
  const savedElementRef = (0, react_1.useRef)(null);
24
25
  const rowRef = (element) => {
@@ -33,17 +34,24 @@ const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options
33
34
  };
34
35
  const [isVisibleTooltip, setVisibleTooltip] = (0, react_1.useState)(false);
35
36
  const rowId = row[keyId];
36
- const { isDisabled: isExternalDisabled, disabledReason: externalDisabledReason, href, } = options || {};
37
- const disabled = isDisabled || isExternalDisabled;
37
+ const { href } = options || {};
38
+ // Блокировку строки из rows таблица передаёт через контекст, вложенная строка считает её сама и не наследует блокировку родителя
39
+ const rowDisabled = (0, react_1.useMemo)(() => isNested ? (0, utils_1.resolveRowDisabled)(row, getRowDisabled) : contextRowDisabled, [isNested, row, getRowDisabled, contextRowDisabled]);
40
+ const { isDisabled, isDisabledLastCell, disabledReason, isCheckboxDisabled, checkboxDisabledReason, } = (0, utils_1.getRowDisabledState)({
41
+ rowDisabled,
42
+ hasBlockingAction,
43
+ blockingActionReason,
44
+ isDisabledLastCellOption: options?.isDisabledLastCell,
45
+ });
38
46
  const handleRowClick = () => {
39
- if (disabled) {
47
+ if (isDisabled) {
40
48
  handleOpenDrawer();
41
49
  return undefined;
42
50
  }
43
51
  onRowClick?.(row);
44
52
  };
45
53
  const isShowConnector = Object.is(variant, enums_1.Variant.Tree);
46
- const childrenColumns = (0, react_1.useMemo)(() => (0, utils_1.mergeColumnsOptions)(columns, options?.childrenColumns), [columns, options]);
54
+ const childrenColumns = (0, react_1.useMemo)(() => (0, utils_2.mergeColumnsOptions)(columns, options?.childrenColumns), [columns, options]);
47
55
  const handleToggle = (0, react_1.useCallback)((event) => {
48
56
  event.stopPropagation();
49
57
  setIsOpen((prev) => !prev);
@@ -57,7 +65,7 @@ const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options
57
65
  };
58
66
  const handleCloseTooltip = () => setVisibleTooltip(false);
59
67
  const handleMouseMove = (event) => {
60
- if (!disabled) {
68
+ if (!isDisabled) {
61
69
  return;
62
70
  }
63
71
  const element = event.target;
@@ -71,19 +79,19 @@ const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options
71
79
  '--level': level,
72
80
  ...style,
73
81
  }), [level, style]);
74
- const isHovered = Boolean(!disabled && (onRowClick || href));
82
+ const isHovered = Boolean(!isDisabled && (onRowClick || href));
75
83
  const isActive = activeRowId === rowId;
76
- const disabledReasonText = externalDisabledReason || disabledReason;
77
84
  const handleCheckboxChange = (0, react_1.useMemo)(() => onSelectRow(row), [onSelectRow, row]);
78
85
  return {
79
- disabledReasonText,
86
+ disabledReason,
80
87
  rowStyles,
81
88
  isOpen,
82
89
  isShowConnector,
83
90
  childrenColumns,
84
91
  rowId,
85
92
  rowRef,
86
- disabled,
93
+ isDisabled,
94
+ isDisabledLastCell,
87
95
  isSelectable,
88
96
  isRenderCollapseButton,
89
97
  handleToggle,
@@ -103,13 +111,14 @@ const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options
103
111
  },
104
112
  tooltipProps: {
105
113
  open: isVisibleTooltip,
106
- title: disabled ? disabledReasonText : undefined,
114
+ title: isDisabled ? disabledReason : undefined,
107
115
  onOpen: handleOpenTooltip,
108
116
  onClose: handleCloseTooltip,
109
117
  },
110
118
  checkboxProps: {
111
119
  checked: isSelected,
112
- disabled,
120
+ disabled: isCheckboxDisabled,
121
+ disabledReason: checkboxDisabledReason,
113
122
  onChange: handleCheckboxChange,
114
123
  },
115
124
  nestedChildrenProps: {
@@ -4,7 +4,6 @@ exports.RowBase = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const BottomDrawer_1 = require("../../BottomDrawer");
7
- const Checkbox_1 = require("../../Checkbox");
8
7
  const Tooltip_1 = require("../../Tooltip");
9
8
  const cn_1 = require("../../utils/cn");
10
9
  const cva_1 = require("../../utils/cva");
@@ -12,6 +11,7 @@ const getInertProps_1 = require("../../utils/getInertProps");
12
11
  const Cell_1 = require("../Cell");
13
12
  const constants_1 = require("../Row/constants");
14
13
  const utils_1 = require("../Row/utils");
14
+ const RowCheckbox_1 = require("../RowCheckbox");
15
15
  const utils_2 = require("../utils");
16
16
  const constants_2 = require("./constants");
17
17
  const GroupCell_1 = require("./GroupCell");
@@ -43,7 +43,7 @@ exports.RowBase = (0, react_1.memo)((props) => {
43
43
  if (!adornment && !shouldRenderCheckbox) {
44
44
  return null;
45
45
  }
46
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [adornment, shouldRenderCheckbox && ((0, jsx_runtime_1.jsx)(styles_1.CheckboxCell, { ...(0, getInertProps_1.getInertProps)(isDisabled), onClick: (event) => event.stopPropagation(), className: constants_1.dataGridRowClassnames.checkbox, children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { ...checkboxProps }) }))] }));
46
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [adornment, shouldRenderCheckbox && ((0, jsx_runtime_1.jsx)(styles_1.CheckboxCell, { ...(0, getInertProps_1.getInertProps)(isDisabled), onClick: (event) => event.stopPropagation(), className: constants_1.dataGridRowClassnames.checkbox, children: (0, jsx_runtime_1.jsx)(RowCheckbox_1.RowCheckbox, { ...checkboxProps }) }))] }));
47
47
  };
48
48
  const renderCells = (0, react_1.useCallback)(() => {
49
49
  const lastCellGlobalIndex = columns.length - 1;
@@ -64,9 +64,12 @@ exports.RowBase = (0, react_1.memo)((props) => {
64
64
  row,
65
65
  columns,
66
66
  isDisabled,
67
+ isDisabledLastCell,
67
68
  sectionOffset,
68
69
  renderStartAdornment,
69
70
  checkboxProps.checked,
71
+ checkboxProps.disabled,
72
+ checkboxProps.disabledReason,
70
73
  ]);
71
74
  return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { className: (0, cn_1.cn)(className, rootCva({ mobileDisplayVariant })), style: rowBaseVars, ...dataGridInfiniteItemProps, children: [(0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { ...tooltipProps, children: (0, jsx_runtime_1.jsx)(styles_1.ContentWrapper, { ref: rowRef, onPointerEnter: () => onRowEnter?.(rowId), onPointerLeave: (event) => onRowLeave?.(rowId, event.nativeEvent), className: contentWrapperCva({ isHovered, isActive }), [constants_1.DISABLE_ROW_ATTR]: isDisabled, onClick: handleRowClick, children: renderCells() }) }), customContent, (0, jsx_runtime_1.jsx)(BottomDrawer_1.BottomDrawer, { ...drawerProps, children: (0, jsx_runtime_1.jsx)(styles_1.BottomDrawerContent, { children: drawerContent }) })] }, `row-base-${rowId}`));
72
75
  });
@@ -1,5 +1,5 @@
1
1
  import { type ChangeEvent, type ReactNode } from 'react';
2
- import type { DataGridColumns, DataGridRowWithOptions } from '../types';
2
+ import type { DataGridColumns, DataGridRowDisabled, DataGridRowWithOptions } from '../types';
3
3
  export type RowBaseProps = {
4
4
  /**
5
5
  * Массив колонок
@@ -42,13 +42,17 @@ export type RowBaseProps = {
42
42
  */
43
43
  isSelected?: boolean;
44
44
  /**
45
- * Заблокирована ли строка
45
+ * Если true, в строке выполняется блокирующее действие DataGridActionCell
46
46
  */
47
- isDisabled?: boolean;
47
+ hasBlockingAction?: boolean;
48
48
  /**
49
- * Причина блокировки строки
49
+ * Причина блокировки от блокирующего действия
50
50
  */
51
- disabledReason?: string;
51
+ blockingActionReason?: string;
52
+ /**
53
+ * Итоговая блокировка строки, рассчитанная resolveRowDisabled
54
+ */
55
+ rowDisabled?: DataGridRowDisabled;
52
56
  /**
53
57
  * Обработчик выбора строки
54
58
  */
@@ -1,7 +1,7 @@
1
1
  import { type CSSProperties, type SyntheticEvent } from 'react';
2
2
  import type { RowBaseProps } from '../types';
3
3
  type UseLogicParams = RowBaseProps;
4
- export declare const useLogic: ({ className, row, keyId, onRowClick, columns, sectionOffset, customContent, renderStartAdornment, isSelected, isDisabled, disabledReason, onSelectRow, onRowEnter, onRowLeave, registerRowElement, unregisterRowElement, gridColumns, activeRowId, emptyCellValue, isSelectable, rowId, mobileDisplayVariant, ...dataGridInfiniteItemProps }: UseLogicParams) => {
4
+ export declare const useLogic: ({ className, row, keyId, onRowClick, columns, sectionOffset, customContent, renderStartAdornment, isSelected, hasBlockingAction, blockingActionReason, rowDisabled, onSelectRow, onRowEnter, onRowLeave, registerRowElement, unregisterRowElement, gridColumns, activeRowId, emptyCellValue, isSelectable, rowId, mobileDisplayVariant, ...dataGridInfiniteItemProps }: UseLogicParams) => {
5
5
  handleRowClick: () => void;
6
6
  tooltipProps: {
7
7
  open: boolean;
@@ -13,7 +13,8 @@ export declare const useLogic: ({ className, row, keyId, onRowClick, columns, se
13
13
  };
14
14
  checkboxProps: {
15
15
  checked: boolean | undefined;
16
- disabled: boolean | undefined;
16
+ disabled: boolean;
17
+ disabledReason: string | undefined;
17
18
  onChange: (event: import("react").ChangeEvent<HTMLInputElement, Element>) => void;
18
19
  };
19
20
  drawerProps: {
@@ -34,10 +35,10 @@ export declare const useLogic: ({ className, row, keyId, onRowClick, columns, se
34
35
  onRowLeave: ((rowId: string, event: PointerEvent) => void) | undefined;
35
36
  rowId: string;
36
37
  row: import("../..").DataGridRowWithOptions<Record<string, unknown>>;
37
- isDisabled: boolean | undefined;
38
+ isDisabled: boolean;
38
39
  sectionOffset: number | undefined;
39
40
  customContent: import("react").ReactNode;
40
- isDisabledLastCell: boolean | undefined;
41
+ isDisabledLastCell: boolean;
41
42
  renderStartAdornment: ((isFirstCell: boolean) => import("react").ReactNode) | undefined;
42
43
  isSelectable: boolean | undefined;
43
44
  isNotSelectable: boolean | undefined;