@skf-design-system/ui-components 0.0.1-beta.4 → 1.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/accordion/accordion.component.d.ts +9 -5
- package/dist/components/accordion/accordion.component.js +22 -19
- package/dist/components/accordion/accordion.d.ts +1 -1
- package/dist/components/accordion/accordion.styles.js +3 -3
- package/dist/components/alert/alert.component.d.ts +7 -4
- package/dist/components/alert/alert.component.js +1 -1
- package/dist/components/alert/alert.styles.js +1 -1
- package/dist/components/button/button.component.js +1 -1
- package/dist/components/button/button.styles.js +1 -1
- package/dist/components/card/card.component.d.ts +3 -3
- package/dist/components/card/card.component.js +16 -19
- package/dist/components/card/card.styles.js +11 -3
- package/dist/components/checkbox/checkbox.component.d.ts +9 -6
- package/dist/components/checkbox/checkbox.component.js +8 -8
- package/dist/components/checkbox/checkbox.styles.js +1 -1
- package/dist/components/checkbox/checkbox.test.d.ts +1 -0
- package/dist/components/collapse/collapse.component.d.ts +9 -6
- package/dist/components/collapse/collapse.component.js +39 -36
- package/dist/components/collapse/collapse.styles.js +3 -3
- package/dist/components/collapse/collapse.test.d.ts +1 -0
- package/dist/components/divider/divider.component.d.ts +13 -10
- package/dist/components/divider/divider.component.js +34 -29
- package/dist/components/divider/divider.styles.js +1 -5
- package/dist/components/heading/heading.component.d.ts +12 -2
- package/dist/components/heading/heading.component.js +14 -14
- package/dist/components/heading/heading.styles.js +1 -1
- package/dist/components/icon/icon.component.d.ts +14 -8
- package/dist/components/icon/icon.component.js +6 -6
- package/dist/components/icon/icon.styles.js +1 -1
- package/dist/components/input/input.component.d.ts +34 -29
- package/dist/components/input/input.component.js +36 -36
- package/dist/components/link/link.component.d.ts +15 -12
- package/dist/components/link/link.component.js +7 -7
- package/dist/components/link/link.styles.js +1 -1
- package/dist/components/loader/loader.component.d.ts +7 -7
- package/dist/components/loader/loader.component.js +35 -61
- package/dist/components/loader/loader.styles.js +42 -10
- package/dist/components/logo/logo.component.d.ts +5 -3
- package/dist/components/logo/logo.component.js +8 -8
- package/dist/components/logo/logo.styles.js +2 -2
- package/dist/components/radio/radio.component.d.ts +15 -13
- package/dist/components/radio/radio.component.js +3 -3
- package/dist/components/radio/radio.styles.js +3 -3
- package/dist/components/select/select.component.d.ts +137 -0
- package/dist/components/select/select.component.js +311 -0
- package/dist/components/select/select.controllers.d.ts +59 -0
- package/dist/components/select/select.controllers.js +169 -0
- package/dist/components/select/select.d.ts +8 -0
- package/dist/components/select/select.js +6 -0
- package/dist/components/select/select.styles.d.ts +1 -0
- package/dist/components/select/select.styles.js +116 -0
- package/dist/components/select-option/select-option.component.d.ts +77 -0
- package/dist/components/select-option/select-option.component.js +117 -0
- package/dist/components/select-option/select-option.controllers.d.ts +9 -0
- package/dist/components/select-option/select-option.d.ts +8 -0
- package/dist/components/select-option/select-option.js +6 -0
- package/dist/components/select-option/select-option.styles.d.ts +1 -0
- package/dist/components/select-option/select-option.styles.js +53 -0
- package/dist/components/select-option-group/select-option-group.component.d.ts +16 -0
- package/dist/components/select-option-group/select-option-group.component.js +31 -0
- package/dist/components/select-option-group/select-option-group.d.ts +8 -0
- package/dist/components/select-option-group/select-option-group.js +6 -0
- package/dist/components/select-option-group/select-option-group.style.d.ts +1 -0
- package/dist/components/select-option-group/select-option-group.style.js +18 -0
- package/dist/components/switch/switch.component.d.ts +2 -3
- package/dist/components/switch/switch.component.js +1 -1
- package/dist/components/switch/switch.styles.js +1 -1
- package/dist/components/switch/switch.test.d.ts +1 -0
- package/dist/components/tag/tag.component.d.ts +25 -4
- package/dist/components/tag/tag.component.js +66 -29
- package/dist/components/tag/tag.styles.js +6 -5
- package/dist/components/textarea/textarea.component.d.ts +26 -23
- package/dist/components/textarea/textarea.component.js +15 -12
- package/dist/custom-elements.json +960 -305
- package/dist/index.d.ts +3 -0
- package/dist/index.js +39 -30
- package/dist/internal/components/formBase.d.ts +18 -1
- package/dist/internal/components/formBase.js +25 -13
- package/dist/internal/components/skf-element.d.ts +4 -4
- package/dist/internal/components/skf-element.js +15 -19
- package/dist/internal/helpers/array.d.ts +4 -0
- package/dist/internal/helpers/findMatchingTags.d.ts +2 -0
- package/dist/internal/helpers/findMatchingTags.js +12 -0
- package/dist/internal/helpers/hintSeverity.d.ts +2 -0
- package/dist/internal/helpers/hintSeverity.js +6 -0
- package/dist/internal/helpers/raiseError.d.ts +28 -0
- package/dist/internal/helpers/raiseError.js +29 -0
- package/dist/internal/storybook/shadowRootTraverser.d.ts +16 -6
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.js +3 -0
- package/dist/react/skf-select/index.d.ts +21 -0
- package/dist/react/skf-select/index.js +21 -0
- package/dist/react/skf-select-option/index.d.ts +9 -0
- package/dist/react/skf-select-option/index.js +17 -0
- package/dist/react/skf-select-option-group/index.d.ts +3 -0
- package/dist/react/skf-select-option-group/index.js +13 -0
- package/dist/styles/form-field.styles.js +7 -7
- package/dist/types/jsx/custom-element-jsx.d.ts +290 -140
- package/dist/types/vue/index.d.ts +223 -90
- package/dist/vscode.html-custom-data.json +294 -97
- package/dist/web-types.json +614 -242
- package/package.json +34 -30
@@ -0,0 +1,311 @@
|
|
1
|
+
import { computePosition as f, flip as v, shift as _, offset as g } from "@floating-ui/dom";
|
2
|
+
import { FormBase as b } from "../../internal/components/formBase.js";
|
3
|
+
import { findMatchingTags as y } from "../../internal/helpers/findMatchingTags.js";
|
4
|
+
import { hintSeverity as O } from "../../internal/helpers/hintSeverity.js";
|
5
|
+
import { raiseError as S } from "../../internal/helpers/raiseError.js";
|
6
|
+
import { Asterisk as w } from "../../internal/templates/asterisk.js";
|
7
|
+
import x from "../../styles/component.styles.js";
|
8
|
+
import { html as h, nothing as $ } from "lit";
|
9
|
+
import { property as r, state as d, query as p } from "lit/decorators.js";
|
10
|
+
import { classMap as V } from "lit/directives/class-map.js";
|
11
|
+
import { ifDefined as m } from "lit/directives/if-defined.js";
|
12
|
+
import "../../internal/components/hint/hint.js";
|
13
|
+
import "../tag/tag.js";
|
14
|
+
import { ScrollController as C, ResizeController as A, GlobalClickController as E, KeyboardNavigationController as k, DeveloperFeedbackController as L } from "./select.controllers.js";
|
15
|
+
import { styles as P } from "./select.styles.js";
|
16
|
+
var D = Object.defineProperty, M = Object.getOwnPropertyDescriptor, l = (u, t, e, s) => {
|
17
|
+
for (var o = s > 1 ? void 0 : s ? M(t, e) : t, n = u.length - 1, a; n >= 0; n--)
|
18
|
+
(a = u[n]) && (o = (s ? a(t, e, o) : a(o)) || o);
|
19
|
+
return s && o && D(t, e, o), o;
|
20
|
+
};
|
21
|
+
const c = class c extends b {
|
22
|
+
constructor() {
|
23
|
+
super(), this.selectDelay = 200, this._optionsList = [], this.buttonLabel = "Select an option", this.size = "md", this._expanded = !1, this._invalid = !1, this.scrollController = new C(this), this.resizeController = new A(this), this.globalClickController = new E(this), this.keyboardNavController = new k(this), this.developerFeedbackController = new L(this), this._handleOptionSelected = (t) => {
|
24
|
+
this._pristine = !1;
|
25
|
+
const e = this._selectedOptions.length > 0;
|
26
|
+
this.setFormValue(e ? this.getSelectedValues.join(",") : null), this._updateState(t);
|
27
|
+
}, this._handleReset = () => {
|
28
|
+
this.emitEvent("reset"), this._resetSelectedOptions();
|
29
|
+
}, this._updateWidth = () => {
|
30
|
+
setTimeout(() => {
|
31
|
+
var t;
|
32
|
+
(t = this.$dropdown) == null || t.style.setProperty("--select-width", `${String(this.offsetWidth)}px`);
|
33
|
+
}, 50);
|
34
|
+
}, this._managePopover = () => ({ close: () => {
|
35
|
+
var s;
|
36
|
+
(s = this.$dropdown) == null || s.hidePopover();
|
37
|
+
}, open: () => {
|
38
|
+
const s = this.$selectBtn, o = this.$dropdown;
|
39
|
+
!s || !o || (o.showPopover(), f(s, o, {
|
40
|
+
placement: "bottom",
|
41
|
+
middleware: [v(), _({ padding: 5 }), g(2)]
|
42
|
+
}).then(({ x: n, y: a }) => {
|
43
|
+
Object.assign(o.style, {
|
44
|
+
left: `${String(n)}px`,
|
45
|
+
top: `${String(Math.round(a - window.scrollY))}px`
|
46
|
+
});
|
47
|
+
}).catch((n) => {
|
48
|
+
console.error(n);
|
49
|
+
}));
|
50
|
+
} }), this._handleDropdownToggle = (t) => {
|
51
|
+
t.stopPropagation(), this._expanded = !this._expanded;
|
52
|
+
}, this._setValue = async () => new Promise((t) => {
|
53
|
+
switch (!0) {
|
54
|
+
case this._selectedOptions.length === 0:
|
55
|
+
this.setFormValue(null), this.requestUpdate();
|
56
|
+
break;
|
57
|
+
case this._selectedOptions.length === 1:
|
58
|
+
this.setFormValue(this.getSelectedValues[0]);
|
59
|
+
break;
|
60
|
+
case this._selectedOptions.length > 1:
|
61
|
+
this.setFormValue(this.getSelectedValues.join(","));
|
62
|
+
break;
|
63
|
+
default:
|
64
|
+
throw new Error("Something went wrong");
|
65
|
+
}
|
66
|
+
this.emitEvent("change"), this._validateInput(), this.$selectedValue && (this.$selectedValue.animate([{ opacity: 0.5 }, { opacity: 1 }], this.selectDelay).onfinish = () => {
|
67
|
+
this.multiple || (this._expanded = !1), t("done");
|
68
|
+
});
|
69
|
+
}), this._resetSelectedOptions = (t) => {
|
70
|
+
const e = !t;
|
71
|
+
this._optionsList.forEach((s) => {
|
72
|
+
(e || s !== t) && s.removeAttribute("selected");
|
73
|
+
});
|
74
|
+
}, this._handleSlotChange = () => {
|
75
|
+
this._collectSlotOptionTags(), this._validateInput();
|
76
|
+
}, this._computeVisibleValue = () => {
|
77
|
+
var t, e;
|
78
|
+
return (t = this.$selectedValue) == null || t.classList.add("contains-meta-info"), this._selectedOptions.length > 1 ? `(${String(this._selectedOptions.length)} items selected)` : this.value ? ((e = this.$selectedValue) == null || e.classList.remove("contains-meta-info"), this.value) : this.buttonLabel;
|
79
|
+
}, this._selectedOptions = [];
|
80
|
+
}
|
81
|
+
get getSelectedValues() {
|
82
|
+
return this._selectedOptions.map((t) => t.value.trim());
|
83
|
+
}
|
84
|
+
get getSelectedOptionsText() {
|
85
|
+
return this._selectedOptions.map((t) => t.textContent);
|
86
|
+
}
|
87
|
+
get value() {
|
88
|
+
return this._selectedOptions.length ? this._selectedOptions.length === 1 ? this._selectedOptions[0].value.trim() : this._selectedOptions.map((t) => t.value.trim()).join(",") : "";
|
89
|
+
}
|
90
|
+
set selectedOptions(t) {
|
91
|
+
if (!t.length) {
|
92
|
+
this._selectedOptions = [];
|
93
|
+
return;
|
94
|
+
}
|
95
|
+
this._selectedOptions = t;
|
96
|
+
}
|
97
|
+
/** @internal */
|
98
|
+
get selectedOptions() {
|
99
|
+
return this._selectedOptions;
|
100
|
+
}
|
101
|
+
willUpdate(t) {
|
102
|
+
if (t.has("_expanded")) {
|
103
|
+
const e = !!t.get("_expanded") && !this._expanded;
|
104
|
+
this._pristine && e && (this._pristine = !1);
|
105
|
+
}
|
106
|
+
if (t.has("_invalid"))
|
107
|
+
if (this._invalid) {
|
108
|
+
this.setAttribute("invalid", ""), this.showValid && this.removeAttribute("valid");
|
109
|
+
const e = this._internals.validationMessage;
|
110
|
+
this.hint = e !== "" ? this._internals.validationMessage : "", this.checkValidity(), this.emitEvent("invalid");
|
111
|
+
} else
|
112
|
+
this.removeAttribute("invalid"), !this._pristine && this.showValid && this.setAttribute("valid", "true"), this.hint = this.getAttribute("hint") ?? "";
|
113
|
+
}
|
114
|
+
firstUpdated() {
|
115
|
+
var t;
|
116
|
+
this.addEventListener("skf-select-option:select", this._handleOptionSelected), (t = this._internals.form) == null || t.addEventListener("reset", this._handleReset), this.onUpdateComplete(), this._collectSlotOptionTags(), this._validateInput();
|
117
|
+
}
|
118
|
+
updated(t) {
|
119
|
+
var e, s;
|
120
|
+
if (t.has("_expanded")) {
|
121
|
+
const o = !!t.get("_expanded") === this._expanded;
|
122
|
+
if (this.emit("skf-select:dropdown", { detail: { expanded: this._expanded } }), o) return;
|
123
|
+
this._expanded ? ((e = this.$selectBtn) == null || e.setAttribute("aria-expanded", "true"), this._managePopover().open()) : ((s = this.$selectBtn) == null || s.setAttribute("aria-expanded", "false"), this._managePopover().close());
|
124
|
+
}
|
125
|
+
}
|
126
|
+
attributeChangedCallback(t, e, s) {
|
127
|
+
if (super.attributeChangedCallback(t, e, s), t === "custom-invalid")
|
128
|
+
if (typeof s == "string") {
|
129
|
+
const n = String(s).trim() || "Custom error";
|
130
|
+
this._pristine = !1, this._invalid = !0, this.setValidity({ customError: !0 }, n), this.checkValidity();
|
131
|
+
} else
|
132
|
+
this.setValidity({}), this._validateInput();
|
133
|
+
}
|
134
|
+
disconnectedCallback() {
|
135
|
+
var t;
|
136
|
+
super.disconnectedCallback(), (t = this._internals.form) == null || t.removeEventListener("reset", this._handleReset);
|
137
|
+
}
|
138
|
+
/** @internal */
|
139
|
+
_updateState(t) {
|
140
|
+
if (this.multiple)
|
141
|
+
this._selectedOptions = [], this._optionsList.forEach((e) => {
|
142
|
+
e.selected && (this.selectedOptions = [...this.selectedOptions, e]);
|
143
|
+
});
|
144
|
+
else {
|
145
|
+
const e = this._selectedOptions.length > 0, s = t.detail.value !== null;
|
146
|
+
e && (this._selectedOptions[0].setSelectedDiscrete = !1, this._selectedOptions = []), s && (this.selectedOptions = [t.target]);
|
147
|
+
}
|
148
|
+
this._setValue();
|
149
|
+
}
|
150
|
+
/** @internal */
|
151
|
+
async onUpdateComplete() {
|
152
|
+
return await this.updateComplete, this._updateWidth(), "done";
|
153
|
+
}
|
154
|
+
/** @internal */
|
155
|
+
/** Filter out elements other than skf-select-option and store in this._optionsList */
|
156
|
+
_collectSlotOptionTags() {
|
157
|
+
this._optionsList = y(this, "skf-select-option"), this._selectedOptions = this._optionsList.filter((t) => t.selected), S({
|
158
|
+
assert: this._optionsList.length > 0,
|
159
|
+
reason: "no-children",
|
160
|
+
replaceStrings: [this.localName, "skf-select-option"]
|
161
|
+
});
|
162
|
+
}
|
163
|
+
/** @internal */
|
164
|
+
_validateInput() {
|
165
|
+
this._invalid = !1;
|
166
|
+
const t = this.required && !this.getSelectedValues.length || this.min === 1, e = !!(this.min && this.getSelectedValues.length < this.min), s = !!(this.max && this.getSelectedValues.length > this.max);
|
167
|
+
if (this._internals.validity.customError) {
|
168
|
+
this._invalid = !0;
|
169
|
+
return;
|
170
|
+
} else if (t) {
|
171
|
+
const n = this.hasAttribute("data-valuemissing") ? this.getAttribute("data-valuemissing") : "Please select an option";
|
172
|
+
this.setValidity({ valueMissing: !0 }, String(n)), this._pristine || (this._invalid = !0);
|
173
|
+
} else if (e) {
|
174
|
+
const n = this.hasAttribute("data-rangeunderflow") ? this.getAttribute("data-rangeunderflow") : `Please select minimum ${String(this.min)} options`;
|
175
|
+
this.setValidity({ rangeUnderflow: !0 }, String(n)), this._pristine || (this._invalid = !0);
|
176
|
+
} else if (s) {
|
177
|
+
const n = this.hasAttribute("data-rangeoverflow") ? this.getAttribute("data-rangeoverflow") : `Please select maximum ${String(this.max)} options`;
|
178
|
+
this.setValidity({ rangeOverflow: !0 }, String(n)), this._pristine || (this._invalid = !0);
|
179
|
+
} else
|
180
|
+
this.setValidity({}), !this._pristine && this.showValid && this.setAttribute("valid", "true");
|
181
|
+
}
|
182
|
+
render() {
|
183
|
+
return h`
|
184
|
+
<div id="root">
|
185
|
+
<label>
|
186
|
+
<div class=${this.hideLabel ? "visually-hidden" : ""} id="label">
|
187
|
+
${this.label}
|
188
|
+
${this.required ? w(this.requiredLabel) : null}
|
189
|
+
</div>
|
190
|
+
<button
|
191
|
+
?disabled=${this.disabled}
|
192
|
+
@click=${this._handleDropdownToggle}
|
193
|
+
aria-controls="select-dropdown"
|
194
|
+
aria-expanded="false"
|
195
|
+
aria-haspopup="listbox"
|
196
|
+
id="select-button"
|
197
|
+
role="combobox"
|
198
|
+
>
|
199
|
+
<span
|
200
|
+
id="selected-value"
|
201
|
+
class=${V({ "selected-value": !0, "contains-meta-info": !this.value })}>
|
202
|
+
${this._computeVisibleValue()}
|
203
|
+
</span>
|
204
|
+
<skf-icon class="arrow" name="chevronDown"></skf-icon>
|
205
|
+
</button>
|
206
|
+
</label>
|
207
|
+
<div aria-multiselectable=${m(this.multiple && !0)} id="select-dropdown" popover role="listbox">
|
208
|
+
<slot @slotchange=${this._handleSlotChange}></slot>
|
209
|
+
</div>
|
210
|
+
${!this.hideTags && this.multiple ? h`
|
211
|
+
<div id="tags">
|
212
|
+
${this.selectedOptions.map(
|
213
|
+
(t) => h`
|
214
|
+
<skf-tag
|
215
|
+
removable
|
216
|
+
.onRemove=${(e) => (e.stopPropagation(), e.preventDefault(), t.removeAttribute("selected"), !1)}
|
217
|
+
>
|
218
|
+
${t.textContent}
|
219
|
+
</skf-tag>
|
220
|
+
`
|
221
|
+
)}
|
222
|
+
</div>
|
223
|
+
` : $}
|
224
|
+
${this.hint && h`
|
225
|
+
<skf-hint
|
226
|
+
aria-live=${this._invalid ? "assertive" : "polite"}
|
227
|
+
id="hint"
|
228
|
+
severity=${m(O(this.severity, this._invalid))}
|
229
|
+
>
|
230
|
+
${this.customInvalid ? this.customInvalid : this.hint}
|
231
|
+
</skf-hint>
|
232
|
+
`}
|
233
|
+
</div>
|
234
|
+
</div>
|
235
|
+
`;
|
236
|
+
}
|
237
|
+
};
|
238
|
+
c.styles = [x, P];
|
239
|
+
let i = c;
|
240
|
+
l([
|
241
|
+
r({ type: String, reflect: !0, attribute: "button-label" })
|
242
|
+
], i.prototype, "buttonLabel", 2);
|
243
|
+
l([
|
244
|
+
r({ attribute: "custom-invalid" })
|
245
|
+
], i.prototype, "customInvalid", 2);
|
246
|
+
l([
|
247
|
+
r({ type: Boolean, attribute: "hide-label" })
|
248
|
+
], i.prototype, "hideLabel", 2);
|
249
|
+
l([
|
250
|
+
r({ type: Boolean, reflect: !0, attribute: "hide-tags" })
|
251
|
+
], i.prototype, "hideTags", 2);
|
252
|
+
l([
|
253
|
+
r()
|
254
|
+
], i.prototype, "hint", 2);
|
255
|
+
l([
|
256
|
+
r({ type: Array, attribute: !1 })
|
257
|
+
], i.prototype, "getSelectedValues", 1);
|
258
|
+
l([
|
259
|
+
r({ type: Array, attribute: !1 })
|
260
|
+
], i.prototype, "getSelectedOptionsText", 1);
|
261
|
+
l([
|
262
|
+
r({ reflect: !0 })
|
263
|
+
], i.prototype, "label", 2);
|
264
|
+
l([
|
265
|
+
r({ type: Number })
|
266
|
+
], i.prototype, "max", 2);
|
267
|
+
l([
|
268
|
+
r({ type: Number })
|
269
|
+
], i.prototype, "min", 2);
|
270
|
+
l([
|
271
|
+
r({ type: Boolean, reflect: !0 })
|
272
|
+
], i.prototype, "multiple", 2);
|
273
|
+
l([
|
274
|
+
r()
|
275
|
+
], i.prototype, "name", 2);
|
276
|
+
l([
|
277
|
+
r({ attribute: "required-label" })
|
278
|
+
], i.prototype, "requiredLabel", 2);
|
279
|
+
l([
|
280
|
+
r()
|
281
|
+
], i.prototype, "severity", 2);
|
282
|
+
l([
|
283
|
+
r({ type: Boolean, attribute: "show-valid" })
|
284
|
+
], i.prototype, "showValid", 2);
|
285
|
+
l([
|
286
|
+
r({ reflect: !0 })
|
287
|
+
], i.prototype, "size", 2);
|
288
|
+
l([
|
289
|
+
d()
|
290
|
+
], i.prototype, "value", 1);
|
291
|
+
l([
|
292
|
+
d()
|
293
|
+
], i.prototype, "selectedOptions", 1);
|
294
|
+
l([
|
295
|
+
d()
|
296
|
+
], i.prototype, "_expanded", 2);
|
297
|
+
l([
|
298
|
+
d()
|
299
|
+
], i.prototype, "_invalid", 2);
|
300
|
+
l([
|
301
|
+
p("#select-button")
|
302
|
+
], i.prototype, "$selectBtn", 2);
|
303
|
+
l([
|
304
|
+
p("#selected-value")
|
305
|
+
], i.prototype, "$selectedValue", 2);
|
306
|
+
l([
|
307
|
+
p("#select-dropdown")
|
308
|
+
], i.prototype, "$dropdown", 2);
|
309
|
+
export {
|
310
|
+
i as SkfSelect
|
311
|
+
};
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import type { SkfSelectOption } from '@components/select-option/select-option.component.js';
|
2
|
+
import type { ReactiveController } from 'lit';
|
3
|
+
import type { SkfSelect } from './select.component.js';
|
4
|
+
type ControllerHost = SkfSelect;
|
5
|
+
export declare class ScrollController implements ReactiveController {
|
6
|
+
_scrollHandler?: () => void;
|
7
|
+
host?: ControllerHost;
|
8
|
+
localExpanded: boolean;
|
9
|
+
constructor(host: ControllerHost);
|
10
|
+
hostDisconnected(): void;
|
11
|
+
hostUpdated(): void;
|
12
|
+
enableScrollDetection(): void;
|
13
|
+
disableScrollDetection(): void;
|
14
|
+
/** @internal */
|
15
|
+
_onScrollOutOfView(): void;
|
16
|
+
/** @internal */
|
17
|
+
_onScrollIntoView(): void;
|
18
|
+
}
|
19
|
+
export declare class ResizeController implements ReactiveController {
|
20
|
+
host: ControllerHost;
|
21
|
+
_resizeObserver?: ResizeObserver;
|
22
|
+
constructor(host: ControllerHost);
|
23
|
+
hostConnected(): void;
|
24
|
+
hostDisconnected(): void;
|
25
|
+
enableResizeObserver(): void;
|
26
|
+
disableResizeObserver(): void;
|
27
|
+
/** @internal */
|
28
|
+
_onResize: () => void;
|
29
|
+
}
|
30
|
+
export declare class GlobalClickController implements ReactiveController {
|
31
|
+
host: ControllerHost;
|
32
|
+
constructor(host: ControllerHost);
|
33
|
+
hostDisconnected(): void;
|
34
|
+
hostUpdated(): void;
|
35
|
+
_globalClickHandler: (event: MouseEvent) => void;
|
36
|
+
enableGlobalClickDetection(): void;
|
37
|
+
disableGlobalClickDetection(): void;
|
38
|
+
}
|
39
|
+
export declare class KeyboardNavigationController implements ReactiveController {
|
40
|
+
host: ControllerHost;
|
41
|
+
_listenerActivated: boolean;
|
42
|
+
constructor(host: ControllerHost);
|
43
|
+
hostDisconnected(): void;
|
44
|
+
hostUpdated(): void;
|
45
|
+
setupKeyboardListener(): void;
|
46
|
+
removeKeyboardListener(): void;
|
47
|
+
_handleKeyDown: (event: KeyboardEvent) => void;
|
48
|
+
_focusFirstOption(): void;
|
49
|
+
_focusSiblingOption(dir: 'next' | 'prev'): void;
|
50
|
+
_selectFocusedOption(target: SkfSelectOption): void;
|
51
|
+
get _selectableOptions(): SkfSelectOption[];
|
52
|
+
}
|
53
|
+
export declare class DeveloperFeedbackController implements ReactiveController {
|
54
|
+
host: ControllerHost;
|
55
|
+
constructor(host: ControllerHost);
|
56
|
+
hostConnected(): void;
|
57
|
+
_badAttributeCombinationWarning(): void;
|
58
|
+
}
|
59
|
+
export {};
|
@@ -0,0 +1,169 @@
|
|
1
|
+
import { raiseError as r } from "../../internal/helpers/raiseError.js";
|
2
|
+
class d {
|
3
|
+
constructor(e) {
|
4
|
+
this.localExpanded = !1, this.host = e, e.addController(this);
|
5
|
+
}
|
6
|
+
hostDisconnected() {
|
7
|
+
this.disableScrollDetection();
|
8
|
+
}
|
9
|
+
hostUpdated() {
|
10
|
+
var e, t, s;
|
11
|
+
((e = this.host) == null ? void 0 : e._expanded) !== this.localExpanded && (this.localExpanded = !!((t = this.host) != null && t._expanded), (s = this.host) != null && s._expanded ? this.enableScrollDetection() : this.disableScrollDetection());
|
12
|
+
}
|
13
|
+
enableScrollDetection() {
|
14
|
+
if (this._scrollHandler = () => {
|
15
|
+
if (!this.host) return;
|
16
|
+
this.host._expanded = !1;
|
17
|
+
const t = this.host.getBoundingClientRect();
|
18
|
+
t.top < 0 || t.bottom > window.innerHeight || t.left < 0 || t.right > window.innerWidth ? this._onScrollOutOfView() : this._onScrollIntoView();
|
19
|
+
}, window.addEventListener("scroll", this._scrollHandler, !0), !this.host) return;
|
20
|
+
let e = this.host.parentElement;
|
21
|
+
for (; e; )
|
22
|
+
(e.scrollHeight > e.clientHeight || e.scrollWidth > e.clientWidth) && e.addEventListener("scroll", this._scrollHandler, !0), e = e.parentElement;
|
23
|
+
}
|
24
|
+
disableScrollDetection() {
|
25
|
+
if (!this._scrollHandler || (window.removeEventListener("scroll", this._scrollHandler, !0), !this.host)) return;
|
26
|
+
let e = this.host.parentElement;
|
27
|
+
for (; e; )
|
28
|
+
(e.scrollHeight > e.clientHeight || e.scrollWidth > e.clientWidth) && e.removeEventListener("scroll", this._scrollHandler, !0), e = e.parentElement;
|
29
|
+
}
|
30
|
+
/** @internal */
|
31
|
+
_onScrollOutOfView() {
|
32
|
+
this.host && (this.host._expanded = !1);
|
33
|
+
}
|
34
|
+
/** @internal */
|
35
|
+
_onScrollIntoView() {
|
36
|
+
}
|
37
|
+
}
|
38
|
+
class b {
|
39
|
+
constructor(e) {
|
40
|
+
this._onResize = () => {
|
41
|
+
this.host._expanded = !1;
|
42
|
+
}, this.host = e, e.addController(this);
|
43
|
+
}
|
44
|
+
hostConnected() {
|
45
|
+
this.enableResizeObserver();
|
46
|
+
}
|
47
|
+
hostDisconnected() {
|
48
|
+
this.disableResizeObserver();
|
49
|
+
}
|
50
|
+
enableResizeObserver() {
|
51
|
+
this._resizeObserver = new ResizeObserver(() => {
|
52
|
+
this.host._expanded = !1, this.host._updateWidth();
|
53
|
+
}), this._resizeObserver.observe(document.body), this._resizeObserver.observe(this.host);
|
54
|
+
}
|
55
|
+
disableResizeObserver() {
|
56
|
+
var e;
|
57
|
+
(e = this._resizeObserver) == null || e.disconnect();
|
58
|
+
}
|
59
|
+
}
|
60
|
+
class p {
|
61
|
+
constructor(e) {
|
62
|
+
this._globalClickHandler = (t) => {
|
63
|
+
t.target.closest(this.host.localName) || (this.host._expanded = !1);
|
64
|
+
}, this.host = e, e.addController(this);
|
65
|
+
}
|
66
|
+
// hostConnected() {
|
67
|
+
// this.enableGlobalClickDetection();
|
68
|
+
// }
|
69
|
+
hostDisconnected() {
|
70
|
+
this.disableGlobalClickDetection();
|
71
|
+
}
|
72
|
+
hostUpdated() {
|
73
|
+
this.host._expanded ? this.enableGlobalClickDetection() : this.disableGlobalClickDetection();
|
74
|
+
}
|
75
|
+
enableGlobalClickDetection() {
|
76
|
+
document.addEventListener("click", this._globalClickHandler);
|
77
|
+
}
|
78
|
+
disableGlobalClickDetection() {
|
79
|
+
document.removeEventListener("click", this._globalClickHandler);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
class u {
|
83
|
+
constructor(e) {
|
84
|
+
this._handleKeyDown = (t) => {
|
85
|
+
switch (t.key) {
|
86
|
+
case "ArrowDown":
|
87
|
+
t.preventDefault(), this._focusSiblingOption("next");
|
88
|
+
break;
|
89
|
+
case "ArrowUp":
|
90
|
+
t.preventDefault(), this._focusSiblingOption("prev");
|
91
|
+
break;
|
92
|
+
case "Enter":
|
93
|
+
t.preventDefault(), this._selectFocusedOption(t.target);
|
94
|
+
break;
|
95
|
+
case "Escape":
|
96
|
+
t.preventDefault(), this.host._expanded = !1, setTimeout(() => {
|
97
|
+
this.host.focus();
|
98
|
+
});
|
99
|
+
break;
|
100
|
+
}
|
101
|
+
}, this.host = e, e.addController(this), this._listenerActivated = !1;
|
102
|
+
}
|
103
|
+
hostDisconnected() {
|
104
|
+
this.removeKeyboardListener();
|
105
|
+
}
|
106
|
+
hostUpdated() {
|
107
|
+
this.host._expanded && !this._listenerActivated && this.setupKeyboardListener(), !this.host._expanded && this._listenerActivated && this.removeKeyboardListener();
|
108
|
+
}
|
109
|
+
setupKeyboardListener() {
|
110
|
+
this._listenerActivated = !0, this.host.addEventListener("keydown", this._handleKeyDown);
|
111
|
+
}
|
112
|
+
removeKeyboardListener() {
|
113
|
+
this.host.removeEventListener("keydown", this._handleKeyDown), this._listenerActivated = !1;
|
114
|
+
}
|
115
|
+
_focusFirstOption() {
|
116
|
+
const e = this._selectableOptions[0];
|
117
|
+
setTimeout(() => {
|
118
|
+
e.focus();
|
119
|
+
});
|
120
|
+
}
|
121
|
+
_focusSiblingOption(e) {
|
122
|
+
const t = (n) => n === document.activeElement, s = this._selectableOptions.find((n) => t(n));
|
123
|
+
if (!s) {
|
124
|
+
this._focusFirstOption();
|
125
|
+
return;
|
126
|
+
}
|
127
|
+
const h = this._selectableOptions.indexOf(s);
|
128
|
+
let o = h - 1, l = h + 1;
|
129
|
+
o < 0 && (o = this._selectableOptions.length - 1), l >= this._selectableOptions.length && (l = 0);
|
130
|
+
const a = this._selectableOptions[e === "next" ? l : o];
|
131
|
+
s.blur(), a.focus();
|
132
|
+
}
|
133
|
+
_selectFocusedOption(e) {
|
134
|
+
e.selected = !0;
|
135
|
+
}
|
136
|
+
get _selectableOptions() {
|
137
|
+
return this.host._optionsList.filter((e) => !e.disabled);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
class _ {
|
141
|
+
constructor(e) {
|
142
|
+
this.host = e, e.addController(this);
|
143
|
+
}
|
144
|
+
hostConnected() {
|
145
|
+
this._badAttributeCombinationWarning();
|
146
|
+
}
|
147
|
+
_badAttributeCombinationWarning() {
|
148
|
+
r({
|
149
|
+
assert: (this.host.min ?? 0) < (this.host.max ?? 1 / 0),
|
150
|
+
reason: "attribute-mismatch",
|
151
|
+
replaceStrings: [this.host.localName, "min", "smaller than max"]
|
152
|
+
}), r({
|
153
|
+
assert: ((this.host.min ?? this.host.max) && this.host.multiple) ?? !(this.host.min && this.host.max),
|
154
|
+
reason: "attribute-mismatch",
|
155
|
+
replaceStrings: [this.host.localName, "min or max", "together with multiple"]
|
156
|
+
}), r({
|
157
|
+
assert: (this.host.hideTags && this.host.multiple) ?? !this.host.hideTags,
|
158
|
+
reason: "attribute-mismatch",
|
159
|
+
replaceStrings: [this.host.localName, "hide-tags", "together with multiple"]
|
160
|
+
});
|
161
|
+
}
|
162
|
+
}
|
163
|
+
export {
|
164
|
+
_ as DeveloperFeedbackController,
|
165
|
+
p as GlobalClickController,
|
166
|
+
u as KeyboardNavigationController,
|
167
|
+
b as ResizeController,
|
168
|
+
d as ScrollController
|
169
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const styles: import("lit").CSSResult[];
|
@@ -0,0 +1,116 @@
|
|
1
|
+
import { visuallyHidden as r } from "../../styles/util.styles.js";
|
2
|
+
import { css as o } from "lit";
|
3
|
+
const t = [
|
4
|
+
r,
|
5
|
+
o`
|
6
|
+
@layer components {
|
7
|
+
:host {
|
8
|
+
contain: initial;
|
9
|
+
}
|
10
|
+
|
11
|
+
#root {
|
12
|
+
color: var(--_skf-select-color, var(--skf-text-color-primary));
|
13
|
+
display: flex;
|
14
|
+
flex-direction: column;
|
15
|
+
gap: var(--skf-spacing-25);
|
16
|
+
|
17
|
+
:host([size='sm']) & {
|
18
|
+
font-size: var(--skf-font-size-75);
|
19
|
+
font-weight: var(--skf-font-weight-medium);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
label {
|
24
|
+
display: inherit;
|
25
|
+
flex-direction: inherit;
|
26
|
+
gap: var(--_skf-select-label-gap, var(--skf-spacing-50));
|
27
|
+
|
28
|
+
:host([size='sm']) & {
|
29
|
+
--_skf-select-label-gap: var(--skf-spacing-25);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
#asterisk {
|
34
|
+
color: var(--skf-severity-fg-color-error);
|
35
|
+
}
|
36
|
+
|
37
|
+
button {
|
38
|
+
align-items: center;
|
39
|
+
background-color: var(
|
40
|
+
--_skf-select-button-bg-color,
|
41
|
+
var(--skf-interactive-bg-color-secondary)
|
42
|
+
);
|
43
|
+
block-size: var(--_skf-select-button-height, var(--skf-size-44));
|
44
|
+
border: var(--skf-border-width-sm) solid
|
45
|
+
var(--_skf-select-button-border-color, var(--skf-border-color-primary));
|
46
|
+
border-radius: var(--skf-border-radius-sm);
|
47
|
+
display: flex;
|
48
|
+
gap: 0 var(--skf-spacing-75);
|
49
|
+
justify-content: space-between;
|
50
|
+
padding-inline: var(--skf-spacing-75);
|
51
|
+
|
52
|
+
&:hover {
|
53
|
+
--_skf-select-button-bg-color: var(--skf-interactive-bg-color-secondary-hover);
|
54
|
+
}
|
55
|
+
|
56
|
+
&:active {
|
57
|
+
--_skf-select-button-bg-color: var(--skf-interactive-bg-color-secondary-active);
|
58
|
+
}
|
59
|
+
|
60
|
+
&:disabled {
|
61
|
+
--_skf-select-button-bg-color: var(--skf-interactive-bg-color-disabled);
|
62
|
+
--_skf-select-button-border-color: var(--skf-interactive-border-color-disabled);
|
63
|
+
}
|
64
|
+
|
65
|
+
:host([invalid]) & {
|
66
|
+
--_skf-select-button-border-color: var(--skf-severity-fg-color-error);
|
67
|
+
}
|
68
|
+
|
69
|
+
:host([valid]) & {
|
70
|
+
--_skf-select-button-border-color: var(--skf-severity-fg-color-success);
|
71
|
+
}
|
72
|
+
|
73
|
+
:host :has(:focus-visible) & {
|
74
|
+
outline: var(--skf-border-width-md) solid var(--skf-interactive-border-color-focus);
|
75
|
+
outline-offset: -1px;
|
76
|
+
}
|
77
|
+
|
78
|
+
:host([size='sm']) & {
|
79
|
+
--_skf-select-button-height: var(--skf-size-32);
|
80
|
+
}
|
81
|
+
|
82
|
+
:host([severity='alert']:not([invalid], [valid])) & {
|
83
|
+
--_skf-select-button-border-color: var(--skf-severity-fg-color-alert);
|
84
|
+
}
|
85
|
+
|
86
|
+
:host([severity='info']:not([invalid], [valid])) & {
|
87
|
+
--_skf-select-button-border-color: var(--skf-severity-fg-color-info);
|
88
|
+
}
|
89
|
+
|
90
|
+
:host([severity='success']:not([invalid], [valid])) & {
|
91
|
+
--_skf-select-button-border-color: var(--skf-severity-fg-color-success);
|
92
|
+
}
|
93
|
+
|
94
|
+
:host([severity='warning']:not([invalid], [valid])) & {
|
95
|
+
--_skf-select-button-border-color: var(--skf-severity-fg-color-warning);
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
#select-dropdown {
|
100
|
+
background-color: var(--skf-bg-color-neutral-1);
|
101
|
+
border: var(--skf-border-width-sm) solid var(--skf-border-color-tertiary);
|
102
|
+
box-shadow: var(--skf-shadow-sm); /* TODO: Discuss with design */
|
103
|
+
inline-size: var(--select-width, auto);
|
104
|
+
padding: var(--skf-spacing-25);
|
105
|
+
}
|
106
|
+
|
107
|
+
#tags {
|
108
|
+
display: flex;
|
109
|
+
gap: 0.5rem;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
`
|
113
|
+
];
|
114
|
+
export {
|
115
|
+
t as styles
|
116
|
+
};
|