@kakadu/components 3.1.4 → 3.2.0

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