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