@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.
@@ -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"),j=require("@kuma-ui/core"),_=require("../icons/icon.js"),F=require("../theme.js"),B=require("./input.js"),T=require("./aria-text.js"),R=require("./flex.js"),b=require("./text.js"),w=require("./hover-gradient.js"),z=require("./click-ripples.js");function N({value:a,className:t}){return e.jsxRuntimeExports.jsx("div",{"aria-hidden":!0,className:j.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(_.default,{type:"check",size:14,fill:"#fff",className:_.iconShadowStyles})}):null})}function M({label:a,disabled:t,className:x,children:r,onChange:s,...k}){const{value:i,...f}=k,[c,m]=o.useState(!1),n=i??c;o.useEffect(()=>{m(!!i)},[i]);const d=o.useCallback(u=>{const{checked:l}=u.target;m(l),s==null||s(l,u)},[s]);return e.jsxRuntimeExports.jsxs("label",{className:j.cx("kakadu-components-1233932825",t&&"kakadu-components-2246117376",x),children:[e.jsxRuntimeExports.jsx("input",{...f,type:"checkbox",checked:n,disabled:t,className:T.ariaTextStyles,onChange:d}),e.jsxRuntimeExports.jsxs(R.default,{direction:"row",gap:.75,children:[e.jsxRuntimeExports.jsx(N,{value:n}),e.jsxRuntimeExports.jsxs(R.default,{fill:!0,gap:.25,children:[e.jsxRuntimeExports.jsx(b.Span,{className:j.cx(F.overflowProtectionStyles,"kakadu-components-3627383913",n&&"kakadu-components-572005680"),children:a}),r?e.jsxRuntimeExports.jsx(b.Footnote,{children:r}):null]})]})]})}function C({label:a,disabled:t,error:x,warning:r,information:s,footnote:k,className:i,children:f,onChange:c,...m}){const n=o.useId(),d=`${n}-error`,u=`${n}-warning`,l=`${n}-information`,p=!!x,h=!p&&!!r,q=!p&&!h&&!!s,V=p?d:h?u:q?l:void 0,{value:E,...g}=m,[$,y]=o.useState(!1),S=E??$;o.useEffect(()=>{y(!!E)},[E]);const P=o.useCallback(v=>{const{checked:I}=v.target;y(I),c==null||c(I,v)},[c]);return e.jsxRuntimeExports.jsxs(B.InputLabel,{label:a,error:x,errorId:d,warning:r,warningId:u,information:s,informationId:l,footnote:k,className:j.cx("kakadu-components-1233932825",t&&"kakadu-components-2246117376",i),children:[e.jsxRuntimeExports.jsx("input",{...g,type:"checkbox",checked:S,disabled:t,"aria-invalid":p,"data-warning":h,"data-information":q,"aria-describedby":V,className:T.ariaTextStyles,onChange:P}),e.jsxRuntimeExports.jsxs("div",{className:B.inputStyles,"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:S,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(w.default,{size:150,className:w.normalBlendStyles}),e.jsxRuntimeExports.jsx(z.default,{})]})]})]})}exports.CheckboxIcon=N;exports.TextCheckbox=M;exports.default=C;
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 T, useState as B, useEffect as w, useCallback as V } from "react";
3
- import { cx as k } from "@kuma-ui/core";
4
- import G, { iconShadowStyles as H } from "../icons/icon.mjs";
5
- import { overflowProtectionStyles as L } from "../theme.mjs";
6
- import { InputLabel as W, inputStyles as q } from "./input.mjs";
7
- import { ariaTextStyles as g } from "./aria-text.mjs";
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 E, Span as A } from "./text.mjs";
10
- import D, { normalBlendStyles as J } from "./hover-gradient.mjs";
11
- import K from "./click-ripples.mjs";
12
- function F({
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: k("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(G, { type: "check", size: 14, fill: "#fff", className: H }) }) : null });
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 se({
18
+ function oe({
19
19
  label: t,
20
20
  disabled: a,
21
- className: m,
22
- children: c,
21
+ className: u,
22
+ children: n,
23
23
  onChange: s,
24
- ...x
24
+ ...k
25
25
  }) {
26
26
  const {
27
- value: r,
28
- ...f
29
- } = x, [n, d] = B(!1), o = r ?? n;
30
- w(() => {
31
- d(!!r);
32
- }, [r]);
33
- const u = V((l) => {
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: i
36
- } = l.target;
37
- d(i), s == null || s(i, l);
35
+ checked: m
36
+ } = i.target;
37
+ o(m), s == null || s(m, i);
38
38
  }, [s]);
39
- return /* @__PURE__ */ e.jsxs("label", { className: k("kakadu-components-1233932825", a && "kakadu-components-2246117376", m), children: [
40
- /* @__PURE__ */ e.jsx("input", { ...f, type: "checkbox", checked: o, disabled: a, className: g, onChange: u }),
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(F, { value: o }),
42
+ /* @__PURE__ */ e.jsx(P, { value: r }),
43
43
  /* @__PURE__ */ e.jsxs(N, { fill: !0, gap: 0.25, children: [
44
- /* @__PURE__ */ e.jsx(A, { className: k(L, "kakadu-components-3627383913", o && "kakadu-components-572005680"), children: t }),
45
- c ? /* @__PURE__ */ e.jsx(E, { children: c }) : null
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 oe({
50
+ function te({
51
51
  label: t,
52
52
  disabled: a,
53
- error: m,
54
- warning: c,
53
+ error: u,
54
+ warning: n,
55
55
  information: s,
56
- footnote: x,
57
- className: r,
56
+ footnote: k,
57
+ className: c,
58
+ labelClassName: x,
58
59
  children: f,
59
- onChange: n,
60
- ...d
60
+ onChange: o,
61
+ ...r
61
62
  }) {
62
- const o = T(), u = `${o}-error`, l = `${o}-warning`, i = `${o}-information`, p = !!m, h = !p && !!c, y = !p && !h && !!s, P = p ? u : h ? l : y ? i : void 0, {
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
- } = d, [z, I] = B(!1), v = j ?? z;
66
- w(() => {
67
- I(!!j);
65
+ ...z
66
+ } = r, [R, v] = w(!1), b = j ?? R;
67
+ V(() => {
68
+ v(!!j);
68
69
  }, [j]);
69
- const R = V((b) => {
70
+ const T = g((S) => {
70
71
  const {
71
- checked: S
72
- } = b.target;
73
- I(S), n == null || n(S, b);
74
- }, [n]);
75
- return /* @__PURE__ */ e.jsxs(W, { label: t, error: m, errorId: u, warning: c, warningId: l, information: s, informationId: i, footnote: x, className: k("kakadu-components-1233932825", a && "kakadu-components-2246117376", r), children: [
76
- /* @__PURE__ */ e.jsx("input", { ...$, type: "checkbox", checked: v, disabled: a, "aria-invalid": p, "data-warning": h, "data-information": y, "aria-describedby": P, className: g, onChange: R }),
77
- /* @__PURE__ */ e.jsxs("div", { className: q, "aria-disabled": a ? !0 : void 0, children: [
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(F, { value: v, className: "kakadu-components-3803487082" }),
80
- /* @__PURE__ */ e.jsx(E, { className: "kakadu-components-4115080333", children: f })
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(D, { size: 150, className: J }),
84
- /* @__PURE__ */ e.jsx(K, {})
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
- F as CheckboxIcon,
91
- se as TextCheckbox,
92
- oe as default
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 f=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:d}=se.default("isKeyboardNavigating");return e.useMemo(()=>({isKeyboardNavigating:n,setIsKeyboardNavigating:d}),[n,d])}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:d,id:V,value:o,label:k,onSelect:j,onHover:w}){const{isKeyboardNavigating:m}=F(),I=e.useCallback(()=>{j(o)},[j,o]),u=e.useCallback(r=>{m||r.movementX===0&&r.movementY===0||w(o)},[m,w,o]),b=e.useRef(null);e.useEffect(()=>{const r=b.current;d&&r&&m&&setTimeout(()=>{r.scrollIntoView({behavior:"smooth",block:"nearest"})},0)},[d,m]);const a=e.useCallback(r=>{b.current=r,n&&(n.current=r)},[n]);return f.jsxRuntimeExports.jsx("li",{ref:a,id:V,role:"option","aria-selected":d,tabIndex:-1,className:_.cx(B,"kakadu-components-4130497639",m?"kakadu-components-962373561":"kakadu-components-1109598791"),onClick:I,onMouseMove:u,children:f.jsxRuntimeExports.jsx(T.Span,{className:_.cx(D,typeof k=="string"&&"kakadu-components-154286052"),children:k})})}function fe({isLoading:n,id:d,activeOptionId:V,selectedValue:o,options:k,onSelect:j,onHover:w}){const m=e.useRef(null);e.useEffect(()=>{const a=m.current;a&&a.scrollIntoView({behavior:"smooth",block:"nearest"})},[]);const I=e.useRef(null),{isKeyboardNavigating:u}=F(),b=e.useRef(u);return b.current=u,e.useLayoutEffect(()=>{const a=m.current;if(a&&k.length>0){if(b.current){const r=I.current;if(r){r.scrollIntoView({block:"nearest"});return}}a.scrollTo({top:0})}},[k]),f.jsxRuntimeExports.jsxs("ul",{ref:m,id:d,role:"listbox","aria-label":"Options",tabIndex:-1,className:"kakadu-components-3718330689",children:[k.length===0?n?null:f.jsxRuntimeExports.jsxs(X.default,{"aria-atomic":!0,as:"li",role:"status","aria-live":"polite",direction:"row",preset:"start",gap:.5,className:B,children:[f.jsxRuntimeExports.jsx(ne.default,{size:15,type:"exclamationTriangle"}),f.jsxRuntimeExports.jsx(T.Span,{className:D,children:"No results."})]}):k.map((a,r)=>f.jsxRuntimeExports.jsx(le,{...a,ref:a.value===o?I:void 0,id:a.value===o?V:void 0,isSelected:a.value===o,onSelect:j,onHover:w},q(a)+r)),n?f.jsxRuntimeExports.jsx(X.default,{as:"li",alignment:"center",className:B,children:f.jsxRuntimeExports.jsx(T.Span,{className:_.cx(D,"kakadu-components-2015848015"),children:f.jsxRuntimeExports.jsx(ce.SkeletonInstance,{width:"100%",height:"1.3em"})})}):null]})}function de({isLoading:n,shouldFilterOptions:d=!0,label:V,options:o,error:k,warning:j,information:w,footnote:m,className:I,onChange:u,onSelect:b,...a}){const r=e.useRef(null),H=e.useId(),P=e.useId(),[R,K]=e.useState(!1),$=e.useCallback(()=>{K(!0)},[]),G=e.useCallback(t=>{var s;(s=r.current)!=null&&s.contains(t.relatedTarget)||K(!1)},[]),[E,i]=e.useState(!1);e.useEffect(()=>{i(R)},[R]),e.useEffect(()=>{var s;if(!E)return;const t=(s=r.current)==null?void 0:s.control;return()=>{t==null||t.scrollIntoView({behavior:"smooth",block:"nearest"})}},[E]);const[A,y]=e.useState(""),{value:p}=a,[v,O]=e.useState(p),[C,J]=e.useState(p),z=e.useRef(C),l=e.useCallback(t=>{J(t),z.current=t},[]);e.useEffect(()=>{O(p),l(p)},[p,l]),e.useEffect(()=>{if(p===void 0)return;const t=o.find(s=>s.value===p);t&&y(q(t))},[o,p]),e.useEffect(()=>{p===void 0&&y("")},[p]);const Q=e.useCallback(()=>{v&&(y(""),l(void 0))},[v,l]),W=e.useCallback((t,s)=>{y(t),u==null||u(t,s),i(!0),O(void 0)},[u]),Z=e.useCallback(t=>{var s;(s=r.current)!=null&&s.contains(t.target)&&i(!0)},[]),g=e.useCallback(t=>{const s=t==null?void 0:t.value;l(s),t?y(q(t)):(y(""),u==null||u("")),b==null||b(s)},[l,u,b]),ee=e.useCallback(t=>{const s=o.find(N=>N.value===t);g(s),O(t),i(!1)},[o,g]),te=e.useCallback(t=>{l(t)},[l]),M=e.useDeferredValue(A),x=e.useMemo(()=>!d||v?o:oe.default(M,o,q),[d,v,o,M]);e.useEffect(()=>{!v&&M.length>0&&x.length>0&&!x.some(t=>C===t.value)&&l(x[0].value)},[v,M,x,C,l]);const{setIsKeyboardNavigating:S}=F();return e.useEffect(()=>{if(R)return ue(t=>{t.movementX===0&&t.movementY===0||S(!1)})},[R,S]),e.useEffect(()=>{if(R)return ie(t=>{var U;let s;const N=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&&(h(),S(!0),i(!1),g(c),O(c.value));break}case"Escape":{if(E)h(),v?l(void 0):g(void 0),i(!1);else if(v)h(),i(!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(),E&&(s=L+1),i(!0);break}case"ArrowUp":{h(),E&&(s=L-1,s<0&&(s=N-1)),i(!0);break}case"Home":{i(!0),s=0;break}case"End":{i(!0),s=N-1;break}case"Backspace":{x.some(c=>c.value===v)&&(h(),g(void 0),i(!0));break}}if(s!==void 0&&(h(),S(!0),N>0)){const c=x[s%N];c&&l(c.value)}})},[R,x,S,i,g,O,E,v,l]),f.jsxRuntimeExports.jsx(ae.default,{...a,ref:r,role:"combobox",autoComplete:"off","aria-controls":H,"aria-expanded":E,"aria-activedescendant":E?P:void 0,label:V,value:A,error:k,warning:j,information:w,footnote:m,attachments:E?f.jsxRuntimeExports.jsx(fe,{isLoading:n,id:H,activeOptionId:P,selectedValue:C,options:x,onSelect:ee,onHover:te}):null,className:_.cx(I,"kakadu-components-1230689972"),onMouseDown:Z,onChange:W,onBeforeInput:Q,onFocus:$,onBlur:G,children:f.jsxRuntimeExports.jsx(re.default,{width:14,height:14,className:"kakadu-components-158931186"})})}exports.default=de;exports.getComboboxOptionString=q;
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 L, useId as Q, useState as S, useCallback as d, useEffect as x, useDeferredValue as ce, useMemo as Z, useLayoutEffect as ie } from "react";
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: K,
47
+ id: M,
48
48
  value: o,
49
- label: h,
50
- onSelect: y,
51
- onHover: N
49
+ label: g,
50
+ onSelect: N,
51
+ onHover: V
52
52
  }) {
53
53
  const {
54
54
  isKeyboardNavigating: f
55
- } = X(), V = d(() => {
56
- y(o);
57
- }, [y, o]), c = d((n) => {
58
- f || n.movementX === 0 && n.movementY === 0 || N(o);
59
- }, [f, N, o]), p = L(null);
60
- x(() => {
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: K, role: "option", "aria-selected": m, tabIndex: -1, className: T(z, "kakadu-components-4130497639", f ? "kakadu-components-962373561" : "kakadu-components-1109598791"), onClick: V, onMouseMove: c, children: /* @__PURE__ */ l.jsx(P, { className: T(U, typeof h == "string" && "kakadu-components-154286052"), children: h }) });
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: K,
81
+ activeOptionId: M,
82
82
  selectedValue: o,
83
- options: h,
84
- onSelect: y,
85
- onHover: N
83
+ options: g,
84
+ onSelect: N,
85
+ onHover: V
86
86
  }) {
87
- const f = L(null);
88
- x(() => {
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 V = L(null), {
95
+ const j = K(null), {
96
96
  isKeyboardNavigating: c
97
- } = X(), p = L(c);
97
+ } = X(), p = K(c);
98
98
  return p.current = c, ie(() => {
99
99
  const s = f.current;
100
- if (s && h.length > 0) {
100
+ if (s && g.length > 0) {
101
101
  if (p.current) {
102
- const n = V.current;
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
- }, [h]), /* @__PURE__ */ l.jsxs("ul", { ref: f, id: m, role: "listbox", "aria-label": "Options", tabIndex: -1, className: "kakadu-components-3718330689", children: [
115
- h.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: [
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
- ] }) : h.map((s, n) => /* @__PURE__ */ l.jsx(
118
+ ] }) : g.map((s, n) => /* @__PURE__ */ l.jsx(
119
119
  ke,
120
120
  {
121
121
  ...s,
122
- ref: s.value === o ? V : void 0,
123
- id: s.value === o ? K : void 0,
122
+ ref: s.value === o ? j : void 0,
123
+ id: s.value === o ? M : void 0,
124
124
  isSelected: s.value === o,
125
- onSelect: y,
126
- onHover: N
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: K,
136
+ label: M,
137
137
  options: o,
138
- error: h,
139
- warning: y,
140
- information: N,
138
+ error: g,
139
+ warning: N,
140
+ information: V,
141
141
  footnote: f,
142
- className: V,
142
+ className: j,
143
143
  onChange: c,
144
144
  onSelect: p,
145
145
  ...s
146
146
  }) {
147
- const n = L(null), Y = Q(), q = Q(), [j, H] = S(!1), $ = d(() => {
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
- }, []), [g, i] = S(!1);
153
- x(() => {
154
- i(j);
155
- }, [j]), x(() => {
152
+ }, []), [b, i] = S(!1);
153
+ h(() => {
154
+ i(E);
155
+ }, [E]), h(() => {
156
156
  var t;
157
- if (!g)
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
- }, [g]);
167
- const [C, E] = S(""), {
168
- value: b
169
- } = s, [k, M] = S(b), [B, te] = S(b), G = L(B), u = d((e) => {
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
- x(() => {
173
- M(b), u(b);
174
- }, [b, u]), x(() => {
175
- if (b === void 0)
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 === b);
178
- e && E(F(e));
179
- }, [o, b]), x(() => {
180
- b === void 0 && E("");
181
- }, [b]);
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
- k && (E(""), u(void 0));
184
- }, [k, u]), ne = d((e, t) => {
185
- E(e), c == null || c(e, t), i(!0), M(void 0);
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
- }, []), I = d((e) => {
189
+ }, []), y = d((e) => {
190
190
  const t = e == null ? void 0 : e.value;
191
- u(t), e ? E(F(e)) : (E(""), c == null || c("")), p == null || p(t);
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((O) => O.value === e);
194
- I(t), M(e), i(!1);
195
- }, [o, I]), ae = d((e) => {
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 || k ? o : me(D, o, F), [m, k, o, D]);
198
- x(() => {
199
- !k && D.length > 0 && v.length > 0 && !v.some((e) => B === e.value) && u(v[0].value);
200
- }, [k, D, v, B, u]);
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 x(() => {
205
- if (j)
204
+ return h(() => {
205
+ if (E)
206
206
  return pe((e) => {
207
207
  e.movementX === 0 && e.movementY === 0 || R(!1);
208
208
  });
209
- }, [j, R]), x(() => {
210
- if (j)
209
+ }, [E, R]), h(() => {
210
+ if (E)
211
211
  return be((e) => {
212
212
  var J;
213
213
  let t;
214
- const O = v.length, A = v.findIndex((a) => a.value === G.current), w = () => {
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), I(a), M(a.value));
220
+ a && b && (w(), R(!0), i(!1), y(a), I(a.value));
221
221
  break;
222
222
  }
223
223
  case "Escape": {
224
- if (g)
225
- w(), k ? u(void 0) : I(void 0), i(!1);
226
- else if (k)
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(), g && (t = A + 1), i(!0);
236
+ w(), b && (t = A + 1), i(!0);
237
237
  break;
238
238
  }
239
239
  case "ArrowUp": {
240
- w(), g && (t = A - 1, t < 0 && (t = O - 1)), i(!0);
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 = O - 1;
248
+ i(!0), t = L - 1;
249
249
  break;
250
250
  }
251
251
  case "Backspace": {
252
- v.some((a) => a.value === k) && (w(), I(void 0), i(!0));
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), O > 0)) {
257
- const a = v[t % O];
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
- }, [j, v, R, i, I, M, g, k, u]), /* @__PURE__ */ l.jsx(fe, { ...s, ref: n, role: "combobox", autoComplete: "off", "aria-controls": Y, "aria-expanded": g, "aria-activedescendant": g ? q : void 0, label: K, value: C, error: h, warning: y, information: N, footnote: f, attachments: g ? /* @__PURE__ */ l.jsx(xe, { isLoading: r, id: Y, activeOptionId: q, selectedValue: B, options: v, onSelect: se, onHover: ae }) : null, className: T(V, "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" }) });
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"),r=require("@kuma-ui/core"),Q=require("../utilities/copy-to-clipboard.js"),M=require("../theme.js"),de=require("../icons/sparkle.js"),je=require("./button-tooltip.js"),B=require("./text-button.js"),x=require("./text.js"),ke=require("./collapsible.js"),X=require("./click-ripples.js"),Y=require("./hover-gradient.js"),fe=require("./notification.js"),he="kakadu-components-922159086",Ee="kakadu-components-25448712",N="kakadu-components-3308836726",T="kakadu-components-4056037255",Z=r.cx(T,"kakadu-components-3245407458"),Re=r.cx(T,"kakadu-components-1117160492"),be=r.cx(T,"kakadu-components-821835704");function ee({as:p,className:c,...m}){return e.jsxRuntimeExports.jsx(x.Span,{as:p??"span",...m,className:r.cx("kakadu-components-2675681525",c)})}function te({label:p,error:c,errorId:m,warning:l,warningId:h,information:i,informationId:S,footnote:a,attachments:C,className:d,children:j,...k}){const E=!!c,u=!!l,R=!!i,f=!!a;return e.jsxRuntimeExports.jsx("label",{...k,className:r.cx(he,d),children:e.jsxRuntimeExports.jsxs("div",{className:"kakadu-components-3146929190",children:[e.jsxRuntimeExports.jsx(x.Span,{className:r.cx(M.overflowProtectionStyles,Ee),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:c instanceof Error?c.message:c}):u?e.jsxRuntimeExports.jsx(x.Paragraph,{id:h,className:Re,children:l instanceof Error?l.message:l}):R?e.jsxRuntimeExports.jsx(x.Paragraph,{id:S,className:be,children:i instanceof Error?i.message:i}):null}):null]})})}const ge=40,L="kakadu-components-4233741488";function ye({ref:p,type:c,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,...b}){const $=t.useRef(null),A=t.useRef(null),q=t.useRef(null),H=fe.useCreateNotification(),I=t.useId(),F=`${I}-error`,V=`${I}-warning`,O=`${I}-information`,{value:g,disabled:se}=b,[ne,W]=t.useState(""),o=g??ne,[ae,oe]=t.useState(),re=c==="textarea"||!!E;t.useLayoutEffect(()=>{typeof o=="string"&&q.current&&oe(q.current.scrollHeight)},[o]);const P=t.useMemo(()=>typeof o=="string"?`${o} `.split(`
2
- `):[],[o]),ce=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]),le=t.useCallback(()=>{typeof o=="string"&&(Q.default(o),H({type:"success",children:"Copied to clipboard."}))},[o,H]),v=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 me=new Event("input",{bubbles:!0});n.dispatchEvent(me),n.focus();return}}throw new Error("Unable to set value.")},[]),ie=t.useCallback(()=>{v("")},[v]),[ue,xe]=t.useState(""),G=!!a&&ue!==a,pe=t.useCallback(()=>{if(a){try{v(a)}catch{Q.default(a)}xe(a)}},[a,v]),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(ke.default,{isCollapsed:!G,children:G?e.jsxRuntimeExports.jsxs("button",{type:"button",className:r.cx(M.buttonResetStyles,M.overflowProtectionStyles,"kakadu-components-4141839293"),onClick:pe,children:[e.jsxRuntimeExports.jsx(je.default,{label:"Apply suggestion"}),e.jsxRuntimeExports.jsx(de.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(${ge*((j?1:0)+(k?1:0)+U)}px + 6px)`},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:r.cx(N,f,"kakadu-components-2033521835"),children:[P.map((s,n)=>e.jsxRuntimeExports.jsxs("span",{children:[s,ce>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:r.cx(N,f,"kakadu-components-2119524139"),style:{minHeight:ae},onChange:D})]}):e.jsxRuntimeExports.jsx("input",{...b,ref:$,type:c??"text",value:o,"aria-invalid":y,"data-warning":_,"data-information":w,"aria-describedby":z,className:r.cx(N,f),onChange:D}),se?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:le}):null,k?e.jsxRuntimeExports.jsx(B.default,{iconLeft:"times",label:"Clear",tooltip:"Clear",className:L,onClick:ie}):null]}):null,R]})}exports.InputAttachment=ee;exports.InputLabel=te;exports.default=ye;exports.errorParagraph=Z;exports.inputStyles=N;
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;