@voidable/ui 0.5.5 → 0.6.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/dist/chunks/{decorate-DKuCkHK4.js → decorate-CaYbmmmm.js} +1 -1
- package/dist/chunks/scale-_ccSuoYg.js +33 -0
- package/dist/chunks/shape-FJvZa8FW.js +52 -0
- package/dist/components/accordion.js +1 -1
- package/dist/components/action-input.js +1 -1
- package/dist/components/alert.js +1 -1
- package/dist/components/avatar.js +1 -1
- package/dist/components/badge.js +1 -1
- package/dist/components/banner.js +1 -1
- package/dist/components/bar-chart.d.ts +47 -0
- package/dist/components/bar-chart.d.ts.map +1 -0
- package/dist/components/bar-chart.js +151 -0
- package/dist/components/breadcrumbs.js +1 -1
- package/dist/components/button.js +1 -1
- package/dist/components/calendar.js +1 -1
- package/dist/components/card.js +1 -1
- package/dist/components/carousel.js +1 -1
- package/dist/components/charts/scale.d.ts +22 -0
- package/dist/components/charts/scale.d.ts.map +1 -0
- package/dist/components/charts/shape.d.ts +13 -0
- package/dist/components/charts/shape.d.ts.map +1 -0
- package/dist/components/checkbox-group.js +1 -1
- package/dist/components/checkbox.js +1 -1
- package/dist/components/collapsible.js +1 -1
- package/dist/components/color-picker.js +1 -1
- package/dist/components/combobox.js +1 -1
- package/dist/components/compose-input.js +1 -1
- package/dist/components/dialog.js +1 -1
- package/dist/components/divider.js +1 -1
- package/dist/components/donut-chart.d.ts +57 -0
- package/dist/components/donut-chart.d.ts.map +1 -0
- package/dist/components/donut-chart.js +187 -0
- package/dist/components/drawer.js +1 -1
- package/dist/components/dropdown-menu.js +1 -1
- package/dist/components/editable.js +1 -1
- package/dist/components/error-fallback.js +1 -1
- package/dist/components/field.js +1 -1
- package/dist/components/file-upload.js +1 -1
- package/dist/components/gauge.d.ts +102 -0
- package/dist/components/gauge.d.ts.map +1 -0
- package/dist/components/gauge.js +398 -0
- package/dist/components/hamburger.js +1 -1
- package/dist/components/hover-card.js +1 -1
- package/dist/components/indicator.js +1 -1
- package/dist/components/input.js +1 -1
- package/dist/components/line-chart.d.ts +47 -0
- package/dist/components/line-chart.d.ts.map +1 -0
- package/dist/components/line-chart.js +216 -0
- package/dist/components/list.js +1 -1
- package/dist/components/menu.js +1 -1
- package/dist/components/multiselect.js +1 -1
- package/dist/components/nav-bar.js +1 -1
- package/dist/components/nav-menu.js +1 -1
- package/dist/components/number-input.d.ts +2 -0
- package/dist/components/number-input.d.ts.map +1 -1
- package/dist/components/number-input.js +15 -13
- package/dist/components/pagination.js +1 -1
- package/dist/components/panel.js +1 -1
- package/dist/components/pin-input.js +1 -1
- package/dist/components/popover.js +1 -1
- package/dist/components/progress.js +1 -1
- package/dist/components/radio-group.js +1 -1
- package/dist/components/radio.js +1 -1
- package/dist/components/scroll-area.js +1 -1
- package/dist/components/segmented-control.js +1 -1
- package/dist/components/select.js +1 -1
- package/dist/components/sidebar.js +1 -1
- package/dist/components/skeleton.js +1 -1
- package/dist/components/slider.js +1 -1
- package/dist/components/spinner.js +1 -1
- package/dist/components/stat.js +1 -1
- package/dist/components/status-dot.js +1 -1
- package/dist/components/stepper.js +1 -1
- package/dist/components/switch.js +1 -1
- package/dist/components/table.js +1 -1
- package/dist/components/tabs.js +1 -1
- package/dist/components/tag.js +1 -1
- package/dist/components/tags-input.js +1 -1
- package/dist/components/textarea.js +1 -1
- package/dist/components/toast.js +1 -1
- package/dist/components/toggle-group.js +1 -1
- package/dist/components/toggle.js +1 -1
- package/dist/components/tooltip.js +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/package.json +1 -5
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { t as e } from "../chunks/decorate-CaYbmmmm.js";
|
|
2
|
+
import { LitElement as t, html as n, nothing as r, svg as i } from "lit";
|
|
3
|
+
import { property as a, state as o } from "lit/decorators.js";
|
|
4
|
+
//#region src/components/gauge.ts
|
|
5
|
+
function s(e) {
|
|
6
|
+
return 1 - (1 - e) ** 3;
|
|
7
|
+
}
|
|
8
|
+
function c(e) {
|
|
9
|
+
return Math.abs(e) >= 1e6 ? `${(e / 1e6).toFixed(1)}M` : Math.abs(e) >= 1e3 ? `${(e / 1e3).toFixed(e >= 1e4 ? 0 : 1)}k` : Math.round(e).toString();
|
|
10
|
+
}
|
|
11
|
+
function l(e, t, n, r, i) {
|
|
12
|
+
let a = i - r, o = Math.abs(a) >= 2 * Math.PI ? r + Math.sign(a) * (2 * Math.PI - 1e-4) : i, s = e + n * Math.cos(r), c = t + n * Math.sin(r), l = e + n * Math.cos(o), u = t + n * Math.sin(o), d = +(Math.abs(o - r) > Math.PI), f = +(o - r >= 0);
|
|
13
|
+
return `M ${s.toFixed(2)} ${c.toFixed(2)} A ${n} ${n} 0 ${d} ${f} ${l.toFixed(2)} ${u.toFixed(2)}`;
|
|
14
|
+
}
|
|
15
|
+
function u(e, t, n, r, i, a) {
|
|
16
|
+
let o = n + r / 2, s = Math.max(0, n - r / 2), c = r / 2, l = a - i, u = Math.abs(l) >= 2 * Math.PI ? i + Math.sign(l) * (2 * Math.PI - 1e-4) : a, d = e + o * Math.cos(i), f = t + o * Math.sin(i), p = e + o * Math.cos(u), m = t + o * Math.sin(u), h = e + s * Math.cos(i), g = t + s * Math.sin(i), _ = e + s * Math.cos(u), v = t + s * Math.sin(u), y = +(Math.abs(u - i) > Math.PI);
|
|
17
|
+
return `M ${d.toFixed(2)} ${f.toFixed(2)} A ${o} ${o} 0 ${y} 1 ${p.toFixed(2)} ${m.toFixed(2)} A ${c} ${c} 0 0 1 ${_.toFixed(2)} ${v.toFixed(2)} A ${s} ${s} 0 ${y} 0 ${h.toFixed(2)} ${g.toFixed(2)} A ${c} ${c} 0 0 1 ${d.toFixed(2)} ${f.toFixed(2)} Z`;
|
|
18
|
+
}
|
|
19
|
+
function d(e, t, n, r, i, a, o, s) {
|
|
20
|
+
let c = n + r / 2, l = Math.max(0, n - r / 2), u = r / 2, d = a - i, f = Math.abs(d) >= 2 * Math.PI ? i + Math.sign(d) * (2 * Math.PI - 1e-4) : a, p = e + c * Math.cos(i), m = t + c * Math.sin(i), h = e + c * Math.cos(f), g = t + c * Math.sin(f), _ = e + l * Math.cos(i), v = t + l * Math.sin(i), y = e + l * Math.cos(f), b = t + l * Math.sin(f), x = +(Math.abs(f - i) > Math.PI), S = `M ${p.toFixed(2)} ${m.toFixed(2)} `;
|
|
21
|
+
return S += `A ${c} ${c} 0 ${x} 1 ${h.toFixed(2)} ${g.toFixed(2)} `, s === "round" ? S += `A ${u} ${u} 0 0 1 ${y.toFixed(2)} ${b.toFixed(2)} ` : S += `L ${y.toFixed(2)} ${b.toFixed(2)} `, S += `A ${l} ${l} 0 ${x} 0 ${_.toFixed(2)} ${v.toFixed(2)} `, o === "round" ? S += `A ${u} ${u} 0 0 1 ${p.toFixed(2)} ${m.toFixed(2)} ` : o === "cup" ? S += `A ${u} ${u} 0 0 0 ${p.toFixed(2)} ${m.toFixed(2)} ` : S += `L ${p.toFixed(2)} ${m.toFixed(2)} `, S += "Z", S;
|
|
22
|
+
}
|
|
23
|
+
var f = 1.5 * 5;
|
|
24
|
+
function p(e) {
|
|
25
|
+
let t = Math.PI;
|
|
26
|
+
return e === "full" ? {
|
|
27
|
+
startAngle: -t / 2,
|
|
28
|
+
endAngle: -t / 2 + 2 * t,
|
|
29
|
+
totalSweep: 2 * t
|
|
30
|
+
} : e === "semi" ? {
|
|
31
|
+
startAngle: -t,
|
|
32
|
+
endAngle: 0,
|
|
33
|
+
totalSweep: t
|
|
34
|
+
} : {
|
|
35
|
+
startAngle: 3 * t / 4,
|
|
36
|
+
endAngle: t / 4 + 2 * t,
|
|
37
|
+
totalSweep: 3 * t / 2
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
var m = class extends t {
|
|
41
|
+
constructor(...e) {
|
|
42
|
+
super(...e), this.unit = "", this.value = 0, this.min = 0, this.max = 100, this.size = 220, this.thickness = 14, this.circular = "triple", this.variant = "filled", this.showValue = !0, this.unitInline = !1, this.tickMajor = 0, this.tickMinor = 0, this.tickMin = !0, this.tickMax = !0, this.segmentsSort = "value", this.gaps = !1, this.ariaLabel = "", this.zones = [], this._data = {}, this._phase = "pre", this._hoverSegment = null, this._hoverX = 0, this._hoverY = 0, this._displayValue = 0, this._displayValueFrom = 0, this._targetValue = 0, this._displaySegments = /* @__PURE__ */ new Map(), this._segmentsFrom = /* @__PURE__ */ new Map(), this._targetSegments = /* @__PURE__ */ new Map(), this._animStart = 0, this._animDuration = 0, this._rafHandle = 0, this._onMouseMove = (e) => {
|
|
43
|
+
let t = this.querySelector("svg");
|
|
44
|
+
if (!t) return;
|
|
45
|
+
let n = this._data.segments;
|
|
46
|
+
if (!n || n.length === 0) {
|
|
47
|
+
this._hoverSegment !== null && (this._hoverSegment = null);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
let r = t.getBoundingClientRect();
|
|
51
|
+
if (r.width === 0) return;
|
|
52
|
+
let i = this._viewBoxHeight(), a = (e.clientX - r.left) / r.width * this.size, o = (e.clientY - r.top) / r.height * i, s = this.size / 2, c = this.size / 2, l = a - s, u = o - c, d = Math.sqrt(l * l + u * u), f = this.size / 2 - Math.max(8, this.thickness / 2), m = this.thickness / 2;
|
|
53
|
+
if (d < f - m || d > f + m) {
|
|
54
|
+
this._hoverSegment !== null && (this._hoverSegment = null);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
let { startAngle: h, totalSweep: g } = p(this.circular), _ = h + g, v = Math.atan2(u, l);
|
|
58
|
+
for (; v < h;) v += 2 * Math.PI;
|
|
59
|
+
for (; v > h + 2 * Math.PI;) v -= 2 * Math.PI;
|
|
60
|
+
if (v > _) {
|
|
61
|
+
this._hoverSegment !== null && (this._hoverSegment = null);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
let y = this.max - this.min === 0 ? 0 : (this._displayValue - this.min) / (this.max - this.min), b = h + Math.max(0, Math.min(1, y)) * g;
|
|
65
|
+
if (v > b) {
|
|
66
|
+
this._hoverSegment !== null && (this._hoverSegment = null);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
let x = this.segmentsSort === "value" ? [...n].sort((e, t) => t.value - e.value) : n, S = [...this._displaySegments.values()].reduce((e, t) => e + t, 0) || this._displayValue || 1, C = h;
|
|
70
|
+
for (let e = 0; e < x.length; e++) {
|
|
71
|
+
let t = x[e], r = n.indexOf(t), i = (this._displaySegments.get(r) ?? 0) / S * g;
|
|
72
|
+
if (v >= C && v < C + i) {
|
|
73
|
+
this._hoverSegment !== r && (this._hoverSegment = r), this._hoverX = a, this._hoverY = o;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
C += i;
|
|
77
|
+
}
|
|
78
|
+
this._hoverSegment !== null && (this._hoverSegment = null);
|
|
79
|
+
}, this._onMouseLeave = () => {
|
|
80
|
+
this._hoverSegment = null;
|
|
81
|
+
}, this._tick = (e) => {
|
|
82
|
+
let t = e - this._animStart, n = Math.min(t / this._animDuration, 1), r = s(n);
|
|
83
|
+
this._displayValue = this._displayValueFrom + (this._targetValue - this._displayValueFrom) * r;
|
|
84
|
+
for (let [e, t] of this._targetSegments) {
|
|
85
|
+
let n = this._segmentsFrom.get(e) ?? 0;
|
|
86
|
+
this._displaySegments.set(e, n + (t - n) * r);
|
|
87
|
+
}
|
|
88
|
+
this.requestUpdate(), n < 1 ? this._rafHandle = requestAnimationFrame(this._tick) : this._phase = "idle";
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
createRenderRoot() {
|
|
92
|
+
return this;
|
|
93
|
+
}
|
|
94
|
+
get data() {
|
|
95
|
+
return this._data;
|
|
96
|
+
}
|
|
97
|
+
set data(e) {
|
|
98
|
+
let t = this._data, n = this._displayValue, r = new Map(this._displaySegments);
|
|
99
|
+
this._data = e, this._refreshTargets(), this.requestUpdate(), this.updateComplete.then(() => {
|
|
100
|
+
let i = t.segments ?? [], a = /* @__PURE__ */ new Map();
|
|
101
|
+
for (let e = 0; e < i.length; e++) a.set(e, r.get(e) ?? 0);
|
|
102
|
+
let o = e.segments ?? [];
|
|
103
|
+
for (let e = 0; e < o.length; e++) a.has(e) || a.set(e, 0);
|
|
104
|
+
this._startAnimation(a, n, !0);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
_refreshTargets() {
|
|
108
|
+
let e = this._data.segments ?? [];
|
|
109
|
+
this._targetSegments.clear();
|
|
110
|
+
for (let t = 0; t < e.length; t++) this._targetSegments.set(t, e[t].value);
|
|
111
|
+
this._targetValue = this._resolveTotal();
|
|
112
|
+
}
|
|
113
|
+
_resolveTotal() {
|
|
114
|
+
if (this._data.value !== void 0) return this._data.value;
|
|
115
|
+
let e = this._data.segments;
|
|
116
|
+
return e && e.length > 0 ? e.reduce((e, t) => e + t.value, 0) : this.value;
|
|
117
|
+
}
|
|
118
|
+
connectedCallback() {
|
|
119
|
+
super.connectedCallback(), this.setAttribute("role", "img"), this._refreshTargets(), requestAnimationFrame(() => {
|
|
120
|
+
let e = /* @__PURE__ */ new Map(), t = this._data.segments ?? [];
|
|
121
|
+
for (let n = 0; n < t.length; n++) e.set(n, 0);
|
|
122
|
+
this._startAnimation(e, 0, !1);
|
|
123
|
+
}), this.addEventListener("mousemove", this._onMouseMove), this.addEventListener("mouseleave", this._onMouseLeave);
|
|
124
|
+
}
|
|
125
|
+
disconnectedCallback() {
|
|
126
|
+
super.disconnectedCallback(), cancelAnimationFrame(this._rafHandle), this.removeEventListener("mousemove", this._onMouseMove), this.removeEventListener("mouseleave", this._onMouseLeave);
|
|
127
|
+
}
|
|
128
|
+
_startAnimation(e, t, n) {
|
|
129
|
+
cancelAnimationFrame(this._rafHandle);
|
|
130
|
+
let r = getComputedStyle(this), i = r.getPropertyValue("--void-anim-scale").trim(), a = i === "" ? 1 : parseFloat(i), o = parseFloat(r.getPropertyValue("--void-duration-chart-enter")) || 700;
|
|
131
|
+
if (this._animDuration = o * a, this._segmentsFrom = e, this._displayValueFrom = n ? t : 0, this._animStart = performance.now(), this._animDuration <= 0) {
|
|
132
|
+
this._displayValue = this._targetValue, this._displaySegments = new Map(this._targetSegments), this._phase = "idle", this.requestUpdate();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
this._phase = "animating", this._rafHandle = requestAnimationFrame(this._tick);
|
|
136
|
+
}
|
|
137
|
+
_viewBoxHeight() {
|
|
138
|
+
return this.circular === "semi" ? this.size * .6 : this.circular === "triple" ? this.size * .85 : this.size;
|
|
139
|
+
}
|
|
140
|
+
_angleAt(e) {
|
|
141
|
+
let { startAngle: t, totalSweep: n } = p(this.circular), r = Math.max(this.min, Math.min(this.max, e));
|
|
142
|
+
return t + (this.max - this.min === 0 ? 0 : (r - this.min) / (this.max - this.min)) * n;
|
|
143
|
+
}
|
|
144
|
+
_resolveFillColor() {
|
|
145
|
+
if (this.zones.length === 0) return "var(--void-color-accent)";
|
|
146
|
+
let e = this._resolveTotal();
|
|
147
|
+
for (let t of this.zones) if (e >= t.from && e <= t.to) return t.color;
|
|
148
|
+
return this.zones[this.zones.length - 1].color;
|
|
149
|
+
}
|
|
150
|
+
_hasSegments() {
|
|
151
|
+
return (this._data.segments?.length ?? 0) > 0;
|
|
152
|
+
}
|
|
153
|
+
_renderZones(e, t, n, a) {
|
|
154
|
+
if (this.zones.length === 0 || this._hasSegments()) return r;
|
|
155
|
+
if (this.variant === "outline") {
|
|
156
|
+
let r = a > this._angleAt(this.min) + 1e-6, o = [];
|
|
157
|
+
for (let s = 0; s < this.zones.length; s++) {
|
|
158
|
+
let c = this.zones[s], l = this._angleAt(c.from), u = this._angleAt(c.to);
|
|
159
|
+
if (u <= a + 1e-6) continue;
|
|
160
|
+
let f = l <= a + 1e-6, p = f ? a : l, m = "butt";
|
|
161
|
+
f && r ? m = "cup" : Math.abs(c.from - this.min) < 1e-6 && (m = "round");
|
|
162
|
+
let h = s === this.zones.length - 1 && Math.abs(c.to - this.max) < 1e-6 ? "round" : "butt";
|
|
163
|
+
o.push(i`
|
|
164
|
+
<path
|
|
165
|
+
class="void-gauge-zone"
|
|
166
|
+
style="--zone-color: ${c.color};"
|
|
167
|
+
d=${d(e, t, n, this.thickness, p, u, m, h)}
|
|
168
|
+
></path>
|
|
169
|
+
`);
|
|
170
|
+
}
|
|
171
|
+
return i`<g class="void-gauge-zones">${o}</g>`;
|
|
172
|
+
}
|
|
173
|
+
let o = this.variant === "wireframe" ? f : this.thickness, s = [];
|
|
174
|
+
for (let r of this.zones) s.push(i`
|
|
175
|
+
<path
|
|
176
|
+
class="void-gauge-zone"
|
|
177
|
+
style="--zone-color: ${r.color}; stroke-width: ${o};"
|
|
178
|
+
d=${l(e, t, n, this._angleAt(r.from), this._angleAt(r.to))}
|
|
179
|
+
></path>
|
|
180
|
+
`);
|
|
181
|
+
let c = o / 2, u = (r, i) => {
|
|
182
|
+
let a = Math.cos(r), o = Math.sin(r);
|
|
183
|
+
return `M ${(e + (n - c) * a).toFixed(2)} ${(t + (n - c) * o).toFixed(2)} A ${c} ${c} 0 0 ${i} ${(e + (n + c) * a).toFixed(2)} ${(t + (n + c) * o).toFixed(2)} Z`;
|
|
184
|
+
}, p = [], m = this.zones[0];
|
|
185
|
+
m && Math.abs(m.from - this.min) < 1e-6 && p.push(i`<path class="void-gauge-zone-cap" d=${u(this._angleAt(m.from), 1)} style="--zone-color: ${m.color};"></path>`);
|
|
186
|
+
let h = this.zones[this.zones.length - 1];
|
|
187
|
+
return h && Math.abs(h.to - this.max) < 1e-6 && p.push(i`<path class="void-gauge-zone-cap" d=${u(this._angleAt(h.to), 0)} style="--zone-color: ${h.color};"></path>`), i`<g class="void-gauge-zones">${s}${p}</g>`;
|
|
188
|
+
}
|
|
189
|
+
_renderSegments(e, t, n, a, o, s, c) {
|
|
190
|
+
if (!this._hasSegments()) return r;
|
|
191
|
+
let d = this._data.segments, f = this.segmentsSort === "value" ? [...d].sort((e, t) => t.value - e.value) : d, p = c - a, m = (this.gaps === !0 ? 1 : this.gaps === !1 ? 0 : this.gaps) / 100 * p, h = f.length, g = (h > 1 ? m / (h - 1) : 0) / 2, _ = [], v = a, y = null, b = null, x = null, S = null;
|
|
192
|
+
for (let r = 0; r < f.length; r++) {
|
|
193
|
+
let a = f[r], p = d.indexOf(a), m = this._displaySegments.get(p) ?? 0;
|
|
194
|
+
if (m <= 0 || s <= 0) {
|
|
195
|
+
v += 0;
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
let C = m / s * o, w = Math.min(v + C, c), T = r > 0 ? v + g : v, E = r < h - 1 ? w - g : w;
|
|
199
|
+
if (E > T + .001) {
|
|
200
|
+
let r = a.color ?? "var(--void-color-accent)", o = this.variant === "outline" ? u(e, t, n, this.thickness, T, E) : l(e, t, n, T, E);
|
|
201
|
+
_.push(i`
|
|
202
|
+
<path
|
|
203
|
+
class="void-gauge-segment"
|
|
204
|
+
d=${o}
|
|
205
|
+
style="--segment-color: ${r}; stroke-width: ${this.thickness};"
|
|
206
|
+
data-segment-index=${p}
|
|
207
|
+
></path>
|
|
208
|
+
`), y === null && (y = r, b = T), x = r, S = E;
|
|
209
|
+
}
|
|
210
|
+
v += C;
|
|
211
|
+
}
|
|
212
|
+
if (_.length === 0) return r;
|
|
213
|
+
let C = this.thickness / 2, w = [];
|
|
214
|
+
if (b !== null && y !== null) {
|
|
215
|
+
let r = e + n * Math.cos(b), a = t + n * Math.sin(b);
|
|
216
|
+
w.push(i`<circle class="void-gauge-segment-cap" cx=${r} cy=${a} r=${C} style="--segment-color: ${y};"></circle>`);
|
|
217
|
+
}
|
|
218
|
+
if (S !== null && x !== null) {
|
|
219
|
+
let r = e + n * Math.cos(S), a = t + n * Math.sin(S);
|
|
220
|
+
w.push(i`<circle class="void-gauge-segment-cap" cx=${r} cy=${a} r=${C} style="--segment-color: ${x};"></circle>`);
|
|
221
|
+
}
|
|
222
|
+
return i`<g class="void-gauge-segments">${w}${_}</g>`;
|
|
223
|
+
}
|
|
224
|
+
_renderCenter(e, t) {
|
|
225
|
+
let n = this._displayValue, a = c(n), o = this.circular === "semi" ? t * .7 : t, s = o + 20;
|
|
226
|
+
return this.unitInline && this.unit ? i`
|
|
227
|
+
<text
|
|
228
|
+
class="void-gauge-center-value"
|
|
229
|
+
x=${e}
|
|
230
|
+
y=${o}
|
|
231
|
+
text-anchor="middle"
|
|
232
|
+
dy="0.32em"
|
|
233
|
+
>${a}<tspan class="void-gauge-center-unit-inline" dx="6">${this.unit}</tspan></text>
|
|
234
|
+
` : i`
|
|
235
|
+
<text
|
|
236
|
+
class="void-gauge-center-value"
|
|
237
|
+
x=${e}
|
|
238
|
+
y=${o}
|
|
239
|
+
text-anchor="middle"
|
|
240
|
+
dy="0.32em"
|
|
241
|
+
>${a}</text>
|
|
242
|
+
${this.unit ? i`
|
|
243
|
+
<text
|
|
244
|
+
class="void-gauge-center-unit"
|
|
245
|
+
x=${e}
|
|
246
|
+
y=${s}
|
|
247
|
+
text-anchor="middle"
|
|
248
|
+
dy="0.32em"
|
|
249
|
+
>${this.unit}</text>
|
|
250
|
+
` : r}
|
|
251
|
+
`;
|
|
252
|
+
}
|
|
253
|
+
_hasTicks() {
|
|
254
|
+
return this.tickMajor > 0 || this.tickMinor > 0;
|
|
255
|
+
}
|
|
256
|
+
_renderTicks(e, t, n) {
|
|
257
|
+
if (!this._hasTicks() || this.max - this.min <= 0) return r;
|
|
258
|
+
let a = Math.max(0, n - this.thickness / 2), o = Math.max(0, a - 3), s = Math.max(0, o - 5), c = Math.max(0, o - 10), l = [], u = this.tickMinor > 0 ? this.tickMinor : this.tickMajor;
|
|
259
|
+
if (u <= 0) return r;
|
|
260
|
+
this.tickMin && l.push({
|
|
261
|
+
v: this.min,
|
|
262
|
+
major: !0
|
|
263
|
+
});
|
|
264
|
+
let d = u * 1e-6;
|
|
265
|
+
for (let e = this.min + u; e < this.max - d; e += u) {
|
|
266
|
+
let t = this.tickMajor > 0 && Math.abs((e - this.min) / this.tickMajor - Math.round((e - this.min) / this.tickMajor)) < 1e-6;
|
|
267
|
+
l.push({
|
|
268
|
+
v: e,
|
|
269
|
+
major: t
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
let f = (this.max - this.min) / u, p = Math.abs(f - Math.round(f)) < d;
|
|
273
|
+
if (this.tickMax || p) {
|
|
274
|
+
let e = this.tickMajor > 0 && Math.abs((this.max - this.min) / this.tickMajor - Math.round((this.max - this.min) / this.tickMajor)) < 1e-6;
|
|
275
|
+
l.push({
|
|
276
|
+
v: this.max,
|
|
277
|
+
major: this.tickMax || e
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
return l.length === 0 ? r : i`<g class="void-gauge-ticks">${l.map(({ v: n, major: r }) => {
|
|
281
|
+
let a = this._angleAt(n), l = r ? c : s, u = (e + o * Math.cos(a)).toFixed(2), d = (t + o * Math.sin(a)).toFixed(2), f = (e + l * Math.cos(a)).toFixed(2), p = (t + l * Math.sin(a)).toFixed(2);
|
|
282
|
+
return i`<line class="void-gauge-tick ${r ? "void-gauge-tick-major" : "void-gauge-tick-minor"}" x1=${u} y1=${d} x2=${f} y2=${p}></line>`;
|
|
283
|
+
})}</g>`;
|
|
284
|
+
}
|
|
285
|
+
render() {
|
|
286
|
+
let { startAngle: e, endAngle: t, totalSweep: a } = p(this.circular), o = this.size / 2, s = this.size / 2, c = Math.max(8, this.thickness / 2), d = this.size / 2 - c, f = this._viewBoxHeight(), m = this._resolveTotal(), h = Math.max(this.min, Math.min(this.max, this._displayValue)), g = this.max - this.min === 0 ? 0 : (h - this.min) / (this.max - this.min), _ = e + Math.max(0, Math.min(1, g)) * a, v = this._resolveFillColor(), y = _ > e + .001;
|
|
287
|
+
return n`
|
|
288
|
+
<svg
|
|
289
|
+
viewBox="0 0 ${this.size} ${f}"
|
|
290
|
+
role="img"
|
|
291
|
+
aria-label=${this.ariaLabel || "Gauge chart"}
|
|
292
|
+
data-phase=${this._phase}
|
|
293
|
+
>
|
|
294
|
+
<!-- Track — full arc, always. Gaps between segments reveal the
|
|
295
|
+
track color underneath, which represents the "empty" gauge
|
|
296
|
+
state (semantically: the gap is "behind" the segments,
|
|
297
|
+
matching the unfilled portion of the gauge). -->
|
|
298
|
+
<path
|
|
299
|
+
class="void-gauge-track"
|
|
300
|
+
style="stroke-width: ${this.thickness};"
|
|
301
|
+
d=${l(o, s, d, e, t)}
|
|
302
|
+
></path>
|
|
303
|
+
|
|
304
|
+
<!-- Zone bands. Filled variant: zones render full-width and are
|
|
305
|
+
covered by the value's opaque stroke. Outline variant: zones
|
|
306
|
+
under the fill are clipped so the active-zone color reads
|
|
307
|
+
contiguously (otherwise the 14% tint composites through). -->
|
|
308
|
+
${this._renderZones(o, s, d, _)}
|
|
309
|
+
|
|
310
|
+
<!-- Value fill (skip when segments are present — segments paint
|
|
311
|
+
their own colors directly). For the 'outline' variant use a
|
|
312
|
+
closed band shape so SVG fill renders the faint tint AND
|
|
313
|
+
stroke renders a hairline border. Other variants use a
|
|
314
|
+
stroked centerline arc. -->
|
|
315
|
+
${y && !this._hasSegments() ? i`
|
|
316
|
+
<path
|
|
317
|
+
class="void-gauge-value"
|
|
318
|
+
style="--value-color: ${v}; stroke-width: ${this.thickness};"
|
|
319
|
+
d=${this.variant === "outline" ? u(o, s, d, this.thickness, e, _) : l(o, s, d, e, _)}
|
|
320
|
+
></path>
|
|
321
|
+
` : r}
|
|
322
|
+
|
|
323
|
+
<!-- Segment overlays -->
|
|
324
|
+
${this._renderSegments(o, s, d, e, a, m, _)}
|
|
325
|
+
|
|
326
|
+
<!-- Tick marks (outside the band) -->
|
|
327
|
+
${this._renderTicks(o, s, d)}
|
|
328
|
+
|
|
329
|
+
<!-- Center label -->
|
|
330
|
+
${this.showValue ? this._renderCenter(o, s) : r}
|
|
331
|
+
|
|
332
|
+
<!-- Hover tooltip -->
|
|
333
|
+
${this._hoverSegment !== null && this._data.segments && this._hoverSegment < this._data.segments.length ? this._renderHoverTooltip(this._data.segments, this._hoverSegment) : r}
|
|
334
|
+
</svg>
|
|
335
|
+
`;
|
|
336
|
+
}
|
|
337
|
+
_renderHoverTooltip(e, t) {
|
|
338
|
+
let n = e[t], r = this._displaySegments.get(t) ?? n.value, a = [...this._displaySegments.values()].reduce((e, t) => e + t, 0) || this._displayValue || 1, o = Math.round(r / a * 100), s = this._viewBoxHeight(), l = this._hoverX + 12, u = this._hoverY + 12;
|
|
339
|
+
return l + 140 > this.size && (l = this._hoverX - 12 - 140), u + 44 > s && (u = this._hoverY - 12 - 44), l < 0 && (l = 0), u < 0 && (u = 0), i`
|
|
340
|
+
<g class="void-gauge-hover" pointer-events="none">
|
|
341
|
+
<rect
|
|
342
|
+
class="void-gauge-tooltip-bg"
|
|
343
|
+
x=${l} y=${u}
|
|
344
|
+
width=${140} height=${44}
|
|
345
|
+
rx="6" ry="6"
|
|
346
|
+
></rect>
|
|
347
|
+
<text
|
|
348
|
+
class="void-gauge-tooltip-name"
|
|
349
|
+
x=${l + 8}
|
|
350
|
+
y=${u + 8 + 10}
|
|
351
|
+
>${n.name}</text>
|
|
352
|
+
<text
|
|
353
|
+
class="void-gauge-tooltip-value"
|
|
354
|
+
x=${l + 8}
|
|
355
|
+
y=${u + 8 + 14 + 10}
|
|
356
|
+
>${c(r)} <tspan class="void-gauge-tooltip-pct">(${o}%)</tspan></text>
|
|
357
|
+
</g>
|
|
358
|
+
`;
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
e([a()], m.prototype, "unit", void 0), e([a({ type: Number })], m.prototype, "value", void 0), e([a({ type: Number })], m.prototype, "min", void 0), e([a({ type: Number })], m.prototype, "max", void 0), e([a({
|
|
362
|
+
type: Number,
|
|
363
|
+
reflect: !0
|
|
364
|
+
})], m.prototype, "size", void 0), e([a({ type: Number })], m.prototype, "thickness", void 0), e([a({ reflect: !0 })], m.prototype, "circular", void 0), e([a({ reflect: !0 })], m.prototype, "variant", void 0), e([a({
|
|
365
|
+
type: Boolean,
|
|
366
|
+
attribute: "show-value",
|
|
367
|
+
reflect: !0
|
|
368
|
+
})], m.prototype, "showValue", void 0), e([a({
|
|
369
|
+
type: Boolean,
|
|
370
|
+
attribute: "unit-inline",
|
|
371
|
+
reflect: !0
|
|
372
|
+
})], m.prototype, "unitInline", void 0), e([a({
|
|
373
|
+
type: Number,
|
|
374
|
+
attribute: "tick-major"
|
|
375
|
+
})], m.prototype, "tickMajor", void 0), e([a({
|
|
376
|
+
type: Number,
|
|
377
|
+
attribute: "tick-minor"
|
|
378
|
+
})], m.prototype, "tickMinor", void 0), e([a({
|
|
379
|
+
type: Boolean,
|
|
380
|
+
attribute: "tick-min",
|
|
381
|
+
reflect: !0
|
|
382
|
+
})], m.prototype, "tickMin", void 0), e([a({
|
|
383
|
+
type: Boolean,
|
|
384
|
+
attribute: "tick-max",
|
|
385
|
+
reflect: !0
|
|
386
|
+
})], m.prototype, "tickMax", void 0), e([a({ attribute: "segments-sort" })], m.prototype, "segmentsSort", void 0), e([a({ converter: {
|
|
387
|
+
fromAttribute(e) {
|
|
388
|
+
if (e === null || e === "" || e === "true") return !0;
|
|
389
|
+
if (e === "false") return !1;
|
|
390
|
+
let t = Number(e);
|
|
391
|
+
return isNaN(t) ? !0 : t;
|
|
392
|
+
},
|
|
393
|
+
toAttribute(e) {
|
|
394
|
+
return e === !0 ? "" : e === !1 ? "false" : String(e);
|
|
395
|
+
}
|
|
396
|
+
} })], m.prototype, "gaps", void 0), e([a({ attribute: "aria-label" })], m.prototype, "ariaLabel", void 0), e([o()], m.prototype, "_phase", void 0), e([o()], m.prototype, "_hoverSegment", void 0), e([o()], m.prototype, "_hoverX", void 0), e([o()], m.prototype, "_hoverY", void 0), customElements.get("void-gauge") || customElements.define("void-gauge", m);
|
|
397
|
+
//#endregion
|
|
398
|
+
export { m as VoidGauge };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VoidElement as e } from "../base.js";
|
|
2
|
-
import { t } from "../chunks/decorate-
|
|
2
|
+
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
3
|
import { html as n } from "lit";
|
|
4
4
|
import { property as r } from "lit/decorators.js";
|
|
5
5
|
//#region src/components/hamburger.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VoidElement as e } from "../base.js";
|
|
2
|
-
import { t } from "../chunks/decorate-
|
|
2
|
+
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
3
|
import { property as n } from "lit/decorators.js";
|
|
4
4
|
//#region src/components/hover-card.ts
|
|
5
5
|
var r = class extends e {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VoidElement as e } from "../base.js";
|
|
2
|
-
import { t } from "../chunks/decorate-
|
|
2
|
+
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
3
|
import { property as n } from "lit/decorators.js";
|
|
4
4
|
//#region src/components/indicator.ts
|
|
5
5
|
var r = class extends e {
|
package/dist/components/input.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VoidElement as e } from "../base.js";
|
|
2
|
-
import { t } from "../chunks/decorate-
|
|
2
|
+
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
3
|
import { html as n } from "lit";
|
|
4
4
|
import { property as r } from "lit/decorators.js";
|
|
5
5
|
//#region src/components/input.ts
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export interface LineChartSeries {
|
|
3
|
+
name: string;
|
|
4
|
+
values: number[];
|
|
5
|
+
color?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface LineChartData {
|
|
8
|
+
series: LineChartSeries[];
|
|
9
|
+
labels?: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare class VoidLineChart extends LitElement {
|
|
12
|
+
createRenderRoot(): this;
|
|
13
|
+
height: number;
|
|
14
|
+
showValues: boolean;
|
|
15
|
+
variant: 'filled' | 'outline' | 'wireframe';
|
|
16
|
+
interpolation: 'linear' | 'step';
|
|
17
|
+
ariaLabel: string;
|
|
18
|
+
private _data;
|
|
19
|
+
get data(): LineChartData;
|
|
20
|
+
set data(next: LineChartData);
|
|
21
|
+
private _phase;
|
|
22
|
+
private _display;
|
|
23
|
+
private _targets;
|
|
24
|
+
private _animFrom;
|
|
25
|
+
private _animStart;
|
|
26
|
+
private _animDuration;
|
|
27
|
+
private _rafHandle;
|
|
28
|
+
private _reveal;
|
|
29
|
+
private _revealFrom;
|
|
30
|
+
private _key;
|
|
31
|
+
private _refreshTargets;
|
|
32
|
+
private _hoverIndex;
|
|
33
|
+
connectedCallback(): void;
|
|
34
|
+
disconnectedCallback(): void;
|
|
35
|
+
private _startAnimation;
|
|
36
|
+
private _tick;
|
|
37
|
+
private _onMouseMove;
|
|
38
|
+
private _onMouseLeave;
|
|
39
|
+
render(): import('lit').TemplateResult<1>;
|
|
40
|
+
private _renderHover;
|
|
41
|
+
}
|
|
42
|
+
declare global {
|
|
43
|
+
interface HTMLElementTagNameMap {
|
|
44
|
+
'void-line-chart': VoidLineChart;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=line-chart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line-chart.d.ts","sourceRoot":"","sources":["../../src/components/line-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAKrD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AA0BD,qBAAa,aAAc,SAAQ,UAAU;IAC3C,gBAAgB,IAAI,IAAI;IAEmB,MAAM,SAAO;IACc,UAAU,UAAS;IAC5D,OAAO,EAAE,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAa;IACxD,aAAa,EAAE,QAAQ,GAAG,MAAM,CAAY;IAClC,SAAS,SAAM;IAEtD,OAAO,CAAC,KAAK,CAAiC;IAE9C,IAAI,IAAI,IAAI,aAAa,CAAuB;IAChD,IAAI,IAAI,CAAC,IAAI,EAAE,aAAa,EAM3B;IAEQ,OAAO,CAAC,MAAM,CAAuC;IAC9D,OAAO,CAAC,QAAQ,CAA6B;IAC7C,OAAO,CAAC,QAAQ,CAA6B;IAC7C,OAAO,CAAC,SAAS,CAA6B;IAC9C,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,WAAW,CAAK;IAExB,OAAO,CAAC,IAAI;IAEZ,OAAO,CAAC,eAAe;IAOd,OAAO,CAAC,WAAW,CAAuB;IAEnD,iBAAiB;IASjB,oBAAoB;IAOpB,OAAO,CAAC,eAAe;IAmCvB,OAAO,CAAC,KAAK,CAmBX;IAEF,OAAO,CAAC,YAAY,CAoBlB;IAEF,OAAO,CAAC,aAAa,CAEnB;IAEF,MAAM;IAsHN,OAAO,CAAC,YAAY;CA+ErB;AAMD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,aAAa,CAAC;KAClC;CACF"}
|