@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,21 +1,41 @@
|
|
|
1
1
|
import { VoidElement } from '../base.js';
|
|
2
|
-
|
|
2
|
+
import { PartsController } from '../parts.js';
|
|
3
|
+
/**
|
|
4
|
+
* Simple expand/collapse panel for FAQ sections, spoiler text, and progressive disclosure of secondary content.
|
|
5
|
+
*
|
|
6
|
+
* Written as two parts: a `<void-collapsible-trigger>` (the heading text that toggles it) followed by a
|
|
7
|
+
* `<void-collapsible-content>`. Both are written by the author and never moved. The trigger becomes the button
|
|
8
|
+
* (`role="button"`, a tab stop, Enter and Space, `aria-expanded`, `aria-controls`); the content is the region it
|
|
9
|
+
* names. Closed content is hidden by the theme from the host's `open` attribute, before the script loads as well, and
|
|
10
|
+
* opens and closes with a height animation (a grid row, no measuring; off under `prefers-reduced-motion` and when
|
|
11
|
+
* `--void-anim-scale` is 0). Where the browser supports `hidden="until-found"` the closed content carries it, so it is
|
|
12
|
+
* out of the accessibility tree and find-in-page opens the panel when it finds text inside.
|
|
13
|
+
*
|
|
14
|
+
* @fires {CustomEvent<{ reason: 'trigger' | 'keyboard' | 'find' }>} void-open - The panel opened: a click on the trigger,
|
|
15
|
+
* Enter or Space on it, or find-in-page found text inside. Does not bubble.
|
|
16
|
+
* @fires {CustomEvent<{ reason: 'trigger' | 'keyboard' }>} void-close - The user is closing the panel. Cancelable:
|
|
17
|
+
* `preventDefault()` keeps it open. Does not bubble.
|
|
18
|
+
*/
|
|
3
19
|
export declare class VoidCollapsible extends VoidElement {
|
|
4
|
-
|
|
20
|
+
/** Whether the content is shown. Add the attribute to start open; it follows the user's toggling. */
|
|
5
21
|
open: boolean;
|
|
22
|
+
/** Stop the panel from toggling. The trigger ignores clicks and Enter or Space. */
|
|
6
23
|
disabled: boolean;
|
|
7
|
-
|
|
8
|
-
private
|
|
9
|
-
private _didSetup;
|
|
24
|
+
protected readonly _parts: PartsController;
|
|
25
|
+
private readonly _closed;
|
|
10
26
|
connectedCallback(): void;
|
|
27
|
+
disconnectedCallback(): void;
|
|
11
28
|
protected updated(changed: Map<string, unknown>): void;
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
|
|
29
|
+
private _wire;
|
|
30
|
+
/** Find-in-page (or a link, or a text fragment) reached text inside the closed content: open. */
|
|
31
|
+
private _onBeforeMatch;
|
|
32
|
+
private _fromTrigger;
|
|
33
|
+
private _onClick;
|
|
34
|
+
private _onKeydown;
|
|
35
|
+
private _toggle;
|
|
15
36
|
}
|
|
16
37
|
declare global {
|
|
17
38
|
interface HTMLElementTagNameMap {
|
|
18
39
|
'void-collapsible': VoidCollapsible;
|
|
19
40
|
}
|
|
20
41
|
}
|
|
21
|
-
//# sourceMappingURL=collapsible.d.ts.map
|
|
@@ -1,61 +1,59 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as e } from "../chunks/base-CMruMbxC.js";
|
|
2
2
|
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { n } from "../chunks/parts-D30c8OoG.js";
|
|
4
|
+
import { t as r } from "../chunks/disclosure-Bj_49GcC.js";
|
|
5
|
+
import { property as i } from "lit/decorators.js";
|
|
5
6
|
//#region src/components/collapsible.ts
|
|
6
|
-
var
|
|
7
|
+
var a = class extends e {
|
|
7
8
|
constructor(...e) {
|
|
8
|
-
super(...e), this.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
super(...e), this.open = !1, this.disabled = !1, this._parts = new n(this, {
|
|
10
|
+
tags: ["void-collapsible-trigger", "void-collapsible-content"],
|
|
11
|
+
onChange: () => this._wire()
|
|
12
|
+
}), this._closed = new r(this, this._parts), this._onBeforeMatch = (e) => {
|
|
13
|
+
this.open || e.target !== this._parts.one("void-collapsible-content") || (this.open = !0, this.dispatchEvent(new CustomEvent("void-open", {
|
|
14
|
+
bubbles: !1,
|
|
15
|
+
detail: { reason: "find" }
|
|
13
16
|
})));
|
|
14
|
-
}, this.
|
|
15
|
-
(e
|
|
17
|
+
}, this._onClick = (e) => {
|
|
18
|
+
this._fromTrigger(e) && (e.preventDefault(), this._toggle("trigger"));
|
|
19
|
+
}, this._onKeydown = (e) => {
|
|
20
|
+
e.key !== "Enter" && e.key !== " " || !this._fromTrigger(e) || e.defaultPrevented || e.target.closest("a, button, input, select, textarea") || (e.preventDefault(), this._toggle("keyboard"));
|
|
16
21
|
};
|
|
17
22
|
}
|
|
18
23
|
connectedCallback() {
|
|
19
|
-
super.connectedCallback(), this.
|
|
24
|
+
super.connectedCallback(), this.addEventListener("click", this._onClick), this.addEventListener("keydown", this._onKeydown), this.addEventListener("beforematch", this._onBeforeMatch);
|
|
25
|
+
}
|
|
26
|
+
disconnectedCallback() {
|
|
27
|
+
super.disconnectedCallback(), this.removeEventListener("click", this._onClick), this.removeEventListener("keydown", this._onKeydown), this.removeEventListener("beforematch", this._onBeforeMatch);
|
|
20
28
|
}
|
|
21
29
|
updated(e) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
super.updated(e), (e.has("open") || e.has("disabled")) && this._wire();
|
|
31
|
+
}
|
|
32
|
+
_wire() {
|
|
33
|
+
let e = this._parts.one("void-collapsible-trigger"), t = this._parts.one("void-collapsible-content");
|
|
34
|
+
e && (this._parts.set(e, "role", "button"), this._parts.set(e, "tabindex", this.disabled ? "-1" : "0"), this._parts.set(e, "aria-expanded", String(this.open)), this._parts.set(e, "aria-disabled", this.disabled ? "true" : null), this._parts.set(e, "aria-controls", t ? this._parts.id(t, "void-collapsible-content") : null)), t && (this._parts.set(t, "role", "region"), this._parts.set(t, "aria-labelledby", e ? this._parts.id(e, "void-collapsible-trigger") : null)), this._closed.sync(t, this.open);
|
|
35
|
+
}
|
|
36
|
+
_fromTrigger(e) {
|
|
37
|
+
let t = this._parts.one("void-collapsible-trigger");
|
|
38
|
+
return !!t && e.target instanceof Node && t.contains(e.target);
|
|
27
39
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
@keydown=${this._handleKeydown}
|
|
38
|
-
>
|
|
39
|
-
${this.heading}
|
|
40
|
-
<svg class="void-collapsible-chevron" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
|
41
|
-
<path d="M4 6l4 4 4-4" stroke="currentColor" stroke-width="var(--void-icon-stroke-width)" stroke-linecap="round" stroke-linejoin="round"/>
|
|
42
|
-
</svg>
|
|
43
|
-
</button>
|
|
44
|
-
<div
|
|
45
|
-
id="content-${this._id}"
|
|
46
|
-
class="void-collapsible-content"
|
|
47
|
-
role="region"
|
|
48
|
-
aria-labelledby="trigger-${this._id}"
|
|
49
|
-
><div class="void-collapsible-inner"></div></div>
|
|
50
|
-
`;
|
|
40
|
+
_toggle(e) {
|
|
41
|
+
this.disabled || (this.open ? this.dispatchEvent(new CustomEvent("void-close", {
|
|
42
|
+
bubbles: !1,
|
|
43
|
+
cancelable: !0,
|
|
44
|
+
detail: { reason: e }
|
|
45
|
+
})) && (this.open = !1) : (this.open = !0, this.dispatchEvent(new CustomEvent("void-open", {
|
|
46
|
+
bubbles: !1,
|
|
47
|
+
detail: { reason: e }
|
|
48
|
+
}))));
|
|
51
49
|
}
|
|
52
50
|
};
|
|
53
|
-
t([
|
|
51
|
+
t([i({
|
|
54
52
|
type: Boolean,
|
|
55
53
|
reflect: !0
|
|
56
|
-
})],
|
|
54
|
+
})], a.prototype, "open", void 0), t([i({
|
|
57
55
|
type: Boolean,
|
|
58
56
|
reflect: !0
|
|
59
|
-
})],
|
|
57
|
+
})], a.prototype, "disabled", void 0), customElements.get("void-collapsible") || customElements.define("void-collapsible", a);
|
|
60
58
|
//#endregion
|
|
61
|
-
export {
|
|
59
|
+
export { a as VoidCollapsible };
|
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
import { VoidElement } from '../base.js';
|
|
2
|
+
declare const VoidColorPicker_base: (new (...args: any[]) => import('../form-control.js').VoidInternalsFormControl) & typeof VoidElement;
|
|
2
3
|
/** Color selection control with spectrum area, hue slider, hex input, and preset swatches for theme customization and design tools. */
|
|
3
|
-
export declare class VoidColorPicker extends
|
|
4
|
+
export declare class VoidColorPicker extends VoidColorPicker_base {
|
|
5
|
+
/** The host's `aria-label` / `aria-labelledby` name the inner control. */
|
|
6
|
+
static labelTarget: string;
|
|
7
|
+
/**
|
|
8
|
+
* Selected colour as a hex string (six digits after the hash). Defaults to black. As an attribute it is the
|
|
9
|
+
* initial value and the form's reset target.
|
|
10
|
+
*/
|
|
4
11
|
value: string;
|
|
12
|
+
/** Stop the picker reacting and exclude the value from the form submission. */
|
|
5
13
|
disabled: boolean;
|
|
14
|
+
/** Size step: `sm`, `md` (default) or `lg`. */
|
|
6
15
|
size: 'sm' | 'md' | 'lg';
|
|
16
|
+
/**
|
|
17
|
+
* Preset colours as an array of hex strings shown under the spectrum. Set it as a property from script
|
|
18
|
+
* (`el.swatches = [red, green]`, each a hex string) or as a JSON array in the attribute.
|
|
19
|
+
*/
|
|
7
20
|
swatches: string[];
|
|
8
|
-
|
|
9
|
-
|
|
21
|
+
/** Leave out the hex text field under the spectrum (it is shown by default). */
|
|
22
|
+
hideInput: boolean;
|
|
23
|
+
/** Show only a swatch button that opens the picker in a popup, instead of the full picker inline. */
|
|
24
|
+
compact: boolean;
|
|
25
|
+
/** Whether the compact variant's picker is open. Only meaningful with `compact`. */
|
|
10
26
|
open: boolean;
|
|
11
27
|
private _hue;
|
|
12
28
|
private _saturation;
|
|
@@ -44,4 +60,4 @@ declare global {
|
|
|
44
60
|
'void-color-picker': VoidColorPicker;
|
|
45
61
|
}
|
|
46
62
|
}
|
|
47
|
-
|
|
63
|
+
export {};
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as e } from "../chunks/base-CMruMbxC.js";
|
|
2
2
|
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { t as n } from "../chunks/form-control-C0vH6gii.js";
|
|
4
|
+
import { html as r, nothing as i } from "lit";
|
|
5
|
+
import { property as a } from "lit/decorators.js";
|
|
6
|
+
import { live as o } from "lit/directives/live.js";
|
|
5
7
|
//#region src/components/color-picker.ts
|
|
6
|
-
var
|
|
8
|
+
var s = class t extends n(e) {
|
|
7
9
|
constructor(...e) {
|
|
8
|
-
super(...e), this.value = "#000000", this.disabled = !1, this.size = "md", this.swatches = [], this.
|
|
10
|
+
super(...e), this.value = "#000000", this.disabled = !1, this.size = "md", this.swatches = [], this.hideInput = !1, this.compact = !1, this.open = !1, this._hue = 0, this._saturation = 0, this._brightness = 0, this._dragging = null, this._boundPointerMove = null, this._boundPointerUp = null, this._onDocumentClick = (e) => {
|
|
9
11
|
this.open && (this.contains(e.target) || (this.open = !1));
|
|
10
12
|
};
|
|
11
13
|
}
|
|
14
|
+
static {
|
|
15
|
+
this.labelTarget = ".void-color-picker-input, .void-color-picker-compact-input";
|
|
16
|
+
}
|
|
12
17
|
connectedCallback() {
|
|
13
18
|
super.connectedCallback(), this._syncFromHex(this.value), this._boundPointerMove = this._onPointerMove.bind(this), this._boundPointerUp = this._onPointerUp.bind(this);
|
|
14
19
|
}
|
|
@@ -17,7 +22,7 @@ var a = class t extends e {
|
|
|
17
22
|
}
|
|
18
23
|
_applyCustomProperties() {
|
|
19
24
|
let e = this._hsvToHex(this._hue, 100, 100);
|
|
20
|
-
this.
|
|
25
|
+
this.setHostStyle("--void-cp-hue", e), this.setHostStyle("--void-cp-current", this.value), this.setHostStyle("--void-cp-area-x", `${this._saturation}%`), this.setHostStyle("--void-cp-area-y", `${100 - this._brightness}%`), this.setHostStyle("--void-cp-hue-x", `${this._hue / 360 * 100}%`);
|
|
21
26
|
}
|
|
22
27
|
_hsvToRgb(e, t, n) {
|
|
23
28
|
let r = t / 100, i = n / 100, a = i * r, o = a * (1 - Math.abs(e / 60 % 2 - 1)), s = i - a, c = 0, l = 0, u = 0;
|
|
@@ -67,10 +72,10 @@ var a = class t extends e {
|
|
|
67
72
|
}));
|
|
68
73
|
}
|
|
69
74
|
_onAreaPointerDown(e) {
|
|
70
|
-
this.
|
|
75
|
+
this.formDisabled || (this._dragging = "area", this._updateAreaFromPointer(e), document.addEventListener("pointermove", this._boundPointerMove), document.addEventListener("pointerup", this._boundPointerUp));
|
|
71
76
|
}
|
|
72
77
|
_onHuePointerDown(e) {
|
|
73
|
-
this.
|
|
78
|
+
this.formDisabled || (this._dragging = "hue", this._updateHueFromPointer(e), document.addEventListener("pointermove", this._boundPointerMove), document.addEventListener("pointerup", this._boundPointerUp));
|
|
74
79
|
}
|
|
75
80
|
_onPointerMove(e) {
|
|
76
81
|
this._dragging === "area" ? this._updateAreaFromPointer(e) : this._dragging === "hue" && this._updateHueFromPointer(e);
|
|
@@ -115,7 +120,7 @@ var a = class t extends e {
|
|
|
115
120
|
e.has("value") && !this._dragging && this._syncFromHex(this.value), this._applyCustomProperties(), e.has("open") && (this.open ? document.addEventListener("click", this._onDocumentClick, !0) : document.removeEventListener("click", this._onDocumentClick, !0));
|
|
116
121
|
}
|
|
117
122
|
_renderPicker() {
|
|
118
|
-
return
|
|
123
|
+
return r`
|
|
119
124
|
<div class="void-color-picker">
|
|
120
125
|
<div
|
|
121
126
|
class="void-color-picker-area"
|
|
@@ -129,25 +134,25 @@ var a = class t extends e {
|
|
|
129
134
|
>
|
|
130
135
|
<div class="void-color-picker-hue-thumb"></div>
|
|
131
136
|
</div>
|
|
132
|
-
${this.
|
|
137
|
+
${this.hideInput ? r`
|
|
138
|
+
<div class="void-color-picker-preview"></div>
|
|
139
|
+
` : r`
|
|
133
140
|
<div class="void-color-picker-field">
|
|
134
141
|
<span class="void-color-picker-field-swatch"></span>
|
|
135
142
|
<span class="void-color-picker-field-separator"></span>
|
|
136
143
|
<input
|
|
137
144
|
class="void-color-picker-input"
|
|
138
145
|
type="text"
|
|
139
|
-
.value=${this.value}
|
|
146
|
+
.value=${o(this.value)}
|
|
140
147
|
?disabled=${this.disabled}
|
|
141
148
|
maxlength="7"
|
|
142
149
|
@change=${this._onHexInput}
|
|
143
150
|
/>
|
|
144
151
|
</div>
|
|
145
|
-
` : n`
|
|
146
|
-
<div class="void-color-picker-preview"></div>
|
|
147
152
|
`}
|
|
148
|
-
${this.swatches.length > 0 ?
|
|
153
|
+
${this.swatches.length > 0 ? r`
|
|
149
154
|
<div class="void-color-picker-swatches">
|
|
150
|
-
${this.swatches.map((e) =>
|
|
155
|
+
${this.swatches.map((e) => r`
|
|
151
156
|
<button
|
|
152
157
|
type="button"
|
|
153
158
|
class="void-color-picker-swatch"
|
|
@@ -158,12 +163,12 @@ var a = class t extends e {
|
|
|
158
163
|
></button>
|
|
159
164
|
`)}
|
|
160
165
|
</div>
|
|
161
|
-
` :
|
|
166
|
+
` : i}
|
|
162
167
|
</div>
|
|
163
168
|
`;
|
|
164
169
|
}
|
|
165
170
|
render() {
|
|
166
|
-
return this.
|
|
171
|
+
return this.compact ? r`
|
|
167
172
|
<div class="void-color-picker-compact">
|
|
168
173
|
<button
|
|
169
174
|
type="button"
|
|
@@ -178,40 +183,41 @@ var a = class t extends e {
|
|
|
178
183
|
<input
|
|
179
184
|
class="void-color-picker-compact-input"
|
|
180
185
|
type="text"
|
|
181
|
-
.value=${this.value}
|
|
186
|
+
.value=${o(this.value)}
|
|
182
187
|
?disabled=${this.disabled}
|
|
183
188
|
maxlength="7"
|
|
184
189
|
@click=${(e) => e.stopPropagation()}
|
|
185
190
|
@change=${this._onCompactHexInput}
|
|
186
191
|
/>
|
|
187
192
|
</button>
|
|
188
|
-
${this.open ?
|
|
193
|
+
${this.open ? r`
|
|
189
194
|
<div class="void-color-picker-compact-dropdown" role="dialog" aria-label="Color picker">
|
|
190
195
|
${this._renderPicker()}
|
|
191
196
|
</div>
|
|
192
|
-
` :
|
|
197
|
+
` : i}
|
|
193
198
|
</div>
|
|
194
199
|
` : this._renderPicker();
|
|
195
200
|
}
|
|
196
201
|
};
|
|
197
|
-
t([
|
|
202
|
+
t([a({
|
|
198
203
|
type: String,
|
|
199
204
|
reflect: !0
|
|
200
|
-
})],
|
|
205
|
+
})], s.prototype, "value", void 0), t([a({
|
|
201
206
|
type: Boolean,
|
|
202
207
|
reflect: !0
|
|
203
|
-
})],
|
|
208
|
+
})], s.prototype, "disabled", void 0), t([a({
|
|
204
209
|
type: String,
|
|
205
210
|
reflect: !0
|
|
206
|
-
})],
|
|
211
|
+
})], s.prototype, "size", void 0), t([a({ type: Array })], s.prototype, "swatches", void 0), t([a({
|
|
207
212
|
type: Boolean,
|
|
213
|
+
attribute: "hide-input",
|
|
208
214
|
reflect: !0
|
|
209
|
-
})],
|
|
210
|
-
type:
|
|
215
|
+
})], s.prototype, "hideInput", void 0), t([a({
|
|
216
|
+
type: Boolean,
|
|
211
217
|
reflect: !0
|
|
212
|
-
})],
|
|
218
|
+
})], s.prototype, "compact", void 0), t([a({
|
|
213
219
|
type: Boolean,
|
|
214
220
|
reflect: !0
|
|
215
|
-
})],
|
|
221
|
+
})], s.prototype, "open", void 0), customElements.get("void-color-picker") || customElements.define("void-color-picker", s);
|
|
216
222
|
//#endregion
|
|
217
|
-
export {
|
|
223
|
+
export { s as VoidColorPicker };
|
|
@@ -1,25 +1,99 @@
|
|
|
1
1
|
import { VoidElement } from '../base.js';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { OverlayController } from '../overlay.js';
|
|
3
|
+
import { PartsController } from '../parts.js';
|
|
4
|
+
import { ProjectionController } from '../projection.js';
|
|
5
|
+
declare const VoidCombobox_base: (new (...args: any[]) => import('../form-control.js').VoidInternalsFormControl) & typeof VoidElement;
|
|
6
|
+
/**
|
|
7
|
+
* Filterable dropdown for long option lists like country selectors, user assignment fields, and tag pickers.
|
|
8
|
+
*
|
|
9
|
+
* One part, `<void-combobox-content>`, holding the `<void-option>`s: it is the list (`role="listbox"`) shown in the
|
|
10
|
+
* top layer under the field. The component renders the text field itself (after the content part) and never
|
|
11
|
+
* moves, copies or wraps the options: each `<void-option>` is the `role="option"` the browser and assistive
|
|
12
|
+
* technology see.
|
|
13
|
+
*
|
|
14
|
+
* Follows the WAI-ARIA "editable combobox with list autocomplete" pattern (manual selection): the rendered input
|
|
15
|
+
* carries `role="combobox"` and keeps DOM focus; the highlighted option is exposed with `aria-activedescendant`
|
|
16
|
+
* and drawn with the `active` attribute; the chosen option has `aria-selected="true"`.
|
|
17
|
+
*
|
|
18
|
+
* Keyboard (focus in the input): ArrowDown opens the list and highlights the chosen option, else the first one
|
|
19
|
+
* (open: the next option, wrapping); ArrowUp the same towards the last; Alt+ArrowDown opens it without
|
|
20
|
+
* highlighting; Enter chooses the highlighted option and closes the list (with nothing highlighted it closes the
|
|
21
|
+
* list and lets a surrounding form submit); Escape closes the list (a second Escape reaches the surrounding
|
|
22
|
+
* dialog); ArrowLeft, ArrowRight, Home and End move the text cursor and take the highlight off the list; typing
|
|
23
|
+
* filters the options; Tab closes the list. Disabled options are skipped.
|
|
24
|
+
*
|
|
25
|
+
* The list is shown in the top layer (never clipped by an `overflow` or `transform` ancestor) and placed under the
|
|
26
|
+
* input with CSS anchor positioning, flipping above it near the bottom of the viewport. A press outside closes it
|
|
27
|
+
* too; focus stays in the input.
|
|
28
|
+
*
|
|
29
|
+
* @fires {CustomEvent<{ reason: 'keyboard' | 'focus' | 'api' }>} void-open - The option list opened.
|
|
30
|
+
* @fires {CustomEvent<{ reason: 'escape' | 'outside' | 'blur' | 'select' | 'parent' | 'api' }>} void-close - The option list is closing.
|
|
31
|
+
*/
|
|
32
|
+
export declare class VoidCombobox extends VoidCombobox_base {
|
|
33
|
+
/** The host's `aria-label` / `aria-labelledby` name the inner control. */
|
|
34
|
+
static labelTarget: string;
|
|
35
|
+
/**
|
|
36
|
+
* `value` of the chosen `void-option`. As an attribute it is the initial choice (without it, an option marked
|
|
37
|
+
* `selected` is); read the `value` property for the current one.
|
|
38
|
+
*/
|
|
4
39
|
value: string;
|
|
40
|
+
/**
|
|
41
|
+
* Hint shown in the search field while it is empty. Defaults to `Search...`. It is also the field's
|
|
42
|
+
* accessible name when no `void-field` label names it.
|
|
43
|
+
*/
|
|
5
44
|
placeholder: string;
|
|
45
|
+
/** Stop the field opening and exclude the value from the form submission. */
|
|
6
46
|
disabled: boolean;
|
|
7
|
-
|
|
47
|
+
/** Size step: `sm`, `md` (default) or `lg`. */
|
|
48
|
+
size: 'sm' | 'md' | 'lg';
|
|
49
|
+
/**
|
|
50
|
+
* Mark the field invalid: it gets the error styling and `aria-invalid`. The message itself is shown by
|
|
51
|
+
* the wrapping `void-field`.
|
|
52
|
+
*/
|
|
8
53
|
error: string;
|
|
9
54
|
name: string;
|
|
10
|
-
|
|
55
|
+
/** Whether the option list is showing. Reflected, so it can be read (and set) from markup. */
|
|
56
|
+
open: boolean;
|
|
11
57
|
private _query;
|
|
12
|
-
|
|
58
|
+
/** The option with visual focus (`aria-activedescendant`), or null. */
|
|
59
|
+
private _active;
|
|
60
|
+
/** Inside updated(): the wiring it runs must not schedule another update. */
|
|
61
|
+
private _wiring;
|
|
62
|
+
/** The rendered input comes first, so reading order puts the field before its (top-layer) list. */
|
|
63
|
+
protected readonly _projection: ProjectionController;
|
|
64
|
+
protected readonly _parts: PartsController;
|
|
65
|
+
protected readonly _overlay: OverlayController;
|
|
66
|
+
private _content;
|
|
67
|
+
private _input;
|
|
68
|
+
/** The options of this combobox, in document order (inside its content part). */
|
|
69
|
+
private get _options();
|
|
70
|
+
/** Options the current query leaves in the list, in document order. */
|
|
71
|
+
private get _visible();
|
|
13
72
|
connectedCallback(): void;
|
|
14
|
-
|
|
15
|
-
|
|
73
|
+
/** Whether the initial choice has been settled (a value, or an option marked `selected`). */
|
|
74
|
+
private _initial;
|
|
75
|
+
/** Without an initial value, an option marked `selected` is the initial choice (as in a native select). */
|
|
76
|
+
private _adoptSelected;
|
|
77
|
+
protected willUpdate(changed: Map<string, unknown>): void;
|
|
78
|
+
protected updated(changed: Map<string, unknown>): void;
|
|
79
|
+
/**
|
|
80
|
+
* The content part is the listbox in the top layer; every option is a `role="option"` with an id, chosen
|
|
81
|
+
* (`aria-selected`), highlighted (`active`) and filtered out (`hidden`) by the parent.
|
|
82
|
+
*/
|
|
83
|
+
private _wire;
|
|
84
|
+
/** The id of the content part while the list is open (one is generated where the author wrote none). */
|
|
85
|
+
private _controls;
|
|
16
86
|
render(): import('lit').TemplateResult<1>;
|
|
87
|
+
disconnectedCallback(): void;
|
|
88
|
+
private _onPointerDown;
|
|
89
|
+
/** Closes the list through the overlay stack (so `void-close` carries the reason). */
|
|
90
|
+
private _close;
|
|
17
91
|
private _onInputFocus;
|
|
18
92
|
private _onInput;
|
|
93
|
+
/** Moves the highlight: `step` from the current option, or to the first/last enabled option. */
|
|
94
|
+
private _moveActive;
|
|
19
95
|
private _onInputKeydown;
|
|
20
96
|
private _onInputBlur;
|
|
21
|
-
private _onDocumentClick;
|
|
22
|
-
private _onDocumentKeydown;
|
|
23
97
|
private _selectOption;
|
|
24
98
|
}
|
|
25
99
|
declare global {
|
|
@@ -27,4 +101,4 @@ declare global {
|
|
|
27
101
|
'void-combobox': VoidCombobox;
|
|
28
102
|
}
|
|
29
103
|
}
|
|
30
|
-
|
|
104
|
+
export {};
|