@voidable/ui 0.10.0 → 0.12.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/angular/index.d.ts +2 -2
- package/dist/angular/index.js +2 -1
- package/dist/base.d.ts +6 -0
- package/dist/base.js +2 -2
- package/dist/chunks/activation-B8aBarKd.js +4 -0
- package/dist/chunks/{base-BxmMM3B7.js → base-BGrS4eIl.js} +9 -0
- package/dist/chunks/carousel-C9u0bg5l.js +10 -0
- package/dist/chunks/choice-BTrsi7OW.js +16 -0
- package/dist/chunks/data-Baycjoo4.js +96 -0
- package/dist/chunks/fields-MEqz-olE.js +21 -0
- package/dist/chunks/{form-control-C0vH6gii.js → form-control-fL-Hhy91.js} +49 -48
- package/dist/chunks/{keyboard-CEhMSkws.js → keyboard-ChtDvhB_.js} +4 -23
- package/dist/chunks/{keyboard-activation-CV0m4hkn.js → keyboard-activation-BfEyoaMT.js} +4 -6
- package/dist/chunks/menu-CxRRgkJI.js +21 -0
- package/dist/chunks/{modal-CgGp_fCs.js → modal-Cz2-Ov76.js} +24 -16
- package/dist/chunks/nav-menu-Bx284Dk6.js +12 -0
- package/dist/chunks/{overlay-hLJ7IQHx.js → overlay-BuV-4Yvt.js} +76 -69
- package/dist/chunks/overlay-K1ilWC1p.js +4 -0
- package/dist/chunks/pickers-CjlFgNke.js +36 -0
- package/dist/chunks/{projection-SnR79EHI.js → projection-oPe6ipjL.js} +1 -1
- package/dist/chunks/table-BBpqwWEi.js +4 -0
- package/dist/chunks/tabs-Buf3EBWq.js +10 -0
- package/dist/components/accordion.d.ts +7 -0
- package/dist/components/accordion.js +23 -15
- package/dist/components/action-input.d.ts +2 -1
- package/dist/components/action-input.js +60 -56
- 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 +68 -45
- package/dist/components/breadcrumbs.d.ts +2 -0
- package/dist/components/breadcrumbs.js +16 -12
- package/dist/components/button.d.ts +7 -0
- package/dist/components/button.js +24 -17
- package/dist/components/calendar.d.ts +85 -12
- package/dist/components/calendar.js +263 -120
- package/dist/components/card.js +1 -1
- package/dist/components/carousel.d.ts +22 -0
- package/dist/components/carousel.js +66 -37
- package/dist/components/charts/data.d.ts +72 -0
- package/dist/components/checkbox-group.js +23 -22
- package/dist/components/checkbox.d.ts +7 -0
- package/dist/components/checkbox.js +30 -25
- package/dist/components/collapsible.d.ts +7 -0
- package/dist/components/collapsible.js +20 -12
- package/dist/components/color-picker.js +29 -28
- package/dist/components/combobox.d.ts +13 -1
- package/dist/components/combobox.js +55 -42
- package/dist/components/compose-input.d.ts +9 -1
- package/dist/components/compose-input.js +29 -17
- 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 +97 -70
- package/dist/components/drawer.js +1 -1
- package/dist/components/dropdown-menu.d.ts +22 -0
- package/dist/components/dropdown-menu.js +55 -40
- package/dist/components/editable.d.ts +11 -1
- package/dist/components/editable.js +36 -23
- package/dist/components/error-fallback.d.ts +4 -2
- package/dist/components/error-fallback.js +35 -29
- package/dist/components/field.js +2 -2
- package/dist/components/file-upload.d.ts +29 -5
- package/dist/components/file-upload.js +84 -28
- package/dist/components/gauge.d.ts +32 -8
- package/dist/components/gauge.js +206 -133
- package/dist/components/hamburger.d.ts +19 -1
- package/dist/components/hamburger.js +45 -25
- package/dist/components/hover-card.d.ts +7 -0
- package/dist/components/hover-card.js +23 -15
- package/dist/components/indicator.js +16 -15
- package/dist/components/input.js +3 -3
- package/dist/components/line-chart.d.ts +22 -7
- package/dist/components/line-chart.js +80 -57
- package/dist/components/list.js +1 -1
- package/dist/components/menu.d.ts +25 -0
- package/dist/components/menu.js +56 -34
- package/dist/components/multiselect.d.ts +17 -1
- package/dist/components/multiselect.js +97 -75
- package/dist/components/nav-bar.d.ts +9 -0
- package/dist/components/nav-bar.js +16 -3
- package/dist/components/nav-menu.d.ts +9 -0
- package/dist/components/nav-menu.js +31 -24
- package/dist/components/number-input.d.ts +15 -1
- package/dist/components/number-input.js +72 -38
- package/dist/components/pagination.js +26 -25
- package/dist/components/panel.js +1 -1
- package/dist/components/pin-input.d.ts +11 -0
- package/dist/components/pin-input.js +47 -33
- package/dist/components/popover.d.ts +7 -0
- package/dist/components/popover.js +22 -14
- package/dist/components/progress.js +2 -2
- package/dist/components/radio-group.js +3 -3
- package/dist/components/radio.d.ts +10 -1
- package/dist/components/radio.js +38 -33
- package/dist/components/scroll-area.js +2 -2
- package/dist/components/segmented-control.d.ts +14 -0
- package/dist/components/segmented-control.js +41 -29
- package/dist/components/select.js +2 -2
- package/dist/components/sidebar.d.ts +1 -0
- package/dist/components/sidebar.js +15 -11
- package/dist/components/skeleton.js +1 -1
- package/dist/components/slider.js +3 -3
- package/dist/components/spinner.d.ts +5 -3
- package/dist/components/spinner.js +22 -15
- package/dist/components/stat.d.ts +13 -1
- package/dist/components/stat.js +28 -20
- package/dist/components/status-dot.d.ts +2 -2
- package/dist/components/status-dot.js +13 -15
- package/dist/components/stepper.d.ts +2 -0
- package/dist/components/stepper.js +21 -14
- package/dist/components/switch.d.ts +7 -0
- package/dist/components/switch.js +25 -17
- package/dist/components/table.d.ts +81 -1
- package/dist/components/table.js +571 -69
- package/dist/components/tabs.d.ts +11 -0
- package/dist/components/tabs.js +43 -34
- package/dist/components/tag.js +13 -12
- package/dist/components/tags-input.d.ts +10 -1
- package/dist/components/tags-input.js +43 -31
- package/dist/components/textarea.js +3 -3
- package/dist/components/toast.d.ts +2 -0
- package/dist/components/toast.js +36 -29
- package/dist/components/toggle-group.d.ts +8 -0
- package/dist/components/toggle-group.js +25 -18
- package/dist/components/toggle.d.ts +7 -0
- package/dist/components/toggle.js +24 -16
- package/dist/components/tooltip.d.ts +7 -0
- package/dist/components/tooltip.js +21 -13
- package/dist/components.json +108 -84
- package/dist/custom-elements.json +4520 -236
- package/dist/dev/rules.d.ts +0 -1
- package/dist/dev/types.d.ts +5 -1
- package/dist/dev.js +298 -122
- package/dist/index.d.ts +4 -0
- package/dist/index.js +69 -67
- package/dist/keyboard-activation.d.ts +9 -9
- package/dist/keyboard.d.ts +2 -10
- package/dist/keymaps/activation.d.ts +8 -0
- package/dist/keymaps/carousel.d.ts +9 -0
- package/dist/keymaps/choice.d.ts +21 -0
- package/dist/keymaps/fields.d.ts +31 -0
- package/dist/keymaps/index.d.ts +2 -0
- package/dist/keymaps/menu.d.ts +36 -0
- package/dist/keymaps/nav-menu.d.ts +11 -0
- package/dist/keymaps/overlay.d.ts +4 -0
- package/dist/keymaps/pickers.d.ts +36 -0
- package/dist/keymaps/table.d.ts +8 -0
- package/dist/keymaps/tabs.d.ts +7 -0
- package/dist/keymaps.js +51 -0
- package/dist/keys.d.ts +46 -0
- package/dist/keys.js +57 -0
- package/dist/llms.txt +11 -3
- package/dist/messages/ar.d.ts +1 -0
- package/dist/messages/ar.js +130 -0
- package/dist/messages/fr.d.ts +1 -0
- package/dist/messages/fr.js +109 -0
- package/dist/messages.d.ts +213 -0
- package/dist/messages.js +190 -0
- package/dist/modal.d.ts +7 -0
- package/dist/reference.md +885 -60
- package/dist/testing/index.d.ts +46 -0
- package/dist/testing.js +79 -0
- package/dist/types/elements.d.ts +100 -84
- package/dist/types/react.d.ts +7 -3
- package/dist/types/solid.d.ts +7 -3
- package/dist/types/solid2.d.ts +4 -0
- package/dist/types/svelte.d.ts +7 -3
- package/dist/types/vue.d.ts +7 -3
- package/dist/vscode.html-custom-data.json +478 -38
- package/dist/web-types.json +1001 -111
- package/package.json +22 -2
|
@@ -16,7 +16,7 @@ import { PartsController } from '../parts.js';
|
|
|
16
16
|
* @fires {CustomEvent} void-retry - The built-in retry button was pressed (the element retries nothing itself).
|
|
17
17
|
*/
|
|
18
18
|
export declare class VoidErrorFallback extends VoidElement {
|
|
19
|
-
/** Headline of the built-in default. Defaults to `Something went wrong
|
|
19
|
+
/** Headline of the built-in default. Defaults to the `errorFallback.heading` message (English: `Something went wrong`). Ignored when the author writes parts. */
|
|
20
20
|
heading: string;
|
|
21
21
|
/** Detail shown under the headline in the built-in default, such as what failed or what to try. Optional. */
|
|
22
22
|
message: string;
|
|
@@ -25,10 +25,12 @@ export declare class VoidErrorFallback extends VoidElement {
|
|
|
25
25
|
* anything itself, so listen for the event and reload. Ignored when the author writes parts.
|
|
26
26
|
*/
|
|
27
27
|
retryable: boolean;
|
|
28
|
-
/** Text of the built-in retry button. Defaults to `Try again
|
|
28
|
+
/** Text of the built-in retry button. Defaults to the `errorFallback.retry` message (English: `Try again`). Only used with `retryable`. */
|
|
29
29
|
retryLabel: string;
|
|
30
30
|
/** Leave out the warning icon above the headline (it is drawn by default). */
|
|
31
31
|
hideIcon: boolean;
|
|
32
|
+
/** The built-in text last written, so a change of language rewrites it. */
|
|
33
|
+
private _shown;
|
|
32
34
|
protected readonly _parts: PartsController;
|
|
33
35
|
constructor();
|
|
34
36
|
connectedCallback(): void;
|
|
@@ -1,20 +1,21 @@
|
|
|
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 {
|
|
3
|
+
import { msg as n } from "../messages.js";
|
|
4
|
+
import { n as r, t as i } from "../chunks/parts-DI_3VpSy.js";
|
|
5
|
+
import { property as a } from "lit/decorators.js";
|
|
5
6
|
//#region src/components/error-fallback.ts
|
|
6
|
-
var
|
|
7
|
+
var o = [
|
|
7
8
|
"void-error-fallback-title",
|
|
8
9
|
"void-error-fallback-description",
|
|
9
10
|
"void-error-fallback-actions"
|
|
10
|
-
],
|
|
11
|
+
], s = "data-void-default", c = class extends e {
|
|
11
12
|
constructor() {
|
|
12
|
-
super(), this.heading = "
|
|
13
|
-
tags: [...
|
|
13
|
+
super(), this.heading = "", this.message = "", this.retryable = !1, this.retryLabel = "", this.hideIcon = !1, this._shown = "", this._parts = new r(this, {
|
|
14
|
+
tags: [...o],
|
|
14
15
|
onChange: () => this._wire()
|
|
15
16
|
}), this._onClick = (e) => {
|
|
16
17
|
let t = e.target, n = t?.closest?.("void-error-fallback-actions");
|
|
17
|
-
!n?.hasAttribute(
|
|
18
|
+
!n?.hasAttribute(s) || !this._parts.owns(n) || !t.closest("button") || this.dispatchEvent(new CustomEvent("void-retry", {
|
|
18
19
|
bubbles: !0,
|
|
19
20
|
composed: !0
|
|
20
21
|
}));
|
|
@@ -22,12 +23,12 @@ var a = [
|
|
|
22
23
|
let e = {
|
|
23
24
|
voidBeforeMorph: (e) => {
|
|
24
25
|
if (this._authored().length) return;
|
|
25
|
-
let t = Array.from(this.children).filter((e) => e.hasAttribute(
|
|
26
|
-
!t.length || Array.from(e.children).some((e) =>
|
|
26
|
+
let t = Array.from(this.children).filter((e) => e.hasAttribute(s));
|
|
27
|
+
!t.length || Array.from(e.children).some((e) => o.includes(e.localName)) || e.append(...t.map((e) => e.cloneNode(!0)));
|
|
27
28
|
},
|
|
28
29
|
isCopy: () => !1
|
|
29
30
|
}, t = this;
|
|
30
|
-
(t[
|
|
31
|
+
(t[i] ??= []).push(e);
|
|
31
32
|
}
|
|
32
33
|
connectedCallback() {
|
|
33
34
|
super.connectedCallback(), this.setHostAttribute("role", "alert"), this.addEventListener("click", this._onClick);
|
|
@@ -36,50 +37,55 @@ var a = [
|
|
|
36
37
|
super.disconnectedCallback(), this.removeEventListener("click", this._onClick);
|
|
37
38
|
}
|
|
38
39
|
updated(e) {
|
|
39
|
-
super.updated(e)
|
|
40
|
+
super.updated(e);
|
|
41
|
+
let t = `${this.heading || n(this, "errorFallback.heading")}\n${this.retryLabel || n(this, "errorFallback.retry")}`;
|
|
42
|
+
([
|
|
40
43
|
"heading",
|
|
41
44
|
"message",
|
|
42
45
|
"retryable",
|
|
43
46
|
"retryLabel"
|
|
44
|
-
].some((t) => e.has(t)) && this._parts.sync();
|
|
47
|
+
].some((t) => e.has(t)) || t !== this._shown) && (this._shown = t, this._parts.sync());
|
|
45
48
|
}
|
|
46
49
|
_authored() {
|
|
47
|
-
return
|
|
50
|
+
return o.flatMap((e) => this._parts.all(e)).filter((e) => !e.hasAttribute(s));
|
|
48
51
|
}
|
|
49
52
|
_wire() {
|
|
50
|
-
let e = (e) => this._parts.all(e).find((e) => e.hasAttribute(
|
|
53
|
+
let e = (e) => this._parts.all(e).find((e) => e.hasAttribute(s)), t = /* @__PURE__ */ new Set();
|
|
51
54
|
if (!this._authored().length) {
|
|
52
|
-
let
|
|
55
|
+
let r = (n, r) => {
|
|
53
56
|
let i = e(n);
|
|
54
|
-
i || (i = document.createElement(n), i.setAttribute(
|
|
57
|
+
i || (i = document.createElement(n), i.setAttribute(s, ""), this.append(i)), r(i), t.add(i);
|
|
55
58
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
r("void-error-fallback-title", (e) => {
|
|
60
|
+
let t = this.heading || n(this, "errorFallback.heading");
|
|
61
|
+
e.textContent !== t && (e.textContent = t);
|
|
62
|
+
}), this.message && r("void-error-fallback-description", (e) => {
|
|
59
63
|
e.textContent !== this.message && (e.textContent = this.message);
|
|
60
|
-
}), this.retryable &&
|
|
64
|
+
}), this.retryable && r("void-error-fallback-actions", (e) => {
|
|
61
65
|
let t = e.querySelector("button");
|
|
62
|
-
t || (t = document.createElement("button"), t.type = "button", e.append(t))
|
|
66
|
+
t || (t = document.createElement("button"), t.type = "button", e.append(t));
|
|
67
|
+
let r = this.retryLabel || n(this, "errorFallback.retry");
|
|
68
|
+
t.textContent !== r && (t.textContent = r);
|
|
63
69
|
}), this._order(t);
|
|
64
70
|
}
|
|
65
|
-
for (let e of
|
|
71
|
+
for (let e of o) for (let n of this._parts.all(e)) n.hasAttribute(s) && !t.has(n) && n.remove();
|
|
66
72
|
}
|
|
67
73
|
_order(e) {
|
|
68
|
-
|
|
74
|
+
o.flatMap((t) => [...e].filter((e) => e.localName === t)).forEach((e, t) => {
|
|
69
75
|
this.children[t] !== e && this.insertBefore(e, this.children[t] ?? null);
|
|
70
76
|
});
|
|
71
77
|
}
|
|
72
78
|
};
|
|
73
|
-
t([
|
|
79
|
+
t([a({ type: String })], c.prototype, "heading", void 0), t([a({ type: String })], c.prototype, "message", void 0), t([a({
|
|
74
80
|
type: Boolean,
|
|
75
81
|
reflect: !0
|
|
76
|
-
})],
|
|
82
|
+
})], c.prototype, "retryable", void 0), t([a({
|
|
77
83
|
type: String,
|
|
78
84
|
attribute: "retry-label"
|
|
79
|
-
})],
|
|
85
|
+
})], c.prototype, "retryLabel", void 0), t([a({
|
|
80
86
|
type: Boolean,
|
|
81
87
|
attribute: "hide-icon",
|
|
82
88
|
reflect: !0
|
|
83
|
-
})],
|
|
89
|
+
})], c.prototype, "hideIcon", void 0), customElements.get("void-error-fallback") || customElements.define("void-error-fallback", c);
|
|
84
90
|
//#endregion
|
|
85
|
-
export {
|
|
91
|
+
export { c as VoidErrorFallback };
|
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,46 @@
|
|
|
1
1
|
import { VoidElement } from '../base.js';
|
|
2
2
|
import { FormSubmission } from '../form-control.js';
|
|
3
|
+
import { KeyOverrides } from '../keys.js';
|
|
4
|
+
/** Why a file was not taken: `type` (not matched by `accept`), `size` (over `max-size`) or `count` (more files than the zone takes). */
|
|
5
|
+
export type FileRejectReason = 'type' | 'size' | 'count';
|
|
3
6
|
declare const VoidFileUpload_base: (new (...args: any[]) => import('../form-control.js').VoidInternalsFormControl) & typeof VoidElement;
|
|
4
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Drag-and-drop file picker for document uploads, image attachment flows, and import wizards.
|
|
9
|
+
*
|
|
10
|
+
* @fires {CustomEvent<{ rejected: { file: File; reason: 'type' | 'size' | 'count' }[] }>} void-reject - Files were refused: one entry per file with the reason. Does not bubble.
|
|
11
|
+
*/
|
|
5
12
|
export declare class VoidFileUpload extends VoidFileUpload_base {
|
|
13
|
+
/** Key bindings for this element's actions, as JSON (`{"activate":["Enter"]}`); `[]` switches an action off. See the keyboard guide. */
|
|
14
|
+
keys: KeyOverrides | null;
|
|
15
|
+
/** @internal The actions of this element and their default keys. */
|
|
16
|
+
static readonly keyMap: {
|
|
17
|
+
activate: string[];
|
|
18
|
+
};
|
|
6
19
|
/** The host's `aria-label` / `aria-labelledby` name the inner control. */
|
|
7
20
|
static labelTarget: string;
|
|
8
21
|
/**
|
|
9
22
|
* 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
|
|
23
|
+
* types (`image/png`) or wildcards (`image/*`). Other files are not taken: `void-reject` fires with
|
|
24
|
+
* reason `type` and the zone shows an error.
|
|
11
25
|
*/
|
|
12
26
|
accept: string;
|
|
13
27
|
/** Allow more than one file. Without it a new choice replaces the old one. */
|
|
14
28
|
multiple: boolean;
|
|
15
29
|
/** Stop the zone reacting and exclude the files from the form submission. */
|
|
16
30
|
disabled: boolean;
|
|
17
|
-
/** Largest allowed file in bytes. 0 (the default) means no limit. Larger files are
|
|
31
|
+
/** Largest allowed file in bytes. 0 (the default) means no limit. Larger files are rejected with reason `size`. */
|
|
18
32
|
maxSize: number;
|
|
19
33
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
34
|
+
* Error message shown under the zone; while it is set the drop zone is `aria-invalid` and described by
|
|
35
|
+
* it. Set it for a server-side upload failure. The zone also sets it itself when it rejects a file
|
|
36
|
+
* (see `void-reject`) and clears what it set on the next accepted selection; a message you set is
|
|
37
|
+
* left alone.
|
|
22
38
|
*/
|
|
23
39
|
error: string;
|
|
24
40
|
private _files;
|
|
41
|
+
private _uid;
|
|
42
|
+
/** The message we wrote into `error` (a rejection); an accepted selection clears it only while it is still there. */
|
|
43
|
+
private _ownError;
|
|
25
44
|
/** One entry per selected file. */
|
|
26
45
|
protected formSubmission(): FormSubmission;
|
|
27
46
|
protected formSnapshot(): unknown;
|
|
@@ -29,6 +48,7 @@ export declare class VoidFileUpload extends VoidFileUpload_base {
|
|
|
29
48
|
/** Files cannot be restored from serialised state. */
|
|
30
49
|
formStateRestoreCallback(): void;
|
|
31
50
|
private get _input();
|
|
51
|
+
protected updated(changed: Map<string, unknown>): void;
|
|
32
52
|
render(): import('lit').TemplateResult<1>;
|
|
33
53
|
private _onDropzoneClick;
|
|
34
54
|
private _onDropzoneKeydown;
|
|
@@ -37,6 +57,10 @@ export declare class VoidFileUpload extends VoidFileUpload_base {
|
|
|
37
57
|
private _onDrop;
|
|
38
58
|
private _onInputChange;
|
|
39
59
|
private _addFiles;
|
|
60
|
+
private _message;
|
|
61
|
+
/** "Drop files here or browse": the language's sentence with the word `browse` drawn as the link. */
|
|
62
|
+
private _prompt;
|
|
63
|
+
private _clearOwnError;
|
|
40
64
|
private _removeFile;
|
|
41
65
|
}
|
|
42
66
|
declare global {
|
|
@@ -1,17 +1,21 @@
|
|
|
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 {
|
|
6
|
-
import {
|
|
3
|
+
import { actionFor as n, keysConverter as r } from "../keys.js";
|
|
4
|
+
import { t as i } from "../chunks/activation-B8aBarKd.js";
|
|
5
|
+
import { localeOf as a, msg as o } from "../messages.js";
|
|
6
|
+
import { t as s } from "../chunks/form-control-fL-Hhy91.js";
|
|
7
|
+
import { r as c } from "../chunks/projection-oPe6ipjL.js";
|
|
8
|
+
import { i as l } from "../chunks/keyboard-ChtDvhB_.js";
|
|
9
|
+
import { html as u, nothing as d } from "lit";
|
|
10
|
+
import { property as f } from "lit/decorators.js";
|
|
7
11
|
//#region src/components/file-upload.ts
|
|
8
|
-
|
|
9
|
-
var
|
|
12
|
+
c();
|
|
13
|
+
var p = class extends s(e) {
|
|
10
14
|
constructor(...e) {
|
|
11
|
-
super(...e), this.accept = "", this.multiple = !1, this.disabled = !1, this.maxSize = 0, this.error = "", this._files = [], this._onDropzoneClick = () => {
|
|
15
|
+
super(...e), this.keys = null, this.accept = "", this.multiple = !1, this.disabled = !1, this.maxSize = 0, this.error = "", this._files = [], this._uid = l("void-file-upload-error"), this._ownError = "", this._onDropzoneClick = () => {
|
|
12
16
|
this.formDisabled || this._input?.click();
|
|
13
17
|
}, this._onDropzoneKeydown = (e) => {
|
|
14
|
-
this.formDisabled || (
|
|
18
|
+
this.formDisabled || n(this, e) === "activate" && (e.preventDefault(), this._input?.click());
|
|
15
19
|
}, this._onDragOver = (e) => {
|
|
16
20
|
this.disabled || (e.preventDefault(), this.setHostAttribute("dragging", ""));
|
|
17
21
|
}, this._onDragLeave = () => {
|
|
@@ -25,6 +29,9 @@ var s = class extends n(e) {
|
|
|
25
29
|
this._addFiles(n), t.value = "";
|
|
26
30
|
};
|
|
27
31
|
}
|
|
32
|
+
static {
|
|
33
|
+
this.keyMap = i;
|
|
34
|
+
}
|
|
28
35
|
static {
|
|
29
36
|
this.labelTarget = ".void-file-upload-dropzone";
|
|
30
37
|
}
|
|
@@ -41,12 +48,17 @@ var s = class extends n(e) {
|
|
|
41
48
|
get _input() {
|
|
42
49
|
return this.querySelector("input[type=\"file\"]");
|
|
43
50
|
}
|
|
51
|
+
updated(e) {
|
|
52
|
+
super.updated(e);
|
|
53
|
+
let t = this.querySelector(".void-file-upload-dropzone");
|
|
54
|
+
t && (this.error ? t.getAttribute("aria-invalid") !== "true" && t.setAttribute("aria-invalid", "true") : t.hasAttribute("aria-invalid") && t.removeAttribute("aria-invalid"));
|
|
55
|
+
}
|
|
44
56
|
render() {
|
|
45
|
-
return
|
|
57
|
+
return u`
|
|
46
58
|
<input
|
|
47
59
|
type="file"
|
|
48
60
|
class="void-file-upload-input"
|
|
49
|
-
accept=${this.accept ||
|
|
61
|
+
accept=${this.accept || d}
|
|
50
62
|
?multiple=${this.multiple}
|
|
51
63
|
?disabled=${this.disabled}
|
|
52
64
|
@change=${this._onInputChange}
|
|
@@ -55,39 +67,55 @@ var s = class extends n(e) {
|
|
|
55
67
|
class="void-file-upload-dropzone"
|
|
56
68
|
tabindex=${this.formDisabled ? "-1" : "0"}
|
|
57
69
|
role="button"
|
|
58
|
-
aria-disabled=${this.formDisabled ? "true" :
|
|
70
|
+
aria-disabled=${this.formDisabled ? "true" : d}
|
|
71
|
+
aria-describedby=${this.error ? this._uid : d}
|
|
59
72
|
@click=${this._onDropzoneClick}
|
|
60
73
|
@keydown=${this._onDropzoneKeydown}
|
|
61
74
|
@dragover=${this._onDragOver}
|
|
62
75
|
@dragleave=${this._onDragLeave}
|
|
63
76
|
@drop=${this._onDrop}
|
|
64
77
|
>
|
|
65
|
-
<span class="void-file-upload-text">
|
|
66
|
-
Drop files here or <span class="void-file-upload-browse">browse</span>
|
|
67
|
-
</span>
|
|
78
|
+
<span class="void-file-upload-text">${this._prompt()}</span>
|
|
68
79
|
</div>
|
|
69
|
-
${this._files.length > 0 ?
|
|
80
|
+
${this._files.length > 0 ? u`
|
|
70
81
|
<div class="void-file-upload-files">
|
|
71
|
-
${this._files.map((e, t) =>
|
|
82
|
+
${this._files.map((e, t) => u`
|
|
72
83
|
<div class="void-file-upload-file">
|
|
73
84
|
<span class="void-file-upload-filename">${e.name}</span>
|
|
74
85
|
<button
|
|
75
86
|
type="button"
|
|
76
87
|
class="void-file-upload-remove"
|
|
77
|
-
aria-label
|
|
88
|
+
aria-label=${o(this, "removeItem", { name: e.name })}
|
|
78
89
|
?disabled=${this.disabled}
|
|
79
90
|
@click=${() => this._removeFile(t)}
|
|
80
91
|
>×</button>
|
|
81
92
|
</div>
|
|
82
93
|
`)}
|
|
83
94
|
</div>
|
|
84
|
-
` :
|
|
85
|
-
${this.error ?
|
|
95
|
+
` : d}
|
|
96
|
+
${this.error ? u`<span class="void-file-upload-error" id=${this._uid} role="alert">${this.error}</span>` : d}
|
|
86
97
|
`;
|
|
87
98
|
}
|
|
88
99
|
_addFiles(e) {
|
|
89
|
-
let t =
|
|
90
|
-
|
|
100
|
+
let t = [], n = [], r = this.accept.split(",").map((e) => e.trim()).filter(Boolean);
|
|
101
|
+
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({
|
|
102
|
+
file: i,
|
|
103
|
+
reason: "type"
|
|
104
|
+
}) : this.maxSize > 0 && i.size > this.maxSize ? t.push({
|
|
105
|
+
file: i,
|
|
106
|
+
reason: "size"
|
|
107
|
+
}) : n.push(i);
|
|
108
|
+
if (!this.multiple && n.length > 1) {
|
|
109
|
+
for (let e of n.slice(1)) t.push({
|
|
110
|
+
file: e,
|
|
111
|
+
reason: "count"
|
|
112
|
+
});
|
|
113
|
+
n = n.slice(0, 1);
|
|
114
|
+
}
|
|
115
|
+
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", {
|
|
116
|
+
bubbles: !1,
|
|
117
|
+
detail: { rejected: t }
|
|
118
|
+
}))), 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
119
|
bubbles: !0,
|
|
92
120
|
composed: !0,
|
|
93
121
|
detail: {
|
|
@@ -96,6 +124,31 @@ var s = class extends n(e) {
|
|
|
96
124
|
}
|
|
97
125
|
})));
|
|
98
126
|
}
|
|
127
|
+
_message(e, t) {
|
|
128
|
+
if (t === "type") return o(this, "fileUpload.rejectType", { name: e.name });
|
|
129
|
+
if (t === "size") {
|
|
130
|
+
let t = `${this.maxSize} B`;
|
|
131
|
+
try {
|
|
132
|
+
t = new Intl.NumberFormat(a(this), {
|
|
133
|
+
style: "unit",
|
|
134
|
+
unit: "byte",
|
|
135
|
+
unitDisplay: "long"
|
|
136
|
+
}).format(this.maxSize);
|
|
137
|
+
} catch {}
|
|
138
|
+
return o(this, "fileUpload.rejectSize", {
|
|
139
|
+
name: e.name,
|
|
140
|
+
limit: t
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return o(this, "fileUpload.rejectCount", { name: e.name });
|
|
144
|
+
}
|
|
145
|
+
_prompt() {
|
|
146
|
+
let e = o(this, "fileUpload.browse"), t = o(this, "fileUpload.prompt", { browse: e }), n = t.indexOf(e);
|
|
147
|
+
return n < 0 ? t : u`${t.slice(0, n)}<span class="void-file-upload-browse">${e}</span>${t.slice(n + e.length)}`;
|
|
148
|
+
}
|
|
149
|
+
_clearOwnError() {
|
|
150
|
+
this._ownError && this.error === this._ownError && (this.error = ""), this._ownError = "";
|
|
151
|
+
}
|
|
99
152
|
_removeFile(e) {
|
|
100
153
|
this._files = this._files.filter((t, n) => n !== e), this.requestUpdate(), this.dispatchEvent(new CustomEvent("void-change", {
|
|
101
154
|
bubbles: !0,
|
|
@@ -107,18 +160,21 @@ var s = class extends n(e) {
|
|
|
107
160
|
}));
|
|
108
161
|
}
|
|
109
162
|
};
|
|
110
|
-
t([
|
|
163
|
+
t([f({
|
|
164
|
+
attribute: "keys",
|
|
165
|
+
converter: r
|
|
166
|
+
})], p.prototype, "keys", void 0), t([f({ type: String })], p.prototype, "accept", void 0), t([f({
|
|
111
167
|
type: Boolean,
|
|
112
168
|
reflect: !0
|
|
113
|
-
})],
|
|
169
|
+
})], p.prototype, "multiple", void 0), t([f({
|
|
114
170
|
type: Boolean,
|
|
115
171
|
reflect: !0
|
|
116
|
-
})],
|
|
172
|
+
})], p.prototype, "disabled", void 0), t([f({
|
|
117
173
|
type: Number,
|
|
118
174
|
attribute: "max-size"
|
|
119
|
-
})],
|
|
175
|
+
})], p.prototype, "maxSize", void 0), t([f({
|
|
120
176
|
type: String,
|
|
121
177
|
reflect: !0
|
|
122
|
-
})],
|
|
178
|
+
})], p.prototype, "error", void 0), customElements.get("void-file-upload") || customElements.define("void-file-upload", p);
|
|
123
179
|
//#endregion
|
|
124
|
-
export {
|
|
180
|
+
export { p 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 {
|