@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
|
@@ -1,53 +1,55 @@
|
|
|
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 {
|
|
6
|
-
import {
|
|
3
|
+
import { r as n } from "../chunks/projection-oPe6ipjL.js";
|
|
4
|
+
import { i as r, n as i, o as a, r as o, s, t as c } from "../chunks/data-BpiiNapL.js";
|
|
5
|
+
import { t as l } from "../chunks/shape-C_LW7EjG.js";
|
|
6
|
+
import { html as u, nothing as d, svg as f } from "lit";
|
|
7
|
+
import { property as p, state as m } from "lit/decorators.js";
|
|
8
|
+
import { guard as h } from "lit/directives/guard.js";
|
|
7
9
|
//#region src/components/donut-chart.ts
|
|
8
10
|
n();
|
|
9
|
-
function
|
|
11
|
+
function g(e) {
|
|
10
12
|
return Number.isFinite(e) ? e : 0;
|
|
11
13
|
}
|
|
12
|
-
function
|
|
14
|
+
function _(e) {
|
|
13
15
|
return 1 - (1 - e) ** 3;
|
|
14
16
|
}
|
|
15
|
-
function
|
|
17
|
+
function v(e) {
|
|
16
18
|
return Math.abs(e) >= 1e3 ? `${(e / 1e3).toFixed(e >= 1e4 ? 0 : 1)}k` : Math.round(e).toString();
|
|
17
19
|
}
|
|
18
|
-
function
|
|
20
|
+
function y(e) {
|
|
19
21
|
return Math.abs(e) >= 1e3 ? `${(e / 1e3).toFixed(e >= 1e4 ? 0 : 1)}k` : Math.round(e).toString();
|
|
20
22
|
}
|
|
21
|
-
var
|
|
23
|
+
var b = class extends e {
|
|
22
24
|
constructor(...e) {
|
|
23
|
-
super(...e), this.size = 220, this.inner = .6, this.gaps = !1, this.variant = "filled", this.showValue = !1, this.showTotal = !1, this.ariaLabel = "", this._data = { segments: [] }, this._phase = "pre", this._hoverSegment = null, this._hoverX = 0, this._hoverY = 0, this._progress = 0, this._progressFrom = 0, this._displayValues = /* @__PURE__ */ new Map(), this._targetValues = /* @__PURE__ */ new Map(), this._animFrom = /* @__PURE__ */ new Map(), this._displayTotal = 0, this._displayTotalFrom = 0, this._targetTotal = 0, this._animStart = 0, this._animDuration = 0, this._rafHandle = 0, this._onMouseMove = (e) => {
|
|
25
|
+
super(...e), this.size = 220, this.inner = .6, this.gaps = !1, this.variant = "filled", this.showValue = !1, this.showTotal = !1, this.ariaLabel = "", this.showTable = !1, this._data = { segments: [] }, this._source = { text: null }, this._entered = !1, this._phase = "pre", this._hoverSegment = null, this._hoverX = 0, this._hoverY = 0, this._progress = 0, this._progressFrom = 0, this._displayValues = /* @__PURE__ */ new Map(), this._targetValues = /* @__PURE__ */ new Map(), this._animFrom = /* @__PURE__ */ new Map(), this._displayTotal = 0, this._displayTotalFrom = 0, this._targetTotal = 0, this._animStart = 0, this._animDuration = 0, this._rafHandle = 0, this._onMouseMove = (e) => {
|
|
24
26
|
let t = this.querySelector("svg");
|
|
25
27
|
if (!t) return;
|
|
26
28
|
let n = this._data.segments;
|
|
27
29
|
if (n.length === 0 || this._displayTotal <= 0) return;
|
|
28
30
|
let r = t.getBoundingClientRect();
|
|
29
31
|
if (r.width === 0) return;
|
|
30
|
-
let i = (e.clientX - r.left) / r.width * this.size, a = (e.clientY - r.top) / r.height * this.size, o = this.size / 2, s = this.size / 2, c = i - o,
|
|
31
|
-
if (
|
|
32
|
+
let i = (e.clientX - r.left) / r.width * this.size, a = (e.clientY - r.top) / r.height * this.size, o = this.size / 2, s = this.size / 2, c = i - o, l = a - s, u = Math.sqrt(c * c + l * l), d = this.size / 2 - 4;
|
|
33
|
+
if (u < d * this.inner || u > d) {
|
|
32
34
|
this._hoverSegment !== null && (this._hoverSegment = null);
|
|
33
35
|
return;
|
|
34
36
|
}
|
|
35
|
-
let
|
|
36
|
-
|
|
37
|
-
let
|
|
37
|
+
let f = Math.atan2(l, c) - -Math.PI / 2;
|
|
38
|
+
f < 0 && (f += 2 * Math.PI);
|
|
39
|
+
let p = 2 * Math.PI, m = 0;
|
|
38
40
|
for (let e = 0; e < n.length; e++) {
|
|
39
|
-
let t =
|
|
40
|
-
if (
|
|
41
|
+
let t = g(n[e].value) / this._targetTotal * p;
|
|
42
|
+
if (f >= m && f < m + t) {
|
|
41
43
|
this._hoverSegment !== e && (this._hoverSegment = e), this._hoverX = i, this._hoverY = a;
|
|
42
44
|
return;
|
|
43
45
|
}
|
|
44
|
-
|
|
46
|
+
m += t;
|
|
45
47
|
}
|
|
46
48
|
this._hoverSegment !== null && (this._hoverSegment = null);
|
|
47
49
|
}, this._onMouseLeave = () => {
|
|
48
50
|
this._hoverSegment = null;
|
|
49
51
|
}, this._tick = (e) => {
|
|
50
|
-
let t = e - this._animStart, n = Math.min(t / this._animDuration, 1), r =
|
|
52
|
+
let t = e - this._animStart, n = Math.min(t / this._animDuration, 1), r = _(n);
|
|
51
53
|
this._progress = this._progressFrom + (1 - this._progressFrom) * r;
|
|
52
54
|
for (let [e, t] of this._targetValues) {
|
|
53
55
|
let n = this._animFrom.get(e) ?? 0;
|
|
@@ -60,23 +62,35 @@ var p = class extends e {
|
|
|
60
62
|
return this._data;
|
|
61
63
|
}
|
|
62
64
|
set data(e) {
|
|
63
|
-
let t =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
let t = a(e, this._source, {
|
|
66
|
+
attr: "data",
|
|
67
|
+
shape: "{\"segments\":[{\"name\":\"Search\",\"value\":40},{\"name\":\"Direct\",\"value\":25}]}",
|
|
68
|
+
empty: () => ({ segments: [] }),
|
|
69
|
+
normalize: (e) => {
|
|
70
|
+
if (!o(e)) return null;
|
|
71
|
+
let t = r(e.segments ?? []);
|
|
72
|
+
return t ? { segments: t } : null;
|
|
73
|
+
},
|
|
74
|
+
warn: (e, t) => this.reportDev("invalid-data", e, t)
|
|
75
|
+
});
|
|
76
|
+
if (!t) return;
|
|
77
|
+
let n = t.value, i = this._data.segments, s = this._progress, c = new Map(this._displayValues), l = this._displayTotal;
|
|
78
|
+
this._data = n, this._refreshTargets(), this.requestUpdate(), this._entered && this.updateComplete.then(() => {
|
|
79
|
+
let e = /* @__PURE__ */ new Map();
|
|
80
|
+
for (let t = 0; t < i.length; t++) e.set(t, c.get(t) ?? 0);
|
|
81
|
+
for (let t = 0; t < n.segments.length; t++) e.has(t) || e.set(t, 0);
|
|
82
|
+
this._startAnimation(e, l, s >= 1 ? 1 : s, !1);
|
|
69
83
|
});
|
|
70
84
|
}
|
|
71
85
|
_refreshTargets() {
|
|
72
86
|
this._targetValues.clear();
|
|
73
87
|
let e = this._data.segments;
|
|
74
|
-
for (let t = 0; t < e.length; t++) this._targetValues.set(t,
|
|
75
|
-
this._targetTotal = e.reduce((e, t) => e +
|
|
88
|
+
for (let t = 0; t < e.length; t++) this._targetValues.set(t, g(e[t].value));
|
|
89
|
+
this._targetTotal = e.reduce((e, t) => e + g(t.value), 0);
|
|
76
90
|
}
|
|
77
91
|
connectedCallback() {
|
|
78
|
-
super.connectedCallback(), this.setHostAttribute("role", "
|
|
79
|
-
this._startAnimation(/* @__PURE__ */ new Map(), 0, 0, !0);
|
|
92
|
+
super.connectedCallback(), this.setHostAttribute("role", "figure"), this._refreshTargets(), requestAnimationFrame(() => {
|
|
93
|
+
this._entered = !0, this._startAnimation(/* @__PURE__ */ new Map(), 0, 0, !0);
|
|
80
94
|
}), this.addEventListener("mousemove", this._onMouseMove), this.addEventListener("mouseleave", this._onMouseLeave);
|
|
81
95
|
}
|
|
82
96
|
disconnectedCallback() {
|
|
@@ -92,82 +106,90 @@ var p = class extends e {
|
|
|
92
106
|
this._phase = "animating", this._rafHandle = requestAnimationFrame(this._tick);
|
|
93
107
|
}
|
|
94
108
|
render() {
|
|
95
|
-
let { segments: e } = this._data, t = e.reduce((e, t) => e +
|
|
96
|
-
if (e.length === 0 || t === 0) return
|
|
97
|
-
let n = this.size / 2,
|
|
109
|
+
let { segments: e } = this._data, t = e.reduce((e, t) => e + g(t.value), 0);
|
|
110
|
+
if (e.length === 0 || t === 0) return u`<svg viewBox="0 0 ${this.size} ${this.size}" aria-hidden="true"></svg>${this._table()}`;
|
|
111
|
+
let n = this.size / 2, r = this.size / 2, i = this.size / 2 - 4, a = i * this.inner, o = Math.max(this._displayTotal, .001), s = 2 * Math.PI, c = -Math.PI / 2 + this._progress * s, p = (this.gaps === !0 ? 1 : this.gaps === !1 ? 0 : this.gaps) / 100 * s, m = e.filter((e, t) => (this._displayValues.get(t) ?? 0) > 0).length, h = (m > 1 ? p / e.length : 0) / 2, _ = [], b = -Math.PI / 2;
|
|
98
112
|
for (let t = 0; t < e.length; t++) {
|
|
99
|
-
let
|
|
100
|
-
if (
|
|
101
|
-
let e =
|
|
102
|
-
|
|
113
|
+
let u = e[t], d = this._displayValues.get(t) ?? 0, p = b, g = p + d / o * s, v = Math.min(g, c);
|
|
114
|
+
if (v > p + .001) {
|
|
115
|
+
let e = u.color ?? `var(--void-chart-series-${t % 6 + 1})`, o = p + h, c = m === 1 && v >= p + s - 1e-9 ? o + s : Math.max(o + .001, v - h);
|
|
116
|
+
_.push(f`
|
|
103
117
|
<path
|
|
104
118
|
class="void-donut-chart-segment"
|
|
105
|
-
d=${
|
|
119
|
+
d=${l(n, r, i, o, c, a)}
|
|
106
120
|
style="--segment-color: ${e}"
|
|
107
121
|
data-segment-index=${t}
|
|
108
122
|
></path>
|
|
109
123
|
`);
|
|
110
124
|
}
|
|
111
|
-
b =
|
|
125
|
+
b = g;
|
|
112
126
|
}
|
|
113
|
-
return
|
|
127
|
+
return u`
|
|
114
128
|
<svg
|
|
115
129
|
viewBox="0 0 ${this.size} ${this.size}"
|
|
116
|
-
|
|
117
|
-
aria-label=${this.ariaLabel || "Donut chart"}
|
|
130
|
+
aria-hidden="true"
|
|
118
131
|
data-phase=${this._phase}
|
|
119
132
|
>
|
|
120
|
-
${
|
|
121
|
-
${this.showTotal ?
|
|
133
|
+
${_}
|
|
134
|
+
${this.showTotal ? f`
|
|
122
135
|
<g class="void-donut-chart-total">
|
|
123
|
-
<text x=${n} y=${
|
|
136
|
+
<text x=${n} y=${r} text-anchor="middle" dy="0.32em">${v(this._displayTotal)}</text>
|
|
124
137
|
</g>
|
|
125
|
-
` :
|
|
126
|
-
${this.showValue ?
|
|
138
|
+
` : d}
|
|
139
|
+
${this.showValue ? f`
|
|
127
140
|
<g class="void-donut-chart-labels">
|
|
128
141
|
${e.map((e, t) => {
|
|
129
|
-
let
|
|
130
|
-
if (
|
|
131
|
-
let
|
|
132
|
-
for (let e = 0; e < t; e++)
|
|
133
|
-
let
|
|
134
|
-
return
|
|
142
|
+
let c = this._displayValues.get(t) ?? 0;
|
|
143
|
+
if (c < .001) return d;
|
|
144
|
+
let l = -Math.PI / 2;
|
|
145
|
+
for (let e = 0; e < t; e++) l += (this._displayValues.get(e) ?? 0) / o * s;
|
|
146
|
+
let u = l + c / o * s / 2, p = (i + a) / 2;
|
|
147
|
+
return f`<text x=${n + p * Math.cos(u)} y=${r + p * Math.sin(u)} text-anchor="middle" dy="0.32em">${y(c)}</text>`;
|
|
135
148
|
})}
|
|
136
149
|
</g>
|
|
137
|
-
` :
|
|
150
|
+
` : d}
|
|
138
151
|
|
|
139
|
-
${this._hoverSegment !== null && this._hoverSegment < e.length ? this._renderHoverTooltip(e, this._hoverSegment) :
|
|
152
|
+
${this._hoverSegment !== null && this._hoverSegment < e.length ? this._renderHoverTooltip(e, this._hoverSegment) : d}
|
|
140
153
|
</svg>
|
|
154
|
+
${this._table()}
|
|
141
155
|
`;
|
|
142
156
|
}
|
|
157
|
+
_table() {
|
|
158
|
+
let e = this._data.segments, t = this.ariaLabel || "Donut chart";
|
|
159
|
+
return h([
|
|
160
|
+
e,
|
|
161
|
+
t,
|
|
162
|
+
c(this)
|
|
163
|
+
], () => i("void-donut-chart-table", s(this, t, e)));
|
|
164
|
+
}
|
|
143
165
|
_renderHoverTooltip(e, t) {
|
|
144
|
-
let n = e[t], r = this._displayValues.get(t) ??
|
|
145
|
-
return
|
|
166
|
+
let n = e[t], r = this._displayValues.get(t) ?? g(n.value), i = [...this._displayValues.values()].reduce((e, t) => e + t, 0) || this._targetTotal || 1, a = Math.round(r / i * 100), o = this.size / 2, s = this._hoverX < o ? this.size - 140 - 8 : 8, c = this._hoverY - 44 / 2;
|
|
167
|
+
return c < 8 && (c = 8), c + 44 > this.size - 8 && (c = this.size - 44 - 8), f`
|
|
146
168
|
<g class="void-donut-chart-hover" pointer-events="none">
|
|
147
169
|
<rect
|
|
148
170
|
class="void-donut-chart-tooltip-bg"
|
|
149
|
-
x=${
|
|
171
|
+
x=${s} y=${c}
|
|
150
172
|
width=${140} height=${44}
|
|
151
173
|
rx="6" ry="6"
|
|
152
174
|
></rect>
|
|
153
175
|
<text
|
|
154
176
|
class="void-donut-chart-tooltip-name"
|
|
155
|
-
x=${
|
|
156
|
-
y=${
|
|
177
|
+
x=${s + 8}
|
|
178
|
+
y=${c + 8 + 10}
|
|
157
179
|
>${n.name}</text>
|
|
158
180
|
<text
|
|
159
181
|
class="void-donut-chart-tooltip-value"
|
|
160
|
-
x=${
|
|
161
|
-
y=${
|
|
162
|
-
>${
|
|
182
|
+
x=${s + 8}
|
|
183
|
+
y=${c + 8 + 14 + 10}
|
|
184
|
+
>${y(r)} <tspan class="void-donut-chart-tooltip-pct">(${a}%)</tspan></text>
|
|
163
185
|
</g>
|
|
164
186
|
`;
|
|
165
187
|
}
|
|
166
188
|
};
|
|
167
|
-
t([
|
|
189
|
+
t([p({
|
|
168
190
|
type: Number,
|
|
169
191
|
reflect: !0
|
|
170
|
-
})],
|
|
192
|
+
})], b.prototype, "size", void 0), t([p({ type: Number })], b.prototype, "inner", void 0), t([p({ converter: {
|
|
171
193
|
fromAttribute(e) {
|
|
172
194
|
if (e === null || e === "" || e === "true") return !0;
|
|
173
195
|
if (e === "false") return !1;
|
|
@@ -177,14 +199,18 @@ t([s({
|
|
|
177
199
|
toAttribute(e) {
|
|
178
200
|
return e === !0 ? "" : e === !1 ? "false" : String(e);
|
|
179
201
|
}
|
|
180
|
-
} })],
|
|
202
|
+
} })], b.prototype, "gaps", void 0), t([p({ reflect: !0 })], b.prototype, "variant", void 0), t([p({
|
|
181
203
|
type: Boolean,
|
|
182
204
|
attribute: "show-value",
|
|
183
205
|
reflect: !0
|
|
184
|
-
})],
|
|
206
|
+
})], b.prototype, "showValue", void 0), t([p({
|
|
185
207
|
type: Boolean,
|
|
186
208
|
attribute: "show-total",
|
|
187
209
|
reflect: !0
|
|
188
|
-
})],
|
|
210
|
+
})], b.prototype, "showTotal", void 0), t([p({ attribute: "aria-label" })], b.prototype, "ariaLabel", void 0), t([p({
|
|
211
|
+
type: Boolean,
|
|
212
|
+
attribute: "show-table",
|
|
213
|
+
reflect: !0
|
|
214
|
+
})], b.prototype, "showTable", void 0), t([p({ attribute: "data" })], b.prototype, "data", null), t([m()], b.prototype, "_phase", void 0), t([m()], b.prototype, "_hoverSegment", void 0), t([m()], b.prototype, "_hoverX", void 0), t([m()], b.prototype, "_hoverY", void 0), customElements.get("void-donut-chart") || customElements.define("void-donut-chart", b);
|
|
189
215
|
//#endregion
|
|
190
|
-
export {
|
|
216
|
+
export { b as VoidDonutChart };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "../chunks/decorate-CaYbmmmm.js";
|
|
2
|
-
import { t } from "../chunks/modal-
|
|
2
|
+
import { t } from "../chunks/modal-DWGkNdNG.js";
|
|
3
3
|
import { property as n } from "lit/decorators.js";
|
|
4
4
|
//#region src/components/drawer.ts
|
|
5
5
|
var r = class extends t {
|
|
@@ -1,9 +1,9 @@
|
|
|
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
3
|
import { t as n } from "../chunks/keyboard-activation-CV0m4hkn.js";
|
|
4
4
|
import { i as r, n as i } from "../chunks/parts-DI_3VpSy.js";
|
|
5
5
|
import { a, i as o, t as s } from "../chunks/keyboard-CEhMSkws.js";
|
|
6
|
-
import { t as c } from "../chunks/overlay-
|
|
6
|
+
import { t as c } from "../chunks/overlay-CH7L4N-h.js";
|
|
7
7
|
import { property as l } from "lit/decorators.js";
|
|
8
8
|
//#region src/components/dropdown-menu.ts
|
|
9
9
|
var u = class extends e {
|
|
@@ -1,7 +1,7 @@
|
|
|
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
3
|
import { t as n } from "../chunks/form-control-C0vH6gii.js";
|
|
4
|
-
import { n as r } from "../chunks/projection-
|
|
4
|
+
import { n as r } from "../chunks/projection-oPe6ipjL.js";
|
|
5
5
|
import { html as i, nothing as a } from "lit";
|
|
6
6
|
import { property as o } from "lit/decorators.js";
|
|
7
7
|
import { live as s } from "lit/directives/live.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
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
3
|
import { n, t as r } from "../chunks/parts-DI_3VpSy.js";
|
|
4
4
|
import { property as i } from "lit/decorators.js";
|
package/dist/components/field.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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 { t as n } from "../chunks/projection-
|
|
3
|
+
import { t as n } from "../chunks/projection-oPe6ipjL.js";
|
|
4
4
|
import { html as r, nothing as i } from "lit";
|
|
5
5
|
import { property as a } from "lit/decorators.js";
|
|
6
6
|
//#region src/components/field.ts
|
|
@@ -1,27 +1,39 @@
|
|
|
1
1
|
import { VoidElement } from '../base.js';
|
|
2
2
|
import { FormSubmission } from '../form-control.js';
|
|
3
|
+
/** Why a file was not taken: `type` (not matched by `accept`), `size` (over `max-size`) or `count` (more files than the zone takes). */
|
|
4
|
+
export type FileRejectReason = 'type' | 'size' | 'count';
|
|
3
5
|
declare const VoidFileUpload_base: (new (...args: any[]) => import('../form-control.js').VoidInternalsFormControl) & typeof VoidElement;
|
|
4
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Drag-and-drop file picker for document uploads, image attachment flows, and import wizards.
|
|
8
|
+
*
|
|
9
|
+
* @fires {CustomEvent<{ rejected: { file: File; reason: 'type' | 'size' | 'count' }[] }>} void-reject - Files were refused: one entry per file with the reason. Does not bubble.
|
|
10
|
+
*/
|
|
5
11
|
export declare class VoidFileUpload extends VoidFileUpload_base {
|
|
6
12
|
/** The host's `aria-label` / `aria-labelledby` name the inner control. */
|
|
7
13
|
static labelTarget: string;
|
|
8
14
|
/**
|
|
9
15
|
* Comma-separated file types the zone takes, as on a native file input: extensions (`.pdf`), MIME
|
|
10
|
-
* types (`image/png`) or wildcards (`image/*`). Other files are
|
|
16
|
+
* types (`image/png`) or wildcards (`image/*`). Other files are not taken: `void-reject` fires with
|
|
17
|
+
* reason `type` and the zone shows an error.
|
|
11
18
|
*/
|
|
12
19
|
accept: string;
|
|
13
20
|
/** Allow more than one file. Without it a new choice replaces the old one. */
|
|
14
21
|
multiple: boolean;
|
|
15
22
|
/** Stop the zone reacting and exclude the files from the form submission. */
|
|
16
23
|
disabled: boolean;
|
|
17
|
-
/** Largest allowed file in bytes. 0 (the default) means no limit. Larger files are
|
|
24
|
+
/** Largest allowed file in bytes. 0 (the default) means no limit. Larger files are rejected with reason `size`. */
|
|
18
25
|
maxSize: number;
|
|
19
26
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
27
|
+
* Error message shown under the zone; while it is set the drop zone is `aria-invalid` and described by
|
|
28
|
+
* it. Set it for a server-side upload failure. The zone also sets it itself when it rejects a file
|
|
29
|
+
* (see `void-reject`) and clears what it set on the next accepted selection; a message you set is
|
|
30
|
+
* left alone.
|
|
22
31
|
*/
|
|
23
32
|
error: string;
|
|
24
33
|
private _files;
|
|
34
|
+
private _uid;
|
|
35
|
+
/** The message we wrote into `error` (a rejection); an accepted selection clears it only while it is still there. */
|
|
36
|
+
private _ownError;
|
|
25
37
|
/** One entry per selected file. */
|
|
26
38
|
protected formSubmission(): FormSubmission;
|
|
27
39
|
protected formSnapshot(): unknown;
|
|
@@ -29,6 +41,7 @@ export declare class VoidFileUpload extends VoidFileUpload_base {
|
|
|
29
41
|
/** Files cannot be restored from serialised state. */
|
|
30
42
|
formStateRestoreCallback(): void;
|
|
31
43
|
private get _input();
|
|
44
|
+
protected updated(changed: Map<string, unknown>): void;
|
|
32
45
|
render(): import('lit').TemplateResult<1>;
|
|
33
46
|
private _onDropzoneClick;
|
|
34
47
|
private _onDropzoneKeydown;
|
|
@@ -37,6 +50,8 @@ export declare class VoidFileUpload extends VoidFileUpload_base {
|
|
|
37
50
|
private _onDrop;
|
|
38
51
|
private _onInputChange;
|
|
39
52
|
private _addFiles;
|
|
53
|
+
private _message;
|
|
54
|
+
private _clearOwnError;
|
|
40
55
|
private _removeFile;
|
|
41
56
|
}
|
|
42
57
|
declare global {
|
|
@@ -1,14 +1,15 @@
|
|
|
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
3
|
import { t as n } from "../chunks/form-control-C0vH6gii.js";
|
|
4
|
-
import { r } from "../chunks/projection-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { r } from "../chunks/projection-oPe6ipjL.js";
|
|
5
|
+
import { o as i } from "../chunks/keyboard-CEhMSkws.js";
|
|
6
|
+
import { html as a, nothing as o } from "lit";
|
|
7
|
+
import { property as s } from "lit/decorators.js";
|
|
7
8
|
//#region src/components/file-upload.ts
|
|
8
9
|
r();
|
|
9
|
-
var
|
|
10
|
+
var c = class extends n(e) {
|
|
10
11
|
constructor(...e) {
|
|
11
|
-
super(...e), this.accept = "", this.multiple = !1, this.disabled = !1, this.maxSize = 0, this.error = "", this._files = [], this._onDropzoneClick = () => {
|
|
12
|
+
super(...e), this.accept = "", this.multiple = !1, this.disabled = !1, this.maxSize = 0, this.error = "", this._files = [], this._uid = i("void-file-upload-error"), this._ownError = "", this._onDropzoneClick = () => {
|
|
12
13
|
this.formDisabled || this._input?.click();
|
|
13
14
|
}, this._onDropzoneKeydown = (e) => {
|
|
14
15
|
this.formDisabled || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), this._input?.click());
|
|
@@ -41,12 +42,17 @@ var s = class extends n(e) {
|
|
|
41
42
|
get _input() {
|
|
42
43
|
return this.querySelector("input[type=\"file\"]");
|
|
43
44
|
}
|
|
45
|
+
updated(e) {
|
|
46
|
+
super.updated(e);
|
|
47
|
+
let t = this.querySelector(".void-file-upload-dropzone");
|
|
48
|
+
t && (this.error ? t.getAttribute("aria-invalid") !== "true" && t.setAttribute("aria-invalid", "true") : t.hasAttribute("aria-invalid") && t.removeAttribute("aria-invalid"));
|
|
49
|
+
}
|
|
44
50
|
render() {
|
|
45
|
-
return
|
|
51
|
+
return a`
|
|
46
52
|
<input
|
|
47
53
|
type="file"
|
|
48
54
|
class="void-file-upload-input"
|
|
49
|
-
accept=${this.accept ||
|
|
55
|
+
accept=${this.accept || o}
|
|
50
56
|
?multiple=${this.multiple}
|
|
51
57
|
?disabled=${this.disabled}
|
|
52
58
|
@change=${this._onInputChange}
|
|
@@ -55,7 +61,8 @@ var s = class extends n(e) {
|
|
|
55
61
|
class="void-file-upload-dropzone"
|
|
56
62
|
tabindex=${this.formDisabled ? "-1" : "0"}
|
|
57
63
|
role="button"
|
|
58
|
-
aria-disabled=${this.formDisabled ? "true" :
|
|
64
|
+
aria-disabled=${this.formDisabled ? "true" : o}
|
|
65
|
+
aria-describedby=${this.error ? this._uid : o}
|
|
59
66
|
@click=${this._onDropzoneClick}
|
|
60
67
|
@keydown=${this._onDropzoneKeydown}
|
|
61
68
|
@dragover=${this._onDragOver}
|
|
@@ -66,9 +73,9 @@ var s = class extends n(e) {
|
|
|
66
73
|
Drop files here or <span class="void-file-upload-browse">browse</span>
|
|
67
74
|
</span>
|
|
68
75
|
</div>
|
|
69
|
-
${this._files.length > 0 ?
|
|
76
|
+
${this._files.length > 0 ? a`
|
|
70
77
|
<div class="void-file-upload-files">
|
|
71
|
-
${this._files.map((e, t) =>
|
|
78
|
+
${this._files.map((e, t) => a`
|
|
72
79
|
<div class="void-file-upload-file">
|
|
73
80
|
<span class="void-file-upload-filename">${e.name}</span>
|
|
74
81
|
<button
|
|
@@ -81,13 +88,30 @@ var s = class extends n(e) {
|
|
|
81
88
|
</div>
|
|
82
89
|
`)}
|
|
83
90
|
</div>
|
|
84
|
-
` :
|
|
85
|
-
${this.error ?
|
|
91
|
+
` : o}
|
|
92
|
+
${this.error ? a`<span class="void-file-upload-error" id=${this._uid} role="alert">${this.error}</span>` : o}
|
|
86
93
|
`;
|
|
87
94
|
}
|
|
88
95
|
_addFiles(e) {
|
|
89
|
-
let t =
|
|
90
|
-
|
|
96
|
+
let t = [], n = [], r = this.accept.split(",").map((e) => e.trim()).filter(Boolean);
|
|
97
|
+
for (let i of e) r.length > 0 && !r.some((e) => e.startsWith(".") ? i.name.toLowerCase().endsWith(e.toLowerCase()) : e.endsWith("/*") ? i.type.startsWith(e.slice(0, -1)) : i.type === e) ? t.push({
|
|
98
|
+
file: i,
|
|
99
|
+
reason: "type"
|
|
100
|
+
}) : this.maxSize > 0 && i.size > this.maxSize ? t.push({
|
|
101
|
+
file: i,
|
|
102
|
+
reason: "size"
|
|
103
|
+
}) : n.push(i);
|
|
104
|
+
if (!this.multiple && n.length > 1) {
|
|
105
|
+
for (let e of n.slice(1)) t.push({
|
|
106
|
+
file: e,
|
|
107
|
+
reason: "count"
|
|
108
|
+
});
|
|
109
|
+
n = n.slice(0, 1);
|
|
110
|
+
}
|
|
111
|
+
t.length > 0 && (this.error = t.map((e) => this._message(e.file, e.reason)).join(" "), this._ownError = this.error, this.dispatchEvent(new CustomEvent("void-reject", {
|
|
112
|
+
bubbles: !1,
|
|
113
|
+
detail: { rejected: t }
|
|
114
|
+
}))), n.length !== 0 && (t.length === 0 && this._clearOwnError(), this._files = this.multiple ? [...this._files, ...n] : n, this.requestUpdate(), this.dispatchEvent(new CustomEvent("void-change", {
|
|
91
115
|
bubbles: !0,
|
|
92
116
|
composed: !0,
|
|
93
117
|
detail: {
|
|
@@ -96,6 +120,12 @@ var s = class extends n(e) {
|
|
|
96
120
|
}
|
|
97
121
|
})));
|
|
98
122
|
}
|
|
123
|
+
_message(e, t) {
|
|
124
|
+
return t === "type" ? `${e.name} is not an accepted file type.` : t === "size" ? `${e.name} is larger than the ${this.maxSize} byte limit.` : `${e.name} was not added: only one file can be chosen.`;
|
|
125
|
+
}
|
|
126
|
+
_clearOwnError() {
|
|
127
|
+
this._ownError && this.error === this._ownError && (this.error = ""), this._ownError = "";
|
|
128
|
+
}
|
|
99
129
|
_removeFile(e) {
|
|
100
130
|
this._files = this._files.filter((t, n) => n !== e), this.requestUpdate(), this.dispatchEvent(new CustomEvent("void-change", {
|
|
101
131
|
bubbles: !0,
|
|
@@ -107,18 +137,18 @@ var s = class extends n(e) {
|
|
|
107
137
|
}));
|
|
108
138
|
}
|
|
109
139
|
};
|
|
110
|
-
t([
|
|
140
|
+
t([s({ type: String })], c.prototype, "accept", void 0), t([s({
|
|
111
141
|
type: Boolean,
|
|
112
142
|
reflect: !0
|
|
113
|
-
})],
|
|
143
|
+
})], c.prototype, "multiple", void 0), t([s({
|
|
114
144
|
type: Boolean,
|
|
115
145
|
reflect: !0
|
|
116
|
-
})],
|
|
146
|
+
})], c.prototype, "disabled", void 0), t([s({
|
|
117
147
|
type: Number,
|
|
118
148
|
attribute: "max-size"
|
|
119
|
-
})],
|
|
149
|
+
})], c.prototype, "maxSize", void 0), t([s({
|
|
120
150
|
type: String,
|
|
121
151
|
reflect: !0
|
|
122
|
-
})],
|
|
152
|
+
})], c.prototype, "error", void 0), customElements.get("void-file-upload") || customElements.define("void-file-upload", c);
|
|
123
153
|
//#endregion
|
|
124
|
-
export {
|
|
154
|
+
export { c as VoidFileUpload };
|
|
@@ -84,21 +84,40 @@ export declare class VoidGauge extends VoidElement {
|
|
|
84
84
|
segmentation but more arc sacrificed; the precision-vs-clarity tradeoff. */
|
|
85
85
|
gaps: boolean | number;
|
|
86
86
|
/**
|
|
87
|
-
* Accessible name of the gauge, such as `Disk usage
|
|
88
|
-
*
|
|
87
|
+
* Accessible name of the gauge, such as `Disk usage`; it is also the caption of the data table.
|
|
88
|
+
* Set it: the drawing itself is hidden from assistive technology.
|
|
89
89
|
*/
|
|
90
90
|
ariaLabel: string;
|
|
91
|
-
/**
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Show the data table (the reading with its range, or one row per segment) below the gauge. The table
|
|
93
|
+
* is always there for assistive technology; this makes it visible too.
|
|
94
|
+
*/
|
|
95
|
+
showTable: boolean;
|
|
96
|
+
private _zones;
|
|
97
|
+
private _zonesSource;
|
|
98
|
+
/**
|
|
99
|
+
* Colour bands over the value range: an array of `{ from, to, color }`; the fill takes the colour of the
|
|
100
|
+
* zone containing the value. Give it as a property or as JSON in the `zones` attribute:
|
|
101
|
+
* `<void-gauge zones='[{"from":0,"to":60,"color":"green"},{"from":60,"to":100,"color":"red"}]'>`.
|
|
102
|
+
* Invalid JSON draws no zones and is reported by `@voidable/ui/dev`. Not reflected to the attribute.
|
|
103
|
+
* @default []
|
|
104
|
+
*/
|
|
105
|
+
get zones(): GaugeZone[];
|
|
106
|
+
set zones(input: GaugeZone[]);
|
|
94
107
|
private _data;
|
|
108
|
+
private _source;
|
|
95
109
|
/**
|
|
96
110
|
* Segmented data: `{ segments: [{ name, value, color? }] }` splits the arc between named parts; the
|
|
97
|
-
* optional `value` is the headline reading.
|
|
98
|
-
* animate to it
|
|
111
|
+
* optional `value` is the headline reading. Give it as a property (assign a new object to update the
|
|
112
|
+
* gauge and animate to it) or as JSON in the `data` attribute:
|
|
113
|
+
* `<void-gauge data='{"segments":[{"name":"Used","value":40},{"name":"Cache","value":15}]}'>`. Invalid
|
|
114
|
+
* JSON draws nothing and is reported by `@voidable/ui/dev`. The property is not reflected to the
|
|
115
|
+
* attribute, and an attribute a server morph leaves unchanged does not animate again. For a single
|
|
116
|
+
* reading, set the `value` attribute instead.
|
|
117
|
+
* @default {}
|
|
99
118
|
*/
|
|
100
119
|
get data(): GaugeData;
|
|
101
|
-
set data(
|
|
120
|
+
set data(input: GaugeData);
|
|
102
121
|
private _phase;
|
|
103
122
|
private _hoverSegment;
|
|
104
123
|
private _hoverX;
|
|
@@ -132,6 +151,11 @@ export declare class VoidGauge extends VoidElement {
|
|
|
132
151
|
private _hasTicks;
|
|
133
152
|
private _renderTicks;
|
|
134
153
|
render(): import('lit').TemplateResult<1>;
|
|
154
|
+
/**
|
|
155
|
+
* The data table for assistive technology (and `show-table`), from the data as given, not the animated
|
|
156
|
+
* state: the reading with its range, or the segments in the order they are drawn.
|
|
157
|
+
*/
|
|
158
|
+
private _table;
|
|
135
159
|
private _renderHoverTooltip;
|
|
136
160
|
}
|
|
137
161
|
declare global {
|