@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.
- package/build/components/collapsible.js +1 -1
- package/build/components/collapsible.mjs +1 -1
- package/build/components/combobox.js +1 -1
- package/build/components/combobox.mjs +1 -1
- package/build/components/flex.js +1 -1
- package/build/components/flex.mjs +24 -24
- package/build/components/modal.js +1 -1
- package/build/components/modal.mjs +45 -45
- package/build/components/popover-menu.d.ts +1 -0
- package/build/components/popover-menu.js +1 -1
- package/build/components/popover-menu.mjs +130 -124
- package/build/components/popover.js +1 -1
- package/build/components/popover.mjs +41 -41
- package/build/components.css +1 -1
- package/build/hooks/use-fetch.js +1 -1
- package/build/hooks/use-fetch.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,183 +1,189 @@
|
|
|
1
1
|
import { j as e } from "../jsx-runtime-B4hRZ52C.mjs";
|
|
2
|
-
import { cx as
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import { buttonResetStyles as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { Span as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import { SkeletonInstance as
|
|
16
|
-
import
|
|
17
|
-
function
|
|
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:
|
|
21
|
-
} =
|
|
22
|
-
return
|
|
20
|
+
setValue: o
|
|
21
|
+
} = B("isKeyboardNavigating");
|
|
22
|
+
return w(() => ({
|
|
23
23
|
isKeyboardNavigating: n,
|
|
24
|
-
setIsKeyboardNavigating:
|
|
25
|
-
}), [n,
|
|
24
|
+
setIsKeyboardNavigating: o
|
|
25
|
+
}), [n, o]);
|
|
26
26
|
}
|
|
27
|
-
const
|
|
28
|
-
function
|
|
27
|
+
const xe = "kakadu-components-949294122";
|
|
28
|
+
function Y({
|
|
29
29
|
isLoading: n,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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:
|
|
44
|
-
isPreparingFocus:
|
|
45
|
-
isFocused:
|
|
46
|
-
close:
|
|
47
|
-
} =
|
|
48
|
-
isKeyboardNavigating:
|
|
49
|
-
} =
|
|
50
|
-
|
|
51
|
-
}, [
|
|
52
|
-
!
|
|
53
|
-
}, [
|
|
54
|
-
/* @__PURE__ */ e.jsx(
|
|
55
|
-
/* @__PURE__ */ e.jsx(
|
|
56
|
-
|
|
57
|
-
/* @__PURE__ */ e.jsx(
|
|
58
|
-
|
|
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
|
-
|
|
61
|
-
/* @__PURE__ */ e.jsx("span", { className: "kakadu-components-4055589237", children:
|
|
62
|
-
|
|
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
|
-
|
|
65
|
-
/* @__PURE__ */ e.jsx(
|
|
66
|
-
/* @__PURE__ */ e.jsx(
|
|
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
|
-
] }), [
|
|
69
|
-
return /* @__PURE__ */ e.jsx(
|
|
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
|
|
72
|
+
function Z(n) {
|
|
72
73
|
if ("type" in n) {
|
|
73
74
|
if (n.type === "separator")
|
|
74
|
-
return /* @__PURE__ */ e.jsx(
|
|
75
|
+
return /* @__PURE__ */ e.jsx(O, {});
|
|
75
76
|
if (n.type === "group")
|
|
76
|
-
return /* @__PURE__ */ e.jsx(
|
|
77
|
+
return /* @__PURE__ */ e.jsx(D, { className: "kakadu-components-1499037363", children: n.label });
|
|
77
78
|
}
|
|
78
|
-
return /* @__PURE__ */ e.jsx(
|
|
79
|
+
return /* @__PURE__ */ e.jsx(Y, { ...n });
|
|
79
80
|
}
|
|
80
|
-
function
|
|
81
|
+
function _({
|
|
81
82
|
items: n
|
|
82
83
|
}) {
|
|
83
84
|
const {
|
|
84
|
-
isFocused:
|
|
85
|
-
} =
|
|
86
|
-
setIsKeyboardNavigating:
|
|
87
|
-
} =
|
|
88
|
-
|
|
89
|
-
}, []),
|
|
90
|
-
|
|
91
|
-
}, [
|
|
92
|
-
return
|
|
93
|
-
if (!
|
|
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
|
|
96
|
-
const d =
|
|
97
|
-
if (
|
|
96
|
+
const s = (c) => {
|
|
97
|
+
const d = u.filter((t) => t.isConnected), l = d.length;
|
|
98
|
+
if (l === 0)
|
|
98
99
|
return;
|
|
99
|
-
let
|
|
100
|
-
const
|
|
101
|
-
let
|
|
102
|
-
switch (
|
|
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
|
-
|
|
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
|
-
|
|
112
|
+
a = 0;
|
|
113
113
|
break;
|
|
114
114
|
}
|
|
115
115
|
case "End": {
|
|
116
|
-
|
|
116
|
+
a = l - 1, v = -1;
|
|
117
117
|
break;
|
|
118
118
|
}
|
|
119
119
|
case "Tab": {
|
|
120
|
-
|
|
120
|
+
r(!0);
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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",
|
|
136
|
+
return window.addEventListener("keydown", s, {
|
|
131
137
|
capture: !0
|
|
132
138
|
}), () => {
|
|
133
|
-
window.removeEventListener("keydown",
|
|
139
|
+
window.removeEventListener("keydown", s, {
|
|
134
140
|
capture: !0
|
|
135
141
|
});
|
|
136
142
|
};
|
|
137
|
-
}, [
|
|
138
|
-
|
|
143
|
+
}, [o, u, r]), /* @__PURE__ */ e.jsx(e.Fragment, { children: n.map((s, c) => /* @__PURE__ */ e.jsx(
|
|
144
|
+
Z,
|
|
139
145
|
{
|
|
140
|
-
...
|
|
141
|
-
reference:
|
|
142
|
-
onMouseEnter:
|
|
146
|
+
...s,
|
|
147
|
+
reference: i,
|
|
148
|
+
onMouseEnter: h
|
|
143
149
|
},
|
|
144
|
-
|
|
150
|
+
c
|
|
145
151
|
)) });
|
|
146
152
|
}
|
|
147
|
-
function
|
|
153
|
+
function $({
|
|
148
154
|
items: n,
|
|
149
|
-
...
|
|
155
|
+
...o
|
|
150
156
|
}) {
|
|
151
|
-
return /* @__PURE__ */ e.jsx(
|
|
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
|
|
154
|
-
const
|
|
159
|
+
function ke(n) {
|
|
160
|
+
const o = w(() => ({
|
|
155
161
|
items: n
|
|
156
162
|
}), [n]), {
|
|
157
|
-
isVisible:
|
|
158
|
-
show:
|
|
159
|
-
close:
|
|
160
|
-
popover:
|
|
161
|
-
} =
|
|
162
|
-
return
|
|
163
|
-
isVisible:
|
|
164
|
-
show:
|
|
165
|
-
close:
|
|
166
|
-
popoverMenu:
|
|
167
|
-
}), [
|
|
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:
|
|
172
|
-
children:
|
|
177
|
+
className: o,
|
|
178
|
+
children: u
|
|
173
179
|
}) {
|
|
174
|
-
return /* @__PURE__ */ e.jsxs(
|
|
175
|
-
|
|
180
|
+
return /* @__PURE__ */ e.jsxs(T, { className: o, children: [
|
|
181
|
+
u,
|
|
176
182
|
n
|
|
177
183
|
] });
|
|
178
184
|
}
|
|
179
185
|
export {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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:
|
|
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
|
|
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
|
|
4
|
-
import { f as
|
|
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:
|
|
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__ */
|
|
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:
|
|
29
|
+
children: v,
|
|
30
30
|
className: a,
|
|
31
31
|
innerClassName: f,
|
|
32
32
|
onClose: c,
|
|
33
33
|
...j
|
|
34
34
|
}) {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
}, []), N =
|
|
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),
|
|
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] =
|
|
56
|
+
}), [p, r]), [L, C] = n(t ?? !1), $ = b(() => ({
|
|
57
57
|
isVisible: L,
|
|
58
58
|
isPreparingFocus: o,
|
|
59
|
-
isFocused:
|
|
59
|
+
isFocused: h,
|
|
60
60
|
setInitialFocus: B,
|
|
61
61
|
close: z
|
|
62
|
-
}), [L, o,
|
|
63
|
-
return
|
|
64
|
-
const e =
|
|
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
|
|
73
|
+
let x = "center";
|
|
74
74
|
if (G && J) {
|
|
75
75
|
const A = O - V;
|
|
76
|
-
|
|
77
|
-
} else J ?
|
|
78
|
-
W((A) => A ===
|
|
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
|
-
}, []),
|
|
84
|
+
}, []), F(() => {
|
|
85
85
|
t && (Y(!0), C(!0));
|
|
86
|
-
}, [t]),
|
|
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]),
|
|
96
|
+
}, [t]), F(() => {
|
|
97
97
|
if (!i) {
|
|
98
|
-
E(!1),
|
|
98
|
+
E(!1), g(!1);
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
|
-
|
|
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]),
|
|
108
|
+
}, [i]), F(() => {
|
|
109
109
|
if (y && !i) {
|
|
110
110
|
const e = setTimeout(() => {
|
|
111
|
-
C(!1), c == null || c(
|
|
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__ */
|
|
118
|
-
/* @__PURE__ */
|
|
119
|
-
/* @__PURE__ */
|
|
120
|
-
/* @__PURE__ */
|
|
121
|
-
/* @__PURE__ */
|
|
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] =
|
|
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 =
|
|
129
|
-
f.current = o,
|
|
130
|
-
}, []),
|
|
131
|
-
var
|
|
132
|
-
const
|
|
133
|
-
f.current = void 0, (
|
|
134
|
-
}, []),
|
|
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:
|
|
140
|
-
}), [r, c, j,
|
|
139
|
+
popover: w
|
|
140
|
+
}), [r, c, j, w]);
|
|
141
141
|
}
|
|
142
142
|
export {
|
|
143
143
|
fe as PopoverContainer,
|