@astral/ui 4.11.0 → 4.13.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/DataGridActionCell/ActionCellContext/ActionCellContext.d.ts +10 -0
- package/components/DataGridActionCell/ActionCellContext/ActionCellContext.js +7 -0
- package/components/DataGridActionCell/ActionCellContext/ActionCellProvider/ActionCellProvider.d.ts +8 -0
- package/components/DataGridActionCell/ActionCellContext/ActionCellProvider/ActionCellProvider.js +29 -0
- package/components/DataGridActionCell/ActionCellContext/ActionCellProvider/index.d.ts +1 -0
- package/components/DataGridActionCell/ActionCellContext/ActionCellProvider/index.js +1 -0
- package/components/DataGridActionCell/ActionCellContext/index.d.ts +2 -0
- package/components/DataGridActionCell/ActionCellContext/index.js +2 -0
- package/components/DataGridActionCell/DataGridActionCell.d.ts +18 -2
- package/components/DataGridActionCell/DataGridActionCell.js +5 -12
- package/components/DataGridActionCell/{MainAction/MainAction.d.ts → DataGridMainActions/Action/Action.d.ts} +3 -3
- package/components/DataGridActionCell/{MainAction/MainAction.js → DataGridMainActions/Action/Action.js} +4 -4
- package/{node/components/DataGridActionCell/MainAction → components/DataGridActionCell/DataGridMainActions/Action}/MainIconButton/MainIconButton.d.ts +3 -3
- package/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/MainIconButton.js +3 -3
- package/components/DataGridActionCell/DataGridMainActions/Action/index.d.ts +1 -0
- package/components/DataGridActionCell/DataGridMainActions/Action/index.js +1 -0
- package/components/DataGridActionCell/DataGridMainActions/DataGridMainActions.d.ts +31 -0
- package/components/DataGridActionCell/DataGridMainActions/DataGridMainActions.js +32 -0
- package/components/DataGridActionCell/DataGridMainActions/index.d.ts +1 -0
- package/components/DataGridActionCell/DataGridMainActions/index.js +1 -0
- package/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActions.d.ts +48 -0
- package/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActions.js +54 -0
- package/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/DataGridSecondaryActionsSkeleton.d.ts +2 -0
- package/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/DataGridSecondaryActionsSkeleton.js +4 -0
- package/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/index.d.ts +1 -0
- package/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/index.js +1 -0
- package/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/styles.d.ts +1 -0
- package/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/styles.js +10 -0
- package/components/DataGridActionCell/DataGridSecondaryActions/index.d.ts +2 -0
- package/components/DataGridActionCell/DataGridSecondaryActions/index.js +2 -0
- package/components/DataGridActionCell/SecondaryActionsButton/SecondaryActionsButton.d.ts +20 -0
- package/components/DataGridActionCell/SecondaryActionsButton/SecondaryActionsButton.js +28 -0
- package/components/DataGridActionCell/SecondaryActionsButton/index.d.ts +1 -0
- package/components/DataGridActionCell/SecondaryActionsButton/index.js +1 -0
- package/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuContext.d.ts +12 -0
- package/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuContext.js +5 -0
- package/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuProvider/SecondaryActionsMenuProvider.d.ts +8 -0
- package/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuProvider/SecondaryActionsMenuProvider.js +5 -0
- package/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuProvider/index.d.ts +1 -0
- package/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuProvider/index.js +1 -0
- package/components/DataGridActionCell/SecondaryActionsMenuContext/index.d.ts +3 -0
- package/components/DataGridActionCell/SecondaryActionsMenuContext/index.js +3 -0
- package/components/DataGridActionCell/SecondaryActionsMenuContext/useSecondaryActionsMenu.d.ts +6 -0
- package/components/DataGridActionCell/SecondaryActionsMenuContext/useSecondaryActionsMenu.js +10 -0
- package/components/DataGridActionCell/constants.d.ts +2 -0
- package/components/DataGridActionCell/constants.js +4 -0
- package/components/DataGridActionCell/hooks/index.d.ts +1 -0
- package/components/DataGridActionCell/hooks/index.js +1 -0
- package/components/DataGridActionCell/hooks/useBlockingActions/index.d.ts +1 -0
- package/components/DataGridActionCell/hooks/useBlockingActions/index.js +1 -0
- package/components/DataGridActionCell/hooks/useBlockingActions/useBlockingActions.d.ts +8 -0
- package/components/DataGridActionCell/hooks/useBlockingActions/useBlockingActions.js +24 -0
- package/components/DataGridActionCell/index.d.ts +3 -0
- package/components/DataGridActionCell/index.js +3 -0
- package/components/DataGridActionCell/useLogic/useLogic.d.ts +5 -2
- package/components/DataGridActionCell/useLogic/useLogic.js +11 -14
- package/components/MenuOrganization/MenuOrganization.js +2 -1
- package/components/MenuOrganization/types.d.ts +13 -0
- package/components/index.d.ts +1 -1
- package/components/index.js +1 -1
- package/node/components/DataGridActionCell/ActionCellContext/ActionCellContext.d.ts +10 -0
- package/node/components/DataGridActionCell/ActionCellContext/ActionCellContext.js +10 -0
- package/node/components/DataGridActionCell/ActionCellContext/ActionCellProvider/ActionCellProvider.d.ts +8 -0
- package/node/components/DataGridActionCell/ActionCellContext/ActionCellProvider/ActionCellProvider.js +33 -0
- package/node/components/DataGridActionCell/ActionCellContext/ActionCellProvider/index.d.ts +1 -0
- package/node/components/DataGridActionCell/{SecondaryAction → ActionCellContext/ActionCellProvider}/index.js +1 -1
- package/node/components/DataGridActionCell/ActionCellContext/index.d.ts +2 -0
- package/node/components/DataGridActionCell/ActionCellContext/index.js +18 -0
- package/node/components/DataGridActionCell/DataGridActionCell.d.ts +18 -2
- package/node/components/DataGridActionCell/DataGridActionCell.js +5 -12
- package/node/components/DataGridActionCell/{MainAction/MainAction.d.ts → DataGridMainActions/Action/Action.d.ts} +3 -3
- package/node/components/DataGridActionCell/{MainAction/MainAction.js → DataGridMainActions/Action/Action.js} +6 -6
- package/{components/DataGridActionCell/MainAction → node/components/DataGridActionCell/DataGridMainActions/Action}/MainIconButton/MainIconButton.d.ts +3 -3
- package/node/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/MainIconButton.js +3 -3
- package/node/components/DataGridActionCell/DataGridMainActions/Action/index.d.ts +1 -0
- package/node/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/index.js +1 -1
- package/node/components/DataGridActionCell/DataGridMainActions/DataGridMainActions.d.ts +31 -0
- package/node/components/DataGridActionCell/DataGridMainActions/DataGridMainActions.js +36 -0
- package/node/components/DataGridActionCell/DataGridMainActions/index.d.ts +1 -0
- package/node/components/DataGridActionCell/DataGridMainActions/index.js +17 -0
- package/node/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActions.d.ts +48 -0
- package/node/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActions.js +58 -0
- package/node/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/DataGridSecondaryActionsSkeleton.d.ts +2 -0
- package/node/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/DataGridSecondaryActionsSkeleton.js +8 -0
- package/node/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/index.d.ts +1 -0
- package/node/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/index.js +17 -0
- package/node/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/styles.d.ts +1 -0
- package/node/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/styles.js +13 -0
- package/node/components/DataGridActionCell/DataGridSecondaryActions/index.d.ts +2 -0
- package/node/components/DataGridActionCell/DataGridSecondaryActions/index.js +18 -0
- package/node/components/DataGridActionCell/SecondaryActionsButton/SecondaryActionsButton.d.ts +20 -0
- package/node/components/DataGridActionCell/SecondaryActionsButton/SecondaryActionsButton.js +32 -0
- package/node/components/DataGridActionCell/SecondaryActionsButton/index.d.ts +1 -0
- package/node/components/DataGridActionCell/SecondaryActionsButton/index.js +17 -0
- package/node/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuContext.d.ts +12 -0
- package/node/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuContext.js +8 -0
- package/node/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuProvider/SecondaryActionsMenuProvider.d.ts +8 -0
- package/node/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuProvider/SecondaryActionsMenuProvider.js +9 -0
- package/node/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuProvider/index.d.ts +1 -0
- package/node/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuProvider/index.js +5 -0
- package/node/components/DataGridActionCell/SecondaryActionsMenuContext/index.d.ts +3 -0
- package/node/components/DataGridActionCell/SecondaryActionsMenuContext/index.js +9 -0
- package/node/components/DataGridActionCell/SecondaryActionsMenuContext/useSecondaryActionsMenu.d.ts +6 -0
- package/node/components/DataGridActionCell/SecondaryActionsMenuContext/useSecondaryActionsMenu.js +14 -0
- package/node/components/DataGridActionCell/constants.d.ts +2 -0
- package/node/components/DataGridActionCell/constants.js +7 -0
- package/node/components/DataGridActionCell/hooks/index.d.ts +1 -0
- package/node/components/DataGridActionCell/hooks/index.js +17 -0
- package/node/components/DataGridActionCell/hooks/useBlockingActions/index.d.ts +1 -0
- package/node/components/DataGridActionCell/hooks/useBlockingActions/index.js +17 -0
- package/node/components/DataGridActionCell/hooks/useBlockingActions/useBlockingActions.d.ts +8 -0
- package/node/components/DataGridActionCell/hooks/useBlockingActions/useBlockingActions.js +28 -0
- package/node/components/DataGridActionCell/index.d.ts +3 -0
- package/node/components/DataGridActionCell/index.js +9 -0
- package/node/components/DataGridActionCell/useLogic/useLogic.d.ts +5 -2
- package/node/components/DataGridActionCell/useLogic/useLogic.js +10 -13
- package/node/components/MenuOrganization/MenuOrganization.js +2 -1
- package/node/components/MenuOrganization/types.d.ts +13 -0
- package/node/components/index.d.ts +1 -1
- package/node/components/index.js +6 -3
- package/package.json +1 -1
- package/components/DataGridActionCell/MainAction/index.d.ts +0 -1
- package/components/DataGridActionCell/MainAction/index.js +0 -1
- package/components/DataGridActionCell/SecondaryAction/SecondaryAction.d.ts +0 -23
- package/components/DataGridActionCell/SecondaryAction/SecondaryAction.js +0 -11
- package/components/DataGridActionCell/SecondaryAction/index.d.ts +0 -1
- package/components/DataGridActionCell/SecondaryAction/index.js +0 -1
- package/node/components/DataGridActionCell/MainAction/index.d.ts +0 -1
- package/node/components/DataGridActionCell/SecondaryAction/SecondaryAction.d.ts +0 -23
- package/node/components/DataGridActionCell/SecondaryAction/SecondaryAction.js +0 -15
- package/node/components/DataGridActionCell/SecondaryAction/index.d.ts +0 -1
- /package/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/index.d.ts +0 -0
- /package/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/index.js +0 -0
- /package/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/useLogic/index.d.ts +0 -0
- /package/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/useLogic/index.js +0 -0
- /package/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/useLogic/useLogic.d.ts +0 -0
- /package/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/useLogic/useLogic.js +0 -0
- /package/node/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/index.d.ts +0 -0
- /package/node/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/index.js +0 -0
- /package/node/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/useLogic/index.d.ts +0 -0
- /package/node/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/useLogic/index.js +0 -0
- /package/node/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/useLogic/useLogic.d.ts +0 -0
- /package/node/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/useLogic/useLogic.js +0 -0
|
@@ -2,9 +2,12 @@ import { type MouseEventHandler } from 'react';
|
|
|
2
2
|
import { type DataGridActionCellProps } from '../DataGridActionCell';
|
|
3
3
|
import type { NestedAction, SingleAction } from '../types';
|
|
4
4
|
type UseLogicParams<TRowData> = DataGridActionCellProps<TRowData>;
|
|
5
|
-
export declare const useLogic: <TRowData>({ row, actions, }: UseLogicParams<TRowData>) => {
|
|
6
|
-
isDisabledAction: boolean;
|
|
5
|
+
export declare const useLogic: <TRowData>({ row, actions, mainActions, secondaryActions, }: UseLogicParams<TRowData>) => {
|
|
7
6
|
handleActionClick: (onClick: ((row: TRowData) => void) | (MouseEventHandler<HTMLLIElement> & ((row: TRowData) => void)) | undefined) => () => void;
|
|
8
7
|
handleWrapperClick: MouseEventHandler<HTMLDivElement>;
|
|
8
|
+
actions: import("../DataGridActionCell").DataGridActions<TRowData> | undefined;
|
|
9
|
+
mainActions: (() => import("react").ReactNode) | undefined;
|
|
10
|
+
secondaryActions: ((props: import("..").DataGridSecondaryActionsProps<TRowData>) => import("react").ReactNode) | undefined;
|
|
11
|
+
hasSecondaryActions: boolean | ((props: import("..").DataGridSecondaryActionsProps<TRowData>) => import("react").ReactNode);
|
|
9
12
|
};
|
|
10
13
|
export {};
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import { useCallback
|
|
2
|
-
|
|
3
|
-
export const useLogic = ({ row, actions, }) => {
|
|
4
|
-
const { main, secondary } = actions;
|
|
5
|
-
const { addDisabledRow, removeDisabledRow } = useContext(RowContext);
|
|
6
|
-
const blockingAction = [...main, ...(secondary || [])].find((action) => action.isBlockingOperation && action.loading);
|
|
7
|
-
const isDisabledAction = Boolean(blockingAction);
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
if (blockingAction) {
|
|
10
|
-
return addDisabledRow(blockingAction?.loadingNote);
|
|
11
|
-
}
|
|
12
|
-
removeDisabledRow();
|
|
13
|
-
}, [blockingAction]);
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
export const useLogic = ({ row, actions, mainActions, secondaryActions, }) => {
|
|
14
3
|
const handleActionClick = useCallback((onClick) => () => {
|
|
15
4
|
onClick?.(row);
|
|
16
5
|
}, [row]);
|
|
17
6
|
const handleWrapperClick = (event) => {
|
|
18
7
|
event.stopPropagation();
|
|
19
8
|
};
|
|
20
|
-
|
|
9
|
+
const hasSecondaryActions = secondaryActions || actions?.secondary !== undefined;
|
|
10
|
+
return {
|
|
11
|
+
handleActionClick,
|
|
12
|
+
handleWrapperClick,
|
|
13
|
+
actions,
|
|
14
|
+
mainActions,
|
|
15
|
+
secondaryActions,
|
|
16
|
+
hasSecondaryActions,
|
|
17
|
+
};
|
|
21
18
|
};
|
|
@@ -12,11 +12,12 @@ import { OrganizationListSkeleton } from './OrganizationListSkeleton';
|
|
|
12
12
|
import { ActionWrapper, OrganizationsWrapper, SearchWrapper, StyledTypography, } from './styles';
|
|
13
13
|
import { useLogic } from './useLogic';
|
|
14
14
|
export const MenuOrganization = (props) => {
|
|
15
|
+
const { anchorOrigin = { vertical: 'bottom', horizontal: 'right' }, transformOrigin = { vertical: 'top', horizontal: 'right' }, } = props;
|
|
15
16
|
const { action, isLoading, isError, onRetry, isComponentLoading, isShowOrganizationList, searchProps, popoverProps, organizationListProps, organizationButtonProps, isShowSearchField, } = useLogic(props);
|
|
16
17
|
if (isComponentLoading) {
|
|
17
18
|
return _jsx(MenuOrganizationSkeleton, {});
|
|
18
19
|
}
|
|
19
|
-
return (_jsxs(_Fragment, { children: [_jsx(OrganizationButton, { ...organizationButtonProps }), _jsxs(Popover, { ...popoverProps, anchorOrigin:
|
|
20
|
+
return (_jsxs(_Fragment, { children: [_jsx(OrganizationButton, { ...organizationButtonProps }), _jsxs(Popover, { ...popoverProps, anchorOrigin: anchorOrigin, transformOrigin: transformOrigin, children: [isShowSearchField && (_jsx(SearchWrapper, { children: _jsx(SearchField, { fullWidth: true, ...searchProps }) })), _jsx(OrganizationsWrapper, { "$isLoading": isLoading, className: menuOrganizationClassnames.root, children: _jsx(ContentState, { isLoading: isLoading, isCustom: isError, customState: {
|
|
20
21
|
title: (_jsx(StyledTypography, { children: "\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0434\u0430\u043D\u043D\u044B\u0435" })),
|
|
21
22
|
Actions: (_jsx(Button, { variant: "light", color: "grey", onClick: onRetry, children: "\u041F\u043E\u043F\u0440\u043E\u0431\u043E\u0432\u0430\u0442\u044C \u0441\u043D\u043E\u0432\u0430" })),
|
|
22
23
|
className: menuOrganizationClassnames.errorPlaceholder,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PopoverOrigin } from '@mui/material';
|
|
1
2
|
import type { ComponentProps, ElementType, ReactNode } from 'react';
|
|
2
3
|
import type { ButtonProps } from '../Button';
|
|
3
4
|
export type Organization = {
|
|
@@ -126,4 +127,16 @@ export type MenuOrganizationProps<TData extends Organization = Organization> = {
|
|
|
126
127
|
renderPreview?: (organization: TData, params: {
|
|
127
128
|
className?: string;
|
|
128
129
|
}) => ReactNode;
|
|
130
|
+
/**
|
|
131
|
+
* Позиция точки привязки на кнопке
|
|
132
|
+
* @example
|
|
133
|
+
* anchorOrigin={{ vertical: 'bottom', horizontal: 'left' }}
|
|
134
|
+
*/
|
|
135
|
+
anchorOrigin?: PopoverOrigin;
|
|
136
|
+
/**
|
|
137
|
+
* Позиция точки привязки на Popover
|
|
138
|
+
* @example
|
|
139
|
+
* transformOrigin={{ vertical: 'top', horizontal: 'left' }}
|
|
140
|
+
*/
|
|
141
|
+
transformOrigin?: PopoverOrigin;
|
|
129
142
|
};
|
package/components/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export { Counter, type CounterProps } from './Counter';
|
|
|
35
35
|
export { DashboardAlert, type DashboardAlertProps } from './DashboardAlert';
|
|
36
36
|
export { type DashboardLayoutProps, DashboardLayout, MenuSidebarButton, type MenuSidebarButtonProps, SidebarButton, SidebarCounter, type SidebarCounterProps, SidebarPopover, type SidebarPopoverItemProps, type SidebarPopoverProps, type SidebarProps as DashboardSidebarProps, DashboardContext, type DashboardContextProps, SidebarSkeleton, } from './DashboardLayout';
|
|
37
37
|
export { DashboardSidebarContext as SidebarContext, type DashboardSidebarContextProps as SidebarContextProps, } from './DashboardSidebarProvider';
|
|
38
|
-
export { DataGridActionCell, type DataGridActionCellProps, type DataGridActions, } from './DataGridActionCell';
|
|
38
|
+
export { DataGridActionCell, type DataGridActionCellProps, type DataGridActions, DataGridMainActions, DataGridSecondaryActions, type DataGridMainActionsProps, type DataGridSecondaryActionsProps, DataGridSecondaryActionsSkeleton, } from './DataGridActionCell';
|
|
39
39
|
export { DataGridMinimalisticPagination, type DataGridMinimalisticPaginationProps, } from './DataGridMinimalisticPagination';
|
|
40
40
|
export * from './DataGridPagination';
|
|
41
41
|
export { DatePicker, type DatePickerProps, datePickerClassnames, } from './DatePicker';
|
package/components/index.js
CHANGED
|
@@ -35,7 +35,7 @@ export { Counter } from './Counter';
|
|
|
35
35
|
export { DashboardAlert } from './DashboardAlert';
|
|
36
36
|
export { DashboardLayout, MenuSidebarButton, SidebarButton, SidebarCounter, SidebarPopover, DashboardContext, SidebarSkeleton, } from './DashboardLayout';
|
|
37
37
|
export { DashboardSidebarContext as SidebarContext, } from './DashboardSidebarProvider';
|
|
38
|
-
export { DataGridActionCell, } from './DataGridActionCell';
|
|
38
|
+
export { DataGridActionCell, DataGridMainActions, DataGridSecondaryActions, DataGridSecondaryActionsSkeleton, } from './DataGridActionCell';
|
|
39
39
|
export { DataGridMinimalisticPagination, } from './DataGridMinimalisticPagination';
|
|
40
40
|
export * from './DataGridPagination';
|
|
41
41
|
export { DatePicker, datePickerClassnames, } from './DatePicker';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ActionCellHandler } from '../types';
|
|
3
|
+
export type ActionCellContextProps<TAction> = {
|
|
4
|
+
isDisabled: boolean;
|
|
5
|
+
onActionClick: ActionCellHandler<TAction>;
|
|
6
|
+
disabledReason?: string;
|
|
7
|
+
addDisabledCell: (disabledReason?: string) => void;
|
|
8
|
+
removeDisabledCell: () => void;
|
|
9
|
+
};
|
|
10
|
+
export declare const ActionCellContext: import("react").Context<ActionCellContextProps<unknown>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActionCellContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
exports.ActionCellContext = (0, react_1.createContext)({
|
|
6
|
+
isDisabled: false,
|
|
7
|
+
onActionClick: () => undefined,
|
|
8
|
+
addDisabledCell: () => undefined,
|
|
9
|
+
removeDisabledCell: () => undefined,
|
|
10
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { ActionCellHandler } from '../../types';
|
|
3
|
+
type ActionCellContextProviderProps<TAction> = {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
onActionClick: ActionCellHandler<TAction>;
|
|
6
|
+
};
|
|
7
|
+
export declare const ActionCellContextProvider: <TAction>({ children, onActionClick, }: ActionCellContextProviderProps<TAction>) => JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActionCellContextProvider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const ActionCellContext_1 = require("../ActionCellContext");
|
|
7
|
+
const ActionCellContextProvider = ({ children, onActionClick, }) => {
|
|
8
|
+
const [isDisabled, setDisabled] = (0, react_1.useState)(false);
|
|
9
|
+
const [disabledReason, setDisabledReason] = (0, react_1.useState)();
|
|
10
|
+
const addDisabledCell = (0, react_1.useCallback)((reason) => {
|
|
11
|
+
setDisabled(true);
|
|
12
|
+
setDisabledReason(reason);
|
|
13
|
+
}, []);
|
|
14
|
+
const removeDisabledCell = (0, react_1.useCallback)(() => {
|
|
15
|
+
setDisabled(false);
|
|
16
|
+
setDisabledReason(undefined);
|
|
17
|
+
}, []);
|
|
18
|
+
const contextValue = (0, react_1.useMemo)(() => ({
|
|
19
|
+
isDisabled,
|
|
20
|
+
disabledReason,
|
|
21
|
+
addDisabledCell,
|
|
22
|
+
removeDisabledCell,
|
|
23
|
+
onActionClick,
|
|
24
|
+
}), [
|
|
25
|
+
isDisabled,
|
|
26
|
+
disabledReason,
|
|
27
|
+
addDisabledCell,
|
|
28
|
+
removeDisabledCell,
|
|
29
|
+
onActionClick,
|
|
30
|
+
]);
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(ActionCellContext_1.ActionCellContext.Provider, { value: contextValue, children: children }));
|
|
32
|
+
};
|
|
33
|
+
exports.ActionCellContextProvider = ActionCellContextProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ActionCellProvider';
|
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./ActionCellProvider"), 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("./ActionCellContext"), exports);
|
|
18
|
+
__exportStar(require("./ActionCellProvider"), exports);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type DataGridSecondaryActionsProps } from './DataGridSecondaryActions';
|
|
2
3
|
import type { MainActionKind, SecondaryActionKind } from './types';
|
|
3
4
|
export type DataGridActions<TAction> = {
|
|
4
5
|
/**
|
|
@@ -13,8 +14,23 @@ export type DataGridActions<TAction> = {
|
|
|
13
14
|
export type DataGridActionCellProps<TRow> = {
|
|
14
15
|
/**
|
|
15
16
|
* Действия
|
|
17
|
+
* @deprecated Используйте `mainActions` и `secondaryActions`.
|
|
18
|
+
*
|
|
19
|
+
* Новый подход обеспечивает:
|
|
20
|
+
* - Ленивую загрузку вторичных действий с бэкенда
|
|
21
|
+
* - Рендеринг `secondaryActions` только при открытии dropdown-меню
|
|
22
|
+
* - Улучшенную производительность при работе со сложной логикой
|
|
23
|
+
* - Оптимизацию за счет tree shaking
|
|
16
24
|
*/
|
|
17
|
-
actions
|
|
25
|
+
actions?: DataGridActions<TRow>;
|
|
26
|
+
/**
|
|
27
|
+
* Компонент всегда отображаемых действий
|
|
28
|
+
*/
|
|
29
|
+
mainActions?: () => ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Компонент доп. действий, которые скрыты в popover за кнопкой
|
|
32
|
+
*/
|
|
33
|
+
secondaryActions?: (props: DataGridSecondaryActionsProps<TRow>) => ReactNode;
|
|
18
34
|
/**
|
|
19
35
|
* Данные строки
|
|
20
36
|
*/
|
|
@@ -2,20 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DataGridActionCell = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const ActionCellContext_1 = require("./ActionCellContext");
|
|
6
|
+
const DataGridMainActions_1 = require("./DataGridMainActions");
|
|
7
|
+
const SecondaryActionsButton_1 = require("./SecondaryActionsButton");
|
|
7
8
|
const styles_1 = require("./styles");
|
|
8
9
|
const useLogic_1 = require("./useLogic");
|
|
9
|
-
const TOOLTIP_PLACEMENT = {
|
|
10
|
-
mainAction: 'top',
|
|
11
|
-
secondaryAction: 'left',
|
|
12
|
-
};
|
|
13
10
|
const DataGridActionCell = (props) => {
|
|
14
|
-
const {
|
|
15
|
-
|
|
16
|
-
const { main, secondary } = actions;
|
|
17
|
-
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { onClick: handleWrapperClick, children: [main.map((action) => {
|
|
18
|
-
return ((0, jsx_runtime_1.jsx)(MainAction_1.MainAction, { action: action, onActionClick: handleActionClick, isDisabled: isDisabledAction, tooltipPlacement: TOOLTIP_PLACEMENT.mainAction }, action.name));
|
|
19
|
-
}), secondary && ((0, jsx_runtime_1.jsx)(SecondaryAction_1.SecondaryActions, { actions: secondary, onActionClick: handleActionClick, tooltipPlacement: TOOLTIP_PLACEMENT.secondaryAction, isDisabled: isDisabledAction }))] }));
|
|
11
|
+
const { handleWrapperClick, handleActionClick, actions, mainActions, secondaryActions, hasSecondaryActions, } = (0, useLogic_1.useLogic)(props);
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)(ActionCellContext_1.ActionCellContextProvider, { onActionClick: handleActionClick, children: (0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { onClick: handleWrapperClick, children: [mainActions ? (mainActions()) : ((0, jsx_runtime_1.jsx)(DataGridMainActions_1.DataGridMainActions, { actions: actions?.main })), hasSecondaryActions && ((0, jsx_runtime_1.jsx)(SecondaryActionsButton_1.SecondaryActionsButton, { actions: actions?.secondary, renderActions: secondaryActions }))] }) }));
|
|
20
13
|
};
|
|
21
14
|
exports.DataGridActionCell = DataGridActionCell;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { type TooltipProps } from '
|
|
3
|
-
import type { ActionCellHandler, MainActionKind } from '
|
|
2
|
+
import { type TooltipProps } from '../../../Tooltip';
|
|
3
|
+
import type { ActionCellHandler, MainActionKind } from '../../types';
|
|
4
4
|
type MainActionProps<TAction> = {
|
|
5
5
|
/**
|
|
6
6
|
* Основные действия
|
|
@@ -19,5 +19,5 @@ type MainActionProps<TAction> = {
|
|
|
19
19
|
*/
|
|
20
20
|
tooltipPlacement?: TooltipProps['placement'];
|
|
21
21
|
};
|
|
22
|
-
export declare const
|
|
22
|
+
export declare const Action: <TAction>({ action, onActionClick, isDisabled, tooltipPlacement, }: MainActionProps<TAction>) => JSX.Element;
|
|
23
23
|
export {};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Action = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const IconDropdownButton_1 = require("
|
|
7
|
-
const MenuItem_1 = require("
|
|
8
|
-
const Tooltip_1 = require("
|
|
6
|
+
const IconDropdownButton_1 = require("../../../IconDropdownButton");
|
|
7
|
+
const MenuItem_1 = require("../../../MenuItem");
|
|
8
|
+
const Tooltip_1 = require("../../../Tooltip");
|
|
9
9
|
const MainIconButton_1 = require("./MainIconButton");
|
|
10
|
-
const
|
|
10
|
+
const Action = ({ action, onActionClick, isDisabled, tooltipPlacement, }) => {
|
|
11
11
|
if ('actions' in action) {
|
|
12
12
|
const { disabled, icon, name, disabledReason, actions } = action;
|
|
13
13
|
return ((0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: disabledReason || name, withoutContainer: !disabled, placement: tooltipPlacement, children: (0, jsx_runtime_1.jsx)(IconDropdownButton_1.IconDropdownButton, { icon: icon, variant: "text", disabled: isDisabled || disabled, children: actions.map(({ name: nestedActionName, onClick: onClickNested, ...props }) => ((0, react_1.createElement)(MenuItem_1.MenuItem, { ...props, key: nestedActionName, onClick: onActionClick(onClickNested) }, nestedActionName))) }) }, name));
|
|
14
14
|
}
|
|
15
15
|
return ((0, jsx_runtime_1.jsx)(MainIconButton_1.MainIconButton, { action: action, onActionClick: onActionClick, isDisabled: isDisabled, tooltipPlacement: tooltipPlacement }));
|
|
16
16
|
};
|
|
17
|
-
exports.
|
|
17
|
+
exports.Action = Action;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { type IconButtonProps } from '
|
|
3
|
-
import { type TooltipProps } from '
|
|
4
|
-
import { type ActionCellHandler, type SingleAction } from '
|
|
2
|
+
import { type IconButtonProps } from '../../../../IconButton';
|
|
3
|
+
import { type TooltipProps } from '../../../../Tooltip';
|
|
4
|
+
import { type ActionCellHandler, type SingleAction } from '../../../types';
|
|
5
5
|
export type MainIconButtonProps<TAction> = {
|
|
6
6
|
action: IconButtonProps & SingleAction<TAction>;
|
|
7
7
|
/**
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MainIconButton = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const ConfirmAction_1 = require("
|
|
6
|
-
const IconButton_1 = require("
|
|
7
|
-
const Tooltip_1 = require("
|
|
5
|
+
const ConfirmAction_1 = require("../../../../ConfirmAction");
|
|
6
|
+
const IconButton_1 = require("../../../../IconButton");
|
|
7
|
+
const Tooltip_1 = require("../../../../Tooltip");
|
|
8
8
|
const useLogic_1 = require("./useLogic");
|
|
9
9
|
const MainIconButton = (props) => {
|
|
10
10
|
const { tooltipProps } = (0, useLogic_1.useLogic)(props);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Action';
|
package/node/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/index.js
RENAMED
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./Action"), exports);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { MainActionKind } from '../types';
|
|
3
|
+
export type DataGridMainActionsProps<TAction> = {
|
|
4
|
+
/**
|
|
5
|
+
* Действия отображаются слева направо в порядке, указанном в массиве
|
|
6
|
+
*/
|
|
7
|
+
actions?: MainActionKind<TAction>[];
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Компонент для отображения основных действий в ячейке таблицы DataGrid.
|
|
11
|
+
*
|
|
12
|
+
* Основные действия отображаются в виде отдельных кнопок непосредственно в ячейке
|
|
13
|
+
* и предназначены для наиболее часто используемых операций над строкой данных.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* - Компонент автоматически обрабатывает блокирующие операции, что предотвращает одновременное выполнение нескольких действий
|
|
17
|
+
* - Для действий автоматически отображаются тултипы с заданным позиционированием
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <DataGridMainActions
|
|
22
|
+
* actions={[
|
|
23
|
+
* { name: 'edit', icon: <EditIcon />, onClick: handleEdit },
|
|
24
|
+
* { name: 'delete', icon: <DeleteIcon />, onClick: handleDelete, isBlockingOperation: true }
|
|
25
|
+
* ]}
|
|
26
|
+
* onActionClick={(handler) => (event) => handler(event)}
|
|
27
|
+
* tooltipPlacement="top"
|
|
28
|
+
* />
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const DataGridMainActions: <TAction>({ actions, }: DataGridMainActionsProps<TAction>) => JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataGridMainActions = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const hooks_1 = require("../hooks");
|
|
7
|
+
const Action_1 = require("./Action");
|
|
8
|
+
/**
|
|
9
|
+
* Компонент для отображения основных действий в ячейке таблицы DataGrid.
|
|
10
|
+
*
|
|
11
|
+
* Основные действия отображаются в виде отдельных кнопок непосредственно в ячейке
|
|
12
|
+
* и предназначены для наиболее часто используемых операций над строкой данных.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* - Компонент автоматически обрабатывает блокирующие операции, что предотвращает одновременное выполнение нескольких действий
|
|
16
|
+
* - Для действий автоматически отображаются тултипы с заданным позиционированием
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* <DataGridMainActions
|
|
21
|
+
* actions={[
|
|
22
|
+
* { name: 'edit', icon: <EditIcon />, onClick: handleEdit },
|
|
23
|
+
* { name: 'delete', icon: <DeleteIcon />, onClick: handleDelete, isBlockingOperation: true }
|
|
24
|
+
* ]}
|
|
25
|
+
* onActionClick={(handler) => (event) => handler(event)}
|
|
26
|
+
* tooltipPlacement="top"
|
|
27
|
+
* />
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
const DataGridMainActions = ({ actions, }) => {
|
|
31
|
+
const { isDisabled, onActionClick } = (0, hooks_1.useBlockingActions)(actions);
|
|
32
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: actions?.map((action) => {
|
|
33
|
+
return ((0, jsx_runtime_1.jsx)(Action_1.Action, { action: action, onActionClick: onActionClick, isDisabled: isDisabled, tooltipPlacement: constants_1.TOOLTIP_PLACEMENT.mainAction }, action.name));
|
|
34
|
+
}) }));
|
|
35
|
+
};
|
|
36
|
+
exports.DataGridMainActions = DataGridMainActions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DataGridMainActions';
|
|
@@ -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("./DataGridMainActions"), exports);
|
package/node/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActions.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { SecondaryActionKind } from '../types';
|
|
3
|
+
export type DataGridSecondaryActionsProps<TAction> = {
|
|
4
|
+
/**
|
|
5
|
+
* Доп. действия отображаются в виде списка элементов меню (`MenuItem`)
|
|
6
|
+
*/
|
|
7
|
+
actions?: SecondaryActionKind<TAction>[];
|
|
8
|
+
/**
|
|
9
|
+
* Флаг состояния загрузки, применяется когда actions подгружаются динамически
|
|
10
|
+
*/
|
|
11
|
+
isLoading?: boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Компонент для отображения дополнительных действий в выпадающем меню ячейки таблицы DataGrid.
|
|
15
|
+
*
|
|
16
|
+
* Вторичные действия отображаются в выпадающем меню (dropdown) и предназначены для менее
|
|
17
|
+
* используемых операций, которые не требуют постоянного отображения в интерфейсе.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* - Компонент поддерживает состояние загрузки (`isLoading`), при котором отображается скелетон вместо действий
|
|
21
|
+
* - Автоматически обрабатывает блокирующие операции, что предотвращает одновременное выполнение нескольких действий
|
|
22
|
+
* - Меню привязывается к кнопке "три точки"
|
|
23
|
+
* - Состояние меню (`open`, `anchorEl`) берется из `SecondaryActionsMenuContext`, не требуется прокидывать пропсы вручную
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* Использование с контекстом (рекомендуется):
|
|
27
|
+
* ```tsx
|
|
28
|
+
* <DataGridSecondaryActions
|
|
29
|
+
* actions={[
|
|
30
|
+
* { name: 'Дублировать', onClick: handleDuplicate },
|
|
31
|
+
* { name: 'Архивировать', onClick: handleArchive, disabled: !canArchive },
|
|
32
|
+
* { name: 'Экспортировать', onClick: handleExport }
|
|
33
|
+
* ]}
|
|
34
|
+
* isLoading={isActionsLoading}
|
|
35
|
+
* />
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* Использование с явными пропсами (для обратной совместимости):
|
|
40
|
+
* ```tsx
|
|
41
|
+
* <DataGridSecondaryActions
|
|
42
|
+
* actions={actions}
|
|
43
|
+
* open={isMenuOpen}
|
|
44
|
+
* anchorEl={buttonRef.current}
|
|
45
|
+
* />
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare const DataGridSecondaryActions: <TAction>({ actions, isLoading, }: DataGridSecondaryActionsProps<TAction>) => JSX.Element;
|
package/node/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActions.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataGridSecondaryActions = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const Menu_1 = require("../../Menu");
|
|
7
|
+
const MenuItem_1 = require("../../MenuItem");
|
|
8
|
+
const constants_1 = require("../constants");
|
|
9
|
+
const hooks_1 = require("../hooks");
|
|
10
|
+
const SecondaryActionsMenuContext_1 = require("../SecondaryActionsMenuContext");
|
|
11
|
+
const DataGridSecondaryActionsSkeleton_1 = require("./DataGridSecondaryActionsSkeleton");
|
|
12
|
+
/**
|
|
13
|
+
* Компонент для отображения дополнительных действий в выпадающем меню ячейки таблицы DataGrid.
|
|
14
|
+
*
|
|
15
|
+
* Вторичные действия отображаются в выпадающем меню (dropdown) и предназначены для менее
|
|
16
|
+
* используемых операций, которые не требуют постоянного отображения в интерфейсе.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* - Компонент поддерживает состояние загрузки (`isLoading`), при котором отображается скелетон вместо действий
|
|
20
|
+
* - Автоматически обрабатывает блокирующие операции, что предотвращает одновременное выполнение нескольких действий
|
|
21
|
+
* - Меню привязывается к кнопке "три точки"
|
|
22
|
+
* - Состояние меню (`open`, `anchorEl`) берется из `SecondaryActionsMenuContext`, не требуется прокидывать пропсы вручную
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* Использование с контекстом (рекомендуется):
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <DataGridSecondaryActions
|
|
28
|
+
* actions={[
|
|
29
|
+
* { name: 'Дублировать', onClick: handleDuplicate },
|
|
30
|
+
* { name: 'Архивировать', onClick: handleArchive, disabled: !canArchive },
|
|
31
|
+
* { name: 'Экспортировать', onClick: handleExport }
|
|
32
|
+
* ]}
|
|
33
|
+
* isLoading={isActionsLoading}
|
|
34
|
+
* />
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* Использование с явными пропсами (для обратной совместимости):
|
|
39
|
+
* ```tsx
|
|
40
|
+
* <DataGridSecondaryActions
|
|
41
|
+
* actions={actions}
|
|
42
|
+
* open={isMenuOpen}
|
|
43
|
+
* anchorEl={buttonRef.current}
|
|
44
|
+
* />
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
const DataGridSecondaryActions = ({ actions, isLoading, }) => {
|
|
48
|
+
const { onActionClick } = (0, hooks_1.useBlockingActions)(actions);
|
|
49
|
+
const { open, anchorEl } = (0, SecondaryActionsMenuContext_1.useSecondaryActionsMenu)();
|
|
50
|
+
const renderActions = () => {
|
|
51
|
+
return actions?.map((action) => {
|
|
52
|
+
const { onClick, name, loading, isBlockingOperation, loadingNote, ...restProps } = action;
|
|
53
|
+
return ((0, react_1.createElement)(MenuItem_1.MenuItem, { ...restProps, key: name, tooltipPlacement: constants_1.TOOLTIP_PLACEMENT.secondaryActions, onClick: onActionClick(onClick) }, name));
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
return ((0, jsx_runtime_1.jsx)(Menu_1.Menu, { open: open, anchorEl: anchorEl, children: isLoading ? (0, jsx_runtime_1.jsx)(DataGridSecondaryActionsSkeleton_1.DataGridSecondaryActionsSkeleton, {}) : renderActions() }));
|
|
57
|
+
};
|
|
58
|
+
exports.DataGridSecondaryActions = DataGridSecondaryActions;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataGridSecondaryActionsSkeleton = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const Skeleton_1 = require("../../../Skeleton");
|
|
6
|
+
const styles_1 = require("./styles");
|
|
7
|
+
const DataGridSecondaryActionsSkeleton = () => ((0, jsx_runtime_1.jsxs)(styles_1.SkeletonWrapper, { children: [(0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { variant: "rounded", width: 110, height: 12 }), (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { variant: "rounded", width: 60, height: 12 }), (0, jsx_runtime_1.jsx)(Skeleton_1.Skeleton, { variant: "rounded", width: 90, height: 12 })] }));
|
|
8
|
+
exports.DataGridSecondaryActionsSkeleton = DataGridSecondaryActionsSkeleton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DataGridSecondaryActionsSkeleton';
|
|
@@ -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("./DataGridSecondaryActionsSkeleton"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SkeletonWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, React.JSX.IntrinsicElements, {}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SkeletonWrapper = void 0;
|
|
4
|
+
const material_1 = require("@mui/material");
|
|
5
|
+
exports.SkeletonWrapper = (0, material_1.styled)('div') `
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
gap: ${({ theme }) => theme.spacing(5)};
|
|
9
|
+
|
|
10
|
+
min-width: 140px;
|
|
11
|
+
min-height: 96px;
|
|
12
|
+
padding: ${({ theme }) => theme.microSpacing(5, 6)};
|
|
13
|
+
`;
|