@astral/ui 4.114.0 → 4.115.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/DataGrid/Body/Body.d.ts +1 -1
- package/components/DataGrid/Body/Body.js +7 -3
- package/components/DataGrid/Body/types.d.ts +11 -3
- package/components/DataGrid/DataGrid.js +0 -1
- package/components/DataGrid/PinnedSections/PinnedSections.js +2 -2
- package/components/DataGrid/PinnedSections/useLogic/useLogic.d.ts +1 -0
- package/components/DataGrid/PinnedSections/useLogic/useLogic.js +4 -3
- package/components/DataGrid/Row/Row.js +13 -9
- package/components/DataGrid/Row/RowContext/RowContext.d.ts +15 -4
- package/components/DataGrid/Row/RowContext/RowContext.js +3 -3
- package/components/DataGrid/Row/RowContext/RowProvider/RowProvider.d.ts +10 -1
- package/components/DataGrid/Row/RowContext/RowProvider/RowProvider.js +23 -17
- package/components/DataGrid/Row/types.d.ts +7 -3
- package/components/DataGrid/Row/useLogic/useLogic.d.ts +6 -4
- package/components/DataGrid/Row/useLogic/useLogic.js +21 -12
- package/components/DataGrid/RowBase/RowBase.js +5 -2
- package/components/DataGrid/RowBase/types.d.ts +9 -5
- package/components/DataGrid/RowBase/useLogic/useLogic.d.ts +5 -4
- package/components/DataGrid/RowBase/useLogic/useLogic.js +16 -10
- package/components/DataGrid/RowCheckbox/RowCheckbox.d.ts +5 -0
- package/components/DataGrid/RowCheckbox/RowCheckbox.js +13 -0
- package/components/DataGrid/RowCheckbox/constants.d.ts +4 -0
- package/components/DataGrid/RowCheckbox/constants.js +4 -0
- package/components/DataGrid/RowCheckbox/index.d.ts +1 -0
- package/components/DataGrid/RowCheckbox/index.js +1 -0
- package/components/DataGrid/RowCheckbox/types.d.ts +7 -0
- package/components/DataGrid/RowCheckbox/types.js +1 -0
- package/components/DataGrid/hooks/index.d.ts +1 -0
- package/components/DataGrid/hooks/index.js +1 -0
- package/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/index.d.ts +1 -0
- package/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/index.js +1 -0
- package/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/useWarnRowsWithoutDisabledReason.d.ts +5 -0
- package/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/useWarnRowsWithoutDisabledReason.js +17 -0
- package/components/DataGrid/index.d.ts +1 -1
- package/components/DataGrid/public.d.ts +1 -1
- package/components/DataGrid/tests/performance/testDataGridPerformance.d.ts +3 -1
- package/components/DataGrid/tests/performance/testDataGridPerformance.js +234 -2
- package/components/DataGrid/tests/selection/testDataGridSelection.d.ts +14 -0
- package/components/DataGrid/tests/selection/testDataGridSelection.js +562 -0
- package/components/DataGrid/types.d.ts +34 -1
- package/components/DataGrid/useLogic/useLogic.d.ts +6 -3
- package/components/DataGrid/useLogic/useLogic.js +15 -10
- package/components/DataGrid/utils/getRowDisabledState/getRowDisabledState.d.ts +31 -0
- package/components/DataGrid/utils/getRowDisabledState/getRowDisabledState.js +20 -0
- package/components/DataGrid/utils/getRowDisabledState/index.d.ts +1 -0
- package/components/DataGrid/utils/getRowDisabledState/index.js +1 -0
- package/components/DataGrid/utils/index.d.ts +3 -0
- package/components/DataGrid/utils/index.js +3 -0
- package/components/DataGrid/utils/resolveRowDisabled/index.d.ts +1 -0
- package/components/DataGrid/utils/resolveRowDisabled/index.js +1 -0
- package/components/DataGrid/utils/resolveRowDisabled/resolveRowDisabled.d.ts +5 -0
- package/components/DataGrid/utils/resolveRowDisabled/resolveRowDisabled.js +17 -0
- package/components/DataGrid/utils/resolveRowsDisabled/index.d.ts +1 -0
- package/components/DataGrid/utils/resolveRowsDisabled/index.js +1 -0
- package/components/DataGrid/utils/resolveRowsDisabled/resolveRowsDisabled.d.ts +16 -0
- package/components/DataGrid/utils/resolveRowsDisabled/resolveRowsDisabled.js +17 -0
- package/components/DataGridActionCell/hooks/useBlockingActions/useBlockingActions.js +3 -3
- package/components/DataGridCollapsibleRow/useLogic/useLogic.d.ts +3 -2
- package/components/DataGridCollapsibleRow/useLogic/useLogic.js +4 -3
- package/components/DataGridInfinite/DataGridInfinite.js +4 -4
- package/components/DataGridInfinite/DataGridInfiniteContext/DataGridInfiniteContext.d.ts +1 -1
- package/components/DataGridInfinite/DataGridInfiniteContext/DataGridInfiniteContext.js +1 -1
- package/components/DataGridInfinite/Footer/Footer.js +2 -2
- package/components/DataGridInfinite/Row/Row.js +2 -2
- package/components/DataGridInfinite/Row/index.d.ts +1 -0
- package/components/DataGridInfinite/Row/types.d.ts +17 -2
- package/components/DataGridInfinite/Row/useLogic/useLogic.d.ts +4 -2
- package/components/DataGridInfinite/Row/useLogic/useLogic.js +12 -4
- package/components/DataGridInfinite/constants.d.ts +2 -0
- package/components/DataGridInfinite/constants.js +2 -0
- package/components/DataGridInfinite/faker.d.ts +1 -5
- package/components/DataGridInfinite/faker.js +1 -2
- package/components/DataGridInfinite/useLogic/useLogic.d.ts +3 -2
- package/components/DataGridInfinite/useLogic/useLogic.js +25 -13
- package/components/PageContent/styles.js +25 -1
- package/components/index.d.ts +1 -1
- package/node/components/DataGrid/Body/Body.d.ts +1 -1
- package/node/components/DataGrid/Body/Body.js +7 -3
- package/node/components/DataGrid/Body/types.d.ts +11 -3
- package/node/components/DataGrid/DataGrid.js +0 -1
- package/node/components/DataGrid/PinnedSections/PinnedSections.js +2 -2
- package/node/components/DataGrid/PinnedSections/useLogic/useLogic.d.ts +1 -0
- package/node/components/DataGrid/PinnedSections/useLogic/useLogic.js +4 -3
- package/node/components/DataGrid/Row/Row.js +13 -9
- package/node/components/DataGrid/Row/RowContext/RowContext.d.ts +15 -4
- package/node/components/DataGrid/Row/RowContext/RowContext.js +3 -3
- package/node/components/DataGrid/Row/RowContext/RowProvider/RowProvider.d.ts +10 -1
- package/node/components/DataGrid/Row/RowContext/RowProvider/RowProvider.js +23 -17
- package/node/components/DataGrid/Row/types.d.ts +7 -3
- package/node/components/DataGrid/Row/useLogic/useLogic.d.ts +6 -4
- package/node/components/DataGrid/Row/useLogic/useLogic.js +23 -14
- package/node/components/DataGrid/RowBase/RowBase.js +5 -2
- package/node/components/DataGrid/RowBase/types.d.ts +9 -5
- package/node/components/DataGrid/RowBase/useLogic/useLogic.d.ts +5 -4
- package/node/components/DataGrid/RowBase/useLogic/useLogic.js +16 -10
- package/node/components/DataGrid/RowCheckbox/RowCheckbox.d.ts +5 -0
- package/node/components/DataGrid/RowCheckbox/RowCheckbox.js +17 -0
- package/node/components/DataGrid/RowCheckbox/constants.d.ts +4 -0
- package/node/components/DataGrid/RowCheckbox/constants.js +7 -0
- package/node/components/DataGrid/RowCheckbox/index.d.ts +1 -0
- package/node/components/DataGrid/RowCheckbox/index.js +17 -0
- package/node/components/DataGrid/RowCheckbox/types.d.ts +7 -0
- package/node/components/DataGrid/RowCheckbox/types.js +2 -0
- package/node/components/DataGrid/hooks/index.d.ts +1 -0
- package/node/components/DataGrid/hooks/index.js +1 -0
- package/node/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/index.d.ts +1 -0
- package/node/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/index.js +17 -0
- package/node/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/useWarnRowsWithoutDisabledReason.d.ts +5 -0
- package/node/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/useWarnRowsWithoutDisabledReason.js +21 -0
- package/node/components/DataGrid/index.d.ts +1 -1
- package/node/components/DataGrid/public.d.ts +1 -1
- package/node/components/DataGrid/tests/performance/testDataGridPerformance.d.ts +3 -1
- package/node/components/DataGrid/tests/performance/testDataGridPerformance.js +232 -0
- package/node/components/DataGrid/tests/selection/testDataGridSelection.d.ts +14 -0
- package/node/components/DataGrid/tests/selection/testDataGridSelection.js +566 -0
- package/node/components/DataGrid/types.d.ts +34 -1
- package/node/components/DataGrid/useLogic/useLogic.d.ts +6 -3
- package/node/components/DataGrid/useLogic/useLogic.js +17 -12
- package/node/components/DataGrid/utils/getRowDisabledState/getRowDisabledState.d.ts +31 -0
- package/node/components/DataGrid/utils/getRowDisabledState/getRowDisabledState.js +24 -0
- package/node/components/DataGrid/utils/getRowDisabledState/index.d.ts +1 -0
- package/node/components/DataGrid/utils/getRowDisabledState/index.js +5 -0
- package/node/components/DataGrid/utils/index.d.ts +3 -0
- package/node/components/DataGrid/utils/index.js +7 -1
- package/node/components/DataGrid/utils/resolveRowDisabled/index.d.ts +1 -0
- package/node/components/DataGrid/utils/resolveRowDisabled/index.js +5 -0
- package/node/components/DataGrid/utils/resolveRowDisabled/resolveRowDisabled.d.ts +5 -0
- package/node/components/DataGrid/utils/resolveRowDisabled/resolveRowDisabled.js +21 -0
- package/node/components/DataGrid/utils/resolveRowsDisabled/index.d.ts +1 -0
- package/node/components/DataGrid/utils/resolveRowsDisabled/index.js +5 -0
- package/node/components/DataGrid/utils/resolveRowsDisabled/resolveRowsDisabled.d.ts +16 -0
- package/node/components/DataGrid/utils/resolveRowsDisabled/resolveRowsDisabled.js +21 -0
- package/node/components/DataGridActionCell/hooks/useBlockingActions/useBlockingActions.js +3 -3
- package/node/components/DataGridCollapsibleRow/useLogic/useLogic.d.ts +3 -2
- package/node/components/DataGridCollapsibleRow/useLogic/useLogic.js +4 -3
- package/node/components/DataGridInfinite/DataGridInfinite.js +4 -4
- package/node/components/DataGridInfinite/DataGridInfiniteContext/DataGridInfiniteContext.d.ts +1 -1
- package/node/components/DataGridInfinite/DataGridInfiniteContext/DataGridInfiniteContext.js +1 -1
- package/node/components/DataGridInfinite/Footer/Footer.js +1 -1
- package/node/components/DataGridInfinite/Row/Row.js +2 -2
- package/node/components/DataGridInfinite/Row/index.d.ts +1 -0
- package/node/components/DataGridInfinite/Row/types.d.ts +17 -2
- package/node/components/DataGridInfinite/Row/useLogic/useLogic.d.ts +4 -2
- package/node/components/DataGridInfinite/Row/useLogic/useLogic.js +12 -4
- package/node/components/DataGridInfinite/constants.d.ts +2 -0
- package/node/components/DataGridInfinite/constants.js +2 -0
- package/node/components/DataGridInfinite/faker.d.ts +1 -5
- package/node/components/DataGridInfinite/faker.js +1 -2
- package/node/components/DataGridInfinite/useLogic/useLogic.d.ts +3 -2
- package/node/components/DataGridInfinite/useLogic/useLogic.js +26 -14
- package/node/components/PageContent/styles.js +24 -0
- package/node/components/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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,
|
|
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
|
|
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
|
|
38
|
+
isDisabled: boolean;
|
|
38
39
|
sectionOffset: number | undefined;
|
|
39
40
|
customContent: import("react").ReactNode;
|
|
40
|
-
isDisabledLastCell: boolean
|
|
41
|
+
isDisabledLastCell: boolean;
|
|
41
42
|
renderStartAdornment: ((isFirstCell: boolean) => import("react").ReactNode) | undefined;
|
|
42
43
|
isSelectable: boolean | undefined;
|
|
43
44
|
isNotSelectable: boolean | undefined;
|
|
@@ -4,16 +4,21 @@ exports.useLogic = void 0;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const redirectToLink_1 = require("../../../utils/redirectToLink");
|
|
6
6
|
const hooks_1 = require("../../Row/useLogic/hooks");
|
|
7
|
+
const utils_1 = require("../../utils");
|
|
7
8
|
const constants_1 = require("../constants");
|
|
8
|
-
const useLogic = ({ className, row, keyId, onRowClick, columns, sectionOffset, customContent, renderStartAdornment, isSelected,
|
|
9
|
+
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 }) => {
|
|
9
10
|
const [isVisibleTooltip, setVisibleTooltip] = (0, react_1.useState)(false);
|
|
10
11
|
const savedElementRef = (0, react_1.useRef)(null);
|
|
11
12
|
const { isDrawerOpen, handleOpenDrawer, handleCloseDrawer } = (0, hooks_1.useMobileLogic)();
|
|
12
13
|
const { options } = row;
|
|
13
14
|
const { style: dataGridInfiniteItemStyle, ...restDataGridInfiniteItemProps } = dataGridInfiniteItemProps || {};
|
|
14
|
-
const {
|
|
15
|
-
const
|
|
16
|
-
|
|
15
|
+
const { href, isNotSelectable, target } = options || {};
|
|
16
|
+
const { isDisabled, isDisabledLastCell, disabledReason, isCheckboxDisabled, checkboxDisabledReason, } = (0, utils_1.getRowDisabledState)({
|
|
17
|
+
rowDisabled,
|
|
18
|
+
hasBlockingAction,
|
|
19
|
+
blockingActionReason,
|
|
20
|
+
isDisabledLastCellOption: options?.isDisabledLastCell,
|
|
21
|
+
});
|
|
17
22
|
const handleOpenTooltip = (event) => {
|
|
18
23
|
const element = event.target;
|
|
19
24
|
const isDisabledCell = element?.getAttribute(constants_1.DISABLE_ROW_ATTR) === 'true';
|
|
@@ -26,7 +31,7 @@ const useLogic = ({ className, row, keyId, onRowClick, columns, sectionOffset, c
|
|
|
26
31
|
'--row-base-grid-columns': gridColumns,
|
|
27
32
|
...(dataGridInfiniteItemStyle || {}),
|
|
28
33
|
};
|
|
29
|
-
const isHovered = Boolean(!
|
|
34
|
+
const isHovered = Boolean(!isDisabled && (onRowClick || href));
|
|
30
35
|
const isActive = activeRowId === rowId;
|
|
31
36
|
const rowRef = (element) => {
|
|
32
37
|
if (element) {
|
|
@@ -39,7 +44,7 @@ const useLogic = ({ className, row, keyId, onRowClick, columns, sectionOffset, c
|
|
|
39
44
|
}
|
|
40
45
|
};
|
|
41
46
|
const handleRowClick = () => {
|
|
42
|
-
if (
|
|
47
|
+
if (isDisabled) {
|
|
43
48
|
handleOpenDrawer();
|
|
44
49
|
return undefined;
|
|
45
50
|
}
|
|
@@ -52,7 +57,7 @@ const useLogic = ({ className, row, keyId, onRowClick, columns, sectionOffset, c
|
|
|
52
57
|
handleRowClick,
|
|
53
58
|
tooltipProps: {
|
|
54
59
|
open: isVisibleTooltip,
|
|
55
|
-
title:
|
|
60
|
+
title: isDisabled ? disabledReason : undefined,
|
|
56
61
|
onOpen: handleOpenTooltip,
|
|
57
62
|
onClose: handleCloseTooltip,
|
|
58
63
|
followCursor: true,
|
|
@@ -60,7 +65,8 @@ const useLogic = ({ className, row, keyId, onRowClick, columns, sectionOffset, c
|
|
|
60
65
|
},
|
|
61
66
|
checkboxProps: {
|
|
62
67
|
checked: isSelected,
|
|
63
|
-
disabled,
|
|
68
|
+
disabled: isCheckboxDisabled,
|
|
69
|
+
disabledReason: checkboxDisabledReason,
|
|
64
70
|
onChange: onSelectRow(row),
|
|
65
71
|
},
|
|
66
72
|
drawerProps: {
|
|
@@ -68,7 +74,7 @@ const useLogic = ({ className, row, keyId, onRowClick, columns, sectionOffset, c
|
|
|
68
74
|
onClose: handleCloseDrawer,
|
|
69
75
|
title: 'Заблокировано',
|
|
70
76
|
},
|
|
71
|
-
drawerContent:
|
|
77
|
+
drawerContent: disabledReason,
|
|
72
78
|
rowBaseVars,
|
|
73
79
|
isHovered,
|
|
74
80
|
isActive,
|
|
@@ -81,7 +87,7 @@ const useLogic = ({ className, row, keyId, onRowClick, columns, sectionOffset, c
|
|
|
81
87
|
onRowLeave,
|
|
82
88
|
rowId,
|
|
83
89
|
row,
|
|
84
|
-
isDisabled
|
|
90
|
+
isDisabled,
|
|
85
91
|
sectionOffset,
|
|
86
92
|
customContent,
|
|
87
93
|
isDisabledLastCell,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type RowCheckboxProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Checkbox строки. Для заблокированного выбора показывает причину в tooltip
|
|
4
|
+
*/
|
|
5
|
+
export declare const RowCheckbox: ({ disabledReason, ...checkboxProps }: RowCheckboxProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RowCheckbox = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const Checkbox_1 = require("../../Checkbox");
|
|
6
|
+
const Tooltip_1 = require("../../Tooltip");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
/**
|
|
9
|
+
* Checkbox строки. Для заблокированного выбора показывает причину в tooltip
|
|
10
|
+
*/
|
|
11
|
+
const RowCheckbox = ({ disabledReason, ...checkboxProps }) => {
|
|
12
|
+
if (!disabledReason) {
|
|
13
|
+
return (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { ...checkboxProps });
|
|
14
|
+
}
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: disabledReason, enterDelay: constants_1.DISABLED_REASON_TOOLTIP_DELAY, enterNextDelay: constants_1.DISABLED_REASON_TOOLTIP_DELAY, withoutContainer: false, children: (0, jsx_runtime_1.jsx)(Checkbox_1.Checkbox, { ...checkboxProps }) }));
|
|
16
|
+
};
|
|
17
|
+
exports.RowCheckbox = RowCheckbox;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './RowCheckbox';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./RowCheckbox"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useWarnRowsWithoutDisabledReason';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useWarnRowsWithoutDisabledReason"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useWarnRowsWithoutDisabledReason = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* Выводит одно агрегированное предупреждение о строках с блокировкой без причины.
|
|
7
|
+
* Строки, о которых уже предупреждали, повторно не попадают в предупреждение
|
|
8
|
+
*/
|
|
9
|
+
const useWarnRowsWithoutDisabledReason = (idsWithoutReason) => {
|
|
10
|
+
const warnedIdsRef = (0, react_1.useRef)(new Set());
|
|
11
|
+
(0, react_1.useEffect)(() => {
|
|
12
|
+
const newIds = idsWithoutReason.filter((id) => !warnedIdsRef.current.has(id));
|
|
13
|
+
if (!newIds.length) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
newIds.forEach((id) => warnedIdsRef.current.add(id));
|
|
17
|
+
// biome-ignore lint/suspicious/noConsole: Ошибка для интеграторов
|
|
18
|
+
console.warn(`UIKIT. DataGrid: getRowDisabled вернул блокировку без reason для строк: ${newIds.join(', ')}`);
|
|
19
|
+
}, [idsWithoutReason]);
|
|
20
|
+
};
|
|
21
|
+
exports.useWarnRowsWithoutDisabledReason = useWarnRowsWithoutDisabledReason;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { DataGrid } from './DataGrid';
|
|
2
|
-
export type { DataGridProps, DataGridRenderLink, DataGridRenderLinkParams, DataGridColumns, DataGridSingleColumn, DataGridRow, DataGridRowOptions, DataGridSort, DataGridRowWithOptions, DataGridRowOptionColumns, } from './types';
|
|
2
|
+
export type { DataGridProps, DataGridRenderLink, DataGridRenderLinkParams, DataGridColumns, DataGridSingleColumn, DataGridRow, DataGridRowOptions, DataGridRowDisabled, DataGridSort, DataGridRowWithOptions, DataGridRowOptionColumns, } from './types';
|
|
3
3
|
export { dataGridClassnames } from './constants';
|
|
4
4
|
export { MobileSkeleton } from './MobileSkeleton';
|
|
5
5
|
export { RowBase, type RowBaseProps } from './RowBase';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { dataGridClassnames } from './constants';
|
|
2
2
|
export { DataGrid } from './DataGrid';
|
|
3
|
-
export type { DataGridColumns, DataGridProps, DataGridRenderLink, DataGridRenderLinkParams, DataGridRow, DataGridRowOptionColumns, DataGridRowOptions, DataGridRowWithOptions, DataGridSort, } from './types';
|
|
3
|
+
export type { DataGridColumns, DataGridProps, DataGridRenderLink, DataGridRenderLinkParams, DataGridRow, DataGridRowDisabled, DataGridRowOptionColumns, DataGridRowOptions, DataGridRowWithOptions, DataGridSort, } from './types';
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { type ReactElement, type ReactNode } from 'react';
|
|
2
|
-
import { type DataGridColumns, type DataGridRowWithOptions } from '../../types';
|
|
2
|
+
import { type DataGridColumns, type DataGridProps, type DataGridRowDisabled, type DataGridRowWithOptions } from '../../types';
|
|
3
3
|
type RenderRow = (row: Record<string, unknown>, index: number) => ReactNode;
|
|
4
4
|
type GridRenderProps = {
|
|
5
5
|
rows: DataGridRowWithOptions<DataItem>[];
|
|
6
6
|
columns: DataGridColumns<DataItem>[];
|
|
7
7
|
selectedRows?: DataItem[];
|
|
8
8
|
onSelectRow?: (rows: DataItem[]) => void;
|
|
9
|
+
getRowDisabled?: (row: DataItem) => DataGridRowDisabled | undefined;
|
|
10
|
+
tree?: DataGridProps<DataItem>['tree'];
|
|
9
11
|
renderRow?: RenderRow;
|
|
10
12
|
onRetry: () => void;
|
|
11
13
|
};
|
|
@@ -10,6 +10,22 @@ const TEST_ROWS = [
|
|
|
10
10
|
{ id: '2', name: 'Petya' },
|
|
11
11
|
{ id: '3', name: 'Ivan' },
|
|
12
12
|
];
|
|
13
|
+
const TEST_ROWS_WITH_CHILDREN = [
|
|
14
|
+
...TEST_ROWS,
|
|
15
|
+
{
|
|
16
|
+
id: '4',
|
|
17
|
+
name: 'Package',
|
|
18
|
+
children: [{ id: '4-1', name: 'Nested' }],
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
const SELECTION_DISABLED = {
|
|
22
|
+
mode: 'selection',
|
|
23
|
+
reason: 'Документ отправляется',
|
|
24
|
+
};
|
|
25
|
+
const ROW_DISABLED = {
|
|
26
|
+
mode: 'row',
|
|
27
|
+
reason: 'Документ отправляется',
|
|
28
|
+
};
|
|
13
29
|
const testDataGridPerformance = ({ render, renderGrid, }) => {
|
|
14
30
|
const getRenderCountFor = (spy, id) => spy.mock.calls.filter(([row]) => row.id === id).length;
|
|
15
31
|
(0, vitest_1.it)('При клике на чекбокс перерендеривается только выбранная строка', async () => {
|
|
@@ -102,5 +118,221 @@ const testDataGridPerformance = ({ render, renderGrid, }) => {
|
|
|
102
118
|
(0, vitest_1.expect)(getRenderCountFor(renderCellSpy, '2')).toBe(0);
|
|
103
119
|
(0, vitest_1.expect)(getRenderCountFor(renderCellSpy, '3')).toBe(1);
|
|
104
120
|
});
|
|
121
|
+
(0, vitest_1.describe)('getRowDisabled', () => {
|
|
122
|
+
const createColumns = (renderCell) => [
|
|
123
|
+
{ field: 'name', label: 'Наименование', renderCell },
|
|
124
|
+
];
|
|
125
|
+
const getRenderCounts = (spy, ids) => Object.fromEntries(ids.map((id) => [id, getRenderCountFor(spy, id)]));
|
|
126
|
+
const setupSelectableGrid = () => {
|
|
127
|
+
const renderCellSpy = vitest_1.vi.fn((row) => row.name);
|
|
128
|
+
const getRowDisabledSpy = vitest_1.vi.fn(() => undefined);
|
|
129
|
+
const TestComponent = () => {
|
|
130
|
+
const [selectedRows, setSelectedRows] = (0, react_1.useState)([]);
|
|
131
|
+
const columns = (0, react_1.useMemo)(() => createColumns(renderCellSpy), []);
|
|
132
|
+
return renderGrid({
|
|
133
|
+
rows: TEST_ROWS,
|
|
134
|
+
columns,
|
|
135
|
+
selectedRows,
|
|
136
|
+
onSelectRow: setSelectedRows,
|
|
137
|
+
getRowDisabled: getRowDisabledSpy,
|
|
138
|
+
onRetry: () => { },
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
render((0, jsx_runtime_1.jsx)(TestComponent, {}));
|
|
142
|
+
renderCellSpy.mockClear();
|
|
143
|
+
getRowDisabledSpy.mockClear();
|
|
144
|
+
return { renderCellSpy, getRowDisabledSpy };
|
|
145
|
+
};
|
|
146
|
+
const setupParentRerender = () => {
|
|
147
|
+
const renderCellSpy = vitest_1.vi.fn((row) => row.name);
|
|
148
|
+
const getRowDisabledSpy = vitest_1.vi.fn(() => undefined);
|
|
149
|
+
const TestComponent = () => {
|
|
150
|
+
const [, setCounter] = (0, react_1.useState)(0);
|
|
151
|
+
const columns = (0, react_1.useMemo)(() => createColumns(renderCellSpy), []);
|
|
152
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => setCounter((value) => value + 1), children: "Rerender" }), renderGrid({
|
|
153
|
+
rows: TEST_ROWS,
|
|
154
|
+
columns,
|
|
155
|
+
selectedRows: [],
|
|
156
|
+
onSelectRow: () => { },
|
|
157
|
+
getRowDisabled: getRowDisabledSpy,
|
|
158
|
+
onRetry: () => { },
|
|
159
|
+
})] }));
|
|
160
|
+
};
|
|
161
|
+
render((0, jsx_runtime_1.jsx)(TestComponent, {}));
|
|
162
|
+
renderCellSpy.mockClear();
|
|
163
|
+
getRowDisabledSpy.mockClear();
|
|
164
|
+
return { renderCellSpy, getRowDisabledSpy };
|
|
165
|
+
};
|
|
166
|
+
const setupChangedResult = () => {
|
|
167
|
+
const renderCellSpy = vitest_1.vi.fn((row) => row.name);
|
|
168
|
+
const getRowDisabledSpy = vitest_1.vi.fn();
|
|
169
|
+
const TestComponent = () => {
|
|
170
|
+
const [lockedId, setLockedId] = (0, react_1.useState)();
|
|
171
|
+
const columns = (0, react_1.useMemo)(() => createColumns(renderCellSpy), []);
|
|
172
|
+
const getRowDisabled = (0, react_1.useCallback)((row) => {
|
|
173
|
+
getRowDisabledSpy(row);
|
|
174
|
+
return row.id === lockedId ? SELECTION_DISABLED : undefined;
|
|
175
|
+
}, [lockedId]);
|
|
176
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => setLockedId('2'), children: "Lock row 2" }), renderGrid({
|
|
177
|
+
rows: TEST_ROWS,
|
|
178
|
+
columns,
|
|
179
|
+
selectedRows: [],
|
|
180
|
+
onSelectRow: () => { },
|
|
181
|
+
getRowDisabled,
|
|
182
|
+
onRetry: () => { },
|
|
183
|
+
})] }));
|
|
184
|
+
};
|
|
185
|
+
render((0, jsx_runtime_1.jsx)(TestComponent, {}));
|
|
186
|
+
renderCellSpy.mockClear();
|
|
187
|
+
getRowDisabledSpy.mockClear();
|
|
188
|
+
return { renderCellSpy, getRowDisabledSpy };
|
|
189
|
+
};
|
|
190
|
+
const setupSameResult = () => {
|
|
191
|
+
const renderCellSpy = vitest_1.vi.fn((row) => row.name);
|
|
192
|
+
const getRowDisabledSpy = vitest_1.vi.fn();
|
|
193
|
+
const TestComponent = () => {
|
|
194
|
+
const [counter, setCounter] = (0, react_1.useState)(0);
|
|
195
|
+
const columns = (0, react_1.useMemo)(() => createColumns(renderCellSpy), []);
|
|
196
|
+
const getRowDisabled = (0, react_1.useCallback)((row) => {
|
|
197
|
+
getRowDisabledSpy(row);
|
|
198
|
+
return undefined;
|
|
199
|
+
}, [counter]);
|
|
200
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => setCounter((value) => value + 1), children: "New function" }), renderGrid({
|
|
201
|
+
rows: TEST_ROWS_WITH_CHILDREN,
|
|
202
|
+
columns,
|
|
203
|
+
selectedRows: [],
|
|
204
|
+
onSelectRow: () => { },
|
|
205
|
+
getRowDisabled,
|
|
206
|
+
tree: { isInitialExpanded: true },
|
|
207
|
+
onRetry: () => { },
|
|
208
|
+
})] }));
|
|
209
|
+
};
|
|
210
|
+
render((0, jsx_runtime_1.jsx)(TestComponent, {}));
|
|
211
|
+
renderCellSpy.mockClear();
|
|
212
|
+
getRowDisabledSpy.mockClear();
|
|
213
|
+
return { renderCellSpy, getRowDisabledSpy };
|
|
214
|
+
};
|
|
215
|
+
(0, vitest_1.describe)('Клик на чекбокс', () => {
|
|
216
|
+
(0, vitest_1.it)('Перерендеривается только выбранная строка', async () => {
|
|
217
|
+
const { renderCellSpy } = setupSelectableGrid();
|
|
218
|
+
// 0 - "Выбрать все", 1 - первая строка
|
|
219
|
+
await tests_1.userEvents.click(tests_1.screen.getAllByRole('checkbox')[2]);
|
|
220
|
+
(0, vitest_1.expect)(getRenderCounts(renderCellSpy, ['1', '2', '3'])).toEqual({
|
|
221
|
+
'1': 0,
|
|
222
|
+
'2': 1,
|
|
223
|
+
'3': 0,
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
(0, vitest_1.it)('getRowDisabled не вызывается', async () => {
|
|
227
|
+
const { getRowDisabledSpy } = setupSelectableGrid();
|
|
228
|
+
await tests_1.userEvents.click(tests_1.screen.getAllByRole('checkbox')[2]);
|
|
229
|
+
(0, vitest_1.expect)(getRowDisabledSpy).not.toHaveBeenCalled();
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
(0, vitest_1.it)('getRowDisabled не вызывается при «Выбрать все»', async () => {
|
|
233
|
+
const { getRowDisabledSpy } = setupSelectableGrid();
|
|
234
|
+
await tests_1.userEvents.click(tests_1.screen.getAllByRole('checkbox')[0]);
|
|
235
|
+
(0, vitest_1.expect)(getRowDisabledSpy).not.toHaveBeenCalled();
|
|
236
|
+
});
|
|
237
|
+
(0, vitest_1.describe)('Перерисовка родителя со стабильной функцией', () => {
|
|
238
|
+
(0, vitest_1.it)('Строки не перерисовываются', async () => {
|
|
239
|
+
const { renderCellSpy } = setupParentRerender();
|
|
240
|
+
await tests_1.userEvents.click(tests_1.screen.getByText('Rerender'));
|
|
241
|
+
(0, vitest_1.expect)(renderCellSpy).not.toHaveBeenCalled();
|
|
242
|
+
});
|
|
243
|
+
(0, vitest_1.it)('getRowDisabled не вызывается', async () => {
|
|
244
|
+
const { getRowDisabledSpy } = setupParentRerender();
|
|
245
|
+
await tests_1.userEvents.click(tests_1.screen.getByText('Rerender'));
|
|
246
|
+
(0, vitest_1.expect)(getRowDisabledSpy).not.toHaveBeenCalled();
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
(0, vitest_1.describe)('Новая функция с изменившимся результатом', () => {
|
|
250
|
+
(0, vitest_1.it)('Перерендеривается только строка с изменившимся результатом', async () => {
|
|
251
|
+
const { renderCellSpy } = setupChangedResult();
|
|
252
|
+
await tests_1.userEvents.click(tests_1.screen.getByText('Lock row 2'));
|
|
253
|
+
(0, vitest_1.expect)(getRenderCounts(renderCellSpy, ['1', '2', '3'])).toEqual({
|
|
254
|
+
'1': 0,
|
|
255
|
+
'2': 1,
|
|
256
|
+
'3': 0,
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
(0, vitest_1.it)('getRowDisabled вызывается один раз на строку', async () => {
|
|
260
|
+
const { getRowDisabledSpy } = setupChangedResult();
|
|
261
|
+
await tests_1.userEvents.click(tests_1.screen.getByText('Lock row 2'));
|
|
262
|
+
(0, vitest_1.expect)(getRowDisabledSpy).toHaveBeenCalledTimes(TEST_ROWS.length);
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
(0, vitest_1.describe)('Новая функция с тем же результатом', () => {
|
|
266
|
+
(0, vitest_1.it)('Перерисовываются только строки с дочерними элементами', async () => {
|
|
267
|
+
const { renderCellSpy } = setupSameResult();
|
|
268
|
+
await tests_1.userEvents.click(tests_1.screen.getByText('New function'));
|
|
269
|
+
(0, vitest_1.expect)(getRenderCounts(renderCellSpy, ['1', '2', '3', '4', '4-1'])).toEqual({ '1': 0, '2': 0, '3': 0, '4': 1, '4-1': 1 });
|
|
270
|
+
});
|
|
271
|
+
(0, vitest_1.it)('getRowDisabled вызывается один раз на строку, включая вложенную', async () => {
|
|
272
|
+
const { getRowDisabledSpy } = setupSameResult();
|
|
273
|
+
await tests_1.userEvents.click(tests_1.screen.getByText('New function'));
|
|
274
|
+
// 4 строки и 1 вложенная
|
|
275
|
+
(0, vitest_1.expect)(getRowDisabledSpy).toHaveBeenCalledTimes(5);
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
// Virtuoso отдаёт строкам новые данные на рендер позже родителя: состояние строки
|
|
279
|
+
// не должно приходить раньше данных и перерисовывать строку дважды
|
|
280
|
+
(0, vitest_1.describe)('Новые rows вместе с изменением состояния строки', () => {
|
|
281
|
+
const createVersionRows = (version) => TEST_ROWS.map((row) => ({ ...row, name: `${row.name} v${version}` }));
|
|
282
|
+
const setupRowsUpdate = () => {
|
|
283
|
+
const renderCellSpy = vitest_1.vi.fn((row) => row.name);
|
|
284
|
+
const TestComponent = () => {
|
|
285
|
+
const [version, setVersion] = (0, react_1.useState)(0);
|
|
286
|
+
const [isOptionsLocked, setOptionsLocked] = (0, react_1.useState)(false);
|
|
287
|
+
const [lockedId, setLockedId] = (0, react_1.useState)();
|
|
288
|
+
const [selectedRows, setSelectedRows] = (0, react_1.useState)([]);
|
|
289
|
+
const columns = (0, react_1.useMemo)(() => createColumns(renderCellSpy), []);
|
|
290
|
+
const versionRows = (0, react_1.useMemo)(() => createVersionRows(version), [version]);
|
|
291
|
+
// Заново создаётся только заблокированная строка, остальные сохраняют ссылки
|
|
292
|
+
const rows = (0, react_1.useMemo)(() => versionRows.map((row) => isOptionsLocked && row.id === '2'
|
|
293
|
+
? { ...row, options: { isDisabled: true } }
|
|
294
|
+
: row), [versionRows, isOptionsLocked]);
|
|
295
|
+
const getRowDisabled = (0, react_1.useCallback)((row) => (row.id === lockedId ? ROW_DISABLED : undefined), [lockedId]);
|
|
296
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => setOptionsLocked(true), children: "Lock via options" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => {
|
|
297
|
+
setVersion(1);
|
|
298
|
+
setSelectedRows([TEST_ROWS[1]]);
|
|
299
|
+
}, children: "Refetch and select" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => {
|
|
300
|
+
setVersion(1);
|
|
301
|
+
setLockedId('2');
|
|
302
|
+
}, children: "Refetch and lock" }), renderGrid({
|
|
303
|
+
rows,
|
|
304
|
+
columns,
|
|
305
|
+
selectedRows,
|
|
306
|
+
onSelectRow: setSelectedRows,
|
|
307
|
+
getRowDisabled,
|
|
308
|
+
onRetry: () => { },
|
|
309
|
+
})] }));
|
|
310
|
+
};
|
|
311
|
+
render((0, jsx_runtime_1.jsx)(TestComponent, {}));
|
|
312
|
+
renderCellSpy.mockClear();
|
|
313
|
+
return { renderCellSpy };
|
|
314
|
+
};
|
|
315
|
+
(0, vitest_1.it)('Строка перерисовывается один раз при блокировке через options', async () => {
|
|
316
|
+
const { renderCellSpy } = setupRowsUpdate();
|
|
317
|
+
await tests_1.userEvents.click(tests_1.screen.getByText('Lock via options'));
|
|
318
|
+
(0, vitest_1.expect)(getRenderCounts(renderCellSpy, ['1', '2', '3'])).toEqual({
|
|
319
|
+
'1': 0,
|
|
320
|
+
'2': 1,
|
|
321
|
+
'3': 0,
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
vitest_1.it.each([
|
|
325
|
+
{ condition: 'изменении выбора', action: 'Refetch and select' },
|
|
326
|
+
{
|
|
327
|
+
condition: 'блокировке через getRowDisabled',
|
|
328
|
+
action: 'Refetch and lock',
|
|
329
|
+
},
|
|
330
|
+
])('Строки перерисовываются один раз и сразу с новыми данными при $condition', async ({ action }) => {
|
|
331
|
+
const { renderCellSpy } = setupRowsUpdate();
|
|
332
|
+
await tests_1.userEvents.click(tests_1.screen.getByText(action));
|
|
333
|
+
(0, vitest_1.expect)(renderCellSpy.mock.calls.map(([row]) => row.name)).toEqual(['Vasya v1', 'Petya v1', 'Ivan v1']);
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
});
|
|
105
337
|
};
|
|
106
338
|
exports.testDataGridPerformance = testDataGridPerformance;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type RenderResult } from '@ui/dev/tests';
|
|
2
|
+
import { type ReactElement } from 'react';
|
|
3
|
+
import { type DataGridProps } from '../../types';
|
|
4
|
+
type DataItem = {
|
|
5
|
+
id: string | number;
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
type GridRenderProps = Pick<DataGridProps<DataItem>, 'rows' | 'columns' | 'selectedRows' | 'onSelectRow' | 'getRowDisabled' | 'onRowClick' | 'variant' | 'tree' | 'onRetry'>;
|
|
9
|
+
type TestDataGridSelectionParams = {
|
|
10
|
+
render: (ui: ReactElement) => Pick<RenderResult, 'rerender'>;
|
|
11
|
+
renderGrid: (props: GridRenderProps) => ReactElement;
|
|
12
|
+
};
|
|
13
|
+
export declare const testDataGridSelection: ({ render, renderGrid, }: TestDataGridSelectionParams) => void;
|
|
14
|
+
export {};
|