@astral/ui 4.91.1 → 4.91.2

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.
@@ -18,7 +18,7 @@ export type HintPopoverProps = Omit<NewPopoverProps, 'hasArrow' | 'disableMobile
18
18
  */
19
19
  action?: ReactNode;
20
20
  /**
21
- * Ref на узел контента — для фокус-трапа/определения кликов у потребителя.
21
+ * Ref на узел контента — для focus-trap/определения кликов у потребителя.
22
22
  */
23
23
  contentRef?: Ref<HTMLDivElement>;
24
24
  };
@@ -9,10 +9,10 @@ import { useLogic } from './useLogic';
9
9
  export const HighlightStep = ({ activeStep, isClosing, geometry, }) => {
10
10
  const { step } = activeStep;
11
11
  const { anchorEl } = geometry;
12
- const { isOpen, shouldShowPopover, setPopoverNode, handleClose } = useLogic(activeStep, isClosing, geometry);
12
+ const { isOpen, shouldShowPopover, handleClose } = useLogic(activeStep, isClosing, geometry);
13
13
  // Без якоря popover не рисуем.
14
14
  if (!anchorEl) {
15
15
  return null;
16
16
  }
17
- return (_jsx(_Fragment, { children: shouldShowPopover && (_jsx(StepPopover, { variant: "light", isOpen: isOpen, disableAutoFocus: true, anchorEl: anchorEl, placement: step.position, onClose: handleClose, contentRef: setPopoverNode, title: step.title, action: _jsx(StepFooter, { activeStep: activeStep }), children: step.content && (_jsx(Typography, { component: "div", variant: "body1", color: "grey", colorIntensity: "900", children: step.content })) })) }));
17
+ return (_jsx(_Fragment, { children: shouldShowPopover && (_jsx(StepPopover, { variant: "light", isOpen: isOpen, disableAutoFocus: true, anchorEl: anchorEl, placement: step.position, onClose: handleClose, title: step.title, action: _jsx(StepFooter, { activeStep: activeStep }), children: step.content && (_jsx(Typography, { component: "div", variant: "body1", color: "grey", colorIntensity: "900", children: step.content })) })) }));
18
18
  };
@@ -3,10 +3,9 @@ import { type OverlayGeometry } from '../../../useLogic';
3
3
  export type UseLogicResult = {
4
4
  isOpen: boolean;
5
5
  shouldShowPopover: boolean;
6
- setPopoverNode: (node: HTMLElement | null) => void;
7
6
  handleClose: () => void;
8
7
  };
9
8
  /**
10
- * Логика highlight-шага: задержка popover, фокус-трап, закрытие.
9
+ * Логика highlight-шага: задержка popover, закрытие.
11
10
  */
12
11
  export declare const useLogic: (activeStep: ActiveStepState, isClosing: boolean, geometry: OverlayGeometry) => UseLogicResult;
@@ -1,12 +1,11 @@
1
- import { useCallback, useEffect, useMemo, useState } from 'react';
1
+ import { useCallback, useEffect, useState } from 'react';
2
2
  import { useTheme } from '../../../../../../theme/hooks/useTheme';
3
- import { useFocusTrap } from '../../../../hooks/useFocusTrap';
4
3
  /**
5
- * Логика highlight-шага: задержка popover, фокус-трап, закрытие.
4
+ * Логика highlight-шага: задержка popover, закрытие.
6
5
  */
7
6
  export const useLogic = (activeStep, isClosing, geometry) => {
8
- const { isInteractive, isConfirming } = activeStep;
9
- const { anchorEl, element, isTransitioning } = geometry;
7
+ const { isConfirming } = activeStep;
8
+ const { anchorEl, isTransitioning } = geometry;
10
9
  const theme = useTheme();
11
10
  const isOpen = !isClosing;
12
11
  // Задержка до появления popover после готовности hole.
@@ -19,10 +18,6 @@ export const useLogic = (activeStep, isClosing, geometry) => {
19
18
  const timer = setTimeout(() => setIsEntered(true), theme.transitions.duration.shortest);
20
19
  return () => clearTimeout(timer);
21
20
  }, [isEntered, isHoleReady]);
22
- const [popoverNode, setPopoverNode] = useState(null);
23
- const trapNodes = useMemo(() => [popoverNode, isInteractive ? element : null], [popoverNode, isInteractive, element]);
24
- // Трап выключен при закрытии/подтверждении.
25
- useFocusTrap(trapNodes, isOpen && !isConfirming);
26
21
  const handleClose = useCallback(() => {
27
22
  activeStep.requestClose();
28
23
  }, [activeStep]);
