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