@astral/ui 4.55.4 → 4.57.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/BottomDrawer/styles.js +1 -1
- package/components/CardGridInfinite/Footer/styles.js +1 -1
- package/components/CheckableTag/styles.js +1 -1
- package/components/Checkbox/styles.js +4 -2
- package/components/Chip/styles.js +1 -1
- package/components/CodeField/styles.js +1 -1
- package/components/ComplianceStatus/styles.js +1 -1
- package/components/ContentState/ContentState.d.ts +1 -1
- package/components/ContentState/ContentState.js +2 -2
- package/components/ContentState/types.d.ts +4 -0
- package/components/DashboardLayout/DashboardWrapper/styles.js +1 -1
- package/components/DashboardLayout/Header/styles.js +4 -4
- package/components/DashboardLayoutSkeleton/styles.js +1 -1
- package/components/DashboardSidebar/styles.js +2 -2
- package/components/DashboardSidebarSkeleton/styles.js +1 -1
- package/components/DataGrid/Body/Body.d.ts +1 -1
- package/components/DataGrid/Body/Body.js +14 -7
- package/components/DataGrid/Body/constants.d.ts +4 -0
- package/components/DataGrid/Body/constants.js +5 -0
- package/components/DataGrid/Body/styles.d.ts +0 -3
- package/components/DataGrid/Body/styles.js +14 -1
- package/components/DataGrid/Body/useLogic/index.d.ts +1 -0
- package/components/DataGrid/Body/useLogic/index.js +1 -0
- package/components/DataGrid/Body/useLogic/useLogic.d.ts +9 -0
- package/components/DataGrid/Body/useLogic/useLogic.js +15 -0
- package/components/DataGrid/Cell/Cell.js +20 -4
- package/components/DataGrid/Cell/constants.d.ts +7 -0
- package/components/DataGrid/Cell/constants.js +8 -0
- package/components/DataGrid/Cell/styles.d.ts +14 -0
- package/components/DataGrid/Cell/styles.js +47 -0
- package/components/DataGrid/Cell/useLogic/useLogic.d.ts +2 -0
- package/components/DataGrid/Cell/useLogic/useLogic.js +3 -2
- package/components/DataGrid/DataGrid.js +42 -8
- package/components/DataGrid/Head/Head.js +1 -1
- package/components/DataGrid/Head/styles.js +5 -1
- package/components/DataGrid/Loader/styles.js +4 -0
- package/components/DataGrid/MobileSkeleton/MobileSkeleton.d.ts +6 -0
- package/components/DataGrid/MobileSkeleton/MobileSkeleton.js +10 -0
- package/components/DataGrid/MobileSkeleton/index.d.ts +1 -0
- package/components/DataGrid/MobileSkeleton/index.js +1 -0
- package/components/DataGrid/MobileSkeleton/styles.d.ts +17 -0
- package/components/DataGrid/MobileSkeleton/styles.js +37 -0
- package/components/DataGrid/PinnedSections/Section/styles.js +2 -2
- package/components/DataGrid/Row/NestedChildren/styles.js +8 -3
- package/components/DataGrid/Row/Row.js +25 -8
- package/components/DataGrid/Row/constants.d.ts +8 -0
- package/components/DataGrid/Row/constants.js +8 -0
- package/components/DataGrid/Row/styles.d.ts +4 -9
- package/components/DataGrid/Row/styles.js +69 -17
- package/components/DataGrid/Row/types.d.ts +5 -1
- package/components/DataGrid/Row/useLogic/hooks/index.d.ts +1 -0
- package/components/DataGrid/Row/useLogic/hooks/index.js +1 -0
- package/components/DataGrid/Row/useLogic/hooks/useMobileLogic.d.ts +5 -0
- package/components/DataGrid/Row/useLogic/hooks/useMobileLogic.js +15 -0
- package/components/DataGrid/Row/useLogic/useLogic.d.ts +868 -3
- package/components/DataGrid/Row/useLogic/useLogic.js +28 -13
- package/components/DataGrid/constants.d.ts +4 -0
- package/components/DataGrid/constants.js +4 -0
- package/components/DataGrid/index.d.ts +1 -0
- package/components/DataGrid/index.js +1 -0
- package/components/DataGrid/styles.d.ts +0 -9
- package/components/DataGrid/styles.js +43 -12
- package/components/DataGrid/types.d.ts +7 -0
- package/components/DataGrid/useLogic/hooks/index.d.ts +1 -1
- package/components/DataGrid/useLogic/hooks/index.js +1 -1
- package/components/DataGrid/useLogic/hooks/useDataGridMobileLogic/index.d.ts +1 -0
- package/components/DataGrid/useLogic/hooks/useDataGridMobileLogic/index.js +1 -0
- package/components/DataGrid/useLogic/hooks/useDataGridMobileLogic/useDataGridMobileLogic.d.ts +16 -0
- package/components/DataGrid/useLogic/hooks/useDataGridMobileLogic/useDataGridMobileLogic.js +32 -0
- package/components/DataGrid/useLogic/hooks/usePinnedColumns/usePinnedColumns.js +11 -3
- package/components/DataGrid/useLogic/useLogic.d.ts +10 -4
- package/components/DataGrid/useLogic/useLogic.js +17 -12
- package/components/DataGrid/useLogic/utils/getIsAllowHorizontalScroll/getIsAllowHorizontalScroll.js +1 -1
- package/components/DataGrid/utils/getDataGridCssVars/getDataGridCssVars.d.ts +2 -0
- package/components/DataGrid/utils/getDataGridCssVars/getDataGridCssVars.js +5 -0
- package/components/DataGrid/utils/getDataGridCssVars/index.d.ts +1 -0
- package/components/DataGrid/utils/getDataGridCssVars/index.js +1 -0
- package/components/DataGrid/utils/index.d.ts +1 -0
- package/components/DataGrid/utils/index.js +1 -0
- package/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActions.js +1 -1
- package/components/DataGridInfinite/DataGridInfinite.js +5 -4
- package/components/DataGridInfinite/useLogic/useLogic.d.ts +7 -1
- package/components/DataGridInfinite/useLogic/useLogic.js +12 -2
- package/components/DateRangePicker/styles.js +1 -1
- package/components/Description/Name/styles.js +1 -1
- package/components/DescriptionCell/styles.js +12 -3
- package/components/DescriptionList/styles.js +4 -2
- package/components/ExpansionPanel/styles.js +1 -1
- package/components/InfiniteDataList/styles.js +1 -1
- package/components/InfiniteTreeList/TreeItem/styles.js +1 -1
- package/components/MenuOrganization/styles.js +2 -2
- package/components/NewStepper/Step/Description/styles.js +1 -1
- package/components/NewStepper/Step/styles.js +2 -2
- package/components/NewStepper/index.d.ts +1 -0
- package/components/NewStepper/index.js +1 -0
- package/components/NewStepper/public.d.ts +1 -0
- package/components/NewStepper/public.js +1 -0
- package/components/PageAside/styles.js +3 -3
- package/components/PageContent/PageContentHeader/styles.js +2 -2
- package/components/PageContent/styles.js +4 -2
- package/components/PageHeader/HeaderContent/styles.js +1 -1
- package/components/PageHeader/styles.js +2 -2
- package/components/PageLayoutLoader/styles.js +1 -1
- package/components/PageLayoutSection/PageLayoutSection.d.ts +4 -0
- package/components/PageLayoutSection/PageLayoutSection.js +13 -4
- package/components/PageLayoutSection/PageLayoutSectionContainer/styles.js +1 -1
- package/components/PageLayoutSection/constants.d.ts +5 -0
- package/components/PageLayoutSection/constants.js +6 -0
- package/components/PageLayoutSection/styles.d.ts +1 -1
- package/components/PageLayoutSection/styles.js +7 -2
- package/components/PagePinnableAside/styles.js +6 -6
- package/components/PdfViewer/PdfPage/styles.js +2 -2
- package/components/Radio/styles.js +4 -2
- package/components/RadioCard/styles.js +13 -5
- package/components/SideDialogActions/styles.js +1 -1
- package/components/SideDialogHeader/styles.js +1 -1
- package/components/SideDialogTitle/styles.js +1 -1
- package/components/Stepper/styles.js +2 -2
- package/components/Tag/styles.js +1 -1
- package/components/Tree/TreeItem/styles.js +3 -3
- package/components/fileUploading/FileUploaderDropzone/DropzoneWrapper/styles.js +1 -1
- package/components/fileUploading/FileUploaderFile/styles.js +1 -1
- package/components/placeholders/LoadingPlaceholder/LoadingPlaceholder.d.ts +5 -1
- package/components/placeholders/LoadingPlaceholder/LoadingPlaceholder.js +5 -4
- package/components/theme/components/MuiButton.js +1 -1
- package/components/theme/components/MuiDivider.d.ts +3 -0
- package/components/theme/components/MuiDivider.js +9 -0
- package/components/theme/components/MuiListItem.d.ts +3 -0
- package/components/theme/components/MuiListItem.js +9 -0
- package/components/theme/components/MuiOutlinedInput.js +2 -2
- package/components/theme/components/MuiPaper.js +1 -1
- package/components/theme/components/MuiStepConnector.js +4 -1
- package/components/theme/components/components.js +4 -0
- package/components/theme/palette/componentsColors/componentsColors.d.ts +3 -0
- package/components/theme/palette/componentsColors/componentsColors.js +3 -0
- package/node/components/BottomDrawer/styles.js +1 -1
- package/node/components/CardGridInfinite/Footer/styles.js +1 -1
- package/node/components/CheckableTag/styles.js +1 -1
- package/node/components/Checkbox/styles.js +4 -2
- package/node/components/Chip/styles.js +1 -1
- package/node/components/CodeField/styles.js +1 -1
- package/node/components/ComplianceStatus/styles.js +1 -1
- package/node/components/ContentState/ContentState.d.ts +1 -1
- package/node/components/ContentState/ContentState.js +2 -2
- package/node/components/ContentState/types.d.ts +4 -0
- package/node/components/DashboardLayout/DashboardWrapper/styles.js +1 -1
- package/node/components/DashboardLayout/Header/styles.js +4 -4
- package/node/components/DashboardLayoutSkeleton/styles.js +1 -1
- package/node/components/DashboardSidebar/styles.js +2 -2
- package/node/components/DashboardSidebarSkeleton/styles.js +1 -1
- package/node/components/DataGrid/Body/Body.d.ts +1 -1
- package/node/components/DataGrid/Body/Body.js +14 -7
- package/node/components/DataGrid/Body/constants.d.ts +4 -0
- package/node/components/DataGrid/Body/constants.js +8 -0
- package/node/components/DataGrid/Body/styles.d.ts +0 -3
- package/node/components/DataGrid/Body/styles.js +14 -1
- package/node/components/DataGrid/Body/useLogic/index.d.ts +1 -0
- package/node/components/DataGrid/{useLogic/hooks/useClassnames → Body/useLogic}/index.js +1 -1
- package/node/components/DataGrid/Body/useLogic/useLogic.d.ts +9 -0
- package/node/components/DataGrid/Body/useLogic/useLogic.js +19 -0
- package/node/components/DataGrid/Cell/Cell.js +18 -2
- package/node/components/DataGrid/Cell/constants.d.ts +7 -0
- package/node/components/DataGrid/Cell/constants.js +11 -0
- package/node/components/DataGrid/Cell/styles.d.ts +14 -0
- package/node/components/DataGrid/Cell/styles.js +48 -1
- package/node/components/DataGrid/Cell/useLogic/useLogic.d.ts +2 -0
- package/node/components/DataGrid/Cell/useLogic/useLogic.js +3 -2
- package/node/components/DataGrid/DataGrid.js +41 -7
- package/node/components/DataGrid/Head/Head.js +1 -1
- package/node/components/DataGrid/Head/styles.js +5 -1
- package/node/components/DataGrid/Loader/styles.js +4 -0
- package/node/components/DataGrid/MobileSkeleton/MobileSkeleton.d.ts +6 -0
- package/node/components/DataGrid/MobileSkeleton/MobileSkeleton.js +14 -0
- package/node/components/DataGrid/MobileSkeleton/index.d.ts +1 -0
- package/node/components/DataGrid/MobileSkeleton/index.js +17 -0
- package/node/components/DataGrid/MobileSkeleton/styles.d.ts +17 -0
- package/node/components/DataGrid/MobileSkeleton/styles.js +40 -0
- package/node/components/DataGrid/PinnedSections/Section/styles.js +2 -2
- package/node/components/DataGrid/Row/NestedChildren/styles.js +8 -3
- package/node/components/DataGrid/Row/Row.js +23 -6
- 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 +4 -9
- package/node/components/DataGrid/Row/styles.js +69 -17
- package/node/components/DataGrid/Row/types.d.ts +5 -1
- package/node/components/DataGrid/Row/useLogic/hooks/index.d.ts +1 -0
- package/node/components/DataGrid/Row/useLogic/hooks/index.js +17 -0
- package/node/components/DataGrid/Row/useLogic/hooks/useMobileLogic.d.ts +5 -0
- package/node/components/DataGrid/Row/useLogic/hooks/useMobileLogic.js +19 -0
- package/node/components/DataGrid/Row/useLogic/useLogic.d.ts +868 -3
- package/node/components/DataGrid/Row/useLogic/useLogic.js +28 -13
- package/node/components/DataGrid/constants.d.ts +4 -0
- package/node/components/DataGrid/constants.js +5 -1
- package/node/components/DataGrid/index.d.ts +1 -0
- package/node/components/DataGrid/index.js +3 -1
- package/node/components/DataGrid/styles.d.ts +0 -9
- package/node/components/DataGrid/styles.js +43 -12
- package/node/components/DataGrid/types.d.ts +7 -0
- package/node/components/DataGrid/useLogic/hooks/index.d.ts +1 -1
- package/node/components/DataGrid/useLogic/hooks/index.js +1 -1
- package/node/components/DataGrid/useLogic/hooks/useDataGridMobileLogic/index.d.ts +1 -0
- package/node/components/DataGrid/useLogic/hooks/useDataGridMobileLogic/index.js +17 -0
- package/node/components/DataGrid/useLogic/hooks/useDataGridMobileLogic/useDataGridMobileLogic.d.ts +16 -0
- package/node/components/DataGrid/useLogic/hooks/useDataGridMobileLogic/useDataGridMobileLogic.js +36 -0
- package/node/components/DataGrid/useLogic/hooks/usePinnedColumns/usePinnedColumns.js +11 -3
- package/node/components/DataGrid/useLogic/useLogic.d.ts +10 -4
- package/node/components/DataGrid/useLogic/useLogic.js +19 -14
- package/node/components/DataGrid/useLogic/utils/getIsAllowHorizontalScroll/getIsAllowHorizontalScroll.js +1 -1
- package/node/components/DataGrid/utils/getDataGridCssVars/getDataGridCssVars.d.ts +2 -0
- package/node/components/DataGrid/utils/getDataGridCssVars/getDataGridCssVars.js +9 -0
- package/node/components/DataGrid/utils/getDataGridCssVars/index.d.ts +1 -0
- package/node/components/DataGrid/utils/getDataGridCssVars/index.js +5 -0
- package/node/components/DataGrid/utils/index.d.ts +1 -0
- package/node/components/DataGrid/utils/index.js +3 -1
- package/node/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActions.js +1 -1
- package/node/components/DataGridInfinite/DataGridInfinite.js +5 -4
- package/node/components/DataGridInfinite/useLogic/useLogic.d.ts +7 -1
- package/node/components/DataGridInfinite/useLogic/useLogic.js +11 -1
- package/node/components/DateRangePicker/styles.js +1 -1
- package/node/components/Description/Name/styles.js +1 -1
- package/node/components/DescriptionCell/styles.js +15 -6
- package/node/components/DescriptionList/styles.js +4 -2
- package/node/components/ExpansionPanel/styles.js +1 -1
- package/node/components/InfiniteDataList/styles.js +1 -1
- package/node/components/InfiniteTreeList/TreeItem/styles.js +1 -1
- package/node/components/MenuOrganization/styles.js +2 -2
- package/node/components/NewStepper/Step/Description/styles.js +1 -1
- package/node/components/NewStepper/Step/styles.js +2 -2
- package/node/components/NewStepper/index.d.ts +1 -0
- package/node/components/NewStepper/index.js +3 -1
- package/node/components/NewStepper/public.d.ts +1 -0
- package/node/components/NewStepper/public.js +3 -1
- package/node/components/PageAside/styles.js +3 -3
- package/node/components/PageContent/PageContentHeader/styles.js +2 -2
- package/node/components/PageContent/styles.js +4 -2
- package/node/components/PageHeader/HeaderContent/styles.js +1 -1
- package/node/components/PageHeader/styles.js +2 -2
- package/node/components/PageLayoutLoader/styles.js +1 -1
- package/node/components/PageLayoutSection/PageLayoutSection.d.ts +4 -0
- package/node/components/PageLayoutSection/PageLayoutSection.js +12 -3
- package/node/components/PageLayoutSection/PageLayoutSectionContainer/styles.js +1 -1
- package/node/components/PageLayoutSection/constants.d.ts +5 -0
- package/node/components/PageLayoutSection/constants.js +9 -0
- package/node/components/PageLayoutSection/styles.d.ts +1 -1
- package/node/components/PageLayoutSection/styles.js +8 -3
- package/node/components/PagePinnableAside/styles.js +6 -6
- package/node/components/PdfViewer/PdfPage/styles.js +2 -2
- package/node/components/Radio/styles.js +4 -2
- package/node/components/RadioCard/styles.js +13 -5
- package/node/components/SideDialogActions/styles.js +1 -1
- package/node/components/SideDialogHeader/styles.js +1 -1
- package/node/components/SideDialogTitle/styles.js +1 -1
- package/node/components/Stepper/styles.js +2 -2
- package/node/components/Tag/styles.js +1 -1
- package/node/components/Tree/TreeItem/styles.js +3 -3
- package/node/components/fileUploading/FileUploaderDropzone/DropzoneWrapper/styles.js +1 -1
- package/node/components/fileUploading/FileUploaderFile/styles.js +1 -1
- package/node/components/placeholders/LoadingPlaceholder/LoadingPlaceholder.d.ts +5 -1
- package/node/components/placeholders/LoadingPlaceholder/LoadingPlaceholder.js +5 -4
- package/node/components/theme/components/MuiButton.js +1 -1
- package/node/components/theme/components/MuiDivider.d.ts +3 -0
- package/node/components/theme/components/MuiDivider.js +12 -0
- package/node/components/theme/components/MuiListItem.d.ts +3 -0
- package/node/components/theme/components/MuiListItem.js +12 -0
- package/node/components/theme/components/MuiOutlinedInput.js +2 -2
- package/node/components/theme/components/MuiPaper.js +1 -1
- package/node/components/theme/components/MuiStepConnector.js +4 -1
- package/node/components/theme/components/components.js +4 -0
- package/node/components/theme/palette/componentsColors/componentsColors.d.ts +3 -0
- package/node/components/theme/palette/componentsColors/componentsColors.js +3 -0
- package/package.json +20 -1
- package/components/DataGrid/useLogic/hooks/useClassnames/index.d.ts +0 -1
- package/components/DataGrid/useLogic/hooks/useClassnames/index.js +0 -1
- package/components/DataGrid/useLogic/hooks/useClassnames/useClassnames.d.ts +0 -12
- package/components/DataGrid/useLogic/hooks/useClassnames/useClassnames.js +0 -14
- package/node/components/DataGrid/useLogic/hooks/useClassnames/index.d.ts +0 -1
- package/node/components/DataGrid/useLogic/hooks/useClassnames/useClassnames.d.ts +0 -12
- package/node/components/DataGrid/useLogic/hooks/useClassnames/useClassnames.js +0 -18
|
@@ -4,8 +4,10 @@ import { DataGridContext } from '../../DataGridContext';
|
|
|
4
4
|
import { Variant } from '../../enums';
|
|
5
5
|
import { DISABLE_ROW_ATTR } from '../constants';
|
|
6
6
|
import { RowContext } from '../RowContext';
|
|
7
|
+
import { useMobileLogic } from './hooks';
|
|
7
8
|
import { mergeColumnsOptions } from './utils';
|
|
8
|
-
export const useLogic = ({ keyId, columns, row, nestedChildren, level, variant,
|
|
9
|
+
export const useLogic = ({ keyId, columns, row, nestedChildren, level, variant, options, isInitialExpanded = false, expandedLevel, isSelectable, selectedRows, onSelectRow, onRowClick, isVisibleCollapseButton, registerRowElement, unregisterRowElement, style, }) => {
|
|
10
|
+
const { isDrawerOpen, handleOpenDrawer, handleCloseDrawer } = useMobileLogic();
|
|
9
11
|
const isDefaultExpanded = isInitialExpanded && level <= expandedLevel - 1 && nestedChildren?.length;
|
|
10
12
|
const { checkIsOpened, toggleOpenItems } = useContext(DataGridContext);
|
|
11
13
|
const { isDisabled, disabledReason } = useContext(RowContext);
|
|
@@ -25,6 +27,16 @@ export const useLogic = ({ keyId, columns, row, nestedChildren, level, variant,
|
|
|
25
27
|
const { isDisabled: isExternalDisabled, disabledReason: externalDisabledReason, href, target, } = options || {};
|
|
26
28
|
const disabled = isDisabled || isExternalDisabled;
|
|
27
29
|
const isOpen = checkIsOpened(rowId);
|
|
30
|
+
const handleRowClick = () => {
|
|
31
|
+
if (disabled) {
|
|
32
|
+
handleOpenDrawer();
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
if (href) {
|
|
36
|
+
return redirectToLink(href, target);
|
|
37
|
+
}
|
|
38
|
+
onRowClick?.(row);
|
|
39
|
+
};
|
|
28
40
|
useEffect(() => {
|
|
29
41
|
// Проверка на isOpen необходима для infinite версии с виртуализацией, когда происходит размонтировании компонента
|
|
30
42
|
if (isDefaultExpanded && !isOpen) {
|
|
@@ -57,17 +69,16 @@ export const useLogic = ({ keyId, columns, row, nestedChildren, level, variant,
|
|
|
57
69
|
setVisibleTooltip(false);
|
|
58
70
|
}
|
|
59
71
|
};
|
|
60
|
-
const handleRowClick = () => {
|
|
61
|
-
if (disabled) {
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
if (href) {
|
|
65
|
-
return redirectToLink(href, target);
|
|
66
|
-
}
|
|
67
|
-
onRowClick?.(row);
|
|
68
|
-
};
|
|
69
72
|
const isRenderCollapseButton = Boolean(nestedChildren?.length) && isVisibleCollapseButton;
|
|
73
|
+
const rowStyles = useMemo(() => ({
|
|
74
|
+
'--level': level,
|
|
75
|
+
...style,
|
|
76
|
+
}), [level, style]);
|
|
77
|
+
const isHovered = Boolean(!disabled && (onRowClick || href));
|
|
78
|
+
const disabledReasonText = externalDisabledReason || disabledReason;
|
|
70
79
|
return {
|
|
80
|
+
disabledReasonText,
|
|
81
|
+
rowStyles,
|
|
71
82
|
isOpen,
|
|
72
83
|
isShowConnector,
|
|
73
84
|
childrenColumns,
|
|
@@ -76,15 +87,19 @@ export const useLogic = ({ keyId, columns, row, nestedChildren, level, variant,
|
|
|
76
87
|
disabled,
|
|
77
88
|
isRenderCollapseButton,
|
|
78
89
|
handleToggle,
|
|
90
|
+
isHovered,
|
|
79
91
|
rowProps: {
|
|
80
|
-
$isHovered: Boolean(!disabled && (onRowClick || href)),
|
|
81
|
-
$isSelected: activeRowId === rowId,
|
|
82
92
|
onClick: handleRowClick,
|
|
83
93
|
onMouseMove: handleMouseMove,
|
|
84
94
|
},
|
|
95
|
+
drawerProps: {
|
|
96
|
+
open: isDrawerOpen,
|
|
97
|
+
onClose: handleCloseDrawer,
|
|
98
|
+
title: 'Заблокировано',
|
|
99
|
+
},
|
|
85
100
|
tooltipProps: {
|
|
86
101
|
open: isVisibleTooltip,
|
|
87
|
-
title: disabled ?
|
|
102
|
+
title: disabled ? disabledReasonText : undefined,
|
|
88
103
|
onOpen: handleOpenTooltip,
|
|
89
104
|
onClose: handleCloseTooltip,
|
|
90
105
|
},
|
|
@@ -2,9 +2,11 @@ export declare const MIN_ROW_HEIGHT = 44;
|
|
|
2
2
|
export declare const ROOT_ACTION_CELL_WIDTH = 32;
|
|
3
3
|
export declare const TREE_LINE_WIDTH: number;
|
|
4
4
|
export declare const MIN_DISPLAY_ROWS_BY_DEFAULT = 10;
|
|
5
|
+
export declare const DEFAULT_MOBILE_SKELETON_ROWS_COUNT = 5;
|
|
5
6
|
export declare const EXPANDED_LEVEL_BY_DEFAULT = 1;
|
|
6
7
|
export declare const INITIAL_OPENED_NESTED_CHILDREN_COUNT_BY_DEFAULT = 2;
|
|
7
8
|
export declare const dataGridClassnames: {
|
|
9
|
+
loadingPlaceholder: string;
|
|
8
10
|
header: string;
|
|
9
11
|
root: string;
|
|
10
12
|
body: string;
|
|
@@ -16,4 +18,6 @@ export declare const dataGridClassnames: {
|
|
|
16
18
|
leftPinnedSection: string;
|
|
17
19
|
rightPinnedSection: string;
|
|
18
20
|
overflowed: string;
|
|
21
|
+
wrapper: string;
|
|
22
|
+
isAllowHorizontalScroll: string;
|
|
19
23
|
};
|
|
@@ -3,9 +3,11 @@ export const MIN_ROW_HEIGHT = 44;
|
|
|
3
3
|
export const ROOT_ACTION_CELL_WIDTH = 32;
|
|
4
4
|
export const TREE_LINE_WIDTH = ROOT_ACTION_CELL_WIDTH / 2;
|
|
5
5
|
export const MIN_DISPLAY_ROWS_BY_DEFAULT = 10;
|
|
6
|
+
export const DEFAULT_MOBILE_SKELETON_ROWS_COUNT = 5;
|
|
6
7
|
export const EXPANDED_LEVEL_BY_DEFAULT = 1;
|
|
7
8
|
export const INITIAL_OPENED_NESTED_CHILDREN_COUNT_BY_DEFAULT = 2;
|
|
8
9
|
export const dataGridClassnames = {
|
|
10
|
+
loadingPlaceholder: createUIKitClassname('data-grid__loading-placeholder'),
|
|
9
11
|
header: createUIKitClassname('data-grid__header'),
|
|
10
12
|
root: createUIKitClassname('data-grid'),
|
|
11
13
|
body: createUIKitClassname('data-grid__body'),
|
|
@@ -17,4 +19,6 @@ export const dataGridClassnames = {
|
|
|
17
19
|
leftPinnedSection: createUIKitClassname('data-grid__left-pinned-section'),
|
|
18
20
|
rightPinnedSection: createUIKitClassname('data-grid__right-pinned-section'),
|
|
19
21
|
overflowed: createUIKitClassname('data-grid_overflowed'),
|
|
22
|
+
wrapper: createUIKitClassname('data-grid__wrapper'),
|
|
23
|
+
isAllowHorizontalScroll: createUIKitClassname('data-grid_is-allow-horizontal-scroll'),
|
|
20
24
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { DataGrid } from './DataGrid';
|
|
2
2
|
export type { DataGridProps, DataGridColumns, DataGridRow, DataGridRowOptions, DataGridSort, DataGridRowWithOptions, DataGridRowOptionColumns, } from './types';
|
|
3
3
|
export { dataGridClassnames } from './constants';
|
|
4
|
+
export { MobileSkeleton } from './MobileSkeleton';
|
|
@@ -2,23 +2,14 @@
|
|
|
2
2
|
export declare const Container: import("../styled").StyledComponent<{
|
|
3
3
|
theme?: import("@emotion/react").Theme | undefined;
|
|
4
4
|
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
5
|
-
} & {
|
|
6
|
-
$maxHeight?: number | undefined;
|
|
7
|
-
$isAllowHorizontalScroll?: boolean | undefined;
|
|
8
5
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
9
6
|
export declare const DataGridWrapper: import("../styled").StyledComponent<{
|
|
10
7
|
theme?: import("@emotion/react").Theme | undefined;
|
|
11
8
|
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
12
|
-
} & {
|
|
13
|
-
$isAllowHorizontalScroll?: boolean | undefined;
|
|
14
9
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
15
10
|
export declare const DisabledDataGridWrapper: import("../styled").StyledComponent<{
|
|
16
11
|
theme?: import("@emotion/react").Theme | undefined;
|
|
17
12
|
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
18
|
-
} & {
|
|
19
|
-
$isAllowHorizontalScroll?: boolean | undefined;
|
|
20
13
|
} & import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
21
14
|
theme?: import("@emotion/react").Theme | undefined;
|
|
22
|
-
} & {
|
|
23
|
-
$isAllowHorizontalScroll: boolean;
|
|
24
15
|
}, {}, {}>;
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { styled } from '../styled';
|
|
2
2
|
import { dataGridClassnames } from './constants';
|
|
3
|
-
export const Container = styled
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export const Container = styled.div `
|
|
4
|
+
--max-height: initial;
|
|
5
|
+
|
|
6
6
|
position: relative;
|
|
7
7
|
|
|
8
|
-
overflow:
|
|
8
|
+
overflow: hidden;
|
|
9
9
|
display: flex;
|
|
10
10
|
flex-direction: column;
|
|
11
11
|
|
|
12
12
|
width: 100%;
|
|
13
13
|
height: 100%;
|
|
14
|
-
max-height:
|
|
14
|
+
max-height: var(--max-height);
|
|
15
|
+
|
|
16
|
+
&.${dataGridClassnames.isAllowHorizontalScroll} {
|
|
17
|
+
overflow: auto hidden;
|
|
18
|
+
|
|
19
|
+
& .${dataGridClassnames.wrapper} {
|
|
20
|
+
overflow: auto hidden;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
15
23
|
|
|
16
24
|
&.${dataGridClassnames.dataGridHasPinnedSections} {
|
|
17
25
|
overflow: hidden;
|
|
@@ -28,21 +36,44 @@ export const Container = styled('div', {
|
|
|
28
36
|
}
|
|
29
37
|
}
|
|
30
38
|
}
|
|
39
|
+
|
|
40
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
41
|
+
/* Нужен для того что бы scroll доходил до вверха страницы на мобильных устройствах после пагинации */
|
|
42
|
+
scroll-margin-top: ${({ theme }) => theme.spacing(8)};
|
|
43
|
+
|
|
44
|
+
overflow: initial;
|
|
45
|
+
|
|
46
|
+
& .${dataGridClassnames.loadingPlaceholder} {
|
|
47
|
+
justify-content: flex-start;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&.${dataGridClassnames.dataGridHasPinnedSections} {
|
|
51
|
+
overflow: initial;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&.${dataGridClassnames.isAllowHorizontalScroll} {
|
|
55
|
+
overflow: initial;
|
|
56
|
+
|
|
57
|
+
& .${dataGridClassnames.wrapper} {
|
|
58
|
+
overflow: initial;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
31
62
|
`;
|
|
32
|
-
export const DataGridWrapper = styled
|
|
33
|
-
shouldForwardProp: (prop) => !['$isAllowHorizontalScroll'].includes(prop),
|
|
34
|
-
}) `
|
|
63
|
+
export const DataGridWrapper = styled.div `
|
|
35
64
|
position: relative;
|
|
36
65
|
|
|
37
|
-
overflow:
|
|
66
|
+
overflow: hidden;
|
|
38
67
|
display: flex;
|
|
39
68
|
flex-direction: column;
|
|
40
69
|
|
|
41
70
|
height: 100%;
|
|
71
|
+
|
|
72
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
73
|
+
overflow: initial;
|
|
74
|
+
}
|
|
42
75
|
`;
|
|
43
|
-
export const DisabledDataGridWrapper = styled(DataGridWrapper
|
|
44
|
-
shouldForwardProp: (prop) => !['$isAllowHorizontalScroll'].includes(prop),
|
|
45
|
-
}) `
|
|
76
|
+
export const DisabledDataGridWrapper = styled(DataGridWrapper) `
|
|
46
77
|
pointer-events: none;
|
|
47
78
|
|
|
48
79
|
background: ${({ theme }) => theme.palette.background.element};
|
|
@@ -27,6 +27,9 @@ export type DataGridProps<TData extends Record<string, CellValue> = DataGridRow,
|
|
|
27
27
|
columns: DataGridColumns<TData>[];
|
|
28
28
|
/**
|
|
29
29
|
* Идентификатор активного элемента массива rows. Выделяет активную строку в таблице
|
|
30
|
+
*
|
|
31
|
+
* @deprecated Не поддерживается, параметр будет удален в следующей major версии пакета.
|
|
32
|
+
* Мотивация: Использование активного элемента не является типичным сценарием использования таблицы.
|
|
30
33
|
*/
|
|
31
34
|
activeRowId?: string;
|
|
32
35
|
/**
|
|
@@ -236,6 +239,10 @@ export type DataGridColumns<TData extends Record<string, CellValue>> = {
|
|
|
236
239
|
* Закрепление колонки в таблице
|
|
237
240
|
*/
|
|
238
241
|
pinned?: 'left' | 'right';
|
|
242
|
+
/**
|
|
243
|
+
* Скрывает колонку на мобильных устройствах
|
|
244
|
+
*/
|
|
245
|
+
isHideOnMobile?: boolean;
|
|
239
246
|
};
|
|
240
247
|
export type DataGridRowOptionColumns<TData extends Record<string, CellValue>> = {
|
|
241
248
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useDataGridMobileLogic';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useDataGridMobileLogic';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import { type CellValue, type DataGridColumns, type DataGridRow } from '../../../types';
|
|
3
|
+
type UseDataGridMobileLogicParams<TData extends Record<string, CellValue> = DataGridRow> = {
|
|
4
|
+
containerRef?: RefObject<HTMLDivElement | null>;
|
|
5
|
+
isLoading?: boolean;
|
|
6
|
+
columns?: DataGridColumns<TData>[];
|
|
7
|
+
rows?: TData[];
|
|
8
|
+
};
|
|
9
|
+
export declare const useDataGridMobileLogic: <TData extends Record<string, unknown> = DataGridRow>({ containerRef, isLoading, columns, rows, }: UseDataGridMobileLogicParams<TData>) => {
|
|
10
|
+
isMobile: boolean;
|
|
11
|
+
mobileSkeletonProps: {
|
|
12
|
+
cellsCount: number;
|
|
13
|
+
rowsCount: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, } from 'react';
|
|
2
|
+
import { useViewportType } from '../../../../useViewportType';
|
|
3
|
+
import { DEFAULT_MOBILE_SKELETON_ROWS_COUNT } from '../../../constants';
|
|
4
|
+
export const useDataGridMobileLogic = ({ containerRef, isLoading, columns, rows, }) => {
|
|
5
|
+
const { isMobile } = useViewportType();
|
|
6
|
+
const firstLoadedRowsCountRef = useRef(null);
|
|
7
|
+
const mobileSkeletonCellsCount = useMemo(() => columns?.filter((column) => !column.isHideOnMobile).length ?? 0, [columns]);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (!isLoading &&
|
|
10
|
+
rows &&
|
|
11
|
+
rows.length > 0 &&
|
|
12
|
+
firstLoadedRowsCountRef.current === null) {
|
|
13
|
+
firstLoadedRowsCountRef.current = rows.length;
|
|
14
|
+
}
|
|
15
|
+
}, [rows, isLoading]);
|
|
16
|
+
useLayoutEffect(() => {
|
|
17
|
+
if (!isMobile) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (isLoading && containerRef?.current) {
|
|
21
|
+
containerRef.current.scrollIntoView({
|
|
22
|
+
block: 'start',
|
|
23
|
+
behavior: 'instant',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}, [containerRef, isLoading, isMobile]);
|
|
27
|
+
const mobileSkeletonProps = {
|
|
28
|
+
cellsCount: mobileSkeletonCellsCount,
|
|
29
|
+
rowsCount: firstLoadedRowsCountRef.current ?? DEFAULT_MOBILE_SKELETON_ROWS_COUNT,
|
|
30
|
+
};
|
|
31
|
+
return { isMobile, mobileSkeletonProps };
|
|
32
|
+
};
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { useCallback, useLayoutEffect, useMemo, useRef } from 'react';
|
|
2
|
+
import { useViewportType } from '../../../../useViewportType';
|
|
2
3
|
import { dataGridClassnames } from '../../../constants';
|
|
3
4
|
import { useRowHover } from '../../../hooks/useRowHover';
|
|
4
5
|
import { getColumnSections } from '../../utils/getColumnSections';
|
|
5
6
|
import { syncRowsHeight } from '../../utils/syncRowsHeight';
|
|
6
7
|
export const usePinnedColumns = ({ isLoading, columns, }) => {
|
|
7
8
|
const containerRef = useRef(null);
|
|
9
|
+
const { isMobile } = useViewportType();
|
|
8
10
|
const hasPinnedColumns = useMemo(() => columns.some((column) => column.pinned), [columns]);
|
|
9
|
-
const
|
|
11
|
+
const isRowHoverSyncEnabled = hasPinnedColumns && !isMobile;
|
|
12
|
+
const { rowsMapRef, ...rowHoverProps } = useRowHover({
|
|
13
|
+
hasPinnedColumns: isRowHoverSyncEnabled,
|
|
14
|
+
});
|
|
10
15
|
const isScrollStateSupported = CSS.supports('container-type', 'scroll-state');
|
|
11
16
|
const checkOverflow = useCallback((element) => {
|
|
12
17
|
if (element) {
|
|
@@ -16,7 +21,10 @@ export const usePinnedColumns = ({ isLoading, columns, }) => {
|
|
|
16
21
|
}, []);
|
|
17
22
|
const { sections } = useMemo(() => getColumnSections(columns), [columns]);
|
|
18
23
|
useLayoutEffect(() => {
|
|
19
|
-
if (isLoading ||
|
|
24
|
+
if (isLoading ||
|
|
25
|
+
!hasPinnedColumns ||
|
|
26
|
+
isMobile ||
|
|
27
|
+
typeof window === 'undefined') {
|
|
20
28
|
return;
|
|
21
29
|
}
|
|
22
30
|
const resizeObserver = new ResizeObserver(() => {
|
|
@@ -38,6 +46,6 @@ export const usePinnedColumns = ({ isLoading, columns, }) => {
|
|
|
38
46
|
return () => {
|
|
39
47
|
resizeObserver.disconnect();
|
|
40
48
|
};
|
|
41
|
-
}, [hasPinnedColumns, isLoading]);
|
|
49
|
+
}, [hasPinnedColumns, isLoading, isMobile]);
|
|
42
50
|
return { containerRef, rowHoverProps, sections, hasPinnedColumns };
|
|
43
51
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type ChangeEvent } from 'react';
|
|
2
2
|
import type { CellValue, DataGridProps, DataGridRow } from '../types';
|
|
3
3
|
type UseLogicParams<TData extends Record<string, CellValue> = DataGridRow, TSortField extends keyof TData = keyof TData> = DataGridProps<TData, TSortField>;
|
|
4
|
-
export declare const useLogic: <TData extends Record<string, unknown> = DataGridRow, TSortField extends keyof TData = keyof TData>({ keyId, columns, rows, variant, tree, subrows, selectedRows, isLoading, isDisabled, onSelectRow, isError, onRetry, errorMsg, isHideSelectAll, isHideHeaderIfNoData, sorting, className, onSort, }: UseLogicParams<TData, TSortField>) => {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export declare const useLogic: <TData extends Record<string, unknown> = DataGridRow, TSortField extends keyof TData = keyof TData>({ keyId, columns, rows, variant, tree, subrows, selectedRows, isLoading, isDisabled, onSelectRow, isError, onRetry, errorMsg, isHideSelectAll, isHideHeaderIfNoData, sorting, className, onSort, maxHeight, }: UseLogicParams<TData, TSortField>) => {
|
|
5
|
+
dataGridClassName: string | undefined;
|
|
6
|
+
containerCssVars: import("react").CSSProperties;
|
|
7
7
|
isDataGridDisabled: boolean | undefined;
|
|
8
8
|
treeRenderConfig: {
|
|
9
9
|
isInitialExpanded?: boolean | undefined;
|
|
@@ -25,6 +25,7 @@ export declare const useLogic: <TData extends Record<string, unknown> = DataGrid
|
|
|
25
25
|
onRetry: () => void;
|
|
26
26
|
};
|
|
27
27
|
isSmoothLoading: boolean;
|
|
28
|
+
loadingPlaceholderClassname: string;
|
|
28
29
|
};
|
|
29
30
|
rowHoverProps: {
|
|
30
31
|
registerRowElement: (rowId: string, el: HTMLElement) => void;
|
|
@@ -32,10 +33,16 @@ export declare const useLogic: <TData extends Record<string, unknown> = DataGrid
|
|
|
32
33
|
onRowEnter: (rowId: string) => void;
|
|
33
34
|
onRowLeave: (rowId: string, e: PointerEvent) => void;
|
|
34
35
|
};
|
|
36
|
+
isMobile: boolean;
|
|
35
37
|
containerRef: import("react").RefObject<HTMLDivElement | null>;
|
|
36
38
|
gridColumns: string;
|
|
37
39
|
isNoData: boolean;
|
|
38
40
|
headColumns: import("../types").DataGridColumns<TData>[];
|
|
41
|
+
isLoading: boolean | undefined;
|
|
42
|
+
mobileSkeletonProps: {
|
|
43
|
+
cellsCount: number;
|
|
44
|
+
rowsCount: number;
|
|
45
|
+
};
|
|
39
46
|
headProps: {
|
|
40
47
|
rowsCount: number;
|
|
41
48
|
uncheckedRowsCount: number;
|
|
@@ -49,7 +56,6 @@ export declare const useLogic: <TData extends Record<string, unknown> = DataGrid
|
|
|
49
56
|
isSelectable: boolean;
|
|
50
57
|
onSelectRow: (row: TData) => (event: ChangeEvent<HTMLInputElement>) => void;
|
|
51
58
|
};
|
|
52
|
-
bodyClassName: string;
|
|
53
59
|
sections: import("../PinnedSections/types").PinnedSection<TData>[];
|
|
54
60
|
loaderProps: {
|
|
55
61
|
isLoading: boolean | undefined;
|
|
@@ -3,11 +3,12 @@ import { ConfigContext } from '../../ConfigProvider';
|
|
|
3
3
|
import { useFirstMountState } from '../../useFirstMountState';
|
|
4
4
|
import { prop } from '../../utils/prop';
|
|
5
5
|
import { uniqueBy } from '../../utils/uniqueBy';
|
|
6
|
+
import { dataGridClassnames } from '../constants';
|
|
6
7
|
import { Variant } from '../enums';
|
|
7
|
-
import { getGridTemplateColumns } from '../utils
|
|
8
|
-
import {
|
|
8
|
+
import { getDataGridCssVars, getGridTemplateColumns } from '../utils';
|
|
9
|
+
import { useDataGridMobileLogic, usePinnedColumns } from './hooks';
|
|
9
10
|
import { getIsAllowHorizontalScroll } from './utils';
|
|
10
|
-
export const useLogic = ({ keyId, columns, rows = [], variant, tree, subrows, selectedRows = [], isLoading, isDisabled, onSelectRow, isError, onRetry, errorMsg, isHideSelectAll, isHideHeaderIfNoData = false, sorting, className, onSort, }) => {
|
|
11
|
+
export const useLogic = ({ keyId, columns, rows = [], variant, tree, subrows, selectedRows = [], isLoading, isDisabled, onSelectRow, isError, onRetry, errorMsg, isHideSelectAll, isHideHeaderIfNoData = false, sorting, className, onSort, maxHeight, }) => {
|
|
11
12
|
const isFirstRender = useFirstMountState();
|
|
12
13
|
const isSelectable = Boolean(onSelectRow);
|
|
13
14
|
const isDataGridDisabled = isLoading || isDisabled;
|
|
@@ -35,11 +36,11 @@ export const useLogic = ({ keyId, columns, rows = [], variant, tree, subrows, se
|
|
|
35
36
|
isLoading,
|
|
36
37
|
columns: processedColumns(),
|
|
37
38
|
});
|
|
38
|
-
const {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
const { isMobile, mobileSkeletonProps } = useDataGridMobileLogic({
|
|
40
|
+
containerRef,
|
|
41
|
+
isLoading,
|
|
42
|
+
columns: processedColumns(),
|
|
43
|
+
rows,
|
|
43
44
|
});
|
|
44
45
|
const treeRenderConfig = Object.is(variant, Variant.Subrows)
|
|
45
46
|
? { ...subrows, isInitialExpanded: true }
|
|
@@ -73,7 +74,7 @@ export const useLogic = ({ keyId, columns, rows = [], variant, tree, subrows, se
|
|
|
73
74
|
const isHideHead = isHideHeaderIfNoData && isNoData;
|
|
74
75
|
const contentStateProps = useMemo(() => {
|
|
75
76
|
return {
|
|
76
|
-
isLoading: isLoading && isNoData,
|
|
77
|
+
isLoading: (isLoading && isNoData) || (isMobile && isLoading),
|
|
77
78
|
isError: isError && isNoData,
|
|
78
79
|
loadingTitle: 'Загрузка данных',
|
|
79
80
|
errorState: {
|
|
@@ -83,11 +84,13 @@ export const useLogic = ({ keyId, columns, rows = [], variant, tree, subrows, se
|
|
|
83
84
|
onRetry,
|
|
84
85
|
},
|
|
85
86
|
isSmoothLoading: false,
|
|
87
|
+
loadingPlaceholderClassname: dataGridClassnames.loadingPlaceholder,
|
|
86
88
|
};
|
|
87
89
|
}, [isLoading, isError, isNoData, errorMsg, onRetry, imagesMap]);
|
|
90
|
+
const containerCssVars = getDataGridCssVars(maxHeight);
|
|
88
91
|
return {
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
dataGridClassName: className,
|
|
93
|
+
containerCssVars,
|
|
91
94
|
isDataGridDisabled,
|
|
92
95
|
treeRenderConfig,
|
|
93
96
|
renderRows,
|
|
@@ -96,10 +99,13 @@ export const useLogic = ({ keyId, columns, rows = [], variant, tree, subrows, se
|
|
|
96
99
|
hasPinnedColumns,
|
|
97
100
|
contentStateProps,
|
|
98
101
|
rowHoverProps,
|
|
102
|
+
isMobile,
|
|
99
103
|
containerRef,
|
|
100
104
|
gridColumns,
|
|
101
105
|
isNoData,
|
|
102
106
|
headColumns: processedColumns(),
|
|
107
|
+
isLoading,
|
|
108
|
+
mobileSkeletonProps,
|
|
103
109
|
headProps: {
|
|
104
110
|
rowsCount: availableRows.length,
|
|
105
111
|
uncheckedRowsCount,
|
|
@@ -113,7 +119,6 @@ export const useLogic = ({ keyId, columns, rows = [], variant, tree, subrows, se
|
|
|
113
119
|
isSelectable,
|
|
114
120
|
onSelectRow: handleSelectRow,
|
|
115
121
|
},
|
|
116
|
-
bodyClassName,
|
|
117
122
|
sections,
|
|
118
123
|
loaderProps: {
|
|
119
124
|
isLoading: !isFirstRender && isLoading,
|
package/components/DataGrid/useLogic/utils/getIsAllowHorizontalScroll/getIsAllowHorizontalScroll.js
CHANGED
|
@@ -3,7 +3,7 @@ export const getIsAllowHorizontalScroll = (columns) => {
|
|
|
3
3
|
const isAllItemsHasMinWidth = columns.every(({ minWidth }) => Boolean(minWidth));
|
|
4
4
|
if (isSomeItemsHasMinWidth && !isAllItemsHasMinWidth) {
|
|
5
5
|
// biome-ignore lint/suspicious/noConsole: Ошибка для интеграторов
|
|
6
|
-
console.error('UIKIT.
|
|
6
|
+
console.error('UIKIT. DataGrid: Необходимо задать minWidth для всех колонок');
|
|
7
7
|
}
|
|
8
8
|
return isAllItemsHasMinWidth;
|
|
9
9
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getDataGridCssVars } from './getDataGridCssVars';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getDataGridCssVars } from './getDataGridCssVars';
|
|
@@ -50,5 +50,5 @@ export const DataGridSecondaryActions = ({ actions, isLoading, }) => {
|
|
|
50
50
|
return (_createElement(MenuItem, { ...restProps, key: name, tooltipPlacement: TOOLTIP_PLACEMENT.secondaryActions, onClick: onActionClick(onClick) }, name));
|
|
51
51
|
});
|
|
52
52
|
};
|
|
53
|
-
return (_jsx(Menu, { open: open, anchorEl: anchorEl, children: isLoading ? _jsx(DataGridSecondaryActionsSkeleton, {}) : renderActions() }));
|
|
53
|
+
return (_jsx(Menu, { open: open, anchorEl: anchorEl, title: "\u0414\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044F", children: isLoading ? _jsx(DataGridSecondaryActionsSkeleton, {}) : renderActions() }));
|
|
54
54
|
};
|
|
@@ -3,6 +3,7 @@ import { useContext } from 'react';
|
|
|
3
3
|
import { Virtuoso } from 'react-virtuoso';
|
|
4
4
|
import { ConfigContext } from '../ConfigProvider';
|
|
5
5
|
import { ContentState } from '../ContentState';
|
|
6
|
+
import { MobileSkeleton } from '../DataGrid';
|
|
6
7
|
import { dataGridClassnames, EXPANDED_LEVEL_BY_DEFAULT, INITIAL_OPENED_NESTED_CHILDREN_COUNT_BY_DEFAULT, } from '../DataGrid/constants';
|
|
7
8
|
import { DataGridContextProvider } from '../DataGrid/DataGridContext';
|
|
8
9
|
import { Variant } from '../DataGrid/enums';
|
|
@@ -23,12 +24,12 @@ import { useLogic } from './useLogic';
|
|
|
23
24
|
const INITIAL_LEVEL = 0;
|
|
24
25
|
export const DataGridInfinite = (props) => {
|
|
25
26
|
const { imagesMap, emptySymbol } = useContext(ConfigContext);
|
|
26
|
-
const { isNoData, isDataGridDisabled, isStickyButtonActive, treeRenderConfig, virtuosoProps, headProps, rowProps, scrollToTopButtonProps, isEndReached, isHideHead, } = useLogic(props);
|
|
27
|
-
const { columns, rows = [], selectedRows = [], sorting,
|
|
27
|
+
const { isNoData, isDataGridDisabled, isStickyButtonActive, treeRenderConfig, virtuosoProps, headProps, rowProps, scrollToTopButtonProps, isEndReached, isHideHead, containerCssVars, isMobile, mobileSkeletonProps, } = useLogic(props);
|
|
28
|
+
const { columns, rows = [], selectedRows = [], sorting, isLoading, isDisabled, keyId, emptyCellValue = emptySymbol, variant = Variant.Tree, subrows, className, isError, endOfScrollMsg, errorMsg, noDataPlaceholder, onRowClick, onSort, onRetry, headPreAddon, } = props;
|
|
28
29
|
const { moreButtonColumnPosition = 1, isVisibleCollapseButton = true } = subrows || {};
|
|
29
30
|
const { isInitialExpanded = false, expandedLevel = EXPANDED_LEVEL_BY_DEFAULT, initialVisibleChildrenCount = INITIAL_OPENED_NESTED_CHILDREN_COUNT_BY_DEFAULT, } = treeRenderConfig || {};
|
|
30
31
|
const TableContainer = isDisabled ? DisabledDataGridWrapper : DataGridWrapper;
|
|
31
|
-
return (_jsx(DataGridContextProvider, { children: _jsxs(Container, {
|
|
32
|
+
return (_jsx(DataGridContextProvider, { children: _jsxs(Container, { style: containerCssVars, className: classNames(dataGridClassnames.root, className), children: [headPreAddon, _jsxs(TableContainer, { ...getInertProps(isDataGridDisabled), children: [!isHideHead && (_jsx(Head, { ...headProps, onSort: onSort, sorting: sorting, columns: columns })), _jsx(ContentState, { isLoading: isLoading && !isNoData, loadingTitle: "\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430 \u0434\u0430\u043D\u043D\u044B\u0445", isError: isError && !isNoData, loadingContent: isMobile && _jsx(MobileSkeleton, { ...mobileSkeletonProps }), errorState: {
|
|
32
33
|
imgAlt: 'Что-то пошло не так',
|
|
33
34
|
errorList: [errorMsg || ''],
|
|
34
35
|
imgSrc: imagesMap.defaultErrorImgSrc,
|
|
@@ -39,7 +40,7 @@ export const DataGridInfinite = (props) => {
|
|
|
39
40
|
List,
|
|
40
41
|
Item: ({ children, item, ...itemProps }) => {
|
|
41
42
|
const { children: nestedChildren, options, ...row } = item;
|
|
42
|
-
return (_jsx(RowContextProvider, { children: _jsx(Row, { ...rowProps, ...itemProps, row: row, columns: columns, selectedRows: selectedRows, options: options, keyId: keyId, variant: variant,
|
|
43
|
+
return (_jsx(RowContextProvider, { children: _jsx(Row, { ...rowProps, ...itemProps, row: row, columns: columns, selectedRows: selectedRows, options: options, keyId: keyId, variant: variant, level: INITIAL_LEVEL, nestedChildren: nestedChildren, isInitialExpanded: isInitialExpanded, expandedLevel: expandedLevel, initialVisibleChildrenCount: initialVisibleChildrenCount, moreButtonColumnPosition: moreButtonColumnPosition, isVisibleCollapseButton: isVisibleCollapseButton, emptyCellValue: emptyCellValue, onRowClick: onRowClick }) }));
|
|
43
44
|
},
|
|
44
45
|
EmptyPlaceholder: () => _jsx(_Fragment, { children: noDataPlaceholder || _jsx(NoData, {}) }),
|
|
45
46
|
Footer: () => {
|
|
@@ -4,8 +4,14 @@ import { type DataGridRow } from '../../DataGrid';
|
|
|
4
4
|
import { type CellValue } from '../../DataGrid/types';
|
|
5
5
|
import { type DataGridInfiniteProps } from '../types';
|
|
6
6
|
type UseLogicParams<TData extends Record<string, CellValue> = DataGridRow, TSortField extends keyof TData = keyof TData> = DataGridInfiniteProps<TData, TSortField>;
|
|
7
|
-
export declare const useLogic: <TData extends Record<string, unknown> = DataGridRow, TSortField extends keyof TData = keyof TData>({ keyId, columns, rows, variant, tree, subrows, selectedRows, isLoading, isDisabled, isEndReached, onEndReached, onSelectRow, isHideSelectAll, isHideHeaderIfNoData, }: UseLogicParams<TData, TSortField>) => {
|
|
7
|
+
export declare const useLogic: <TData extends Record<string, unknown> = DataGridRow, TSortField extends keyof TData = keyof TData>({ keyId, columns, rows, variant, tree, subrows, selectedRows, maxHeight, isLoading, isDisabled, isEndReached, onEndReached, onSelectRow, isHideSelectAll, isHideHeaderIfNoData, }: UseLogicParams<TData, TSortField>) => {
|
|
8
|
+
containerCssVars: import("react").CSSProperties;
|
|
9
|
+
mobileSkeletonProps: {
|
|
10
|
+
cellsCount: number;
|
|
11
|
+
rowsCount: number;
|
|
12
|
+
};
|
|
8
13
|
isNoData: boolean;
|
|
14
|
+
isMobile: boolean;
|
|
9
15
|
isDataGridDisabled: boolean | undefined;
|
|
10
16
|
isStickyButtonActive: boolean;
|
|
11
17
|
treeRenderConfig: {
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { useCallback, useMemo, useRef, useState, } from 'react';
|
|
2
2
|
import { Variant } from '../../DataGrid/enums';
|
|
3
|
-
import {
|
|
3
|
+
import { useDataGridMobileLogic } from '../../DataGrid/useLogic/hooks';
|
|
4
|
+
import { getDataGridCssVars, getGridTemplateColumns, } from '../../DataGrid/utils';
|
|
4
5
|
import { useToggle } from '../../useToggle';
|
|
6
|
+
import { useViewportType } from '../../useViewportType';
|
|
5
7
|
import { prop } from '../../utils/prop';
|
|
6
8
|
import { uniqueBy } from '../../utils/uniqueBy';
|
|
7
9
|
import { VIRTUOSO_CONTAINER_ID, VIRTUOSO_LIST_ID } from '../constants';
|
|
8
|
-
export const useLogic = ({ keyId, columns, rows, variant, tree, subrows, selectedRows = [], isLoading, isDisabled, isEndReached, onEndReached, onSelectRow, isHideSelectAll, isHideHeaderIfNoData = false, }) => {
|
|
10
|
+
export const useLogic = ({ keyId, columns, rows, variant, tree, subrows, selectedRows = [], maxHeight, isLoading, isDisabled, isEndReached, onEndReached, onSelectRow, isHideSelectAll, isHideHeaderIfNoData = false, }) => {
|
|
9
11
|
const virtuoso = useRef(null);
|
|
12
|
+
const { isMobile } = useViewportType();
|
|
10
13
|
const [hasVerticalScroll, setHasVerticalScroll] = useState(false);
|
|
11
14
|
const [isStickyButtonActive, showStickyButton, hideStickyButton] = useToggle();
|
|
12
15
|
const isNoData = Boolean(rows?.length);
|
|
@@ -59,8 +62,15 @@ export const useLogic = ({ keyId, columns, rows, variant, tree, subrows, selecte
|
|
|
59
62
|
}
|
|
60
63
|
};
|
|
61
64
|
const isHideHead = isHideHeaderIfNoData && rows.length === 0;
|
|
65
|
+
const { mobileSkeletonProps } = useDataGridMobileLogic({
|
|
66
|
+
columns,
|
|
67
|
+
});
|
|
68
|
+
const containerCssVars = getDataGridCssVars(maxHeight);
|
|
62
69
|
return {
|
|
70
|
+
containerCssVars,
|
|
71
|
+
mobileSkeletonProps,
|
|
63
72
|
isNoData,
|
|
73
|
+
isMobile,
|
|
64
74
|
isDataGridDisabled,
|
|
65
75
|
isStickyButtonActive,
|
|
66
76
|
treeRenderConfig,
|