@astral/ui 4.11.0 → 4.12.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.
Files changed (139) hide show
  1. package/components/DataGridActionCell/ActionCellContext/ActionCellContext.d.ts +10 -0
  2. package/components/DataGridActionCell/ActionCellContext/ActionCellContext.js +7 -0
  3. package/components/DataGridActionCell/ActionCellContext/ActionCellProvider/ActionCellProvider.d.ts +8 -0
  4. package/components/DataGridActionCell/ActionCellContext/ActionCellProvider/ActionCellProvider.js +29 -0
  5. package/components/DataGridActionCell/ActionCellContext/ActionCellProvider/index.d.ts +1 -0
  6. package/components/DataGridActionCell/ActionCellContext/ActionCellProvider/index.js +1 -0
  7. package/components/DataGridActionCell/ActionCellContext/index.d.ts +2 -0
  8. package/components/DataGridActionCell/ActionCellContext/index.js +2 -0
  9. package/components/DataGridActionCell/DataGridActionCell.d.ts +18 -2
  10. package/components/DataGridActionCell/DataGridActionCell.js +5 -12
  11. package/components/DataGridActionCell/{MainAction/MainAction.d.ts → DataGridMainActions/Action/Action.d.ts} +3 -3
  12. package/components/DataGridActionCell/{MainAction/MainAction.js → DataGridMainActions/Action/Action.js} +4 -4
  13. package/{node/components/DataGridActionCell/MainAction → components/DataGridActionCell/DataGridMainActions/Action}/MainIconButton/MainIconButton.d.ts +3 -3
  14. package/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/MainIconButton.js +3 -3
  15. package/components/DataGridActionCell/DataGridMainActions/Action/index.d.ts +1 -0
  16. package/components/DataGridActionCell/DataGridMainActions/Action/index.js +1 -0
  17. package/components/DataGridActionCell/DataGridMainActions/DataGridMainActions.d.ts +31 -0
  18. package/components/DataGridActionCell/DataGridMainActions/DataGridMainActions.js +32 -0
  19. package/components/DataGridActionCell/DataGridMainActions/index.d.ts +1 -0
  20. package/components/DataGridActionCell/DataGridMainActions/index.js +1 -0
  21. package/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActions.d.ts +48 -0
  22. package/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActions.js +54 -0
  23. package/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/DataGridSecondaryActionsSkeleton.d.ts +2 -0
  24. package/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/DataGridSecondaryActionsSkeleton.js +4 -0
  25. package/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/index.d.ts +1 -0
  26. package/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/index.js +1 -0
  27. package/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/styles.d.ts +1 -0
  28. package/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/styles.js +10 -0
  29. package/components/DataGridActionCell/DataGridSecondaryActions/index.d.ts +2 -0
  30. package/components/DataGridActionCell/DataGridSecondaryActions/index.js +2 -0
  31. package/components/DataGridActionCell/SecondaryActionsButton/SecondaryActionsButton.d.ts +20 -0
  32. package/components/DataGridActionCell/SecondaryActionsButton/SecondaryActionsButton.js +28 -0
  33. package/components/DataGridActionCell/SecondaryActionsButton/index.d.ts +1 -0
  34. package/components/DataGridActionCell/SecondaryActionsButton/index.js +1 -0
  35. package/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuContext.d.ts +12 -0
  36. package/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuContext.js +5 -0
  37. package/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuProvider/SecondaryActionsMenuProvider.d.ts +8 -0
  38. package/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuProvider/SecondaryActionsMenuProvider.js +5 -0
  39. package/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuProvider/index.d.ts +1 -0
  40. package/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuProvider/index.js +1 -0
  41. package/components/DataGridActionCell/SecondaryActionsMenuContext/index.d.ts +3 -0
  42. package/components/DataGridActionCell/SecondaryActionsMenuContext/index.js +3 -0
  43. package/components/DataGridActionCell/SecondaryActionsMenuContext/useSecondaryActionsMenu.d.ts +6 -0
  44. package/components/DataGridActionCell/SecondaryActionsMenuContext/useSecondaryActionsMenu.js +10 -0
  45. package/components/DataGridActionCell/constants.d.ts +2 -0
  46. package/components/DataGridActionCell/constants.js +4 -0
  47. package/components/DataGridActionCell/hooks/index.d.ts +1 -0
  48. package/components/DataGridActionCell/hooks/index.js +1 -0
  49. package/components/DataGridActionCell/hooks/useBlockingActions/index.d.ts +1 -0
  50. package/components/DataGridActionCell/hooks/useBlockingActions/index.js +1 -0
  51. package/components/DataGridActionCell/hooks/useBlockingActions/useBlockingActions.d.ts +8 -0
  52. package/components/DataGridActionCell/hooks/useBlockingActions/useBlockingActions.js +24 -0
  53. package/components/DataGridActionCell/index.d.ts +3 -0
  54. package/components/DataGridActionCell/index.js +3 -0
  55. package/components/DataGridActionCell/useLogic/useLogic.d.ts +5 -2
  56. package/components/DataGridActionCell/useLogic/useLogic.js +11 -14
  57. package/components/index.d.ts +1 -1
  58. package/components/index.js +1 -1
  59. package/node/components/DataGridActionCell/ActionCellContext/ActionCellContext.d.ts +10 -0
  60. package/node/components/DataGridActionCell/ActionCellContext/ActionCellContext.js +10 -0
  61. package/node/components/DataGridActionCell/ActionCellContext/ActionCellProvider/ActionCellProvider.d.ts +8 -0
  62. package/node/components/DataGridActionCell/ActionCellContext/ActionCellProvider/ActionCellProvider.js +33 -0
  63. package/node/components/DataGridActionCell/ActionCellContext/ActionCellProvider/index.d.ts +1 -0
  64. package/node/components/DataGridActionCell/{SecondaryAction → ActionCellContext/ActionCellProvider}/index.js +1 -1
  65. package/node/components/DataGridActionCell/ActionCellContext/index.d.ts +2 -0
  66. package/node/components/DataGridActionCell/ActionCellContext/index.js +18 -0
  67. package/node/components/DataGridActionCell/DataGridActionCell.d.ts +18 -2
  68. package/node/components/DataGridActionCell/DataGridActionCell.js +5 -12
  69. package/node/components/DataGridActionCell/{MainAction/MainAction.d.ts → DataGridMainActions/Action/Action.d.ts} +3 -3
  70. package/node/components/DataGridActionCell/{MainAction/MainAction.js → DataGridMainActions/Action/Action.js} +6 -6
  71. package/{components/DataGridActionCell/MainAction → node/components/DataGridActionCell/DataGridMainActions/Action}/MainIconButton/MainIconButton.d.ts +3 -3
  72. package/node/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/MainIconButton.js +3 -3
  73. package/node/components/DataGridActionCell/DataGridMainActions/Action/index.d.ts +1 -0
  74. package/node/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/index.js +1 -1
  75. package/node/components/DataGridActionCell/DataGridMainActions/DataGridMainActions.d.ts +31 -0
  76. package/node/components/DataGridActionCell/DataGridMainActions/DataGridMainActions.js +36 -0
  77. package/node/components/DataGridActionCell/DataGridMainActions/index.d.ts +1 -0
  78. package/node/components/DataGridActionCell/DataGridMainActions/index.js +17 -0
  79. package/node/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActions.d.ts +48 -0
  80. package/node/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActions.js +58 -0
  81. package/node/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/DataGridSecondaryActionsSkeleton.d.ts +2 -0
  82. package/node/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/DataGridSecondaryActionsSkeleton.js +8 -0
  83. package/node/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/index.d.ts +1 -0
  84. package/node/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/index.js +17 -0
  85. package/node/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/styles.d.ts +1 -0
  86. package/node/components/DataGridActionCell/DataGridSecondaryActions/DataGridSecondaryActionsSkeleton/styles.js +13 -0
  87. package/node/components/DataGridActionCell/DataGridSecondaryActions/index.d.ts +2 -0
  88. package/node/components/DataGridActionCell/DataGridSecondaryActions/index.js +18 -0
  89. package/node/components/DataGridActionCell/SecondaryActionsButton/SecondaryActionsButton.d.ts +20 -0
  90. package/node/components/DataGridActionCell/SecondaryActionsButton/SecondaryActionsButton.js +32 -0
  91. package/node/components/DataGridActionCell/SecondaryActionsButton/index.d.ts +1 -0
  92. package/node/components/DataGridActionCell/SecondaryActionsButton/index.js +17 -0
  93. package/node/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuContext.d.ts +12 -0
  94. package/node/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuContext.js +8 -0
  95. package/node/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuProvider/SecondaryActionsMenuProvider.d.ts +8 -0
  96. package/node/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuProvider/SecondaryActionsMenuProvider.js +9 -0
  97. package/node/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuProvider/index.d.ts +1 -0
  98. package/node/components/DataGridActionCell/SecondaryActionsMenuContext/SecondaryActionsMenuProvider/index.js +5 -0
  99. package/node/components/DataGridActionCell/SecondaryActionsMenuContext/index.d.ts +3 -0
  100. package/node/components/DataGridActionCell/SecondaryActionsMenuContext/index.js +9 -0
  101. package/node/components/DataGridActionCell/SecondaryActionsMenuContext/useSecondaryActionsMenu.d.ts +6 -0
  102. package/node/components/DataGridActionCell/SecondaryActionsMenuContext/useSecondaryActionsMenu.js +14 -0
  103. package/node/components/DataGridActionCell/constants.d.ts +2 -0
  104. package/node/components/DataGridActionCell/constants.js +7 -0
  105. package/node/components/DataGridActionCell/hooks/index.d.ts +1 -0
  106. package/node/components/DataGridActionCell/hooks/index.js +17 -0
  107. package/node/components/DataGridActionCell/hooks/useBlockingActions/index.d.ts +1 -0
  108. package/node/components/DataGridActionCell/hooks/useBlockingActions/index.js +17 -0
  109. package/node/components/DataGridActionCell/hooks/useBlockingActions/useBlockingActions.d.ts +8 -0
  110. package/node/components/DataGridActionCell/hooks/useBlockingActions/useBlockingActions.js +28 -0
  111. package/node/components/DataGridActionCell/index.d.ts +3 -0
  112. package/node/components/DataGridActionCell/index.js +9 -0
  113. package/node/components/DataGridActionCell/useLogic/useLogic.d.ts +5 -2
  114. package/node/components/DataGridActionCell/useLogic/useLogic.js +10 -13
  115. package/node/components/index.d.ts +1 -1
  116. package/node/components/index.js +6 -3
  117. package/package.json +1 -1
  118. package/components/DataGridActionCell/MainAction/index.d.ts +0 -1
  119. package/components/DataGridActionCell/MainAction/index.js +0 -1
  120. package/components/DataGridActionCell/SecondaryAction/SecondaryAction.d.ts +0 -23
  121. package/components/DataGridActionCell/SecondaryAction/SecondaryAction.js +0 -11
  122. package/components/DataGridActionCell/SecondaryAction/index.d.ts +0 -1
  123. package/components/DataGridActionCell/SecondaryAction/index.js +0 -1
  124. package/node/components/DataGridActionCell/MainAction/index.d.ts +0 -1
  125. package/node/components/DataGridActionCell/SecondaryAction/SecondaryAction.d.ts +0 -23
  126. package/node/components/DataGridActionCell/SecondaryAction/SecondaryAction.js +0 -15
  127. package/node/components/DataGridActionCell/SecondaryAction/index.d.ts +0 -1
  128. /package/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/index.d.ts +0 -0
  129. /package/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/index.js +0 -0
  130. /package/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/useLogic/index.d.ts +0 -0
  131. /package/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/useLogic/index.js +0 -0
  132. /package/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/useLogic/useLogic.d.ts +0 -0
  133. /package/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/useLogic/useLogic.js +0 -0
  134. /package/node/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/index.d.ts +0 -0
  135. /package/node/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/index.js +0 -0
  136. /package/node/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/useLogic/index.d.ts +0 -0
  137. /package/node/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/useLogic/index.js +0 -0
  138. /package/node/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/useLogic/useLogic.d.ts +0 -0
  139. /package/node/components/DataGridActionCell/{MainAction → DataGridMainActions/Action}/MainIconButton/useLogic/useLogic.js +0 -0
