@voidable/ui 0.9.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-entry.d.ts +1 -0
- package/dist/base.d.ts +8 -1
- package/dist/base.js +5 -1
- package/dist/chunks/base-BGrS4eIl.js +307 -0
- package/dist/chunks/data-BpiiNapL.js +95 -0
- package/dist/chunks/{keyboard-MQpfTX5I.js → keyboard-CEhMSkws.js} +19 -3
- package/dist/chunks/{modal-hivQ4YoU.js → modal-DWGkNdNG.js} +3 -3
- package/dist/chunks/{overlay-BywGMcDW.js → overlay-CH7L4N-h.js} +2 -2
- package/dist/chunks/{parts-CMQQop0D.js → parts-DI_3VpSy.js} +21 -17
- package/dist/chunks/{base-CMruMbxC.js → projection-oPe6ipjL.js} +105 -389
- package/dist/components/accordion.js +2 -2
- package/dist/components/action-input.d.ts +2 -2
- package/dist/components/action-input.js +56 -54
- package/dist/components/alert.d.ts +11 -0
- package/dist/components/alert.js +11 -4
- package/dist/components/avatar.js +13 -11
- 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 +11 -4
- package/dist/components/bar-chart.d.ts +21 -7
- package/dist/components/bar-chart.js +67 -43
- package/dist/components/breadcrumbs.js +2 -2
- package/dist/components/button.js +1 -1
- package/dist/components/calendar.d.ts +40 -2
- package/dist/components/calendar.js +170 -79
- package/dist/components/card.js +1 -1
- package/dist/components/carousel.js +20 -19
- package/dist/components/charts/data.d.ts +72 -0
- package/dist/components/checkbox-group.js +13 -12
- package/dist/components/checkbox.js +17 -16
- package/dist/components/collapsible.js +2 -2
- package/dist/components/color-picker.js +26 -24
- package/dist/components/combobox.js +17 -16
- package/dist/components/compose-input.js +13 -11
- package/dist/components/dialog.js +1 -1
- package/dist/components/divider.js +11 -9
- package/dist/components/donut-chart.d.ts +22 -6
- package/dist/components/donut-chart.js +96 -68
- package/dist/components/drawer.d.ts +2 -2
- package/dist/components/drawer.js +1 -1
- package/dist/components/dropdown-menu.js +4 -4
- package/dist/components/editable.js +13 -12
- package/dist/components/error-fallback.js +2 -2
- package/dist/components/field.js +10 -9
- package/dist/components/file-upload.d.ts +20 -5
- package/dist/components/file-upload.js +52 -20
- package/dist/components/gauge.d.ts +32 -8
- package/dist/components/gauge.js +209 -135
- package/dist/components/hamburger.d.ts +12 -1
- package/dist/components/hamburger.js +33 -20
- package/dist/components/hover-card.js +3 -3
- package/dist/components/indicator.js +14 -12
- package/dist/components/input.js +41 -39
- package/dist/components/line-chart.d.ts +22 -7
- package/dist/components/line-chart.js +80 -56
- package/dist/components/list.js +1 -1
- package/dist/components/menu.js +3 -3
- package/dist/components/multiselect.js +30 -29
- package/dist/components/nav-bar.d.ts +9 -0
- package/dist/components/nav-bar.js +16 -3
- package/dist/components/nav-menu.js +20 -19
- package/dist/components/number-input.js +17 -15
- package/dist/components/pagination.js +22 -20
- package/dist/components/panel.js +2 -2
- package/dist/components/pin-input.js +32 -30
- package/dist/components/popover.js +3 -3
- package/dist/components/progress.js +14 -12
- package/dist/components/radio-group.js +13 -11
- package/dist/components/radio.d.ts +25 -0
- package/dist/components/radio.js +78 -29
- package/dist/components/scroll-area.js +8 -7
- package/dist/components/segmented-control.js +21 -21
- package/dist/components/select.js +49 -47
- package/dist/components/sidebar.d.ts +2 -2
- package/dist/components/sidebar.js +2 -2
- package/dist/components/skeleton.js +1 -1
- package/dist/components/slider.js +16 -14
- package/dist/components/spinner.js +11 -9
- package/dist/components/stat.d.ts +13 -1
- package/dist/components/stat.js +29 -19
- package/dist/components/status-dot.js +1 -1
- package/dist/components/stepper.js +15 -13
- package/dist/components/switch.js +14 -12
- package/dist/components/table.d.ts +4 -0
- package/dist/components/table.js +42 -29
- package/dist/components/tabs.js +29 -29
- package/dist/components/tag.js +9 -8
- package/dist/components/tags-input.js +24 -22
- package/dist/components/textarea.js +34 -32
- package/dist/components/toast.d.ts +19 -2
- package/dist/components/toast.js +43 -10
- package/dist/components/toggle-group.js +16 -15
- package/dist/components/toggle.js +1 -1
- package/dist/components/tooltip.js +3 -3
- package/dist/components.json +15 -13
- package/dist/custom-elements.json +320 -88
- package/dist/dev/types.d.ts +3 -1
- package/dist/dev.js +85 -16
- package/dist/index.js +1 -1
- package/dist/keyboard.d.ts +10 -0
- package/dist/llms.txt +1 -1
- package/dist/parts.d.ts +5 -0
- package/dist/projection-api.d.ts +23 -0
- package/dist/projection.d.ts +8 -2
- package/dist/reference.md +84 -59
- 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 +108 -28
- package/dist/web-types.json +189 -60
- package/package.json +1 -1
|
@@ -1,51 +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 {
|
|
4
|
-
import {
|
|
5
|
-
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";
|
|
6
9
|
//#region src/components/donut-chart.ts
|
|
7
|
-
|
|
10
|
+
n();
|
|
11
|
+
function g(e) {
|
|
8
12
|
return Number.isFinite(e) ? e : 0;
|
|
9
13
|
}
|
|
10
|
-
function
|
|
14
|
+
function _(e) {
|
|
11
15
|
return 1 - (1 - e) ** 3;
|
|
12
16
|
}
|
|
13
|
-
function
|
|
17
|
+
function v(e) {
|
|
14
18
|
return Math.abs(e) >= 1e3 ? `${(e / 1e3).toFixed(e >= 1e4 ? 0 : 1)}k` : Math.round(e).toString();
|
|
15
19
|
}
|
|
16
|
-
function
|
|
20
|
+
function y(e) {
|
|
17
21
|
return Math.abs(e) >= 1e3 ? `${(e / 1e3).toFixed(e >= 1e4 ? 0 : 1)}k` : Math.round(e).toString();
|
|
18
22
|
}
|
|
19
|
-
var
|
|
23
|
+
var b = class extends e {
|
|
20
24
|
constructor(...e) {
|
|
21
|
-
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) => {
|
|
22
26
|
let t = this.querySelector("svg");
|
|
23
27
|
if (!t) return;
|
|
24
28
|
let n = this._data.segments;
|
|
25
29
|
if (n.length === 0 || this._displayTotal <= 0) return;
|
|
26
30
|
let r = t.getBoundingClientRect();
|
|
27
31
|
if (r.width === 0) return;
|
|
28
|
-
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,
|
|
29
|
-
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) {
|
|
30
34
|
this._hoverSegment !== null && (this._hoverSegment = null);
|
|
31
35
|
return;
|
|
32
36
|
}
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
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;
|
|
36
40
|
for (let e = 0; e < n.length; e++) {
|
|
37
|
-
let t =
|
|
38
|
-
if (
|
|
41
|
+
let t = g(n[e].value) / this._targetTotal * p;
|
|
42
|
+
if (f >= m && f < m + t) {
|
|
39
43
|
this._hoverSegment !== e && (this._hoverSegment = e), this._hoverX = i, this._hoverY = a;
|
|
40
44
|
return;
|
|
41
45
|
}
|
|
42
|
-
|
|
46
|
+
m += t;
|
|
43
47
|
}
|
|
44
48
|
this._hoverSegment !== null && (this._hoverSegment = null);
|
|
45
49
|
}, this._onMouseLeave = () => {
|
|
46
50
|
this._hoverSegment = null;
|
|
47
51
|
}, this._tick = (e) => {
|
|
48
|
-
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);
|
|
49
53
|
this._progress = this._progressFrom + (1 - this._progressFrom) * r;
|
|
50
54
|
for (let [e, t] of this._targetValues) {
|
|
51
55
|
let n = this._animFrom.get(e) ?? 0;
|
|
@@ -58,23 +62,35 @@ var f = class extends e {
|
|
|
58
62
|
return this._data;
|
|
59
63
|
}
|
|
60
64
|
set data(e) {
|
|
61
|
-
let t =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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);
|
|
67
83
|
});
|
|
68
84
|
}
|
|
69
85
|
_refreshTargets() {
|
|
70
86
|
this._targetValues.clear();
|
|
71
87
|
let e = this._data.segments;
|
|
72
|
-
for (let t = 0; t < e.length; t++) this._targetValues.set(t,
|
|
73
|
-
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);
|
|
74
90
|
}
|
|
75
91
|
connectedCallback() {
|
|
76
|
-
super.connectedCallback(), this.setHostAttribute("role", "
|
|
77
|
-
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);
|
|
78
94
|
}), this.addEventListener("mousemove", this._onMouseMove), this.addEventListener("mouseleave", this._onMouseLeave);
|
|
79
95
|
}
|
|
80
96
|
disconnectedCallback() {
|
|
@@ -90,82 +106,90 @@ var f = class extends e {
|
|
|
90
106
|
this._phase = "animating", this._rafHandle = requestAnimationFrame(this._tick);
|
|
91
107
|
}
|
|
92
108
|
render() {
|
|
93
|
-
let { segments: e } = this._data, t = e.reduce((e, t) => e +
|
|
94
|
-
if (e.length === 0 || t === 0) return
|
|
95
|
-
let
|
|
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;
|
|
96
112
|
for (let t = 0; t < e.length; t++) {
|
|
97
|
-
let
|
|
98
|
-
if (
|
|
99
|
-
let e =
|
|
100
|
-
|
|
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`
|
|
101
117
|
<path
|
|
102
118
|
class="void-donut-chart-segment"
|
|
103
|
-
d=${n
|
|
119
|
+
d=${l(n, r, i, o, c, a)}
|
|
104
120
|
style="--segment-color: ${e}"
|
|
105
121
|
data-segment-index=${t}
|
|
106
122
|
></path>
|
|
107
123
|
`);
|
|
108
124
|
}
|
|
109
|
-
b =
|
|
125
|
+
b = g;
|
|
110
126
|
}
|
|
111
|
-
return
|
|
127
|
+
return u`
|
|
112
128
|
<svg
|
|
113
129
|
viewBox="0 0 ${this.size} ${this.size}"
|
|
114
|
-
|
|
115
|
-
aria-label=${this.ariaLabel || "Donut chart"}
|
|
130
|
+
aria-hidden="true"
|
|
116
131
|
data-phase=${this._phase}
|
|
117
132
|
>
|
|
118
|
-
${
|
|
119
|
-
${this.showTotal ?
|
|
133
|
+
${_}
|
|
134
|
+
${this.showTotal ? f`
|
|
120
135
|
<g class="void-donut-chart-total">
|
|
121
|
-
<text x=${
|
|
136
|
+
<text x=${n} y=${r} text-anchor="middle" dy="0.32em">${v(this._displayTotal)}</text>
|
|
122
137
|
</g>
|
|
123
|
-
` :
|
|
124
|
-
${this.showValue ?
|
|
138
|
+
` : d}
|
|
139
|
+
${this.showValue ? f`
|
|
125
140
|
<g class="void-donut-chart-labels">
|
|
126
141
|
${e.map((e, t) => {
|
|
127
|
-
let
|
|
128
|
-
if (
|
|
129
|
-
let
|
|
130
|
-
for (let e = 0; e < t; e++)
|
|
131
|
-
let
|
|
132
|
-
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>`;
|
|
133
148
|
})}
|
|
134
149
|
</g>
|
|
135
|
-
` :
|
|
150
|
+
` : d}
|
|
136
151
|
|
|
137
|
-
${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}
|
|
138
153
|
</svg>
|
|
154
|
+
${this._table()}
|
|
139
155
|
`;
|
|
140
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
|
+
}
|
|
141
165
|
_renderHoverTooltip(e, t) {
|
|
142
|
-
let n = e[t], r = this._displayValues.get(t) ??
|
|
143
|
-
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`
|
|
144
168
|
<g class="void-donut-chart-hover" pointer-events="none">
|
|
145
169
|
<rect
|
|
146
170
|
class="void-donut-chart-tooltip-bg"
|
|
147
|
-
x=${
|
|
171
|
+
x=${s} y=${c}
|
|
148
172
|
width=${140} height=${44}
|
|
149
173
|
rx="6" ry="6"
|
|
150
174
|
></rect>
|
|
151
175
|
<text
|
|
152
176
|
class="void-donut-chart-tooltip-name"
|
|
153
|
-
x=${
|
|
154
|
-
y=${
|
|
177
|
+
x=${s + 8}
|
|
178
|
+
y=${c + 8 + 10}
|
|
155
179
|
>${n.name}</text>
|
|
156
180
|
<text
|
|
157
181
|
class="void-donut-chart-tooltip-value"
|
|
158
|
-
x=${
|
|
159
|
-
y=${
|
|
160
|
-
>${
|
|
182
|
+
x=${s + 8}
|
|
183
|
+
y=${c + 8 + 14 + 10}
|
|
184
|
+
>${y(r)} <tspan class="void-donut-chart-tooltip-pct">(${a}%)</tspan></text>
|
|
161
185
|
</g>
|
|
162
186
|
`;
|
|
163
187
|
}
|
|
164
188
|
};
|
|
165
|
-
t([
|
|
189
|
+
t([p({
|
|
166
190
|
type: Number,
|
|
167
191
|
reflect: !0
|
|
168
|
-
})],
|
|
192
|
+
})], b.prototype, "size", void 0), t([p({ type: Number })], b.prototype, "inner", void 0), t([p({ converter: {
|
|
169
193
|
fromAttribute(e) {
|
|
170
194
|
if (e === null || e === "" || e === "true") return !0;
|
|
171
195
|
if (e === "false") return !1;
|
|
@@ -175,14 +199,18 @@ t([o({
|
|
|
175
199
|
toAttribute(e) {
|
|
176
200
|
return e === !0 ? "" : e === !1 ? "false" : String(e);
|
|
177
201
|
}
|
|
178
|
-
} })],
|
|
202
|
+
} })], b.prototype, "gaps", void 0), t([p({ reflect: !0 })], b.prototype, "variant", void 0), t([p({
|
|
179
203
|
type: Boolean,
|
|
180
204
|
attribute: "show-value",
|
|
181
205
|
reflect: !0
|
|
182
|
-
})],
|
|
206
|
+
})], b.prototype, "showValue", void 0), t([p({
|
|
183
207
|
type: Boolean,
|
|
184
208
|
attribute: "show-total",
|
|
185
209
|
reflect: !0
|
|
186
|
-
})],
|
|
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);
|
|
187
215
|
//#endregion
|
|
188
|
-
export {
|
|
216
|
+
export { b as VoidDonutChart };
|
|
@@ -15,8 +15,8 @@ import { VoidModal } from '../modal.js';
|
|
|
15
15
|
* drawer is closing. Cancelable when the user caused it (`escape`, `outside`, `close-button`).
|
|
16
16
|
*/
|
|
17
17
|
export declare class VoidDrawer extends VoidModal {
|
|
18
|
-
/**
|
|
19
|
-
side: 'left' | 'right' | 'top' | 'bottom';
|
|
18
|
+
/** Edge the drawer slides in from: `right` (default), `left`, `top` or `bottom` (the screen edges), or `start` or `end` (the side the text starts or ends on, so they swap in right-to-left). */
|
|
19
|
+
side: 'left' | 'right' | 'start' | 'end' | 'top' | 'bottom';
|
|
20
20
|
/** Width of a side drawer, or height of a top or bottom one: `sm`, `md` (default) or `lg`. */
|
|
21
21
|
size: 'sm' | 'md' | 'lg';
|
|
22
22
|
}
|
|
@@ -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
|
-
import { i as r, n as i } from "../chunks/parts-
|
|
5
|
-
import {
|
|
6
|
-
import { t as c } from "../chunks/overlay-
|
|
4
|
+
import { i as r, n as i } from "../chunks/parts-DI_3VpSy.js";
|
|
5
|
+
import { a, i as o, t as s } from "../chunks/keyboard-CEhMSkws.js";
|
|
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,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t
|
|
3
|
-
import { t as
|
|
1
|
+
import { t as e } from "../chunks/base-BGrS4eIl.js";
|
|
2
|
+
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
+
import { t as n } from "../chunks/form-control-C0vH6gii.js";
|
|
4
|
+
import { n as r } from "../chunks/projection-oPe6ipjL.js";
|
|
4
5
|
import { html as i, nothing as a } from "lit";
|
|
5
6
|
import { property as o } from "lit/decorators.js";
|
|
6
7
|
import { live as s } from "lit/directives/live.js";
|
|
7
8
|
//#region src/components/editable.ts
|
|
8
|
-
var c = class extends
|
|
9
|
-
constructor(...
|
|
10
|
-
super(...
|
|
9
|
+
var c = class extends n(e) {
|
|
10
|
+
constructor(...e) {
|
|
11
|
+
super(...e), this.value = "", this.editing = !1, this.disabled = !1, this.placeholder = "Click to edit", this.submitMode = "both", this.size = "md", this._previousValue = "", this._draft = null, this._handleClick = () => {
|
|
11
12
|
this.formDisabled || this.editing || this._enterEditMode();
|
|
12
13
|
}, this._handlePreviewKeydown = (e) => {
|
|
13
14
|
this.formDisabled || this.editing || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), this._enterEditMode());
|
|
@@ -26,7 +27,7 @@ var c = class extends r(t) {
|
|
|
26
27
|
}
|
|
27
28
|
e.key === "Enter" && (this.submitMode === "enter" || this.submitMode === "both") && (e.preventDefault(), this._confirm());
|
|
28
29
|
}, this._handleBlur = () => {
|
|
29
|
-
!this.editing ||
|
|
30
|
+
!this.editing || r(this) || (this.submitMode === "blur" || this.submitMode === "both" ? this._confirm() : this._cancel());
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
33
|
static {
|
|
@@ -82,20 +83,20 @@ var c = class extends r(t) {
|
|
|
82
83
|
}));
|
|
83
84
|
}
|
|
84
85
|
};
|
|
85
|
-
|
|
86
|
+
t([o({
|
|
86
87
|
type: String,
|
|
87
88
|
reflect: !0
|
|
88
|
-
})], c.prototype, "value", void 0),
|
|
89
|
+
})], c.prototype, "value", void 0), t([o({
|
|
89
90
|
type: Boolean,
|
|
90
91
|
reflect: !0
|
|
91
|
-
})], c.prototype, "editing", void 0),
|
|
92
|
+
})], c.prototype, "editing", void 0), t([o({
|
|
92
93
|
type: Boolean,
|
|
93
94
|
reflect: !0
|
|
94
|
-
})], c.prototype, "disabled", void 0),
|
|
95
|
+
})], c.prototype, "disabled", void 0), t([o({ type: String })], c.prototype, "placeholder", void 0), t([o({
|
|
95
96
|
type: String,
|
|
96
97
|
reflect: !0,
|
|
97
98
|
attribute: "submit-mode"
|
|
98
|
-
})], c.prototype, "submitMode", void 0),
|
|
99
|
+
})], c.prototype, "submitMode", void 0), t([o({
|
|
99
100
|
type: String,
|
|
100
101
|
reflect: !0
|
|
101
102
|
})], c.prototype, "size", void 0), customElements.get("void-editable") || customElements.define("void-editable", c);
|
|
@@ -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 { n, t as r } from "../chunks/parts-
|
|
3
|
+
import { n, t as r } from "../chunks/parts-DI_3VpSy.js";
|
|
4
4
|
import { property as i } from "lit/decorators.js";
|
|
5
5
|
//#region src/components/error-fallback.ts
|
|
6
6
|
var a = [
|
package/dist/components/field.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t
|
|
1
|
+
import { t as e } from "../chunks/base-BGrS4eIl.js";
|
|
2
|
+
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
+
import { t as n } from "../chunks/projection-oPe6ipjL.js";
|
|
3
4
|
import { html as r, nothing as i } from "lit";
|
|
4
5
|
import { property as a } from "lit/decorators.js";
|
|
5
6
|
//#region src/components/field.ts
|
|
6
|
-
var o = "", s = class extends
|
|
7
|
-
constructor(...
|
|
8
|
-
super(...
|
|
7
|
+
var o = "", s = class extends e {
|
|
8
|
+
constructor(...e) {
|
|
9
|
+
super(...e), this.label = "", this.error = "", this.helper = "", this.required = !1, this._uid = Math.random().toString(36).slice(2), this._labelledControl = null, this._controlObserver = null, this._projection = new n(this, {
|
|
9
10
|
regions: [{
|
|
10
11
|
name: "control",
|
|
11
12
|
target: () => this.querySelector(":scope > .void-field-control")
|
|
@@ -67,16 +68,16 @@ var o = "", s = class extends t {
|
|
|
67
68
|
`;
|
|
68
69
|
}
|
|
69
70
|
};
|
|
70
|
-
|
|
71
|
+
t([a({
|
|
71
72
|
type: String,
|
|
72
73
|
reflect: !0
|
|
73
|
-
})], s.prototype, "label", void 0),
|
|
74
|
+
})], s.prototype, "label", void 0), t([a({
|
|
74
75
|
type: String,
|
|
75
76
|
reflect: !0
|
|
76
|
-
})], s.prototype, "error", void 0),
|
|
77
|
+
})], s.prototype, "error", void 0), t([a({
|
|
77
78
|
type: String,
|
|
78
79
|
reflect: !0
|
|
79
|
-
})], s.prototype, "helper", void 0),
|
|
80
|
+
})], s.prototype, "helper", void 0), t([a({
|
|
80
81
|
type: Boolean,
|
|
81
82
|
reflect: !0
|
|
82
83
|
})], s.prototype, "required", void 0), customElements.get("void-field") || customElements.define("void-field", s);
|
|
@@ -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,12 +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 {
|
|
5
|
-
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";
|
|
6
8
|
//#region src/components/file-upload.ts
|
|
7
|
-
|
|
9
|
+
r();
|
|
10
|
+
var c = class extends n(e) {
|
|
8
11
|
constructor(...e) {
|
|
9
|
-
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 = () => {
|
|
10
13
|
this.formDisabled || this._input?.click();
|
|
11
14
|
}, this._onDropzoneKeydown = (e) => {
|
|
12
15
|
this.formDisabled || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), this._input?.click());
|
|
@@ -39,12 +42,17 @@ var o = class extends n(e) {
|
|
|
39
42
|
get _input() {
|
|
40
43
|
return this.querySelector("input[type=\"file\"]");
|
|
41
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
|
+
}
|
|
42
50
|
render() {
|
|
43
|
-
return
|
|
51
|
+
return a`
|
|
44
52
|
<input
|
|
45
53
|
type="file"
|
|
46
54
|
class="void-file-upload-input"
|
|
47
|
-
accept=${this.accept ||
|
|
55
|
+
accept=${this.accept || o}
|
|
48
56
|
?multiple=${this.multiple}
|
|
49
57
|
?disabled=${this.disabled}
|
|
50
58
|
@change=${this._onInputChange}
|
|
@@ -53,7 +61,8 @@ var o = class extends n(e) {
|
|
|
53
61
|
class="void-file-upload-dropzone"
|
|
54
62
|
tabindex=${this.formDisabled ? "-1" : "0"}
|
|
55
63
|
role="button"
|
|
56
|
-
aria-disabled=${this.formDisabled ? "true" :
|
|
64
|
+
aria-disabled=${this.formDisabled ? "true" : o}
|
|
65
|
+
aria-describedby=${this.error ? this._uid : o}
|
|
57
66
|
@click=${this._onDropzoneClick}
|
|
58
67
|
@keydown=${this._onDropzoneKeydown}
|
|
59
68
|
@dragover=${this._onDragOver}
|
|
@@ -64,9 +73,9 @@ var o = class extends n(e) {
|
|
|
64
73
|
Drop files here or <span class="void-file-upload-browse">browse</span>
|
|
65
74
|
</span>
|
|
66
75
|
</div>
|
|
67
|
-
${this._files.length > 0 ?
|
|
76
|
+
${this._files.length > 0 ? a`
|
|
68
77
|
<div class="void-file-upload-files">
|
|
69
|
-
${this._files.map((e, t) =>
|
|
78
|
+
${this._files.map((e, t) => a`
|
|
70
79
|
<div class="void-file-upload-file">
|
|
71
80
|
<span class="void-file-upload-filename">${e.name}</span>
|
|
72
81
|
<button
|
|
@@ -79,13 +88,30 @@ var o = class extends n(e) {
|
|
|
79
88
|
</div>
|
|
80
89
|
`)}
|
|
81
90
|
</div>
|
|
82
|
-
` :
|
|
83
|
-
${this.error ?
|
|
91
|
+
` : o}
|
|
92
|
+
${this.error ? a`<span class="void-file-upload-error" id=${this._uid} role="alert">${this.error}</span>` : o}
|
|
84
93
|
`;
|
|
85
94
|
}
|
|
86
95
|
_addFiles(e) {
|
|
87
|
-
let t =
|
|
88
|
-
|
|
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", {
|
|
89
115
|
bubbles: !0,
|
|
90
116
|
composed: !0,
|
|
91
117
|
detail: {
|
|
@@ -94,6 +120,12 @@ var o = class extends n(e) {
|
|
|
94
120
|
}
|
|
95
121
|
})));
|
|
96
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
|
+
}
|
|
97
129
|
_removeFile(e) {
|
|
98
130
|
this._files = this._files.filter((t, n) => n !== e), this.requestUpdate(), this.dispatchEvent(new CustomEvent("void-change", {
|
|
99
131
|
bubbles: !0,
|
|
@@ -105,18 +137,18 @@ var o = class extends n(e) {
|
|
|
105
137
|
}));
|
|
106
138
|
}
|
|
107
139
|
};
|
|
108
|
-
t([
|
|
140
|
+
t([s({ type: String })], c.prototype, "accept", void 0), t([s({
|
|
109
141
|
type: Boolean,
|
|
110
142
|
reflect: !0
|
|
111
|
-
})],
|
|
143
|
+
})], c.prototype, "multiple", void 0), t([s({
|
|
112
144
|
type: Boolean,
|
|
113
145
|
reflect: !0
|
|
114
|
-
})],
|
|
146
|
+
})], c.prototype, "disabled", void 0), t([s({
|
|
115
147
|
type: Number,
|
|
116
148
|
attribute: "max-size"
|
|
117
|
-
})],
|
|
149
|
+
})], c.prototype, "maxSize", void 0), t([s({
|
|
118
150
|
type: String,
|
|
119
151
|
reflect: !0
|
|
120
|
-
})],
|
|
152
|
+
})], c.prototype, "error", void 0), customElements.get("void-file-upload") || customElements.define("void-file-upload", c);
|
|
121
153
|
//#endregion
|
|
122
|
-
export {
|
|
154
|
+
export { c as VoidFileUpload };
|