@kakadu/components 4.3.0 → 4.3.1

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.
@@ -19,7 +19,10 @@ export type ComboboxProperties<Type = string> = Omit<InputLabelControllerPropert
19
19
  readonly isLoading?: boolean;
20
20
  readonly value?: Type;
21
21
  readonly options: Array<ComboboxOption<Type>>;
22
+ /** If `false`, `options` is assumed to be sorted and filtered based on the current search value (eg. by the server).
23
+ * @default true */
24
+ readonly shouldFilterOptions?: boolean;
22
25
  readonly onChange?: (value: string, event?: ChangeEvent<InputType>) => void;
23
26
  readonly onSelect?: (value?: Type) => void;
24
27
  };
25
- export default function Combobox<Type = string>({ isLoading, label, options, error, warning, information, footnote, className, onChange, onSelect, ...properties }: ComboboxProperties<Type>): import("react/jsx-runtime").JSX.Element;
28
+ export default function Combobox<Type = string>({ isLoading, shouldFilterOptions, label, options, error, warning, information, footnote, className, onChange, onSelect, ...properties }: ComboboxProperties<Type>): import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("../jsx-runtime-BB_1_6y_.js"),e=require("react"),K=require("@kuma-ui/core"),te=require("../hooks/use-synchronized-value.js"),se=require("../icons/icon.js"),ne=require("../icons/chevron-up.js"),oe=require("../utilities/search.js"),re=require("./input.js"),B=require("./text.js"),U=require("./flex.js"),ae=require("./skeleton.js");function X(){const{value:o,setValue:p}=te.default("isKeyboardNavigating");return e.useMemo(()=>({isKeyboardNavigating:o,setIsKeyboardNavigating:p}),[o,p])}function _(o){return"text"in o?o.text:o.label}const D="kakadu-components-1144794361",F="kakadu-components-2911184744";function ue({isSelected:o,id:p,value:i,label:k,onSelect:v,onHover:E}){const{isKeyboardNavigating:f}=X(),j=e.useCallback(()=>{v(i)},[v,i]),n=e.useCallback(b=>{f||b.movementX===0&&b.movementY===0||E(i)},[f,E,i]),x=e.useRef(null);return e.useEffect(()=>{const b=x.current;o&&b&&f&&setTimeout(()=>{b.scrollIntoView({behavior:"smooth",block:"nearest"})},0)},[o,f]),c.jsxRuntimeExports.jsx("li",{ref:x,id:p,role:"option","aria-selected":o,tabIndex:-1,className:K.cx(D,"kakadu-components-4130497639",f?"kakadu-components-962373561":"kakadu-components-1109598791"),onClick:j,onMouseMove:n,children:c.jsxRuntimeExports.jsx(B.Span,{className:K.cx(F,typeof k=="string"&&"kakadu-components-154286052"),children:k})})}function ce({isLoading:o,id:p,activeOptionId:i,selectedValue:k,options:v,onSelect:E,onHover:f}){const j=e.useRef(null);return e.useEffect(()=>{const n=j.current;n&&n.scrollIntoView({behavior:"smooth",block:"nearest"})},[]),c.jsxRuntimeExports.jsxs("ul",{ref:j,id:p,role:"listbox","aria-label":"Options",tabIndex:-1,className:"kakadu-components-1951042708",children:[v.length===0?o?null:c.jsxRuntimeExports.jsxs(U.default,{"aria-atomic":!0,as:"li",role:"status","aria-live":"polite",direction:"row",preset:"start",gap:.5,className:D,children:[c.jsxRuntimeExports.jsx(se.default,{size:15,type:"exclamationTriangle"}),c.jsxRuntimeExports.jsx(B.Span,{className:F,children:"No results."})]}):v.map((n,x)=>c.jsxRuntimeExports.jsx(ue,{...n,id:n.value===k?i:void 0,isSelected:n.value===k,onSelect:E,onHover:f},_(n)+x)),o?c.jsxRuntimeExports.jsx(U.default,{as:"li",alignment:"center",className:D,children:c.jsxRuntimeExports.jsx(B.Span,{className:F,children:c.jsxRuntimeExports.jsx(ae.SkeletonInstance,{width:"100%",height:"1.3em"})})}):null]})}function ie({isLoading:o,label:p,options:i,error:k,warning:v,information:E,footnote:f,className:j,onChange:n,onSelect:x,...b}){const O=e.useRef(null),T=e.useId(),H=e.useId(),[g,M]=e.useState(!1),Y=e.useCallback(()=>{M(!0)},[]),$=e.useCallback(t=>{var s;(s=O.current)!=null&&s.contains(t.relatedTarget)||M(!1)},[]),[I,a]=e.useState(!1);e.useEffect(()=>{a(g)},[g]);const[P,V]=e.useState(""),{value:R}=b,[d,y]=e.useState(R),[S,G]=e.useState(R),A=e.useRef(S),u=e.useCallback(t=>{G(t),A.current=t},[]);e.useEffect(()=>{y(R),u(R)},[R,u]);const J=e.useCallback(()=>{d&&(V(""),u(void 0))},[d,u]),Q=e.useCallback((t,s)=>{V(t),n==null||n(t,s),a(!0),y(void 0)},[n]),W=e.useCallback(t=>{var s;(s=O.current)!=null&&s.contains(t.target)&&a(!0)},[]),h=e.useCallback(t=>{const s=t==null?void 0:t.value;u(s),t?V(_(t)):(V(""),n==null||n("")),x==null||x(s)},[u,n,x]),Z=e.useCallback(t=>{const s=i.find(m=>m.value===t);h(s),y(t),a(!1)},[i,h]),ee=e.useCallback(t=>{u(t)},[u]),q=e.useDeferredValue(P),l=e.useMemo(()=>d?i:oe.default(q,i,_),[d,i,q]);e.useEffect(()=>{!d&&q.length>0&&l.length>0&&!l.some(t=>S===t.value)&&u(l[0].value)},[d,q,l,S,u]);const{setIsKeyboardNavigating:N}=X();return e.useEffect(()=>{if(!g)return;const t=s=>{s.movementX===0&&s.movementY===0||N(!1)};return window.addEventListener("mousemove",t,{capture:!0}),()=>{window.removeEventListener("mousemove",t,{capture:!0})}},[g,N]),e.useEffect(()=>{if(!g)return;const t=s=>{var z;let m;const C=l.length,L=l.findIndex(r=>r.value===A.current),w=()=>{s.preventDefault(),s.stopPropagation(),s.stopImmediatePropagation()};switch(s.key){case"Enter":{const r=l[L];r&&(w(),N(!0),a(!1),h(r),y(r.value));break}case"Escape":{if(I)w(),d?u(void 0):h(void 0),a(!1);else if(d)w(),a(!0),h(void 0);else{w(),M(!1);const r=document.activeElement;r instanceof HTMLElement&&((z=O.current)!=null&&z.contains(r))&&r.blur()}return}case"ArrowDown":{m=L+1,a(!0);break}case"ArrowUp":{m=L-1,a(!0),m<0&&(m=C-1);break}case"Home":{a(!0),m=0;break}case"End":{a(!0),m=C-1;break}case"Backspace":{l.some(r=>r.value===d)&&(w(),h(void 0),a(!0));break}}if(m!==void 0&&(w(),N(!0),C>0)){const r=l[m%C];r&&u(r.value)}};return window.addEventListener("keydown",t,{capture:!0}),()=>{window.removeEventListener("keydown",t,{capture:!0})}},[g,l,N,a,h,y,I,d,u]),c.jsxRuntimeExports.jsx(re.default,{...b,ref:O,role:"combobox",autoComplete:"off","aria-controls":T,"aria-expanded":I,"aria-activedescendant":I?H:void 0,label:p,value:P,error:k,warning:v,information:E,footnote:f,attachments:I?c.jsxRuntimeExports.jsx(ce,{isLoading:o,id:T,activeOptionId:H,selectedValue:S,options:l,onSelect:Z,onHover:ee}):null,className:K.cx(j,"kakadu-components-879486679"),onMouseDown:W,onChange:Q,onBeforeInput:J,onFocus:Y,onBlur:$,children:c.jsxRuntimeExports.jsx(ne.default,{width:14,height:14,className:"kakadu-components-158931186"})})}exports.default=ie;exports.getComboboxOptionString=_;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("../jsx-runtime-BB_1_6y_.js"),e=require("react"),K=require("@kuma-ui/core"),se=require("../hooks/use-synchronized-value.js"),ne=require("../icons/icon.js"),oe=require("../icons/chevron-up.js"),re=require("../utilities/search.js"),ae=require("./input.js"),B=require("./text.js"),X=require("./flex.js"),ue=require("./skeleton.js");function Y(){const{value:n,setValue:p}=se.default("isKeyboardNavigating");return e.useMemo(()=>({isKeyboardNavigating:n,setIsKeyboardNavigating:p}),[n,p])}function _(n){return"text"in n?n.text:n.label}const D="kakadu-components-1144794361",T="kakadu-components-2911184744";function ce({isSelected:n,id:p,value:k,label:i,onSelect:v,onHover:E}){const{isKeyboardNavigating:b}=Y(),j=e.useCallback(()=>{v(k)},[v,k]),l=e.useCallback(m=>{b||m.movementX===0&&m.movementY===0||E(k)},[b,E,k]),r=e.useRef(null);return e.useEffect(()=>{const m=r.current;n&&m&&b&&setTimeout(()=>{m.scrollIntoView({behavior:"smooth",block:"nearest"})},0)},[n,b]),c.jsxRuntimeExports.jsx("li",{ref:r,id:p,role:"option","aria-selected":n,tabIndex:-1,className:K.cx(D,"kakadu-components-4130497639",b?"kakadu-components-962373561":"kakadu-components-1109598791"),onClick:j,onMouseMove:l,children:c.jsxRuntimeExports.jsx(B.Span,{className:K.cx(T,typeof i=="string"&&"kakadu-components-154286052"),children:i})})}function ie({isLoading:n,id:p,activeOptionId:k,selectedValue:i,options:v,onSelect:E,onHover:b}){const j=e.useRef(null);return e.useEffect(()=>{const l=j.current;l&&l.scrollIntoView({behavior:"smooth",block:"nearest"})},[]),c.jsxRuntimeExports.jsxs("ul",{ref:j,id:p,role:"listbox","aria-label":"Options",tabIndex:-1,className:"kakadu-components-1951042708",children:[v.length===0?n?null:c.jsxRuntimeExports.jsxs(X.default,{"aria-atomic":!0,as:"li",role:"status","aria-live":"polite",direction:"row",preset:"start",gap:.5,className:D,children:[c.jsxRuntimeExports.jsx(ne.default,{size:15,type:"exclamationTriangle"}),c.jsxRuntimeExports.jsx(B.Span,{className:T,children:"No results."})]}):v.map((l,r)=>c.jsxRuntimeExports.jsx(ce,{...l,id:l.value===i?k:void 0,isSelected:l.value===i,onSelect:E,onHover:b},_(l)+r)),n?c.jsxRuntimeExports.jsx(X.default,{as:"li",alignment:"center",className:D,children:c.jsxRuntimeExports.jsx(B.Span,{className:T,children:c.jsxRuntimeExports.jsx(ue.SkeletonInstance,{width:"100%",height:"1.3em"})})}):null]})}function le({isLoading:n,shouldFilterOptions:p=!0,label:k,options:i,error:v,warning:E,information:b,footnote:j,className:l,onChange:r,onSelect:m,...F}){const V=e.useRef(null),H=e.useId(),P=e.useId(),[g,M]=e.useState(!1),$=e.useCallback(()=>{M(!0)},[]),G=e.useCallback(t=>{var s;(s=V.current)!=null&&s.contains(t.relatedTarget)||M(!1)},[]),[I,a]=e.useState(!1);e.useEffect(()=>{a(g)},[g]);const[A,O]=e.useState(""),{value:R}=F,[f,y]=e.useState(R),[S,J]=e.useState(R),z=e.useRef(S),u=e.useCallback(t=>{J(t),z.current=t},[]);e.useEffect(()=>{y(R),u(R)},[R,u]);const Q=e.useCallback(()=>{f&&(O(""),u(void 0))},[f,u]),W=e.useCallback((t,s)=>{O(t),r==null||r(t,s),a(!0),y(void 0)},[r]),Z=e.useCallback(t=>{var s;(s=V.current)!=null&&s.contains(t.target)&&a(!0)},[]),h=e.useCallback(t=>{const s=t==null?void 0:t.value;u(s),t?O(_(t)):(O(""),r==null||r("")),m==null||m(s)},[u,r,m]),ee=e.useCallback(t=>{const s=i.find(x=>x.value===t);h(s),y(t),a(!1)},[i,h]),te=e.useCallback(t=>{u(t)},[u]),q=e.useDeferredValue(A),d=e.useMemo(()=>!p||f?i:re.default(q,i,_),[p,f,i,q]);e.useEffect(()=>{!f&&q.length>0&&d.length>0&&!d.some(t=>S===t.value)&&u(d[0].value)},[f,q,d,S,u]);const{setIsKeyboardNavigating:N}=Y();return e.useEffect(()=>{if(!g)return;const t=s=>{s.movementX===0&&s.movementY===0||N(!1)};return window.addEventListener("mousemove",t,{capture:!0}),()=>{window.removeEventListener("mousemove",t,{capture:!0})}},[g,N]),e.useEffect(()=>{if(!g)return;const t=s=>{var U;let x;const C=d.length,L=d.findIndex(o=>o.value===z.current),w=()=>{s.preventDefault(),s.stopPropagation(),s.stopImmediatePropagation()};switch(s.key){case"Enter":{const o=d[L];o&&(w(),N(!0),a(!1),h(o),y(o.value));break}case"Escape":{if(I)w(),f?u(void 0):h(void 0),a(!1);else if(f)w(),a(!0),h(void 0);else{w(),M(!1);const o=document.activeElement;o instanceof HTMLElement&&((U=V.current)!=null&&U.contains(o))&&o.blur()}return}case"ArrowDown":{x=L+1,a(!0);break}case"ArrowUp":{x=L-1,a(!0),x<0&&(x=C-1);break}case"Home":{a(!0),x=0;break}case"End":{a(!0),x=C-1;break}case"Backspace":{d.some(o=>o.value===f)&&(w(),h(void 0),a(!0));break}}if(x!==void 0&&(w(),N(!0),C>0)){const o=d[x%C];o&&u(o.value)}};return window.addEventListener("keydown",t,{capture:!0}),()=>{window.removeEventListener("keydown",t,{capture:!0})}},[g,d,N,a,h,y,I,f,u]),c.jsxRuntimeExports.jsx(ae.default,{...F,ref:V,role:"combobox",autoComplete:"off","aria-controls":H,"aria-expanded":I,"aria-activedescendant":I?P:void 0,label:k,value:A,error:v,warning:E,information:b,footnote:j,attachments:I?c.jsxRuntimeExports.jsx(ie,{isLoading:n,id:H,activeOptionId:P,selectedValue:S,options:d,onSelect:ee,onHover:te}):null,className:K.cx(l,"kakadu-components-879486679"),onMouseDown:Z,onChange:W,onBeforeInput:Q,onFocus:$,onBlur:G,children:c.jsxRuntimeExports.jsx(oe.default,{width:14,height:14,className:"kakadu-components-158931186"})})}exports.default=le;exports.getComboboxOptionString=_;
@@ -1,139 +1,140 @@
1
1
  import { j as c } from "../jsx-runtime-B4hRZ52C.mjs";
