@kakadu/components 4.0.0 → 4.0.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,193 +1,170 @@
1
1
  import { j as e } from "../jsx-runtime-B4hRZ52C.mjs";
2
- import { useRef as M, useId as ee, useState as T, useLayoutEffect as fe, useMemo as A, useEffect as ne, useCallback as N } from "react";
3
- import { cx as c } from "@kuma-ui/core";
4
- import he from "../icons/chevron-up.mjs";
5
- import Y from "../utilities/copy-to-clipboard.mjs";
6
- import { buttonResetStyles as xe, overflowProtectionStyles as ae } from "../theme.mjs";
2
+ import { useRef as L, useId as ke, useState as P, useLayoutEffect as fe, useMemo as T, useEffect as he, useCallback as x } from "react";
3
+ import { cx as o } from "@kuma-ui/core";
4
+ import Z from "../utilities/copy-to-clipboard.mjs";
5
+ import { buttonResetStyles as xe, overflowProtectionStyles as ne } from "../theme.mjs";
7
6
  import je from "../icons/sparkle.mjs";
8
7
  import be from "./button-tooltip.mjs";
9
- import F from "./text-button.mjs";
10
- import { Span as U, Paragraph as W } from "./text.mjs";
11
- import ve from "./collapsible.mjs";
12
- import Z from "./click-ripples.mjs";
13
- import _ from "./hover-gradient.mjs";
14
- import { useCreateNotification as ye } from "./notification.mjs";
15
- const ge = "kakadu-components-922159086", Ne = "kakadu-components-25448712", $ = "kakadu-components-1923392328", z = "kakadu-components-4056037255", Se = c(z, "kakadu-components-3245407458"), Ie = c(z, "kakadu-components-1117160492"), Be = c(z, "kakadu-components-2261792866");
16
- function Ee({
17
- as: h,
18
- className: r,
19
- ...m
8
+ import H from "./text-button.mjs";
9
+ import { Span as A, Paragraph as R } from "./text.mjs";
10
+ import ye from "./collapsible.mjs";
11
+ import _ from "./click-ripples.mjs";
12
+ import ee from "./hover-gradient.mjs";
13
+ import { useCreateNotification as ge } from "./notification.mjs";
14
+ const Ne = "kakadu-components-922159086", ve = "kakadu-components-25448712", M = "kakadu-components-1923392328", F = "kakadu-components-4056037255", Ce = o(F, "kakadu-components-3245407458"), Se = o(F, "kakadu-components-1117160492"), Ee = o(F, "kakadu-components-2261792866");
15
+ function Ie({
16
+ as: m,
17
+ className: l,
18
+ ...p
20
19
  }) {
21
- return /* @__PURE__ */ e.jsx(U, { as: h ?? "span", ...m, className: c("kakadu-components-520991867", r) });
20
+ return /* @__PURE__ */ e.jsx(A, { as: m ?? "span", ...p, className: o("kakadu-components-520991867", l) });
22
21
  }
23
- function te({
24
- label: h,
25
- error: r,
26
- errorId: m,
27
- warning: i,
28
- warningId: b,
29
- information: x,
30
- informationId: n,
31
- footnote: o,
32
- attachments: j,
22
+ function Be({
23
+ label: m,
24
+ error: l,
25
+ errorId: p,
26
+ warning: c,
27
+ warningId: j,
28
+ information: r,
29
+ informationId: v,
30
+ footnote: a,
31
+ attachments: C,
33
32
  className: u,
34
- children: g,
35
- ...p
33
+ children: k,
34
+ ...f
36
35
  }) {
37
- const k = !!r, l = !!i, f = !!x, v = !!o;
38
- return /* @__PURE__ */ e.jsx("label", { ...p, className: c(ge, u), children: /* @__PURE__ */ e.jsxs("div", { className: "kakadu-components-3146929190", children: [
39
- /* @__PURE__ */ e.jsx(U, { className: c(ae, Ne), children: /* @__PURE__ */ e.jsx("span", { children: h }) }),
36
+ const b = !!l, i = !!c, d = !!r, h = !!a;
37
+ return /* @__PURE__ */ e.jsx("label", { ...f, className: o(Ne, u), children: /* @__PURE__ */ e.jsxs("div", { className: "kakadu-components-3146929190", children: [
38
+ /* @__PURE__ */ e.jsx(A, { className: o(ne, ve), children: /* @__PURE__ */ e.jsx("span", { children: m }) }),
40
39
  /* @__PURE__ */ e.jsxs("span", { className: "kakadu-components-3298764637", children: [
41
- g,
42
- v ? /* @__PURE__ */ e.jsx(Ee, { className: "kakadu-components-613632806", children: o }) : null,
43
- j
40
+ k,
41
+ h ? /* @__PURE__ */ e.jsx(Ie, { className: "kakadu-components-613632806", children: a }) : null,
42
+ C
44
43
  ] }),
45
- k || l || f ? /* @__PURE__ */ e.jsx("div", { className: "kakadu-components-2927674627", children: k ? /* @__PURE__ */ e.jsx(W, { id: m, className: Se, children: r instanceof Error ? r.message : r }) : l ? /* @__PURE__ */ e.jsx(W, { id: b, className: Ie, children: i instanceof Error ? i.message : i }) : f ? /* @__PURE__ */ e.jsx(W, { id: n, className: Be, children: x instanceof Error ? x.message : x }) : null }) : null
44
+ b || i || d ? /* @__PURE__ */ e.jsx("div", { className: "kakadu-components-2927674627", children: b ? /* @__PURE__ */ e.jsx(R, { id: p, className: Ce, children: l instanceof Error ? l.message : l }) : i ? /* @__PURE__ */ e.jsx(R, { id: j, className: Se, children: c instanceof Error ? c.message : c }) : d ? /* @__PURE__ */ e.jsx(R, { id: v, className: Ee, children: r instanceof Error ? r.message : r }) : null }) : null
46
45
  ] }) });
47
46
  }
48
- function ze({
49
- label: h,
50
- options: r,
51
- error: m,
52
- warning: i,
53
- information: b,
54
- footnote: x,
55
- className: n,
56
- onChange: o,
57
- ...j
58
- }) {
59
- const u = ee(), g = `${u}-error`, p = `${u}-warning`, k = `${u}-information`, l = !!m, f = !l && !!i, v = !l && !f && !!b, S = l ? g : f ? p : v ? k : void 0, {
60
- value: y
61
- } = j, [I, B] = T(""), E = y ?? I;
62
- ne(() => {
63
- B(typeof y == "string" ? y : "");
64
- }, [y]);
65
- const C = N((a) => {
66
- const {
67
- value: w
68
- } = a.target;
69
- B(w), o == null || o(w, a);
70
- }, [o]);
71
- return /* @__PURE__ */ e.jsxs(te, { label: h, error: m, errorId: g, warning: i, warningId: p, information: b, informationId: k, footnote: x, children: [
72
- /* @__PURE__ */ e.jsx("select", { ...j, value: E, "aria-invalid": l, "data-warning": f, "data-information": v, "aria-describedby": S, className: c($, "kakadu-components-4228384787", n), onChange: C, children: r.map((a) => /* @__PURE__ */ e.jsx("option", { value: a.value, disabled: a.disabled, children: a.label }, a.value)) }),
73
- /* @__PURE__ */ e.jsx(he, { width: 14, height: 14, className: "kakadu-components-158931186" })
74
- ] });
75
- }
76
- const Ce = 40, O = "kakadu-components-4233741488";
47
+ const we = 40, $ = "kakadu-components-4233741488";
77
48
  function De({
78
- type: h,
79
- label: r,
80
- error: m,
81
- warning: i,
82
- information: b,
83
- footnote: x,
84
- suggestion: n,
85
- actions: o = [],
86
- hasCopyButton: j,
87
- hasClearButton: u,
88
- isMultiline: g,
89
- onChange: p,
90
- className: k,
91
- ...l
49
+ ref: m,
50
+ type: l,
51
+ label: p,
52
+ error: c,
53
+ warning: j,
54
+ information: r,
55
+ footnote: v,
56
+ suggestion: a,
57
+ attachments: C,
58
+ actions: u = [],
59
+ hasCopyButton: k,
60
+ hasClearButton: f,
61
+ isMultiline: b,
62
+ onChange: i,
63
+ className: d,
64
+ ...h
92
65
  }) {
93
- const f = M(null), v = M(null), S = M(null), y = ye(), I = ee(), B = `${I}-error`, E = `${I}-warning`, C = `${I}-information`, {
94
- value: a,
95
- disabled: w
96
- } = l, [se, D] = T(""), d = a ?? se, [oe, le] = T(), ce = h === "textarea" || !!g;
66
+ const V = L(null), O = L(null), S = L(null), W = ge(), E = ke(), z = `${E}-error`, D = `${E}-warning`, G = `${E}-information`, {
67
+ value: y,
68
+ disabled: te
69
+ } = h, [ae, U] = P(""), s = y ?? ae, [se, oe] = P(), le = l === "textarea" || !!b;
97
70
  fe(() => {
98
- typeof d == "string" && S.current && le(S.current.scrollHeight);
99
- }, [d]);
100
- const H = A(() => typeof d == "string" ? `${d} `.split(`
101
- `) : [], [d]), re = A(() => H.length, [H]), L = !!m, R = !L && !!i, V = !!b, G = L ? B : R ? E : V ? C : void 0;
102
- ne(() => {
103
- D(typeof a == "string" ? a : "");
104
- }, [a]);
105
- const q = N((t) => {
71
+ typeof s == "string" && S.current && oe(S.current.scrollHeight);
72
+ }, [s]);
73
+ const I = T(() => typeof s == "string" ? `${s} `.split(`
74
+ `) : [], [s]), ce = T(() => I.length, [I]), g = !!c, B = !g && !!j, w = !!r, q = g ? z : B ? D : w ? G : void 0;
75
+ he(() => {
76
+ U(typeof y == "string" ? y : "");
77
+ }, [y]);
78
+ const J = x((n) => {
106
79
  const {
107
- value: s
108
- } = t.target;
109
- D(s), p == null || p(s, t);
110
- }, [p]), ie = N(() => {
111
- typeof d == "string" && (Y(d), y({
80
+ value: t
81
+ } = n.target;
82
+ U(t), i == null || i(t, n);
83
+ }, [i]), re = x(() => {
84
+ typeof s == "string" && (Z(s), W({
112
85
  type: "success",
113
86
  children: "Copied to clipboard."
114
87
  }));
115
- }, [d, y]), P = N((t) => {
116
- var Q;
117
- const s = v.current ?? f.current ?? void 0;
118
- if (s) {
119
- const X = (Q = Object.getOwnPropertyDescriptor(s instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype, "value")) == null ? void 0 : Q.set;
120
- if (X) {
121
- X.call(s, t);
122
- const ke = new Event("input", {
88
+ }, [s, W]), N = x((n) => {
89
+ var X;
90
+ const t = O.current ?? V.current ?? void 0;
91
+ if (t) {
92
+ const Y = (X = Object.getOwnPropertyDescriptor(t instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype, "value")) == null ? void 0 : X.set;
93
+ if (Y) {
94
+ Y.call(t, n);
95
+ const ue = new Event("input", {
123
96
  bubbles: !0
124
97
  });
125
- s.dispatchEvent(ke), s.focus();
98
+ t.dispatchEvent(ue), t.focus();
126
99
  return;
127
100
  }
128
101
  }
129
102
  throw new Error("Unable to set value.");
130
- }, []), de = N(() => {
131
- P("");
132
- }, [P]), [me, ue] = T(""), J = !!n && me !== n, pe = N(() => {
133
- if (n) {
103
+ }, []), ie = x(() => {
104
+ N("");
105
+ }, [N]), [de, me] = P(""), K = !!a && de !== a, pe = x(() => {
106
+ if (a) {
134
107
  try {
135
- P(n);
108
+ N(a);
136
109
  } catch {
137
- Y(n);
110
+ Z(a);
138
111
  }
139
- ue(n);
112
+ me(a);
140
113
  }
141
- }, [n, P]), K = A(() => o.length, [o]);
142
- return /* @__PURE__ */ e.jsxs(te, { label: r, error: m, errorId: B, warning: i, warningId: E, information: b, informationId: C, footnote: x, attachments: /* @__PURE__ */ e.jsx(ve, { isCollapsed: !J, children: J ? /* @__PURE__ */ e.jsxs("button", { type: "button", className: c(xe, ae, "kakadu-components-2355856341"), onClick: pe, children: [
143
- /* @__PURE__ */ e.jsx(be, { label: "Apply suggestion" }),
144
- /* @__PURE__ */ e.jsx(je, { width: 13, height: 13, className: "kakadu-components-1021263934" }),
145
- /* @__PURE__ */ e.jsx(U, { className: "kakadu-components-1585874956", children: n }),
146
- /* @__PURE__ */ e.jsx(Z, { className: "kakadu-components-3448565402" }),
147
- /* @__PURE__ */ e.jsx(_, {})
148
- ] }) : null }), style: {
149
- "--button-padding": `calc(${Ce * ((j ? 1 : 0) + (u ? 1 : 0) + K)}px + 6px)`
114
+ }, [a, N]), Q = T(() => u.length, [u]);
115
+ return /* @__PURE__ */ e.jsxs(Be, { ref: m, label: p, error: c, errorId: z, warning: j, warningId: D, information: r, informationId: G, footnote: v, attachments: /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
116
+ /* @__PURE__ */ e.jsx(ye, { isCollapsed: !K, children: K ? /* @__PURE__ */ e.jsxs("button", { type: "button", className: o(xe, ne, "kakadu-components-4141839293"), onClick: pe, children: [
117
+ /* @__PURE__ */ e.jsx(be, { label: "Apply suggestion" }),
118
+ /* @__PURE__ */ e.jsx(je, { width: 13, height: 13, className: "kakadu-components-1417828741" }),
119
+ /* @__PURE__ */ e.jsx(A, { className: "kakadu-components-1384720019", children: a }),
120
+ /* @__PURE__ */ e.jsx(_, { className: "kakadu-components-2744733744" }),
121
+ /* @__PURE__ */ e.jsx(ee, {})
122
+ ] }) : null }),
123
+ C
124
+ ] }), style: {
125
+ "--button-padding": `calc(${we * ((k ? 1 : 0) + (f ? 1 : 0) + Q)}px + 6px)`
150
126
  }, children: [
151
127
  /* @__PURE__ */ e.jsxs("div", { className: "kakadu-components-3146929190", children: [
152
- ce ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
153
- /* @__PURE__ */ e.jsxs("span", { ref: S, "aria-hidden": !0, className: c($, k, "kakadu-components-2033521835"), children: [
154
- H.map((t, s) => (
128
+ le ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
129
+ /* @__PURE__ */ e.jsxs("span", { ref: S, "aria-hidden": !0, className: o(M, d, "kakadu-components-2033521835"), children: [
130
+ I.map((n, t) => (
155
131
  // eslint-disable-next-line react/no-array-index-key
156
132
  /* @__PURE__ */ e.jsxs("span", { children: [
157
- t,
158
- re > 1 ? /* @__PURE__ */ e.jsx("br", {}) : null
159
- ] }, s)
133
+ n,
134
+ ce > 1 ? /* @__PURE__ */ e.jsx("br", {}) : null
135
+ ] }, t)
160
136
  )),
161
137
  " "
162
138
  ] }),
163
- /* @__PURE__ */ e.jsx("textarea", { ...l, ref: v, rows: 1, "aria-invalid": L, "data-warning": R, "data-information": V, "aria-describedby": G, value: d, className: c($, k, "kakadu-components-2119524139"), style: {
164
- minHeight: oe
165
- }, onChange: q })
166
- ] }) : /* @__PURE__ */ e.jsx("input", { ...l, ref: f, type: h ?? "text", value: d, "aria-invalid": L, "data-warning": R, "data-information": V, "aria-describedby": G, className: c($, k), onChange: q }),
167
- w ? null : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
168
- /* @__PURE__ */ e.jsx(Z, { className: "kakadu-components-616311160" }),
169
- /* @__PURE__ */ e.jsx(_, { className: "kakadu-components-1962999040" })
139
+ /* @__PURE__ */ e.jsx("textarea", { ...h, ref: O, rows: 1, "aria-invalid": g, "data-warning": B, "data-information": w, "aria-describedby": q, value: s, className: o(M, d, "kakadu-components-2119524139"), style: {
140
+ minHeight: se
141
+ }, onChange: J })
142
+ ] }) : /* @__PURE__ */ e.jsx("input", { ...h, ref: V, type: l ?? "text", value: s, "aria-invalid": g, "data-warning": B, "data-information": w, "aria-describedby": q, className: o(M, d), onChange: J }),
143
+ te ? null : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
144
+ /* @__PURE__ */ e.jsx(_, { className: "kakadu-components-616311160" }),
145
+ /* @__PURE__ */ e.jsx(ee, { className: "kakadu-components-1962999040" })
170
146
  ] })
171
147
  ] }),
172
- j || u || K > 0 ? /* @__PURE__ */ e.jsxs("div", { className: "kakadu-components-131986363", children: [
173
- o.map((t, s) => /* @__PURE__ */ e.jsx(
174
- F,
148
+ k || f || Q > 0 ? /* @__PURE__ */ e.jsxs("div", { className: "kakadu-components-131986363", children: [
149
+ u.map((n, t) => /* @__PURE__ */ e.jsx(
150
+ H,
175
151
  {
176
- iconLeft: t.icon,
177
- label: t.label,
178
- tooltip: t.label,
179
- className: O,
180
- onClick: t.onClick
152
+ iconLeft: n.icon,
153
+ label: n.label,
154
+ tooltip: n.label,
155
+ className: $,
156
+ onClick: n.onClick
181
157
  },
182
- t.label + s
158
+ n.label + t
183
159
  )),
184
- j ? /* @__PURE__ */ e.jsx(F, { iconLeft: "copy", label: "Copy", tooltip: "Copy", className: O, onClick: ie }) : null,
185
- u ? /* @__PURE__ */ e.jsx(F, { iconLeft: "times", label: "Clear", tooltip: "Clear", className: O, onClick: de }) : null
160
+ k ? /* @__PURE__ */ e.jsx(H, { iconLeft: "copy", label: "Copy", tooltip: "Copy", className: $, onClick: re }) : null,
161
+ f ? /* @__PURE__ */ e.jsx(H, { iconLeft: "times", label: "Clear", tooltip: "Clear", className: $, onClick: ie }) : null
186
162
  ] }) : null
187
163
  ] });
188
164
  }
189
165
  export {
190
- ze as Select,
166
+ Be as InputLabel,
191
167
  De as default,
192
- Se as errorParagraph
168
+ Ce as errorParagraph,
169
+ M as inputStyles
193
170
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("../jsx-runtime-BB_1_6y_.js"),e=require("react"),k=require("@kuma-ui/core"),P=require("react-dom"),$=require("../focus-trap-react-CcpTuiJi.js"),B=require("./text-button.js"),T=require("./decorators.js"),I=require("./flex.js"),D=require("./atom.js"),C=require("./text.js"),y=e.createContext({isVisible:!1,isInteractive:!1}),{Provider:z}=y;function _(){return e.useContext(y)}function G(){const{isInteractive:n,close:o}=_(),r=e.useCallback(()=>{o==null||o()},[o]);return s.jsxRuntimeExports.jsx("div",{className:"kakadu-components-2566044647",children:s.jsxRuntimeExports.jsx(B.default,{iconLeft:"times",label:"Close",disabled:!n,onClick:r})})}function J(n){return s.jsxRuntimeExports.jsx(I.default,{gap:2,...n})}function K({as:n,className:o,...r}){return s.jsxRuntimeExports.jsx(C.Heading,{...r,as:n??C.defaultHeadingElementType,className:k.cx("kakadu-components-4275938488",o)})}function Q({as:n,...o}){return s.jsxRuntimeExports.jsx(I.default,{direction:"row",gap:1,preset:"end",...o,as:n??D.defaultAtomElementType})}function U({root:n,outerDecorators:o=[],innerDecorators:r=[],label:f,maxWidth:c,className:m,isVisible:a,isFullWidth:l=!1,shouldCloseOnOutsideClick:i=!0,shouldCloseOnEscapePress:d=!0,showCloseButton:L=!0,onClose:p,children:N}){const v=e.useRef(null),R=e.useRef(null),[M,S]=e.useState(!1),[u,x]=e.useState(!1),b=e.useCallback(t=>{v.current=t,x(!1)},[]),E=e.useRef(null),g=e.useCallback(t=>{t&&(E.current=t)},[]),[h,q]=e.useState(a??!1),A=e.useMemo(()=>({isVisible:h,isInteractive:u,setInitialFocus:g,close:b}),[h,u,g,b]);e.useEffect(()=>{a&&(S(!0),q(!0))},[a]),e.useEffect(()=>{if(a){const t=setTimeout(()=>{x(!0)},100);return()=>{clearTimeout(t)}}x(!1)},[a]),e.useEffect(()=>{if(M&&!u){const t=setTimeout(()=>{p==null||p(v.current??void 0),q(!1)},370);return()=>{clearTimeout(t)}}},[M,u,p]),e.useEffect(()=>{const t=R.current;if(a&&i&&t){const j=H=>{t===H.target&&x(!1)};return t.addEventListener("click",j),()=>{t.removeEventListener("click",j)}}},[a,i]),e.useEffect(()=>{if(!a||!d)return;const t=j=>{j.key==="Escape"&&x(!1)};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[a,d]);const F=e.useMemo(()=>({initialFocus:()=>E.current??void 0,onActivate:()=>{var t;return(t=E.current)==null?void 0:t.focus()}}),[]),w=s.jsxRuntimeExports.jsx(T.default,{decorators:o,children:s.jsxRuntimeExports.jsx("div",{"aria-hidden":!u,style:{"--max-width":c?`${c}px`:void 0},className:k.cx("kakadu-components-4119461136",u&&"kakadu-components-2522346797",m),children:s.jsxRuntimeExports.jsx(T.default,{decorators:r,children:s.jsxRuntimeExports.jsx($.focusTrapReactExports.FocusTrap,{active:u,focusTrapOptions:F,children:s.jsxRuntimeExports.jsx("div",{ref:R,className:"kakadu-components-4011815997",children:s.jsxRuntimeExports.jsx("div",{role:"dialog","aria-modal":"true","aria-label":f??"Modal",className:k.cx("kakadu-components-3324483532",l&&"kakadu-components-3799971070",u&&"kakadu-components-968755580"),children:s.jsxRuntimeExports.jsxs(z,{value:A,children:[L?s.jsxRuntimeExports.jsx(G,{}):null,s.jsxRuntimeExports.jsx("div",{className:k.cx("kakadu-components-633990035",l&&"kakadu-components-171969824"),children:N})]})})})})})})});return n?P.createPortal(w,n):w}function V(n,o){const[r,f]=e.useState(!1),c=e.useRef(void 0),m=e.useCallback(async()=>(f(!0),new Promise(i=>{c.current=i})),[]),a=e.useCallback(i=>{var d;f(!1),(d=c.current)==null||d.call(c,i),c.current=void 0},[]),l=e.useMemo(()=>s.jsxRuntimeExports.jsx(n,{...o,isVisible:r,onClose:a}),[n,o,r,a]);return e.useMemo(()=>({isVisible:r,show:m,modal:l}),[r,m,l])}exports.ModalActions=Q;exports.ModalContent=J;exports.ModalHeading=K;exports.default=U;exports.useModal=V;exports.useModalContext=_;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("../jsx-runtime-BB_1_6y_.js"),e=require("react"),k=require("@kuma-ui/core"),P=require("react-dom"),$=require("../focus-trap-react-CkKg4ubd.js"),B=require("./text-button.js"),T=require("./decorators.js"),I=require("./flex.js"),D=require("./atom.js"),C=require("./text.js"),y=e.createContext({isVisible:!1,isInteractive:!1}),{Provider:z}=y;function _(){return e.useContext(y)}function G(){const{isInteractive:n,close:o}=_(),r=e.useCallback(()=>{o==null||o()},[o]);return s.jsxRuntimeExports.jsx("div",{className:"kakadu-components-2566044647",children:s.jsxRuntimeExports.jsx(B.default,{iconLeft:"times",label:"Close",disabled:!n,onClick:r})})}function J(n){return s.jsxRuntimeExports.jsx(I.default,{gap:2,...n})}function K({as:n,className:o,...r}){return s.jsxRuntimeExports.jsx(C.Heading,{...r,as:n??C.defaultHeadingElementType,className:k.cx("kakadu-components-4275938488",o)})}function Q({as:n,...o}){return s.jsxRuntimeExports.jsx(I.default,{direction:"row",gap:1,preset:"end",...o,as:n??D.defaultAtomElementType})}function U({root:n,outerDecorators:o=[],innerDecorators:r=[],label:f,maxWidth:c,className:m,isVisible:a,isFullWidth:l=!1,shouldCloseOnOutsideClick:i=!0,shouldCloseOnEscapePress:d=!0,showCloseButton:L=!0,onClose:p,children:N}){const v=e.useRef(null),R=e.useRef(null),[M,S]=e.useState(!1),[u,x]=e.useState(!1),b=e.useCallback(t=>{v.current=t,x(!1)},[]),E=e.useRef(null),g=e.useCallback(t=>{t&&(E.current=t)},[]),[h,q]=e.useState(a??!1),A=e.useMemo(()=>({isVisible:h,isInteractive:u,setInitialFocus:g,close:b}),[h,u,g,b]);e.useEffect(()=>{a&&(S(!0),q(!0))},[a]),e.useEffect(()=>{if(a){const t=setTimeout(()=>{x(!0)},100);return()=>{clearTimeout(t)}}x(!1)},[a]),e.useEffect(()=>{if(M&&!u){const t=setTimeout(()=>{p==null||p(v.current??void 0),q(!1)},370);return()=>{clearTimeout(t)}}},[M,u,p]),e.useEffect(()=>{const t=R.current;if(a&&i&&t){const j=H=>{t===H.target&&x(!1)};return t.addEventListener("click",j),()=>{t.removeEventListener("click",j)}}},[a,i]),e.useEffect(()=>{if(!a||!d)return;const t=j=>{j.key==="Escape"&&x(!1)};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[a,d]);const F=e.useMemo(()=>({initialFocus:()=>E.current??void 0,onActivate:()=>{var t;return(t=E.current)==null?void 0:t.focus()}}),[]),w=s.jsxRuntimeExports.jsx(T.default,{decorators:o,children:s.jsxRuntimeExports.jsx("div",{"aria-hidden":!u,style:{"--max-width":c?`${c}px`:void 0},className:k.cx("kakadu-components-4119461136",u&&"kakadu-components-2522346797",m),children:s.jsxRuntimeExports.jsx(T.default,{decorators:r,children:s.jsxRuntimeExports.jsx($.focusTrapReactExports.FocusTrap,{active:u,focusTrapOptions:F,children:s.jsxRuntimeExports.jsx("div",{ref:R,className:"kakadu-components-4011815997",children:s.jsxRuntimeExports.jsx("div",{role:"dialog","aria-modal":"true","aria-label":f??"Modal",className:k.cx("kakadu-components-3324483532",l&&"kakadu-components-3799971070",u&&"kakadu-components-968755580"),children:s.jsxRuntimeExports.jsxs(z,{value:A,children:[L?s.jsxRuntimeExports.jsx(G,{}):null,s.jsxRuntimeExports.jsx("div",{className:k.cx("kakadu-components-633990035",l&&"kakadu-components-171969824"),children:N})]})})})})})})});return n?P.createPortal(w,n):w}function V(n,o){const[r,f]=e.useState(!1),c=e.useRef(void 0),m=e.useCallback(async()=>(f(!0),new Promise(i=>{c.current=i})),[]),a=e.useCallback(i=>{var d;f(!1),(d=c.current)==null||d.call(c,i),c.current=void 0},[]),l=e.useMemo(()=>s.jsxRuntimeExports.jsx(n,{...o,isVisible:r,onClose:a}),[n,o,r,a]);return e.useMemo(()=>({isVisible:r,show:m,modal:l}),[r,m,l])}exports.ModalActions=Q;exports.ModalContent=J;exports.ModalHeading=K;exports.default=U;exports.useModal=V;exports.useModalContext=_;
@@ -2,7 +2,7 @@ import { j as t } from "../jsx-runtime-B4hRZ52C.mjs";
2
2
  import { createContext as q, useRef as j, useState as h, useCallback as f, useMemo as I, useEffect as m, useContext as z } from "react";
3
3
  import { cx as w } from "@kuma-ui/core";
4
4
  import { createPortal as G } from "react-dom";
5
- import { f as J } from "../focus-trap-react-DYXrtbDH.mjs";
5
+ import { f as J } from "../focus-trap-react-DATIi_Ob.mjs";
6
6
  import K from "./text-button.mjs";
7
7
  import F from "./decorators.mjs";
8
8
  import C from "./flex.mjs";
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../jsx-runtime-BB_1_6y_.js"),N=require("@kuma-ui/core"),i=require("react"),C=require("../theme.js"),w=require("../icons/icon.js"),v=require("./popover.js"),F=require("./atom.js"),q=require("./text.js"),M=require("./hover-gradient.js"),K=require("./click-ripples.js"),z=require("./separator.js"),A=require("./decorators.js"),P=require("./spinner.js"),D=require("./skeleton.js"),T=require("./aria-text.js"),R=new Set;function I(){const[t,s]=i.useState(!1),r=i.useCallback(u=>{s(u);for(const n of R)n(u)},[]);return i.useEffect(()=>{const u=n=>{s(n)};return R.add(u),()=>{R.delete(u)}},[]),i.useMemo(()=>({isKeyboardNavigating:t,setIsKeyboardNavigating:r}),[t,r])}const V="kakadu-components-949294122";function H({isLoading:t,label:s,iconLeft:r,iconRight:u,href:n,target:m,shouldCloseOnClick:E=!0,decorators:c=[],submenu:o,className:d,onClick:x,...l}){const{isVisible:j,isPreparingFocus:p,isFocused:a,close:k}=v.usePopoverContext(),{isKeyboardNavigating:f}=I(),h=i.useRef(!0),y=i.useCallback(()=>{h.current=a},[a]),b=i.useCallback(_=>{!f&&!h.current||a&&(x==null||x(_),o?o.show():E&&(k==null||k()))},[f,a,x,o,E,k]),g=i.useMemo(()=>e.jsxRuntimeExports.jsxs(F.default,{as:n&&!t?"a":"button",...l,type:n&&!t?void 0:"button",role:"menuitem",href:n,target:m,inert:!j&&!p||t,disabled:n?void 0:!j&&!p||t,className:N.cx(C.buttonResetStyles,"kakadu-components-1772835671",a&&"kakadu-components-3160069815",f?"kakadu-components-2254977234":a&&"kakadu-components-278139688",d),onClick:b,onPointerDownCapture:y,children:[e.jsxRuntimeExports.jsx(q.Span,{className:"kakadu-components-1109353535",children:t?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(T.default,{children:s}),r?e.jsxRuntimeExports.jsx(P.default,{size:12}):null,e.jsxRuntimeExports.jsx(D.SkeletonInstance,{height:"1em",width:"100%"}),u?e.jsxRuntimeExports.jsx(P.default,{size:12}):null]}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[r?e.jsxRuntimeExports.jsx(w.default,{width:12,height:12,type:r}):null,e.jsxRuntimeExports.jsx("span",{className:"kakadu-components-4055589237",children:s}),u?e.jsxRuntimeExports.jsx(w.default,{width:12,height:12,type:u}):null]})}),f||t?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(K.default,{isActive:a,size:100}),e.jsxRuntimeExports.jsx(M.default,{isActive:a,size:150,className:M.normalBlendStyles})]})]}),[n,m,t,l,j,p,f,d,b,y,r,s,u,a]);return e.jsxRuntimeExports.jsx(A.default,{decorators:c,children:o?e.jsxRuntimeExports.jsx(S,{menu:o.popoverMenu,className:"kakadu-components-1861176543",children:g}):g})}function $(t){if("type"in t){if(t.type==="separator")return e.jsxRuntimeExports.jsx(z.default,{});if(t.type==="group")return e.jsxRuntimeExports.jsx(q.Span,{className:"kakadu-components-1499037363",children:t.label})}return e.jsxRuntimeExports.jsx(H,{...t})}function B({items:t}){const{isFocused:s}=v.usePopoverContext(),[r,u]=i.useState([]),{setIsKeyboardNavigating:n}=I(),m=i.useCallback(c=>{c&&u(o=>o.includes(c)?o:[...o,c])},[]),E=i.useCallback(c=>{s&&(c.currentTarget.focus(),n(!1))},[s,n]);return i.useEffect(()=>{if(!s)return;const c=o=>{const d=r.filter(a=>a.isConnected),x=d.length;if(x===0)return;let l;const j=document.activeElement;let p=j?d.indexOf(j):-1;switch(p===-1&&(p=0),o.key){case"ArrowDown":{l=(p+1)%x;break}case"ArrowUp":{l=(p-1+x)%x;break}case"Home":{l=0;break}case"End":{l=x-1;break}case"Tab":{n(!0);return}}if(l!==void 0){o.preventDefault(),o.stopPropagation();const a=d[l];a&&(a.focus(),n(!0))}};return window.addEventListener("keydown",c,{capture:!0}),()=>{window.removeEventListener("keydown",c,{capture:!0})}},[s,r,n]),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:t.map((c,o)=>e.jsxRuntimeExports.jsx($,{...c,reference:m,onMouseEnter:E},o))})}function G({items:t,...s}){return e.jsxRuntimeExports.jsx(v.default,{...s,as:"nav",role:"menu",innerClassName:"kakadu-components-3600436535",children:e.jsxRuntimeExports.jsx(B,{items:t})})}function O(t){const s=i.useMemo(()=>({items:t}),[t]),{isVisible:r,show:u,close:n,popover:m}=v.usePopover(G,s);return i.useMemo(()=>({isVisible:r,show:u,close:n,popoverMenu:m}),[r,u,n,m])}function S({menu:t,className:s,children:r}){return e.jsxRuntimeExports.jsxs(v.PopoverContainer,{className:s,children:[r,t]})}exports.dangerPopoverMenuItemStyles=V;exports.default=S;exports.usePopoverMenu=O;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../jsx-runtime-BB_1_6y_.js"),N=require("@kuma-ui/core"),a=require("react"),S=require("../theme.js"),b=require("../icons/icon.js"),C=require("../use-synchronized-value-D0_rS5Wp.js"),f=require("./popover.js"),F=require("./atom.js"),P=require("./text.js"),w=require("./hover-gradient.js"),z=require("./click-ripples.js"),K=require("./separator.js"),V=require("./decorators.js"),M=require("./spinner.js"),A=require("./skeleton.js"),D=require("./aria-text.js");function q(){const{value:t,setValue:n}=C.useSynchronizedValue("isKeyboardNavigating");return a.useMemo(()=>({isKeyboardNavigating:t,setIsKeyboardNavigating:n}),[t,n])}const T="kakadu-components-949294122";function H({isLoading:t,label:n,iconLeft:u,iconRight:x,href:o,target:m,shouldCloseOnClick:E=!0,decorators:i=[],submenu:s,className:d,onClick:c,...p}){const{isVisible:j,isPreparingFocus:l,isFocused:r,close:k}=f.usePopoverContext(),{isKeyboardNavigating:v}=q(),R=a.useRef(!0),h=a.useCallback(()=>{R.current=r},[r]),y=a.useCallback(_=>{!v&&!R.current||r&&(c==null||c(_),s?s.show():E&&(k==null||k()))},[v,r,c,s,E,k]),g=a.useMemo(()=>e.jsxRuntimeExports.jsxs(F.default,{as:o&&!t?"a":"button",...p,type:o&&!t?void 0:"button",role:"menuitem",href:o,target:m,inert:!j&&!l||t,disabled:o?void 0:!j&&!l||t,className:N.cx(S.buttonResetStyles,"kakadu-components-1772835671",r&&"kakadu-components-3160069815",v?"kakadu-components-2254977234":r&&"kakadu-components-278139688",d),onClick:y,onPointerDownCapture:h,children:[e.jsxRuntimeExports.jsx(P.Span,{className:"kakadu-components-1109353535",children:t?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(D.default,{children:n}),u?e.jsxRuntimeExports.jsx(M.default,{size:12}):null,e.jsxRuntimeExports.jsx(A.SkeletonInstance,{height:"1em",width:"100%"}),x?e.jsxRuntimeExports.jsx(M.default,{size:12}):null]}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[u?e.jsxRuntimeExports.jsx(b.default,{width:12,height:12,type:u}):null,e.jsxRuntimeExports.jsx("span",{className:"kakadu-components-4055589237",children:n}),x?e.jsxRuntimeExports.jsx(b.default,{width:12,height:12,type:x}):null]})}),v||t?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(z.default,{isActive:r,size:100}),e.jsxRuntimeExports.jsx(w.default,{isActive:r,size:150,className:w.normalBlendStyles})]})]}),[o,t,p,m,j,l,r,v,d,y,h,u,n,x]);return e.jsxRuntimeExports.jsx(V.default,{decorators:i,children:s?e.jsxRuntimeExports.jsx(I,{menu:s.popoverMenu,className:"kakadu-components-1861176543",children:g}):g})}function $(t){if("type"in t){if(t.type==="separator")return e.jsxRuntimeExports.jsx(K.default,{});if(t.type==="group")return e.jsxRuntimeExports.jsx(P.Span,{className:"kakadu-components-1499037363",children:t.label})}return e.jsxRuntimeExports.jsx(H,{...t})}function B({items:t}){const{isFocused:n}=f.usePopoverContext(),[u,x]=a.useState([]),{setIsKeyboardNavigating:o}=q(),m=a.useCallback(i=>{i&&x(s=>s.includes(i)?s:[...s,i])},[]),E=a.useCallback(i=>{n&&(i.currentTarget.focus(),o(!1))},[n,o]);return a.useEffect(()=>{if(!n)return;const i=s=>{const d=u.filter(r=>r.isConnected),c=d.length;if(c===0)return;let p;const j=document.activeElement;let l=j?d.indexOf(j):-1;switch(l===-1&&(l=0),s.key){case"ArrowDown":{p=(l+1)%c;break}case"ArrowUp":{p=(l-1+c)%c;break}case"Home":{p=0;break}case"End":{p=c-1;break}case"Tab":{o(!0);return}}if(p!==void 0){s.preventDefault(),s.stopPropagation();const r=d[p];r&&(r.focus(),o(!0))}};return window.addEventListener("keydown",i,{capture:!0}),()=>{window.removeEventListener("keydown",i,{capture:!0})}},[n,u,o]),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:t.map((i,s)=>e.jsxRuntimeExports.jsx($,{...i,reference:m,onMouseEnter:E},s))})}function G({items:t,...n}){return e.jsxRuntimeExports.jsx(f.default,{...n,as:"nav",role:"menu",innerClassName:"kakadu-components-3600436535",children:e.jsxRuntimeExports.jsx(B,{items:t})})}function O(t){const n=a.useMemo(()=>({items:t}),[t]),{isVisible:u,show:x,close:o,popover:m}=f.usePopover(G,n);return a.useMemo(()=>({isVisible:u,show:x,close:o,popoverMenu:m}),[u,x,o,m])}function I({menu:t,className:n,children:u}){return e.jsxRuntimeExports.jsxs(f.PopoverContainer,{className:n,children:[u,t]})}exports.dangerPopoverMenuItemStyles=T;exports.default=I;exports.usePopoverMenu=O;