@spfx-fast/sharepoint-ui 0.4.2 → 0.5.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/QUICKSTART.md +18 -0
- package/README.md +19 -24
- package/components.json +240 -5694
- package/dist/accordion.d.ts +11 -0
- package/dist/accordion.js +4 -0
- package/dist/alert.d.ts +3 -0
- package/dist/alert.js +4 -0
- package/dist/attachment-list.d.ts +15 -0
- package/dist/attachment-list.js +14 -0
- package/dist/avatar-group.d.ts +12 -0
- package/dist/avatar-group.js +7 -0
- package/dist/avatar.d.ts +6 -0
- package/dist/avatar.js +5 -0
- package/dist/badge.d.ts +3 -0
- package/dist/badge.js +4 -0
- package/dist/breadcrumb.d.ts +10 -0
- package/dist/breadcrumb.js +9 -0
- package/dist/button-group.d.ts +6 -0
- package/dist/button-group.js +4 -0
- package/dist/button.d.ts +3 -0
- package/dist/button.js +4 -0
- package/dist/card.d.ts +3 -0
- package/dist/card.js +4 -0
- package/dist/carousel.d.ts +11 -0
- package/dist/carousel.js +6 -0
- package/dist/checkbox.d.ts +3 -0
- package/dist/checkbox.js +4 -0
- package/dist/combobox.d.ts +9 -0
- package/dist/combobox.js +6 -0
- package/dist/command-bar.d.ts +6 -0
- package/dist/command-bar.js +4 -0
- package/dist/copy-button.d.ts +7 -0
- package/dist/copy-button.js +19 -0
- package/dist/data-grid.d.ts +25 -0
- package/dist/data-grid.js +39 -0
- package/dist/date-range-picker.d.ts +12 -0
- package/dist/date-range-picker.js +4 -0
- package/dist/dialog.d.ts +9 -0
- package/dist/dialog.js +21 -0
- package/dist/divider.d.ts +3 -0
- package/dist/divider.js +4 -0
- package/dist/drawer.d.ts +6 -0
- package/dist/drawer.js +5 -0
- package/dist/empty-state.d.ts +7 -0
- package/dist/empty-state.js +5 -0
- package/dist/field.d.ts +15 -0
- package/dist/field.js +11 -0
- package/dist/file-dropzone.d.ts +15 -0
- package/dist/file-dropzone.js +21 -0
- package/dist/filter-bar.d.ts +9 -0
- package/dist/filter-bar.js +9 -0
- package/dist/image.d.ts +5 -0
- package/dist/image.js +4 -0
- package/dist/index.d.ts +68 -76
- package/dist/index.js +60 -66
- package/dist/input.d.ts +3 -0
- package/dist/input.js +4 -0
- package/dist/label.d.ts +3 -0
- package/dist/label.js +4 -0
- package/dist/link.d.ts +3 -0
- package/dist/link.js +9 -0
- package/dist/list-view.d.ts +29 -0
- package/dist/list-view.js +14 -0
- package/dist/list.d.ts +6 -0
- package/dist/list.js +5 -0
- package/dist/lookup-picker.d.ts +12 -0
- package/dist/lookup-picker.js +4 -0
- package/dist/menu.d.ts +6 -0
- package/dist/menu.js +4 -0
- package/dist/nav.d.ts +12 -0
- package/dist/nav.js +4 -0
- package/dist/pagination.d.ts +11 -0
- package/dist/pagination.js +5 -0
- package/dist/person-picker.d.ts +13 -0
- package/dist/person-picker.js +4 -0
- package/dist/persona.d.ts +7 -0
- package/dist/persona.js +5 -0
- package/dist/popover.d.ts +6 -0
- package/dist/popover.js +4 -0
- package/dist/progress-bar.d.ts +5 -0
- package/dist/progress-bar.js +5 -0
- package/dist/radio-group.d.ts +6 -0
- package/dist/radio-group.js +4 -0
- package/dist/radio.d.ts +3 -0
- package/dist/radio.js +4 -0
- package/dist/rating.d.ts +8 -0
- package/dist/rating.js +5 -0
- package/dist/react.d.ts +1 -4583
- package/dist/react.js +1 -6837
- package/dist/select.d.ts +3 -0
- package/dist/select.js +4 -0
- package/dist/sharepoint-field.d.ts +18 -0
- package/dist/sharepoint-field.js +54 -0
- package/dist/skeleton.d.ts +6 -0
- package/dist/skeleton.js +9 -0
- package/dist/spinner.d.ts +5 -0
- package/dist/spinner.js +4 -0
- package/dist/swatch-picker.d.ts +17 -0
- package/dist/swatch-picker.js +11 -0
- package/dist/switch.d.ts +3 -0
- package/dist/switch.js +4 -0
- package/dist/table.d.ts +6 -0
- package/dist/table.js +4 -0
- package/dist/tabs.d.ts +14 -0
- package/dist/tabs.js +30 -0
- package/dist/tag-group.d.ts +6 -0
- package/dist/tag-group.js +4 -0
- package/dist/tag-picker.d.ts +12 -0
- package/dist/tag-picker.js +4 -0
- package/dist/tag.d.ts +7 -0
- package/dist/tag.js +5 -0
- package/dist/text.d.ts +5 -0
- package/dist/text.js +4 -0
- package/dist/textarea.d.ts +3 -0
- package/dist/textarea.js +4 -0
- package/dist/theme.d.ts +15 -167
- package/dist/theme.js +36 -162
- package/dist/toast.d.ts +9 -0
- package/dist/toast.js +12 -0
- package/dist/tree.d.ts +13 -0
- package/dist/tree.js +9 -0
- package/dist/view-card.d.ts +8 -0
- package/dist/view-card.js +4 -0
- package/dist/view-switcher.d.ts +13 -0
- package/dist/view-switcher.js +7 -0
- package/dist/virtual-list.d.ts +11 -0
- package/dist/virtual-list.js +25 -0
- package/measurements.json +365 -0
- package/package.json +19 -42
- package/src/theme.css +125 -0
- package/AGENTS.md +0 -211
- package/dist/appearance.d.ts +0 -6
- package/dist/appearance.js +0 -217
- package/dist/elements/accordion.d.ts +0 -9
- package/dist/elements/accordion.js +0 -338
- package/dist/elements/alert.d.ts +0 -2
- package/dist/elements/alert.js +0 -62
- package/dist/elements/avatar-group-primitives.d.ts +0 -3
- package/dist/elements/avatar-group-primitives.js +0 -189
- package/dist/elements/avatar-group.d.ts +0 -2
- package/dist/elements/avatar-group.js +0 -110
- package/dist/elements/avatar.d.ts +0 -4
- package/dist/elements/avatar.js +0 -251
- package/dist/elements/badge.d.ts +0 -8
- package/dist/elements/badge.js +0 -182
- package/dist/elements/breadcrumb.d.ts +0 -4
- package/dist/elements/breadcrumb.js +0 -233
- package/dist/elements/button-group.d.ts +0 -1
- package/dist/elements/button-group.js +0 -20
- package/dist/elements/button-variants.d.ts +0 -6
- package/dist/elements/button-variants.js +0 -339
- package/dist/elements/button.d.ts +0 -5
- package/dist/elements/button.js +0 -233
- package/dist/elements/card-primitives.d.ts +0 -3
- package/dist/elements/card-primitives.js +0 -83
- package/dist/elements/card.d.ts +0 -5
- package/dist/elements/card.js +0 -213
- package/dist/elements/carousel.d.ts +0 -92
- package/dist/elements/carousel.js +0 -1112
- package/dist/elements/color-picker.d.ts +0 -24
- package/dist/elements/color-picker.js +0 -1004
- package/dist/elements/combobox.d.ts +0 -1
- package/dist/elements/combobox.js +0 -1012
- package/dist/elements/data-grid-model.d.ts +0 -117
- package/dist/elements/data-grid-model.js +0 -294
- package/dist/elements/data-grid.d.ts +0 -29
- package/dist/elements/data-grid.js +0 -1567
- package/dist/elements/date-picker.d.ts +0 -1
- package/dist/elements/date-picker.js +0 -486
- package/dist/elements/dialog.d.ts +0 -23
- package/dist/elements/dialog.js +0 -409
- package/dist/elements/divider.d.ts +0 -2
- package/dist/elements/divider.js +0 -66
- package/dist/elements/drawer.d.ts +0 -3
- package/dist/elements/drawer.js +0 -308
- package/dist/elements/field-composition.d.ts +0 -26
- package/dist/elements/field-composition.js +0 -133
- package/dist/elements/field.d.ts +0 -1
- package/dist/elements/field.js +0 -67
- package/dist/elements/file-upload.d.ts +0 -6
- package/dist/elements/file-upload.js +0 -211
- package/dist/elements/floating-position.d.ts +0 -26
- package/dist/elements/floating-position.js +0 -39
- package/dist/elements/image.d.ts +0 -28
- package/dist/elements/image.js +0 -38
- package/dist/elements/info.d.ts +0 -9
- package/dist/elements/info.js +0 -102
- package/dist/elements/input.d.ts +0 -5
- package/dist/elements/input.js +0 -255
- package/dist/elements/label.d.ts +0 -15
- package/dist/elements/label.js +0 -56
- package/dist/elements/link.d.ts +0 -1
- package/dist/elements/link.js +0 -92
- package/dist/elements/list.d.ts +0 -19
- package/dist/elements/list.js +0 -297
- package/dist/elements/menu.d.ts +0 -33
- package/dist/elements/menu.js +0 -1103
- package/dist/elements/message-bar.d.ts +0 -10
- package/dist/elements/message-bar.js +0 -299
- package/dist/elements/nav.d.ts +0 -32
- package/dist/elements/nav.js +0 -791
- package/dist/elements/overflow.d.ts +0 -9
- package/dist/elements/overflow.js +0 -218
- package/dist/elements/persona.d.ts +0 -3
- package/dist/elements/persona.js +0 -125
- package/dist/elements/popover.d.ts +0 -77
- package/dist/elements/popover.js +0 -840
- package/dist/elements/progress-bar.d.ts +0 -4
- package/dist/elements/progress-bar.js +0 -82
- package/dist/elements/radio-group.d.ts +0 -1
- package/dist/elements/radio-group.js +0 -303
- package/dist/elements/rating-display.d.ts +0 -2
- package/dist/elements/rating-display.js +0 -125
- package/dist/elements/rating.d.ts +0 -2
- package/dist/elements/rating.js +0 -206
- package/dist/elements/rich-text-editor.d.ts +0 -18
- package/dist/elements/rich-text-editor.js +0 -508
- package/dist/elements/search.d.ts +0 -3
- package/dist/elements/search.js +0 -207
- package/dist/elements/select.d.ts +0 -6
- package/dist/elements/select.js +0 -291
- package/dist/elements/shared.d.ts +0 -19
- package/dist/elements/shared.js +0 -396
- package/dist/elements/skeleton.d.ts +0 -6
- package/dist/elements/skeleton.js +0 -91
- package/dist/elements/slider.d.ts +0 -1
- package/dist/elements/slider.js +0 -248
- package/dist/elements/spin-button.d.ts +0 -7
- package/dist/elements/spin-button.js +0 -499
- package/dist/elements/spinner.d.ts +0 -4
- package/dist/elements/spinner.js +0 -124
- package/dist/elements/swatch-picker.d.ts +0 -5
- package/dist/elements/swatch-picker.js +0 -363
- package/dist/elements/table.d.ts +0 -21
- package/dist/elements/table.js +0 -261
- package/dist/elements/tabs.d.ts +0 -1
- package/dist/elements/tabs.js +0 -276
- package/dist/elements/tag-picker.d.ts +0 -29
- package/dist/elements/tag-picker.js +0 -697
- package/dist/elements/tags.d.ts +0 -21
- package/dist/elements/tags.js +0 -421
- package/dist/elements/teaching-popover.d.ts +0 -32
- package/dist/elements/teaching-popover.js +0 -412
- package/dist/elements/text.d.ts +0 -9
- package/dist/elements/text.js +0 -75
- package/dist/elements/textarea.d.ts +0 -1
- package/dist/elements/textarea.js +0 -182
- package/dist/elements/toast.d.ts +0 -25
- package/dist/elements/toast.js +0 -337
- package/dist/elements/toaster.d.ts +0 -6
- package/dist/elements/toaster.js +0 -356
- package/dist/elements/toggle.d.ts +0 -2
- package/dist/elements/toggle.js +0 -246
- package/dist/elements/toolbar.d.ts +0 -12
- package/dist/elements/toolbar.js +0 -381
- package/dist/elements/tooltip.d.ts +0 -76
- package/dist/elements/tooltip.js +0 -510
- package/dist/elements/tree-model.d.ts +0 -19
- package/dist/elements/tree-model.js +0 -34
- package/dist/elements/tree.d.ts +0 -5
- package/dist/elements/tree.js +0 -273
- package/dist/elements/view-card.d.ts +0 -2
- package/dist/elements/view-card.js +0 -78
- package/dist/elements/virtual-list.d.ts +0 -41
- package/dist/elements/virtual-list.js +0 -369
- package/dist/elements.d.ts +0 -72
- package/dist/elements.js +0 -207
- package/dist/virtualizer-hooks.d.ts +0 -80
- package/dist/virtualizer-hooks.js +0 -253
- package/scripts/generate-token-index.mjs +0 -43
- package/scripts/sync-component-catalog-signatures.mjs +0 -55
- package/scripts/validate-component-catalog.mjs +0 -44
- package/skills/sharepoint-ui/SKILL.md +0 -12
- package/skills/sharepoint-ui/references/choosing-components.md +0 -20
- package/skills/sharepoint-ui/references/sharepoint-patterns.md +0 -17
- package/tokens.json +0 -3777
package/dist/elements/search.js
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import { base, stopHostAccessibleNameSync, syncHostAccessibleName } from "./shared.js";
|
|
2
|
-
export function defineSearchBox() {
|
|
3
|
-
if (customElements.get("spui-search-box"))
|
|
4
|
-
return;
|
|
5
|
-
class SpuiSearchBox extends HTMLElement {
|
|
6
|
-
static formAssociated = true;
|
|
7
|
-
static observedAttributes = ["label", "value", "placeholder", "type", "disabled", "required", "read-only", "name", "autocomplete", "maxlength", "minlength", "pattern", "inputmode", "size", "appearance", "clear-label", "aria-label", "aria-labelledby", "aria-description", "aria-describedby", "aria-invalid", "aria-required"];
|
|
8
|
-
#internals = this.attachInternals();
|
|
9
|
-
#value = "";
|
|
10
|
-
#dirty = false;
|
|
11
|
-
#formDisabled = false;
|
|
12
|
-
get form() { return this.#internals.form; }
|
|
13
|
-
get value() { return this.#value; }
|
|
14
|
-
set value(value) { this.setValue(String(value ?? ""), true); }
|
|
15
|
-
get defaultValue() { return this.getAttribute("value") ?? ""; }
|
|
16
|
-
set defaultValue(value) { this.setAttribute("value", value); }
|
|
17
|
-
get name() { return this.getAttribute("name") ?? ""; }
|
|
18
|
-
set name(value) { this.setAttribute("name", value); }
|
|
19
|
-
connectedCallback() {
|
|
20
|
-
if (!this.#dirty)
|
|
21
|
-
this.#value = this.getAttribute("value") ?? "";
|
|
22
|
-
this.render();
|
|
23
|
-
}
|
|
24
|
-
disconnectedCallback() { stopHostAccessibleNameSync(this); }
|
|
25
|
-
attributeChangedCallback(name, _oldValue, value) {
|
|
26
|
-
if (!this.isConnected || !this.shadowRoot?.querySelector("input"))
|
|
27
|
-
return;
|
|
28
|
-
if (name === "value") {
|
|
29
|
-
if (!this.#dirty)
|
|
30
|
-
this.setValue(value ?? "", false);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (name === "label") {
|
|
34
|
-
const label = this.shadowRoot?.querySelector("label");
|
|
35
|
-
if (label)
|
|
36
|
-
label.textContent = value ?? "";
|
|
37
|
-
}
|
|
38
|
-
if (name === "placeholder")
|
|
39
|
-
this.input().placeholder = value ?? "";
|
|
40
|
-
if (name === "type")
|
|
41
|
-
this.input().type = value || "search";
|
|
42
|
-
if (name === "disabled")
|
|
43
|
-
this.input().disabled = value !== null || this.#formDisabled;
|
|
44
|
-
if (name === "required") {
|
|
45
|
-
this.input().required = value !== null;
|
|
46
|
-
this.syncFormValue();
|
|
47
|
-
}
|
|
48
|
-
if (name === "read-only")
|
|
49
|
-
this.input().readOnly = value !== null;
|
|
50
|
-
if (["autocomplete", "maxlength", "minlength", "pattern", "inputmode"].includes(name)) {
|
|
51
|
-
if (value === null)
|
|
52
|
-
this.input().removeAttribute(name);
|
|
53
|
-
else
|
|
54
|
-
this.input().setAttribute(name, value);
|
|
55
|
-
}
|
|
56
|
-
if (name === "aria-label" || name === "aria-labelledby" || name === "aria-description" || name === "aria-describedby" || name === "aria-invalid" || name === "aria-required") {
|
|
57
|
-
if (value === null)
|
|
58
|
-
this.input().removeAttribute(name);
|
|
59
|
-
else
|
|
60
|
-
this.input().setAttribute(name, value);
|
|
61
|
-
}
|
|
62
|
-
if (name === "size")
|
|
63
|
-
this.shadowRoot.querySelector(".control").dataset.size = value || "medium";
|
|
64
|
-
if (name === "appearance")
|
|
65
|
-
this.shadowRoot.querySelector(".control").dataset.appearance = value || "outline";
|
|
66
|
-
if (name === "clear-label")
|
|
67
|
-
this.shadowRoot.querySelector("[part=clear-button]").setAttribute("aria-label", value || "Clear search");
|
|
68
|
-
if (name === "disabled" || name === "read-only")
|
|
69
|
-
this.setValue(this.#value, false);
|
|
70
|
-
this.syncFormValue();
|
|
71
|
-
}
|
|
72
|
-
formResetCallback() { this.#dirty = false; this.setValue(this.defaultValue, false); }
|
|
73
|
-
formStateRestoreCallback(state) { if (typeof state === "string")
|
|
74
|
-
this.setValue(state, false); }
|
|
75
|
-
formDisabledCallback(disabled) {
|
|
76
|
-
this.#formDisabled = disabled;
|
|
77
|
-
const input = this.shadowRoot?.querySelector("input");
|
|
78
|
-
if (input)
|
|
79
|
-
input.disabled = disabled || this.hasAttribute("disabled");
|
|
80
|
-
const clear = this.shadowRoot?.querySelector("[part=clear-button]");
|
|
81
|
-
if (clear)
|
|
82
|
-
clear.hidden = !this.#value || Boolean(input?.disabled) || Boolean(input?.readOnly);
|
|
83
|
-
}
|
|
84
|
-
input() { return this.shadowRoot.querySelector("input"); }
|
|
85
|
-
setValue(value, dirty) {
|
|
86
|
-
this.#value = value;
|
|
87
|
-
if (dirty)
|
|
88
|
-
this.#dirty = true;
|
|
89
|
-
const input = this.shadowRoot?.querySelector("input");
|
|
90
|
-
if (input && input.value !== value)
|
|
91
|
-
input.value = value;
|
|
92
|
-
const clear = this.shadowRoot?.querySelector("[part=clear-button]");
|
|
93
|
-
if (clear)
|
|
94
|
-
clear.hidden = !value || Boolean(input?.disabled) || Boolean(input?.readOnly);
|
|
95
|
-
this.syncFormValue();
|
|
96
|
-
}
|
|
97
|
-
syncFormValue() {
|
|
98
|
-
if (!this.#internals)
|
|
99
|
-
return;
|
|
100
|
-
const input = this.shadowRoot?.querySelector("input");
|
|
101
|
-
if (input)
|
|
102
|
-
syncHostAccessibleName(this, input);
|
|
103
|
-
this.#internals.setFormValue(this.#value, this.#value);
|
|
104
|
-
if (input && !input.validity.valid) {
|
|
105
|
-
const invalidFlags = ["badInput", "customError", "patternMismatch", "rangeOverflow", "rangeUnderflow", "stepMismatch", "tooLong", "tooShort", "typeMismatch", "valueMissing"];
|
|
106
|
-
const flags = {};
|
|
107
|
-
for (const flag of invalidFlags)
|
|
108
|
-
if (input.validity[flag])
|
|
109
|
-
flags[flag] = true;
|
|
110
|
-
this.#internals.setValidity(flags, input.validationMessage, input);
|
|
111
|
-
}
|
|
112
|
-
else
|
|
113
|
-
this.#internals.setValidity({});
|
|
114
|
-
}
|
|
115
|
-
render() {
|
|
116
|
-
const shadow = this.shadowRoot ?? this.attachShadow({ mode: "open" });
|
|
117
|
-
const label = document.createElement("label");
|
|
118
|
-
label.part.add("label");
|
|
119
|
-
label.htmlFor = "search-input";
|
|
120
|
-
label.textContent = this.getAttribute("label") ?? "";
|
|
121
|
-
const control = document.createElement("div");
|
|
122
|
-
control.className = "control";
|
|
123
|
-
control.dataset.size = this.getAttribute("size") || "medium";
|
|
124
|
-
control.dataset.appearance = this.getAttribute("appearance") || "outline";
|
|
125
|
-
const icon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
126
|
-
icon.setAttribute("viewBox", "0 0 20 20");
|
|
127
|
-
icon.setAttribute("aria-hidden", "true");
|
|
128
|
-
icon.setAttribute("focusable", "false");
|
|
129
|
-
icon.setAttribute("part", "search-icon");
|
|
130
|
-
icon.innerHTML = '<circle cx="8.5" cy="8.5" r="5.75"/><path d="m13 13 4.25 4.25"/>';
|
|
131
|
-
const contentBefore = document.createElement("slot");
|
|
132
|
-
contentBefore.name = "content-before";
|
|
133
|
-
contentBefore.append(icon);
|
|
134
|
-
const input = document.createElement("input");
|
|
135
|
-
input.type = this.getAttribute("type") || "search";
|
|
136
|
-
input.value = this.#value;
|
|
137
|
-
input.placeholder = this.getAttribute("placeholder") ?? "";
|
|
138
|
-
input.disabled = this.#formDisabled || this.hasAttribute("disabled");
|
|
139
|
-
input.required = this.hasAttribute("required");
|
|
140
|
-
input.readOnly = this.hasAttribute("read-only");
|
|
141
|
-
input.id = "search-input";
|
|
142
|
-
input.part.add("control");
|
|
143
|
-
for (const name of ["autocomplete", "maxlength", "minlength", "pattern", "inputmode"]) {
|
|
144
|
-
const value = this.getAttribute(name);
|
|
145
|
-
if (value !== null)
|
|
146
|
-
input.setAttribute(name, value);
|
|
147
|
-
}
|
|
148
|
-
for (const name of ["aria-label", "aria-labelledby", "aria-description", "aria-describedby", "aria-invalid", "aria-required"]) {
|
|
149
|
-
const value = this.getAttribute(name);
|
|
150
|
-
if (value !== null)
|
|
151
|
-
input.setAttribute(name, value);
|
|
152
|
-
}
|
|
153
|
-
const clear = document.createElement("span");
|
|
154
|
-
clear.className = "dismiss";
|
|
155
|
-
clear.setAttribute("role", "button");
|
|
156
|
-
clear.tabIndex = -1;
|
|
157
|
-
clear.part.add("clear-button");
|
|
158
|
-
clear.setAttribute("aria-label", this.getAttribute("clear-label") || "Clear search");
|
|
159
|
-
clear.hidden = !this.#value || input.disabled || input.readOnly;
|
|
160
|
-
const dismiss = document.createElement("slot");
|
|
161
|
-
dismiss.name = "dismiss";
|
|
162
|
-
const dismissIcon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
163
|
-
dismissIcon.setAttribute("viewBox", "0 0 16 16");
|
|
164
|
-
dismissIcon.setAttribute("aria-hidden", "true");
|
|
165
|
-
dismissIcon.setAttribute("focusable", "false");
|
|
166
|
-
dismissIcon.innerHTML = '<path d="m4 4 8 8m0-8-8 8"/>';
|
|
167
|
-
dismiss.append(dismissIcon);
|
|
168
|
-
clear.append(dismiss);
|
|
169
|
-
clear.addEventListener("click", event => {
|
|
170
|
-
this.setValue("", true);
|
|
171
|
-
input.focus();
|
|
172
|
-
this.dispatchEvent(new CustomEvent("spui-input", { bubbles: true, composed: true, detail: { value: "", reason: "clear", sourceEvent: event } }));
|
|
173
|
-
this.dispatchEvent(new CustomEvent("spui-clear", { bubbles: true, composed: true }));
|
|
174
|
-
});
|
|
175
|
-
clear.addEventListener("keydown", event => {
|
|
176
|
-
if (event.key !== "Enter" && event.key !== " ")
|
|
177
|
-
return;
|
|
178
|
-
event.preventDefault();
|
|
179
|
-
clear.click();
|
|
180
|
-
});
|
|
181
|
-
input.addEventListener("input", event => {
|
|
182
|
-
this.setValue(input.value, true);
|
|
183
|
-
this.dispatchEvent(new CustomEvent("spui-input", { bubbles: true, composed: true, detail: { value: input.value, reason: "input", sourceEvent: event } }));
|
|
184
|
-
});
|
|
185
|
-
input.addEventListener("keydown", event => {
|
|
186
|
-
if (event.key !== "Enter" || event.isComposing)
|
|
187
|
-
return;
|
|
188
|
-
this.dispatchEvent(new CustomEvent("spui-search", { bubbles: true, composed: true, detail: { value: input.value } }));
|
|
189
|
-
if (this.#internals.form) {
|
|
190
|
-
event.preventDefault();
|
|
191
|
-
this.#internals.form.requestSubmit();
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
const afterSlot = document.createElement("slot");
|
|
195
|
-
afterSlot.name = "content-after";
|
|
196
|
-
const after = document.createElement("span");
|
|
197
|
-
after.className = "content-after";
|
|
198
|
-
after.append(afterSlot, clear);
|
|
199
|
-
control.append(contentBefore, input, after);
|
|
200
|
-
const style = document.createElement("style");
|
|
201
|
-
style.textContent = `${base}:host{display:grid;gap:var(--spui-control-gap,6px);min-width:0}label:empty{display:none}label{font-size:14px;font-weight:600;color:var(--spui-ui-muted,var(--spui-semantic-body-text,inherit))}.control{box-sizing:border-box;display:flex;align-items:center;gap:8px;min-width:0;min-height:var(--spui-control-height,36px);padding-inline:var(--spui-control-padding-inline,12px);border:1px solid var(--spui-control-border,var(--spui-ui-stroke,var(--spui-semantic-input-border,var(--colorNeutralStroke1,#8a8886))));border-radius:var(--spui-control-radius,4px);background:var(--spui-control-background,var(--spui-ui-surface,var(--spui-semantic-input-background,var(--colorNeutralBackground1,#fff))));box-shadow:var(--spui-control-shadow,none);color:var(--spui-ui-text,var(--spui-semantic-body-text,inherit))}.control[data-size=small]{min-height:28px;font-size:13px}.control[data-size=large]{min-height:44px;font-size:16px}.control[data-appearance=underline]{border:0;border-bottom:1px solid var(--spui-control-border,var(--spui-ui-stroke,#8a8886));border-radius:0}.control[data-appearance=filled-darker],.control[data-appearance=filled-darker-shadow]{border-color:transparent;background:var(--spui-input-filled-darker,var(--spui-ui-surface-hover,var(--spui-semantic-input-background,#f3f2f1)))}.control[data-appearance=filled-lighter],.control[data-appearance=filled-lighter-shadow]{border-color:transparent;background:var(--spui-input-filled-lighter,var(--spui-base-surface,var(--spui-ui-canvas,#faf9f8)))}.control[data-appearance=filled-darker-shadow],.control[data-appearance=filled-lighter-shadow]{box-shadow:var(--spui-input-filled-shadow,var(--spui-control-shadow,var(--shadow2,0 1px 2px rgb(0 0 0 / 20%))))}.control:focus-within{border-color:var(--spui-focus-ring,var(--spui-semantic-focus-border,var(--colorStrokeFocus2,#005a9e)))}.control:focus-within[data-appearance=underline]{border-bottom-width:2px}slot[name=content-before],.content-after{display:inline-flex;align-items:center;flex:none;gap:4px}slot[name=content-after]{display:inline-flex;align-items:center;gap:4px}input{box-sizing:border-box;flex:1;min-width:0;width:100%;padding:0;border:0;outline:0;background:transparent;color:inherit;font:inherit}input::placeholder{color:var(--spui-ui-muted,var(--spui-semantic-body-subtext,#616161));opacity:1}input::-webkit-search-cancel-.dismiss{display:none}svg[part=search-icon]{width:18px;height:18px;flex:none;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}.dismiss{display:grid;place-items:center;flex:none;width:28px;height:28px;padding:5px;border:0;border-radius:var(--spui-control-radius,4px);background:transparent;color:inherit;cursor:pointer}.dismiss[hidden]{display:none}.dismiss:hover{background:var(--spui-ui-surface-hover,var(--spui-ui-canvas,#f5f5f5))}.dismiss:focus-visible{outline:2px solid var(--spui-focus-ring,var(--spui-ui-accent,#0078d4));outline-offset:1px}.dismiss svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round}@media(forced-colors:active){.control{border-color:FieldText}.control:focus-within,.dismiss:focus-visible{outline-color:Highlight}}`;
|
|
202
|
-
shadow.replaceChildren(style, label, control);
|
|
203
|
-
this.syncFormValue();
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
customElements.define("spui-search-box", SpuiSearchBox);
|
|
207
|
-
}
|
package/dist/elements/select.js
DELETED
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import { base, rememberNativeFormControlDefaults, stopHostAccessibleNameSync, syncHostAccessibleName } from "./shared.js";
|
|
2
|
-
export function defineSelect() {
|
|
3
|
-
if (customElements.get("spui-select"))
|
|
4
|
-
return;
|
|
5
|
-
class SpuiSelect extends HTMLElement {
|
|
6
|
-
static formAssociated = true;
|
|
7
|
-
static observedAttributes = ["label", "value", "default-value", "auto-complete", "autofocus", "tabindex", "appearance", "size", "disabled", "required", "name", "multiple", "form", "aria-label", "aria-labelledby", "aria-description", "aria-describedby", "aria-invalid"];
|
|
8
|
-
internals;
|
|
9
|
-
observer;
|
|
10
|
-
currentValue;
|
|
11
|
-
boundSelect;
|
|
12
|
-
formDisabled = false;
|
|
13
|
-
slotSelectDefaults;
|
|
14
|
-
initialSelectedValues;
|
|
15
|
-
requestedTabIndex;
|
|
16
|
-
slotSelectTabIndex;
|
|
17
|
-
slotSelectTabIndexCaptured = false;
|
|
18
|
-
normalizingTabIndex = false;
|
|
19
|
-
get form() { return this.internals?.form ?? null; }
|
|
20
|
-
cloneOptionContent() {
|
|
21
|
-
return [...this.children]
|
|
22
|
-
.filter(child => child.localName === "option" || child.localName === "optgroup")
|
|
23
|
-
.map(child => child.cloneNode(true));
|
|
24
|
-
}
|
|
25
|
-
handleSelectChange = (event) => {
|
|
26
|
-
const select = event.currentTarget;
|
|
27
|
-
this.currentValue = select.value;
|
|
28
|
-
this.syncFormValue(select);
|
|
29
|
-
this.dispatchEvent(new CustomEvent("spui-change", { detail: { value: select.value, sourceEvent: event }, bubbles: true, composed: true }));
|
|
30
|
-
};
|
|
31
|
-
getSelect() {
|
|
32
|
-
const slot = this.shadowRoot?.querySelector('slot[name="select"]');
|
|
33
|
-
const assigned = slot?.assignedElements().find((element) => element instanceof HTMLSelectElement);
|
|
34
|
-
return assigned ?? this.shadowRoot?.querySelector(".select-fallback") ?? null;
|
|
35
|
-
}
|
|
36
|
-
constructor() {
|
|
37
|
-
super();
|
|
38
|
-
try {
|
|
39
|
-
this.internals = this.attachInternals();
|
|
40
|
-
}
|
|
41
|
-
catch { /* Form association is an enhancement where ElementInternals is unavailable. */ }
|
|
42
|
-
}
|
|
43
|
-
connectedCallback() {
|
|
44
|
-
this.render();
|
|
45
|
-
if (this.hasAttribute("autofocus"))
|
|
46
|
-
this.getSelect()?.focus();
|
|
47
|
-
this.observer = new MutationObserver(records => {
|
|
48
|
-
if (records.some(record => !this.boundSelect?.contains(record.target)))
|
|
49
|
-
this.syncOptions();
|
|
50
|
-
});
|
|
51
|
-
this.observer.observe(this, { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: ["value", "label", "disabled", "selected"] });
|
|
52
|
-
}
|
|
53
|
-
disconnectedCallback() { this.observer?.disconnect(); stopHostAccessibleNameSync(this); }
|
|
54
|
-
attributeChangedCallback(name, _oldValue, value) {
|
|
55
|
-
if (name === "tabindex" && !this.normalizingTabIndex)
|
|
56
|
-
this.requestedTabIndex = value === null ? undefined : Number(value);
|
|
57
|
-
if (this.normalizingTabIndex || !this.isConnected)
|
|
58
|
-
return;
|
|
59
|
-
const select = this.getSelect();
|
|
60
|
-
if (!select)
|
|
61
|
-
return;
|
|
62
|
-
if (name === "tabindex") {
|
|
63
|
-
this.syncTabIndex(select);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (name === "autofocus") {
|
|
67
|
-
if (value !== null)
|
|
68
|
-
select.focus();
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if (name === "value")
|
|
72
|
-
this.currentValue = value ?? "";
|
|
73
|
-
if (name === "default-value" && this.currentValue === undefined && this.getAttribute("value") === null)
|
|
74
|
-
this.currentValue = value ?? "";
|
|
75
|
-
if (name === "label") {
|
|
76
|
-
const label = this.shadowRoot?.querySelector("label");
|
|
77
|
-
if (label)
|
|
78
|
-
label.textContent = value ?? "";
|
|
79
|
-
}
|
|
80
|
-
if (name === "disabled")
|
|
81
|
-
select.disabled = this.formDisabled || this.hasAttribute("disabled") || Boolean(this.slotSelectDefaults?.disabled);
|
|
82
|
-
if (name === "required")
|
|
83
|
-
select.required = this.hasAttribute("required") || Boolean(this.slotSelectDefaults?.required);
|
|
84
|
-
if (name === "multiple")
|
|
85
|
-
select.multiple = this.hasAttribute("multiple") || Boolean(this.slotSelectDefaults?.multiple);
|
|
86
|
-
if (name === "form")
|
|
87
|
-
value === null ? select.removeAttribute("form") : select.setAttribute("form", value);
|
|
88
|
-
if (name === "auto-complete")
|
|
89
|
-
value === null ? select.removeAttribute("autocomplete") : select.setAttribute("autocomplete", value);
|
|
90
|
-
if (name === "aria-label" || name === "aria-labelledby" || name === "aria-description" || name === "aria-describedby" || name === "aria-invalid")
|
|
91
|
-
value === null ? select.removeAttribute(name) : select.setAttribute(name, value);
|
|
92
|
-
if (name === "value")
|
|
93
|
-
select.value = this.currentValue ?? "";
|
|
94
|
-
if (name === "default-value" && this.currentValue !== undefined)
|
|
95
|
-
select.value = this.currentValue;
|
|
96
|
-
if (name === "appearance" || name === "size") {
|
|
97
|
-
this.render();
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
this.syncFormValue(select);
|
|
101
|
-
}
|
|
102
|
-
focus(options) { this.getSelect()?.focus(options); }
|
|
103
|
-
blur() { this.getSelect()?.blur(); }
|
|
104
|
-
get value() { return this.currentValue ?? this.getAttribute("value") ?? this.getSelect()?.value ?? ""; }
|
|
105
|
-
set value(value) {
|
|
106
|
-
this.currentValue = value;
|
|
107
|
-
const select = this.getSelect();
|
|
108
|
-
if (select) {
|
|
109
|
-
select.value = value;
|
|
110
|
-
this.syncFormValue(select);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
get defaultValue() { return this.getAttribute("default-value") ?? ""; }
|
|
114
|
-
set defaultValue(value) { this.setAttribute("default-value", value); }
|
|
115
|
-
formDisabledCallback(disabled) {
|
|
116
|
-
this.formDisabled = disabled;
|
|
117
|
-
this.syncOptions();
|
|
118
|
-
}
|
|
119
|
-
formResetCallback() {
|
|
120
|
-
const select = this.getSelect();
|
|
121
|
-
if (select?.multiple) {
|
|
122
|
-
this.currentValue = undefined;
|
|
123
|
-
for (const option of [...select.options])
|
|
124
|
-
option.selected = this.initialSelectedValues?.has(option.value) ?? option.defaultSelected;
|
|
125
|
-
this.syncFormValue(select);
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
const options = [...this.querySelectorAll("option")];
|
|
129
|
-
this.value = this.getAttribute("value") ?? this.getAttribute("default-value") ?? this.initialSelectedValues?.values().next().value ?? options.find(option => option.hasAttribute("selected"))?.value ?? options[0]?.value ?? "";
|
|
130
|
-
}
|
|
131
|
-
formStateRestoreCallback(state) { if (typeof state === "string")
|
|
132
|
-
this.value = state; }
|
|
133
|
-
syncFormValue(select) {
|
|
134
|
-
syncHostAccessibleName(this, select);
|
|
135
|
-
const value = select.multiple
|
|
136
|
-
? [...select.selectedOptions].reduce((data, option) => { const name = this.getAttribute("name"); if (name)
|
|
137
|
-
data.append(name, option.value); return data; }, new FormData())
|
|
138
|
-
: select.value;
|
|
139
|
-
this.internals?.setFormValue(value);
|
|
140
|
-
try {
|
|
141
|
-
this.internals?.setValidity(select.validity.valid ? {} : { valueMissing: select.validity.valueMissing }, select.validationMessage, select);
|
|
142
|
-
}
|
|
143
|
-
catch { /* Older engines can omit custom-element validity anchors. */ }
|
|
144
|
-
}
|
|
145
|
-
syncTabIndex(select) {
|
|
146
|
-
const fallback = select.classList.contains("select-fallback");
|
|
147
|
-
if (!fallback && !this.slotSelectTabIndexCaptured) {
|
|
148
|
-
this.slotSelectTabIndex = select.tabIndex;
|
|
149
|
-
this.slotSelectTabIndexCaptured = true;
|
|
150
|
-
}
|
|
151
|
-
select.tabIndex = this.requestedTabIndex ?? (fallback ? 0 : this.slotSelectTabIndex ?? select.tabIndex);
|
|
152
|
-
if (this.requestedTabIndex !== undefined && this.requestedTabIndex !== -1 && this.getAttribute("tabindex") !== "-1") {
|
|
153
|
-
this.normalizingTabIndex = true;
|
|
154
|
-
this.setAttribute("tabindex", "-1");
|
|
155
|
-
this.normalizingTabIndex = false;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
syncOptions() {
|
|
159
|
-
const select = this.getSelect();
|
|
160
|
-
if (!select)
|
|
161
|
-
return;
|
|
162
|
-
if (!select.classList.contains("select-fallback"))
|
|
163
|
-
this.slotSelectDefaults = rememberNativeFormControlDefaults(this.slotSelectDefaults, select);
|
|
164
|
-
const defaults = select.classList.contains("select-fallback") ? undefined : this.slotSelectDefaults;
|
|
165
|
-
if (select.classList.contains("select-fallback")) {
|
|
166
|
-
const priorValue = this.currentValue ?? select.value;
|
|
167
|
-
const sourceOptions = [...this.querySelectorAll("option")];
|
|
168
|
-
const sourceSelectedValues = new Set(sourceOptions.filter(option => option.selected).map(option => option.value));
|
|
169
|
-
if (!this.initialSelectedValues && sourceOptions.length > 0)
|
|
170
|
-
this.initialSelectedValues = sourceSelectedValues;
|
|
171
|
-
const priorValues = select.multiple ? new Set([...select.selectedOptions].map(option => option.value)) : undefined;
|
|
172
|
-
select.replaceChildren(...this.cloneOptionContent());
|
|
173
|
-
select.disabled = this.formDisabled || this.hasAttribute("disabled");
|
|
174
|
-
select.required = this.hasAttribute("required");
|
|
175
|
-
select.multiple = this.hasAttribute("multiple");
|
|
176
|
-
if (this.hasAttribute("form"))
|
|
177
|
-
select.setAttribute("form", this.getAttribute("form"));
|
|
178
|
-
else
|
|
179
|
-
select.removeAttribute("form");
|
|
180
|
-
if (this.hasAttribute("auto-complete"))
|
|
181
|
-
select.setAttribute("autocomplete", this.getAttribute("auto-complete"));
|
|
182
|
-
else
|
|
183
|
-
select.removeAttribute("autocomplete");
|
|
184
|
-
for (const name of ["aria-label", "aria-labelledby", "aria-description", "aria-describedby", "aria-invalid"]) {
|
|
185
|
-
const value = this.getAttribute(name);
|
|
186
|
-
if (value === null)
|
|
187
|
-
select.removeAttribute(name);
|
|
188
|
-
else
|
|
189
|
-
select.setAttribute(name, value);
|
|
190
|
-
}
|
|
191
|
-
if (this.getAttribute("label") && !select.hasAttribute("aria-label") && !select.hasAttribute("aria-labelledby"))
|
|
192
|
-
select.setAttribute("aria-label", this.getAttribute("label"));
|
|
193
|
-
if (priorValues) {
|
|
194
|
-
const selectedValues = priorValues.size > 0 ? priorValues : this.initialSelectedValues ?? sourceSelectedValues;
|
|
195
|
-
for (const option of [...select.options])
|
|
196
|
-
option.selected = selectedValues.has(option.value);
|
|
197
|
-
}
|
|
198
|
-
else if (this.initialSelectedValues?.size) {
|
|
199
|
-
select.value = this.initialSelectedValues.values().next().value ?? priorValue;
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
select.value = priorValue;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
select.disabled = this.formDisabled || this.hasAttribute("disabled") || Boolean(defaults?.disabled);
|
|
207
|
-
select.required = this.hasAttribute("required") || Boolean(defaults?.required);
|
|
208
|
-
select.multiple = this.hasAttribute("multiple") || Boolean(defaults?.multiple);
|
|
209
|
-
if (this.hasAttribute("auto-complete") && !select.hasAttribute("autocomplete"))
|
|
210
|
-
select.setAttribute("autocomplete", this.getAttribute("auto-complete"));
|
|
211
|
-
if (this.hasAttribute("name"))
|
|
212
|
-
select.removeAttribute("name");
|
|
213
|
-
for (const name of ["aria-label", "aria-labelledby", "aria-description", "aria-describedby", "aria-invalid"]) {
|
|
214
|
-
if (select.hasAttribute(name))
|
|
215
|
-
continue;
|
|
216
|
-
const value = this.getAttribute(name);
|
|
217
|
-
if (value !== null)
|
|
218
|
-
select.setAttribute(name, value);
|
|
219
|
-
}
|
|
220
|
-
if (this.getAttribute("label") && !select.hasAttribute("aria-label") && !select.hasAttribute("aria-labelledby"))
|
|
221
|
-
select.setAttribute("aria-label", this.getAttribute("label"));
|
|
222
|
-
if (this.currentValue !== undefined || this.hasAttribute("value") || this.hasAttribute("default-value"))
|
|
223
|
-
select.value = this.currentValue ?? this.getAttribute("value") ?? this.getAttribute("default-value") ?? "";
|
|
224
|
-
}
|
|
225
|
-
this.syncTabIndex(select);
|
|
226
|
-
if (this.boundSelect !== select) {
|
|
227
|
-
this.boundSelect?.removeEventListener("change", this.handleSelectChange);
|
|
228
|
-
select.addEventListener("change", this.handleSelectChange);
|
|
229
|
-
this.boundSelect = select;
|
|
230
|
-
}
|
|
231
|
-
this.syncFormValue(select);
|
|
232
|
-
}
|
|
233
|
-
render() {
|
|
234
|
-
const shadow = this.shadowRoot ?? this.attachShadow({ mode: "open" });
|
|
235
|
-
const id = `select-${crypto.randomUUID()}`;
|
|
236
|
-
const label = document.createElement("label");
|
|
237
|
-
label.htmlFor = id;
|
|
238
|
-
label.textContent = this.getAttribute("label") ?? "";
|
|
239
|
-
label.part.add("label");
|
|
240
|
-
const select = document.createElement("select");
|
|
241
|
-
select.className = "select-fallback";
|
|
242
|
-
select.id = id;
|
|
243
|
-
select.part.add("control");
|
|
244
|
-
select.disabled = this.hasAttribute("disabled");
|
|
245
|
-
select.required = this.hasAttribute("required");
|
|
246
|
-
select.multiple = this.hasAttribute("multiple");
|
|
247
|
-
if (this.hasAttribute("form"))
|
|
248
|
-
select.setAttribute("form", this.getAttribute("form"));
|
|
249
|
-
if (this.hasAttribute("auto-complete"))
|
|
250
|
-
select.setAttribute("autocomplete", this.getAttribute("auto-complete"));
|
|
251
|
-
for (const name of ["aria-label", "aria-labelledby", "aria-description", "aria-describedby", "aria-invalid"]) {
|
|
252
|
-
const value = this.getAttribute(name);
|
|
253
|
-
if (value !== null)
|
|
254
|
-
select.setAttribute(name, value);
|
|
255
|
-
}
|
|
256
|
-
select.append(...this.cloneOptionContent());
|
|
257
|
-
if (this.currentValue !== undefined || this.hasAttribute("value") || this.hasAttribute("default-value"))
|
|
258
|
-
select.value = this.currentValue ?? this.getAttribute("value") ?? this.getAttribute("default-value") ?? "";
|
|
259
|
-
const control = document.createElement("span");
|
|
260
|
-
control.className = "control";
|
|
261
|
-
const selectSlot = document.createElement("slot");
|
|
262
|
-
selectSlot.name = "select";
|
|
263
|
-
selectSlot.part.add("select");
|
|
264
|
-
selectSlot.append(select);
|
|
265
|
-
selectSlot.addEventListener("slotchange", () => this.syncOptions());
|
|
266
|
-
const icon = document.createElement("slot");
|
|
267
|
-
icon.name = "icon";
|
|
268
|
-
icon.part.add("icon");
|
|
269
|
-
icon.setAttribute("aria-hidden", "true");
|
|
270
|
-
const fallbackIcon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
271
|
-
fallbackIcon.setAttribute("viewBox", "0 0 20 20");
|
|
272
|
-
fallbackIcon.setAttribute("width", "20");
|
|
273
|
-
fallbackIcon.setAttribute("height", "20");
|
|
274
|
-
fallbackIcon.setAttribute("fill", "none");
|
|
275
|
-
fallbackIcon.setAttribute("aria-hidden", "true");
|
|
276
|
-
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
277
|
-
path.setAttribute("d", "m5 7.5 5 5 5-5");
|
|
278
|
-
path.setAttribute("stroke", "currentColor");
|
|
279
|
-
path.setAttribute("stroke-width", "1.5");
|
|
280
|
-
fallbackIcon.append(path);
|
|
281
|
-
icon.append(fallbackIcon);
|
|
282
|
-
control.append(selectSlot, icon);
|
|
283
|
-
const style = document.createElement("style");
|
|
284
|
-
style.textContent = `${base}:host{display:grid;gap:var(--spui-control-gap,6px)}label{font-size:14px;font-weight:600;color:var(--spui-ui-muted,var(--spui-semantic-body-text,inherit))}.control{position:relative;min-width:0}select{box-sizing:border-box;width:100%;min-height:var(--spui-control-height,36px);padding-inline:var(--spui-control-padding-inline,12px);padding-inline-end:36px;appearance:none;border:1px solid var(--spui-control-border,var(--spui-ui-stroke,var(--spui-semantic-input-border,var(--colorNeutralStroke1,#8a8886))));border-radius:var(--spui-control-radius,4px);background:var(--spui-control-background,var(--spui-ui-surface,var(--spui-semantic-input-background,var(--colorNeutralBackground1,#fff))));box-shadow:var(--spui-control-shadow,none);color:var(--spui-ui-text,var(--spui-semantic-body-text,inherit));font:inherit}:host([size=small]) select{min-height:24px;font-size:var(--spui-text-font-size-small,12px)}:host([size=large]) select{min-height:40px;font-size:var(--spui-text-font-size-large,18px)}:host([appearance=underline]) select{border-width:0 0 1px;border-radius:0}:host([appearance=filled-darker]) select{background:var(--colorNeutralBackground3,var(--spui-ui-surface-sunken,#f0f0f0));border-color:transparent}:host([appearance=filled-lighter]) select{background:var(--colorNeutralBackground2,var(--spui-ui-surface-hover,#f5f5f5));border-color:transparent}slot[name=icon]{position:absolute;inset-inline-end:8px;top:50%;display:grid;place-items:center;width:20px;height:20px;transform:translateY(-50%);color:var(--spui-ui-muted,var(--spui-ui-text,#424242));pointer-events:none}slot[name=icon]::slotted(*){width:20px;height:20px}select:focus-visible{outline:2px solid var(--spui-focus-ring,var(--colorStrokeFocus2,#005a9e));outline-offset:2px}select:disabled{opacity:.55}@media(forced-colors:active){select{border-color:FieldText}slot[name=icon]{color:ButtonText}select:focus-visible{outline-color:Highlight}}`;
|
|
285
|
-
style.textContent += `slot[name=select]{display:block}slot[name=select]::slotted(select){box-sizing:border-box;width:100%;min-height:var(--spui-control-height,36px);padding-inline:var(--spui-control-padding-inline,12px);padding-inline-end:36px;appearance:none;border:1px solid var(--spui-control-border,var(--spui-ui-stroke,var(--colorNeutralStroke1,#8a8886)));border-radius:var(--spui-control-radius,4px);background:var(--spui-control-background,var(--spui-ui-surface,#fff));color:var(--spui-ui-text,inherit);font:inherit}:host([size=small]) slot[name=select]::slotted(select){min-height:24px;font-size:var(--spui-text-font-size-small,12px)}:host([size=large]) slot[name=select]::slotted(select){min-height:40px;font-size:var(--spui-text-font-size-large,18px)}:host([appearance=underline]) slot[name=select]::slotted(select){border-width:0 0 1px;border-radius:0}:host([appearance=filled-darker]) slot[name=select]::slotted(select){background:var(--colorNeutralBackground3,var(--spui-ui-surface-sunken,#f0f0f0));border-color:transparent}:host([appearance=filled-lighter]) slot[name=select]::slotted(select){background:var(--colorNeutralBackground2,var(--spui-ui-surface-hover,#f5f5f5));border-color:transparent}slot[name=select]::slotted(select:focus-visible){outline:2px solid var(--spui-focus-ring,var(--colorStrokeFocus2,#005a9e));outline-offset:2px}slot[name=select]::slotted(select:disabled){opacity:.55}@media(forced-colors:active){slot[name=select]::slotted(select){border-color:FieldText}slot[name=select]::slotted(select:focus-visible){outline-color:Highlight}}`;
|
|
286
|
-
shadow.replaceChildren(style, label, control);
|
|
287
|
-
this.syncOptions();
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
customElements.define("spui-select", SpuiSelect);
|
|
291
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare const base = ":host{font:inherit;font-family:var(--spui-font-family,inherit);color:var(--spui-ui-text,var(--spui-semantic-body-text,var(--colorNeutralForeground1,#323130)));color-scheme:var(--spui-color-scheme,light dark)}button,input,textarea{font:inherit;font-family:var(--spui-font-family,inherit)}button:focus-visible,input:focus-visible,textarea:focus-visible{outline:2px solid var(--spui-focus-ring,var(--spui-semantic-focus-border,var(--colorStrokeFocus2,#005a9e)));outline-offset:2px}";
|
|
2
|
-
export type NativeFormControl = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
|
|
3
|
-
export type NativeFormControlDefaults = {
|
|
4
|
-
control: NativeFormControl;
|
|
5
|
-
disabled: boolean;
|
|
6
|
-
required: boolean;
|
|
7
|
-
readOnly: boolean;
|
|
8
|
-
multiple: boolean;
|
|
9
|
-
value: string;
|
|
10
|
-
defaultValue: string;
|
|
11
|
-
checked: boolean;
|
|
12
|
-
defaultChecked: boolean;
|
|
13
|
-
};
|
|
14
|
-
export declare function stopHostAccessibleNameSync(host: HTMLElement): void;
|
|
15
|
-
export declare function observeAccessibleTextFromIdRefs(context: HTMLElement, labelledBy: string, onText: (text: string) => void): Pick<MutationObserver, "disconnect">;
|
|
16
|
-
export declare function resolveAccessibleTextFromIdRefs(context: HTMLElement | Document, labelledBy: string): string;
|
|
17
|
-
export declare function syncHostAccessibleName(host: HTMLElement, control: HTMLElement): void;
|
|
18
|
-
export declare function rememberNativeFormControlDefaults(current: NativeFormControlDefaults | undefined, control: NativeFormControl): NativeFormControlDefaults;
|
|
19
|
-
export declare function findFocusable(root: ParentNode): HTMLElement | undefined;
|