2
- import { useRef as D, useId as J, useState as L, useCallback as u, useEffect as w, useDeferredValue as ae, useMemo as W } from "react";
2
+ import { useRef as F, useId as Q, useState as L, useCallback as m, useEffect as w, useDeferredValue as ce, useMemo as Z } from "react";
3
3
  import { cx as A } from "@kuma-ui/core";
4
- import ce from "../hooks/use-synchronized-value.mjs";
5
- import ie from "../icons/icon.mjs";
6
- import le from "../icons/chevron-up.mjs";
7
- import ue from "../utilities/search.mjs";
8
- import me from "./input.mjs";
4
+ import ie from "../hooks/use-synchronized-value.mjs";
5
+ import le from "../icons/icon.mjs";
6
+ import ue from "../icons/chevron-up.mjs";
7
+ import me from "../utilities/search.mjs";
8
+ import de from "./input.mjs";
9
9
  import { Span as P } from "./text.mjs";
10
- import Q from "./flex.mjs";
11
- import { SkeletonInstance as de } from "./skeleton.mjs";
12
- function Z() {
10
+ import W from "./flex.mjs";
11
+ import { SkeletonInstance as fe } from "./skeleton.mjs";
12
+ function _() {
13
13
  const {
14
- value: s,
14
+ value: n,
15
15
  setValue: v
16
- } = ce("isKeyboardNavigating");
17
- return W(() => ({
18
- isKeyboardNavigating: s,
16
+ } = ie("isKeyboardNavigating");
17
+ return Z(() => ({
18
+ isKeyboardNavigating: n,
19
19
  setIsKeyboardNavigating: v
20
- }), [s, v]);
20
+ }), [n, v]);
21
21
  }
