@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.
- 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/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/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -4,13 +4,13 @@ exports.useLogic = void 0;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const constants_1 = require("../../DataGrid/constants");
|
|
6
6
|
const enums_1 = require("../../DataGrid/enums");
|
|
7
|
-
const hooks_1 = require("../../DataGrid/
|
|
7
|
+
const hooks_1 = require("../../DataGrid/hooks");
|
|
8
|
+
const hooks_2 = require("../../DataGrid/useLogic/hooks");
|
|
8
9
|
const utils_1 = require("../../DataGrid/utils");
|
|
9
10
|
const useViewportType_1 = require("../../useViewportType");
|
|
10
|
-
const prop_1 = require("../../utils/prop");
|
|
11
11
|
const uniqueBy_1 = require("../../utils/uniqueBy");
|
|
12
12
|
const constants_2 = require("../constants");
|
|
13
|
-
const useLogic = ({ keyId, columns, rows, variant, tree, subrows, selectedRows = [], maxHeight, isLoading, isError, isDisabled, isEndReached, endOfScrollMsg, onRetry, onEndReached, onStartReached, isStartReached, onSelectRow, isHideSelectAll, initialVisibleItemIndex, isHideHeaderIfNoData = false, gridViewMode: gridViewModeProp = 'standard', massActions, mobileDisplayVariant = variant === 'subrows' ? 'cards' : 'list', virtuosoRef, }) => {
|
|
13
|
+
const useLogic = ({ keyId, columns, rows, variant, tree, subrows, selectedRows = [], maxHeight, isLoading, isError, isDisabled, getRowDisabled, isEndReached, endOfScrollMsg, onRetry, onEndReached, onStartReached, isStartReached, onSelectRow, isHideSelectAll, initialVisibleItemIndex, isHideHeaderIfNoData = false, gridViewMode: gridViewModeProp = 'standard', massActions, mobileDisplayVariant = variant === 'subrows' ? 'cards' : 'list', virtuosoRef, }) => {
|
|
14
14
|
const virtuoso = (0, react_1.useRef)(null);
|
|
15
15
|
const handleVirtuosoRef = (0, react_1.useCallback)((node) => {
|
|
16
16
|
virtuoso.current = node;
|
|
@@ -69,7 +69,16 @@ const useLogic = ({ keyId, columns, rows, variant, tree, subrows, selectedRows =
|
|
|
69
69
|
}
|
|
70
70
|
return config;
|
|
71
71
|
}, [variant, subrows, tree, isMobile]);
|
|
72
|
-
|
|
72
|
+
// Блокировки строк: getRowDisabled вызывается один раз на строку
|
|
73
|
+
const { rowsDisabled, idsWithoutReason } = (0, react_1.useMemo)(() => (0, utils_1.resolveRowsDisabled)(rows, keyId, getRowDisabled), [rows, keyId, getRowDisabled]);
|
|
74
|
+
(0, hooks_1.useWarnRowsWithoutDisabledReason)(idsWithoutReason);
|
|
75
|
+
const selectedIds = (0, react_1.useMemo)(() => new Set(selectedRows.map((row) => row[keyId])), [selectedRows, keyId]);
|
|
76
|
+
const itemContext = (0, react_1.useMemo)(() => ({
|
|
77
|
+
selectedIds,
|
|
78
|
+
rowsDisabled,
|
|
79
|
+
getRowDisabled: getRowDisabled,
|
|
80
|
+
}), [selectedIds, rowsDisabled, getRowDisabled]);
|
|
81
|
+
const availableRows = (0, react_1.useMemo)(() => rows.filter((row) => !row.options?.isNotSelectable && !rowsDisabled.get(row[keyId])), [rows, rowsDisabled, keyId]);
|
|
73
82
|
const flattenColumns = (0, react_1.useMemo)(() => (0, utils_1.getFlattenColumns)(columns), [columns]);
|
|
74
83
|
const hasGroupedColumns = columns.some(utils_1.isGroupColumns);
|
|
75
84
|
const gridViewMode = hasGroupedColumns ? 'full' : gridViewModeProp;
|
|
@@ -84,9 +93,7 @@ const useLogic = ({ keyId, columns, rows, variant, tree, subrows, selectedRows =
|
|
|
84
93
|
onStartReached();
|
|
85
94
|
}
|
|
86
95
|
}, [isStartReached, onStartReached]);
|
|
87
|
-
const uncheckedRowsCount = (0, react_1.useMemo)(() =>
|
|
88
|
-
return availableRows.filter((row) => !selectedRows.find((selectedRow) => selectedRow[keyId] === row[keyId])).length;
|
|
89
|
-
}, [availableRows, selectedRows, keyId]);
|
|
96
|
+
const uncheckedRowsCount = (0, react_1.useMemo)(() => availableRows.filter((row) => !selectedIds.has(row[keyId])).length, [availableRows, selectedIds, keyId]);
|
|
90
97
|
const handleRangeChanged = (0, react_1.useCallback)((range) => {
|
|
91
98
|
if (scrollToTopButtonRef.current) {
|
|
92
99
|
scrollToTopButtonRef.current.classList.toggle(constants_2.dataGridInfiniteClassnames.visibleScrollToTopButton, range.startIndex > baseIndex.current + 2);
|
|
@@ -97,11 +104,11 @@ const useLogic = ({ keyId, columns, rows, variant, tree, subrows, selectedRows =
|
|
|
97
104
|
return;
|
|
98
105
|
}
|
|
99
106
|
if (event.target.checked) {
|
|
100
|
-
const mergedSelectedRows = (0, uniqueBy_1.uniqueBy)([...
|
|
107
|
+
const mergedSelectedRows = (0, uniqueBy_1.uniqueBy)([...selectedRowsRef.current, ...availableRows], (row) => row[keyId]);
|
|
101
108
|
return onSelectRow(mergedSelectedRows);
|
|
102
109
|
}
|
|
103
|
-
const
|
|
104
|
-
onSelectRow(
|
|
110
|
+
const rowsIds = new Set(rows.map((row) => row[keyId]));
|
|
111
|
+
onSelectRow(selectedRowsRef.current.filter((selectedRow) => !rowsIds.has(selectedRow[keyId])));
|
|
105
112
|
};
|
|
106
113
|
const handleSelectRow = (0, react_1.useCallback)((row) => (event) => {
|
|
107
114
|
if (!onSelectRow) {
|
|
@@ -118,12 +125,16 @@ const useLogic = ({ keyId, columns, rows, variant, tree, subrows, selectedRows =
|
|
|
118
125
|
const recalculateVerticalScroll = (listHeight) => {
|
|
119
126
|
const container = document.getElementById(constants_2.VIRTUOSO_CONTAINER_ID);
|
|
120
127
|
if (container) {
|
|
121
|
-
|
|
122
|
-
|
|
128
|
+
// listHeight включает header и footer
|
|
129
|
+
const getHeight = (className) => container.querySelector(`.${className}`)?.clientHeight ?? 0;
|
|
130
|
+
const rowsHeight = listHeight -
|
|
131
|
+
getHeight(constants_2.dataGridInfiniteClassnames.header) -
|
|
132
|
+
getHeight(constants_2.dataGridInfiniteClassnames.footer);
|
|
133
|
+
setHasVerticalScroll(rowsHeight > container.clientHeight);
|
|
123
134
|
}
|
|
124
135
|
};
|
|
125
136
|
const isHideHead = isHideHeaderIfNoData && rows.length === 0;
|
|
126
|
-
const { mobileSkeletonProps } = (0,
|
|
137
|
+
const { mobileSkeletonProps } = (0, hooks_2.useDataGridMobileLogic)({
|
|
127
138
|
columns: flattenColumns,
|
|
128
139
|
mobileDisplayVariant,
|
|
129
140
|
});
|
|
@@ -155,8 +166,9 @@ const useLogic = ({ keyId, columns, rows, variant, tree, subrows, selectedRows =
|
|
|
155
166
|
onRetry,
|
|
156
167
|
hasMassActions,
|
|
157
168
|
]);
|
|
169
|
+
const virtuosoContext = (0, react_1.useMemo)(() => ({ ...itemContext, ...footerContext }), [itemContext, footerContext]);
|
|
158
170
|
return {
|
|
159
|
-
|
|
171
|
+
virtuosoContext,
|
|
160
172
|
hasMassActions,
|
|
161
173
|
isMassActionsOpen,
|
|
162
174
|
containerCssVars,
|
|
@@ -131,7 +131,7 @@ export * from './MenuItem';
|
|
|
131
131
|
export * from './MenuList';
|
|
132
132
|
export { MinimalisticPagination, type MinimalisticPaginationProps, } from './MinimalisticPagination';
|
|
133
133
|
export * from './NavMenu';
|
|
134
|
-
export { type DataGridColumns, type DataGridRenderLink, type DataGridRenderLinkParams, type DataGridRow, type DataGridRowOptions, type DataGridSort, DataGrid, type DataGridProps, } from './DataGrid';
|
|
134
|
+
export { type DataGridColumns, type DataGridRenderLink, type DataGridRenderLinkParams, type DataGridRow, type DataGridRowDisabled, type DataGridRowOptions, type DataGridSort, DataGrid, type DataGridProps, } from './DataGrid';
|
|
135
135
|
export { DataGridInfinite, type DataGridInfiniteProps, } from './DataGridInfinite';
|
|
136
136
|
export { DataGridColumnHintIcon, type DataGridColumnHintIconProps, } from './DataGridColumnHintIcon';
|
|
137
137
|
export { type DateItemProps, type DateRangePickerProps, type DateRangePickerValue, DateRangePicker, } from './DateRangePicker';
|