@kakadu/components 2.3.3 → 2.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/button.d.ts +4 -0
- package/build/components/button.js +1 -1
- package/build/components/button.mjs +53 -46
- package/build/components/icon-button.d.ts +2 -1
- package/build/components/icon-button.js +1 -1
- package/build/components/icon-button.mjs +36 -32
- package/build/components/popover.js +1 -1
- package/build/components/popover.mjs +78 -68
- package/build/components.css +1 -1
- package/build/index.js +1 -1
- package/build/index.mjs +202 -201
- package/package.json +1 -1
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type ReactNode, type HTMLProps } from 'react';
|
|
2
2
|
import { type IconType } from '../icons/icon';
|
|
3
3
|
import { type ButtonTooltipPosition } from './button-tooltip';
|
|
4
|
+
export declare function ButtonLoader({ isLoading, size, }: {
|
|
5
|
+
readonly isLoading?: boolean;
|
|
6
|
+
readonly size?: number;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
4
8
|
export declare enum ButtonVariant {
|
|
5
9
|
primary = "primary",
|
|
6
10
|
secondary = "secondary",
|
|
@@ -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("react"),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"),j=require("react"),a=require("@kuma-ui/core"),z=require("../theme.js"),W=require("../icons/icon.js"),$=require("./spinner.js"),C=require("./moving-gradients.js"),F=require("./moving-stars.js"),O=require("./theme-setter.js"),P=require("./click-ripples.js"),y=require("./hover-gradient.js"),A=require("./button-tooltip.js"),H=require("./aria-text.js"),J=require("./atom.js");function b({isLoading:s,size:n}){return e.jsxRuntimeExports.jsx("div",{className:a.cx("kakadu-components-3118361790",s&&"kakadu-components-4114685569"),children:e.jsxRuntimeExports.jsx("div",{className:"kakadu-components-2395688468",children:e.jsxRuntimeExports.jsx($.RevealSpinner,{isVisible:s,size:n})})})}var S=(s=>(s.primary="primary",s.secondary="secondary",s.warning="warning",s.danger="danger",s))(S||{});function R({icon:s,variant:n="primary",className:o,...r}){return e.jsxRuntimeExports.jsx("div",{...r,className:a.cx("kakadu-components-2658660333",n==="secondary"&&"kakadu-components-3469662110",o),children:typeof s=="string"?e.jsxRuntimeExports.jsx(W.default,{width:14,height:14,type:s}):s})}const E="kakadu-components-2244098950",K="kakadu-components-3923184173",f="kakadu-components-317965671",q="kakadu-components-1978976872";function Q({type:s,variant:n="primary",href:o,target:r,rel:g,disabled:v,className:_,children:t,label:N,tooltip:u,tooltipPosition:w,iconLeft:c,iconRight:i,isLoading:m,hasMovingGradients:B=!1,movingGradientsCount:d=4,hasMovingStars:M=!1,movingStarsCount:l=10,...D}){const x=j.useId(),p=j.useRef(null),h=O.useIsDarkMode(p),I=s??"button",T=B&&d>0,G=M&&l>0,k=o?!1:!!v||!!m;return e.jsxRuntimeExports.jsxs(J.default,{...D,as:o?"a":"button",type:o?void 0:I,href:o,target:r,rel:g,"aria-describedby":u?x:void 0,disabled:k,className:a.cx(z.effectStyles,"kakadu-components-1897763514",!!c&&"kakadu-components-3652831856",!t&&"kakadu-components-2746167644",n==="secondary"&&E,n==="warning"&&f,n==="danger"&&q,_),children:[c?e.jsxRuntimeExports.jsx(R,{variant:n,icon:c,className:t?"kakadu-components-294089230":void 0}):null,t?e.jsxRuntimeExports.jsx("div",{ref:p,className:"kakadu-components-2618257692",children:t}):e.jsxRuntimeExports.jsx(H.default,{children:N}),i?e.jsxRuntimeExports.jsx(R,{variant:n,icon:i,className:t?"kakadu-components-3127707672":void 0}):null,e.jsxRuntimeExports.jsx(b,{isLoading:m}),T&&e.jsxRuntimeExports.jsx(C.default,{opacity:h?.4:.3,maximumGradientsCount:d,className:a.cx("kakadu-components-1505766785",n==="secondary"&&"kakadu-components-3712045697")}),G&&e.jsxRuntimeExports.jsx(F.default,{maximumStarsCount:l,className:"kakadu-components-2813474662"}),k?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(P.default,{size:t?void 0:50}),e.jsxRuntimeExports.jsx(y.default,{size:t?void 0:50,className:n==="secondary"?y.normalBlendStyles:void 0})]}),u?e.jsxRuntimeExports.jsx(A.default,{id:x,label:u,position:w}):null]})}exports.ButtonLoader=b;exports.ButtonVariant=S;exports.buttonDangerStyles=q;exports.buttonSecondaryStyles=E;exports.buttonSuccessStyles=K;exports.buttonWarningStyles=f;exports.default=Q;
|
|
@@ -1,68 +1,75 @@
|
|
|
1
1
|
import { j as o } from "../jsx-runtime-B4hRZ52C.mjs";
|
|
2
|
-
import { useId as
|
|
2
|
+
import { useId as G, useRef as R } from "react";
|
|
3
3
|
import { cx as t } from "@kuma-ui/core";
|
|
4
|
-
import { effectStyles as
|
|
5
|
-
import
|
|
6
|
-
import { RevealSpinner as
|
|
7
|
-
import
|
|
4
|
+
import { effectStyles as T } from "../theme.mjs";
|
|
5
|
+
import z from "../icons/icon.mjs";
|
|
6
|
+
import { RevealSpinner as A } from "./spinner.mjs";
|
|
7
|
+
import C from "./moving-gradients.mjs";
|
|
8
8
|
import h from "./moving-stars.mjs";
|
|
9
|
-
import { useIsDarkMode as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
|
|
9
|
+
import { useIsDarkMode as E } from "./theme-setter.mjs";
|
|
10
|
+
import F from "./click-ripples.mjs";
|
|
11
|
+
import H, { normalBlendStyles as W } from "./hover-gradient.mjs";
|
|
12
|
+
import q from "./button-tooltip.mjs";
|
|
13
|
+
import J from "./aria-text.mjs";
|
|
14
|
+
import K from "./atom.mjs";
|
|
15
|
+
function O({
|
|
16
|
+
isLoading: s,
|
|
17
|
+
size: n
|
|
18
|
+
}) {
|
|
19
|
+
return /* @__PURE__ */ o.jsx("div", { className: t("kakadu-components-3118361790", s && "kakadu-components-4114685569"), children: /* @__PURE__ */ o.jsx("div", { className: "kakadu-components-2395688468", children: /* @__PURE__ */ o.jsx(A, { isVisible: s, size: n }) }) });
|
|
20
|
+
}
|
|
21
|
+
var P = /* @__PURE__ */ ((s) => (s.primary = "primary", s.secondary = "secondary", s.warning = "warning", s.danger = "danger", s))(P || {});
|
|
16
22
|
function y({
|
|
17
23
|
icon: s,
|
|
18
24
|
variant: n = "primary",
|
|
19
25
|
className: a,
|
|
20
|
-
...
|
|
26
|
+
...r
|
|
21
27
|
}) {
|
|
22
|
-
return /* @__PURE__ */ o.jsx("div", { ...
|
|
28
|
+
return /* @__PURE__ */ o.jsx("div", { ...r, className: t("kakadu-components-2658660333", n === "secondary" && "kakadu-components-3469662110", a), children: typeof s == "string" ? /* @__PURE__ */ o.jsx(z, { width: 14, height: 14, type: s }) : s });
|
|
23
29
|
}
|
|
24
|
-
const
|
|
25
|
-
function
|
|
30
|
+
const Q = "kakadu-components-2244098950", co = "kakadu-components-3923184173", U = "kakadu-components-317965671", X = "kakadu-components-1978976872";
|
|
31
|
+
function io({
|
|
26
32
|
type: s,
|
|
27
33
|
variant: n = "primary",
|
|
28
34
|
href: a,
|
|
29
|
-
target:
|
|
35
|
+
target: r,
|
|
30
36
|
rel: f,
|
|
31
|
-
disabled:
|
|
32
|
-
className:
|
|
37
|
+
disabled: j,
|
|
38
|
+
className: b,
|
|
33
39
|
children: e,
|
|
34
|
-
label:
|
|
35
|
-
tooltip:
|
|
36
|
-
tooltipPosition:
|
|
40
|
+
label: S,
|
|
41
|
+
tooltip: m,
|
|
42
|
+
tooltipPosition: g,
|
|
37
43
|
iconLeft: c,
|
|
38
|
-
iconRight:
|
|
39
|
-
isLoading:
|
|
40
|
-
hasMovingGradients:
|
|
41
|
-
movingGradientsCount:
|
|
42
|
-
hasMovingStars:
|
|
43
|
-
movingStarsCount:
|
|
44
|
-
...
|
|
44
|
+
iconRight: d,
|
|
45
|
+
isLoading: i,
|
|
46
|
+
hasMovingGradients: v = !1,
|
|
47
|
+
movingGradientsCount: p = 4,
|
|
48
|
+
hasMovingStars: N = !1,
|
|
49
|
+
movingStarsCount: u = 10,
|
|
50
|
+
...w
|
|
45
51
|
}) {
|
|
46
|
-
const
|
|
47
|
-
return /* @__PURE__ */ o.jsxs(
|
|
52
|
+
const l = G(), k = R(null), M = E(k), B = s ?? "button", I = v && p > 0, D = N && u > 0, x = a ? !1 : !!j || !!i;
|
|
53
|
+
return /* @__PURE__ */ o.jsxs(K, { ...w, as: a ? "a" : "button", type: a ? void 0 : B, href: a, target: r, rel: f, "aria-describedby": m ? l : void 0, disabled: x, className: t(T, "kakadu-components-1897763514", !!c && "kakadu-components-3652831856", !e && "kakadu-components-2746167644", n === "secondary" && Q, n === "warning" && U, n === "danger" && X, b), children: [
|
|
48
54
|
c ? /* @__PURE__ */ o.jsx(y, { variant: n, icon: c, className: e ? "kakadu-components-294089230" : void 0 }) : null,
|
|
49
|
-
e ? /* @__PURE__ */ o.jsx("div", { ref:
|
|
50
|
-
|
|
51
|
-
/* @__PURE__ */ o.jsx(
|
|
52
|
-
I && /* @__PURE__ */ o.jsx(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
/* @__PURE__ */ o.jsx(
|
|
56
|
-
/* @__PURE__ */ o.jsx(
|
|
55
|
+
e ? /* @__PURE__ */ o.jsx("div", { ref: k, className: "kakadu-components-2618257692", children: e }) : /* @__PURE__ */ o.jsx(J, { children: S }),
|
|
56
|
+
d ? /* @__PURE__ */ o.jsx(y, { variant: n, icon: d, className: e ? "kakadu-components-3127707672" : void 0 }) : null,
|
|
57
|
+
/* @__PURE__ */ o.jsx(O, { isLoading: i }),
|
|
58
|
+
I && /* @__PURE__ */ o.jsx(C, { opacity: M ? 0.4 : 0.3, maximumGradientsCount: p, className: t("kakadu-components-1505766785", n === "secondary" && "kakadu-components-3712045697") }),
|
|
59
|
+
D && /* @__PURE__ */ o.jsx(h, { maximumStarsCount: u, className: "kakadu-components-2813474662" }),
|
|
60
|
+
x ? null : /* @__PURE__ */ o.jsxs(o.Fragment, { children: [
|
|
61
|
+
/* @__PURE__ */ o.jsx(F, { size: e ? void 0 : 50 }),
|
|
62
|
+
/* @__PURE__ */ o.jsx(H, { size: e ? void 0 : 50, className: n === "secondary" ? W : void 0 })
|
|
57
63
|
] }),
|
|
58
|
-
|
|
64
|
+
m ? /* @__PURE__ */ o.jsx(q, { id: l, label: m, position: g }) : null
|
|
59
65
|
] });
|
|
60
66
|
}
|
|
61
67
|
export {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
O as ButtonLoader,
|
|
69
|
+
P as ButtonVariant,
|
|
70
|
+
X as buttonDangerStyles,
|
|
71
|
+
Q as buttonSecondaryStyles,
|
|
72
|
+
co as buttonSuccessStyles,
|
|
73
|
+
U as buttonWarningStyles,
|
|
74
|
+
io as default
|
|
68
75
|
};
|
|
@@ -12,5 +12,6 @@ export type IconButtonProperties = HTMLProps<HTMLButtonElement> & {
|
|
|
12
12
|
readonly variant?: IconButtonVariant;
|
|
13
13
|
readonly label: string;
|
|
14
14
|
readonly tooltipPosition?: ButtonTooltipPosition;
|
|
15
|
+
readonly isLoading?: boolean;
|
|
15
16
|
};
|
|
16
|
-
export default function IconButton({ icon, variant, label, tooltipPosition, disabled, className, ...properties }: IconButtonProperties): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export default function IconButton({ icon, variant, label, tooltipPosition, disabled, isLoading, className, ...properties }: IconButtonProperties): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../jsx-runtime-BB_1_6y_.js"),s=require("react"),n=require("@kuma-ui/core"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../jsx-runtime-BB_1_6y_.js"),s=require("react"),n=require("@kuma-ui/core"),l=require("../icons/icon.js"),S=require("../theme.js"),_=require("./theme-setter.js"),o=require("./button.js"),N=require("./button-tooltip.js"),T=require("./click-ripples.js"),h=require("./hover-gradient.js");var R=(e=>(e.default="default",e.success="success",e.warning="warning",e.danger="danger",e))(R||{});function D({icon:e,variant:u="default",label:d,tooltipPosition:b,disabled:y,isLoading:m,className:g,...E}){const x=s.useId(),q=_.useIsDarkMode(),[r,w]=s.useState(e),[p,i]=s.useState(!1),f=s.useRef(e),c=s.useRef(null);s.useEffect(()=>{f.current=e},[e]);const a=s.useCallback(()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]);s.useEffect(()=>{if(r===e){i(j=>j&&!1);return}i(!0),a(),c.current=setTimeout(()=>{i(!1),w(f.current)},370)},[r,e,a]),s.useEffect(()=>()=>{a()},[a]);const k=!!y||!!m;return t.jsxRuntimeExports.jsxs("button",{...E,type:"button","aria-label":d,"aria-describedby":x,disabled:k,className:n.cx(S.buttonResetStyles,S.effectStyles,"kakadu-components-1150622507",u==="default"&&n.cx(o.buttonSecondaryStyles,"kakadu-components-2089159949"),u==="success"&&n.cx(o.buttonSuccessStyles,"kakadu-components-4088931955"),u==="warning"&&n.cx(o.buttonWarningStyles,"kakadu-components-1450399719"),u==="danger"&&n.cx(o.buttonDangerStyles,"kakadu-components-3594030066"),g),children:[t.jsxRuntimeExports.jsxs("span",{"data-theme":u==="default"?q?"dark":"light":"dark",className:"kakadu-components-2197738751",children:[t.jsxRuntimeExports.jsx(l.default,{width:16,height:16,type:r,className:n.cx(l.iconShadowStyles,"kakadu-components-1309118222",p&&"kakadu-components-3602476657")}),r===e?null:t.jsxRuntimeExports.jsx(l.default,{width:16,height:16,type:e,className:n.cx(l.iconShadowStyles,"kakadu-components-2883440801",p&&"kakadu-components-1406924214")})]}),t.jsxRuntimeExports.jsx(o.ButtonLoader,{isLoading:m,size:14}),t.jsxRuntimeExports.jsx(N.default,{id:x,label:d,position:b}),k?null:t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(T.default,{size:50}),t.jsxRuntimeExports.jsx(h.default,{size:50,className:u==="default"?h.normalBlendStyles:void 0})]})]})}exports.IconButtonVariant=R;exports.default=D;
|
|
@@ -1,53 +1,57 @@
|
|
|
1
1
|
import { j as t } from "../jsx-runtime-B4hRZ52C.mjs";
|
|
2
|
-
import { useId as
|
|
2
|
+
import { useId as D, useState as h, useRef as y, useEffect as c, useCallback as I } from "react";
|
|
3
3
|
import { cx as s } from "@kuma-ui/core";
|
|
4
|
-
import
|
|
5
|
-
import { buttonResetStyles as
|
|
6
|
-
import { useIsDarkMode as
|
|
7
|
-
import { buttonSecondaryStyles as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
var
|
|
12
|
-
function
|
|
4
|
+
import S, { iconShadowStyles as g } from "../icons/icon.mjs";
|
|
5
|
+
import { buttonResetStyles as T, effectStyles as z } from "../theme.mjs";
|
|
6
|
+
import { useIsDarkMode as B } from "./theme-setter.mjs";
|
|
7
|
+
import { ButtonLoader as C, buttonSecondaryStyles as E, buttonSuccessStyles as M, buttonWarningStyles as F, buttonDangerStyles as G } from "./button.mjs";
|
|
8
|
+
import H from "./button-tooltip.mjs";
|
|
9
|
+
import P from "./click-ripples.mjs";
|
|
10
|
+
import W, { normalBlendStyles as q } from "./hover-gradient.mjs";
|
|
11
|
+
var A = /* @__PURE__ */ ((e) => (e.default = "default", e.success = "success", e.warning = "warning", e.danger = "danger", e))(A || {});
|
|
12
|
+
function $({
|
|
13
13
|
icon: e,
|
|
14
14
|
variant: o = "default",
|
|
15
15
|
label: l,
|
|
16
|
-
tooltipPosition:
|
|
17
|
-
disabled:
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
tooltipPosition: x,
|
|
17
|
+
disabled: b,
|
|
18
|
+
isLoading: m,
|
|
19
|
+
className: j,
|
|
20
|
+
...w
|
|
20
21
|
}) {
|
|
21
|
-
const d =
|
|
22
|
+
const d = D(), R = B(), [n, N] = h(e), [i, u] = h(!1), f = y(e), r = y(null);
|
|
22
23
|
c(() => {
|
|
23
24
|
f.current = e;
|
|
24
25
|
}, [e]);
|
|
25
|
-
const
|
|
26
|
+
const a = I(() => {
|
|
26
27
|
r.current && (clearTimeout(r.current), r.current = null);
|
|
27
28
|
}, []);
|
|
28
|
-
|
|
29
|
+
c(() => {
|
|
29
30
|
if (n === e) {
|
|
30
|
-
|
|
31
|
+
u((k) => k && !1);
|
|
31
32
|
return;
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
u(!0), a(), r.current = setTimeout(() => {
|
|
35
|
+
u(!1), N(f.current);
|
|
35
36
|
}, 370);
|
|
36
|
-
}, [n, e,
|
|
37
|
-
|
|
38
|
-
}, [
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
}, [n, e, a]), c(() => () => {
|
|
38
|
+
a();
|
|
39
|
+
}, [a]);
|
|
40
|
+
const p = !!b || !!m;
|
|
41
|
+
return /* @__PURE__ */ t.jsxs("button", { ...w, type: "button", "aria-label": l, "aria-describedby": d, disabled: p, className: s(T, z, "kakadu-components-1150622507", o === "default" && s(E, "kakadu-components-2089159949"), o === "success" && s(M, "kakadu-components-4088931955"), o === "warning" && s(F, "kakadu-components-1450399719"), o === "danger" && s(G, "kakadu-components-3594030066"), j), children: [
|
|
42
|
+
/* @__PURE__ */ t.jsxs("span", { "data-theme": o === "default" ? R ? "dark" : "light" : "dark", className: "kakadu-components-2197738751", children: [
|
|
43
|
+
/* @__PURE__ */ t.jsx(S, { width: 16, height: 16, type: n, className: s(g, "kakadu-components-1309118222", i && "kakadu-components-3602476657") }),
|
|
44
|
+
n === e ? null : /* @__PURE__ */ t.jsx(S, { width: 16, height: 16, type: e, className: s(g, "kakadu-components-2883440801", i && "kakadu-components-1406924214") })
|
|
42
45
|
] }),
|
|
43
|
-
/* @__PURE__ */ t.jsx(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
/* @__PURE__ */ t.jsx(
|
|
46
|
+
/* @__PURE__ */ t.jsx(C, { isLoading: m, size: 14 }),
|
|
47
|
+
/* @__PURE__ */ t.jsx(H, { id: d, label: l, position: x }),
|
|
48
|
+
p ? null : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
49
|
+
/* @__PURE__ */ t.jsx(P, { size: 50 }),
|
|
50
|
+
/* @__PURE__ */ t.jsx(W, { size: 50, className: o === "default" ? q : void 0 })
|
|
47
51
|
] })
|
|
48
52
|
] });
|
|
49
53
|
}
|
|
50
54
|
export {
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
A as IconButtonVariant,
|
|
56
|
+
$ as default
|
|
53
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
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-2899069338",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-3905822111",R),children:[s.jsxRuntimeExports.jsx(z,{value:W,children:u}),s.jsxRuntimeExports.jsx("div",{className:d.cx("kakadu-components-3328048824",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,114 +1,124 @@
|
|
|
1
1
|
import { j as n } from "../jsx-runtime-B4hRZ52C.mjs";
|
|
2
|
-
import { cx as
|
|
3
|
-
import { createContext as
|
|
4
|
-
import { f as
|
|
5
|
-
import
|
|
6
|
-
const
|
|
2
|
+
import { cx as f } from "@kuma-ui/core";
|
|
3
|
+
import { createContext as K, useRef as h, useState as v, useCallback as T, useMemo as P, useEffect as R, useContext as Q } from "react";
|
|
4
|
+
import { f as U } from "../focus-trap-react-DYXrtbDH.mjs";
|
|
5
|
+
import B, { defaultAtomElementType as H } from "./atom.mjs";
|
|
6
|
+
const S = K({
|
|
7
7
|
isVisible: !1
|
|
8
8
|
}), {
|
|
9
|
-
Provider:
|
|
10
|
-
} =
|
|
11
|
-
function
|
|
12
|
-
return S
|
|
9
|
+
Provider: X
|
|
10
|
+
} = S;
|
|
11
|
+
function ne() {
|
|
12
|
+
return Q(S);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
as:
|
|
14
|
+
function se({
|
|
15
|
+
as: i,
|
|
16
16
|
className: t,
|
|
17
17
|
...s
|
|
18
18
|
}) {
|
|
19
|
-
return /* @__PURE__ */ n.jsx(
|
|
19
|
+
return /* @__PURE__ */ n.jsx(B, { as: i ?? H, ...s, className: f("kakadu-components-2845019685", t) });
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
as:
|
|
21
|
+
function oe({
|
|
22
|
+
as: i,
|
|
23
23
|
isVisible: t,
|
|
24
24
|
label: s,
|
|
25
|
-
shouldCloseOnOutsideClick:
|
|
25
|
+
shouldCloseOnOutsideClick: d = !0,
|
|
26
26
|
shouldCloseOnEscapePress: o = !0,
|
|
27
|
-
children:
|
|
28
|
-
className:
|
|
27
|
+
children: a,
|
|
28
|
+
className: w,
|
|
29
29
|
innerClassName: x,
|
|
30
|
-
onClose:
|
|
30
|
+
onClose: r,
|
|
31
31
|
...m
|
|
32
32
|
}) {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
}, []),
|
|
36
|
-
e && (
|
|
37
|
-
}, []),
|
|
38
|
-
initialFocus: () =>
|
|
33
|
+
const c = h(null), p = h(null), [F, q] = v(!1), [u, g] = v(!1), L = T((e) => {
|
|
34
|
+
c.current = e, g(!1);
|
|
35
|
+
}, []), b = h(null), D = T((e) => {
|
|
36
|
+
e && (b.current = e);
|
|
37
|
+
}, []), G = P(() => ({
|
|
38
|
+
initialFocus: () => b.current ?? void 0,
|
|
39
39
|
onActivate: () => {
|
|
40
40
|
var e;
|
|
41
|
-
return (e =
|
|
41
|
+
return (e = b.current) == null ? void 0 : e.focus();
|
|
42
42
|
},
|
|
43
|
-
clickOutsideDeactivates:
|
|
43
|
+
clickOutsideDeactivates: d,
|
|
44
44
|
escapeDeactivates: o,
|
|
45
45
|
onDeactivate() {
|
|
46
|
-
|
|
46
|
+
g(!1);
|
|
47
47
|
}
|
|
48
|
-
}), [
|
|
49
|
-
isVisible:
|
|
50
|
-
setInitialFocus:
|
|
51
|
-
close:
|
|
52
|
-
}), [
|
|
53
|
-
return
|
|
48
|
+
}), [d, o]), [O, V] = v(t ?? !1), J = P(() => ({
|
|
49
|
+
isVisible: O,
|
|
50
|
+
setInitialFocus: D,
|
|
51
|
+
close: L
|
|
52
|
+
}), [O, D, L]), [l, A] = v("center");
|
|
53
|
+
return R(() => {
|
|
54
54
|
const e = p.current;
|
|
55
55
|
if (e) {
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
|
|
56
|
+
const E = () => {
|
|
57
|
+
const C = e.offsetParent, I = C instanceof HTMLElement ? C.getBoundingClientRect() : null, M = e.getBoundingClientRect();
|
|
58
|
+
if (!I) {
|
|
59
|
+
A("center");
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const N = I.left + I.width / 2 - M.width / 2, W = N + M.width, y = N < 0, z = W > window.innerWidth;
|
|
63
|
+
let k = "center";
|
|
64
|
+
if (y && z) {
|
|
65
|
+
const j = Math.abs(N);
|
|
66
|
+
k = W - window.innerWidth > j ? "right" : "left";
|
|
67
|
+
} else z ? k = "right" : y && (k = "left");
|
|
68
|
+
A((j) => j === k ? j : k);
|
|
59
69
|
};
|
|
60
|
-
return
|
|
61
|
-
window.removeEventListener("resize",
|
|
70
|
+
return E(), window.addEventListener("resize", E), () => {
|
|
71
|
+
window.removeEventListener("resize", E);
|
|
62
72
|
};
|
|
63
73
|
}
|
|
64
|
-
}, []),
|
|
65
|
-
t && (
|
|
66
|
-
}, [t]),
|
|
74
|
+
}, []), R(() => {
|
|
75
|
+
t && (q(!0), V(!0));
|
|
76
|
+
}, [t]), R(() => {
|
|
67
77
|
if (t) {
|
|
68
78
|
const e = setTimeout(() => {
|
|
69
|
-
|
|
79
|
+
g(!0);
|
|
70
80
|
}, 100);
|
|
71
81
|
return () => {
|
|
72
82
|
clearTimeout(e);
|
|
73
83
|
};
|
|
74
84
|
}
|
|
75
|
-
|
|
76
|
-
}, [t]),
|
|
77
|
-
if (
|
|
85
|
+
g(!1);
|
|
86
|
+
}, [t]), R(() => {
|
|
87
|
+
if (F && !u) {
|
|
78
88
|
const e = setTimeout(() => {
|
|
79
|
-
|
|
89
|
+
r == null || r(c.current ?? void 0), V(!1);
|
|
80
90
|
}, 370);
|
|
81
91
|
return () => {
|
|
82
92
|
clearTimeout(e);
|
|
83
93
|
};
|
|
84
94
|
}
|
|
85
|
-
}, [
|
|
86
|
-
/* @__PURE__ */ n.jsx("div", { className:
|
|
87
|
-
/* @__PURE__ */ n.jsx(
|
|
88
|
-
/* @__PURE__ */ n.jsx(
|
|
89
|
-
/* @__PURE__ */ n.jsx("div", { className:
|
|
95
|
+
}, [F, u, r]), /* @__PURE__ */ n.jsx(B, { reference: p, as: i ?? H, role: "dialog", "aria-hidden": !u, "aria-label": s ?? "Popover", ...m, className: f("kakadu-components-3920007758", l === "left" && "kakadu-components-611400930", l === "right" && "kakadu-components-944244368", u && "kakadu-components-1399012551", w), children: /* @__PURE__ */ n.jsxs("div", { className: f("kakadu-components-1118152266", u && "kakadu-components-231244945"), children: [
|
|
96
|
+
/* @__PURE__ */ n.jsx("div", { className: f("kakadu-components-2899069338", l === "left" && "kakadu-components-1495725644", l === "right" && "kakadu-components-4235689197") }),
|
|
97
|
+
/* @__PURE__ */ n.jsx(U.FocusTrap, { active: u, focusTrapOptions: G, children: /* @__PURE__ */ n.jsxs("div", { className: f("kakadu-components-3905822111", x), children: [
|
|
98
|
+
/* @__PURE__ */ n.jsx(X, { value: J, children: a }),
|
|
99
|
+
/* @__PURE__ */ n.jsx("div", { className: f("kakadu-components-3328048824", l === "left" && "kakadu-components-3754561431", l === "right" && "kakadu-components-2265262600") })
|
|
90
100
|
] }) })
|
|
91
101
|
] }) });
|
|
92
102
|
}
|
|
93
|
-
function
|
|
94
|
-
const [s,
|
|
95
|
-
o.current =
|
|
96
|
-
})), []), x =
|
|
97
|
-
var
|
|
98
|
-
if (
|
|
99
|
-
const p =
|
|
100
|
-
p.isConnected && p.focus(),
|
|
103
|
+
function re(i, t) {
|
|
104
|
+
const [s, d] = v(!1), o = h(void 0), a = h(null), w = T(async (m) => (d(!0), a.current = m ?? document.activeElement, new Promise((c) => {
|
|
105
|
+
o.current = c;
|
|
106
|
+
})), []), x = T((m) => {
|
|
107
|
+
var c;
|
|
108
|
+
if (d(!1), (c = o.current) == null || c.call(o, m), o.current = void 0, a.current) {
|
|
109
|
+
const p = a.current;
|
|
110
|
+
p.isConnected && p.focus(), a.current = null;
|
|
101
111
|
}
|
|
102
|
-
}, []),
|
|
103
|
-
return
|
|
112
|
+
}, []), r = P(() => /* @__PURE__ */ n.jsx(i, { ...t, isVisible: s, onClose: x }), [i, t, s, x]);
|
|
113
|
+
return P(() => ({
|
|
104
114
|
isVisible: s,
|
|
105
|
-
show:
|
|
106
|
-
popover:
|
|
107
|
-
}), [s,
|
|
115
|
+
show: w,
|
|
116
|
+
popover: r
|
|
117
|
+
}), [s, w, r]);
|
|
108
118
|
}
|
|
109
119
|
export {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
120
|
+
se as PopoverContainer,
|
|
121
|
+
oe as default,
|
|
122
|
+
re as usePopover,
|
|
123
|
+
ne as usePopoverContext
|
|
114
124
|
};
|