22
- function R(s) {
23
- return "text" in s ? s.text : s.label;
22
+ function R(n) {
23
+ return "text" in n ? n.text : n.label;
24
24
  }
25
25
  const z = "kakadu-components-1144794361", U = "kakadu-components-2911184744";
26
- function fe({
27
- isSelected: s,
26
+ function pe({
27
+ isSelected: n,
28
28
  id: v,
29
- value: i,
30
- label: x,
29
+ value: x,
30
+ label: i,
31
31
  onSelect: k,
32
32
  onHover: I
33
33
  }) {
34
34
  const {
35
- isKeyboardNavigating: f
36
- } = Z(), g = u(() => {
37
- k(i);
38
- }, [k, i]), n = u((b) => {
39
- f || b.movementX === 0 && b.movementY === 0 || I(i);
40
- }, [f, I, i]), p = D(null);
35
+ isKeyboardNavigating: b
36
+ } = _(), g = m(() => {
37
+ k(x);
38
+ }, [k, x]), l = m((d) => {
39
+ b || d.movementX === 0 && d.movementY === 0 || I(x);
40
+ }, [b, I, x]), o = F(null);
41
41
  return w(() => {
42
- const b = p.current;
43
- s && b && f && setTimeout(() => {
44
- b.scrollIntoView({
42
+ const d = o.current;
43
+ n && d && b && setTimeout(() => {
44
+ d.scrollIntoView({
45
45
  behavior: "smooth",
46
46
  block: "nearest"
47
47
  });
48
48
  }, 0);
49
- }, [s, f]), /* @__PURE__ */ c.jsx("li", { ref: p, id: v, role: "option", "aria-selected": s, tabIndex: -1, className: A(z, "kakadu-components-4130497639", f ? "kakadu-components-962373561" : "kakadu-components-1109598791"), onClick: g, onMouseMove: n, children: /* @__PURE__ */ c.jsx(P, { className: A(U, typeof x == "string" && "kakadu-components-154286052"), children: x }) });
49
+ }, [n, b]), /* @__PURE__ */ c.jsx("li", { ref: o, id: v, role: "option", "aria-selected": n, tabIndex: -1, className: A(z, "kakadu-components-4130497639", b ? "kakadu-components-962373561" : "kakadu-components-1109598791"), onClick: g, onMouseMove: l, children: /* @__PURE__ */ c.jsx(P, { className: A(U, typeof i == "string" && "kakadu-components-154286052"), children: i }) });
50
50
  }
51
- function pe({
52
- isLoading: s,
51
+ function ve({
52
+ isLoading: n,
53
53
  id: v,
54
- activeOptionId: i,
55
- selectedValue: x,
54
+ activeOptionId: x,
55
+ selectedValue: i,
56
56
  options: k,
57
57
  onSelect: I,
58
- onHover: f
58
+ onHover: b
59
59
  }) {
60
- const g = D(null);
60
+ const g = F(null);
61
61
  return w(() => {
62
- const n = g.current;
63
- n && n.scrollIntoView({
62
+ const l = g.current;
63
+ l && l.scrollIntoView({
64
64
  behavior: "smooth",
65
65
  block: "nearest"
66
66
  });
67
67
  }, []), /* @__PURE__ */ c.jsxs("ul", { ref: g, id: v, role: "listbox", "aria-label": "Options", tabIndex: -1, className: "kakadu-components-1951042708", children: [
68
- k.length === 0 ? s ? null : /* @__PURE__ */ c.jsxs(Q, { "aria-atomic": !0, as: "li", role: "status", "aria-live": "polite", direction: "row", preset: "start", gap: 0.5, className: z, children: [
69
- /* @__PURE__ */ c.jsx(ie, { size: 15, type: "exclamationTriangle" }),
68
+ k.length === 0 ? n ? null : /* @__PURE__ */ c.jsxs(W, { "aria-atomic": !0, as: "li", role: "status", "aria-live": "polite", direction: "row", preset: "start", gap: 0.5, className: z, children: [
69
+ /* @__PURE__ */ c.jsx(le, { size: 15, type: "exclamationTriangle" }),
70
70
  /* @__PURE__ */ c.jsx(P, { className: U, children: "No results." })
71
- ] }) : k.map((n, p) => /* @__PURE__ */ c.jsx(
72
- fe,
71
+ ] }) : k.map((l, o) => /* @__PURE__ */ c.jsx(
72
+ pe,
73
73
  {
74
- ...n,
75
- id: n.value === x ? i : void 0,
76
- isSelected: n.value === x,
74
+ ...l,
75
+ id: l.value === i ? x : void 0,
76
+ isSelected: l.value === i,
77
77
  onSelect: I,
78
- onHover: f
78
+ onHover: b
79
79
  },
80
- R(n) + p
80
+ R(l) + o
81
81
  )),
82
- s ? /* @__PURE__ */ c.jsx(Q, { as: "li", alignment: "center", className: z, children: /* @__PURE__ */ c.jsx(P, { className: U, children: /* @__PURE__ */ c.jsx(de, { width: "100%", height: "1.3em" }) }) }) : null
82
+ n ? /* @__PURE__ */ c.jsx(W, { as: "li", alignment: "center", className: z, children: /* @__PURE__ */ c.jsx(P, { className: U, children: /* @__PURE__ */ c.jsx(fe, { width: "100%", height: "1.3em" }) }) }) : null
83
83
  ] });
84
84
  }
85
- function ye({
86
- isLoading: s,
87
- label: v,
85
+ function Oe({
86
+ isLoading: n,
87
+ shouldFilterOptions: v = !0,
88
+ label: x,
88
89
  options: i,
89
- error: x,
90
- warning: k,
91
- information: I,
92
- footnote: f,
93
- className: g,
94
- onChange: n,
95
- onSelect: p,
96
- ...b
90
+ error: k,
91
+ warning: I,
92
+ information: b,
93
+ footnote: g,
94
+ className: l,
95
+ onChange: o,
96
+ onSelect: d,
97
+ ...X
97
98
  }) {
98
- const F = D(null), X = J(), Y = J(), [N, H] = L(!1), _ = u(() => {
99
+ const K = F(null), Y = Q(), q = Q(), [N, H] = L(!1), $ = m(() => {
99
100
  H(!0);
100
- }, []), $ = u((e) => {
101
+ }, []), ee = m((e) => {
101
102
  var t;
102
- (t = F.current) != null && t.contains(e.relatedTarget) || H(!1);
103
+ (t = K.current) != null && t.contains(e.relatedTarget) || H(!1);
103
104
  }, []), [j, r] = L(!1);
104
105
  w(() => {
105
106
  r(N);
106
107
  }, [N]);
107
- const [q, K] = L(""), {
108
+ const [C, M] = L(""), {
108
109
  value: y
109
- } = b, [m, O] = L(y), [M, ee] = L(y), C = D(M), a = u((e) => {
110
- ee(e), C.current = e;
110
+ } = X, [f, O] = L(y), [S, te] = L(y), G = F(S), a = m((e) => {
111
+ te(e), G.current = e;
111
112
  }, []);
112
113
  w(() => {
113
114
  O(y), a(y);
114
115
  }, [y, a]);
115
- const te = u(() => {
116
- m && (K(""), a(void 0));
117
- }, [m, a]), ne = u((e, t) => {
118
- K(e), n == null || n(e, t), r(!0), O(void 0);
119
- }, [n]), se = u((e) => {
116
+ const ne = m(() => {
117
+ f && (M(""), a(void 0));
118
+ }, [f, a]), se = m((e, t) => {
119
+ M(e), o == null || o(e, t), r(!0), O(void 0);
120
+ }, [o]), oe = m((e) => {
120
121
  var t;
121
- (t = F.current) != null && t.contains(e.target) && r(!0);
122
- }, []), h = u((e) => {
122
+ (t = K.current) != null && t.contains(e.target) && r(!0);
123
+ }, []), h = m((e) => {
123
124
  const t = e == null ? void 0 : e.value;
124
- a(t), e ? K(R(e)) : (K(""), n == null || n("")), p == null || p(t);
125
- }, [a, n, p]), oe = u((e) => {
126
- const t = i.find((d) => d.value === e);
125
+ a(t), e ? M(R(e)) : (M(""), o == null || o("")), d == null || d(t);
126
+ }, [a, o, d]), re = m((e) => {
127
+ const t = i.find((p) => p.value === e);
127
128
  h(t), O(e), r(!1);
128
- }, [i, h]), re = u((e) => {
129
+ }, [i, h]), ae = m((e) => {
129
130
  a(e);
130
- }, [a]), S = ae(q), l = W(() => m ? i : ue(S, i, R), [m, i, S]);
131
+ }, [a]), B = ce(C), u = Z(() => !v || f ? i : me(B, i, R), [v, f, i, B]);
131
132
  w(() => {
132
- !m && S.length > 0 && l.length > 0 && !l.some((e) => M === e.value) && a(l[0].value);
133
- }, [m, S, l, M, a]);
133
+ !f && B.length > 0 && u.length > 0 && !u.some((e) => S === e.value) && a(u[0].value);
134
+ }, [f, B, u, S, a]);
134
135
  const {
135
136
  setIsKeyboardNavigating: E
136
- } = Z();
137
+ } = _();
137
138
  return w(() => {
138
139
  if (!N)
139
140
  return;
@@ -151,53 +152,53 @@ function ye({
151
152
  if (!N)
152
153
  return;
153
154
  const e = (t) => {
154
- var G;
155
- let d;
156
- const B = l.length, T = l.findIndex((o) => o.value === C.current), V = () => {
155
+ var J;
156
+ let p;
157
+ const D = u.length, T = u.findIndex((s) => s.value === G.current), V = () => {
157
158
  t.preventDefault(), t.stopPropagation(), t.stopImmediatePropagation();
158
159
  };
159
160
  switch (t.key) {
160
161
  case "Enter": {
161
- const o = l[T];
162
- o && (V(), E(!0), r(!1), h(o), O(o.value));
162
+ const s = u[T];
163
+ s && (V(), E(!0), r(!1), h(s), O(s.value));
163
164
  break;
164
165
  }
165
166
  case "Escape": {
166
167
  if (j)
167
- V(), m ? a(void 0) : h(void 0), r(!1);
168
- else if (m)
168
+ V(), f ? a(void 0) : h(void 0), r(!1);
169
+ else if (f)
169
170
  V(), r(!0), h(void 0);
170
171
  else {
171
172
  V(), H(!1);
172
- const o = document.activeElement;
173
- o instanceof HTMLElement && ((G = F.current) != null && G.contains(o)) && o.blur();
173
+ const s = document.activeElement;
174
+ s instanceof HTMLElement && ((J = K.current) != null && J.contains(s)) && s.blur();
174
175
  }
175
176
  return;
176
177
  }
177
178
  case "ArrowDown": {
178
- d = T + 1, r(!0);
179
+ p = T + 1, r(!0);
179
180
  break;
180
181
  }
181
182
  case "ArrowUp": {
182
- d = T - 1, r(!0), d < 0 && (d = B - 1);
183
+ p = T - 1, r(!0), p < 0 && (p = D - 1);
183
184
  break;
184
185
  }
185
186
  case "Home": {
186
- r(!0), d = 0;
187
+ r(!0), p = 0;
187
188
  break;
188
189
  }
189
190
  case "End": {
190
- r(!0), d = B - 1;
191
+ r(!0), p = D - 1;
191
192
  break;
192
193
  }
193
194
  case "Backspace": {
194
- l.some((o) => o.value === m) && (V(), h(void 0), r(!0));
195
+ u.some((s) => s.value === f) && (V(), h(void 0), r(!0));
195
196
  break;
196
197
  }
197
198
  }
198
- if (d !== void 0 && (V(), E(!0), B > 0)) {
199
- const o = l[d % B];
200
- o && a(o.value);
199
+ if (p !== void 0 && (V(), E(!0), D > 0)) {
200
+ const s = u[p % D];
201
+ s && a(s.value);
201
202
  }
202
203
  };
203
204
  return window.addEventListener("keydown", e, {
@@ -207,9 +208,9 @@ function ye({
207
208
  capture: !0
208
209
  });
209
210
  };
210
- }, [N, l, E, r, h, O, j, m, a]), /* @__PURE__ */ c.jsx(me, { ...b, ref: F, role: "combobox", autoComplete: "off", "aria-controls": X, "aria-expanded": j, "aria-activedescendant": j ? Y : void 0, label: v, value: q, error: x, warning: k, information: I, footnote: f, attachments: j ? /* @__PURE__ */ c.jsx(pe, { isLoading: s, id: X, activeOptionId: Y, selectedValue: M, options: l, onSelect: oe, onHover: re }) : null, className: A(g, "kakadu-components-879486679"), onMouseDown: se, onChange: ne, onBeforeInput: te, onFocus: _, onBlur: $, children: /* @__PURE__ */ c.jsx(le, { width: 14, height: 14, className: "kakadu-components-158931186" }) });
211
+ }, [N, u, E, r, h, O, j, f, a]), /* @__PURE__ */ c.jsx(de, { ...X, ref: K, role: "combobox", autoComplete: "off", "aria-controls": Y, "aria-expanded": j, "aria-activedescendant": j ? q : void 0, label: x, value: C, error: k, warning: I, information: b, footnote: g, attachments: j ? /* @__PURE__ */ c.jsx(ve, { isLoading: n, id: Y, activeOptionId: q, selectedValue: S, options: u, onSelect: re, onHover: ae }) : null, className: A(l, "kakadu-components-879486679"), onMouseDown: oe, onChange: se, onBeforeInput: ne, onFocus: $, onBlur: ee, children: /* @__PURE__ */ c.jsx(ue, { width: 14, height: 14, className: "kakadu-components-158931186" }) });
211
212
  }
212
213
  export {
213
- ye as default,
214
+ Oe as default,
214
215
  R as getComboboxOptionString
215
216
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kakadu/components",
3
- "version": "4.3.0",
3
+ "version": "4.3.1",
4
4
  "description": "Kakadu components library",
5
5
  "license": "MIT",
6
6
  "main": "./build/index.js",