@kakadu/components 3.0.0 → 3.1.1

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.
@@ -0,0 +1,8 @@
1
+ import { type ComponentType, type ReactNode } from 'react';
2
+ export type DecoratorType = ComponentType<{
3
+ children: ReactNode;
4
+ }>;
5
+ export default function Decorators({ decorators, children, }: {
6
+ readonly decorators: DecoratorType[];
7
+ readonly children: ReactNode;
8
+ }): ReactNode;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("../jsx-runtime-BB_1_6y_.js");function n({decorators:e,children:t}){return e.length===0?t:e.reduceRight((u,r)=>i.jsxRuntimeExports.jsx(r,{children:u}),t)}exports.default=n;
@@ -0,0 +1,13 @@
1
+ import { j as u } from "../jsx-runtime-B4hRZ52C.mjs";
2
+ function o({
3
+ decorators: t,
4
+ children: r
5
+ }) {
6
+ return t.length === 0 ? r : t.reduceRight(
7
+ (e, n) => /* @__PURE__ */ u.jsx(n, { children: e }),
8
+ r
9
+ );
10
+ }
11
+ export {
12
+ o as default
13
+ };
@@ -1,4 +1,5 @@
1
1
  import { type ComponentType, type ReactNode } from 'react';
2
+ import { type DecoratorType } from './decorators';
2
3
  type InitialFocusElement = HTMLElement | null;