@@ -31,7 +26,6 @@ export const useLogic = (activeStep, isClosing, geometry) => {
31
26
  return {
32
27
  isOpen,
33
28
  shouldShowPopover,
34
- setPopoverNode,
35
29
  handleClose,
36
30
  };
37
31
  };
@@ -18,7 +18,7 @@ export type HintPopoverProps = Omit<NewPopoverProps, 'hasArrow' | 'disableMobile
18
18
  */
19
19
  action?: ReactNode;
20
20
  /**
21
- * Ref на узел контента — для фокус-трапа/определения кликов у потребителя.
21
+ * Ref на узел контента — для focus-trap/определения кликов у потребителя.
22
22
  */
23
23
  contentRef?: Ref<HTMLDivElement>;
24
24
  };
@@ -12,11 +12,11 @@ const useLogic_1 = require("./useLogic");
12
12
  const HighlightStep = ({ activeStep, isClosing, geometry, }) => {
13
13
  const { step } = activeStep;
14
14
  const { anchorEl } = geometry;
15
- const { isOpen, shouldShowPopover, setPopoverNode, handleClose } = (0, useLogic_1.useLogic)(activeStep, isClosing, geometry);
15
+ const { isOpen, shouldShowPopover, handleClose } = (0, useLogic_1.useLogic)(activeStep, isClosing, geometry);
16
16
  // Без якоря popover не рисуем.
17
17
  if (!anchorEl) {
18
18
  return null;
19
19
  }
20
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: shouldShowPopover && ((0, jsx_runtime_1.jsx)(styles_1.StepPopover, { variant: "light", isOpen: isOpen, disableAutoFocus: true, anchorEl: anchorEl, placement: step.position, onClose: handleClose, contentRef: setPopoverNode, title: step.title, action: (0, jsx_runtime_1.jsx)(StepFooter_1.StepFooter, { activeStep: activeStep }), children: step.content && ((0, jsx_runtime_1.jsx)(Typography_1.Typography, { component: "div", variant: "body1", color: "grey", colorIntensity: "900", children: step.content })) })) }));
20
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: shouldShowPopover && ((0, jsx_runtime_1.jsx)(styles_1.StepPopover, { variant: "light", isOpen: isOpen, disableAutoFocus: true, anchorEl: anchorEl, placement: step.position, onClose: handleClose, title: step.title, action: (0, jsx_runtime_1.jsx)(StepFooter_1.StepFooter, { activeStep: activeStep }), children: step.content && ((0, jsx_runtime_1.jsx)(Typography_1.Typography, { component: "div", variant: "body1", color: "grey", colorIntensity: "900", children: step.content })) })) }));
21
21
  };
22
22
  exports.HighlightStep = HighlightStep;
@@ -3,10 +3,9 @@ import { type OverlayGeometry } from '../../../useLogic';
3
3
  export type UseLogicResult = {
4
4
  isOpen: boolean;
5
5
  shouldShowPopover: boolean;
6
- setPopoverNode: (node: HTMLElement | null) => void;
7
6
  handleClose: () => void;
8
7
  };
9
8
  /**
10
- * Логика highlight-шага: задержка popover, фокус-трап, закрытие.
9
+ * Логика highlight-шага: задержка popover, закрытие.
11
10
  */
12
11
  export declare const useLogic: (activeStep: ActiveStepState, isClosing: boolean, geometry: OverlayGeometry) => UseLogicResult;
@@ -3,13 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useLogic = void 0;
4
4
  const react_1 = require("react");
5
5
  const useTheme_1 = require("../../../../../../theme/hooks/useTheme");
6
- const useFocusTrap_1 = require("../../../../hooks/useFocusTrap");
7
6
  /**
8
- * Логика highlight-шага: задержка popover, фокус-трап, закрытие.
7
+ * Логика highlight-шага: задержка popover, закрытие.
9
8
  */
10
9
  const useLogic = (activeStep, isClosing, geometry) => {
11
- const { isInteractive, isConfirming } = activeStep;
12
- const { anchorEl, element, isTransitioning } = geometry;
10
+ const { isConfirming } = activeStep;
11
+ const { anchorEl, isTransitioning } = geometry;
13
12
  const theme = (0, useTheme_1.useTheme)();
14
13
  const isOpen = !isClosing;
15
14
  // Задержка до появления popover после готовности hole.
@@ -22,10 +21,6 @@ const useLogic = (activeStep, isClosing, geometry) => {
22
21
  const timer = setTimeout(() => setIsEntered(true), theme.transitions.duration.shortest);
23
22
  return () => clearTimeout(timer);
24
23
  }, [isEntered, isHoleReady]);
