@voidable/ui 0.10.0 → 0.11.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.
- package/dist/base.d.ts +6 -0
- package/dist/base.js +2 -2
- package/dist/chunks/{base-BxmMM3B7.js → base-BGrS4eIl.js} +9 -0
- package/dist/chunks/data-BpiiNapL.js +95 -0
- package/dist/chunks/{modal-CgGp_fCs.js → modal-DWGkNdNG.js} +2 -2
- package/dist/chunks/{overlay-hLJ7IQHx.js → overlay-CH7L4N-h.js} +1 -1
- package/dist/chunks/{projection-SnR79EHI.js → projection-oPe6ipjL.js} +1 -1
- package/dist/components/accordion.js +1 -1
- package/dist/components/action-input.js +2 -2
- package/dist/components/alert.d.ts +11 -0
- package/dist/components/alert.js +10 -3
- package/dist/components/avatar.js +2 -2
- package/dist/components/badge.d.ts +8 -2
- package/dist/components/badge.js +1 -4
- package/dist/components/banner.d.ts +9 -0
- package/dist/components/banner.js +10 -3
- package/dist/components/bar-chart.d.ts +21 -7
- package/dist/components/bar-chart.js +65 -43
- package/dist/components/breadcrumbs.js +1 -1
- package/dist/components/button.js +1 -1
- package/dist/components/calendar.d.ts +40 -2
- package/dist/components/calendar.js +110 -21
- package/dist/components/card.js +1 -1
- package/dist/components/carousel.js +3 -3
- package/dist/components/charts/data.d.ts +72 -0
- package/dist/components/checkbox-group.js +2 -2
- package/dist/components/checkbox.js +2 -2
- package/dist/components/collapsible.js +1 -1
- package/dist/components/color-picker.js +2 -2
- package/dist/components/combobox.js +3 -3
- package/dist/components/compose-input.js +2 -2
- package/dist/components/dialog.js +1 -1
- package/dist/components/divider.js +2 -2
- package/dist/components/donut-chart.d.ts +22 -6
- package/dist/components/donut-chart.js +95 -69
- package/dist/components/drawer.js +1 -1
- package/dist/components/dropdown-menu.js +2 -2
- package/dist/components/editable.js +2 -2
- package/dist/components/error-fallback.js +1 -1
- package/dist/components/field.js +2 -2
- package/dist/components/file-upload.d.ts +20 -5
- package/dist/components/file-upload.js +51 -21
- package/dist/components/gauge.d.ts +32 -8
- package/dist/components/gauge.js +202 -130
- package/dist/components/hamburger.d.ts +12 -1
- package/dist/components/hamburger.js +24 -13
- package/dist/components/hover-card.js +2 -2
- package/dist/components/indicator.js +2 -2
- package/dist/components/input.js +2 -2
- package/dist/components/line-chart.d.ts +22 -7
- package/dist/components/line-chart.js +76 -54
- package/dist/components/list.js +1 -1
- package/dist/components/menu.js +1 -1
- package/dist/components/multiselect.js +3 -3
- package/dist/components/nav-bar.d.ts +9 -0
- package/dist/components/nav-bar.js +16 -3
- package/dist/components/nav-menu.js +1 -1
- package/dist/components/number-input.js +2 -2
- package/dist/components/pagination.js +2 -2
- package/dist/components/panel.js +1 -1
- package/dist/components/pin-input.js +2 -2
- package/dist/components/popover.js +2 -2
- package/dist/components/progress.js +2 -2
- package/dist/components/radio-group.js +2 -2
- package/dist/components/radio.js +2 -2
- package/dist/components/scroll-area.js +2 -2
- package/dist/components/segmented-control.js +1 -1
- package/dist/components/select.js +2 -2
- package/dist/components/sidebar.js +1 -1
- package/dist/components/skeleton.js +1 -1
- package/dist/components/slider.js +2 -2
- package/dist/components/spinner.js +2 -2
- package/dist/components/stat.d.ts +13 -1
- package/dist/components/stat.js +28 -20
- package/dist/components/status-dot.js +1 -1
- package/dist/components/stepper.js +2 -2
- package/dist/components/switch.js +2 -2
- package/dist/components/table.d.ts +4 -0
- package/dist/components/table.js +42 -29
- package/dist/components/tabs.js +1 -1
- package/dist/components/tag.js +2 -2
- package/dist/components/tags-input.js +2 -2
- package/dist/components/textarea.js +2 -2
- 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 +2 -2
- package/dist/components.json +15 -13
- package/dist/custom-elements.json +272 -70
- package/dist/dev/types.d.ts +3 -1
- package/dist/dev.js +54 -9
- package/dist/index.js +1 -1
- package/dist/llms.txt +1 -1
- package/dist/reference.md +81 -56
- package/dist/types/elements.d.ts +13 -13
- package/dist/types/react.d.ts +2 -2
- package/dist/types/solid.d.ts +2 -2
- package/dist/types/svelte.d.ts +2 -2
- package/dist/types/vue.d.ts +2 -2
- package/dist/vscode.html-custom-data.json +95 -21
- package/dist/web-types.json +173 -44
- package/package.json +1 -1
package/dist/components/gauge.js
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
import { t as e } from "../chunks/base-
|
|
1
|
+
import { t as e } from "../chunks/base-BGrS4eIl.js";
|
|
2
2
|
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
-
import { r as n } from "../chunks/projection-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { r as n } from "../chunks/projection-oPe6ipjL.js";
|
|
4
|
+
import { i as r, l as i, n as a, o, r as s, s as c, t as l } from "../chunks/data-BpiiNapL.js";
|
|
5
|
+
import { html as u, nothing as d, svg as f } from "lit";
|
|
6
|
+
import { property as p, state as m } from "lit/decorators.js";
|
|
7
|
+
import { guard as h } from "lit/directives/guard.js";
|
|
6
8
|
//#region src/components/gauge.ts
|
|
7
9
|
n();
|
|
8
|
-
function
|
|
10
|
+
function g(e) {
|
|
9
11
|
return 1 - (1 - e) ** 3;
|
|
10
12
|
}
|
|
11
|
-
function
|
|
13
|
+
function _(e) {
|
|
12
14
|
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();
|
|
13
15
|
}
|
|
14
|
-
function
|
|
16
|
+
function v(e, t, n, r, i) {
|
|
15
17
|
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);
|
|
16
18
|
return `M ${s.toFixed(2)} ${c.toFixed(2)} A ${n} ${n} 0 ${d} ${f} ${l.toFixed(2)} ${u.toFixed(2)}`;
|
|
17
19
|
}
|
|
18
|
-
function
|
|
20
|
+
function y(e, t, n, r, i, a) {
|
|
19
21
|
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);
|
|
20
22
|
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`;
|
|
21
23
|
}
|
|
22
|
-
function
|
|
24
|
+
function b(e, t, n, r, i, a, o, s) {
|
|
23
25
|
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)} `;
|
|
24
26
|
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;
|
|
25
27
|
}
|
|
26
|
-
var
|
|
27
|
-
function
|
|
28
|
+
var x = 1.5 * 5;
|
|
29
|
+
function S(e) {
|
|
28
30
|
let t = Math.PI;
|
|
29
31
|
return e === "full" ? {
|
|
30
32
|
startAngle: -t / 2,
|
|
@@ -40,9 +42,9 @@ function m(e) {
|
|
|
40
42
|
totalSweep: 3 * t / 2
|
|
41
43
|
};
|
|
42
44
|
}
|
|
43
|
-
var
|
|
45
|
+
var C = class extends e {
|
|
44
46
|
constructor(...e) {
|
|
45
|
-
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.hideValue = !1, this.unitInline = !1, this.tickMajor = 0, this.tickMinor = 0, this.hideTickMin = !1, this.hideTickMax = !1, this.segmentsSort = "value", this.gaps = !1, this.ariaLabel = "", this.
|
|
47
|
+
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.hideValue = !1, this.unitInline = !1, this.tickMajor = 0, this.tickMinor = 0, this.hideTickMin = !1, this.hideTickMax = !1, this.segmentsSort = "value", this.gaps = !1, this.ariaLabel = "", this.showTable = !1, this._zones = [], this._zonesSource = { text: null }, this._data = {}, this._source = { text: null }, 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._hasAnimated = !1, this._onMouseMove = (e) => {
|
|
46
48
|
let t = this.querySelector("svg");
|
|
47
49
|
if (!t) return;
|
|
48
50
|
let n = this._data.segments;
|
|
@@ -57,22 +59,22 @@ var h = class extends e {
|
|
|
57
59
|
this._hoverSegment !== null && (this._hoverSegment = null);
|
|
58
60
|
return;
|
|
59
61
|
}
|
|
60
|
-
let { startAngle:
|
|
61
|
-
for (;
|
|
62
|
-
for (;
|
|
63
|
-
if (
|
|
62
|
+
let { startAngle: m, totalSweep: h } = S(this.circular), g = m + h, _ = Math.atan2(u, l);
|
|
63
|
+
for (; _ < m;) _ += 2 * Math.PI;
|
|
64
|
+
for (; _ > m + 2 * Math.PI;) _ -= 2 * Math.PI;
|
|
65
|
+
if (_ > g) {
|
|
64
66
|
this._hoverSegment !== null && (this._hoverSegment = null);
|
|
65
67
|
return;
|
|
66
68
|
}
|
|
67
|
-
let
|
|
68
|
-
if (
|
|
69
|
+
let v = this.max - this.min === 0 ? 0 : (this._displayValue - this.min) / (this.max - this.min), y = m + Math.max(0, Math.min(1, v)) * h;
|
|
70
|
+
if (_ > y) {
|
|
69
71
|
this._hoverSegment !== null && (this._hoverSegment = null);
|
|
70
72
|
return;
|
|
71
73
|
}
|
|
72
|
-
let
|
|
73
|
-
for (let e = 0; e <
|
|
74
|
-
let t =
|
|
75
|
-
if (
|
|
74
|
+
let b = this.segmentsSort === "value" ? [...n].sort((e, t) => t.value - e.value) : n, x = [...this._displaySegments.values()].reduce((e, t) => e + t, 0) || this._displayValue || 1, C = y - m, w = m;
|
|
75
|
+
for (let e = 0; e < b.length; e++) {
|
|
76
|
+
let t = b[e], r = n.indexOf(t), i = (this._displaySegments.get(r) ?? 0) / x * C;
|
|
77
|
+
if (_ >= w && _ < w + i) {
|
|
76
78
|
this._hoverSegment !== r && (this._hoverSegment = r), this._hoverX = a, this._hoverY = o;
|
|
77
79
|
return;
|
|
78
80
|
}
|
|
@@ -82,7 +84,7 @@ var h = class extends e {
|
|
|
82
84
|
}, this._onMouseLeave = () => {
|
|
83
85
|
this._hoverSegment = null;
|
|
84
86
|
}, this._tick = (e) => {
|
|
85
|
-
let t = e - this._animStart, n = Math.min(t / this._animDuration, 1), r =
|
|
87
|
+
let t = e - this._animStart, n = Math.min(t / this._animDuration, 1), r = g(n);
|
|
86
88
|
this._displayValue = this._displayValueFrom + (this._targetValue - this._displayValueFrom) * r;
|
|
87
89
|
for (let [e, t] of this._targetSegments) {
|
|
88
90
|
let n = this._segmentsFrom.get(e) ?? 0;
|
|
@@ -91,17 +93,48 @@ var h = class extends e {
|
|
|
91
93
|
this.requestUpdate(), n < 1 ? this._rafHandle = requestAnimationFrame(this._tick) : this._phase = "idle";
|
|
92
94
|
};
|
|
93
95
|
}
|
|
96
|
+
get zones() {
|
|
97
|
+
return this._zones;
|
|
98
|
+
}
|
|
99
|
+
set zones(e) {
|
|
100
|
+
let t = o(e, this._zonesSource, {
|
|
101
|
+
attr: "zones",
|
|
102
|
+
shape: "[{\"from\":0,\"to\":60,\"color\":\"green\"},{\"from\":60,\"to\":100,\"color\":\"red\"}]",
|
|
103
|
+
empty: () => [],
|
|
104
|
+
normalize: (e) => Array.isArray(e) ? e.filter(s).map((e) => ({
|
|
105
|
+
from: Number(e.from),
|
|
106
|
+
to: Number(e.to),
|
|
107
|
+
color: String(e.color ?? "")
|
|
108
|
+
})) : null,
|
|
109
|
+
warn: (e, t) => this.reportDev("invalid-data", e, t)
|
|
110
|
+
});
|
|
111
|
+
t && (this._zones = t.value);
|
|
112
|
+
}
|
|
94
113
|
get data() {
|
|
95
114
|
return this._data;
|
|
96
115
|
}
|
|
97
116
|
set data(e) {
|
|
98
|
-
let t =
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
117
|
+
let t = o(e, this._source, {
|
|
118
|
+
attr: "data",
|
|
119
|
+
shape: "{\"segments\":[{\"name\":\"Used\",\"value\":40},{\"name\":\"Cache\",\"value\":15}]}",
|
|
120
|
+
empty: () => ({}),
|
|
121
|
+
normalize: (e) => {
|
|
122
|
+
if (!s(e)) return null;
|
|
123
|
+
let t = e.segments === void 0 ? void 0 : r(e.segments);
|
|
124
|
+
if (t === null) return null;
|
|
125
|
+
let n = {};
|
|
126
|
+
return e.value !== void 0 && (n.value = Number(e.value)), t && (n.segments = t), n;
|
|
127
|
+
},
|
|
128
|
+
warn: (e, t) => this.reportDev("invalid-data", e, t)
|
|
129
|
+
});
|
|
130
|
+
if (!t) return;
|
|
131
|
+
let n = t.value, i = this._data, a = this._displayValue, c = new Map(this._displaySegments);
|
|
132
|
+
this._data = n, this._refreshTargets(), this.requestUpdate(), this._hasAnimated && this.updateComplete.then(() => {
|
|
133
|
+
let e = i.segments ?? [], t = /* @__PURE__ */ new Map();
|
|
134
|
+
for (let n = 0; n < e.length; n++) t.set(n, c.get(n) ?? 0);
|
|
135
|
+
let r = n.segments ?? [];
|
|
136
|
+
for (let e = 0; e < r.length; e++) t.has(e) || t.set(e, 0);
|
|
137
|
+
this._startAnimation(t, a, !0);
|
|
105
138
|
});
|
|
106
139
|
}
|
|
107
140
|
willUpdate(e) {
|
|
@@ -119,7 +152,7 @@ var h = class extends e {
|
|
|
119
152
|
return e && e.length > 0 ? e.reduce((e, t) => e + t.value, 0) : this.value;
|
|
120
153
|
}
|
|
121
154
|
connectedCallback() {
|
|
122
|
-
super.connectedCallback(), this.setHostAttribute("role", "
|
|
155
|
+
super.connectedCallback(), this.setHostAttribute("role", "figure"), this._refreshTargets(), requestAnimationFrame(() => {
|
|
123
156
|
let e = /* @__PURE__ */ new Map(), t = this._data.segments ?? [];
|
|
124
157
|
for (let n = 0; n < t.length; n++) e.set(n, 0);
|
|
125
158
|
this._startAnimation(e, 0, !1);
|
|
@@ -141,7 +174,7 @@ var h = class extends e {
|
|
|
141
174
|
return this.circular === "semi" ? this.size * .6 : this.circular === "triple" ? this.size * .85 : this.size;
|
|
142
175
|
}
|
|
143
176
|
_angleAt(e) {
|
|
144
|
-
let { startAngle: t, totalSweep: n } =
|
|
177
|
+
let { startAngle: t, totalSweep: n } = S(this.circular), r = Math.max(this.min, Math.min(this.max, e));
|
|
145
178
|
return t + (this.max - this.min === 0 ? 0 : (r - this.min) / (this.max - this.min)) * n;
|
|
146
179
|
}
|
|
147
180
|
_resolveFillColor() {
|
|
@@ -155,144 +188,143 @@ var h = class extends e {
|
|
|
155
188
|
return (this._data.segments?.length ?? 0) > 0;
|
|
156
189
|
}
|
|
157
190
|
_renderZones(e, t, n, r) {
|
|
158
|
-
if (this.zones.length === 0 || this._hasSegments()) return
|
|
191
|
+
if (this.zones.length === 0 || this._hasSegments()) return d;
|
|
159
192
|
if (this.variant === "outline") {
|
|
160
|
-
let i = r > this._angleAt(this.min) + 1e-6,
|
|
161
|
-
for (let
|
|
162
|
-
let
|
|
163
|
-
if (
|
|
164
|
-
let
|
|
165
|
-
|
|
166
|
-
let
|
|
167
|
-
|
|
193
|
+
let i = r > this._angleAt(this.min) + 1e-6, a = [];
|
|
194
|
+
for (let o = 0; o < this.zones.length; o++) {
|
|
195
|
+
let s = this.zones[o], c = this._angleAt(s.from), l = this._angleAt(s.to);
|
|
196
|
+
if (l <= r + 1e-6) continue;
|
|
197
|
+
let u = c <= r + 1e-6, d = u ? r : c, p = "butt";
|
|
198
|
+
u && i ? p = "cup" : Math.abs(s.from - this.min) < 1e-6 && (p = "round");
|
|
199
|
+
let m = o === this.zones.length - 1 && Math.abs(s.to - this.max) < 1e-6 ? "round" : "butt";
|
|
200
|
+
a.push(f`
|
|
168
201
|
<path
|
|
169
202
|
class="void-gauge-zone"
|
|
170
|
-
style="--zone-color: ${
|
|
171
|
-
d=${
|
|
203
|
+
style="--zone-color: ${s.color};"
|
|
204
|
+
d=${b(e, t, n, this.thickness, d, l, p, m)}
|
|
172
205
|
></path>
|
|
173
206
|
`);
|
|
174
207
|
}
|
|
175
|
-
return
|
|
208
|
+
return f`<g class="void-gauge-zones">${a}</g>`;
|
|
176
209
|
}
|
|
177
|
-
let
|
|
178
|
-
for (let r of this.zones)
|
|
210
|
+
let i = this.variant === "wireframe" ? x : this.thickness, a = [];
|
|
211
|
+
for (let r of this.zones) a.push(f`
|
|
179
212
|
<path
|
|
180
213
|
class="void-gauge-zone"
|
|
181
|
-
style="--zone-color: ${r.color}; --gauge-stroke-width: ${
|
|
182
|
-
d=${
|
|
214
|
+
style="--zone-color: ${r.color}; --gauge-stroke-width: ${i};"
|
|
215
|
+
d=${v(e, t, n, this._angleAt(r.from), this._angleAt(r.to))}
|
|
183
216
|
></path>
|
|
184
217
|
`);
|
|
185
|
-
let
|
|
186
|
-
let a = Math.cos(r),
|
|
187
|
-
return `M ${(e + (n -
|
|
188
|
-
},
|
|
189
|
-
|
|
190
|
-
let
|
|
191
|
-
return
|
|
218
|
+
let o = i / 2, s = (r, i) => {
|
|
219
|
+
let a = Math.cos(r), s = Math.sin(r);
|
|
220
|
+
return `M ${(e + (n - o) * a).toFixed(2)} ${(t + (n - o) * s).toFixed(2)} A ${o} ${o} 0 0 ${i} ${(e + (n + o) * a).toFixed(2)} ${(t + (n + o) * s).toFixed(2)} Z`;
|
|
221
|
+
}, c = [], l = this.zones[0];
|
|
222
|
+
l && Math.abs(l.from - this.min) < 1e-6 && c.push(f`<path class="void-gauge-zone-cap" d=${s(this._angleAt(l.from), 1)} style="--zone-color: ${l.color};"></path>`);
|
|
223
|
+
let u = this.zones[this.zones.length - 1];
|
|
224
|
+
return u && Math.abs(u.to - this.max) < 1e-6 && c.push(f`<path class="void-gauge-zone-cap" d=${s(this._angleAt(u.to), 0)} style="--zone-color: ${u.color};"></path>`), f`<g class="void-gauge-zones">${a}${c}</g>`;
|
|
192
225
|
}
|
|
193
|
-
_renderSegments(e, t, n, r,
|
|
194
|
-
if (!this._hasSegments()) return
|
|
195
|
-
let
|
|
196
|
-
for (let r = 0; r <
|
|
197
|
-
let
|
|
198
|
-
if (S <= 0 ||
|
|
199
|
-
|
|
226
|
+
_renderSegments(e, t, n, r, i, a) {
|
|
227
|
+
if (!this._hasSegments()) return d;
|
|
228
|
+
let o = this._data.segments, s = this.segmentsSort === "value" ? [...o].sort((e, t) => t.value - e.value) : o, c = a - r, l = (this.gaps === !0 ? 1 : this.gaps === !1 ? 0 : this.gaps) / 100 * c, u = s.length, p = (u > 1 ? l / (u - 1) : 0) / 2, m = [], h = r, g = null, _ = null, b = null, x = null;
|
|
229
|
+
for (let r = 0; r < s.length; r++) {
|
|
230
|
+
let l = s[r], d = o.indexOf(l), S = this._displaySegments.get(d) ?? 0;
|
|
231
|
+
if (S <= 0 || i <= 0) {
|
|
232
|
+
h += 0;
|
|
200
233
|
continue;
|
|
201
234
|
}
|
|
202
|
-
let C = S /
|
|
235
|
+
let C = S / i * c, w = Math.min(h + C, a), T = r > 0 ? h + p : h, E = r < u - 1 ? w - p : w;
|
|
203
236
|
if (E > T + .001) {
|
|
204
|
-
let r =
|
|
205
|
-
|
|
237
|
+
let r = l.color ?? "var(--void-color-accent)", i = this.variant === "outline" ? y(e, t, n, this.thickness, T, E) : v(e, t, n, T, E);
|
|
238
|
+
m.push(f`
|
|
206
239
|
<path
|
|
207
240
|
class="void-gauge-segment"
|
|
208
|
-
d=${
|
|
241
|
+
d=${i}
|
|
209
242
|
style="--segment-color: ${r}; --gauge-stroke-width: ${this.thickness};"
|
|
210
|
-
data-segment-index=${
|
|
243
|
+
data-segment-index=${d}
|
|
211
244
|
></path>
|
|
212
|
-
`),
|
|
245
|
+
`), g === null && (g = r, _ = T), b = r, x = E;
|
|
213
246
|
}
|
|
214
|
-
|
|
247
|
+
h += C;
|
|
215
248
|
}
|
|
216
|
-
if (
|
|
249
|
+
if (m.length === 0) return d;
|
|
217
250
|
let S = this.thickness / 2, C = [];
|
|
218
|
-
if (
|
|
219
|
-
let r = e + n * Math.cos(
|
|
220
|
-
C.push(
|
|
251
|
+
if (_ !== null && g !== null) {
|
|
252
|
+
let r = e + n * Math.cos(_), i = t + n * Math.sin(_);
|
|
253
|
+
C.push(f`<circle class="void-gauge-segment-cap" cx=${r} cy=${i} r=${S} style="--segment-color: ${g};"></circle>`);
|
|
221
254
|
}
|
|
222
255
|
if (x !== null && b !== null) {
|
|
223
256
|
let r = e + n * Math.cos(x), i = t + n * Math.sin(x);
|
|
224
|
-
C.push(
|
|
257
|
+
C.push(f`<circle class="void-gauge-segment-cap" cx=${r} cy=${i} r=${S} style="--segment-color: ${b};"></circle>`);
|
|
225
258
|
}
|
|
226
|
-
return
|
|
259
|
+
return f`<g class="void-gauge-segments">${C}${m}</g>`;
|
|
227
260
|
}
|
|
228
261
|
_renderCenter(e, t) {
|
|
229
|
-
let n = this._displayValue, r =
|
|
230
|
-
return this.unitInline && this.unit ?
|
|
262
|
+
let n = this._displayValue, r = _(n), i = this.circular === "semi" ? t * .7 : t, a = i + 20;
|
|
263
|
+
return this.unitInline && this.unit ? f`
|
|
231
264
|
<text
|
|
232
265
|
class="void-gauge-center-value"
|
|
233
266
|
x=${e}
|
|
234
|
-
y=${
|
|
267
|
+
y=${i}
|
|
235
268
|
text-anchor="middle"
|
|
236
269
|
dy="0.32em"
|
|
237
270
|
>${r}<tspan class="void-gauge-center-unit-inline" dx="6">${this.unit}</tspan></text>
|
|
238
|
-
` :
|
|
271
|
+
` : f`
|
|
239
272
|
<text
|
|
240
273
|
class="void-gauge-center-value"
|
|
241
274
|
x=${e}
|
|
242
|
-
y=${
|
|
275
|
+
y=${i}
|
|
243
276
|
text-anchor="middle"
|
|
244
277
|
dy="0.32em"
|
|
245
278
|
>${r}</text>
|
|
246
|
-
${this.unit ?
|
|
279
|
+
${this.unit ? f`
|
|
247
280
|
<text
|
|
248
281
|
class="void-gauge-center-unit"
|
|
249
282
|
x=${e}
|
|
250
|
-
y=${
|
|
283
|
+
y=${a}
|
|
251
284
|
text-anchor="middle"
|
|
252
285
|
dy="0.32em"
|
|
253
286
|
>${this.unit}</text>
|
|
254
|
-
` :
|
|
287
|
+
` : d}
|
|
255
288
|
`;
|
|
256
289
|
}
|
|
257
290
|
_hasTicks() {
|
|
258
291
|
return this.tickMajor > 0 || this.tickMinor > 0;
|
|
259
292
|
}
|
|
260
293
|
_renderTicks(e, t, n) {
|
|
261
|
-
if (!this._hasTicks() || this.max - this.min <= 0) return
|
|
262
|
-
let r = Math.max(0, n - this.thickness / 2),
|
|
263
|
-
if (
|
|
264
|
-
this.hideTickMin ||
|
|
294
|
+
if (!this._hasTicks() || this.max - this.min <= 0) return d;
|
|
295
|
+
let r = Math.max(0, n - this.thickness / 2), i = Math.max(0, r - 3), a = Math.max(0, i - 5), o = Math.max(0, i - 10), s = [], c = this.tickMinor > 0 ? this.tickMinor : this.tickMajor;
|
|
296
|
+
if (c <= 0) return d;
|
|
297
|
+
this.hideTickMin || s.push({
|
|
265
298
|
v: this.min,
|
|
266
299
|
major: !0
|
|
267
300
|
});
|
|
268
|
-
let
|
|
269
|
-
for (let e = this.min +
|
|
301
|
+
let l = c * 1e-6;
|
|
302
|
+
for (let e = this.min + c; e < this.max - l; e += c) {
|
|
270
303
|
let t = this.tickMajor > 0 && Math.abs((e - this.min) / this.tickMajor - Math.round((e - this.min) / this.tickMajor)) < 1e-6;
|
|
271
|
-
|
|
304
|
+
s.push({
|
|
272
305
|
v: e,
|
|
273
306
|
major: t
|
|
274
307
|
});
|
|
275
308
|
}
|
|
276
|
-
let
|
|
309
|
+
let u = (this.max - this.min) / c, p = Math.abs(u - Math.round(u)) < l;
|
|
277
310
|
if (!this.hideTickMax || p) {
|
|
278
311
|
let e = this.tickMajor > 0 && Math.abs((this.max - this.min) / this.tickMajor - Math.round((this.max - this.min) / this.tickMajor)) < 1e-6;
|
|
279
|
-
|
|
312
|
+
s.push({
|
|
280
313
|
v: this.max,
|
|
281
314
|
major: !this.hideTickMax || e
|
|
282
315
|
});
|
|
283
316
|
}
|
|
284
|
-
return
|
|
285
|
-
let
|
|
286
|
-
return
|
|
317
|
+
return s.length === 0 ? d : f`<g class="void-gauge-ticks">${s.map(({ v: n, major: r }) => {
|
|
318
|
+
let s = this._angleAt(n), c = r ? o : a, l = (e + i * Math.cos(s)).toFixed(2), u = (t + i * Math.sin(s)).toFixed(2), d = (e + c * Math.cos(s)).toFixed(2), p = (t + c * Math.sin(s)).toFixed(2);
|
|
319
|
+
return f`<line class="void-gauge-tick ${r ? "void-gauge-tick-major" : "void-gauge-tick-minor"}" x1=${l} y1=${u} x2=${d} y2=${p}></line>`;
|
|
287
320
|
})}</g>`;
|
|
288
321
|
}
|
|
289
322
|
render() {
|
|
290
|
-
let { startAngle: e, endAngle: t, totalSweep: n } =
|
|
291
|
-
return
|
|
323
|
+
let { startAngle: e, endAngle: t, totalSweep: n } = S(this.circular), r = this.size / 2, i = this.size / 2, a = Math.max(8, this.thickness / 2), o = this.size / 2 - a, s = this._viewBoxHeight(), c = [...this._displaySegments.values()].reduce((e, t) => e + t, 0), l = Math.max(this.min, Math.min(this.max, this._displayValue)), p = this.max - this.min === 0 ? 0 : (l - this.min) / (this.max - this.min), m = e + Math.max(0, Math.min(1, p)) * n, h = this._resolveFillColor(), g = m > e + .001;
|
|
324
|
+
return u`
|
|
292
325
|
<svg
|
|
293
|
-
viewBox="0 0 ${this.size} ${
|
|
294
|
-
|
|
295
|
-
aria-label=${this.ariaLabel || "Gauge chart"}
|
|
326
|
+
viewBox="0 0 ${this.size} ${s}"
|
|
327
|
+
aria-hidden="true"
|
|
296
328
|
data-phase=${this._phase}
|
|
297
329
|
>
|
|
298
330
|
<!-- Track — full arc, always. Gaps between segments reveal the
|
|
@@ -302,95 +334,131 @@ var h = class extends e {
|
|
|
302
334
|
<path
|
|
303
335
|
class="void-gauge-track"
|
|
304
336
|
style="--gauge-stroke-width: ${this.thickness};"
|
|
305
|
-
d=${
|
|
337
|
+
d=${v(r, i, o, e, t)}
|
|
306
338
|
></path>
|
|
307
339
|
|
|
308
340
|
<!-- Zone bands. Filled variant: zones render full-width and are
|
|
309
341
|
covered by the value's opaque stroke. Outline variant: zones
|
|
310
342
|
under the fill are clipped so the active-zone color reads
|
|
311
343
|
contiguously (otherwise the 14% tint composites through). -->
|
|
312
|
-
${this._renderZones(
|
|
344
|
+
${this._renderZones(r, i, o, m)}
|
|
313
345
|
|
|
314
346
|
<!-- Value fill (skip when segments are present — segments paint
|
|
315
347
|
their own colors directly). For the 'outline' variant use a
|
|
316
348
|
closed band shape so SVG fill renders the faint tint AND
|
|
317
349
|
stroke renders a hairline border. Other variants use a
|
|
318
350
|
stroked centerline arc. -->
|
|
319
|
-
${
|
|
351
|
+
${g && !this._hasSegments() ? f`
|
|
320
352
|
<path
|
|
321
353
|
class="void-gauge-value"
|
|
322
|
-
style="--value-color: ${
|
|
323
|
-
d=${this.variant === "outline" ?
|
|
354
|
+
style="--value-color: ${h}; --gauge-stroke-width: ${this.thickness};"
|
|
355
|
+
d=${this.variant === "outline" ? y(r, i, o, this.thickness, e, m) : v(r, i, o, e, m)}
|
|
324
356
|
></path>
|
|
325
|
-
` :
|
|
357
|
+
` : d}
|
|
326
358
|
|
|
327
359
|
<!-- Segment overlays -->
|
|
328
|
-
${this._renderSegments(
|
|
360
|
+
${this._renderSegments(r, i, o, e, c, m)}
|
|
329
361
|
|
|
330
362
|
<!-- Tick marks (outside the band) -->
|
|
331
|
-
${this._renderTicks(
|
|
363
|
+
${this._renderTicks(r, i, o)}
|
|
332
364
|
|
|
333
365
|
<!-- Center label -->
|
|
334
|
-
${this.hideValue ?
|
|
366
|
+
${this.hideValue ? d : this._renderCenter(r, i)}
|
|
335
367
|
|
|
336
368
|
<!-- Hover tooltip -->
|
|
337
|
-
${this._hoverSegment !== null && this._data.segments && this._hoverSegment < this._data.segments.length ? this._renderHoverTooltip(this._data.segments, this._hoverSegment) :
|
|
369
|
+
${this._hoverSegment !== null && this._data.segments && this._hoverSegment < this._data.segments.length ? this._renderHoverTooltip(this._data.segments, this._hoverSegment) : d}
|
|
338
370
|
</svg>
|
|
371
|
+
${this._table()}
|
|
339
372
|
`;
|
|
340
373
|
}
|
|
374
|
+
_table() {
|
|
375
|
+
let { value: e, min: t, max: n, unit: r, segmentsSort: o, _data: s } = this, u = this.ariaLabel || "Gauge chart";
|
|
376
|
+
return h([
|
|
377
|
+
e,
|
|
378
|
+
t,
|
|
379
|
+
n,
|
|
380
|
+
r,
|
|
381
|
+
o,
|
|
382
|
+
s,
|
|
383
|
+
u,
|
|
384
|
+
l(this)
|
|
385
|
+
], () => {
|
|
386
|
+
let l, d = s.segments ?? [];
|
|
387
|
+
if (d.length > 0) {
|
|
388
|
+
let e = o === "value" ? [...d].sort((e, t) => t.value - e.value) : d;
|
|
389
|
+
l = c(this, u, e);
|
|
390
|
+
} else {
|
|
391
|
+
let a = i(this), o = s.value ?? e, c = (e) => a.number(e) + (r ? /^[\p{L}]/u.test(r) ? ` ${r}` : r : "");
|
|
392
|
+
l = {
|
|
393
|
+
caption: u,
|
|
394
|
+
head: [
|
|
395
|
+
"Value",
|
|
396
|
+
"Minimum",
|
|
397
|
+
"Maximum"
|
|
398
|
+
],
|
|
399
|
+
rows: [{ cells: [
|
|
400
|
+
c(o),
|
|
401
|
+
c(t),
|
|
402
|
+
c(n)
|
|
403
|
+
] }]
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
return a("void-gauge-table", l);
|
|
407
|
+
});
|
|
408
|
+
}
|
|
341
409
|
_renderHoverTooltip(e, t) {
|
|
342
|
-
let n = e[t], r = this._displaySegments.get(t) ?? n.value, i = [...this._displaySegments.values()].reduce((e, t) => e + t, 0) || this._displayValue || 1,
|
|
343
|
-
return
|
|
410
|
+
let n = e[t], r = this._displaySegments.get(t) ?? n.value, i = [...this._displaySegments.values()].reduce((e, t) => e + t, 0) || this._displayValue || 1, a = Math.round(r / i * 100), o = this._viewBoxHeight(), s = this._hoverX + 12, c = this._hoverY + 12;
|
|
411
|
+
return s + 140 > this.size && (s = this._hoverX - 12 - 140), c + 44 > o && (c = this._hoverY - 12 - 44), s < 0 && (s = 0), c < 0 && (c = 0), f`
|
|
344
412
|
<g class="void-gauge-hover" pointer-events="none">
|
|
345
413
|
<rect
|
|
346
414
|
class="void-gauge-tooltip-bg"
|
|
347
|
-
x=${
|
|
415
|
+
x=${s} y=${c}
|
|
348
416
|
width=${140} height=${44}
|
|
349
417
|
rx="6" ry="6"
|
|
350
418
|
></rect>
|
|
351
419
|
<text
|
|
352
420
|
class="void-gauge-tooltip-name"
|
|
353
|
-
x=${
|
|
354
|
-
y=${
|
|
421
|
+
x=${s + 8}
|
|
422
|
+
y=${c + 8 + 10}
|
|
355
423
|
>${n.name}</text>
|
|
356
424
|
<text
|
|
357
425
|
class="void-gauge-tooltip-value"
|
|
358
|
-
x=${
|
|
359
|
-
y=${
|
|
360
|
-
>${
|
|
426
|
+
x=${s + 8}
|
|
427
|
+
y=${c + 8 + 14 + 10}
|
|
428
|
+
>${_(r)} <tspan class="void-gauge-tooltip-pct">(${a}%)</tspan></text>
|
|
361
429
|
</g>
|
|
362
430
|
`;
|
|
363
431
|
}
|
|
364
432
|
};
|
|
365
|
-
t([
|
|
433
|
+
t([p()], C.prototype, "unit", void 0), t([p({
|
|
366
434
|
type: Number,
|
|
367
435
|
reflect: !0
|
|
368
|
-
})],
|
|
436
|
+
})], C.prototype, "value", void 0), t([p({ type: Number })], C.prototype, "min", void 0), t([p({ type: Number })], C.prototype, "max", void 0), t([p({
|
|
369
437
|
type: Number,
|
|
370
438
|
reflect: !0
|
|
371
|
-
})],
|
|
439
|
+
})], C.prototype, "size", void 0), t([p({ type: Number })], C.prototype, "thickness", void 0), t([p({ reflect: !0 })], C.prototype, "circular", void 0), t([p({ reflect: !0 })], C.prototype, "variant", void 0), t([p({
|
|
372
440
|
type: Boolean,
|
|
373
441
|
attribute: "hide-value",
|
|
374
442
|
reflect: !0
|
|
375
|
-
})],
|
|
443
|
+
})], C.prototype, "hideValue", void 0), t([p({
|
|
376
444
|
type: Boolean,
|
|
377
445
|
attribute: "unit-inline",
|
|
378
446
|
reflect: !0
|
|
379
|
-
})],
|
|
447
|
+
})], C.prototype, "unitInline", void 0), t([p({
|
|
380
448
|
type: Number,
|
|
381
449
|
attribute: "tick-major"
|
|
382
|
-
})],
|
|
450
|
+
})], C.prototype, "tickMajor", void 0), t([p({
|
|
383
451
|
type: Number,
|
|
384
452
|
attribute: "tick-minor"
|
|
385
|
-
})],
|
|
453
|
+
})], C.prototype, "tickMinor", void 0), t([p({
|
|
386
454
|
type: Boolean,
|
|
387
455
|
attribute: "hide-tick-min",
|
|
388
456
|
reflect: !0
|
|
389
|
-
})],
|
|
457
|
+
})], C.prototype, "hideTickMin", void 0), t([p({
|
|
390
458
|
type: Boolean,
|
|
391
459
|
attribute: "hide-tick-max",
|
|
392
460
|
reflect: !0
|
|
393
|
-
})],
|
|
461
|
+
})], C.prototype, "hideTickMax", void 0), t([p({ attribute: "segments-sort" })], C.prototype, "segmentsSort", void 0), t([p({ converter: {
|
|
394
462
|
fromAttribute(e) {
|
|
395
463
|
if (e === null || e === "" || e === "true") return !0;
|
|
396
464
|
if (e === "false") return !1;
|
|
@@ -400,6 +468,10 @@ t([o()], h.prototype, "unit", void 0), t([o({
|
|
|
400
468
|
toAttribute(e) {
|
|
401
469
|
return e === !0 ? "" : e === !1 ? "false" : String(e);
|
|
402
470
|
}
|
|
403
|
-
} })],
|
|
471
|
+
} })], C.prototype, "gaps", void 0), t([p({ attribute: "aria-label" })], C.prototype, "ariaLabel", void 0), t([p({
|
|
472
|
+
type: Boolean,
|
|
473
|
+
attribute: "show-table",
|
|
474
|
+
reflect: !0
|
|
475
|
+
})], C.prototype, "showTable", void 0), t([p({ attribute: "zones" })], C.prototype, "zones", null), t([p({ attribute: "data" })], C.prototype, "data", null), t([m()], C.prototype, "_phase", void 0), t([m()], C.prototype, "_hoverSegment", void 0), t([m()], C.prototype, "_hoverX", void 0), t([m()], C.prototype, "_hoverY", void 0), customElements.get("void-gauge") || customElements.define("void-gauge", C);
|
|
404
476
|
//#endregion
|
|
405
|
-
export {
|
|
477
|
+
export { C as VoidGauge };
|
|
@@ -3,12 +3,16 @@ import { KeyboardActivation } from '../keyboard-activation.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Animated open/close toggle for mobile navigation menus and collapsible sidebars.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* Name it by what it opens: `aria-label="Main navigation"` (or `aria-labelledby`). Without one it is called "Menu" ("Close menu" while open).
|
|
7
|
+
*
|
|
8
|
+
* @fires {CustomEvent<{ reason: 'trigger' | 'keyboard' }>} void-open - The user opened it: `trigger` for a click, `keyboard` for Enter or Space. Does not bubble.
|
|
7
9
|
* @fires {CustomEvent<{ reason: 'trigger' }>} void-close - The user closed it. Does not bubble.
|
|
8
10
|
*/
|
|
9
11
|
export declare class VoidHamburger extends VoidElement {
|
|
10
12
|
/** Enter and Space fire a real `click`, as on a native button. */
|
|
11
13
|
protected readonly _activation: KeyboardActivation;
|
|
14
|
+
/** A key (Enter, Space) is activating it, so the click it fires reports reason `keyboard`. */
|
|
15
|
+
private _byKey;
|
|
12
16
|
/**
|
|
13
17
|
* Whether the menu it controls is open: draws the lines as a close cross and sets `aria-expanded`. It
|
|
14
18
|
* flips on every click and Enter or Space, firing `void-open` or `void-close`; set it yourself when the
|
|
@@ -24,6 +28,13 @@ export declare class VoidHamburger extends VoidElement {
|
|
|
24
28
|
disconnectedCallback(): void;
|
|
25
29
|
updated(changed: Map<string, unknown>): void;
|
|
26
30
|
private _handleClick;
|
|
31
|
+
/** The label this component wrote itself, so a name the author wrote is told apart from it. */
|
|
32
|
+
private _writtenLabel;
|
|
33
|
+
/**
|
|
34
|
+
* The name is the author's `aria-label` or `aria-labelledby` (say what it opens: "Main navigation"; it stays the
|
|
35
|
+
* same while open, `aria-expanded` says the rest). Without one it is "Menu", or "Close menu" while open.
|
|
36
|
+
*/
|
|
37
|
+
private _syncLabel;
|
|
27
38
|
render(): import('lit').TemplateResult<1>;
|
|
28
39
|
}
|
|
29
40
|
declare global {
|