@@ -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,7 @@
1
+ import { createContext } from 'react';
2
+ export const ActionCellContext = createContext({
3
+ isDisabled: false,
4
+ onActionClick: () => undefined,
5
+ addDisabledCell: () => undefined,
6
+ removeDisabledCell: () => undefined,
7
+ });
@@ -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,29 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback, useMemo, useState } from 'react';
3
+ import { ActionCellContext } from '../ActionCellContext';
4
+ export const ActionCellContextProvider = ({ children, onActionClick, }) => {
5
+ const [isDisabled, setDisabled] = useState(false);
6
+ const [disabledReason, setDisabledReason] = useState();
7
+ const addDisabledCell = useCallback((reason) => {
8
+ setDisabled(true);
9
+ setDisabledReason(reason);
10
+ }, []);
11
+ const removeDisabledCell = useCallback(() => {
12
+ setDisabled(false);
13
+ setDisabledReason(undefined);
14
+ }, []);
15
+ const contextValue = useMemo(() => ({
16
+ isDisabled,
17
+ disabledReason,
18
+ addDisabledCell,
19
+ removeDisabledCell,
20
+ onActionClick,
21
+ }), [
22
+ isDisabled,
23
+ disabledReason,
24
+ addDisabledCell,
25
+ removeDisabledCell,
26
+ onActionClick,
27
+ ]);
28
+ return (_jsx(ActionCellContext.Provider, { value: contextValue, children: children }));
29
+ };
@@ -0,0 +1 @@
1
+ export * from './ActionCellProvider';
@@ -0,0 +1 @@
1
+ export * from './ActionCellProvider';
@@ -0,0 +1,2 @@
1
+ export * from './ActionCellContext';
2
+ export * from './ActionCellProvider';
@@ -0,0 +1,2 @@
1
+ export * from './ActionCellContext';
2
+ export * from './ActionCellProvider';
@@ -1,4 +1,5 @@
1
- /// <reference types="react" />
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: DataGridActions<TRow>;
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
  */
