@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ToggleButtonGroupProps } from '../../components/ToggleButtonGroup';
|
|
2
2
|
import { type WithFormFieldProps } from '../types';
|
|
3
|
-
export type FormToggleButtonGroupProps<TFieldValues extends object, TDisableHelperText extends boolean = false> = WithFormFieldProps<Omit<ToggleButtonGroupProps, 'exclusive'>, TFieldValues> & {
|
|
3
|
+
export type FormToggleButtonGroupProps<TFieldValues extends object, TDisableHelperText extends boolean = false> = WithFormFieldProps<Omit<ToggleButtonGroupProps, 'exclusive' | 'defaultValue'>, TFieldValues> & {
|
|
4
4
|
/**
|
|
5
5
|
* Если true, сообщение об ошибке не будет показано
|
|
6
6
|
*/
|
|
@@ -5,11 +5,11 @@ export const FormToggleButtonGroup = (props) => {
|
|
|
5
5
|
const { isError, onChange, errorText, color: colorToggleButton, isDisabledErrorText, ...restProps } = props;
|
|
6
6
|
const { error, children, helperText, onChange: fieldPropsOnChange, ...fieldProps } = useFormFieldProps({
|
|
7
7
|
...restProps,
|
|
8
|
-
defaultValue: restProps.defaultValue
|
|
8
|
+
defaultValue: restProps.defaultValue ??
|
|
9
9
|
null,
|
|
10
10
|
});
|
|
11
11
|
const handleChange = (_, value) => {
|
|
12
|
-
if (value) {
|
|
12
|
+
if (value != null) {
|
|
13
13
|
fieldPropsOnChange(value);
|
|
14
14
|
}
|
|
15
15
|
};
|
|
@@ -8,8 +8,8 @@ const SecondaryActions_1 = require("./SecondaryActions");
|
|
|
8
8
|
const SecondaryVisibleActions_1 = require("./SecondaryVisibleActions");
|
|
9
9
|
const styles_1 = require("./styles");
|
|
10
10
|
const ActionGroup = (props) => {
|
|
11
|
-
const { main, secondary, secondaryVisible, className, size = 'medium', } = props;
|
|
11
|
+
const { main, secondary, secondaryVisible, secondaryPopoverProps, className, size = 'medium', } = props;
|
|
12
12
|
const { disabledAction } = (0, hooks_1.useActionsState)({ main, secondary });
|
|
13
|
-
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { className: className, children: [secondary && ((0, jsx_runtime_1.jsx)(SecondaryActions_1.SecondaryActions, { isDisabled: disabledAction, actions: secondary, size: size })), secondaryVisible && ((0, jsx_runtime_1.jsx)(SecondaryVisibleActions_1.SecondaryVisibleActions, { actions: secondaryVisible, size: size })), main && ((0, jsx_runtime_1.jsx)(MainActions_1.MainActions, { isDisabled: disabledAction, actions: main, size: size }))] }));
|
|
13
|
+
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { className: className, children: [secondary && ((0, jsx_runtime_1.jsx)(SecondaryActions_1.SecondaryActions, { isDisabled: disabledAction, actions: secondary, size: size, popoverProps: secondaryPopoverProps })), secondaryVisible && ((0, jsx_runtime_1.jsx)(SecondaryVisibleActions_1.SecondaryVisibleActions, { actions: secondaryVisible, size: size })), main && ((0, jsx_runtime_1.jsx)(MainActions_1.MainActions, { isDisabled: disabledAction, actions: main, size: size }))] }));
|
|
14
14
|
};
|
|
15
15
|
exports.ActionGroup = ActionGroup;
|
|
@@ -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;
|
|
@@ -8,11 +8,11 @@ const IconDropdownButton_1 = require("../../IconDropdownButton");
|
|
|
8
8
|
const ListItemButton_1 = require("../../ListItemButton");
|
|
9
9
|
const ListItemText_1 = require("../../ListItemText");
|
|
10
10
|
const TOOLTIP_PLACEMENT = 'right';
|
|
11
|
-
const SecondaryActions = ({ actions, isDisabled, className, size, }) => {
|
|
11
|
+
const SecondaryActions = ({ actions, isDisabled, className, size, popoverProps, }) => {
|
|
12
12
|
if (!actions.length) {
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
|
-
return ((0, jsx_runtime_1.jsx)(IconDropdownButton_1.IconDropdownButton, { disabled: isDisabled, icon: (0, jsx_runtime_1.jsx)(DotsOutlineMd_1.DotsOutlineMd, {}), variant: "outlined", color: "grey", size: size, className: className, children: actions.map(({ text, ...secondaryProps }) => ((0, react_1.createElement)(ListItemButton_1.ListItemButton, { tooltipPlacement: TOOLTIP_PLACEMENT, ...secondaryProps, key: text },
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(IconDropdownButton_1.IconDropdownButton, { disabled: isDisabled, icon: (0, jsx_runtime_1.jsx)(DotsOutlineMd_1.DotsOutlineMd, {}), variant: "outlined", color: "grey", size: size, className: className, popoverProps: popoverProps, children: actions.map(({ text, ...secondaryProps }) => ((0, react_1.createElement)(ListItemButton_1.ListItemButton, { tooltipPlacement: TOOLTIP_PLACEMENT, ...secondaryProps, key: text },
|
|
16
16
|
(0, jsx_runtime_1.jsx)(ListItemText_1.ListItemText, { primary: text })))) }));
|
|
17
17
|
};
|
|
18
18
|
exports.SecondaryActions = SecondaryActions;
|
|
@@ -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
|
*/
|
|
@@ -29,6 +29,12 @@ const pinnedSectionsCva = (0, cva_1.cva)(constants_2.dataGridClassnames.pinnedSe
|
|
|
29
29
|
});
|
|
30
30
|
const dataGridCva = (0, cva_1.cva)(constants_2.dataGridClassnames.root, {
|
|
31
31
|
variants: {
|
|
32
|
+
hasMassActions: {
|
|
33
|
+
true: constants_2.dataGridClassnames.hasMassActions,
|
|
34
|
+
},
|
|
35
|
+
isMassActionsOpen: {
|
|
36
|
+
true: constants_2.dataGridClassnames.massActionsOpen,
|
|
37
|
+
},
|
|
32
38
|
hasPinnedColumns: {
|
|
33
39
|
true: constants_2.dataGridClassnames.hasPinnedSections,
|
|
34
40
|
},
|
|
@@ -59,9 +65,9 @@ const bodyCva = (0, cva_1.cva)(constants_2.dataGridClassnames.body, {
|
|
|
59
65
|
},
|
|
60
66
|
});
|
|
61
67
|
const DataGrid = (props) => {
|
|
62
|
-
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, } = (0, useLogic_1.useLogic)(props);
|
|
68
|
+
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, } = (0, useLogic_1.useLogic)(props);
|
|
63
69
|
const { emptySymbol } = (0, react_1.useContext)(ConfigProvider_1.ConfigContext);
|
|
64
|
-
const { columns, selectedRows = [], minDisplayRows = constants_2.MIN_DISPLAY_ROWS_BY_DEFAULT, variant = enums_1.Variant.Tree, footer, noDataPlaceholder, subrows, keyId, activeRowId, emptyCellValue = emptySymbol, onRowClick, noDataOptions, headPreAddon, isTabularNums, renderRow, renderLink, } = props;
|
|
70
|
+
const { columns, selectedRows = [], onSelectRow, minDisplayRows = constants_2.MIN_DISPLAY_ROWS_BY_DEFAULT, variant = enums_1.Variant.Tree, footer, massActions, noDataPlaceholder, subrows, keyId, activeRowId, emptyCellValue = emptySymbol, onRowClick, noDataOptions, headPreAddon, isTabularNums, renderRow, renderLink, } = props;
|
|
65
71
|
const { moreButtonColumnPosition = 1, isVisibleCollapseButton = true } = subrows || {};
|
|
66
72
|
const { isInitialExpanded = false, expandedLevel = constants_2.EXPANDED_LEVEL_BY_DEFAULT, initialVisibleChildrenCount = constants_2.INITIAL_OPENED_NESTED_CHILDREN_COUNT_BY_DEFAULT, } = treeRenderConfig || {};
|
|
67
73
|
const Wrapper = isDataGridDisabled
|
|
@@ -101,13 +107,15 @@ const DataGrid = (props) => {
|
|
|
101
107
|
isDisabled: isDataGridDisabled,
|
|
102
108
|
}), isDisabled: isDataGridDisabled, headProps: headProps, gridColumns: gridColumns, bodyProps: commonBodyProps, isNoData: isNoData }) }));
|
|
103
109
|
};
|
|
104
|
-
return ((0, jsx_runtime_1.jsx)(DataGridContext_1.DataGridContextProvider, { isLoading: isLoading, isTabularNums: isTabularNums, gridColumns: gridColumns, emptyCellValue: emptyCellValue, activeRowId: activeRowId, keyId: keyId, columns: columns, onRowClick: onRowClick, mobileDisplayVariant: mobileDisplayVariant, renderLink: renderLink, children: (0, jsx_runtime_1.jsxs)(styles_1.Container, { ref: containerRef, style: containerCssVars, className: (0, cn_1.cn)(dataGridClassName, dataGridCva({
|
|
110
|
+
return ((0, jsx_runtime_1.jsx)(DataGridContext_1.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: (0, jsx_runtime_1.jsxs)(styles_1.Container, { ref: containerRef, style: containerCssVars, className: (0, cn_1.cn)(dataGridClassName, dataGridCva({
|
|
105
111
|
isAllowHorizontalScroll,
|
|
106
112
|
hasPinnedColumns,
|
|
107
113
|
gridViewMode,
|
|
108
114
|
hasGroupedColumns,
|
|
109
115
|
mobileDisplayVariant,
|
|
110
116
|
isSelfContained,
|
|
111
|
-
|
|
117
|
+
hasMassActions,
|
|
118
|
+
isMassActionsOpen,
|
|
119
|
+
})), children: [renderTableContent(), (0, jsx_runtime_1.jsx)(Loader_1.Loader, { ...loaderProps }), massActions && (0, jsx_runtime_1.jsx)(styles_1.MassActionsAnchor, { children: massActions }), footer && footer] }) }));
|
|
112
120
|
};
|
|
113
121
|
exports.DataGrid = DataGrid;
|
|
@@ -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 {};
|
|
@@ -3,9 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DataGridContextProvider = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const DataGridSelectionContext_1 = require("../../DataGridSelectionContext");
|
|
6
7
|
const DataGridStorageContext_1 = require("../../DataGridStorageContext");
|
|
7
8
|
const DataGridContext_1 = require("../DataGridContext");
|
|
8
|
-
const DataGridContextProvider = ({ isLoading, isTabularNums, gridColumns, emptyCellValue, activeRowId, children, keyId, columns, onRowClick, mobileDisplayVariant, renderLink, }) => {
|
|
9
|
+
const DataGridContextProvider = ({ isLoading, isTabularNums, gridColumns, emptyCellValue, activeRowId, children, keyId, columns, onRowClick, mobileDisplayVariant, renderLink, selectedRows, onSelectRow, isMassActionsOpen, }) => {
|
|
9
10
|
const contextValue = (0, react_1.useMemo)(() => ({
|
|
10
11
|
isLoading,
|
|
11
12
|
isTabularNums,
|
|
@@ -29,6 +30,6 @@ const DataGridContextProvider = ({ isLoading, isTabularNums, gridColumns, emptyC
|
|
|
29
30
|
mobileDisplayVariant,
|
|
30
31
|
renderLink,
|
|
31
32
|
]);
|
|
32
|
-
return ((0, jsx_runtime_1.jsx)(DataGridContext_1.DataGridContext.Provider, { value: contextValue, children: (0, jsx_runtime_1.jsx)(DataGridStorageContext_1.DataGridStorageProvider, { children: children }) }));
|
|
33
|
+
return ((0, jsx_runtime_1.jsx)(DataGridContext_1.DataGridContext.Provider, { value: contextValue, children: (0, jsx_runtime_1.jsx)(DataGridSelectionContext_1.DataGridSelectionProvider, { selectedRows: selectedRows, onSelectRow: onSelectRow, isMassActionsOpen: isMassActionsOpen, children: (0, jsx_runtime_1.jsx)(DataGridStorageContext_1.DataGridStorageProvider, { children: children }) }) }));
|
|
33
34
|
};
|
|
34
35
|
exports.DataGridContextProvider = DataGridContextProvider;
|
|
@@ -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,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataGridSelectionContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* Контекст выбранных строк таблицы для панели массовых действий.
|
|
7
|
+
*
|
|
8
|
+
* Вынесен из `DataGridContext`, чтобы изменение выбора не вызывало ре-рендер всех строк и ячеек:
|
|
9
|
+
* контекст читает только панель массовых действий.
|
|
10
|
+
*
|
|
11
|
+
* Провайдер подключается внутри `DataGridContextProvider`.
|
|
12
|
+
*/
|
|
13
|
+
exports.DataGridSelectionContext = (0, react_1.createContext)({
|
|
14
|
+
selectedRows: [],
|
|
15
|
+
isMassActionsOpen: false,
|
|
16
|
+
});
|
|
@@ -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,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataGridSelectionProvider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const DataGridSelectionContext_1 = require("../DataGridSelectionContext");
|
|
7
|
+
const EMPTY_SELECTED_ROWS = [];
|
|
8
|
+
const DataGridSelectionProvider = ({ selectedRows = EMPTY_SELECTED_ROWS, onSelectRow, isMassActionsOpen = false, children, }) => {
|
|
9
|
+
const contextValue = (0, react_1.useMemo)(() => ({ selectedRows, onSelectRow, isMassActionsOpen }), [selectedRows, onSelectRow, isMassActionsOpen]);
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(DataGridSelectionContext_1.DataGridSelectionContext.Provider, { value: contextValue, children: children }));
|
|
11
|
+
};
|
|
12
|
+
exports.DataGridSelectionProvider = DataGridSelectionProvider;
|
package/node/components/DataGrid/DataGridSelectionContext/DataGridSelectionProvider/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DataGridSelectionProvider';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./DataGridSelectionProvider"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./DataGridSelectionContext"), exports);
|
|
18
|
+
__exportStar(require("./DataGridSelectionProvider"), exports);
|
|
@@ -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;
|
|
@@ -25,6 +25,8 @@ exports.dataGridClassnames = {
|
|
|
25
25
|
rightPinnedSection: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__right-pinned-section'),
|
|
26
26
|
overflowed: (0, createUIKitClassname_1.createUIKitClassname)('data-grid_overflowed'),
|
|
27
27
|
wrapper: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__wrapper'),
|
|
28
|
+
hasMassActions: (0, createUIKitClassname_1.createUIKitClassname)('data-grid_has-mass-actions'),
|
|
29
|
+
massActionsOpen: (0, createUIKitClassname_1.createUIKitClassname)('data-grid_mass-actions-open'),
|
|
28
30
|
isAllowHorizontalScroll: (0, createUIKitClassname_1.createUIKitClassname)('data-grid_is-allow-horizontal-scroll'),
|
|
29
31
|
hasGroupedColumns: (0, createUIKitClassname_1.createUIKitClassname)('data-grid_has-grouped-columns'),
|
|
30
32
|
gridViewFull: (0, createUIKitClassname_1.createUIKitClassname)('data-grid_grid-view-full'),
|
|
@@ -13,3 +13,7 @@ export declare const DisabledDataGridWrapper: import("@emotion/styled/dist/decla
|
|
|
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("@emotion/styled/dist/declarations/src/types").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>, {}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DisabledDataGridWrapper = exports.DataGridWrapper = exports.Container = void 0;
|
|
3
|
+
exports.MassActionsAnchor = exports.DisabledDataGridWrapper = exports.DataGridWrapper = exports.Container = void 0;
|
|
4
4
|
const styled_1 = require("../styled");
|
|
5
5
|
const constants_1 = require("./Body/constants");
|
|
6
6
|
const constants_2 = require("./Cell/constants");
|
|
@@ -10,6 +10,9 @@ const constants_4 = require("./Row/constants");
|
|
|
10
10
|
exports.Container = styled_1.styled.div `
|
|
11
11
|
--max-height: initial;
|
|
12
12
|
|
|
13
|
+
/* Место под открытой панелью массовых действий: высота панели + отступ */
|
|
14
|
+
--mass-actions-reserved-space: 96px;
|
|
15
|
+
|
|
13
16
|
position: relative;
|
|
14
17
|
|
|
15
18
|
overflow: hidden;
|
|
@@ -155,6 +158,24 @@ exports.Container = styled_1.styled.div `
|
|
|
155
158
|
}
|
|
156
159
|
}
|
|
157
160
|
}
|
|
161
|
+
|
|
162
|
+
&.${constants_3.dataGridClassnames.hasMassActions} {
|
|
163
|
+
/* Резерв места под панель массовых действий убирается одновременно с анимацией её скрытия, чтобы строки не прыгали */
|
|
164
|
+
& .${constants_3.dataGridClassnames.wrapper} .${constants_3.dataGridClassnames.body},
|
|
165
|
+
& .${constants_3.dataGridClassnames.pinnedSections} {
|
|
166
|
+
transition: padding-bottom
|
|
167
|
+
${({ theme }) => theme.transitions.duration.leavingScreen}ms
|
|
168
|
+
${({ theme }) => theme.transitions.easing.easeIn};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* Пока панель массовых действий открыта, последние строки не должны перекрываться ею */
|
|
172
|
+
&.${constants_3.dataGridClassnames.massActionsOpen} {
|
|
173
|
+
& .${constants_3.dataGridClassnames.wrapper} .${constants_3.dataGridClassnames.body},
|
|
174
|
+
& .${constants_3.dataGridClassnames.pinnedSections} {
|
|
175
|
+
padding-bottom: var(--mass-actions-reserved-space);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
158
179
|
`;
|
|
159
180
|
exports.DataGridWrapper = styled_1.styled.div `
|
|
160
181
|
position: relative;
|
|
@@ -180,3 +201,8 @@ exports.DisabledDataGridWrapper = (0, styled_1.styled)(exports.DataGridWrapper)
|
|
|
180
201
|
opacity: 0.7;
|
|
181
202
|
}
|
|
182
203
|
`;
|
|
204
|
+
exports.MassActionsAnchor = styled_1.styled.div `
|
|
205
|
+
position: relative;
|
|
206
|
+
|
|
207
|
+
height: 0;
|
|
208
|
+
`;
|
|
@@ -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;
|
|
@@ -11,7 +11,7 @@ const enums_1 = require("../enums");
|
|
|
11
11
|
const utils_1 = require("../utils");
|
|
12
12
|
const hooks_1 = require("./hooks");
|
|
13
13
|
const utils_2 = require("./utils");
|
|
14
|
-
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', }) => {
|
|
14
|
+
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, }) => {
|
|
15
15
|
const isFirstRender = (0, useFirstMountState_1.useFirstMountState)();
|
|
16
16
|
const isSelectable = Boolean(onSelectRow);
|
|
17
17
|
const isDataGridDisabled = isLoading || isDisabled;
|
|
@@ -105,7 +105,15 @@ const useLogic = ({ keyId, columns, rows = [], variant, tree, subrows, selectedR
|
|
|
105
105
|
};
|
|
106
106
|
}, [isLoading, isError, isNoData, errorMsg, onRetry, imagesMap]);
|
|
107
107
|
const containerCssVars = (0, utils_1.getDataGridCssVars)(maxHeight);
|
|
108
|
+
const hasMassActions = Boolean(massActions);
|
|
109
|
+
const isMassActionsOpen = (0, utils_1.checkIsMassActionsOpen)({
|
|
110
|
+
hasMassActions,
|
|
111
|
+
selectedRowsCount: selectedRows.length,
|
|
112
|
+
isMobile,
|
|
113
|
+
});
|
|
108
114
|
return {
|
|
115
|
+
hasMassActions,
|
|
116
|
+
isMassActionsOpen,
|
|
109
117
|
dataGridClassName: className,
|
|
110
118
|
containerCssVars,
|
|
111
119
|
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,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkIsMassActionsOpen = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Панель массовых действий открыта, если она передана, выбрана хотя бы одна строка и это не мобильное разрешение
|
|
6
|
+
*/
|
|
7
|
+
const checkIsMassActionsOpen = ({ hasMassActions, selectedRowsCount, isMobile, }) => hasMassActions && selectedRowsCount > 0 && !isMobile;
|
|
8
|
+
exports.checkIsMassActionsOpen = checkIsMassActionsOpen;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { checkIsMassActionsOpen } from './checkIsMassActionsOpen';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkIsMassActionsOpen = void 0;
|
|
4
|
+
var checkIsMassActionsOpen_1 = require("./checkIsMassActionsOpen");
|
|
5
|
+
Object.defineProperty(exports, "checkIsMassActionsOpen", { enumerable: true, get: function () { return checkIsMassActionsOpen_1.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';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFlattenColumns = exports.isGroupColumns = exports.getGridTemplateColumns = exports.getDataGridCssVars = void 0;
|
|
3
|
+
exports.checkIsMassActionsOpen = exports.getFlattenColumns = exports.isGroupColumns = exports.getGridTemplateColumns = exports.getDataGridCssVars = void 0;
|
|
4
4
|
var getDataGridCssVars_1 = require("./getDataGridCssVars");
|
|
5
5
|
Object.defineProperty(exports, "getDataGridCssVars", { enumerable: true, get: function () { return getDataGridCssVars_1.getDataGridCssVars; } });
|
|
6
6
|
var getGridTemplateColumns_1 = require("./getGridTemplateColumns");
|
|
@@ -9,3 +9,5 @@ var isGroupColumns_1 = require("./isGroupColumns");
|
|
|
9
9
|
Object.defineProperty(exports, "isGroupColumns", { enumerable: true, get: function () { return isGroupColumns_1.isGroupColumns; } });
|
|
10
10
|
var getFlattenColumns_1 = require("./getFlattenColumns");
|
|
11
11
|
Object.defineProperty(exports, "getFlattenColumns", { enumerable: true, get: function () { return getFlattenColumns_1.getFlattenColumns; } });
|
|
12
|
+
var checkIsMassActionsOpen_1 = require("./checkIsMassActionsOpen");
|
|
13
|
+
Object.defineProperty(exports, "checkIsMassActionsOpen", { enumerable: true, get: function () { return checkIsMassActionsOpen_1.checkIsMassActionsOpen; } });
|
|
@@ -12,21 +12,28 @@ const constants_2 = require("../DataGrid/constants");
|
|
|
12
12
|
const DataGridContext_1 = require("../DataGrid/DataGridContext");
|
|
13
13
|
const enums_1 = require("../DataGrid/enums");
|
|
14
14
|
const Head_1 = require("../DataGrid/Head");
|
|
15
|
+
const styles_1 = require("../DataGrid/styles");
|
|
15
16
|
const Loader_1 = require("../Loader");
|
|
16
17
|
const cn_1 = require("../utils/cn");
|
|
17
18
|
const cva_1 = require("../utils/cva");
|
|
18
19
|
const getInertProps_1 = require("../utils/getInertProps");
|
|
19
20
|
const constants_3 = require("./constants");
|
|
20
21
|
const DataGridInfiniteContext_1 = require("./DataGridInfiniteContext");
|
|
21
|
-
const EndData_1 = require("./EndData");
|
|
22
22
|
const ErrorMessage_1 = require("./ErrorMessage");
|
|
23
|
+
const Footer_1 = require("./Footer");
|
|
23
24
|
const List_1 = require("./List");
|
|
24
25
|
const NoData_1 = require("./NoData");
|
|
25
26
|
const Row_1 = require("./Row");
|
|
26
|
-
const
|
|
27
|
+
const styles_2 = require("./styles");
|
|
27
28
|
const useLogic_1 = require("./useLogic");
|
|
28
29
|
const dataGridInfiniteCva = (0, cva_1.cva)(constants_2.dataGridClassnames.root, {
|
|
29
30
|
variants: {
|
|
31
|
+
hasMassActions: {
|
|
32
|
+
true: constants_2.dataGridClassnames.hasMassActions,
|
|
33
|
+
},
|
|
34
|
+
isMassActionsOpen: {
|
|
35
|
+
true: constants_2.dataGridClassnames.massActionsOpen,
|
|
36
|
+
},
|
|
30
37
|
hasGroupedColumns: {
|
|
31
38
|
true: constants_2.dataGridClassnames.hasGroupedColumns,
|
|
32
39
|
},
|
|
@@ -45,17 +52,19 @@ const dataGridInfiniteCva = (0, cva_1.cva)(constants_2.dataGridClassnames.root,
|
|
|
45
52
|
});
|
|
46
53
|
const DataGridInfinite = (props) => {
|
|
47
54
|
const { imagesMap, emptySymbol } = (0, react_1.useContext)(ConfigProvider_1.ConfigContext);
|
|
48
|
-
const { isNoData, isDataGridDisabled, treeRenderConfig, virtuosoProps, headProps, rowProps, scrollToTopButtonProps,
|
|
49
|
-
const { columns, rows = [], selectedRows = [], sorting, isLoading, isDisabled, keyId, emptyCellValue = emptySymbol, variant = enums_1.Variant.Tree, subrows, className, isError,
|
|
55
|
+
const { isNoData, isDataGridDisabled, treeRenderConfig, virtuosoProps, headProps, rowProps, scrollToTopButtonProps, isHideHead, containerCssVars, isMobile, mobileSkeletonProps, hasGroupedColumns, gridViewMode, gridColumns, handleSelectRow, mobileDisplayVariant, isSelfContained, isNotRenderHeader, initialTopMostItemIndex, hasMassActions, isMassActionsOpen, footerContext, } = (0, useLogic_1.useLogic)(props);
|
|
56
|
+
const { columns, rows = [], selectedRows = [], onSelectRow, sorting, isLoading, isDisabled, keyId, emptyCellValue = emptySymbol, variant = enums_1.Variant.Tree, subrows, className, isError, errorMsg, noDataPlaceholder, onRowClick, onSort, onRetry, headPreAddon, activeRowId, isTabularNums, renderRow, renderLink, massActions, } = props;
|
|
50
57
|
const { moreButtonColumnPosition = 1, isVisibleCollapseButton = true } = subrows || {};
|
|
51
58
|
const { isInitialExpanded = false, expandedLevel = constants_2.EXPANDED_LEVEL_BY_DEFAULT, initialVisibleChildrenCount = constants_2.INITIAL_OPENED_NESTED_CHILDREN_COUNT_BY_DEFAULT, } = treeRenderConfig || {};
|
|
52
59
|
const { isSelectable } = rowProps;
|
|
53
|
-
const TableContainer = isDisabled ?
|
|
54
|
-
return ((0, jsx_runtime_1.jsx)(DataGridInfiniteContext_1.DataGridInfiniteContextProvider, { renderRow: renderRow, onSelectRow: handleSelectRow, variant: variant, isInitialExpanded: isInitialExpanded, expandedLevel: expandedLevel, initialVisibleChildrenCount: initialVisibleChildrenCount, isSelectable: isSelectable, selectedRows: selectedRows, moreButtonColumnPosition: moreButtonColumnPosition, isVisibleCollapseButton: isVisibleCollapseButton, children: (0, jsx_runtime_1.jsx)(DataGridContext_1.DataGridContextProvider, { gridColumns: gridColumns, emptyCellValue: emptyCellValue, activeRowId: activeRowId, columns: columns, keyId: keyId, isTabularNums: isTabularNums, onRowClick: onRowClick, mobileDisplayVariant: mobileDisplayVariant, renderLink: renderLink, children: (0, jsx_runtime_1.jsxs)(
|
|
60
|
+
const TableContainer = isDisabled ? styles_2.DisabledDataGridWrapper : styles_2.DataGridWrapper;
|
|
61
|
+
return ((0, jsx_runtime_1.jsx)(DataGridInfiniteContext_1.DataGridInfiniteContextProvider, { renderRow: renderRow, onSelectRow: handleSelectRow, variant: variant, isInitialExpanded: isInitialExpanded, expandedLevel: expandedLevel, initialVisibleChildrenCount: initialVisibleChildrenCount, isSelectable: isSelectable, selectedRows: selectedRows, moreButtonColumnPosition: moreButtonColumnPosition, isVisibleCollapseButton: isVisibleCollapseButton, children: (0, jsx_runtime_1.jsx)(DataGridContext_1.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: (0, jsx_runtime_1.jsxs)(styles_2.StyledContainer, { style: containerCssVars, className: (0, cn_1.cn)(dataGridInfiniteCva({
|
|
55
62
|
hasGroupedColumns,
|
|
56
63
|
gridViewMode,
|
|
57
64
|
mobileDisplayVariant,
|
|
58
65
|
isSelfContained,
|
|
66
|
+
hasMassActions,
|
|
67
|
+
isMassActionsOpen,
|
|
59
68
|
}), className), children: [headPreAddon, (0, jsx_runtime_1.jsxs)(TableContainer, { ...(0, getInertProps_1.getInertProps)(isDataGridDisabled), children: [!isHideHead && ((0, jsx_runtime_1.jsx)(Head_1.Head, { ...headProps, onSort: onSort, sorting: sorting, columns: columns })), (0, jsx_runtime_1.jsx)(ContentState_1.ContentState, { isLoading: isLoading && !isNoData, loadingTitle: "\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430 \u0434\u0430\u043D\u043D\u044B\u0445", isError: isError && !isNoData, loadingContent: isMobile && (0, jsx_runtime_1.jsx)(DataGrid_1.MobileSkeleton, { ...mobileSkeletonProps }), errorState: {
|
|
60
69
|
imgAlt: 'Что-то пошло не так',
|
|
61
70
|
errorList: [errorMsg || ''],
|
|
@@ -63,24 +72,19 @@ const DataGridInfinite = (props) => {
|
|
|
63
72
|
onRetry,
|
|
64
73
|
}, children: (0, jsx_runtime_1.jsx)(react_virtuoso_1.Virtuoso, { ...virtuosoProps, ...(initialTopMostItemIndex && {
|
|
65
74
|
initialTopMostItemIndex,
|
|
66
|
-
}), style: { height: '100%' }, overscan: constants_3.OVERSCAN_COUNT, data: rows, components: {
|
|
75
|
+
}), style: { height: '100%' }, overscan: constants_3.OVERSCAN_COUNT, data: rows, context: footerContext, components: {
|
|
67
76
|
// biome-ignore lint/suspicious/noTsIgnore: Требует HTMLDivElement, а для элемента списка используем HTMLUListElement (https://github.com/petyosi/react-virtuoso/issues/864)
|
|
68
77
|
// @ts-ignore
|
|
69
78
|
List: List_1.List,
|
|
70
79
|
Item: Row_1.Row,
|
|
71
80
|
EmptyPlaceholder: () => ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: noDataPlaceholder || (0, jsx_runtime_1.jsx)(NoData_1.NoData, {}) })),
|
|
72
|
-
Footer:
|
|
73
|
-
if (!isLoading && !isError && !isEndReached) {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
return ((0, jsx_runtime_1.jsxs)(styles_1.FooterRow, { children: [isLoading && (0, jsx_runtime_1.jsx)(Loader_1.Loader, {}), isError && (0, jsx_runtime_1.jsx)(ErrorMessage_1.ErrorMessage, { onRetry: onRetry }), isEndReached && ((0, jsx_runtime_1.jsx)(EndData_1.EndData, { endOfScrollMsg: endOfScrollMsg }))] }));
|
|
77
|
-
},
|
|
81
|
+
Footer: Footer_1.Footer,
|
|
78
82
|
Header: () => {
|
|
79
83
|
if (isNotRenderHeader) {
|
|
80
84
|
return null;
|
|
81
85
|
}
|
|
82
|
-
return ((0, jsx_runtime_1.jsxs)(
|
|
86
|
+
return ((0, jsx_runtime_1.jsxs)(styles_2.HeaderRow, { children: [isLoading && (0, jsx_runtime_1.jsx)(Loader_1.Loader, {}), isError && (0, jsx_runtime_1.jsx)(ErrorMessage_1.ErrorMessage, { onRetry: onRetry })] }));
|
|
83
87
|
},
|
|
84
|
-
} }) }), (0, jsx_runtime_1.jsx)(styles_1.StyledScrollToTopButton, { ...scrollToTopButtonProps, className: constants_3.dataGridInfiniteClassnames.scrollToTopButton }), isDisabled && (0, jsx_runtime_1.jsx)(
|
|
88
|
+
} }) }), massActions && ((0, jsx_runtime_1.jsx)(styles_1.MassActionsAnchor, { children: massActions })), (0, jsx_runtime_1.jsx)(styles_2.StyledScrollToTopButton, { ...scrollToTopButtonProps, className: constants_3.dataGridInfiniteClassnames.scrollToTopButton }), isDisabled && (0, jsx_runtime_1.jsx)(styles_2.Backdrop, {})] })] }) }) }));
|
|
85
89
|
};
|
|
86
90
|
exports.DataGridInfinite = DataGridInfinite;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Footer = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const Loader_1 = require("../../Loader");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
7
|
+
const EndData_1 = require("../EndData");
|
|
8
|
+
const ErrorMessage_1 = require("../ErrorMessage");
|
|
9
|
+
const styles_1 = require("../styles");
|
|
10
|
+
/**
|
|
11
|
+
* Футер списка для Virtuoso.
|
|
12
|
+
*/
|
|
13
|
+
const Footer = ({ context }) => {
|
|
14
|
+
const { isLoading, isError, isEndReached, endOfScrollMsg, onRetry, hasMassActions, } = context;
|
|
15
|
+
const renderStatus = () => {
|
|
16
|
+
if (isLoading) {
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(styles_1.FooterRow, { children: (0, jsx_runtime_1.jsx)(Loader_1.Loader, {}) }));
|
|
18
|
+
}
|
|
19
|
+
if (isError) {
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)(styles_1.FooterRow, { children: (0, jsx_runtime_1.jsx)(ErrorMessage_1.ErrorMessage, { onRetry: onRetry }) }));
|
|
21
|
+
}
|
|
22
|
+
if (isEndReached) {
|
|
23
|
+
return ((0, jsx_runtime_1.jsx)(styles_1.FooterRow, { children: (0, jsx_runtime_1.jsx)(EndData_1.EndData, { endOfScrollMsg: endOfScrollMsg }) }));
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [renderStatus(), hasMassActions && ((0, jsx_runtime_1.jsx)(styles_1.MassActionsSpacer, { className: constants_1.dataGridInfiniteClassnames.massActionsSpacer }))] }));
|
|
28
|
+
};
|
|
29
|
+
exports.Footer = Footer;
|