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