@kakadu/components 6.13.2 → 6.14.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/checkbox.d.ts +1 -1
- package/build/components/checkbox.js +1 -1
- package/build/components/checkbox.mjs +58 -57
- package/build/components/combobox.js +1 -1
- package/build/components/combobox.mjs +82 -82
- package/build/components/input.d.ts +4 -2
- package/build/components/input.js +2 -2
- package/build/components/input.mjs +45 -44
- package/build/components/select.d.ts +1 -1
- package/build/components/select.js +1 -1
- package/build/components/select.mjs +18 -17
- package/build/components.css +1 -1
- package/package.json +1 -1
|
@@ -16,4 +16,4 @@ export type CheckboxProperties<Type extends boolean = boolean> = Omit<InputLabel
|
|
|
16
16
|
readonly children: ReactNode;
|
|
17
17
|
readonly onChange?: (value: Type, event: ChangeEvent<HTMLInputElement>) => void;
|
|
18
18
|
};
|
|
19
|
-
export default function Checkbox<Type extends boolean = boolean>({ label, disabled, error, warning, information, footnote, className, children, onChange, ...properties }: CheckboxProperties<Type>): React.JSX.Element;
|
|
19
|
+
export default function Checkbox<Type extends boolean = boolean>({ label, disabled, error, warning, information, footnote, className, labelClassName, children, onChange, ...properties }: CheckboxProperties<Type>): React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../jsx-runtime-CZa898vN.js"),o=require("react"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../jsx-runtime-CZa898vN.js"),o=require("react"),m=require("@kuma-ui/core"),B=require("../icons/icon.js"),z=require("../theme.js"),w=require("./input.js"),V=require("./aria-text.js"),R=require("./flex.js"),b=require("./text.js"),T=require("./hover-gradient.js"),M=require("./click-ripples.js");function N({value:a,className:t}){return e.jsxRuntimeExports.jsx("div",{"aria-hidden":!0,className:m.cx("kakadu-components-483027860",a&&"kakadu-components-347512941",t),children:a?e.jsxRuntimeExports.jsx("div",{"data-theme":"dark",className:"kakadu-components-3323194660",children:e.jsxRuntimeExports.jsx(B.default,{type:"check",size:14,fill:"#fff",className:B.iconShadowStyles})}):null})}function C({label:a,disabled:t,className:d,children:c,onChange:s,...j}){const{value:r,...k}=j,[f,n]=o.useState(!1),i=r??f;o.useEffect(()=>{n(!!r)},[r]);const u=o.useCallback(l=>{const{checked:x}=l.target;n(x),s==null||s(x,l)},[s]);return e.jsxRuntimeExports.jsxs("label",{className:m.cx("kakadu-components-1233932825",t&&"kakadu-components-2246117376",d),children:[e.jsxRuntimeExports.jsx("input",{...k,type:"checkbox",checked:i,disabled:t,className:V.ariaTextStyles,onChange:u}),e.jsxRuntimeExports.jsxs(R.default,{direction:"row",gap:.75,children:[e.jsxRuntimeExports.jsx(N,{value:i}),e.jsxRuntimeExports.jsxs(R.default,{fill:!0,gap:.25,children:[e.jsxRuntimeExports.jsx(b.Span,{className:m.cx(z.overflowProtectionStyles,"kakadu-components-3627383913",i&&"kakadu-components-572005680"),children:a}),c?e.jsxRuntimeExports.jsx(b.Footnote,{children:c}):null]})]})]})}function G({label:a,disabled:t,error:d,warning:c,information:s,footnote:j,className:r,labelClassName:k,children:f,onChange:n,...i}){const u=o.useId(),l=`${u}-error`,x=`${u}-warning`,q=`${u}-information`,p=!!d,h=!p&&!!c,y=!p&&!h&&!!s,g=p?l:h?x:y?q:void 0,{value:E,...$}=i,[P,S]=o.useState(!1),v=E??P;o.useEffect(()=>{S(!!E)},[E]);const F=o.useCallback(I=>{const{checked:_}=I.target;S(_),n==null||n(_,I)},[n]);return e.jsxRuntimeExports.jsxs(w.InputLabel,{label:a,error:d,errorId:l,warning:c,warningId:x,information:s,informationId:q,footnote:j,className:m.cx("kakadu-components-1233932825",t&&"kakadu-components-2246117376",k),children:[e.jsxRuntimeExports.jsx("input",{...$,type:"checkbox",checked:v,disabled:t,"aria-invalid":p,"data-warning":h,"data-information":y,"aria-describedby":g,className:V.ariaTextStyles,onChange:F}),e.jsxRuntimeExports.jsxs("div",{className:m.cx(w.inputStyles,r),"aria-disabled":t?!0:void 0,children:[e.jsxRuntimeExports.jsxs(R.default,{direction:"row",gap:.75,className:"kakadu-components-1066891822",children:[e.jsxRuntimeExports.jsx(N,{value:v,className:"kakadu-components-3803487082"}),e.jsxRuntimeExports.jsx(b.Footnote,{className:"kakadu-components-4115080333",children:f})]}),t?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(T.default,{size:150,className:T.normalBlendStyles}),e.jsxRuntimeExports.jsx(M.default,{})]})]})]})}exports.CheckboxIcon=N;exports.TextCheckbox=C;exports.default=G;
|
|
@@ -1,93 +1,94 @@
|
|
|
1
1
|
import { j as e } from "../jsx-runtime-z6PQ6F3d.mjs";
|
|
2
|
-
import { useId as
|
|
3
|
-
import { cx as
|
|
4
|
-
import
|
|
5
|
-
import { overflowProtectionStyles as
|
|
6
|
-
import { InputLabel as
|
|
7
|
-
import { ariaTextStyles as
|
|
2
|
+
import { useId as G, useState as w, useEffect as V, useCallback as g } from "react";
|
|
3
|
+
import { cx as d } from "@kuma-ui/core";
|
|
4
|
+
import H, { iconShadowStyles as L } from "../icons/icon.mjs";
|
|
5
|
+
import { overflowProtectionStyles as W } from "../theme.mjs";
|
|
6
|
+
import { InputLabel as q, inputStyles as A } from "./input.mjs";
|
|
7
|
+
import { ariaTextStyles as E } from "./aria-text.mjs";
|
|
8
8
|
import N from "./flex.mjs";
|
|
9
|
-
import { Footnote as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
function
|
|
9
|
+
import { Footnote as F, Span as D } from "./text.mjs";
|
|
10
|
+
import J, { normalBlendStyles as K } from "./hover-gradient.mjs";
|
|
11
|
+
import M from "./click-ripples.mjs";
|
|
12
|
+
function P({
|
|
13
13
|
value: t,
|
|
14
14
|
className: a
|
|
15
15
|
}) {
|
|
16
|
-
return /* @__PURE__ */ e.jsx("div", { "aria-hidden": !0, className:
|
|
16
|
+
return /* @__PURE__ */ e.jsx("div", { "aria-hidden": !0, className: d("kakadu-components-483027860", t && "kakadu-components-347512941", a), children: t ? /* @__PURE__ */ e.jsx("div", { "data-theme": "dark", className: "kakadu-components-3323194660", children: /* @__PURE__ */ e.jsx(H, { type: "check", size: 14, fill: "#fff", className: L }) }) : null });
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function oe({
|
|
19
19
|
label: t,
|
|
20
20
|
disabled: a,
|
|
21
|
-
className:
|
|
22
|
-
children:
|
|
21
|
+
className: u,
|
|
22
|
+
children: n,
|
|
23
23
|
onChange: s,
|
|
24
|
-
...
|
|
24
|
+
...k
|
|
25
25
|
}) {
|
|
26
26
|
const {
|
|
27
|
-
value:
|
|
28
|
-
...
|
|
29
|
-
} =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}, [
|
|
33
|
-
const
|
|
27
|
+
value: c,
|
|
28
|
+
...x
|
|
29
|
+
} = k, [f, o] = w(!1), r = c ?? f;
|
|
30
|
+
V(() => {
|
|
31
|
+
o(!!c);
|
|
32
|
+
}, [c]);
|
|
33
|
+
const l = g((i) => {
|
|
34
34
|
const {
|
|
35
|
-
checked:
|
|
36
|
-
} =
|
|
37
|
-
|
|
35
|
+
checked: m
|
|
36
|
+
} = i.target;
|
|
37
|
+
o(m), s == null || s(m, i);
|
|
38
38
|
}, [s]);
|
|
39
|
-
return /* @__PURE__ */ e.jsxs("label", { className:
|
|
40
|
-
/* @__PURE__ */ e.jsx("input", { ...
|
|
39
|
+
return /* @__PURE__ */ e.jsxs("label", { className: d("kakadu-components-1233932825", a && "kakadu-components-2246117376", u), children: [
|
|
40
|
+
/* @__PURE__ */ e.jsx("input", { ...x, type: "checkbox", checked: r, disabled: a, className: E, onChange: l }),
|
|
41
41
|
/* @__PURE__ */ e.jsxs(N, { direction: "row", gap: 0.75, children: [
|
|
42
|
-
/* @__PURE__ */ e.jsx(
|
|
42
|
+
/* @__PURE__ */ e.jsx(P, { value: r }),
|
|
43
43
|
/* @__PURE__ */ e.jsxs(N, { fill: !0, gap: 0.25, children: [
|
|
44
|
-
/* @__PURE__ */ e.jsx(
|
|
45
|
-
|
|
44
|
+
/* @__PURE__ */ e.jsx(D, { className: d(W, "kakadu-components-3627383913", r && "kakadu-components-572005680"), children: t }),
|
|
45
|
+
n ? /* @__PURE__ */ e.jsx(F, { children: n }) : null
|
|
46
46
|
] })
|
|
47
47
|
] })
|
|
48
48
|
] });
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function te({
|
|
51
51
|
label: t,
|
|
52
52
|
disabled: a,
|
|
53
|
-
error:
|
|
54
|
-
warning:
|
|
53
|
+
error: u,
|
|
54
|
+
warning: n,
|
|
55
55
|
information: s,
|
|
56
|
-
footnote:
|
|
57
|
-
className:
|
|
56
|
+
footnote: k,
|
|
57
|
+
className: c,
|
|
58
|
+
labelClassName: x,
|
|
58
59
|
children: f,
|
|
59
|
-
onChange:
|
|
60
|
-
...
|
|
60
|
+
onChange: o,
|
|
61
|
+
...r
|
|
61
62
|
}) {
|
|
62
|
-
const
|
|
63
|
+
const l = G(), i = `${l}-error`, m = `${l}-warning`, y = `${l}-information`, p = !!u, h = !p && !!n, I = !p && !h && !!s, $ = p ? i : h ? m : I ? y : void 0, {
|
|
63
64
|
value: j,
|
|
64
|
-
|
|
65
|
-
} =
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
...z
|
|
66
|
+
} = r, [R, v] = w(!1), b = j ?? R;
|
|
67
|
+
V(() => {
|
|
68
|
+
v(!!j);
|
|
68
69
|
}, [j]);
|
|
69
|
-
const
|
|
70
|
+
const T = g((S) => {
|
|
70
71
|
const {
|
|
71
|
-
checked:
|
|
72
|
-
} =
|
|
73
|
-
|
|
74
|
-
}, [
|
|
75
|
-
return /* @__PURE__ */ e.jsxs(
|
|
76
|
-
/* @__PURE__ */ e.jsx("input", {
|
|
77
|
-
/* @__PURE__ */ e.jsxs("div", { className:
|
|
72
|
+
checked: B
|
|
73
|
+
} = S.target;
|
|
74
|
+
v(B), o == null || o(B, S);
|
|
75
|
+
}, [o]);
|
|
76
|
+
return /* @__PURE__ */ e.jsxs(q, { label: t, error: u, errorId: i, warning: n, warningId: m, information: s, informationId: y, footnote: k, className: d("kakadu-components-1233932825", a && "kakadu-components-2246117376", x), children: [
|
|
77
|
+
/* @__PURE__ */ e.jsx("input", { ...z, type: "checkbox", checked: b, disabled: a, "aria-invalid": p, "data-warning": h, "data-information": I, "aria-describedby": $, className: E, onChange: T }),
|
|
78
|
+
/* @__PURE__ */ e.jsxs("div", { className: d(A, c), "aria-disabled": a ? !0 : void 0, children: [
|
|
78
79
|
/* @__PURE__ */ e.jsxs(N, { direction: "row", gap: 0.75, className: "kakadu-components-1066891822", children: [
|
|
79
|
-
/* @__PURE__ */ e.jsx(
|
|
80
|
-
/* @__PURE__ */ e.jsx(
|
|
80
|
+
/* @__PURE__ */ e.jsx(P, { value: b, className: "kakadu-components-3803487082" }),
|
|
81
|
+
/* @__PURE__ */ e.jsx(F, { className: "kakadu-components-4115080333", children: f })
|
|
81
82
|
] }),
|
|
82
83
|
a ? null : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
83
|
-
/* @__PURE__ */ e.jsx(
|
|
84
|
-
/* @__PURE__ */ e.jsx(
|
|
84
|
+
/* @__PURE__ */ e.jsx(J, { size: 150, className: K }),
|
|
85
|
+
/* @__PURE__ */ e.jsx(M, {})
|
|
85
86
|
] })
|
|
86
87
|
] })
|
|
87
88
|
] });
|
|
88
89
|
}
|
|
89
90
|
export {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
P as CheckboxIcon,
|
|
92
|
+
oe as TextCheckbox,
|
|
93
|
+
te as default
|
|
93
94
|
};
|
|
@@ -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 d=require("../jsx-runtime-CZa898vN.js"),e=require("react"),_=require("@kuma-ui/core"),se=require("../hooks/use-synchronized-value.js"),ne=require("../icons/icon.js"),re=require("../icons/chevron-up.js"),oe=require("../utilities/search.js"),Y=require("../utilities/listeners.js"),ae=require("./input.js"),T=require("./text.js"),X=require("./flex.js"),ce=require("./skeleton.js"),ue=Y.default(n=>{window.addEventListener("mousemove",n,{capture:!0})},n=>{window.removeEventListener("mousemove",n,{capture:!0})}),ie=Y.default(n=>{window.addEventListener("keydown",n,{capture:!0})},n=>{window.removeEventListener("keydown",n,{capture:!0})});function F(){const{value:n,setValue:f}=se.default("isKeyboardNavigating");return e.useMemo(()=>({isKeyboardNavigating:n,setIsKeyboardNavigating:f}),[n,f])}function q(n){return"text"in n?n.text:n.label}const B="kakadu-components-1144794361",D="kakadu-components-2911184744";function le({ref:n,isSelected:f,id:O,value:o,label:E,onSelect:w,onHover:I}){const{isKeyboardNavigating:m}=F(),R=e.useCallback(()=>{w(o)},[w,o]),u=e.useCallback(r=>{m||r.movementX===0&&r.movementY===0||I(o)},[m,I,o]),b=e.useRef(null);e.useEffect(()=>{const r=b.current;f&&r&&m&&setTimeout(()=>{r.scrollIntoView({behavior:"smooth",block:"nearest"})},0)},[f,m]);const a=e.useCallback(r=>{b.current=r,n&&(n.current=r)},[n]);return d.jsxRuntimeExports.jsx("li",{ref:a,id:O,role:"option","aria-selected":f,tabIndex:-1,className:_.cx(B,"kakadu-components-4130497639",m?"kakadu-components-962373561":"kakadu-components-1109598791"),onClick:R,onMouseMove:u,children:d.jsxRuntimeExports.jsx(T.Span,{className:_.cx(D,typeof E=="string"&&"kakadu-components-154286052"),children:E})})}function de({isLoading:n,id:f,activeOptionId:O,selectedValue:o,options:E,onSelect:w,onHover:I}){const m=e.useRef(null);e.useEffect(()=>{const a=m.current;a&&a.scrollIntoView({behavior:"smooth",block:"nearest"})},[]);const R=e.useRef(null),{isKeyboardNavigating:u}=F(),b=e.useRef(u);return b.current=u,e.useLayoutEffect(()=>{const a=m.current;if(a&&E.length>0){if(b.current){const r=R.current;if(r){r.scrollIntoView({block:"nearest"});return}}a.scrollTo({top:0})}},[E]),d.jsxRuntimeExports.jsxs("ul",{ref:m,id:f,role:"listbox","aria-label":"Options",tabIndex:-1,className:"kakadu-components-1713806412",children:[E.length===0?n?null:d.jsxRuntimeExports.jsxs(X.default,{"aria-atomic":!0,as:"li",role:"status","aria-live":"polite",direction:"row",preset:"start",gap:.5,className:B,children:[d.jsxRuntimeExports.jsx(ne.default,{size:15,type:"exclamationTriangle"}),d.jsxRuntimeExports.jsx(T.Span,{className:D,children:"No results."})]}):E.map((a,r)=>d.jsxRuntimeExports.jsx(le,{...a,ref:a.value===o?R:void 0,id:a.value===o?O:void 0,isSelected:a.value===o,onSelect:w,onHover:I},q(a)+r)),n?d.jsxRuntimeExports.jsx(X.default,{as:"li",alignment:"center",className:B,children:d.jsxRuntimeExports.jsx(T.Span,{className:_.cx(D,"kakadu-components-2015848015"),children:d.jsxRuntimeExports.jsx(ce.SkeletonInstance,{width:"100%",height:"1.3em"})})}):null]})}function fe({isLoading:n,shouldFilterOptions:f=!0,label:O,options:o,error:E,warning:w,information:I,footnote:m,className:R,onChange:u,onSelect:b,...a}){const r=e.useRef(null),H=e.useId(),P=e.useId(),[y,K]=e.useState(!1),$=e.useCallback(()=>{K(!0)},[]),G=e.useCallback(t=>{var s;(s=r.current)!=null&&s.contains(t.relatedTarget)||K(!1)},[]),[v,i]=e.useState(!1);e.useEffect(()=>{i(y)},[y]),e.useEffect(()=>{var s;if(!v)return;const t=(s=r.current)==null?void 0:s.control;return()=>{t==null||t.scrollIntoView({behavior:"smooth",block:"nearest"})}},[v]);const[A,N]=e.useState(""),{value:p}=a,[k,g]=e.useState(p),[C,J]=e.useState(p),z=e.useRef(C),l=e.useCallback(t=>{J(t),z.current=t},[]);e.useEffect(()=>{g(p),l(p)},[p,l]),e.useEffect(()=>{if(p===void 0)return;const t=o.find(s=>s.value===p);t&&N(q(t))},[o,p]),e.useEffect(()=>{p===void 0&&N("")},[p]);const Q=e.useCallback(()=>{k&&(N(""),l(void 0))},[k,l]),W=e.useCallback((t,s)=>{N(t),u==null||u(t,s),i(!0),g(void 0)},[u]),Z=e.useCallback(t=>{var s;(s=r.current)!=null&&s.contains(t.target)&&i(!0)},[]),j=e.useCallback(t=>{const s=t==null?void 0:t.value;l(s),t?N(q(t)):(N(""),u==null||u("")),b==null||b(s)},[l,u,b]),ee=e.useCallback(t=>{const s=o.find(V=>V.value===t);j(s),g(t),i(!1)},[o,j]),te=e.useCallback(t=>{l(t)},[l]),M=e.useDeferredValue(A),x=e.useMemo(()=>!f||k?o:oe.default(M,o,q),[f,k,o,M]);e.useEffect(()=>{!k&&M.length>0&&x.length>0&&!x.some(t=>C===t.value)&&l(x[0].value)},[k,M,x,C,l]);const{setIsKeyboardNavigating:S}=F();return e.useEffect(()=>{if(y)return ue(t=>{t.movementX===0&&t.movementY===0||S(!1)})},[y,S]),e.useEffect(()=>{if(y)return ie(t=>{var U;let s;const V=x.length,L=x.findIndex(c=>c.value===z.current),h=()=>{t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()};switch(t.key){case"Enter":{const c=x[L];c&&v&&(h(),S(!0),i(!1),j(c),g(c.value));break}case"Escape":{if(v)h(),k?l(void 0):j(void 0),i(!1);else if(k)h(),i(!0),j(void 0),g(void 0);else{h(),K(!1);const c=document.activeElement;c instanceof HTMLElement&&((U=r.current)!=null&&U.contains(c))&&c.blur()}return}case"ArrowDown":{h(),v&&(s=L+1),i(!0);break}case"ArrowUp":{h(),v&&(s=L-1,s<0&&(s=V-1)),i(!0);break}case"Home":{i(!0),s=0;break}case"End":{i(!0),s=V-1;break}case"Backspace":{x.some(c=>c.value===k)&&(h(),j(void 0),i(!0),g(void 0));break}}if(s!==void 0&&(h(),S(!0),V>0)){const c=x[s%V];c&&l(c.value)}})},[y,x,S,i,j,g,v,k,l]),d.jsxRuntimeExports.jsx(ae.default,{...a,ref:r,role:"combobox",autoComplete:"off","aria-controls":H,"aria-expanded":v,"aria-activedescendant":v?P:void 0,label:O,value:A,error:E,warning:w,information:I,footnote:m,attachments:v?d.jsxRuntimeExports.jsx(de,{isLoading:n,id:H,activeOptionId:P,selectedValue:C,options:x,onSelect:ee,onHover:te}):null,className:_.cx(R,"kakadu-components-1230689972"),onMouseDown:Z,onChange:W,onBeforeInput:Q,onFocus:$,onBlur:G,children:d.jsxRuntimeExports.jsx(re.default,{width:14,height:14,className:"kakadu-components-158931186"})})}exports.default=fe;exports.getComboboxOptionString=q;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { j as l } from "../jsx-runtime-z6PQ6F3d.mjs";
|
|
2
|
-
import { useRef as
|
|
2
|
+
import { useRef as K, useId as Q, useState as S, useCallback as d, useEffect as h, useDeferredValue as ce, useMemo as Z, useLayoutEffect as ie } from "react";
|
|
3
3
|
import { cx as T } from "@kuma-ui/core";
|
|
4
4
|
import ue from "../hooks/use-synchronized-value.mjs";
|
|
5
5
|
import le from "../icons/icon.mjs";
|
|
@@ -44,20 +44,20 @@ const z = "kakadu-components-1144794361", U = "kakadu-components-2911184744";
|
|
|
44
44
|
function ke({
|
|
45
45
|
ref: r,
|
|
46
46
|
isSelected: m,
|
|
47
|
-
id:
|
|
47
|
+
id: M,
|
|
48
48
|
value: o,
|
|
49
|
-
label:
|
|
50
|
-
onSelect:
|
|
51
|
-
onHover:
|
|
49
|
+
label: g,
|
|
50
|
+
onSelect: N,
|
|
51
|
+
onHover: V
|
|
52
52
|
}) {
|
|
53
53
|
const {
|
|
54
54
|
isKeyboardNavigating: f
|
|
55
|
-
} = X(),
|
|
56
|
-
|
|
57
|
-
}, [
|
|
58
|
-
f || n.movementX === 0 && n.movementY === 0 ||
|
|
59
|
-
}, [f,
|
|
60
|
-
|
|
55
|
+
} = X(), j = d(() => {
|
|
56
|
+
N(o);
|
|
57
|
+
}, [N, o]), c = d((n) => {
|
|
58
|
+
f || n.movementX === 0 && n.movementY === 0 || V(o);
|
|
59
|
+
}, [f, V, o]), p = K(null);
|
|
60
|
+
h(() => {
|
|
61
61
|
const n = p.current;
|
|
62
62
|
m && n && f && setTimeout(() => {
|
|
63
63
|
n.scrollIntoView({
|
|
@@ -73,33 +73,33 @@ function ke({
|
|
|
73
73
|
},
|
|
74
74
|
[r]
|
|
75
75
|
);
|
|
76
|
-
return /* @__PURE__ */ l.jsx("li", { ref: s, id:
|
|
76
|
+
return /* @__PURE__ */ l.jsx("li", { ref: s, id: M, role: "option", "aria-selected": m, tabIndex: -1, className: T(z, "kakadu-components-4130497639", f ? "kakadu-components-962373561" : "kakadu-components-1109598791"), onClick: j, onMouseMove: c, children: /* @__PURE__ */ l.jsx(P, { className: T(U, typeof g == "string" && "kakadu-components-154286052"), children: g }) });
|
|
77
77
|
}
|
|
78
78
|
function xe({
|
|
79
79
|
isLoading: r,
|
|
80
80
|
id: m,
|
|
81
|
-
activeOptionId:
|
|
81
|
+
activeOptionId: M,
|
|
82
82
|
selectedValue: o,
|
|
83
|
-
options:
|
|
84
|
-
onSelect:
|
|
85
|
-
onHover:
|
|
83
|
+
options: g,
|
|
84
|
+
onSelect: N,
|
|
85
|
+
onHover: V
|
|
86
86
|
}) {
|
|
87
|
-
const f =
|
|
88
|
-
|
|
87
|
+
const f = K(null);
|
|
88
|
+
h(() => {
|
|
89
89
|
const s = f.current;
|
|
90
90
|
s && s.scrollIntoView({
|
|
91
91
|
behavior: "smooth",
|
|
92
92
|
block: "nearest"
|
|
93
93
|
});
|
|
94
94
|
}, []);
|
|
95
|
-
const
|
|
95
|
+
const j = K(null), {
|
|
96
96
|
isKeyboardNavigating: c
|
|
97
|
-
} = X(), p =
|
|
97
|
+
} = X(), p = K(c);
|
|
98
98
|
return p.current = c, ie(() => {
|
|
99
99
|
const s = f.current;
|
|
100
|
-
if (s &&
|
|
100
|
+
if (s && g.length > 0) {
|
|
101
101
|
if (p.current) {
|
|
102
|
-
const n =
|
|
102
|
+
const n = j.current;
|
|
103
103
|
if (n) {
|
|
104
104
|
n.scrollIntoView({
|
|
105
105
|
block: "nearest"
|
|
@@ -111,19 +111,19 @@ function xe({
|
|
|
111
111
|
top: 0
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
|
-
}, [
|
|
115
|
-
|
|
114
|
+
}, [g]), /* @__PURE__ */ l.jsxs("ul", { ref: f, id: m, role: "listbox", "aria-label": "Options", tabIndex: -1, className: "kakadu-components-1713806412", children: [
|
|
115
|
+
g.length === 0 ? r ? null : /* @__PURE__ */ l.jsxs(W, { "aria-atomic": !0, as: "li", role: "status", "aria-live": "polite", direction: "row", preset: "start", gap: 0.5, className: z, children: [
|
|
116
116
|
/* @__PURE__ */ l.jsx(le, { size: 15, type: "exclamationTriangle" }),
|
|
117
117
|
/* @__PURE__ */ l.jsx(P, { className: U, children: "No results." })
|
|
118
|
-
] }) :
|
|
118
|
+
] }) : g.map((s, n) => /* @__PURE__ */ l.jsx(
|
|
119
119
|
ke,
|
|
120
120
|
{
|
|
121
121
|
...s,
|
|
122
|
-
ref: s.value === o ?
|
|
123
|
-
id: s.value === o ?
|
|
122
|
+
ref: s.value === o ? j : void 0,
|
|
123
|
+
id: s.value === o ? M : void 0,
|
|
124
124
|
isSelected: s.value === o,
|
|
125
|
-
onSelect:
|
|
126
|
-
onHover:
|
|
125
|
+
onSelect: N,
|
|
126
|
+
onHover: V
|
|
127
127
|
},
|
|
128
128
|
F(s) + n
|
|
129
129
|
)),
|
|
@@ -133,28 +133,28 @@ function xe({
|
|
|
133
133
|
function Me({
|
|
134
134
|
isLoading: r,
|
|
135
135
|
shouldFilterOptions: m = !0,
|
|
136
|
-
label:
|
|
136
|
+
label: M,
|
|
137
137
|
options: o,
|
|
138
|
-
error:
|
|
139
|
-
warning:
|
|
140
|
-
information:
|
|
138
|
+
error: g,
|
|
139
|
+
warning: N,
|
|
140
|
+
information: V,
|
|
141
141
|
footnote: f,
|
|
142
|
-
className:
|
|
142
|
+
className: j,
|
|
143
143
|
onChange: c,
|
|
144
144
|
onSelect: p,
|
|
145
145
|
...s
|
|
146
146
|
}) {
|
|
147
|
-
const n =
|
|
147
|
+
const n = K(null), Y = Q(), q = Q(), [E, H] = S(!1), $ = d(() => {
|
|
148
148
|
H(!0);
|
|
149
149
|
}, []), ee = d((e) => {
|
|
150
150
|
var t;
|
|
151
151
|
(t = n.current) != null && t.contains(e.relatedTarget) || H(!1);
|
|
152
|
-
}, []), [
|
|
153
|
-
|
|
154
|
-
i(
|
|
155
|
-
}, [
|
|
152
|
+
}, []), [b, i] = S(!1);
|
|
153
|
+
h(() => {
|
|
154
|
+
i(E);
|
|
155
|
+
}, [E]), h(() => {
|
|
156
156
|
var t;
|
|
157
|
-
if (!
|
|
157
|
+
if (!b)
|
|
158
158
|
return;
|
|
159
159
|
const e = (t = n.current) == null ? void 0 : t.control;
|
|
160
160
|
return () => {
|
|
@@ -163,68 +163,68 @@ function Me({
|
|
|
163
163
|
block: "nearest"
|
|
164
164
|
});
|
|
165
165
|
};
|
|
166
|
-
}, [
|
|
167
|
-
const [C,
|
|
168
|
-
value:
|
|
169
|
-
} = s, [
|
|
166
|
+
}, [b]);
|
|
167
|
+
const [C, O] = S(""), {
|
|
168
|
+
value: k
|
|
169
|
+
} = s, [x, I] = S(k), [B, te] = S(k), G = K(B), u = d((e) => {
|
|
170
170
|
te(e), G.current = e;
|
|
171
171
|
}, []);
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}, [
|
|
175
|
-
if (
|
|
172
|
+
h(() => {
|
|
173
|
+
I(k), u(k);
|
|
174
|
+
}, [k, u]), h(() => {
|
|
175
|
+
if (k === void 0)
|
|
176
176
|
return;
|
|
177
|
-
const e = o.find((t) => t.value ===
|
|
178
|
-
e &&
|
|
179
|
-
}, [o,
|
|
180
|
-
|
|
181
|
-
}, [
|
|
177
|
+
const e = o.find((t) => t.value === k);
|
|
178
|
+
e && O(F(e));
|
|
179
|
+
}, [o, k]), h(() => {
|
|
180
|
+
k === void 0 && O("");
|
|
181
|
+
}, [k]);
|
|
182
182
|
const re = d(() => {
|
|
183
|
-
|
|
184
|
-
}, [
|
|
185
|
-
|
|
183
|
+
x && (O(""), u(void 0));
|
|
184
|
+
}, [x, u]), ne = d((e, t) => {
|
|
185
|
+
O(e), c == null || c(e, t), i(!0), I(void 0);
|
|
186
186
|
}, [c]), oe = d((e) => {
|
|
187
187
|
var t;
|
|
188
188
|
(t = n.current) != null && t.contains(e.target) && i(!0);
|
|
189
|
-
}, []),
|
|
189
|
+
}, []), y = d((e) => {
|
|
190
190
|
const t = e == null ? void 0 : e.value;
|
|
191
|
-
u(t), e ?
|
|
191
|
+
u(t), e ? O(F(e)) : (O(""), c == null || c("")), p == null || p(t);
|
|
192
192
|
}, [u, c, p]), se = d((e) => {
|
|
193
|
-
const t = o.find((
|
|
194
|
-
|
|
195
|
-
}, [o,
|
|
193
|
+
const t = o.find((L) => L.value === e);
|
|
194
|
+
y(t), I(e), i(!1);
|
|
195
|
+
}, [o, y]), ae = d((e) => {
|
|
196
196
|
u(e);
|
|
197
|
-
}, [u]), D = ce(C), v = Z(() => !m ||
|
|
198
|
-
|
|
199
|
-
!
|
|
200
|
-
}, [
|
|
197
|
+
}, [u]), D = ce(C), v = Z(() => !m || x ? o : me(D, o, F), [m, x, o, D]);
|
|
198
|
+
h(() => {
|
|
199
|
+
!x && D.length > 0 && v.length > 0 && !v.some((e) => B === e.value) && u(v[0].value);
|
|
200
|
+
}, [x, D, v, B, u]);
|
|
201
201
|
const {
|
|
202
202
|
setIsKeyboardNavigating: R
|
|
203
203
|
} = X();
|
|
204
|
-
return
|
|
205
|
-
if (
|
|
204
|
+
return h(() => {
|
|
205
|
+
if (E)
|
|
206
206
|
return pe((e) => {
|
|
207
207
|
e.movementX === 0 && e.movementY === 0 || R(!1);
|
|
208
208
|
});
|
|
209
|
-
}, [
|
|
210
|
-
if (
|
|
209
|
+
}, [E, R]), h(() => {
|
|
210
|
+
if (E)
|
|
211
211
|
return be((e) => {
|
|
212
212
|
var J;
|
|
213
213
|
let t;
|
|
214
|
-
const
|
|
214
|
+
const L = v.length, A = v.findIndex((a) => a.value === G.current), w = () => {
|
|
215
215
|
e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation();
|
|
216
216
|
};
|
|
217
217
|
switch (e.key) {
|
|
218
218
|
case "Enter": {
|
|
219
219
|
const a = v[A];
|
|
220
|
-
a && (w(), R(!0), i(!1),
|
|
220
|
+
a && b && (w(), R(!0), i(!1), y(a), I(a.value));
|
|
221
221
|
break;
|
|
222
222
|
}
|
|
223
223
|
case "Escape": {
|
|
224
|
-
if (
|
|
225
|
-
w(),
|
|
226
|
-
else if (
|
|
227
|
-
w(), i(!0), I(void 0);
|
|
224
|
+
if (b)
|
|
225
|
+
w(), x ? u(void 0) : y(void 0), i(!1);
|
|
226
|
+
else if (x)
|
|
227
|
+
w(), i(!0), y(void 0), I(void 0);
|
|
228
228
|
else {
|
|
229
229
|
w(), H(!1);
|
|
230
230
|
const a = document.activeElement;
|
|
@@ -233,11 +233,11 @@ function Me({
|
|
|
233
233
|
return;
|
|
234
234
|
}
|
|
235
235
|
case "ArrowDown": {
|
|
236
|
-
w(),
|
|
236
|
+
w(), b && (t = A + 1), i(!0);
|
|
237
237
|
break;
|
|
238
238
|
}
|
|
239
239
|
case "ArrowUp": {
|
|
240
|
-
w(),
|
|
240
|
+
w(), b && (t = A - 1, t < 0 && (t = L - 1)), i(!0);
|
|
241
241
|
break;
|
|
242
242
|
}
|
|
243
243
|
case "Home": {
|
|
@@ -245,20 +245,20 @@ function Me({
|
|
|
245
245
|
break;
|
|
246
246
|
}
|
|
247
247
|
case "End": {
|
|
248
|
-
i(!0), t =
|
|
248
|
+
i(!0), t = L - 1;
|
|
249
249
|
break;
|
|
250
250
|
}
|
|
251
251
|
case "Backspace": {
|
|
252
|
-
v.some((a) => a.value ===
|
|
252
|
+
v.some((a) => a.value === x) && (w(), y(void 0), i(!0), I(void 0));
|
|
253
253
|
break;
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
|
-
if (t !== void 0 && (w(), R(!0),
|
|
257
|
-
const a = v[t %
|
|
256
|
+
if (t !== void 0 && (w(), R(!0), L > 0)) {
|
|
257
|
+
const a = v[t % L];
|
|
258
258
|
a && u(a.value);
|
|
259
259
|
}
|
|
260
260
|
});
|
|
261
|
-
}, [
|
|
261
|
+
}, [E, v, R, i, y, I, b, x, u]), /* @__PURE__ */ l.jsx(fe, { ...s, ref: n, role: "combobox", autoComplete: "off", "aria-controls": Y, "aria-expanded": b, "aria-activedescendant": b ? q : void 0, label: M, value: C, error: g, warning: N, information: V, footnote: f, attachments: b ? /* @__PURE__ */ l.jsx(xe, { isLoading: r, id: Y, activeOptionId: q, selectedValue: B, options: v, onSelect: se, onHover: ae }) : null, className: T(j, "kakadu-components-1230689972"), onMouseDown: oe, onChange: ne, onBeforeInput: re, onFocus: $, onBlur: ee, children: /* @__PURE__ */ l.jsx(de, { width: 14, height: 14, className: "kakadu-components-158931186" }) });
|
|
262
262
|
}
|
|
263
263
|
export {
|
|
264
264
|
Me as default,
|
|
@@ -20,7 +20,9 @@ type InputLabelProperties = HTMLProps<HTMLLabelElement> & InputLabelMessagePrope
|
|
|
20
20
|
readonly attachments?: ReactNode;
|
|
21
21
|
};
|
|
22
22
|
export declare function InputLabel({ label, error, errorId, warning, warningId, information, informationId, footnote, attachments, className, children, ...properties }: InputLabelProperties): React.JSX.Element;
|
|
23
|
-
export type InputLabelControllerProperties = Omit<InputLabelProperties, 'errorId' | 'warningId' | 'attachments' | 'onClick' | 'onMouseDown' | 'onMouseUp' | 'onChange' | 'onFocus' | 'onBlur' | 'onInput' | 'onBeforeInput'
|
|
23
|
+
export type InputLabelControllerProperties = Omit<InputLabelProperties, 'errorId' | 'warningId' | 'attachments' | 'onClick' | 'onMouseDown' | 'onMouseUp' | 'onChange' | 'onFocus' | 'onBlur' | 'onInput' | 'onBeforeInput'> & {
|
|
24
|
+
readonly labelClassName?: string;
|
|
25
|
+
};
|
|
24
26
|
export type InputType = HTMLInputElement | HTMLTextAreaElement;
|
|
25
27
|
export type InputAction = {
|
|
26
28
|
icon: IconType;
|
|
@@ -36,5 +38,5 @@ export type InputProperties = Omit<InputLabelControllerProperties & Omit<HTMLPro
|
|
|
36
38
|
readonly isMultiline?: boolean;
|
|
37
39
|
readonly onChange?: (value: string, event: ChangeEvent<InputType>) => void;
|
|
38
40
|
};
|
|
39
|
-
export default function Input({ ref, type, label, error, warning, information, footnote, suggestion, attachments, actions, hasCopyButton, hasClearButton, isMultiline, onChange, children, className, ...properties }: InputProperties): React.JSX.Element;
|
|
41
|
+
export default function Input({ ref, type, label, error, warning, information, footnote, suggestion, attachments, actions, hasCopyButton, hasClearButton, isMultiline, onChange, children, className, labelClassName, ...properties }: InputProperties): React.JSX.Element;
|
|
40
42
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../jsx-runtime-CZa898vN.js"),t=require("react"),
|
|
2
|
-
`):[],[o]),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../jsx-runtime-CZa898vN.js"),t=require("react"),c=require("@kuma-ui/core"),Q=require("../utilities/copy-to-clipboard.js"),M=require("../theme.js"),je=require("../icons/sparkle.js"),ke=require("./button-tooltip.js"),B=require("./text-button.js"),x=require("./text.js"),fe=require("./collapsible.js"),X=require("./click-ripples.js"),Y=require("./hover-gradient.js"),he=require("./notification.js"),Ee="kakadu-components-922159086",Re="kakadu-components-25448712",v="kakadu-components-3308836726",T="kakadu-components-4056037255",Z=c.cx(T,"kakadu-components-3245407458"),be=c.cx(T,"kakadu-components-1117160492"),ge=c.cx(T,"kakadu-components-821835704");function ee({as:p,className:r,...m}){return e.jsxRuntimeExports.jsx(x.Span,{as:p??"span",...m,className:c.cx("kakadu-components-2675681525",r)})}function te({label:p,error:r,errorId:m,warning:l,warningId:h,information:i,informationId:S,footnote:a,attachments:C,className:d,children:j,...k}){const E=!!r,u=!!l,R=!!i,f=!!a;return e.jsxRuntimeExports.jsx("label",{...k,className:c.cx(Ee,d),children:e.jsxRuntimeExports.jsxs("div",{className:"kakadu-components-3146929190",children:[e.jsxRuntimeExports.jsx(x.Span,{className:c.cx(M.overflowProtectionStyles,Re),children:e.jsxRuntimeExports.jsx("span",{children:p})}),e.jsxRuntimeExports.jsxs("span",{className:"kakadu-components-3298764637",children:[j,f?e.jsxRuntimeExports.jsx(ee,{children:a}):null,C]}),E||u||R?e.jsxRuntimeExports.jsx("div",{className:"kakadu-components-2927674627",children:E?e.jsxRuntimeExports.jsx(x.Paragraph,{id:m,className:Z,children:r instanceof Error?r.message:r}):u?e.jsxRuntimeExports.jsx(x.Paragraph,{id:h,className:be,children:l instanceof Error?l.message:l}):R?e.jsxRuntimeExports.jsx(x.Paragraph,{id:S,className:ge,children:i instanceof Error?i.message:i}):null}):null]})})}const ye=40,L="kakadu-components-4233741488";function Ne({ref:p,type:r,label:m,error:l,warning:h,information:i,footnote:S,suggestion:a,attachments:C,actions:d=[],hasCopyButton:j,hasClearButton:k,isMultiline:E,onChange:u,children:R,className:f,labelClassName:se,...b}){const $=t.useRef(null),A=t.useRef(null),q=t.useRef(null),H=he.useCreateNotification(),I=t.useId(),F=`${I}-error`,V=`${I}-warning`,O=`${I}-information`,{value:g,disabled:ne}=b,[ae,W]=t.useState(""),o=g??ae,[oe,ce]=t.useState(),re=r==="textarea"||!!E;t.useLayoutEffect(()=>{typeof o=="string"&&q.current&&ce(q.current.scrollHeight)},[o]);const P=t.useMemo(()=>typeof o=="string"?`${o} `.split(`
|
|
2
|
+
`):[],[o]),le=t.useMemo(()=>P.length,[P]),y=!!l,_=!y&&!!h,w=!!i,z=y?F:_?V:w?O:void 0;t.useEffect(()=>{W(typeof g=="string"?g:"")},[g]);const D=t.useCallback(s=>{const{value:n}=s.target;W(n),u==null||u(n,s)},[u]),ie=t.useCallback(()=>{typeof o=="string"&&(Q.default(o),H({type:"success",children:"Copied to clipboard."}))},[o,H]),N=t.useCallback(s=>{var J;const n=A.current??$.current??void 0;if(n){const K=(J=Object.getOwnPropertyDescriptor(n instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value"))==null?void 0:J.set;if(K){K.call(n,s);const de=new Event("input",{bubbles:!0});n.dispatchEvent(de),n.focus();return}}throw new Error("Unable to set value.")},[]),ue=t.useCallback(()=>{N("")},[N]),[xe,pe]=t.useState(""),G=!!a&&xe!==a,me=t.useCallback(()=>{if(a){try{N(a)}catch{Q.default(a)}pe(a)}},[a,N]),U=t.useMemo(()=>d.length,[d]);return e.jsxRuntimeExports.jsxs(te,{ref:p,label:m,error:l,errorId:F,warning:h,warningId:V,information:i,informationId:O,footnote:S,attachments:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(fe.default,{isCollapsed:!G,children:G?e.jsxRuntimeExports.jsxs("button",{type:"button",className:c.cx(M.buttonResetStyles,M.overflowProtectionStyles,"kakadu-components-4141839293"),onClick:me,children:[e.jsxRuntimeExports.jsx(ke.default,{label:"Apply suggestion"}),e.jsxRuntimeExports.jsx(je.default,{width:13,height:13,className:"kakadu-components-1417828741"}),e.jsxRuntimeExports.jsx(x.Span,{className:"kakadu-components-1384720019",children:a}),e.jsxRuntimeExports.jsx(X.default,{className:"kakadu-components-2744733744"}),e.jsxRuntimeExports.jsx(Y.default,{})]}):null}),C]}),style:{"--button-padding":`calc(${ye*((j?1:0)+(k?1:0)+U)}px + 6px)`},className:se,children:[e.jsxRuntimeExports.jsxs("div",{className:"kakadu-components-3146929190",children:[re?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("span",{ref:q,"aria-hidden":!0,className:c.cx(v,f,"kakadu-components-2033521835"),children:[P.map((s,n)=>e.jsxRuntimeExports.jsxs("span",{children:[s,le>1?e.jsxRuntimeExports.jsx("br",{}):null]},n))," "]}),e.jsxRuntimeExports.jsx("textarea",{...b,ref:A,rows:b.rows??1,"aria-invalid":y,"data-warning":_,"data-information":w,"aria-describedby":z,value:o,className:c.cx(v,f,"kakadu-components-2119524139"),style:{minHeight:oe},onChange:D})]}):e.jsxRuntimeExports.jsx("input",{...b,ref:$,type:r??"text",value:o,"aria-invalid":y,"data-warning":_,"data-information":w,"aria-describedby":z,className:c.cx(v,f),onChange:D}),ne?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(X.default,{className:"kakadu-components-616311160"}),e.jsxRuntimeExports.jsx(Y.default,{className:"kakadu-components-1962999040"})]})]}),j||k||U>0?e.jsxRuntimeExports.jsxs("div",{className:"kakadu-components-131986363",children:[d.map((s,n)=>e.jsxRuntimeExports.jsx(B.default,{iconLeft:s.icon,label:s.label,tooltip:s.label,className:L,onClick:s.onClick},s.label+n)),j?e.jsxRuntimeExports.jsx(B.default,{iconLeft:"copy",label:"Copy",tooltip:"Copy",className:L,onClick:ie}):null,k?e.jsxRuntimeExports.jsx(B.default,{iconLeft:"times",label:"Clear",tooltip:"Clear",className:L,onClick:ue}):null]}):null,R]})}exports.InputAttachment=ee;exports.InputLabel=te;exports.default=Ne;exports.errorParagraph=Z;exports.inputStyles=v;
|