@kakadu/components 6.3.13 → 6.3.14

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