@astral/ui 4.114.0 → 4.115.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/DataGrid/Body/Body.d.ts +1 -1
- package/components/DataGrid/Body/Body.js +7 -3
- package/components/DataGrid/Body/types.d.ts +11 -3
- package/components/DataGrid/DataGrid.js +0 -1
- package/components/DataGrid/PinnedSections/PinnedSections.js +2 -2
- package/components/DataGrid/PinnedSections/useLogic/useLogic.d.ts +1 -0
- package/components/DataGrid/PinnedSections/useLogic/useLogic.js +4 -3
- package/components/DataGrid/Row/Row.js +13 -9
- package/components/DataGrid/Row/RowContext/RowContext.d.ts +15 -4
- package/components/DataGrid/Row/RowContext/RowContext.js +3 -3
- package/components/DataGrid/Row/RowContext/RowProvider/RowProvider.d.ts +10 -1
- package/components/DataGrid/Row/RowContext/RowProvider/RowProvider.js +23 -17
- package/components/DataGrid/Row/types.d.ts +7 -3
- package/components/DataGrid/Row/useLogic/useLogic.d.ts +6 -4
- package/components/DataGrid/Row/useLogic/useLogic.js +21 -12
- package/components/DataGrid/RowBase/RowBase.js +5 -2
- package/components/DataGrid/RowBase/types.d.ts +9 -5
- package/components/DataGrid/RowBase/useLogic/useLogic.d.ts +5 -4
- package/components/DataGrid/RowBase/useLogic/useLogic.js +16 -10
- package/components/DataGrid/RowCheckbox/RowCheckbox.d.ts +5 -0
- package/components/DataGrid/RowCheckbox/RowCheckbox.js +13 -0
- package/components/DataGrid/RowCheckbox/constants.d.ts +4 -0
- package/components/DataGrid/RowCheckbox/constants.js +4 -0
- package/components/DataGrid/RowCheckbox/index.d.ts +1 -0
- package/components/DataGrid/RowCheckbox/index.js +1 -0
- package/components/DataGrid/RowCheckbox/types.d.ts +7 -0
- package/components/DataGrid/RowCheckbox/types.js +1 -0
- package/components/DataGrid/hooks/index.d.ts +1 -0
- package/components/DataGrid/hooks/index.js +1 -0
- package/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/index.d.ts +1 -0
- package/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/index.js +1 -0
- package/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/useWarnRowsWithoutDisabledReason.d.ts +5 -0
- package/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/useWarnRowsWithoutDisabledReason.js +17 -0
- package/components/DataGrid/index.d.ts +1 -1
- package/components/DataGrid/public.d.ts +1 -1
- package/components/DataGrid/tests/performance/testDataGridPerformance.d.ts +3 -1
- package/components/DataGrid/tests/performance/testDataGridPerformance.js +234 -2
- package/components/DataGrid/tests/selection/testDataGridSelection.d.ts +14 -0
- package/components/DataGrid/tests/selection/testDataGridSelection.js +562 -0
- package/components/DataGrid/types.d.ts +34 -1
- package/components/DataGrid/useLogic/useLogic.d.ts +6 -3
- package/components/DataGrid/useLogic/useLogic.js +15 -10
- package/components/DataGrid/utils/getRowDisabledState/getRowDisabledState.d.ts +31 -0
- package/components/DataGrid/utils/getRowDisabledState/getRowDisabledState.js +20 -0
- package/components/DataGrid/utils/getRowDisabledState/index.d.ts +1 -0
- package/components/DataGrid/utils/getRowDisabledState/index.js +1 -0
- package/components/DataGrid/utils/index.d.ts +3 -0
- package/components/DataGrid/utils/index.js +3 -0
- package/components/DataGrid/utils/resolveRowDisabled/index.d.ts +1 -0
- package/components/DataGrid/utils/resolveRowDisabled/index.js +1 -0
- package/components/DataGrid/utils/resolveRowDisabled/resolveRowDisabled.d.ts +5 -0
- package/components/DataGrid/utils/resolveRowDisabled/resolveRowDisabled.js +17 -0
- package/components/DataGrid/utils/resolveRowsDisabled/index.d.ts +1 -0
- package/components/DataGrid/utils/resolveRowsDisabled/index.js +1 -0
- package/components/DataGrid/utils/resolveRowsDisabled/resolveRowsDisabled.d.ts +16 -0
- package/components/DataGrid/utils/resolveRowsDisabled/resolveRowsDisabled.js +17 -0
- package/components/DataGridActionCell/hooks/useBlockingActions/useBlockingActions.js +3 -3
- package/components/DataGridCollapsibleRow/useLogic/useLogic.d.ts +3 -2
- package/components/DataGridCollapsibleRow/useLogic/useLogic.js +4 -3
- package/components/DataGridInfinite/DataGridInfinite.js +4 -4
- package/components/DataGridInfinite/DataGridInfiniteContext/DataGridInfiniteContext.d.ts +1 -1
- package/components/DataGridInfinite/DataGridInfiniteContext/DataGridInfiniteContext.js +1 -1
- package/components/DataGridInfinite/Footer/Footer.js +2 -2
- package/components/DataGridInfinite/Row/Row.js +2 -2
- package/components/DataGridInfinite/Row/index.d.ts +1 -0
- package/components/DataGridInfinite/Row/types.d.ts +17 -2
- package/components/DataGridInfinite/Row/useLogic/useLogic.d.ts +4 -2
- package/components/DataGridInfinite/Row/useLogic/useLogic.js +12 -4
- package/components/DataGridInfinite/constants.d.ts +2 -0
- package/components/DataGridInfinite/constants.js +2 -0
- package/components/DataGridInfinite/faker.d.ts +1 -5
- package/components/DataGridInfinite/faker.js +1 -2
- package/components/DataGridInfinite/useLogic/useLogic.d.ts +3 -2
- package/components/DataGridInfinite/useLogic/useLogic.js +25 -13
- package/components/PageContent/styles.js +25 -1
- package/components/index.d.ts +1 -1
- package/node/components/DataGrid/Body/Body.d.ts +1 -1
- package/node/components/DataGrid/Body/Body.js +7 -3
- package/node/components/DataGrid/Body/types.d.ts +11 -3
- package/node/components/DataGrid/DataGrid.js +0 -1
- package/node/components/DataGrid/PinnedSections/PinnedSections.js +2 -2
- package/node/components/DataGrid/PinnedSections/useLogic/useLogic.d.ts +1 -0
- package/node/components/DataGrid/PinnedSections/useLogic/useLogic.js +4 -3
- package/node/components/DataGrid/Row/Row.js +13 -9
- package/node/components/DataGrid/Row/RowContext/RowContext.d.ts +15 -4
- package/node/components/DataGrid/Row/RowContext/RowContext.js +3 -3
- package/node/components/DataGrid/Row/RowContext/RowProvider/RowProvider.d.ts +10 -1
- package/node/components/DataGrid/Row/RowContext/RowProvider/RowProvider.js +23 -17
- package/node/components/DataGrid/Row/types.d.ts +7 -3
- package/node/components/DataGrid/Row/useLogic/useLogic.d.ts +6 -4
- package/node/components/DataGrid/Row/useLogic/useLogic.js +23 -14
- package/node/components/DataGrid/RowBase/RowBase.js +5 -2
- package/node/components/DataGrid/RowBase/types.d.ts +9 -5
- package/node/components/DataGrid/RowBase/useLogic/useLogic.d.ts +5 -4
- package/node/components/DataGrid/RowBase/useLogic/useLogic.js +16 -10
- package/node/components/DataGrid/RowCheckbox/RowCheckbox.d.ts +5 -0
- package/node/components/DataGrid/RowCheckbox/RowCheckbox.js +17 -0
- package/node/components/DataGrid/RowCheckbox/constants.d.ts +4 -0
- package/node/components/DataGrid/RowCheckbox/constants.js +7 -0
- package/node/components/DataGrid/RowCheckbox/index.d.ts +1 -0
- package/node/components/DataGrid/RowCheckbox/index.js +17 -0
- package/node/components/DataGrid/RowCheckbox/types.d.ts +7 -0
- package/node/components/DataGrid/RowCheckbox/types.js +2 -0
- package/node/components/DataGrid/hooks/index.d.ts +1 -0
- package/node/components/DataGrid/hooks/index.js +1 -0
- package/node/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/index.d.ts +1 -0
- package/node/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/index.js +17 -0
- package/node/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/useWarnRowsWithoutDisabledReason.d.ts +5 -0
- package/node/components/DataGrid/hooks/useWarnRowsWithoutDisabledReason/useWarnRowsWithoutDisabledReason.js +21 -0
- package/node/components/DataGrid/index.d.ts +1 -1
- package/node/components/DataGrid/public.d.ts +1 -1
- package/node/components/DataGrid/tests/performance/testDataGridPerformance.d.ts +3 -1
- package/node/components/DataGrid/tests/performance/testDataGridPerformance.js +232 -0
- package/node/components/DataGrid/tests/selection/testDataGridSelection.d.ts +14 -0
- package/node/components/DataGrid/tests/selection/testDataGridSelection.js +566 -0
- package/node/components/DataGrid/types.d.ts +34 -1
- package/node/components/DataGrid/useLogic/useLogic.d.ts +6 -3
- package/node/components/DataGrid/useLogic/useLogic.js +17 -12
- package/node/components/DataGrid/utils/getRowDisabledState/getRowDisabledState.d.ts +31 -0
- package/node/components/DataGrid/utils/getRowDisabledState/getRowDisabledState.js +24 -0
- package/node/components/DataGrid/utils/getRowDisabledState/index.d.ts +1 -0
- package/node/components/DataGrid/utils/getRowDisabledState/index.js +5 -0
- package/node/components/DataGrid/utils/index.d.ts +3 -0
- package/node/components/DataGrid/utils/index.js +7 -1
- package/node/components/DataGrid/utils/resolveRowDisabled/index.d.ts +1 -0
- package/node/components/DataGrid/utils/resolveRowDisabled/index.js +5 -0
- package/node/components/DataGrid/utils/resolveRowDisabled/resolveRowDisabled.d.ts +5 -0
- package/node/components/DataGrid/utils/resolveRowDisabled/resolveRowDisabled.js +21 -0
- package/node/components/DataGrid/utils/resolveRowsDisabled/index.d.ts +1 -0
- package/node/components/DataGrid/utils/resolveRowsDisabled/index.js +5 -0
- package/node/components/DataGrid/utils/resolveRowsDisabled/resolveRowsDisabled.d.ts +16 -0
- package/node/components/DataGrid/utils/resolveRowsDisabled/resolveRowsDisabled.js +21 -0
- package/node/components/DataGridActionCell/hooks/useBlockingActions/useBlockingActions.js +3 -3
- package/node/components/DataGridCollapsibleRow/useLogic/useLogic.d.ts +3 -2
- package/node/components/DataGridCollapsibleRow/useLogic/useLogic.js +4 -3
- package/node/components/DataGridInfinite/DataGridInfinite.js +4 -4
- package/node/components/DataGridInfinite/DataGridInfiniteContext/DataGridInfiniteContext.d.ts +1 -1
- package/node/components/DataGridInfinite/DataGridInfiniteContext/DataGridInfiniteContext.js +1 -1
- package/node/components/DataGridInfinite/Footer/Footer.js +1 -1
- package/node/components/DataGridInfinite/Row/Row.js +2 -2
- package/node/components/DataGridInfinite/Row/index.d.ts +1 -0
- package/node/components/DataGridInfinite/Row/types.d.ts +17 -2
- package/node/components/DataGridInfinite/Row/useLogic/useLogic.d.ts +4 -2
- package/node/components/DataGridInfinite/Row/useLogic/useLogic.js +12 -4
- package/node/components/DataGridInfinite/constants.d.ts +2 -0
- package/node/components/DataGridInfinite/constants.js +2 -0
- package/node/components/DataGridInfinite/faker.d.ts +1 -5
- package/node/components/DataGridInfinite/faker.js +1 -2
- package/node/components/DataGridInfinite/useLogic/useLogic.d.ts +3 -2
- package/node/components/DataGridInfinite/useLogic/useLogic.js +26 -14
- package/node/components/PageContent/styles.js +24 -0
- package/node/components/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HOVER_MEDIA, selfContainedClassname } from '../constants';
|
|
1
|
+
import { HOVER_MEDIA, SCROLLBAR_SIZE, selfContainedClassname, } from '../constants';
|
|
2
2
|
import { pdfViewerClassnames } from '../PdfViewer/constants';
|
|
3
3
|
import { styled } from '../styled';
|
|
4
4
|
import { PAGE_CONTENT_ANIMATION, pageContentClassnames } from './constants';
|
|
@@ -60,10 +60,16 @@ export const Content = styled.div `
|
|
|
60
60
|
|
|
61
61
|
${HOVER_MEDIA} {
|
|
62
62
|
scrollbar-gutter: stable;
|
|
63
|
+
|
|
64
|
+
padding-right: ${({ theme }) => `calc(${theme.spacing(6)} - ${SCROLLBAR_SIZE})`};
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
&.${pageContentClassnames.contentHasHeader}, &.${pageContentClassnames.hasAside} {
|
|
66
68
|
padding: ${({ theme }) => theme.spacing(4, 6, 4)};
|
|
69
|
+
|
|
70
|
+
${HOVER_MEDIA} {
|
|
71
|
+
padding-right: ${({ theme }) => `calc(${theme.spacing(6)} - ${SCROLLBAR_SIZE})`};
|
|
72
|
+
}
|
|
67
73
|
}
|
|
68
74
|
|
|
69
75
|
${({ theme }) => theme.breakpoints.down('laptop')} {
|
|
@@ -71,8 +77,16 @@ export const Content = styled.div `
|
|
|
71
77
|
padding-bottom: ${({ theme }) => theme.spacing(3)};
|
|
72
78
|
padding-left: ${({ theme }) => theme.spacing(4)};
|
|
73
79
|
|
|
80
|
+
${HOVER_MEDIA} {
|
|
81
|
+
padding-right: ${({ theme }) => `calc(${theme.spacing(4)} - ${SCROLLBAR_SIZE})`};
|
|
82
|
+
}
|
|
83
|
+
|
|
74
84
|
&.${pageContentClassnames.contentHasHeader}, &.${pageContentClassnames.hasAside} {
|
|
75
85
|
padding: ${({ theme }) => theme.spacing(4, 4, 3)};
|
|
86
|
+
|
|
87
|
+
${HOVER_MEDIA} {
|
|
88
|
+
padding-right: ${({ theme }) => `calc(${theme.spacing(4)} - ${SCROLLBAR_SIZE})`};
|
|
89
|
+
}
|
|
76
90
|
}
|
|
77
91
|
}
|
|
78
92
|
|
|
@@ -88,6 +102,16 @@ export const Content = styled.div `
|
|
|
88
102
|
border: 1px solid ${({ theme }) => theme.palette.components.border.default};
|
|
89
103
|
border-radius: ${({ theme }) => theme.shape.medium};
|
|
90
104
|
|
|
105
|
+
${HOVER_MEDIA} {
|
|
106
|
+
padding-right: ${({ theme }) => theme.spacing(4)};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
&.${pageContentClassnames.contentHasHeader}, &.${pageContentClassnames.hasAside} {
|
|
110
|
+
${HOVER_MEDIA} {
|
|
111
|
+
padding-right: ${({ theme }) => theme.spacing(4)};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
91
115
|
&.${pageContentClassnames.contentHasHeader} {
|
|
92
116
|
border-top-left-radius: 0;
|
|
93
117
|
border-top-right-radius: 0;
|
package/components/index.d.ts
CHANGED
|
@@ -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';
|
|
@@ -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;
|
|
@@ -18,13 +18,17 @@ const bodyCva = (0, cva_1.cva)(constants_1.bodyClassnames.root, {
|
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
20
|
});
|
|
21
|
-
const Body = ({ rows,
|
|
21
|
+
const Body = ({ rows, selectedIds, rowsDisabled, getRowDisabled, minDisplayRows, keyId, noDataPlaceholder, className, renderRow, columns, isSelectable, onSelectRow, onRowEnter, onRowLeave, registerRowElement, unregisterRowElement, ...rowProps }) => {
|
|
22
22
|
const { disableMinHeight, bodyCssVars } = (0, useLogic_1.useLogic)({ minDisplayRows });
|
|
23
23
|
const renderedRows = rows.map((row, index) => {
|
|
24
24
|
const rowId = row[keyId];
|
|
25
|
-
const isSelected =
|
|
25
|
+
const isSelected = selectedIds.has(rowId);
|
|
26
|
+
const rowDisabled = rowsDisabled.get(rowId);
|
|
26
27
|
const { children, options } = row;
|
|
27
|
-
|
|
28
|
+
const hasNestedChildren = Array.isArray(children) && children.length > 0;
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)(RowContext_1.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 ? ((0, jsx_runtime_1.jsx)(CustomRowWrapper_1.CustomRowWrapper, { index: index, renderRow: renderRow, row: row })) : ((0, jsx_runtime_1.jsx)(Row_1.Row, { row: row, options: options, keyId: keyId, level: INITIAL_LEVEL, nestedChildren: children, isSelected: isSelected,
|
|
30
|
+
// Функция нужна только для расчёта блокировки вложенных строк, остальным не передаём, чтобы не сбрасывать memo
|
|
31
|
+
getRowDisabled: hasNestedChildren ? getRowDisabled : undefined, columns: columns, isSelectable: isSelectable, onSelectRow: onSelectRow, onRowEnter: onRowEnter, onRowLeave: onRowLeave, registerRowElement: registerRowElement, unregisterRowElement: unregisterRowElement, ...rowProps }, rowId)) }, rowId));
|
|
28
32
|
});
|
|
29
33
|
return ((0, jsx_runtime_1.jsx)(styles_1.Wrapper, { className: (0, cn_1.cn)(className, bodyCva({ disableMinHeight })), style: bodyCssVars, children: rows.length ? renderedRows : noDataPlaceholder }));
|
|
30
34
|
};
|
|
@@ -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
|
*/
|
|
@@ -7,9 +7,9 @@ const Section_1 = require("./Section");
|
|
|
7
7
|
const styles_1 = require("./styles");
|
|
8
8
|
const useLogic_1 = require("./useLogic");
|
|
9
9
|
const PinnedSections = ({ gridColumns, className, isDisabled, headProps, bodyProps, sections, isNoData, }) => {
|
|
10
|
-
const { pinnedContainerStyles, sectionOffsets } = (0, useLogic_1.useLogic)({ sections });
|
|
10
|
+
const { pinnedContainerStyles, sectionOffsets, totalColumnsCount } = (0, useLogic_1.useLogic)({ sections });
|
|
11
11
|
return ((0, jsx_runtime_1.jsx)(styles_1.PinnedColumnsContainer, { "$gridColumns": gridColumns, className: className, ...(0, getInertProps_1.getInertProps)(isDisabled), style: pinnedContainerStyles, children: sections.map(({ columns, position }) => {
|
|
12
|
-
return ((0, jsx_runtime_1.jsx)(Section_1.Section, { columns: columns, position: position, sectionOffset: sectionOffsets[position], bodyProps: bodyProps, headProps: headProps, isNoData: isNoData }, position));
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)(Section_1.Section, { columns: columns, position: position, sectionOffset: sectionOffsets[position], bodyProps: { ...bodyProps, totalColumnsCount }, headProps: headProps, isNoData: isNoData }, position));
|
|
13
13
|
}) }));
|
|
14
14
|
};
|
|
15
15
|
exports.PinnedSections = PinnedSections;
|
|
@@ -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 {};
|
|
@@ -14,15 +14,16 @@ const useLogic = ({ sections, }) => {
|
|
|
14
14
|
? (0, utils_1.getFlattenColumns)(rightColumns).length
|
|
15
15
|
: 0,
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
// Строка в секции видит только свои колонки, поэтому для поиска последней ячейки таблицы ей передаётся общее число колонок всех секций
|
|
18
|
+
const { sectionOffsets, totalColumnsCount } = (0, react_1.useMemo)(() => {
|
|
18
19
|
const offsets = {};
|
|
19
20
|
let currentOffset = 0;
|
|
20
21
|
sections.forEach((section) => {
|
|
21
22
|
offsets[section.position] = currentOffset;
|
|
22
23
|
currentOffset += (0, utils_1.getFlattenColumns)(section.columns).length;
|
|
23
24
|
});
|
|
24
|
-
return offsets;
|
|
25
|
+
return { sectionOffsets: offsets, totalColumnsCount: currentOffset };
|
|
25
26
|
}, [sections]);
|
|
26
|
-
return { pinnedContainerStyles, sectionOffsets };
|
|
27
|
+
return { pinnedContainerStyles, sectionOffsets, totalColumnsCount };
|
|
27
28
|
};
|
|
28
29
|
exports.useLogic = useLogic;
|
|
@@ -4,12 +4,12 @@ exports.Row = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const BottomDrawer_1 = require("../../BottomDrawer");
|
|
7
|
-
const Checkbox_1 = require("../../Checkbox");
|
|
8
7
|
const Tooltip_1 = require("../../Tooltip");
|
|
9
8
|
const cn_1 = require("../../utils/cn");
|
|
10
9
|
const cva_1 = require("../../utils/cva");
|
|
11
10
|
const getInertProps_1 = require("../../utils/getInertProps");
|
|
12
11
|
const Cell_1 = require("../Cell");
|
|
12
|
+
const RowCheckbox_1 = require("../RowCheckbox");
|
|
13
13
|
const utils_1 = require("../utils");
|
|
14
14
|
const constants_1 = require("./constants");
|
|
15
15
|
const NestedChildren_1 = require("./NestedChildren");
|
|
@@ -60,17 +60,17 @@ const singleCellCva = (0, cva_1.cva)(constants_1.dataGridRowCellClassnames.singl
|
|
|
60
60
|
* который позволяет полностью контролировать рендер каждой строки.
|
|
61
61
|
*/
|
|
62
62
|
const RowInner = (props) => {
|
|
63
|
-
const { isOpen, isShowConnector, childrenColumns, rowId, handleToggle, checkboxProps, rowProps, isHovered, tooltipProps, nestedChildrenProps,
|
|
64
|
-
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,
|
|
63
|
+
const { isOpen, isShowConnector, childrenColumns, rowId, handleToggle, checkboxProps, rowProps, isHovered, tooltipProps, nestedChildrenProps, isDisabled, isDisabledLastCell, isRenderCollapseButton, rowRef, rowStyles, drawerProps, disabledReason, isActive, isSelectable, mobileDisplayVariant, rootRowElement, rootRowRef, } = (0, useLogic_1.useLogic)(props);
|
|
64
|
+
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,
|
|
65
65
|
// В этот rest-оператор попадают специфичные пропсы (атрибуты) virtuoso
|
|
66
66
|
// Необходимы для DataGridInfinite
|
|
67
67
|
...selfProps } = props;
|
|
68
|
-
const {
|
|
68
|
+
const { isNotSelectable, href, target } = options || {};
|
|
69
69
|
const renderStartAdornment = () => {
|
|
70
70
|
if (!isRenderCollapseButton && (!isSelectable || isNotSelectable)) {
|
|
71
71
|
return null;
|
|
72
72
|
}
|
|
73
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isRenderCollapseButton && ((0, jsx_runtime_1.jsx)(styles_1.CollapseCell, { children: (0, jsx_runtime_1.jsx)(styles_1.CollapseButton, { variant: "text", onClick: handleToggle, children: (0, jsx_runtime_1.jsx)(styles_1.ChevronIcon, { "$isActive": isOpen }) }) })), isSelectable && !isNotSelectable && ((0, jsx_runtime_1.jsx)(styles_1.CheckboxCell, { ...(0, getInertProps_1.getInertProps)(
|
|
73
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isRenderCollapseButton && ((0, jsx_runtime_1.jsx)(styles_1.CollapseCell, { children: (0, jsx_runtime_1.jsx)(styles_1.CollapseButton, { variant: "text", onClick: handleToggle, children: (0, jsx_runtime_1.jsx)(styles_1.ChevronIcon, { "$isActive": isOpen }) }) })), isSelectable && !isNotSelectable && ((0, jsx_runtime_1.jsx)(styles_1.CheckboxCell, { ...(0, getInertProps_1.getInertProps)(isDisabled), onClick: (event) => event.stopPropagation(), className: constants_1.dataGridRowClassnames.checkbox, children: (0, jsx_runtime_1.jsx)(RowCheckbox_1.RowCheckbox, { ...checkboxProps }) }))] }));
|
|
74
74
|
};
|
|
75
75
|
const renderCells = (0, react_1.useCallback)(() => {
|
|
76
76
|
const lastCellGlobalIndex = (totalColumnsCount ?? columns.length) - 1;
|
|
@@ -80,7 +80,7 @@ const RowInner = (props) => {
|
|
|
80
80
|
return columns?.map((cell, index) => {
|
|
81
81
|
const cellId = `${rowId}-${index}`;
|
|
82
82
|
const globalIndex = (sectionOffset ?? 0) + index;
|
|
83
|
-
const isDisabledCell = (0, utils_2.checkIsDisabled)(
|
|
83
|
+
const isDisabledCell = (0, utils_2.checkIsDisabled)(isDisabled, availableCellsByIndex, globalIndex);
|
|
84
84
|
const isFirstCell = globalIndex === 0;
|
|
85
85
|
if ((0, utils_1.isGroupColumns)(cell)) {
|
|
86
86
|
const { label, children, hideTitleOnMobile, isHideOnMobile } = cell;
|
|
@@ -98,13 +98,16 @@ const RowInner = (props) => {
|
|
|
98
98
|
row,
|
|
99
99
|
isOpen,
|
|
100
100
|
columns,
|
|
101
|
-
|
|
101
|
+
isDisabled,
|
|
102
|
+
isDisabledLastCell,
|
|
102
103
|
checkboxProps.checked,
|
|
104
|
+
checkboxProps.disabled,
|
|
105
|
+
checkboxProps.disabledReason,
|
|
103
106
|
totalColumnsCount,
|
|
104
107
|
sectionOffset,
|
|
105
108
|
rootRowElement,
|
|
106
109
|
]);
|
|
107
|
-
const renderRow = (0, react_1.useCallback)(({ key, ...nestedRowProps }) => ((0, jsx_runtime_1.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)), [
|
|
110
|
+
const renderRow = (0, react_1.useCallback)(({ key, ...nestedRowProps }) => ((0, jsx_runtime_1.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)), [
|
|
108
111
|
keyId,
|
|
109
112
|
variant,
|
|
110
113
|
isSelectable,
|
|
@@ -123,11 +126,12 @@ const RowInner = (props) => {
|
|
|
123
126
|
unregisterRowElement,
|
|
124
127
|
onRowEnter,
|
|
125
128
|
onRowLeave,
|
|
129
|
+
getRowDisabled,
|
|
126
130
|
]);
|
|
127
131
|
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { className: (0, cn_1.cn)(className, rootCva({
|
|
128
132
|
isShowConnector,
|
|
129
133
|
mobileDisplayVariant,
|
|
130
134
|
hasNestedChildren: Boolean(nestedChildren?.length),
|
|
131
|
-
})), style: rowStyles, ...selfProps, ref: rootRowRef, 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]:
|
|
135
|
+
})), style: rowStyles, ...selfProps, ref: rootRowRef, 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]: isDisabled, ...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, renderRow: renderRow }), (0, jsx_runtime_1.jsx)(BottomDrawer_1.BottomDrawer, { ...drawerProps, children: (0, jsx_runtime_1.jsx)(styles_1.BottomDrawerContent, { children: disabledReason }) })] }, `row-${rowId}`));
|
|
132
136
|
};
|
|
133
137
|
exports.Row = (0, react_1.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>;
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RowContext = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
exports.RowContext = (0, react_1.createContext)({
|
|
6
|
-
|
|
6
|
+
hasBlockingAction: false,
|
|
7
7
|
isSelectable: false,
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
addBlockingAction: () => undefined,
|
|
9
|
+
removeBlockingAction: () => undefined,
|
|
10
10
|
row: {},
|
|
11
11
|
onSelectRow: () => () => undefined,
|
|
12
12
|
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 {};
|
|
@@ -4,23 +4,27 @@ exports.RowContextProvider = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const RowContext_1 = require("../RowContext");
|
|
7
|
-
const RowContextProvider = ({ row, itemProps, onSelectRow, onRowEnter, onRowLeave, registerRowElement, unregisterRowElement, children, isSelectable, isSelected, }) => {
|
|
8
|
-
const [
|
|
9
|
-
const [
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
const RowContextProvider = ({ row, itemProps, onSelectRow, onRowEnter, onRowLeave, registerRowElement, unregisterRowElement, children, isSelectable, isSelected, disabledMode, disabledReason, }) => {
|
|
8
|
+
const [hasBlockingAction, setHasBlockingAction] = (0, react_1.useState)(false);
|
|
9
|
+
const [blockingActionReason, setBlockingActionReason] = (0, react_1.useState)();
|
|
10
|
+
const addBlockingAction = (0, react_1.useCallback)((reason) => {
|
|
11
|
+
setHasBlockingAction(true);
|
|
12
|
+
setBlockingActionReason(reason);
|
|
13
13
|
}, []);
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const removeBlockingAction = (0, react_1.useCallback)(() => {
|
|
15
|
+
setHasBlockingAction(false);
|
|
16
|
+
setBlockingActionReason(undefined);
|
|
17
17
|
}, []);
|
|
18
|
+
// Блокировка приходит примитивами, чтобы новый объект с тем же содержимым не обновлял контекст
|
|
19
|
+
const rowDisabled = (0, react_1.useMemo)(() => disabledMode
|
|
20
|
+
? { mode: disabledMode, reason: disabledReason ?? '' }
|
|
21
|
+
: undefined, [disabledMode, disabledReason]);
|
|
18
22
|
const contextValue = (0, react_1.useMemo)(() => ({
|
|
19
|
-
|
|
23
|
+
hasBlockingAction,
|
|
24
|
+
blockingActionReason,
|
|
25
|
+
addBlockingAction,
|
|
26
|
+
removeBlockingAction,
|
|
20
27
|
isSelectable,
|
|
21
|
-
disabledReason,
|
|
22
|
-
addDisabledRow,
|
|
23
|
-
removeDisabledRow,
|
|
24
28
|
row,
|
|
25
29
|
itemProps,
|
|
26
30
|
onSelectRow,
|
|
@@ -29,12 +33,13 @@ const RowContextProvider = ({ row, itemProps, onSelectRow, onRowEnter, onRowLeav
|
|
|
29
33
|
registerRowElement,
|
|
30
34
|
unregisterRowElement,
|
|
31
35
|
isSelected,
|
|
36
|
+
rowDisabled,
|
|
32
37
|
}), [
|
|
33
|
-
|
|
38
|
+
hasBlockingAction,
|
|
39
|
+
blockingActionReason,
|
|
40
|
+
addBlockingAction,
|
|
41
|
+
removeBlockingAction,
|
|
34
42
|
isSelectable,
|
|
35
|
-
disabledReason,
|
|
36
|
-
addDisabledRow,
|
|
37
|
-
removeDisabledRow,
|
|
38
43
|
row,
|
|
39
44
|
itemProps,
|
|
40
45
|
onSelectRow,
|
|
@@ -43,6 +48,7 @@ const RowContextProvider = ({ row, itemProps, onSelectRow, onRowEnter, onRowLeav
|
|
|
43
48
|
registerRowElement,
|
|
44
49
|
unregisterRowElement,
|
|
45
50
|
isSelected,
|
|
51
|
+
rowDisabled,
|
|
46
52
|
]);
|
|
47
53
|
return ((0, jsx_runtime_1.jsx)(RowContext_1.RowContext.Provider, { value: contextValue, children: children }));
|
|
48
54
|
};
|
|
@@ -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: {
|
|
@@ -4,11 +4,12 @@ exports.useLogic = void 0;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const DataGridContext_1 = require("../../DataGridContext");
|
|
6
6
|
const enums_1 = require("../../enums");
|
|
7
|
+
const utils_1 = require("../../utils");
|
|
7
8
|
const constants_1 = require("../constants");
|
|
8
9
|
const RowContext_1 = require("../RowContext");
|
|
9
10
|
const hooks_1 = require("./hooks");
|
|
10
|
-
const
|
|
11
|
-
const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options, isInitialExpanded = false, expandedLevel, isSelectable, isSelected, onSelectRow, onRowClick, isVisibleCollapseButton, registerRowElement, unregisterRowElement, style, activeRowId, }) => {
|
|
11
|
+
const utils_2 = require("./utils");
|
|
12
|
+
const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options, isInitialExpanded = false, expandedLevel, isSelectable, isSelected, getRowDisabled, isNested = false, onSelectRow, onRowClick, isVisibleCollapseButton, registerRowElement, unregisterRowElement, style, activeRowId, }) => {
|
|
12
13
|
const { isDrawerOpen, handleOpenDrawer, handleCloseDrawer } = (0, hooks_1.useMobileLogic)();
|
|
13
14
|
const [rootRowElement, setRootRowElement] = (0, react_1.useState)(null);
|
|
14
15
|
const rootRowRef = (0, react_1.useCallback)((element) => {
|
|
@@ -18,7 +19,7 @@ const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options
|
|
|
18
19
|
}, []);
|
|
19
20
|
const isDefaultExpanded = Boolean(isInitialExpanded && level <= expandedLevel - 1 && nestedChildren?.length);
|
|
20
21
|
const { mobileDisplayVariant } = (0, react_1.useContext)(DataGridContext_1.DataGridContext);
|
|
21
|
-
const {
|
|
22
|
+
const { hasBlockingAction, blockingActionReason, rowDisabled: contextRowDisabled, } = (0, react_1.useContext)(RowContext_1.RowContext);
|
|
22
23
|
const [isOpen, setIsOpen] = (0, react_1.useState)(isDefaultExpanded);
|
|
23
24
|
const savedElementRef = (0, react_1.useRef)(null);
|
|
24
25
|
const rowRef = (element) => {
|
|
@@ -33,17 +34,24 @@ const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options
|
|
|
33
34
|
};
|
|
34
35
|
const [isVisibleTooltip, setVisibleTooltip] = (0, react_1.useState)(false);
|
|
35
36
|
const rowId = row[keyId];
|
|
36
|
-
const {
|
|
37
|
-
|
|
37
|
+
const { href } = options || {};
|
|
38
|
+
// Блокировку строки из rows таблица передаёт через контекст, вложенная строка считает её сама и не наследует блокировку родителя
|
|
39
|
+
const rowDisabled = (0, react_1.useMemo)(() => isNested ? (0, utils_1.resolveRowDisabled)(row, getRowDisabled) : contextRowDisabled, [isNested, row, getRowDisabled, contextRowDisabled]);
|
|
40
|
+
const { isDisabled, isDisabledLastCell, disabledReason, isCheckboxDisabled, checkboxDisabledReason, } = (0, utils_1.getRowDisabledState)({
|
|
41
|
+
rowDisabled,
|
|
42
|
+
hasBlockingAction,
|
|
43
|
+
blockingActionReason,
|
|
44
|
+
isDisabledLastCellOption: options?.isDisabledLastCell,
|
|
45
|
+
});
|
|
38
46
|
const handleRowClick = () => {
|
|
39
|
-
if (
|
|
47
|
+
if (isDisabled) {
|
|
40
48
|
handleOpenDrawer();
|
|
41
49
|
return undefined;
|
|
42
50
|
}
|
|
43
51
|
onRowClick?.(row);
|
|
44
52
|
};
|
|
45
53
|
const isShowConnector = Object.is(variant, enums_1.Variant.Tree);
|
|
46
|
-
const childrenColumns = (0, react_1.useMemo)(() => (0,
|
|
54
|
+
const childrenColumns = (0, react_1.useMemo)(() => (0, utils_2.mergeColumnsOptions)(columns, options?.childrenColumns), [columns, options]);
|
|
47
55
|
const handleToggle = (0, react_1.useCallback)((event) => {
|
|
48
56
|
event.stopPropagation();
|
|
49
57
|
setIsOpen((prev) => !prev);
|
|
@@ -57,7 +65,7 @@ const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options
|
|
|
57
65
|
};
|
|
58
66
|
const handleCloseTooltip = () => setVisibleTooltip(false);
|
|
59
67
|
const handleMouseMove = (event) => {
|
|
60
|
-
if (!
|
|
68
|
+
if (!isDisabled) {
|
|
61
69
|
return;
|
|
62
70
|
}
|
|
63
71
|
const element = event.target;
|
|
@@ -71,19 +79,19 @@ const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options
|
|
|
71
79
|
'--level': level,
|
|
72
80
|
...style,
|
|
73
81
|
}), [level, style]);
|
|
74
|
-
const isHovered = Boolean(!
|
|
82
|
+
const isHovered = Boolean(!isDisabled && (onRowClick || href));
|
|
75
83
|
const isActive = activeRowId === rowId;
|
|
76
|
-
const disabledReasonText = externalDisabledReason || disabledReason;
|
|
77
84
|
const handleCheckboxChange = (0, react_1.useMemo)(() => onSelectRow(row), [onSelectRow, row]);
|
|
78
85
|
return {
|
|
79
|
-
|
|
86
|
+
disabledReason,
|
|
80
87
|
rowStyles,
|
|
81
88
|
isOpen,
|
|
82
89
|
isShowConnector,
|
|
83
90
|
childrenColumns,
|
|
84
91
|
rowId,
|
|
85
92
|
rowRef,
|
|
86
|
-
|
|
93
|
+
isDisabled,
|
|
94
|
+
isDisabledLastCell,
|
|
87
95
|
isSelectable,
|
|
88
96
|
isRenderCollapseButton,
|
|
89
97
|
handleToggle,
|
|
@@ -103,13 +111,14 @@ const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options
|
|
|
103
111
|
},
|
|
104
112
|
tooltipProps: {
|
|
105
113
|
open: isVisibleTooltip,
|
|
106
|
-
title:
|
|
114
|
+
title: isDisabled ? disabledReason : undefined,
|
|
107
115
|
onOpen: handleOpenTooltip,
|
|
108
116
|
onClose: handleCloseTooltip,
|
|
109
117
|
},
|
|
110
118
|
checkboxProps: {
|
|
111
119
|
checked: isSelected,
|
|
112
|
-
disabled,
|
|
120
|
+
disabled: isCheckboxDisabled,
|
|
121
|
+
disabledReason: checkboxDisabledReason,
|
|
113
122
|
onChange: handleCheckboxChange,
|
|
114
123
|
},
|
|
115
124
|
nestedChildrenProps: {
|
|
@@ -4,7 +4,6 @@ exports.RowBase = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const BottomDrawer_1 = require("../../BottomDrawer");
|
|
7
|
-
const Checkbox_1 = require("../../Checkbox");
|
|
8
7
|
const Tooltip_1 = require("../../Tooltip");
|
|
9
8
|
const cn_1 = require("../../utils/cn");
|
|
10
9
|
const cva_1 = require("../../utils/cva");
|
|
@@ -12,6 +11,7 @@ const getInertProps_1 = require("../../utils/getInertProps");
|
|
|
12
11
|
const Cell_1 = require("../Cell");
|
|
13
12
|
const constants_1 = require("../Row/constants");
|
|
14
13
|
const utils_1 = require("../Row/utils");
|
|
14
|
+
const RowCheckbox_1 = require("../RowCheckbox");
|
|
15
15
|
const utils_2 = require("../utils");
|
|
16
16
|
const constants_2 = require("./constants");
|
|
17
17
|
const GroupCell_1 = require("./GroupCell");
|
|
@@ -43,7 +43,7 @@ exports.RowBase = (0, react_1.memo)((props) => {
|
|
|
43
43
|
if (!adornment && !shouldRenderCheckbox) {
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
46
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [adornment, shouldRenderCheckbox && ((0, jsx_runtime_1.jsx)(styles_1.CheckboxCell, { ...(0, getInertProps_1.getInertProps)(isDisabled), onClick: (event) => event.stopPropagation(), className: constants_1.dataGridRowClassnames.checkbox, children: (0, jsx_runtime_1.jsx)(
|
|
46
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [adornment, shouldRenderCheckbox && ((0, jsx_runtime_1.jsx)(styles_1.CheckboxCell, { ...(0, getInertProps_1.getInertProps)(isDisabled), onClick: (event) => event.stopPropagation(), className: constants_1.dataGridRowClassnames.checkbox, children: (0, jsx_runtime_1.jsx)(RowCheckbox_1.RowCheckbox, { ...checkboxProps }) }))] }));
|
|
47
47
|
};
|
|
48
48
|
const renderCells = (0, react_1.useCallback)(() => {
|
|
49
49
|
const lastCellGlobalIndex = columns.length - 1;
|
|
@@ -64,9 +64,12 @@ exports.RowBase = (0, react_1.memo)((props) => {
|
|
|
64
64
|
row,
|
|
65
65
|
columns,
|
|
66
66
|
isDisabled,
|
|
67
|
+
isDisabledLastCell,
|
|
67
68
|
sectionOffset,
|
|
68
69
|
renderStartAdornment,
|
|
69
70
|
checkboxProps.checked,
|
|
71
|
+
checkboxProps.disabled,
|
|
72
|
+
checkboxProps.disabledReason,
|
|
70
73
|
]);
|
|
71
74
|
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { className: (0, cn_1.cn)(className, rootCva({ mobileDisplayVariant })), style: rowBaseVars, ...dataGridInfiniteItemProps, children: [(0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { ...tooltipProps, children: (0, jsx_runtime_1.jsx)(styles_1.ContentWrapper, { ref: rowRef, onPointerEnter: () => onRowEnter?.(rowId), onPointerLeave: (event) => onRowLeave?.(rowId, event.nativeEvent), className: contentWrapperCva({ isHovered, isActive }), [constants_1.DISABLE_ROW_ATTR]: isDisabled, onClick: handleRowClick, children: renderCells() }) }), customContent, (0, jsx_runtime_1.jsx)(BottomDrawer_1.BottomDrawer, { ...drawerProps, children: (0, jsx_runtime_1.jsx)(styles_1.BottomDrawerContent, { children: drawerContent }) })] }, `row-base-${rowId}`));
|
|
72
75
|
});
|
|
@@ -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
|
*/
|