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