@kakadu/components 6.17.1 → 6.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../jsx-runtime-CZa898vN.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../jsx-runtime-CZa898vN.js"),a=require("react"),N=require("@kuma-ui/core"),P=require("../utilities/clamp.js"),x=require("./text.js"),g=require("./flex.js"),M={0:["#D60D43"],15:["#D60D43","#FFCD45"],30:["#D6460D","#ffda54"],50:["#D6860D","#F1DC3B","#CEE838"],65:["#D6BE0D","#FFD045","#6DE838"],80:["#D9E838","#93E838","#3EE838"],100:["#55EB62","#38E99A","#5EEA52"]},S=Object.keys(M).map(s=>Number.parseInt(s,10)).sort((s,t)=>t-s);function v({label:s,size:t,percentage:n=0,isInverted:y,showSymbol:d=!0,isAnimated:p}){const[j,l]=a.useState(n);a.useEffect(()=>{if(p){l(0);const u=300,i=10,F=30,f=.65,D=[];let h=u;for(let c=0;c<n;c+=1){const _=(c+1)/n,R=Math.min(Math.max((_-f)/(1-f),0),1),$=1-(1-R)*(1-R);h+=i+F*$,D.push(setTimeout(()=>{l(c+1)},h))}return()=>{for(const c of D)clearTimeout(c)}}l(n)},[p,n]);const k=a.useMemo(()=>P.default(j,0,100),[j]),m=Math.round(k),r=y?100-m:m,o=a.useMemo(()=>{for(const u of S)if(r>=u)return M[u];return[]},[r]),E=a.useMemo(()=>o.length,[o]),C=a.useMemo(()=>o.at(0),[o]),b=a.useMemo(()=>o.at(-1),[o]),q=a.useMemo(()=>o.map((u,i)=>`${u} ${Math.round(i/E*100)}%`).join(", "),[o,E]);return e.jsxRuntimeExports.jsxs("div",{style:{"--percentage":`${r}%`,"--percentage-factor":r/100,"--gradient":q,"--start-color":C,"--end-color":b},role:"meter","aria-valuenow":k,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s,className:N.cx("kakadu-components-3163931049",t==="small"&&"kakadu-components-1272093092",t==="large"&&"kakadu-components-553520060"),children:[r>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:N.cx("kakadu-components-3402528359",d&&"kakadu-components-3473805935"),children:m}),d?e.jsxRuntimeExports.jsx(x.Span,{className:"kakadu-components-810313368",children:"%"}):null]}),r>0&&r<100?e.jsxRuntimeExports.jsx("div",{className:"kakadu-components-967240013",children:e.jsxRuntimeExports.jsx("div",{className:"kakadu-components-3225063030"})}):null]})}function T({title:s,description:t,...n}){return!s&&!t?e.jsxRuntimeExports.jsx(v,{...n}):e.jsxRuntimeExports.jsxs(g.default,{preset:"center",gap:1.5,children:[e.jsxRuntimeExports.jsx(v,{...n}),e.jsxRuntimeExports.jsxs(g.default,{preset:"center",gap:.25,children:[s?e.jsxRuntimeExports.jsx(x.Label,{className:"kakadu-components-1477072149",children:s}):null,t?e.jsxRuntimeExports.jsx(x.Span,{className:"kakadu-components-2235337211",children:t}):null]})]})}exports.default=T;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { j as e } from "../jsx-runtime-z6PQ6F3d.mjs";
|
|
2
|
-
import { useState as
|
|
3
|
-
import { cx as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
2
|
+
import { useState as G, useEffect as L, useMemo as l } from "react";
|
|
3
|
+
import { cx as N } from "@kuma-ui/core";
|
|
4
|
+
import R from "../utilities/clamp.mjs";
|
|
5
|
+
import { Label as A, Span as C } from "./text.mjs";
|
|
6
|
+
import g from "./flex.mjs";
|
|
7
|
+
const y = {
|
|
7
8
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
8
9
|
0: ["#D60D43"],
|
|
9
10
|
15: ["#D60D43", "#FFCD45"],
|
|
@@ -13,68 +14,69 @@ const C = {
|
|
|
13
14
|
80: ["#D9E838", "#93E838", "#3EE838"],
|
|
14
15
|
100: ["#55EB62", "#38E99A", "#5EEA52"]
|
|
15
16
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
16
|
-
},
|
|
17
|
-
function
|
|
18
|
-
label:
|
|
19
|
-
size:
|
|
20
|
-
percentage:
|
|
17
|
+
}, I = Object.keys(y).map((s) => Number.parseInt(s, 10)).sort((s, a) => a - s);
|
|
18
|
+
function v({
|
|
19
|
+
label: s,
|
|
20
|
+
size: a,
|
|
21
|
+
percentage: o = 0,
|
|
22
|
+
isInverted: b,
|
|
21
23
|
showSymbol: i = !0,
|
|
22
24
|
isAnimated: k
|
|
23
25
|
}) {
|
|
24
|
-
const [p,
|
|
25
|
-
|
|
26
|
+
const [p, u] = G(o);
|
|
27
|
+
L(() => {
|
|
26
28
|
if (k) {
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
let
|
|
30
|
-
for (let
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
29
|
+
u(0);
|
|
30
|
+
const r = 300, d = 10, P = 30, j = 0.65, D = [];
|
|
31
|
+
let h = r;
|
|
32
|
+
for (let c = 0; c < o; c += 1) {
|
|
33
|
+
const T = (c + 1) / o, E = Math.min(Math.max((T - j) / (1 - j), 0), 1), $ = 1 - (1 - E) * (1 - E);
|
|
34
|
+
h += d + P * $, D.push(setTimeout(() => {
|
|
35
|
+
u(c + 1);
|
|
36
|
+
}, h));
|
|
35
37
|
}
|
|
36
38
|
return () => {
|
|
37
|
-
for (const
|
|
38
|
-
clearTimeout(
|
|
39
|
+
for (const c of D)
|
|
40
|
+
clearTimeout(c);
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
|
-
|
|
42
|
-
}, [k,
|
|
43
|
-
const
|
|
44
|
-
for (const
|
|
45
|
-
if (
|
|
46
|
-
return
|
|
43
|
+
u(o);
|
|
44
|
+
}, [k, o]);
|
|
45
|
+
const x = l(() => R(p, 0, 100), [p]), m = Math.round(x), t = b ? 100 - m : m, n = l(() => {
|
|
46
|
+
for (const r of I)
|
|
47
|
+
if (t >= r)
|
|
48
|
+
return y[r];
|
|
47
49
|
return [];
|
|
48
|
-
}, [
|
|
50
|
+
}, [t]), f = l(() => n.length, [n]), F = l(() => n.at(0), [n]), M = l(() => n.at(-1), [n]), B = l(() => n.map((r, d) => `${r} ${Math.round(d / f * 100)}%`).join(", "), [n, f]);
|
|
49
51
|
return /* @__PURE__ */ e.jsxs("div", { style: {
|
|
50
|
-
"--percentage": `${
|
|
51
|
-
"--percentage-factor":
|
|
52
|
-
"--gradient":
|
|
53
|
-
"--start-color":
|
|
54
|
-
"--end-color":
|
|
55
|
-
}, role: "meter", "aria-valuenow":
|
|
56
|
-
|
|
52
|
+
"--percentage": `${t}%`,
|
|
53
|
+
"--percentage-factor": t / 100,
|
|
54
|
+
"--gradient": B,
|
|
55
|
+
"--start-color": F,
|
|
56
|
+
"--end-color": M
|
|
57
|
+
}, role: "meter", "aria-valuenow": x, "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": s, className: N("kakadu-components-3163931049", a === "small" && "kakadu-components-1272093092", a === "large" && "kakadu-components-553520060"), children: [
|
|
58
|
+
t > 0 ? /* @__PURE__ */ e.jsx("div", { className: "kakadu-components-707327569" }) : null,
|
|
57
59
|
/* @__PURE__ */ e.jsx("div", { className: "kakadu-components-2636723344", children: /* @__PURE__ */ e.jsx("div", { className: "kakadu-components-2810161405" }) }),
|
|
58
60
|
/* @__PURE__ */ e.jsxs("div", { className: "kakadu-components-114088345", children: [
|
|
59
|
-
/* @__PURE__ */ e.jsx("span", { className:
|
|
60
|
-
i ? /* @__PURE__ */ e.jsx(
|
|
61
|
+
/* @__PURE__ */ e.jsx("span", { className: N("kakadu-components-3402528359", i && "kakadu-components-3473805935"), children: m }),
|
|
62
|
+
i ? /* @__PURE__ */ e.jsx(C, { className: "kakadu-components-810313368", children: "%" }) : null
|
|
61
63
|
] }),
|
|
62
|
-
|
|
64
|
+
t > 0 && t < 100 ? /* @__PURE__ */ e.jsx("div", { className: "kakadu-components-967240013", children: /* @__PURE__ */ e.jsx("div", { className: "kakadu-components-3225063030" }) }) : null
|
|
63
65
|
] });
|
|
64
66
|
}
|
|
65
|
-
function
|
|
66
|
-
title:
|
|
67
|
-
description:
|
|
68
|
-
...
|
|
67
|
+
function J({
|
|
68
|
+
title: s,
|
|
69
|
+
description: a,
|
|
70
|
+
...o
|
|
69
71
|
}) {
|
|
70
|
-
return !
|
|
71
|
-
/* @__PURE__ */ e.jsx(
|
|
72
|
-
/* @__PURE__ */ e.jsxs(
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
return !s && !a ? /* @__PURE__ */ e.jsx(v, { ...o }) : /* @__PURE__ */ e.jsxs(g, { preset: "center", gap: 1.5, children: [
|
|
73
|
+
/* @__PURE__ */ e.jsx(v, { ...o }),
|
|
74
|
+
/* @__PURE__ */ e.jsxs(g, { preset: "center", gap: 0.25, children: [
|
|
75
|
+
s ? /* @__PURE__ */ e.jsx(A, { className: "kakadu-components-1477072149", children: s }) : null,
|
|
76
|
+
a ? /* @__PURE__ */ e.jsx(C, { className: "kakadu-components-2235337211", children: a }) : null
|
|
75
77
|
] })
|
|
76
78
|
] });
|
|
77
79
|
}
|
|
78
80
|
export {
|
|
79
|
-
|
|
81
|
+
J as default
|
|
80
82
|
};
|