@kakadu/components 4.5.4 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,183 +1,189 @@
1
1
  import { j as e } from "../jsx-runtime-B4hRZ52C.mjs";
2
- import { cx as F } from "@kuma-ui/core";
3
- import { useMemo as j, useState as A, useCallback as h, useEffect as K, useRef as z } from "react";
4
- import { buttonResetStyles as C } from "../theme.mjs";
5
- import b from "../icons/icon.mjs";
6
- import D from "../hooks/use-synchronized-value.mjs";
7
- import V, { PopoverContainer as H, usePopover as T, usePopoverContext as N } from "./popover.mjs";
8
- import R from "./atom.mjs";
9
- import { Span as M } from "./text.mjs";
10
- import B, { normalBlendStyles as G } from "./hover-gradient.mjs";
11
- import U from "./click-ripples.mjs";
12
- import q from "./separator.mjs";
13
- import J from "./decorators.mjs";
14
- import I from "./spinner.mjs";
15
- import { SkeletonInstance as O } from "./skeleton.mjs";
16
- import Q from "./aria-text.mjs";
17
- function E() {
2
+ import { cx as N } from "@kuma-ui/core";
3
+ import { useMemo as w, useState as K, useCallback as b, useEffect as z, useRef as C } from "react";
4
+ import { buttonResetStyles as V } from "../theme.mjs";
5
+ import M from "../icons/icon.mjs";
6
+ import B from "../hooks/use-synchronized-value.mjs";
7
+ import H, { PopoverContainer as T, usePopover as R, usePopoverContext as S } from "./popover.mjs";
8
+ import G from "./atom.mjs";
9
+ import { Span as D } from "./text.mjs";
10
+ import U, { normalBlendStyles as q } from "./hover-gradient.mjs";
11
+ import J from "./click-ripples.mjs";
12
+ import O from "./separator.mjs";
13
+ import Q from "./decorators.mjs";
14
+ import E from "./spinner.mjs";
15
+ import { SkeletonInstance as W } from "./skeleton.mjs";
16
+ import X from "./aria-text.mjs";
17
+ function F() {
18
18
  const {
19
19
  value: n,
20
- setValue: t
21
- } = D("isKeyboardNavigating");
22
- return j(() => ({
20
+ setValue: o
21
+ } = B("isKeyboardNavigating");
22
+ return w(() => ({
23
23
  isKeyboardNavigating: n,
24
- setIsKeyboardNavigating: t
25
- }), [n, t]);
24
+ setIsKeyboardNavigating: o
25
+ }), [n, o]);
26
26
  }
