@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.
@@ -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"),T=require("../theme.js"),G=require("../icons/icon.js"),z=require("./spinner.js"),W=require("./moving-gradients.js"),$=require("./moving-stars.js"),F=require("./theme-setter.js"),O=require("./click-ripples.js"),y=require("./hover-gradient.js"),P=require("./button-tooltip.js"),A=require("./aria-text.js"),C=require("./atom.js");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(G.default,{width:14,height:14,type:s}):s})}const b="kakadu-components-2244098950",H="kakadu-components-3923184173",E="kakadu-components-317965671",f="kakadu-components-1978976872";function J({type:s,variant:n="primary",href:o,target:r,rel:q,disabled:m,className:g,children:t,label:v,tooltip:u,tooltipPosition:_,iconLeft:c,iconRight:d,isLoading:i,hasMovingGradients:N=!1,movingGradientsCount:p=4,hasMovingStars:w=!1,movingStarsCount:x=10,...M}){const l=j.useId(),k=j.useRef(null),h=F.useIsDarkMode(k),B=s??"button",D=N&&p>0,I=w&&x>0;return e.jsxRuntimeExports.jsxs(C.default,{...M,as:o?"a":"button",type:o?void 0:B,href:o,target:r,rel:q,"aria-describedby":u?l:void 0,disabled:o?void 0:!!m||!!i,className:a.cx(T.effectStyles,"kakadu-components-1897763514",!!c&&"kakadu-components-3652831856",!t&&"kakadu-components-2746167644",n==="secondary"&&b,n==="warning"&&E,n==="danger"&&f,g),children:[c?e.jsxRuntimeExports.jsx(R,{variant:n,icon:c,className:t?"kakadu-components-294089230":void 0}):null,t?e.jsxRuntimeExports.jsx("div",{ref:k,className:"kakadu-components-2618257692",children:t}):e.jsxRuntimeExports.jsx(A.default,{children:v}),d?e.jsxRuntimeExports.jsx(R,{variant:n,icon:d,className:t?"kakadu-components-3127707672":void 0}):null,e.jsxRuntimeExports.jsx("div",{className:a.cx("kakadu-components-1029011626",i&&"kakadu-components-726496666"),children:e.jsxRuntimeExports.jsx("div",{className:"kakadu-components-772420116",children:e.jsxRuntimeExports.jsx(z.RevealSpinner,{isVisible:i})})}),D&&e.jsxRuntimeExports.jsx(W.default,{opacity:h?.4:.3,maximumGradientsCount:p,className:a.cx("kakadu-components-1505766785",n==="secondary"&&"kakadu-components-3712045697")}),I&&e.jsxRuntimeExports.jsx($.default,{maximumStarsCount:x,className:"kakadu-components-2813474662"}),m?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(O.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(P.default,{id:l,label:u,position:_}):null]})}exports.ButtonVariant=S;exports.buttonDangerStyles=f;exports.buttonSecondaryStyles=b;exports.buttonSuccessStyles=H;exports.buttonWarningStyles=E;exports.default=J;
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 D, useRef as G } from "react";
2
+ import { useId as G, useRef as R } from "react";
3
3
  import { cx as t } from "@kuma-ui/core";
