@kakadu/components 6.2.0 → 6.3.1

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