@kakadu/components 4.3.1 → 4.3.2

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