27
- const fe = "kakadu-components-949294122";
28
- function W({
27
+ const xe = "kakadu-components-949294122";
28
+ function Y({
29
29
  isLoading: n,
30
- label: t,
31
- iconLeft: a,
32
- iconRight: u,
33
- href: o,
34
- target: l,
35
- shouldCloseOnClick: x = !0,
36
- decorators: i = [],
37
- submenu: r,
38
- className: d,
39
- onClick: c,
40
- ...m
30
+ isDisabled: o,
31
+ label: u,
32
+ iconLeft: p,
33
+ iconRight: r,
34
+ href: i,
35
+ target: h,
36
+ shouldCloseOnClick: s = !0,
37
+ decorators: c = [],
38
+ submenu: d,
39
+ className: l,
40
+ onClick: a,
41
+ ...v
41
42
  }) {
42
43
  const {
43
- isVisible: f,
44
- isPreparingFocus: p,
45
- isFocused: s,
46
- close: k
47
- } = N(), {
48
- isKeyboardNavigating: v
49
- } = E(), y = z(!0), w = h(() => {
50
- y.current = s;
51
- }, [s]), g = h((S) => {
52
- !v && !y.current || s && (c == null || c(S), r ? r.show() : x && (k == null || k()));
53
- }, [v, s, c, r, x, k]), P = j(() => /* @__PURE__ */ e.jsxs(R, { as: o && !n ? "a" : "button", ...m, type: o && !n ? void 0 : "button", role: "menuitem", href: o, target: l, inert: !f && !p || n, disabled: o ? void 0 : !f && !p || n, className: F(C, "kakadu-components-1772835671", s && "kakadu-components-3160069815", v ? "kakadu-components-2254977234" : s && "kakadu-components-278139688", d), onClick: g, onPointerDownCapture: w, children: [
54
- /* @__PURE__ */ e.jsx(M, { className: "kakadu-components-1109353535", children: n ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
55
- /* @__PURE__ */ e.jsx(Q, { children: t }),
56
- a ? /* @__PURE__ */ e.jsx(I, { size: 12 }) : null,
57
- /* @__PURE__ */ e.jsx(O, { height: "1em", width: "100%" }),
58
- u ? /* @__PURE__ */ e.jsx(I, { size: 12 }) : null
44
+ isVisible: y,
45
+ isPreparingFocus: j,
46
+ isFocused: t,
47
+ close: x
48
+ } = S(), {
49
+ isKeyboardNavigating: f
50
+ } = F(), k = C(!0), g = b(() => {
51
+ k.current = t;
52
+ }, [t]), P = b((A) => {
53
+ !f && !k.current || t && (a == null || a(A), d ? d.show() : s && (x == null || x()));
54
+ }, [f, t, a, d, s, x]), m = !y && !j || !!n || !!o, I = w(() => /* @__PURE__ */ e.jsxs(G, { as: i && !n ? "a" : "button", ...v, "aria-disabled": i && m ? !0 : void 0, type: i && !n ? void 0 : "button", role: "menuitem", href: i, target: h, inert: i ? m : void 0, disabled: i ? void 0 : m, className: N(V, "kakadu-components-1772835671", t && "kakadu-components-3160069815", f ? "kakadu-components-2254977234" : t && !m && "kakadu-components-278139688", m && "kakadu-components-1879666195", l), onClick: m ? void 0 : P, onPointerDownCapture: m ? void 0 : g, children: [
55
+ /* @__PURE__ */ e.jsx(D, { className: N("kakadu-components-1377252111", n ? "kakadu-components-2409458488" : m && "kakadu-components-532828420"), children: n ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
56
+ /* @__PURE__ */ e.jsx(X, { children: u }),
57
+ p ? /* @__PURE__ */ e.jsx(E, { size: 12 }) : null,
58
+ /* @__PURE__ */ e.jsx(W, { width: "100%" }),
59
+ r ? /* @__PURE__ */ e.jsx(E, { size: 12 }) : null
59
60
  ] }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
60
- a ? /* @__PURE__ */ e.jsx(b, { width: 12, height: 12, type: a }) : null,
61
- /* @__PURE__ */ e.jsx("span", { className: "kakadu-components-4055589237", children: t }),
62
- u ? /* @__PURE__ */ e.jsx(b, { width: 12, height: 12, type: u }) : null
61
+ p ? /* @__PURE__ */ e.jsx(M, { width: 12, height: 12, type: p }) : null,
62
+ /* @__PURE__ */ e.jsx("span", { className: "kakadu-components-4055589237", children: u }),
63
+ r ? /* @__PURE__ */ e.jsx(M, { width: 12, height: 12, type: r }) : null
63
64
  ] }) }),
64
- v || n ? null : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
65
- /* @__PURE__ */ e.jsx(U, { isActive: s, size: 100 }),
66
- /* @__PURE__ */ e.jsx(B, { isActive: s, size: 150, className: G })
65
+ f || m ? null : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
66
+ /* @__PURE__ */ e.jsx(J, { isActive: t, size: 100 }),
67
+ /* @__PURE__ */ e.jsx(U, { isActive: t, size: 150, className: q })
67
68
  ] })
68
- ] }), [o, n, m, l, f, p, s, v, d, g, w, a, t, u]);
69
- return /* @__PURE__ */ e.jsx(J, { decorators: i, children: r ? /* @__PURE__ */ e.jsx(_, { menu: r.popoverMenu, className: "kakadu-components-1861176543", children: P }) : P });
69
+ ] }), [i, n, v, m, h, t, f, l, P, g, u, p, r]);
70
+ return /* @__PURE__ */ e.jsx(Q, { decorators: c, children: d ? /* @__PURE__ */ e.jsx(L, { menu: d.popoverMenu, className: "kakadu-components-1861176543", children: I }) : I });
70
71
  }
