@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.
- package/build/components/code.js +1 -1
- package/build/components/code.mjs +20 -17
- package/build/components/combobox.js +1 -1
- package/build/components/combobox.mjs +139 -137
- package/build/components/gauge.d.ts +9 -3
- package/build/components/gauge.js +1 -1
- package/build/components/gauge.mjs +60 -41
- package/build/components.css +1 -1
- package/package.json +10 -10
|
@@ -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
|
|
4726
|
-
if (
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
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
|
-
)
|
|
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"),
|
|
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
|
|
2
|
-
import { useRef as K, useId as Q, useState as
|
|
3
|
-
import { cx as
|
|
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
|
|
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 = _((
|
|
14
|
-
window.addEventListener("mousemove",
|
|
13
|
+
const pe = _((n) => {
|
|
14
|
+
window.addEventListener("mousemove", n, {
|
|
15
15
|
capture: !0
|
|
16
16
|
});
|
|
17
|
-
}, (
|
|
18
|
-
window.removeEventListener("mousemove",
|
|
17
|
+
}, (n) => {
|
|
18
|
+
window.removeEventListener("mousemove", n, {
|
|
19
19
|
capture: !0
|
|
20
20
|
});
|
|
21
|
-
}), be = _((
|
|
22
|
-
window.addEventListener("keydown",
|
|
21
|
+
}), be = _((n) => {
|
|
22
|
+
window.addEventListener("keydown", n, {
|
|
23
23
|
capture: !0
|
|
24
24
|
});
|
|
25
|
-
}, (
|
|
26
|
-
window.removeEventListener("keydown",
|
|
25
|
+
}, (n) => {
|
|
26
|
+
window.removeEventListener("keydown", n, {
|
|
27
27
|
capture: !0
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
|
-
function
|
|
30
|
+
function Y() {
|
|
31
31
|
const {
|
|
32
|
-
value:
|
|
33
|
-
setValue:
|
|
32
|
+
value: n,
|
|
33
|
+
setValue: f
|
|
34
34
|
} = ue("isKeyboardNavigating");
|
|
35
35
|
return Z(() => ({
|
|
36
|
-
isKeyboardNavigating:
|
|
37
|
-
setIsKeyboardNavigating:
|
|
38
|
-
}), [
|
|
36
|
+
isKeyboardNavigating: n,
|
|
37
|
+
setIsKeyboardNavigating: f
|
|
38
|
+
}), [n, f]);
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
return "text" in
|
|
40
|
+
function T(n) {
|
|
41
|
+
return "text" in n ? n.text : n.label;
|
|
42
42
|
}
|
|
43
|
-
const
|
|
43
|
+
const U = "kakadu-components-1144794361", X = "kakadu-components-2911184744";
|
|
44
44
|
function ke({
|
|
45
|
-
ref:
|
|
46
|
-
isSelected:
|
|
47
|
-
id:
|
|
48
|
-
value:
|
|
45
|
+
ref: n,
|
|
46
|
+
isSelected: f,
|
|
47
|
+
id: R,
|
|
48
|
+
value: r,
|
|
49
49
|
label: g,
|
|
50
|
-
onSelect:
|
|
51
|
-
onHover:
|
|
50
|
+
onSelect: E,
|
|
51
|
+
onHover: I
|
|
52
52
|
}) {
|
|
53
53
|
const {
|
|
54
|
-
isKeyboardNavigating:
|
|
55
|
-
} =
|
|
56
|
-
|
|
57
|
-
}, [
|
|
58
|
-
|
|
59
|
-
}, [
|
|
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
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
}, [
|
|
69
|
-
const
|
|
70
|
+
}, [f, a]);
|
|
71
|
+
const m = l(
|
|
70
72
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
71
|
-
(
|
|
72
|
-
|
|
73
|
+
(v) => {
|
|
74
|
+
o.current = v, n && (n.current = v);
|
|
73
75
|
},
|
|
74
|
-
[
|
|
76
|
+
[n]
|
|
75
77
|
);
|
|
76
|
-
return /* @__PURE__ */
|
|
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:
|
|
80
|
-
id:
|
|
81
|
-
activeOptionId:
|
|
82
|
-
selectedValue:
|
|
81
|
+
isLoading: n,
|
|
82
|
+
id: f,
|
|
83
|
+
activeOptionId: R,
|
|
84
|
+
selectedValue: r,
|
|
83
85
|
options: g,
|
|
84
|
-
onSelect:
|
|
85
|
-
onHover:
|
|
86
|
+
onSelect: E,
|
|
87
|
+
onHover: I
|
|
86
88
|
}) {
|
|
87
|
-
const
|
|
89
|
+
const a = K(null);
|
|
88
90
|
h(() => {
|
|
89
|
-
const
|
|
90
|
-
|
|
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
|
-
} =
|
|
98
|
-
return
|
|
99
|
-
const
|
|
100
|
-
if (
|
|
101
|
-
if (
|
|
102
|
-
const
|
|
103
|
-
if (
|
|
104
|
-
|
|
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
|
-
|
|
112
|
+
o.scrollTo({
|
|
111
113
|
top: 0
|
|
112
114
|
});
|
|
113
115
|
}
|
|
114
|
-
}, [g]), /* @__PURE__ */
|
|
115
|
-
g.length === 0 ?
|
|
116
|
-
/* @__PURE__ */
|
|
117
|
-
/* @__PURE__ */
|
|
118
|
-
] }) : g.map((
|
|
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
|
-
...
|
|
122
|
-
ref:
|
|
123
|
-
id:
|
|
124
|
-
isSelected:
|
|
125
|
-
onSelect:
|
|
126
|
-
onHover:
|
|
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
|
-
|
|
130
|
+
T(o) + m
|
|
129
131
|
)),
|
|
130
|
-
|
|
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
|
|
134
|
-
isLoading:
|
|
135
|
-
shouldFilterOptions:
|
|
136
|
-
label:
|
|
137
|
-
options:
|
|
135
|
+
function Ke({
|
|
136
|
+
isLoading: n,
|
|
137
|
+
shouldFilterOptions: f = !0,
|
|
138
|
+
label: R,
|
|
139
|
+
options: r,
|
|
138
140
|
error: g,
|
|
139
|
-
warning:
|
|
140
|
-
information:
|
|
141
|
-
footnote:
|
|
141
|
+
warning: E,
|
|
142
|
+
information: I,
|
|
143
|
+
footnote: a,
|
|
142
144
|
className: j,
|
|
143
145
|
onChange: c,
|
|
144
|
-
onSelect:
|
|
145
|
-
...
|
|
146
|
+
onSelect: w,
|
|
147
|
+
...o
|
|
146
148
|
}) {
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
}, []), ee =
|
|
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 =
|
|
152
|
-
}, []), [b, i] =
|
|
153
|
+
(t = m.current) != null && t.contains(e.relatedTarget) || P(!1);
|
|
154
|
+
}, []), [b, i] = B(!1);
|
|
153
155
|
h(() => {
|
|
154
|
-
i(
|
|
155
|
-
}, [
|
|
156
|
+
i(O);
|
|
157
|
+
}, [O]), h(() => {
|
|
156
158
|
var t;
|
|
157
159
|
if (!b)
|
|
158
160
|
return;
|
|
159
|
-
const e = (t =
|
|
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,
|
|
169
|
+
const [C, L] = B(""), {
|
|
168
170
|
value: k
|
|
169
|
-
} =
|
|
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
|
-
|
|
175
|
+
N(k), u(k);
|
|
174
176
|
}, [k, u]), h(() => {
|
|
175
177
|
if (k === void 0)
|
|
176
178
|
return;
|
|
177
|
-
const e =
|
|
178
|
-
e &&
|
|
179
|
-
}, [
|
|
180
|
-
k === void 0 &&
|
|
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
|
|
183
|
-
x && (
|
|
184
|
-
}, [x, u]),
|
|
185
|
-
|
|
186
|
-
}, [c]), oe =
|
|
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 =
|
|
189
|
-
}, []),
|
|
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 ?
|
|
192
|
-
}, [u, c,
|
|
193
|
-
const t =
|
|
194
|
-
|
|
195
|
-
}, [
|
|
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]),
|
|
199
|
+
}, [u]), F = ce(C), p = Z(() => !f || x ? r : me(F, r, T), [f, x, r, F]);
|
|
198
200
|
h(() => {
|
|
199
|
-
!x &&
|
|
200
|
-
}, [x,
|
|
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:
|
|
203
|
-
} =
|
|
204
|
+
setIsKeyboardNavigating: S
|
|
205
|
+
} = Y();
|
|
204
206
|
return h(() => {
|
|
205
|
-
if (
|
|
207
|
+
if (O)
|
|
206
208
|
return pe((e) => {
|
|
207
|
-
e.movementX === 0 && e.movementY === 0 ||
|
|
209
|
+
e.movementX === 0 && e.movementY === 0 || S(!1);
|
|
208
210
|
});
|
|
209
|
-
}, [
|
|
210
|
-
if (
|
|
211
|
+
}, [O, S]), h(() => {
|
|
212
|
+
if (O)
|
|
211
213
|
return be((e) => {
|
|
212
214
|
var J;
|
|
213
215
|
let t;
|
|
214
|
-
const
|
|
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
|
|
220
|
-
|
|
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
|
-
|
|
227
|
+
y(), x ? u(void 0) : V(void 0), i(!1);
|
|
226
228
|
else if (x)
|
|
227
|
-
|
|
229
|
+
y(), i(!0), V(void 0), N(void 0);
|
|
228
230
|
else {
|
|
229
|
-
|
|
230
|
-
const
|
|
231
|
-
|
|
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
|
-
|
|
238
|
+
y(), b && (t = z + 1), i(!0);
|
|
237
239
|
break;
|
|
238
240
|
}
|
|
239
241
|
case "ArrowUp": {
|
|
240
|
-
|
|
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 =
|
|
250
|
+
i(!0), t = M - 1;
|
|
249
251
|
break;
|
|
250
252
|
}
|
|
251
253
|
case "Backspace": {
|
|
252
|
-
|
|
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 && (
|
|
257
|
-
const
|
|
258
|
-
|
|
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
|
-
}, [
|
|
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
|
-
|
|
265
|
-
|
|
266
|
+
Ke as default,
|
|
267
|
+
T as getComboboxOptionString
|
|
266
268
|
};
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
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
|
|
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
|
|
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;
|