@astral/ui 4.62.2 → 4.64.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/ConfirmDialog/ConfirmDialog.js +2 -2
- package/components/ConfirmDialog/types.d.ts +2 -2
- package/components/DataGrid/Body/styles.js +4 -0
- package/components/DataGrid/Cell/Cell.d.ts +6 -2
- package/components/DataGrid/Cell/Cell.js +18 -2
- package/components/DataGrid/Cell/constants.d.ts +6 -0
- package/components/DataGrid/Cell/constants.js +6 -0
- package/components/DataGrid/Cell/index.d.ts +1 -0
- package/components/DataGrid/Cell/index.js +1 -0
- package/components/DataGrid/Cell/styles.d.ts +1 -8
- package/components/DataGrid/Cell/styles.js +43 -8
- package/components/DataGrid/DataGrid.js +11 -2
- package/components/DataGrid/Head/Head.js +14 -30
- package/components/DataGrid/Head/HeadColumns/GroupColumns/GroupColumns.d.ts +14 -0
- package/components/DataGrid/Head/HeadColumns/GroupColumns/GroupColumns.js +4 -0
- package/components/DataGrid/Head/HeadColumns/GroupColumns/index.d.ts +1 -0
- package/components/DataGrid/Head/HeadColumns/GroupColumns/index.js +1 -0
- package/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/HeadCellStartAdornment.d.ts +9 -0
- package/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/HeadCellStartAdornment.js +9 -0
- package/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/index.d.ts +1 -0
- package/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/index.js +1 -0
- package/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/styles.d.ts +5 -0
- package/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/styles.js +9 -0
- package/components/DataGrid/Head/HeadColumns/HeadColumns.d.ts +41 -0
- package/components/DataGrid/Head/HeadColumns/HeadColumns.js +26 -0
- package/components/DataGrid/Head/HeadColumns/SingleColumn/SingleColumn.d.ts +13 -0
- package/components/DataGrid/Head/HeadColumns/SingleColumn/SingleColumn.js +3 -0
- package/components/DataGrid/Head/HeadColumns/SingleColumn/index.d.ts +1 -0
- package/components/DataGrid/Head/HeadColumns/SingleColumn/index.js +1 -0
- package/components/DataGrid/Head/HeadColumns/index.d.ts +1 -0
- package/components/DataGrid/Head/HeadColumns/index.js +1 -0
- package/components/DataGrid/Head/HeadColumns/styles.d.ts +5 -0
- package/components/DataGrid/Head/HeadColumns/styles.js +9 -0
- package/components/DataGrid/Head/HeadColumns/useLogic/useLogic.d.ts +12 -0
- package/components/DataGrid/Head/HeadColumns/useLogic/useLogic.js +46 -0
- package/components/DataGrid/Head/HeadColumns/useLogic/utils/getGridPositions/getGridPositions.d.ts +6 -0
- package/components/DataGrid/Head/HeadColumns/useLogic/utils/getGridPositions/getGridPositions.js +19 -0
- package/components/DataGrid/Head/HeadColumns/useLogic/utils/getGridPositions/index.d.ts +1 -0
- package/components/DataGrid/Head/HeadColumns/useLogic/utils/getGridPositions/index.js +1 -0
- package/components/DataGrid/Head/HeadColumns/useLogic/utils/index.d.ts +1 -0
- package/components/DataGrid/Head/HeadColumns/useLogic/utils/index.js +1 -0
- package/components/DataGrid/Head/HeadColumns/utils/getHeadCellProps.d.ts +18 -0
- package/components/DataGrid/Head/HeadColumns/utils/getHeadCellProps.js +17 -0
- package/components/DataGrid/Head/HeadColumns/utils/index.d.ts +1 -0
- package/components/DataGrid/Head/HeadColumns/utils/index.js +1 -0
- package/components/DataGrid/Head/styles.d.ts +0 -4
- package/components/DataGrid/Head/styles.js +2 -8
- package/components/DataGrid/HeadCell/HeadCell.d.ts +11 -0
- package/components/DataGrid/HeadCell/HeadCell.js +21 -3
- package/components/DataGrid/HeadCell/constants.d.ts +11 -0
- package/components/DataGrid/HeadCell/constants.js +12 -0
- package/components/DataGrid/HeadCell/index.d.ts +1 -0
- package/components/DataGrid/HeadCell/index.js +1 -0
- package/components/DataGrid/HeadCell/styles.d.ts +1 -8
- package/components/DataGrid/HeadCell/styles.js +24 -7
- package/components/DataGrid/HeadCell/useLogic/useLogic.d.ts +5 -5
- package/components/DataGrid/HeadCell/useLogic/useLogic.js +8 -5
- package/components/DataGrid/PinnedSections/Section/styles.js +4 -0
- package/components/DataGrid/PinnedSections/Section/useLogic/useLogic.js +2 -2
- package/components/DataGrid/PinnedSections/styles.js +8 -4
- package/components/DataGrid/PinnedSections/useLogic/useLogic.js +10 -5
- package/components/DataGrid/Row/Row.js +22 -3
- package/components/DataGrid/Row/constants.d.ts +8 -0
- package/components/DataGrid/Row/constants.js +8 -0
- package/components/DataGrid/Row/styles.d.ts +10 -0
- package/components/DataGrid/Row/styles.js +15 -2
- package/components/DataGrid/constants.d.ts +4 -1
- package/components/DataGrid/constants.js +4 -1
- package/components/DataGrid/faker.js +13 -9
- package/components/DataGrid/index.d.ts +1 -1
- package/components/DataGrid/styles.js +84 -2
- package/components/DataGrid/types.d.ts +38 -1
- package/components/DataGrid/useLogic/hooks/useDataGridMobileLogic/useDataGridMobileLogic.d.ts +2 -2
- package/components/DataGrid/useLogic/useLogic.d.ts +3 -1
- package/components/DataGrid/useLogic/useLogic.js +10 -6
- package/components/DataGrid/useLogic/utils/getColumnSections/getColumnSections.d.ts +1 -1
- package/components/DataGrid/useLogic/utils/getColumnSections/getColumnSections.js +17 -10
- package/components/DataGrid/utils/getFlattenColumns/getFlattenColumns.d.ts +2 -0
- package/components/DataGrid/utils/getFlattenColumns/getFlattenColumns.js +13 -0
- package/components/DataGrid/utils/getFlattenColumns/index.d.ts +1 -0
- package/components/DataGrid/utils/getFlattenColumns/index.js +1 -0
- package/components/DataGrid/utils/index.d.ts +2 -1
- package/components/DataGrid/utils/index.js +2 -1
- package/components/DataGrid/utils/isGroupColumns/index.d.ts +1 -0
- package/components/DataGrid/utils/isGroupColumns/index.js +1 -0
- package/components/DataGrid/utils/isGroupColumns/isGroupColumns.d.ts +2 -0
- package/components/DataGrid/utils/isGroupColumns/isGroupColumns.js +3 -0
- package/components/DataGridInfinite/DataGridInfinite.js +15 -3
- package/components/DataGridInfinite/useLogic/useLogic.d.ts +4 -1
- package/components/DataGridInfinite/useLogic/useLogic.js +10 -4
- package/components/Dialog/Dialog.d.ts +2 -24
- package/components/Dialog/Dialog.js +18 -11
- package/components/Dialog/constants.d.ts +5 -0
- package/components/Dialog/constants.js +6 -0
- package/components/Dialog/index.d.ts +2 -1
- package/components/Dialog/index.js +1 -1
- package/components/Dialog/public.d.ts +2 -1
- package/components/Dialog/public.js +1 -1
- package/components/Dialog/styles.js +11 -4
- package/components/Dialog/types.d.ts +23 -0
- package/components/Dialog/types.js +1 -0
- package/components/Dialog/useLogic/index.js +1 -0
- package/components/Dialog/useLogic/useLogic.d.ts +25 -0
- package/components/Dialog/useLogic/useLogic.js +19 -0
- package/components/PageLayoutContainer/PageLayoutContainer.js +2 -2
- package/components/PageLayoutContainer/styles.d.ts +1 -1
- package/components/PageLayoutContainer/styles.js +1 -1
- package/components/ResizingDataGrid/hooks/useComputedColumns/useComputedColumns.d.ts +1 -1
- package/components/ResizingDataGrid/hooks/useComputedColumns/utils/createComputedColumns/createComputedColumns.d.ts +2 -2
- package/components/ResizingDataGrid/types.d.ts +2 -2
- package/node/components/ConfirmDialog/ConfirmDialog.js +2 -2
- package/node/components/ConfirmDialog/types.d.ts +2 -2
- package/node/components/DataGrid/Body/styles.js +4 -0
- package/node/components/DataGrid/Cell/Cell.d.ts +6 -2
- package/node/components/DataGrid/Cell/Cell.js +18 -2
- package/node/components/DataGrid/Cell/constants.d.ts +6 -0
- package/node/components/DataGrid/Cell/constants.js +6 -0
- package/node/components/DataGrid/Cell/index.d.ts +1 -0
- package/node/components/DataGrid/Cell/index.js +3 -0
- package/node/components/DataGrid/Cell/styles.d.ts +1 -8
- package/node/components/DataGrid/Cell/styles.js +43 -8
- package/node/components/DataGrid/DataGrid.js +11 -2
- package/node/components/DataGrid/Head/Head.js +12 -28
- package/node/components/DataGrid/Head/HeadColumns/GroupColumns/GroupColumns.d.ts +14 -0
- package/node/components/DataGrid/Head/HeadColumns/GroupColumns/GroupColumns.js +8 -0
- package/node/components/DataGrid/Head/HeadColumns/GroupColumns/index.d.ts +1 -0
- package/node/components/DataGrid/{utils/alignToJustifyContent → Head/HeadColumns/GroupColumns}/index.js +1 -1
- package/node/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/HeadCellStartAdornment.d.ts +9 -0
- package/node/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/HeadCellStartAdornment.js +13 -0
- package/node/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/index.d.ts +1 -0
- package/node/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/index.js +17 -0
- package/node/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/styles.d.ts +5 -0
- package/node/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/styles.js +12 -0
- package/node/components/DataGrid/Head/HeadColumns/HeadColumns.d.ts +41 -0
- package/node/components/DataGrid/Head/HeadColumns/HeadColumns.js +30 -0
- package/node/components/DataGrid/Head/HeadColumns/SingleColumn/SingleColumn.d.ts +13 -0
- package/node/components/DataGrid/Head/HeadColumns/SingleColumn/SingleColumn.js +7 -0
- package/node/components/DataGrid/Head/HeadColumns/SingleColumn/index.d.ts +1 -0
- package/node/components/DataGrid/Head/HeadColumns/SingleColumn/index.js +17 -0
- package/node/components/DataGrid/Head/HeadColumns/index.d.ts +1 -0
- package/node/components/DataGrid/Head/HeadColumns/index.js +17 -0
- package/node/components/DataGrid/Head/HeadColumns/styles.d.ts +5 -0
- package/node/components/DataGrid/Head/HeadColumns/styles.js +12 -0
- package/node/components/DataGrid/Head/HeadColumns/useLogic/index.d.ts +1 -0
- package/node/components/DataGrid/Head/HeadColumns/useLogic/useLogic.d.ts +12 -0
- package/node/components/DataGrid/Head/{useLogic → HeadColumns/useLogic}/useLogic.js +25 -9
- package/node/components/DataGrid/Head/HeadColumns/useLogic/utils/getGridPositions/getGridPositions.d.ts +6 -0
- package/node/components/DataGrid/Head/HeadColumns/useLogic/utils/getGridPositions/getGridPositions.js +23 -0
- package/node/components/DataGrid/Head/HeadColumns/useLogic/utils/getGridPositions/index.d.ts +1 -0
- package/node/components/DataGrid/Head/HeadColumns/useLogic/utils/getGridPositions/index.js +17 -0
- package/node/components/DataGrid/Head/HeadColumns/useLogic/utils/index.d.ts +1 -0
- package/node/components/DataGrid/Head/HeadColumns/useLogic/utils/index.js +17 -0
- package/node/components/DataGrid/Head/HeadColumns/utils/getHeadCellProps.d.ts +18 -0
- package/node/components/DataGrid/Head/HeadColumns/utils/getHeadCellProps.js +21 -0
- package/node/components/DataGrid/Head/HeadColumns/utils/index.d.ts +1 -0
- package/node/components/DataGrid/Head/HeadColumns/utils/index.js +17 -0
- package/node/components/DataGrid/Head/styles.d.ts +0 -4
- package/node/components/DataGrid/Head/styles.js +3 -9
- package/node/components/DataGrid/HeadCell/HeadCell.d.ts +11 -0
- package/node/components/DataGrid/HeadCell/HeadCell.js +21 -3
- package/node/components/DataGrid/HeadCell/constants.d.ts +11 -0
- package/node/components/DataGrid/HeadCell/constants.js +15 -0
- package/node/components/DataGrid/HeadCell/index.d.ts +1 -0
- package/node/components/DataGrid/HeadCell/index.js +3 -0
- package/node/components/DataGrid/HeadCell/styles.d.ts +1 -8
- package/node/components/DataGrid/HeadCell/styles.js +24 -7
- package/node/components/DataGrid/HeadCell/useLogic/useLogic.d.ts +5 -5
- package/node/components/DataGrid/HeadCell/useLogic/useLogic.js +8 -5
- package/node/components/DataGrid/PinnedSections/Section/styles.js +4 -0
- package/node/components/DataGrid/PinnedSections/Section/useLogic/useLogic.js +1 -1
- package/node/components/DataGrid/PinnedSections/styles.js +8 -4
- package/node/components/DataGrid/PinnedSections/useLogic/useLogic.js +10 -5
- package/node/components/DataGrid/Row/Row.js +21 -2
- package/node/components/DataGrid/Row/constants.d.ts +8 -0
- package/node/components/DataGrid/Row/constants.js +9 -1
- package/node/components/DataGrid/Row/styles.d.ts +10 -0
- package/node/components/DataGrid/Row/styles.js +15 -2
- package/node/components/DataGrid/constants.d.ts +4 -1
- package/node/components/DataGrid/constants.js +4 -1
- package/node/components/DataGrid/faker.js +13 -9
- package/node/components/DataGrid/index.d.ts +1 -1
- package/node/components/DataGrid/styles.js +93 -11
- package/node/components/DataGrid/types.d.ts +38 -1
- package/node/components/DataGrid/useLogic/hooks/useDataGridMobileLogic/useDataGridMobileLogic.d.ts +2 -2
- package/node/components/DataGrid/useLogic/useLogic.d.ts +3 -1
- package/node/components/DataGrid/useLogic/useLogic.js +9 -5
- package/node/components/DataGrid/useLogic/utils/getColumnSections/getColumnSections.d.ts +1 -1
- package/node/components/DataGrid/useLogic/utils/getColumnSections/getColumnSections.js +17 -10
- package/node/components/DataGrid/utils/getFlattenColumns/getFlattenColumns.d.ts +2 -0
- package/node/components/DataGrid/utils/getFlattenColumns/getFlattenColumns.js +17 -0
- package/node/components/DataGrid/utils/getFlattenColumns/index.d.ts +1 -0
- package/node/components/DataGrid/utils/getFlattenColumns/index.js +5 -0
- package/node/components/DataGrid/utils/index.d.ts +2 -1
- package/node/components/DataGrid/utils/index.js +5 -3
- package/node/components/DataGrid/utils/isGroupColumns/index.d.ts +1 -0
- package/node/components/DataGrid/utils/isGroupColumns/index.js +17 -0
- package/node/components/DataGrid/utils/isGroupColumns/isGroupColumns.d.ts +2 -0
- package/node/components/DataGrid/utils/isGroupColumns/isGroupColumns.js +7 -0
- package/node/components/DataGridInfinite/DataGridInfinite.js +15 -3
- package/node/components/DataGridInfinite/useLogic/useLogic.d.ts +4 -1
- package/node/components/DataGridInfinite/useLogic/useLogic.js +9 -3
- package/node/components/Dialog/Dialog.d.ts +2 -24
- package/node/components/Dialog/Dialog.js +18 -11
- package/node/components/Dialog/constants.d.ts +5 -0
- package/node/components/Dialog/constants.js +7 -1
- package/node/components/Dialog/index.d.ts +2 -1
- package/node/components/Dialog/index.js +2 -1
- package/node/components/Dialog/public.d.ts +2 -1
- package/node/components/Dialog/public.js +2 -1
- package/node/components/Dialog/styles.js +12 -25
- package/node/components/Dialog/types.d.ts +23 -0
- package/node/components/Dialog/types.js +2 -0
- package/node/components/Dialog/useLogic/index.d.ts +1 -0
- package/node/components/Dialog/useLogic/index.js +17 -0
- package/node/components/Dialog/useLogic/useLogic.d.ts +25 -0
- package/node/components/Dialog/useLogic/useLogic.js +23 -0
- package/node/components/PageLayoutContainer/PageLayoutContainer.js +1 -1
- package/node/components/PageLayoutContainer/styles.d.ts +1 -1
- package/node/components/PageLayoutContainer/styles.js +2 -2
- package/node/components/ResizingDataGrid/hooks/useComputedColumns/useComputedColumns.d.ts +1 -1
- package/node/components/ResizingDataGrid/hooks/useComputedColumns/utils/createComputedColumns/createComputedColumns.d.ts +2 -2
- package/node/components/ResizingDataGrid/types.d.ts +2 -2
- package/package.json +1 -1
- package/components/DataGrid/Head/useLogic/useLogic.d.ts +0 -12
- package/components/DataGrid/Head/useLogic/useLogic.js +0 -30
- package/components/DataGrid/utils/alignToJustifyContent/alignToJustifyContent.d.ts +0 -5
- package/components/DataGrid/utils/alignToJustifyContent/alignToJustifyContent.js +0 -7
- package/components/DataGrid/utils/alignToJustifyContent/constants.d.ts +0 -6
- package/components/DataGrid/utils/alignToJustifyContent/constants.js +0 -6
- package/components/DataGrid/utils/alignToJustifyContent/index.d.ts +0 -1
- package/components/DataGrid/utils/alignToJustifyContent/index.js +0 -1
- package/node/components/DataGrid/Head/useLogic/useLogic.d.ts +0 -12
- package/node/components/DataGrid/utils/alignToJustifyContent/alignToJustifyContent.d.ts +0 -5
- package/node/components/DataGrid/utils/alignToJustifyContent/alignToJustifyContent.js +0 -11
- package/node/components/DataGrid/utils/alignToJustifyContent/constants.d.ts +0 -6
- package/node/components/DataGrid/utils/alignToJustifyContent/constants.js +0 -9
- package/node/components/DataGrid/utils/alignToJustifyContent/index.d.ts +0 -1
- /package/components/DataGrid/Head/{useLogic → HeadColumns/useLogic}/index.d.ts +0 -0
- /package/components/DataGrid/Head/{useLogic → HeadColumns/useLogic}/index.js +0 -0
- /package/{node/components/DataGrid/Head → components/Dialog}/useLogic/index.d.ts +0 -0
- /package/node/components/DataGrid/Head/{useLogic → HeadColumns/useLogic}/index.js +0 -0
|
@@ -8,8 +8,8 @@ import { CancelButton } from './styles';
|
|
|
8
8
|
import { useLogic } from './useLogic';
|
|
9
9
|
export const ConfirmDialog = (props) => {
|
|
10
10
|
const { isShowCancelButton, cancelButtonProps } = useLogic(props);
|
|
11
|
-
const { open, title, description, actions, onClose, ...restProps } = props;
|
|
11
|
+
const { open, title, description, actions, onClose, size = 'sm', ...restProps } = props;
|
|
12
12
|
const { text: confirmText, ...confirmButtonProps } = actions.confirm;
|
|
13
13
|
const { text: cancelText, variant, onClick, ...restCancelProps } = actions.cancel || {};
|
|
14
|
-
return (_jsxs(Dialog, { size:
|
|
14
|
+
return (_jsxs(Dialog, { size: size, title: title, open: open, onClose: onClose, ...restProps, children: [description && (_jsx(DialogContent, { children: typeof description === 'string' ? (_jsx(DialogContentText, { children: description })) : (description) })), _jsxs(DialogActions, { children: [isShowCancelButton && (_jsx(CancelButton, { ...restCancelProps, ...cancelButtonProps, children: cancelText })), _jsx(Button, { ...confirmButtonProps, children: confirmText })] })] }));
|
|
15
15
|
};
|
|
@@ -5,7 +5,7 @@ export type ConfirmDialogProps = {
|
|
|
5
5
|
/**
|
|
6
6
|
* Заголовок диалога
|
|
7
7
|
*/
|
|
8
|
-
title
|
|
8
|
+
title?: string;
|
|
9
9
|
/**
|
|
10
10
|
* Вспомогательный текст
|
|
11
11
|
*/
|
|
@@ -33,4 +33,4 @@ export type ConfirmDialogProps = {
|
|
|
33
33
|
text: string;
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
|
-
} & Pick<DialogProps, 'aria-labelledby' | 'aria-describedby' | 'disableBackdropClick' | 'disablePortal' | 'disableScrollLock' | 'hideBackdrop' | 'keepMounted' | 'open'>;
|
|
36
|
+
} & Pick<DialogProps, 'aria-labelledby' | 'aria-describedby' | 'disableBackdropClick' | 'disablePortal' | 'disableScrollLock' | 'hideBackdrop' | 'keepMounted' | 'open' | 'size'>;
|
|
@@ -4,6 +4,8 @@ import { bodyClassnames } from './constants';
|
|
|
4
4
|
export const Wrapper = styled.ul `
|
|
5
5
|
--min-display-rows: 0;
|
|
6
6
|
|
|
7
|
+
scrollbar-gutter: stable;
|
|
8
|
+
|
|
7
9
|
overflow-y: auto;
|
|
8
10
|
|
|
9
11
|
width: fit-content;
|
|
@@ -25,6 +27,8 @@ export const Wrapper = styled.ul `
|
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
30
|
+
scrollbar-gutter: unset;
|
|
31
|
+
|
|
28
32
|
overflow: initial;
|
|
29
33
|
|
|
30
34
|
width: 100%;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
import type { CellValue,
|
|
2
|
+
import type { CellValue, DataGridSingleColumn } from '../types';
|
|
3
3
|
export type CellProps<TData extends Record<string, CellValue>> = {
|
|
4
4
|
/**
|
|
5
5
|
* Название класса, применяется к корневому компоненту
|
|
@@ -9,7 +9,7 @@ export type CellProps<TData extends Record<string, CellValue>> = {
|
|
|
9
9
|
* Данные строки для отображения
|
|
10
10
|
*/
|
|
11
11
|
row: TData;
|
|
12
|
-
cell:
|
|
12
|
+
cell: DataGridSingleColumn<TData>;
|
|
13
13
|
/**
|
|
14
14
|
* Дополнительное содержимое ячейки, которое будет распложено справа
|
|
15
15
|
*/
|
|
@@ -26,5 +26,9 @@ export type CellProps<TData extends Record<string, CellValue>> = {
|
|
|
26
26
|
* Скрытие персональных данных от инструментов мониторинга
|
|
27
27
|
*/
|
|
28
28
|
isHidePersonalData?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Скрытие ячейки на мобильных устройствах
|
|
31
|
+
*/
|
|
32
|
+
isHideOnMobile?: boolean;
|
|
29
33
|
};
|
|
30
34
|
export declare const Cell: <TData extends Record<string, unknown>>(props: CellProps<TData>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -12,6 +12,17 @@ const cellCva = cva(dataGridCellClassnames.root, {
|
|
|
12
12
|
isHideOnMobile: {
|
|
13
13
|
true: dataGridCellClassnames.isHideOnMobile,
|
|
14
14
|
},
|
|
15
|
+
isDisabled: {
|
|
16
|
+
true: dataGridCellClassnames.disabled,
|
|
17
|
+
},
|
|
18
|
+
withStartAdornment: {
|
|
19
|
+
true: dataGridCellClassnames.withStartAdornment,
|
|
20
|
+
},
|
|
21
|
+
align: {
|
|
22
|
+
left: dataGridCellClassnames.alignLeft,
|
|
23
|
+
center: dataGridCellClassnames.alignCenter,
|
|
24
|
+
right: dataGridCellClassnames.alignRight,
|
|
25
|
+
},
|
|
15
26
|
},
|
|
16
27
|
});
|
|
17
28
|
const cellContentCva = cva(dataGridCellClassnames.cellContent, {
|
|
@@ -30,12 +41,17 @@ const columnLabelCva = cva(dataGridCellClassnames.columnLabel, {
|
|
|
30
41
|
});
|
|
31
42
|
export const Cell = (props) => {
|
|
32
43
|
const { formattedValue, hasStartAdornment, isActionColumn, label, hideTitleOnMobile, } = useLogic(props);
|
|
33
|
-
const { className, startAdornment, row, cell, isDisabled, isHidePersonalData, } = props;
|
|
44
|
+
const { className, startAdornment, row, cell, isDisabled, isHidePersonalData, isHideOnMobile, } = props;
|
|
34
45
|
const { renderCell, align = 'left' } = cell;
|
|
35
46
|
const hidePersonalDataClassname = useHidePersonalData({
|
|
36
47
|
isEnabled: isHidePersonalData === true,
|
|
37
48
|
});
|
|
38
|
-
return (_jsxs(Wrapper, {
|
|
49
|
+
return (_jsxs(Wrapper, { className: classNames(className, hidePersonalDataClassname, cellCva({
|
|
50
|
+
isHideOnMobile: cell.isHideOnMobile || isHideOnMobile,
|
|
51
|
+
isDisabled,
|
|
52
|
+
withStartAdornment: hasStartAdornment,
|
|
53
|
+
align,
|
|
54
|
+
})), ...getInertProps(isDisabled), children: [startAdornment && startAdornment, _jsxs(CellContent, { className: cellContentCva({ isActionColumn }), children: [_jsx(ColumnLabel, { variant: "caption", color: "textSecondary", className: columnLabelCva({
|
|
39
55
|
hidden: hideTitleOnMobile || isActionColumn,
|
|
40
56
|
}), children: label }), renderCell?.(row), !renderCell && (_jsx(OverflowTypography, { rowsCount: 2, tooltipProps: { className: hidePersonalDataClassname }, children: _jsx(_Fragment, { children: formattedValue }) }))] })] }));
|
|
41
57
|
};
|
|
@@ -5,4 +5,10 @@ export declare const dataGridCellClassnames: {
|
|
|
5
5
|
columnLabelHidden: string;
|
|
6
6
|
actionColumn: string;
|
|
7
7
|
cellContent: string;
|
|
8
|
+
disabled: string;
|
|
9
|
+
withStartAdornment: string;
|
|
10
|
+
alignLeft: string;
|
|
11
|
+
alignCenter: string;
|
|
12
|
+
alignRight: string;
|
|
13
|
+
grouped: string;
|
|
8
14
|
};
|
|
@@ -6,4 +6,10 @@ export const dataGridCellClassnames = {
|
|
|
6
6
|
columnLabelHidden: createUIKitClassname('data-grid__cell-column-label_hidden'),
|
|
7
7
|
actionColumn: createUIKitClassname('data-grid__cell_action-column'),
|
|
8
8
|
cellContent: createUIKitClassname('data-grid__cell-content'),
|
|
9
|
+
disabled: createUIKitClassname('data-grid__cell_disabled'),
|
|
10
|
+
withStartAdornment: createUIKitClassname('data-grid__cell_with-start-adornment'),
|
|
11
|
+
alignLeft: createUIKitClassname('data-grid__cell_align-left'),
|
|
12
|
+
alignCenter: createUIKitClassname('data-grid__cell_align-center'),
|
|
13
|
+
alignRight: createUIKitClassname('data-grid__cell_align-right'),
|
|
14
|
+
grouped: createUIKitClassname('data-grid__cell_grouped'),
|
|
9
15
|
};
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { AlignVariant } from '../types';
|
|
3
|
-
type HeadCellProps = {
|
|
4
|
-
$align?: AlignVariant;
|
|
5
|
-
$isDisabled?: boolean;
|
|
6
|
-
$hasStartAdornment?: boolean;
|
|
7
|
-
};
|
|
8
2
|
export declare const Wrapper: import("../../styled").StyledComponent<{
|
|
9
3
|
theme?: import("@emotion/react").Theme | undefined;
|
|
10
4
|
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
11
|
-
}
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
12
6
|
export declare const ColumnLabel: import("../../styled").StyledComponent<import("../../Typography/types").TypographyPropsBase & {
|
|
13
7
|
color?: import("../../Typography").TypographyColor | undefined;
|
|
14
8
|
variant?: import("../../Typography").TypographyVariant | undefined;
|
|
@@ -23,4 +17,3 @@ export declare const CellContent: import("../../styled").StyledComponent<{
|
|
|
23
17
|
theme?: import("@emotion/react").Theme | undefined;
|
|
24
18
|
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
25
19
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
26
|
-
export {};
|
|
@@ -2,36 +2,71 @@ import { styled } from '../../styled';
|
|
|
2
2
|
import { Typography } from '../../Typography';
|
|
3
3
|
import { MIN_ROW_HEIGHT } from '../constants';
|
|
4
4
|
import { dataGridRowClassnames } from '../Row/constants';
|
|
5
|
-
import { alignToJustifyContent } from '../utils';
|
|
6
5
|
import { dataGridCellClassnames } from './constants';
|
|
7
|
-
export const Wrapper = styled
|
|
8
|
-
shouldForwardProp: (prop) => !['$align', '$isDisabled', '$hasStartAdornment'].includes(prop),
|
|
9
|
-
}) `
|
|
6
|
+
export const Wrapper = styled.div `
|
|
10
7
|
overflow: hidden;
|
|
11
8
|
display: flex;
|
|
12
9
|
align-items: center;
|
|
13
|
-
justify-content: ${({ $align }) => alignToJustifyContent($align)};
|
|
14
10
|
|
|
15
11
|
min-height: ${MIN_ROW_HEIGHT}px;
|
|
16
|
-
padding: ${({ theme
|
|
12
|
+
padding: ${({ theme }) => theme.spacing(1, 2)};
|
|
17
13
|
|
|
18
|
-
|
|
14
|
+
&.${dataGridCellClassnames.disabled} {
|
|
15
|
+
opacity: 0.5;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&.${dataGridCellClassnames.withStartAdornment} {
|
|
19
|
+
padding: ${({ theme }) => theme.spacing(1, 2, 1, 0)};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&.${dataGridCellClassnames.alignLeft} {
|
|
23
|
+
justify-content: flex-start;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&.${dataGridCellClassnames.alignCenter} {
|
|
27
|
+
justify-content: center;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&.${dataGridCellClassnames.alignRight} {
|
|
31
|
+
justify-content: flex-end;
|
|
32
|
+
}
|
|
19
33
|
|
|
20
34
|
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
21
35
|
justify-content: space-between;
|
|
22
36
|
|
|
23
37
|
min-height: unset;
|
|
38
|
+
margin-top: ${({ theme }) => theme.spacing(3)};
|
|
24
39
|
padding: 0;
|
|
25
40
|
|
|
26
41
|
&.${dataGridCellClassnames.isHideOnMobile} {
|
|
27
42
|
display: none;
|
|
28
43
|
}
|
|
29
44
|
|
|
30
|
-
|
|
31
45
|
& .${dataGridRowClassnames.checkbox} {
|
|
32
46
|
align-self: flex-start;
|
|
33
47
|
order: 1;
|
|
34
48
|
}
|
|
49
|
+
|
|
50
|
+
&.${dataGridCellClassnames.grouped} {
|
|
51
|
+
margin-top: ${({ theme }) => theme.spacing(1)};
|
|
52
|
+
|
|
53
|
+
& .${dataGridCellClassnames.cellContent} {
|
|
54
|
+
flex-direction: row;
|
|
55
|
+
gap: ${({ theme }) => theme.spacing(2)};
|
|
56
|
+
align-items: baseline;
|
|
57
|
+
|
|
58
|
+
& .${dataGridCellClassnames.columnLabel} {
|
|
59
|
+
/* Декоративный разделитель между названием колонки и значением */
|
|
60
|
+
&::after {
|
|
61
|
+
content: ':';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&:first-of-type {
|
|
68
|
+
margin-top: 0;
|
|
69
|
+
}
|
|
35
70
|
}
|
|
36
71
|
`;
|
|
37
72
|
export const ColumnLabel = styled(Typography) `
|
|
@@ -26,11 +26,18 @@ const pinnedSectionsCva = cva(dataGridClassnames.pinnedSections, {
|
|
|
26
26
|
const dataGridCva = cva(dataGridClassnames.root, {
|
|
27
27
|
variants: {
|
|
28
28
|
hasPinnedColumns: {
|
|
29
|
-
true: dataGridClassnames.
|
|
29
|
+
true: dataGridClassnames.hasPinnedSections,
|
|
30
30
|
},
|
|
31
31
|
isAllowHorizontalScroll: {
|
|
32
32
|
true: dataGridClassnames.isAllowHorizontalScroll,
|
|
33
33
|
},
|
|
34
|
+
gridViewMode: {
|
|
35
|
+
full: dataGridClassnames.gridViewFull,
|
|
36
|
+
standard: dataGridClassnames.gridViewStandard,
|
|
37
|
+
},
|
|
38
|
+
hasGroupedColumns: {
|
|
39
|
+
true: dataGridClassnames.hasGroupedColumns,
|
|
40
|
+
},
|
|
34
41
|
},
|
|
35
42
|
});
|
|
36
43
|
const bodyCva = cva(dataGridClassnames.body, {
|
|
@@ -41,7 +48,7 @@ const bodyCva = cva(dataGridClassnames.body, {
|
|
|
41
48
|
},
|
|
42
49
|
});
|
|
43
50
|
export const DataGrid = (props) => {
|
|
44
|
-
const { dataGridClassName, isDataGridDisabled, treeRenderConfig, headColumns, headProps, bodyProps, gridColumns, loaderProps, renderRows, isAllowHorizontalScroll, isHideHead, hasPinnedColumns, contentStateProps, rowHoverProps, containerRef, sections, isNoData, isMobile, mobileSkeletonProps, isLoading, containerCssVars, } = useLogic(props);
|
|
51
|
+
const { dataGridClassName, isDataGridDisabled, treeRenderConfig, headColumns, headProps, bodyProps, gridColumns, loaderProps, renderRows, isAllowHorizontalScroll, isHideHead, hasPinnedColumns, contentStateProps, rowHoverProps, containerRef, sections, isNoData, isMobile, mobileSkeletonProps, isLoading, containerCssVars, hasGroupedColumns, gridViewMode, } = useLogic(props);
|
|
45
52
|
const { emptySymbol } = useContext(ConfigContext);
|
|
46
53
|
const { columns, selectedRows = [], minDisplayRows = MIN_DISPLAY_ROWS_BY_DEFAULT, variant = Variant.Tree, footer, noDataPlaceholder, subrows, keyId, activeRowId, emptyCellValue = emptySymbol, onRowClick, noDataOptions, headPreAddon, } = props;
|
|
47
54
|
const { moreButtonColumnPosition = 1, isVisibleCollapseButton = true } = subrows || {};
|
|
@@ -86,5 +93,7 @@ export const DataGrid = (props) => {
|
|
|
86
93
|
return (_jsx(DataGridContextProvider, { isLoading: isLoading, children: _jsxs(Container, { ref: containerRef, style: containerCssVars, className: classNames(dataGridClassName, dataGridCva({
|
|
87
94
|
isAllowHorizontalScroll,
|
|
88
95
|
hasPinnedColumns,
|
|
96
|
+
gridViewMode,
|
|
97
|
+
hasGroupedColumns,
|
|
89
98
|
})), children: [renderTableContent(), _jsx(Loader, { ...loaderProps }), footer && footer] }) }));
|
|
90
99
|
};
|
|
@@ -1,33 +1,17 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import {
|
|
3
|
-
import { Checkbox } from '../../Checkbox';
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from '../../utils/cva';
|
|
4
3
|
import { dataGridClassnames } from '../constants';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { isGroupColumns } from '../utils';
|
|
5
|
+
import { HeadColumns } from './HeadColumns/HeadColumns';
|
|
6
|
+
import { Wrapper } from './styles';
|
|
7
|
+
const headerCva = cva(dataGridClassnames.header, {
|
|
8
|
+
variants: {
|
|
9
|
+
isGroup: {
|
|
10
|
+
true: dataGridClassnames.hasGroupedColumns,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
});
|
|
8
14
|
export const Head = (props) => {
|
|
9
|
-
const {
|
|
10
|
-
|
|
11
|
-
const renderColumns = useMemo(() => {
|
|
12
|
-
return columns.map(({ field, label, sortable, align, columnHint }, index) => {
|
|
13
|
-
const globalIndex = (sectionOffset ?? 0) + index;
|
|
14
|
-
const isFirstCell = globalIndex === 0;
|
|
15
|
-
const startAdornmentRender = () => {
|
|
16
|
-
const showCheckbox = isFirstCell && isSelectable && !isHideSelectAll;
|
|
17
|
-
if (!showCheckbox && !columnHint) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
return (_jsxs(_Fragment, { children: [showCheckbox && (_jsx(CheckboxCell, { children: _jsx(Checkbox, { ...checkboxProps, onChange: onSelectAllRows }) })), columnHint] }));
|
|
21
|
-
};
|
|
22
|
-
return (_jsx(HeadCell, { sorting: sorting, field: field, label: label, isSortable: sortable, align: align, startAdornment: startAdornmentRender(), onSort: handleSort }, label));
|
|
23
|
-
});
|
|
24
|
-
}, [
|
|
25
|
-
columns,
|
|
26
|
-
sorting,
|
|
27
|
-
isSelectable,
|
|
28
|
-
checkboxProps,
|
|
29
|
-
onSelectAllRows,
|
|
30
|
-
handleSort,
|
|
31
|
-
]);
|
|
32
|
-
return (_jsx(Wrapper, { role: "heading", className: dataGridClassnames.header, "$gridColumns": gridColumns, children: renderColumns }));
|
|
15
|
+
const { columns, gridColumns } = props;
|
|
16
|
+
return (_jsx(Wrapper, { role: "heading", className: headerCva({ isGroup: columns.some(isGroupColumns) }), "$gridColumns": gridColumns, children: _jsx(HeadColumns, { ...props }) }));
|
|
33
17
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type CellValue, type DataGridGroupColumn, type DataGridRow, type DataGridSort } from '../../../types';
|
|
3
|
+
type GroupColumnsProps<TData extends Record<string, CellValue> = DataGridRow, TSortField extends keyof TData = keyof TData> = {
|
|
4
|
+
column: DataGridGroupColumn<TData>;
|
|
5
|
+
sorting?: DataGridSort<TSortField>;
|
|
6
|
+
onSort: (field: TSortField) => void;
|
|
7
|
+
gridPosition?: {
|
|
8
|
+
start: number;
|
|
9
|
+
end: number;
|
|
10
|
+
};
|
|
11
|
+
startAdornment?: ReactNode;
|
|
12
|
+
};
|
|
13
|
+
export declare const GroupColumns: <TData extends Record<string, unknown>, TSortField extends keyof TData>({ column, sorting, onSort, gridPosition, startAdornment, }: GroupColumnsProps<TData, TSortField>) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from 'react';
|
|
3
|
+
import { HeadCell, headCellClassnames } from '../../../HeadCell';
|
|
4
|
+
export const GroupColumns = ({ column, sorting, onSort, gridPosition, startAdornment, }) => (_jsxs(Fragment, { children: [_jsx(HeadCell, { sorting: sorting, label: column.label, onSort: onSort, className: headCellClassnames.groupParent, gridPosition: gridPosition, startAdornment: startAdornment }), column.children.map((child) => (_jsx(HeadCell, { ...child, onSort: onSort, className: headCellClassnames.groupChild, startAdornment: child.columnHint }, child.label)))] }, column.label));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './GroupColumns';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './GroupColumns';
|
package/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/HeadCellStartAdornment.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type CheckboxProps } from '../../../../Checkbox';
|
|
3
|
+
type HeadCellStartAdornmentProps = {
|
|
4
|
+
showCheckbox: boolean;
|
|
5
|
+
columnHint?: ReactNode;
|
|
6
|
+
checkboxProps: CheckboxProps;
|
|
7
|
+
};
|
|
8
|
+
export declare const HeadCellStartAdornment: ({ showCheckbox, columnHint, checkboxProps, }: HeadCellStartAdornmentProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Checkbox } from '../../../../Checkbox';
|
|
3
|
+
import { CheckboxCell } from './styles';
|
|
4
|
+
export const HeadCellStartAdornment = ({ showCheckbox, columnHint, checkboxProps, }) => {
|
|
5
|
+
if (!showCheckbox && !columnHint) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
return (_jsxs(_Fragment, { children: [showCheckbox && (_jsx(CheckboxCell, { children: _jsx(Checkbox, { ...checkboxProps }) })), columnHint] }));
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './HeadCellStartAdornment';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './HeadCellStartAdornment';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const CheckboxCell: import("../../../../styled").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type ChangeEvent } from 'react';
|
|
2
|
+
import { type CellValue, type DataGridColumns, type DataGridRow, type DataGridSort } from '../../types';
|
|
3
|
+
export type HeadColumnsProps<TData extends Record<string, CellValue> = DataGridRow, TSortField extends keyof TData = keyof TData> = {
|
|
4
|
+
/**
|
|
5
|
+
* Конфигурация колонок для таблицы
|
|
6
|
+
*/
|
|
7
|
+
columns: DataGridColumns<TData>[];
|
|
8
|
+
/**
|
|
9
|
+
* Если true, то будет отображаться чекбокс для выбора элемента
|
|
10
|
+
*/
|
|
11
|
+
isSelectable: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Параметры сортируемой колонки
|
|
14
|
+
*/
|
|
15
|
+
sorting?: DataGridSort<TSortField>;
|
|
16
|
+
/**
|
|
17
|
+
* Общее количество строк, доступных для выбора
|
|
18
|
+
*/
|
|
19
|
+
rowsCount: number;
|
|
20
|
+
/**
|
|
21
|
+
* Количество строк, которые не выбраны
|
|
22
|
+
*/
|
|
23
|
+
uncheckedRowsCount: number;
|
|
24
|
+
/**
|
|
25
|
+
* Обработчик выбора всех строк
|
|
26
|
+
*/
|
|
27
|
+
onSelectAllRows: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Обработчик сортировки
|
|
30
|
+
*/
|
|
31
|
+
onSort?: (sorting: DataGridSort<TSortField> | undefined) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Используется для скрытия чекбокса "Выбрать все"
|
|
34
|
+
*/
|
|
35
|
+
isHideSelectAll?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Смещение секции
|
|
38
|
+
*/
|
|
39
|
+
sectionOffset?: number;
|
|
40
|
+
};
|
|
41
|
+
export declare const HeadColumns: <TData extends Record<string, unknown>, TSortField extends keyof TData>(props: HeadColumnsProps<TData, TSortField>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { isGroupColumns } from '../../utils';
|
|
3
|
+
import { GroupColumns } from './GroupColumns';
|
|
4
|
+
import { HeadCellStartAdornment } from './HeadCellStartAdornment';
|
|
5
|
+
import { SingleColumn } from './SingleColumn';
|
|
6
|
+
import { useLogic } from './useLogic';
|
|
7
|
+
import { getHeadCellProps } from './utils';
|
|
8
|
+
export const HeadColumns = (props) => {
|
|
9
|
+
const { checkboxProps, handleSort, gridPositions } = useLogic(props);
|
|
10
|
+
const { columns, isSelectable, sorting, isHideSelectAll, sectionOffset } = props;
|
|
11
|
+
return (_jsx(_Fragment, { children: columns.map((column, index) => {
|
|
12
|
+
const { label, align, columnHint, field, sortable, showCheckbox } = getHeadCellProps({
|
|
13
|
+
column,
|
|
14
|
+
index,
|
|
15
|
+
sectionOffset,
|
|
16
|
+
isSelectable,
|
|
17
|
+
isHideSelectAll,
|
|
18
|
+
});
|
|
19
|
+
const startAdornment = showCheckbox || columnHint ? (_jsx(HeadCellStartAdornment, { showCheckbox: showCheckbox, columnHint: columnHint, checkboxProps: checkboxProps })) : undefined;
|
|
20
|
+
if (isGroupColumns(column)) {
|
|
21
|
+
const position = gridPositions.get(column.label);
|
|
22
|
+
return (_jsx(GroupColumns, { column: column, sorting: sorting, onSort: handleSort, gridPosition: position, startAdornment: startAdornment }, column.label));
|
|
23
|
+
}
|
|
24
|
+
return (_jsx(SingleColumn, { sorting: sorting, field: field, label: label, isSortable: sortable, align: align, startAdornment: startAdornment, onSort: handleSort }, label));
|
|
25
|
+
}) }));
|
|
26
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type CellValue, type DataGridRow, type DataGridSort } from '../../../types';
|
|
3
|
+
type SingleColumnProps<TData extends Record<string, CellValue> = DataGridRow, TSortField extends keyof TData = keyof TData> = {
|
|
4
|
+
field?: keyof TData;
|
|
5
|
+
label?: string;
|
|
6
|
+
isSortable?: boolean;
|
|
7
|
+
align?: 'left' | 'center' | 'right';
|
|
8
|
+
sorting?: DataGridSort<TSortField>;
|
|
9
|
+
onSort: (field: TSortField) => void;
|
|
10
|
+
startAdornment?: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
export declare const SingleColumn: <TData extends Record<string, unknown>, TSortField extends keyof TData>({ field, label, isSortable, align, sorting, onSort, startAdornment, }: SingleColumnProps<TData, TSortField>) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { HeadCell, headCellClassnames } from '../../../HeadCell';
|
|
3
|
+
export const SingleColumn = ({ field, label, isSortable, align, sorting, onSort, startAdornment, }) => (_jsx(HeadCell, { sorting: sorting, field: field, label: label, isSortable: isSortable, align: align, startAdornment: startAdornment, onSort: onSort, className: headCellClassnames.singleColumn }));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SingleColumn';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SingleColumn';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './HeadColumns';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './HeadColumns';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const CheckboxCell: import("../../../styled").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type CSSProperties } from 'react';
|
|
2
|
+
import { type CheckboxProps } from '../../../../Checkbox';
|
|
3
|
+
import { type DataGridRow } from '../../../types';
|
|
4
|
+
import { type HeadColumnsProps } from '../HeadColumns';
|
|
5
|
+
import { type GridPositions } from './utils';
|
|
6
|
+
export declare const useLogic: <TData extends Record<string, unknown> = DataGridRow, TSortField extends keyof TData = keyof TData>({ columns, onSort, sorting, uncheckedRowsCount, rowsCount, onSelectAllRows, }: HeadColumnsProps<TData, TSortField>) => {
|
|
7
|
+
checkboxProps: CheckboxProps;
|
|
8
|
+
handleSort: (field: TSortField) => void;
|
|
9
|
+
gridPositions: Map<string | keyof TData, GridPositions>;
|
|
10
|
+
headerCssVars: (position?: GridPositions) => CSSProperties;
|
|
11
|
+
hasGroupedColumns: boolean;
|
|
12
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useCallback, useMemo } from 'react';
|
|
2
|
+
import { isGroupColumns } from '../../../utils';
|
|
3
|
+
import { getGridPositions } from './utils';
|
|
4
|
+
export const useLogic = ({ columns, onSort, sorting, uncheckedRowsCount, rowsCount, onSelectAllRows, }) => {
|
|
5
|
+
const isChecked = useMemo(() => !uncheckedRowsCount && rowsCount > 0, [uncheckedRowsCount, rowsCount]);
|
|
6
|
+
const isIndeterminate = useMemo(() => uncheckedRowsCount > 0 && uncheckedRowsCount < rowsCount, [uncheckedRowsCount, rowsCount]);
|
|
7
|
+
const isDisabled = !rowsCount;
|
|
8
|
+
const checkboxProps = useMemo(() => ({
|
|
9
|
+
checked: isChecked,
|
|
10
|
+
disabled: isDisabled,
|
|
11
|
+
indeterminate: isIndeterminate,
|
|
12
|
+
onChange: onSelectAllRows,
|
|
13
|
+
}), [isChecked, isDisabled, isIndeterminate, onSelectAllRows]);
|
|
14
|
+
const handleSort = useCallback((field) => {
|
|
15
|
+
if (!onSort) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const isCurrentField = sorting?.fieldId === field;
|
|
19
|
+
if (isCurrentField && sorting?.sort === 'asc') {
|
|
20
|
+
return onSort({ fieldId: field, sort: 'desc' });
|
|
21
|
+
}
|
|
22
|
+
if (isCurrentField && sorting?.sort === 'desc') {
|
|
23
|
+
return onSort(undefined);
|
|
24
|
+
}
|
|
25
|
+
onSort({ fieldId: field, sort: 'asc' });
|
|
26
|
+
}, [sorting, onSort]);
|
|
27
|
+
const gridPositions = useMemo(() => {
|
|
28
|
+
return getGridPositions(columns);
|
|
29
|
+
}, [columns]);
|
|
30
|
+
const headerCssVars = useCallback((position) => {
|
|
31
|
+
if (!position) {
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
'--grid-column-start': position.start,
|
|
36
|
+
'--grid-column-end': position.end,
|
|
37
|
+
};
|
|
38
|
+
}, []);
|
|
39
|
+
return {
|
|
40
|
+
checkboxProps,
|
|
41
|
+
handleSort,
|
|
42
|
+
gridPositions,
|
|
43
|
+
headerCssVars,
|
|
44
|
+
hasGroupedColumns: columns.some(isGroupColumns),
|
|
45
|
+
};
|
|
46
|
+
};
|
package/components/DataGrid/Head/HeadColumns/useLogic/utils/getGridPositions/getGridPositions.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type DataGridColumns } from '../../../../../types';
|
|
2
|
+
export type GridPositions = {
|
|
3
|
+
start: number;
|
|
4
|
+
end: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const getGridPositions: <TData extends Record<string, unknown>>(columns: DataGridColumns<TData>[]) => Map<string | keyof TData, GridPositions>;
|
package/components/DataGrid/Head/HeadColumns/useLogic/utils/getGridPositions/getGridPositions.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isGroupColumns } from '../../../../../utils';
|
|
2
|
+
export const getGridPositions = (columns) => {
|
|
3
|
+
const { positionsMap } = columns.reduce((acc, column) => {
|
|
4
|
+
// Ширина колонки: количество детей для группы или 1 для обычной ячейки
|
|
5
|
+
const width = isGroupColumns(column) ? column.children.length : 1;
|
|
6
|
+
const start = acc.currentLine;
|
|
7
|
+
const end = start + width;
|
|
8
|
+
const key = isGroupColumns(column)
|
|
9
|
+
? column.label
|
|
10
|
+
: column.field || column.label || '';
|
|
11
|
+
acc.positionsMap.set(key, { start, end });
|
|
12
|
+
acc.currentLine = end;
|
|
13
|
+
return acc;
|
|
14
|
+
}, {
|
|
15
|
+
positionsMap: new Map(),
|
|
16
|
+
currentLine: 1,
|
|
17
|
+
});
|
|
18
|
+
return positionsMap;
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getGridPositions';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getGridPositions';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getGridPositions';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getGridPositions';
|