@kakadu/components 4.0.2 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/combobox.js +1 -1
- package/build/components/combobox.mjs +163 -161
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const j=require("../jsx-runtime-BB_1_6y_.js"),o=require("react"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const j=require("../jsx-runtime-BB_1_6y_.js"),o=require("react"),H=require("../focus-trap-react-CkKg4ubd.js"),X=require("@kuma-ui/core"),re=require("../use-synchronized-value-D0_rS5Wp.js"),ae=require("../icons/icon.js"),ce=require("./input.js"),$=require("./text.js"),Y=require("./flex.js"),ie=require("./skeleton.js");var z={exports:{}};const M=new Uint32Array(65536),le=(t,c)=>{const r=t.length,p=c.length,i=1<<r-1;let l=-1,f=0,x=r,n=r;for(;n--;)M[t.charCodeAt(n)]|=1<<n;for(n=0;n<p;n++){let m=M[c.charCodeAt(n)];const v=m|f;m|=(m&l)+l^l,f|=~(m|l),l&=m,f&i&&x++,l&i&&x--,f=f<<1|1,l=l<<1|~(v|f),f&=v}for(n=r;n--;)M[t.charCodeAt(n)]=0;return x},ue=(t,c)=>{const r=c.length,p=t.length,i=[],l=[],f=Math.ceil(r/32),x=Math.ceil(p/32);for(let e=0;e<f;e++)l[e]=-1,i[e]=0;let n=0;for(;n<x-1;n++){let e=0,u=-1;const b=n*32,g=Math.min(32,p)+b;for(let s=b;s<g;s++)M[t.charCodeAt(s)]|=1<<s;for(let s=0;s<r;s++){const h=M[c.charCodeAt(s)],k=l[s/32|0]>>>s&1,w=i[s/32|0]>>>s&1,N=h|e,E=((h|w)&u)+u^u|h|w;let O=e|~(E|u),A=u&E;O>>>31^k&&(l[s/32|0]^=1<<s),A>>>31^w&&(i[s/32|0]^=1<<s),O=O<<1|k,A=A<<1|w,u=A|~(N|O),e=O&N}for(let s=b;s<g;s++)M[t.charCodeAt(s)]=0}let m=0,v=-1;const R=n*32,C=Math.min(32,p-R)+R;for(let e=R;e<C;e++)M[t.charCodeAt(e)]|=1<<e;let q=p;for(let e=0;e<r;e++){const u=M[c.charCodeAt(e)],b=l[e/32|0]>>>e&1,g=i[e/32|0]>>>e&1,s=u|m,h=((u|g)&v)+v^v|u|g;let k=m|~(h|v),w=v&h;q+=k>>>p-1&1,q-=w>>>p-1&1,k>>>31^b&&(l[e/32|0]^=1<<e),w>>>31^g&&(i[e/32|0]^=1<<e),k=k<<1|b,w=w<<1|g,v=w|~(s|k),m=k&s}for(let e=R;e<C;e++)M[t.charCodeAt(e)]=0;return q},J=(t,c)=>{if(t.length<c.length){const r=c;c=t,t=r}return c.length===0?t.length:t.length<=32?le(t,c):ue(t,c)},fe=(t,c)=>{let r=1/0,p=0;for(let i=0;i<c.length;i++){const l=J(t,c[i]);l<r&&(r=l,p=i)}return c[p]},de=Object.freeze(Object.defineProperty({__proto__:null,closest:fe,distance:J},Symbol.toStringTag,{value:"Module"})),me=H.getAugmentedNamespace(de);var G;function pe(){return G||(G=1,(function(t,c){(function(){var r;try{r=typeof Intl<"u"&&typeof Intl.Collator<"u"?Intl.Collator("generic",{sensitivity:"base"}):null}catch{console.log("Collator could not be initialized and wouldn't be used")}var p=me,i=[],l=[],f={get:function(x,n,m){var v=m&&r&&m.useCollator;if(v){var R=x.length,C=n.length;if(R===0)return C;if(C===0)return R;var q,e,u,b,g;for(u=0;u<C;++u)i[u]=u,l[u]=n.charCodeAt(u);i[C]=C;var s;for(u=0;u<R;++u){for(e=u+1,b=0;b<C;++b)q=e,s=r.compare(x.charAt(u),String.fromCharCode(l[b]))===0,e=i[b]+(s?0:1),g=q+1,e>g&&(e=g),g=i[b+1]+1,e>g&&(e=g),i[b]=q;i[b]=e}return e}return p.distance(x,n)}};t!==null&&t.exports===c?t.exports=f:typeof self<"u"&&typeof self.postMessage=="function"&&typeof self.importScripts=="function"?self.Levenshtein=f:typeof window<"u"&&window!==null&&(window.Levenshtein=f)})()})(z,z.exports)),z.exports}var ve=pe();const he=H.getDefaultExportFromCjs(ve);function Q(){const{value:t,setValue:c}=re.useSynchronizedValue("isKeyboardNavigating");return o.useMemo(()=>({isKeyboardNavigating:t,setIsKeyboardNavigating:c}),[t,c])}function L(t){return"text"in t?t.text:t.label}const B="kakadu-components-1144794361",P="kakadu-components-2911184744";function xe({isSelected:t,id:c,value:r,label:p,onSelect:i,onHover:l}){const{isKeyboardNavigating:f}=Q(),x=o.useCallback(()=>{i(r)},[i,r]),n=o.useCallback(v=>{f||v.movementX===0&&v.movementY===0||l(r)},[f,l,r]),m=o.useRef(null);return o.useEffect(()=>{const v=m.current;t&&v&&f&&setTimeout(()=>{v.scrollIntoView({behavior:"smooth",block:"nearest"})},0)},[t,f]),j.jsxRuntimeExports.jsx("li",{ref:m,id:c,role:"option","aria-selected":t,tabIndex:-1,className:X.cx(B,"kakadu-components-4130497639",f?"kakadu-components-962373561":"kakadu-components-1109598791"),onClick:x,onMouseMove:n,children:j.jsxRuntimeExports.jsx($.Span,{className:X.cx(P,typeof p=="string"&&"kakadu-components-154286052"),children:p})})}function be({isLoading:t,id:c,activeOptionId:r,selectedValue:p,options:i,onSelect:l,onHover:f}){const x=o.useRef(null);return o.useEffect(()=>{const n=x.current;n&&n.scrollIntoView({behavior:"smooth",block:"nearest"})},[]),j.jsxRuntimeExports.jsxs("ul",{ref:x,id:c,role:"listbox","aria-label":"Options",className:"kakadu-components-1951042708",children:[i.length===0?t?null:j.jsxRuntimeExports.jsxs(Y.default,{"aria-atomic":!0,as:"li",role:"status","aria-live":"polite",direction:"row",preset:"start",gap:.5,className:B,children:[j.jsxRuntimeExports.jsx(ae.default,{size:15,type:"exclamationTriangle"}),j.jsxRuntimeExports.jsx($.Span,{className:P,children:"No results."})]}):i.map((n,m)=>j.jsxRuntimeExports.jsx(xe,{...n,id:n.value===p?r:void 0,isSelected:n.value===p,onSelect:l,onHover:f},L(n)+m)),t?j.jsxRuntimeExports.jsx(Y.default,{as:"li",alignment:"center",className:B,children:j.jsxRuntimeExports.jsx($.Span,{className:P,children:j.jsxRuntimeExports.jsx(ie.SkeletonInstance,{width:"100%",height:"1.3em"})})}):null]})}function ge({isLoading:t,label:c,options:r,error:p,warning:i,information:l,footnote:f,className:x,onChange:n,onSelect:m,...v}){const R=o.useRef(null),C=o.useId(),q=o.useId(),[e,u]=o.useState(!1),b=o.useCallback(()=>{u(!0)},[]),g=o.useCallback(a=>{var d;(d=R.current)!=null&&d.contains(a.relatedTarget)||u(!1)},[]),[s,h]=o.useState(!1);o.useEffect(()=>{h(e)},[e]);const[k,w]=o.useState(""),{value:N}=v,[E,O]=o.useState(N),[A,W]=o.useState(N),U=o.useRef(A),I=o.useCallback(a=>{W(a),U.current=a},[]);o.useEffect(()=>{O(N),I(N)},[N,I]);const Z=o.useCallback(()=>{E&&(w(""),I(void 0))},[E,I]),ee=o.useCallback((a,d)=>{w(a),n==null||n(a,d),h(!0),O(void 0)},[n]),te=o.useCallback(a=>{var d;(d=R.current)!=null&&d.contains(a.target)&&h(!0)},[]),T=o.useCallback(a=>{const d=a==null?void 0:a.value;I(d),a?w(L(a)):(w(""),n==null||n("")),m==null||m(d)},[I,n,m]),ne=o.useCallback(a=>{const d=r.find(y=>y.value===a);T(d),O(a),h(!1)},[r,T]),se=o.useCallback(a=>{I(a)},[I]),S=o.useMemo(()=>E||k.length===0?r:r.filter(a=>{const y=L(a).toLowerCase(),_=k.toLowerCase();return!!(y.includes(_)||_.includes(y)||he.get(y,_,{useCollator:!0})<=2)}),[E,r,k]);o.useEffect(()=>{!E&&k.length>0&&S.length>0&&!S.some(a=>A===a.value)&&I(S[0].value)},[E,k,S,A,I]);const{setIsKeyboardNavigating:F}=Q();o.useEffect(()=>{if(!e)return;const a=d=>{d.movementX===0&&d.movementY===0||F(!1)};return window.addEventListener("mousemove",a,{capture:!0}),()=>{window.removeEventListener("mousemove",a,{capture:!0})}},[e,F]),o.useEffect(()=>{if(!e)return;const a=d=>{let y;const _=S.length,K=S.findIndex(V=>V.value===U.current),D=()=>{d.preventDefault(),d.stopPropagation(),d.stopImmediatePropagation()};switch(d.key){case"Enter":{const V=S[K];V&&(D(),F(!0),h(!1),T(V),O(V.value));break}case"Escape":{s?(D(),E?I(void 0):T(void 0),h(!1)):E?(D(),h(!0),T(void 0)):(D(),u(!1),d.target instanceof HTMLInputElement&&d.target.blur());return}case"ArrowDown":{y=K+1,h(!0);break}case"ArrowUp":{y=K-1,h(!0),y<0&&(y=_-1);break}case"Home":{h(!0),y=0;break}case"End":{h(!0),y=_-1;break}case"Backspace":{S.some(V=>V.value===E)&&(D(),T(void 0),h(!0));break}}if(y!==void 0&&(D(),F(!0),_>0)){const V=S[y%_];V&&I(V.value)}};return window.addEventListener("keydown",a,{capture:!0}),()=>{window.removeEventListener("keydown",a,{capture:!0})}},[e,S,F,h,T,O,s,E,I]);const oe=o.useMemo(()=>({clickOutsideDeactivates:!0,returnFocusOnDeactivate:!1,escapeDeactivates:!1}),[]);return j.jsxRuntimeExports.jsx(H.focusTrapReactExports.FocusTrap,{active:s,focusTrapOptions:oe,children:j.jsxRuntimeExports.jsx(ce.default,{...v,ref:R,role:"combobox",autoComplete:"off","aria-controls":C,"aria-expanded":s,"aria-activedescendant":s?q:void 0,label:c,value:k,error:p,warning:i,information:l,footnote:f,attachments:s?j.jsxRuntimeExports.jsx(be,{isLoading:t,id:C,activeOptionId:q,selectedValue:A,options:S,onSelect:ne,onHover:se}):null,className:x,onMouseDown:te,onChange:ee,onBeforeInput:Z,onFocus:b,onBlur:g})})}exports.default=ge;exports.getComboboxOptionString=L;
|
|
@@ -1,79 +1,79 @@
|
|
|
1
1
|
import { j as O } from "../jsx-runtime-B4hRZ52C.mjs";
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { g as
|
|
4
|
-
import { cx as
|
|
5
|
-
import { u as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { Span as
|
|
9
|
-
import
|
|
10
|
-
import { SkeletonInstance as
|
|
11
|
-
var
|
|
12
|
-
const
|
|
13
|
-
const r = t.length, m =
|
|
14
|
-
let
|
|
2
|
+
import { useRef as B, useId as J, useState as K, useCallback as E, useEffect as q, useMemo as P } from "react";
|
|
3
|
+
import { g as le, a as ue, f as fe } from "../focus-trap-react-DATIi_Ob.mjs";
|
|
4
|
+
import { cx as Q } from "@kuma-ui/core";
|
|
5
|
+
import { u as de } from "../use-synchronized-value-XnIpeq1s.mjs";
|
|
6
|
+
import me from "../icons/icon.mjs";
|
|
7
|
+
import ve from "./input.mjs";
|
|
8
|
+
import { Span as $ } from "./text.mjs";
|
|
9
|
+
import W from "./flex.mjs";
|
|
10
|
+
import { SkeletonInstance as he } from "./skeleton.mjs";
|
|
11
|
+
var R = { exports: {} };
|
|
12
|
+
const S = new Uint32Array(65536), pe = (t, a) => {
|
|
13
|
+
const r = t.length, m = a.length, c = 1 << r - 1;
|
|
14
|
+
let i = -1, u = 0, p = r, n = r;
|
|
15
15
|
for (; n--; )
|
|
16
|
-
|
|
16
|
+
S[t.charCodeAt(n)] |= 1 << n;
|
|
17
17
|
for (n = 0; n < m; n++) {
|
|
18
|
-
let d =
|
|
19
|
-
const
|
|
20
|
-
d |= (d &
|
|
18
|
+
let d = S[a.charCodeAt(n)];
|
|
19
|
+
const v = d | u;
|
|
20
|
+
d |= (d & i) + i ^ i, u |= ~(d | i), i &= d, u & c && p++, i & c && p--, u = u << 1 | 1, i = i << 1 | ~(v | u), u &= v;
|
|
21
21
|
}
|
|
22
22
|
for (n = r; n--; )
|
|
23
|
-
|
|
24
|
-
return
|
|
25
|
-
},
|
|
26
|
-
const r =
|
|
27
|
-
for (let e = 0; e <
|
|
28
|
-
|
|
23
|
+
S[t.charCodeAt(n)] = 0;
|
|
24
|
+
return p;
|
|
25
|
+
}, ge = (t, a) => {
|
|
26
|
+
const r = a.length, m = t.length, c = [], i = [], u = Math.ceil(r / 32), p = Math.ceil(m / 32);
|
|
27
|
+
for (let e = 0; e < u; e++)
|
|
28
|
+
i[e] = -1, c[e] = 0;
|
|
29
29
|
let n = 0;
|
|
30
|
-
for (; n <
|
|
31
|
-
let e = 0,
|
|
30
|
+
for (; n < p - 1; n++) {
|
|
31
|
+
let e = 0, l = -1;
|
|
32
32
|
const g = n * 32, x = Math.min(32, m) + g;
|
|
33
33
|
for (let o = g; o < x; o++)
|
|
34
|
-
|
|
34
|
+
S[t.charCodeAt(o)] |= 1 << o;
|
|
35
35
|
for (let o = 0; o < r; o++) {
|
|
36
|
-
const h =
|
|
37
|
-
let N = e | ~(
|
|
38
|
-
N >>> 31 ^ b && (
|
|
36
|
+
const h = S[a.charCodeAt(o)], b = i[o / 32 | 0] >>> o & 1, w = c[o / 32 | 0] >>> o & 1, D = h | e, y = ((h | w) & l) + l ^ l | h | w;
|
|
37
|
+
let N = e | ~(y | l), F = l & y;
|
|
38
|
+
N >>> 31 ^ b && (i[o / 32 | 0] ^= 1 << o), F >>> 31 ^ w && (c[o / 32 | 0] ^= 1 << o), N = N << 1 | b, F = F << 1 | w, l = F | ~(D | N), e = N & D;
|
|
39
39
|
}
|
|
40
40
|
for (let o = g; o < x; o++)
|
|
41
|
-
|
|
41
|
+
S[t.charCodeAt(o)] = 0;
|
|
42
42
|
}
|
|
43
|
-
let d = 0,
|
|
43
|
+
let d = 0, v = -1;
|
|
44
44
|
const A = n * 32, V = Math.min(32, m - A) + A;
|
|
45
45
|
for (let e = A; e < V; e++)
|
|
46
|
-
|
|
46
|
+
S[t.charCodeAt(e)] |= 1 << e;
|
|
47
47
|
let M = m;
|
|
48
48
|
for (let e = 0; e < r; e++) {
|
|
49
|
-
const
|
|
50
|
-
let b = d | ~(h |
|
|
51
|
-
M += b >>> m - 1 & 1, M -= w >>> m - 1 & 1, b >>> 31 ^ g && (
|
|
49
|
+
const l = S[a.charCodeAt(e)], g = i[e / 32 | 0] >>> e & 1, x = c[e / 32 | 0] >>> e & 1, o = l | d, h = ((l | x) & v) + v ^ v | l | x;
|
|
50
|
+
let b = d | ~(h | v), w = v & h;
|
|
51
|
+
M += b >>> m - 1 & 1, M -= w >>> m - 1 & 1, b >>> 31 ^ g && (i[e / 32 | 0] ^= 1 << e), w >>> 31 ^ x && (c[e / 32 | 0] ^= 1 << e), b = b << 1 | g, w = w << 1 | x, v = w | ~(o | b), d = b & o;
|
|
52
52
|
}
|
|
53
53
|
for (let e = A; e < V; e++)
|
|
54
|
-
|
|
54
|
+
S[t.charCodeAt(e)] = 0;
|
|
55
55
|
return M;
|
|
56
|
-
},
|
|
57
|
-
if (t.length <
|
|
58
|
-
const r =
|
|
59
|
-
|
|
56
|
+
}, ee = (t, a) => {
|
|
57
|
+
if (t.length < a.length) {
|
|
58
|
+
const r = a;
|
|
59
|
+
a = t, t = r;
|
|
60
60
|
}
|
|
61
|
-
return
|
|
62
|
-
},
|
|
61
|
+
return a.length === 0 ? t.length : t.length <= 32 ? pe(t, a) : ge(t, a);
|
|
62
|
+
}, xe = (t, a) => {
|
|
63
63
|
let r = 1 / 0, m = 0;
|
|
64
|
-
for (let c = 0; c <
|
|
65
|
-
const
|
|
66
|
-
|
|
64
|
+
for (let c = 0; c < a.length; c++) {
|
|
65
|
+
const i = ee(t, a[c]);
|
|
66
|
+
i < r && (r = i, m = c);
|
|
67
67
|
}
|
|
68
|
-
return
|
|
69
|
-
},
|
|
68
|
+
return a[m];
|
|
69
|
+
}, be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
70
70
|
__proto__: null,
|
|
71
|
-
closest:
|
|
72
|
-
distance:
|
|
73
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
74
|
-
var
|
|
75
|
-
function
|
|
76
|
-
return
|
|
71
|
+
closest: xe,
|
|
72
|
+
distance: ee
|
|
73
|
+
}, Symbol.toStringTag, { value: "Module" })), we = /* @__PURE__ */ le(be);
|
|
74
|
+
var Z;
|
|
75
|
+
function ke() {
|
|
76
|
+
return Z || (Z = 1, (function(t, a) {
|
|
77
77
|
(function() {
|
|
78
78
|
var r;
|
|
79
79
|
try {
|
|
@@ -81,7 +81,7 @@ function we() {
|
|
|
81
81
|
} catch {
|
|
82
82
|
console.log("Collator could not be initialized and wouldn't be used");
|
|
83
83
|
}
|
|
84
|
-
var m =
|
|
84
|
+
var m = we, c = [], i = [], u = {
|
|
85
85
|
/**
|
|
86
86
|
* Calculate levenshtein distance of the two strings.
|
|
87
87
|
*
|
|
@@ -91,168 +91,168 @@ function we() {
|
|
|
91
91
|
* @param [options.useCollator] Use `Intl.Collator` for locale-sensitive string comparison.
|
|
92
92
|
* @return Integer the levenshtein distance (0 and above).
|
|
93
93
|
*/
|
|
94
|
-
get: function(
|
|
95
|
-
var
|
|
96
|
-
if (
|
|
97
|
-
var A =
|
|
94
|
+
get: function(p, n, d) {
|
|
95
|
+
var v = d && r && d.useCollator;
|
|
96
|
+
if (v) {
|
|
97
|
+
var A = p.length, V = n.length;
|
|
98
98
|
if (A === 0) return V;
|
|
99
99
|
if (V === 0) return A;
|
|
100
|
-
var M, e,
|
|
101
|
-
for (
|
|
102
|
-
c[
|
|
100
|
+
var M, e, l, g, x;
|
|
101
|
+
for (l = 0; l < V; ++l)
|
|
102
|
+
c[l] = l, i[l] = n.charCodeAt(l);
|
|
103
103
|
c[V] = V;
|
|
104
104
|
var o;
|
|
105
|
-
for (
|
|
106
|
-
for (e =
|
|
107
|
-
M = e, o = r.compare(
|
|
105
|
+
for (l = 0; l < A; ++l) {
|
|
106
|
+
for (e = l + 1, g = 0; g < V; ++g)
|
|
107
|
+
M = e, o = r.compare(p.charAt(l), String.fromCharCode(i[g])) === 0, e = c[g] + (o ? 0 : 1), x = M + 1, e > x && (e = x), x = c[g + 1] + 1, e > x && (e = x), c[g] = M;
|
|
108
108
|
c[g] = e;
|
|
109
109
|
}
|
|
110
110
|
return e;
|
|
111
111
|
}
|
|
112
|
-
return m.distance(
|
|
112
|
+
return m.distance(p, n);
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
|
-
t !== null && t.exports ===
|
|
115
|
+
t !== null && t.exports === a ? t.exports = u : typeof self < "u" && typeof self.postMessage == "function" && typeof self.importScripts == "function" ? self.Levenshtein = u : typeof window < "u" && window !== null && (window.Levenshtein = u);
|
|
116
116
|
})();
|
|
117
|
-
})(
|
|
117
|
+
})(R, R.exports)), R.exports;
|
|
118
118
|
}
|
|
119
|
-
var
|
|
120
|
-
const Ie = /* @__PURE__ */
|
|
121
|
-
function
|
|
119
|
+
var ye = ke();
|
|
120
|
+
const Ie = /* @__PURE__ */ ue(ye);
|
|
121
|
+
function te() {
|
|
122
122
|
const {
|
|
123
123
|
value: t,
|
|
124
|
-
setValue:
|
|
125
|
-
} =
|
|
126
|
-
return
|
|
124
|
+
setValue: a
|
|
125
|
+
} = de("isKeyboardNavigating");
|
|
126
|
+
return P(() => ({
|
|
127
127
|
isKeyboardNavigating: t,
|
|
128
|
-
setIsKeyboardNavigating:
|
|
129
|
-
}), [t,
|
|
128
|
+
setIsKeyboardNavigating: a
|
|
129
|
+
}), [t, a]);
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function U(t) {
|
|
132
132
|
return "text" in t ? t.text : t.label;
|
|
133
133
|
}
|
|
134
|
-
const
|
|
135
|
-
function
|
|
134
|
+
const X = "kakadu-components-1144794361", Y = "kakadu-components-2911184744";
|
|
135
|
+
function Oe({
|
|
136
136
|
isSelected: t,
|
|
137
|
-
id:
|
|
137
|
+
id: a,
|
|
138
138
|
value: r,
|
|
139
139
|
label: m,
|
|
140
140
|
onSelect: c,
|
|
141
|
-
onHover:
|
|
141
|
+
onHover: i
|
|
142
142
|
}) {
|
|
143
143
|
const {
|
|
144
|
-
isKeyboardNavigating:
|
|
145
|
-
} =
|
|
144
|
+
isKeyboardNavigating: u
|
|
145
|
+
} = te(), p = E(() => {
|
|
146
146
|
c(r);
|
|
147
|
-
}, [c, r]), n = E((
|
|
148
|
-
|
|
149
|
-
}, [
|
|
147
|
+
}, [c, r]), n = E((v) => {
|
|
148
|
+
u || v.movementX === 0 && v.movementY === 0 || i(r);
|
|
149
|
+
}, [u, i, r]), d = B(null);
|
|
150
150
|
return q(() => {
|
|
151
|
-
const
|
|
152
|
-
t &&
|
|
153
|
-
|
|
151
|
+
const v = d.current;
|
|
152
|
+
t && v && u && setTimeout(() => {
|
|
153
|
+
v.scrollIntoView({
|
|
154
154
|
behavior: "smooth",
|
|
155
155
|
block: "nearest"
|
|
156
156
|
});
|
|
157
157
|
}, 0);
|
|
158
|
-
}, [t,
|
|
158
|
+
}, [t, u]), /* @__PURE__ */ O.jsx("li", { ref: d, id: a, role: "option", "aria-selected": t, tabIndex: -1, className: Q(X, "kakadu-components-4130497639", u ? "kakadu-components-962373561" : "kakadu-components-1109598791"), onClick: p, onMouseMove: n, children: /* @__PURE__ */ O.jsx($, { className: Q(Y, typeof m == "string" && "kakadu-components-154286052"), children: m }) });
|
|
159
159
|
}
|
|
160
|
-
function
|
|
160
|
+
function Ae({
|
|
161
161
|
isLoading: t,
|
|
162
|
-
id:
|
|
162
|
+
id: a,
|
|
163
163
|
activeOptionId: r,
|
|
164
164
|
selectedValue: m,
|
|
165
165
|
options: c,
|
|
166
|
-
onSelect:
|
|
167
|
-
onHover:
|
|
166
|
+
onSelect: i,
|
|
167
|
+
onHover: u
|
|
168
168
|
}) {
|
|
169
|
-
const
|
|
169
|
+
const p = B(null);
|
|
170
170
|
return q(() => {
|
|
171
|
-
const n =
|
|
171
|
+
const n = p.current;
|
|
172
172
|
n && n.scrollIntoView({
|
|
173
173
|
behavior: "smooth",
|
|
174
174
|
block: "nearest"
|
|
175
175
|
});
|
|
176
|
-
}, []), /* @__PURE__ */ O.jsxs("ul", { ref:
|
|
177
|
-
c.length === 0 ? t ? null : /* @__PURE__ */ O.jsxs(
|
|
178
|
-
/* @__PURE__ */ O.jsx(
|
|
179
|
-
/* @__PURE__ */ O.jsx(
|
|
176
|
+
}, []), /* @__PURE__ */ O.jsxs("ul", { ref: p, id: a, role: "listbox", "aria-label": "Options", className: "kakadu-components-1951042708", children: [
|
|
177
|
+
c.length === 0 ? t ? null : /* @__PURE__ */ O.jsxs(W, { "aria-atomic": !0, as: "li", role: "status", "aria-live": "polite", direction: "row", preset: "start", gap: 0.5, className: X, children: [
|
|
178
|
+
/* @__PURE__ */ O.jsx(me, { size: 15, type: "exclamationTriangle" }),
|
|
179
|
+
/* @__PURE__ */ O.jsx($, { className: Y, children: "No results." })
|
|
180
180
|
] }) : c.map((n, d) => /* @__PURE__ */ O.jsx(
|
|
181
|
-
|
|
181
|
+
Oe,
|
|
182
182
|
{
|
|
183
183
|
...n,
|
|
184
184
|
id: n.value === m ? r : void 0,
|
|
185
185
|
isSelected: n.value === m,
|
|
186
|
-
onSelect:
|
|
187
|
-
onHover:
|
|
186
|
+
onSelect: i,
|
|
187
|
+
onHover: u
|
|
188
188
|
},
|
|
189
|
-
|
|
189
|
+
U(n) + d
|
|
190
190
|
)),
|
|
191
|
-
t ? /* @__PURE__ */ O.jsx(
|
|
191
|
+
t ? /* @__PURE__ */ O.jsx(W, { as: "li", alignment: "center", className: X, children: /* @__PURE__ */ O.jsx($, { className: Y, children: /* @__PURE__ */ O.jsx(he, { width: "100%", height: "1.3em" }) }) }) : null
|
|
192
192
|
] });
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function _e({
|
|
195
195
|
isLoading: t,
|
|
196
|
-
label:
|
|
196
|
+
label: a,
|
|
197
197
|
options: r,
|
|
198
198
|
error: m,
|
|
199
199
|
warning: c,
|
|
200
|
-
information:
|
|
201
|
-
footnote:
|
|
202
|
-
className:
|
|
200
|
+
information: i,
|
|
201
|
+
footnote: u,
|
|
202
|
+
className: p,
|
|
203
203
|
onChange: n,
|
|
204
204
|
onSelect: d,
|
|
205
|
-
...
|
|
205
|
+
...v
|
|
206
206
|
}) {
|
|
207
|
-
const A =
|
|
208
|
-
|
|
207
|
+
const A = B(null), V = J(), M = J(), [e, l] = K(!1), g = E(() => {
|
|
208
|
+
l(!0);
|
|
209
209
|
}, []), x = E((s) => {
|
|
210
|
-
var
|
|
211
|
-
(
|
|
212
|
-
}, []), [o, h] =
|
|
210
|
+
var f;
|
|
211
|
+
(f = A.current) != null && f.contains(s.relatedTarget) || l(!1);
|
|
212
|
+
}, []), [o, h] = K(!1);
|
|
213
213
|
q(() => {
|
|
214
214
|
h(e);
|
|
215
215
|
}, [e]);
|
|
216
|
-
const [b, w] =
|
|
217
|
-
value:
|
|
218
|
-
} =
|
|
219
|
-
|
|
216
|
+
const [b, w] = K(""), {
|
|
217
|
+
value: D
|
|
218
|
+
} = v, [y, N] = K(D), [F, ne] = K(D), G = B(F), I = E((s) => {
|
|
219
|
+
ne(s), G.current = s;
|
|
220
220
|
}, []);
|
|
221
221
|
q(() => {
|
|
222
|
-
N(
|
|
223
|
-
}, [
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
}, [
|
|
227
|
-
w(s), n == null || n(s,
|
|
228
|
-
}, [n]),
|
|
229
|
-
var
|
|
230
|
-
(
|
|
222
|
+
N(D), I(D);
|
|
223
|
+
}, [D, I]);
|
|
224
|
+
const oe = E(() => {
|
|
225
|
+
y && (w(""), I(void 0));
|
|
226
|
+
}, [y, I]), re = E((s, f) => {
|
|
227
|
+
w(s), n == null || n(s, f), h(!0), N(void 0);
|
|
228
|
+
}, [n]), se = E((s) => {
|
|
229
|
+
var f;
|
|
230
|
+
(f = A.current) != null && f.contains(s.target) && h(!0);
|
|
231
231
|
}, []), _ = E((s) => {
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
}, [
|
|
235
|
-
const
|
|
236
|
-
_(
|
|
237
|
-
}, [r, _]),
|
|
238
|
-
|
|
239
|
-
}, [
|
|
240
|
-
const k =
|
|
232
|
+
const f = s == null ? void 0 : s.value;
|
|
233
|
+
I(f), s ? w(U(s)) : (w(""), n == null || n("")), d == null || d(f);
|
|
234
|
+
}, [I, n, d]), ae = E((s) => {
|
|
235
|
+
const f = r.find((k) => k.value === s);
|
|
236
|
+
_(f), N(s), h(!1);
|
|
237
|
+
}, [r, _]), ce = E((s) => {
|
|
238
|
+
I(s);
|
|
239
|
+
}, [I]), j = P(() => y || b.length === 0 ? r : r.filter((s) => {
|
|
240
|
+
const k = U(s).toLowerCase(), T = b.toLowerCase();
|
|
241
241
|
return !!(k.includes(T) || T.includes(k) || Ie.get(k, T, {
|
|
242
242
|
useCollator: !0
|
|
243
243
|
}) <= 2);
|
|
244
|
-
}), [
|
|
244
|
+
}), [y, r, b]);
|
|
245
245
|
q(() => {
|
|
246
|
-
!
|
|
247
|
-
}, [
|
|
246
|
+
!y && b.length > 0 && j.length > 0 && !j.some((s) => F === s.value) && I(j[0].value);
|
|
247
|
+
}, [y, b, j, F, I]);
|
|
248
248
|
const {
|
|
249
|
-
setIsKeyboardNavigating:
|
|
250
|
-
} =
|
|
249
|
+
setIsKeyboardNavigating: z
|
|
250
|
+
} = te();
|
|
251
251
|
q(() => {
|
|
252
252
|
if (!e)
|
|
253
253
|
return;
|
|
254
|
-
const s = (
|
|
255
|
-
|
|
254
|
+
const s = (f) => {
|
|
255
|
+
f.movementX === 0 && f.movementY === 0 || z(!1);
|
|
256
256
|
};
|
|
257
257
|
return window.addEventListener("mousemove", s, {
|
|
258
258
|
capture: !0
|
|
@@ -261,28 +261,30 @@ function Te({
|
|
|
261
261
|
capture: !0
|
|
262
262
|
});
|
|
263
263
|
};
|
|
264
|
-
}, [e,
|
|
264
|
+
}, [e, z]), q(() => {
|
|
265
265
|
if (!e)
|
|
266
266
|
return;
|
|
267
|
-
const s = (
|
|
267
|
+
const s = (f) => {
|
|
268
268
|
let k;
|
|
269
|
-
const T = j.length,
|
|
270
|
-
|
|
269
|
+
const T = j.length, H = j.findIndex((C) => C.value === G.current), L = () => {
|
|
270
|
+
f.preventDefault(), f.stopPropagation(), f.stopImmediatePropagation();
|
|
271
|
+
};
|
|
272
|
+
switch (f.key) {
|
|
271
273
|
case "Enter": {
|
|
272
|
-
const C = j[
|
|
273
|
-
C && (
|
|
274
|
+
const C = j[H];
|
|
275
|
+
C && (L(), z(!0), h(!1), _(C), N(C.value));
|
|
274
276
|
break;
|
|
275
277
|
}
|
|
276
278
|
case "Escape": {
|
|
277
|
-
o ? (
|
|
279
|
+
o ? (L(), y ? I(void 0) : _(void 0), h(!1)) : y ? (L(), h(!0), _(void 0)) : (L(), l(!1), f.target instanceof HTMLInputElement && f.target.blur());
|
|
278
280
|
return;
|
|
279
281
|
}
|
|
280
282
|
case "ArrowDown": {
|
|
281
|
-
k =
|
|
283
|
+
k = H + 1, h(!0);
|
|
282
284
|
break;
|
|
283
285
|
}
|
|
284
286
|
case "ArrowUp": {
|
|
285
|
-
k =
|
|
287
|
+
k = H - 1, h(!0), k < 0 && (k = T - 1);
|
|
286
288
|
break;
|
|
287
289
|
}
|
|
288
290
|
case "Home": {
|
|
@@ -294,13 +296,13 @@ function Te({
|
|
|
294
296
|
break;
|
|
295
297
|
}
|
|
296
298
|
case "Backspace": {
|
|
297
|
-
j.some((C) => C.value ===
|
|
299
|
+
j.some((C) => C.value === y) && (L(), _(void 0), h(!0));
|
|
298
300
|
break;
|
|
299
301
|
}
|
|
300
302
|
}
|
|
301
|
-
if (k !== void 0 && (
|
|
303
|
+
if (k !== void 0 && (L(), z(!0), T > 0)) {
|
|
302
304
|
const C = j[k % T];
|
|
303
|
-
C &&
|
|
305
|
+
C && I(C.value);
|
|
304
306
|
}
|
|
305
307
|
};
|
|
306
308
|
return window.addEventListener("keydown", s, {
|
|
@@ -310,15 +312,15 @@ function Te({
|
|
|
310
312
|
capture: !0
|
|
311
313
|
});
|
|
312
314
|
};
|
|
313
|
-
}, [e, j,
|
|
314
|
-
const ie =
|
|
315
|
+
}, [e, j, z, h, _, N, o, y, I]);
|
|
316
|
+
const ie = P(() => ({
|
|
315
317
|
clickOutsideDeactivates: !0,
|
|
316
318
|
returnFocusOnDeactivate: !1,
|
|
317
319
|
escapeDeactivates: !1
|
|
318
320
|
}), []);
|
|
319
|
-
return /* @__PURE__ */ O.jsx(
|
|
321
|
+
return /* @__PURE__ */ O.jsx(fe.FocusTrap, { active: o, focusTrapOptions: ie, children: /* @__PURE__ */ O.jsx(ve, { ...v, ref: A, role: "combobox", autoComplete: "off", "aria-controls": V, "aria-expanded": o, "aria-activedescendant": o ? M : void 0, label: a, value: b, error: m, warning: c, information: i, footnote: u, attachments: o ? /* @__PURE__ */ O.jsx(Ae, { isLoading: t, id: V, activeOptionId: M, selectedValue: F, options: j, onSelect: ae, onHover: ce }) : null, className: p, onMouseDown: se, onChange: re, onBeforeInput: oe, onFocus: g, onBlur: x }) });
|
|
320
322
|
}
|
|
321
323
|
export {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
+
_e as default,
|
|
325
|
+
U as getComboboxOptionString
|
|
324
326
|
};
|