@@ -1,17 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { MainAction } from './MainAction';
3
- import { SecondaryActions } from './SecondaryAction';
2
+ import { ActionCellContextProvider } from './ActionCellContext';
3
+ import { DataGridMainActions } from './DataGridMainActions';
4
+ import { SecondaryActionsButton } from './SecondaryActionsButton';
4
5
  import { Wrapper } from './styles';
5
6
  import { useLogic } from './useLogic';
6
- const TOOLTIP_PLACEMENT = {
7
- mainAction: 'top',
8
- secondaryAction: 'left',
9
- };
10
7
  export const DataGridActionCell = (props) => {
11
- const { isDisabledAction, handleWrapperClick, handleActionClick } = useLogic(props);
12
- const { actions } = props;
13
- const { main, secondary } = actions;
14
- return (_jsxs(Wrapper, { onClick: handleWrapperClick, children: [main.map((action) => {
15
- return (_jsx(MainAction, { action: action, onActionClick: handleActionClick, isDisabled: isDisabledAction, tooltipPlacement: TOOLTIP_PLACEMENT.mainAction }, action.name));
16
- }), secondary && (_jsx(SecondaryActions, { actions: secondary, onActionClick: handleActionClick, tooltipPlacement: TOOLTIP_PLACEMENT.secondaryAction, isDisabled: isDisabledAction }))] }));
8
+ const { handleWrapperClick, handleActionClick, actions, mainActions, secondaryActions, hasSecondaryActions, } = useLogic(props);
9
+ return (_jsx(ActionCellContextProvider, { onActionClick: handleActionClick, children: _jsxs(Wrapper, { onClick: handleWrapperClick, children: [mainActions ? (mainActions()) : (_jsx(DataGridMainActions, { actions: actions?.main })), hasSecondaryActions && (_jsx(SecondaryActionsButton, { actions: actions?.secondary, renderActions: secondaryActions }))] }) }));
17
10
  };
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { type TooltipProps } from '../../Tooltip';
3
- import type { ActionCellHandler, MainActionKind } from '../types';
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 MainAction: <TAction>({ action, onActionClick, isDisabled, tooltipPlacement, }: MainActionProps<TAction>) => JSX.Element;
22
+ export declare const Action: <TAction>({ action, onActionClick, isDisabled, tooltipPlacement, }: MainActionProps<TAction>) => JSX.Element;
23
23
  export {};
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createElement as _createElement } from "react";
3
- import { IconDropdownButton } from '../../IconDropdownButton';
4
- import { MenuItem } from '../../MenuItem';
5
- import { Tooltip } from '../../Tooltip';
3
+ import { IconDropdownButton } from '../../../IconDropdownButton';
4
+ import { MenuItem } from '../../../MenuItem';
5
+ import { Tooltip } from '../../../Tooltip';
6
6
  import { MainIconButton } from './MainIconButton';