25
- const [popoverNode, setPopoverNode] = (0, react_1.useState)(null);
26
- const trapNodes = (0, react_1.useMemo)(() => [popoverNode, isInteractive ? element : null], [popoverNode, isInteractive, element]);
27
- // Трап выключен при закрытии/подтверждении.
28
- (0, useFocusTrap_1.useFocusTrap)(trapNodes, isOpen && !isConfirming);
29
24
  const handleClose = (0, react_1.useCallback)(() => {
30
25
  activeStep.requestClose();
31
26
  }, [activeStep]);
@@ -34,7 +29,6 @@ const useLogic = (activeStep, isClosing, geometry) => {
34
29
  return {
35
30
  isOpen,
36
31
  shouldShowPopover,
37
- setPopoverNode,
38
32
  handleClose,
39
33
  };
40
34
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/ui",
3
- "version": "4.91.1",
3
+ "version": "4.91.2",
4
4
  "browser": "./index.js",
5
5
  "main": "./node/index.js",
6
6
  "dependencies": {
@@ -1 +0,0 @@
1
- export { useFocusTrap } from './useFocusTrap';
@@ -1 +0,0 @@
1
- export { useFocusTrap } from './useFocusTrap';
@@ -1,6 +0,0 @@
1
- /**
2
- * Мульти-контейнерный фокус-трап для highlight-шага.
3
- * @param nodes контейнеры
4
- * @param isActive включение трапа
5
- */
6
- export declare const useFocusTrap: (nodes: (HTMLElement | null)[], isActive?: boolean) => void;
@@ -1,33 +0,0 @@
1
- import { createFocusTrap } from 'focus-trap';
2
- import { useEffect } from 'react';
3
- /**
4
- * Мульти-контейнерный фокус-трап для highlight-шага.
5
- * @param nodes контейнеры
6
- * @param isActive включение трапа
7
- */
8
- export const useFocusTrap = (nodes, isActive = true) => {
9
- useEffect(() => {
10
- const containers = nodes.filter((node) => node !== null);
11
- if (!isActive || containers.length === 0) {
12
- return;
13
- }
14
- const trap = createFocusTrap(containers, {
15
- escapeDeactivates: false,
16
- clickOutsideDeactivates: false,
17
- allowOutsideClick: true,
18
- returnFocusOnDeactivate: false,
19
- fallbackFocus: containers[0],
20
- initialFocus: () => containers[0],
21
- });
22
- try {
23
- trap.activate();
24
- }
25
- catch {
26
- // Нет фокусируемых узлов.
27
- return;
28
- }
29
- return () => {
30
- trap.deactivate();
31
- };
32
- }, [nodes, isActive]);
33
- };
@@ -1 +0,0 @@
1
- export { useFocusTrap } from './useFocusTrap';
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useFocusTrap = void 0;
4
- var useFocusTrap_1 = require("./useFocusTrap");
5
- Object.defineProperty(exports, "useFocusTrap", { enumerable: true, get: function () { return useFocusTrap_1.useFocusTrap; } });
@@ -1,6 +0,0 @@
1
- /**
2
- * Мульти-контейнерный фокус-трап для highlight-шага.
3
- * @param nodes контейнеры
4
- * @param isActive включение трапа
5
- */
6
- export declare const useFocusTrap: (nodes: (HTMLElement | null)[], isActive?: boolean) => void;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useFocusTrap = void 0;
4
- const focus_trap_1 = require("focus-trap");
5
- const react_1 = require("react");
6
- /**
7
- * Мульти-контейнерный фокус-трап для highlight-шага.
8
- * @param nodes контейнеры
9
- * @param isActive включение трапа
10
- */
11
- const useFocusTrap = (nodes, isActive = true) => {
12
- (0, react_1.useEffect)(() => {
13
- const containers = nodes.filter((node) => node !== null);
14
- if (!isActive || containers.length === 0) {
15
- return;
16
- }
17
- const trap = (0, focus_trap_1.createFocusTrap)(containers, {
18
- escapeDeactivates: false,
19
- clickOutsideDeactivates: false,
20
- allowOutsideClick: true,
21
- returnFocusOnDeactivate: false,
22
- fallbackFocus: containers[0],
23
- initialFocus: () => containers[0],
24
- });
25
- try {
26
- trap.activate();
27
- }
28
- catch {
29
- // Нет фокусируемых узлов.
30
- return;
31
- }
32
- return () => {
33
- trap.deactivate();
34
- };
35
- }, [nodes, isActive]);
36
- };
37
- exports.useFocusTrap = useFocusTrap;