@kakadu/components 6.16.0 → 6.17.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.
@@ -4692,7 +4692,7 @@ function gn(e, n, t) {
4692
4692
  }
4693
4693
  for (const c of i)
4694
4694
  de(u.children, c);
4695
- return u.type === "element" && u.tagName === "template" && (u.content = { type: "root", children: u.children }, u.children = []), u;
4695
+ return u.type === "element" && u.tagName === "template" && e.space === "html" && (u.content = { type: "root", children: u.children }, u.children = []), u;
4696
4696
  }
4697
4697
  return a;
4698
4698
  }
@@ -4720,27 +4720,30 @@ function Mn(e) {
4720
4720
  return !!("children" in e && Array.isArray(e.children));
4721
4721
  }
4722
4722
  function Un(e, n, t, r) {
4723
+ if (r == null) return;
4723
4724
  const a = Ln(e, t);
4724
4725
  let o;
4725
- if (r != null) {
4726
- if (typeof r == "number") {
4727
- if (Number.isNaN(r)) return;
4728
- o = r;
4729
- } else typeof r == "boolean" ? o = r : typeof r == "string" ? a.spaceSeparated ? o = Xe(r) : a.commaSeparated ? o = Ze(r) : a.commaOrSpaceSeparated ? o = Xe(Ze(r).join(" ")) : o = Je(a, a.property, r) : Array.isArray(r) ? o = [...r] : o = a.property === "style" ? qn(r) : String(r);
4730
- if (Array.isArray(o)) {
4731
- const s = [];
4732
- for (const i of o)
4733
- s.push(
4734
- /** @type {number | string} */
4735
- Je(a, a.property, i)
4736
- );
4737
- o = s;
4738
- }
4739
- a.property === "className" && Array.isArray(n.className) && (o = n.className.concat(
4726
+ if (typeof r == "number") {
4727
+ if (Number.isNaN(r)) return;
4728
+ o = r;
4729
+ } else typeof r == "boolean" ? o = r : typeof r == "string" ? a.spaceSeparated ? o = Xe(r) : a.commaSeparated ? o = Ze(r) : a.commaOrSpaceSeparated ? o = Xe(Ze(r).join(" ")) : o = Je(a, a.property, r) : Array.isArray(r) ? o = [...r] : o = a.property === "style" ? qn(r) : String(r);
4730
+ if (Array.isArray(o)) {
4731
+ const s = [];
4732
+ for (const i of o)
4733
+ s.push(
4734
+ /** @type {number | string} */
4735
+ Je(a, a.property, i)
4736
+ );
4737
+ o = s;
4738
+ }
4739
+ if (a.property === "className" && Array.isArray(n.className)) {
4740
+ const s = (
4740
4741
  /** @type {Array<number | string> | number | string} */
4741
4742
  o
4742
- )), n[a.property] = o;
4743
+ );
4744
+ o = [...n.className, ...Array.isArray(s) ? s : [s]];
4743
4745
  }
4746
+ n[a.property] = o;
4744
4747
  }
4745
4748
  function de(e, n) {
4746
4749
  if (n != null) if (typeof n == "number" || typeof n == "string")
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("../jsx-runtime-CZa898vN.js"),e=require("react"),_=require("@kuma-ui/core"),se=require("../hooks/use-synchronized-value.js"),ne=require("../icons/icon.js"),re=require("../icons/chevron-up.js"),oe=require("../utilities/search.js"),Y=require("../utilities/listeners.js"),ae=require("./input.js"),T=require("./text.js"),X=require("./flex.js"),ce=require("./skeleton.js"),ue=Y.default(n=>{window.addEventListener("mousemove",n,{capture:!0})},n=>{window.removeEventListener("mousemove",n,{capture:!0})}),ie=Y.default(n=>{window.addEventListener("keydown",n,{capture:!0})},n=>{window.removeEventListener("keydown",n,{capture:!0})});function F(){const{value:n,setValue:f}=se.default("isKeyboardNavigating");return e.useMemo(()=>({isKeyboardNavigating:n,setIsKeyboardNavigating:f}),[n,f])}function q(n){return"text"in n?n.text:n.label}const B="kakadu-components-1144794361",D="kakadu-components-2911184744";function le({ref:n,isSelected:f,id:O,value:o,label:E,onSelect:w,onHover:I}){const{isKeyboardNavigating:m}=F(),R=e.useCallback(()=>{w(o)},[w,o]),u=e.useCallback(r=>{m||r.movementX===0&&r.movementY===0||I(o)},[m,I,o]),b=e.useRef(null);e.useEffect(()=>{const r=b.current;f&&r&&m&&setTimeout(()=>{r.scrollIntoView({behavior:"smooth",block:"nearest"})},0)},[f,m]);const a=e.useCallback(r=>{b.current=r,n&&(n.current=r)},[n]);return d.jsxRuntimeExports.jsx("li",{ref:a,id:O,role:"option","aria-selected":f,tabIndex:-1,className:_.cx(B,"kakadu-components-4130497639",m?"kakadu-components-962373561":"kakadu-components-1109598791"),onClick:R,onMouseMove:u,children:d.jsxRuntimeExports.jsx(T.Span,{className:_.cx(D,typeof E=="string"&&"kakadu-components-154286052"),children:E})})}function de({isLoading:n,id:f,activeOptionId:O,selectedValue:o,options:E,onSelect:w,onHover:I}){const m=e.useRef(null);e.useEffect(()=>{const a=m.current;a&&a.scrollIntoView({behavior:"smooth",block:"nearest"})},[]);const R=e.useRef(null),{isKeyboardNavigating:u}=F(),b=e.useRef(u);return b.current=u,e.useLayoutEffect(()=>{const a=m.current;if(a&&E.length>0){if(b.current){const r=R.current;if(r){r.scrollIntoView({block:"nearest"});return}}a.scrollTo({top:0})}},[E]),d.jsxRuntimeExports.jsxs("ul",{ref:m,id:f,role:"listbox","aria-label":"Options",tabIndex:-1,className:"kakadu-components-1713806412",children:[E.length===0?n?null:d.jsxRuntimeExports.jsxs(X.default,{"aria-atomic":!0,as:"li",role:"status","aria-live":"polite",direction:"row",preset:"start",gap:.5,className:B,children:[d.jsxRuntimeExports.jsx(ne.default,{size:15,type:"exclamationTriangle"}),d.jsxRuntimeExports.jsx(T.Span,{className:D,children:"No results."})]}):E.map((a,r)=>d.jsxRuntimeExports.jsx(le,{...a,ref:a.value===o?R:void 0,id:a.value===o?O:void 0,isSelected:a.value===o,onSelect:w,onHover:I},q(a)+r)),n?d.jsxRuntimeExports.jsx(X.default,{as:"li",alignment:"center",className:B,children:d.jsxRuntimeExports.jsx(T.Span,{className:_.cx(D,"kakadu-components-2015848015"),children:d.jsxRuntimeExports.jsx(ce.SkeletonInstance,{width:"100%",height:"1.3em"})})}):null]})}function fe({isLoading:n,shouldFilterOptions:f=!0,label:O,options:o,error:E,warning:w,information:I,footnote:m,className:R,onChange:u,onSelect:b,...a}){const r=e.useRef(null),H=e.useId(),P=e.useId(),[y,K]=e.useState(!1),$=e.useCallback(()=>{K(!0)},[]),G=e.useCallback(t=>{var s;(s=r.current)!=null&&s.contains(t.relatedTarget)||K(!1)},[]),[v,i]=e.useState(!1);e.useEffect(()=>{i(y)},[y]),e.useEffect(()=>{var s;if(!v)return;const t=(s=r.current)==null?void 0:s.control;return()=>{t==null||t.scrollIntoView({behavior:"smooth",block:"nearest"})}},[v]);const[A,N]=e.useState(""),{value:p}=a,[k,g]=e.useState(p),[C,J]=e.useState(p),z=e.useRef(C),l=e.useCallback(t=>{J(t),z.current=t},[]);e.useEffect(()=>{g(p),l(p)},[p,l]),e.useEffect(()=>{if(p===void 0)return;const t=o.find(s=>s.value===p);t&&N(q(t))},[o,p]),e.useEffect(()=>{p===void 0&&N("")},[p]);const Q=e.useCallback(()=>{k&&(N(""),l(void 0))},[k,l]),W=e.useCallback((t,s)=>{N(t),u==null||u(t,s),i(!0),g(void 0)},[u]),Z=e.useCallback(t=>{var s;(s=r.current)!=null&&s.contains(t.target)&&i(!0)},[]),j=e.useCallback(t=>{const s=t==null?void 0:t.value;l(s),t?N(q(t)):(N(""),u==null||u("")),b==null||b(s)},[l,u,b]),ee=e.useCallback(t=>{const s=o.find(V=>V.value===t);j(s),g(t),i(!1)},[o,j]),te=e.useCallback(t=>{l(t)},[l]),M=e.useDeferredValue(A),x=e.useMemo(()=>!f||k?o:oe.default(M,o,q),[f,k,o,M]);e.useEffect(()=>{!k&&M.length>0&&x.length>0&&!x.some(t=>C===t.value)&&l(x[0].value)},[k,M,x,C,l]);const{setIsKeyboardNavigating:S}=F();return e.useEffect(()=>{if(y)return ue(t=>{t.movementX===0&&t.movementY===0||S(!1)})},[y,S]),e.useEffect(()=>{if(y)return ie(t=>{var U;let s;const V=x.length,L=x.findIndex(c=>c.value===z.current),h=()=>{t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()};switch(t.key){case"Enter":{const c=x[L];c&&v&&(h(),S(!0),i(!1),j(c),g(c.value));break}case"Escape":{if(v)h(),k?l(void 0):j(void 0),i(!1);else if(k)h(),i(!0),j(void 0),g(void 0);else{h(),K(!1);const c=document.activeElement;c instanceof HTMLElement&&((U=r.current)!=null&&U.contains(c))&&c.blur()}return}case"ArrowDown":{h(),v&&(s=L+1),i(!0);break}case"ArrowUp":{h(),v&&(s=L-1,s<0&&(s=V-1)),i(!0);break}case"Home":{i(!0),s=0;break}case"End":{i(!0),s=V-1;break}case"Backspace":{x.some(c=>c.value===k)&&(h(),j(void 0),i(!0),g(void 0));break}}if(s!==void 0&&(h(),S(!0),V>0)){const c=x[s%V];c&&l(c.value)}})},[y,x,S,i,j,g,v,k,l]),d.jsxRuntimeExports.jsx(ae.default,{...a,ref:r,role:"combobox",autoComplete:"off","aria-controls":H,"aria-expanded":v,"aria-activedescendant":v?P:void 0,label:O,value:A,error:E,warning:w,information:I,footnote:m,attachments:v?d.jsxRuntimeExports.jsx(de,{isLoading:n,id:H,activeOptionId:P,selectedValue:C,options:x,onSelect:ee,onHover:te}):null,className:_.cx(R,"kakadu-components-1230689972"),onMouseDown:Z,onChange:W,onBeforeInput:Q,onFocus:$,onBlur:G,children:d.jsxRuntimeExports.jsx(re.default,{width:14,height:14,className:"kakadu-components-158931186"})})}exports.default=fe;exports.getComboboxOptionString=q;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("../jsx-runtime-CZa898vN.js"),e=require("react"),K=require("@kuma-ui/core"),se=require("../hooks/use-synchronized-value.js"),ne=require("../icons/icon.js"),re=require("../icons/chevron-up.js"),oe=require("../utilities/search.js"),Y=require("../utilities/listeners.js"),ae=require("./input.js"),B=require("./text.js"),X=require("./flex.js"),ce=require("./skeleton.js"),ue=Y.default(n=>{window.addEventListener("mousemove",n,{capture:!0})},n=>{window.removeEventListener("mousemove",n,{capture:!0})}),ie=Y.default(n=>{window.addEventListener("keydown",n,{capture:!0})},n=>{window.removeEventListener("keydown",n,{capture:!0})});function P(){const{value:n,setValue:m}=se.default("isKeyboardNavigating");return e.useMemo(()=>({isKeyboardNavigating:n,setIsKeyboardNavigating:m}),[n,m])}function M(n){return"text"in n?n.text:n.label}const D="kakadu-components-1144794361",F="kakadu-components-2911184744";function le({ref:n,isSelected:m,id:S,value:r,label:E,onSelect:R,onHover:g}){const{isKeyboardNavigating:c}=P(),y=e.useCallback(()=>{R(r)},[R,r]),u=e.useCallback(x=>{c||x.movementX===0&&x.movementY===0||g(r)},[c,g,r]),h=e.useCallback(()=>{c||g(r)},[c,g,r]),o=e.useRef(null);e.useEffect(()=>{const x=o.current;m&&x&&c&&setTimeout(()=>{x.scrollIntoView({behavior:"smooth",block:"nearest"})},0)},[m,c]);const f=e.useCallback(x=>{o.current=x,n&&(n.current=x)},[n]);return d.jsxRuntimeExports.jsx("li",{ref:f,id:S,role:"option","aria-selected":m,tabIndex:-1,className:K.cx(D,"kakadu-components-4130497639",c?"kakadu-components-962373561":"kakadu-components-1109598791"),onClick:y,onMouseMove:u,onMouseEnter:h,children:d.jsxRuntimeExports.jsx(B.Span,{className:K.cx(F,typeof E=="string"&&"kakadu-components-154286052"),children:E})})}function de({isLoading:n,id:m,activeOptionId:S,selectedValue:r,options:E,onSelect:R,onHover:g}){const c=e.useRef(null);e.useEffect(()=>{const o=c.current;o&&o.scrollIntoView({behavior:"smooth",block:"nearest"})},[]);const y=e.useRef(null),{isKeyboardNavigating:u}=P(),h=e.useRef(u);return h.current=u,e.useLayoutEffect(()=>{const o=c.current;if(o&&E.length>0){if(h.current){const f=y.current;if(f){f.scrollIntoView({block:"nearest"});return}}o.scrollTo({top:0})}},[E]),d.jsxRuntimeExports.jsxs("ul",{ref:c,id:m,role:"listbox","aria-label":"Options",tabIndex:-1,className:"kakadu-components-1713806412",children:[E.length===0?n?null:d.jsxRuntimeExports.jsxs(X.default,{"aria-atomic":!0,as:"li",role:"status","aria-live":"polite",direction:"row",preset:"start",gap:.5,className:D,children:[d.jsxRuntimeExports.jsx(ne.default,{size:15,type:"exclamationTriangle"}),d.jsxRuntimeExports.jsx(B.Span,{className:F,children:"No results."})]}):E.map((o,f)=>d.jsxRuntimeExports.jsx(le,{...o,ref:o.value===r?y:void 0,id:o.value===r?S:void 0,isSelected:o.value===r,onSelect:R,onHover:g},M(o)+f)),n?d.jsxRuntimeExports.jsx(X.default,{as:"li",alignment:"center",className:D,children:d.jsxRuntimeExports.jsx(B.Span,{className:K.cx(F,"kakadu-components-2015848015"),children:d.jsxRuntimeExports.jsx(ce.SkeletonInstance,{width:"100%",height:"1.3em"})})}):null]})}function fe({isLoading:n,shouldFilterOptions:m=!0,label:S,options:r,error:E,warning:R,information:g,footnote:c,className:y,onChange:u,onSelect:h,...o}){const f=e.useRef(null),x=e.useId(),A=e.useId(),[N,L]=e.useState(!1),$=e.useCallback(()=>{L(!0)},[]),G=e.useCallback(t=>{var s;(s=f.current)!=null&&s.contains(t.relatedTarget)||L(!1)},[]),[p,i]=e.useState(!1);e.useEffect(()=>{i(N)},[N]),e.useEffect(()=>{var s;if(!p)return;const t=(s=f.current)==null?void 0:s.control;return()=>{t==null||t.scrollIntoView({behavior:"smooth",block:"nearest"})}},[p]);const[z,V]=e.useState(""),{value:v}=o,[k,w]=e.useState(v),[C,J]=e.useState(v),H=e.useRef(C),l=e.useCallback(t=>{J(t),H.current=t},[]);e.useEffect(()=>{w(v),l(v)},[v,l]),e.useEffect(()=>{if(v===void 0)return;const t=r.find(s=>s.value===v);t&&V(M(t))},[r,v]),e.useEffect(()=>{v===void 0&&V("")},[v]);const Q=e.useCallback(()=>{k&&(V(""),l(void 0))},[k,l]),W=e.useCallback((t,s)=>{V(t),u==null||u(t,s),i(!0),w(void 0)},[u]),Z=e.useCallback(t=>{var s;(s=f.current)!=null&&s.contains(t.target)&&i(!0)},[]),I=e.useCallback(t=>{const s=t==null?void 0:t.value;l(s),t?V(M(t)):(V(""),u==null||u("")),h==null||h(s)},[l,u,h]),ee=e.useCallback(t=>{const s=r.find(O=>O.value===t);I(s),w(t),i(!1)},[r,I]),te=e.useCallback(t=>{l(t)},[l]),_=e.useDeferredValue(z),b=e.useMemo(()=>!m||k?r:oe.default(_,r,M),[m,k,r,_]);e.useEffect(()=>{!k&&_.length>0&&b.length>0&&!b.some(t=>C===t.value)&&l(b[0].value)},[k,_,b,C,l]);const{setIsKeyboardNavigating:q}=P();return e.useEffect(()=>{if(N)return ue(t=>{t.movementX===0&&t.movementY===0||q(!1)})},[N,q]),e.useEffect(()=>{if(N)return ie(t=>{var U;let s;const O=b.length,T=b.findIndex(a=>a.value===H.current),j=()=>{t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation()};switch(t.key){case"Enter":{const a=b[T];a&&p&&(j(),q(!0),i(!1),I(a),w(a.value));break}case"Escape":{if(p)j(),k?l(void 0):I(void 0),i(!1);else if(k)j(),i(!0),I(void 0),w(void 0);else{j(),L(!1);const a=document.activeElement;a instanceof HTMLElement&&((U=f.current)!=null&&U.contains(a))&&a.blur()}return}case"ArrowDown":{j(),p&&(s=T+1),i(!0);break}case"ArrowUp":{j(),p&&(s=T-1,s<0&&(s=O-1)),i(!0);break}case"Home":{i(!0),s=0;break}case"End":{i(!0),s=O-1;break}case"Backspace":{b.some(a=>a.value===k)&&(j(),I(void 0),i(!0),w(void 0));break}}if(s!==void 0&&(j(),q(!0),O>0)){const a=b[s%O];a&&l(a.value)}})},[N,b,q,i,I,w,p,k,l]),d.jsxRuntimeExports.jsx(ae.default,{...o,ref:f,role:"combobox",autoComplete:"off","aria-controls":x,"aria-expanded":p,"aria-activedescendant":p?A:void 0,label:S,value:z,error:E,warning:R,information:g,footnote:c,attachments:p?d.jsxRuntimeExports.jsx(de,{isLoading:n,id:x,activeOptionId:A,selectedValue:C,options:b,onSelect:ee,onHover:te}):null,className:K.cx(y,"kakadu-components-1230689972"),onMouseDown:Z,onChange:W,onBeforeInput:Q,onFocus:$,onBlur:G,children:d.jsxRuntimeExports.jsx(re.default,{width:14,height:14,className:"kakadu-components-158931186"})})}exports.default=fe;exports.getComboboxOptionString=M;
@@ -1,162 +1,164 @@
1
- import { j as l } from "../jsx-runtime-z6PQ6F3d.mjs";
2
- import { useRef as K, useId as Q, useState as S, useCallback as d, useEffect as h, useDeferredValue as ce, useMemo as Z, useLayoutEffect as ie } from "react";
3
- import { cx as T } from "@kuma-ui/core";
1
+ import { j as d } from "../jsx-runtime-z6PQ6F3d.mjs";
2
+ import { useRef as K, useId as Q, useState as B, useCallback as l, useEffect as h, useDeferredValue as ce, useMemo as Z, useLayoutEffect as ie } from "react";
3
+ import { cx as A } from "@kuma-ui/core";
4
4
  import ue from "../hooks/use-synchronized-value.mjs";
5
5
  import le from "../icons/icon.mjs";
6
6
  import de from "../icons/chevron-up.mjs";
7
7
  import me from "../utilities/search.mjs";
8
8
  import _ from "../utilities/listeners.mjs";
9
9
  import fe from "./input.mjs";
10
- import { Span as P } from "./text.mjs";
10
+ import { Span as H } from "./text.mjs";
11
11
  import W from "./flex.mjs";
12
12
  import { SkeletonInstance as ve } from "./skeleton.mjs";
13
- const pe = _((r) => {
14
- window.addEventListener("mousemove", r, {
13
+ const pe = _((n) => {
14
+ window.addEventListener("mousemove", n, {
15
15
  capture: !0
16
16
  });
17
- }, (r) => {
18
- window.removeEventListener("mousemove", r, {
17
+ }, (n) => {
18
+ window.removeEventListener("mousemove", n, {
19
19
  capture: !0
20
20
  });
21
- }), be = _((r) => {
22
- window.addEventListener("keydown", r, {
21
+ }), be = _((n) => {
22
+ window.addEventListener("keydown", n, {
23
23
  capture: !0
24
24
  });
25
- }, (r) => {
26
- window.removeEventListener("keydown", r, {
25
+ }, (n) => {
26
+ window.removeEventListener("keydown", n, {
27
27
  capture: !0
28
28
  });
29
29
  });
30
- function X() {
30
+ function Y() {
31
31
  const {
32
- value: r,
33
- setValue: m
32
+ value: n,
33
+ setValue: f
34
34
  } = ue("isKeyboardNavigating");
35
35
  return Z(() => ({
36
- isKeyboardNavigating: r,
37
- setIsKeyboardNavigating: m
38
- }), [r, m]);
36
+ isKeyboardNavigating: n,
37
+ setIsKeyboardNavigating: f
38
+ }), [n, f]);
39
39
  }
40
- function F(r) {
41
- return "text" in r ? r.text : r.label;
40
+ function T(n) {
41
+ return "text" in n ? n.text : n.label;
42
42
  }
43
- const z = "kakadu-components-1144794361", U = "kakadu-components-2911184744";
43
+ const U = "kakadu-components-1144794361", X = "kakadu-components-2911184744";
44
44
  function ke({
45
- ref: r,
46
- isSelected: m,
47
- id: M,
48
- value: o,
45
+ ref: n,
46
+ isSelected: f,
47
+ id: R,
48
+ value: r,
49
49
  label: g,
50
- onSelect: N,
51
- onHover: V
50
+ onSelect: E,
51
+ onHover: I
52
52
  }) {
53
53
  const {
54
- isKeyboardNavigating: f
55
- } = X(), j = d(() => {
56
- N(o);
57
- }, [N, o]), c = d((n) => {
58
- f || n.movementX === 0 && n.movementY === 0 || V(o);
59
- }, [f, V, o]), p = K(null);
54
+ isKeyboardNavigating: a
55
+ } = Y(), j = l(() => {
56
+ E(r);
57
+ }, [E, r]), c = l((v) => {
58
+ a || v.movementX === 0 && v.movementY === 0 || I(r);
59
+ }, [a, I, r]), w = l(() => {
60
+ a || I(r);
61
+ }, [a, I, r]), o = K(null);
60
62
  h(() => {
61
- const n = p.current;
62
- m && n && f && setTimeout(() => {
63
- n.scrollIntoView({
63
+ const v = o.current;
64
+ f && v && a && setTimeout(() => {
65
+ v.scrollIntoView({
64
66
  behavior: "smooth",
65
67
  block: "nearest"
66
68
  });
67
69
  }, 0);
68
- }, [m, f]);
69
- const s = d(
70
+ }, [f, a]);
71
+ const m = l(
70
72
  // eslint-disable-next-line @typescript-eslint/ban-types
71
- (n) => {
72
- p.current = n, r && (r.current = n);
73
+ (v) => {
74
+ o.current = v, n && (n.current = v);
73
75
  },
74
- [r]
76
+ [n]
75
77
  );
76
- return /* @__PURE__ */ l.jsx("li", { ref: s, id: M, role: "option", "aria-selected": m, tabIndex: -1, className: T(z, "kakadu-components-4130497639", f ? "kakadu-components-962373561" : "kakadu-components-1109598791"), onClick: j, onMouseMove: c, children: /* @__PURE__ */ l.jsx(P, { className: T(U, typeof g == "string" && "kakadu-components-154286052"), children: g }) });
78
+ return /* @__PURE__ */ d.jsx("li", { ref: m, id: R, role: "option", "aria-selected": f, tabIndex: -1, className: A(U, "kakadu-components-4130497639", a ? "kakadu-components-962373561" : "kakadu-components-1109598791"), onClick: j, onMouseMove: c, onMouseEnter: w, children: /* @__PURE__ */ d.jsx(H, { className: A(X, typeof g == "string" && "kakadu-components-154286052"), children: g }) });
77
79
  }
78
80
  function xe({
79
- isLoading: r,
80
- id: m,
81
- activeOptionId: M,
82
- selectedValue: o,
81
+ isLoading: n,
82
+ id: f,
83
+ activeOptionId: R,
84
+ selectedValue: r,
83
85
  options: g,
84
- onSelect: N,
85
- onHover: V
86
+ onSelect: E,
87
+ onHover: I
86
88
  }) {
87
- const f = K(null);
89
+ const a = K(null);
88
90
  h(() => {
89
- const s = f.current;
90
- s && s.scrollIntoView({
91
+ const o = a.current;
92
+ o && o.scrollIntoView({
91
93
  behavior: "smooth",
92
94
  block: "nearest"
93
95
  });
94
96
  }, []);
95
97
  const j = K(null), {
96
98
  isKeyboardNavigating: c
97
- } = X(), p = K(c);
98
- return p.current = c, ie(() => {
99
- const s = f.current;
100
- if (s && g.length > 0) {
101
- if (p.current) {
102
- const n = j.current;
103
- if (n) {
104
- n.scrollIntoView({
99
+ } = Y(), w = K(c);
100
+ return w.current = c, ie(() => {
101
+ const o = a.current;
102
+ if (o && g.length > 0) {
103
+ if (w.current) {
104
+ const m = j.current;
105
+ if (m) {
106
+ m.scrollIntoView({
105
107
  block: "nearest"
106
108
  });
107
109
  return;
108
110
  }
109
111
  }
110
- s.scrollTo({
112
+ o.scrollTo({
111
113
  top: 0
112
114
  });
113
115
  }
114
- }, [g]), /* @__PURE__ */ l.jsxs("ul", { ref: f, id: m, role: "listbox", "aria-label": "Options", tabIndex: -1, className: "kakadu-components-1713806412", children: [
115
- g.length === 0 ? r ? null : /* @__PURE__ */ l.jsxs(W, { "aria-atomic": !0, as: "li", role: "status", "aria-live": "polite", direction: "row", preset: "start", gap: 0.5, className: z, children: [
116
- /* @__PURE__ */ l.jsx(le, { size: 15, type: "exclamationTriangle" }),
117
- /* @__PURE__ */ l.jsx(P, { className: U, children: "No results." })
118
- ] }) : g.map((s, n) => /* @__PURE__ */ l.jsx(
116
+ }, [g]), /* @__PURE__ */ d.jsxs("ul", { ref: a, id: f, role: "listbox", "aria-label": "Options", tabIndex: -1, className: "kakadu-components-1713806412", children: [
117
+ g.length === 0 ? n ? null : /* @__PURE__ */ d.jsxs(W, { "aria-atomic": !0, as: "li", role: "status", "aria-live": "polite", direction: "row", preset: "start", gap: 0.5, className: U, children: [
118
+ /* @__PURE__ */ d.jsx(le, { size: 15, type: "exclamationTriangle" }),
119
+ /* @__PURE__ */ d.jsx(H, { className: X, children: "No results." })
120
+ ] }) : g.map((o, m) => /* @__PURE__ */ d.jsx(
119
121
  ke,
120
122
  {
121
- ...s,
122
- ref: s.value === o ? j : void 0,
123
- id: s.value === o ? M : void 0,
124
- isSelected: s.value === o,
125
- onSelect: N,
126
- onHover: V
123
+ ...o,
124
+ ref: o.value === r ? j : void 0,
125
+ id: o.value === r ? R : void 0,
126
+ isSelected: o.value === r,
127
+ onSelect: E,
128
+ onHover: I
127
129
  },
128
- F(s) + n
130
+ T(o) + m
129
131
  )),
130
- r ? /* @__PURE__ */ l.jsx(W, { as: "li", alignment: "center", className: z, children: /* @__PURE__ */ l.jsx(P, { className: T(U, "kakadu-components-2015848015"), children: /* @__PURE__ */ l.jsx(ve, { width: "100%", height: "1.3em" }) }) }) : null
132
+ n ? /* @__PURE__ */ d.jsx(W, { as: "li", alignment: "center", className: U, children: /* @__PURE__ */ d.jsx(H, { className: A(X, "kakadu-components-2015848015"), children: /* @__PURE__ */ d.jsx(ve, { width: "100%", height: "1.3em" }) }) }) : null
131
133
  ] });
132
134
  }
133
- function Me({
134
- isLoading: r,
135
- shouldFilterOptions: m = !0,
136
- label: M,
137
- options: o,
135
+ function Ke({
136
+ isLoading: n,
137
+ shouldFilterOptions: f = !0,
138
+ label: R,
139
+ options: r,
138
140
  error: g,
139
- warning: N,
140
- information: V,
141
- footnote: f,
141
+ warning: E,
142
+ information: I,
143
+ footnote: a,
142
144
  className: j,
143
145
  onChange: c,
144
- onSelect: p,
145
- ...s
146
+ onSelect: w,
147
+ ...o
146
148
  }) {
147
- const n = K(null), Y = Q(), q = Q(), [E, H] = S(!1), $ = d(() => {
148
- H(!0);
149
- }, []), ee = d((e) => {
149
+ const m = K(null), v = Q(), q = Q(), [O, P] = B(!1), $ = l(() => {
150
+ P(!0);
151
+ }, []), ee = l((e) => {
150
152
  var t;
151
- (t = n.current) != null && t.contains(e.relatedTarget) || H(!1);
152
- }, []), [b, i] = S(!1);
153
+ (t = m.current) != null && t.contains(e.relatedTarget) || P(!1);
154
+ }, []), [b, i] = B(!1);
153
155
  h(() => {
154
- i(E);
155
- }, [E]), h(() => {
156
+ i(O);
157
+ }, [O]), h(() => {
156
158
  var t;
157
159
  if (!b)
158
160
  return;
159
- const e = (t = n.current) == null ? void 0 : t.control;
161
+ const e = (t = m.current) == null ? void 0 : t.control;
160
162
  return () => {
161
163
  e == null || e.scrollIntoView({
162
164
  behavior: "smooth",
@@ -164,80 +166,80 @@ function Me({
164
166
  });
165
167
  };
166
168
  }, [b]);
167
- const [C, O] = S(""), {
169
+ const [C, L] = B(""), {
168
170
  value: k
169
- } = s, [x, I] = S(k), [B, te] = S(k), G = K(B), u = d((e) => {
171
+ } = o, [x, N] = B(k), [D, te] = B(k), G = K(D), u = l((e) => {
170
172
  te(e), G.current = e;
171
173
  }, []);
172
174
  h(() => {
173
- I(k), u(k);
175
+ N(k), u(k);
174
176
  }, [k, u]), h(() => {
175
177
  if (k === void 0)
176
178
  return;
177
- const e = o.find((t) => t.value === k);
178
- e && O(F(e));
179
- }, [o, k]), h(() => {
180
- k === void 0 && O("");
179
+ const e = r.find((t) => t.value === k);
180
+ e && L(T(e));
181
+ }, [r, k]), h(() => {
182
+ k === void 0 && L("");
181
183
  }, [k]);
182
- const re = d(() => {
183
- x && (O(""), u(void 0));
184
- }, [x, u]), ne = d((e, t) => {
185
- O(e), c == null || c(e, t), i(!0), I(void 0);
186
- }, [c]), oe = d((e) => {
184
+ const ne = l(() => {
185
+ x && (L(""), u(void 0));
186
+ }, [x, u]), re = l((e, t) => {
187
+ L(e), c == null || c(e, t), i(!0), N(void 0);
188
+ }, [c]), oe = l((e) => {
187
189
  var t;
188
- (t = n.current) != null && t.contains(e.target) && i(!0);
189
- }, []), y = d((e) => {
190
+ (t = m.current) != null && t.contains(e.target) && i(!0);
191
+ }, []), V = l((e) => {
190
192
  const t = e == null ? void 0 : e.value;
191
- u(t), e ? O(F(e)) : (O(""), c == null || c("")), p == null || p(t);
192
- }, [u, c, p]), se = d((e) => {
193
- const t = o.find((L) => L.value === e);
194
- y(t), I(e), i(!1);
195
- }, [o, y]), ae = d((e) => {
193
+ u(t), e ? L(T(e)) : (L(""), c == null || c("")), w == null || w(t);
194
+ }, [u, c, w]), se = l((e) => {
195
+ const t = r.find((M) => M.value === e);
196
+ V(t), N(e), i(!1);
197
+ }, [r, V]), ae = l((e) => {
196
198
  u(e);
197
- }, [u]), D = ce(C), v = Z(() => !m || x ? o : me(D, o, F), [m, x, o, D]);
199
+ }, [u]), F = ce(C), p = Z(() => !f || x ? r : me(F, r, T), [f, x, r, F]);
198
200
  h(() => {
199
- !x && D.length > 0 && v.length > 0 && !v.some((e) => B === e.value) && u(v[0].value);
200
- }, [x, D, v, B, u]);
201
+ !x && F.length > 0 && p.length > 0 && !p.some((e) => D === e.value) && u(p[0].value);
202
+ }, [x, F, p, D, u]);
201
203
  const {
202
- setIsKeyboardNavigating: R
203
- } = X();
204
+ setIsKeyboardNavigating: S
205
+ } = Y();
204
206
  return h(() => {
205
- if (E)
207
+ if (O)
206
208
  return pe((e) => {
207
- e.movementX === 0 && e.movementY === 0 || R(!1);
209
+ e.movementX === 0 && e.movementY === 0 || S(!1);
208
210
  });
209
- }, [E, R]), h(() => {
210
- if (E)
211
+ }, [O, S]), h(() => {
212
+ if (O)
211
213
  return be((e) => {
212
214
  var J;
213
215
  let t;
214
- const L = v.length, A = v.findIndex((a) => a.value === G.current), w = () => {
216
+ const M = p.length, z = p.findIndex((s) => s.value === G.current), y = () => {
215
217
  e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation();
216
218
  };
217
219
  switch (e.key) {
218
220
  case "Enter": {
219
- const a = v[A];
220
- a && b && (w(), R(!0), i(!1), y(a), I(a.value));
221
+ const s = p[z];
222
+ s && b && (y(), S(!0), i(!1), V(s), N(s.value));
221
223
  break;
222
224
  }
223
225
  case "Escape": {
224
226
  if (b)
225
- w(), x ? u(void 0) : y(void 0), i(!1);
227
+ y(), x ? u(void 0) : V(void 0), i(!1);
226
228
  else if (x)
227
- w(), i(!0), y(void 0), I(void 0);
229
+ y(), i(!0), V(void 0), N(void 0);
228
230
  else {
229
- w(), H(!1);
230
- const a = document.activeElement;
231
- a instanceof HTMLElement && ((J = n.current) != null && J.contains(a)) && a.blur();
231
+ y(), P(!1);
232
+ const s = document.activeElement;
233
+ s instanceof HTMLElement && ((J = m.current) != null && J.contains(s)) && s.blur();
232
234
  }
233
235
  return;
234
236
  }
235
237
  case "ArrowDown": {
236
- w(), b && (t = A + 1), i(!0);
238
+ y(), b && (t = z + 1), i(!0);
237
239
  break;
238
240
  }
239
241
  case "ArrowUp": {
240
- w(), b && (t = A - 1, t < 0 && (t = L - 1)), i(!0);
242
+ y(), b && (t = z - 1, t < 0 && (t = M - 1)), i(!0);
241
243
  break;
242
244
  }
243
245
  case "Home": {
@@ -245,22 +247,22 @@ function Me({
245
247
  break;
246
248
  }
247
249
  case "End": {
248
- i(!0), t = L - 1;
250
+ i(!0), t = M - 1;
249
251
  break;
250
252
  }
251
253
  case "Backspace": {
252
- v.some((a) => a.value === x) && (w(), y(void 0), i(!0), I(void 0));
254
+ p.some((s) => s.value === x) && (y(), V(void 0), i(!0), N(void 0));
253
255
  break;
254
256
  }
255
257
  }
256
- if (t !== void 0 && (w(), R(!0), L > 0)) {
257
- const a = v[t % L];
258
- a && u(a.value);
258
+ if (t !== void 0 && (y(), S(!0), M > 0)) {
259
+ const s = p[t % M];
260
+ s && u(s.value);
259
261
  }
260
262
  });
261
- }, [E, v, R, i, y, I, b, x, u]), /* @__PURE__ */ l.jsx(fe, { ...s, ref: n, role: "combobox", autoComplete: "off", "aria-controls": Y, "aria-expanded": b, "aria-activedescendant": b ? q : void 0, label: M, value: C, error: g, warning: N, information: V, footnote: f, attachments: b ? /* @__PURE__ */ l.jsx(xe, { isLoading: r, id: Y, activeOptionId: q, selectedValue: B, options: v, onSelect: se, onHover: ae }) : null, className: T(j, "kakadu-components-1230689972"), onMouseDown: oe, onChange: ne, onBeforeInput: re, onFocus: $, onBlur: ee, children: /* @__PURE__ */ l.jsx(de, { width: 14, height: 14, className: "kakadu-components-158931186" }) });
263
+ }, [O, p, S, i, V, N, b, x, u]), /* @__PURE__ */ d.jsx(fe, { ...o, ref: m, role: "combobox", autoComplete: "off", "aria-controls": v, "aria-expanded": b, "aria-activedescendant": b ? q : void 0, label: R, value: C, error: g, warning: E, information: I, footnote: a, attachments: b ? /* @__PURE__ */ d.jsx(xe, { isLoading: n, id: v, activeOptionId: q, selectedValue: D, options: p, onSelect: se, onHover: ae }) : null, className: A(j, "kakadu-components-1230689972"), onMouseDown: oe, onChange: re, onBeforeInput: ne, onFocus: $, onBlur: ee, children: /* @__PURE__ */ d.jsx(de, { width: 14, height: 14, className: "kakadu-components-158931186" }) });
262
264
  }
263
265
  export {
264
- Me as default,
265
- F as getComboboxOptionString
266
+ Ke as default,
267
+ T as getComboboxOptionString
266
268
  };
@@ -1,8 +1,14 @@
1
- import React from 'react';
2
- export type GaugeProperties = {
1
+ import React, { type ReactNode } from 'react';
2
+ type GaugeDisplayProperties = {
3
3
  readonly label: string;
4
4
  readonly size?: 'small' | 'medium' | 'large';
5
5
  readonly percentage?: number;
6
+ readonly showSymbol?: boolean;
6
7
  readonly isAnimated?: boolean;
7
8
  };
8
- export default function Gauge({ label, size, percentage, isAnimated, }: GaugeProperties): React.JSX.Element;
9
+ export type GaugeProperties = GaugeDisplayProperties & {
10
+ readonly title?: ReactNode;
11
+ readonly description?: ReactNode;
12
+ };
13
+ export default function Gauge({ title, description, ...properties }: GaugeProperties): React.JSX.Element;
14
+ export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("../jsx-runtime-CZa898vN.js"),s=require("react"),N=require("@kuma-ui/core"),D={0:["#D60D43"],15:["#D60D43","#FFCD45"],30:["#D6460D","#ffda54"],50:["#D6860D","#F1DC3B","#CEE838"],65:["#D6BE0D","#FFD045","#6DE838"],80:["#D9E838","#93E838","#3EE838"],100:["#55EB62","#38E99A","#5EEA52"]},R=Object.keys(D).map(r=>Number.parseInt(r,10)).sort((r,c)=>c-r);function b({label:r,size:c,percentage:u=0,isAnimated:i}){const[d,l]=s.useState(u);s.useEffect(()=>{if(i){l(0);const a=300,m=10,g=30,k=.65,p=[];let E=a;for(let n=0;n<u;n+=1){const y=(n+1)/u,j=Math.min(Math.max((y-k)/(1-k),0),1),C=1-(1-j)*(1-j);E+=m+g*C,p.push(setTimeout(()=>{l(n+1)},E))}return()=>{for(const n of p)clearTimeout(n)}}l(u)},[i,u]);const e=s.useMemo(()=>Math.max(0,Math.min(100,d)),[d]),f=s.useMemo(()=>e/100,[e]),t=s.useMemo(()=>{for(const a of R)if(e>=a)return D[a];return[]},[e]),x=s.useMemo(()=>t.length,[t]),h=s.useMemo(()=>t.at(0),[t]),M=s.useMemo(()=>t.at(-1),[t]),v=s.useMemo(()=>t.map((a,m)=>`${a} ${Math.round(m/x*100)}%`).join(", "),[t,x]);return o.jsxRuntimeExports.jsxs("div",{style:{"--percentage":`${e}%`,"--percentage-factor":f,"--gradient":v,"--start-color":h,"--end-color":M},role:"meter","aria-valuenow":e,"aria-valuemin":0,"aria-valuemax":100,"aria-label":r,className:N.cx("kakadu-components-2176404336",c==="small"&&"kakadu-components-3162945807",c==="large"&&"kakadu-components-2977513648"),children:[e>0?o.jsxRuntimeExports.jsx("div",{className:"kakadu-components-707327569"}):null,o.jsxRuntimeExports.jsx("div",{className:"kakadu-components-2636723344",children:o.jsxRuntimeExports.jsx("div",{className:"kakadu-components-2810161405"})}),o.jsxRuntimeExports.jsx("div",{className:"kakadu-components-1913523229",children:e}),e>0&&e<100?o.jsxRuntimeExports.jsx("div",{className:"kakadu-components-967240013",children:o.jsxRuntimeExports.jsx("div",{className:"kakadu-components-3225063030"})}):null]})}exports.default=b;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../jsx-runtime-CZa898vN.js"),s=require("react"),M=require("@kuma-ui/core"),x=require("./text.js"),R=require("./flex.js"),N={0:["#D60D43"],15:["#D60D43","#FFCD45"],30:["#D6460D","#ffda54"],50:["#D6860D","#F1DC3B","#CEE838"],65:["#D6BE0D","#FFD045","#6DE838"],80:["#D9E838","#93E838","#3EE838"],100:["#55EB62","#38E99A","#5EEA52"]},P=Object.keys(N).map(t=>Number.parseInt(t,10)).sort((t,n)=>n-t);function g({label:t,size:n,percentage:o=0,showSymbol:d=!0,isAnimated:p}){const[j,m]=s.useState(o);s.useEffect(()=>{if(p){m(0);const u=300,i=10,q=30,E=.65,f=[];let h=u;for(let c=0;c<o;c+=1){const F=(c+1)/o,D=Math.min(Math.max((F-E)/(1-E),0),1),$=1-(1-D)*(1-D);h+=i+q*$,f.push(setTimeout(()=>{m(c+1)},h))}return()=>{for(const c of f)clearTimeout(c)}}m(o)},[p,o]);const r=s.useMemo(()=>Math.max(0,Math.min(100,j)),[j]),v=s.useMemo(()=>r/100,[r]),a=s.useMemo(()=>{for(const u of P)if(r>=u)return N[u];return[]},[r]),k=s.useMemo(()=>a.length,[a]),y=s.useMemo(()=>a.at(0),[a]),C=s.useMemo(()=>a.at(-1),[a]),b=s.useMemo(()=>a.map((u,i)=>`${u} ${Math.round(i/k*100)}%`).join(", "),[a,k]),l=s.useMemo(()=>Math.round(r),[r]);return e.jsxRuntimeExports.jsxs("div",{style:{"--percentage":`${l}%`,"--percentage-factor":v,"--gradient":b,"--start-color":y,"--end-color":C},role:"meter","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":t,className:M.cx("kakadu-components-3163931049",n==="small"&&"kakadu-components-1272093092",n==="large"&&"kakadu-components-553520060"),children:[l>0?e.jsxRuntimeExports.jsx("div",{className:"kakadu-components-707327569"}):null,e.jsxRuntimeExports.jsx("div",{className:"kakadu-components-2636723344",children:e.jsxRuntimeExports.jsx("div",{className:"kakadu-components-2810161405"})}),e.jsxRuntimeExports.jsxs("div",{className:"kakadu-components-114088345",children:[e.jsxRuntimeExports.jsx("span",{className:M.cx("kakadu-components-3402528359",d&&"kakadu-components-3473805935"),children:l}),d?e.jsxRuntimeExports.jsx(x.Span,{className:"kakadu-components-810313368",children:"%"}):null]}),l>0&&l<100?e.jsxRuntimeExports.jsx("div",{className:"kakadu-components-967240013",children:e.jsxRuntimeExports.jsx("div",{className:"kakadu-components-3225063030"})}):null]})}function S({title:t,description:n,...o}){return!t&&!n?e.jsxRuntimeExports.jsx(g,{...o}):e.jsxRuntimeExports.jsxs(R.default,{preset:"center",gap:1.5,children:[e.jsxRuntimeExports.jsx(g,{...o}),e.jsxRuntimeExports.jsxs(R.default,{preset:"center",gap:.25,children:[t?e.jsxRuntimeExports.jsx(x.Label,{className:"kakadu-components-1477072149",children:t}):null,n?e.jsxRuntimeExports.jsx(x.Span,{className:"kakadu-components-2235337211",children:n}):null]})]})}exports.default=S;