se-design 1.0.83-dev.4 → 1.0.83-dev.5

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.
@@ -1,4 +1,4 @@
1
- import { default as React, FC } from 'react';
1
+ import { default as React, FC, MutableRefObject, RefObject } from 'react';
2
2
  export interface CustomModalProps {
3
3
  onSubmit?: () => void;
4
4
  onClose?: () => void;
@@ -19,6 +19,12 @@ export interface CustomModalProps {
19
19
  * Ignored when `ariaLabelledBy` is provided.
20
20
  */
21
21
  ariaLabel?: string;
22
+ /**
23
+ * Additional container refs for elements outside the modal DOM that should
24
+ * remain focusable while the focus trap is active (e.g. a header bar above
25
+ * a full-page overlay). Forwarded to useFocusTrap's portalContainerRefs.
26
+ */
27
+ portalContainerRefs?: MutableRefObject<RefObject<HTMLElement | null>[]>;
22
28
  }
23
29
  /**
24
30
  * Modal container with built-in focus trap, Escape dismissal, and dialog semantics.
@@ -1,4 +1,4 @@
1
- import { default as React, FC } from 'react';
1
+ import { default as React } from 'react';
2
2
  export interface HeaderProps {
3
3
  leftContainer?: React.ReactNode;
4
4
  centerContainer?: React.ReactNode;
@@ -7,4 +7,4 @@ export interface HeaderProps {
7
7
  className?: string;
8
8
  id?: string;
9
9
  }
10
- export declare const Header: FC<HeaderProps>;
10
+ export declare const Header: React.ForwardRefExoticComponent<HeaderProps & React.RefAttributes<HTMLElement>>;
package/dist/index13.js CHANGED
@@ -1,54 +1,68 @@
1
- import i from "react";
1
+ import i, { useEffect as h } from "react";
2
2
  import "./index72.js";
3
- import { useModalA11y as b } from "./index207.js";
3
+ import { useModalA11y as y } from "./index207.js";
4
+ import { useFocusTrapPortalRegistry as R, FocusTrapPortalContext as w } from "./index208.js";
4
5
  /* empty css */
5
- function o() {
6
- return o = Object.assign ? Object.assign.bind() : function(n) {
6
+ function l() {
7
+ return l = Object.assign ? Object.assign.bind() : function(a) {
7
8
  for (var t = 1; t < arguments.length; t++) {
8
9
  var e = arguments[t];
9
- for (var a in e) ({}).hasOwnProperty.call(e, a) && (n[a] = e[a]);
10
+ for (var r in e) ({}).hasOwnProperty.call(e, r) && (a[r] = e[r]);
10
11
  }
11
- return n;
12
- }, o.apply(null, arguments);
12
+ return a;
13
+ }, l.apply(null, arguments);
13
14
  }
14
- const y = (n) => {
15
+ const O = (a) => {
15
16
  const {
16
17
  renderModalContent: t,
17
18
  isOpen: e,
18
- width: a = "500px",
19
- className: r = "",
20
- contentClassName: s = "",
21
- automationId: l = "",
22
- onModalClick: d = () => {
19
+ width: r = "500px",
20
+ className: c = "",
21
+ contentClassName: d = "",
22
+ automationId: m = "",
23
+ onModalClick: u = () => {
23
24
  },
24
- onClose: m,
25
- ariaLabel: c,
26
- ariaLabelledBy: u
27
- } = n, {
28
- containerRef: p,
29
- dialogProps: f
30
- } = b({
25
+ onClose: p,
26
+ ariaLabel: f,
27
+ ariaLabelledBy: g,
28
+ portalContainerRefs: n
29
+ } = a, {
30
+ register: o,
31
+ portalContainerRefs: v
32
+ } = R();
33
+ h(() => {
34
+ if (!n?.current) return;
35
+ const C = n.current.map((s) => o(s));
36
+ return () => C.forEach((s) => s());
37
+ }, [o, n]);
38
+ const {
39
+ containerRef: b,
40
+ dialogProps: x
41
+ } = y({
31
42
  isOpen: e,
32
- onDismiss: m,
33
- ariaLabel: c,
34
- ariaLabelledBy: u
43
+ onDismiss: p,
44
+ ariaLabel: f,
45
+ ariaLabelledBy: g,
46
+ portalContainerRefs: v
35
47
  });
36
- return /* @__PURE__ */ i.createElement("div", {
37
- className: `se-design-modal fixed inset-0 flex items-start justify-center z-[2001] backdrop-brightness-50 backdrop-blur-sm ${e ? "visible" : "invisible pointer-events-none"} ${r}`,
38
- "data-automation-id": l,
39
- onClick: d,
48
+ return /* @__PURE__ */ i.createElement(w.Provider, {
49
+ value: o
50
+ }, /* @__PURE__ */ i.createElement("div", {
51
+ className: `se-design-modal fixed inset-0 flex items-start justify-center z-[2001] backdrop-brightness-50 backdrop-blur-sm ${e ? "visible" : "invisible pointer-events-none"} ${c}`,
52
+ "data-automation-id": m,
53
+ onClick: u,
40
54
  "aria-hidden": e ? void 0 : !0
41
- }, /* @__PURE__ */ i.createElement("div", o({
42
- ref: p
43
- }, f, {
44
- className: `modal-content flex flex-col gap-3 bg-[var(--color-white)] rounded shadow-lg p-8 mt-[48px] ${s}`,
55
+ }, /* @__PURE__ */ i.createElement("div", l({
56
+ ref: b
57
+ }, x, {
58
+ className: `modal-content flex flex-col gap-3 bg-[var(--color-white)] rounded shadow-lg p-8 mt-[48px] ${d}`,
45
59
  style: {
46
- width: a,
60
+ width: r,
47
61
  maxWidth: "100vw"
48
62
  }
49
- }), t()));
63
+ }), t())));
50
64
  };
51
65
  export {
52
- y as CustomModal
66
+ O as CustomModal
53
67
  };
54
68
  //# sourceMappingURL=index13.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index13.js","sources":["../src/components/CustomModal/index.tsx"],"sourcesContent":["import React, { FC } from 'react';\nimport { useModalA11y } from 'src/utils/a11y';\nimport './style.scss';\n\nexport interface CustomModalProps {\n onSubmit?: () => void;\n onClose?: () => void;\n onModalClick?: () => void;\n renderModalContent: () => React.ReactNode;\n isOpen: boolean;\n width?: string;\n className?: string;\n contentClassName?: string;\n automationId?: string;\n /**\n * ID of a visible heading element rendered inside `renderModalContent`.\n * Add `id={ariaLabelledBy}` to that element to complete the association.\n */\n ariaLabelledBy?: string;\n /**\n * aria-label for modals without a visible title heading.\n * Ignored when `ariaLabelledBy` is provided.\n */\n ariaLabel?: string;\n}\n\n/**\n * Modal container with built-in focus trap, Escape dismissal, and dialog semantics.\n *\n * Labelling (pick one):\n * - `ariaLabelledBy` — ID of a heading rendered inside `renderModalContent`\n * - `ariaLabel` — for modals with no visible title\n *\n * Escape dismissal requires `onClose` to be passed.\n *\n * ---\n * ## Header + close button pattern (zoom-safe)\n *\n * If your modal has a title and a close button, use a flex row — NOT absolute positioning.\n * Absolute positioning causes the close icon to overlap the title at 200%/400% zoom.\n *\n * ✅ Correct:\n * ```tsx\n * renderModalContent={() => (\n * <>\n * <div className=\"modal-header\"> // display:flex; align-items:flex-start; justify-content:space-between; gap:12px\n * <h2 className=\"modal-title\">Title</h2> // flex:1 so it wraps without touching the icon\n * <Icon name=\"close\" onClick={onClose} ariaLabel=\"Close\" className=\"shrink-0\" />\n * </div>\n * <div className=\"modal-body\">...content...</div>\n * </>\n * )}\n * ```\n *\n * ❌ Avoid:\n * ```tsx\n * renderModalContent={() => (\n * <div style={{ position: 'relative' }}>\n * <h2>Title</h2>\n * <Icon name=\"close\" style={{ position: 'absolute', top: 8, right: 8 }} />\n * </div>\n * )}\n * ```\n */\nexport const CustomModal: FC<CustomModalProps> = (props) => {\n const {\n renderModalContent,\n isOpen,\n width = '500px',\n className = '',\n contentClassName = '',\n automationId = '',\n onModalClick = () => {},\n onClose,\n ariaLabel,\n ariaLabelledBy,\n } = props;\n\n const { containerRef, dialogProps } = useModalA11y({\n isOpen,\n onDismiss: onClose,\n ariaLabel,\n ariaLabelledBy,\n });\n\n return (\n <div\n className={`se-design-modal fixed inset-0 flex items-start justify-center z-[2001] backdrop-brightness-50 backdrop-blur-sm ${\n isOpen ? 'visible' : 'invisible pointer-events-none'\n } ${className}`}\n data-automation-id={automationId}\n onClick={onModalClick}\n aria-hidden={isOpen ? undefined : true}\n >\n <div\n ref={containerRef}\n {...dialogProps}\n className={`modal-content flex flex-col gap-3 bg-[var(--color-white)] rounded shadow-lg p-8 mt-[48px] ${contentClassName}`}\n style={{ width, maxWidth: '100vw' }}\n >\n {renderModalContent()}\n </div>\n </div>\n );\n};\n"],"names":["CustomModal","props","renderModalContent","isOpen","width","className","contentClassName","automationId","onModalClick","onClose","ariaLabel","ariaLabelledBy","containerRef","dialogProps","useModalA11y","onDismiss","React","createElement","onClick","undefined","_extends","ref","style","maxWidth"],"mappings":";;;;;;;;;;;;;AAgEO,MAAMA,IAAqCC,CAAAA,MAAU;AAC1D,QAAM;AAAA,IACJC,oBAAAA;AAAAA,IACAC,QAAAA;AAAAA,IACAC,OAAAA,IAAQ;AAAA,IACRC,WAAAA,IAAY;AAAA,IACZC,kBAAAA,IAAmB;AAAA,IACnBC,cAAAA,IAAe;AAAA,IACfC,cAAAA,IAAeA,MAAM;AAAA,IAAC;AAAA,IACtBC,SAAAA;AAAAA,IACAC,WAAAA;AAAAA,IACAC,gBAAAA;AAAAA,EAAAA,IACEV,GAEE;AAAA,IAAEW,cAAAA;AAAAA,IAAcC,aAAAA;AAAAA,EAAAA,IAAgBC,EAAa;AAAA,IACjDX,QAAAA;AAAAA,IACAY,WAAWN;AAAAA,IACXC,WAAAA;AAAAA,IACAC,gBAAAA;AAAAA,EAAAA,CACD;AAED,SACEK,gBAAAA,EAAAC,cAAA,OAAA;AAAA,IACEZ,WAAW,kHACTF,IAAS,YAAY,+BAA+B,IAClDE,CAAS;AAAA,IACb,sBAAoBE;AAAAA,IACpBW,SAASV;AAAAA,IACT,eAAaL,IAASgB,SAAY;AAAA,EAAA,GAElCH,gBAAAA,EAAAC,cAAA,OAAAG,EAAA;AAAA,IACEC,KAAKT;AAAAA,EAAAA,GACDC,GAAW;AAAA,IACfR,WAAW,6FAA6FC,CAAgB;AAAA,IACxHgB,OAAO;AAAA,MAAElB,OAAAA;AAAAA,MAAOmB,UAAU;AAAA,IAAA;AAAA,EAAQ,CAAE,GAEnCrB,EAAAA,CACE,CACF;AAET;"}
1
+ {"version":3,"file":"index13.js","sources":["../src/components/CustomModal/index.tsx"],"sourcesContent":["import React, { FC, useEffect } from 'react';\nimport type { MutableRefObject, RefObject } from 'react';\nimport { useModalA11y } from 'src/utils/a11y';\nimport { FocusTrapPortalContext, useFocusTrapPortalRegistry } from 'src/utils/a11y/FocusTrapPortalContext';\nimport './style.scss';\n\nexport interface CustomModalProps {\n onSubmit?: () => void;\n onClose?: () => void;\n onModalClick?: () => void;\n renderModalContent: () => React.ReactNode;\n isOpen: boolean;\n width?: string;\n className?: string;\n contentClassName?: string;\n automationId?: string;\n /**\n * ID of a visible heading element rendered inside `renderModalContent`.\n * Add `id={ariaLabelledBy}` to that element to complete the association.\n */\n ariaLabelledBy?: string;\n /**\n * aria-label for modals without a visible title heading.\n * Ignored when `ariaLabelledBy` is provided.\n */\n ariaLabel?: string;\n /**\n * Additional container refs for elements outside the modal DOM that should\n * remain focusable while the focus trap is active (e.g. a header bar above\n * a full-page overlay). Forwarded to useFocusTrap's portalContainerRefs.\n */\n portalContainerRefs?: MutableRefObject<RefObject<HTMLElement | null>[]>;\n}\n\n/**\n * Modal container with built-in focus trap, Escape dismissal, and dialog semantics.\n *\n * Labelling (pick one):\n * - `ariaLabelledBy` — ID of a heading rendered inside `renderModalContent`\n * - `ariaLabel` — for modals with no visible title\n *\n * Escape dismissal requires `onClose` to be passed.\n *\n * ---\n * ## Header + close button pattern (zoom-safe)\n *\n * If your modal has a title and a close button, use a flex row — NOT absolute positioning.\n * Absolute positioning causes the close icon to overlap the title at 200%/400% zoom.\n *\n * ✅ Correct:\n * ```tsx\n * renderModalContent={() => (\n * <>\n * <div className=\"modal-header\"> // display:flex; align-items:flex-start; justify-content:space-between; gap:12px\n * <h2 className=\"modal-title\">Title</h2> // flex:1 so it wraps without touching the icon\n * <Icon name=\"close\" onClick={onClose} ariaLabel=\"Close\" className=\"shrink-0\" />\n * </div>\n * <div className=\"modal-body\">...content...</div>\n * </>\n * )}\n * ```\n *\n * ❌ Avoid:\n * ```tsx\n * renderModalContent={() => (\n * <div style={{ position: 'relative' }}>\n * <h2>Title</h2>\n * <Icon name=\"close\" style={{ position: 'absolute', top: 8, right: 8 }} />\n * </div>\n * )}\n * ```\n */\nexport const CustomModal: FC<CustomModalProps> = (props) => {\n const {\n renderModalContent,\n isOpen,\n width = '500px',\n className = '',\n contentClassName = '',\n automationId = '',\n onModalClick = () => {},\n onClose,\n ariaLabel,\n ariaLabelledBy,\n portalContainerRefs,\n } = props;\n\n const { register, portalContainerRefs: registryRefs } = useFocusTrapPortalRegistry();\n\n // Append explicit portalContainerRefs (e.g. header ref) into the registry\n // so they're included alongside auto-registered portal refs from Popovers/Dropdowns.\n useEffect(() => {\n if (!portalContainerRefs?.current) return;\n const unregisters = portalContainerRefs.current.map((ref) => register(ref));\n return () => unregisters.forEach((unregister) => unregister());\n }, [register, portalContainerRefs]);\n\n const { containerRef, dialogProps } = useModalA11y({\n isOpen,\n onDismiss: onClose,\n ariaLabel,\n ariaLabelledBy,\n portalContainerRefs: registryRefs,\n });\n\n return (\n <FocusTrapPortalContext.Provider value={register}>\n <div\n className={`se-design-modal fixed inset-0 flex items-start justify-center z-[2001] backdrop-brightness-50 backdrop-blur-sm ${\n isOpen ? 'visible' : 'invisible pointer-events-none'\n } ${className}`}\n data-automation-id={automationId}\n onClick={onModalClick}\n aria-hidden={isOpen ? undefined : true}\n >\n <div\n ref={containerRef}\n {...dialogProps}\n className={`modal-content flex flex-col gap-3 bg-[var(--color-white)] rounded shadow-lg p-8 mt-[48px] ${contentClassName}`}\n style={{ width, maxWidth: '100vw' }}\n >\n {renderModalContent()}\n </div>\n </div>\n </FocusTrapPortalContext.Provider>\n );\n};\n"],"names":["CustomModal","props","renderModalContent","isOpen","width","className","contentClassName","automationId","onModalClick","onClose","ariaLabel","ariaLabelledBy","portalContainerRefs","register","registryRefs","useFocusTrapPortalRegistry","useEffect","current","unregisters","map","ref","forEach","unregister","containerRef","dialogProps","useModalA11y","onDismiss","React","createElement","FocusTrapPortalContext","Provider","value","onClick","undefined","_extends","style","maxWidth"],"mappings":";;;;;;;;;;;;;;AAwEO,MAAMA,IAAqCC,CAAAA,MAAU;AAC1D,QAAM;AAAA,IACJC,oBAAAA;AAAAA,IACAC,QAAAA;AAAAA,IACAC,OAAAA,IAAQ;AAAA,IACRC,WAAAA,IAAY;AAAA,IACZC,kBAAAA,IAAmB;AAAA,IACnBC,cAAAA,IAAe;AAAA,IACfC,cAAAA,IAAeA,MAAM;AAAA,IAAC;AAAA,IACtBC,SAAAA;AAAAA,IACAC,WAAAA;AAAAA,IACAC,gBAAAA;AAAAA,IACAC,qBAAAA;AAAAA,EAAAA,IACEX,GAEE;AAAA,IAAEY,UAAAA;AAAAA,IAAUD,qBAAqBE;AAAAA,EAAAA,IAAiBC,EAAAA;AAIxDC,EAAAA,EAAU,MAAM;AACd,QAAI,CAACJ,GAAqBK,QAAS;AACnC,UAAMC,IAAcN,EAAoBK,QAAQE,IAAKC,CAAAA,MAAQP,EAASO,CAAG,CAAC;AAC1E,WAAO,MAAMF,EAAYG,QAASC,CAAAA,MAAeA,GAAY;AAAA,EAC/D,GAAG,CAACT,GAAUD,CAAmB,CAAC;AAElC,QAAM;AAAA,IAAEW,cAAAA;AAAAA,IAAcC,aAAAA;AAAAA,EAAAA,IAAgBC,EAAa;AAAA,IACjDtB,QAAAA;AAAAA,IACAuB,WAAWjB;AAAAA,IACXC,WAAAA;AAAAA,IACAC,gBAAAA;AAAAA,IACAC,qBAAqBE;AAAAA,EAAAA,CACtB;AAED,SACEa,gBAAAA,EAAAC,cAACC,EAAuBC,UAAQ;AAAA,IAACC,OAAOlB;AAAAA,EAAAA,GACtCc,gBAAAA,EAAAC,cAAA,OAAA;AAAA,IACEvB,WAAW,kHACTF,IAAS,YAAY,+BAA+B,IAClDE,CAAS;AAAA,IACb,sBAAoBE;AAAAA,IACpByB,SAASxB;AAAAA,IACT,eAAaL,IAAS8B,SAAY;AAAA,EAAA,GAElCN,gBAAAA,EAAAC,cAAA,OAAAM,EAAA;AAAA,IACEd,KAAKG;AAAAA,EAAAA,GACDC,GAAW;AAAA,IACfnB,WAAW,6FAA6FC,CAAgB;AAAA,IACxH6B,OAAO;AAAA,MAAE/B,OAAAA;AAAAA,MAAOgC,UAAU;AAAA,IAAA;AAAA,EAAQ,CAAE,GAEnClC,EAAAA,CACE,CACF,CAC0B;AAErC;"}
package/dist/index19.js CHANGED
@@ -1,250 +1,265 @@
1
- import B, { forwardRef as we, useState as F, useRef as te, useEffect as M, useImperativeHandle as ge } from "react";
1
+ import B, { forwardRef as ge, useState as F, useRef as oe, useEffect as M, useImperativeHandle as we } from "react";
2
2
  import he from "react-dom";
3
3
  import { getA11yNameAttributes as be } from "./index81.js";
4
- import { useDismissOnFocusOut as ye } from "./index80.js";
5
- import { getFirstFocusableElement as D, getLastFocusableElement as Ee, getFocusableElements as N, FOCUSABLE_WITH_ROLES_SELECTOR as ke } from "./index71.js";
4
+ import { useDismissOnFocusOut as Ee } from "./index80.js";
5
+ import { getFirstFocusableElement as R, getLastFocusableElement as ye, getFocusableElements as T, FOCUSABLE_WITH_ROLES_SELECTOR as ke } from "./index71.js";
6
6
  import "./index72.js";
7
7
  import { useRegisterPortalWithFocusTrap as Pe } from "./index208.js";
8
- function T() {
9
- return T = Object.assign ? Object.assign.bind() : function(b) {
10
- for (var y = 1; y < arguments.length; y++) {
11
- var m = arguments[y];
8
+ function C() {
9
+ return C = Object.assign ? Object.assign.bind() : function(b) {
10
+ for (var E = 1; E < arguments.length; E++) {
11
+ var m = arguments[E];
12
12
  for (var h in m) ({}).hasOwnProperty.call(m, h) && (b[h] = m[h]);
13
13
  }
14
14
  return b;
15
- }, T.apply(null, arguments);
15
+ }, C.apply(null, arguments);
16
16
  }
17
- const He = /* @__PURE__ */ we(({
17
+ const Se = /* @__PURE__ */ ge(({
18
18
  className: b = "",
19
- automationId: y = "",
19
+ automationId: E = "",
20
20
  position: m = "bottom-center",
21
21
  popoverContentAutomationId: h = "",
22
- contentWidth: R = "max",
22
+ contentWidth: D = "max",
23
23
  renderPopoverContents: K,
24
- renderPopoverSrcElement: oe,
24
+ renderPopoverSrcElement: ne,
25
25
  onPopoverToggle: z,
26
- isPopoverOpen: C,
27
- disabled: E = !1,
26
+ isPopoverOpen: q,
27
+ disabled: y = !1,
28
28
  isWithPortal: f = !1,
29
- ariaLabel: ne,
30
- ariaLabelledBy: re,
31
- sourceRole: q = "button",
32
- popupType: _ = "true",
33
- popoverContentStyleProperty: $ = {
29
+ ariaLabel: re,
30
+ ariaLabelledBy: se,
31
+ sourceRole: _ = "button",
32
+ popupType: $ = "true",
33
+ popoverContentStyleProperty: U = {
34
34
  zIndex: 1e3,
35
35
  borderColor: "var(--color-gray-200)",
36
36
  color: "var(--color-gray-900)",
37
37
  backgroundColor: "var(--color-white)"
38
38
  },
39
- disableClickToggle: g = !1,
40
- noBorder: se = !1,
39
+ disableClickToggle: w = !1,
40
+ noBorder: ce = !1,
41
41
  disableAutoClose: v = !1,
42
- focusFirstOnOpen: ie = !1,
43
- ...ce
42
+ focusFirstOnOpen: O = !1,
43
+ ...ie
44
44
  }, ae) => {
45
- const [i, p] = F(!1), [k, U] = F(m), [le, V] = F(!1), l = te(null), c = te(null);
46
- Pe(c, f && i);
45
+ const [c, p] = F(!1), [k, V] = F(m), [le, X] = F(!1), l = oe(null), i = oe(null);
46
+ Pe(i, f && c);
47
47
  const ue = be({
48
- ariaLabel: ne,
49
- ariaLabelledBy: re,
48
+ ariaLabel: re,
49
+ ariaLabelledBy: se,
50
50
  ariaDescribedBy: void 0
51
51
  // Popover doesn't support describedBy yet
52
52
  }), {
53
53
  onBlurCapture: fe
54
- } = ye({
55
- disabled: !i || v || f,
54
+ } = Ee({
55
+ disabled: !c || v || f,
56
56
  onFocusOut: () => p(!1),
57
57
  closeOnEscape: !1
58
58
  }), [L, A] = F({
59
59
  top: 0,
60
60
  left: 0,
61
61
  srcWidth: 0
62
- }), [pe, W] = F(!1), P = () => {
63
- g ? (D({
62
+ }), [pe, j] = F(!1), P = () => {
63
+ w ? (R({
64
64
  container: l.current,
65
65
  includeRoles: !0
66
66
  }) ?? l.current)?.focus() : l.current?.focus();
67
- }, X = (e) => {
67
+ }, W = (e) => {
68
68
  p(!1), e?.returnFocus !== !1 && requestAnimationFrame(() => {
69
69
  e?.returnFocusTo ? (e.returnFocusTo instanceof HTMLElement ? e.returnFocusTo : e.returnFocusTo.current)?.focus() : P();
70
70
  });
71
- }, O = (e = "bottom-center") => {
71
+ }, H = (e = "bottom-center") => {
72
72
  if (!l.current) return {
73
73
  top: 0,
74
74
  left: 0,
75
75
  srcWidth: 0
76
76
  };
77
77
  let o = e;
78
- const t = l.current.getBoundingClientRect(), r = window.innerWidth - document.documentElement.clientWidth, u = window.innerWidth - Math.max(r, 16), a = window.innerHeight;
79
- let n = 0, s = 0;
78
+ const t = l.current.getBoundingClientRect(), n = window.innerWidth - document.documentElement.clientWidth, u = window.innerWidth - Math.max(n, 16), a = window.innerHeight;
79
+ let r = 0, s = 0;
80
80
  switch (o) {
81
81
  case "bottom-left":
82
- n = t.bottom, s = t.left;
82
+ r = t.bottom, s = t.left;
83
83
  break;
84
84
  case "bottom-right":
85
- n = t.bottom, s = t.right - t.width * 0.5;
85
+ r = t.bottom, s = t.right - t.width * 0.5;
86
86
  break;
87
87
  case "bottom-center":
88
- n = t.bottom, s = t.left + t.width / 2;
88
+ r = t.bottom, s = t.left + t.width / 2;
89
89
  break;
90
90
  case "top-left":
91
- n = t.top - t.height * 1.9, s = t.left;
91
+ r = t.top - t.height * 1.9, s = t.left;
92
92
  break;
93
93
  case "top-right":
94
- n = t.top - t.height * 1.9, s = t.right - t.width * 0.5;
94
+ r = t.top - t.height * 1.9, s = t.right - t.width * 0.5;
95
95
  break;
96
96
  case "top-center":
97
- n = t.top - t.height * 1.9, s = t.left + t.width / 2;
97
+ r = t.top - t.height * 1.9, s = t.left + t.width / 2;
98
98
  break;
99
99
  default:
100
- n = t.bottom, s = t.left;
100
+ r = t.bottom, s = t.left;
101
101
  break;
102
102
  }
103
- const d = c.current?.getBoundingClientRect(), x = (R === "full" ? Math.max(t.width, d?.width || 0) : d?.width) || 0, w = d?.height || 0;
104
- if ((o === "bottom-center" || o === "top-center") && (s = s - x / 2), s + x > u && (s = Math.max(0, u - x)), s < 0 && (s = 0), n + w > a) {
105
- const ee = t.top, ve = a - t.bottom;
106
- ee >= w || ee > ve ? (n = t.top - w, n < 48 && (n = 48)) : n = Math.max(48, a - w);
103
+ const d = i.current?.getBoundingClientRect(), x = (D === "full" ? Math.max(t.width, d?.width || 0) : d?.width) || 0, g = d?.height || 0;
104
+ if ((o === "bottom-center" || o === "top-center") && (s = s - x / 2), s + x > u && (s = Math.max(0, u - x)), s < 0 && (s = 0), r + g > a) {
105
+ const te = t.top, ve = a - t.bottom;
106
+ te >= g || te > ve ? (r = t.top - g, r < 48 && (r = 48)) : r = Math.max(48, a - g);
107
107
  }
108
- return n < 48 && (n = t.bottom, n + w > a && (n = Math.max(48, a - w))), {
109
- top: Math.round(n),
108
+ return r < 48 && (r = t.bottom, r + g > a && (r = Math.max(48, a - g))), {
109
+ top: Math.round(r),
110
110
  left: Math.round(s),
111
111
  srcWidth: t.width
112
112
  };
113
113
  };
114
114
  M(() => {
115
- if (z && z(i), i && !f)
116
- return v || document.body.addEventListener("click", j, !0), de(), () => {
117
- v || document.body.removeEventListener("click", j, !0);
115
+ if (z && z(c), c && !f)
116
+ return v || document.body.addEventListener("click", Y, !0), de(), () => {
117
+ v || document.body.removeEventListener("click", Y, !0);
118
118
  };
119
- if (i && f) {
120
- v ? window.addEventListener("scroll", G) : (document.body.addEventListener("click", I, !0), window.addEventListener("scroll", I)), window.addEventListener("resize", Y);
121
- const e = (r) => {
122
- r.key === "Escape" && c.current?.contains(document.activeElement) && (r.preventDefault(), r.stopPropagation(), p(!1), requestAnimationFrame(() => P()));
119
+ if (c && f) {
120
+ v ? window.addEventListener("scroll", J) : (document.body.addEventListener("click", I, !0), window.addEventListener("scroll", I)), window.addEventListener("resize", G);
121
+ const e = (n) => {
122
+ n.key === "Escape" && i.current?.contains(document.activeElement) && (n.preventDefault(), n.stopPropagation(), p(!1), requestAnimationFrame(() => P()));
123
123
  };
124
- window.addEventListener("keydown", e, !0), H();
124
+ window.addEventListener("keydown", e, !0), S();
125
125
  let o, t;
126
126
  return o = requestAnimationFrame(() => {
127
127
  t = requestAnimationFrame(() => {
128
- const r = O(k);
129
- r && A(r), W(!0);
128
+ const n = H(k);
129
+ n && A(n), j(!0);
130
130
  });
131
131
  }), () => {
132
- v ? window.removeEventListener("scroll", G) : (document.body.removeEventListener("click", I, !0), window.removeEventListener("scroll", I)), window.removeEventListener("resize", Y), window.removeEventListener("keydown", e, !0), cancelAnimationFrame(o), cancelAnimationFrame(t), W(!1);
132
+ v ? window.removeEventListener("scroll", J) : (document.body.removeEventListener("click", I, !0), window.removeEventListener("scroll", I)), window.removeEventListener("resize", G), window.removeEventListener("keydown", e, !0), cancelAnimationFrame(o), cancelAnimationFrame(t), j(!1);
133
133
  };
134
134
  }
135
- }, [i, f, v]);
136
- const H = () => {
135
+ }, [c, f, v]);
136
+ const S = () => {
137
137
  if (!l.current) {
138
- V(!1);
138
+ X(!1);
139
139
  return;
140
140
  }
141
- const e = l.current.getBoundingClientRect(), o = window.innerHeight, t = window.innerWidth, r = e.top < o && e.bottom > 0 && e.left < t && e.right > 0;
142
- V(r);
141
+ const e = l.current.getBoundingClientRect(), o = window.innerHeight, t = window.innerWidth, n = e.top < o && e.bottom > 0 && e.left < t && e.right > 0;
142
+ X(n);
143
143
  };
144
144
  M(() => {
145
- p(C ?? !1);
146
- }, [C]), M(() => {
147
- i && setTimeout(() => {
148
- const e = D({
149
- container: c.current,
145
+ p(q ?? !1);
146
+ }, [q]), M(() => {
147
+ c && setTimeout(() => {
148
+ const e = R({
149
+ container: i.current,
150
150
  includeRoles: !0
151
151
  });
152
- e && (ie || document.activeElement === l.current) && e.focus();
152
+ console.log("[Popover open] focus check:", {
153
+ hasFocusable: !!e,
154
+ focusFirstOnOpen: O,
155
+ isSrcFocused: document.activeElement === l.current,
156
+ activeEl: document.activeElement?.className?.slice(0, 50),
157
+ willFocus: !!(e && (O || document.activeElement === l.current)),
158
+ isWithPortal: f,
159
+ hasPortalContent: !!i.current
160
+ }), e && (O || document.activeElement === l.current) && e.focus();
153
161
  }, f ? 60 : 0);
154
- }, [i]);
162
+ }, [c]);
155
163
  const de = () => {
156
- if (!c.current) return;
157
- const e = c.current.getBoundingClientRect(), o = window.innerHeight;
158
- e?.bottom > o ? U(m.includes("left") ? "top-left" : m.includes("right") ? "top-right" : "top-center") : e?.top < 0 && U(m.includes("left") ? "bottom-left" : m.includes("right") ? "bottom-right" : "bottom-center");
159
- }, j = (e) => {
164
+ if (!i.current) return;
165
+ const e = i.current.getBoundingClientRect(), o = window.innerHeight;
166
+ e?.bottom > o ? V(m.includes("left") ? "top-left" : m.includes("right") ? "top-right" : "top-center") : e?.top < 0 && V(m.includes("left") ? "bottom-left" : m.includes("right") ? "bottom-right" : "bottom-center");
167
+ }, Y = (e) => {
160
168
  const o = l.current;
161
169
  if (!o) return;
162
- const t = e.target, r = o.contains(t), u = c.current?.contains(t), n = t.closest?.(".se-design-popover-wrapper"), s = n && n !== o, d = c.current?.contains(n);
163
- v || (!r && !u || s && !d) && p(!1);
170
+ const t = e.target, n = o.contains(t), u = i.current?.contains(t), r = t.closest?.(".se-design-popover-wrapper"), s = r && r !== o, d = i.current?.contains(r);
171
+ v || (!n && !u || s && !d) && p(!1);
164
172
  }, I = (e) => {
165
- const o = l.current, t = c.current;
173
+ const o = l.current, t = i.current;
166
174
  if (!o) return;
167
- if (H(), e.type === "scroll" && i) {
168
- const w = O(k);
169
- w && A(w);
175
+ if (S(), e.type === "scroll" && c) {
176
+ const g = H(k);
177
+ g && A(g);
170
178
  }
171
- const r = e.target, u = o.contains(r), a = t?.contains(r), s = r.closest?.(".se-design-popover-wrapper"), d = s && s !== o, x = c.current?.contains(s);
179
+ const n = e.target, u = o.contains(n), a = t?.contains(n), s = n.closest?.(".se-design-popover-wrapper"), d = s && s !== o, x = i.current?.contains(s);
172
180
  v || (!u && !a || d && !x) && p(!1);
173
- }, Y = () => {
174
- if (i && f && l.current) {
175
- H();
176
- const e = O(k);
181
+ }, G = () => {
182
+ if (c && f && l.current) {
183
+ S();
184
+ const e = H(k);
177
185
  e && A(e);
178
186
  }
179
- }, G = () => {
180
- if (i && f && l.current) {
181
- H();
182
- const e = O(k);
187
+ }, J = () => {
188
+ if (c && f && l.current) {
189
+ S();
190
+ const e = H(k);
183
191
  e && A(e);
184
192
  }
185
- }, S = (e = !1) => {
186
- const o = i;
193
+ }, N = (e = !1) => {
194
+ const o = c;
187
195
  p((t) => !t), !o && e && setTimeout(() => {
188
196
  if (e === "last") {
189
- const t = Ee({
190
- container: c.current,
197
+ const t = ye({
198
+ container: i.current,
191
199
  includeRoles: !0
192
200
  });
193
201
  t && t.focus();
194
202
  } else {
195
- const t = D({
196
- container: c.current,
203
+ const t = R({
204
+ container: i.current,
197
205
  includeRoles: !0
198
206
  });
199
207
  t && t.focus();
200
208
  }
201
209
  }, 50);
202
- }, J = (e, o) => {
210
+ }, Q = (e, o) => {
203
211
  if (!o) return;
204
212
  const t = document.activeElement;
205
213
  if (t?.tagName === "INPUT" || t?.tagName === "TEXTAREA" || t?.tagName === "SELECT")
206
214
  return;
207
- const r = Array.from(o.querySelectorAll(ke)).filter((n) => {
208
- const s = window.getComputedStyle(n);
209
- return !n.hasAttribute("disabled") && n.getAttribute("aria-disabled") !== "true" && s.display !== "none" && s.visibility !== "hidden" && (n.tabIndex >= 0 || n.hasAttribute("role"));
215
+ const n = Array.from(o.querySelectorAll(ke)).filter((r) => {
216
+ const s = window.getComputedStyle(r);
217
+ return !r.hasAttribute("disabled") && r.getAttribute("aria-disabled") !== "true" && s.display !== "none" && s.visibility !== "hidden" && (r.tabIndex >= 0 || r.hasAttribute("role"));
210
218
  });
211
- if (r.length === 0) return;
212
- const u = r.findIndex((n) => n === document.activeElement);
219
+ if (n.length === 0) return;
220
+ const u = n.findIndex((r) => r === document.activeElement);
213
221
  let a = -1;
214
- e.key === "ArrowDown" ? (e.preventDefault(), e.stopPropagation(), a = u < r.length - 1 ? u + 1 : 0) : e.key === "ArrowUp" ? (e.preventDefault(), e.stopPropagation(), a = u > 0 ? u - 1 : r.length - 1) : e.key === "Home" ? (e.preventDefault(), e.stopPropagation(), a = 0) : e.key === "End" && (e.preventDefault(), e.stopPropagation(), a = r.length - 1), a >= 0 && r[a] ? r[a].focus() : u === -1 && r.length > 0 && r[0].focus();
215
- }, Q = (e) => {
222
+ e.key === "ArrowDown" ? (e.preventDefault(), e.stopPropagation(), a = u < n.length - 1 ? u + 1 : 0) : e.key === "ArrowUp" ? (e.preventDefault(), e.stopPropagation(), a = u > 0 ? u - 1 : n.length - 1) : e.key === "Home" ? (e.preventDefault(), e.stopPropagation(), a = 0) : e.key === "End" && (e.preventDefault(), e.stopPropagation(), a = n.length - 1), console.log("[Popover] arrowNav:", {
223
+ focusableCount: n.length,
224
+ currentIndex: u,
225
+ nextIndex: a,
226
+ activeEl: document.activeElement?.tagName,
227
+ activeRole: document.activeElement?.getAttribute("role"),
228
+ firstEl: n[0]?.tagName + "." + n[0]?.className?.slice(0, 30)
229
+ }), a >= 0 && n[a] ? n[a].focus() : u === -1 && n.length > 0 && n[0].focus();
230
+ }, Z = (e) => {
216
231
  if (e.key === "Escape")
217
232
  e.preventDefault(), e.stopPropagation(), p(!1), requestAnimationFrame(() => P());
218
233
  else if (e.key === "Tab") {
219
- if (_ === "dialog") {
220
- const o = N({
221
- container: c.current,
234
+ if ($ === "dialog") {
235
+ const o = T({
236
+ container: i.current,
222
237
  filterHidden: !0
223
- }), t = o.indexOf(e.target), r = t === o.length - 1, u = t === 0 || t === -1;
238
+ }), t = o.indexOf(e.target), n = t === o.length - 1, u = t === 0 || t === -1;
224
239
  if (e.shiftKey && u)
225
240
  e.preventDefault(), p(!1), P();
226
- else if (!e.shiftKey && r && (p(!1), f)) {
241
+ else if (!e.shiftKey && n && (p(!1), f)) {
227
242
  e.preventDefault();
228
- const a = l.current, n = N({
243
+ const a = l.current, r = T({
229
244
  container: document.body,
230
245
  filterHidden: !0
231
- }), s = a ? n.indexOf(a) : -1, d = n[s + 1];
246
+ }), s = a ? r.indexOf(a) : -1, d = r[s + 1];
232
247
  d ? d.focus() : a?.focus();
233
248
  }
234
249
  } else if (p(!1), e.shiftKey)
235
250
  e.preventDefault(), P();
236
251
  else if (f) {
237
252
  e.preventDefault();
238
- const o = l.current, t = N({
253
+ const o = l.current, t = T({
239
254
  container: document.body,
240
255
  filterHidden: !0
241
- }), r = o ? t.indexOf(o) : -1, u = t[r + 1];
256
+ }), n = o ? t.indexOf(o) : -1, u = t[n + 1];
242
257
  u ? u.focus() : o?.focus();
243
258
  }
244
- } else e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "Home" || e.key === "End" ? J(e, c.current) : (e.key === "Enter" || e.key === " ") && e.stopPropagation();
259
+ } else e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "Home" || e.key === "End" ? Q(e, i.current) : (e.key === "Enter" || e.key === " ") && e.stopPropagation();
245
260
  };
246
- ge(ae, () => ({
247
- togglePopover: S,
261
+ we(ae, () => ({
262
+ togglePopover: N,
248
263
  focusTrigger: () => l.current?.focus(),
249
264
  element: l.current
250
265
  }), []);
@@ -275,33 +290,36 @@ const He = /* @__PURE__ */ we(({
275
290
  transform: "translateX(-50%)",
276
291
  bottom: "100%"
277
292
  }
278
- }, Z = se ? "" : "shadow-md border rounded-md";
279
- return /* @__PURE__ */ B.createElement("div", T({
280
- className: "se-design-popover-wrapper cursor-pointer relative focus-outline rounded-md" + (b.length > 0 ? ` ${b}` : "") + (i ? " open" : "") + (E ? " opacity-50 cursor-not-allowed pointer-events-none" : ""),
293
+ }, ee = ce ? "" : "shadow-md border rounded-md";
294
+ return /* @__PURE__ */ B.createElement("div", C({
295
+ className: "se-design-popover-wrapper cursor-pointer relative focus-outline rounded-md" + (b.length > 0 ? ` ${b}` : "") + (c ? " open" : "") + (y ? " opacity-50 cursor-not-allowed pointer-events-none" : ""),
281
296
  ref: l,
282
297
  onClick: (e) => {
283
- E || g || (e.stopPropagation(), S());
298
+ y || w || (e.stopPropagation(), N());
284
299
  },
285
300
  onKeyDown: (e) => {
286
- if (!(E || g))
301
+ if (!(y || w))
287
302
  if (e.key === "Enter" || e.key === " ") {
288
303
  e.preventDefault(), e.stopPropagation();
289
- const o = i;
290
- S(), o || setTimeout(() => {
291
- const t = D({
292
- container: c.current,
304
+ const o = c;
305
+ N(), o || setTimeout(() => {
306
+ const t = R({
307
+ container: i.current,
293
308
  includeRoles: !0
294
309
  });
295
310
  t && t.focus();
296
311
  }, f ? 60 : 0);
297
- } else if (e.key === "Escape" && i)
312
+ } else if (e.key === "Escape" && c)
298
313
  e.preventDefault(), e.stopPropagation(), p(!1);
299
- else if ((e.key === "ArrowDown" || e.key === "ArrowUp") && i) {
300
- const o = c.current;
301
- o && J(e, o);
302
- } else e.key === "ArrowDown" && !i && (e.preventDefault(), e.stopPropagation(), p(!0), setTimeout(() => {
303
- const o = D({
304
- container: c.current,
314
+ else if ((e.key === "ArrowDown" || e.key === "ArrowUp") && c) {
315
+ const o = i.current;
316
+ console.log("[Popover] arrow on wrapper:", {
317
+ key: e.key,
318
+ hasRef: !!o
319
+ }), o && Q(e, o);
320
+ } else e.key === "ArrowDown" && !c && (e.preventDefault(), e.stopPropagation(), p(!0), setTimeout(() => {
321
+ const o = R({
322
+ container: i.current,
305
323
  includeRoles: !0
306
324
  });
307
325
  o && o.focus();
@@ -309,34 +327,34 @@ const He = /* @__PURE__ */ we(({
309
327
  },
310
328
  onBlurCapture: fe,
311
329
  onBlur: (e) => {
312
- if (!i || v || !f) return;
313
- const o = e.relatedTarget, t = !!(o && l.current?.contains(o)), r = !!(o && c.current?.contains(o));
314
- !t && !r && p(!1);
330
+ if (!c || v || !f) return;
331
+ const o = e.relatedTarget, t = !!(o && l.current?.contains(o)), n = !!(o && i.current?.contains(o));
332
+ !t && !n && p(!1);
315
333
  },
316
- role: g ? "none" : q,
317
- "aria-expanded": g ? void 0 : i ? "true" : "false",
318
- "aria-haspopup": g ? void 0 : q === "combobox" ? "listbox" : _,
319
- tabIndex: E || g ? -1 : 0,
320
- "aria-disabled": g ? void 0 : E ? "true" : void 0
334
+ role: w ? "none" : _,
335
+ "aria-expanded": w ? void 0 : c ? "true" : "false",
336
+ "aria-haspopup": w ? void 0 : _ === "combobox" ? "listbox" : $,
337
+ tabIndex: y || w ? -1 : 0,
338
+ "aria-disabled": w ? void 0 : y ? "true" : void 0
321
339
  }, ue, {
322
- "data-automation-id": y
323
- }, ce), oe({
324
- displayPopover: i,
325
- togglePopover: S
326
- }), i && !f && /* @__PURE__ */ B.createElement("div", {
327
- className: `popover-content absolute ${Z} z-[1000] ${R == "full" ? "w-full" : "w-max"}`,
340
+ "data-automation-id": E
341
+ }, ie), ne({
342
+ displayPopover: c,
343
+ togglePopover: N
344
+ }), c && !f && /* @__PURE__ */ B.createElement("div", {
345
+ className: `popover-content absolute ${ee} z-[1000] ${D == "full" ? "w-full" : "w-max"}`,
328
346
  style: {
329
- ...$,
347
+ ...U,
330
348
  ...me[k]
331
349
  },
332
350
  onClick: (e) => e.stopPropagation(),
333
- onKeyDown: Q,
334
- ref: c,
351
+ onKeyDown: Z,
352
+ ref: i,
335
353
  "data-automation-id": h
336
354
  }, K({
337
- closePopoverCb: X
338
- })), f && i && le && /* @__PURE__ */ he.createPortal(/* @__PURE__ */ B.createElement("div", {
339
- className: `popover-content-with-portal z-[2002] ${Z} ${R == "full" ? "" : "w-max"}`,
355
+ closePopoverCb: W
356
+ })), f && c && le && /* @__PURE__ */ he.createPortal(/* @__PURE__ */ B.createElement("div", {
357
+ className: `popover-content-with-portal z-[2002] ${ee} ${D == "full" ? "" : "w-max"}`,
340
358
  style: {
341
359
  position: "fixed",
342
360
  top: L.top,
@@ -344,21 +362,21 @@ const He = /* @__PURE__ */ we(({
344
362
  visibility: pe ? "visible" : "hidden",
345
363
  maxHeight: "calc(100vh - 96px)",
346
364
  overflowY: "hidden",
347
- ...R === "full" && L.srcWidth ? {
365
+ ...D === "full" && L.srcWidth ? {
348
366
  width: `${L.srcWidth}px`
349
367
  } : {},
350
- ...$,
368
+ ...U,
351
369
  zIndex: 2002
352
370
  },
353
371
  onClick: (e) => e.stopPropagation(),
354
- onKeyDown: Q,
355
- ref: c,
372
+ onKeyDown: Z,
373
+ ref: i,
356
374
  "data-automation-id": h
357
375
  }, K({
358
- closePopoverCb: X
376
+ closePopoverCb: W
359
377
  })), document.body));
360
378
  });
361
379
  export {
362
- He as Popover
380
+ Se as Popover
363
381
  };
364
382
  //# sourceMappingURL=index19.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index19.js","sources":["../src/components/Popover/index.tsx"],"sourcesContent":["import React, { useState, useRef, ReactNode, useEffect, forwardRef, ForwardedRef, useImperativeHandle } from 'react';\nimport ReactDOM from 'react-dom';\nimport {\n getA11yNameAttributes,\n useDismissOnFocusOut,\n FOCUSABLE_WITH_ROLES_SELECTOR,\n getFocusableElements,\n getFirstFocusableElement,\n getLastFocusableElement\n} from '../../utils/a11y';\nimport { useRegisterPortalWithFocusTrap } from '../../utils/a11y/FocusTrapPortalContext';\n\nexport interface PopoverHandle {\n togglePopover: (focusFirst?: boolean | 'last') => void;\n /** Focus the popover source/trigger element. */\n focusTrigger: () => void;\n /** The wrapper element that acts as the popover trigger. Stable DOM node with tabIndex=0. */\n element: HTMLElement | null;\n}\n\nexport interface PopoverProps {\n className?: string;\n automationId?: string;\n popoverContentAutomationId?: string;\n renderPopoverContents: (props: { closePopoverCb: (options?: { returnFocus?: boolean; returnFocusTo?: HTMLElement | React.RefObject<HTMLElement> }) => void }) => ReactNode;\n renderPopoverSrcElement: (props: { displayPopover: boolean; togglePopover: (focusFirst?: boolean | 'last') => void }) => ReactNode;\n position?: 'bottom-center' | 'bottom-left' | 'bottom-right' | 'top-center' | 'top-left' | 'top-right';\n onPopoverToggle?: (displayPopover: boolean) => void;\n contentWidth?: 'full' | 'max';\n isPopoverOpen?: boolean;\n disabled?: boolean;\n isWithPortal?: boolean;\n noBorder?: boolean;\n ariaLabel?: string;\n ariaLabelledBy?: string;\n sourceRole?: 'button' | 'combobox';\n popupType?: 'menu' | 'listbox' | 'dialog' | 'true';\n popoverContentStyleProperty?: React.CSSProperties;\n disableClickToggle?: boolean;\n disableAutoClose?: boolean;\n /** Focus the first focusable element when the popover opens via isPopoverOpen (external state). */\n focusFirstOnOpen?: boolean;\n}\n\nexport const Popover = forwardRef<PopoverHandle, PopoverProps>(\n (\n {\n className = '',\n automationId = '',\n position = 'bottom-center',\n popoverContentAutomationId = '',\n contentWidth = 'max',\n renderPopoverContents,\n renderPopoverSrcElement,\n onPopoverToggle,\n isPopoverOpen,\n disabled = false,\n isWithPortal = false,\n ariaLabel,\n ariaLabelledBy,\n sourceRole = 'button',\n popupType = 'true',\n popoverContentStyleProperty = {\n zIndex: 1000,\n borderColor: 'var(--color-gray-200)',\n color: 'var(--color-gray-900)',\n backgroundColor: 'var(--color-white)'\n },\n disableClickToggle = false,\n noBorder = false,\n disableAutoClose = false,\n focusFirstOnOpen = false,\n ...props\n },\n ref: ForwardedRef<PopoverHandle>\n ) => {\n const [displayPopover, setDisplayPopover] = useState(false);\n const [popoverPosition, setPopoverPosition] = useState(position);\n const [isSrcElementVisible, setIsSrcElementVisible] = useState(false);\n const srcElementRef = useRef<HTMLDivElement>(null);\n const popoverContentRef = useRef<HTMLDivElement>(null);\n\n // Register portal content with the nearest ancestor focus trap (e.g., Modal)\n // so the focus trap's safety net allows focus to move into portal content.\n useRegisterPortalWithFocusTrap(popoverContentRef, isWithPortal && displayPopover);\n\n // Compute accessible name/description props with correct precedence\n const accessibleNameProps = getA11yNameAttributes({\n ariaLabel,\n ariaLabelledBy,\n ariaDescribedBy: undefined // Popover doesn't support describedBy yet\n });\n\n // Use shared focus-out dismissal for non-portal popovers.\n // Portal content lives outside the wrapper, so portal uses a dedicated onBlur fallback below.\n const { onBlurCapture: onDismissBlurCapture } = useDismissOnFocusOut<HTMLDivElement>({\n disabled: !displayPopover || disableAutoClose || isWithPortal,\n onFocusOut: () => setDisplayPopover(false),\n closeOnEscape: false\n });\n\n const [portalPosition, setPortalPosition] = useState({ top: 0, left: 0, srcWidth: 0 });\n const [isPortalMeasured, setIsPortalMeasured] = useState(false);\n\n // Focus the actual trigger element on popover close.\n // When disableClickToggle=true the wrapper is role=\"none\"/tabIndex=-1 — focus the\n // first focusable child (the inner Button/Icon) instead.\n const focusTriggerElement = () => {\n if (disableClickToggle) {\n const inner = getFirstFocusableElement({ container: srcElementRef.current, includeRoles: true });\n (inner ?? srcElementRef.current)?.focus();\n } else {\n srcElementRef.current?.focus();\n }\n };\n\n const closePopover = (options?: { returnFocus?: boolean; returnFocusTo?: HTMLElement | React.RefObject<HTMLElement> }) => {\n setDisplayPopover(false);\n if (options?.returnFocus !== false) {\n requestAnimationFrame(() => {\n if (options?.returnFocusTo) {\n const target = options.returnFocusTo instanceof HTMLElement\n ? options.returnFocusTo\n : options.returnFocusTo.current;\n target?.focus();\n } else {\n focusTriggerElement();\n }\n });\n }\n };\n\n const calculatePositionOfPopover = (position: string = 'bottom-center') => {\n if (!srcElementRef.current) return { top: 0, left: 0, srcWidth: 0 };\n\n let localPosition = position;\n\n const srcRect = srcElementRef.current.getBoundingClientRect();\n // Subtract scrollbar width so portal content doesn't render behind a scrollbar.\n // document.documentElement.clientWidth excludes any visible scrollbar;\n // fall back to a 16px buffer (max scrollbar width across OS/browsers) when\n // body overflow is hidden and the scrollbar belongs to a nested container.\n const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;\n const viewportWidth = window.innerWidth - Math.max(scrollbarWidth, 16);\n const viewportHeight = window.innerHeight;\n\n // Calculate position for portal\n let top = 0;\n let left = 0;\n\n switch (localPosition) {\n case 'bottom-left':\n top = srcRect.bottom;\n left = srcRect.left;\n break;\n case 'bottom-right':\n top = srcRect.bottom;\n left = srcRect.right - srcRect.width * 0.5;\n break;\n case 'bottom-center':\n top = srcRect.bottom;\n // Center the popover relative to the source element\n left = srcRect.left + srcRect.width / 2;\n break;\n case 'top-left':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.left;\n break;\n case 'top-right':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.right - srcRect.width * 0.5;\n break;\n case 'top-center':\n top = srcRect.top - srcRect.height * 1.9;\n // Center the popover relative to the source element\n left = srcRect.left + srcRect.width / 2;\n break;\n default:\n top = srcRect.bottom;\n left = srcRect.left;\n break;\n }\n\n // Get popover dimensions if available\n const popoverRect = popoverContentRef.current?.getBoundingClientRect();\n // When contentWidth='full', the panel will be sized to srcRect.width after measurement.\n // Use srcRect.width directly so centering and viewport clamping use the correct final width.\n const popoverWidth = (contentWidth === 'full' ? Math.max(srcRect.width, popoverRect?.width || 0) : popoverRect?.width) || 0;\n const popoverHeight = popoverRect?.height || 0;\n\n // Adjust center positions to account for popover width\n if (localPosition === 'bottom-center' || localPosition === 'top-center') {\n // Center the popover by subtracting half its width from the source center\n left = left - popoverWidth / 2;\n }\n\n // Adjust position to keep popover within viewport bounds\n // Horizontal adjustments\n if (left + popoverWidth > viewportWidth) {\n // Popover extends beyond right edge, shift it left\n left = Math.max(0, viewportWidth - popoverWidth);\n }\n if (left < 0) {\n // Popover extends beyond left edge, shift it right\n left = 0;\n }\n\n // Vertical adjustments\n if (top + popoverHeight > viewportHeight) {\n // Popover extends beyond bottom edge\n // Try to position it above the source element\n const spaceAbove = srcRect.top;\n const spaceBelow = viewportHeight - srcRect.bottom;\n\n if (spaceAbove >= popoverHeight || spaceAbove > spaceBelow) {\n // Position above if there's enough space or more space above\n top = srcRect.top - popoverHeight;\n // Ensure it doesn't go above the topbar (48px fixed header)\n if (top < 48) {\n top = 48;\n }\n } else {\n // Keep at bottom but adjust to fit within viewport\n top = Math.max(48, viewportHeight - popoverHeight);\n }\n }\n if (top < 48) {\n // Popover extends beyond top edge, position it below the source element\n top = srcRect.bottom;\n // Ensure it doesn't go below viewport\n if (top + popoverHeight > viewportHeight) {\n top = Math.max(48, viewportHeight - popoverHeight);\n }\n }\n\n return { top: Math.round(top), left: Math.round(left), srcWidth: srcRect.width };\n };\n\n useEffect(() => {\n if (onPopoverToggle) {\n onPopoverToggle(displayPopover);\n }\n\n if (displayPopover && !isWithPortal) {\n // Add click listener for auto-close behavior only if not disabled\n if (!disableAutoClose) {\n document.body.addEventListener('click', clickListener, true);\n }\n checkPopoverPosition();\n return () => {\n if (!disableAutoClose) {\n document.body.removeEventListener('click', clickListener, true);\n }\n };\n } else if (displayPopover && isWithPortal) {\n // Add click/scroll listeners for auto-close behavior only if not disabled\n if (!disableAutoClose) {\n document.body.addEventListener('click', clickAndScrollListenerWithPortal, true);\n window.addEventListener('scroll', clickAndScrollListenerWithPortal);\n } else {\n // When disableAutoClose is true, still listen to scroll for repositioning\n window.addEventListener('scroll', scrollListenerForRepositioning);\n }\n // Always add resize listener for repositioning\n window.addEventListener('resize', resizeListenerWithPortal);\n\n // Escape on window capture phase — must fire before document-capture listeners\n // (e.g. useDismissOnEscape in Modal) so Escape closes the portal Dropdown without\n // also dismissing the modal behind it.\n const escapeHandler = (e: KeyboardEvent) => {\n if (e.key !== 'Escape') return;\n if (!popoverContentRef.current?.contains(document.activeElement)) return;\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n requestAnimationFrame(() => focusTriggerElement());\n };\n window.addEventListener('keydown', escapeHandler, true);\n\n // Trigger source visibility check immediately\n checkSourceVisibility();\n\n // Use double-rAF to measure portal after browser has completed layout,\n // guaranteeing real dimensions are available for flip/clamp calculations.\n // Portal is hidden via visibility:hidden until this completes (no flash).\n let rafId1: number;\n let rafId2: number;\n rafId1 = requestAnimationFrame(() => {\n rafId2 = requestAnimationFrame(() => {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n setIsPortalMeasured(true);\n });\n });\n\n return () => {\n if (!disableAutoClose) {\n document.body.removeEventListener('click', clickAndScrollListenerWithPortal, true);\n window.removeEventListener('scroll', clickAndScrollListenerWithPortal);\n } else {\n window.removeEventListener('scroll', scrollListenerForRepositioning);\n }\n window.removeEventListener('resize', resizeListenerWithPortal);\n window.removeEventListener('keydown', escapeHandler, true);\n cancelAnimationFrame(rafId1);\n cancelAnimationFrame(rafId2);\n setIsPortalMeasured(false);\n };\n }\n }, [displayPopover, isWithPortal, disableAutoClose]);\n\n const checkSourceVisibility = () => {\n if (!srcElementRef.current) {\n setIsSrcElementVisible(false);\n return;\n }\n\n const rec = srcElementRef.current.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n const viewportWidth = window.innerWidth;\n\n const isVisible = rec.top < viewportHeight && rec.bottom > 0 && rec.left < viewportWidth && rec.right > 0;\n\n setIsSrcElementVisible(isVisible);\n };\n\n useEffect(() => {\n setDisplayPopover(isPopoverOpen ?? false);\n }, [isPopoverOpen]);\n\n useEffect(() => {\n // Focus first focusable element when popover opens.\n // For portal, delay longer so isSrcElementVisible can be set and portal can mount first.\n if (displayPopover) {\n setTimeout(() => {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable && (focusFirstOnOpen || document.activeElement === srcElementRef.current)) {\n firstFocusable.focus();\n }\n }, isWithPortal ? 60 : 0);\n }\n }, [displayPopover]);\n\n //Function to check popover position\n const checkPopoverPosition = () => {\n if (!popoverContentRef.current) return;\n\n const popoverRect = popoverContentRef.current.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n\n if (popoverRect?.bottom > viewportHeight) {\n setPopoverPosition(\n position.includes('left') ? 'top-left' : position.includes('right') ? 'top-right' : 'top-center'\n );\n } else if (popoverRect?.top < 0) {\n // If popover extends beyond top of viewport, switch to bottom position\n setPopoverPosition(\n position.includes('left') ? 'bottom-left' : position.includes('right') ? 'bottom-right' : 'bottom-center'\n );\n }\n };\n\n const clickListener = (event: MouseEvent) => {\n const currentDropRef = srcElementRef.current;\n if (!currentDropRef) return;\n\n const target = event.target as Node;\n const isSourcePopover = currentDropRef.contains(target);\n const isPopoverContent = popoverContentRef.current?.contains(target);\n\n // Check if click is on another popover's source element\n const clickedElement = target as HTMLElement;\n const closestPopoverWrapper = clickedElement.closest?.('.se-design-popover-wrapper');\n const isAnotherPopoverSource = closestPopoverWrapper && closestPopoverWrapper !== currentDropRef;\n\n // check if the clicked popover is a nesteded child of the current popover content\n const isNestedPopover = popoverContentRef.current?.contains(closestPopoverWrapper as Node);\n\n // if clicked source is parent or the popover-content, do not toggle dropdown.\n // Also close if clicking on another popover's source element\n if (disableAutoClose) return;\n if ((!isSourcePopover && !isPopoverContent) || (isAnotherPopoverSource && !isNestedPopover)) {\n setDisplayPopover(false);\n }\n };\n\n const clickAndScrollListenerWithPortal = (event: Event) => {\n const currentDropRef = srcElementRef.current;\n const currentPopoverRef = popoverContentRef.current;\n if (!currentDropRef) return;\n checkSourceVisibility();\n\n // Recalculate position on scroll\n if (event.type === 'scroll' && displayPopover) {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n\n const target = event.target as Node;\n const isSourcePopover = currentDropRef.contains(target);\n const isPopoverContent = currentPopoverRef?.contains(target);\n\n // Check if click is on another popover's source element\n const clickedElement = target as HTMLElement;\n const closestPopoverWrapper = clickedElement.closest?.('.se-design-popover-wrapper');\n const isAnotherPopoverSource = closestPopoverWrapper && closestPopoverWrapper !== currentDropRef;\n\n // check if the clicked popover is a nesteded child of the current popover content\n const isNestedPopover = popoverContentRef.current?.contains(closestPopoverWrapper as Node);\n\n if (disableAutoClose) return;\n // if clicked source is parent or the popover-content, do not toggle dropdown.\n // Also close if clicking on another popover's source element\n if ((!isSourcePopover && !isPopoverContent) || (isAnotherPopoverSource && !isNestedPopover)) {\n setDisplayPopover(false);\n }\n };\n\n const resizeListenerWithPortal = () => {\n if (displayPopover && isWithPortal && srcElementRef.current) {\n checkSourceVisibility();\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n };\n\n const scrollListenerForRepositioning = () => {\n if (displayPopover && isWithPortal && srcElementRef.current) {\n checkSourceVisibility();\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n };\n\n const togglePopover = (focusFirst: boolean | 'last' = false) => {\n const wasOpen = displayPopover;\n setDisplayPopover((prev) => !prev);\n if (!wasOpen && focusFirst) {\n setTimeout(() => {\n if (focusFirst === 'last') {\n const lastFocusable = getLastFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (lastFocusable) lastFocusable.focus();\n } else {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable) firstFocusable.focus();\n }\n }, 50);\n }\n };\n\n const handleArrowKeyNavigation = (e: React.KeyboardEvent, container: HTMLDivElement | null) => {\n if (!container) return;\n\n // Native form controls own their arrow key behavior — don't intercept.\n // (e.g. a SearchBox inside a Popover should keep focus while typing/navigating)\n const activeEl = document.activeElement;\n if (activeEl?.tagName === 'INPUT' || activeEl?.tagName === 'TEXTAREA' || activeEl?.tagName === 'SELECT') {\n return;\n }\n\n const focusableElements = Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE_WITH_ROLES_SELECTOR)).filter((el) => {\n // Filter out disabled and hidden elements.\n // Note: check aria-disabled VALUE not just presence — React always writes aria-disabled=\"false\"\n // on elements like MenuItem even when not disabled, so hasAttribute would wrongly exclude them.\n const style = window.getComputedStyle(el);\n return (\n !el.hasAttribute('disabled') &&\n el.getAttribute('aria-disabled') !== 'true' &&\n style.display !== 'none' &&\n style.visibility !== 'hidden' &&\n (el.tabIndex >= 0 || el.hasAttribute('role'))\n );\n });\n\n if (focusableElements.length === 0) return;\n\n const currentIndex = focusableElements.findIndex((el) => el === document.activeElement);\n let nextIndex = -1;\n\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = currentIndex < focusableElements.length - 1 ? currentIndex + 1 : 0;\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = currentIndex > 0 ? currentIndex - 1 : focusableElements.length - 1;\n } else if (e.key === 'Home') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = 0;\n } else if (e.key === 'End') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = focusableElements.length - 1;\n }\n\n if (nextIndex >= 0 && focusableElements[nextIndex]) {\n focusableElements[nextIndex].focus();\n } else if (currentIndex === -1 && focusableElements.length > 0) {\n // If no element is currently focused, focus the first one\n focusableElements[0].focus();\n }\n };\n\n const handlePopoverContentKeyDown = (e: React.KeyboardEvent) => {\n // Allow Escape key to close popover when focus is on content\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n // Defer focus restoration to after React re-renders and portal unmounts.\n // Synchronous focus() during the event can be displaced by the portal\n // teardown in some browsers, especially when isWithPortal=true.\n requestAnimationFrame(() => focusTriggerElement());\n } else if (e.key === 'Tab') {\n if (popupType === 'dialog') {\n // Dialog popovers: let Tab flow naturally within the content.\n // Only close when focus would actually leave the popover.\n const focusables = getFocusableElements({ container: popoverContentRef.current, filterHidden: true });\n const currentIndex = focusables.indexOf(e.target as HTMLElement);\n const isOnLast = currentIndex === focusables.length - 1;\n const isOnFirst = currentIndex === 0 || currentIndex === -1;\n\n if (e.shiftKey && isOnFirst) {\n // Shift+Tab past first element — close and return focus to trigger\n e.preventDefault();\n setDisplayPopover(false);\n focusTriggerElement();\n } else if (!e.shiftKey && isOnLast) {\n // Tab past last element — close popover\n setDisplayPopover(false);\n if (isWithPortal) {\n e.preventDefault();\n const srcEl = srcElementRef.current;\n const allFocusables = getFocusableElements({ container: document.body, filterHidden: true });\n const idx = srcEl ? allFocusables.indexOf(srcEl) : -1;\n const next = allFocusables[idx + 1];\n if (next) next.focus();\n else srcEl?.focus();\n }\n }\n // Otherwise: let browser handle Tab naturally within the popover content\n } else {\n // Non-dialog: close popover when Tab exits the menu\n setDisplayPopover(false);\n if (e.shiftKey) {\n // Shift+Tab: prevent default (would go to wrapper) and focus trigger instead\n e.preventDefault();\n focusTriggerElement();\n } else if (isWithPortal) {\n // Portal forward Tab: portal content is at document.body so natural Tab order\n // skips back to the top of the page. Manually advance to the next focusable\n // element after the trigger in the main document instead.\n e.preventDefault();\n const srcEl = srcElementRef.current;\n const focusables = getFocusableElements({ container: document.body, filterHidden: true });\n const idx = srcEl ? focusables.indexOf(srcEl) : -1;\n const next = focusables[idx + 1];\n if (next) next.focus();\n else srcEl?.focus();\n }\n // Non-portal forward Tab: do NOT preventDefault — browser moves focus to next element naturally\n }\n } else if (e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === 'Home' || e.key === 'End') {\n // Handle arrow key navigation for focusable elements inside popover\n handleArrowKeyNavigation(e, popoverContentRef.current);\n } else if (e.key === 'Enter' || e.key === ' ') {\n // Prevent Enter/Space from bubbling to wrapper (mirrors click stopPropagation)\n e.stopPropagation();\n }\n };\n\n useImperativeHandle(ref, () => ({ togglePopover, focusTrigger: () => srcElementRef.current?.focus(), element: srcElementRef.current }), []);\n\n const popoverContentStyle = {\n 'bottom-left': { left: '0', top: '100%' },\n 'bottom-right': { right: '0', top: '100%' },\n 'bottom-center': { left: '50%', transform: 'translateX(-50%)', top: '100%' },\n 'top-left': { left: '0', bottom: '100%' },\n 'top-right': { right: '0', bottom: '100%' },\n 'top-center': { left: '50%', transform: 'translateX(-50%)', bottom: '100%' }\n };\n const popoverContentClasses = noBorder ? '' : 'shadow-md border rounded-md';\n\n return (\n <div\n className={\n 'se-design-popover-wrapper cursor-pointer relative focus-outline rounded-md' +\n (className.length > 0 ? ` ${className}` : '') +\n (displayPopover ? ' open' : '') +\n (disabled ? ' opacity-50 cursor-not-allowed pointer-events-none' : '')\n }\n ref={srcElementRef}\n onClick={(e) => {\n if (disabled || disableClickToggle) return;\n e.stopPropagation();\n togglePopover();\n }}\n onKeyDown={(e) => {\n if (disabled || disableClickToggle) return;\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n e.stopPropagation();\n const wasOpen = displayPopover;\n togglePopover();\n // Focus first focusable element when opening.\n // Portal content isn't mounted until isSrcElementVisible resolves (via setTimeout 0),\n // so use a longer delay for portal to ensure popoverContentRef.current is set.\n if (!wasOpen) {\n setTimeout(() => {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable) firstFocusable.focus();\n }, isWithPortal ? 60 : 0);\n }\n } else if (e.key === 'Escape' && displayPopover) {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n } else if ((e.key === 'ArrowDown' || e.key === 'ArrowUp') && displayPopover) {\n // Handle arrow keys when popover is open\n const currentRef = popoverContentRef.current;\n if (currentRef) {\n handleArrowKeyNavigation(e, currentRef);\n }\n } else if (e.key === 'ArrowDown' && !displayPopover) {\n // Open popover and focus first item when ArrowDown is pressed\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(true);\n setTimeout(() => {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable) firstFocusable.focus();\n }, 0);\n }\n }}\n onBlurCapture={onDismissBlurCapture}\n onBlur={(e) => {\n // Portal content is rendered outside wrapper, so keep explicit check for that case.\n if (!displayPopover || disableAutoClose || !isWithPortal) return;\n\n const nextFocused = e.relatedTarget as Node | null;\n const isFocusInSource = !!(nextFocused && srcElementRef.current?.contains(nextFocused));\n const isFocusInPopover = !!(nextFocused && popoverContentRef.current?.contains(nextFocused));\n\n // Close only when focus leaves both source and portal content.\n if (!isFocusInSource && !isFocusInPopover) {\n setDisplayPopover(false);\n }\n }}\n role={disableClickToggle ? 'none' : sourceRole}\n aria-expanded={disableClickToggle ? undefined : displayPopover ? 'true' : 'false'}\n aria-haspopup={disableClickToggle ? undefined : sourceRole === 'combobox' ? 'listbox' : popupType}\n tabIndex={disabled || disableClickToggle ? -1 : 0}\n aria-disabled={disableClickToggle ? undefined : disabled ? 'true' : undefined}\n {...accessibleNameProps}\n data-automation-id={automationId}\n {...props}\n >\n {renderPopoverSrcElement({ displayPopover, togglePopover })}\n\n {displayPopover && !isWithPortal && (\n <div\n className={`popover-content absolute ${popoverContentClasses} z-[1000] ${\n contentWidth == 'full' ? 'w-full' : 'w-max'\n }`}\n style={{\n ...popoverContentStyleProperty,\n ...popoverContentStyle[popoverPosition]\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={handlePopoverContentKeyDown}\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: closePopover })}\n </div>\n )}\n {isWithPortal &&\n displayPopover &&\n isSrcElementVisible &&\n ReactDOM.createPortal(\n <div\n className={`popover-content-with-portal z-[2002] ${popoverContentClasses} ${\n contentWidth == 'full' ? '' : 'w-max'\n }`}\n style={{\n position: 'fixed',\n top: portalPosition.top,\n left: portalPosition.left,\n visibility: isPortalMeasured ? 'visible' : 'hidden',\n maxHeight: 'calc(100vh - 96px)',\n overflowY: 'hidden',\n ...(contentWidth === 'full' && portalPosition.srcWidth\n ? { width: `${portalPosition.srcWidth}px` }\n : {}),\n ...popoverContentStyleProperty,\n zIndex: 2002\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={handlePopoverContentKeyDown}\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: closePopover })}\n </div>,\n document.body\n )}\n </div>\n );\n }\n);\n"],"names":["Popover","className","automationId","position","popoverContentAutomationId","contentWidth","renderPopoverContents","renderPopoverSrcElement","onPopoverToggle","isPopoverOpen","disabled","isWithPortal","ariaLabel","ariaLabelledBy","sourceRole","popupType","popoverContentStyleProperty","zIndex","borderColor","color","backgroundColor","disableClickToggle","noBorder","disableAutoClose","focusFirstOnOpen","props","ref","displayPopover","setDisplayPopover","useState","popoverPosition","setPopoverPosition","isSrcElementVisible","setIsSrcElementVisible","srcElementRef","useRef","popoverContentRef","useRegisterPortalWithFocusTrap","accessibleNameProps","getA11yNameAttributes","ariaDescribedBy","undefined","onBlurCapture","onDismissBlurCapture","useDismissOnFocusOut","onFocusOut","closeOnEscape","portalPosition","setPortalPosition","top","left","srcWidth","isPortalMeasured","setIsPortalMeasured","focusTriggerElement","getFirstFocusableElement","container","current","includeRoles","focus","closePopover","options","returnFocus","requestAnimationFrame","returnFocusTo","HTMLElement","calculatePositionOfPopover","localPosition","srcRect","getBoundingClientRect","scrollbarWidth","window","innerWidth","document","documentElement","clientWidth","viewportWidth","Math","max","viewportHeight","innerHeight","bottom","right","width","height","popoverRect","popoverWidth","popoverHeight","spaceAbove","spaceBelow","round","useEffect","body","addEventListener","clickListener","checkPopoverPosition","removeEventListener","scrollListenerForRepositioning","clickAndScrollListenerWithPortal","resizeListenerWithPortal","escapeHandler","e","key","contains","activeElement","preventDefault","stopPropagation","checkSourceVisibility","rafId1","rafId2","cancelAnimationFrame","rec","isVisible","setTimeout","firstFocusable","includes","event","currentDropRef","target","isSourcePopover","isPopoverContent","closestPopoverWrapper","closest","isAnotherPopoverSource","isNestedPopover","currentPopoverRef","type","togglePopover","focusFirst","wasOpen","prev","lastFocusable","getLastFocusableElement","handleArrowKeyNavigation","activeEl","tagName","focusableElements","Array","from","querySelectorAll","FOCUSABLE_WITH_ROLES_SELECTOR","filter","el","style","getComputedStyle","hasAttribute","getAttribute","display","visibility","tabIndex","length","currentIndex","findIndex","nextIndex","handlePopoverContentKeyDown","focusables","getFocusableElements","filterHidden","indexOf","isOnLast","isOnFirst","shiftKey","srcEl","allFocusables","idx","next","useImperativeHandle","focusTrigger","element","popoverContentStyle","transform","popoverContentClasses","React","createElement","_extends","onClick","onKeyDown","currentRef","onBlur","nextFocused","relatedTarget","isFocusInSource","isFocusInPopover","role","closePopoverCb","ReactDOM","createPortal","maxHeight","overflowY"],"mappings":";;;;;;;;;;;;;;;;AA4CO,MAAMA,wBACX,CACE;AAAA,EACEC,WAAAA,IAAY;AAAA,EACZC,cAAAA,IAAe;AAAA,EACfC,UAAAA,IAAW;AAAA,EACXC,4BAAAA,IAA6B;AAAA,EAC7BC,cAAAA,IAAe;AAAA,EACfC,uBAAAA;AAAAA,EACAC,yBAAAA;AAAAA,EACAC,iBAAAA;AAAAA,EACAC,eAAAA;AAAAA,EACAC,UAAAA,IAAW;AAAA,EACXC,cAAAA,IAAe;AAAA,EACfC,WAAAA;AAAAA,EACAC,gBAAAA;AAAAA,EACAC,YAAAA,IAAa;AAAA,EACbC,WAAAA,IAAY;AAAA,EACZC,6BAAAA,IAA8B;AAAA,IAC5BC,QAAQ;AAAA,IACRC,aAAa;AAAA,I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AA,IACXhI,KAAKU;AAAAA,IACL,sBAAoBhC;AAAAA,EAAAA,GAEnBE,EAAsB;AAAA,IAAEkL,gBAAgB5H;AAAAA,EAAAA,CAAc,CACpD,GAENjD,KACCgB,KACAK,MACAyJ,gBAAAA,GAASC,aACPd,gBAAAA,EAAAC,cAAA,OAAA;AAAA,IACE5K,WAAW,wCAAwC0K,CAAqB,IACtEtK,KAAgB,SAAS,KAAK,OAAO;AAAA,IAEvC0I,OAAO;AAAA,MACL5I,UAAU;AAAA,MACV8C,KAAKF,EAAeE;AAAAA,MACpBC,MAAMH,EAAeG;AAAAA,MACrBkG,YAAYhG,KAAmB,YAAY;AAAA,MAC3CuI,WAAW;AAAA,MACXC,WAAW;AAAA,MACX,GAAIvL,MAAiB,UAAU0C,EAAeI,WAC1C;AAAA,QAAEgC,OAAO,GAAGpC,EAAeI,QAAQ;AAAA,MAAA,IACnC,CAAA;AAAA,MACJ,GAAGnC;AAAAA,MACHC,QAAQ;AAAA,IAAA;AAAA,IAEV8J,SAAU1E,CAAAA,MAAMA,EAAEK,gBAAAA;AAAAA,IAClBsE,WAAWtB;AAAAA,IACXhI,KAAKU;AAAAA,IACL,sBAAoBhC;AAAAA,EAAAA,GAEnBE,EAAsB;AAAA,IAAEkL,gBAAgB5H;AAAAA,EAAAA,CAAc,CACpD,GACLa,SAASmB,IACX,CACC;AAET,CACF;"}
1
+ {"version":3,"file":"index19.js","sources":["../src/components/Popover/index.tsx"],"sourcesContent":["import React, { useState, useRef, ReactNode, useEffect, forwardRef, ForwardedRef, useImperativeHandle } from 'react';\nimport ReactDOM from 'react-dom';\nimport {\n getA11yNameAttributes,\n useDismissOnFocusOut,\n FOCUSABLE_WITH_ROLES_SELECTOR,\n getFocusableElements,\n getFirstFocusableElement,\n getLastFocusableElement\n} from '../../utils/a11y';\nimport { useRegisterPortalWithFocusTrap } from '../../utils/a11y/FocusTrapPortalContext';\n\nexport interface PopoverHandle {\n togglePopover: (focusFirst?: boolean | 'last') => void;\n /** Focus the popover source/trigger element. */\n focusTrigger: () => void;\n /** The wrapper element that acts as the popover trigger. Stable DOM node with tabIndex=0. */\n element: HTMLElement | null;\n}\n\nexport interface PopoverProps {\n className?: string;\n automationId?: string;\n popoverContentAutomationId?: string;\n renderPopoverContents: (props: { closePopoverCb: (options?: { returnFocus?: boolean; returnFocusTo?: HTMLElement | React.RefObject<HTMLElement> }) => void }) => ReactNode;\n renderPopoverSrcElement: (props: { displayPopover: boolean; togglePopover: (focusFirst?: boolean | 'last') => void }) => ReactNode;\n position?: 'bottom-center' | 'bottom-left' | 'bottom-right' | 'top-center' | 'top-left' | 'top-right';\n onPopoverToggle?: (displayPopover: boolean) => void;\n contentWidth?: 'full' | 'max';\n isPopoverOpen?: boolean;\n disabled?: boolean;\n isWithPortal?: boolean;\n noBorder?: boolean;\n ariaLabel?: string;\n ariaLabelledBy?: string;\n sourceRole?: 'button' | 'combobox';\n popupType?: 'menu' | 'listbox' | 'dialog' | 'true';\n popoverContentStyleProperty?: React.CSSProperties;\n disableClickToggle?: boolean;\n disableAutoClose?: boolean;\n /** Focus the first focusable element when the popover opens via isPopoverOpen (external state). */\n focusFirstOnOpen?: boolean;\n}\n\nexport const Popover = forwardRef<PopoverHandle, PopoverProps>(\n (\n {\n className = '',\n automationId = '',\n position = 'bottom-center',\n popoverContentAutomationId = '',\n contentWidth = 'max',\n renderPopoverContents,\n renderPopoverSrcElement,\n onPopoverToggle,\n isPopoverOpen,\n disabled = false,\n isWithPortal = false,\n ariaLabel,\n ariaLabelledBy,\n sourceRole = 'button',\n popupType = 'true',\n popoverContentStyleProperty = {\n zIndex: 1000,\n borderColor: 'var(--color-gray-200)',\n color: 'var(--color-gray-900)',\n backgroundColor: 'var(--color-white)'\n },\n disableClickToggle = false,\n noBorder = false,\n disableAutoClose = false,\n focusFirstOnOpen = false,\n ...props\n },\n ref: ForwardedRef<PopoverHandle>\n ) => {\n const [displayPopover, setDisplayPopover] = useState(false);\n const [popoverPosition, setPopoverPosition] = useState(position);\n const [isSrcElementVisible, setIsSrcElementVisible] = useState(false);\n const srcElementRef = useRef<HTMLDivElement>(null);\n const popoverContentRef = useRef<HTMLDivElement>(null);\n\n // Register portal content with the nearest ancestor focus trap (e.g., Modal)\n // so the focus trap's safety net allows focus to move into portal content.\n useRegisterPortalWithFocusTrap(popoverContentRef, isWithPortal && displayPopover);\n\n // Compute accessible name/description props with correct precedence\n const accessibleNameProps = getA11yNameAttributes({\n ariaLabel,\n ariaLabelledBy,\n ariaDescribedBy: undefined // Popover doesn't support describedBy yet\n });\n\n // Use shared focus-out dismissal for non-portal popovers.\n // Portal content lives outside the wrapper, so portal uses a dedicated onBlur fallback below.\n const { onBlurCapture: onDismissBlurCapture } = useDismissOnFocusOut<HTMLDivElement>({\n disabled: !displayPopover || disableAutoClose || isWithPortal,\n onFocusOut: () => setDisplayPopover(false),\n closeOnEscape: false\n });\n\n const [portalPosition, setPortalPosition] = useState({ top: 0, left: 0, srcWidth: 0 });\n const [isPortalMeasured, setIsPortalMeasured] = useState(false);\n\n // Focus the actual trigger element on popover close.\n // When disableClickToggle=true the wrapper is role=\"none\"/tabIndex=-1 — focus the\n // first focusable child (the inner Button/Icon) instead.\n const focusTriggerElement = () => {\n if (disableClickToggle) {\n const inner = getFirstFocusableElement({ container: srcElementRef.current, includeRoles: true });\n (inner ?? srcElementRef.current)?.focus();\n } else {\n srcElementRef.current?.focus();\n }\n };\n\n const closePopover = (options?: { returnFocus?: boolean; returnFocusTo?: HTMLElement | React.RefObject<HTMLElement> }) => {\n setDisplayPopover(false);\n if (options?.returnFocus !== false) {\n requestAnimationFrame(() => {\n if (options?.returnFocusTo) {\n const target = options.returnFocusTo instanceof HTMLElement\n ? options.returnFocusTo\n : options.returnFocusTo.current;\n target?.focus();\n } else {\n focusTriggerElement();\n }\n });\n }\n };\n\n const calculatePositionOfPopover = (position: string = 'bottom-center') => {\n if (!srcElementRef.current) return { top: 0, left: 0, srcWidth: 0 };\n\n let localPosition = position;\n\n const srcRect = srcElementRef.current.getBoundingClientRect();\n // Subtract scrollbar width so portal content doesn't render behind a scrollbar.\n // document.documentElement.clientWidth excludes any visible scrollbar;\n // fall back to a 16px buffer (max scrollbar width across OS/browsers) when\n // body overflow is hidden and the scrollbar belongs to a nested container.\n const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;\n const viewportWidth = window.innerWidth - Math.max(scrollbarWidth, 16);\n const viewportHeight = window.innerHeight;\n\n // Calculate position for portal\n let top = 0;\n let left = 0;\n\n switch (localPosition) {\n case 'bottom-left':\n top = srcRect.bottom;\n left = srcRect.left;\n break;\n case 'bottom-right':\n top = srcRect.bottom;\n left = srcRect.right - srcRect.width * 0.5;\n break;\n case 'bottom-center':\n top = srcRect.bottom;\n // Center the popover relative to the source element\n left = srcRect.left + srcRect.width / 2;\n break;\n case 'top-left':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.left;\n break;\n case 'top-right':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.right - srcRect.width * 0.5;\n break;\n case 'top-center':\n top = srcRect.top - srcRect.height * 1.9;\n // Center the popover relative to the source element\n left = srcRect.left + srcRect.width / 2;\n break;\n default:\n top = srcRect.bottom;\n left = srcRect.left;\n break;\n }\n\n // Get popover dimensions if available\n const popoverRect = popoverContentRef.current?.getBoundingClientRect();\n // When contentWidth='full', the panel will be sized to srcRect.width after measurement.\n // Use srcRect.width directly so centering and viewport clamping use the correct final width.\n const popoverWidth = (contentWidth === 'full' ? Math.max(srcRect.width, popoverRect?.width || 0) : popoverRect?.width) || 0;\n const popoverHeight = popoverRect?.height || 0;\n\n // Adjust center positions to account for popover width\n if (localPosition === 'bottom-center' || localPosition === 'top-center') {\n // Center the popover by subtracting half its width from the source center\n left = left - popoverWidth / 2;\n }\n\n // Adjust position to keep popover within viewport bounds\n // Horizontal adjustments\n if (left + popoverWidth > viewportWidth) {\n // Popover extends beyond right edge, shift it left\n left = Math.max(0, viewportWidth - popoverWidth);\n }\n if (left < 0) {\n // Popover extends beyond left edge, shift it right\n left = 0;\n }\n\n // Vertical adjustments\n if (top + popoverHeight > viewportHeight) {\n // Popover extends beyond bottom edge\n // Try to position it above the source element\n const spaceAbove = srcRect.top;\n const spaceBelow = viewportHeight - srcRect.bottom;\n\n if (spaceAbove >= popoverHeight || spaceAbove > spaceBelow) {\n // Position above if there's enough space or more space above\n top = srcRect.top - popoverHeight;\n // Ensure it doesn't go above the topbar (48px fixed header)\n if (top < 48) {\n top = 48;\n }\n } else {\n // Keep at bottom but adjust to fit within viewport\n top = Math.max(48, viewportHeight - popoverHeight);\n }\n }\n if (top < 48) {\n // Popover extends beyond top edge, position it below the source element\n top = srcRect.bottom;\n // Ensure it doesn't go below viewport\n if (top + popoverHeight > viewportHeight) {\n top = Math.max(48, viewportHeight - popoverHeight);\n }\n }\n\n return { top: Math.round(top), left: Math.round(left), srcWidth: srcRect.width };\n };\n\n useEffect(() => {\n if (onPopoverToggle) {\n onPopoverToggle(displayPopover);\n }\n\n if (displayPopover && !isWithPortal) {\n // Add click listener for auto-close behavior only if not disabled\n if (!disableAutoClose) {\n document.body.addEventListener('click', clickListener, true);\n }\n checkPopoverPosition();\n return () => {\n if (!disableAutoClose) {\n document.body.removeEventListener('click', clickListener, true);\n }\n };\n } else if (displayPopover && isWithPortal) {\n // Add click/scroll listeners for auto-close behavior only if not disabled\n if (!disableAutoClose) {\n document.body.addEventListener('click', clickAndScrollListenerWithPortal, true);\n window.addEventListener('scroll', clickAndScrollListenerWithPortal);\n } else {\n // When disableAutoClose is true, still listen to scroll for repositioning\n window.addEventListener('scroll', scrollListenerForRepositioning);\n }\n // Always add resize listener for repositioning\n window.addEventListener('resize', resizeListenerWithPortal);\n\n // Escape on window capture phase — must fire before document-capture listeners\n // (e.g. useDismissOnEscape in Modal) so Escape closes the portal Dropdown without\n // also dismissing the modal behind it.\n const escapeHandler = (e: KeyboardEvent) => {\n if (e.key !== 'Escape') return;\n if (!popoverContentRef.current?.contains(document.activeElement)) return;\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n requestAnimationFrame(() => focusTriggerElement());\n };\n window.addEventListener('keydown', escapeHandler, true);\n\n // Trigger source visibility check immediately\n checkSourceVisibility();\n\n // Use double-rAF to measure portal after browser has completed layout,\n // guaranteeing real dimensions are available for flip/clamp calculations.\n // Portal is hidden via visibility:hidden until this completes (no flash).\n let rafId1: number;\n let rafId2: number;\n rafId1 = requestAnimationFrame(() => {\n rafId2 = requestAnimationFrame(() => {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n setIsPortalMeasured(true);\n });\n });\n\n return () => {\n if (!disableAutoClose) {\n document.body.removeEventListener('click', clickAndScrollListenerWithPortal, true);\n window.removeEventListener('scroll', clickAndScrollListenerWithPortal);\n } else {\n window.removeEventListener('scroll', scrollListenerForRepositioning);\n }\n window.removeEventListener('resize', resizeListenerWithPortal);\n window.removeEventListener('keydown', escapeHandler, true);\n cancelAnimationFrame(rafId1);\n cancelAnimationFrame(rafId2);\n setIsPortalMeasured(false);\n };\n }\n }, [displayPopover, isWithPortal, disableAutoClose]);\n\n const checkSourceVisibility = () => {\n if (!srcElementRef.current) {\n setIsSrcElementVisible(false);\n return;\n }\n\n const rec = srcElementRef.current.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n const viewportWidth = window.innerWidth;\n\n const isVisible = rec.top < viewportHeight && rec.bottom > 0 && rec.left < viewportWidth && rec.right > 0;\n\n setIsSrcElementVisible(isVisible);\n };\n\n useEffect(() => {\n setDisplayPopover(isPopoverOpen ?? false);\n }, [isPopoverOpen]);\n\n useEffect(() => {\n // Focus first focusable element when popover opens.\n // For portal, delay longer so isSrcElementVisible can be set and portal can mount first.\n if (displayPopover) {\n setTimeout(() => {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n console.log('[Popover open] focus check:', {\n hasFocusable: !!firstFocusable,\n focusFirstOnOpen,\n isSrcFocused: document.activeElement === srcElementRef.current,\n activeEl: (document.activeElement as HTMLElement)?.className?.slice(0, 50),\n willFocus: !!(firstFocusable && (focusFirstOnOpen || document.activeElement === srcElementRef.current)),\n isWithPortal,\n hasPortalContent: !!popoverContentRef.current,\n });\n if (firstFocusable && (focusFirstOnOpen || document.activeElement === srcElementRef.current)) {\n firstFocusable.focus();\n }\n }, isWithPortal ? 60 : 0);\n }\n }, [displayPopover]);\n\n //Function to check popover position\n const checkPopoverPosition = () => {\n if (!popoverContentRef.current) return;\n\n const popoverRect = popoverContentRef.current.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n\n if (popoverRect?.bottom > viewportHeight) {\n setPopoverPosition(\n position.includes('left') ? 'top-left' : position.includes('right') ? 'top-right' : 'top-center'\n );\n } else if (popoverRect?.top < 0) {\n // If popover extends beyond top of viewport, switch to bottom position\n setPopoverPosition(\n position.includes('left') ? 'bottom-left' : position.includes('right') ? 'bottom-right' : 'bottom-center'\n );\n }\n };\n\n const clickListener = (event: MouseEvent) => {\n const currentDropRef = srcElementRef.current;\n if (!currentDropRef) return;\n\n const target = event.target as Node;\n const isSourcePopover = currentDropRef.contains(target);\n const isPopoverContent = popoverContentRef.current?.contains(target);\n\n // Check if click is on another popover's source element\n const clickedElement = target as HTMLElement;\n const closestPopoverWrapper = clickedElement.closest?.('.se-design-popover-wrapper');\n const isAnotherPopoverSource = closestPopoverWrapper && closestPopoverWrapper !== currentDropRef;\n\n // check if the clicked popover is a nesteded child of the current popover content\n const isNestedPopover = popoverContentRef.current?.contains(closestPopoverWrapper as Node);\n\n // if clicked source is parent or the popover-content, do not toggle dropdown.\n // Also close if clicking on another popover's source element\n if (disableAutoClose) return;\n if ((!isSourcePopover && !isPopoverContent) || (isAnotherPopoverSource && !isNestedPopover)) {\n setDisplayPopover(false);\n }\n };\n\n const clickAndScrollListenerWithPortal = (event: Event) => {\n const currentDropRef = srcElementRef.current;\n const currentPopoverRef = popoverContentRef.current;\n if (!currentDropRef) return;\n checkSourceVisibility();\n\n // Recalculate position on scroll\n if (event.type === 'scroll' && displayPopover) {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n\n const target = event.target as Node;\n const isSourcePopover = currentDropRef.contains(target);\n const isPopoverContent = currentPopoverRef?.contains(target);\n\n // Check if click is on another popover's source element\n const clickedElement = target as HTMLElement;\n const closestPopoverWrapper = clickedElement.closest?.('.se-design-popover-wrapper');\n const isAnotherPopoverSource = closestPopoverWrapper && closestPopoverWrapper !== currentDropRef;\n\n // check if the clicked popover is a nesteded child of the current popover content\n const isNestedPopover = popoverContentRef.current?.contains(closestPopoverWrapper as Node);\n\n if (disableAutoClose) return;\n // if clicked source is parent or the popover-content, do not toggle dropdown.\n // Also close if clicking on another popover's source element\n if ((!isSourcePopover && !isPopoverContent) || (isAnotherPopoverSource && !isNestedPopover)) {\n setDisplayPopover(false);\n }\n };\n\n const resizeListenerWithPortal = () => {\n if (displayPopover && isWithPortal && srcElementRef.current) {\n checkSourceVisibility();\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n };\n\n const scrollListenerForRepositioning = () => {\n if (displayPopover && isWithPortal && srcElementRef.current) {\n checkSourceVisibility();\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n };\n\n const togglePopover = (focusFirst: boolean | 'last' = false) => {\n const wasOpen = displayPopover;\n setDisplayPopover((prev) => !prev);\n if (!wasOpen && focusFirst) {\n setTimeout(() => {\n if (focusFirst === 'last') {\n const lastFocusable = getLastFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (lastFocusable) lastFocusable.focus();\n } else {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable) firstFocusable.focus();\n }\n }, 50);\n }\n };\n\n const handleArrowKeyNavigation = (e: React.KeyboardEvent, container: HTMLDivElement | null) => {\n if (!container) return;\n\n // Native form controls own their arrow key behavior — don't intercept.\n // (e.g. a SearchBox inside a Popover should keep focus while typing/navigating)\n const activeEl = document.activeElement;\n if (activeEl?.tagName === 'INPUT' || activeEl?.tagName === 'TEXTAREA' || activeEl?.tagName === 'SELECT') {\n return;\n }\n\n const focusableElements = Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE_WITH_ROLES_SELECTOR)).filter((el) => {\n // Filter out disabled and hidden elements.\n // Note: check aria-disabled VALUE not just presence — React always writes aria-disabled=\"false\"\n // on elements like MenuItem even when not disabled, so hasAttribute would wrongly exclude them.\n const style = window.getComputedStyle(el);\n return (\n !el.hasAttribute('disabled') &&\n el.getAttribute('aria-disabled') !== 'true' &&\n style.display !== 'none' &&\n style.visibility !== 'hidden' &&\n (el.tabIndex >= 0 || el.hasAttribute('role'))\n );\n });\n\n if (focusableElements.length === 0) return;\n\n const currentIndex = focusableElements.findIndex((el) => el === document.activeElement);\n let nextIndex = -1;\n\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = currentIndex < focusableElements.length - 1 ? currentIndex + 1 : 0;\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = currentIndex > 0 ? currentIndex - 1 : focusableElements.length - 1;\n } else if (e.key === 'Home') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = 0;\n } else if (e.key === 'End') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = focusableElements.length - 1;\n }\n\n console.log('[Popover] arrowNav:', {\n focusableCount: focusableElements.length,\n currentIndex,\n nextIndex,\n activeEl: document.activeElement?.tagName,\n activeRole: document.activeElement?.getAttribute('role'),\n firstEl: focusableElements[0]?.tagName + '.' + focusableElements[0]?.className?.slice(0, 30),\n });\n if (nextIndex >= 0 && focusableElements[nextIndex]) {\n focusableElements[nextIndex].focus();\n } else if (currentIndex === -1 && focusableElements.length > 0) {\n // If no element is currently focused, focus the first one\n focusableElements[0].focus();\n }\n };\n\n const handlePopoverContentKeyDown = (e: React.KeyboardEvent) => {\n // Allow Escape key to close popover when focus is on content\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n // Defer focus restoration to after React re-renders and portal unmounts.\n // Synchronous focus() during the event can be displaced by the portal\n // teardown in some browsers, especially when isWithPortal=true.\n requestAnimationFrame(() => focusTriggerElement());\n } else if (e.key === 'Tab') {\n if (popupType === 'dialog') {\n // Dialog popovers: let Tab flow naturally within the content.\n // Only close when focus would actually leave the popover.\n const focusables = getFocusableElements({ container: popoverContentRef.current, filterHidden: true });\n const currentIndex = focusables.indexOf(e.target as HTMLElement);\n const isOnLast = currentIndex === focusables.length - 1;\n const isOnFirst = currentIndex === 0 || currentIndex === -1;\n\n if (e.shiftKey && isOnFirst) {\n // Shift+Tab past first element — close and return focus to trigger\n e.preventDefault();\n setDisplayPopover(false);\n focusTriggerElement();\n } else if (!e.shiftKey && isOnLast) {\n // Tab past last element — close popover\n setDisplayPopover(false);\n if (isWithPortal) {\n e.preventDefault();\n const srcEl = srcElementRef.current;\n const allFocusables = getFocusableElements({ container: document.body, filterHidden: true });\n const idx = srcEl ? allFocusables.indexOf(srcEl) : -1;\n const next = allFocusables[idx + 1];\n if (next) next.focus();\n else srcEl?.focus();\n }\n }\n // Otherwise: let browser handle Tab naturally within the popover content\n } else {\n // Non-dialog: close popover when Tab exits the menu\n setDisplayPopover(false);\n if (e.shiftKey) {\n // Shift+Tab: prevent default (would go to wrapper) and focus trigger instead\n e.preventDefault();\n focusTriggerElement();\n } else if (isWithPortal) {\n // Portal forward Tab: portal content is at document.body so natural Tab order\n // skips back to the top of the page. Manually advance to the next focusable\n // element after the trigger in the main document instead.\n e.preventDefault();\n const srcEl = srcElementRef.current;\n const focusables = getFocusableElements({ container: document.body, filterHidden: true });\n const idx = srcEl ? focusables.indexOf(srcEl) : -1;\n const next = focusables[idx + 1];\n if (next) next.focus();\n else srcEl?.focus();\n }\n // Non-portal forward Tab: do NOT preventDefault — browser moves focus to next element naturally\n }\n } else if (e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === 'Home' || e.key === 'End') {\n // Handle arrow key navigation for focusable elements inside popover\n handleArrowKeyNavigation(e, popoverContentRef.current);\n } else if (e.key === 'Enter' || e.key === ' ') {\n // Prevent Enter/Space from bubbling to wrapper (mirrors click stopPropagation)\n e.stopPropagation();\n }\n };\n\n useImperativeHandle(ref, () => ({ togglePopover, focusTrigger: () => srcElementRef.current?.focus(), element: srcElementRef.current }), []);\n\n const popoverContentStyle = {\n 'bottom-left': { left: '0', top: '100%' },\n 'bottom-right': { right: '0', top: '100%' },\n 'bottom-center': { left: '50%', transform: 'translateX(-50%)', top: '100%' },\n 'top-left': { left: '0', bottom: '100%' },\n 'top-right': { right: '0', bottom: '100%' },\n 'top-center': { left: '50%', transform: 'translateX(-50%)', bottom: '100%' }\n };\n const popoverContentClasses = noBorder ? '' : 'shadow-md border rounded-md';\n\n return (\n <div\n className={\n 'se-design-popover-wrapper cursor-pointer relative focus-outline rounded-md' +\n (className.length > 0 ? ` ${className}` : '') +\n (displayPopover ? ' open' : '') +\n (disabled ? ' opacity-50 cursor-not-allowed pointer-events-none' : '')\n }\n ref={srcElementRef}\n onClick={(e) => {\n if (disabled || disableClickToggle) return;\n e.stopPropagation();\n togglePopover();\n }}\n onKeyDown={(e) => {\n if (disabled || disableClickToggle) return;\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n e.stopPropagation();\n const wasOpen = displayPopover;\n togglePopover();\n // Focus first focusable element when opening.\n // Portal content isn't mounted until isSrcElementVisible resolves (via setTimeout 0),\n // so use a longer delay for portal to ensure popoverContentRef.current is set.\n if (!wasOpen) {\n setTimeout(() => {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable) firstFocusable.focus();\n }, isWithPortal ? 60 : 0);\n }\n } else if (e.key === 'Escape' && displayPopover) {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n } else if ((e.key === 'ArrowDown' || e.key === 'ArrowUp') && displayPopover) {\n // Handle arrow keys when popover is open\n const currentRef = popoverContentRef.current;\n console.log('[Popover] arrow on wrapper:', { key: e.key, hasRef: !!currentRef });\n if (currentRef) {\n handleArrowKeyNavigation(e, currentRef);\n }\n } else if (e.key === 'ArrowDown' && !displayPopover) {\n // Open popover and focus first item when ArrowDown is pressed\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(true);\n setTimeout(() => {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable) firstFocusable.focus();\n }, 0);\n }\n }}\n onBlurCapture={onDismissBlurCapture}\n onBlur={(e) => {\n // Portal content is rendered outside wrapper, so keep explicit check for that case.\n if (!displayPopover || disableAutoClose || !isWithPortal) return;\n\n const nextFocused = e.relatedTarget as Node | null;\n const isFocusInSource = !!(nextFocused && srcElementRef.current?.contains(nextFocused));\n const isFocusInPopover = !!(nextFocused && popoverContentRef.current?.contains(nextFocused));\n\n // Close only when focus leaves both source and portal content.\n if (!isFocusInSource && !isFocusInPopover) {\n setDisplayPopover(false);\n }\n }}\n role={disableClickToggle ? 'none' : sourceRole}\n aria-expanded={disableClickToggle ? undefined : displayPopover ? 'true' : 'false'}\n aria-haspopup={disableClickToggle ? undefined : sourceRole === 'combobox' ? 'listbox' : popupType}\n tabIndex={disabled || disableClickToggle ? -1 : 0}\n aria-disabled={disableClickToggle ? undefined : disabled ? 'true' : undefined}\n {...accessibleNameProps}\n data-automation-id={automationId}\n {...props}\n >\n {renderPopoverSrcElement({ displayPopover, togglePopover })}\n\n {displayPopover && !isWithPortal && (\n <div\n className={`popover-content absolute ${popoverContentClasses} z-[1000] ${\n contentWidth == 'full' ? 'w-full' : 'w-max'\n }`}\n style={{\n ...popoverContentStyleProperty,\n ...popoverContentStyle[popoverPosition]\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={handlePopoverContentKeyDown}\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: closePopover })}\n </div>\n )}\n {isWithPortal &&\n displayPopover &&\n isSrcElementVisible &&\n ReactDOM.createPortal(\n <div\n className={`popover-content-with-portal z-[2002] ${popoverContentClasses} ${\n contentWidth == 'full' ? '' : 'w-max'\n }`}\n style={{\n position: 'fixed',\n top: portalPosition.top,\n left: portalPosition.left,\n visibility: isPortalMeasured ? 'visible' : 'hidden',\n maxHeight: 'calc(100vh - 96px)',\n overflowY: 'hidden',\n ...(contentWidth === 'full' && portalPosition.srcWidth\n ? { width: `${portalPosition.srcWidth}px` }\n : {}),\n ...popoverContentStyleProperty,\n zIndex: 2002\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={handlePopoverContentKeyDown}\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: closePopover })}\n </div>,\n document.body\n )}\n </div>\n );\n }\n);\n"],"names":["Popover","className","automationId","position","popoverContentAutomationId","contentWidth","renderPopoverContents","renderPopoverSrcElement","onPopoverToggle","isPopoverOpen","disabled","isWithPortal","ariaLabel","ariaLabelledBy","sourceRole","popupType","popoverContentStyleProperty","zIndex","borderColor","color","backgroundColor","disableClickToggle","noBorder","disableAutoClose","focusFirstOnOpen","props","ref","displayPopover","setDisplayPopover","useState","popoverPosition","setPopoverPosition","isSrcElementVisible","setIsSrcElementVisible","srcElementRef","useRef","popoverContentRef","useRegisterPortalWithFocusTrap","accessibleNameProps","getA11yNameAttributes","ariaDescribedBy","undefined","onBlurCapture","onDismissBlurCapture","useDismissOnFocusOut","onFocusOut","closeOnEscape","portalPosition","setPortalPosition","top","left","srcWidth","isPortalMeasured","setIsPortalMeasured","focusTriggerElement","getFirstFocusableElement","container","current","includeRoles","focus","closePopover","options","returnFocus","requestAnimationFrame","returnFocusTo","HTMLElement","calculatePositionOfPopover","localPosition","srcRect","getBoundingClientRect","scrollbarWidth","window","innerWidth","document","documentElement","clientWidth","viewportWidth","Math","max","viewportHeight","innerHeight","bottom","right","width","height","popoverRect","popoverWidth","popoverHeight","spaceAbove","spaceBelow","round","useEffect","body","addEventListener","clickListener","checkPopoverPosition","removeEventListener","scrollListenerForRepositioning","clickAndScrollListenerWithPortal","resizeListenerWithPortal","escapeHandler","e","key","contains","activeElement","preventDefault","stopPropagation","checkSourceVisibility","rafId1","rafId2","cancelAnimationFrame","rec","isVisible","setTimeout","firstFocusable","console","log","hasFocusable","isSrcFocused","activeEl","slice","willFocus","hasPortalContent","includes","event","currentDropRef","target","isSourcePopover","isPopoverContent","closestPopoverWrapper","closest","isAnotherPopoverSource","isNestedPopover","currentPopoverRef","type","togglePopover","focusFirst","wasOpen","prev","lastFocusable","getLastFocusableElement","handleArrowKeyNavigation","tagName","focusableElements","Array","from","querySelectorAll","FOCUSABLE_WITH_ROLES_SELECTOR","filter","el","style","getComputedStyle","hasAttribute","getAttribute","display","visibility","tabIndex","length","currentIndex","findIndex","nextIndex","focusableCount","activeRole","firstEl","handlePopoverContentKeyDown","focusables","getFocusableElements","filterHidden","indexOf","isOnLast","isOnFirst","shiftKey","srcEl","allFocusables","idx","next","useImperativeHandle","focusTrigger","element","popoverContentStyle","transform","popoverContentClasses","React","createElement","_extends","onClick","onKeyDown","currentRef","hasRef","onBlur","nextFocused","relatedTarget","isFocusInSource","isFocusInPopover","role","closePopoverCb","ReactDOM","createPortal","maxHeight","overflowY"],"mappings":";;;;;;;;;;;;;;;;AA4CO,MAAMA,wBACX,CACE;AAAA,EACEC,WAAAA,IAAY;AAAA,EACZC,cAAAA,IAAe;AAAA,EACfC,UAAAA,IAAW;AAAA,EACXC,4BAAAA,IAA6B;AAAA,EAC7BC,cAAAA,IAAe;AAAA,EACfC,uBAAAA;AAAAA,EACAC,yBAAAA;AAAAA,EACAC,iBAAAA;AAAAA,EACAC,eAAAA;AAAAA,EACAC,UAAAA,IAAW;AAAA,EACXC,cAAAA,IAAe;AAAA,EACfC,WAAAA;AAAAA,EACAC,gBAAAA;AAAAA,EACAC,YAAAA,IAAa;AAAA,EACbC,WAAAA,IAAY;AAAA,EACZC,6BAAAA,IA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;AAAAA,MACrByG,YAAYvG,KAAmB,YAAY;AAAA,MAC3CkJ,WAAW;AAAA,MACXC,WAAW;AAAA,MACX,GAAIlM,MAAiB,UAAU0C,EAAeI,WAC1C;AAAA,QAAEgC,OAAO,GAAGpC,EAAeI,QAAQ;AAAA,MAAA,IACnC,CAAA;AAAA,MACJ,GAAGnC;AAAAA,MACHC,QAAQ;AAAA,IAAA;AAAA,IAEVwK,SAAUpF,CAAAA,MAAMA,EAAEK,gBAAAA;AAAAA,IAClBgF,WAAWtB;AAAAA,IACX1I,KAAKU;AAAAA,IACL,sBAAoBhC;AAAAA,EAAAA,GAEnBE,EAAsB;AAAA,IAAE6L,gBAAgBvI;AAAAA,EAAAA,CAAc,CACpD,GACLa,SAASmB,IACX,CACC;AAET,CACF;"}
package/dist/index20.js CHANGED
@@ -1,20 +1,21 @@
1
- import e from "react";
2
- const u = ({
1
+ import e, { forwardRef as u } from "react";
2
+ const m = /* @__PURE__ */ u(({
3
3
  leftContainer: t,
4
4
  centerContainer: l,
5
5
  rightContainer: r,
6
6
  className: a,
7
- id: c,
8
- ...o
9
- }) => /* @__PURE__ */ e.createElement("header", {
10
- id: c,
7
+ id: o,
8
+ ...c
9
+ }, n) => /* @__PURE__ */ e.createElement("header", {
10
+ ref: n,
11
+ id: o,
11
12
  tabIndex: -1,
12
13
  style: {
13
14
  "--focus-color": "var(--color-blue-300)"
14
15
  },
15
- className: `se-design-header ${a} sticky top-0 h-[48px] w-full z-[1010] bg-[var(--color-blue-600)] flex justify-between items-center focus:outline-none ${o?.type === "fixed" ? "fixed left-0 right-0 top-0" : ""}`
16
- }, t && /* @__PURE__ */ e.createElement(e.Fragment, null, t), l && /* @__PURE__ */ e.createElement(e.Fragment, null, l), r && /* @__PURE__ */ e.createElement(e.Fragment, null, r));
16
+ className: `se-design-header ${a} sticky top-0 h-[48px] w-full z-[1010] bg-[var(--color-blue-600)] flex justify-between items-center focus:outline-none ${c?.type === "fixed" ? "fixed left-0 right-0 top-0" : ""}`
17
+ }, t && /* @__PURE__ */ e.createElement(e.Fragment, null, t), l && /* @__PURE__ */ e.createElement(e.Fragment, null, l), r && /* @__PURE__ */ e.createElement(e.Fragment, null, r)));
17
18
  export {
18
- u as Header
19
+ m as Header
19
20
  };
20
21
  //# sourceMappingURL=index20.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index20.js","sources":["../src/components/Header/index.tsx"],"sourcesContent":["import React, { FC } from 'react';\n\nexport interface HeaderProps {\n leftContainer?: React.ReactNode;\n centerContainer?: React.ReactNode;\n rightContainer?: React.ReactNode;\n type?: string;\n className?: string;\n id?: string;\n}\n\nexport const Header: FC<HeaderProps> = ({\n leftContainer,\n centerContainer,\n rightContainer,\n className,\n id,\n ...props\n}) => {\n return (\n <header\n id={id}\n tabIndex={-1}\n style={{ '--focus-color': 'var(--color-blue-300)' } as React.CSSProperties}\n className={`se-design-header ${className} sticky top-0 h-[48px] w-full z-[1010] bg-[var(--color-blue-600)] flex justify-between items-center focus:outline-none ${\n props?.type === 'fixed' ? 'fixed left-0 right-0 top-0' : ''\n }`}\n >\n {leftContainer && <>{leftContainer}</>}\n {centerContainer && <>{centerContainer}</>}\n {rightContainer && <>{rightContainer}</>}\n </header>\n );\n};\n"],"names":["Header","leftContainer","centerContainer","rightContainer","className","id","props","React","createElement","tabIndex","style","type","Fragment"],"mappings":";AAWO,MAAMA,IAA0BA,CAAC;AAAA,EACtCC,eAAAA;AAAAA,EACAC,iBAAAA;AAAAA,EACAC,gBAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,IAAAA;AAAAA,EACA,GAAGC;AACL,MAEIC,gBAAAA,EAAAC,cAAA,UAAA;AAAA,EACEH,IAAAA;AAAAA,EACAI,UAAU;AAAA,EACVC,OAAO;AAAA,IAAE,iBAAiB;AAAA,EAAA;AAAA,EAC1BN,WAAW,oBAAoBA,CAAS,0HACtCE,GAAOK,SAAS,UAAU,+BAA+B,EAAE;AAAA,GAG5DV,KAAiBM,gBAAAA,EAAAC,cAAAD,EAAAK,UAAA,MAAGX,CAAgB,GACpCC,KAAmBK,gBAAAA,EAAAC,cAAAD,EAAAK,UAAA,MAAGV,CAAkB,GACxCC,KAAkBI,gBAAAA,EAAAC,cAAAD,EAAAK,UAAA,MAAGT,CAAiB,CACjC;"}
1
+ {"version":3,"file":"index20.js","sources":["../src/components/Header/index.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nexport interface HeaderProps {\n leftContainer?: React.ReactNode;\n centerContainer?: React.ReactNode;\n rightContainer?: React.ReactNode;\n type?: string;\n className?: string;\n id?: string;\n}\n\nexport const Header = forwardRef<HTMLElement, HeaderProps>(({\n leftContainer,\n centerContainer,\n rightContainer,\n className,\n id,\n ...props\n}, ref) => {\n return (\n <header\n ref={ref}\n id={id}\n tabIndex={-1}\n style={{ '--focus-color': 'var(--color-blue-300)' } as React.CSSProperties}\n className={`se-design-header ${className} sticky top-0 h-[48px] w-full z-[1010] bg-[var(--color-blue-600)] flex justify-between items-center focus:outline-none ${\n props?.type === 'fixed' ? 'fixed left-0 right-0 top-0' : ''\n }`}\n >\n {leftContainer && <>{leftContainer}</>}\n {centerContainer && <>{centerContainer}</>}\n {rightContainer && <>{rightContainer}</>}\n </header>\n );\n});\n"],"names":["React__default","forwardRef","Header","leftContainer","centerContainer","rightContainer","className","id","props","ref","React","createElement","tabIndex","style","type","Fragment"],"mappings":"AAWO,OAAAA,KAAA,cAAAC,SAAA;AAAA,MAAMC,sBAA8C,CAAC;AAAA,EAC1DC,eAAAA;AAAAA,EACAC,iBAAAA;AAAAA,EACAC,gBAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,IAAAA;AAAAA,EACA,GAAGC;AACL,GAAGC,MAECC,gBAAAA,EAAAC,cAAA,UAAA;AAAA,EACEF,KAAAA;AAAAA,EACAF,IAAAA;AAAAA,EACAK,UAAU;AAAA,EACVC,OAAO;AAAA,IAAE,iBAAiB;AAAA,EAAA;AAAA,EAC1BP,WAAW,oBAAoBA,CAAS,0HACtCE,GAAOM,SAAS,UAAU,+BAA+B,EAAE;AAAA,GAG5DX,KAAiBO,gBAAAA,EAAAC,cAAAD,EAAAK,UAAA,MAAGZ,CAAgB,GACpCC,KAAmBM,gBAAAA,EAAAC,cAAAD,EAAAK,UAAA,MAAGX,CAAkB,GACxCC,KAAkBK,gBAAAA,EAAAC,cAAAD,EAAAK,UAAA,MAAGV,CAAiB,CACjC,CAEX;"}
package/dist/index72.js CHANGED
@@ -1,7 +1,7 @@
1
- import { useRef as p, useLayoutEffect as a } from "react";
2
- import { getFirstFocusableElement as A, getFocusableElements as L } from "./index71.js";
1
+ import { useRef as p, useLayoutEffect as m } from "react";
2
+ import { getFirstFocusableElement as y, getFocusableElements as F } from "./index71.js";
3
3
  let f = null;
4
- function F(e) {
4
+ function L(e) {
5
5
  const n = e.composedPath();
6
6
  for (const s of n)
7
7
  if (s instanceof HTMLElement && s.tabIndex >= 0) {
@@ -12,24 +12,24 @@ function F(e) {
12
12
  function k(e) {
13
13
  (e.key === "Enter" || e.key === " ") && (f = document.activeElement);
14
14
  }
15
- typeof document < "u" && (document.addEventListener("pointerdown", F, !0), document.addEventListener("keydown", k, !0));
16
- function T() {
15
+ typeof document < "u" && (document.addEventListener("pointerdown", L, !0), document.addEventListener("keydown", k, !0));
16
+ function N() {
17
17
  const e = f;
18
18
  return f = null, e;
19
19
  }
20
- let m = null, l = null;
21
- function _(e) {
22
- l !== null && cancelAnimationFrame(l), m = e, l = requestAnimationFrame(() => {
23
- m = null, l = null;
20
+ let a = null, l = null;
21
+ function q(e) {
22
+ l !== null && cancelAnimationFrame(l), a = e, l = requestAnimationFrame(() => {
23
+ a = null, l = null;
24
24
  });
25
25
  }
26
26
  function I() {
27
27
  l !== null && (cancelAnimationFrame(l), l = null);
28
- const e = m;
29
- return m = null, e;
28
+ const e = a;
29
+ return a = null, e;
30
30
  }
31
31
  function w(e, n) {
32
- return n === "none" ? null : n === "first" ? A({
32
+ return n === "none" ? null : n === "first" ? y({
33
33
  container: e
34
34
  }) || e : n === "container" ? e : typeof n == "string" ? e.querySelector(n) : n instanceof HTMLElement ? n : null;
35
35
  }
@@ -38,74 +38,74 @@ function C({
38
38
  containerRef: n,
39
39
  restoreFocus: s = !0,
40
40
  initialFocus: d = "first",
41
- returnFocusRef: g,
41
+ returnFocusRef: A,
42
42
  portalContainerRefs: h
43
43
  }) {
44
- const u = p(null), E = p(null);
45
- return a(() => {
44
+ const o = p(null), E = p(null);
45
+ return m(() => {
46
46
  if (!e) {
47
- if (s && u.current) {
48
- const t = u.current;
49
- u.current = null, requestAnimationFrame(() => {
47
+ if (s && o.current) {
48
+ const t = o.current;
49
+ o.current = null, requestAnimationFrame(() => {
50
50
  t.isConnected && t.focus();
51
51
  });
52
52
  }
53
53
  return;
54
54
  }
55
- const r = n.current;
56
- if (!r) return;
57
- const c = g?.current ?? I() ?? f ?? document.activeElement;
55
+ const u = n.current;
56
+ if (!u) return;
57
+ const c = A?.current ?? I() ?? f ?? document.activeElement;
58
58
  if (f = null, c?.tagName === "IFRAME") {
59
- u.current = null;
59
+ o.current = null;
60
60
  return;
61
61
  }
62
- return u.current = c, r.contains(document.activeElement) || requestAnimationFrame(() => {
63
- w(r, d)?.focus();
62
+ return o.current = c, u.contains(document.activeElement) || requestAnimationFrame(() => {
63
+ w(u, d)?.focus();
64
64
  }), () => {
65
- if (s && u.current) {
66
- const t = u.current;
67
- u.current = null, requestAnimationFrame(() => {
65
+ if (s && o.current) {
66
+ const t = o.current;
67
+ o.current = null, requestAnimationFrame(() => {
68
68
  t.isConnected && t.focus();
69
69
  });
70
70
  }
71
71
  };
72
- }, [e, n, s, d]), a(() => {
72
+ }, [e, n, s, d]), m(() => {
73
73
  if (!e) return;
74
- const r = n.current;
75
- if (!r) return;
74
+ const u = n.current;
75
+ if (!u) return;
76
76
  const c = (t) => {
77
77
  if (t.key === "Tab") {
78
- const o = L({
79
- container: r
78
+ const r = F({
79
+ container: u
80
80
  });
81
- if (o.length === 0) {
82
- t.preventDefault(), r.focus();
81
+ if (r.length === 0) {
82
+ t.preventDefault(), u.focus();
83
83
  return;
84
84
  }
85
- const i = o[0], v = o[o.length - 1], y = document.activeElement;
86
- t.shiftKey && y === i ? (t.preventDefault(), v.focus()) : !t.shiftKey && y === v && (t.preventDefault(), i.focus());
85
+ const i = r[0], v = r[r.length - 1], g = document.activeElement;
86
+ t.shiftKey && g === i ? (t.preventDefault(), v.focus()) : !t.shiftKey && g === v && (t.preventDefault(), i.focus());
87
87
  }
88
88
  };
89
89
  return document.addEventListener("keydown", c, !0), () => document.removeEventListener("keydown", c, !0);
90
- }, [e, n]), a(() => {
90
+ }, [e, n]), m(() => {
91
91
  if (!e) return;
92
- const r = n.current;
93
- if (!r) return;
92
+ const u = n.current;
93
+ if (!u) return;
94
94
  const c = (t) => {
95
- const o = t.target;
96
- o?.tagName !== "IFRAME" && (r.contains(o) ? E.current = o : h?.current?.some((i) => i.current?.contains(o)) || (E.current || A({
97
- container: r
98
- }) || r).focus());
95
+ const r = t.target;
96
+ r?.tagName !== "IFRAME" && (u.contains(r) ? E.current = r : h?.current?.some((i) => i.current?.contains(r)) ? console.log("[FocusTrap] allowed portal focus:", r?.tagName, r?.className?.slice(0, 40)) : (console.log("[FocusTrap] REDIRECT:", r?.tagName, r?.className?.slice(0, 40), "→ back to container"), (E.current || y({
97
+ container: u
98
+ }) || u).focus()));
99
99
  };
100
100
  return document.addEventListener("focusin", c, !0), () => document.removeEventListener("focusin", c, !0);
101
101
  }, [e, n]), {
102
- triggerRef: u
102
+ triggerRef: o
103
103
  };
104
104
  }
105
105
  export {
106
106
  I as consumeFocusAnchor,
107
- T as consumeLastInteractedElement,
108
- _ as setFocusAnchor,
107
+ N as consumeLastInteractedElement,
108
+ q as setFocusAnchor,
109
109
  C as useFocusTrap
110
110
  };
111
111
  //# sourceMappingURL=index72.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index72.js","sources":["../src/utils/a11y/useFocusTrap.ts"],"sourcesContent":["import { useLayoutEffect, useRef } from 'react';\nimport type { MutableRefObject, RefObject } from 'react';\nimport { getFocusableElements, getFirstFocusableElement } from './focusableElements';\n\nexport interface UseFocusTrapOptions<T extends HTMLElement = HTMLElement> {\n /**\n * Whether the focus trap is active.\n */\n enabled: boolean;\n /**\n * Container element ref to trap focus within.\n */\n containerRef: React.RefObject<T | null>;\n /**\n * Whether to restore focus to the element that had focus before trap activated.\n * Default: true\n */\n restoreFocus?: boolean;\n /**\n * Initial focus target when trap activates.\n * - 'first': Focus first focusable element (default)\n * - 'container': Focus the container itself\n * - 'none': Skip initial focus — browser handles it (e.g. autofocus attribute)\n * - CSS selector: Focus element matching selector\n * - HTMLElement: Focus this specific element\n */\n initialFocus?: 'first' | 'container' | 'none' | string | HTMLElement;\n /**\n * Explicit element to restore focus to when the trap deactivates.\n * Overrides the automatic trigger capture (_lastInteractedElement / document.activeElement).\n * Use when the opener is known at call-site (e.g. a ref on the toggle button).\n */\n returnFocusRef?: React.RefObject<HTMLElement | null>;\n /**\n * Additional container refs that are logically part of this focus trap\n * (e.g., portal-rendered content from Popover/Dropdown). Focus moving to\n * these containers will NOT trigger the safety net redirect.\n */\n portalContainerRefs?: MutableRefObject<RefObject<HTMLElement | null>[]>;\n}\n\nexport interface UseFocusTrapReturn {\n /**\n * Ref to the element that had focus before trap activated.\n * Useful for manual focus restoration if needed.\n */\n triggerRef: React.MutableRefObject<HTMLElement | null>;\n}\n\n// Module-level trigger tracking: React's commit phase is bottom-up, so by the\n// time useFocusTrap's useLayoutEffect runs, document.activeElement may already\n// be the autoFocus element inside the modal rather than the opener button.\n// We capture the last interacted element via pointerdown/keydown listeners\n// (which fire before any React state update commits) to work around this.\nlet _lastInteractedElement: HTMLElement | null = null;\n\nfunction _onPointerDown(e: PointerEvent): void {\n // Walk composedPath to find the nearest focusable element being pressed.\n const path = e.composedPath();\n for (const node of path) {\n if (node instanceof HTMLElement && node.tabIndex >= 0) {\n _lastInteractedElement = node;\n return;\n }\n }\n}\n\nfunction _onKeyDown(e: KeyboardEvent): void {\n // Enter/Space on a focused button will synthesise a click — capture before that.\n if (e.key === 'Enter' || e.key === ' ') {\n _lastInteractedElement = document.activeElement as HTMLElement;\n }\n}\n\nif (typeof document !== 'undefined') {\n document.addEventListener('pointerdown', _onPointerDown, true);\n document.addEventListener('keydown', _onKeyDown, true);\n}\n\n/**\n * Returns (and clears) the last element interacted with before a React commit.\n * Used by SidebarOverlay complementary mode to seed its trigger ref without\n * relying on document.activeElement timing.\n */\nexport function consumeLastInteractedElement(): HTMLElement | null {\n const el = _lastInteractedElement;\n _lastInteractedElement = null;\n return el;\n}\n\n// Focus anchor — explicit stable return-focus target, higher priority than\n// _lastInteractedElement. Auto-clears via setTimeout(0) to prevent a stale\n// anchor leaking to an unrelated open.\nlet _focusAnchor: HTMLElement | null = null;\nlet _focusAnchorClearFrame: ReturnType<typeof requestAnimationFrame> | null = null;\n\n/**\n * Sets an explicit focus-return anchor element.\n * Call this before dispatching an action that will open a modal or sidebar,\n * when the natural last-interacted element is not the right return target\n * (e.g. a popover menu item that will be unmounted when the popover closes).\n */\nexport function setFocusAnchor(el: HTMLElement | null): void {\n if (_focusAnchorClearFrame !== null) cancelAnimationFrame(_focusAnchorClearFrame);\n _focusAnchor = el;\n // Auto-clear if not consumed — prevents stale anchor leaking to unrelated opens.\n // rAF fires after React has committed and painted, giving useFocusTrap time to\n // consume the anchor before it is discarded.\n _focusAnchorClearFrame = requestAnimationFrame(() => {\n _focusAnchor = null;\n _focusAnchorClearFrame = null;\n });\n}\n\n/**\n * Returns (and clears) the focus anchor if one was set, otherwise null.\n * Used internally by useFocusTrap and SidebarOverlay.\n */\nexport function consumeFocusAnchor(): HTMLElement | null {\n if (_focusAnchorClearFrame !== null) {\n cancelAnimationFrame(_focusAnchorClearFrame);\n _focusAnchorClearFrame = null;\n }\n const el = _focusAnchor;\n _focusAnchor = null;\n return el;\n}\n\n/**\n * Resolve the initial focus target based on the initialFocus option.\n */\nfunction resolveInitialFocusTarget(\n container: HTMLElement,\n initialFocus: 'first' | 'container' | 'none' | string | HTMLElement\n): HTMLElement | null {\n if (initialFocus === 'none') return null;\n if (initialFocus === 'first') {\n return getFirstFocusableElement({ container }) || container;\n }\n if (initialFocus === 'container') {\n return container;\n }\n if (typeof initialFocus === 'string') {\n return container.querySelector<HTMLElement>(initialFocus);\n }\n if (initialFocus instanceof HTMLElement) {\n return initialFocus;\n }\n return null;\n}\n\n/**\n * Hook to trap focus within a container (for modals, dialogs, drawers).\n *\n * Implements WCAG 2.1 focus trap pattern:\n * - Moves focus into container on activation\n * - Wraps Tab/Shift+Tab navigation within container\n * - Restores focus to trigger element on deactivation\n * - Safety net: catches focus escaping via other means\n * - Handles autoFocus content: captures trigger before autoFocus fires\n * - Handles {isOpen && <Modal>} pattern: restores focus on unmount\n *\n * Note: For Escape key handling, use `useDismissOnEscape` hook separately.\n * This keeps focus trap (accessibility) separate from Escape handling (UX).\n *\n * @example\n * ```tsx\n * const MyModal = ({ isOpen, onClose }) => {\n * const containerRef = useRef<HTMLDivElement>(null);\n *\n * // Escape handling (UX)\n * useDismissOnEscape({\n * containerRef,\n * onDismiss: onClose,\n * enabled: isOpen\n * });\n *\n * // Focus trap (accessibility)\n * const { triggerRef } = useFocusTrap({\n * enabled: isOpen,\n * containerRef,\n * restoreFocus: true\n * });\n *\n * return (\n * <div ref={containerRef}>\n * <button>First</button>\n * <button>Second</button>\n * </div>\n * );\n * };\n * ```\n */\nexport function useFocusTrap<T extends HTMLElement = HTMLElement>({\n enabled,\n containerRef,\n restoreFocus = true,\n initialFocus = 'first',\n returnFocusRef,\n portalContainerRefs,\n}: UseFocusTrapOptions<T>): UseFocusTrapReturn {\n const triggerRef = useRef<HTMLElement | null>(null);\n const lastFocusedInContainer = useRef<HTMLElement | null>(null);\n\n // Focus management: save trigger, move focus into container on activate, restore on deactivate\n useLayoutEffect(() => {\n if (!enabled) {\n // Restore focus to trigger when trap deactivates\n if (restoreFocus && triggerRef.current) {\n const el = triggerRef.current;\n triggerRef.current = null;\n requestAnimationFrame(() => {\n if (el.isConnected) el.focus();\n });\n }\n return;\n }\n\n const container = containerRef.current;\n if (!container) return;\n\n // Resolve trigger: explicit returnFocusRef wins, then focusAnchor (explicitly set\n // by caller for two-step flows like popover menu → modal), then the pre-commit\n // interaction record, then document.activeElement as final fallback.\n const previousActiveElement = returnFocusRef?.current ?? consumeFocusAnchor() ?? _lastInteractedElement ?? (document.activeElement as HTMLElement);\n _lastInteractedElement = null;\n\n // iframes manage their own internal focus. document.activeElement only ever\n // resolves to the <iframe> element from the parent doc — calling .focus()\n // on any parent-doc element forcibly blurs the iframe content (kills caret\n // in textareas, cancels native <select> dropdowns). Skip capture so the\n // auto-focus on open and focus-restore on close short-circuit on null trigger.\n if (previousActiveElement?.tagName === 'IFRAME') {\n triggerRef.current = null;\n return;\n }\n\n triggerRef.current = previousActiveElement;\n\n // Only move initial focus if autoFocus hasn't already placed it inside the container.\n if (!container.contains(document.activeElement)) {\n requestAnimationFrame(() => {\n resolveInitialFocusTarget(container, initialFocus)?.focus();\n });\n }\n\n // Restore focus on unmount while enabled (covers {isOpen && <Modal>} pattern\n // where the component unmounts before enabled can transition true → false)\n return () => {\n if (restoreFocus && triggerRef.current) {\n const el = triggerRef.current;\n triggerRef.current = null;\n requestAnimationFrame(() => {\n if (el.isConnected) el.focus();\n });\n }\n };\n }, [enabled, containerRef, restoreFocus, initialFocus]);\n\n // Focus trap: Tab wrapping (only when enabled)\n useLayoutEffect(() => {\n if (!enabled) return;\n\n const container = containerRef.current;\n if (!container) return;\n\n const handleKeyDown = (e: KeyboardEvent) => {\n // Tab wrapping\n if (e.key === 'Tab') {\n const focusables = getFocusableElements({ container });\n\n if (focusables.length === 0) {\n e.preventDefault();\n container.focus();\n return;\n }\n\n const first = focusables[0];\n const last = focusables[focusables.length - 1];\n const activeElement = document.activeElement;\n\n if (e.shiftKey && activeElement === first) {\n e.preventDefault();\n last.focus();\n } else if (!e.shiftKey && activeElement === last) {\n e.preventDefault();\n first.focus();\n }\n }\n };\n\n document.addEventListener('keydown', handleKeyDown, true);\n return () => document.removeEventListener('keydown', handleKeyDown, true);\n }, [enabled, containerRef]);\n\n // Focus trap safety net: catch focus escaping\n useLayoutEffect(() => {\n if (!enabled) return;\n\n const container = containerRef.current;\n if (!container) return;\n\n const handleFocusIn = (e: FocusEvent) => {\n const target = e.target as Node;\n\n // iframe focus is opaque from the parent doc — leave it alone, otherwise\n // a click into the iframe gets yanked back into the trap.\n if ((target as Element | null)?.tagName === 'IFRAME') return;\n\n if (container.contains(target)) {\n lastFocusedInContainer.current = target as HTMLElement;\n } else if (portalContainerRefs?.current?.some(ref => ref.current?.contains(target))) {\n // Focus is in a registered portal — allow it, but don't update\n // lastFocusedInContainer so safety net restores to the last main-container\n // element (e.g., the dropdown trigger) when the portal unmounts\n } else {\n // Focus escaped — redirect back\n const fallback = lastFocusedInContainer.current\n || getFirstFocusableElement({ container })\n || container;\n fallback.focus();\n }\n };\n\n document.addEventListener('focusin', handleFocusIn, true);\n return () => document.removeEventListener('focusin', handleFocusIn, true);\n }, [enabled, containerRef]);\n\n return { triggerRef };\n}\n"],"names":["_lastInteractedElement","_onPointerDown","e","path","composedPath","node","HTMLElement","tabIndex","_onKeyDown","key","document","activeElement","addEventListener","consumeLastInteractedElement","el","_focusAnchor","_focusAnchorClearFrame","setFocusAnchor","cancelAnimationFrame","requestAnimationFrame","consumeFocusAnchor","resolveInitialFocusTarget","container","initialFocus","getFirstFocusableElement","querySelector","useFocusTrap","enabled","containerRef","restoreFocus","returnFocusRef","portalContainerRefs","triggerRef","useRef","lastFocusedInContainer","useLayoutEffect","current","isConnected","focus","previousActiveElement","tagName","contains","handleKeyDown","focusables","getFocusableElements","length","preventDefault","first","last","shiftKey","removeEventListener","handleFocusIn","target","some","ref"],"mappings":";;AAsDA,IAAIA,IAA6C;AAEjD,SAASC,EAAeC,GAAuB;AAE7C,QAAMC,IAAOD,EAAEE,aAAAA;AACf,aAAWC,KAAQF;AACjB,QAAIE,aAAgBC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,EAAW,CAAC,GACpBK,IAAOL,EAAWA,EAAWE,SAAS,CAAC,GACvClC,IAAgBD,SAASC;AAE/B,QAAIT,EAAE+C,YAAYtC,MAAkBoC,KAClC7C,EAAE4C,eAAAA,GACFE,EAAKV,MAAAA,KACI,CAACpC,EAAE+C,YAAYtC,MAAkBqC,MAC1C9C,EAAE4C,eAAAA,GACFC,EAAMT,MAAAA;AAAAA,MAEV;AAAA,IACF;AAEA5B,oBAASE,iBAAiB,WAAW8B,GAAe,EAAI,GACjD,MAAMhC,SAASwC,oBAAoB,WAAWR,GAAe,EAAI;AAAA,EAC1E,GAAG,CAACf,GAASC,CAAY,CAAC,GAG1BO,EAAgB,MAAM;AACpB,QAAI,CAACR,EAAS;AAEd,UAAML,IAAYM,EAAaQ;AAC/B,QAAI,CAACd,EAAW;AAEhB,UAAM6B,IAAgBA,CAACjD,MAAkB;AACvC,YAAMkD,IAASlD,EAAEkD;AAIjB,MAAKA,GAA2BZ,YAAY,aAExClB,EAAUmB,SAASW,CAAM,IAC3BlB,EAAuBE,UAAUgB,IACxBrB,GAAqBK,SAASiB,KAAKC,CAAAA,MAAOA,EAAIlB,SAASK,SAASW,CAAM,CAAC,MAM/DlB,EAAuBE,WACnCZ,EAAyB;AAAA,QAAEF,WAAAA;AAAAA,MAAAA,CAAW,KACtCA,GACIgB,MAAAA;AAAAA,IAEb;AAEA5B,oBAASE,iBAAiB,WAAWuC,GAAe,EAAI,GACjD,MAAMzC,SAASwC,oBAAoB,WAAWC,GAAe,EAAI;AAAA,EAC1E,GAAG,CAACxB,GAASC,CAAY,CAAC,GAEnB;AAAA,IAAEI,YAAAA;AAAAA,EAAAA;AACX;"}
1
+ {"version":3,"file":"index72.js","sources":["../src/utils/a11y/useFocusTrap.ts"],"sourcesContent":["import { useLayoutEffect, useRef } from 'react';\nimport type { MutableRefObject, RefObject } from 'react';\nimport { getFocusableElements, getFirstFocusableElement } from './focusableElements';\n\nexport interface UseFocusTrapOptions<T extends HTMLElement = HTMLElement> {\n /**\n * Whether the focus trap is active.\n */\n enabled: boolean;\n /**\n * Container element ref to trap focus within.\n */\n containerRef: React.RefObject<T | null>;\n /**\n * Whether to restore focus to the element that had focus before trap activated.\n * Default: true\n */\n restoreFocus?: boolean;\n /**\n * Initial focus target when trap activates.\n * - 'first': Focus first focusable element (default)\n * - 'container': Focus the container itself\n * - 'none': Skip initial focus — browser handles it (e.g. autofocus attribute)\n * - CSS selector: Focus element matching selector\n * - HTMLElement: Focus this specific element\n */\n initialFocus?: 'first' | 'container' | 'none' | string | HTMLElement;\n /**\n * Explicit element to restore focus to when the trap deactivates.\n * Overrides the automatic trigger capture (_lastInteractedElement / document.activeElement).\n * Use when the opener is known at call-site (e.g. a ref on the toggle button).\n */\n returnFocusRef?: React.RefObject<HTMLElement | null>;\n /**\n * Additional container refs that are logically part of this focus trap\n * (e.g., portal-rendered content from Popover/Dropdown). Focus moving to\n * these containers will NOT trigger the safety net redirect.\n */\n portalContainerRefs?: MutableRefObject<RefObject<HTMLElement | null>[]>;\n}\n\nexport interface UseFocusTrapReturn {\n /**\n * Ref to the element that had focus before trap activated.\n * Useful for manual focus restoration if needed.\n */\n triggerRef: React.MutableRefObject<HTMLElement | null>;\n}\n\n// Module-level trigger tracking: React's commit phase is bottom-up, so by the\n// time useFocusTrap's useLayoutEffect runs, document.activeElement may already\n// be the autoFocus element inside the modal rather than the opener button.\n// We capture the last interacted element via pointerdown/keydown listeners\n// (which fire before any React state update commits) to work around this.\nlet _lastInteractedElement: HTMLElement | null = null;\n\nfunction _onPointerDown(e: PointerEvent): void {\n // Walk composedPath to find the nearest focusable element being pressed.\n const path = e.composedPath();\n for (const node of path) {\n if (node instanceof HTMLElement && node.tabIndex >= 0) {\n _lastInteractedElement = node;\n return;\n }\n }\n}\n\nfunction _onKeyDown(e: KeyboardEvent): void {\n // Enter/Space on a focused button will synthesise a click — capture before that.\n if (e.key === 'Enter' || e.key === ' ') {\n _lastInteractedElement = document.activeElement as HTMLElement;\n }\n}\n\nif (typeof document !== 'undefined') {\n document.addEventListener('pointerdown', _onPointerDown, true);\n document.addEventListener('keydown', _onKeyDown, true);\n}\n\n/**\n * Returns (and clears) the last element interacted with before a React commit.\n * Used by SidebarOverlay complementary mode to seed its trigger ref without\n * relying on document.activeElement timing.\n */\nexport function consumeLastInteractedElement(): HTMLElement | null {\n const el = _lastInteractedElement;\n _lastInteractedElement = null;\n return el;\n}\n\n// Focus anchor — explicit stable return-focus target, higher priority than\n// _lastInteractedElement. Auto-clears via setTimeout(0) to prevent a stale\n// anchor leaking to an unrelated open.\nlet _focusAnchor: HTMLElement | null = null;\nlet _focusAnchorClearFrame: ReturnType<typeof requestAnimationFrame> | null = null;\n\n/**\n * Sets an explicit focus-return anchor element.\n * Call this before dispatching an action that will open a modal or sidebar,\n * when the natural last-interacted element is not the right return target\n * (e.g. a popover menu item that will be unmounted when the popover closes).\n */\nexport function setFocusAnchor(el: HTMLElement | null): void {\n if (_focusAnchorClearFrame !== null) cancelAnimationFrame(_focusAnchorClearFrame);\n _focusAnchor = el;\n // Auto-clear if not consumed — prevents stale anchor leaking to unrelated opens.\n // rAF fires after React has committed and painted, giving useFocusTrap time to\n // consume the anchor before it is discarded.\n _focusAnchorClearFrame = requestAnimationFrame(() => {\n _focusAnchor = null;\n _focusAnchorClearFrame = null;\n });\n}\n\n/**\n * Returns (and clears) the focus anchor if one was set, otherwise null.\n * Used internally by useFocusTrap and SidebarOverlay.\n */\nexport function consumeFocusAnchor(): HTMLElement | null {\n if (_focusAnchorClearFrame !== null) {\n cancelAnimationFrame(_focusAnchorClearFrame);\n _focusAnchorClearFrame = null;\n }\n const el = _focusAnchor;\n _focusAnchor = null;\n return el;\n}\n\n/**\n * Resolve the initial focus target based on the initialFocus option.\n */\nfunction resolveInitialFocusTarget(\n container: HTMLElement,\n initialFocus: 'first' | 'container' | 'none' | string | HTMLElement\n): HTMLElement | null {\n if (initialFocus === 'none') return null;\n if (initialFocus === 'first') {\n return getFirstFocusableElement({ container }) || container;\n }\n if (initialFocus === 'container') {\n return container;\n }\n if (typeof initialFocus === 'string') {\n return container.querySelector<HTMLElement>(initialFocus);\n }\n if (initialFocus instanceof HTMLElement) {\n return initialFocus;\n }\n return null;\n}\n\n/**\n * Hook to trap focus within a container (for modals, dialogs, drawers).\n *\n * Implements WCAG 2.1 focus trap pattern:\n * - Moves focus into container on activation\n * - Wraps Tab/Shift+Tab navigation within container\n * - Restores focus to trigger element on deactivation\n * - Safety net: catches focus escaping via other means\n * - Handles autoFocus content: captures trigger before autoFocus fires\n * - Handles {isOpen && <Modal>} pattern: restores focus on unmount\n *\n * Note: For Escape key handling, use `useDismissOnEscape` hook separately.\n * This keeps focus trap (accessibility) separate from Escape handling (UX).\n *\n * @example\n * ```tsx\n * const MyModal = ({ isOpen, onClose }) => {\n * const containerRef = useRef<HTMLDivElement>(null);\n *\n * // Escape handling (UX)\n * useDismissOnEscape({\n * containerRef,\n * onDismiss: onClose,\n * enabled: isOpen\n * });\n *\n * // Focus trap (accessibility)\n * const { triggerRef } = useFocusTrap({\n * enabled: isOpen,\n * containerRef,\n * restoreFocus: true\n * });\n *\n * return (\n * <div ref={containerRef}>\n * <button>First</button>\n * <button>Second</button>\n * </div>\n * );\n * };\n * ```\n */\nexport function useFocusTrap<T extends HTMLElement = HTMLElement>({\n enabled,\n containerRef,\n restoreFocus = true,\n initialFocus = 'first',\n returnFocusRef,\n portalContainerRefs,\n}: UseFocusTrapOptions<T>): UseFocusTrapReturn {\n const triggerRef = useRef<HTMLElement | null>(null);\n const lastFocusedInContainer = useRef<HTMLElement | null>(null);\n\n // Focus management: save trigger, move focus into container on activate, restore on deactivate\n useLayoutEffect(() => {\n if (!enabled) {\n // Restore focus to trigger when trap deactivates\n if (restoreFocus && triggerRef.current) {\n const el = triggerRef.current;\n triggerRef.current = null;\n requestAnimationFrame(() => {\n if (el.isConnected) el.focus();\n });\n }\n return;\n }\n\n const container = containerRef.current;\n if (!container) return;\n\n // Resolve trigger: explicit returnFocusRef wins, then focusAnchor (explicitly set\n // by caller for two-step flows like popover menu → modal), then the pre-commit\n // interaction record, then document.activeElement as final fallback.\n const previousActiveElement = returnFocusRef?.current ?? consumeFocusAnchor() ?? _lastInteractedElement ?? (document.activeElement as HTMLElement);\n _lastInteractedElement = null;\n\n // iframes manage their own internal focus. document.activeElement only ever\n // resolves to the <iframe> element from the parent doc — calling .focus()\n // on any parent-doc element forcibly blurs the iframe content (kills caret\n // in textareas, cancels native <select> dropdowns). Skip capture so the\n // auto-focus on open and focus-restore on close short-circuit on null trigger.\n if (previousActiveElement?.tagName === 'IFRAME') {\n triggerRef.current = null;\n return;\n }\n\n triggerRef.current = previousActiveElement;\n\n // Only move initial focus if autoFocus hasn't already placed it inside the container.\n if (!container.contains(document.activeElement)) {\n requestAnimationFrame(() => {\n resolveInitialFocusTarget(container, initialFocus)?.focus();\n });\n }\n\n // Restore focus on unmount while enabled (covers {isOpen && <Modal>} pattern\n // where the component unmounts before enabled can transition true → false)\n return () => {\n if (restoreFocus && triggerRef.current) {\n const el = triggerRef.current;\n triggerRef.current = null;\n requestAnimationFrame(() => {\n if (el.isConnected) el.focus();\n });\n }\n };\n }, [enabled, containerRef, restoreFocus, initialFocus]);\n\n // Focus trap: Tab wrapping (only when enabled)\n useLayoutEffect(() => {\n if (!enabled) return;\n\n const container = containerRef.current;\n if (!container) return;\n\n const handleKeyDown = (e: KeyboardEvent) => {\n // Tab wrapping\n if (e.key === 'Tab') {\n const focusables = getFocusableElements({ container });\n\n if (focusables.length === 0) {\n e.preventDefault();\n container.focus();\n return;\n }\n\n const first = focusables[0];\n const last = focusables[focusables.length - 1];\n const activeElement = document.activeElement;\n\n if (e.shiftKey && activeElement === first) {\n e.preventDefault();\n last.focus();\n } else if (!e.shiftKey && activeElement === last) {\n e.preventDefault();\n first.focus();\n }\n }\n };\n\n document.addEventListener('keydown', handleKeyDown, true);\n return () => document.removeEventListener('keydown', handleKeyDown, true);\n }, [enabled, containerRef]);\n\n // Focus trap safety net: catch focus escaping\n useLayoutEffect(() => {\n if (!enabled) return;\n\n const container = containerRef.current;\n if (!container) return;\n\n const handleFocusIn = (e: FocusEvent) => {\n const target = e.target as Node;\n\n // iframe focus is opaque from the parent doc — leave it alone, otherwise\n // a click into the iframe gets yanked back into the trap.\n if ((target as Element | null)?.tagName === 'IFRAME') return;\n\n if (container.contains(target)) {\n lastFocusedInContainer.current = target as HTMLElement;\n } else if (portalContainerRefs?.current?.some(ref => ref.current?.contains(target))) {\n // Focus is in a registered portal — allow it, but don't update\n // lastFocusedInContainer so safety net restores to the last main-container\n // element (e.g., the dropdown trigger) when the portal unmounts\n console.log('[FocusTrap] allowed portal focus:', (target as HTMLElement)?.tagName, (target as HTMLElement)?.className?.slice(0, 40));\n } else {\n // Focus escaped — redirect back\n console.log('[FocusTrap] REDIRECT:', (target as HTMLElement)?.tagName, (target as HTMLElement)?.className?.slice(0, 40), '→ back to container');\n const fallback = lastFocusedInContainer.current\n || getFirstFocusableElement({ container })\n || container;\n fallback.focus();\n }\n };\n\n document.addEventListener('focusin', handleFocusIn, true);\n return () => document.removeEventListener('focusin', handleFocusIn, true);\n }, [enabled, containerRef]);\n\n return { triggerRef };\n}\n"],"names":["_lastInteractedElement","_onPointerDown","e","path","composedPath","node","HTMLElement","tabIndex","_onKeyDown","key","document","activeElement","addEventListener","consumeLastInteractedElement","el","_focusAnchor","_focusAnchorClearFrame","setFocusAnchor","cancelAnimationFrame","requestAnimationFrame","consumeFocusAnchor","resolveInitialFocusTarget","container","initialFocus","getFirstFocusableElement","querySelector","useFocusTrap","enabled","containerRef","restoreFocus","returnFocusRef","portalContainerRefs","triggerRef","useRef","lastFocusedInContainer","useLayoutEffect","current","isConnected","focus","previousActiveElement","tagName","contains","handleKeyDown","focusables","getFocusableElements","length","preventDefault","first","last","shiftKey","removeEventListener","handleFocusIn","target","some","ref","console","log","className","slice"],"mappings":";;AAsDA,IAAIA,IAA6C;AAEjD,SAASC,EAAeC,GAAuB;AAE7C,QAAMC,IAAOD,E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AAAA,IAAEI,YAAAA;AAAAA,EAAAA;AACX;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "se-design",
3
- "version": "1.0.83-dev.4",
3
+ "version": "1.0.83-dev.5",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "exports": {