@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.
- package/build/components/combobox.d.ts +25 -0
- package/build/components/combobox.js +1 -0
- package/build/components/combobox.mjs +324 -0
- package/build/components/input.d.ts +11 -18
- package/build/components/input.js +2 -2
- package/build/components/input.mjs +124 -147
- package/build/components/modal.js +1 -1
- package/build/components/modal.mjs +1 -1
- package/build/components/popover-menu.js +1 -1
- package/build/components/popover-menu.mjs +98 -106
- package/build/components/popover.js +1 -1
- package/build/components/popover.mjs +1 -1
- package/build/components/select.d.ts +12 -0
- package/build/components/select.js +1 -0
- package/build/components/select.mjs +36 -0
- package/build/components/theme-setter.d.ts +1 -1
- package/build/components.css +1 -1
- package/build/{focus-trap-react-CcpTuiJi.js → focus-trap-react-CkKg4ubd.js} +5 -5
- package/build/{focus-trap-react-DYXrtbDH.mjs → focus-trap-react-DATIi_Ob.mjs} +34 -29
- package/build/hooks/use-synchronized-value.d.ts +4 -0
- package/build/icons/icon.d.ts +2 -1
- package/build/icons/icon.js +1 -1
- package/build/icons/icon.mjs +90 -89
- package/build/index.d.ts +4 -0
- package/build/index.js +1 -1
- package/build/index.mjs +233 -227
- package/build/use-synchronized-value-D0_rS5Wp.js +1 -0
- package/build/use-synchronized-value-XnIpeq1s.mjs +28 -0
- package/package.json +3 -1
|
@@ -1,193 +1,170 @@
|
|
|
1
1
|
import { j as e } from "../jsx-runtime-B4hRZ52C.mjs";
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { cx as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
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
|
|
10
|
-
import { Span as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import { useCreateNotification as
|
|
15
|
-
const
|
|
16
|
-
function
|
|
17
|
-
as:
|
|
18
|
-
className:
|
|
19
|
-
...
|
|
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(
|
|
20
|
+
return /* @__PURE__ */ e.jsx(A, { as: m ?? "span", ...p, className: o("kakadu-components-520991867", l) });
|
|
22
21
|
}
|
|
23
|
-
function
|
|
24
|
-
label:
|
|
25
|
-
error:
|
|
26
|
-
errorId:
|
|
27
|
-
warning:
|
|
28
|
-
warningId:
|
|
29
|
-
information:
|
|
30
|
-
informationId:
|
|
31
|
-
footnote:
|
|
32
|
-
attachments:
|
|
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:
|
|
35
|
-
...
|
|
33
|
+
children: k,
|
|
34
|
+
...f
|
|
36
35
|
}) {
|
|
37
|
-
const
|
|
38
|
-
return /* @__PURE__ */ e.jsx("label", { ...
|
|
39
|
-
/* @__PURE__ */ e.jsx(
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
k,
|
|
41
|
+
h ? /* @__PURE__ */ e.jsx(Ie, { className: "kakadu-components-613632806", children: a }) : null,
|
|
42
|
+
C
|
|
44
43
|
] }),
|
|
45
|
-
|
|
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
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
|
94
|
-
value:
|
|
95
|
-
disabled:
|
|
96
|
-
} =
|
|
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
|
|
99
|
-
}, [
|
|
100
|
-
const
|
|
101
|
-
`) : [], [
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}, [
|
|
105
|
-
const
|
|
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:
|
|
108
|
-
} =
|
|
109
|
-
|
|
110
|
-
}, [
|
|
111
|
-
typeof
|
|
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
|
-
}, [
|
|
116
|
-
var
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
119
|
-
const
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
const
|
|
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
|
-
|
|
98
|
+
t.dispatchEvent(ue), t.focus();
|
|
126
99
|
return;
|
|
127
100
|
}
|
|
128
101
|
}
|
|
129
102
|
throw new Error("Unable to set value.");
|
|
130
|
-
}, []),
|
|
131
|
-
|
|
132
|
-
}, [
|
|
133
|
-
if (
|
|
103
|
+
}, []), ie = x(() => {
|
|
104
|
+
N("");
|
|
105
|
+
}, [N]), [de, me] = P(""), K = !!a && de !== a, pe = x(() => {
|
|
106
|
+
if (a) {
|
|
134
107
|
try {
|
|
135
|
-
|
|
108
|
+
N(a);
|
|
136
109
|
} catch {
|
|
137
|
-
|
|
110
|
+
Z(a);
|
|
138
111
|
}
|
|
139
|
-
|
|
112
|
+
me(a);
|
|
140
113
|
}
|
|
141
|
-
}, [
|
|
142
|
-
return /* @__PURE__ */ e.jsxs(
|
|
143
|
-
/* @__PURE__ */ e.jsx(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
-
|
|
153
|
-
/* @__PURE__ */ e.jsxs("span", { ref: S, "aria-hidden": !0, className:
|
|
154
|
-
|
|
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
|
-
|
|
158
|
-
|
|
159
|
-
] },
|
|
133
|
+
n,
|
|
134
|
+
ce > 1 ? /* @__PURE__ */ e.jsx("br", {}) : null
|
|
135
|
+
] }, t)
|
|
160
136
|
)),
|
|
161
137
|
" "
|
|
162
138
|
] }),
|
|
163
|
-
/* @__PURE__ */ e.jsx("textarea", { ...
|
|
164
|
-
minHeight:
|
|
165
|
-
}, onChange:
|
|
166
|
-
] }) : /* @__PURE__ */ e.jsx("input", { ...
|
|
167
|
-
|
|
168
|
-
/* @__PURE__ */ e.jsx(
|
|
169
|
-
/* @__PURE__ */ e.jsx(
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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:
|
|
177
|
-
label:
|
|
178
|
-
tooltip:
|
|
179
|
-
className:
|
|
180
|
-
onClick:
|
|
152
|
+
iconLeft: n.icon,
|
|
153
|
+
label: n.label,
|
|
154
|
+
tooltip: n.label,
|
|
155
|
+
className: $,
|
|
156
|
+
onClick: n.onClick
|
|
181
157
|
},
|
|
182
|
-
|
|
158
|
+
n.label + t
|
|
183
159
|
)),
|
|
184
|
-
|
|
185
|
-
|
|
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
|
-
|
|
166
|
+
Be as InputLabel,
|
|
191
167
|
De as default,
|
|
192
|
-
|
|
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-
|
|
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-
|
|
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"),
|
|
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;
|