71
- function X(n) {
72
+ function Z(n) {
72
73
  if ("type" in n) {
73
74
  if (n.type === "separator")
74
- return /* @__PURE__ */ e.jsx(q, {});
75
+ return /* @__PURE__ */ e.jsx(O, {});
75
76
  if (n.type === "group")
76
- return /* @__PURE__ */ e.jsx(M, { className: "kakadu-components-1499037363", children: n.label });
77
+ return /* @__PURE__ */ e.jsx(D, { className: "kakadu-components-1499037363", children: n.label });
77
78
  }
78
- return /* @__PURE__ */ e.jsx(W, { ...n });
79
+ return /* @__PURE__ */ e.jsx(Y, { ...n });
79
80
  }
80
- function Y({
81
+ function _({
81
82
  items: n
82
83
  }) {
83
84
  const {
84
- isFocused: t
85
- } = N(), [a, u] = A([]), {
86
- setIsKeyboardNavigating: o
87
- } = E(), l = h((i) => {
88
- i && u((r) => r.includes(i) ? r : [...r, i]);
89
- }, []), x = h((i) => {
90
- t && (i.currentTarget.focus(), o(!1));
91
- }, [t, o]);
92
- return K(() => {
93
- if (!t)
85
+ isFocused: o
86
+ } = S(), [u, p] = K([]), {
87
+ setIsKeyboardNavigating: r
88
+ } = F(), i = b((s) => {
89
+ s && p((c) => c.includes(s) ? c : [...c, s]);
90
+ }, []), h = b((s) => {
91
+ o && (s.currentTarget.focus(), r(!1));
92
+ }, [o, r]);
93
+ return z(() => {
94
+ if (!o)
94
95
  return;
95
- const i = (r) => {
96
- const d = a.filter((s) => s.isConnected), c = d.length;
97
- if (c === 0)
96
+ const s = (c) => {
97
+ const d = u.filter((t) => t.isConnected), l = d.length;
98
+ if (l === 0)
98
99
  return;
99
- let m;
100
- const f = document.activeElement;
101
- let p = f ? d.indexOf(f) : -1;
102
- switch (p === -1 && (p = 0), r.key) {
100
+ let a, v = 1;
101
+ const y = document.activeElement;
102
+ let j = y ? d.indexOf(y) : -1;
103
+ switch (j === -1 && (j = 0), c.key) {
104
+ case "ArrowUp":
105
+ v = -1;
106
+ // eslint-disable-next-line no-fallthrough
103
107
  case "ArrowDown": {
104
- m = (p + 1) % c;
105
- break;
106
- }
107
- case "ArrowUp": {
108
- m = (p - 1 + c) % c;
108
+ a = (j + v + l) % l;
109
109
  break;
110
110
  }
111
111
  case "Home": {
112
- m = 0;
112
+ a = 0;
113
113
  break;
114
114
  }
115
115
  case "End": {
116
- m = c - 1;
116
+ a = l - 1, v = -1;
117
117
  break;
118
118
  }
119
119
  case "Tab": {
120
- o(!0);
120
+ r(!0);
121
121
  return;
122
122
  }
123
123
  }
124
- if (m !== void 0) {
125
- r.preventDefault(), r.stopPropagation();
126
- const s = d[m];
127
- s && (s.focus(), o(!0));
124
+ if (a !== void 0) {
125
+ c.preventDefault(), c.stopPropagation();
126
+ let t = d[a];
127
+ if (t) {
128
+ let x = 0;
129
+ const f = (k) => "disabled" in k && k.disabled || "inert" in k && k.inert;
130
+ for (; f(t) && x < l; )
131
+ a = (a + v + l) % l, t = d[a], x += 1;
132
+ t && !f(t) && (t.focus(), r(!0));
133
+ }
128
134
  }
129
135
  };
130
- return window.addEventListener("keydown", i, {
136
+ return window.addEventListener("keydown", s, {
131
137
  capture: !0
132
138
  }), () => {
133
- window.removeEventListener("keydown", i, {
139
+ window.removeEventListener("keydown", s, {
134
140
  capture: !0
135
141
  });
136
142
  };
137
- }, [t, a, o]), /* @__PURE__ */ e.jsx(e.Fragment, { children: n.map((i, r) => /* @__PURE__ */ e.jsx(
138
- X,
143
+ }, [o, u, r]), /* @__PURE__ */ e.jsx(e.Fragment, { children: n.map((s, c) => /* @__PURE__ */ e.jsx(
144
+ Z,
139
145
  {
140
- ...i,
141
- reference: l,
142
- onMouseEnter: x
146
+ ...s,
147
+ reference: i,
148
+ onMouseEnter: h
143
149
  },
144
- r
150
+ c
145
151
  )) });
146
152
  }
147
- function Z({
153
+ function $({
148
154
  items: n,
149
- ...t
155
+ ...o
150
156
  }) {
151
- return /* @__PURE__ */ e.jsx(V, { ...t, as: "nav", role: "menu", innerClassName: "kakadu-components-3600436535", children: /* @__PURE__ */ e.jsx(Y, { items: n }) });
157
+ return /* @__PURE__ */ e.jsx(H, { ...o, as: "nav", role: "menu", innerClassName: "kakadu-components-3600436535", children: /* @__PURE__ */ e.jsx(_, { items: n }) });
152
158
  }
153
- function ve(n) {
154
- const t = j(() => ({
159
+ function ke(n) {
160
+ const o = w(() => ({
155
161
  items: n
156
162
  }), [n]), {
157
- isVisible: a,
158
- show: u,
159
- close: o,
160
- popover: l
161
- } = T(Z, t);
162
- return j(() => ({
163
- isVisible: a,
164
- show: u,
165
- close: o,
166
- popoverMenu: l
167
- }), [a, u, o, l]);
163
+ isVisible: u,
164
+ show: p,
165
+ close: r,
166
+ popover: i
167
+ } = R($, o);
168
+ return w(() => ({
169
+ isVisible: u,
170
+ show: p,
171
+ close: r,
172
+ popoverMenu: i
173
+ }), [u, p, r, i]);
168
174
  }
169
- function _({
175
+ function L({
170
176
  menu: n,
171
- className: t,
172
- children: a
177
+ className: o,
178
+ children: u
173
179
  }) {
174
- return /* @__PURE__ */ e.jsxs(H, { className: t, children: [
175
- a,
180
+ return /* @__PURE__ */ e.jsxs(T, { className: o, children: [
181
+ u,
176
182
  n
177
183
  ] });
178
184
  }
179
185
  export {
180
- fe as dangerPopoverMenuItemStyles,
181
- _ as default,
182
- ve as usePopoverMenu
186
+ xe as dangerPopoverMenuItemStyles,
187
+ L as default,
188
+ ke as usePopoverMenu
183
189
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("../jsx-runtime-BB_1_6y_.js"),m=require("@kuma-ui/core"),e=require("react"),K=require("../focus-trap-react-B7f3iC5h.js"),F=require("./atom.js"),$=e.createContext({isVisible:!1,isPreparingFocus:!1,isFocused:!1}),{Provider:Q}=$;function X(){return e.useContext($)}function Y({as:i,className:s,...l}){return n.jsxRuntimeExports.jsx(F.default,{as:i??F.defaultAtomElementType,...l,className:m.cx("kakadu-components-2845019685",s)})}function Z({as:i,isVisible:s,label:l,shouldCloseOnOutsideClick:p=!0,shouldCloseOnEscapePress:r=!0,children:w,className:c,innerClassName:f,onClose:a,...h}){const v=e.useRef(null),x=e.useRef(null),[o,k]=e.useState(!1),[R,j]=e.useState(!1),[A,H]=e.useState(!1),[u,E]=e.useState(!1),[U,T]=e.useState(!1),N=e.useCallback(t=>{v.current=t,E(!1)},[]),b=e.useRef(null),L=e.useCallback(t=>{t&&(b.current=t)},[]),G=e.useMemo(()=>({initialFocus:()=>b.current??void 0,onPostActivate(){var t;j(!0),k(!1),(t=b.current)==null||t.focus()},clickOutsideDeactivates:p,escapeDeactivates:r,onPostUnpause(){j(!0)},onPause(){j(!1)},onDeactivate(){T(!1),E(!1),j(!1)}}),[p,r]),[I,O]=e.useState(s??!1),J=e.useMemo(()=>({isVisible:I,isPreparingFocus:o,isFocused:R,setInitialFocus:L,close:N}),[I,o,R,L,N]),[d,y]=e.useState("center");return e.useEffect(()=>{const t=x.current;if(t){const S=()=>{const D=t.offsetParent,M=D instanceof HTMLElement?D.getBoundingClientRect():null,V=t.getBoundingClientRect();if(!M){y("center");return}const C=16,_=window.innerWidth-C,q=M.left+M.width/2-V.width/2,z=q+V.width,B=q<C,W=z>_;let g="center";if(B&&W){const P=C-q;g=z-_>P?"right":"left"}else W?g="right":B&&(g="left");y(P=>P===g?P:g)};return S(),window.addEventListener("resize",S),()=>{window.removeEventListener("resize",S)}}},[]),e.useEffect(()=>{s&&(H(!0),O(!0))},[s]),e.useEffect(()=>{if(s){const t=setTimeout(()=>{E(!0)},100);return()=>{clearTimeout(t)}}E(!1)},[s]),e.useEffect(()=>{if(!u){T(!1),k(!1);return}k(!0);const t=window.requestAnimationFrame(()=>{T(!0)});return()=>{window.cancelAnimationFrame(t)}},[u]),e.useEffect(()=>{if(A&&!u){const t=setTimeout(()=>{O(!1),a==null||a(v.current??void 0)},370);return()=>{clearTimeout(t)}}},[A,u,a]),I?n.jsxRuntimeExports.jsx(F.default,{reference:x,as:i??F.defaultAtomElementType,role:"dialog","aria-hidden":!u,"aria-label":l??"Popover",...h,className:m.cx("kakadu-components-3920007758",d==="left"&&"kakadu-components-611400930",d==="right"&&"kakadu-components-944244368",u&&"kakadu-components-1399012551",c),children:n.jsxRuntimeExports.jsxs("div",{className:m.cx("kakadu-components-1118152266",u&&"kakadu-components-231244945"),children:[n.jsxRuntimeExports.jsx("div",{className:m.cx("kakadu-components-1951789226",d==="left"&&"kakadu-components-1495725644",d==="right"&&"kakadu-components-4235689197")}),n.jsxRuntimeExports.jsx(K.focusTrapReactExports.FocusTrap,{active:U,focusTrapOptions:G,children:n.jsxRuntimeExports.jsxs("div",{className:m.cx("kakadu-components-2488426662",f),children:[n.jsxRuntimeExports.jsx(Q,{value:J,children:w}),n.jsxRuntimeExports.jsx("div",{className:m.cx("kakadu-components-3252390100",d==="left"&&"kakadu-components-3754561431",d==="right"&&"kakadu-components-2265262600")})]})})]})}):null}function ee(i,s){const[l,p]=e.useState(!1),[r,w]=e.useState(!1),c=e.useRef(void 0),f=e.useRef(void 0),a=e.useCallback(async()=>(f.current=void 0,p(!0),w(!0),new Promise(o=>{c.current=o})),[]),h=e.useCallback(o=>{f.current=o,w(!1)},[]),v=e.useCallback(o=>{var R;const k=o??f.current;f.current=void 0,(R=c.current)==null||R.call(c,k),c.current=void 0,p(!1)},[]),x=e.useMemo(()=>l?n.jsxRuntimeExports.jsx(i,{...s,isVisible:r,onClose:v}):null,[l,i,s,r,v]);return e.useMemo(()=>({isVisible:r,show:a,close:h,popover:x}),[r,a,h,x])}exports.PopoverContainer=Y;exports.default=Z;exports.usePopover=ee;exports.usePopoverContext=X;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("../jsx-runtime-BB_1_6y_.js"),m=require("@kuma-ui/core"),e=require("react"),K=require("../focus-trap-react-B7f3iC5h.js"),F=require("./atom.js"),$=e.createContext({isVisible:!1,isPreparingFocus:!1,isFocused:!1}),{Provider:Q}=$;function X(){return e.useContext($)}function Y({as:i,className:s,...l}){return n.jsxRuntimeExports.jsx(F.default,{as:i??F.defaultAtomElementType,...l,className:m.cx("kakadu-components-2845019685",s)})}function Z({as:i,isVisible:s,label:l,shouldCloseOnOutsideClick:p=!0,shouldCloseOnEscapePress:r=!0,children:v,className:a,innerClassName:f,onClose:c,...h}){const x=e.useRef(null),k=e.useRef(null),[o,R]=e.useState(!1),[g,j]=e.useState(!1),[A,H]=e.useState(!1),[u,E]=e.useState(!1),[U,T]=e.useState(!1),N=e.useCallback(t=>{x.current=t,E(!1)},[]),b=e.useRef(null),L=e.useCallback(t=>{t&&(b.current=t)},[]),G=e.useMemo(()=>({initialFocus:()=>b.current??void 0,onPostActivate(){var t;j(!0),R(!1),(t=b.current)==null||t.focus()},clickOutsideDeactivates:p,escapeDeactivates:r,onPostUnpause(){j(!0)},onPause(){j(!1)},onDeactivate(){T(!1),E(!1),j(!1)}}),[p,r]),[I,O]=e.useState(s??!1),J=e.useMemo(()=>({isVisible:I,isPreparingFocus:o,isFocused:g,setInitialFocus:L,close:N}),[I,o,g,L,N]),[d,y]=e.useState("center");return e.useEffect(()=>{const t=k.current;if(t){const S=()=>{const D=t.offsetParent,M=D instanceof HTMLElement?D.getBoundingClientRect():null,V=t.getBoundingClientRect();if(!M){y("center");return}const C=16,_=window.innerWidth-C,q=M.left+M.width/2-V.width/2,z=q+V.width,B=q<C,W=z>_;let w="center";if(B&&W){const P=C-q;w=z-_>P?"right":"left"}else W?w="right":B&&(w="left");y(P=>P===w?P:w)};return S(),window.addEventListener("resize",S),()=>{window.removeEventListener("resize",S)}}},[]),e.useEffect(()=>{s&&(H(!0),O(!0))},[s]),e.useEffect(()=>{if(s){const t=setTimeout(()=>{E(!0)},100);return()=>{clearTimeout(t)}}E(!1)},[s]),e.useEffect(()=>{if(!u){T(!1),R(!1);return}R(!0);const t=window.requestAnimationFrame(()=>{T(!0)});return()=>{window.cancelAnimationFrame(t)}},[u]),e.useEffect(()=>{if(A&&!u){const t=setTimeout(()=>{O(!1),c==null||c(x.current??void 0)},370);return()=>{clearTimeout(t)}}},[A,u,c]),I?n.jsxRuntimeExports.jsx(F.default,{reference:k,as:i??F.defaultAtomElementType,role:"dialog","aria-hidden":!u,"aria-label":l??"Popover",...h,className:m.cx("kakadu-components-3920007758",d==="left"&&"kakadu-components-611400930",d==="right"&&"kakadu-components-944244368",u&&"kakadu-components-1399012551",a),children:n.jsxRuntimeExports.jsxs("div",{className:m.cx("kakadu-components-1118152266",u&&"kakadu-components-231244945"),children:[n.jsxRuntimeExports.jsx("div",{className:m.cx("kakadu-components-1951789226",d==="left"&&"kakadu-components-1495725644",d==="right"&&"kakadu-components-4235689197")}),n.jsxRuntimeExports.jsx(K.focusTrapReactExports.FocusTrap,{active:U,focusTrapOptions:G,children:n.jsxRuntimeExports.jsxs("div",{className:m.cx("kakadu-components-2488426662",f),children:[n.jsxRuntimeExports.jsx(Q,{value:J,children:v}),n.jsxRuntimeExports.jsx("div",{className:m.cx("kakadu-components-3252390100",d==="left"&&"kakadu-components-3754561431",d==="right"&&"kakadu-components-2265262600")})]})})]})}):null}function ee(i,s){const[l,p]=e.useState(!1),[r,v]=e.useState(!1),a=e.useRef(void 0),f=e.useRef(void 0),c=e.useCallback(async()=>(f.current=void 0,p(!0),v(!0),new Promise(o=>{a.current=o})),[]),h=e.useCallback(o=>{f.current=o,v(!1)},[]),x=e.useCallback(o=>{var g;const R=o??f.current;f.current=void 0,(g=a.current)==null||g.call(a,R),a.current=void 0,p(!1),v(!1)},[]),k=e.useMemo(()=>l?n.jsxRuntimeExports.jsx(i,{...s,isVisible:r,onClose:x}):null,[l,i,s,r,x]);return e.useMemo(()=>({isVisible:r,show:c,close:h,popover:k}),[r,c,h,k])}exports.PopoverContainer=Y;exports.default=Z;exports.usePopover=ee;exports.usePopoverContext=X;
@@ -1,14 +1,14 @@
1
- import { j as n } from "../jsx-runtime-B4hRZ52C.mjs";
1
+ import { j as s } from "../jsx-runtime-B4hRZ52C.mjs";
2
2
  import { cx as m } from "@kuma-ui/core";
3
- import { createContext as ee, useRef as F, useState as s, useCallback as P, useMemo as b, useEffect as x, useContext as te } from "react";
4
- import { f as ne } from "../focus-trap-react-Dr3BYLw6.mjs";
3
+ import { createContext as ee, useRef as P, useState as n, useCallback as R, useMemo as b, useEffect as F, useContext as te } from "react";
4
+ import { f as se } from "../focus-trap-react-Dr3BYLw6.mjs";
5
5
  import K, { defaultAtomElementType as Q } from "./atom.mjs";
6
6
  const X = ee({
7
7
  isVisible: !1,
8
8
  isPreparingFocus: !1,
9
9
  isFocused: !1
10
10
  }), {
11
- Provider: se
11
+ Provider: ne
12
12
  } = X;
13
13
  function le() {
14
14
  return te(X);
@@ -18,7 +18,7 @@ function fe({
18
18
  className: t,
19
19
  ...l
20
20
  }) {
21
- return /* @__PURE__ */ n.jsx(K, { as: u ?? Q, ...l, className: m("kakadu-components-2845019685", t) });
21
+ return /* @__PURE__ */ s.jsx(K, { as: u ?? Q, ...l, className: m("kakadu-components-2845019685", t) });
22
22
  }
23
23
  function de({
24
24
  as: u,
@@ -26,21 +26,21 @@ function de({
26
26
  label: l,
27
27
  shouldCloseOnOutsideClick: p = !0,
28
28
  shouldCloseOnEscapePress: r = !0,
29
- children: R,
29
+ children: v,
30
30
  className: a,
31
31
  innerClassName: f,
32
32
  onClose: c,
33
33
  ...j
34
34
  }) {
35
- const v = F(null), k = F(null), [o, w] = s(!1), [g, I] = s(!1), [y, Y] = s(!1), [i, T] = s(!1), [Z, E] = s(!1), z = P((e) => {
36
- v.current = e, T(!1);
37
- }, []), N = F(null), B = P((e) => {
35
+ const k = P(null), w = P(null), [o, g] = n(!1), [h, I] = n(!1), [y, Y] = n(!1), [i, T] = n(!1), [Z, E] = n(!1), z = R((e) => {
36
+ k.current = e, T(!1);
37
+ }, []), N = P(null), B = R((e) => {
38
38
  e && (N.current = e);
39
39
  }, []), _ = b(() => ({
40
40
  initialFocus: () => N.current ?? void 0,
41
41
  onPostActivate() {
42
42
  var e;
43
- I(!0), w(!1), (e = N.current) == null || e.focus();
43
+ I(!0), g(!1), (e = N.current) == null || e.focus();
44
44
  },
45
45
  clickOutsideDeactivates: p,
46
46
  escapeDeactivates: r,
@@ -53,15 +53,15 @@ function de({
53
53
  onDeactivate() {
54
54
  E(!1), T(!1), I(!1);
55
55
  }
56
- }), [p, r]), [L, C] = s(t ?? !1), $ = b(() => ({
56
+ }), [p, r]), [L, C] = n(t ?? !1), $ = b(() => ({
57
57
  isVisible: L,
58
58
  isPreparingFocus: o,
59
- isFocused: g,
59
+ isFocused: h,
60
60
  setInitialFocus: B,
61
61
  close: z
62
- }), [L, o, g, B, z]), [d, W] = s("center");
63
- return x(() => {
64
- const e = k.current;
62
+ }), [L, o, h, B, z]), [d, W] = n("center");
63
+ return F(() => {
64
+ const e = w.current;
65
65
  if (e) {
66
66
  const D = () => {
67
67
  const q = e.offsetParent, M = q instanceof HTMLElement ? q.getBoundingClientRect() : null, H = e.getBoundingClientRect();
@@ -70,20 +70,20 @@ function de({
70
70
  return;
71
71
  }
72
72
  const O = 16, S = window.innerWidth - O, V = M.left + M.width / 2 - H.width / 2, U = V + H.width, G = V < O, J = U > S;
73
- let h = "center";
73
+ let x = "center";
74
74
  if (G && J) {
75
75
  const A = O - V;
76
- h = U - S > A ? "right" : "left";
77
- } else J ? h = "right" : G && (h = "left");
78
- W((A) => A === h ? A : h);
76
+ x = U - S > A ? "right" : "left";
77
+ } else J ? x = "right" : G && (x = "left");
78
+ W((A) => A === x ? A : x);
79
79
  };
80
80
  return D(), window.addEventListener("resize", D), () => {
81
81
  window.removeEventListener("resize", D);
82
82
  };
83
83
  }
84
- }, []), x(() => {
84
+ }, []), F(() => {
85
85
  t && (Y(!0), C(!0));
86
- }, [t]), x(() => {
86
+ }, [t]), F(() => {
87
87
  if (t) {
88
88
  const e = setTimeout(() => {
89
89
  T(!0);
@@ -93,51 +93,51 @@ function de({
93
93
  };
94
94
  }
95
95
  T(!1);
96
- }, [t]), x(() => {
96
+ }, [t]), F(() => {
97
97
  if (!i) {
98
- E(!1), w(!1);
98
+ E(!1), g(!1);
99
99
  return;
100
100
  }
101
- w(!0);
101
+ g(!0);
102
102
  const e = window.requestAnimationFrame(() => {
103
103
  E(!0);
104
104
  });
105
105
  return () => {
106
106
  window.cancelAnimationFrame(e);
107
107
  };
108
- }, [i]), x(() => {
108
+ }, [i]), F(() => {
109
109
  if (y && !i) {
110
110
  const e = setTimeout(() => {
111
- C(!1), c == null || c(v.current ?? void 0);
111
+ C(!1), c == null || c(k.current ?? void 0);
112
112
  }, 370);
113
113
  return () => {
114
114
  clearTimeout(e);
115
115
  };
116
116
  }
117
- }, [y, i, c]), L ? /* @__PURE__ */ n.jsx(K, { reference: k, as: u ?? Q, role: "dialog", "aria-hidden": !i, "aria-label": l ?? "Popover", ...j, className: m("kakadu-components-3920007758", d === "left" && "kakadu-components-611400930", d === "right" && "kakadu-components-944244368", i && "kakadu-components-1399012551", a), children: /* @__PURE__ */ n.jsxs("div", { className: m("kakadu-components-1118152266", i && "kakadu-components-231244945"), children: [
118
- /* @__PURE__ */ n.jsx("div", { className: m("kakadu-components-1951789226", d === "left" && "kakadu-components-1495725644", d === "right" && "kakadu-components-4235689197") }),
119
- /* @__PURE__ */ n.jsx(ne.FocusTrap, { active: Z, focusTrapOptions: _, children: /* @__PURE__ */ n.jsxs("div", { className: m("kakadu-components-2488426662", f), children: [
120
- /* @__PURE__ */ n.jsx(se, { value: $, children: R }),
121
- /* @__PURE__ */ n.jsx("div", { className: m("kakadu-components-3252390100", d === "left" && "kakadu-components-3754561431", d === "right" && "kakadu-components-2265262600") })
117
+ }, [y, i, c]), L ? /* @__PURE__ */ s.jsx(K, { reference: w, as: u ?? Q, role: "dialog", "aria-hidden": !i, "aria-label": l ?? "Popover", ...j, className: m("kakadu-components-3920007758", d === "left" && "kakadu-components-611400930", d === "right" && "kakadu-components-944244368", i && "kakadu-components-1399012551", a), children: /* @__PURE__ */ s.jsxs("div", { className: m("kakadu-components-1118152266", i && "kakadu-components-231244945"), children: [
118
+ /* @__PURE__ */ s.jsx("div", { className: m("kakadu-components-1951789226", d === "left" && "kakadu-components-1495725644", d === "right" && "kakadu-components-4235689197") }),
119
+ /* @__PURE__ */ s.jsx(se.FocusTrap, { active: Z, focusTrapOptions: _, children: /* @__PURE__ */ s.jsxs("div", { className: m("kakadu-components-2488426662", f), children: [
120
+ /* @__PURE__ */ s.jsx(ne, { value: $, children: v }),
121
+ /* @__PURE__ */ s.jsx("div", { className: m("kakadu-components-3252390100", d === "left" && "kakadu-components-3754561431", d === "right" && "kakadu-components-2265262600") })
122
122
  ] }) })
123
123
  ] }) }) : null;
124
124
  }
125
125
  function me(u, t) {
126
- const [l, p] = s(!1), [r, R] = s(!1), a = F(void 0), f = F(void 0), c = P(async () => (f.current = void 0, p(!0), R(!0), new Promise((o) => {
126
+ const [l, p] = n(!1), [r, v] = n(!1), a = P(void 0), f = P(void 0), c = R(async () => (f.current = void 0, p(!0), v(!0), new Promise((o) => {
127
127
  a.current = o;
128
- })), []), j = P((o) => {
129
- f.current = o, R(!1);
130
- }, []), v = P((o) => {
131
- var g;
132
- const w = o ?? f.current;
133
- f.current = void 0, (g = a.current) == null || g.call(a, w), a.current = void 0, p(!1);
134
- }, []), k = b(() => l ? /* @__PURE__ */ n.jsx(u, { ...t, isVisible: r, onClose: v }) : null, [l, u, t, r, v]);
128
+ })), []), j = R((o) => {
129
+ f.current = o, v(!1);
130
+ }, []), k = R((o) => {
131
+ var h;
132
+ const g = o ?? f.current;
133
+ f.current = void 0, (h = a.current) == null || h.call(a, g), a.current = void 0, p(!1), v(!1);
134
+ }, []), w = b(() => l ? /* @__PURE__ */ s.jsx(u, { ...t, isVisible: r, onClose: k }) : null, [l, u, t, r, k]);
135
135
  return b(() => ({
136
136
  isVisible: r,
137
137
  show: c,
138
138
  close: j,
139
- popover: k
140
- }), [r, c, j, k]);
139
+ popover: w
140
+ }), [r, c, j, w]);
141
141
  }
142
142
  export {
143
143
  fe as PopoverContainer,