3
4
  type ModalProviderProperties<Data = any> = {
4
5
  isVisible: boolean;
@@ -6,9 +7,6 @@ type ModalProviderProperties<Data = any> = {
6
7
  close?: (data?: Data) => void;
7
8
  };
8
9
  export declare function useModalContext<Data = any>(): ModalProviderProperties<Data>;
9
- export type DecoratorType = ComponentType<{
10
- children: ReactNode;
11
- }>;
12
10
  export type ModalProperties<Data = any> = {
13
11
  readonly root?: HTMLElement | ShadowRoot;
14
12
  readonly outerDecorators?: DecoratorType[];
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("../jsx-runtime-BB_1_6y_.js"),e=require("react"),E=require("@kuma-ui/core"),P=require("react-dom"),$=require("../focus-trap-react-CcpTuiJi.js"),B=require("../icons/icon.js"),D=require("./text-button.js"),I=e.createContext({isVisible:!1}),{Provider:A}=I;function y(){return e.useContext(I)}function z(){const{close:n}=y(),r=e.useCallback(()=>{n==null||n()},[n]);return s.jsxRuntimeExports.jsxs(s.jsxRuntimeExports.Fragment,{children:[s.jsxRuntimeExports.jsx("div",{className:"kakadu-components-2543813221"}),s.jsxRuntimeExports.jsx("div",{className:"kakadu-components-840864829",children:s.jsxRuntimeExports.jsx(D.default,{iconLeft:B.IconType.times,label:"Close",className:"kakadu-components-3855719072",onClick:r})})]})}function q({decorators:n,children:r}){return n.length===0?r:n.reduceRight((c,i)=>s.jsxRuntimeExports.jsx(i,{children:c}),r)}function G({root:n,outerDecorators:r=[],innerDecorators:c=[],label:i,maxWidth:u,className:l,isVisible:o,isFullWidth:f=!1,shouldCloseOnOutsideClick:p=!0,shouldCloseOnEscapePress:d=!0,showCloseButton:x=!0,onClose:a,children:N}){const v=e.useRef(null),h=e.useRef(null),[M,L]=e.useState(!1),[m,j]=e.useState(!1),b=e.useCallback(t=>{v.current=t,j(!1)},[]),R=e.useRef(null),w=e.useCallback(t=>{t&&(R.current=t)},[]),[T,C]=e.useState(o??!1),S=e.useMemo(()=>({isVisible:T,setInitialFocus:w,close:b}),[T,w,b]);e.useEffect(()=>{o&&(L(!0),C(!0))},[o]),e.useEffect(()=>{if(o){const t=setTimeout(()=>{j(!0)},100);return()=>{clearTimeout(t)}}j(!1)},[o]),e.useEffect(()=>{if(M&&!m){const t=setTimeout(()=>{a==null||a(v.current??void 0),C(!1)},370);return()=>{clearTimeout(t)}}},[M,m,a]),e.useEffect(()=>{const t=h.current;if(o&&p&&t){const k=_=>{t===_.target&&j(!1)};return t.addEventListener("click",k),()=>{t.removeEventListener("click",k)}}},[o,p]),e.useEffect(()=>{if(!o||!d)return;const t=k=>{k.key==="Escape"&&j(!1)};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[o,d]);const F=e.useMemo(()=>({initialFocus:()=>R.current??void 0,onActivate:()=>{var t;return(t=R.current)==null?void 0:t.focus()}}),[]),g=s.jsxRuntimeExports.jsx(q,{decorators:r,children:s.jsxRuntimeExports.jsx("div",{"aria-hidden":!m,style:{"--max-width":u?`${u}px`:void 0},className:E.cx("kakadu-components-4119461136",m&&"kakadu-components-2522346797",l),children:s.jsxRuntimeExports.jsx(q,{decorators:c,children:s.jsxRuntimeExports.jsx($.focusTrapReactExports.FocusTrap,{active:m,focusTrapOptions:F,children:s.jsxRuntimeExports.jsx("div",{ref:h,className:"kakadu-components-4011815997",children:s.jsxRuntimeExports.jsx("div",{role:"dialog","aria-modal":"true","aria-label":i??"Modal",className:E.cx("kakadu-components-3324483532",f&&"kakadu-components-3799971070",m&&"kakadu-components-968755580"),children:s.jsxRuntimeExports.jsxs(A,{value:S,children:[x?s.jsxRuntimeExports.jsx(z,{}):null,s.jsxRuntimeExports.jsx("div",{className:E.cx("kakadu-components-633990035",f&&"kakadu-components-171969824"),children:N})]})})})})})})});return n?P.createPortal(g,n):g}function H(n,r){const[c,i]=e.useState(!1),u=e.useRef(void 0),l=e.useRef(null),o=e.useCallback(async d=>(i(!0),l.current=d??document.activeElement,new Promise(x=>{u.current=x})),[]),f=e.useCallback(d=>{var x;if(i(!1),(x=u.current)==null||x.call(u,d),u.current=void 0,l.current){const a=l.current;a.isConnected&&a.focus(),l.current=null}},[]),p=e.useMemo(()=>s.jsxRuntimeExports.jsx(n,{...r,isVisible:c,onClose:f}),[n,r,c,f]);return e.useMemo(()=>({isVisible:c,show:o,modal:p}),[c,o,p])}exports.default=G;exports.useModal=H;exports.useModalContext=y;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("../jsx-runtime-BB_1_6y_.js"),e=require("react"),E=require("@kuma-ui/core"),P=require("react-dom"),$=require("../focus-trap-react-CcpTuiJi.js"),B=require("../icons/icon.js"),A=require("./text-button.js"),I=require("./decorators.js"),y=e.createContext({isVisible:!1}),{Provider:D}=y;function N(){return e.useContext(y)}function z(){const{close:o}=N(),u=e.useCallback(()=>{o==null||o()},[o]);return s.jsxRuntimeExports.jsxs(s.jsxRuntimeExports.Fragment,{children:[s.jsxRuntimeExports.jsx("div",{className:"kakadu-components-2543813221"}),s.jsxRuntimeExports.jsx("div",{className:"kakadu-components-840864829",children:s.jsxRuntimeExports.jsx(A.default,{iconLeft:B.IconType.times,label:"Close",className:"kakadu-components-3855719072",onClick:u})})]})}function G({root:o,outerDecorators:u=[],innerDecorators:a=[],label:k,maxWidth:r,className:i,isVisible:n,isFullWidth:x=!1,shouldCloseOnOutsideClick:f=!0,shouldCloseOnEscapePress:l=!0,showCloseButton:d=!0,onClose:c,children:g}){const v=e.useRef(null),M=e.useRef(null),[h,L]=e.useState(!1),[m,p]=e.useState(!1),b=e.useCallback(t=>{v.current=t,p(!1)},[]),R=e.useRef(null),w=e.useCallback(t=>{t&&(R.current=t)},[]),[T,q]=e.useState(n??!1),S=e.useMemo(()=>({isVisible:T,setInitialFocus:w,close:b}),[T,w,b]);e.useEffect(()=>{n&&(L(!0),q(!0))},[n]),e.useEffect(()=>{if(n){const t=setTimeout(()=>{p(!0)},100);return()=>{clearTimeout(t)}}p(!1)},[n]),e.useEffect(()=>{if(h&&!m){const t=setTimeout(()=>{c==null||c(v.current??void 0),q(!1)},370);return()=>{clearTimeout(t)}}},[h,m,c]),e.useEffect(()=>{const t=M.current;if(n&&f&&t){const j=_=>{t===_.target&&p(!1)};return t.addEventListener("click",j),()=>{t.removeEventListener("click",j)}}},[n,f]),e.useEffect(()=>{if(!n||!l)return;const t=j=>{j.key==="Escape"&&p(!1)};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[n,l]);const F=e.useMemo(()=>({initialFocus:()=>R.current??void 0,onActivate:()=>{var t;return(t=R.current)==null?void 0:t.focus()}}),[]),C=s.jsxRuntimeExports.jsx(I.default,{decorators:u,children:s.jsxRuntimeExports.jsx("div",{"aria-hidden":!m,style:{"--max-width":r?`${r}px`:void 0},className:E.cx("kakadu-components-4119461136",m&&"kakadu-components-2522346797",i),children:s.jsxRuntimeExports.jsx(I.default,{decorators:a,children:s.jsxRuntimeExports.jsx($.focusTrapReactExports.FocusTrap,{active:m,focusTrapOptions:F,children:s.jsxRuntimeExports.jsx("div",{ref:M,className:"kakadu-components-4011815997",children:s.jsxRuntimeExports.jsx("div",{role:"dialog","aria-modal":"true","aria-label":k??"Modal",className:E.cx("kakadu-components-3324483532",x&&"kakadu-components-3799971070",m&&"kakadu-components-968755580"),children:s.jsxRuntimeExports.jsxs(D,{value:S,children:[d?s.jsxRuntimeExports.jsx(z,{}):null,s.jsxRuntimeExports.jsx("div",{className:E.cx("kakadu-components-633990035",x&&"kakadu-components-171969824"),children:g})]})})})})})})});return o?P.createPortal(C,o):C}function H(o,u){const[a,k]=e.useState(!1),r=e.useRef(void 0),i=e.useRef(null),n=e.useCallback(async l=>(k(!0),i.current=l??document.activeElement,new Promise(d=>{r.current=d})),[]),x=e.useCallback(l=>{var d;if(k(!1),(d=r.current)==null||d.call(r,l),r.current=void 0,i.current){const c=i.current;c.isConnected&&c.focus(),i.current=null}},[]),f=e.useMemo(()=>s.jsxRuntimeExports.jsx(o,{...u,isVisible:a,onClose:x}),[o,u,a,x]);return e.useMemo(()=>({isVisible:a,show:n,modal:f}),[a,n,f])}exports.default=G;exports.useModal=H;exports.useModalContext=N;
@@ -1,10 +1,11 @@
1
1
  import { j as t } from "../jsx-runtime-B4hRZ52C.mjs";
2
- import { createContext as q, useRef as v, useState as w, useCallback as j, useMemo as T, useEffect as p, useContext as z } from "react";
2
+ import { createContext as q, useRef as p, useState as w, useCallback as v, useMemo as T, useEffect as x, useContext as z } from "react";
3
3
  import { cx as I } from "@kuma-ui/core";
4
4
  import { createPortal as G } from "react-dom";
5
5
  import { f as H } from "../focus-trap-react-DYXrtbDH.mjs";
6
6
  import { IconType as J } from "../icons/icon.mjs";
7
7
  import K from "./text-button.mjs";
8
+ import C from "./decorators.mjs";
8
9
  const B = q({
9
10
  isVisible: !1
10
11
  }), {
@@ -15,118 +16,112 @@ function U() {
15
16
  }
16
17
  function V() {
17
18
  const {
18
- close: n
19
- } = U(), o = j(() => {
20
- n == null || n();
21
- }, [n]);
19
+ close: o
20
+ } = U(), a = v(() => {
21
+ o == null || o();
22
+ }, [o]);
22
23
  return /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
23
24
  /* @__PURE__ */ t.jsx("div", { className: "kakadu-components-2543813221" }),
24
- /* @__PURE__ */ t.jsx("div", { className: "kakadu-components-840864829", children: /* @__PURE__ */ t.jsx(K, { iconLeft: J.times, label: "Close", className: "kakadu-components-3855719072", onClick: o }) })
25
+ /* @__PURE__ */ t.jsx("div", { className: "kakadu-components-840864829", children: /* @__PURE__ */ t.jsx(K, { iconLeft: J.times, label: "Close", className: "kakadu-components-3855719072", onClick: a }) })
25
26
  ] });
26
27
  }
27
- function C({
28
- decorators: n,
29
- children: o
30
- }) {
31
- return n.length === 0 ? o : n.reduceRight((r, u) => /* @__PURE__ */ t.jsx(u, { children: r }), o);
32
- }
33
- function te({
34
- root: n,
35
- outerDecorators: o = [],
36
- innerDecorators: r = [],
37
- label: u,
38
- maxWidth: c,
28
+ function ne({
29
+ root: o,
30
+ outerDecorators: a = [],
31
+ innerDecorators: c = [],
32
+ label: j,
33
+ maxWidth: s,
39
34
  className: i,
40
- isVisible: s,
41
- isFullWidth: f = !1,
42
- shouldCloseOnOutsideClick: k = !0,
43
- shouldCloseOnEscapePress: l = !0,
44
- showCloseButton: d = !0,
45
- onClose: a,
35
+ isVisible: n,
36
+ isFullWidth: m = !1,
37
+ shouldCloseOnOutsideClick: f = !0,
38
+ shouldCloseOnEscapePress: u = !0,
39
+ showCloseButton: l = !0,
40
+ onClose: r,
46
41
  children: P
47
42
  }) {
48
- const R = v(null), N = v(null), [g, A] = w(!1), [m, x] = w(!1), y = j((e) => {
49
- R.current = e, x(!1);
50
- }, []), E = v(null), L = j((e) => {
43
+ const N = p(null), R = p(null), [y, A] = w(!1), [d, k] = w(!1), L = v((e) => {
44
+ N.current = e, k(!1);
45
+ }, []), E = p(null), M = v((e) => {
51
46
  e && (E.current = e);
52
- }, []), [M, F] = w(s ?? !1), D = T(() => ({
53
- isVisible: M,
54
- setInitialFocus: L,
55
- close: y
56
- }), [M, L, y]);
57
- p(() => {
58
- s && (A(!0), F(!0));
59
- }, [s]), p(() => {
60
- if (s) {
47
+ }, []), [F, b] = w(n ?? !1), D = T(() => ({
48
+ isVisible: F,
49
+ setInitialFocus: M,
50
+ close: L
51
+ }), [F, M, L]);
52
+ x(() => {
53
+ n && (A(!0), b(!0));
54
+ }, [n]), x(() => {
55
+ if (n) {
61
56
  const e = setTimeout(() => {
62
- x(!0);
57
+ k(!0);
63
58
  }, 100);
64
59
  return () => {
65
60
  clearTimeout(e);
66
61
  };
67
62
  }
68
- x(!1);
69
- }, [s]), p(() => {
70
- if (g && !m) {
63
+ k(!1);
64
+ }, [n]), x(() => {
65
+ if (y && !d) {
71
66
  const e = setTimeout(() => {
72
- a == null || a(R.current ?? void 0), F(!1);
67
+ r == null || r(N.current ?? void 0), b(!1);
73
68
  }, 370);
74
69
  return () => {
75
70
  clearTimeout(e);
76
71
  };
77
72
  }
78
- }, [g, m, a]), p(() => {
79
- const e = N.current;
80
- if (s && k && e) {
73
+ }, [y, d, r]), x(() => {
74
+ const e = R.current;
75
+ if (n && f && e) {
81
76
  const h = ($) => {
82
- e === $.target && x(!1);
77
+ e === $.target && k(!1);
83
78
  };
84
79
  return e.addEventListener("click", h), () => {
85
80
  e.removeEventListener("click", h);
86
81
  };
87
82
  }
88
- }, [s, k]), p(() => {
89
- if (!s || !l)
83
+ }, [n, f]), x(() => {
84
+ if (!n || !u)
90
85
  return;
91
86
  const e = (h) => {
92
- h.key === "Escape" && x(!1);
87
+ h.key === "Escape" && k(!1);
93
88
  };
94
89
  return window.addEventListener("keydown", e), () => {
95
90
  window.removeEventListener("keydown", e);
96
91
  };
97
- }, [s, l]);
92
+ }, [n, u]);
98
93
  const S = T(() => ({
99
94
  initialFocus: () => E.current ?? void 0,
100
95
  onActivate: () => {
101
96
  var e;
102
97
  return (e = E.current) == null ? void 0 : e.focus();
103
98
  }
104
- }), []), b = /* @__PURE__ */ t.jsx(C, { decorators: o, children: /* @__PURE__ */ t.jsx("div", { "aria-hidden": !m, style: {
105
- "--max-width": c ? `${c}px` : void 0
106
- }, className: I("kakadu-components-4119461136", m && "kakadu-components-2522346797", i), children: /* @__PURE__ */ t.jsx(C, { decorators: r, children: /* @__PURE__ */ t.jsx(H.FocusTrap, { active: m, focusTrapOptions: S, children: /* @__PURE__ */ t.jsx("div", { ref: N, className: "kakadu-components-4011815997", children: /* @__PURE__ */ t.jsx("div", { role: "dialog", "aria-modal": "true", "aria-label": u ?? "Modal", className: I("kakadu-components-3324483532", f && "kakadu-components-3799971070", m && "kakadu-components-968755580"), children: /* @__PURE__ */ t.jsxs(Q, { value: D, children: [
107
- d ? /* @__PURE__ */ t.jsx(V, {}) : null,
108
- /* @__PURE__ */ t.jsx("div", { className: I("kakadu-components-633990035", f && "kakadu-components-171969824"), children: P })
99
+ }), []), g = /* @__PURE__ */ t.jsx(C, { decorators: a, children: /* @__PURE__ */ t.jsx("div", { "aria-hidden": !d, style: {
100
+ "--max-width": s ? `${s}px` : void 0
101
+ }, className: I("kakadu-components-4119461136", d && "kakadu-components-2522346797", i), children: /* @__PURE__ */ t.jsx(C, { decorators: c, children: /* @__PURE__ */ t.jsx(H.FocusTrap, { active: d, focusTrapOptions: S, children: /* @__PURE__ */ t.jsx("div", { ref: R, className: "kakadu-components-4011815997", children: /* @__PURE__ */ t.jsx("div", { role: "dialog", "aria-modal": "true", "aria-label": j ?? "Modal", className: I("kakadu-components-3324483532", m && "kakadu-components-3799971070", d && "kakadu-components-968755580"), children: /* @__PURE__ */ t.jsxs(Q, { value: D, children: [
102
+ l ? /* @__PURE__ */ t.jsx(V, {}) : null,
103
+ /* @__PURE__ */ t.jsx("div", { className: I("kakadu-components-633990035", m && "kakadu-components-171969824"), children: P })
109
104
  ] }) }) }) }) }) }) });
110
- return n ? G(b, n) : b;
105
+ return o ? G(g, o) : g;
111
106
  }
112
- function ne(n, o) {
113
- const [r, u] = w(!1), c = v(void 0), i = v(null), s = j(async (l) => (u(!0), i.current = l ?? document.activeElement, new Promise((d) => {
114
- c.current = d;
115
- })), []), f = j((l) => {
116
- var d;
117
- if (u(!1), (d = c.current) == null || d.call(c, l), c.current = void 0, i.current) {
118
- const a = i.current;
119
- a.isConnected && a.focus(), i.current = null;
107
+ function oe(o, a) {
108
+ const [c, j] = w(!1), s = p(void 0), i = p(null), n = v(async (u) => (j(!0), i.current = u ?? document.activeElement, new Promise((l) => {
109
+ s.current = l;
110
+ })), []), m = v((u) => {
111
+ var l;
112
+ if (j(!1), (l = s.current) == null || l.call(s, u), s.current = void 0, i.current) {
113
+ const r = i.current;
114
+ r.isConnected && r.focus(), i.current = null;
120
115
  }
121
- }, []), k = T(() => /* @__PURE__ */ t.jsx(n, { ...o, isVisible: r, onClose: f }), [n, o, r, f]);
116
+ }, []), f = T(() => /* @__PURE__ */ t.jsx(o, { ...a, isVisible: c, onClose: m }), [o, a, c, m]);
122
117
  return T(() => ({
123
- isVisible: r,
124
- show: s,
125
- modal: k
126
- }), [r, s, k]);
118
+ isVisible: c,
119
+ show: n,
120
+ modal: f
121
+ }), [c, n, f]);
127
122
  }
128
123
  export {
129
- te as default,
130
- ne as useModal,
124
+ ne as default,
125
+ oe as useModal,
131
126
  U as useModalContext
132
127
  };
@@ -1,12 +1,25 @@
1
- import { type MouseEvent, type ReactNode } from 'react';
1
+ import { type FocusEvent, type MouseEvent, type ReactNode, type Ref } from 'react';
2
2
  import { type IconType } from '../icons/icon';
3
+ import { type DecoratorType } from './decorators';
4
+ type PopoverMenuItemElementType = HTMLButtonElement | HTMLAnchorElement;
3
5
  export type PopoverMenuItemProperties = {
6
+ type: 'separator';
7
+ } | {
8
+ type: 'group';
4
9
  readonly label: ReactNode;
10
+ } | {
11
+ readonly reference?: Ref<PopoverMenuItemElementType>;
12
+ readonly label: ReactNode;
13
+ readonly href?: string;
5
14
  readonly iconLeft?: IconType;
6
15
  readonly iconRight?: IconType;
7
- readonly href?: string;
16
+ readonly submenu?: ReturnType<typeof usePopoverMenu>;
8
17
  readonly shouldCloseOnClick?: boolean;
9
- readonly onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
18
+ readonly decorators?: DecoratorType[];
19
+ readonly className?: string;
20
+ readonly onClick?: (event: MouseEvent<PopoverMenuItemElementType>) => void;
21
+ readonly onFocus?: (event: FocusEvent<PopoverMenuItemElementType>) => void;
22
+ readonly onMouseEnter?: (event: MouseEvent<PopoverMenuItemElementType>) => void;
10
23
  };
11
24
  export declare function usePopoverMenu(items: PopoverMenuItemProperties[]): {
12
25
  show: (reference?: HTMLElement) => Promise<void | undefined>;
@@ -14,6 +27,8 @@ export declare function usePopoverMenu(items: PopoverMenuItemProperties[]): {
14
27
  };
15
28
  export type PopoverMenuProperties = {
16
29
  readonly menu: ReactNode;
17
- readonly children: ReactNode;
30
+ readonly className?: string;
31
+ readonly children?: ReactNode;
18
32
  };
19
- export default function PopoverMenu({ menu, children }: PopoverMenuProperties): import("react/jsx-runtime").JSX.Element;
33
+ export default function PopoverMenu({ menu, className, children, }: PopoverMenuProperties): import("react/jsx-runtime").JSX.Element;
34
+ export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../jsx-runtime-BB_1_6y_.js"),j=require("@kuma-ui/core"),p=require("react"),v=require("../theme.js"),c=require("../icons/icon.js"),i=require("./popover.js"),R=require("./atom.js"),h=require("./text.js"),m=require("./hover-gradient.js"),q=require("./click-ripples.js");function f({label:t,iconLeft:s,iconRight:o,href:n,shouldCloseOnClick:a=!0,onClick:r,...x}){const{close:u}=i.usePopoverContext(),l=p.useCallback(d=>{r==null||r(d),a&&(u==null||u())},[r,a,u]);return e.jsxRuntimeExports.jsxs(R.default,{as:n?"a":"button",...x,type:n?void 0:"button",role:"menuitem",href:n,className:j.cx(v.buttonResetStyles,"kakadu-components-3983689191"),onClick:l,children:[e.jsxRuntimeExports.jsxs(h.Span,{className:"kakadu-components-2031937592",children:[s?e.jsxRuntimeExports.jsx(c.default,{width:12,height:12,type:s}):null,e.jsxRuntimeExports.jsx("span",{className:"kakadu-components-3911899222",children:t}),o?e.jsxRuntimeExports.jsx(c.default,{width:12,height:12,type:o}):null]}),e.jsxRuntimeExports.jsx(m.default,{size:100,className:m.normalBlendStyles}),e.jsxRuntimeExports.jsx(q.default,{size:100})]})}function E({items:t,...s}){return e.jsxRuntimeExports.jsx(i.default,{...s,as:"nav",role:"menu",innerClassName:"kakadu-components-3719863410",children:t.map((o,n)=>e.jsxRuntimeExports.jsx(f,{...o},n))})}function M(t){const s=p.useMemo(()=>({items:t}),[t]),{show:o,popover:n}=i.usePopover(E,s);return p.useMemo(()=>({show:o,popoverMenu:n}),[o,n])}function P({menu:t,children:s}){return e.jsxRuntimeExports.jsxs(i.PopoverContainer,{children:[s,t]})}exports.default=P;exports.usePopoverMenu=M;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../jsx-runtime-BB_1_6y_.js"),w=require("@kuma-ui/core"),a=require("react"),M=require("../theme.js"),k=require("../icons/icon.js"),m=require("./popover.js"),q=require("./atom.js"),h=require("./text.js"),g=require("./hover-gradient.js"),I=require("./click-ripples.js"),P=require("./separator.js"),N=require("./decorators.js"),E=new Set;function R(){const[e,n]=a.useState(!1),s=a.useCallback(o=>{n(o);for(const i of E)i(o)},[]);return a.useEffect(()=>{const o=i=>{n(i)};return E.add(o),()=>{E.delete(o)}},[]),a.useMemo(()=>({isKeyboardNavigating:e,setIsKeyboardNavigating:s}),[e,s])}function S({label:e,iconLeft:n,iconRight:s,href:o,shouldCloseOnClick:i=!0,decorators:v=[],submenu:c,className:j,onClick:p,...f}){const{isFocused:u,close:r}=m.usePopoverContext(),{isKeyboardNavigating:l}=R(),x=a.useCallback(b=>{u&&(p==null||p(b),c?c.show():i&&(r==null||r()))},[u,p,i,r,c]),d=a.useMemo(()=>t.jsxRuntimeExports.jsxs(q.default,{as:o?"a":"button",...f,type:o?void 0:"button",role:"menuitem",href:o,className:w.cx(M.buttonResetStyles,"kakadu-components-3114599304",l?"kakadu-components-4096376656":"kakadu-components-2554182777",j),onClick:x,children:[t.jsxRuntimeExports.jsxs(h.Span,{className:"kakadu-components-1109353535",children:[n?t.jsxRuntimeExports.jsx(k.default,{width:12,height:12,type:n}):null,t.jsxRuntimeExports.jsx("span",{className:"kakadu-components-913703148",children:e}),s?t.jsxRuntimeExports.jsx(k.default,{width:12,height:12,type:s}):null]}),l?null:t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(g.default,{size:150,className:g.normalBlendStyles}),t.jsxRuntimeExports.jsx(I.default,{size:100})]})]}),[l,f,o,j,x,n,e,s]);return t.jsxRuntimeExports.jsx(N.default,{decorators:v,children:c?t.jsxRuntimeExports.jsx(y,{menu:c.popoverMenu,className:"kakadu-components-1861176543",children:d}):d})}function _(e){if("type"in e){if(e.type==="separator")return t.jsxRuntimeExports.jsx(P.default,{});if(e.type==="group")return t.jsxRuntimeExports.jsx(h.Span,{className:"kakadu-components-1499037363",children:e.label})}return t.jsxRuntimeExports.jsx(S,{...e})}function C({items:e}){const{isFocused:n}=m.usePopoverContext(),[s,o]=a.useState(0),[i,v]=a.useState([]),{setIsKeyboardNavigating:c}=R(),j=a.useCallback(u=>{u&&v(r=>[...r,u])},[]),p=a.useCallback(u=>{n&&(u.currentTarget.focus(),c(!1))},[n,c]),f=a.useCallback(u=>{if(n){const r=u.target;o(i.indexOf(r))}},[n,i]);return a.useEffect(()=>{if(!n)return;const u=r=>{const l=i.length;if(l===0)return;let x;switch(r.key){case"ArrowDown":{x=(s+1)%l;break}case"ArrowUp":{x=(s-1+l)%l;break}case"Home":{x=0;break}case"End":{x=l-1;break}}if(x!==void 0){r.preventDefault(),r.stopPropagation();const d=i[x];d&&(d.focus(),c(!0))}};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u)}},[n,i,s,c]),t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:e.map((u,r)=>t.jsxRuntimeExports.jsx(_,{...u,reference:j,onFocus:f,onMouseEnter:p},r))})}function F({items:e,...n}){return t.jsxRuntimeExports.jsx(m.default,{...n,as:"nav",role:"menu",innerClassName:"kakadu-components-3600436535",children:t.jsxRuntimeExports.jsx(C,{items:e})})}function K(e){const n=a.useMemo(()=>({items:e}),[e]),{show:s,popover:o}=m.usePopover(F,n);return a.useMemo(()=>({show:s,popoverMenu:o}),[s,o])}function y({menu:e,className:n,children:s}){return t.jsxRuntimeExports.jsxs(m.PopoverContainer,{className:n,children:[s,e]})}exports.default=y;exports.usePopoverMenu=K;
@@ -1,68 +1,167 @@
1
- import { j as e } from "../jsx-runtime-B4hRZ52C.mjs";
2
- import { cx as d } from "@kuma-ui/core";
3
- import { useMemo as a, useCallback as x } from "react";
4
- import { buttonResetStyles as f } from "../theme.mjs";
5
- import u from "../icons/icon.mjs";
6
- import v, { PopoverContainer as j, usePopover as h, usePopoverContext as P } from "./popover.mjs";
7
- import k from "./atom.mjs";
8
- import { Span as M } from "./text.mjs";
9
- import y, { normalBlendStyles as N } from "./hover-gradient.mjs";
10
- import b from "./click-ripples.mjs";
11
- function w({
12
- label: o,
13
- iconLeft: r,
14
- iconRight: n,
15
- href: t,
16
- shouldCloseOnClick: m = !0,
17
- onClick: s,
18
- ...i
1
+ import { j as n } from "../jsx-runtime-B4hRZ52C.mjs";
2
+ import { cx as b } from "@kuma-ui/core";
3
+ import { useMemo as v, useState as h, useCallback as p, useEffect as y } from "react";
4
+ import { buttonResetStyles as M } from "../theme.mjs";
5
+ import j from "../icons/icon.mjs";
6
+ import E, { PopoverContainer as S, usePopover as F, usePopoverContext as w } from "./popover.mjs";
7
+ import K from "./atom.mjs";
8
+ import { Span as I } from "./text.mjs";
9
+ import A, { normalBlendStyles as D } from "./hover-gradient.mjs";
10
+ import H from "./click-ripples.mjs";
11
+ import z from "./separator.mjs";
12
+ import C from "./decorators.mjs";
13
+ const g = /* @__PURE__ */ new Set();
14
+ function N() {
15
+ const [e, t] = h(!1), o = p((r) => {
16
+ t(r);
17
+ for (const i of g)
18
+ i(r);
19
+ }, []);
20
+ return y(() => {
21
+ const r = (i) => {
22
+ t(i);
23
+ };
24
+ return g.add(r), () => {
25
+ g.delete(r);
26
+ };
27
+ }, []), v(() => ({
28
+ isKeyboardNavigating: e,
29
+ setIsKeyboardNavigating: o
30
+ }), [e, o]);
31
+ }
32
+ function L({
33
+ label: e,
34
+ iconLeft: t,
35
+ iconRight: o,
36
+ href: r,
37
+ shouldCloseOnClick: i = !0,
38
+ decorators: k = [],
39
+ submenu: c,
40
+ className: f,
41
+ onClick: d,
42
+ ...x
19
43
  }) {
20
44
  const {
21
- close: p
22
- } = P(), c = x((l) => {
23
- s == null || s(l), m && (p == null || p());
24
- }, [s, m, p]);
25
- return /* @__PURE__ */ e.jsxs(k, { as: t ? "a" : "button", ...i, type: t ? void 0 : "button", role: "menuitem", href: t, className: d(f, "kakadu-components-3983689191"), onClick: c, children: [
26
- /* @__PURE__ */ e.jsxs(M, { className: "kakadu-components-2031937592", children: [
27
- r ? /* @__PURE__ */ e.jsx(u, { width: 12, height: 12, type: r }) : null,
28
- /* @__PURE__ */ e.jsx("span", { className: "kakadu-components-3911899222", children: o }),
29
- n ? /* @__PURE__ */ e.jsx(u, { width: 12, height: 12, type: n }) : null
45
+ isFocused: a,
46
+ close: s
47
+ } = w(), {
48
+ isKeyboardNavigating: u
49
+ } = N(), m = p((P) => {
50
+ a && (d == null || d(P), c ? c.show() : i && (s == null || s()));
51
+ }, [a, d, i, s, c]), l = v(() => /* @__PURE__ */ n.jsxs(K, { as: r ? "a" : "button", ...x, type: r ? void 0 : "button", role: "menuitem", href: r, className: b(M, "kakadu-components-3114599304", u ? "kakadu-components-4096376656" : "kakadu-components-2554182777", f), onClick: m, children: [
52
+ /* @__PURE__ */ n.jsxs(I, { className: "kakadu-components-1109353535", children: [
53
+ t ? /* @__PURE__ */ n.jsx(j, { width: 12, height: 12, type: t }) : null,
54
+ /* @__PURE__ */ n.jsx("span", { className: "kakadu-components-913703148", children: e }),
55
+ o ? /* @__PURE__ */ n.jsx(j, { width: 12, height: 12, type: o }) : null
30
56
  ] }),
31
- /* @__PURE__ */ e.jsx(y, { size: 100, className: N }),
32
- /* @__PURE__ */ e.jsx(b, { size: 100 })
33
- ] });
57
+ u ? null : /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
58
+ /* @__PURE__ */ n.jsx(A, { size: 150, className: D }),
59
+ /* @__PURE__ */ n.jsx(H, { size: 100 })
60
+ ] })
61
+ ] }), [u, x, r, f, m, t, e, o]);
62
+ return /* @__PURE__ */ n.jsx(C, { decorators: k, children: c ? /* @__PURE__ */ n.jsx(T, { menu: c.popoverMenu, className: "kakadu-components-1861176543", children: l }) : l });
63
+ }
64
+ function R(e) {
65
+ if ("type" in e) {
66
+ if (e.type === "separator")
67
+ return /* @__PURE__ */ n.jsx(z, {});
68
+ if (e.type === "group")
69
+ return /* @__PURE__ */ n.jsx(I, { className: "kakadu-components-1499037363", children: e.label });
70
+ }
71
+ return /* @__PURE__ */ n.jsx(L, { ...e });
34
72
  }
35
- function I({
36
- items: o,
37
- ...r
73
+ function B({
74
+ items: e
38
75
  }) {
39
- return /* @__PURE__ */ e.jsx(v, { ...r, as: "nav", role: "menu", innerClassName: "kakadu-components-3719863410", children: o.map((n, t) => (
40
- // eslint-disable-next-line react/no-array-index-key
41
- /* @__PURE__ */ e.jsx(w, { ...n }, t)
76
+ const {
77
+ isFocused: t
78
+ } = w(), [o, r] = h(0), [i, k] = h([]), {
79
+ setIsKeyboardNavigating: c
80
+ } = N(), f = p((a) => {
81
+ a && k((s) => [...s, a]);
82
+ }, []), d = p((a) => {
83
+ t && (a.currentTarget.focus(), c(!1));
84
+ }, [t, c]), x = p((a) => {
85
+ if (t) {
86
+ const s = a.target;
87
+ r(i.indexOf(s));
88
+ }
89
+ }, [t, i]);
90
+ return y(() => {
91
+ if (!t)
92
+ return;
93
+ const a = (s) => {
94
+ const u = i.length;
95
+ if (u === 0)
96
+ return;
97
+ let m;
98
+ switch (s.key) {
99
+ case "ArrowDown": {
100
+ m = (o + 1) % u;
101
+ break;
102
+ }
103
+ case "ArrowUp": {
104
+ m = (o - 1 + u) % u;
105
+ break;
106
+ }
107
+ case "Home": {
108
+ m = 0;
109
+ break;
110
+ }
111
+ case "End": {
112
+ m = u - 1;
113
+ break;
114
+ }
115
+ }
116
+ if (m !== void 0) {
117
+ s.preventDefault(), s.stopPropagation();
118
+ const l = i[m];
119
+ l && (l.focus(), c(!0));
120
+ }
121
+ };
122
+ return window.addEventListener("keydown", a), () => {
123
+ window.removeEventListener("keydown", a);
124
+ };
125
+ }, [t, i, o, c]), /* @__PURE__ */ n.jsx(n.Fragment, { children: e.map((a, s) => /* @__PURE__ */ n.jsx(
126
+ R,
127
+ {
128
+ ...a,
129
+ reference: f,
130
+ onFocus: x,
131
+ onMouseEnter: d
132
+ },
133
+ s
42
134
  )) });
43
135
  }
44
- function C(o) {
45
- const r = a(() => ({
46
- items: o
47
- }), [o]), {
48
- show: n,
49
- popover: t
50
- } = h(I, r);
51
- return a(() => ({
52
- show: n,
53
- popoverMenu: t
54
- }), [n, t]);
136
+ function G({
137
+ items: e,
138
+ ...t
139
+ }) {
140
+ return /* @__PURE__ */ n.jsx(E, { ...t, as: "nav", role: "menu", innerClassName: "kakadu-components-3600436535", children: /* @__PURE__ */ n.jsx(B, { items: e }) });
141
+ }
142
+ function ee(e) {
143
+ const t = v(() => ({
144
+ items: e
145
+ }), [e]), {
146
+ show: o,
147
+ popover: r
148
+ } = F(G, t);
149
+ return v(() => ({
150
+ show: o,
151
+ popoverMenu: r
152
+ }), [o, r]);
55
153
  }
56
- function D({
57
- menu: o,
58
- children: r
154
+ function T({
155
+ menu: e,
156
+ className: t,
157
+ children: o
59
158
  }) {
60
- return /* @__PURE__ */ e.jsxs(j, { children: [
61
- r,
62
- o
159
+ return /* @__PURE__ */ n.jsxs(S, { className: t, children: [
160
+ o,
161
+ e
63
162
  ] });
64
163
  }
65
164
  export {
66
- D as default,
67
- C as usePopoverMenu
165
+ T as default,
166
+ ee as usePopoverMenu
68
167
  };
@@ -3,6 +3,7 @@ import { type AtomElementType, type AtomProperties, type DefaultAtomElementType
3
3
  type InitialFocusElement = HTMLElement | null;
4
4
  type PopoverProviderProperties<Data = any> = {
5
5
  isVisible: boolean;
6
+ isFocused: boolean;
6
7
  setInitialFocus?: (initialFocus?: InitialFocusElement) => void;
7
8
  close?: (data?: Data) => void;
8
9
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("../jsx-runtime-BB_1_6y_.js"),d=require("@kuma-ui/core"),e=require("react"),_=require("../focus-trap-react-CcpTuiJi.js"),w=require("./atom.js"),D=e.createContext({isVisible:!1}),{Provider:z}=D;function B(){return e.useContext(D)}function $({as:i,className:n,...o}){return s.jsxRuntimeExports.jsx(w.default,{as:i??w.defaultAtomElementType,...o,className:d.cx("kakadu-components-2845019685",n)})}function H({as:i,isVisible:n,label:o,shouldCloseOnOutsideClick:m=!0,shouldCloseOnEscapePress:r=!0,children:u,className:k,innerClassName:R,onClose:c,...p}){const a=e.useRef(null),x=e.useRef(null),[T,V]=e.useState(!1),[l,h]=e.useState(!1),C=e.useCallback(t=>{a.current=t,h(!1)},[]),E=e.useRef(null),M=e.useCallback(t=>{t&&(E.current=t)},[]),A=e.useMemo(()=>({initialFocus:()=>E.current??void 0,onActivate:()=>{var t;return(t=E.current)==null?void 0:t.focus()},clickOutsideDeactivates:m,escapeDeactivates:r,onDeactivate(){h(!1)}}),[m,r]),[I,S]=e.useState(n??!1),W=e.useMemo(()=>({isVisible:I,setInitialFocus:M,close:C}),[I,M,C]),[f,q]=e.useState("center");return e.useEffect(()=>{const t=x.current;if(t){const g=()=>{const N=t.offsetParent,b=N instanceof HTMLElement?N.getBoundingClientRect():null,F=t.getBoundingClientRect();if(!b){q("center");return}const P=b.left+b.width/2-F.width/2,L=P+F.width,O=P<0,y=L>window.innerWidth;let v="center";if(O&&y){const j=Math.abs(P);v=L-window.innerWidth>j?"right":"left"}else y?v="right":O&&(v="left");q(j=>j===v?j:v)};return g(),window.addEventListener("resize",g),()=>{window.removeEventListener("resize",g)}}},[]),e.useEffect(()=>{n&&(V(!0),S(!0))},[n]),e.useEffect(()=>{if(n){const t=setTimeout(()=>{h(!0)},100);return()=>{clearTimeout(t)}}h(!1)},[n]),e.useEffect(()=>{if(T&&!l){const t=setTimeout(()=>{c==null||c(a.current??void 0),S(!1)},370);return()=>{clearTimeout(t)}}},[T,l,c]),s.jsxRuntimeExports.jsx(w.default,{reference:x,as:i??w.defaultAtomElementType,role:"dialog","aria-hidden":!l,"aria-label":o??"Popover",...p,className:d.cx("kakadu-components-3920007758",f==="left"&&"kakadu-components-611400930",f==="right"&&"kakadu-components-944244368",l&&"kakadu-components-1399012551",k),children:s.jsxRuntimeExports.jsxs("div",{className:d.cx("kakadu-components-1118152266",l&&"kakadu-components-231244945"),children:[s.jsxRuntimeExports.jsx("div",{className:d.cx("kakadu-components-3330289187",f==="left"&&"kakadu-components-1495725644",f==="right"&&"kakadu-components-4235689197")}),s.jsxRuntimeExports.jsx(_.focusTrapReactExports.FocusTrap,{active:l,focusTrapOptions:A,children:s.jsxRuntimeExports.jsxs("div",{className:d.cx("kakadu-components-3253940005",R),children:[s.jsxRuntimeExports.jsx(z,{value:W,children:u}),s.jsxRuntimeExports.jsx("div",{className:d.cx("kakadu-components-3252390100",f==="left"&&"kakadu-components-3754561431",f==="right"&&"kakadu-components-2265262600")})]})})]})})}function G(i,n){const[o,m]=e.useState(!1),r=e.useRef(void 0),u=e.useRef(null),k=e.useCallback(async p=>(m(!0),u.current=p??document.activeElement,new Promise(a=>{r.current=a})),[]),R=e.useCallback(p=>{var a;if(m(!1),(a=r.current)==null||a.call(r,p),r.current=void 0,u.current){const x=u.current;x.isConnected&&x.focus(),u.current=null}},[]),c=e.useMemo(()=>s.jsxRuntimeExports.jsx(i,{...n,isVisible:o,onClose:R}),[i,n,o,R]);return e.useMemo(()=>({isVisible:o,show:k,popover:c}),[o,k,c])}exports.PopoverContainer=$;exports.default=H;exports.usePopover=G;exports.usePopoverContext=B;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("../jsx-runtime-BB_1_6y_.js"),d=require("@kuma-ui/core"),e=require("react"),B=require("../focus-trap-react-CcpTuiJi.js"),E=require("./atom.js"),A=e.createContext({isVisible:!1,isFocused:!1}),{Provider:$}=A;function H(){return e.useContext(A)}function U({as:u,className:s,...o}){return n.jsxRuntimeExports.jsx(E.default,{as:u??E.defaultAtomElementType,...o,className:d.cx("kakadu-components-2845019685",s)})}function G({as:u,isVisible:s,label:o,shouldCloseOnOutsideClick:m=!0,shouldCloseOnEscapePress:c=!0,children:i,className:k,innerClassName:R,onClose:r,...p}){const a=e.useRef(null),x=e.useRef(null),[F,h]=e.useState(!1),[C,W]=e.useState(!1),[l,j]=e.useState(!1),I=e.useCallback(t=>{a.current=t,j(!1)},[]),g=e.useRef(null),M=e.useCallback(t=>{t&&(g.current=t)},[]),_=e.useMemo(()=>({initialFocus:()=>g.current??void 0,onActivate(){var t;(t=g.current)==null||t.focus(),h(!0)},returnFocusOnDeactivate:!1,clickOutsideDeactivates:m,escapeDeactivates:c,onUnpause(){h(!0)},onPause(){h(!1)},onDeactivate(){j(!1),h(!1)}}),[m,c]),[S,q]=e.useState(s??!1),z=e.useMemo(()=>({isVisible:S,isFocused:F,setInitialFocus:M,close:I}),[S,F,M,I]),[f,N]=e.useState("center");return e.useEffect(()=>{const t=x.current;if(t){const P=()=>{const O=t.offsetParent,b=O instanceof HTMLElement?O.getBoundingClientRect():null,D=t.getBoundingClientRect();if(!b){N("center");return}const T=b.left+b.width/2-D.width/2,L=T+D.width,y=T<0,V=L>window.innerWidth;let v="center";if(y&&V){const w=Math.abs(T);v=L-window.innerWidth>w?"right":"left"}else V?v="right":y&&(v="left");N(w=>w===v?w:v)};return P(),window.addEventListener("resize",P),()=>{window.removeEventListener("resize",P)}}},[]),e.useEffect(()=>{s&&(W(!0),q(!0))},[s]),e.useEffect(()=>{if(s){const t=setTimeout(()=>{j(!0)},100);return()=>{clearTimeout(t)}}j(!1)},[s]),e.useEffect(()=>{if(C&&!l){const t=setTimeout(()=>{r==null||r(a.current??void 0),q(!1)},370);return()=>{clearTimeout(t)}}},[C,l,r]),n.jsxRuntimeExports.jsx(E.default,{reference:x,as:u??E.defaultAtomElementType,role:"dialog","aria-hidden":!l,"aria-label":o??"Popover",...p,className:d.cx("kakadu-components-3920007758",f==="left"&&"kakadu-components-611400930",f==="right"&&"kakadu-components-944244368",l&&"kakadu-components-1399012551",k),children:n.jsxRuntimeExports.jsxs("div",{className:d.cx("kakadu-components-1118152266",l&&"kakadu-components-231244945"),children:[n.jsxRuntimeExports.jsx("div",{className:d.cx("kakadu-components-677077174",f==="left"&&"kakadu-components-1495725644",f==="right"&&"kakadu-components-4235689197")}),n.jsxRuntimeExports.jsx(B.focusTrapReactExports.FocusTrap,{active:l,focusTrapOptions:_,children:n.jsxRuntimeExports.jsxs("div",{className:d.cx("kakadu-components-2488426662",R),children:[n.jsxRuntimeExports.jsx($,{value:z,children:i}),n.jsxRuntimeExports.jsx("div",{className:d.cx("kakadu-components-3252390100",f==="left"&&"kakadu-components-3754561431",f==="right"&&"kakadu-components-2265262600")})]})})]})})}function J(u,s){const[o,m]=e.useState(!1),c=e.useRef(void 0),i=e.useRef(null),k=e.useCallback(async p=>(m(!0),i.current=p??document.activeElement,new Promise(a=>{c.current=a})),[]),R=e.useCallback(p=>{var a;if(m(!1),(a=c.current)==null||a.call(c,p),c.current=void 0,i.current){const x=i.current;x.isConnected&&x.focus(),i.current=null}},[]),r=e.useMemo(()=>n.jsxRuntimeExports.jsx(u,{...s,isVisible:o,onClose:R}),[u,s,o,R]);return e.useMemo(()=>({isVisible:o,show:k,popover:r}),[o,k,r])}exports.PopoverContainer=U;exports.default=G;exports.usePopover=J;exports.usePopoverContext=H;