7
- export const MainAction = ({ action, onActionClick, isDisabled, tooltipPlacement, }) => {
7
+ export const Action = ({ action, onActionClick, isDisabled, tooltipPlacement, }) => {
8
8
  if ('actions' in action) {
9
9
  const { disabled, icon, name, disabledReason, actions } = action;
10
10
  return (_jsx(Tooltip, { title: disabledReason || name, withoutContainer: !disabled, placement: tooltipPlacement, children: _jsx(IconDropdownButton, { icon: icon, variant: "text", disabled: isDisabled || disabled, children: actions.map(({ name: nestedActionName, onClick: onClickNested, ...props }) => (_createElement(MenuItem, { ...props, key: nestedActionName, onClick: onActionClick(onClickNested) }, nestedActionName))) }) }, name));
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
- import { type IconButtonProps } from '../../../IconButton';
3
- import { type TooltipProps } from '../../../Tooltip';
4
- import { type ActionCellHandler, type SingleAction } from '../../types';
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
  /**
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { ConfirmAction, } from '../../../ConfirmAction';
3
- import { IconButton } from '../../../IconButton';
4
- import { Tooltip } from '../../../Tooltip';
2
+ import { ConfirmAction, } from '../../../../ConfirmAction';
3
+ import { IconButton } from '../../../../IconButton';
4
+ import { Tooltip } from '../../../../Tooltip';
5
5
  import { useLogic } from './useLogic';
6
6
  export const MainIconButton = (props) => {
7
7
  const { tooltipProps } = useLogic(props);
@@ -0,0 +1 @@
1
+ export * from './Action';
@@ -0,0 +1 @@
1
+ export * from './Action';
@@ -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,32 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { TOOLTIP_PLACEMENT } from '../constants';
3
+ import { useBlockingActions } from '../hooks';
4
+ import { Action } from './Action';
5
+ /**
6
+ * Компонент для отображения основных действий в ячейке таблицы DataGrid.
7
+ *
8
+ * Основные действия отображаются в виде отдельных кнопок непосредственно в ячейке
9
+ * и предназначены для наиболее часто используемых операций над строкой данных.
10
+ *
11
+ * @remarks
12
+ * - Компонент автоматически обрабатывает блокирующие операции, что предотвращает одновременное выполнение нескольких действий
13
+ * - Для действий автоматически отображаются тултипы с заданным позиционированием
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * <DataGridMainActions
18
+ * actions={[
19
+ * { name: 'edit', icon: <EditIcon />, onClick: handleEdit },
20
+ * { name: 'delete', icon: <DeleteIcon />, onClick: handleDelete, isBlockingOperation: true }
21
+ * ]}
22
+ * onActionClick={(handler) => (event) => handler(event)}
23
+ * tooltipPlacement="top"
24
+ * />
25
+ * ```
26
+ */
27
+ export const DataGridMainActions = ({ actions, }) => {
28
+ const { isDisabled, onActionClick } = useBlockingActions(actions);
29
+ return (_jsx(_Fragment, { children: actions?.map((action) => {
30
+ return (_jsx(Action, { action: action, onActionClick: onActionClick, isDisabled: isDisabled, tooltipPlacement: TOOLTIP_PLACEMENT.mainAction }, action.name));
31
+ }) }));
32
+ };
@@ -0,0 +1 @@
1
+ export * from './DataGridMainActions';
@@ -0,0 +1 @@
1
+ export * from './DataGridMainActions';
@@ -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;
@@ -0,0 +1,54 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createElement as _createElement } from "react";
3
+ import { Menu } from '../../Menu';
4
+ import { MenuItem } from '../../MenuItem';
5
+ import { TOOLTIP_PLACEMENT } from '../constants';
6
+ import { useBlockingActions } from '../hooks';
7
+ import { useSecondaryActionsMenu } from '../SecondaryActionsMenuContext';
8
+ import { DataGridSecondaryActionsSkeleton } from './DataGridSecondaryActionsSkeleton';
9
+ /**
10
+ * Компонент для отображения дополнительных действий в выпадающем меню ячейки таблицы DataGrid.
11
+ *
12
+ * Вторичные действия отображаются в выпадающем меню (dropdown) и предназначены для менее
13
+ * используемых операций, которые не требуют постоянного отображения в интерфейсе.
14
+ *
15
+ * @remarks
16
+ * - Компонент поддерживает состояние загрузки (`isLoading`), при котором отображается скелетон вместо действий
17
+ * - Автоматически обрабатывает блокирующие операции, что предотвращает одновременное выполнение нескольких действий
18
+ * - Меню привязывается к кнопке "три точки"
19
+ * - Состояние меню (`open`, `anchorEl`) берется из `SecondaryActionsMenuContext`, не требуется прокидывать пропсы вручную
20
+ *
21
+ * @example
22
+ * Использование с контекстом (рекомендуется):
23
+ * ```tsx
24
+ * <DataGridSecondaryActions
25
+ * actions={[
26
+ * { name: 'Дублировать', onClick: handleDuplicate },
27
+ * { name: 'Архивировать', onClick: handleArchive, disabled: !canArchive },
28
+ * { name: 'Экспортировать', onClick: handleExport }
29
+ * ]}
30
+ * isLoading={isActionsLoading}
31
+ * />
32
+ * ```
33
+ *
34
+ * @example
35
+ * Использование с явными пропсами (для обратной совместимости):
36
+ * ```tsx
37
+ * <DataGridSecondaryActions
38
+ * actions={actions}
39
+ * open={isMenuOpen}
40
+ * anchorEl={buttonRef.current}
41
+ * />
42
+ * ```
43
+ */
44
+ export const DataGridSecondaryActions = ({ actions, isLoading, }) => {
45
+ const { onActionClick } = useBlockingActions(actions);
46
+ const { open, anchorEl } = useSecondaryActionsMenu();
47
+ const renderActions = () => {
48
+ return actions?.map((action) => {
49
+ const { onClick, name, loading, isBlockingOperation, loadingNote, ...restProps } = action;
50
+ return (_createElement(MenuItem, { ...restProps, key: name, tooltipPlacement: TOOLTIP_PLACEMENT.secondaryActions, onClick: onActionClick(onClick) }, name));
51
+ });
52
+ };
53
+ return (_jsx(Menu, { open: open, anchorEl: anchorEl, children: isLoading ? _jsx(DataGridSecondaryActionsSkeleton, {}) : renderActions() }));
54
+ };
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const DataGridSecondaryActionsSkeleton: () => JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Skeleton } from '../../../Skeleton';
3
+ import { SkeletonWrapper } from './styles';
4
+ export const DataGridSecondaryActionsSkeleton = () => (_jsxs(SkeletonWrapper, { children: [_jsx(Skeleton, { variant: "rounded", width: 110, height: 12 }), _jsx(Skeleton, { variant: "rounded", width: 60, height: 12 }), _jsx(Skeleton, { variant: "rounded", width: 90, height: 12 })] }));
@@ -0,0 +1 @@
1
+ export * from './DataGridSecondaryActionsSkeleton';
@@ -0,0 +1 @@
1
+ export * from './DataGridSecondaryActionsSkeleton';
@@ -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,10 @@
1
+ import { styled } from '@mui/material';
2
+ export const SkeletonWrapper = styled('div') `
3
+ display: flex;
4
+ flex-direction: column;
5
+ gap: ${({ theme }) => theme.spacing(5)};
6
+
7
+ min-width: 140px;
8
+ min-height: 96px;
9
+ padding: ${({ theme }) => theme.microSpacing(5, 6)};
10
+ `;
@@ -0,0 +1,2 @@
1
+ export * from './DataGridSecondaryActions';
2
+ export * from './DataGridSecondaryActionsSkeleton';
@@ -0,0 +1,2 @@
1
+ export * from './DataGridSecondaryActions';
2
+ export * from './DataGridSecondaryActionsSkeleton';
@@ -0,0 +1,20 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { TooltipProps } from '../../Tooltip';
3
+ import { type DataGridSecondaryActionsProps } from '../DataGridSecondaryActions';
4
+ import type { SecondaryActionKind } from '../types';
5
+ type SecondaryActionsButtonProps<TAction> = {
6
+ /**
7
+ * Вторичные действия
8
+ */
9
+ actions?: SecondaryActionKind<TAction>[];
10
+ /**
11
+ * Положение тултипа
12
+ */
13
+ tooltipPlacement?: TooltipProps['placement'];
14
+ /**
15
+ * Контент меню
16
+ */
17
+ renderActions?: (props: DataGridSecondaryActionsProps<TAction>) => ReactNode;
18
+ };
19
+ export declare const SecondaryActionsButton: <TAction>({ actions, renderActions, }: SecondaryActionsButtonProps<TAction>) => JSX.Element;
20
+ export {};
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ClickAwayListener } from '@mui/material';
3
+ import { useContext, useRef, useState } from 'react';
4
+ import { DotsVOutlineMd } from '../../../icons';
5
+ import { useMenu } from '../../hooks';
6
+ import { IconButton } from '../../IconButton';
7
+ import { ActionCellContext } from '../ActionCellContext';
8
+ import { DataGridSecondaryActions, } from '../DataGridSecondaryActions';
9
+ import { SecondaryActionsMenuProvider } from '../SecondaryActionsMenuContext';
10
+ export const SecondaryActionsButton = ({ actions, renderActions, }) => {
11
+ const buttonRef = useRef(null);
12
+ const { open, anchorRef, handleOpenMenu, handleCloseMenu } = useMenu(buttonRef);
13
+ const { isDisabled } = useContext(ActionCellContext);
14
+ // Если контент единожды отрендерился, то будем рендерить его дальше,
15
+ // чтобы были актуальные статусы loading для блокировки действий
16
+ const [isOnceOpen, setIsOnceOpen] = useState(false);
17
+ const handleOpen = () => {
18
+ setIsOnceOpen(true);
19
+ handleOpenMenu();
20
+ };
21
+ const renderContent = () => {
22
+ if (renderActions) {
23
+ return renderActions({ isLoading: false });
24
+ }
25
+ return _jsx(DataGridSecondaryActions, { actions: actions });
26
+ };
27
+ return (_jsxs(SecondaryActionsMenuProvider, { value: { open, anchorEl: anchorRef.current }, children: [_jsx(ClickAwayListener, { onClickAway: handleCloseMenu, mouseEvent: "onMouseUp", children: _jsx(IconButton, { ref: anchorRef, onClick: handleOpen, selected: open, variant: "text", disabled: isDisabled, children: _jsx(DotsVOutlineMd, {}) }) }), isOnceOpen && renderContent()] }));
28
+ };
@@ -0,0 +1 @@
1
+ export * from './SecondaryActionsButton';
@@ -0,0 +1 @@
1
+ export * from './SecondaryActionsButton';
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ export type SecondaryActionsMenuContextProps = {
3
+ /**
4
+ * Флаг состояния меню (открыто-закрыто)
5
+ */
6
+ open: boolean;
7
+ /**
8
+ * Элемент, к которому привязано меню
9
+ */
10
+ anchorEl: HTMLButtonElement | null;
11
+ };
12
+ export declare const SecondaryActionsMenuContext: import("react").Context<SecondaryActionsMenuContextProps>;
@@ -0,0 +1,5 @@
1
+ import { createContext } from 'react';
2
+ export const SecondaryActionsMenuContext = createContext({
3
+ open: false,
4
+ anchorEl: null,
5
+ });
@@ -0,0 +1,8 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type SecondaryActionsMenuContextProps } from '../SecondaryActionsMenuContext';
3
+ type SecondaryActionsMenuProviderProps = {
4
+ children: ReactNode;
5
+ value: SecondaryActionsMenuContextProps;
6
+ };
7
+ export declare const SecondaryActionsMenuProvider: ({ children, value, }: SecondaryActionsMenuProviderProps) => JSX.Element;
8
+ export {};
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { SecondaryActionsMenuContext, } from '../SecondaryActionsMenuContext';
3
+ export const SecondaryActionsMenuProvider = ({ children, value, }) => {
4
+ return (_jsx(SecondaryActionsMenuContext.Provider, { value: value, children: children }));
5
+ };
@@ -0,0 +1 @@
1
+ export { SecondaryActionsMenuProvider } from './SecondaryActionsMenuProvider';
@@ -0,0 +1 @@
1
+ export { SecondaryActionsMenuProvider } from './SecondaryActionsMenuProvider';
@@ -0,0 +1,3 @@
1
+ export { SecondaryActionsMenuContext } from './SecondaryActionsMenuContext';
2
+ export { SecondaryActionsMenuProvider } from './SecondaryActionsMenuProvider';
3
+ export { useSecondaryActionsMenu } from './useSecondaryActionsMenu';
@@ -0,0 +1,3 @@
1
+ export { SecondaryActionsMenuContext } from './SecondaryActionsMenuContext';
2
+ export { SecondaryActionsMenuProvider } from './SecondaryActionsMenuProvider';
3
+ export { useSecondaryActionsMenu } from './useSecondaryActionsMenu';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Хук для получения состояния меню вторичных действий
3
+ *
4
+ * @returns Состояние меню (open, anchorEl)
5
+ */
6
+ export declare const useSecondaryActionsMenu: () => import("./SecondaryActionsMenuContext").SecondaryActionsMenuContextProps;
@@ -0,0 +1,10 @@
1
+ import { useContext } from 'react';
2
+ import { SecondaryActionsMenuContext } from './SecondaryActionsMenuContext';
3
+ /**
4
+ * Хук для получения состояния меню вторичных действий
5
+ *
6
+ * @returns Состояние меню (open, anchorEl)
7
+ */
8
+ export const useSecondaryActionsMenu = () => {
9
+ return useContext(SecondaryActionsMenuContext);
10
+ };
@@ -0,0 +1,2 @@
1
+ import type { TooltipProps } from '../Tooltip';
2
+ export declare const TOOLTIP_PLACEMENT: Record<string, TooltipProps['placement']>;
@@ -0,0 +1,4 @@
1
+ export const TOOLTIP_PLACEMENT = {
2
+ mainAction: 'top',
3
+ secondaryAction: 'left',
4
+ };
@@ -0,0 +1 @@
1
+ export * from './useBlockingActions';
@@ -0,0 +1 @@
1
+ export * from './useBlockingActions';
@@ -0,0 +1 @@
1
+ export * from './useBlockingActions';
@@ -0,0 +1 @@
1
+ export * from './useBlockingActions';
@@ -0,0 +1,8 @@
1
+ import type { MainActionKind, SecondaryActionKind } from '../../types';
2
+ /**
3
+ * хук позволяющий подписаться на событие блокировки действий
4
+ */
5
+ export declare const useBlockingActions: <TAction>(actions?: MainActionKind<TAction>[] | SecondaryActionKind<TAction>[] | undefined) => {
6
+ isDisabled: boolean;
7
+ onActionClick: import("../../types").ActionCellHandler<TAction>;
8
+ };
@@ -0,0 +1,24 @@
1
+ import { useContext, useEffect } from 'react';
2
+ import { RowContext } from '../../../DataGrid';
3
+ import { ActionCellContext, } from '../../ActionCellContext';
4
+ /**
5
+ * хук позволяющий подписаться на событие блокировки действий
6
+ */
7
+ export const useBlockingActions = (actions) => {
8
+ const { addDisabledRow, removeDisabledRow } = useContext(RowContext);
9
+ const { addDisabledCell, removeDisabledCell, isDisabled, onActionClick } = useContext(ActionCellContext);
10
+ const blockingAction = [...(actions || [])].find((action) => action.isBlockingOperation && action.loading);
11
+ useEffect(() => {
12
+ if (blockingAction) {
13
+ addDisabledRow(blockingAction?.loadingNote);
14
+ addDisabledCell(blockingAction?.loadingNote);
15
+ return;
16
+ }
17
+ removeDisabledRow();
18
+ removeDisabledCell();
19
+ }, [blockingAction]);
20
+ return {
21
+ isDisabled,
22
+ onActionClick,
23
+ };
24
+ };
@@ -1 +1,4 @@
1
1
  export * from './DataGridActionCell';
2
+ export { DataGridMainActions, type DataGridMainActionsProps, } from './DataGridMainActions';
3
+ export { DataGridSecondaryActions, type DataGridSecondaryActionsProps, DataGridSecondaryActionsSkeleton, } from './DataGridSecondaryActions';
4
+ export { SecondaryActionsMenuProvider, useSecondaryActionsMenu, } from './SecondaryActionsMenuContext';
@@ -1 +1,4 @@
1
1
  export * from './DataGridActionCell';
2
+ export { DataGridMainActions, } from './DataGridMainActions';
3
+ export { DataGridSecondaryActions, DataGridSecondaryActionsSkeleton, } from './DataGridSecondaryActions';
4
+ export { SecondaryActionsMenuProvider, useSecondaryActionsMenu, } from './SecondaryActionsMenuContext';