@astral/ui 4.68.1 → 4.69.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/DataGrid.js +1 -2
- package/components/DataGrid/Row/Row.js +5 -2
- package/components/DataGrid/Row/constants.d.ts +1 -0
- package/components/DataGrid/Row/constants.js +1 -0
- package/components/DataGrid/Row/styles.js +23 -11
- package/components/DataGrid/Row/useLogic/useLogic.d.ts +2 -1
- package/components/DataGrid/Row/useLogic/useLogic.js +3 -1
- package/components/DataGrid/types.d.ts +0 -3
- package/components/DataGridInfinite/DataGridInfinite.js +2 -2
- package/node/components/DataGrid/DataGrid.js +1 -2
- package/node/components/DataGrid/Row/Row.js +5 -2
- package/node/components/DataGrid/Row/constants.d.ts +1 -0
- package/node/components/DataGrid/Row/constants.js +1 -0
- package/node/components/DataGrid/Row/styles.js +23 -11
- package/node/components/DataGrid/Row/useLogic/useLogic.d.ts +2 -1
- package/node/components/DataGrid/Row/useLogic/useLogic.js +3 -1
- package/node/components/DataGrid/types.d.ts +0 -3
- package/node/components/DataGridInfinite/DataGridInfinite.js +2 -2
- package/package.json +1 -1
|
@@ -64,7 +64,6 @@ export const DataGrid = (props) => {
|
|
|
64
64
|
}, [noDataPlaceholder, noDataOptions, isLoading]);
|
|
65
65
|
const commonBodyProps = {
|
|
66
66
|
...bodyProps,
|
|
67
|
-
activeRowId,
|
|
68
67
|
keyId,
|
|
69
68
|
selectedRows,
|
|
70
69
|
minDisplayRows,
|
|
@@ -82,7 +81,7 @@ export const DataGrid = (props) => {
|
|
|
82
81
|
};
|
|
83
82
|
const renderTableContent = () => {
|
|
84
83
|
if (!hasPinnedColumns || isMobile) {
|
|
85
|
-
return (_jsxs(Wrapper, { ...getInertProps(isDataGridDisabled), className: dataGridClassnames.wrapper, children: [headPreAddon, !isHideHead && (_jsx(Head, { ...headProps, columns: headColumns, gridColumns: gridColumns })), _jsx(ContentState, { ...contentStateProps, loadingContent: isMobile && _jsx(MobileSkeleton, { ...mobileSkeletonProps }), children: _jsx(Body, { ...commonBodyProps, columns: columns, gridColumns: gridColumns, className: bodyCva({
|
|
84
|
+
return (_jsxs(Wrapper, { ...getInertProps(isDataGridDisabled), className: dataGridClassnames.wrapper, children: [headPreAddon, !isHideHead && (_jsx(Head, { ...headProps, columns: headColumns, gridColumns: gridColumns })), _jsx(ContentState, { ...contentStateProps, loadingContent: isMobile && _jsx(MobileSkeleton, { ...mobileSkeletonProps }), children: _jsx(Body, { ...commonBodyProps, activeRowId: activeRowId, columns: columns, gridColumns: gridColumns, className: bodyCva({
|
|
86
85
|
isNoData,
|
|
87
86
|
}) }) })] }));
|
|
88
87
|
}
|
|
@@ -26,6 +26,9 @@ const rowContentCva = cva(dataGridRowContentClassnames.root, {
|
|
|
26
26
|
isHovered: {
|
|
27
27
|
true: dataGridRowContentClassnames.hovered,
|
|
28
28
|
},
|
|
29
|
+
isActive: {
|
|
30
|
+
true: dataGridRowContentClassnames.active,
|
|
31
|
+
},
|
|
29
32
|
},
|
|
30
33
|
});
|
|
31
34
|
const groupedColumnLabelCva = cva(dataGridGroupedColumnLabelClassnames.root, {
|
|
@@ -36,7 +39,7 @@ const groupedColumnLabelCva = cva(dataGridGroupedColumnLabelClassnames.root, {
|
|
|
36
39
|
},
|
|
37
40
|
});
|
|
38
41
|
const RowComponent = (props) => {
|
|
39
|
-
const { isOpen, isShowConnector, childrenColumns, rowId, handleToggle, checkboxProps, rowProps, isHovered, tooltipProps, nestedChildrenProps, disabled, isRenderCollapseButton, rowRef, rowStyles, drawerProps, disabledReasonText, } = useLogic(props);
|
|
42
|
+
const { isOpen, isShowConnector, childrenColumns, rowId, handleToggle, checkboxProps, rowProps, isHovered, tooltipProps, nestedChildrenProps, disabled, isRenderCollapseButton, rowRef, rowStyles, drawerProps, disabledReasonText, isActive, } = useLogic(props);
|
|
40
43
|
const { className, row, options, variant, isSelectable, gridColumns, isInitialExpanded, expandedLevel, level, nestedChildren, initialVisibleChildrenCount, moreButtonColumnPosition, isVisibleCollapseButton, columns, emptyCellValue, selectedRows, activeRowId, keyId, onSelectRow, onRowClick, sectionOffset, totalColumnsCount, registerRowElement, unregisterRowElement, onRowEnter, onRowLeave, style,
|
|
41
44
|
// В этот rest-оператор попадают специфичные пропсы (атрибуты) virtuoso
|
|
42
45
|
// Необходимы для DataGridInfinite
|
|
@@ -99,7 +102,7 @@ const RowComponent = (props) => {
|
|
|
99
102
|
onRowEnter,
|
|
100
103
|
onRowLeave,
|
|
101
104
|
]);
|
|
102
|
-
return (_jsxs(Wrapper, { className: classNames(className, rootCva({ isShowConnector })), style: rowStyles, ...selfProps, 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 }), "$gridColumns": gridColumns, [DISABLE_ROW_ATTR]: disabled, ...rowProps, children: renderCells() }) }), _jsx(NestedChildren, { ...nestedChildrenProps, data: nestedChildren, keyId: keyId, level: level, variant: variant, gridColumns: gridColumns, initialVisibleChildrenCount: initialVisibleChildrenCount, moreButtonColumnPosition: moreButtonColumnPosition,
|
|
105
|
+
return (_jsxs(Wrapper, { className: classNames(className, rootCva({ isShowConnector })), style: rowStyles, ...selfProps, 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]: disabled, ...rowProps, children: renderCells() }) }), _jsx(NestedChildren, { ...nestedChildrenProps, data: nestedChildren, keyId: keyId, level: level, variant: variant, gridColumns: gridColumns, initialVisibleChildrenCount: initialVisibleChildrenCount, moreButtonColumnPosition: moreButtonColumnPosition,
|
|
103
106
|
// biome-ignore lint/suspicious/noTsIgnore: <>
|
|
104
107
|
// @ts-ignore
|
|
105
108
|
renderRow: renderRow }), _jsx(BottomDrawer, { ...drawerProps, children: _jsx(BottomDrawerContent, { children: disabledReasonText }) })] }));
|
|
@@ -12,6 +12,7 @@ export const dataGridRowClassnames = {
|
|
|
12
12
|
export const dataGridRowContentClassnames = {
|
|
13
13
|
root: createUIKitClassname('data-grid__row-content'),
|
|
14
14
|
hovered: createUIKitClassname('data-grid__row-content_hovered'),
|
|
15
|
+
active: createUIKitClassname('data-grid__row-content_active'),
|
|
15
16
|
};
|
|
16
17
|
export const dataGridRowCellClassnames = {
|
|
17
18
|
single: createUIKitClassname('data-grid__row-cell_single'),
|
|
@@ -74,35 +74,47 @@ export const ContentWrapper = styled.div `
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
&.${dataGridRowContentClassnames.active} {
|
|
78
|
+
background-color: ${({ theme }) => theme.palette.primary[100]};
|
|
79
|
+
}
|
|
80
|
+
|
|
77
81
|
&:hover {
|
|
78
82
|
background-color: ${({ theme }) => theme.palette.background.elementHover};
|
|
79
|
-
&.${dataGridRowContentClassnames.hovered} {
|
|
80
|
-
cursor: pointer;
|
|
81
|
-
}
|
|
82
83
|
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
&.${dataGridRowContentClassnames.active} {
|
|
85
|
+
background-color: ${({ theme }) => theme.palette.primary[100]};
|
|
86
|
+
}
|
|
85
87
|
|
|
86
|
-
|
|
88
|
+
&.${dataGridRowContentClassnames.hovered} {
|
|
89
|
+
cursor: pointer;
|
|
87
90
|
}
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
|
|
91
94
|
&.${dataGridRowClassnames.hover} {
|
|
92
95
|
background-color: ${({ theme }) => theme.palette.background.elementHover};
|
|
96
|
+
|
|
93
97
|
&.${dataGridRowContentClassnames.hovered} {
|
|
94
98
|
cursor: pointer;
|
|
95
99
|
}
|
|
100
|
+
}
|
|
96
101
|
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
103
|
+
grid-template-columns: 1fr;
|
|
99
104
|
|
|
105
|
+
&.${dataGridRowContentClassnames.active} {
|
|
100
106
|
background-color: transparent;
|
|
101
107
|
}
|
|
102
|
-
}
|
|
103
108
|
|
|
104
|
-
|
|
105
|
-
|
|
109
|
+
&:hover, &.${dataGridRowClassnames.hover} {
|
|
110
|
+
cursor: initial;
|
|
111
|
+
|
|
112
|
+
background-color: transparent;
|
|
113
|
+
|
|
114
|
+
&.${dataGridRowContentClassnames.active} {
|
|
115
|
+
background-color: transparent;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
106
118
|
}
|
|
107
119
|
`;
|
|
108
120
|
export const CellStyled = styled(Cell) `
|
|
@@ -2,7 +2,7 @@ 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, selectedRows, onSelectRow, onRowClick, isVisibleCollapseButton, registerRowElement, unregisterRowElement, style, }: UseLogicParams<TData>) => {
|
|
5
|
+
export declare const useLogic: <TData extends Record<string, unknown>>({ keyId, columns, row, nestedChildren, level, variant, options, isInitialExpanded, expandedLevel, isSelectable, selectedRows, onSelectRow, onRowClick, isVisibleCollapseButton, registerRowElement, unregisterRowElement, style, activeRowId, }: UseLogicParams<TData>) => {
|
|
6
6
|
disabledReasonText: string | undefined;
|
|
7
7
|
rowStyles: {
|
|
8
8
|
accentColor?: import("csstype").Property.AccentColor | undefined;
|
|
@@ -873,6 +873,7 @@ export declare const useLogic: <TData extends Record<string, unknown>>({ keyId,
|
|
|
873
873
|
isRenderCollapseButton: boolean;
|
|
874
874
|
handleToggle: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
875
875
|
isHovered: boolean;
|
|
876
|
+
isActive: boolean;
|
|
876
877
|
rowProps: {
|
|
877
878
|
onClick: () => void;
|
|
878
879
|
onMouseMove: (event: MouseEvent<HTMLElement>) => void;
|
|
@@ -6,7 +6,7 @@ import { DISABLE_ROW_ATTR } from '../constants';
|
|
|
6
6
|
import { RowContext } from '../RowContext';
|
|
7
7
|
import { useMobileLogic } from './hooks';
|
|
8
8
|
import { mergeColumnsOptions } from './utils';
|
|
9
|
-
export const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options, isInitialExpanded = false, expandedLevel, isSelectable, selectedRows, onSelectRow, onRowClick, isVisibleCollapseButton, registerRowElement, unregisterRowElement, style, }) => {
|
|
9
|
+
export const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options, isInitialExpanded = false, expandedLevel, isSelectable, selectedRows, onSelectRow, onRowClick, isVisibleCollapseButton, registerRowElement, unregisterRowElement, style, activeRowId, }) => {
|
|
10
10
|
const { isDrawerOpen, handleOpenDrawer, handleCloseDrawer } = useMobileLogic();
|
|
11
11
|
const isDefaultExpanded = isInitialExpanded && level <= expandedLevel - 1 && nestedChildren?.length;
|
|
12
12
|
const { checkIsOpened, toggleOpenItems } = useContext(DataGridContext);
|
|
@@ -75,6 +75,7 @@ export const useLogic = ({ keyId, columns, row, nestedChildren, level, variant,
|
|
|
75
75
|
...style,
|
|
76
76
|
}), [level, style]);
|
|
77
77
|
const isHovered = Boolean(!disabled && (onRowClick || href));
|
|
78
|
+
const isActive = activeRowId === rowId;
|
|
78
79
|
const disabledReasonText = externalDisabledReason || disabledReason;
|
|
79
80
|
return {
|
|
80
81
|
disabledReasonText,
|
|
@@ -88,6 +89,7 @@ export const useLogic = ({ keyId, columns, row, nestedChildren, level, variant,
|
|
|
88
89
|
isRenderCollapseButton,
|
|
89
90
|
handleToggle,
|
|
90
91
|
isHovered,
|
|
92
|
+
isActive,
|
|
91
93
|
rowProps: {
|
|
92
94
|
onClick: handleRowClick,
|
|
93
95
|
onMouseMove: handleMouseMove,
|
|
@@ -27,9 +27,6 @@ export type DataGridProps<TData extends Record<string, CellValue> = DataGridRow,
|
|
|
27
27
|
columns: DataGridColumns<TData>[];
|
|
28
28
|
/**
|
|
29
29
|
* Идентификатор активного элемента массива rows. Выделяет активную строку в таблице
|
|
30
|
-
*
|
|
31
|
-
* @deprecated Не поддерживается, параметр будет удален в следующей major версии пакета.
|
|
32
|
-
* Мотивация: Использование активного элемента не является типичным сценарием использования таблицы.
|
|
33
30
|
*/
|
|
34
31
|
activeRowId?: string;
|
|
35
32
|
/**
|
|
@@ -36,7 +36,7 @@ const dataGridInfiniteCva = cva(dataGridClassnames.root, {
|
|
|
36
36
|
export const DataGridInfinite = (props) => {
|
|
37
37
|
const { imagesMap, emptySymbol } = useContext(ConfigContext);
|
|
38
38
|
const { isNoData, isDataGridDisabled, treeRenderConfig, virtuosoProps, headProps, rowProps, scrollToTopButtonProps, isEndReached, isHideHead, containerCssVars, isMobile, mobileSkeletonProps, flattenColumns, hasGroupedColumns, gridViewMode, } = useLogic(props);
|
|
39
|
-
const { columns, rows = [], selectedRows = [], sorting, isLoading, isDisabled, keyId, emptyCellValue = emptySymbol, variant = Variant.Tree, subrows, className, isError, endOfScrollMsg, errorMsg, noDataPlaceholder, onRowClick, onSort, onRetry, headPreAddon, } = props;
|
|
39
|
+
const { columns, rows = [], selectedRows = [], sorting, isLoading, isDisabled, keyId, emptyCellValue = emptySymbol, variant = Variant.Tree, subrows, className, isError, endOfScrollMsg, errorMsg, noDataPlaceholder, onRowClick, onSort, onRetry, headPreAddon, activeRowId, } = props;
|
|
40
40
|
const { moreButtonColumnPosition = 1, isVisibleCollapseButton = true } = subrows || {};
|
|
41
41
|
const { isInitialExpanded = false, expandedLevel = EXPANDED_LEVEL_BY_DEFAULT, initialVisibleChildrenCount = INITIAL_OPENED_NESTED_CHILDREN_COUNT_BY_DEFAULT, } = treeRenderConfig || {};
|
|
42
42
|
const TableContainer = isDisabled ? DisabledDataGridWrapper : DataGridWrapper;
|
|
@@ -51,7 +51,7 @@ export const DataGridInfinite = (props) => {
|
|
|
51
51
|
List,
|
|
52
52
|
Item: ({ children, item, ...itemProps }) => {
|
|
53
53
|
const { children: nestedChildren, options, ...row } = item;
|
|
54
|
-
return (_jsx(RowContextProvider, { children: _jsx(Row, { ...rowProps, ...itemProps, row: row, columns: flattenColumns, selectedRows: selectedRows, options: options, keyId: keyId, variant: variant, level: INITIAL_LEVEL, nestedChildren: nestedChildren, isInitialExpanded: isInitialExpanded, expandedLevel: expandedLevel, initialVisibleChildrenCount: initialVisibleChildrenCount, moreButtonColumnPosition: moreButtonColumnPosition, isVisibleCollapseButton: isVisibleCollapseButton, emptyCellValue: emptyCellValue, onRowClick: onRowClick }) }));
|
|
54
|
+
return (_jsx(RowContextProvider, { children: _jsx(Row, { ...rowProps, ...itemProps, row: row, columns: flattenColumns, selectedRows: selectedRows, options: options, keyId: keyId, variant: variant, level: INITIAL_LEVEL, nestedChildren: nestedChildren, isInitialExpanded: isInitialExpanded, expandedLevel: expandedLevel, initialVisibleChildrenCount: initialVisibleChildrenCount, activeRowId: activeRowId, moreButtonColumnPosition: moreButtonColumnPosition, isVisibleCollapseButton: isVisibleCollapseButton, emptyCellValue: emptyCellValue, onRowClick: onRowClick }) }));
|
|
55
55
|
},
|
|
56
56
|
EmptyPlaceholder: () => _jsx(_Fragment, { children: noDataPlaceholder || _jsx(NoData, {}) }),
|
|
57
57
|
Footer: () => {
|
|
@@ -67,7 +67,6 @@ const DataGrid = (props) => {
|
|
|
67
67
|
}, [noDataPlaceholder, noDataOptions, isLoading]);
|
|
68
68
|
const commonBodyProps = {
|
|
69
69
|
...bodyProps,
|
|
70
|
-
activeRowId,
|
|
71
70
|
keyId,
|
|
72
71
|
selectedRows,
|
|
73
72
|
minDisplayRows,
|
|
@@ -85,7 +84,7 @@ const DataGrid = (props) => {
|
|
|
85
84
|
};
|
|
86
85
|
const renderTableContent = () => {
|
|
87
86
|
if (!hasPinnedColumns || isMobile) {
|
|
88
|
-
return ((0, jsx_runtime_1.jsxs)(Wrapper, { ...(0, getInertProps_1.getInertProps)(isDataGridDisabled), className: constants_1.dataGridClassnames.wrapper, children: [headPreAddon, !isHideHead && ((0, jsx_runtime_1.jsx)(Head_1.Head, { ...headProps, columns: headColumns, gridColumns: gridColumns })), (0, jsx_runtime_1.jsx)(ContentState_1.ContentState, { ...contentStateProps, loadingContent: isMobile && (0, jsx_runtime_1.jsx)(MobileSkeleton_1.MobileSkeleton, { ...mobileSkeletonProps }), children: (0, jsx_runtime_1.jsx)(Body_1.Body, { ...commonBodyProps, columns: columns, gridColumns: gridColumns, className: bodyCva({
|
|
87
|
+
return ((0, jsx_runtime_1.jsxs)(Wrapper, { ...(0, getInertProps_1.getInertProps)(isDataGridDisabled), className: constants_1.dataGridClassnames.wrapper, children: [headPreAddon, !isHideHead && ((0, jsx_runtime_1.jsx)(Head_1.Head, { ...headProps, columns: headColumns, gridColumns: gridColumns })), (0, jsx_runtime_1.jsx)(ContentState_1.ContentState, { ...contentStateProps, loadingContent: isMobile && (0, jsx_runtime_1.jsx)(MobileSkeleton_1.MobileSkeleton, { ...mobileSkeletonProps }), children: (0, jsx_runtime_1.jsx)(Body_1.Body, { ...commonBodyProps, activeRowId: activeRowId, columns: columns, gridColumns: gridColumns, className: bodyCva({
|
|
89
88
|
isNoData,
|
|
90
89
|
}) }) })] }));
|
|
91
90
|
}
|
|
@@ -29,6 +29,9 @@ const rowContentCva = (0, cva_1.cva)(constants_1.dataGridRowContentClassnames.ro
|
|
|
29
29
|
isHovered: {
|
|
30
30
|
true: constants_1.dataGridRowContentClassnames.hovered,
|
|
31
31
|
},
|
|
32
|
+
isActive: {
|
|
33
|
+
true: constants_1.dataGridRowContentClassnames.active,
|
|
34
|
+
},
|
|
32
35
|
},
|
|
33
36
|
});
|
|
34
37
|
const groupedColumnLabelCva = (0, cva_1.cva)(constants_1.dataGridGroupedColumnLabelClassnames.root, {
|
|
@@ -39,7 +42,7 @@ const groupedColumnLabelCva = (0, cva_1.cva)(constants_1.dataGridGroupedColumnLa
|
|
|
39
42
|
},
|
|
40
43
|
});
|
|
41
44
|
const RowComponent = (props) => {
|
|
42
|
-
const { isOpen, isShowConnector, childrenColumns, rowId, handleToggle, checkboxProps, rowProps, isHovered, tooltipProps, nestedChildrenProps, disabled, isRenderCollapseButton, rowRef, rowStyles, drawerProps, disabledReasonText, } = (0, useLogic_1.useLogic)(props);
|
|
45
|
+
const { isOpen, isShowConnector, childrenColumns, rowId, handleToggle, checkboxProps, rowProps, isHovered, tooltipProps, nestedChildrenProps, disabled, isRenderCollapseButton, rowRef, rowStyles, drawerProps, disabledReasonText, isActive, } = (0, useLogic_1.useLogic)(props);
|
|
43
46
|
const { className, row, options, variant, isSelectable, gridColumns, isInitialExpanded, expandedLevel, level, nestedChildren, initialVisibleChildrenCount, moreButtonColumnPosition, isVisibleCollapseButton, columns, emptyCellValue, selectedRows, activeRowId, keyId, onSelectRow, onRowClick, sectionOffset, totalColumnsCount, registerRowElement, unregisterRowElement, onRowEnter, onRowLeave, style,
|
|
44
47
|
// В этот rest-оператор попадают специфичные пропсы (атрибуты) virtuoso
|
|
45
48
|
// Необходимы для DataGridInfinite
|
|
@@ -102,7 +105,7 @@ const RowComponent = (props) => {
|
|
|
102
105
|
onRowEnter,
|
|
103
106
|
onRowLeave,
|
|
104
107
|
]);
|
|
105
|
-
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { className: (0, classNames_1.classNames)(className, rootCva({ isShowConnector })), style: rowStyles, ...selfProps, children: [(0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { followCursor: true, arrow: false, ...tooltipProps, children: (0, jsx_runtime_1.jsx)(styles_1.ContentWrapper, { "data-row-id": rowId, ref: rowRef, onPointerEnter: () => onRowEnter?.(rowId), onPointerLeave: (event) => onRowLeave?.(rowId, event.nativeEvent), className: rowContentCva({ isHovered }), "$gridColumns": gridColumns, [constants_1.DISABLE_ROW_ATTR]: disabled, ...rowProps, children: renderCells() }) }), (0, jsx_runtime_1.jsx)(NestedChildren_1.NestedChildren, { ...nestedChildrenProps, data: nestedChildren, keyId: keyId, level: level, variant: variant, gridColumns: gridColumns, initialVisibleChildrenCount: initialVisibleChildrenCount, moreButtonColumnPosition: moreButtonColumnPosition,
|
|
108
|
+
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { className: (0, classNames_1.classNames)(className, rootCva({ isShowConnector })), style: rowStyles, ...selfProps, children: [(0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { followCursor: true, arrow: false, ...tooltipProps, children: (0, jsx_runtime_1.jsx)(styles_1.ContentWrapper, { "data-row-id": rowId, ref: rowRef, onPointerEnter: () => onRowEnter?.(rowId), onPointerLeave: (event) => onRowLeave?.(rowId, event.nativeEvent), className: rowContentCva({ isHovered, isActive }), "$gridColumns": gridColumns, [constants_1.DISABLE_ROW_ATTR]: disabled, ...rowProps, children: renderCells() }) }), (0, jsx_runtime_1.jsx)(NestedChildren_1.NestedChildren, { ...nestedChildrenProps, data: nestedChildren, keyId: keyId, level: level, variant: variant, gridColumns: gridColumns, initialVisibleChildrenCount: initialVisibleChildrenCount, moreButtonColumnPosition: moreButtonColumnPosition,
|
|
106
109
|
// biome-ignore lint/suspicious/noTsIgnore: <>
|
|
107
110
|
// @ts-ignore
|
|
108
111
|
renderRow: renderRow }), (0, jsx_runtime_1.jsx)(BottomDrawer_1.BottomDrawer, { ...drawerProps, children: (0, jsx_runtime_1.jsx)(styles_1.BottomDrawerContent, { children: disabledReasonText }) })] }));
|
|
@@ -15,6 +15,7 @@ exports.dataGridRowClassnames = {
|
|
|
15
15
|
exports.dataGridRowContentClassnames = {
|
|
16
16
|
root: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__row-content'),
|
|
17
17
|
hovered: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__row-content_hovered'),
|
|
18
|
+
active: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__row-content_active'),
|
|
18
19
|
};
|
|
19
20
|
exports.dataGridRowCellClassnames = {
|
|
20
21
|
single: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__row-cell_single'),
|
|
@@ -77,35 +77,47 @@ exports.ContentWrapper = styled_1.styled.div `
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
&.${constants_2.dataGridRowContentClassnames.active} {
|
|
81
|
+
background-color: ${({ theme }) => theme.palette.primary[100]};
|
|
82
|
+
}
|
|
83
|
+
|
|
80
84
|
&:hover {
|
|
81
85
|
background-color: ${({ theme }) => theme.palette.background.elementHover};
|
|
82
|
-
&.${constants_2.dataGridRowContentClassnames.hovered} {
|
|
83
|
-
cursor: pointer;
|
|
84
|
-
}
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
&.${constants_2.dataGridRowContentClassnames.active} {
|
|
88
|
+
background-color: ${({ theme }) => theme.palette.primary[100]};
|
|
89
|
+
}
|
|
88
90
|
|
|
89
|
-
|
|
91
|
+
&.${constants_2.dataGridRowContentClassnames.hovered} {
|
|
92
|
+
cursor: pointer;
|
|
90
93
|
}
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
|
|
94
97
|
&.${constants_2.dataGridRowClassnames.hover} {
|
|
95
98
|
background-color: ${({ theme }) => theme.palette.background.elementHover};
|
|
99
|
+
|
|
96
100
|
&.${constants_2.dataGridRowContentClassnames.hovered} {
|
|
97
101
|
cursor: pointer;
|
|
98
102
|
}
|
|
103
|
+
}
|
|
99
104
|
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
106
|
+
grid-template-columns: 1fr;
|
|
102
107
|
|
|
108
|
+
&.${constants_2.dataGridRowContentClassnames.active} {
|
|
103
109
|
background-color: transparent;
|
|
104
110
|
}
|
|
105
|
-
}
|
|
106
111
|
|
|
107
|
-
|
|
108
|
-
|
|
112
|
+
&:hover, &.${constants_2.dataGridRowClassnames.hover} {
|
|
113
|
+
cursor: initial;
|
|
114
|
+
|
|
115
|
+
background-color: transparent;
|
|
116
|
+
|
|
117
|
+
&.${constants_2.dataGridRowContentClassnames.active} {
|
|
118
|
+
background-color: transparent;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
109
121
|
}
|
|
110
122
|
`;
|
|
111
123
|
exports.CellStyled = (0, styled_1.styled)(Cell_1.Cell) `
|
|
@@ -2,7 +2,7 @@ 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, selectedRows, onSelectRow, onRowClick, isVisibleCollapseButton, registerRowElement, unregisterRowElement, style, }: UseLogicParams<TData>) => {
|
|
5
|
+
export declare const useLogic: <TData extends Record<string, unknown>>({ keyId, columns, row, nestedChildren, level, variant, options, isInitialExpanded, expandedLevel, isSelectable, selectedRows, onSelectRow, onRowClick, isVisibleCollapseButton, registerRowElement, unregisterRowElement, style, activeRowId, }: UseLogicParams<TData>) => {
|
|
6
6
|
disabledReasonText: string | undefined;
|
|
7
7
|
rowStyles: {
|
|
8
8
|
accentColor?: import("csstype").Property.AccentColor | undefined;
|
|
@@ -873,6 +873,7 @@ export declare const useLogic: <TData extends Record<string, unknown>>({ keyId,
|
|
|
873
873
|
isRenderCollapseButton: boolean;
|
|
874
874
|
handleToggle: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
875
875
|
isHovered: boolean;
|
|
876
|
+
isActive: boolean;
|
|
876
877
|
rowProps: {
|
|
877
878
|
onClick: () => void;
|
|
878
879
|
onMouseMove: (event: MouseEvent<HTMLElement>) => void;
|
|
@@ -9,7 +9,7 @@ const constants_1 = require("../constants");
|
|
|
9
9
|
const RowContext_1 = require("../RowContext");
|
|
10
10
|
const hooks_1 = require("./hooks");
|
|
11
11
|
const utils_1 = require("./utils");
|
|
12
|
-
const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options, isInitialExpanded = false, expandedLevel, isSelectable, selectedRows, onSelectRow, onRowClick, isVisibleCollapseButton, registerRowElement, unregisterRowElement, style, }) => {
|
|
12
|
+
const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options, isInitialExpanded = false, expandedLevel, isSelectable, selectedRows, onSelectRow, onRowClick, isVisibleCollapseButton, registerRowElement, unregisterRowElement, style, activeRowId, }) => {
|
|
13
13
|
const { isDrawerOpen, handleOpenDrawer, handleCloseDrawer } = (0, hooks_1.useMobileLogic)();
|
|
14
14
|
const isDefaultExpanded = isInitialExpanded && level <= expandedLevel - 1 && nestedChildren?.length;
|
|
15
15
|
const { checkIsOpened, toggleOpenItems } = (0, react_1.useContext)(DataGridContext_1.DataGridContext);
|
|
@@ -78,6 +78,7 @@ const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options
|
|
|
78
78
|
...style,
|
|
79
79
|
}), [level, style]);
|
|
80
80
|
const isHovered = Boolean(!disabled && (onRowClick || href));
|
|
81
|
+
const isActive = activeRowId === rowId;
|
|
81
82
|
const disabledReasonText = externalDisabledReason || disabledReason;
|
|
82
83
|
return {
|
|
83
84
|
disabledReasonText,
|
|
@@ -91,6 +92,7 @@ const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options
|
|
|
91
92
|
isRenderCollapseButton,
|
|
92
93
|
handleToggle,
|
|
93
94
|
isHovered,
|
|
95
|
+
isActive,
|
|
94
96
|
rowProps: {
|
|
95
97
|
onClick: handleRowClick,
|
|
96
98
|
onMouseMove: handleMouseMove,
|
|
@@ -27,9 +27,6 @@ export type DataGridProps<TData extends Record<string, CellValue> = DataGridRow,
|
|
|
27
27
|
columns: DataGridColumns<TData>[];
|
|
28
28
|
/**
|
|
29
29
|
* Идентификатор активного элемента массива rows. Выделяет активную строку в таблице
|
|
30
|
-
*
|
|
31
|
-
* @deprecated Не поддерживается, параметр будет удален в следующей major версии пакета.
|
|
32
|
-
* Мотивация: Использование активного элемента не является типичным сценарием использования таблицы.
|
|
33
30
|
*/
|
|
34
31
|
activeRowId?: string;
|
|
35
32
|
/**
|
|
@@ -39,7 +39,7 @@ const dataGridInfiniteCva = (0, cva_1.cva)(constants_1.dataGridClassnames.root,
|
|
|
39
39
|
const DataGridInfinite = (props) => {
|
|
40
40
|
const { imagesMap, emptySymbol } = (0, react_1.useContext)(ConfigProvider_1.ConfigContext);
|
|
41
41
|
const { isNoData, isDataGridDisabled, treeRenderConfig, virtuosoProps, headProps, rowProps, scrollToTopButtonProps, isEndReached, isHideHead, containerCssVars, isMobile, mobileSkeletonProps, flattenColumns, hasGroupedColumns, gridViewMode, } = (0, useLogic_1.useLogic)(props);
|
|
42
|
-
const { columns, rows = [], selectedRows = [], sorting, isLoading, isDisabled, keyId, emptyCellValue = emptySymbol, variant = enums_1.Variant.Tree, subrows, className, isError, endOfScrollMsg, errorMsg, noDataPlaceholder, onRowClick, onSort, onRetry, headPreAddon, } = props;
|
|
42
|
+
const { columns, rows = [], selectedRows = [], sorting, isLoading, isDisabled, keyId, emptyCellValue = emptySymbol, variant = enums_1.Variant.Tree, subrows, className, isError, endOfScrollMsg, errorMsg, noDataPlaceholder, onRowClick, onSort, onRetry, headPreAddon, activeRowId, } = props;
|
|
43
43
|
const { moreButtonColumnPosition = 1, isVisibleCollapseButton = true } = subrows || {};
|
|
44
44
|
const { isInitialExpanded = false, expandedLevel = constants_1.EXPANDED_LEVEL_BY_DEFAULT, initialVisibleChildrenCount = constants_1.INITIAL_OPENED_NESTED_CHILDREN_COUNT_BY_DEFAULT, } = treeRenderConfig || {};
|
|
45
45
|
const TableContainer = isDisabled ? styles_2.DisabledDataGridWrapper : styles_2.DataGridWrapper;
|
|
@@ -54,7 +54,7 @@ const DataGridInfinite = (props) => {
|
|
|
54
54
|
List: List_1.List,
|
|
55
55
|
Item: ({ children, item, ...itemProps }) => {
|
|
56
56
|
const { children: nestedChildren, options, ...row } = item;
|
|
57
|
-
return ((0, jsx_runtime_1.jsx)(Row_1.RowContextProvider, { children: (0, jsx_runtime_1.jsx)(Row_1.Row, { ...rowProps, ...itemProps, row: row, columns: flattenColumns, selectedRows: selectedRows, options: options, keyId: keyId, variant: variant, level: INITIAL_LEVEL, nestedChildren: nestedChildren, isInitialExpanded: isInitialExpanded, expandedLevel: expandedLevel, initialVisibleChildrenCount: initialVisibleChildrenCount, moreButtonColumnPosition: moreButtonColumnPosition, isVisibleCollapseButton: isVisibleCollapseButton, emptyCellValue: emptyCellValue, onRowClick: onRowClick }) }));
|
|
57
|
+
return ((0, jsx_runtime_1.jsx)(Row_1.RowContextProvider, { children: (0, jsx_runtime_1.jsx)(Row_1.Row, { ...rowProps, ...itemProps, row: row, columns: flattenColumns, selectedRows: selectedRows, options: options, keyId: keyId, variant: variant, level: INITIAL_LEVEL, nestedChildren: nestedChildren, isInitialExpanded: isInitialExpanded, expandedLevel: expandedLevel, initialVisibleChildrenCount: initialVisibleChildrenCount, activeRowId: activeRowId, moreButtonColumnPosition: moreButtonColumnPosition, isVisibleCollapseButton: isVisibleCollapseButton, emptyCellValue: emptyCellValue, onRowClick: onRowClick }) }));
|
|
58
58
|
},
|
|
59
59
|
EmptyPlaceholder: () => (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: noDataPlaceholder || (0, jsx_runtime_1.jsx)(NoData_1.NoData, {}) }),
|
|
60
60
|
Footer: () => {
|