@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
@@ -4,14 +4,14 @@ exports.useLogic = void 0;
4
4
  const react_1 = require("react");
5
5
  const ConfigProvider_1 = require("../../ConfigProvider");
6
6
  const useFirstMountState_1 = require("../../useFirstMountState");
7
- const prop_1 = require("../../utils/prop");
8
7
  const uniqueBy_1 = require("../../utils/uniqueBy");
9
8
  const constants_1 = require("../constants");
10
9
  const enums_1 = require("../enums");
10
+ const hooks_1 = require("../hooks");
11
11
  const utils_1 = require("../utils");
12
- const hooks_1 = require("./hooks");
12
+ const hooks_2 = require("./hooks");
13
13
  const utils_2 = require("./utils");
14
- const useLogic = ({ keyId, columns, rows = [], variant, tree, subrows, selectedRows = [], isLoading, isDisabled, mobileDisplayVariant = variant === 'subrows' ? 'cards' : 'list', onSelectRow, isError, onRetry, errorMsg, isHideSelectAll, isHideHeaderIfNoData = false, sorting, className, onSort, maxHeight, gridViewMode: gridViewModeProp = 'standard', massActions, }) => {
14
+ const useLogic = ({ keyId, columns, rows = [], variant, tree, subrows, selectedRows = [], isLoading, isDisabled, getRowDisabled, mobileDisplayVariant = variant === 'subrows' ? 'cards' : 'list', onSelectRow, isError, onRetry, errorMsg, isHideSelectAll, isHideHeaderIfNoData = false, sorting, className, onSort, maxHeight, gridViewMode: gridViewModeProp = 'standard', massActions, }) => {
15
15
  const isFirstRender = (0, useFirstMountState_1.useFirstMountState)();
16
16
  const isSelectable = Boolean(onSelectRow);
17
17
  const isDataGridDisabled = isLoading || isDisabled;
@@ -35,11 +35,11 @@ const useLogic = ({ keyId, columns, rows = [], variant, tree, subrows, selectedR
35
35
  }, [columns, rows]);
36
36
  const renderRows = isLoading ? prevRowsRef.current : rows;
37
37
  const isNoData = !renderRows.length;
38
- const { containerRef, rowHoverProps, sections, hasPinnedColumns } = (0, hooks_1.usePinnedColumns)({
38
+ const { containerRef, rowHoverProps, sections, hasPinnedColumns } = (0, hooks_2.usePinnedColumns)({
39
39
  isLoading,
40
40
  columns: processedColumns(),
41
41
  });
42
- const { isMobile, mobileSkeletonProps } = (0, hooks_1.useDataGridMobileLogic)({
42
+ const { isMobile, mobileSkeletonProps } = (0, hooks_2.useDataGridMobileLogic)({
43
43
  containerRef,
44
44
  isLoading,
45
45
  columns: (0, utils_1.getFlattenColumns)(processedColumns()),
@@ -60,22 +60,24 @@ const useLogic = ({ keyId, columns, rows = [], variant, tree, subrows, selectedR
60
60
  }
61
61
  return config;
62
62
  }, [variant, subrows, tree, isMobile]);
63
- const availableRows = rows.filter((row) => !(row.options?.isDisabled || row.options?.isNotSelectable));
63
+ // Блокировки строк: getRowDisabled вызывается один раз на строку
64
+ const { rowsDisabled, idsWithoutReason } = (0, react_1.useMemo)(() => (0, utils_1.resolveRowsDisabled)(renderRows, keyId, getRowDisabled), [renderRows, keyId, getRowDisabled]);
65
+ (0, hooks_1.useWarnRowsWithoutDisabledReason)(idsWithoutReason);
66
+ const selectedIds = (0, react_1.useMemo)(() => new Set(selectedRows.map((row) => row[keyId])), [selectedRows, keyId]);
67
+ const availableRows = (0, react_1.useMemo)(() => renderRows.filter((row) => !row.options?.isNotSelectable && !rowsDisabled.get(row[keyId])), [renderRows, rowsDisabled, keyId]);
64
68
  const gridColumns = (0, react_1.useMemo)(() => (0, utils_1.getGridTemplateColumns)((0, utils_1.getFlattenColumns)(columns)), [columns]);
65
69
  const isAllowHorizontalScroll = (0, utils_2.getIsAllowHorizontalScroll)((0, utils_1.getFlattenColumns)(columns));
66
- const uncheckedRowsCount = (0, react_1.useMemo)(() => {
67
- return availableRows.filter((row) => !selectedRows.find((selectedRow) => selectedRow[keyId] === row[keyId])).length;
68
- }, [availableRows, selectedRows, keyId]);
70
+ const uncheckedRowsCount = (0, react_1.useMemo)(() => availableRows.filter((row) => !selectedIds.has(row[keyId])).length, [availableRows, selectedIds, keyId]);
69
71
  const handleSelectAllRows = (event) => {
70
72
  if (!onSelectRow) {
71
73
  return;
72
74
  }
73
75
  if (event.target.checked) {
74
- const mergedSelectedRows = (0, uniqueBy_1.uniqueBy)([...selectedRows, ...availableRows], (0, prop_1.prop)(keyId));
76
+ const mergedSelectedRows = (0, uniqueBy_1.uniqueBy)([...selectedRowsRef.current, ...availableRows], (row) => row[keyId]);
75
77
  return onSelectRow(mergedSelectedRows);
76
78
  }
77
- const filteredRows = selectedRows.filter((selectedRow) => !rows.find((row) => row[keyId] === selectedRow[keyId]));
78
- onSelectRow(filteredRows);
79
+ const renderRowsIds = new Set(renderRows.map((row) => row[keyId]));
80
+ onSelectRow(selectedRowsRef.current.filter((selectedRow) => !renderRowsIds.has(selectedRow[keyId])));
79
81
  };
80
82
  const handleSelectRow = (0, react_1.useCallback)((row) => (event) => {
81
83
  if (!onSelectRow) {
@@ -144,6 +146,9 @@ const useLogic = ({ keyId, columns, rows = [], variant, tree, subrows, selectedR
144
146
  },
145
147
  bodyProps: {
146
148
  isSelectable,
149
+ selectedIds,
150
+ rowsDisabled,
151
+ getRowDisabled,
147
152
  onSelectRow: handleSelectRow,
148
153
  },
149
154
  mobileDisplayVariant,
@@ -0,0 +1,31 @@
1
+ import type { DataGridRowDisabled } from '../../types';
2
+ type GetRowDisabledStateParams = {
3
+ /**
4
+ * Итоговая блокировка строки, рассчитанная resolveRowDisabled
5
+ */
6
+ rowDisabled?: DataGridRowDisabled;
7
+ /**
8
+ * Если true, в строке выполняется блокирующее действие DataGridActionCell
9
+ */
10
+ hasBlockingAction?: boolean;
11
+ /**
12
+ * Причина блокировки от блокирующего действия
13
+ */
14
+ blockingActionReason?: string;
15
+ /**
16
+ * Значение options.isDisabledLastCell. Влияет только на блокировку от DataGridActionCell:
17
+ * options.isDisabled уже преобразован в mode в resolveRowDisabled
18
+ */
19
+ isDisabledLastCellOption?: boolean;
20
+ };
21
+ /**
22
+ * Вычисляет доступность строки и её checkbox по режиму блокировки и блокирующему действию
23
+ */
24
+ export declare const getRowDisabledState: ({ rowDisabled, hasBlockingAction, blockingActionReason, isDisabledLastCellOption, }: GetRowDisabledStateParams) => {
25
+ isDisabled: boolean;
26
+ isDisabledLastCell: boolean;
27
+ disabledReason: string | undefined;
28
+ isCheckboxDisabled: boolean;
29
+ checkboxDisabledReason: string | undefined;
30
+ };
31
+ export {};
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRowDisabledState = void 0;
4
+ /**
5
+ * Вычисляет доступность строки и её checkbox по режиму блокировки и блокирующему действию
6
+ */
7
+ const getRowDisabledState = ({ rowDisabled, hasBlockingAction = false, blockingActionReason, isDisabledLastCellOption = true, }) => {
8
+ const mode = rowDisabled?.mode;
9
+ const isSelectionDisabled = mode === 'selection';
10
+ const isDisabled = hasBlockingAction || mode === 'row' || mode === 'row-except-last-cell';
11
+ const disabledReason = rowDisabled?.reason || blockingActionReason;
12
+ return {
13
+ isDisabled,
14
+ // Без режима сохраняется прежнее поведение: isDisabledLastCell действует и при блокирующем действии
15
+ isDisabledLastCell: mode
16
+ ? mode !== 'row-except-last-cell'
17
+ : isDisabledLastCellOption,
18
+ disabledReason,
19
+ isCheckboxDisabled: isDisabled || isSelectionDisabled,
20
+ // У полностью заблокированной строки причину показывает tooltip строки
21
+ checkboxDisabledReason: isSelectionDisabled ? disabledReason : undefined,
22
+ };
23
+ };
24
+ exports.getRowDisabledState = getRowDisabledState;
@@ -0,0 +1 @@
1
+ export { getRowDisabledState } from './getRowDisabledState';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRowDisabledState = void 0;
4
+ var getRowDisabledState_1 = require("./getRowDisabledState");
5
+ Object.defineProperty(exports, "getRowDisabledState", { enumerable: true, get: function () { return getRowDisabledState_1.getRowDisabledState; } });
@@ -3,3 +3,6 @@ export { getGridTemplateColumns } from './getGridTemplateColumns';
3
3
  export { isGroupColumns } from './isGroupColumns';
4
4
  export { getFlattenColumns } from './getFlattenColumns';
5
5
  export { checkIsMassActionsOpen } from './checkIsMassActionsOpen';
6
+ export { getRowDisabledState } from './getRowDisabledState';
7
+ export { resolveRowDisabled } from './resolveRowDisabled';
8
+ export { resolveRowsDisabled } from './resolveRowsDisabled';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkIsMassActionsOpen = exports.getFlattenColumns = exports.isGroupColumns = exports.getGridTemplateColumns = exports.getDataGridCssVars = void 0;
3
+ exports.resolveRowsDisabled = exports.resolveRowDisabled = exports.getRowDisabledState = exports.checkIsMassActionsOpen = exports.getFlattenColumns = exports.isGroupColumns = exports.getGridTemplateColumns = exports.getDataGridCssVars = void 0;
4
4
  var getDataGridCssVars_1 = require("./getDataGridCssVars");
5
5
  Object.defineProperty(exports, "getDataGridCssVars", { enumerable: true, get: function () { return getDataGridCssVars_1.getDataGridCssVars; } });
6
6
  var getGridTemplateColumns_1 = require("./getGridTemplateColumns");
@@ -11,3 +11,9 @@ var getFlattenColumns_1 = require("./getFlattenColumns");
11
11
  Object.defineProperty(exports, "getFlattenColumns", { enumerable: true, get: function () { return getFlattenColumns_1.getFlattenColumns; } });
12
12
  var checkIsMassActionsOpen_1 = require("./checkIsMassActionsOpen");
13
13
  Object.defineProperty(exports, "checkIsMassActionsOpen", { enumerable: true, get: function () { return checkIsMassActionsOpen_1.checkIsMassActionsOpen; } });
14
+ var getRowDisabledState_1 = require("./getRowDisabledState");
15
+ Object.defineProperty(exports, "getRowDisabledState", { enumerable: true, get: function () { return getRowDisabledState_1.getRowDisabledState; } });
16
+ var resolveRowDisabled_1 = require("./resolveRowDisabled");
17
+ Object.defineProperty(exports, "resolveRowDisabled", { enumerable: true, get: function () { return resolveRowDisabled_1.resolveRowDisabled; } });
18
+ var resolveRowsDisabled_1 = require("./resolveRowsDisabled");
19
+ Object.defineProperty(exports, "resolveRowsDisabled", { enumerable: true, get: function () { return resolveRowsDisabled_1.resolveRowsDisabled; } });
@@ -0,0 +1 @@
1
+ export { resolveRowDisabled } from './resolveRowDisabled';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveRowDisabled = void 0;
4
+ var resolveRowDisabled_1 = require("./resolveRowDisabled");
5
+ Object.defineProperty(exports, "resolveRowDisabled", { enumerable: true, get: function () { return resolveRowDisabled_1.resolveRowDisabled; } });
@@ -0,0 +1,5 @@
1
+ import type { DataGridProps, DataGridRowDisabled, DataGridRowWithOptions } from '../../types';
2
+ /**
3
+ * Возвращает блокировку строки: результат getRowDisabled, а если его нет — блокировку из deprecated-полей options (isDisabled, isDisabledLastCell, disabledReason)
4
+ */
5
+ export declare const resolveRowDisabled: <TData extends Record<string, unknown>>(row: DataGridRowWithOptions<TData>, getRowDisabled?: ((row: TData) => DataGridRowDisabled | undefined) | undefined) => DataGridRowDisabled | undefined;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveRowDisabled = void 0;
4
+ /**
5
+ * Возвращает блокировку строки: результат getRowDisabled, а если его нет — блокировку из deprecated-полей options (isDisabled, isDisabledLastCell, disabledReason)
6
+ */
7
+ const resolveRowDisabled = (row, getRowDisabled) => {
8
+ const rowDisabled = getRowDisabled?.(row);
9
+ if (rowDisabled) {
10
+ return rowDisabled;
11
+ }
12
+ const { isDisabled, isDisabledLastCell = true, disabledReason = '', } = row.options ?? {};
13
+ if (!isDisabled) {
14
+ return undefined;
15
+ }
16
+ return {
17
+ mode: isDisabledLastCell ? 'row' : 'row-except-last-cell',
18
+ reason: disabledReason,
19
+ };
20
+ };
21
+ exports.resolveRowDisabled = resolveRowDisabled;
@@ -0,0 +1 @@
1
+ export { resolveRowsDisabled } from './resolveRowsDisabled';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveRowsDisabled = void 0;
4
+ var resolveRowsDisabled_1 = require("./resolveRowsDisabled");
5
+ Object.defineProperty(exports, "resolveRowsDisabled", { enumerable: true, get: function () { return resolveRowsDisabled_1.resolveRowsDisabled; } });
@@ -0,0 +1,16 @@
1
+ import type { DataGridProps, DataGridRowDisabled, DataGridRowWithOptions } from '../../types';
2
+ type ResolveRowsDisabledResult = {
3
+ /**
4
+ * Блокировки строк по row[keyId]
5
+ */
6
+ rowsDisabled: Map<unknown, DataGridRowDisabled | undefined>;
7
+ /**
8
+ * Идентификаторы строк, для которых getRowDisabled вернул блокировку без причины
9
+ */
10
+ idsWithoutReason: unknown[];
11
+ };
12
+ /**
13
+ * Вычисляет блокировки строк
14
+ */
15
+ export declare const resolveRowsDisabled: <TData extends Record<string, unknown>>(rows: DataGridRowWithOptions<TData>[], keyId: keyof TData, getRowDisabled?: ((row: TData) => DataGridRowDisabled | undefined) | undefined) => ResolveRowsDisabledResult;
16
+ export {};
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveRowsDisabled = void 0;
4
+ const resolveRowDisabled_1 = require("../resolveRowDisabled");
5
+ /**
6
+ * Вычисляет блокировки строк
7
+ */
8
+ const resolveRowsDisabled = (rows, keyId, getRowDisabled) => {
9
+ const rowsDisabled = new Map();
10
+ const idsWithoutReason = [];
11
+ rows.forEach((row) => {
12
+ const rowId = row[keyId];
13
+ const rowDisabled = getRowDisabled?.(row);
14
+ if (rowDisabled && !rowDisabled.reason) {
15
+ idsWithoutReason.push(rowId);
16
+ }
17
+ rowsDisabled.set(rowId, rowDisabled ?? (0, resolveRowDisabled_1.resolveRowDisabled)(row));
18
+ });
19
+ return { rowsDisabled, idsWithoutReason };
20
+ };
21
+ exports.resolveRowsDisabled = resolveRowsDisabled;
@@ -8,16 +8,16 @@ const ActionCellContext_1 = require("../../ActionCellContext");
8
8
  * хук позволяющий подписаться на событие блокировки действий
9
9
  */
10
10
  const useBlockingActions = (actions) => {
11
- const { addDisabledRow, removeDisabledRow } = (0, react_1.useContext)(Row_1.RowContext);
11
+ const { addBlockingAction, removeBlockingAction } = (0, react_1.useContext)(Row_1.RowContext);
12
12
  const { addDisabledCell, removeDisabledCell, isDisabled, onActionClick } = (0, react_1.useContext)(ActionCellContext_1.ActionCellContext);
13
13
  const blockingAction = [...(actions || [])].find((action) => action.isBlockingOperation && action.loading);
14
14
  (0, react_1.useEffect)(() => {
15
15
  if (blockingAction) {
16
- addDisabledRow(blockingAction?.loadingNote);
16
+ addBlockingAction(blockingAction?.loadingNote);
17
17
  addDisabledCell(blockingAction?.loadingNote);
18
18
  return;
19
19
  }
20
- removeDisabledRow();
20
+ removeBlockingAction();
21
21
  removeDisabledCell();
22
22
  }, [blockingAction]);
23
23
  return {
@@ -12,8 +12,9 @@ export declare const useLogic: ({ initialOpen, onOpen, onClose }: UseLogicParams
12
12
  keyId: unknown;
13
13
  columns: import("../..").DataGridColumns<Record<string, unknown>>[];
14
14
  rowId: string;
15
- isDisabled: boolean;
16
- disabledReason: string | undefined;
15
+ hasBlockingAction: boolean;
16
+ blockingActionReason: string | undefined;
17
+ rowDisabled: import("../..").DataGridRowDisabled | undefined;
17
18
  onSelectRow: (row: Record<string, unknown>) => (event: import("react").ChangeEvent<HTMLInputElement, Element>) => void;
18
19
  onRowEnter: ((rowId: string) => void) | undefined;
19
20
  onRowLeave: ((rowId: string, event: PointerEvent) => void) | undefined;
@@ -8,7 +8,7 @@ const RowContext_1 = require("../../DataGrid/Row/RowContext");
8
8
  const constants_1 = require("../constants");
9
9
  const useLogic = ({ initialOpen, onOpen, onClose }) => {
10
10
  const { keyId, columns, gridColumns, activeRowId, emptyCellValue, onRowClick, mobileDisplayVariant, } = (0, react_1.useContext)(DataGridContext_1.DataGridContext);
11
- const { row, onSelectRow, isDisabled, disabledReason, onRowEnter, onRowLeave, registerRowElement, unregisterRowElement, isSelectable, itemProps, isSelected, } = (0, react_1.useContext)(RowContext_1.RowContext);
11
+ const { row, onSelectRow, hasBlockingAction, blockingActionReason, onRowEnter, onRowLeave, registerRowElement, unregisterRowElement, isSelectable, itemProps, isSelected, rowDisabled, } = (0, react_1.useContext)(RowContext_1.RowContext);
12
12
  const rowId = row[keyId];
13
13
  /**
14
14
  * Используется локальное хранилище DataGridStorageContext. Для сохранения состояния раскрытия строки на время жизни DataGrid.
@@ -49,8 +49,9 @@ const useLogic = ({ initialOpen, onOpen, onClose }) => {
49
49
  keyId,
50
50
  columns,
51
51
  rowId,
52
- isDisabled,
53
- disabledReason,
52
+ hasBlockingAction,
53
+ blockingActionReason,
54
+ rowDisabled,
54
55
  onSelectRow,
55
56
  onRowEnter,
56
57
  onRowLeave,
@@ -52,13 +52,13 @@ const dataGridInfiniteCva = (0, cva_1.cva)(constants_2.dataGridClassnames.root,
52
52
  });
53
53
  const DataGridInfinite = (props) => {
54
54
  const { imagesMap, emptySymbol } = (0, react_1.useContext)(ConfigProvider_1.ConfigContext);
55
- const { isNoData, isDataGridDisabled, treeRenderConfig, virtuosoProps, headProps, rowProps, scrollToTopButtonProps, isHideHead, containerCssVars, isMobile, mobileSkeletonProps, hasGroupedColumns, gridViewMode, gridColumns, handleSelectRow, mobileDisplayVariant, isSelfContained, isNotRenderHeader, initialTopMostItemIndex, hasMassActions, isMassActionsOpen, footerContext, } = (0, useLogic_1.useLogic)(props);
55
+ const { isNoData, isDataGridDisabled, treeRenderConfig, virtuosoProps, headProps, rowProps, scrollToTopButtonProps, isHideHead, containerCssVars, isMobile, mobileSkeletonProps, hasGroupedColumns, gridViewMode, gridColumns, handleSelectRow, mobileDisplayVariant, isSelfContained, isNotRenderHeader, initialTopMostItemIndex, hasMassActions, isMassActionsOpen, virtuosoContext, } = (0, useLogic_1.useLogic)(props);
56
56
  const { columns, rows = [], selectedRows = [], onSelectRow, sorting, isLoading, isDisabled, keyId, emptyCellValue = emptySymbol, variant = enums_1.Variant.Tree, subrows, className, isError, errorMsg, noDataPlaceholder, onRowClick, onSort, onRetry, headPreAddon, activeRowId, isTabularNums, renderRow, renderLink, massActions, } = props;
57
57
  const { moreButtonColumnPosition = 1, isVisibleCollapseButton = true } = subrows || {};
58
58
  const { isInitialExpanded = false, expandedLevel = constants_2.EXPANDED_LEVEL_BY_DEFAULT, initialVisibleChildrenCount = constants_2.INITIAL_OPENED_NESTED_CHILDREN_COUNT_BY_DEFAULT, } = treeRenderConfig || {};
59
59
  const { isSelectable } = rowProps;
60
60
  const TableContainer = isDisabled ? styles_2.DisabledDataGridWrapper : styles_2.DataGridWrapper;
61
- return ((0, jsx_runtime_1.jsx)(DataGridInfiniteContext_1.DataGridInfiniteContextProvider, { renderRow: renderRow, onSelectRow: handleSelectRow, variant: variant, isInitialExpanded: isInitialExpanded, expandedLevel: expandedLevel, initialVisibleChildrenCount: initialVisibleChildrenCount, isSelectable: isSelectable, selectedRows: selectedRows, moreButtonColumnPosition: moreButtonColumnPosition, isVisibleCollapseButton: isVisibleCollapseButton, children: (0, jsx_runtime_1.jsx)(DataGridContext_1.DataGridContextProvider, { gridColumns: gridColumns, emptyCellValue: emptyCellValue, activeRowId: activeRowId, columns: columns, keyId: keyId, isTabularNums: isTabularNums, onRowClick: onRowClick, mobileDisplayVariant: mobileDisplayVariant, renderLink: renderLink, selectedRows: selectedRows, onSelectRow: onSelectRow, isMassActionsOpen: isMassActionsOpen, children: (0, jsx_runtime_1.jsxs)(styles_2.StyledContainer, { style: containerCssVars, className: (0, cn_1.cn)(dataGridInfiniteCva({
61
+ return ((0, jsx_runtime_1.jsx)(DataGridInfiniteContext_1.DataGridInfiniteContextProvider, { renderRow: renderRow, onSelectRow: handleSelectRow, variant: variant, isInitialExpanded: isInitialExpanded, expandedLevel: expandedLevel, initialVisibleChildrenCount: initialVisibleChildrenCount, isSelectable: isSelectable, moreButtonColumnPosition: moreButtonColumnPosition, isVisibleCollapseButton: isVisibleCollapseButton, children: (0, jsx_runtime_1.jsx)(DataGridContext_1.DataGridContextProvider, { gridColumns: gridColumns, emptyCellValue: emptyCellValue, activeRowId: activeRowId, columns: columns, keyId: keyId, isTabularNums: isTabularNums, onRowClick: onRowClick, mobileDisplayVariant: mobileDisplayVariant, renderLink: renderLink, selectedRows: selectedRows, onSelectRow: onSelectRow, isMassActionsOpen: isMassActionsOpen, children: (0, jsx_runtime_1.jsxs)(styles_2.StyledContainer, { style: containerCssVars, className: (0, cn_1.cn)(dataGridInfiniteCva({
62
62
  hasGroupedColumns,
63
63
  gridViewMode,
64
64
  mobileDisplayVariant,
@@ -72,7 +72,7 @@ const DataGridInfinite = (props) => {
72
72
  onRetry,
73
73
  }, children: (0, jsx_runtime_1.jsx)(react_virtuoso_1.Virtuoso, { ...virtuosoProps, ...(initialTopMostItemIndex && {
74
74
  initialTopMostItemIndex,
75
- }), style: { height: '100%' }, overscan: constants_3.OVERSCAN_COUNT, data: rows, context: footerContext, components: {
75
+ }), style: { height: '100%' }, overscan: constants_3.OVERSCAN_COUNT, data: rows, context: virtuosoContext, components: {
76
76
  // biome-ignore lint/suspicious/noTsIgnore: Требует HTMLDivElement, а для элемента списка используем HTMLUListElement (https://github.com/petyosi/react-virtuoso/issues/864)
77
77
  // @ts-ignore
78
78
  List: List_1.List,
@@ -83,7 +83,7 @@ const DataGridInfinite = (props) => {
83
83
  if (isNotRenderHeader) {
84
84
  return null;
85
85
  }
86
- return ((0, jsx_runtime_1.jsxs)(styles_2.HeaderRow, { children: [isLoading && (0, jsx_runtime_1.jsx)(Loader_1.Loader, {}), isError && (0, jsx_runtime_1.jsx)(ErrorMessage_1.ErrorMessage, { onRetry: onRetry })] }));
86
+ return ((0, jsx_runtime_1.jsxs)(styles_2.HeaderRow, { className: constants_3.dataGridInfiniteClassnames.header, children: [isLoading && (0, jsx_runtime_1.jsx)(Loader_1.Loader, {}), isError && (0, jsx_runtime_1.jsx)(ErrorMessage_1.ErrorMessage, { onRetry: onRetry })] }));
87
87
  },
88
88
  } }) }), massActions && ((0, jsx_runtime_1.jsx)(styles_1.MassActionsAnchor, { children: massActions })), (0, jsx_runtime_1.jsx)(styles_2.StyledScrollToTopButton, { ...scrollToTopButtonProps, className: constants_3.dataGridInfiniteClassnames.scrollToTopButton }), isDisabled && (0, jsx_runtime_1.jsx)(styles_2.Backdrop, {})] })] }) }) }));
89
89
  };
@@ -9,7 +9,6 @@ export type DataGridInfiniteContextProps = {
9
9
  moreButtonColumnPosition?: number;
10
10
  isVisibleCollapseButton?: boolean;
11
11
  isSelectable?: boolean;
12
- selectedRows?: Record<string, unknown>[];
13
12
  };
14
13
  /**
15
14
  * Контекст общих параметров для компонента `Item` внутри `DataGridInfinite`.
@@ -19,5 +18,6 @@ export type DataGridInfiniteContextProps = {
19
18
  * лишние перерисовки виртуализированного списка.
20
19
  *
21
20
  * Поскольку `Virtuoso` сам управляет параметрами `Item`, общие настройки передаются через контекст.
21
+ * Состояние строк передаётся отдельно, см. `DataGridInfiniteItemContext` в `Row/types.ts`.
22
22
  */
23
23
  export declare const DataGridInfiniteContext: import("react").Context<DataGridInfiniteContextProps>;
@@ -10,6 +10,7 @@ const react_1 = require("react");
10
10
  * лишние перерисовки виртуализированного списка.
11
11
  *
12
12
  * Поскольку `Virtuoso` сам управляет параметрами `Item`, общие настройки передаются через контекст.
13
+ * Состояние строк передаётся отдельно, см. `DataGridInfiniteItemContext` в `Row/types.ts`.
13
14
  */
14
15
  exports.DataGridInfiniteContext = (0, react_1.createContext)({
15
16
  renderRow: () => null,
@@ -20,5 +21,4 @@ exports.DataGridInfiniteContext = (0, react_1.createContext)({
20
21
  initialVisibleChildrenCount: 0,
21
22
  moreButtonColumnPosition: 0,
22
23
  isVisibleCollapseButton: true,
23
- selectedRows: [],
24
24
  });
@@ -24,6 +24,6 @@ const Footer = ({ context }) => {
24
24
  }
25
25
  return null;
26
26
  };
27
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [renderStatus(), hasMassActions && ((0, jsx_runtime_1.jsx)(styles_1.MassActionsSpacer, { className: constants_1.dataGridInfiniteClassnames.massActionsSpacer }))] }));
27
+ return ((0, jsx_runtime_1.jsxs)("div", { className: constants_1.dataGridInfiniteClassnames.footer, children: [renderStatus(), hasMassActions && ((0, jsx_runtime_1.jsx)(styles_1.MassActionsSpacer, { className: constants_1.dataGridInfiniteClassnames.massActionsSpacer }))] }));
28
28
  };
29
29
  exports.Footer = Footer;
@@ -8,7 +8,7 @@ const RowContext_1 = require("../../DataGrid/Row/RowContext");
8
8
  const useLogic_1 = require("./useLogic");
9
9
  const INITIAL_LEVEL = 0;
10
10
  const Row = ({ children, ...props }) => {
11
- const { item, memoizedItemProps, onSelectRow, renderRow, flattenColumns, gridColumns, options, keyId, variant, isSelectable, isSelected, nestedChildren, isInitialExpanded, expandedLevel, initialVisibleChildrenCount, moreButtonColumnPosition, isVisibleCollapseButton, emptyCellValue, activeRowId, onRowClick, } = (0, useLogic_1.useLogic)(props);
12
- return ((0, jsx_runtime_1.jsx)(RowContext_1.RowContextProvider, { row: item, itemProps: memoizedItemProps, onSelectRow: onSelectRow, isSelectable: isSelectable, isSelected: isSelected, children: renderRow ? ((0, jsx_runtime_1.jsx)(CustomRowWrapper_1.CustomRowWrapper, { index: memoizedItemProps['data-index'], renderRow: renderRow, row: item })) : ((0, jsx_runtime_1.jsx)(Row_1.Row, { ...memoizedItemProps, row: item, columns: flattenColumns, gridColumns: gridColumns, options: options, keyId: keyId, variant: variant, isSelectable: isSelectable, isSelected: isSelected, level: INITIAL_LEVEL, nestedChildren: nestedChildren, isInitialExpanded: isInitialExpanded || false, expandedLevel: expandedLevel || 1, initialVisibleChildrenCount: initialVisibleChildrenCount || 2, activeRowId: activeRowId, moreButtonColumnPosition: moreButtonColumnPosition || 1, isVisibleCollapseButton: isVisibleCollapseButton || true, emptyCellValue: emptyCellValue, onRowClick: onRowClick, onSelectRow: onSelectRow })) }));
11
+ const { item, memoizedItemProps, onSelectRow, renderRow, flattenColumns, gridColumns, options, keyId, variant, isSelectable, isSelected, disabledMode, disabledReason, getRowDisabled, nestedChildren, isInitialExpanded, expandedLevel, initialVisibleChildrenCount, moreButtonColumnPosition, isVisibleCollapseButton, emptyCellValue, activeRowId, onRowClick, } = (0, useLogic_1.useLogic)(props);
12
+ return ((0, jsx_runtime_1.jsx)(RowContext_1.RowContextProvider, { row: item, itemProps: memoizedItemProps, onSelectRow: onSelectRow, isSelectable: isSelectable, isSelected: isSelected, disabledMode: disabledMode, disabledReason: disabledReason, children: renderRow ? ((0, jsx_runtime_1.jsx)(CustomRowWrapper_1.CustomRowWrapper, { index: memoizedItemProps['data-index'], renderRow: renderRow, row: item })) : ((0, jsx_runtime_1.jsx)(Row_1.Row, { ...memoizedItemProps, row: item, columns: flattenColumns, gridColumns: gridColumns, options: options, keyId: keyId, variant: variant, isSelectable: isSelectable, isSelected: isSelected, getRowDisabled: getRowDisabled, level: INITIAL_LEVEL, nestedChildren: nestedChildren, isInitialExpanded: isInitialExpanded || false, expandedLevel: expandedLevel || 1, initialVisibleChildrenCount: initialVisibleChildrenCount || 2, activeRowId: activeRowId, moreButtonColumnPosition: moreButtonColumnPosition || 1, isVisibleCollapseButton: isVisibleCollapseButton || true, emptyCellValue: emptyCellValue, onRowClick: onRowClick, onSelectRow: onSelectRow })) }));
13
13
  };
14
14
  exports.Row = Row;
@@ -1 +1,2 @@
1
1
  export * from './Row';
2
+ export type { DataGridInfiniteItemContext } from './types';
@@ -1,2 +1,17 @@
1
- import type { ItemProps as VirtuosoItemProps } from 'react-virtuoso';
2
- export type RowProps = VirtuosoItemProps<Record<string, unknown>>;
1
+ import type { ContextProp, ItemProps as VirtuosoItemProps } from 'react-virtuoso';
2
+ import { type DataGridProps, type DataGridRowDisabled } from '../../DataGrid/types';
3
+ type ContextGetRowDisabled = DataGridProps<Record<string, unknown>>['getRowDisabled'];
4
+ /**
5
+ * Состояние строк.
6
+ *
7
+ * Передаётся через `context` `Virtuoso`, а не через React-контекст: `Virtuoso` отдаёт `Item` новые данные
8
+ * на рендер позже родителя. Состояние из React-контекста приходило бы раньше данных, и строка
9
+ * перерисовывалась бы дважды — сначала со старыми данными и новым состоянием, затем с новыми данными.
10
+ */
11
+ export type DataGridInfiniteItemContext = {
12
+ selectedIds: Set<unknown>;
13
+ rowsDisabled: Map<unknown, DataGridRowDisabled | undefined>;
14
+ getRowDisabled?: ContextGetRowDisabled;
15
+ };
16
+ export type RowProps = VirtuosoItemProps<Record<string, unknown>> & ContextProp<DataGridInfiniteItemContext>;
17
+ export {};
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { type RowProps } from '../types';
3
3
  type UseLogicParams = Omit<RowProps, 'children'>;
4
- export declare const useLogic: ({ item, ...itemProps }: UseLogicParams) => {
4
+ export declare const useLogic: ({ item, context, ...itemProps }: UseLogicParams) => {
5
5
  item: Record<string, unknown>;
6
6
  renderRow: (row: Record<string, unknown>, index: number) => import("react").ReactNode;
7
7
  isSelected: boolean;
@@ -21,7 +21,9 @@ export declare const useLogic: ({ item, ...itemProps }: UseLogicParams) => {
21
21
  moreButtonColumnPosition: number | undefined;
22
22
  isVisibleCollapseButton: boolean | undefined;
23
23
  isSelectable: boolean | undefined;
24
- selectedRows: Record<string, unknown>[] | undefined;
24
+ disabledMode: "row" | "selection" | "row-except-last-cell" | undefined;
25
+ disabledReason: string | undefined;
26
+ getRowDisabled: ((row: Record<string, unknown>) => import("../../..").DataGridRowDisabled | undefined) | undefined;
25
27
  memoizedItemProps: {
26
28
  style?: import("react").CSSProperties | undefined;
27
29
  'data-index': number;
@@ -5,13 +5,18 @@ const react_1 = require("react");
5
5
  const DataGridContext_1 = require("../../../DataGrid/DataGridContext");
6
6
  const utils_1 = require("../../../DataGrid/utils");
7
7
  const DataGridInfiniteContext_1 = require("../../DataGridInfiniteContext");
8
- const useLogic = ({ item, ...itemProps }) => {
9
- const { renderRow, onSelectRow, variant, isInitialExpanded, expandedLevel, initialVisibleChildrenCount, moreButtonColumnPosition, isVisibleCollapseButton, isSelectable, selectedRows, } = (0, react_1.useContext)(DataGridInfiniteContext_1.DataGridInfiniteContext);
8
+ const useLogic = ({ item, context, ...itemProps }) => {
9
+ const { renderRow, onSelectRow, variant, isInitialExpanded, expandedLevel, initialVisibleChildrenCount, moreButtonColumnPosition, isVisibleCollapseButton, isSelectable, } = (0, react_1.useContext)(DataGridInfiniteContext_1.DataGridInfiniteContext);
10
+ // Состояние строки приходит от Virtuoso вместе с item, см. DataGridInfiniteItemContext
11
+ const { selectedIds, rowsDisabled, getRowDisabled } = context;
10
12
  const { activeRowId, columns, emptyCellValue, onRowClick, keyId, gridColumns, } = (0, react_1.useContext)(DataGridContext_1.DataGridContext);
11
13
  const memoizedItemProps = (0, react_1.useMemo)(() => itemProps, [itemProps.style]);
12
14
  const flattenColumns = (0, react_1.useMemo)(() => (0, utils_1.getFlattenColumns)(columns), [columns]);
13
15
  const { children: nestedChildren, options } = item;
14
- const isSelected = Boolean(selectedRows?.find((selectedRow) => selectedRow[keyId] === item[keyId]));
16
+ const rowId = item[keyId];
17
+ const isSelected = selectedIds.has(rowId);
18
+ const rowDisabled = rowsDisabled.get(rowId);
19
+ const hasNestedChildren = Array.isArray(nestedChildren) && nestedChildren.length > 0;
15
20
  return {
16
21
  item,
17
22
  renderRow,
@@ -32,7 +37,10 @@ const useLogic = ({ item, ...itemProps }) => {
32
37
  moreButtonColumnPosition,
33
38
  isVisibleCollapseButton,
34
39
  isSelectable,
35
- selectedRows,
40
+ disabledMode: rowDisabled?.mode,
41
+ disabledReason: rowDisabled?.reason,
42
+ // Функция нужна только для расчёта блокировки вложенных строк, остальным не передаём, чтобы не сбрасывать memo
43
+ getRowDisabled: hasNestedChildren ? getRowDisabled : undefined,
36
44
  memoizedItemProps,
37
45
  };
38
46
  };
@@ -6,4 +6,6 @@ export declare const dataGridInfiniteClassnames: {
6
6
  scrollToTopButton: string;
7
7
  visibleScrollToTopButton: string;
8
8
  massActionsSpacer: string;
9
+ header: string;
10
+ footer: string;
9
11
  };
@@ -10,4 +10,6 @@ exports.dataGridInfiniteClassnames = {
10
10
  scrollToTopButton: (0, createUIKitClassname_1.createUIKitClassname)('data-grid-infinite__scroll-to-top-button'),
11
11
  visibleScrollToTopButton: (0, createUIKitClassname_1.createUIKitClassname)('data-grid-infinite__scroll-to-top-button_visible'),
12
12
  massActionsSpacer: (0, createUIKitClassname_1.createUIKitClassname)('data-grid-infinite__mass-actions-spacer'),
13
+ header: (0, createUIKitClassname_1.createUIKitClassname)('data-grid-infinite__header'),
14
+ footer: (0, createUIKitClassname_1.createUIKitClassname)('data-grid-infinite__footer'),
13
15
  };
@@ -7,11 +7,7 @@ type DataType = {
7
7
  actions?: object;
8
8
  };
9
9
  export declare const makeRandomDate: () => string;
10
- export declare const makeDataList: (length?: number, options?: {
11
- isDisabled?: boolean;
12
- isDisabledLastCell?: boolean;
13
- disabledReason?: string;
14
- }) => DataType[];
10
+ export declare const makeDataList: (length?: number) => DataType[];
15
11
  export declare const makeDataListWithTree: (length?: number, options?: {
16
12
  isNotSelectable?: boolean;
17
13
  childrenCount?: number;
@@ -15,13 +15,12 @@ const makeRandomDate = () => {
15
15
  return randomDate.toISOString();
16
16
  };
17
17
  exports.makeRandomDate = makeRandomDate;
18
- const makeDataList = (length = 10, options) => {
18
+ const makeDataList = (length = 10) => {
19
19
  return Array.from({ length }).map((_, i) => ({
20
20
  id: i.toString(),
21
21
  documentName: `Договор №${i + 1}`,
22
22
  recipient: RECIPIENTS[faker_1.faker.number.int({ min: 0, max: RECIPIENTS.length })],
23
23
  createDate: (0, exports.makeRandomDate)(),
24
- options: Math.random() < 0.4 ? options : {},
25
24
  }));
26
25
  };
27
26
  exports.makeDataList = makeDataList;
@@ -3,10 +3,11 @@ import type { ListRange } from 'react-virtuoso';
3
3
  import { type DataGridRow } from '../../DataGrid';
4
4
  import { type CellValue } from '../../DataGrid/types';
5
5
  import { type FooterContext } from '../Footer';
6
+ import { type DataGridInfiniteItemContext } from '../Row';
6
7
  import { type DataGridInfiniteProps, type DataGridInfiniteVirtuosoHandle } from '../types';
7
8
  type UseLogicParams<TData extends Record<string, CellValue> = DataGridRow, TSortField extends keyof TData = keyof TData> = DataGridInfiniteProps<TData, TSortField>;
8
- export declare const useLogic: <TData extends Record<string, unknown> = DataGridRow, TSortField extends keyof TData = keyof TData>({ keyId, columns, rows, variant, tree, subrows, selectedRows, maxHeight, isLoading, isError, isDisabled, isEndReached, endOfScrollMsg, onRetry, onEndReached, onStartReached, isStartReached, onSelectRow, isHideSelectAll, initialVisibleItemIndex, isHideHeaderIfNoData, gridViewMode: gridViewModeProp, massActions, mobileDisplayVariant, virtuosoRef, }: UseLogicParams<TData, TSortField>) => {
9
- footerContext: FooterContext;
9
+ export declare const useLogic: <TData extends Record<string, unknown> = DataGridRow, TSortField extends keyof TData = keyof TData>({ keyId, columns, rows, variant, tree, subrows, selectedRows, maxHeight, isLoading, isError, isDisabled, getRowDisabled, isEndReached, endOfScrollMsg, onRetry, onEndReached, onStartReached, isStartReached, onSelectRow, isHideSelectAll, initialVisibleItemIndex, isHideHeaderIfNoData, gridViewMode: gridViewModeProp, massActions, mobileDisplayVariant, virtuosoRef, }: UseLogicParams<TData, TSortField>) => {
10
+ virtuosoContext: DataGridInfiniteItemContext & FooterContext;
10
11
  hasMassActions: boolean;
11
12
  isMassActionsOpen: boolean;
12
13
  containerCssVars: import("react").CSSProperties;