@skf-design-system/ui-components 1.0.0-beta.4 → 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/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 +21 -19
- 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 +6 -6
- 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 +7 -7
- package/dist/components/checkbox/checkbox.styles.js +7 -2
- 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 +56 -54
- package/dist/components/input/input.component.d.ts +43 -29
- package/dist/components/input/input.component.js +46 -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 +6 -1
- package/dist/components/select/select.component.d.ts +12 -10
- package/dist/components/select/select.component.js +113 -100
- package/dist/components/select/select.controllers.js +5 -2
- package/dist/components/select/select.styles.js +18 -3
- 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.component.d.ts +2 -3
- package/dist/components/switch/switch.component.js +1 -1
- package/dist/components/switch/switch.styles.js +6 -1
- package/dist/components/switch/switch.test.d.ts +1 -0
- package/dist/components/tag/tag.component.d.ts +12 -7
- package/dist/components/tag/tag.component.js +24 -24
- package/dist/components/tag/tag.styles.js +6 -1
- package/dist/components/textarea/textarea.component.d.ts +26 -23
- package/dist/components/textarea/textarea.component.js +15 -12
- 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 +676 -238
- 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/internal/storybook/shadowRootTraverser.d.ts +16 -8
- package/dist/react/index.d.ts +5 -3
- package/dist/react/index.js +5 -3
- 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 +5 -1
- package/dist/types/jsx/custom-element-jsx.d.ts +88 -50
- package/dist/types/vue/index.d.ts +91 -51
- package/dist/vscode.html-custom-data.json +101 -62
- package/dist/web-types.json +208 -122
- package/package.json +3 -3
@@ -1,12 +1,12 @@
|
|
1
1
|
import { SkfElement as i } from "../../internal/components/skf-element.js";
|
2
2
|
import m from "../../styles/component.styles.js";
|
3
3
|
import { html as n } from "lit";
|
4
|
-
import { property as
|
4
|
+
import { property as l } from "lit/decorators.js";
|
5
5
|
import a from "./logo.styles.js";
|
6
|
-
var d = Object.defineProperty, s = (h, o,
|
7
|
-
for (var c = void 0, r = h.length - 1,
|
8
|
-
(
|
9
|
-
return c && d(o,
|
6
|
+
var d = Object.defineProperty, s = (h, o, p, f) => {
|
7
|
+
for (var c = void 0, r = h.length - 1, v; r >= 0; r--)
|
8
|
+
(v = h[r]) && (c = v(o, p, c) || c);
|
9
|
+
return c && d(o, p, c), c;
|
10
10
|
};
|
11
11
|
const e = class e extends i {
|
12
12
|
constructor() {
|
@@ -14,7 +14,7 @@ const e = class e extends i {
|
|
14
14
|
}
|
15
15
|
render() {
|
16
16
|
return n`
|
17
|
-
<svg id="
|
17
|
+
<svg id="root" viewBox="0 0 1300 300" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px">
|
18
18
|
<title>${this.title}</title>
|
19
19
|
<g>
|
20
20
|
<g>
|
@@ -58,10 +58,10 @@ c0,5.8-4.3,6.1-9.1,6.1H1230.9z"
|
|
58
58
|
e.styles = [m, a];
|
59
59
|
let t = e;
|
60
60
|
s([
|
61
|
-
|
61
|
+
l()
|
62
62
|
], t.prototype, "title");
|
63
63
|
s([
|
64
|
-
|
64
|
+
l()
|
65
65
|
], t.prototype, "color");
|
66
66
|
export {
|
67
67
|
t as SkfLogo
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import { css as o } from "lit";
|
2
2
|
const r = o`
|
3
3
|
:host {
|
4
|
-
display:
|
4
|
+
display: inline-flex;
|
5
5
|
}
|
6
6
|
|
7
|
-
#
|
7
|
+
#root {
|
8
8
|
aspect-ratio: 13 / 3;
|
9
9
|
block-size: var(--skf-logo-height, var(--skf-size-32));
|
10
10
|
fill: var(--_skf-logo-color, var(--skf-logo-primary));
|
@@ -5,40 +5,42 @@ import { type CSSResultGroup } from 'lit';
|
|
5
5
|
/**
|
6
6
|
* The `<skf-radio>` component is used to create a radio input
|
7
7
|
*
|
8
|
-
* @documentation See [
|
8
|
+
* @documentation See [zeroheight](https://zeroheight.com/853e936c9/p/78d5dd-radio-button) for design principles
|
9
9
|
*
|
10
10
|
* @attribute {boolean} disabled - If true, sets disabled state
|
11
11
|
* @attribute {boolean} required - If true, value is required or must be checked for the form to be submittable
|
12
12
|
*
|
13
13
|
* @event change {object} - When the value of the input changes
|
14
14
|
*
|
15
|
-
* @slot
|
15
|
+
* @slot - The radios label. Alternatively, you can use the `label` attribute.
|
16
16
|
*
|
17
17
|
* @tagname skf-radio
|
18
18
|
*/
|
19
19
|
export declare class SkfRadio extends FormBase implements FormFieldBaseProps {
|
20
20
|
static styles: CSSResultGroup;
|
21
|
-
/** @internal */
|
22
21
|
private _initialChecked;
|
23
|
-
/** If
|
24
|
-
debug?: boolean
|
22
|
+
/** If true, outputs helping hints in console */
|
23
|
+
debug?: boolean;
|
25
24
|
/** If true, outputs helping hints in console */
|
26
25
|
checked?: boolean;
|
27
26
|
/** If true, forces component to invalid state until removed */
|
28
27
|
customInvalid?: boolean;
|
29
28
|
/** If true, hides the label visually */
|
30
|
-
hideLabel
|
31
|
-
/**
|
29
|
+
hideLabel?: boolean;
|
30
|
+
/** If defined, sets the input's label unless the default slot is used. Alternatively, you can use the `label` attribute. */
|
32
31
|
label?: string;
|
33
|
-
/** If
|
32
|
+
/** If defined, adds name to the input-element */
|
34
33
|
name?: string;
|
35
|
-
/** If
|
34
|
+
/** If defined, renders an alternative A11y text for the asterisk */
|
36
35
|
requiredLabel?: string;
|
37
|
-
/**
|
38
|
-
size
|
39
|
-
/**
|
36
|
+
/** Size of the Radio */
|
37
|
+
size: 'sm' | 'md';
|
38
|
+
/**
|
39
|
+
* If defined, displays provided severity state
|
40
|
+
* @type {"success" | "info" | "warning" | "alert"}
|
41
|
+
*/
|
40
42
|
severity?: FormFieldBaseProps['severity'];
|
41
|
-
/** If
|
43
|
+
/** If true, displays valid state after interaction */
|
42
44
|
showValid?: boolean;
|
43
45
|
/** The current value of the input field */
|
44
46
|
value: string;
|
@@ -14,7 +14,7 @@ var k = Object.defineProperty, i = (n, t, r, l) => {
|
|
14
14
|
};
|
15
15
|
const d = class d extends u {
|
16
16
|
constructor() {
|
17
|
-
super(...arguments), this._initialChecked = !1, this.
|
17
|
+
super(...arguments), this._initialChecked = !1, this.size = "md", this.value = "", this._invalid = !1, this._resetValue = (t) => {
|
18
18
|
t.stopPropagation(), this.checked = this._initialChecked, this.$input && (this.$input.checked = !!this._initialChecked), this.setFormValue(this.checked ? this.value : "");
|
19
19
|
};
|
20
20
|
}
|
@@ -70,7 +70,7 @@ const d = class d extends u {
|
|
70
70
|
}
|
71
71
|
render() {
|
72
72
|
return m`
|
73
|
-
<label id="
|
73
|
+
<label id="root">
|
74
74
|
<input
|
75
75
|
?disabled=${this.disabled}
|
76
76
|
?required=${this.required}
|
@@ -115,7 +115,7 @@ i([
|
|
115
115
|
a({ reflect: !0 })
|
116
116
|
], e.prototype, "size");
|
117
117
|
i([
|
118
|
-
a(
|
118
|
+
a()
|
119
119
|
], e.prototype, "severity");
|
120
120
|
i([
|
121
121
|
a({ type: Boolean, attribute: "show-valid" })
|
@@ -8,11 +8,16 @@ const e = [
|
|
8
8
|
contain: initial;
|
9
9
|
}
|
10
10
|
|
11
|
-
#
|
11
|
+
#root {
|
12
12
|
align-items: center;
|
13
|
+
color: var(--_skf-radio-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-radio-color: var(--skf-interactive-text-color-disabled);
|
19
|
+
}
|
20
|
+
|
16
21
|
:host([size='sm']) & {
|
17
22
|
--_skf-radio-size: var(--skf-size-20);
|
18
23
|
|
@@ -15,10 +15,9 @@ import { DeveloperFeedbackController, GlobalClickController, KeyboardNavigationC
|
|
15
15
|
*
|
16
16
|
* @documentation See [InVision DSM](https://skf.invisionapp.com/dsm/ab-skf/4-web-applications/nav/5fa7caf78c01200018354495/asset/6229d63d9fe16020a60657e5) for design principles
|
17
17
|
*
|
18
|
-
* @attribute {
|
18
|
+
* @attribute {boolean} [disabled] - If true, the select is disabled `default: false`
|
19
19
|
*
|
20
20
|
* @slot - The select's placeholder content
|
21
|
-
* @slot icon - The select's slot for custom meta information
|
22
21
|
*
|
23
22
|
* @event change - Fired when the selected option(s) changes
|
24
23
|
* @event invalid - Fired when the select is invalid
|
@@ -45,31 +44,34 @@ export declare class SkfSelect extends FormBase {
|
|
45
44
|
/** If defined, sets the hint text under the select component in the form */
|
46
45
|
hint?: string;
|
47
46
|
/** A readonly property that returns the selected value(s) in a array */
|
48
|
-
|
47
|
+
set selectedValues(values: string[]);
|
48
|
+
get selectedValues(): string[];
|
49
49
|
/** A readonly property that returns the selected slot(s) text content in a array */
|
50
|
-
|
51
|
-
|
52
|
-
label
|
50
|
+
set selectedOptionsText(values: string[]);
|
51
|
+
get selectedOptionsText(): string[];
|
52
|
+
/** If defined, displays provided label */
|
53
|
+
label?: string;
|
53
54
|
/** If defined, limits the number of selectable options */
|
54
55
|
max?: number;
|
55
56
|
/** If defined, sets the minimum number of required options */
|
56
57
|
min?: number;
|
57
|
-
/** If
|
58
|
+
/** If true, allows for multiple options to be selected */
|
58
59
|
multiple?: boolean;
|
59
|
-
/** If
|
60
|
+
/** If defined, set name of the component */
|
60
61
|
name?: string;
|
61
62
|
/** If defined, renders an alternative A11y text for the asterisk */
|
62
63
|
requiredLabel?: string;
|
63
64
|
/** If defined, displays provided severity state */
|
64
65
|
severity?: FormFieldBaseProps['severity'];
|
65
|
-
/** If
|
66
|
+
/** If true, displays valid state after interaction */
|
66
67
|
showValid?: boolean;
|
67
68
|
/** Size of the Select */
|
68
69
|
size: 'sm' | 'md';
|
69
70
|
/** Read only, returns the selected value. (if multiple: in a comma separated string) */
|
71
|
+
set value(newValue: string);
|
70
72
|
get value(): string;
|
71
|
-
/** @internal */
|
72
73
|
/** Stores the selected SkfSelectOption tag(s) in a array. Is the source of truth for the internal state. */
|
74
|
+
/** @internal */
|
73
75
|
private _selectedOptions;
|
74
76
|
/** @internal */
|
75
77
|
/** The selected options in an array. Treat it as a read only property. See selectedValues, slectedSlots for computed value arrays. */
|
@@ -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
|
-
(
|
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 =
|
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,20 +32,20 @@ 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: [_(),
|
42
|
-
}).then(({ x:
|
43
|
-
Object.assign(
|
44
|
-
left: `${String(
|
45
|
-
top: `${String(Math.round(
|
41
|
+
middleware: [_(), f({ padding: 5 }), g(2)]
|
42
|
+
}).then(({ x: n, y: a }) => {
|
43
|
+
Object.assign(r.style, {
|
44
|
+
left: `${String(n)}px`,
|
45
|
+
top: `${String(Math.round(a - window.scrollY))}px`
|
46
46
|
});
|
47
|
-
}).catch((
|
48
|
-
console.error(
|
47
|
+
}).catch((n) => {
|
48
|
+
console.error(n);
|
49
49
|
}));
|
50
50
|
} }), this._handleDropdownToggle = (t) => {
|
51
51
|
t.stopPropagation(), this._expanded = !this._expanded;
|
@@ -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,21 +125,20 @@ 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
|
130
|
-
this._pristine = !1, this._invalid = !0, this.setValidity({ customError: !0 },
|
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";
|
141
|
+
this._pristine = !1, this._invalid = !0, this.setValidity({ customError: !0 }, n), this.checkValidity();
|
131
142
|
} else
|
132
143
|
this.setValidity({}), this._validateInput();
|
133
144
|
}
|
@@ -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,36 +174,38 @@ 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;
|
170
181
|
} else if (t) {
|
171
|
-
const
|
172
|
-
this.setValidity({ valueMissing: !0 }, String(
|
182
|
+
const n = this.hasAttribute("data-valuemissing") ? this.getAttribute("data-valuemissing") : "Please select an option";
|
183
|
+
this.setValidity({ valueMissing: !0 }, String(n)), this._pristine || (this._invalid = !0);
|
173
184
|
} else if (e) {
|
174
|
-
const
|
175
|
-
this.setValidity({ rangeUnderflow: !0 }, String(
|
176
|
-
} else if (
|
177
|
-
const
|
178
|
-
this.setValidity({ rangeOverflow: !0 }, String(
|
185
|
+
const n = this.hasAttribute("data-rangeunderflow") ? this.getAttribute("data-rangeunderflow") : `Please select minimum ${String(this.min)} options`;
|
186
|
+
this.setValidity({ rangeUnderflow: !0 }, String(n)), this._pristine || (this._invalid = !0);
|
187
|
+
} else if (i) {
|
188
|
+
const n = this.hasAttribute("data-rangeoverflow") ? this.getAttribute("data-rangeoverflow") : `Please select maximum ${String(this.max)} options`;
|
189
|
+
this.setValidity({ rangeOverflow: !0 }, String(n)), this._pristine || (this._invalid = !0);
|
179
190
|
} else
|
180
191
|
this.setValidity({}), !this._pristine && this.showValid && this.setAttribute("valid", "true");
|
181
192
|
}
|
182
193
|
render() {
|
183
194
|
return h`
|
184
|
-
<div id="
|
195
|
+
<div id="root">
|
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,14 +233,14 @@ 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"}
|
227
240
|
id="hint"
|
228
241
|
severity=${m(O(this.severity, this._invalid))}
|
229
242
|
>
|
230
|
-
${this.hint}
|
243
|
+
${this.customInvalid ? this.customInvalid : this.hint}
|
231
244
|
</skf-hint>
|
232
245
|
`}
|
233
246
|
</div>
|
@@ -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({
|
@@ -1,19 +1,23 @@
|
|
1
1
|
import { visuallyHidden as r } from "../../styles/util.styles.js";
|
2
|
-
import { css as
|
2
|
+
import { css as o } from "lit";
|
3
3
|
const t = [
|
4
4
|
r,
|
5
|
-
|
5
|
+
o`
|
6
6
|
@layer components {
|
7
7
|
:host {
|
8
8
|
contain: initial;
|
9
9
|
}
|
10
10
|
|
11
|
-
#
|
11
|
+
#root {
|
12
12
|
color: var(--_skf-select-color, var(--skf-text-color-primary));
|
13
13
|
display: flex;
|
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
|
}
|