@skf-design-system/ui-components 1.0.2-beta.5 → 1.0.2-beta.7
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 +18 -0
- package/dist/components/accordion/accordion.component.d.ts +1 -1
- package/dist/components/accordion/accordion.component.js +2 -2
- package/dist/components/alert/alert.component.d.ts +3 -2
- package/dist/components/alert/alert.component.js +39 -33
- package/dist/components/button/button.styles.js +3 -3
- package/dist/components/checkbox/checkbox.component.d.ts +4 -2
- package/dist/components/checkbox/checkbox.component.js +73 -65
- package/dist/components/checkbox/checkbox.styles.js +1 -1
- package/dist/components/datepicker/datepicker-calendar.component.d.ts +4 -0
- package/dist/components/datepicker/datepicker-calendar.component.js +134 -127
- package/dist/components/datepicker/datepicker-popup.component.d.ts +4 -0
- package/dist/components/datepicker/datepicker-popup.component.js +100 -88
- package/dist/components/datepicker/datepicker.component.d.ts +4 -2
- package/dist/components/datepicker/datepicker.component.js +151 -140
- package/dist/components/dialog/dialog.component.d.ts +3 -2
- package/dist/components/dialog/dialog.component.js +39 -37
- package/dist/components/divider/divider.component.d.ts +3 -0
- package/dist/components/divider/divider.component.js +43 -22
- package/dist/components/divider/divider.styles.js +9 -9
- package/dist/components/drawer/drawer.component.d.ts +11 -4
- package/dist/components/drawer/drawer.component.js +77 -55
- package/dist/components/drawer/drawer.styles.js +47 -40
- package/dist/components/header/header.component.d.ts +4 -2
- package/dist/components/header/header.component.js +66 -57
- package/dist/components/header/header.styles.js +2 -2
- package/dist/components/icon/icon.component.js +7 -7
- package/dist/components/icon/icon.styles.js +2 -2
- package/dist/components/input/input.component.d.ts +4 -8
- package/dist/components/input/input.component.js +147 -147
- package/dist/components/input/input.controllers.d.ts +0 -1
- package/dist/components/input/input.controllers.js +12 -12
- package/dist/components/link/link.component.d.ts +15 -18
- package/dist/components/link/link.component.js +105 -107
- package/dist/components/link/link.styles.js +53 -45
- package/dist/components/loader/loader.component.d.ts +5 -3
- package/dist/components/loader/loader.component.js +39 -28
- package/dist/components/loader/loader.styles.js +6 -10
- package/dist/components/menu/menu-item.component.d.ts +1 -1
- package/dist/components/menu/menu-item.component.js +8 -8
- package/dist/components/menu/menu-item.styles.js +13 -9
- package/dist/components/menu/menu.component.d.ts +5 -2
- package/dist/components/menu/menu.component.js +8 -8
- package/dist/components/nav/nav-item.component.d.ts +4 -0
- package/dist/components/nav/nav-item.component.js +44 -25
- package/dist/components/nav/nav-item.styles.js +29 -25
- package/dist/components/nav/nav.component.d.ts +9 -0
- package/dist/components/nav/nav.component.js +47 -21
- package/dist/components/nav/nav.styles.js +15 -9
- package/dist/components/popover/popover.component.d.ts +10 -3
- package/dist/components/popover/popover.component.js +30 -22
- package/dist/components/progress/progress.component.d.ts +2 -0
- package/dist/components/progress/progress.component.js +38 -29
- package/dist/components/progress/progress.styles.js +4 -4
- package/dist/components/radio/radio.component.d.ts +4 -2
- package/dist/components/radio/radio.component.js +91 -83
- package/dist/components/radio/radio.styles.js +1 -1
- package/dist/components/segmented-button/segmented-button-item.component.js +1 -1
- package/dist/components/segmented-button/segmented-button-item.styles.js +1 -1
- package/dist/components/select/select-option-group.component.d.ts +4 -0
- package/dist/components/select/select-option-group.component.js +37 -18
- package/dist/components/select/select-option-group.style.js +12 -6
- package/dist/components/select/select-option.component.d.ts +7 -2
- package/dist/components/select/select-option.component.js +70 -53
- package/dist/components/select/select-option.styles.js +43 -31
- package/dist/components/select/select.component.d.ts +18 -10
- package/dist/components/select/select.component.js +175 -132
- package/dist/components/select/select.controllers.js +2 -1
- package/dist/components/select/select.styles.js +8 -2
- package/dist/components/stepper/stepper-item.component.d.ts +1 -1
- package/dist/components/stepper/stepper-item.component.js +26 -23
- package/dist/components/stepper/stepper-item.styles.js +4 -4
- package/dist/components/switch/switch.component.d.ts +4 -2
- package/dist/components/switch/switch.component.js +64 -56
- package/dist/components/switch/switch.styles.js +1 -1
- package/dist/components/tabs/tab-panel.component.d.ts +1 -1
- package/dist/components/tabs/tab-panel.component.js +19 -16
- package/dist/components/tabs/tab.component.d.ts +1 -1
- package/dist/components/tabs/tab.component.js +17 -14
- package/dist/components/tabs/tab.styles.js +2 -2
- package/dist/components/tag/tag.component.d.ts +3 -0
- package/dist/components/tag/tag.component.js +50 -41
- package/dist/components/textarea/textarea.component.d.ts +4 -2
- package/dist/components/textarea/textarea.component.js +127 -118
- package/dist/components/toast/toast-item.styles.js +13 -10
- package/dist/components/toast/toast.component.js +9 -9
- package/dist/components/toast/toast.singleton.d.ts +1 -1
- package/dist/components/toast/toast.singleton.js +18 -18
- package/dist/components/tooltip/tooltip.component.d.ts +9 -2
- package/dist/components/tooltip/tooltip.component.js +13 -7
- package/dist/custom-elements.json +1305 -946
- package/dist/index.d.ts +2 -2
- package/dist/index.js +20 -20
- package/dist/internal/base-classes/popover/popover.base.d.ts +24 -5
- package/dist/internal/base-classes/popover/popover.base.js +28 -29
- package/dist/internal/base-classes/popover/popover.styles.js +4 -5
- package/dist/internal/components/hint/hint.component.d.ts +4 -0
- package/dist/internal/components/hint/hint.component.js +47 -20
- package/dist/internal/components/hint/hint.styles.js +29 -25
- package/dist/internal/controllers/popover.controller.d.ts +2 -0
- package/dist/internal/helpers/uuid.d.ts +8 -10
- package/dist/internal/helpers/uuid.js +4 -11
- package/dist/internal/helpers/watch.d.ts +1 -1
- package/dist/internal/templates/asterisk.d.ts +1 -1
- package/dist/internal/templates/asterisk.js +4 -4
- package/dist/internal/types.d.ts +4 -0
- package/dist/styles/global-alt.css +1 -1
- package/dist/styles/global.css +1 -1
- package/dist/translations/en.d.ts +3 -0
- package/dist/translations/en.js +27 -0
- package/dist/translations/es.d.ts +3 -0
- package/dist/translations/es.js +27 -0
- package/dist/translations/index.d.ts +4 -0
- package/dist/translations/pt.d.ts +3 -0
- package/dist/translations/pt.js +27 -0
- package/dist/translations/sv.d.ts +3 -0
- package/dist/translations/sv.js +27 -0
- package/dist/types/jsx/custom-element-jsx.d.ts +243 -128
- package/dist/types/vue/index.d.ts +136 -127
- package/dist/utilities/localize.d.ts +28 -0
- package/dist/utilities/localize.js +13 -0
- package/dist/vscode.html-custom-data.json +168 -177
- package/dist/web-types.json +411 -381
- package/package.json +34 -41
@@ -1,50 +1,62 @@
|
|
1
1
|
import { css as e } from "lit";
|
2
2
|
const o = e`
|
3
3
|
@layer components {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
4
|
+
@layer base {
|
5
|
+
button {
|
6
|
+
--_skf-select-option-bg: var(--skf-interactive-bg-color-secondary);
|
7
|
+
--_skf-select-option-color: inherit;
|
8
|
+
--_skf-select-option-height: var(--skf-size-44);
|
9
|
+
|
10
|
+
align-items: center;
|
11
|
+
background-color: var(--_skf-select-option-bg);
|
12
|
+
block-size: var(--_skf-select-option-height);
|
13
|
+
color: var(--_skf-select-option-color);
|
14
|
+
display: flex;
|
15
|
+
gap: var(--skf-spacing-50);
|
16
|
+
padding-inline: var(--skf-spacing-50);
|
17
|
+
width: 100%;
|
16
18
|
}
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
+
#icon-check {
|
21
|
+
opacity: 0;
|
22
|
+
|
23
|
+
:host([selected]) & {
|
24
|
+
opacity: 1;
|
25
|
+
}
|
20
26
|
}
|
21
27
|
|
22
|
-
|
23
|
-
|
28
|
+
#adornments {
|
29
|
+
align-items: inherit;
|
30
|
+
display: inherit;
|
31
|
+
gap: inherit;
|
32
|
+
margin-inline-start: auto;
|
24
33
|
}
|
25
34
|
|
26
|
-
|
27
|
-
|
35
|
+
#short-label {
|
36
|
+
color: var(--skf-text-color-tertiary);
|
28
37
|
}
|
29
38
|
}
|
30
39
|
|
31
|
-
|
32
|
-
|
40
|
+
@layer states {
|
41
|
+
button {
|
42
|
+
&:disabled {
|
43
|
+
--_skf-select-option-color: var(--skf-interactive-text-color-disabled);
|
44
|
+
}
|
33
45
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
}
|
46
|
+
&:is(:hover, :focus):not(:disabled) {
|
47
|
+
--_skf-select-option-bg: var(--skf-interactive-bg-color-secondary-hover);
|
48
|
+
}
|
38
49
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
margin-inline-start: auto;
|
50
|
+
&:active:not(:disabled) {
|
51
|
+
--_skf-select-option-bg: var(--skf-interactive-bg-color-secondary-active);
|
52
|
+
}
|
53
|
+
}
|
44
54
|
}
|
45
55
|
|
46
|
-
|
47
|
-
|
56
|
+
@layer mods {
|
57
|
+
:host(:state(small)) button {
|
58
|
+
--_skf-select-option-height: var(--skf-size-32);
|
59
|
+
}
|
48
60
|
}
|
49
61
|
}
|
50
62
|
`;
|
@@ -1,10 +1,12 @@
|
|
1
|
+
import { SkfSelectOptionGroup } from '../select/select-option-group.component.js';
|
1
2
|
import '../tag/tag.js';
|
2
3
|
import { FormBase } from '../../internal/components/formBase.js';
|
3
4
|
import '../../internal/components/hint/hint.js';
|
4
5
|
import { PopoverController } from '../../internal/controllers/popover.controller.js';
|
5
6
|
import type { FormFieldSeverity } from '../../internal/types.js';
|
7
|
+
import { type Language } from '../../utilities/localize.js';
|
6
8
|
import { type CSSResultGroup } from 'lit';
|
7
|
-
import
|
9
|
+
import { SkfSelectOption, type SelectOptionEvent } from './select-option.component.js';
|
8
10
|
import { DeveloperFeedbackController, GlobalClickController, KeyboardNavigationController } from './select.controllers.js';
|
9
11
|
/**
|
10
12
|
* TODO: abstract the popover logic to a separate component/helper/partial, and use it in both select and in input[datalist], combobox etc
|
@@ -26,11 +28,14 @@ import { DeveloperFeedbackController, GlobalClickController, KeyboardNavigationC
|
|
26
28
|
* @event {Event} reset - Fired when the form is reset
|
27
29
|
* @event {CustomEvent} skf-select-dropdown - {detail: {expanded: boolean}} Fired when the select dropdown is toggled
|
28
30
|
* @event {CustomEvent} skf-select-option-select - {detail: {value: string | null, option: SkfSelectOption}} Fired when the select dropdown is toggled
|
31
|
+
* @event {CustomEvent} skf-update-calendar-view - Fires when the calendar view is updated
|
29
32
|
*
|
30
33
|
* @tagname skf-select
|
31
34
|
*/
|
32
35
|
export declare class SkfSelect extends FormBase {
|
36
|
+
#private;
|
33
37
|
static styles: CSSResultGroup;
|
38
|
+
private _componentIsConnected;
|
34
39
|
/** @internal */
|
35
40
|
selectDelay: number;
|
36
41
|
/** @internal */
|
@@ -53,6 +58,8 @@ export declare class SkfSelect extends FormBase {
|
|
53
58
|
get selectedOptionsText(): string[];
|
54
59
|
/** If defined, displays provided label */
|
55
60
|
label?: string;
|
61
|
+
/** Sets the internal language of the component */
|
62
|
+
lang: Language;
|
56
63
|
/** If defined, limits the number of selectable options */
|
57
64
|
max?: number;
|
58
65
|
/** If defined, sets the minimum number of required options */
|
@@ -61,22 +68,18 @@ export declare class SkfSelect extends FormBase {
|
|
61
68
|
multiple: boolean;
|
62
69
|
/** If defined, set name of the component */
|
63
70
|
name?: string;
|
64
|
-
/** If defined, renders an alternative A11y text for the asterisk */
|
65
|
-
requiredLabel?: string;
|
66
71
|
/** If defined, displays provided severity state */
|
67
72
|
severity?: FormFieldSeverity;
|
68
73
|
/** If true, displays valid state after interaction */
|
69
74
|
showValid: boolean;
|
70
75
|
/** Size of the Select */
|
71
76
|
size: 'sm' | 'md';
|
72
|
-
/**
|
77
|
+
/** Returns the selected value. (if multiple: in a comma separated string). If set will default set corresponding option. */
|
73
78
|
set value(newValue: string);
|
74
79
|
get value(): string;
|
75
|
-
/** @internal */
|
76
|
-
/** Stores the selected SkfSelectOption tag(s) in a array. Is the source of truth for the internal state. */
|
80
|
+
/** @internal - Stores the selected SkfSelectOption tag(s) in a array. Is the source of truth for the internal state. */
|
77
81
|
private _selectedOptions;
|
78
|
-
/** @internal */
|
79
|
-
/** The selected options in an array. Treat it as a read only property. See selectedValues, slectedSlots for computed value arrays. */
|
82
|
+
/** @internal - Read only. The selected options in an array. See also selectedValues, slectedSlots for computed value arrays. */
|
80
83
|
set selectedOptions(option: SkfSelectOption[]);
|
81
84
|
/** @internal */
|
82
85
|
get selectedOptions(): SkfSelectOption[];
|
@@ -92,6 +95,8 @@ export declare class SkfSelect extends FormBase {
|
|
92
95
|
/** @internal */
|
93
96
|
$popover: HTMLDivElement;
|
94
97
|
/** @internal */
|
98
|
+
_slottedItems: SkfSelectOption[] | SkfSelectOptionGroup[];
|
99
|
+
/** @internal */
|
95
100
|
protected globalClickController: GlobalClickController;
|
96
101
|
/** @internal */
|
97
102
|
protected keyboardNavController: KeyboardNavigationController;
|
@@ -102,6 +107,7 @@ export declare class SkfSelect extends FormBase {
|
|
102
107
|
constructor();
|
103
108
|
willUpdate(changedProperties: Map<string | number | symbol, unknown>): void;
|
104
109
|
firstUpdated(): void;
|
110
|
+
_handleSizeUpdate(): void;
|
105
111
|
handleExpandedChange(): void;
|
106
112
|
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
107
113
|
disconnectedCallback(): void;
|
@@ -131,8 +137,10 @@ export declare class SkfSelect extends FormBase {
|
|
131
137
|
_resetSelectedOptions: (target?: SkfSelectOption) => void;
|
132
138
|
/** @internal */
|
133
139
|
_handleSlotChange: () => void;
|
134
|
-
/** @internal */
|
135
|
-
|
140
|
+
/** @internal - on slot update, if value is set, select the corresponding option */
|
141
|
+
_ifValueIsSetSelectOption: () => void;
|
142
|
+
/** @internal - Computes the visible value of the select component - if multiple options are selected, shows a visually dimmed summary (meta info) */
|
143
|
+
_computeVisibleValue: () => string | null;
|
136
144
|
/** @internal */
|
137
145
|
private _validateInput;
|
138
146
|
render(): import("lit").TemplateResult<1>;
|
@@ -1,28 +1,38 @@
|
|
1
|
+
var _ = (l) => {
|
2
|
+
throw TypeError(l);
|
3
|
+
};
|
4
|
+
var v = (l, r, t) => r.has(l) || _("Cannot " + t);
|
5
|
+
var c = (l, r, t) => (v(l, r, "read from private field"), t ? t.call(l) : r.get(l)), g = (l, r, t) => r.has(l) ? _("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(l) : r.set(l, t), y = (l, r, t, e) => (v(l, r, "write to private field"), e ? e.call(l, t) : r.set(l, t), t);
|
6
|
+
import { SkfSelectOptionGroup as w } from "./select-option-group.component.js";
|
1
7
|
import "../tag/tag.js";
|
2
|
-
import { computePosition as
|
3
|
-
import { FormBase as
|
8
|
+
import { computePosition as x, flip as C, shift as V, offset as $ } from "@floating-ui/dom";
|
9
|
+
import { FormBase as L } from "../../internal/components/formBase.js";
|
4
10
|
import "../../internal/components/hint/hint.js";
|
5
|
-
import { PopoverController as
|
6
|
-
import { findMatchingTags as
|
7
|
-
import { hintSeverity as
|
8
|
-
import { raiseError as
|
9
|
-
import { watch as
|
10
|
-
import { Asterisk as
|
11
|
-
import { componentStyles as
|
12
|
-
import {
|
13
|
-
import {
|
14
|
-
import {
|
15
|
-
import {
|
16
|
-
import {
|
17
|
-
import {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
11
|
+
import { PopoverController as E } from "../../internal/controllers/popover.controller.js";
|
12
|
+
import { findMatchingTags as k } from "../../internal/helpers/findMatchingTags.js";
|
13
|
+
import { hintSeverity as A } from "../../internal/helpers/hintSeverity.js";
|
14
|
+
import { raiseError as D } from "../../internal/helpers/raiseError.js";
|
15
|
+
import { watch as S } from "../../internal/helpers/watch.js";
|
16
|
+
import { Asterisk as I } from "../../internal/templates/asterisk.js";
|
17
|
+
import { componentStyles as P } from "../../styles/component.styles.js";
|
18
|
+
import { LocalizeController as T } from "../../utilities/localize.js";
|
19
|
+
import { nothing as b, html as p } from "lit";
|
20
|
+
import { property as a, state as u, query as m, queryAssignedElements as F } from "lit/decorators.js";
|
21
|
+
import { classMap as U } from "lit/directives/class-map.js";
|
22
|
+
import { ifDefined as O } from "lit/directives/if-defined.js";
|
23
|
+
import { SkfSelectOption as z } from "./select-option.component.js";
|
24
|
+
import { GlobalClickController as M, KeyboardNavigationController as q, DeveloperFeedbackController as j } from "./select.controllers.js";
|
25
|
+
import { styles as N } from "./select.styles.js";
|
26
|
+
var B = Object.defineProperty, R = Object.getOwnPropertyDescriptor, o = (l, r, t, e) => {
|
27
|
+
for (var i = e > 1 ? void 0 : e ? R(r, t) : r, d = l.length - 1, n; d >= 0; d--)
|
28
|
+
(n = l[d]) && (i = (e ? n(r, t, i) : n(i)) || i);
|
29
|
+
return e && i && B(r, t, i), i;
|
30
|
+
}, h;
|
31
|
+
const f = class f extends L {
|
24
32
|
constructor() {
|
25
|
-
super()
|
33
|
+
super();
|
34
|
+
g(this, h);
|
35
|
+
y(this, h, new T(this)), this._componentIsConnected = !1, this.selectDelay = 200, this._optionsList = [], this.buttonLabel = "Select an option", this.hideLabel = !1, this.hideTags = !1, this.lang = "en", this.multiple = !1, this.showValid = !1, this.size = "md", this._expanded = !1, this._invalid = !1, this.globalClickController = new M(this), this.keyboardNavController = new q(this), this.developerFeedbackController = new j(this), this.popoverController = new E(this), this._handleOptionSelected = (t) => {
|
26
36
|
this._pristine = !1;
|
27
37
|
const e = this._selectedOptions.length > 0;
|
28
38
|
this.setFormValue(e ? this.selectedValues.join(",") : null), this._updateState(t);
|
@@ -33,9 +43,9 @@ const c = class c extends b {
|
|
33
43
|
this.$popover.style.setProperty("--select-width", `${String(this.offsetWidth)}px`);
|
34
44
|
}, 50);
|
35
45
|
}, this.reposition = async () => {
|
36
|
-
const { x: t, y: e } = await
|
46
|
+
const { x: t, y: e } = await x(this.$anchor, this.$popover, {
|
37
47
|
placement: "bottom",
|
38
|
-
middleware: [
|
48
|
+
middleware: [C(), V(), $(2)],
|
39
49
|
strategy: "fixed"
|
40
50
|
});
|
41
51
|
Object.assign(this.$popover.style, {
|
@@ -59,19 +69,36 @@ const c = class c extends b {
|
|
59
69
|
default:
|
60
70
|
throw new Error("Something went wrong");
|
61
71
|
}
|
62
|
-
this.emitEvent("change"), this._validateInput(), this.$selectedValue && (this.$selectedValue.animate([{ opacity: 0.5 }, { opacity: 1 }], this.selectDelay).onfinish = () => {
|
72
|
+
this._componentIsConnected && this.emitEvent("change"), this._validateInput(), this.$selectedValue && (this.$selectedValue.animate([{ opacity: 0.5 }, { opacity: 1 }], this.selectDelay).onfinish = () => {
|
63
73
|
this.multiple || (this._expanded = !1), t("done");
|
64
74
|
});
|
65
75
|
}), this._resetSelectedOptions = (t) => {
|
66
76
|
const e = !t;
|
67
|
-
this._optionsList.forEach((
|
68
|
-
(e ||
|
69
|
-
});
|
77
|
+
this._optionsList.forEach((i) => {
|
78
|
+
(e || i !== t) && i.removeAttribute("selected");
|
79
|
+
}), this._optionsList = [];
|
70
80
|
}, this._handleSlotChange = () => {
|
71
|
-
this._collectSlotOptionTags(), this._validateInput();
|
81
|
+
this._handleSizeUpdate(), this._collectSlotOptionTags(), this._ifValueIsSetSelectOption(), this._validateInput(), this._componentIsConnected = !0;
|
82
|
+
}, this._ifValueIsSetSelectOption = () => {
|
83
|
+
if (this.value)
|
84
|
+
if (this.multiple) {
|
85
|
+
const t = String(this.value).split(",").map((e) => e.toLowerCase().trim());
|
86
|
+
this._optionsList.forEach((e) => {
|
87
|
+
t.includes(e.value.toLowerCase().trim()) ? (e.setSelectedDiscrete = !0, this.selectedOptions = [...this.selectedOptions, e]) : (e.setSelectedDiscrete = !1, this._selectedOptions = this._selectedOptions.filter(
|
88
|
+
(i) => i.value.toLowerCase().trim() !== e.value.toLowerCase().trim()
|
89
|
+
));
|
90
|
+
}), this._setValue().catch((e) => {
|
91
|
+
console.error(e);
|
92
|
+
});
|
93
|
+
} else {
|
94
|
+
const t = this.value.toLowerCase().trim(), e = this._optionsList.find((i) => i.value.toLowerCase().trim() === t);
|
95
|
+
e && (e.setSelectedDiscrete = !0, this.selectedOptions = [e], this._setValue().catch((i) => {
|
96
|
+
console.error(i);
|
97
|
+
}));
|
98
|
+
}
|
72
99
|
}, this._computeVisibleValue = () => {
|
73
100
|
var t, e;
|
74
|
-
return (t = this.$selectedValue) == null || t.classList.add("contains-meta-info"), this._selectedOptions.length > 1 ? `(${
|
101
|
+
return (t = this.$selectedValue) == null || t.classList.add("contains-meta-info"), this._selectedOptions.length > 1 ? `(${c(this, h).term("itemsSelected", this._selectedOptions.length)})` : this.value ? ((e = this.$selectedValue) == null || e.classList.remove("contains-meta-info"), this._selectedOptions[0].textContent) : this.buttonLabel;
|
75
102
|
}, this._selectedOptions = [];
|
76
103
|
}
|
77
104
|
set selectedValues(t) {
|
@@ -89,8 +116,12 @@ const c = class c extends b {
|
|
89
116
|
return this._selectedOptions.map((t) => t.textContent ?? "");
|
90
117
|
}
|
91
118
|
set value(t) {
|
92
|
-
|
93
|
-
this.
|
119
|
+
let e = [];
|
120
|
+
this.multiple ? e = String(t).split(",").map((i) => i.toLowerCase().trim()) : e = [String(t).toLowerCase().trim()], this._selectedOptions = this._optionsList.filter(
|
121
|
+
(i) => e.includes(i.value.toLowerCase().trim())
|
122
|
+
), this._optionsList.forEach((i) => {
|
123
|
+
i.selected && (i.setSelectedDiscrete = !1);
|
124
|
+
}), this._selectedOptions.forEach((i) => i.setSelectedDiscrete = !0), this._setValue();
|
94
125
|
}
|
95
126
|
get value() {
|
96
127
|
return this._selectedOptions.length ? this._selectedOptions.length === 1 ? this._selectedOptions[0].value.trim() : this._selectedOptions.map((t) => t.value.trim()).join(",") : "";
|
@@ -123,16 +154,21 @@ const c = class c extends b {
|
|
123
154
|
var t;
|
124
155
|
this.addEventListener("skf-select-option-select", this._handleOptionSelected), (t = this._internals.form) == null || t.addEventListener("reset", this._handleReset), this.onUpdateComplete(), this._validateInput();
|
125
156
|
}
|
157
|
+
_handleSizeUpdate() {
|
158
|
+
this._slottedItems.forEach((t) => {
|
159
|
+
(t instanceof z || t instanceof w) && (t.small = this.size === "sm");
|
160
|
+
});
|
161
|
+
}
|
126
162
|
handleExpandedChange() {
|
127
163
|
this._expanded ? (this.$popover.togglePopover(this._expanded), this.popoverController.start()) : (this.$popover.togglePopover(this._expanded), this.popoverController.stop().catch((t) => {
|
128
164
|
console.error(t);
|
129
165
|
})), this.emit("skf-select-dropdown", { detail: { expanded: this._expanded } });
|
130
166
|
}
|
131
|
-
attributeChangedCallback(t, e,
|
132
|
-
if (super.attributeChangedCallback(t, e,
|
133
|
-
if (typeof
|
134
|
-
const
|
135
|
-
this._pristine = !1, this._invalid = !0, this.setValidity({ customError: !0 },
|
167
|
+
attributeChangedCallback(t, e, i) {
|
168
|
+
if (super.attributeChangedCallback(t, e, i), t === "custom-invalid")
|
169
|
+
if (typeof i == "string") {
|
170
|
+
const n = this.withFallback(i);
|
171
|
+
this._pristine = !1, this._invalid = !0, this.setValidity({ customError: !0 }, n), this.checkValidity();
|
136
172
|
} else
|
137
173
|
this.setValidity({}), this._validateInput();
|
138
174
|
}
|
@@ -147,8 +183,8 @@ const c = class c extends b {
|
|
147
183
|
e.selected && (this.selectedOptions = [...this.selectedOptions, e]);
|
148
184
|
});
|
149
185
|
else {
|
150
|
-
const e = this._selectedOptions.length > 0,
|
151
|
-
e && (this._selectedOptions[0].setSelectedDiscrete = !1, this._selectedOptions = []),
|
186
|
+
const e = this._selectedOptions.length > 0, i = t.detail.value !== null;
|
187
|
+
e && (this._selectedOptions[0].setSelectedDiscrete = !1, this._selectedOptions = []), i && (this.selectedOptions = [t.target]);
|
152
188
|
}
|
153
189
|
this._setValue();
|
154
190
|
}
|
@@ -159,7 +195,7 @@ const c = class c extends b {
|
|
159
195
|
/** @internal */
|
160
196
|
/** Filter out elements other than skf-select-option and store in this._optionsList */
|
161
197
|
_collectSlotOptionTags() {
|
162
|
-
this._optionsList =
|
198
|
+
this._optionsList = k(this, "skf-select-option"), this._selectedOptions = this._optionsList.filter((t) => t.selected), D({
|
163
199
|
assert: this._optionsList.length > 0,
|
164
200
|
reason: "no-children",
|
165
201
|
replaceStrings: [this.localName, "skf-select-option"]
|
@@ -168,29 +204,29 @@ const c = class c extends b {
|
|
168
204
|
/** @internal */
|
169
205
|
_validateInput() {
|
170
206
|
this._invalid = !1;
|
171
|
-
const t = this.required && !this.selectedValues.length || this.min === 1, e = !!(this.min && this.selectedValues.length < this.min),
|
207
|
+
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);
|
172
208
|
if (this._internals.validity.customError) {
|
173
209
|
this._invalid = !0;
|
174
210
|
return;
|
175
211
|
} else if (t) {
|
176
|
-
const
|
177
|
-
this.setValidity({ valueMissing: !0 }, String(
|
212
|
+
const n = this.hasAttribute("data-valuemissing") ? this.getAttribute("data-valuemissing") : "Please select an option";
|
213
|
+
this.setValidity({ valueMissing: !0 }, String(n)), this._pristine || (this._invalid = !0);
|
178
214
|
} else if (e) {
|
179
|
-
const
|
180
|
-
this.setValidity({ rangeUnderflow: !0 }, String(
|
181
|
-
} else if (
|
182
|
-
const
|
183
|
-
this.setValidity({ rangeOverflow: !0 }, String(
|
215
|
+
const n = this.hasAttribute("data-rangeunderflow") ? this.getAttribute("data-rangeunderflow") : `Please select minimum ${String(this.min)} options`;
|
216
|
+
this.setValidity({ rangeUnderflow: !0 }, String(n)), this._pristine || (this._invalid = !0);
|
217
|
+
} else if (i) {
|
218
|
+
const n = this.hasAttribute("data-rangeoverflow") ? this.getAttribute("data-rangeoverflow") : `Please select maximum ${String(this.max)} options`;
|
219
|
+
this.setValidity({ rangeOverflow: !0 }, String(n)), this._pristine || (this._invalid = !0);
|
184
220
|
} else
|
185
221
|
this.setValidity({}), !this._pristine && this.showValid && this.setAttribute("valid", "true");
|
186
222
|
}
|
187
223
|
render() {
|
188
|
-
return
|
224
|
+
return p`
|
189
225
|
<div id="root">
|
190
226
|
<label>
|
191
227
|
<div class=${this.hideLabel ? "visually-hidden" : ""} id="label">
|
192
228
|
${this.label}
|
193
|
-
${this.required ?
|
229
|
+
${this.required ? I(c(this, h).term("required")) : b}
|
194
230
|
</div>
|
195
231
|
<button
|
196
232
|
?disabled=${this.disabled}
|
@@ -204,19 +240,19 @@ const c = class c extends b {
|
|
204
240
|
>
|
205
241
|
<span
|
206
242
|
id="selected-value"
|
207
|
-
class=${
|
243
|
+
class=${U({ "selected-value": !0, "contains-meta-info": !this.value })}>
|
208
244
|
${this._computeVisibleValue()}
|
209
245
|
</span>
|
210
246
|
<skf-icon class="arrow" data-color="custom" name="chevronDown"></skf-icon>
|
211
247
|
</button>
|
212
248
|
</label>
|
213
|
-
<div aria-multiselectable=${
|
249
|
+
<div aria-multiselectable=${O(this.multiple && !0)} id="select-dropdown" popover role="listbox">
|
214
250
|
<slot @slotchange=${this._handleSlotChange}></slot>
|
215
251
|
</div>
|
216
|
-
${!this.hideTags && this.multiple && this.selectedOptions.length > 0 ?
|
252
|
+
${!this.hideTags && this.multiple && this.selectedOptions.length > 0 ? p`
|
217
253
|
<div id="tags">
|
218
254
|
${this.selectedOptions.map(
|
219
|
-
(t) =>
|
255
|
+
(t) => p`
|
220
256
|
<skf-tag
|
221
257
|
style="${`view-transition-name: tag-${String(t.textContent).replace(/[^a-zA-Z]/g, "").toLowerCase()}`}"
|
222
258
|
removable
|
@@ -229,12 +265,13 @@ const c = class c extends b {
|
|
229
265
|
`
|
230
266
|
)}
|
231
267
|
</div>
|
232
|
-
` :
|
233
|
-
${this.hint &&
|
268
|
+
` : b}
|
269
|
+
${this.hint && p`
|
234
270
|
<skf-hint
|
271
|
+
?disabled=${this.disabled}
|
235
272
|
aria-live=${this._invalid ? "assertive" : "polite"}
|
236
273
|
id="hint"
|
237
|
-
severity=${
|
274
|
+
severity=${O(A(this._invalid, this.severity))}
|
238
275
|
>
|
239
276
|
${this.customInvalid ?? this.hint}
|
240
277
|
</skf-hint>
|
@@ -244,80 +281,86 @@ const c = class c extends b {
|
|
244
281
|
`;
|
245
282
|
}
|
246
283
|
};
|
247
|
-
|
248
|
-
let
|
249
|
-
|
250
|
-
|
251
|
-
],
|
252
|
-
|
253
|
-
|
254
|
-
],
|
255
|
-
|
256
|
-
|
257
|
-
],
|
258
|
-
|
259
|
-
|
260
|
-
],
|
261
|
-
|
262
|
-
|
263
|
-
],
|
264
|
-
|
265
|
-
|
266
|
-
],
|
267
|
-
|
268
|
-
|
269
|
-
],
|
270
|
-
|
271
|
-
|
272
|
-
],
|
273
|
-
|
274
|
-
|
275
|
-
],
|
276
|
-
|
277
|
-
|
278
|
-
],
|
279
|
-
|
280
|
-
|
281
|
-
],
|
282
|
-
|
283
|
-
|
284
|
-
],
|
285
|
-
|
286
|
-
|
287
|
-
],
|
288
|
-
|
289
|
-
|
290
|
-
],
|
291
|
-
|
292
|
-
|
293
|
-
],
|
294
|
-
|
295
|
-
|
296
|
-
],
|
297
|
-
|
298
|
-
|
299
|
-
],
|
300
|
-
|
301
|
-
|
302
|
-
],
|
303
|
-
|
304
|
-
|
305
|
-
],
|
306
|
-
|
307
|
-
|
308
|
-
],
|
309
|
-
|
310
|
-
|
311
|
-
],
|
312
|
-
|
313
|
-
|
314
|
-
],
|
315
|
-
|
316
|
-
|
317
|
-
],
|
318
|
-
|
319
|
-
|
320
|
-
],
|
284
|
+
h = new WeakMap(), f.styles = [P, N];
|
285
|
+
let s = f;
|
286
|
+
o([
|
287
|
+
a({ type: String, reflect: !0, attribute: "button-label" })
|
288
|
+
], s.prototype, "buttonLabel", 2);
|
289
|
+
o([
|
290
|
+
a({ type: String, attribute: "custom-invalid" })
|
291
|
+
], s.prototype, "customInvalid", 2);
|
292
|
+
o([
|
293
|
+
a({ type: Boolean, attribute: "hide-label" })
|
294
|
+
], s.prototype, "hideLabel", 2);
|
295
|
+
o([
|
296
|
+
a({ type: Boolean, reflect: !0, attribute: "hide-tags" })
|
297
|
+
], s.prototype, "hideTags", 2);
|
298
|
+
o([
|
299
|
+
a({ type: String })
|
300
|
+
], s.prototype, "hint", 2);
|
301
|
+
o([
|
302
|
+
a({ type: Array, attribute: !1 })
|
303
|
+
], s.prototype, "selectedValues", 1);
|
304
|
+
o([
|
305
|
+
a({ type: Array, attribute: !1 })
|
306
|
+
], s.prototype, "selectedOptionsText", 1);
|
307
|
+
o([
|
308
|
+
a({ type: String, reflect: !0 })
|
309
|
+
], s.prototype, "label", 2);
|
310
|
+
o([
|
311
|
+
a({ type: String })
|
312
|
+
], s.prototype, "lang", 2);
|
313
|
+
o([
|
314
|
+
a({ type: Number })
|
315
|
+
], s.prototype, "max", 2);
|
316
|
+
o([
|
317
|
+
a({ type: Number })
|
318
|
+
], s.prototype, "min", 2);
|
319
|
+
o([
|
320
|
+
a({ type: Boolean, reflect: !0 })
|
321
|
+
], s.prototype, "multiple", 2);
|
322
|
+
o([
|
323
|
+
a({ type: String })
|
324
|
+
], s.prototype, "name", 2);
|
325
|
+
o([
|
326
|
+
a()
|
327
|
+
], s.prototype, "severity", 2);
|
328
|
+
o([
|
329
|
+
a({ type: Boolean, attribute: "show-valid" })
|
330
|
+
], s.prototype, "showValid", 2);
|
331
|
+
o([
|
332
|
+
a({ reflect: !0 })
|
333
|
+
], s.prototype, "size", 2);
|
334
|
+
o([
|
335
|
+
a({ type: String, attribute: !1 })
|
336
|
+
], s.prototype, "value", 1);
|
337
|
+
o([
|
338
|
+
u()
|
339
|
+
], s.prototype, "selectedOptions", 1);
|
340
|
+
o([
|
341
|
+
u()
|
342
|
+
], s.prototype, "_expanded", 2);
|
343
|
+
o([
|
344
|
+
u()
|
345
|
+
], s.prototype, "_invalid", 2);
|
346
|
+
o([
|
347
|
+
m("#select-button")
|
348
|
+
], s.prototype, "$anchor", 2);
|
349
|
+
o([
|
350
|
+
m("#selected-value")
|
351
|
+
], s.prototype, "$selectedValue", 2);
|
352
|
+
o([
|
353
|
+
m("#select-dropdown")
|
354
|
+
], s.prototype, "$popover", 2);
|
355
|
+
o([
|
356
|
+
F()
|
357
|
+
], s.prototype, "_slottedItems", 2);
|
358
|
+
o([
|
359
|
+
S("size", { waitUntilFirstUpdate: !0 })
|
360
|
+
], s.prototype, "_handleSizeUpdate", 1);
|
361
|
+
o([
|
362
|
+
S("_expanded", { afterUpdate: !0 })
|
363
|
+
], s.prototype, "handleExpandedChange", 1);
|
321
364
|
export {
|
322
|
-
|
365
|
+
s as SkfSelect
|
323
366
|
};
|
@@ -104,7 +104,8 @@ class b {
|
|
104
104
|
reason: "attribute-mismatch",
|
105
105
|
replaceStrings: [t, "min or max", "together with multiple"]
|
106
106
|
}), a({
|
107
|
-
|
107
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
108
|
+
assert: this.host.hideTags && this.host.multiple || !this.host.hideTags,
|
108
109
|
reason: "attribute-mismatch",
|
109
110
|
replaceStrings: [t, "hide-tags", "together with multiple"]
|
110
111
|
});
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { visuallyHidden as r } from "../../styles/util.styles.js";
|
2
|
-
import { css as
|
2
|
+
import { css as e } from "lit";
|
3
3
|
const t = [
|
4
4
|
r,
|
5
|
-
|
5
|
+
e`
|
6
6
|
@layer components {
|
7
7
|
:host {
|
8
8
|
contain: initial;
|
@@ -53,6 +53,12 @@ const t = [
|
|
53
53
|
justify-content: space-between;
|
54
54
|
padding-inline: var(--skf-spacing-75);
|
55
55
|
|
56
|
+
span {
|
57
|
+
overflow: hidden;
|
58
|
+
text-overflow: ellipsis;
|
59
|
+
white-space: nowrap;
|
60
|
+
}
|
61
|
+
|
56
62
|
&:hover {
|
57
63
|
--_skf-select-button-bg-color: var(--skf-interactive-bg-color-secondary-hover);
|
58
64
|
}
|