@skf-design-system/ui-components 1.0.0-beta.3 → 1.0.0-beta.5
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 +26 -6
- package/dist/components/alert/alert.component.js +20 -18
- package/dist/components/alert/alert.styles.js +50 -47
- package/dist/components/button/button.component.d.ts +2 -0
- package/dist/components/button/button.component.js +5 -5
- package/dist/components/checkbox/checkbox.styles.js +6 -1
- package/dist/components/icon/icon.styles.js +56 -54
- package/dist/components/input/input.component.d.ts +9 -0
- package/dist/components/input/input.component.js +32 -24
- package/dist/components/radio/radio.styles.js +7 -2
- package/dist/components/select/select.component.d.ts +5 -2
- package/dist/components/select/select.component.js +99 -86
- package/dist/components/select/select.controllers.js +5 -2
- package/dist/components/select/select.styles.js +15 -0
- package/dist/components/select-option/select-option.component.d.ts +2 -2
- package/dist/components/select-option/select-option.component.js +16 -10
- package/dist/components/switch/switch.styles.js +5 -0
- package/dist/components/toast/toast.component.d.ts +35 -0
- package/dist/components/toast/toast.component.js +52 -0
- package/dist/components/toast/toast.d.ts +8 -0
- package/dist/components/toast/toast.js +6 -0
- package/dist/components/toast/toast.singleton.d.ts +26 -0
- package/dist/components/toast/toast.singleton.js +53 -0
- package/dist/components/toast/toast.style.d.ts +1 -0
- package/dist/components/toast/toast.style.js +9 -0
- package/dist/components/toast-item/toast-item.component.d.ts +21 -0
- package/dist/components/toast-item/toast-item.component.js +65 -0
- package/dist/components/toast-item/toast-item.d.ts +6 -0
- package/dist/components/toast-item/toast-item.js +2 -0
- package/dist/components/toast-item/toast-item.style.d.ts +2 -0
- package/dist/components/toast-item/toast-item.style.js +16 -0
- package/dist/components/toast-wrapper/toast-wrapper.component.d.ts +24 -0
- package/dist/components/toast-wrapper/toast-wrapper.component.js +37 -0
- package/dist/components/toast-wrapper/toast-wrapper.d.ts +8 -0
- package/dist/components/toast-wrapper/toast-wrapper.js +6 -0
- package/dist/components/toast-wrapper/toast-wrapper.style.d.ts +1 -0
- package/dist/components/toast-wrapper/toast-wrapper.style.js +20 -0
- package/dist/custom-elements.json +450 -12
- package/dist/index.d.ts +1 -0
- package/dist/index.js +43 -40
- package/dist/internal/components/hint/hint.component.js +12 -10
- package/dist/internal/components/hint/hint.styles.js +26 -10
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.js +2 -0
- package/dist/react/skf-toast/index.d.ts +3 -0
- package/dist/react/skf-toast/index.js +13 -0
- package/dist/react/skf-toast-wrapper/index.d.ts +3 -0
- package/dist/react/skf-toast-wrapper/index.js +13 -0
- package/dist/styles/form-field.styles.js +4 -0
- package/dist/types/jsx/custom-element-jsx.d.ts +41 -3
- package/dist/types/vue/index.d.ts +42 -2
- package/dist/vscode.html-custom-data.json +40 -1
- package/dist/web-types.json +90 -4
- package/package.json +3 -3
@@ -1,29 +1,29 @@
|
|
1
|
-
import { computePosition as
|
1
|
+
import { computePosition as v, flip as _, shift as f, offset as g } from "@floating-ui/dom";
|
2
2
|
import { FormBase as b } from "../../internal/components/formBase.js";
|
3
3
|
import { findMatchingTags as y } from "../../internal/helpers/findMatchingTags.js";
|
4
4
|
import { hintSeverity as O } from "../../internal/helpers/hintSeverity.js";
|
5
|
-
import { raiseError as
|
6
|
-
import { Asterisk as
|
7
|
-
import
|
8
|
-
import { html as h, nothing as
|
9
|
-
import { property as
|
5
|
+
import { raiseError as w } from "../../internal/helpers/raiseError.js";
|
6
|
+
import { Asterisk as x } from "../../internal/templates/asterisk.js";
|
7
|
+
import $ from "../../styles/component.styles.js";
|
8
|
+
import { html as h, nothing as S } from "lit";
|
9
|
+
import { property as o, state as d, query as p } from "lit/decorators.js";
|
10
10
|
import { classMap as V } from "lit/directives/class-map.js";
|
11
11
|
import { ifDefined as m } from "lit/directives/if-defined.js";
|
12
12
|
import "../../internal/components/hint/hint.js";
|
13
13
|
import "../tag/tag.js";
|
14
|
-
import { ScrollController as C, ResizeController as
|
14
|
+
import { ScrollController as C, ResizeController as k, GlobalClickController as E, KeyboardNavigationController as L, DeveloperFeedbackController as A } from "./select.controllers.js";
|
15
15
|
import { styles as P } from "./select.styles.js";
|
16
|
-
var D = Object.defineProperty, M = Object.getOwnPropertyDescriptor, l = (u, t, e,
|
17
|
-
for (var
|
18
|
-
(a = u[n]) && (
|
19
|
-
return
|
16
|
+
var D = Object.defineProperty, M = Object.getOwnPropertyDescriptor, l = (u, t, e, i) => {
|
17
|
+
for (var r = i > 1 ? void 0 : i ? M(t, e) : t, n = u.length - 1, a; n >= 0; n--)
|
18
|
+
(a = u[n]) && (r = (i ? a(t, e, r) : a(r)) || r);
|
19
|
+
return i && r && D(t, e, r), r;
|
20
20
|
};
|
21
21
|
const c = class c extends b {
|
22
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
|
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 k(this), this.globalClickController = new E(this), this.keyboardNavController = new L(this), this.developerFeedbackController = new A(this), this._handleOptionSelected = (t) => {
|
24
24
|
this._pristine = !1;
|
25
25
|
const e = this._selectedOptions.length > 0;
|
26
|
-
this.setFormValue(e ? this.
|
26
|
+
this.setFormValue(e ? this.selectedValues.join(",") : null), this._updateState(t);
|
27
27
|
}, this._handleReset = () => {
|
28
28
|
this.emitEvent("reset"), this._resetSelectedOptions();
|
29
29
|
}, this._updateWidth = () => {
|
@@ -32,15 +32,15 @@ const c = class c extends b {
|
|
32
32
|
(t = this.$dropdown) == null || t.style.setProperty("--select-width", `${String(this.offsetWidth)}px`);
|
33
33
|
}, 50);
|
34
34
|
}, this._managePopover = () => ({ close: () => {
|
35
|
-
var
|
36
|
-
(
|
35
|
+
var i;
|
36
|
+
(i = this.$dropdown) == null || i.hidePopover();
|
37
37
|
}, open: () => {
|
38
|
-
const
|
39
|
-
!
|
38
|
+
const i = this.$selectBtn, r = this.$dropdown;
|
39
|
+
!i || !r || (r.showPopover(), v(i, r, {
|
40
40
|
placement: "bottom",
|
41
|
-
middleware: [
|
41
|
+
middleware: [_(), f({ padding: 5 }), g(2)]
|
42
42
|
}).then(({ x: n, y: a }) => {
|
43
|
-
Object.assign(
|
43
|
+
Object.assign(r.style, {
|
44
44
|
left: `${String(n)}px`,
|
45
45
|
top: `${String(Math.round(a - window.scrollY))}px`
|
46
46
|
});
|
@@ -55,10 +55,10 @@ const c = class c extends b {
|
|
55
55
|
this.setFormValue(null), this.requestUpdate();
|
56
56
|
break;
|
57
57
|
case this._selectedOptions.length === 1:
|
58
|
-
this.setFormValue(this.
|
58
|
+
this.setFormValue(this.selectedValues[0]);
|
59
59
|
break;
|
60
60
|
case this._selectedOptions.length > 1:
|
61
|
-
this.setFormValue(this.
|
61
|
+
this.setFormValue(this.selectedValues.join(","));
|
62
62
|
break;
|
63
63
|
default:
|
64
64
|
throw new Error("Something went wrong");
|
@@ -68,8 +68,8 @@ const c = class c extends b {
|
|
68
68
|
});
|
69
69
|
}), this._resetSelectedOptions = (t) => {
|
70
70
|
const e = !t;
|
71
|
-
this._optionsList.forEach((
|
72
|
-
(e ||
|
71
|
+
this._optionsList.forEach((i) => {
|
72
|
+
(e || i !== t) && i.removeAttribute("selected");
|
73
73
|
});
|
74
74
|
}, this._handleSlotChange = () => {
|
75
75
|
this._collectSlotOptionTags(), this._validateInput();
|
@@ -78,11 +78,23 @@ const c = class c extends b {
|
|
78
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
79
|
}, this._selectedOptions = [];
|
80
80
|
}
|
81
|
-
|
81
|
+
set selectedValues(t) {
|
82
|
+
this._selectedOptions = this._optionsList.filter((e) => t.includes(e.value.trim()));
|
83
|
+
}
|
84
|
+
get selectedValues() {
|
82
85
|
return this._selectedOptions.map((t) => t.value.trim());
|
83
86
|
}
|
84
|
-
|
85
|
-
|
87
|
+
set selectedOptionsText(t) {
|
88
|
+
this._selectedOptions = this._selectedOptions.filter(
|
89
|
+
(e) => e.textContent && t.includes(e.textContent)
|
90
|
+
);
|
91
|
+
}
|
92
|
+
get selectedOptionsText() {
|
93
|
+
return this._selectedOptions.map((t) => t.textContent ?? "");
|
94
|
+
}
|
95
|
+
set value(t) {
|
96
|
+
const e = t.split(",").map((i) => i.trim());
|
97
|
+
this._selectedOptions = this._optionsList.filter((i) => e.includes(i.value.trim()));
|
86
98
|
}
|
87
99
|
get value() {
|
88
100
|
return this._selectedOptions.length ? this._selectedOptions.length === 1 ? this._selectedOptions[0].value.trim() : this._selectedOptions.map((t) => t.value.trim()).join(",") : "";
|
@@ -113,20 +125,19 @@ const c = class c extends b {
|
|
113
125
|
}
|
114
126
|
firstUpdated() {
|
115
127
|
var t;
|
116
|
-
this.addEventListener("skf-select-option:select", this._handleOptionSelected), (t = this._internals.form) == null || t.addEventListener("reset", this._handleReset), this.onUpdateComplete(), this.
|
128
|
+
this.addEventListener("skf-select-option:select", this._handleOptionSelected), (t = this._internals.form) == null || t.addEventListener("reset", this._handleReset), this.onUpdateComplete(), this._validateInput();
|
117
129
|
}
|
118
130
|
updated(t) {
|
119
|
-
var e, s;
|
120
131
|
if (t.has("_expanded")) {
|
121
|
-
const
|
122
|
-
if (this.emit("skf-select:dropdown", { detail: { expanded: this._expanded } }),
|
123
|
-
this._expanded ?
|
132
|
+
const e = !!t.get("_expanded") === this._expanded;
|
133
|
+
if (this.emit("skf-select:dropdown", { detail: { expanded: this._expanded } }), e) return;
|
134
|
+
this._expanded ? this._managePopover().open() : this._managePopover().close();
|
124
135
|
}
|
125
136
|
}
|
126
|
-
attributeChangedCallback(t, e,
|
127
|
-
if (super.attributeChangedCallback(t, e,
|
128
|
-
if (typeof
|
129
|
-
const n = String(
|
137
|
+
attributeChangedCallback(t, e, i) {
|
138
|
+
if (super.attributeChangedCallback(t, e, i), t === "custom-invalid")
|
139
|
+
if (typeof i == "string") {
|
140
|
+
const n = String(i).trim() || "Custom error";
|
130
141
|
this._pristine = !1, this._invalid = !0, this.setValidity({ customError: !0 }, n), this.checkValidity();
|
131
142
|
} else
|
132
143
|
this.setValidity({}), this._validateInput();
|
@@ -142,8 +153,8 @@ const c = class c extends b {
|
|
142
153
|
e.selected && (this.selectedOptions = [...this.selectedOptions, e]);
|
143
154
|
});
|
144
155
|
else {
|
145
|
-
const e = this._selectedOptions.length > 0,
|
146
|
-
e && (this._selectedOptions[0].setSelectedDiscrete = !1, this._selectedOptions = []),
|
156
|
+
const e = this._selectedOptions.length > 0, i = t.detail.value !== null;
|
157
|
+
e && (this._selectedOptions[0].setSelectedDiscrete = !1, this._selectedOptions = []), i && (this.selectedOptions = [t.target]);
|
147
158
|
}
|
148
159
|
this._setValue();
|
149
160
|
}
|
@@ -154,7 +165,7 @@ const c = class c extends b {
|
|
154
165
|
/** @internal */
|
155
166
|
/** Filter out elements other than skf-select-option and store in this._optionsList */
|
156
167
|
_collectSlotOptionTags() {
|
157
|
-
this._optionsList = y(this, "skf-select-option"), this._selectedOptions = this._optionsList.filter((t) => t.selected),
|
168
|
+
this._optionsList = y(this, "skf-select-option"), this._selectedOptions = this._optionsList.filter((t) => t.selected), w({
|
158
169
|
assert: this._optionsList.length > 0,
|
159
170
|
reason: "no-children",
|
160
171
|
replaceStrings: [this.localName, "skf-select-option"]
|
@@ -163,7 +174,7 @@ const c = class c extends b {
|
|
163
174
|
/** @internal */
|
164
175
|
_validateInput() {
|
165
176
|
this._invalid = !1;
|
166
|
-
const t = this.required && !this.
|
177
|
+
const t = this.required && !this.selectedValues.length || this.min === 1, e = !!(this.min && this.selectedValues.length < this.min), i = !!(this.max && this.selectedValues.length > this.max);
|
167
178
|
if (this._internals.validity.customError) {
|
168
179
|
this._invalid = !0;
|
169
180
|
return;
|
@@ -173,7 +184,7 @@ const c = class c extends b {
|
|
173
184
|
} else if (e) {
|
174
185
|
const n = this.hasAttribute("data-rangeunderflow") ? this.getAttribute("data-rangeunderflow") : `Please select minimum ${String(this.min)} options`;
|
175
186
|
this.setValidity({ rangeUnderflow: !0 }, String(n)), this._pristine || (this._invalid = !0);
|
176
|
-
} else if (
|
187
|
+
} else if (i) {
|
177
188
|
const n = this.hasAttribute("data-rangeoverflow") ? this.getAttribute("data-rangeoverflow") : `Please select maximum ${String(this.max)} options`;
|
178
189
|
this.setValidity({ rangeOverflow: !0 }, String(n)), this._pristine || (this._invalid = !0);
|
179
190
|
} else
|
@@ -185,14 +196,16 @@ const c = class c extends b {
|
|
185
196
|
<label>
|
186
197
|
<div class=${this.hideLabel ? "visually-hidden" : ""} id="label">
|
187
198
|
${this.label}
|
188
|
-
${this.required ?
|
199
|
+
${this.required ? x(this.requiredLabel) : null}
|
189
200
|
</div>
|
190
201
|
<button
|
191
202
|
?disabled=${this.disabled}
|
192
203
|
@click=${this._handleDropdownToggle}
|
193
204
|
aria-controls="select-dropdown"
|
194
|
-
aria-expanded
|
205
|
+
aria-expanded=${this._expanded}
|
206
|
+
aria-invalid=${this._invalid}
|
195
207
|
aria-haspopup="listbox"
|
208
|
+
class="skf-icon-host"
|
196
209
|
id="select-button"
|
197
210
|
role="combobox"
|
198
211
|
>
|
@@ -207,7 +220,7 @@ const c = class c extends b {
|
|
207
220
|
<div aria-multiselectable=${m(this.multiple && !0)} id="select-dropdown" popover role="listbox">
|
208
221
|
<slot @slotchange=${this._handleSlotChange}></slot>
|
209
222
|
</div>
|
210
|
-
${!this.hideTags && this.multiple ? h`
|
223
|
+
${!this.hideTags && this.multiple && this.selectedOptions.length > 0 ? h`
|
211
224
|
<div id="tags">
|
212
225
|
${this.selectedOptions.map(
|
213
226
|
(t) => h`
|
@@ -220,7 +233,7 @@ const c = class c extends b {
|
|
220
233
|
`
|
221
234
|
)}
|
222
235
|
</div>
|
223
|
-
` :
|
236
|
+
` : S}
|
224
237
|
${this.hint && h`
|
225
238
|
<skf-hint
|
226
239
|
aria-live=${this._invalid ? "assertive" : "polite"}
|
@@ -235,77 +248,77 @@ const c = class c extends b {
|
|
235
248
|
`;
|
236
249
|
}
|
237
250
|
};
|
238
|
-
c.styles = [
|
239
|
-
let
|
251
|
+
c.styles = [$, P];
|
252
|
+
let s = c;
|
240
253
|
l([
|
241
|
-
|
242
|
-
],
|
254
|
+
o({ type: String, reflect: !0, attribute: "button-label" })
|
255
|
+
], s.prototype, "buttonLabel", 2);
|
243
256
|
l([
|
244
|
-
|
245
|
-
],
|
257
|
+
o({ attribute: "custom-invalid" })
|
258
|
+
], s.prototype, "customInvalid", 2);
|
246
259
|
l([
|
247
|
-
|
248
|
-
],
|
260
|
+
o({ type: Boolean, attribute: "hide-label" })
|
261
|
+
], s.prototype, "hideLabel", 2);
|
249
262
|
l([
|
250
|
-
|
251
|
-
],
|
263
|
+
o({ type: Boolean, reflect: !0, attribute: "hide-tags" })
|
264
|
+
], s.prototype, "hideTags", 2);
|
252
265
|
l([
|
253
|
-
|
254
|
-
],
|
266
|
+
o()
|
267
|
+
], s.prototype, "hint", 2);
|
255
268
|
l([
|
256
|
-
|
257
|
-
],
|
269
|
+
o({ type: Array, attribute: !1 })
|
270
|
+
], s.prototype, "selectedValues", 1);
|
258
271
|
l([
|
259
|
-
|
260
|
-
],
|
272
|
+
o({ type: Array, attribute: !1 })
|
273
|
+
], s.prototype, "selectedOptionsText", 1);
|
261
274
|
l([
|
262
|
-
|
263
|
-
],
|
275
|
+
o({ reflect: !0 })
|
276
|
+
], s.prototype, "label", 2);
|
264
277
|
l([
|
265
|
-
|
266
|
-
],
|
278
|
+
o({ type: Number })
|
279
|
+
], s.prototype, "max", 2);
|
267
280
|
l([
|
268
|
-
|
269
|
-
],
|
281
|
+
o({ type: Number })
|
282
|
+
], s.prototype, "min", 2);
|
270
283
|
l([
|
271
|
-
|
272
|
-
],
|
284
|
+
o({ type: Boolean, reflect: !0 })
|
285
|
+
], s.prototype, "multiple", 2);
|
273
286
|
l([
|
274
|
-
|
275
|
-
],
|
287
|
+
o()
|
288
|
+
], s.prototype, "name", 2);
|
276
289
|
l([
|
277
|
-
|
278
|
-
],
|
290
|
+
o({ attribute: "required-label" })
|
291
|
+
], s.prototype, "requiredLabel", 2);
|
279
292
|
l([
|
280
|
-
|
281
|
-
],
|
293
|
+
o()
|
294
|
+
], s.prototype, "severity", 2);
|
282
295
|
l([
|
283
|
-
|
284
|
-
],
|
296
|
+
o({ type: Boolean, attribute: "show-valid" })
|
297
|
+
], s.prototype, "showValid", 2);
|
285
298
|
l([
|
286
|
-
|
287
|
-
],
|
299
|
+
o({ reflect: !0 })
|
300
|
+
], s.prototype, "size", 2);
|
288
301
|
l([
|
289
302
|
d()
|
290
|
-
],
|
303
|
+
], s.prototype, "value", 1);
|
291
304
|
l([
|
292
305
|
d()
|
293
|
-
],
|
306
|
+
], s.prototype, "selectedOptions", 1);
|
294
307
|
l([
|
295
308
|
d()
|
296
|
-
],
|
309
|
+
], s.prototype, "_expanded", 2);
|
297
310
|
l([
|
298
311
|
d()
|
299
|
-
],
|
312
|
+
], s.prototype, "_invalid", 2);
|
300
313
|
l([
|
301
314
|
p("#select-button")
|
302
|
-
],
|
315
|
+
], s.prototype, "$selectBtn", 2);
|
303
316
|
l([
|
304
317
|
p("#selected-value")
|
305
|
-
],
|
318
|
+
], s.prototype, "$selectedValue", 2);
|
306
319
|
l([
|
307
320
|
p("#select-dropdown")
|
308
|
-
],
|
321
|
+
], s.prototype, "$dropdown", 2);
|
309
322
|
export {
|
310
|
-
|
323
|
+
s as SkfSelect
|
311
324
|
};
|
@@ -146,11 +146,14 @@ class _ {
|
|
146
146
|
}
|
147
147
|
_badAttributeCombinationWarning() {
|
148
148
|
r({
|
149
|
-
assert: (this.host.min ?? 0)
|
149
|
+
assert: (this.host.min ?? 0) <= (this.host.max ?? 1 / 0),
|
150
150
|
reason: "attribute-mismatch",
|
151
151
|
replaceStrings: [this.host.localName, "min", "smaller than max"]
|
152
152
|
}), r({
|
153
|
-
assert: (
|
153
|
+
assert: (
|
154
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
155
|
+
(this.host.min || this.host.max) && this.host.multiple || !(this.host.min && this.host.max)
|
156
|
+
),
|
154
157
|
reason: "attribute-mismatch",
|
155
158
|
replaceStrings: [this.host.localName, "min or max", "together with multiple"]
|
156
159
|
}), r({
|
@@ -14,6 +14,10 @@ const t = [
|
|
14
14
|
flex-direction: column;
|
15
15
|
gap: var(--skf-spacing-25);
|
16
16
|
|
17
|
+
:host([disabled]) & {
|
18
|
+
--_skf-select-color: var(--skf-interactive-text-color-disabled);
|
19
|
+
}
|
20
|
+
|
17
21
|
:host([size='sm']) & {
|
18
22
|
font-size: var(--skf-font-size-75);
|
19
23
|
font-weight: var(--skf-font-weight-medium);
|
@@ -96,6 +100,16 @@ const t = [
|
|
96
100
|
}
|
97
101
|
}
|
98
102
|
|
103
|
+
skf-icon {
|
104
|
+
transform: var(--_skf-select-icon-transform, rotateX(0deg));
|
105
|
+
transform-origin: center;
|
106
|
+
transition: transform calc(var(--skf-motion-duration-normal) * 1ms) ease-out;
|
107
|
+
|
108
|
+
[aria-expanded='true'] & {
|
109
|
+
--_skf-select-icon-transform: rotateX(180deg);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
99
113
|
#select-dropdown {
|
100
114
|
background-color: var(--skf-bg-color-neutral-1);
|
101
115
|
border: var(--skf-border-width-sm) solid var(--skf-border-color-tertiary);
|
@@ -106,6 +120,7 @@ const t = [
|
|
106
120
|
|
107
121
|
#tags {
|
108
122
|
display: flex;
|
123
|
+
flex-wrap: wrap;
|
109
124
|
gap: 0.5rem;
|
110
125
|
}
|
111
126
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { SkfElement } from '@internal/components/skf-element.js';
|
2
|
-
import type {
|
2
|
+
import type { SeverityFgColor } from '@skf-design-system/ui-assets';
|
3
3
|
import { type CSSResultGroup } from 'lit';
|
4
4
|
import '../icon/icon';
|
5
5
|
import { SkfIcon } from '../icon/icon';
|
@@ -43,7 +43,7 @@ export declare class SkfSelectOption extends SkfElement {
|
|
43
43
|
/** If defined, set an icon */
|
44
44
|
icon?: SkfIcon['name'];
|
45
45
|
/** If defined, sets provided color on the icon */
|
46
|
-
iconColor?:
|
46
|
+
iconColor?: SeverityFgColor;
|
47
47
|
/** If true, sets the option as selected */
|
48
48
|
selected?: boolean;
|
49
49
|
/** If defined, sets a short label */
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { SkfElement as
|
2
|
-
import
|
3
|
-
import { LitElement as
|
4
|
-
import { property as n, queryAssignedNodes as
|
5
|
-
import { ifDefined as
|
1
|
+
import { SkfElement as u } from "../../internal/components/skf-element.js";
|
2
|
+
import f from "../../styles/component.styles.js";
|
3
|
+
import { LitElement as m, html as h } from "lit";
|
4
|
+
import { property as n, queryAssignedNodes as _ } from "lit/decorators.js";
|
5
|
+
import { ifDefined as p } from "lit/directives/if-defined.js";
|
6
6
|
import "../icon/icon.js";
|
7
7
|
import { styles as y } from "./select-option.styles.js";
|
8
8
|
var v = Object.defineProperty, b = Object.getOwnPropertyDescriptor, o = (d, t, s, i) => {
|
@@ -10,7 +10,7 @@ var v = Object.defineProperty, b = Object.getOwnPropertyDescriptor, o = (d, t, s
|
|
10
10
|
(c = d[a]) && (r = (i ? c(t, s, r) : c(r)) || r);
|
11
11
|
return i && r && v(t, s, r), r;
|
12
12
|
};
|
13
|
-
const l = class l extends
|
13
|
+
const l = class l extends u {
|
14
14
|
constructor() {
|
15
15
|
super(), this._handleClick = (s) => {
|
16
16
|
s.stopPropagation(), this.selected = !this.selected;
|
@@ -69,16 +69,22 @@ const l = class l extends p {
|
|
69
69
|
render() {
|
70
70
|
return h`
|
71
71
|
<button
|
72
|
+
?disabled=${this.disabled}
|
72
73
|
@click=${this._handleClick}
|
73
74
|
aria-selected=${this.selected ? "true" : "false"}
|
74
|
-
?disabled=${this.disabled}
|
75
75
|
role="option"
|
76
76
|
>
|
77
77
|
<skf-icon id="icon-check" name="check" size="sm"></skf-icon>
|
78
78
|
<slot>${this.text}</slot>
|
79
79
|
<div id="adornments">
|
80
80
|
<slot name="icon">
|
81
|
-
${this.icon && h
|
81
|
+
${this.icon && h`
|
82
|
+
<skf-icon
|
83
|
+
class=${p((this.disabled ?? !this.iconColor) && "skf-icon-host")}
|
84
|
+
color=${p(this.iconColor)}
|
85
|
+
name=${this.icon}
|
86
|
+
></skf-icon>
|
87
|
+
`}
|
82
88
|
</slot>
|
83
89
|
${this.shortLabel && h`<div id="short-label">${this.shortLabel}</div>`}
|
84
90
|
</div>
|
@@ -86,7 +92,7 @@ const l = class l extends p {
|
|
86
92
|
`;
|
87
93
|
}
|
88
94
|
};
|
89
|
-
l.styles = [
|
95
|
+
l.styles = [f, y], l.shadowRootOptions = { ...m.shadowRootOptions, delegatesFocus: !0 };
|
90
96
|
let e = l;
|
91
97
|
o([
|
92
98
|
n({ type: Boolean, reflect: !0 })
|
@@ -110,7 +116,7 @@ o([
|
|
110
116
|
n({ reflect: !0 })
|
111
117
|
], e.prototype, "value", 1);
|
112
118
|
o([
|
113
|
-
|
119
|
+
_({ flatten: !0 })
|
114
120
|
], e.prototype, "_assignedNodes", 2);
|
115
121
|
export {
|
116
122
|
e as SkfSelectOption
|
@@ -10,9 +10,14 @@ const t = [
|
|
10
10
|
|
11
11
|
#root {
|
12
12
|
align-items: center;
|
13
|
+
color: var(--_skf-switch-color, var(--skf-text-color-primary));
|
13
14
|
display: flex;
|
14
15
|
grid-gap: var(--skf-spacing-50);
|
15
16
|
|
17
|
+
:host([disabled]) & {
|
18
|
+
--_skf-switch-color: var(--skf-interactive-text-color-disabled);
|
19
|
+
}
|
20
|
+
|
16
21
|
:host([size='sm']) & {
|
17
22
|
--_skf-switch-height: var(--skf-size-20);
|
18
23
|
--_skf-switch-width: var(--skf-size-32);
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { SkfElement } from '@internal/components/skf-element';
|
2
|
+
import { type CSSResultGroup } from 'lit';
|
3
|
+
/**
|
4
|
+
* SkfToast is the only component a user (developer) interacts with to create a toast notification. Once rendered it will invoke a singleton instance to manage the toast notifications.
|
5
|
+
* The singleton instance will create a new toast notification (using SkfAlert) and append it to SkfToastWrapper (or append SkfToastWrapper if it doesn't exist yet) and mount that to the DOM.
|
6
|
+
* Once a toast notification is created, it will be removed after a set amount of time (if not set as a closeable SkfToast) together with the original SkfToast.
|
7
|
+
* Once the queue in the singleton is empty, the SkfToastWrapper will be removed from the DOM.
|
8
|
+
*/
|
9
|
+
/**
|
10
|
+
* A simple toast component that displays a message to the user. Use by appending a <skf-toast> tag to the DOM. Position in DOM is irrelevant.
|
11
|
+
*
|
12
|
+
* @documentation See [zeroheight](https://zeroheight.com/853e936c9/p/98e432-toast) for design principles
|
13
|
+
*
|
14
|
+
* @slot - The component's placeholder content
|
15
|
+
*
|
16
|
+
* @tagname skf-toast
|
17
|
+
*/
|
18
|
+
export declare class SkfToast extends SkfElement {
|
19
|
+
static styles: CSSResultGroup;
|
20
|
+
private _singleton?;
|
21
|
+
/** If provided, adds a close button to the toast and will not disapear until user actively dismisses it. */
|
22
|
+
closeable: boolean;
|
23
|
+
debug: boolean;
|
24
|
+
/** Severity of the toast. */
|
25
|
+
severity: 'info' | 'success' | 'warning' | 'error';
|
26
|
+
/** Time in seconds before the toast disappears. */
|
27
|
+
timer: number;
|
28
|
+
/** offsets where toasts emerge vertically */
|
29
|
+
topOffset?: number;
|
30
|
+
/** @internal */
|
31
|
+
_slottedText: Node[];
|
32
|
+
constructor();
|
33
|
+
firstUpdated(): void;
|
34
|
+
render(): import("lit").TemplateResult<1>;
|
35
|
+
}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import { Singleton as f } from "./toast.singleton.js";
|
2
|
+
import { SkfElement as m } from "../../internal/components/skf-element.js";
|
3
|
+
import { html as h } from "lit";
|
4
|
+
import { property as s, queryAssignedNodes as y } from "lit/decorators.js";
|
5
|
+
import { styles as a } from "./toast.style.js";
|
6
|
+
var u = Object.defineProperty, o = (l, r, n, b) => {
|
7
|
+
for (var e = void 0, i = l.length - 1, d; i >= 0; i--)
|
8
|
+
(d = l[i]) && (e = d(r, n, e) || e);
|
9
|
+
return e && u(r, n, e), e;
|
10
|
+
};
|
11
|
+
const p = class p extends m {
|
12
|
+
constructor() {
|
13
|
+
super(), this.closeable = !1, this.debug = !1, this.severity = "info", this.timer = 5, this._singleton = void 0;
|
14
|
+
}
|
15
|
+
firstUpdated() {
|
16
|
+
this._singleton = new f(this.getRootNode()), this._singleton.addData({
|
17
|
+
text: this._slottedText.map((r) => r.textContent).join(),
|
18
|
+
timer: this.timer,
|
19
|
+
closeable: this.closeable,
|
20
|
+
originEl: this,
|
21
|
+
severity: this.severity,
|
22
|
+
topOffset: this.topOffset,
|
23
|
+
debug: this.debug
|
24
|
+
});
|
25
|
+
}
|
26
|
+
render() {
|
27
|
+
return h`<slot></slot>`;
|
28
|
+
}
|
29
|
+
};
|
30
|
+
p.styles = [a];
|
31
|
+
let t = p;
|
32
|
+
o([
|
33
|
+
s({ type: Boolean })
|
34
|
+
], t.prototype, "closeable");
|
35
|
+
o([
|
36
|
+
s({ type: Boolean })
|
37
|
+
], t.prototype, "debug");
|
38
|
+
o([
|
39
|
+
s()
|
40
|
+
], t.prototype, "severity");
|
41
|
+
o([
|
42
|
+
s({ type: Number })
|
43
|
+
], t.prototype, "timer");
|
44
|
+
o([
|
45
|
+
s({ type: Number })
|
46
|
+
], t.prototype, "topOffset");
|
47
|
+
o([
|
48
|
+
y()
|
49
|
+
], t.prototype, "_slottedText");
|
50
|
+
export {
|
51
|
+
t as SkfToast
|
52
|
+
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import '@components/toast-item/toast-item.js';
|
2
|
+
import '@components/toast-wrapper/toast-wrapper.js';
|
3
|
+
import type { SkfToast } from '@components/toast/toast.component.js';
|
4
|
+
interface ToastData {
|
5
|
+
text: string;
|
6
|
+
timer: number;
|
7
|
+
closeable: boolean;
|
8
|
+
topOffset?: number;
|
9
|
+
originEl: SkfToast;
|
10
|
+
severity: 'info' | 'success' | 'warning' | 'error';
|
11
|
+
debug: boolean;
|
12
|
+
}
|
13
|
+
export declare class Singleton {
|
14
|
+
private static instance?;
|
15
|
+
data: ToastData[];
|
16
|
+
root: Document;
|
17
|
+
usePopover: boolean;
|
18
|
+
constructor(root: Document);
|
19
|
+
hasToasts(): boolean;
|
20
|
+
popToast(): ToastData | undefined;
|
21
|
+
getData(): ToastData[];
|
22
|
+
setData(data: ToastData[]): void;
|
23
|
+
addData(data: ToastData): void;
|
24
|
+
udpateUI(): void;
|
25
|
+
}
|
26
|
+
export {};
|