@voidable/ui 0.6.1 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +168 -9
- package/dist/angular/index.d.ts +20 -0
- package/dist/angular/index.js +78 -0
- package/dist/autoloader-core.d.ts +45 -0
- package/dist/autoloader-table.generated.d.ts +5 -0
- package/dist/autoloader.d.ts +13 -0
- package/dist/autoloader.js +229 -0
- package/dist/base.d.ts +173 -2
- package/dist/base.js +2 -9
- package/dist/chunks/base-CMruMbxC.js +824 -0
- package/dist/chunks/disclosure-Bj_49GcC.js +23 -0
- package/dist/chunks/dismiss-Drsy_dE5.js +37 -0
- package/dist/chunks/form-control-C0vH6gii.js +300 -0
- package/dist/chunks/keyboard-MQpfTX5I.js +46 -0
- package/dist/chunks/keyboard-activation-CV0m4hkn.js +29 -0
- package/dist/chunks/modal-D_YVy2vg.js +71 -0
- package/dist/chunks/overlay-BywGMcDW.js +467 -0
- package/dist/chunks/parts-D30c8OoG.js +229 -0
- package/dist/chunks/{shape-FJvZa8FW.js → shape-C_LW7EjG.js} +12 -4
- package/dist/components/accordion.d.ts +38 -10
- package/dist/components/accordion.js +51 -53
- package/dist/components/action-input.d.ts +64 -6
- package/dist/components/action-input.js +84 -41
- package/dist/components/alert.d.ts +24 -10
- package/dist/components/alert.js +26 -27
- package/dist/components/avatar.d.ts +8 -2
- package/dist/components/avatar.js +3 -3
- package/dist/components/badge.d.ts +8 -3
- package/dist/components/badge.js +2 -2
- package/dist/components/banner.d.ts +21 -10
- package/dist/components/banner.js +27 -27
- package/dist/components/bar-chart.d.ts +30 -6
- package/dist/components/bar-chart.js +29 -39
- package/dist/components/breadcrumbs.d.ts +19 -6
- package/dist/components/breadcrumbs.js +16 -22
- package/dist/components/button.d.ts +64 -10
- package/dist/components/button.js +70 -26
- package/dist/components/calendar.d.ts +65 -10
- package/dist/components/calendar.js +157 -106
- package/dist/components/card.d.ts +14 -9
- package/dist/components/card.js +8 -22
- package/dist/components/carousel.d.ts +65 -14
- package/dist/components/carousel.js +84 -93
- package/dist/components/charts/scale.d.ts +0 -1
- package/dist/components/charts/shape.d.ts +0 -1
- package/dist/components/checkbox-group.d.ts +38 -5
- package/dist/components/checkbox-group.js +61 -20
- package/dist/components/checkbox.d.ts +53 -7
- package/dist/components/checkbox.js +66 -29
- package/dist/components/collapsible.d.ts +29 -9
- package/dist/components/collapsible.js +42 -44
- package/dist/components/color-picker.d.ts +20 -4
- package/dist/components/color-picker.js +35 -29
- package/dist/components/combobox.d.ts +84 -10
- package/dist/components/combobox.js +142 -45
- package/dist/components/compose-input.d.ts +8 -1
- package/dist/components/compose-input.js +9 -3
- package/dist/components/dialog.d.ts +24 -20
- package/dist/components/dialog.js +8 -57
- package/dist/components/divider.d.ts +8 -1
- package/dist/components/divider.js +3 -3
- package/dist/components/donut-chart.d.ts +28 -5
- package/dist/components/donut-chart.js +55 -54
- package/dist/components/drawer.d.ts +19 -18
- package/dist/components/drawer.js +9 -53
- package/dist/components/dropdown-menu.d.ts +62 -7
- package/dist/components/dropdown-menu.js +124 -33
- package/dist/components/editable.d.ts +37 -3
- package/dist/components/editable.js +45 -24
- package/dist/components/error-fallback.d.ts +36 -5
- package/dist/components/error-fallback.js +73 -23
- package/dist/components/field.d.ts +38 -4
- package/dist/components/field.js +63 -21
- package/dist/components/file-upload.d.ts +23 -2
- package/dist/components/file-upload.js +47 -24
- package/dist/components/gauge.d.ts +48 -9
- package/dist/components/gauge.js +57 -55
- package/dist/components/hamburger.d.ts +19 -4
- package/dist/components/hamburger.js +28 -19
- package/dist/components/hover-card.d.ts +40 -14
- package/dist/components/hover-card.js +76 -59
- package/dist/components/indicator.d.ts +18 -7
- package/dist/components/indicator.js +16 -18
- package/dist/components/input.d.ts +70 -5
- package/dist/components/input.js +83 -20
- package/dist/components/line-chart.d.ts +27 -5
- package/dist/components/line-chart.js +19 -21
- package/dist/components/list.d.ts +10 -1
- package/dist/components/list.js +3 -3
- package/dist/components/menu.d.ts +67 -21
- package/dist/components/menu.js +116 -115
- package/dist/components/multiselect.d.ts +108 -13
- package/dist/components/multiselect.js +207 -70
- package/dist/components/nav-bar.d.ts +12 -7
- package/dist/components/nav-bar.js +11 -21
- package/dist/components/nav-menu.d.ts +52 -12
- package/dist/components/nav-menu.js +68 -70
- package/dist/components/number-input.d.ts +76 -8
- package/dist/components/number-input.js +117 -51
- package/dist/components/pagination.d.ts +19 -1
- package/dist/components/pagination.js +68 -7
- package/dist/components/panel.d.ts +16 -8
- package/dist/components/panel.js +20 -20
- package/dist/components/pin-input.d.ts +41 -4
- package/dist/components/pin-input.js +45 -27
- package/dist/components/popover.d.ts +29 -11
- package/dist/components/popover.js +47 -35
- package/dist/components/progress.d.ts +7 -3
- package/dist/components/progress.js +3 -3
- package/dist/components/radio-group.d.ts +30 -5
- package/dist/components/radio-group.js +56 -19
- package/dist/components/radio.d.ts +47 -7
- package/dist/components/radio.js +68 -29
- package/dist/components/scroll-area.d.ts +8 -5
- package/dist/components/scroll-area.js +19 -20
- package/dist/components/segmented-control.d.ts +52 -8
- package/dist/components/segmented-control.js +66 -36
- package/dist/components/select.d.ts +59 -12
- package/dist/components/select.js +96 -46
- package/dist/components/sidebar.d.ts +22 -3
- package/dist/components/sidebar.js +20 -10
- package/dist/components/skeleton.d.ts +5 -2
- package/dist/components/skeleton.js +4 -4
- package/dist/components/slider.d.ts +27 -5
- package/dist/components/slider.js +29 -17
- package/dist/components/spinner.d.ts +6 -2
- package/dist/components/spinner.js +3 -3
- package/dist/components/stat.d.ts +21 -4
- package/dist/components/stat.js +7 -3
- package/dist/components/status-dot.d.ts +4 -1
- package/dist/components/status-dot.js +3 -3
- package/dist/components/stepper.d.ts +5 -1
- package/dist/components/stepper.js +2 -2
- package/dist/components/switch.d.ts +24 -5
- package/dist/components/switch.js +37 -19
- package/dist/components/table.d.ts +51 -2
- package/dist/components/table.js +157 -8
- package/dist/components/tabs.d.ts +49 -17
- package/dist/components/tabs.js +85 -54
- package/dist/components/tag.d.ts +17 -7
- package/dist/components/tag.js +19 -21
- package/dist/components/tags-input.d.ts +33 -4
- package/dist/components/tags-input.js +40 -30
- package/dist/components/textarea.d.ts +61 -5
- package/dist/components/textarea.js +58 -21
- package/dist/components/toast.d.ts +89 -15
- package/dist/components/toast.js +105 -30
- package/dist/components/toggle-group.d.ts +30 -3
- package/dist/components/toggle-group.js +43 -16
- package/dist/components/toggle.d.ts +25 -4
- package/dist/components/toggle.js +28 -18
- package/dist/components/tooltip.d.ts +31 -12
- package/dist/components/tooltip.js +62 -28
- package/dist/components.json +1518 -0
- package/dist/custom-elements.json +31817 -0
- package/dist/dev/index.d.ts +40 -0
- package/dist/dev/rules.d.ts +46 -0
- package/dist/dev/table.generated.d.ts +8 -0
- package/dist/dev/types.d.ts +113 -0
- package/dist/dev.js +3364 -0
- package/dist/disclosure.d.ts +30 -0
- package/dist/dismiss.d.ts +20 -0
- package/dist/form-control.d.ts +92 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +24 -24
- package/dist/keyboard-activation.d.ts +31 -0
- package/dist/keyboard.d.ts +32 -0
- package/dist/modal.d.ts +44 -0
- package/dist/overlay.d.ts +249 -0
- package/dist/parts.d.ts +171 -0
- package/dist/projection.d.ts +370 -0
- package/dist/types/elements.d.ts +648 -0
- package/dist/types/react.d.ts +163 -0
- package/dist/types/solid.d.ts +164 -0
- package/dist/types/solid2.d.ts +161 -0
- package/dist/types/svelte.d.ts +154 -0
- package/dist/types/vue.d.ts +156 -0
- package/dist/vscode.html-custom-data.json +6004 -0
- package/dist/web-types.json +8365 -0
- package/package.json +113 -21
- package/dist/base.d.ts.map +0 -1
- package/dist/components/accordion.d.ts.map +0 -1
- package/dist/components/action-input.d.ts.map +0 -1
- package/dist/components/alert.d.ts.map +0 -1
- package/dist/components/avatar.d.ts.map +0 -1
- package/dist/components/badge.d.ts.map +0 -1
- package/dist/components/banner.d.ts.map +0 -1
- package/dist/components/bar-chart.d.ts.map +0 -1
- package/dist/components/breadcrumbs.d.ts.map +0 -1
- package/dist/components/button.d.ts.map +0 -1
- package/dist/components/calendar.d.ts.map +0 -1
- package/dist/components/card.d.ts.map +0 -1
- package/dist/components/carousel.d.ts.map +0 -1
- package/dist/components/charts/scale.d.ts.map +0 -1
- package/dist/components/charts/shape.d.ts.map +0 -1
- package/dist/components/checkbox-group.d.ts.map +0 -1
- package/dist/components/checkbox.d.ts.map +0 -1
- package/dist/components/collapsible.d.ts.map +0 -1
- package/dist/components/color-picker.d.ts.map +0 -1
- package/dist/components/combobox.d.ts.map +0 -1
- package/dist/components/compose-input.d.ts.map +0 -1
- package/dist/components/dialog.d.ts.map +0 -1
- package/dist/components/divider.d.ts.map +0 -1
- package/dist/components/donut-chart.d.ts.map +0 -1
- package/dist/components/drawer.d.ts.map +0 -1
- package/dist/components/dropdown-menu.d.ts.map +0 -1
- package/dist/components/editable.d.ts.map +0 -1
- package/dist/components/error-fallback.d.ts.map +0 -1
- package/dist/components/field.d.ts.map +0 -1
- package/dist/components/file-upload.d.ts.map +0 -1
- package/dist/components/gauge.d.ts.map +0 -1
- package/dist/components/hamburger.d.ts.map +0 -1
- package/dist/components/hover-card.d.ts.map +0 -1
- package/dist/components/indicator.d.ts.map +0 -1
- package/dist/components/input.d.ts.map +0 -1
- package/dist/components/line-chart.d.ts.map +0 -1
- package/dist/components/list.d.ts.map +0 -1
- package/dist/components/menu.d.ts.map +0 -1
- package/dist/components/multiselect.d.ts.map +0 -1
- package/dist/components/nav-bar.d.ts.map +0 -1
- package/dist/components/nav-menu.d.ts.map +0 -1
- package/dist/components/number-input.d.ts.map +0 -1
- package/dist/components/pagination.d.ts.map +0 -1
- package/dist/components/panel.d.ts.map +0 -1
- package/dist/components/pin-input.d.ts.map +0 -1
- package/dist/components/popover.d.ts.map +0 -1
- package/dist/components/progress.d.ts.map +0 -1
- package/dist/components/radio-group.d.ts.map +0 -1
- package/dist/components/radio.d.ts.map +0 -1
- package/dist/components/scroll-area.d.ts.map +0 -1
- package/dist/components/segmented-control.d.ts.map +0 -1
- package/dist/components/select.d.ts.map +0 -1
- package/dist/components/sidebar.d.ts.map +0 -1
- package/dist/components/skeleton.d.ts.map +0 -1
- package/dist/components/slider.d.ts.map +0 -1
- package/dist/components/spinner.d.ts.map +0 -1
- package/dist/components/stat.d.ts.map +0 -1
- package/dist/components/status-dot.d.ts.map +0 -1
- package/dist/components/stepper.d.ts.map +0 -1
- package/dist/components/switch.d.ts.map +0 -1
- package/dist/components/table.d.ts.map +0 -1
- package/dist/components/tabs.d.ts.map +0 -1
- package/dist/components/tag.d.ts.map +0 -1
- package/dist/components/tags-input.d.ts.map +0 -1
- package/dist/components/textarea.d.ts.map +0 -1
- package/dist/components/toast.d.ts.map +0 -1
- package/dist/components/toggle-group.d.ts.map +0 -1
- package/dist/components/toggle.d.ts.map +0 -1
- package/dist/components/tooltip.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
|
@@ -1,18 +1,52 @@
|
|
|
1
1
|
import { VoidElement } from '../base.js';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
declare const VoidEditable_base: (new (...args: any[]) => import('../form-control.js').VoidInternalsFormControl) & typeof VoidElement;
|
|
3
|
+
/**
|
|
4
|
+
* Inline editable text for renaming items, editing headings, and click-to-edit table cells.
|
|
5
|
+
*
|
|
6
|
+
* Forms submit the committed `value`, never text still being edited. With
|
|
7
|
+
* `submit-mode="enter"` only Enter commits: leaving the field (blur, including
|
|
8
|
+
* clicking a submit button) cancels the edit by design, so the form submits
|
|
9
|
+
* the previous value. Use `both` (default) or `blur` to commit on blur.
|
|
10
|
+
*/
|
|
11
|
+
export declare class VoidEditable extends VoidEditable_base {
|
|
12
|
+
/** The host's `aria-label` / `aria-labelledby` name the inner control. */
|
|
13
|
+
static labelTarget: string;
|
|
14
|
+
/** While focus is inside, a morph does not apply the server's value over what the user is typing. */
|
|
15
|
+
static editState: string[];
|
|
16
|
+
/**
|
|
17
|
+
* The committed text. As an attribute it is the initial value and the form's reset target. Text still
|
|
18
|
+
* being edited is not part of it until committed.
|
|
19
|
+
*/
|
|
4
20
|
value: string;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the field is in edit mode (an input) rather than showing text. Clicking, Enter or Space
|
|
23
|
+
* starts editing; Escape cancels and `void-cancel` fires.
|
|
24
|
+
*/
|
|
5
25
|
editing: boolean;
|
|
26
|
+
/** Stop the field entering edit mode and exclude the value from the form submission. */
|
|
6
27
|
disabled: boolean;
|
|
28
|
+
/** Text shown while the value is empty and the field is not being edited. Defaults to `Click to edit`. */
|
|
7
29
|
placeholder: string;
|
|
30
|
+
/**
|
|
31
|
+
* How an edit is committed: `enter` only on Enter (blur cancels), `blur` only when focus leaves, or
|
|
32
|
+
* `both` (default).
|
|
33
|
+
*/
|
|
8
34
|
submitMode: 'blur' | 'enter' | 'both';
|
|
35
|
+
/** Size step: `sm`, `md` (default) or `lg`. */
|
|
9
36
|
size: 'sm' | 'md' | 'lg';
|
|
10
37
|
private _previousValue;
|
|
38
|
+
/** Text being edited and not confirmed yet; null when the field shows `value`. */
|
|
39
|
+
private _draft;
|
|
40
|
+
/** The draft survives re-renders and morphs until confirmed or cancelled, unless the server changes `value`. */
|
|
41
|
+
static clientState: {
|
|
42
|
+
_draft: string;
|
|
43
|
+
};
|
|
11
44
|
connectedCallback(): void;
|
|
12
45
|
disconnectedCallback(): void;
|
|
13
46
|
render(): import('lit').TemplateResult<1>;
|
|
14
47
|
private _handleClick;
|
|
15
48
|
private _handlePreviewKeydown;
|
|
49
|
+
private _handleInput;
|
|
16
50
|
private _enterEditMode;
|
|
17
51
|
private _handleInputKeydown;
|
|
18
52
|
private _handleBlur;
|
|
@@ -24,4 +58,4 @@ declare global {
|
|
|
24
58
|
'void-editable': VoidEditable;
|
|
25
59
|
}
|
|
26
60
|
}
|
|
27
|
-
|
|
61
|
+
export {};
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { r as e, t } from "../chunks/base-CMruMbxC.js";
|
|
2
|
+
import { t as n } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
+
import { t as r } from "../chunks/form-control-C0vH6gii.js";
|
|
4
|
+
import { html as i, nothing as a } from "lit";
|
|
5
|
+
import { property as o } from "lit/decorators.js";
|
|
6
|
+
import { live as s } from "lit/directives/live.js";
|
|
5
7
|
//#region src/components/editable.ts
|
|
6
|
-
var
|
|
7
|
-
constructor(...
|
|
8
|
-
super(...
|
|
9
|
-
this.
|
|
8
|
+
var c = class extends r(t) {
|
|
9
|
+
constructor(...t) {
|
|
10
|
+
super(...t), 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
|
+
this.formDisabled || this.editing || this._enterEditMode();
|
|
10
12
|
}, this._handlePreviewKeydown = (e) => {
|
|
11
|
-
this.
|
|
13
|
+
this.formDisabled || this.editing || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), this._enterEditMode());
|
|
14
|
+
}, this._handleInput = (e) => {
|
|
15
|
+
if (!this.editing) return;
|
|
16
|
+
let t = e.target.value;
|
|
17
|
+
this._draft = t, this.dispatchEvent(new CustomEvent("void-input", {
|
|
18
|
+
bubbles: !0,
|
|
19
|
+
composed: !0,
|
|
20
|
+
detail: { value: t }
|
|
21
|
+
}));
|
|
12
22
|
}, this._handleInputKeydown = (e) => {
|
|
13
23
|
if (e.key === "Escape") {
|
|
14
24
|
e.preventDefault(), this._cancel();
|
|
@@ -16,9 +26,18 @@ var a = class extends e {
|
|
|
16
26
|
}
|
|
17
27
|
e.key === "Enter" && (this.submitMode === "enter" || this.submitMode === "both") && (e.preventDefault(), this._confirm());
|
|
18
28
|
}, this._handleBlur = () => {
|
|
19
|
-
this.editing
|
|
29
|
+
!this.editing || e(this) || (this.submitMode === "blur" || this.submitMode === "both" ? this._confirm() : this._cancel());
|
|
20
30
|
};
|
|
21
31
|
}
|
|
32
|
+
static {
|
|
33
|
+
this.labelTarget = ".void-editable-preview, .void-editable-input";
|
|
34
|
+
}
|
|
35
|
+
static {
|
|
36
|
+
this.editState = ["value"];
|
|
37
|
+
}
|
|
38
|
+
static {
|
|
39
|
+
this.clientState = { _draft: "value" };
|
|
40
|
+
}
|
|
22
41
|
connectedCallback() {
|
|
23
42
|
super.connectedCallback(), this.addEventListener("click", this._handleClick), this.addEventListener("dblclick", this._handleClick);
|
|
24
43
|
}
|
|
@@ -26,57 +45,59 @@ var a = class extends e {
|
|
|
26
45
|
super.disconnectedCallback(), this.removeEventListener("click", this._handleClick), this.removeEventListener("dblclick", this._handleClick);
|
|
27
46
|
}
|
|
28
47
|
render() {
|
|
29
|
-
return
|
|
48
|
+
return i`
|
|
30
49
|
<span
|
|
31
50
|
class="void-editable-preview"
|
|
32
|
-
|
|
51
|
+
role="button"
|
|
52
|
+
tabindex=${this.formDisabled ? a : "0"}
|
|
33
53
|
@keydown=${this._handlePreviewKeydown}
|
|
34
|
-
>${this.value ||
|
|
54
|
+
>${this.value || i`<span class="void-editable-placeholder">${this.placeholder}</span>`}</span>
|
|
35
55
|
<input
|
|
36
56
|
class="void-editable-input"
|
|
37
|
-
.value=${this.value}
|
|
57
|
+
.value=${s(this._draft ?? this.value)}
|
|
58
|
+
@input=${this._handleInput}
|
|
38
59
|
@keydown=${this._handleInputKeydown}
|
|
39
60
|
@blur=${this._handleBlur}
|
|
40
61
|
/>
|
|
41
62
|
`;
|
|
42
63
|
}
|
|
43
64
|
_enterEditMode() {
|
|
44
|
-
this._previousValue = this.value, this.editing = !0, this.updateComplete.then(() => {
|
|
65
|
+
this._previousValue = this.value, this._draft = null, this.editing = !0, this.updateComplete.then(() => {
|
|
45
66
|
let e = this.querySelector(".void-editable-input");
|
|
46
67
|
e && (e.focus(), e.select());
|
|
47
68
|
});
|
|
48
69
|
}
|
|
49
70
|
_confirm() {
|
|
50
71
|
let e = this.querySelector(".void-editable-input");
|
|
51
|
-
e && (this.value = e.value), this.editing = !1, this.dispatchEvent(new CustomEvent("void-change", {
|
|
72
|
+
e && (this.value = e.value), this._draft = null, this.editing = !1, this.dispatchEvent(new CustomEvent("void-change", {
|
|
52
73
|
bubbles: !0,
|
|
53
74
|
composed: !0,
|
|
54
75
|
detail: { value: this.value }
|
|
55
76
|
}));
|
|
56
77
|
}
|
|
57
78
|
_cancel() {
|
|
58
|
-
this.value = this._previousValue, this.editing = !1, this.dispatchEvent(new CustomEvent("void-cancel", {
|
|
79
|
+
this.value = this._previousValue, this._draft = null, this.editing = !1, this.dispatchEvent(new CustomEvent("void-cancel", {
|
|
59
80
|
bubbles: !0,
|
|
60
81
|
composed: !0
|
|
61
82
|
}));
|
|
62
83
|
}
|
|
63
84
|
};
|
|
64
|
-
|
|
85
|
+
n([o({
|
|
65
86
|
type: String,
|
|
66
87
|
reflect: !0
|
|
67
|
-
})],
|
|
88
|
+
})], c.prototype, "value", void 0), n([o({
|
|
68
89
|
type: Boolean,
|
|
69
90
|
reflect: !0
|
|
70
|
-
})],
|
|
91
|
+
})], c.prototype, "editing", void 0), n([o({
|
|
71
92
|
type: Boolean,
|
|
72
93
|
reflect: !0
|
|
73
|
-
})],
|
|
94
|
+
})], c.prototype, "disabled", void 0), n([o({ type: String })], c.prototype, "placeholder", void 0), n([o({
|
|
74
95
|
type: String,
|
|
75
96
|
reflect: !0,
|
|
76
97
|
attribute: "submit-mode"
|
|
77
|
-
})],
|
|
98
|
+
})], c.prototype, "submitMode", void 0), n([o({
|
|
78
99
|
type: String,
|
|
79
100
|
reflect: !0
|
|
80
|
-
})],
|
|
101
|
+
})], c.prototype, "size", void 0), customElements.get("void-editable") || customElements.define("void-editable", c);
|
|
81
102
|
//#endregion
|
|
82
|
-
export {
|
|
103
|
+
export { c as VoidEditable };
|
|
@@ -1,18 +1,49 @@
|
|
|
1
1
|
import { VoidElement } from '../base.js';
|
|
2
|
-
|
|
2
|
+
import { PartsController } from '../parts.js';
|
|
3
|
+
/**
|
|
4
|
+
* Error state display for failed data fetches and unexpected runtime errors; includes an optional retry action.
|
|
5
|
+
*
|
|
6
|
+
* Write it with parts: a `<void-error-fallback-title>`, an optional `<void-error-fallback-description>` and an
|
|
7
|
+
* optional `<void-error-fallback-actions>` (buttons). The parts are never moved.
|
|
8
|
+
*
|
|
9
|
+
* It also has a built-in default for the common case. While the author writes no part, the component writes the
|
|
10
|
+
* parts itself from `heading` (default `Something went wrong`), `message`, `retryable` and `retry-label`
|
|
11
|
+
* (default `Try again`), and a click on its retry button fires `void-retry`. As soon as the author writes any
|
|
12
|
+
* part, the component takes its own parts away and the attributes `heading`, `message`, `retryable` and
|
|
13
|
+
* `retry-label` no longer apply: the author's parts replace the default, and the author's own buttons use their
|
|
14
|
+
* own listeners.
|
|
15
|
+
*
|
|
16
|
+
* @fires {CustomEvent} void-retry - The built-in retry button was pressed (the element retries nothing itself).
|
|
17
|
+
*/
|
|
3
18
|
export declare class VoidErrorFallback extends VoidElement {
|
|
19
|
+
/** Headline of the built-in default. Defaults to `Something went wrong`. Ignored when the author writes parts. */
|
|
4
20
|
heading: string;
|
|
21
|
+
/** Detail shown under the headline in the built-in default, such as what failed or what to try. Optional. */
|
|
5
22
|
message: string;
|
|
23
|
+
/**
|
|
24
|
+
* Show a retry button in the built-in default. Clicking it fires `void-retry`; the element does not retry
|
|
25
|
+
* anything itself, so listen for the event and reload. Ignored when the author writes parts.
|
|
26
|
+
*/
|
|
6
27
|
retryable: boolean;
|
|
28
|
+
/** Text of the built-in retry button. Defaults to `Try again`. Only used with `retryable`. */
|
|
7
29
|
retryLabel: string;
|
|
8
|
-
icon
|
|
30
|
+
/** Leave out the warning icon above the headline (it is drawn by default). */
|
|
31
|
+
hideIcon: boolean;
|
|
32
|
+
protected readonly _parts: PartsController;
|
|
33
|
+
constructor();
|
|
9
34
|
connectedCallback(): void;
|
|
10
|
-
|
|
11
|
-
|
|
35
|
+
disconnectedCallback(): void;
|
|
36
|
+
protected updated(changed: Map<string, unknown>): void;
|
|
37
|
+
/** Parts the author wrote. */
|
|
38
|
+
private _authored;
|
|
39
|
+
/** Writes the built-in default while the author has written no part, and takes it away once there is one. */
|
|
40
|
+
private _wire;
|
|
41
|
+
/** Title, description, actions: the order the parts are written in. */
|
|
42
|
+
private _order;
|
|
43
|
+
private _onClick;
|
|
12
44
|
}
|
|
13
45
|
declare global {
|
|
14
46
|
interface HTMLElementTagNameMap {
|
|
15
47
|
'void-error-fallback': VoidErrorFallback;
|
|
16
48
|
}
|
|
17
49
|
}
|
|
18
|
-
//# sourceMappingURL=error-fallback.d.ts.map
|
|
@@ -1,35 +1,85 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as e } from "../chunks/base-CMruMbxC.js";
|
|
2
2
|
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
-
import {
|
|
3
|
+
import { n, t as r } from "../chunks/parts-D30c8OoG.js";
|
|
4
4
|
import { property as i } from "lit/decorators.js";
|
|
5
5
|
//#region src/components/error-fallback.ts
|
|
6
|
-
var a =
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
var a = [
|
|
7
|
+
"void-error-fallback-title",
|
|
8
|
+
"void-error-fallback-description",
|
|
9
|
+
"void-error-fallback-actions"
|
|
10
|
+
], o = "data-void-default", s = class extends e {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(), this.heading = "Something went wrong", this.message = "", this.retryable = !1, this.retryLabel = "Try again", this.hideIcon = !1, this._parts = new n(this, {
|
|
13
|
+
tags: [...a],
|
|
14
|
+
onChange: () => this._wire()
|
|
15
|
+
}), this._onClick = (e) => {
|
|
16
|
+
let t = e.target, n = t?.closest?.("void-error-fallback-actions");
|
|
17
|
+
!n?.hasAttribute(o) || !this._parts.owns(n) || !t.closest("button") || this.dispatchEvent(new CustomEvent("void-retry", {
|
|
18
|
+
bubbles: !0,
|
|
19
|
+
composed: !0
|
|
20
|
+
}));
|
|
21
|
+
};
|
|
22
|
+
let e = {
|
|
23
|
+
voidBeforeMorph: (e) => {
|
|
24
|
+
if (this._authored().length) return;
|
|
25
|
+
let t = Array.from(this.children).filter((e) => e.hasAttribute(o));
|
|
26
|
+
!t.length || Array.from(e.children).some((e) => a.includes(e.localName)) || e.append(...t.map((e) => e.cloneNode(!0)));
|
|
27
|
+
},
|
|
28
|
+
isCopy: () => !1
|
|
29
|
+
}, t = this;
|
|
30
|
+
(t[r] ??= []).push(e);
|
|
9
31
|
}
|
|
10
32
|
connectedCallback() {
|
|
11
|
-
super.connectedCallback(), this.
|
|
33
|
+
super.connectedCallback(), this.setHostAttribute("role", "alert"), this.addEventListener("click", this._onClick);
|
|
12
34
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
bubbles: !0,
|
|
16
|
-
composed: !0
|
|
17
|
-
}));
|
|
35
|
+
disconnectedCallback() {
|
|
36
|
+
super.disconnectedCallback(), this.removeEventListener("click", this._onClick);
|
|
18
37
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
38
|
+
updated(e) {
|
|
39
|
+
super.updated(e), [
|
|
40
|
+
"heading",
|
|
41
|
+
"message",
|
|
42
|
+
"retryable",
|
|
43
|
+
"retryLabel"
|
|
44
|
+
].some((t) => e.has(t)) && this._parts.sync();
|
|
45
|
+
}
|
|
46
|
+
_authored() {
|
|
47
|
+
return a.flatMap((e) => this._parts.all(e)).filter((e) => !e.hasAttribute(o));
|
|
48
|
+
}
|
|
49
|
+
_wire() {
|
|
50
|
+
let e = (e) => this._parts.all(e).find((e) => e.hasAttribute(o)), t = /* @__PURE__ */ new Set();
|
|
51
|
+
if (!this._authored().length) {
|
|
52
|
+
let n = (n, r) => {
|
|
53
|
+
let i = e(n);
|
|
54
|
+
i || (i = document.createElement(n), i.setAttribute(o, ""), this.append(i)), r(i), t.add(i);
|
|
55
|
+
};
|
|
56
|
+
n("void-error-fallback-title", (e) => {
|
|
57
|
+
e.textContent !== this.heading && (e.textContent = this.heading);
|
|
58
|
+
}), this.message && n("void-error-fallback-description", (e) => {
|
|
59
|
+
e.textContent !== this.message && (e.textContent = this.message);
|
|
60
|
+
}), this.retryable && n("void-error-fallback-actions", (e) => {
|
|
61
|
+
let t = e.querySelector("button");
|
|
62
|
+
t || (t = document.createElement("button"), t.type = "button", e.append(t)), t.textContent !== this.retryLabel && (t.textContent = this.retryLabel);
|
|
63
|
+
}), this._order(t);
|
|
64
|
+
}
|
|
65
|
+
for (let e of a) for (let n of this._parts.all(e)) n.hasAttribute(o) && !t.has(n) && n.remove();
|
|
66
|
+
}
|
|
67
|
+
_order(e) {
|
|
68
|
+
a.flatMap((t) => [...e].filter((e) => e.localName === t)).forEach((e, t) => {
|
|
69
|
+
this.children[t] !== e && this.insertBefore(e, this.children[t] ?? null);
|
|
70
|
+
});
|
|
28
71
|
}
|
|
29
72
|
};
|
|
30
|
-
t([i({ type: String })],
|
|
73
|
+
t([i({ type: String })], s.prototype, "heading", void 0), t([i({ type: String })], s.prototype, "message", void 0), t([i({
|
|
74
|
+
type: Boolean,
|
|
75
|
+
reflect: !0
|
|
76
|
+
})], s.prototype, "retryable", void 0), t([i({
|
|
77
|
+
type: String,
|
|
78
|
+
attribute: "retry-label"
|
|
79
|
+
})], s.prototype, "retryLabel", void 0), t([i({
|
|
31
80
|
type: Boolean,
|
|
81
|
+
attribute: "hide-icon",
|
|
32
82
|
reflect: !0
|
|
33
|
-
})],
|
|
83
|
+
})], s.prototype, "hideIcon", void 0), customElements.get("void-error-fallback") || customElements.define("void-error-fallback", s);
|
|
34
84
|
//#endregion
|
|
35
|
-
export {
|
|
85
|
+
export { s as VoidErrorFallback };
|
|
@@ -1,14 +1,49 @@
|
|
|
1
1
|
import { VoidElement } from '../base.js';
|
|
2
|
-
|
|
2
|
+
import { ProjectionController } from '../projection.js';
|
|
3
|
+
/**
|
|
4
|
+
* Form field wrapper that pairs an input with its label, helper text, and validation error.
|
|
5
|
+
*
|
|
6
|
+
* The label names the control as it appears: the native input, select or textarea (also inside Void
|
|
7
|
+
* components), else the widget a component renders inside itself (the multiselect trigger), else the first
|
|
8
|
+
* child. Controls that arrive after the field (a script that runs before the page is parsed, a framework)
|
|
9
|
+
* are wired when they do.
|
|
10
|
+
*/
|
|
3
11
|
export declare class VoidField extends VoidElement {
|
|
12
|
+
/**
|
|
13
|
+
* Visible label. It names the control inside (`for` on a native control, `aria-labelledby` otherwise),
|
|
14
|
+
* so use it instead of a `label` attribute on the control.
|
|
15
|
+
*/
|
|
4
16
|
label: string;
|
|
17
|
+
/**
|
|
18
|
+
* Validation message shown under the control in the error colour. While it is set the control inside
|
|
19
|
+
* is marked `aria-invalid` and described by the message.
|
|
20
|
+
*/
|
|
5
21
|
error: string;
|
|
22
|
+
/**
|
|
23
|
+
* Hint shown under the control when there is no `error`. It describes the control for assistive
|
|
24
|
+
* technology.
|
|
25
|
+
*/
|
|
6
26
|
helper: string;
|
|
27
|
+
/**
|
|
28
|
+
* Draws an asterisk after the label. It is only the mark: put `required` on the control itself to make
|
|
29
|
+
* the browser enforce it.
|
|
30
|
+
*/
|
|
7
31
|
required: boolean;
|
|
8
|
-
private
|
|
9
|
-
private
|
|
32
|
+
private _uid;
|
|
33
|
+
private _labelledControl;
|
|
34
|
+
/** Re-wires when the control's own rendering changes (a Void control re-rendering its native input). */
|
|
35
|
+
private _controlObserver;
|
|
36
|
+
protected readonly _projection: ProjectionController;
|
|
10
37
|
connectedCallback(): void;
|
|
38
|
+
disconnectedCallback(): void;
|
|
11
39
|
protected updated(_changed: Map<string, unknown>): void;
|
|
40
|
+
private _observeControl;
|
|
41
|
+
/** The element that should carry the accessible name: an inner native control (also inside Void components), else the first child. */
|
|
42
|
+
private _findControl;
|
|
43
|
+
private _unwireControl;
|
|
44
|
+
private _wireControl;
|
|
45
|
+
/** Puts back the control's own aria-invalid (or removes it) once the field no longer has an error. */
|
|
46
|
+
private _restoreInvalid;
|
|
12
47
|
render(): import('lit').TemplateResult<1>;
|
|
13
48
|
}
|
|
14
49
|
declare global {
|
|
@@ -16,4 +51,3 @@ declare global {
|
|
|
16
51
|
'void-field': VoidField;
|
|
17
52
|
}
|
|
18
53
|
}
|
|
19
|
-
//# sourceMappingURL=field.d.ts.map
|
package/dist/components/field.js
CHANGED
|
@@ -1,42 +1,84 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
-
import { html as
|
|
4
|
-
import { property as
|
|
1
|
+
import { n as e, t } from "../chunks/base-CMruMbxC.js";
|
|
2
|
+
import { t as n } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
+
import { html as r, nothing as i } from "lit";
|
|
4
|
+
import { property as a } from "lit/decorators.js";
|
|
5
5
|
//#region src/components/field.ts
|
|
6
|
-
var
|
|
7
|
-
constructor(...
|
|
8
|
-
super(...
|
|
6
|
+
var o = "", s = class extends t {
|
|
7
|
+
constructor(...t) {
|
|
8
|
+
super(...t), 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 e(this, {
|
|
9
|
+
regions: [{
|
|
10
|
+
name: "control",
|
|
11
|
+
target: () => this.querySelector(":scope > .void-field-control")
|
|
12
|
+
}],
|
|
13
|
+
onChange: () => this.requestUpdate()
|
|
14
|
+
});
|
|
9
15
|
}
|
|
10
16
|
connectedCallback() {
|
|
11
|
-
super.connectedCallback(), this.
|
|
17
|
+
super.connectedCallback(), this.hasUpdated && this._observeControl();
|
|
18
|
+
}
|
|
19
|
+
disconnectedCallback() {
|
|
20
|
+
super.disconnectedCallback(), this._controlObserver?.disconnect(), this._controlObserver = null;
|
|
12
21
|
}
|
|
13
22
|
updated(e) {
|
|
14
|
-
|
|
15
|
-
this.
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
super.updated(e), this._wireControl(), this._observeControl(), queueMicrotask(() => {
|
|
24
|
+
this.isConnected && this._wireControl();
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
_observeControl() {
|
|
28
|
+
let e = this.querySelector(":scope > .void-field-control");
|
|
29
|
+
!e || !this.isConnected || (this._controlObserver ??= new MutationObserver(() => this._wireControl()), this._controlObserver.disconnect(), this._controlObserver.observe(e, {
|
|
30
|
+
childList: !0,
|
|
31
|
+
subtree: !0
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
_findControl() {
|
|
35
|
+
let e = this.querySelector(".void-field-control");
|
|
36
|
+
return e ? e.querySelector("input:not([aria-hidden=\"true\"]):not([type=\"hidden\"]), select, textarea") ?? e.querySelector("[role=\"combobox\"]") ?? e.firstElementChild : null;
|
|
37
|
+
}
|
|
38
|
+
_unwireControl() {
|
|
39
|
+
let e = this._labelledControl;
|
|
40
|
+
if (!e) return;
|
|
41
|
+
let t = `${this._uid}-label`, n = new Set([`${this._uid}-error`, `${this._uid}-helper`]);
|
|
42
|
+
e.getAttribute("aria-labelledby") === t && e.removeAttribute("aria-labelledby");
|
|
43
|
+
let r = (e.getAttribute("aria-describedby") ?? "").split(/\s+/).filter((e) => e && !n.has(e));
|
|
44
|
+
r.length ? e.setAttribute("aria-describedby", r.join(" ")) : e.removeAttribute("aria-describedby"), this._restoreInvalid(e), this._labelledControl = null;
|
|
45
|
+
}
|
|
46
|
+
_wireControl() {
|
|
47
|
+
let e = this._findControl();
|
|
48
|
+
if (this._labelledControl && this._labelledControl !== e && this._unwireControl(), !e) {
|
|
49
|
+
this.querySelector(":scope > .void-field-label")?.removeAttribute("for");
|
|
50
|
+
return;
|
|
18
51
|
}
|
|
52
|
+
this._labelledControl = e;
|
|
53
|
+
let t = this.querySelector(".void-field-label"), n = `${this._uid}-label`;
|
|
54
|
+
t ? (t.id = n, e.setAttribute("aria-labelledby", n), /^(INPUT|SELECT|TEXTAREA|BUTTON)$/.test(e.tagName) ? (e.id ||= `${this._uid}-control`, t.setAttribute("for", e.id)) : t.removeAttribute("for")) : e.getAttribute("aria-labelledby") === n && e.removeAttribute("aria-labelledby");
|
|
55
|
+
let r = new Set([`${this._uid}-error`, `${this._uid}-helper`]), i = (e.getAttribute("aria-describedby") ?? "").split(/\s+/).filter((e) => e && !r.has(e)), a = this.querySelector(".void-field-error, .void-field-helper");
|
|
56
|
+
a && i.push(a.id), i.length ? e.setAttribute("aria-describedby", i.join(" ")) : e.removeAttribute("aria-describedby"), this.error ? (e.hasAttribute("data-void-field-invalid") || e.setAttribute("data-void-field-invalid", e.getAttribute("aria-invalid") ?? o), e.setAttribute("aria-invalid", "true")) : this._restoreInvalid(e);
|
|
57
|
+
}
|
|
58
|
+
_restoreInvalid(e) {
|
|
59
|
+
let t = e.getAttribute("data-void-field-invalid");
|
|
60
|
+
t !== null && (t === o ? e.removeAttribute("aria-invalid") : e.setAttribute("aria-invalid", t), e.removeAttribute("data-void-field-invalid"));
|
|
19
61
|
}
|
|
20
62
|
render() {
|
|
21
|
-
return
|
|
22
|
-
${this.label ?
|
|
63
|
+
return r`
|
|
64
|
+
${this.label ? r`<label class="void-field-label" id="${this._uid}-label">${this.label}${this.required ? r`<span class="void-field-required" aria-hidden="true"> *</span>` : ""}</label>` : i}
|
|
23
65
|
<div class="void-field-control"></div>
|
|
24
|
-
${this.error ?
|
|
66
|
+
${this.error ? r`<span class="void-field-error" id="${this._uid}-error">${this.error}</span>` : this.helper ? r`<span class="void-field-helper" id="${this._uid}-helper">${this.helper}</span>` : i}
|
|
25
67
|
`;
|
|
26
68
|
}
|
|
27
69
|
};
|
|
28
|
-
|
|
70
|
+
n([a({
|
|
29
71
|
type: String,
|
|
30
72
|
reflect: !0
|
|
31
|
-
})],
|
|
73
|
+
})], s.prototype, "label", void 0), n([a({
|
|
32
74
|
type: String,
|
|
33
75
|
reflect: !0
|
|
34
|
-
})],
|
|
76
|
+
})], s.prototype, "error", void 0), n([a({
|
|
35
77
|
type: String,
|
|
36
78
|
reflect: !0
|
|
37
|
-
})],
|
|
79
|
+
})], s.prototype, "helper", void 0), n([a({
|
|
38
80
|
type: Boolean,
|
|
39
81
|
reflect: !0
|
|
40
|
-
})],
|
|
82
|
+
})], s.prototype, "required", void 0), customElements.get("void-field") || customElements.define("void-field", s);
|
|
41
83
|
//#endregion
|
|
42
|
-
export {
|
|
84
|
+
export { s as VoidField };
|
|
@@ -1,12 +1,33 @@
|
|
|
1
1
|
import { VoidElement } from '../base.js';
|
|
2
|
+
import { FormSubmission } from '../form-control.js';
|
|
3
|
+
declare const VoidFileUpload_base: (new (...args: any[]) => import('../form-control.js').VoidInternalsFormControl) & typeof VoidElement;
|
|
2
4
|
/** Drag-and-drop file picker for document uploads, image attachment flows, and import wizards. */
|
|
3
|
-
export declare class VoidFileUpload extends
|
|
5
|
+
export declare class VoidFileUpload extends VoidFileUpload_base {
|
|
6
|
+
/** The host's `aria-label` / `aria-labelledby` name the inner control. */
|
|
7
|
+
static labelTarget: string;
|
|
8
|
+
/**
|
|
9
|
+
* 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 dropped without an error.
|
|
11
|
+
*/
|
|
4
12
|
accept: string;
|
|
13
|
+
/** Allow more than one file. Without it a new choice replaces the old one. */
|
|
5
14
|
multiple: boolean;
|
|
15
|
+
/** Stop the zone reacting and exclude the files from the form submission. */
|
|
6
16
|
disabled: boolean;
|
|
17
|
+
/** Largest allowed file in bytes. 0 (the default) means no limit. Larger files are dropped silently. */
|
|
7
18
|
maxSize: number;
|
|
19
|
+
/**
|
|
20
|
+
* Message shown under the zone, such as a server-side upload failure. It does not set `aria-invalid`;
|
|
21
|
+
* the component never produces an error text itself.
|
|
22
|
+
*/
|
|
8
23
|
error: string;
|
|
9
24
|
private _files;
|
|
25
|
+
/** One entry per selected file. */
|
|
26
|
+
protected formSubmission(): FormSubmission;
|
|
27
|
+
protected formSnapshot(): unknown;
|
|
28
|
+
protected formRestore(state: unknown): void;
|
|
29
|
+
/** Files cannot be restored from serialised state. */
|
|
30
|
+
formStateRestoreCallback(): void;
|
|
10
31
|
private get _input();
|
|
11
32
|
render(): import('lit').TemplateResult<1>;
|
|
12
33
|
private _onDropzoneClick;
|
|
@@ -23,4 +44,4 @@ declare global {
|
|
|
23
44
|
'void-file-upload': VoidFileUpload;
|
|
24
45
|
}
|
|
25
46
|
}
|
|
26
|
-
|
|
47
|
+
export {};
|