4
- import { effectStyles as R } from "../theme.mjs";
5
- import T from "../icons/icon.mjs";
6
- import { RevealSpinner as z } from "./spinner.mjs";
7
- import A from "./moving-gradients.mjs";
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 C } from "./theme-setter.mjs";
10
- import E from "./click-ripples.mjs";
11
- import F, { normalBlendStyles as H } from "./hover-gradient.mjs";
12
- import W from "./button-tooltip.mjs";
13
- import q from "./aria-text.mjs";
14
- import J from "./atom.mjs";
15
- var K = /* @__PURE__ */ ((s) => (s.primary = "primary", s.secondary = "secondary", s.warning = "warning", s.danger = "danger", s))(K || {});
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
- ...m
26
+ ...r
21
27
  }) {
22
- return /* @__PURE__ */ o.jsx("div", { ...m, className: t("kakadu-components-2658660333", n === "secondary" && "kakadu-components-3469662110", a), children: typeof s == "string" ? /* @__PURE__ */ o.jsx(T, { width: 14, height: 14, type: s }) : s });
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 O = "kakadu-components-2244098950", mo = "kakadu-components-3923184173", P = "kakadu-components-317965671", Q = "kakadu-components-1978976872";
25
- function ro({
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: m,
35
+ target: r,
30
36
  rel: f,
31
- disabled: p,
32
- className: j,
37
+ disabled: j,
38
+ className: b,
33
39
  children: e,
34
- label: b,
35
- tooltip: r,
36
- tooltipPosition: v,
40
+ label: S,
41
+ tooltip: m,
42
+ tooltipPosition: g,
37
43
  iconLeft: c,
38
- iconRight: i,
39
- isLoading: d,
40
- hasMovingGradients: S = !1,
41
- movingGradientsCount: u = 4,
42
- hasMovingStars: g = !1,
43
- movingStarsCount: l = 10,
44
- ...N
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 k = D(), x = G(null), w = C(x), M = s ?? "button", I = S && u > 0, B = g && l > 0;
47
- return /* @__PURE__ */ o.jsxs(J, { ...N, as: a ? "a" : "button", type: a ? void 0 : M, href: a, target: m, rel: f, "aria-describedby": r ? k : void 0, disabled: a ? void 0 : !!p || !!d, className: t(R, "kakadu-components-1897763514", !!c && "kakadu-components-3652831856", !e && "kakadu-components-2746167644", n === "secondary" && O, n === "warning" && P, n === "danger" && Q, j), children: [
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: x, className: "kakadu-components-2618257692", children: e }) : /* @__PURE__ */ o.jsx(q, { children: b }),
50
- i ? /* @__PURE__ */ o.jsx(y, { variant: n, icon: i, className: e ? "kakadu-components-3127707672" : void 0 }) : null,
51
- /* @__PURE__ */ o.jsx("div", { className: t("kakadu-components-1029011626", d && "kakadu-components-726496666"), children: /* @__PURE__ */ o.jsx("div", { className: "kakadu-components-772420116", children: /* @__PURE__ */ o.jsx(z, { isVisible: d }) }) }),
52
- I && /* @__PURE__ */ o.jsx(A, { opacity: w ? 0.4 : 0.3, maximumGradientsCount: u, className: t("kakadu-components-1505766785", n === "secondary" && "kakadu-components-3712045697") }),
53
- B && /* @__PURE__ */ o.jsx(h, { maximumStarsCount: l, className: "kakadu-components-2813474662" }),
54
- p ? null : /* @__PURE__ */ o.jsxs(o.Fragment, { children: [
55
- /* @__PURE__ */ o.jsx(E, { size: e ? void 0 : 50 }),
56
- /* @__PURE__ */ o.jsx(F, { size: e ? void 0 : 50, className: n === "secondary" ? H : void 0 })
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
- r ? /* @__PURE__ */ o.jsx(W, { id: k, label: r, position: v }) : null
64
+ m ? /* @__PURE__ */ o.jsx(q, { id: l, label: m, position: g }) : null
59
65
  ] });
60
66
  }
61
67
  export {
62
- K as ButtonVariant,
63
- Q as buttonDangerStyles,
64
- O as buttonSecondaryStyles,
65
- mo as buttonSuccessStyles,
66
- P as buttonWarningStyles,
67
- ro as default
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"),a=require("../icons/icon.js"),S=require("../theme.js"),q=require("./theme-setter.js"),i=require("./button.js"),w=require("./button-tooltip.js"),_=require("./click-ripples.js"),h=require("./hover-gradient.js");var j=(e=>(e.default="default",e.success="success",e.warning="warning",e.danger="danger",e))(j||{});function N({icon:e,variant:u="default",label:d,tooltipPosition:g,disabled:m,className:R,...y}){const x=s.useId(),b=q.useIsDarkMode(),[o,E]=s.useState(e),[p,l]=s.useState(!1),f=s.useRef(e),r=s.useRef(null);s.useEffect(()=>{f.current=e},[e]);const c=s.useCallback(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]);return s.useEffect(()=>{if(o===e){l(k=>k&&!1);return}l(!0),c(),r.current=setTimeout(()=>{l(!1),E(f.current)},370)},[o,e,c]),s.useEffect(()=>()=>{c()},[c]),t.jsxRuntimeExports.jsxs("button",{...y,type:"button","aria-label":d,"aria-describedby":x,disabled:m,className:n.cx(S.buttonResetStyles,S.effectStyles,"kakadu-components-3515018630",u==="default"&&n.cx(i.buttonSecondaryStyles,"kakadu-components-2089159949"),u==="success"&&n.cx(i.buttonSuccessStyles,"kakadu-components-4088931955"),u==="warning"&&n.cx(i.buttonWarningStyles,"kakadu-components-1450399719"),u==="danger"&&n.cx(i.buttonDangerStyles,"kakadu-components-3594030066"),R),children:[t.jsxRuntimeExports.jsxs("span",{"data-theme":u==="default"?b?"dark":"light":"dark",className:"kakadu-components-2197738751",children:[t.jsxRuntimeExports.jsx(a.default,{width:16,height:16,type:o,className:n.cx(a.iconShadowStyles,"kakadu-components-1309118222",p&&"kakadu-components-3602476657")}),o===e?null:t.jsxRuntimeExports.jsx(a.default,{width:16,height:16,type:e,className:n.cx(a.iconShadowStyles,"kakadu-components-2883440801",p&&"kakadu-components-1406924214")})]}),t.jsxRuntimeExports.jsx(w.default,{id:x,label:d,position:g}),m?null:t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(_.default,{size:50}),t.jsxRuntimeExports.jsx(h.default,{size:50,className:u==="default"?h.normalBlendStyles:void 0})]})]})}exports.IconButtonVariant=j;exports.default=N;
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 R, useState as k, useRef as h, useEffect as c, useCallback as N } from "react";
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 g, { iconShadowStyles as S } from "../icons/icon.mjs";
5
- import { buttonResetStyles as I, effectStyles as T } from "../theme.mjs";
6
- import { useIsDarkMode as D } from "./theme-setter.mjs";
7
- import { buttonSecondaryStyles as z, buttonSuccessStyles as C, buttonWarningStyles as E, buttonDangerStyles as M } from "./button.mjs";
8
- import F from "./button-tooltip.mjs";
9
- import G from "./click-ripples.mjs";
10
- import H, { normalBlendStyles as P } from "./hover-gradient.mjs";
11
- var W = /* @__PURE__ */ ((e) => (e.default = "default", e.success = "success", e.warning = "warning", e.danger = "danger", e))(W || {});
12
- function Y({
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: y,
17
- disabled: m,
18
- className: x,
19
- ...j
16
+ tooltipPosition: x,
17
+ disabled: b,
18
+ isLoading: m,
19
+ className: j,
20
+ ...w
20
21
  }) {
21
- const d = R(), b = D(), [n, w] = k(e), [i, a] = k(!1), f = h(e), r = h(null);
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 u = N(() => {
26
+ const a = I(() => {
26
27
  r.current && (clearTimeout(r.current), r.current = null);
27
28
  }, []);
28
- return c(() => {
29
+ c(() => {
29
30
  if (n === e) {
30
- a((p) => p && !1);
31
+ u((k) => k && !1);
31
32
  return;
32
33
  }
33
- a(!0), u(), r.current = setTimeout(() => {
34
- a(!1), w(f.current);
34
+ u(!0), a(), r.current = setTimeout(() => {
35
+ u(!1), N(f.current);
35
36
  }, 370);
36
- }, [n, e, u]), c(() => () => {
37
- u();
38
- }, [u]), /* @__PURE__ */ t.jsxs("button", { ...j, type: "button", "aria-label": l, "aria-describedby": d, disabled: m, className: s(I, T, "kakadu-components-3515018630", o === "default" && s(z, "kakadu-components-2089159949"), o === "success" && s(C, "kakadu-components-4088931955"), o === "warning" && s(E, "kakadu-components-1450399719"), o === "danger" && s(M, "kakadu-components-3594030066"), x), children: [
39
- /* @__PURE__ */ t.jsxs("span", { "data-theme": o === "default" ? b ? "dark" : "light" : "dark", className: "kakadu-components-2197738751", children: [
40
- /* @__PURE__ */ t.jsx(g, { width: 16, height: 16, type: n, className: s(S, "kakadu-components-1309118222", i && "kakadu-components-3602476657") }),
41
- n === e ? null : /* @__PURE__ */ t.jsx(g, { width: 16, height: 16, type: e, className: s(S, "kakadu-components-2883440801", i && "kakadu-components-1406924214") })
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(F, { id: d, label: l, position: y }),
44
- m ? null : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
45
- /* @__PURE__ */ t.jsx(G, { size: 50 }),
46
- /* @__PURE__ */ t.jsx(H, { size: 50, className: o === "default" ? P : void 0 })
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
- W as IconButtonVariant,
52
- Y as default
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 n=require("../jsx-runtime-BB_1_6y_.js"),f=require("@kuma-ui/core"),e=require("react"),L=require("../focus-trap-react-CcpTuiJi.js"),R=require("./atom.js"),C=e.createContext({isVisible:!1}),{Provider:O}=C;function V(){return e.useContext(C)}function A({as:r,className:s,...o}){return n.jsxRuntimeExports.jsx(R.default,{as:r??R.defaultAtomElementType,...o,className:f.cx("kakadu-components-2845019685",s)})}function D({as:r,isVisible:s,label:o,shouldCloseOnOutsideClick:d=!0,shouldCloseOnEscapePress:u=!0,children:i,className:p,innerClassName:v,onClose:a,...m}){const c=e.useRef(null),x=e.useRef(null),[b,q]=e.useState(!1),[l,k]=e.useState(!1),h=e.useCallback(t=>{c.current=t,k(!1)},[]),j=e.useRef(null),T=e.useCallback(t=>{t&&(j.current=t)},[]),M=e.useMemo(()=>({initialFocus:()=>j.current??void 0,onActivate:()=>{var t;return(t=j.current)==null?void 0:t.focus()},clickOutsideDeactivates:d,escapeDeactivates:u,onDeactivate(){k(!1)}}),[d,u]),[P,I]=e.useState(s??!1),N=e.useMemo(()=>({isVisible:P,setInitialFocus:T,close:h}),[P,T,h]),[E,F]=e.useState(!1),[w,y]=e.useState(!1);return e.useEffect(()=>{const t=x.current;if(t){const g=()=>{const S=t.getBoundingClientRect();F(S.left<0),y(S.right>window.innerWidth)};return g(),window.addEventListener("resize",g),()=>{window.removeEventListener("resize",g)}}},[]),e.useEffect(()=>{s&&(q(!0),I(!0))},[s]),e.useEffect(()=>{if(s){const t=setTimeout(()=>{k(!0)},100);return()=>{clearTimeout(t)}}k(!1)},[s]),e.useEffect(()=>{if(b&&!l){const t=setTimeout(()=>{a==null||a(c.current??void 0),I(!1)},370);return()=>{clearTimeout(t)}}},[b,l,a]),n.jsxRuntimeExports.jsx(R.default,{reference:x,as:r??R.defaultAtomElementType,role:"dialog","aria-hidden":!l,"aria-label":o??"Popover",...m,className:f.cx("kakadu-components-3920007758",E&&"kakadu-components-611400930",w&&"kakadu-components-944244368",l&&"kakadu-components-1399012551",p),children:n.jsxRuntimeExports.jsxs("div",{className:f.cx("kakadu-components-1118152266",l&&"kakadu-components-231244945"),children:[n.jsxRuntimeExports.jsx("div",{className:f.cx("kakadu-components-2899069338",E&&"kakadu-components-1495725644",w&&"kakadu-components-4235689197")}),n.jsxRuntimeExports.jsx(L.focusTrapReactExports.FocusTrap,{active:l,focusTrapOptions:M,children:n.jsxRuntimeExports.jsxs("div",{className:f.cx("kakadu-components-3905822111",v),children:[n.jsxRuntimeExports.jsx(O,{value:N,children:i}),n.jsxRuntimeExports.jsx("div",{className:f.cx("kakadu-components-3328048824",E&&"kakadu-components-3754561431",w&&"kakadu-components-2265262600")})]})})]})})}function _(r,s){const[o,d]=e.useState(!1),u=e.useRef(void 0),i=e.useRef(null),p=e.useCallback(async m=>(d(!0),i.current=m??document.activeElement,new Promise(c=>{u.current=c})),[]),v=e.useCallback(m=>{var c;if(d(!1),(c=u.current)==null||c.call(u,m),u.current=void 0,i.current){const x=i.current;x.isConnected&&x.focus(),i.current=null}},[]),a=e.useMemo(()=>n.jsxRuntimeExports.jsx(r,{...s,isVisible:o,onClose:v}),[r,s,o,v]);return e.useMemo(()=>({isVisible:o,show:p,popover:a}),[o,p,a])}exports.PopoverContainer=A;exports.default=D;exports.usePopover=_;exports.usePopoverContext=V;
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 l } from "@kuma-ui/core";
3
- import { createContext as M, useRef as k, useState as d, useCallback as j, useMemo as g, useEffect as h, useContext as S } from "react";
4
- import { f as q } from "../focus-trap-react-DYXrtbDH.mjs";
5
- import A, { defaultAtomElementType as D } from "./atom.mjs";
6
- const O = M({
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: G
10
- } = O;
11
- function X() {
12
- return S(O);
9
+ Provider: X
10
+ } = S;
11
+ function ne() {
12
+ return Q(S);
13
13
  }
14
- function Y({
15
- as: c,
14
+ function se({
15
+ as: i,
16
16
  className: t,
17
17
  ...s
18
18
  }) {
19
- return /* @__PURE__ */ n.jsx(A, { as: c ?? D, ...s, className: l("kakadu-components-2845019685", t) });
19
+ return /* @__PURE__ */ n.jsx(B, { as: i ?? H, ...s, className: f("kakadu-components-2845019685", t) });
20
20
  }
21
- function Z({
22
- as: c,
21
+ function oe({
22
+ as: i,
23
23
  isVisible: t,
24
24
  label: s,
25
- shouldCloseOnOutsideClick: f = !0,
25
+ shouldCloseOnOutsideClick: d = !0,
26
26
  shouldCloseOnEscapePress: o = !0,
27
- children: i,
28
- className: v,
27
+ children: a,
28
+ className: w,
29
29
  innerClassName: x,
30
- onClose: a,
30
+ onClose: r,
31
31
  ...m
32
32
  }) {
33
- const r = k(null), p = k(null), [E, y] = d(!1), [u, w] = d(!1), N = j((e) => {
34
- r.current = e, w(!1);
35
- }, []), I = k(null), P = j((e) => {
36
- e && (I.current = e);
37
- }, []), z = g(() => ({
38
- initialFocus: () => I.current ?? void 0,
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 = I.current) == null ? void 0 : e.focus();
41
+ return (e = b.current) == null ? void 0 : e.focus();
42
42
  },
43
- clickOutsideDeactivates: f,
43
+ clickOutsideDeactivates: d,
44
44
  escapeDeactivates: o,
45
45
  onDeactivate() {
46
- w(!1);
46
+ g(!1);
47
47
  }
48
- }), [f, o]), [F, L] = d(t ?? !1), C = g(() => ({
49
- isVisible: F,
50
- setInitialFocus: P,
51
- close: N
52
- }), [F, P, N]), [R, W] = d(!1), [T, B] = d(!1);
53
- return h(() => {
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 b = () => {
57
- const V = e.getBoundingClientRect();
58
- W(V.left < 0), B(V.right > window.innerWidth);
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 b(), window.addEventListener("resize", b), () => {
61
- window.removeEventListener("resize", b);
70
+ return E(), window.addEventListener("resize", E), () => {
71
+ window.removeEventListener("resize", E);
62
72
  };
63
73
  }
64
- }, []), h(() => {
65
- t && (y(!0), L(!0));
66
- }, [t]), h(() => {
74
+ }, []), R(() => {
75
+ t && (q(!0), V(!0));
76
+ }, [t]), R(() => {
67
77
  if (t) {
68
78
  const e = setTimeout(() => {
69
- w(!0);
79
+ g(!0);
70
80
  }, 100);
71
81
  return () => {
72
82
  clearTimeout(e);
73
83
  };
74
84
  }
75
- w(!1);
76
- }, [t]), h(() => {
77
- if (E && !u) {
85
+ g(!1);
86
+ }, [t]), R(() => {
87
+ if (F && !u) {
78
88
  const e = setTimeout(() => {
79
- a == null || a(r.current ?? void 0), L(!1);
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
- }, [E, u, a]), /* @__PURE__ */ n.jsx(A, { reference: p, as: c ?? D, role: "dialog", "aria-hidden": !u, "aria-label": s ?? "Popover", ...m, className: l("kakadu-components-3920007758", R && "kakadu-components-611400930", T && "kakadu-components-944244368", u && "kakadu-components-1399012551", v), children: /* @__PURE__ */ n.jsxs("div", { className: l("kakadu-components-1118152266", u && "kakadu-components-231244945"), children: [
86
- /* @__PURE__ */ n.jsx("div", { className: l("kakadu-components-2899069338", R && "kakadu-components-1495725644", T && "kakadu-components-4235689197") }),
87
- /* @__PURE__ */ n.jsx(q.FocusTrap, { active: u, focusTrapOptions: z, children: /* @__PURE__ */ n.jsxs("div", { className: l("kakadu-components-3905822111", x), children: [
88
- /* @__PURE__ */ n.jsx(G, { value: C, children: i }),
89
- /* @__PURE__ */ n.jsx("div", { className: l("kakadu-components-3328048824", R && "kakadu-components-3754561431", T && "kakadu-components-2265262600") })
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 _(c, t) {
94
- const [s, f] = d(!1), o = k(void 0), i = k(null), v = j(async (m) => (f(!0), i.current = m ?? document.activeElement, new Promise((r) => {
95
- o.current = r;
96
- })), []), x = j((m) => {
97
- var r;
98
- if (f(!1), (r = o.current) == null || r.call(o, m), o.current = void 0, i.current) {
99
- const p = i.current;
100
- p.isConnected && p.focus(), i.current = null;
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
- }, []), a = g(() => /* @__PURE__ */ n.jsx(c, { ...t, isVisible: s, onClose: x }), [c, t, s, x]);
103
- return g(() => ({
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: v,
106
- popover: a
107
- }), [s, v, a]);
115
+ show: w,
116
+ popover: r
117
+ }), [s, w, r]);
108
118
  }
109
119
  export {
110
- Y as PopoverContainer,
111
- Z as default,
112
- _ as usePopover,
113
- X as usePopoverContext
120
+ se as PopoverContainer,
121
+ oe as default,
122
+ re as usePopover,
123
+ ne as usePopoverContext
114
124
  };