@kakadu/components 4.0.7 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/combobox.js +1 -1
- package/build/components/combobox.mjs +164 -154
- package/build/components/input.d.ts +1 -1
- package/build/components/input.js +2 -2
- package/build/components/input.mjs +98 -96
- package/build/components/popover-menu.js +1 -1
- package/build/components/popover-menu.mjs +1 -1
- package/build/components.css +1 -1
- package/build/hooks/use-media-query.d.ts +1 -0
- package/build/hooks/use-synchronized-value.d.ts +1 -0
- package/build/hooks/use-synchronized-value.js +1 -0
- package/build/{use-synchronized-value-XnIpeq1s.mjs → hooks/use-synchronized-value.mjs} +8 -8
- package/build/hooks/use-throttled.d.ts +2 -0
- package/build/hooks/use-throttled.js +1 -0
- package/build/hooks/use-throttled.mjs +16 -0
- package/build/index.d.ts +6 -2
- package/build/index.js +1 -1
- package/build/index.mjs +36 -32
- package/package.json +1 -1
- package/build/use-synchronized-value-D0_rS5Wp.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const C=require("../jsx-runtime-BB_1_6y_.js"),o=require("react"),Q=require("../_commonjsHelpers-DGT2Y9Xa.js"),B=require("@kuma-ui/core"),ce=require("../hooks/use-synchronized-value.js"),ae=require("../icons/icon.js"),le=require("../icons/chevron-up.js"),ie=require("./input.js"),H=require("./text.js"),G=require("./flex.js"),ue=require("./skeleton.js");var K={exports:{}};const N=new Uint32Array(65536),fe=(t,a)=>{const r=t.length,m=a.length,l=1<<r-1;let i=-1,f=0,x=r,n=r;for(;n--;)N[t.charCodeAt(n)]|=1<<n;for(n=0;n<m;n++){let d=N[a.charCodeAt(n)];const v=d|f;d|=(d&i)+i^i,f|=~(d|i),i&=d,f&l&&x++,i&l&&x--,f=f<<1|1,i=i<<1|~(v|f),f&=v}for(n=r;n--;)N[t.charCodeAt(n)]=0;return x},de=(t,a)=>{const r=a.length,m=t.length,l=[],i=[],f=Math.ceil(r/32),x=Math.ceil(m/32);for(let e=0;e<f;e++)i[e]=-1,l[e]=0;let n=0;for(;n<x-1;n++){let e=0,u=-1;const b=n*32,k=Math.min(32,m)+b;for(let s=b;s<k;s++)N[t.charCodeAt(s)]|=1<<s;for(let s=0;s<r;s++){const p=N[a.charCodeAt(s)],q=i[s/32|0]>>>s&1,g=l[s/32|0]>>>s&1,A=p|e,j=((p|g)&u)+u^u|p|g;let S=e|~(j|u),_=u&j;S>>>31^q&&(i[s/32|0]^=1<<s),_>>>31^g&&(l[s/32|0]^=1<<s),S=S<<1|q,_=_<<1|g,u=_|~(A|S),e=S&A}for(let s=b;s<k;s++)N[t.charCodeAt(s)]=0}let d=0,v=-1;const y=n*32,R=Math.min(32,m-y)+y;for(let e=y;e<R;e++)N[t.charCodeAt(e)]|=1<<e;let V=m;for(let e=0;e<r;e++){const u=N[a.charCodeAt(e)],b=i[e/32|0]>>>e&1,k=l[e/32|0]>>>e&1,s=u|d,p=((u|k)&v)+v^v|u|k;let q=d|~(p|v),g=v&p;V+=q>>>m-1&1,V-=g>>>m-1&1,q>>>31^b&&(i[e/32|0]^=1<<e),g>>>31^k&&(l[e/32|0]^=1<<e),q=q<<1|b,g=g<<1|k,v=g|~(s|q),d=q&s}for(let e=y;e<R;e++)N[t.charCodeAt(e)]=0;return V},W=(t,a)=>{if(t.length<a.length){const r=a;a=t,t=r}return a.length===0?t.length:t.length<=32?fe(t,a):de(t,a)},me=(t,a)=>{let r=1/0,m=0;for(let l=0;l<a.length;l++){const i=W(t,a[l]);i<r&&(r=i,m=l)}return a[m]},he=Object.freeze(Object.defineProperty({__proto__:null,closest:me,distance:W},Symbol.toStringTag,{value:"Module"})),ve=Q.getAugmentedNamespace(he);var J;function pe(){return J||(J=1,(function(t,a){(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 m=ve,l=[],i=[],f={get:function(x,n,d){var v=d&&r&&d.useCollator;if(v){var y=x.length,R=n.length;if(y===0)return R;if(R===0)return y;var V,e,u,b,k;for(u=0;u<R;++u)l[u]=u,i[u]=n.charCodeAt(u);l[R]=R;var s;for(u=0;u<y;++u){for(e=u+1,b=0;b<R;++b)V=e,s=r.compare(x.charAt(u),String.fromCharCode(i[b]))===0,e=l[b]+(s?0:1),k=V+1,e>k&&(e=k),k=l[b+1]+1,e>k&&(e=k),l[b]=V;l[b]=e}return e}return m.distance(x,n)}};t!==null&&t.exports===a?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)})()})(K,K.exports)),K.exports}var xe=pe();const be=Q.getDefaultExportFromCjs(xe);function Z(){const{value:t,setValue:a}=ce.default("isKeyboardNavigating");return o.useMemo(()=>({isKeyboardNavigating:t,setIsKeyboardNavigating:a}),[t,a])}function T(t){return"text"in t?t.text:t.label}const P="kakadu-components-1144794361",U="kakadu-components-2911184744";function ke({isSelected:t,id:a,value:r,label:m,onSelect:l,onHover:i}){const{isKeyboardNavigating:f}=Z(),x=o.useCallback(()=>{l(r)},[l,r]),n=o.useCallback(v=>{f||v.movementX===0&&v.movementY===0||i(r)},[f,i,r]),d=o.useRef(null);return o.useEffect(()=>{const v=d.current;t&&v&&f&&setTimeout(()=>{v.scrollIntoView({behavior:"smooth",block:"nearest"})},0)},[t,f]),C.jsxRuntimeExports.jsx("li",{ref:d,id:a,role:"option","aria-selected":t,tabIndex:-1,className:B.cx(P,"kakadu-components-4130497639",f?"kakadu-components-962373561":"kakadu-components-1109598791"),onClick:x,onMouseMove:n,children:C.jsxRuntimeExports.jsx(H.Span,{className:B.cx(U,typeof m=="string"&&"kakadu-components-154286052"),children:m})})}function ge({isLoading:t,id:a,activeOptionId:r,selectedValue:m,options:l,onSelect:i,onHover:f}){const x=o.useRef(null);return o.useEffect(()=>{const n=x.current;n&&n.scrollIntoView({behavior:"smooth",block:"nearest"})},[]),C.jsxRuntimeExports.jsxs("ul",{ref:x,id:a,role:"listbox","aria-label":"Options",tabIndex:-1,className:"kakadu-components-1951042708",children:[l.length===0?t?null:C.jsxRuntimeExports.jsxs(G.default,{"aria-atomic":!0,as:"li",role:"status","aria-live":"polite",direction:"row",preset:"start",gap:.5,className:P,children:[C.jsxRuntimeExports.jsx(ae.default,{size:15,type:"exclamationTriangle"}),C.jsxRuntimeExports.jsx(H.Span,{className:U,children:"No results."})]}):l.map((n,d)=>C.jsxRuntimeExports.jsx(ke,{...n,id:n.value===m?r:void 0,isSelected:n.value===m,onSelect:i,onHover:f},T(n)+d)),t?C.jsxRuntimeExports.jsx(G.default,{as:"li",alignment:"center",className:P,children:C.jsxRuntimeExports.jsx(H.Span,{className:U,children:C.jsxRuntimeExports.jsx(ue.SkeletonInstance,{width:"100%",height:"1.3em"})})}):null]})}function we({isLoading:t,label:a,options:r,error:m,warning:l,information:i,footnote:f,className:x,onChange:n,onSelect:d,...v}){const y=o.useRef(null),R=o.useId(),V=o.useId(),[e,u]=o.useState(!1),b=o.useCallback(()=>{u(!0)},[]),k=o.useCallback(c=>{var h;(h=y.current)!=null&&h.contains(c.relatedTarget)||u(!1)},[]),[s,p]=o.useState(!1);o.useEffect(()=>{p(e)},[e]);const[q,g]=o.useState(""),{value:A}=v,[j,S]=o.useState(A),[_,ee]=o.useState(A),X=o.useRef(_),I=o.useCallback(c=>{ee(c),X.current=c},[]);o.useEffect(()=>{S(A),I(A)},[A,I]);const te=o.useCallback(()=>{j&&(g(""),I(void 0))},[j,I]),ne=o.useCallback((c,h)=>{g(c),n==null||n(c,h),p(!0),S(void 0)},[n]),se=o.useCallback(c=>{var h;(h=y.current)!=null&&h.contains(c.target)&&p(!0)},[]),L=o.useCallback(c=>{const h=c==null?void 0:c.value;I(h),c?g(T(c)):(g(""),n==null||n("")),d==null||d(h)},[I,n,d]),oe=o.useCallback(c=>{const h=r.find(w=>w.value===c);L(h),S(c),p(!1)},[r,L]),re=o.useCallback(c=>{I(c)},[I]),D=o.useDeferredValue(q),O=o.useMemo(()=>j||D.length===0?r:r.filter(c=>{const w=T(c).toLowerCase(),M=D.toLowerCase();return!!(w.includes(M)||M.includes(w)||be.get(w,M,{useCollator:!0})<=2)}),[j,r,D]);o.useEffect(()=>{!j&&D.length>0&&O.length>0&&!O.some(c=>_===c.value)&&I(O[0].value)},[j,D,O,_,I]);const{setIsKeyboardNavigating:F}=Z();return o.useEffect(()=>{if(!e)return;const c=h=>{h.movementX===0&&h.movementY===0||F(!1)};return window.addEventListener("mousemove",c,{capture:!0}),()=>{window.removeEventListener("mousemove",c,{capture:!0})}},[e,F]),o.useEffect(()=>{if(!e)return;const c=h=>{var Y;let w;const M=O.length,$=O.findIndex(E=>E.value===X.current),z=()=>{h.preventDefault(),h.stopPropagation(),h.stopImmediatePropagation()};switch(h.key){case"Enter":{const E=O[$];E&&(z(),F(!0),p(!1),L(E),S(E.value));break}case"Escape":{if(s)z(),j?I(void 0):L(void 0),p(!1);else if(j)z(),p(!0),L(void 0);else{z(),u(!1);const E=document.activeElement;E instanceof HTMLElement&&((Y=y.current)!=null&&Y.contains(E))&&E.blur()}return}case"ArrowDown":{w=$+1,p(!0);break}case"ArrowUp":{w=$-1,p(!0),w<0&&(w=M-1);break}case"Home":{p(!0),w=0;break}case"End":{p(!0),w=M-1;break}case"Backspace":{O.some(E=>E.value===j)&&(z(),L(void 0),p(!0));break}}if(w!==void 0&&(z(),F(!0),M>0)){const E=O[w%M];E&&I(E.value)}};return window.addEventListener("keydown",c,{capture:!0}),()=>{window.removeEventListener("keydown",c,{capture:!0})}},[e,O,F,p,L,S,s,j,I]),C.jsxRuntimeExports.jsx(ie.default,{...v,ref:y,role:"combobox",autoComplete:"off","aria-controls":R,"aria-expanded":s,"aria-activedescendant":s?V:void 0,label:a,value:q,error:m,warning:l,information:i,footnote:f,attachments:s?C.jsxRuntimeExports.jsx(ge,{isLoading:t,id:R,activeOptionId:V,selectedValue:_,options:O,onSelect:oe,onHover:re}):null,className:B.cx(x,"kakadu-components-879486679"),onMouseDown:se,onChange:ne,onBeforeInput:te,onFocus:b,onBlur:k,children:C.jsxRuntimeExports.jsx(le.default,{width:14,height:14,className:"kakadu-components-158931186"})})}exports.default=we;exports.getComboboxOptionString=T;
|
|
@@ -1,79 +1,80 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { g as
|
|
4
|
-
import { cx as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { j as N } from "../jsx-runtime-B4hRZ52C.mjs";
|
|
2
|
+
import { useRef as H, useId as W, useState as R, useCallback as M, useEffect as z, useDeferredValue as ue, useMemo as te } from "react";
|
|
3
|
+
import { g as fe, a as de } from "../_commonjsHelpers-MdHo5S7N.mjs";
|
|
4
|
+
import { cx as U } from "@kuma-ui/core";
|
|
5
|
+
import me from "../hooks/use-synchronized-value.mjs";
|
|
6
|
+
import he from "../icons/icon.mjs";
|
|
7
|
+
import ve from "../icons/chevron-up.mjs";
|
|
8
|
+
import pe from "./input.mjs";
|
|
9
|
+
import { Span as $ } from "./text.mjs";
|
|
10
|
+
import Z from "./flex.mjs";
|
|
11
|
+
import { SkeletonInstance as ge } from "./skeleton.mjs";
|
|
12
|
+
var T = { exports: {} };
|
|
13
|
+
const _ = new Uint32Array(65536), xe = (t, a) => {
|
|
14
|
+
const r = t.length, d = a.length, c = 1 << r - 1;
|
|
15
|
+
let i = -1, u = 0, p = r, n = r;
|
|
15
16
|
for (; n--; )
|
|
16
17
|
_[t.charCodeAt(n)] |= 1 << n;
|
|
17
|
-
for (n = 0; n <
|
|
18
|
-
let
|
|
19
|
-
const h =
|
|
20
|
-
|
|
18
|
+
for (n = 0; n < d; n++) {
|
|
19
|
+
let f = _[a.charCodeAt(n)];
|
|
20
|
+
const h = f | u;
|
|
21
|
+
f |= (f & i) + i ^ i, u |= ~(f | i), i &= f, u & c && p++, i & c && p--, u = u << 1 | 1, i = i << 1 | ~(h | u), u &= h;
|
|
21
22
|
}
|
|
22
23
|
for (n = r; n--; )
|
|
23
24
|
_[t.charCodeAt(n)] = 0;
|
|
24
25
|
return p;
|
|
25
|
-
},
|
|
26
|
-
const r = a.length,
|
|
26
|
+
}, be = (t, a) => {
|
|
27
|
+
const r = a.length, d = t.length, c = [], i = [], u = Math.ceil(r / 32), p = Math.ceil(d / 32);
|
|
27
28
|
for (let e = 0; e < u; e++)
|
|
28
|
-
|
|
29
|
+
i[e] = -1, c[e] = 0;
|
|
29
30
|
let n = 0;
|
|
30
31
|
for (; n < p - 1; n++) {
|
|
31
32
|
let e = 0, l = -1;
|
|
32
|
-
const g = n * 32, x = Math.min(32,
|
|
33
|
+
const g = n * 32, x = Math.min(32, d) + g;
|
|
33
34
|
for (let o = g; o < x; o++)
|
|
34
35
|
_[t.charCodeAt(o)] |= 1 << o;
|
|
35
36
|
for (let o = 0; o < r; o++) {
|
|
36
|
-
const v = _[a.charCodeAt(o)],
|
|
37
|
-
let
|
|
38
|
-
|
|
37
|
+
const v = _[a.charCodeAt(o)], O = i[o / 32 | 0] >>> o & 1, b = c[o / 32 | 0] >>> o & 1, q = v | e, I = ((v | b) & l) + l ^ l | v | b;
|
|
38
|
+
let E = e | ~(I | l), S = l & I;
|
|
39
|
+
E >>> 31 ^ O && (i[o / 32 | 0] ^= 1 << o), S >>> 31 ^ b && (c[o / 32 | 0] ^= 1 << o), E = E << 1 | O, S = S << 1 | b, l = S | ~(q | E), e = E & q;
|
|
39
40
|
}
|
|
40
41
|
for (let o = g; o < x; o++)
|
|
41
42
|
_[t.charCodeAt(o)] = 0;
|
|
42
43
|
}
|
|
43
|
-
let
|
|
44
|
-
const
|
|
45
|
-
for (let e =
|
|
44
|
+
let f = 0, h = -1;
|
|
45
|
+
const y = n * 32, A = Math.min(32, d - y) + y;
|
|
46
|
+
for (let e = y; e < A; e++)
|
|
46
47
|
_[t.charCodeAt(e)] |= 1 << e;
|
|
47
|
-
let
|
|
48
|
+
let C = d;
|
|
48
49
|
for (let e = 0; e < r; e++) {
|
|
49
|
-
const l = _[a.charCodeAt(e)], g =
|
|
50
|
-
let
|
|
51
|
-
|
|
50
|
+
const l = _[a.charCodeAt(e)], g = i[e / 32 | 0] >>> e & 1, x = c[e / 32 | 0] >>> e & 1, o = l | f, v = ((l | x) & h) + h ^ h | l | x;
|
|
51
|
+
let O = f | ~(v | h), b = h & v;
|
|
52
|
+
C += O >>> d - 1 & 1, C -= b >>> d - 1 & 1, O >>> 31 ^ g && (i[e / 32 | 0] ^= 1 << e), b >>> 31 ^ x && (c[e / 32 | 0] ^= 1 << e), O = O << 1 | g, b = b << 1 | x, h = b | ~(o | O), f = O & o;
|
|
52
53
|
}
|
|
53
|
-
for (let e =
|
|
54
|
+
for (let e = y; e < A; e++)
|
|
54
55
|
_[t.charCodeAt(e)] = 0;
|
|
55
|
-
return
|
|
56
|
-
},
|
|
56
|
+
return C;
|
|
57
|
+
}, ne = (t, a) => {
|
|
57
58
|
if (t.length < a.length) {
|
|
58
59
|
const r = a;
|
|
59
60
|
a = t, t = r;
|
|
60
61
|
}
|
|
61
|
-
return a.length === 0 ? t.length : t.length <= 32 ?
|
|
62
|
-
},
|
|
63
|
-
let r = 1 / 0,
|
|
64
|
-
for (let
|
|
65
|
-
const
|
|
66
|
-
|
|
62
|
+
return a.length === 0 ? t.length : t.length <= 32 ? xe(t, a) : be(t, a);
|
|
63
|
+
}, ke = (t, a) => {
|
|
64
|
+
let r = 1 / 0, d = 0;
|
|
65
|
+
for (let c = 0; c < a.length; c++) {
|
|
66
|
+
const i = ne(t, a[c]);
|
|
67
|
+
i < r && (r = i, d = c);
|
|
67
68
|
}
|
|
68
|
-
return a[
|
|
69
|
-
},
|
|
69
|
+
return a[d];
|
|
70
|
+
}, we = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
70
71
|
__proto__: null,
|
|
71
|
-
closest:
|
|
72
|
-
distance:
|
|
73
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
74
|
-
var
|
|
75
|
-
function
|
|
76
|
-
return
|
|
72
|
+
closest: ke,
|
|
73
|
+
distance: ne
|
|
74
|
+
}, Symbol.toStringTag, { value: "Module" })), ye = /* @__PURE__ */ fe(we);
|
|
75
|
+
var ee;
|
|
76
|
+
function Ie() {
|
|
77
|
+
return ee || (ee = 1, (function(t, a) {
|
|
77
78
|
(function() {
|
|
78
79
|
var r;
|
|
79
80
|
try {
|
|
@@ -81,7 +82,7 @@ function be() {
|
|
|
81
82
|
} catch {
|
|
82
83
|
console.log("Collator could not be initialized and wouldn't be used");
|
|
83
84
|
}
|
|
84
|
-
var
|
|
85
|
+
var d = ye, c = [], i = [], u = {
|
|
85
86
|
/**
|
|
86
87
|
* Calculate levenshtein distance of the two strings.
|
|
87
88
|
*
|
|
@@ -91,168 +92,168 @@ function be() {
|
|
|
91
92
|
* @param [options.useCollator] Use `Intl.Collator` for locale-sensitive string comparison.
|
|
92
93
|
* @return Integer the levenshtein distance (0 and above).
|
|
93
94
|
*/
|
|
94
|
-
get: function(p, n,
|
|
95
|
-
var h =
|
|
95
|
+
get: function(p, n, f) {
|
|
96
|
+
var h = f && r && f.useCollator;
|
|
96
97
|
if (h) {
|
|
97
|
-
var
|
|
98
|
-
if (
|
|
99
|
-
if (
|
|
100
|
-
var
|
|
101
|
-
for (l = 0; l <
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
var y = p.length, A = n.length;
|
|
99
|
+
if (y === 0) return A;
|
|
100
|
+
if (A === 0) return y;
|
|
101
|
+
var C, e, l, g, x;
|
|
102
|
+
for (l = 0; l < A; ++l)
|
|
103
|
+
c[l] = l, i[l] = n.charCodeAt(l);
|
|
104
|
+
c[A] = A;
|
|
104
105
|
var o;
|
|
105
|
-
for (l = 0; l <
|
|
106
|
-
for (e = l + 1, g = 0; g <
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
for (l = 0; l < y; ++l) {
|
|
107
|
+
for (e = l + 1, g = 0; g < A; ++g)
|
|
108
|
+
C = e, o = r.compare(p.charAt(l), String.fromCharCode(i[g])) === 0, e = c[g] + (o ? 0 : 1), x = C + 1, e > x && (e = x), x = c[g + 1] + 1, e > x && (e = x), c[g] = C;
|
|
109
|
+
c[g] = e;
|
|
109
110
|
}
|
|
110
111
|
return e;
|
|
111
112
|
}
|
|
112
|
-
return
|
|
113
|
+
return d.distance(p, n);
|
|
113
114
|
}
|
|
114
115
|
};
|
|
115
116
|
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
117
|
})();
|
|
117
|
-
})(
|
|
118
|
+
})(T, T.exports)), T.exports;
|
|
118
119
|
}
|
|
119
|
-
var
|
|
120
|
-
const
|
|
121
|
-
function
|
|
120
|
+
var Ve = Ie();
|
|
121
|
+
const Ne = /* @__PURE__ */ de(Ve);
|
|
122
|
+
function oe() {
|
|
122
123
|
const {
|
|
123
124
|
value: t,
|
|
124
125
|
setValue: a
|
|
125
|
-
} =
|
|
126
|
-
return
|
|
126
|
+
} = me("isKeyboardNavigating");
|
|
127
|
+
return te(() => ({
|
|
127
128
|
isKeyboardNavigating: t,
|
|
128
129
|
setIsKeyboardNavigating: a
|
|
129
130
|
}), [t, a]);
|
|
130
131
|
}
|
|
131
|
-
function
|
|
132
|
+
function X(t) {
|
|
132
133
|
return "text" in t ? t.text : t.label;
|
|
133
134
|
}
|
|
134
|
-
const
|
|
135
|
-
function
|
|
135
|
+
const Y = "kakadu-components-1144794361", G = "kakadu-components-2911184744";
|
|
136
|
+
function Ae({
|
|
136
137
|
isSelected: t,
|
|
137
138
|
id: a,
|
|
138
139
|
value: r,
|
|
139
|
-
label:
|
|
140
|
-
onSelect:
|
|
141
|
-
onHover:
|
|
140
|
+
label: d,
|
|
141
|
+
onSelect: c,
|
|
142
|
+
onHover: i
|
|
142
143
|
}) {
|
|
143
144
|
const {
|
|
144
145
|
isKeyboardNavigating: u
|
|
145
|
-
} =
|
|
146
|
-
|
|
147
|
-
}, [
|
|
148
|
-
u || h.movementX === 0 && h.movementY === 0 ||
|
|
149
|
-
}, [u,
|
|
146
|
+
} = oe(), p = M(() => {
|
|
147
|
+
c(r);
|
|
148
|
+
}, [c, r]), n = M((h) => {
|
|
149
|
+
u || h.movementX === 0 && h.movementY === 0 || i(r);
|
|
150
|
+
}, [u, i, r]), f = H(null);
|
|
150
151
|
return z(() => {
|
|
151
|
-
const h =
|
|
152
|
+
const h = f.current;
|
|
152
153
|
t && h && u && setTimeout(() => {
|
|
153
154
|
h.scrollIntoView({
|
|
154
155
|
behavior: "smooth",
|
|
155
156
|
block: "nearest"
|
|
156
157
|
});
|
|
157
158
|
}, 0);
|
|
158
|
-
}, [t, u]), /* @__PURE__ */
|
|
159
|
+
}, [t, u]), /* @__PURE__ */ N.jsx("li", { ref: f, id: a, role: "option", "aria-selected": t, tabIndex: -1, className: U(Y, "kakadu-components-4130497639", u ? "kakadu-components-962373561" : "kakadu-components-1109598791"), onClick: p, onMouseMove: n, children: /* @__PURE__ */ N.jsx($, { className: U(G, typeof d == "string" && "kakadu-components-154286052"), children: d }) });
|
|
159
160
|
}
|
|
160
|
-
function
|
|
161
|
+
function Oe({
|
|
161
162
|
isLoading: t,
|
|
162
163
|
id: a,
|
|
163
164
|
activeOptionId: r,
|
|
164
|
-
selectedValue:
|
|
165
|
-
options:
|
|
166
|
-
onSelect:
|
|
165
|
+
selectedValue: d,
|
|
166
|
+
options: c,
|
|
167
|
+
onSelect: i,
|
|
167
168
|
onHover: u
|
|
168
169
|
}) {
|
|
169
|
-
const p =
|
|
170
|
+
const p = H(null);
|
|
170
171
|
return z(() => {
|
|
171
172
|
const n = p.current;
|
|
172
173
|
n && n.scrollIntoView({
|
|
173
174
|
behavior: "smooth",
|
|
174
175
|
block: "nearest"
|
|
175
176
|
});
|
|
176
|
-
}, []), /* @__PURE__ */
|
|
177
|
-
|
|
178
|
-
/* @__PURE__ */
|
|
179
|
-
/* @__PURE__ */
|
|
180
|
-
] }) :
|
|
181
|
-
|
|
177
|
+
}, []), /* @__PURE__ */ N.jsxs("ul", { ref: p, id: a, role: "listbox", "aria-label": "Options", tabIndex: -1, className: "kakadu-components-1951042708", children: [
|
|
178
|
+
c.length === 0 ? t ? null : /* @__PURE__ */ N.jsxs(Z, { "aria-atomic": !0, as: "li", role: "status", "aria-live": "polite", direction: "row", preset: "start", gap: 0.5, className: Y, children: [
|
|
179
|
+
/* @__PURE__ */ N.jsx(he, { size: 15, type: "exclamationTriangle" }),
|
|
180
|
+
/* @__PURE__ */ N.jsx($, { className: G, children: "No results." })
|
|
181
|
+
] }) : c.map((n, f) => /* @__PURE__ */ N.jsx(
|
|
182
|
+
Ae,
|
|
182
183
|
{
|
|
183
184
|
...n,
|
|
184
|
-
id: n.value ===
|
|
185
|
-
isSelected: n.value ===
|
|
186
|
-
onSelect:
|
|
185
|
+
id: n.value === d ? r : void 0,
|
|
186
|
+
isSelected: n.value === d,
|
|
187
|
+
onSelect: i,
|
|
187
188
|
onHover: u
|
|
188
189
|
},
|
|
189
|
-
|
|
190
|
+
X(n) + f
|
|
190
191
|
)),
|
|
191
|
-
t ? /* @__PURE__ */
|
|
192
|
+
t ? /* @__PURE__ */ N.jsx(Z, { as: "li", alignment: "center", className: Y, children: /* @__PURE__ */ N.jsx($, { className: G, children: /* @__PURE__ */ N.jsx(ge, { width: "100%", height: "1.3em" }) }) }) : null
|
|
192
193
|
] });
|
|
193
194
|
}
|
|
194
|
-
function
|
|
195
|
+
function Ke({
|
|
195
196
|
isLoading: t,
|
|
196
197
|
label: a,
|
|
197
198
|
options: r,
|
|
198
|
-
error:
|
|
199
|
-
warning:
|
|
200
|
-
information:
|
|
199
|
+
error: d,
|
|
200
|
+
warning: c,
|
|
201
|
+
information: i,
|
|
201
202
|
footnote: u,
|
|
202
203
|
className: p,
|
|
203
204
|
onChange: n,
|
|
204
|
-
onSelect:
|
|
205
|
+
onSelect: f,
|
|
205
206
|
...h
|
|
206
207
|
}) {
|
|
207
|
-
const
|
|
208
|
+
const y = H(null), A = W(), C = W(), [e, l] = R(!1), g = M(() => {
|
|
208
209
|
l(!0);
|
|
209
|
-
}, []), x =
|
|
210
|
-
var
|
|
211
|
-
(
|
|
212
|
-
}, []), [o, v] =
|
|
210
|
+
}, []), x = M((s) => {
|
|
211
|
+
var m;
|
|
212
|
+
(m = y.current) != null && m.contains(s.relatedTarget) || l(!1);
|
|
213
|
+
}, []), [o, v] = R(!1);
|
|
213
214
|
z(() => {
|
|
214
215
|
v(e);
|
|
215
216
|
}, [e]);
|
|
216
|
-
const [
|
|
217
|
+
const [O, b] = R(""), {
|
|
217
218
|
value: q
|
|
218
|
-
} = h, [
|
|
219
|
-
|
|
219
|
+
} = h, [I, E] = R(q), [S, re] = R(q), J = H(S), V = M((s) => {
|
|
220
|
+
re(s), J.current = s;
|
|
220
221
|
}, []);
|
|
221
222
|
z(() => {
|
|
222
|
-
|
|
223
|
-
}, [q,
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
}, [
|
|
227
|
-
|
|
228
|
-
}, [n]),
|
|
229
|
-
var
|
|
230
|
-
(
|
|
231
|
-
}, []), L =
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
}, [
|
|
235
|
-
const
|
|
236
|
-
L(
|
|
237
|
-
}, [r, L]),
|
|
238
|
-
|
|
239
|
-
}, [
|
|
240
|
-
const k =
|
|
241
|
-
return !!(k.includes(F) || F.includes(k) ||
|
|
223
|
+
E(q), V(q);
|
|
224
|
+
}, [q, V]);
|
|
225
|
+
const se = M(() => {
|
|
226
|
+
I && (b(""), V(void 0));
|
|
227
|
+
}, [I, V]), ae = M((s, m) => {
|
|
228
|
+
b(s), n == null || n(s, m), v(!0), E(void 0);
|
|
229
|
+
}, [n]), ce = M((s) => {
|
|
230
|
+
var m;
|
|
231
|
+
(m = y.current) != null && m.contains(s.target) && v(!0);
|
|
232
|
+
}, []), L = M((s) => {
|
|
233
|
+
const m = s == null ? void 0 : s.value;
|
|
234
|
+
V(m), s ? b(X(s)) : (b(""), n == null || n("")), f == null || f(m);
|
|
235
|
+
}, [V, n, f]), ie = M((s) => {
|
|
236
|
+
const m = r.find((k) => k.value === s);
|
|
237
|
+
L(m), E(s), v(!1);
|
|
238
|
+
}, [r, L]), le = M((s) => {
|
|
239
|
+
V(s);
|
|
240
|
+
}, [V]), K = ue(O), j = te(() => I || K.length === 0 ? r : r.filter((s) => {
|
|
241
|
+
const k = X(s).toLowerCase(), F = K.toLowerCase();
|
|
242
|
+
return !!(k.includes(F) || F.includes(k) || Ne.get(k, F, {
|
|
242
243
|
useCollator: !0
|
|
243
244
|
}) <= 2);
|
|
244
|
-
}), [
|
|
245
|
+
}), [I, r, K]);
|
|
245
246
|
z(() => {
|
|
246
|
-
!
|
|
247
|
-
}, [
|
|
247
|
+
!I && K.length > 0 && j.length > 0 && !j.some((s) => S === s.value) && V(j[0].value);
|
|
248
|
+
}, [I, K, j, S, V]);
|
|
248
249
|
const {
|
|
249
250
|
setIsKeyboardNavigating: B
|
|
250
|
-
} =
|
|
251
|
+
} = oe();
|
|
251
252
|
return z(() => {
|
|
252
253
|
if (!e)
|
|
253
254
|
return;
|
|
254
|
-
const s = (
|
|
255
|
-
|
|
255
|
+
const s = (m) => {
|
|
256
|
+
m.movementX === 0 && m.movementY === 0 || B(!1);
|
|
256
257
|
};
|
|
257
258
|
return window.addEventListener("mousemove", s, {
|
|
258
259
|
capture: !0
|
|
@@ -264,27 +265,36 @@ function qe({
|
|
|
264
265
|
}, [e, B]), z(() => {
|
|
265
266
|
if (!e)
|
|
266
267
|
return;
|
|
267
|
-
const s = (
|
|
268
|
+
const s = (m) => {
|
|
269
|
+
var Q;
|
|
268
270
|
let k;
|
|
269
|
-
const F = j.length,
|
|
270
|
-
|
|
271
|
+
const F = j.length, P = j.findIndex((w) => w.value === J.current), D = () => {
|
|
272
|
+
m.preventDefault(), m.stopPropagation(), m.stopImmediatePropagation();
|
|
271
273
|
};
|
|
272
|
-
switch (
|
|
274
|
+
switch (m.key) {
|
|
273
275
|
case "Enter": {
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
+
const w = j[P];
|
|
277
|
+
w && (D(), B(!0), v(!1), L(w), E(w.value));
|
|
276
278
|
break;
|
|
277
279
|
}
|
|
278
280
|
case "Escape": {
|
|
279
|
-
|
|
281
|
+
if (o)
|
|
282
|
+
D(), I ? V(void 0) : L(void 0), v(!1);
|
|
283
|
+
else if (I)
|
|
284
|
+
D(), v(!0), L(void 0);
|
|
285
|
+
else {
|
|
286
|
+
D(), l(!1);
|
|
287
|
+
const w = document.activeElement;
|
|
288
|
+
w instanceof HTMLElement && ((Q = y.current) != null && Q.contains(w)) && w.blur();
|
|
289
|
+
}
|
|
280
290
|
return;
|
|
281
291
|
}
|
|
282
292
|
case "ArrowDown": {
|
|
283
|
-
k =
|
|
293
|
+
k = P + 1, v(!0);
|
|
284
294
|
break;
|
|
285
295
|
}
|
|
286
296
|
case "ArrowUp": {
|
|
287
|
-
k =
|
|
297
|
+
k = P - 1, v(!0), k < 0 && (k = F - 1);
|
|
288
298
|
break;
|
|
289
299
|
}
|
|
290
300
|
case "Home": {
|
|
@@ -296,13 +306,13 @@ function qe({
|
|
|
296
306
|
break;
|
|
297
307
|
}
|
|
298
308
|
case "Backspace": {
|
|
299
|
-
j.some((
|
|
309
|
+
j.some((w) => w.value === I) && (D(), L(void 0), v(!0));
|
|
300
310
|
break;
|
|
301
311
|
}
|
|
302
312
|
}
|
|
303
|
-
if (k !== void 0 && (
|
|
304
|
-
const
|
|
305
|
-
|
|
313
|
+
if (k !== void 0 && (D(), B(!0), F > 0)) {
|
|
314
|
+
const w = j[k % F];
|
|
315
|
+
w && V(w.value);
|
|
306
316
|
}
|
|
307
317
|
};
|
|
308
318
|
return window.addEventListener("keydown", s, {
|
|
@@ -312,9 +322,9 @@ function qe({
|
|
|
312
322
|
capture: !0
|
|
313
323
|
});
|
|
314
324
|
};
|
|
315
|
-
}, [e, j, B, v, L,
|
|
325
|
+
}, [e, j, B, v, L, E, o, I, V]), /* @__PURE__ */ N.jsx(pe, { ...h, ref: y, role: "combobox", autoComplete: "off", "aria-controls": A, "aria-expanded": o, "aria-activedescendant": o ? C : void 0, label: a, value: O, error: d, warning: c, information: i, footnote: u, attachments: o ? /* @__PURE__ */ N.jsx(Oe, { isLoading: t, id: A, activeOptionId: C, selectedValue: S, options: j, onSelect: ie, onHover: le }) : null, className: U(p, "kakadu-components-879486679"), onMouseDown: ce, onChange: ae, onBeforeInput: se, onFocus: g, onBlur: x, children: /* @__PURE__ */ N.jsx(ve, { width: 14, height: 14, className: "kakadu-components-158931186" }) });
|
|
316
326
|
}
|
|
317
327
|
export {
|
|
318
|
-
|
|
319
|
-
|
|
328
|
+
Ke as default,
|
|
329
|
+
X as getComboboxOptionString
|
|
320
330
|
};
|
|
@@ -34,5 +34,5 @@ export type InputProperties = Omit<InputLabelControllerProperties & Omit<HTMLPro
|
|
|
34
34
|
readonly isMultiline?: boolean;
|
|
35
35
|
readonly onChange?: (value: string, event: ChangeEvent<InputType>) => void;
|
|
36
36
|
};
|
|
37
|
-
export default function Input({ ref, type, label, error, warning, information, footnote, suggestion, attachments, actions, hasCopyButton, hasClearButton, isMultiline, onChange, className, ...properties }: InputProperties): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
export default function Input({ ref, type, label, error, warning, information, footnote, suggestion, attachments, actions, hasCopyButton, hasClearButton, isMultiline, onChange, children, className, ...properties }: InputProperties): import("react/jsx-runtime").JSX.Element;
|
|
38
38
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../jsx-runtime-BB_1_6y_.js"),t=require("react"),r=require("@kuma-ui/core"),
|
|
2
|
-
`):[],[o]),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../jsx-runtime-BB_1_6y_.js"),t=require("react"),r=require("@kuma-ui/core"),Q=require("../utilities/copy-to-clipboard.js"),M=require("../theme.js"),me=require("../icons/sparkle.js"),de=require("./button-tooltip.js"),w=require("./text-button.js"),x=require("./text.js"),je=require("./collapsible.js"),X=require("./click-ripples.js"),Y=require("./hover-gradient.js"),ke=require("./notification.js"),fe="kakadu-components-922159086",he="kakadu-components-25448712",N="kakadu-components-1621260869",T="kakadu-components-4056037255",Z=r.cx(T,"kakadu-components-3245407458"),Ee=r.cx(T,"kakadu-components-1117160492"),Re=r.cx(T,"kakadu-components-2261792866");function be({as:p,className:c,...m}){return e.jsxRuntimeExports.jsx(x.Span,{as:p??"span",...m,className:r.cx("kakadu-components-520991867",c)})}function ee({label:p,error:c,errorId:m,warning:l,warningId:h,information:i,informationId:v,footnote:a,attachments:S,className:d,children:j,...k}){const E=!!c,u=!!l,R=!!i,f=!!a;return e.jsxRuntimeExports.jsx("label",{...k,className:r.cx(fe,d),children:e.jsxRuntimeExports.jsxs("div",{className:"kakadu-components-3146929190",children:[e.jsxRuntimeExports.jsx(x.Span,{className:r.cx(M.overflowProtectionStyles,he),children:e.jsxRuntimeExports.jsx("span",{children:p})}),e.jsxRuntimeExports.jsxs("span",{className:"kakadu-components-3298764637",children:[j,f?e.jsxRuntimeExports.jsx(be,{className:"kakadu-components-613632806",children:a}):null,S]}),E||u||R?e.jsxRuntimeExports.jsx("div",{className:"kakadu-components-2927674627",children:E?e.jsxRuntimeExports.jsx(x.Paragraph,{id:m,className:Z,children:c instanceof Error?c.message:c}):u?e.jsxRuntimeExports.jsx(x.Paragraph,{id:h,className:Ee,children:l instanceof Error?l.message:l}):R?e.jsxRuntimeExports.jsx(x.Paragraph,{id:v,className:Re,children:i instanceof Error?i.message:i}):null}):null]})})}const ge=40,L="kakadu-components-4233741488";function ye({ref:p,type:c,label:m,error:l,warning:h,information:i,footnote:v,suggestion:a,attachments:S,actions:d=[],hasCopyButton:j,hasClearButton:k,isMultiline:E,onChange:u,children:R,className:f,...C}){const $=t.useRef(null),H=t.useRef(null),q=t.useRef(null),A=ke.useCreateNotification(),I=t.useId(),F=`${I}-error`,V=`${I}-warning`,O=`${I}-information`,{value:b,disabled:te}=C,[se,W]=t.useState(""),o=b??se,[ne,ae]=t.useState(),oe=c==="textarea"||!!E;t.useLayoutEffect(()=>{typeof o=="string"&&q.current&&ae(q.current.scrollHeight)},[o]);const P=t.useMemo(()=>typeof o=="string"?`${o} `.split(`
|
|
2
|
+
`):[],[o]),re=t.useMemo(()=>P.length,[P]),g=!!l,_=!g&&!!h,B=!!i,z=g?F:_?V:B?O:void 0;t.useEffect(()=>{W(typeof b=="string"?b:"")},[b]);const D=t.useCallback(s=>{const{value:n}=s.target;W(n),u==null||u(n,s)},[u]),ce=t.useCallback(()=>{typeof o=="string"&&(Q.default(o),A({type:"success",children:"Copied to clipboard."}))},[o,A]),y=t.useCallback(s=>{var J;const n=H.current??$.current??void 0;if(n){const K=(J=Object.getOwnPropertyDescriptor(n instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value"))==null?void 0:J.set;if(K){K.call(n,s);const pe=new Event("input",{bubbles:!0});n.dispatchEvent(pe),n.focus();return}}throw new Error("Unable to set value.")},[]),le=t.useCallback(()=>{y("")},[y]),[ie,ue]=t.useState(""),G=!!a&&ie!==a,xe=t.useCallback(()=>{if(a){try{y(a)}catch{Q.default(a)}ue(a)}},[a,y]),U=t.useMemo(()=>d.length,[d]);return e.jsxRuntimeExports.jsxs(ee,{ref:p,label:m,error:l,errorId:F,warning:h,warningId:V,information:i,informationId:O,footnote:v,attachments:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(je.default,{isCollapsed:!G,children:G?e.jsxRuntimeExports.jsxs("button",{type:"button",className:r.cx(M.buttonResetStyles,M.overflowProtectionStyles,"kakadu-components-4141839293"),onClick:xe,children:[e.jsxRuntimeExports.jsx(de.default,{label:"Apply suggestion"}),e.jsxRuntimeExports.jsx(me.default,{width:13,height:13,className:"kakadu-components-1417828741"}),e.jsxRuntimeExports.jsx(x.Span,{className:"kakadu-components-1384720019",children:a}),e.jsxRuntimeExports.jsx(X.default,{className:"kakadu-components-2744733744"}),e.jsxRuntimeExports.jsx(Y.default,{})]}):null}),S]}),style:{"--button-padding":`calc(${ge*((j?1:0)+(k?1:0)+U)}px + 6px)`},children:[e.jsxRuntimeExports.jsxs("div",{className:"kakadu-components-3146929190",children:[oe?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("span",{ref:q,"aria-hidden":!0,className:r.cx(N,f,"kakadu-components-2033521835"),children:[P.map((s,n)=>e.jsxRuntimeExports.jsxs("span",{children:[s,re>1?e.jsxRuntimeExports.jsx("br",{}):null]},n))," "]}),e.jsxRuntimeExports.jsx("textarea",{...C,ref:H,rows:1,"aria-invalid":g,"data-warning":_,"data-information":B,"aria-describedby":z,value:o,className:r.cx(N,f,"kakadu-components-2119524139"),style:{minHeight:ne},onChange:D})]}):e.jsxRuntimeExports.jsx("input",{...C,ref:$,type:c??"text",value:o,"aria-invalid":g,"data-warning":_,"data-information":B,"aria-describedby":z,className:r.cx(N,f),onChange:D}),te?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(X.default,{className:"kakadu-components-616311160"}),e.jsxRuntimeExports.jsx(Y.default,{className:"kakadu-components-1962999040"})]})]}),j||k||U>0?e.jsxRuntimeExports.jsxs("div",{className:"kakadu-components-131986363",children:[d.map((s,n)=>e.jsxRuntimeExports.jsx(w.default,{iconLeft:s.icon,label:s.label,tooltip:s.label,className:L,onClick:s.onClick},s.label+n)),j?e.jsxRuntimeExports.jsx(w.default,{iconLeft:"copy",label:"Copy",tooltip:"Copy",className:L,onClick:ce}):null,k?e.jsxRuntimeExports.jsx(w.default,{iconLeft:"times",label:"Clear",tooltip:"Clear",className:L,onClick:le}):null]}):null,R]})}exports.InputLabel=ee;exports.default=ye;exports.errorParagraph=Z;exports.inputStyles=N;
|