@astral/ui 4.113.2 → 4.114.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/ActionGroup/ActionGroup.js +2 -2
- package/components/ActionGroup/SecondaryActions/SecondaryActions.d.ts +1 -1
- package/components/ActionGroup/SecondaryActions/SecondaryActions.js +2 -2
- package/components/ActionGroup/types.d.ts +9 -0
- package/components/DataGrid/DataGrid.js +13 -5
- package/components/DataGrid/DataGridContext/DataGridProvider/DataGridProvider.d.ts +3 -2
- package/components/DataGrid/DataGridContext/DataGridProvider/DataGridProvider.js +3 -2
- package/components/DataGrid/DataGridSelectionContext/DataGridSelectionContext.d.ts +25 -0
- package/components/DataGrid/DataGridSelectionContext/DataGridSelectionContext.js +13 -0
- package/components/DataGrid/DataGridSelectionContext/DataGridSelectionProvider/DataGridSelectionProvider.d.ts +7 -0
- package/components/DataGrid/DataGridSelectionContext/DataGridSelectionProvider/DataGridSelectionProvider.js +8 -0
- package/components/DataGrid/DataGridSelectionContext/DataGridSelectionProvider/index.d.ts +1 -0
- package/components/DataGrid/DataGridSelectionContext/DataGridSelectionProvider/index.js +1 -0
- package/components/DataGrid/DataGridSelectionContext/index.d.ts +2 -0
- package/components/DataGrid/DataGridSelectionContext/index.js +2 -0
- package/components/DataGrid/constants.d.ts +2 -0
- package/components/DataGrid/constants.js +2 -0
- package/components/DataGrid/styles.d.ts +4 -0
- package/components/DataGrid/styles.js +26 -0
- package/components/DataGrid/types.d.ts +7 -0
- package/components/DataGrid/useLogic/useLogic.d.ts +3 -1
- package/components/DataGrid/useLogic/useLogic.js +10 -2
- package/components/DataGrid/utils/checkIsMassActionsOpen/checkIsMassActionsOpen.d.ts +10 -0
- package/components/DataGrid/utils/checkIsMassActionsOpen/checkIsMassActionsOpen.js +4 -0
- package/components/DataGrid/utils/checkIsMassActionsOpen/index.d.ts +1 -0
- package/components/DataGrid/utils/checkIsMassActionsOpen/index.js +1 -0
- package/components/DataGrid/utils/index.d.ts +1 -0
- package/components/DataGrid/utils/index.js +1 -0
- package/components/DataGridInfinite/DataGridInfinite.js +17 -13
- package/components/DataGridInfinite/Footer/Footer.d.ts +6 -0
- package/components/DataGridInfinite/Footer/Footer.js +25 -0
- package/components/DataGridInfinite/Footer/index.d.ts +2 -0
- package/components/DataGridInfinite/Footer/index.js +1 -0
- package/components/DataGridInfinite/Footer/types.d.ts +26 -0
- package/components/DataGridInfinite/Footer/types.js +1 -0
- package/components/DataGridInfinite/constants.d.ts +1 -0
- package/components/DataGridInfinite/constants.js +1 -0
- package/components/DataGridInfinite/styles.d.ts +4 -0
- package/components/DataGridInfinite/styles.js +24 -0
- package/components/DataGridInfinite/useLogic/useLogic.d.ts +6 -3
- package/components/DataGridInfinite/useLogic/useLogic.js +32 -8
- package/components/DataGridMassActions/DataGridMassActions.d.ts +15 -0
- package/components/DataGridMassActions/DataGridMassActions.js +32 -0
- package/components/DataGridMassActions/constants.d.ts +4 -0
- package/components/DataGridMassActions/constants.js +5 -0
- package/components/DataGridMassActions/index.d.ts +2 -0
- package/components/DataGridMassActions/index.js +1 -0
- package/components/DataGridMassActions/public.d.ts +2 -0
- package/components/DataGridMassActions/public.js +1 -0
- package/components/DataGridMassActions/styles.d.ts +8 -0
- package/components/DataGridMassActions/styles.js +49 -0
- package/components/DataGridMassActions/tests/testDataGridMassActions.d.ts +23 -0
- package/components/DataGridMassActions/tests/testDataGridMassActions.js +77 -0
- package/components/DataGridMassActions/types.d.ts +2 -0
- package/components/DataGridMassActions/types.js +1 -0
- package/components/DataGridMassActions/useLogic/index.d.ts +1 -0
- package/components/DataGridMassActions/useLogic/index.js +1 -0
- package/components/DataGridMassActions/useLogic/useLogic.d.ts +6 -0
- package/components/DataGridMassActions/useLogic/useLogic.js +21 -0
- package/components/IconDropdownButton/IconDropdownButton.d.ts +5 -0
- package/components/IconDropdownButton/IconDropdownButton.js +2 -2
- package/components/MassActions/MassActions.d.ts +5 -0
- package/components/MassActions/MassActions.js +17 -0
- package/components/MassActions/constants.d.ts +6 -0
- package/components/MassActions/constants.js +12 -0
- package/components/MassActions/index.d.ts +2 -0
- package/components/MassActions/index.js +1 -0
- package/components/MassActions/styles.d.ts +34 -0
- package/components/MassActions/styles.js +43 -0
- package/components/MassActions/types.d.ts +20 -0
- package/components/MassActions/types.js +1 -0
- package/components/MassActions/useLogic/index.d.ts +1 -0
- package/components/MassActions/useLogic/index.js +1 -0
- package/components/MassActions/useLogic/useLogic.d.ts +7 -0
- package/components/MassActions/useLogic/useLogic.js +9 -0
- package/components/PageHeader/PageActions/SecondaryActions/styles.d.ts +1 -1
- package/components/Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/index.d.ts +0 -1
- package/components/Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/index.js +0 -1
- package/components/Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/useLogic.js +2 -1
- package/hook-form/FormToggleButtonGroup/FormToggleButtonGroup.d.ts +1 -1
- package/hook-form/FormToggleButtonGroup/FormToggleButtonGroup.js +2 -2
- package/node/components/ActionGroup/ActionGroup.js +2 -2
- package/node/components/ActionGroup/SecondaryActions/SecondaryActions.d.ts +1 -1
- package/node/components/ActionGroup/SecondaryActions/SecondaryActions.js +2 -2
- package/node/components/ActionGroup/types.d.ts +9 -0
- package/node/components/DataGrid/DataGrid.js +12 -4
- package/node/components/DataGrid/DataGridContext/DataGridProvider/DataGridProvider.d.ts +3 -2
- package/node/components/DataGrid/DataGridContext/DataGridProvider/DataGridProvider.js +3 -2
- package/node/components/DataGrid/DataGridSelectionContext/DataGridSelectionContext.d.ts +25 -0
- package/node/components/DataGrid/DataGridSelectionContext/DataGridSelectionContext.js +16 -0
- package/node/components/DataGrid/DataGridSelectionContext/DataGridSelectionProvider/DataGridSelectionProvider.d.ts +7 -0
- package/node/components/DataGrid/DataGridSelectionContext/DataGridSelectionProvider/DataGridSelectionProvider.js +12 -0
- package/node/components/DataGrid/DataGridSelectionContext/DataGridSelectionProvider/index.d.ts +1 -0
- package/node/components/DataGrid/DataGridSelectionContext/DataGridSelectionProvider/index.js +17 -0
- package/node/components/DataGrid/DataGridSelectionContext/index.d.ts +2 -0
- package/node/components/DataGrid/DataGridSelectionContext/index.js +18 -0
- package/node/components/DataGrid/constants.d.ts +2 -0
- package/node/components/DataGrid/constants.js +2 -0
- package/node/components/DataGrid/styles.d.ts +4 -0
- package/node/components/DataGrid/styles.js +27 -1
- package/node/components/DataGrid/types.d.ts +7 -0
- package/node/components/DataGrid/useLogic/useLogic.d.ts +3 -1
- package/node/components/DataGrid/useLogic/useLogic.js +9 -1
- package/node/components/DataGrid/utils/checkIsMassActionsOpen/checkIsMassActionsOpen.d.ts +10 -0
- package/node/components/DataGrid/utils/checkIsMassActionsOpen/checkIsMassActionsOpen.js +8 -0
- package/node/components/DataGrid/utils/checkIsMassActionsOpen/index.d.ts +1 -0
- package/node/components/DataGrid/utils/checkIsMassActionsOpen/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/DataGridInfinite/DataGridInfinite.js +19 -15
- package/node/components/DataGridInfinite/Footer/Footer.d.ts +6 -0
- package/node/components/DataGridInfinite/Footer/Footer.js +29 -0
- package/node/components/DataGridInfinite/Footer/index.d.ts +2 -0
- package/node/components/DataGridInfinite/Footer/index.js +17 -0
- package/node/components/DataGridInfinite/Footer/types.d.ts +26 -0
- package/node/components/DataGridInfinite/Footer/types.js +2 -0
- package/node/components/DataGridInfinite/constants.d.ts +1 -0
- package/node/components/DataGridInfinite/constants.js +1 -0
- package/node/components/DataGridInfinite/styles.d.ts +4 -0
- package/node/components/DataGridInfinite/styles.js +27 -3
- package/node/components/DataGridInfinite/useLogic/useLogic.d.ts +6 -3
- package/node/components/DataGridInfinite/useLogic/useLogic.js +30 -6
- package/node/components/DataGridMassActions/DataGridMassActions.d.ts +15 -0
- package/node/components/DataGridMassActions/DataGridMassActions.js +36 -0
- package/node/components/DataGridMassActions/constants.d.ts +4 -0
- package/node/components/DataGridMassActions/constants.js +8 -0
- package/node/components/DataGridMassActions/index.d.ts +2 -0
- package/node/components/DataGridMassActions/index.js +5 -0
- package/node/components/DataGridMassActions/public.d.ts +2 -0
- package/node/components/DataGridMassActions/public.js +5 -0
- package/node/components/DataGridMassActions/styles.d.ts +8 -0
- package/node/components/DataGridMassActions/styles.js +52 -0
- package/node/components/DataGridMassActions/tests/testDataGridMassActions.d.ts +23 -0
- package/node/components/DataGridMassActions/tests/testDataGridMassActions.js +81 -0
- package/node/components/DataGridMassActions/types.d.ts +2 -0
- package/node/components/DataGridMassActions/types.js +2 -0
- package/node/components/DataGridMassActions/useLogic/index.d.ts +1 -0
- package/node/components/DataGridMassActions/useLogic/index.js +17 -0
- package/node/components/DataGridMassActions/useLogic/useLogic.d.ts +6 -0
- package/node/components/DataGridMassActions/useLogic/useLogic.js +25 -0
- package/node/components/IconDropdownButton/IconDropdownButton.d.ts +5 -0
- package/node/components/IconDropdownButton/IconDropdownButton.js +2 -2
- package/node/components/MassActions/MassActions.d.ts +5 -0
- package/node/components/MassActions/MassActions.js +21 -0
- package/node/components/MassActions/constants.d.ts +6 -0
- package/node/components/MassActions/constants.js +15 -0
- package/node/components/MassActions/index.d.ts +2 -0
- package/node/components/MassActions/index.js +5 -0
- package/node/components/MassActions/styles.d.ts +34 -0
- package/node/components/MassActions/styles.js +46 -0
- package/node/components/MassActions/types.d.ts +20 -0
- package/node/components/MassActions/types.js +2 -0
- package/node/components/MassActions/useLogic/index.d.ts +1 -0
- package/node/components/MassActions/useLogic/index.js +17 -0
- package/node/components/MassActions/useLogic/useLogic.d.ts +7 -0
- package/node/components/MassActions/useLogic/useLogic.js +13 -0
- package/node/components/PageHeader/PageActions/SecondaryActions/styles.d.ts +1 -1
- package/node/components/Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/index.d.ts +0 -1
- package/node/components/Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/index.js +0 -1
- package/node/components/Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/useLogic.js +2 -1
- package/node/hook-form/FormToggleButtonGroup/FormToggleButtonGroup.d.ts +1 -1
- package/node/hook-form/FormToggleButtonGroup/FormToggleButtonGroup.js +2 -2
- package/package.json +1 -1
- /package/components/{Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/useDelayedUnmount → useDelayedUnmount}/index.d.ts +0 -0
- /package/components/{Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/useDelayedUnmount → useDelayedUnmount}/index.js +0 -0
- /package/components/{Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/useDelayedUnmount → useDelayedUnmount}/useDelayedUnmount.d.ts +0 -0
- /package/components/{Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/useDelayedUnmount → useDelayedUnmount}/useDelayedUnmount.js +0 -0
- /package/node/components/{Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/useDelayedUnmount → useDelayedUnmount}/index.d.ts +0 -0
- /package/node/components/{Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/useDelayedUnmount → useDelayedUnmount}/index.js +0 -0
- /package/node/components/{Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/useDelayedUnmount → useDelayedUnmount}/useDelayedUnmount.d.ts +0 -0
- /package/node/components/{Tree/TreeItem/MobileSlidePanel/MobileSlidePanelContent/useLogic/hooks/useDelayedUnmount → useDelayedUnmount}/useDelayedUnmount.js +0 -0
|
@@ -5,7 +5,7 @@ import { SecondaryActions } from './SecondaryActions';
|
|
|
5
5
|
import { SecondaryVisibleActions } from './SecondaryVisibleActions';
|
|
6
6
|
import { Wrapper } from './styles';
|
|
7
7
|
export const ActionGroup = (props) => {
|
|
8
|
-
const { main, secondary, secondaryVisible, className, size = 'medium', } = props;
|
|
8
|
+
const { main, secondary, secondaryVisible, secondaryPopoverProps, className, size = 'medium', } = props;
|
|
9
9
|
const { disabledAction } = useActionsState({ main, secondary });
|
|
10
|
-
return (_jsxs(Wrapper, { className: className, children: [secondary && (_jsx(SecondaryActions, { isDisabled: disabledAction, actions: secondary, size: size })), secondaryVisible && (_jsx(SecondaryVisibleActions, { actions: secondaryVisible, size: size })), main && (_jsx(MainActions, { isDisabled: disabledAction, actions: main, size: size }))] }));
|
|
10
|
+
return (_jsxs(Wrapper, { className: className, children: [secondary && (_jsx(SecondaryActions, { isDisabled: disabledAction, actions: secondary, size: size, popoverProps: secondaryPopoverProps })), secondaryVisible && (_jsx(SecondaryVisibleActions, { actions: secondaryVisible, size: size })), main && (_jsx(MainActions, { isDisabled: disabledAction, actions: main, size: size }))] }));
|
|
11
11
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type ElementType } from 'react';
|
|
2
2
|
import type { SecondaryActionProps } from '../types';
|
|
3
|
-
export declare const SecondaryActions: <TSecondaryActionComponent extends ElementType = ElementType>({ actions, isDisabled, className, size, }: SecondaryActionProps<TSecondaryActionComponent>) => import("react/jsx-runtime").JSX.Element | null;
|
|
3
|
+
export declare const SecondaryActions: <TSecondaryActionComponent extends ElementType = ElementType>({ actions, isDisabled, className, size, popoverProps, }: SecondaryActionProps<TSecondaryActionComponent>) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -5,10 +5,10 @@ import { IconDropdownButton } from '../../IconDropdownButton';
|
|
|
5
5
|
import { ListItemButton } from '../../ListItemButton';
|
|
6
6
|
import { ListItemText } from '../../ListItemText';
|
|
7
7
|
const TOOLTIP_PLACEMENT = 'right';
|
|
8
|
-
export const SecondaryActions = ({ actions, isDisabled, className, size, }) => {
|
|
8
|
+
export const SecondaryActions = ({ actions, isDisabled, className, size, popoverProps, }) => {
|
|
9
9
|
if (!actions.length) {
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
|
-
return (_jsx(IconDropdownButton, { disabled: isDisabled, icon: _jsx(DotsOutlineMd, {}), variant: "outlined", color: "grey", size: size, className: className, children: actions.map(({ text, ...secondaryProps }) => (_createElement(ListItemButton, { tooltipPlacement: TOOLTIP_PLACEMENT, ...secondaryProps, key: text },
|
|
12
|
+
return (_jsx(IconDropdownButton, { disabled: isDisabled, icon: _jsx(DotsOutlineMd, {}), variant: "outlined", color: "grey", size: size, className: className, popoverProps: popoverProps, children: actions.map(({ text, ...secondaryProps }) => (_createElement(ListItemButton, { tooltipPlacement: TOOLTIP_PLACEMENT, ...secondaryProps, key: text },
|
|
13
13
|
_jsx(ListItemText, { primary: text })))) }));
|
|
14
14
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ComponentProps, ElementType, ReactElement, ReactNode } from 'react';
|
|
2
2
|
import type { ButtonProps, ButtonSize } from '../Button';
|
|
3
3
|
import type { DropdownButtonProps } from '../DropdownButton';
|
|
4
|
+
import type { IconDropdownButtonProps } from '../IconDropdownButton';
|
|
4
5
|
import type { ListItemButtonProps } from '../ListItemButton';
|
|
5
6
|
import type { MenuItemProps } from '../MenuItem';
|
|
6
7
|
import type { TooltipProps } from '../Tooltip';
|
|
@@ -143,6 +144,10 @@ export type SecondaryActionProps<TSecondaryActionComponent extends ElementType>
|
|
|
143
144
|
*/
|
|
144
145
|
className?: string;
|
|
145
146
|
size?: ButtonSize;
|
|
147
|
+
/**
|
|
148
|
+
* Пропсы Popover меню второстепенных действий
|
|
149
|
+
*/
|
|
150
|
+
popoverProps?: IconDropdownButtonProps['popoverProps'];
|
|
146
151
|
};
|
|
147
152
|
/** Модель второстепенного видимого экшена */
|
|
148
153
|
export type SecondaryVisibleAction = Omit<ButtonProps, 'children'> & {
|
|
@@ -177,6 +182,10 @@ export type ActionGroupProps<TMainActionComponent extends ElementType = ElementT
|
|
|
177
182
|
* Второстепенные действия, спрятанные за троеточием
|
|
178
183
|
*/
|
|
179
184
|
secondary?: SecondaryAction<TSecondaryActionComponent>[];
|
|
185
|
+
/**
|
|
186
|
+
* Пропсы Popover меню второстепенных действий
|
|
187
|
+
*/
|
|
188
|
+
secondaryPopoverProps?: IconDropdownButtonProps['popoverProps'];
|
|
180
189
|
/**
|
|
181
190
|
* Видимые второстепенные действия
|
|
182
191
|
*/
|
|
@@ -15,7 +15,7 @@ import { Loader } from './Loader';
|
|
|
15
15
|
import { MobileSkeleton } from './MobileSkeleton';
|
|
16
16
|
import { NoData } from './NoData';
|
|
17
17
|
import { PinnedSections } from './PinnedSections';
|
|
18
|
-
import { Container, DataGridWrapper, DisabledDataGridWrapper } from './styles';
|
|
18
|
+
import { Container, DataGridWrapper, DisabledDataGridWrapper, MassActionsAnchor, } from './styles';
|
|
19
19
|
import { useLogic } from './useLogic';
|
|
20
20
|
const pinnedSectionsCva = cva(dataGridClassnames.pinnedSections, {
|
|
21
21
|
variants: {
|
|
@@ -26,6 +26,12 @@ const pinnedSectionsCva = cva(dataGridClassnames.pinnedSections, {
|
|
|
26
26
|
});
|
|
27
27
|
const dataGridCva = cva(dataGridClassnames.root, {
|
|
28
28
|
variants: {
|
|
29
|
+
hasMassActions: {
|
|
30
|
+
true: dataGridClassnames.hasMassActions,
|
|
31
|
+
},
|
|
32
|
+
isMassActionsOpen: {
|
|
33
|
+
true: dataGridClassnames.massActionsOpen,
|
|
34
|
+
},
|
|
29
35
|
hasPinnedColumns: {
|
|
30
36
|
true: dataGridClassnames.hasPinnedSections,
|
|
31
37
|
},
|
|
@@ -56,9 +62,9 @@ const bodyCva = cva(dataGridClassnames.body, {
|
|
|
56
62
|
},
|
|
57
63
|
});
|
|
58
64
|
export const DataGrid = (props) => {
|
|
59
|
-
const { dataGridClassName, isDataGridDisabled, treeRenderConfig, headColumns, headProps, bodyProps, gridColumns, loaderProps, renderRows, isAllowHorizontalScroll, isHideHead, hasPinnedColumns, contentStateProps, rowHoverProps, containerRef, sections, isNoData, isMobile, mobileSkeletonProps, isLoading, containerCssVars, hasGroupedColumns, gridViewMode, mobileDisplayVariant, isSelfContained, } = useLogic(props);
|
|
65
|
+
const { dataGridClassName, isDataGridDisabled, treeRenderConfig, headColumns, headProps, bodyProps, gridColumns, loaderProps, renderRows, isAllowHorizontalScroll, isHideHead, hasPinnedColumns, contentStateProps, rowHoverProps, containerRef, sections, isNoData, isMobile, mobileSkeletonProps, isLoading, containerCssVars, hasGroupedColumns, gridViewMode, mobileDisplayVariant, isSelfContained, isMassActionsOpen, hasMassActions, } = useLogic(props);
|
|
60
66
|
const { emptySymbol } = useContext(ConfigContext);
|
|
61
|
-
const { columns, selectedRows = [], minDisplayRows = MIN_DISPLAY_ROWS_BY_DEFAULT, variant = Variant.Tree, footer, noDataPlaceholder, subrows, keyId, activeRowId, emptyCellValue = emptySymbol, onRowClick, noDataOptions, headPreAddon, isTabularNums, renderRow, renderLink, } = props;
|
|
67
|
+
const { columns, selectedRows = [], onSelectRow, minDisplayRows = MIN_DISPLAY_ROWS_BY_DEFAULT, variant = Variant.Tree, footer, massActions, noDataPlaceholder, subrows, keyId, activeRowId, emptyCellValue = emptySymbol, onRowClick, noDataOptions, headPreAddon, isTabularNums, renderRow, renderLink, } = props;
|
|
62
68
|
const { moreButtonColumnPosition = 1, isVisibleCollapseButton = true } = subrows || {};
|
|
63
69
|
const { isInitialExpanded = false, expandedLevel = EXPANDED_LEVEL_BY_DEFAULT, initialVisibleChildrenCount = INITIAL_OPENED_NESTED_CHILDREN_COUNT_BY_DEFAULT, } = treeRenderConfig || {};
|
|
64
70
|
const Wrapper = isDataGridDisabled
|
|
@@ -98,12 +104,14 @@ export const DataGrid = (props) => {
|
|
|
98
104
|
isDisabled: isDataGridDisabled,
|
|
99
105
|
}), isDisabled: isDataGridDisabled, headProps: headProps, gridColumns: gridColumns, bodyProps: commonBodyProps, isNoData: isNoData }) }));
|
|
100
106
|
};
|
|
101
|
-
return (_jsx(DataGridContextProvider, { isLoading: isLoading, isTabularNums: isTabularNums, gridColumns: gridColumns, emptyCellValue: emptyCellValue, activeRowId: activeRowId, keyId: keyId, columns: columns, onRowClick: onRowClick, mobileDisplayVariant: mobileDisplayVariant, renderLink: renderLink, children: _jsxs(Container, { ref: containerRef, style: containerCssVars, className: cn(dataGridClassName, dataGridCva({
|
|
107
|
+
return (_jsx(DataGridContextProvider, { isLoading: isLoading, isTabularNums: isTabularNums, gridColumns: gridColumns, emptyCellValue: emptyCellValue, activeRowId: activeRowId, keyId: keyId, columns: columns, onRowClick: onRowClick, mobileDisplayVariant: mobileDisplayVariant, renderLink: renderLink, selectedRows: selectedRows, onSelectRow: onSelectRow, isMassActionsOpen: isMassActionsOpen, children: _jsxs(Container, { ref: containerRef, style: containerCssVars, className: cn(dataGridClassName, dataGridCva({
|
|
102
108
|
isAllowHorizontalScroll,
|
|
103
109
|
hasPinnedColumns,
|
|
104
110
|
gridViewMode,
|
|
105
111
|
hasGroupedColumns,
|
|
106
112
|
mobileDisplayVariant,
|
|
107
113
|
isSelfContained,
|
|
108
|
-
|
|
114
|
+
hasMassActions,
|
|
115
|
+
isMassActionsOpen,
|
|
116
|
+
})), children: [renderTableContent(), _jsx(Loader, { ...loaderProps }), massActions && _jsx(MassActionsAnchor, { children: massActions }), footer && footer] }) }));
|
|
109
117
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
+
import { type DataGridSelectionContextProps } from '../../DataGridSelectionContext';
|
|
2
3
|
import { type DataGridContextProps } from '../DataGridContext';
|
|
3
|
-
type DataGridContextProviderProps = Pick<DataGridContextProps, 'isLoading' | 'isTabularNums' | 'gridColumns' | 'emptyCellValue' | 'activeRowId' | 'keyId' | 'columns' | 'onRowClick' | 'mobileDisplayVariant' | 'renderLink'> & {
|
|
4
|
+
type DataGridContextProviderProps = Pick<DataGridContextProps, 'isLoading' | 'isTabularNums' | 'gridColumns' | 'emptyCellValue' | 'activeRowId' | 'keyId' | 'columns' | 'onRowClick' | 'mobileDisplayVariant' | 'renderLink'> & Partial<DataGridSelectionContextProps> & {
|
|
4
5
|
children: ReactNode;
|
|
5
6
|
};
|
|
6
|
-
export declare const DataGridContextProvider: ({ isLoading, isTabularNums, gridColumns, emptyCellValue, activeRowId, children, keyId, columns, onRowClick, mobileDisplayVariant, renderLink, }: DataGridContextProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare const DataGridContextProvider: ({ isLoading, isTabularNums, gridColumns, emptyCellValue, activeRowId, children, keyId, columns, onRowClick, mobileDisplayVariant, renderLink, selectedRows, onSelectRow, isMassActionsOpen, }: DataGridContextProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
+
import { DataGridSelectionProvider, } from '../../DataGridSelectionContext';
|
|
3
4
|
import { DataGridStorageProvider } from '../../DataGridStorageContext';
|
|
4
5
|
import { DataGridContext } from '../DataGridContext';
|
|
5
|
-
export const DataGridContextProvider = ({ isLoading, isTabularNums, gridColumns, emptyCellValue, activeRowId, children, keyId, columns, onRowClick, mobileDisplayVariant, renderLink, }) => {
|
|
6
|
+
export const DataGridContextProvider = ({ isLoading, isTabularNums, gridColumns, emptyCellValue, activeRowId, children, keyId, columns, onRowClick, mobileDisplayVariant, renderLink, selectedRows, onSelectRow, isMassActionsOpen, }) => {
|
|
6
7
|
const contextValue = useMemo(() => ({
|
|
7
8
|
isLoading,
|
|
8
9
|
isTabularNums,
|
|
@@ -26,5 +27,5 @@ export const DataGridContextProvider = ({ isLoading, isTabularNums, gridColumns,
|
|
|
26
27
|
mobileDisplayVariant,
|
|
27
28
|
renderLink,
|
|
28
29
|
]);
|
|
29
|
-
return (_jsx(DataGridContext.Provider, { value: contextValue, children: _jsx(DataGridStorageProvider, { children: children }) }));
|
|
30
|
+
return (_jsx(DataGridContext.Provider, { value: contextValue, children: _jsx(DataGridSelectionProvider, { selectedRows: selectedRows, onSelectRow: onSelectRow, isMassActionsOpen: isMassActionsOpen, children: _jsx(DataGridStorageProvider, { children: children }) }) }));
|
|
30
31
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type ContextOnChangeSelectedRows, type ContextSelectedRows } from '../types';
|
|
3
|
+
export type DataGridSelectionContextProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Выбранные строки таблицы
|
|
6
|
+
*/
|
|
7
|
+
selectedRows: ContextSelectedRows;
|
|
8
|
+
/**
|
|
9
|
+
* Обработчик изменения выбора, переданный в таблицу.
|
|
10
|
+
*/
|
|
11
|
+
onSelectRow?: ContextOnChangeSelectedRows;
|
|
12
|
+
/**
|
|
13
|
+
* Флаг отображения панели массовых действий
|
|
14
|
+
*/
|
|
15
|
+
isMassActionsOpen: boolean;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Контекст выбранных строк таблицы для панели массовых действий.
|
|
19
|
+
*
|
|
20
|
+
* Вынесен из `DataGridContext`, чтобы изменение выбора не вызывало ре-рендер всех строк и ячеек:
|
|
21
|
+
* контекст читает только панель массовых действий.
|
|
22
|
+
*
|
|
23
|
+
* Провайдер подключается внутри `DataGridContextProvider`.
|
|
24
|
+
*/
|
|
25
|
+
export declare const DataGridSelectionContext: import("react").Context<DataGridSelectionContextProps>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Контекст выбранных строк таблицы для панели массовых действий.
|
|
4
|
+
*
|
|
5
|
+
* Вынесен из `DataGridContext`, чтобы изменение выбора не вызывало ре-рендер всех строк и ячеек:
|
|
6
|
+
* контекст читает только панель массовых действий.
|
|
7
|
+
*
|
|
8
|
+
* Провайдер подключается внутри `DataGridContextProvider`.
|
|
9
|
+
*/
|
|
10
|
+
export const DataGridSelectionContext = createContext({
|
|
11
|
+
selectedRows: [],
|
|
12
|
+
isMassActionsOpen: false,
|
|
13
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type DataGridSelectionContextProps } from '../DataGridSelectionContext';
|
|
3
|
+
type DataGridSelectionProviderProps = Partial<DataGridSelectionContextProps> & {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
};
|
|
6
|
+
export declare const DataGridSelectionProvider: ({ selectedRows, onSelectRow, isMassActionsOpen, children, }: DataGridSelectionProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { DataGridSelectionContext, } from '../DataGridSelectionContext';
|
|
4
|
+
const EMPTY_SELECTED_ROWS = [];
|
|
5
|
+
export const DataGridSelectionProvider = ({ selectedRows = EMPTY_SELECTED_ROWS, onSelectRow, isMassActionsOpen = false, children, }) => {
|
|
6
|
+
const contextValue = useMemo(() => ({ selectedRows, onSelectRow, isMassActionsOpen }), [selectedRows, onSelectRow, isMassActionsOpen]);
|
|
7
|
+
return (_jsx(DataGridSelectionContext.Provider, { value: contextValue, children: children }));
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DataGridSelectionProvider';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DataGridSelectionProvider';
|
|
@@ -21,6 +21,8 @@ export declare const dataGridClassnames: {
|
|
|
21
21
|
rightPinnedSection: string;
|
|
22
22
|
overflowed: string;
|
|
23
23
|
wrapper: string;
|
|
24
|
+
hasMassActions: string;
|
|
25
|
+
massActionsOpen: string;
|
|
24
26
|
isAllowHorizontalScroll: string;
|
|
25
27
|
hasGroupedColumns: string;
|
|
26
28
|
gridViewFull: string;
|
|
@@ -22,6 +22,8 @@ export const dataGridClassnames = {
|
|
|
22
22
|
rightPinnedSection: createUIKitClassname('data-grid__right-pinned-section'),
|
|
23
23
|
overflowed: createUIKitClassname('data-grid_overflowed'),
|
|
24
24
|
wrapper: createUIKitClassname('data-grid__wrapper'),
|
|
25
|
+
hasMassActions: createUIKitClassname('data-grid_has-mass-actions'),
|
|
26
|
+
massActionsOpen: createUIKitClassname('data-grid_mass-actions-open'),
|
|
25
27
|
isAllowHorizontalScroll: createUIKitClassname('data-grid_is-allow-horizontal-scroll'),
|
|
26
28
|
hasGroupedColumns: createUIKitClassname('data-grid_has-grouped-columns'),
|
|
27
29
|
gridViewFull: createUIKitClassname('data-grid_grid-view-full'),
|
|
@@ -13,3 +13,7 @@ export declare const DisabledDataGridWrapper: import("../styled").StyledComponen
|
|
|
13
13
|
} & import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
14
14
|
theme?: import("@emotion/react").Theme | undefined;
|
|
15
15
|
}, {}, {}>;
|
|
16
|
+
export declare const MassActionsAnchor: import("../styled").StyledComponent<{
|
|
17
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
18
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
19
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -7,6 +7,9 @@ import { dataGridRowClassnames } from './Row/constants';
|
|
|
7
7
|
export const Container = styled.div `
|
|
8
8
|
--max-height: initial;
|
|
9
9
|
|
|
10
|
+
/* Место под открытой панелью массовых действий: высота панели + отступ */
|
|
11
|
+
--mass-actions-reserved-space: 96px;
|
|
12
|
+
|
|
10
13
|
position: relative;
|
|
11
14
|
|
|
12
15
|
overflow: hidden;
|
|
@@ -152,6 +155,24 @@ export const Container = styled.div `
|
|
|
152
155
|
}
|
|
153
156
|
}
|
|
154
157
|
}
|
|
158
|
+
|
|
159
|
+
&.${dataGridClassnames.hasMassActions} {
|
|
160
|
+
/* Резерв места под панель массовых действий убирается одновременно с анимацией её скрытия, чтобы строки не прыгали */
|
|
161
|
+
& .${dataGridClassnames.wrapper} .${dataGridClassnames.body},
|
|
162
|
+
& .${dataGridClassnames.pinnedSections} {
|
|
163
|
+
transition: padding-bottom
|
|
164
|
+
${({ theme }) => theme.transitions.duration.leavingScreen}ms
|
|
165
|
+
${({ theme }) => theme.transitions.easing.easeIn};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/* Пока панель массовых действий открыта, последние строки не должны перекрываться ею */
|
|
169
|
+
&.${dataGridClassnames.massActionsOpen} {
|
|
170
|
+
& .${dataGridClassnames.wrapper} .${dataGridClassnames.body},
|
|
171
|
+
& .${dataGridClassnames.pinnedSections} {
|
|
172
|
+
padding-bottom: var(--mass-actions-reserved-space);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
155
176
|
`;
|
|
156
177
|
export const DataGridWrapper = styled.div `
|
|
157
178
|
position: relative;
|
|
@@ -177,3 +198,8 @@ export const DisabledDataGridWrapper = styled(DataGridWrapper) `
|
|
|
177
198
|
opacity: 0.7;
|
|
178
199
|
}
|
|
179
200
|
`;
|
|
201
|
+
export const MassActionsAnchor = styled.div `
|
|
202
|
+
position: relative;
|
|
203
|
+
|
|
204
|
+
height: 0;
|
|
205
|
+
`;
|
|
@@ -46,6 +46,11 @@ export type DataGridProps<TData extends Record<string, CellValue> = DataGridRow,
|
|
|
46
46
|
* Компонент кастомного футера (например Pagination)
|
|
47
47
|
*/
|
|
48
48
|
footer?: ReactNode;
|
|
49
|
+
/**
|
|
50
|
+
* Панель массовых действий над выбранными строками
|
|
51
|
+
* @example <DataGrid massActions={<DataGridMassActions />} />
|
|
52
|
+
*/
|
|
53
|
+
massActions?: ReactNode;
|
|
49
54
|
/**
|
|
50
55
|
* Используется для отображения placeholder при отсутствии данных в таблице
|
|
51
56
|
*/
|
|
@@ -367,4 +372,6 @@ export type DataGridRowWithOptions<TData extends DataGridRow> = TData & {
|
|
|
367
372
|
children?: DataGridRowWithOptions<TData>[];
|
|
368
373
|
};
|
|
369
374
|
export type ContextOnRowClick = (row: Record<string, unknown>) => void;
|
|
375
|
+
export type ContextSelectedRows = Record<string, unknown>[];
|
|
376
|
+
export type ContextOnChangeSelectedRows = (rows: ContextSelectedRows) => void;
|
|
370
377
|
export type RenderRow = (row: Record<string, unknown>, index: number) => ReactNode;
|
|
@@ -1,7 +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, mobileDisplayVariant, onSelectRow, isError, onRetry, errorMsg, isHideSelectAll, isHideHeaderIfNoData, sorting, className, onSort, maxHeight, gridViewMode: gridViewModeProp, }: UseLogicParams<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, mobileDisplayVariant, onSelectRow, isError, onRetry, errorMsg, isHideSelectAll, isHideHeaderIfNoData, sorting, className, onSort, maxHeight, gridViewMode: gridViewModeProp, massActions, }: UseLogicParams<TData, TSortField>) => {
|
|
5
|
+
hasMassActions: boolean;
|
|
6
|
+
isMassActionsOpen: boolean;
|
|
5
7
|
dataGridClassName: string | undefined;
|
|
6
8
|
containerCssVars: import("react").CSSProperties;
|
|
7
9
|
isDataGridDisabled: boolean | undefined;
|
|
@@ -5,10 +5,10 @@ import { prop } from '../../utils/prop';
|
|
|
5
5
|
import { uniqueBy } from '../../utils/uniqueBy';
|
|
6
6
|
import { dataGridClassnames, EXPANDED_LEVEL_BY_DEFAULT, INITIAL_OPENED_NESTED_CHILDREN_COUNT_ON_MOBILE_BY_DEFAULT, } from '../constants';
|
|
7
7
|
import { Variant } from '../enums';
|
|
8
|
-
import { getDataGridCssVars, getFlattenColumns, getGridTemplateColumns, isGroupColumns, } from '../utils';
|
|
8
|
+
import { checkIsMassActionsOpen, getDataGridCssVars, getFlattenColumns, getGridTemplateColumns, isGroupColumns, } from '../utils';
|
|
9
9
|
import { useDataGridMobileLogic, usePinnedColumns } from './hooks';
|
|
10
10
|
import { getIsAllowHorizontalScroll } from './utils';
|
|
11
|
-
export const useLogic = ({ keyId, columns, rows = [], variant, tree, subrows, selectedRows = [], isLoading, isDisabled, mobileDisplayVariant = variant === 'subrows' ? 'cards' : 'list', onSelectRow, isError, onRetry, errorMsg, isHideSelectAll, isHideHeaderIfNoData = false, sorting, className, onSort, maxHeight, gridViewMode: gridViewModeProp = 'standard', }) => {
|
|
11
|
+
export const useLogic = ({ keyId, columns, rows = [], variant, tree, subrows, selectedRows = [], isLoading, isDisabled, mobileDisplayVariant = variant === 'subrows' ? 'cards' : 'list', onSelectRow, isError, onRetry, errorMsg, isHideSelectAll, isHideHeaderIfNoData = false, sorting, className, onSort, maxHeight, gridViewMode: gridViewModeProp = 'standard', massActions, }) => {
|
|
12
12
|
const isFirstRender = useFirstMountState();
|
|
13
13
|
const isSelectable = Boolean(onSelectRow);
|
|
14
14
|
const isDataGridDisabled = isLoading || isDisabled;
|
|
@@ -102,7 +102,15 @@ export const useLogic = ({ keyId, columns, rows = [], variant, tree, subrows, se
|
|
|
102
102
|
};
|
|
103
103
|
}, [isLoading, isError, isNoData, errorMsg, onRetry, imagesMap]);
|
|
104
104
|
const containerCssVars = getDataGridCssVars(maxHeight);
|
|
105
|
+
const hasMassActions = Boolean(massActions);
|
|
106
|
+
const isMassActionsOpen = checkIsMassActionsOpen({
|
|
107
|
+
hasMassActions,
|
|
108
|
+
selectedRowsCount: selectedRows.length,
|
|
109
|
+
isMobile,
|
|
110
|
+
});
|
|
105
111
|
return {
|
|
112
|
+
hasMassActions,
|
|
113
|
+
isMassActionsOpen,
|
|
106
114
|
dataGridClassName: className,
|
|
107
115
|
containerCssVars,
|
|
108
116
|
isDataGridDisabled,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type CheckIsMassActionsOpenParams = {
|
|
2
|
+
hasMassActions: boolean;
|
|
3
|
+
selectedRowsCount: number;
|
|
4
|
+
isMobile: boolean;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Панель массовых действий открыта, если она передана, выбрана хотя бы одна строка и это не мобильное разрешение
|
|
8
|
+
*/
|
|
9
|
+
export declare const checkIsMassActionsOpen: ({ hasMassActions, selectedRowsCount, isMobile, }: CheckIsMassActionsOpenParams) => boolean;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { checkIsMassActionsOpen } from './checkIsMassActionsOpen';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { checkIsMassActionsOpen } from './checkIsMassActionsOpen';
|
|
@@ -2,3 +2,4 @@ export { getDataGridCssVars } from './getDataGridCssVars';
|
|
|
2
2
|
export { getGridTemplateColumns } from './getGridTemplateColumns';
|
|
3
3
|
export { isGroupColumns } from './isGroupColumns';
|
|
4
4
|
export { getFlattenColumns } from './getFlattenColumns';
|
|
5
|
+
export { checkIsMassActionsOpen } from './checkIsMassActionsOpen';
|
|
@@ -2,3 +2,4 @@ export { getDataGridCssVars } from './getDataGridCssVars';
|
|
|
2
2
|
export { getGridTemplateColumns } from './getGridTemplateColumns';
|
|
3
3
|
export { isGroupColumns } from './isGroupColumns';
|
|
4
4
|
export { getFlattenColumns } from './getFlattenColumns';
|
|
5
|
+
export { checkIsMassActionsOpen } from './checkIsMassActionsOpen';
|
|
@@ -9,21 +9,28 @@ import { dataGridClassnames, EXPANDED_LEVEL_BY_DEFAULT, INITIAL_OPENED_NESTED_CH
|
|
|
9
9
|
import { DataGridContextProvider } from '../DataGrid/DataGridContext';
|
|
10
10
|
import { Variant } from '../DataGrid/enums';
|
|
11
11
|
import { Head } from '../DataGrid/Head';
|
|
12
|
+
import { MassActionsAnchor } from '../DataGrid/styles';
|
|
12
13
|
import { Loader } from '../Loader';
|
|
13
14
|
import { cn } from '../utils/cn';
|
|
14
15
|
import { cva } from '../utils/cva';
|
|
15
16
|
import { getInertProps } from '../utils/getInertProps';
|
|
16
17
|
import { dataGridInfiniteClassnames, OVERSCAN_COUNT } from './constants';
|
|
17
18
|
import { DataGridInfiniteContextProvider } from './DataGridInfiniteContext';
|
|
18
|
-
import { EndData } from './EndData';
|
|
19
19
|
import { ErrorMessage } from './ErrorMessage';
|
|
20
|
+
import { Footer } from './Footer';
|
|
20
21
|
import { List } from './List';
|
|
21
22
|
import { NoData } from './NoData';
|
|
22
23
|
import { Row } from './Row';
|
|
23
|
-
import { Backdrop, DataGridWrapper, DisabledDataGridWrapper,
|
|
24
|
+
import { Backdrop, DataGridWrapper, DisabledDataGridWrapper, HeaderRow, StyledContainer, StyledScrollToTopButton, } from './styles';
|
|
24
25
|
import { useLogic } from './useLogic';
|
|
25
26
|
const dataGridInfiniteCva = cva(dataGridClassnames.root, {
|
|
26
27
|
variants: {
|
|
28
|
+
hasMassActions: {
|
|
29
|
+
true: dataGridClassnames.hasMassActions,
|
|
30
|
+
},
|
|
31
|
+
isMassActionsOpen: {
|
|
32
|
+
true: dataGridClassnames.massActionsOpen,
|
|
33
|
+
},
|
|
27
34
|
hasGroupedColumns: {
|
|
28
35
|
true: dataGridClassnames.hasGroupedColumns,
|
|
29
36
|
},
|
|
@@ -42,17 +49,19 @@ const dataGridInfiniteCva = cva(dataGridClassnames.root, {
|
|
|
42
49
|
});
|
|
43
50
|
export const DataGridInfinite = (props) => {
|
|
44
51
|
const { imagesMap, emptySymbol } = useContext(ConfigContext);
|
|
45
|
-
const { isNoData, isDataGridDisabled, treeRenderConfig, virtuosoProps, headProps, rowProps, scrollToTopButtonProps,
|
|
46
|
-
const { columns, rows = [], selectedRows = [], sorting, isLoading, isDisabled, keyId, emptyCellValue = emptySymbol, variant = Variant.Tree, subrows, className, isError,
|
|
52
|
+
const { isNoData, isDataGridDisabled, treeRenderConfig, virtuosoProps, headProps, rowProps, scrollToTopButtonProps, isHideHead, containerCssVars, isMobile, mobileSkeletonProps, hasGroupedColumns, gridViewMode, gridColumns, handleSelectRow, mobileDisplayVariant, isSelfContained, isNotRenderHeader, initialTopMostItemIndex, hasMassActions, isMassActionsOpen, footerContext, } = useLogic(props);
|
|
53
|
+
const { columns, rows = [], selectedRows = [], onSelectRow, sorting, isLoading, isDisabled, keyId, emptyCellValue = emptySymbol, variant = Variant.Tree, subrows, className, isError, errorMsg, noDataPlaceholder, onRowClick, onSort, onRetry, headPreAddon, activeRowId, isTabularNums, renderRow, renderLink, massActions, } = props;
|
|
47
54
|
const { moreButtonColumnPosition = 1, isVisibleCollapseButton = true } = subrows || {};
|
|
48
55
|
const { isInitialExpanded = false, expandedLevel = EXPANDED_LEVEL_BY_DEFAULT, initialVisibleChildrenCount = INITIAL_OPENED_NESTED_CHILDREN_COUNT_BY_DEFAULT, } = treeRenderConfig || {};
|
|
49
56
|
const { isSelectable } = rowProps;
|
|
50
57
|
const TableContainer = isDisabled ? DisabledDataGridWrapper : DataGridWrapper;
|
|
51
|
-
return (_jsx(DataGridInfiniteContextProvider, { renderRow: renderRow, onSelectRow: handleSelectRow, variant: variant, isInitialExpanded: isInitialExpanded, expandedLevel: expandedLevel, initialVisibleChildrenCount: initialVisibleChildrenCount, isSelectable: isSelectable, selectedRows: selectedRows, moreButtonColumnPosition: moreButtonColumnPosition, isVisibleCollapseButton: isVisibleCollapseButton, children: _jsx(DataGridContextProvider, { gridColumns: gridColumns, emptyCellValue: emptyCellValue, activeRowId: activeRowId, columns: columns, keyId: keyId, isTabularNums: isTabularNums, onRowClick: onRowClick, mobileDisplayVariant: mobileDisplayVariant, renderLink: renderLink, children: _jsxs(StyledContainer, { style: containerCssVars, className: cn(dataGridInfiniteCva({
|
|
58
|
+
return (_jsx(DataGridInfiniteContextProvider, { renderRow: renderRow, onSelectRow: handleSelectRow, variant: variant, isInitialExpanded: isInitialExpanded, expandedLevel: expandedLevel, initialVisibleChildrenCount: initialVisibleChildrenCount, isSelectable: isSelectable, selectedRows: selectedRows, moreButtonColumnPosition: moreButtonColumnPosition, isVisibleCollapseButton: isVisibleCollapseButton, children: _jsx(DataGridContextProvider, { gridColumns: gridColumns, emptyCellValue: emptyCellValue, activeRowId: activeRowId, columns: columns, keyId: keyId, isTabularNums: isTabularNums, onRowClick: onRowClick, mobileDisplayVariant: mobileDisplayVariant, renderLink: renderLink, selectedRows: selectedRows, onSelectRow: onSelectRow, isMassActionsOpen: isMassActionsOpen, children: _jsxs(StyledContainer, { style: containerCssVars, className: cn(dataGridInfiniteCva({
|
|
52
59
|
hasGroupedColumns,
|
|
53
60
|
gridViewMode,
|
|
54
61
|
mobileDisplayVariant,
|
|
55
62
|
isSelfContained,
|
|
63
|
+
hasMassActions,
|
|
64
|
+
isMassActionsOpen,
|
|
56
65
|
}), 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: {
|
|
57
66
|
imgAlt: 'Что-то пошло не так',
|
|
58
67
|
errorList: [errorMsg || ''],
|
|
@@ -60,23 +69,18 @@ export const DataGridInfinite = (props) => {
|
|
|
60
69
|
onRetry,
|
|
61
70
|
}, children: _jsx(Virtuoso, { ...virtuosoProps, ...(initialTopMostItemIndex && {
|
|
62
71
|
initialTopMostItemIndex,
|
|
63
|
-
}), style: { height: '100%' }, overscan: OVERSCAN_COUNT, data: rows, components: {
|
|
72
|
+
}), style: { height: '100%' }, overscan: OVERSCAN_COUNT, data: rows, context: footerContext, components: {
|
|
64
73
|
// biome-ignore lint/suspicious/noTsIgnore: Требует HTMLDivElement, а для элемента списка используем HTMLUListElement (https://github.com/petyosi/react-virtuoso/issues/864)
|
|
65
74
|
// @ts-ignore
|
|
66
75
|
List,
|
|
67
76
|
Item: Row,
|
|
68
77
|
EmptyPlaceholder: () => (_jsx(_Fragment, { children: noDataPlaceholder || _jsx(NoData, {}) })),
|
|
69
|
-
Footer
|
|
70
|
-
if (!isLoading && !isError && !isEndReached) {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
return (_jsxs(FooterRow, { children: [isLoading && _jsx(Loader, {}), isError && _jsx(ErrorMessage, { onRetry: onRetry }), isEndReached && (_jsx(EndData, { endOfScrollMsg: endOfScrollMsg }))] }));
|
|
74
|
-
},
|
|
78
|
+
Footer,
|
|
75
79
|
Header: () => {
|
|
76
80
|
if (isNotRenderHeader) {
|
|
77
81
|
return null;
|
|
78
82
|
}
|
|
79
83
|
return (_jsxs(HeaderRow, { children: [isLoading && _jsx(Loader, {}), isError && _jsx(ErrorMessage, { onRetry: onRetry })] }));
|
|
80
84
|
},
|
|
81
|
-
} }) }), _jsx(StyledScrollToTopButton, { ...scrollToTopButtonProps, className: dataGridInfiniteClassnames.scrollToTopButton }), isDisabled && _jsx(Backdrop, {})] })] }) }) }));
|
|
85
|
+
} }) }), massActions && (_jsx(MassActionsAnchor, { children: massActions })), _jsx(StyledScrollToTopButton, { ...scrollToTopButtonProps, className: dataGridInfiniteClassnames.scrollToTopButton }), isDisabled && _jsx(Backdrop, {})] })] }) }) }));
|
|
82
86
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Loader } from '../../Loader';
|
|
3
|
+
import { dataGridInfiniteClassnames } from '../constants';
|
|
4
|
+
import { EndData } from '../EndData';
|
|
5
|
+
import { ErrorMessage } from '../ErrorMessage';
|
|
6
|
+
import { FooterRow, MassActionsSpacer } from '../styles';
|
|
7
|
+
/**
|
|
8
|
+
* Футер списка для Virtuoso.
|
|
9
|
+
*/
|
|
10
|
+
export const Footer = ({ context }) => {
|
|
11
|
+
const { isLoading, isError, isEndReached, endOfScrollMsg, onRetry, hasMassActions, } = context;
|
|
12
|
+
const renderStatus = () => {
|
|
13
|
+
if (isLoading) {
|
|
14
|
+
return (_jsx(FooterRow, { children: _jsx(Loader, {}) }));
|
|
15
|
+
}
|
|
16
|
+
if (isError) {
|
|
17
|
+
return (_jsx(FooterRow, { children: _jsx(ErrorMessage, { onRetry: onRetry }) }));
|
|
18
|
+
}
|
|
19
|
+
if (isEndReached) {
|
|
20
|
+
return (_jsx(FooterRow, { children: _jsx(EndData, { endOfScrollMsg: endOfScrollMsg }) }));
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
};
|
|
24
|
+
return (_jsxs(_Fragment, { children: [renderStatus(), hasMassActions && (_jsx(MassActionsSpacer, { className: dataGridInfiniteClassnames.massActionsSpacer }))] }));
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Footer';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type FooterContext = {
|
|
2
|
+
/**
|
|
3
|
+
* Флаг состояния загрузки
|
|
4
|
+
*/
|
|
5
|
+
isLoading?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Флаг состояния ошибки
|
|
8
|
+
*/
|
|
9
|
+
isError?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Флаг достижения конца списка
|
|
12
|
+
*/
|
|
13
|
+
isEndReached?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Текст достижения конца списка
|
|
16
|
+
*/
|
|
17
|
+
endOfScrollMsg?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Обработчик повторной загрузки при ошибке
|
|
20
|
+
*/
|
|
21
|
+
onRetry: () => void;
|
|
22
|
+
/**
|
|
23
|
+
* Флаг наличия массовых действий
|
|
24
|
+
*/
|
|
25
|
+
hasMassActions: boolean;
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,4 +6,5 @@ export const VIRTUOSO_LIST_ID = 'virtuoso-list';
|
|
|
6
6
|
export const dataGridInfiniteClassnames = {
|
|
7
7
|
scrollToTopButton: createUIKitClassname('data-grid-infinite__scroll-to-top-button'),
|
|
8
8
|
visibleScrollToTopButton: createUIKitClassname('data-grid-infinite__scroll-to-top-button_visible'),
|
|
9
|
+
massActionsSpacer: createUIKitClassname('data-grid-infinite__mass-actions-spacer'),
|
|
9
10
|
};
|
|
@@ -30,3 +30,7 @@ export declare const StyledContainer: import("../styled").StyledComponent<{
|
|
|
30
30
|
} & import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
31
31
|
theme?: import("@emotion/react").Theme | undefined;
|
|
32
32
|
}, {}, {}>;
|
|
33
|
+
export declare const MassActionsSpacer: import("../styled").StyledComponent<{
|
|
34
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
35
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
36
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { dataGridClassnames } from '../DataGrid/constants';
|
|
1
2
|
import { Container } from '../DataGrid/styles';
|
|
2
3
|
import { ScrollToTopButton } from '../ScrollToTopButton';
|
|
3
4
|
import { styled } from '../styled';
|
|
@@ -52,6 +53,26 @@ export const StyledScrollToTopButton = styled(ScrollToTopButton) `
|
|
|
52
53
|
}
|
|
53
54
|
`;
|
|
54
55
|
export const StyledContainer = styled(Container) `
|
|
56
|
+
&.${dataGridClassnames.hasMassActions} {
|
|
57
|
+
/* Резерв места под панель массовых действий убирается одновременно с анимацией её скрытия, чтобы строки не прыгали */
|
|
58
|
+
& .${dataGridInfiniteClassnames.massActionsSpacer} {
|
|
59
|
+
transition: height
|
|
60
|
+
${({ theme }) => theme.transitions.duration.leavingScreen}ms
|
|
61
|
+
${({ theme }) => theme.transitions.easing.easeIn};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&.${dataGridClassnames.massActionsOpen} {
|
|
65
|
+
& .${dataGridInfiniteClassnames.massActionsSpacer} {
|
|
66
|
+
height: var(--mass-actions-reserved-space);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* Кнопка «Наверх» скрыта при открытой панели, чтобы не перегружать интерфейс */
|
|
70
|
+
& .${dataGridInfiniteClassnames.scrollToTopButton} {
|
|
71
|
+
display: none;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
55
76
|
${({ theme }) => theme.breakpoints.down('mobile')} {
|
|
56
77
|
& .${dataGridInfiniteListClassnames.root} {
|
|
57
78
|
display: flex;
|
|
@@ -60,3 +81,6 @@ export const StyledContainer = styled(Container) `
|
|
|
60
81
|
}
|
|
61
82
|
}
|
|
62
83
|
`;
|
|
84
|
+
export const MassActionsSpacer = styled.div `
|
|
85
|
+
height: 0;
|
|
86
|
+
`;
|