@skf-design-system/ui-components 0.0.1-beta.4 → 1.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/checkbox/checkbox.component.js +1 -1
- package/dist/components/input/input.component.js +24 -26
- package/dist/components/select/select.component.d.ts +138 -0
- package/dist/components/select/select.component.js +311 -0
- package/dist/components/select/select.controllers.d.ts +59 -0
- package/dist/components/select/select.controllers.js +169 -0
- package/dist/components/select/select.d.ts +8 -0
- package/dist/components/select/select.js +6 -0
- package/dist/components/select/select.styles.d.ts +1 -0
- package/dist/components/select/select.styles.js +116 -0
- package/dist/components/select-option/select-option.component.d.ts +77 -0
- package/dist/components/select-option/select-option.component.js +117 -0
- package/dist/components/select-option/select-option.controllers.d.ts +9 -0
- package/dist/components/select-option/select-option.d.ts +8 -0
- package/dist/components/select-option/select-option.js +6 -0
- package/dist/components/select-option/select-option.styles.d.ts +1 -0
- package/dist/components/select-option/select-option.styles.js +53 -0
- package/dist/components/select-option-group/select-option-group.component.d.ts +16 -0
- package/dist/components/select-option-group/select-option-group.component.js +31 -0
- package/dist/components/select-option-group/select-option-group.d.ts +8 -0
- package/dist/components/select-option-group/select-option-group.js +6 -0
- package/dist/components/select-option-group/select-option-group.style.d.ts +1 -0
- package/dist/components/select-option-group/select-option-group.style.js +18 -0
- package/dist/components/tag/tag.component.d.ts +18 -2
- package/dist/components/tag/tag.component.js +69 -32
- package/dist/components/tag/tag.styles.js +0 -4
- package/dist/custom-elements.json +1279 -624
- package/dist/index.d.ts +3 -0
- package/dist/index.js +39 -30
- package/dist/internal/components/formBase.d.ts +18 -1
- package/dist/internal/components/formBase.js +25 -13
- package/dist/internal/components/skf-element.d.ts +4 -4
- package/dist/internal/components/skf-element.js +15 -19
- package/dist/internal/helpers/array.d.ts +4 -0
- package/dist/internal/helpers/findMatchingTags.d.ts +2 -0
- package/dist/internal/helpers/findMatchingTags.js +12 -0
- package/dist/internal/helpers/hintSeverity.d.ts +2 -0
- package/dist/internal/helpers/hintSeverity.js +6 -0
- package/dist/internal/helpers/raiseError.d.ts +28 -0
- package/dist/internal/helpers/raiseError.js +29 -0
- package/dist/internal/storybook/shadowRootTraverser.d.ts +2 -0
- package/dist/react/index.d.ts +6 -3
- package/dist/react/index.js +6 -3
- package/dist/react/skf-select/index.d.ts +21 -0
- package/dist/react/skf-select/index.js +21 -0
- package/dist/react/skf-select-option/index.d.ts +9 -0
- package/dist/react/skf-select-option/index.js +17 -0
- package/dist/react/skf-select-option-group/index.d.ts +3 -0
- package/dist/react/skf-select-option-group/index.js +13 -0
- package/dist/styles/form-field.styles.js +6 -6
- package/dist/types/jsx/custom-element-jsx.d.ts +326 -176
- package/dist/types/vue/index.d.ts +268 -135
- package/dist/vscode.html-custom-data.json +344 -147
- package/dist/web-types.json +755 -383
- package/package.json +34 -30
@@ -0,0 +1,169 @@
|
|
1
|
+
import { raiseError as r } from "../../internal/helpers/raiseError.js";
|
2
|
+
class d {
|
3
|
+
constructor(e) {
|
4
|
+
this.localExpanded = !1, this.host = e, e.addController(this);
|
5
|
+
}
|
6
|
+
hostDisconnected() {
|
7
|
+
this.disableScrollDetection();
|
8
|
+
}
|
9
|
+
hostUpdated() {
|
10
|
+
var e, t, s;
|
11
|
+
((e = this.host) == null ? void 0 : e._expanded) !== this.localExpanded && (this.localExpanded = !!((t = this.host) != null && t._expanded), (s = this.host) != null && s._expanded ? this.enableScrollDetection() : this.disableScrollDetection());
|
12
|
+
}
|
13
|
+
enableScrollDetection() {
|
14
|
+
if (this._scrollHandler = () => {
|
15
|
+
if (!this.host) return;
|
16
|
+
this.host._expanded = !1;
|
17
|
+
const t = this.host.getBoundingClientRect();
|
18
|
+
t.top < 0 || t.bottom > window.innerHeight || t.left < 0 || t.right > window.innerWidth ? this._onScrollOutOfView() : this._onScrollIntoView();
|
19
|
+
}, window.addEventListener("scroll", this._scrollHandler, !0), !this.host) return;
|
20
|
+
let e = this.host.parentElement;
|
21
|
+
for (; e; )
|
22
|
+
(e.scrollHeight > e.clientHeight || e.scrollWidth > e.clientWidth) && e.addEventListener("scroll", this._scrollHandler, !0), e = e.parentElement;
|
23
|
+
}
|
24
|
+
disableScrollDetection() {
|
25
|
+
if (!this._scrollHandler || (window.removeEventListener("scroll", this._scrollHandler, !0), !this.host)) return;
|
26
|
+
let e = this.host.parentElement;
|
27
|
+
for (; e; )
|
28
|
+
(e.scrollHeight > e.clientHeight || e.scrollWidth > e.clientWidth) && e.removeEventListener("scroll", this._scrollHandler, !0), e = e.parentElement;
|
29
|
+
}
|
30
|
+
/** @internal */
|
31
|
+
_onScrollOutOfView() {
|
32
|
+
this.host && (this.host._expanded = !1);
|
33
|
+
}
|
34
|
+
/** @internal */
|
35
|
+
_onScrollIntoView() {
|
36
|
+
}
|
37
|
+
}
|
38
|
+
class b {
|
39
|
+
constructor(e) {
|
40
|
+
this._onResize = () => {
|
41
|
+
this.host._expanded = !1;
|
42
|
+
}, this.host = e, e.addController(this);
|
43
|
+
}
|
44
|
+
hostConnected() {
|
45
|
+
this.enableResizeObserver();
|
46
|
+
}
|
47
|
+
hostDisconnected() {
|
48
|
+
this.disableResizeObserver();
|
49
|
+
}
|
50
|
+
enableResizeObserver() {
|
51
|
+
this._resizeObserver = new ResizeObserver(() => {
|
52
|
+
this.host._expanded = !1, this.host._updateWidth();
|
53
|
+
}), this._resizeObserver.observe(document.body), this._resizeObserver.observe(this.host);
|
54
|
+
}
|
55
|
+
disableResizeObserver() {
|
56
|
+
var e;
|
57
|
+
(e = this._resizeObserver) == null || e.disconnect();
|
58
|
+
}
|
59
|
+
}
|
60
|
+
class p {
|
61
|
+
constructor(e) {
|
62
|
+
this._globalClickHandler = (t) => {
|
63
|
+
t.target.closest(this.host.localName) || (this.host._expanded = !1);
|
64
|
+
}, this.host = e, e.addController(this);
|
65
|
+
}
|
66
|
+
// hostConnected() {
|
67
|
+
// this.enableGlobalClickDetection();
|
68
|
+
// }
|
69
|
+
hostDisconnected() {
|
70
|
+
this.disableGlobalClickDetection();
|
71
|
+
}
|
72
|
+
hostUpdated() {
|
73
|
+
this.host._expanded ? this.enableGlobalClickDetection() : this.disableGlobalClickDetection();
|
74
|
+
}
|
75
|
+
enableGlobalClickDetection() {
|
76
|
+
document.addEventListener("click", this._globalClickHandler);
|
77
|
+
}
|
78
|
+
disableGlobalClickDetection() {
|
79
|
+
document.removeEventListener("click", this._globalClickHandler);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
class u {
|
83
|
+
constructor(e) {
|
84
|
+
this._handleKeyDown = (t) => {
|
85
|
+
switch (t.key) {
|
86
|
+
case "ArrowDown":
|
87
|
+
t.preventDefault(), this._focusSiblingOption("next");
|
88
|
+
break;
|
89
|
+
case "ArrowUp":
|
90
|
+
t.preventDefault(), this._focusSiblingOption("prev");
|
91
|
+
break;
|
92
|
+
case "Enter":
|
93
|
+
t.preventDefault(), this._selectFocusedOption(t.target);
|
94
|
+
break;
|
95
|
+
case "Escape":
|
96
|
+
t.preventDefault(), this.host._expanded = !1, setTimeout(() => {
|
97
|
+
this.host.focus();
|
98
|
+
});
|
99
|
+
break;
|
100
|
+
}
|
101
|
+
}, this.host = e, e.addController(this), this._listenerActivated = !1;
|
102
|
+
}
|
103
|
+
hostDisconnected() {
|
104
|
+
this.removeKeyboardListener();
|
105
|
+
}
|
106
|
+
hostUpdated() {
|
107
|
+
this.host._expanded && !this._listenerActivated && this.setupKeyboardListener(), !this.host._expanded && this._listenerActivated && this.removeKeyboardListener();
|
108
|
+
}
|
109
|
+
setupKeyboardListener() {
|
110
|
+
this._listenerActivated = !0, this.host.addEventListener("keydown", this._handleKeyDown);
|
111
|
+
}
|
112
|
+
removeKeyboardListener() {
|
113
|
+
this.host.removeEventListener("keydown", this._handleKeyDown), this._listenerActivated = !1;
|
114
|
+
}
|
115
|
+
_focusFirstOption() {
|
116
|
+
const e = this._selectableOptions[0];
|
117
|
+
setTimeout(() => {
|
118
|
+
e.focus();
|
119
|
+
});
|
120
|
+
}
|
121
|
+
_focusSiblingOption(e) {
|
122
|
+
const t = (n) => n === document.activeElement, s = this._selectableOptions.find((n) => t(n));
|
123
|
+
if (!s) {
|
124
|
+
this._focusFirstOption();
|
125
|
+
return;
|
126
|
+
}
|
127
|
+
const h = this._selectableOptions.indexOf(s);
|
128
|
+
let o = h - 1, l = h + 1;
|
129
|
+
o < 0 && (o = this._selectableOptions.length - 1), l >= this._selectableOptions.length && (l = 0);
|
130
|
+
const a = this._selectableOptions[e === "next" ? l : o];
|
131
|
+
s.blur(), a.focus();
|
132
|
+
}
|
133
|
+
_selectFocusedOption(e) {
|
134
|
+
e.selected = !0;
|
135
|
+
}
|
136
|
+
get _selectableOptions() {
|
137
|
+
return this.host._optionsList.filter((e) => !e.disabled);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
class _ {
|
141
|
+
constructor(e) {
|
142
|
+
this.host = e, e.addController(this);
|
143
|
+
}
|
144
|
+
hostConnected() {
|
145
|
+
this._badAttributeCombinationWarning();
|
146
|
+
}
|
147
|
+
_badAttributeCombinationWarning() {
|
148
|
+
r({
|
149
|
+
assert: (this.host.min ?? 0) < (this.host.max ?? 1 / 0),
|
150
|
+
reason: "attribute-mismatch",
|
151
|
+
replaceStrings: [this.host.localName, "min", "smaller than max"]
|
152
|
+
}), r({
|
153
|
+
assert: ((this.host.min ?? this.host.max) && this.host.multiple) ?? !(this.host.min && this.host.max),
|
154
|
+
reason: "attribute-mismatch",
|
155
|
+
replaceStrings: [this.host.localName, "min or max", "together with multiple"]
|
156
|
+
}), r({
|
157
|
+
assert: (this.host.hideTags && this.host.multiple) ?? !this.host.hideTags,
|
158
|
+
reason: "attribute-mismatch",
|
159
|
+
replaceStrings: [this.host.localName, "hide-tags", "together with multiple"]
|
160
|
+
});
|
161
|
+
}
|
162
|
+
}
|
163
|
+
export {
|
164
|
+
_ as DeveloperFeedbackController,
|
165
|
+
p as GlobalClickController,
|
166
|
+
u as KeyboardNavigationController,
|
167
|
+
b as ResizeController,
|
168
|
+
d as ScrollController
|
169
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const styles: import("lit").CSSResult[];
|
@@ -0,0 +1,116 @@
|
|
1
|
+
import { visuallyHidden as r } from "../../styles/util.styles.js";
|
2
|
+
import { css as e } from "lit";
|
3
|
+
const t = [
|
4
|
+
r,
|
5
|
+
e`
|
6
|
+
@layer components {
|
7
|
+
:host {
|
8
|
+
contain: initial;
|
9
|
+
}
|
10
|
+
|
11
|
+
#select {
|
12
|
+
color: var(--_skf-select-color, var(--skf-text-color-primary));
|
13
|
+
display: flex;
|
14
|
+
flex-direction: column;
|
15
|
+
gap: var(--skf-spacing-25);
|
16
|
+
|
17
|
+
:host([size='sm']) & {
|
18
|
+
font-size: var(--skf-font-size-75);
|
19
|
+
font-weight: var(--skf-font-weight-medium);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
label {
|
24
|
+
display: inherit;
|
25
|
+
flex-direction: inherit;
|
26
|
+
gap: var(--_skf-select-label-gap, var(--skf-spacing-50));
|
27
|
+
|
28
|
+
:host([size='sm']) & {
|
29
|
+
--_skf-select-label-gap: var(--skf-spacing-25);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
#asterisk {
|
34
|
+
color: var(--skf-severity-fg-color-error);
|
35
|
+
}
|
36
|
+
|
37
|
+
button {
|
38
|
+
align-items: center;
|
39
|
+
background-color: var(
|
40
|
+
--_skf-select-button-bg-color,
|
41
|
+
var(--skf-interactive-bg-color-secondary)
|
42
|
+
);
|
43
|
+
block-size: var(--_skf-select-button-height, var(--skf-size-44));
|
44
|
+
border: var(--skf-border-width-sm) solid
|
45
|
+
var(--_skf-select-button-border-color, var(--skf-border-color-primary));
|
46
|
+
border-radius: var(--skf-border-radius-sm);
|
47
|
+
display: flex;
|
48
|
+
gap: 0 var(--skf-spacing-75);
|
49
|
+
justify-content: space-between;
|
50
|
+
padding-inline: var(--skf-spacing-75);
|
51
|
+
|
52
|
+
&:hover {
|
53
|
+
--_skf-select-button-bg-color: var(--skf-interactive-bg-color-secondary-hover);
|
54
|
+
}
|
55
|
+
|
56
|
+
&:active {
|
57
|
+
--_skf-select-button-bg-color: var(--skf-interactive-bg-color-secondary-active);
|
58
|
+
}
|
59
|
+
|
60
|
+
&:disabled {
|
61
|
+
--_skf-select-button-bg-color: var(--skf-interactive-bg-color-disabled);
|
62
|
+
--_skf-select-button-border-color: var(--skf-interactive-border-color-disabled);
|
63
|
+
}
|
64
|
+
|
65
|
+
:host([invalid]) & {
|
66
|
+
--_skf-select-button-border-color: var(--skf-severity-fg-color-error);
|
67
|
+
}
|
68
|
+
|
69
|
+
:host([valid]) & {
|
70
|
+
--_skf-select-button-border-color: var(--skf-severity-fg-color-success);
|
71
|
+
}
|
72
|
+
|
73
|
+
:host :has(:focus-visible) & {
|
74
|
+
outline: var(--skf-border-width-md) solid var(--skf-interactive-border-color-focus);
|
75
|
+
outline-offset: -1px;
|
76
|
+
}
|
77
|
+
|
78
|
+
:host([size='sm']) & {
|
79
|
+
--_skf-select-button-height: var(--skf-size-32);
|
80
|
+
}
|
81
|
+
|
82
|
+
:host([severity='alert']:not([invalid], [valid])) & {
|
83
|
+
--_skf-select-button-border-color: var(--skf-severity-fg-color-alert);
|
84
|
+
}
|
85
|
+
|
86
|
+
:host([severity='info']:not([invalid], [valid])) & {
|
87
|
+
--_skf-select-button-border-color: var(--skf-severity-fg-color-info);
|
88
|
+
}
|
89
|
+
|
90
|
+
:host([severity='success']:not([invalid], [valid])) & {
|
91
|
+
--_skf-select-button-border-color: var(--skf-severity-fg-color-success);
|
92
|
+
}
|
93
|
+
|
94
|
+
:host([severity='warning']:not([invalid], [valid])) & {
|
95
|
+
--_skf-select-button-border-color: var(--skf-severity-fg-color-warning);
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
#select-dropdown {
|
100
|
+
background-color: var(--skf-bg-color-neutral-1);
|
101
|
+
border: var(--skf-border-width-sm) solid var(--skf-border-color-tertiary);
|
102
|
+
box-shadow: var(--skf-shadow-sm); /* TODO: Discuss with design */
|
103
|
+
inline-size: var(--select-width, auto);
|
104
|
+
padding: var(--skf-spacing-25);
|
105
|
+
}
|
106
|
+
|
107
|
+
#tags {
|
108
|
+
display: flex;
|
109
|
+
gap: 0.5rem;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
`
|
113
|
+
];
|
114
|
+
export {
|
115
|
+
t as styles
|
116
|
+
};
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import { SkfElement } from '@internal/components/skf-element.js';
|
2
|
+
import type { IconColor } from '@skf-design-system/ui-assets';
|
3
|
+
import { type CSSResultGroup } from 'lit';
|
4
|
+
import '../icon/icon';
|
5
|
+
import { SkfIcon } from '../icon/icon';
|
6
|
+
import type { SkfSelect } from '../select/select.component.js';
|
7
|
+
export interface SelectOptionEvent {
|
8
|
+
value: string | null;
|
9
|
+
option: SkfSelectOption;
|
10
|
+
}
|
11
|
+
/**
|
12
|
+
* The `<skf-select-option>` is a component is used nested in a skf-select or skf-select-option-group.
|
13
|
+
*
|
14
|
+
* @documentation See [InVision DSM](https://skf.invisionapp.com/dsm/ab-skf/4-web-applications/nav/5fa7caf78c01200018354495/asset/6229d63d9fe16020a60657e5) for design principles
|
15
|
+
*
|
16
|
+
* @slot - The option's text content
|
17
|
+
* @slot icon - The option's slot for icon or custom meta information (svg).
|
18
|
+
*
|
19
|
+
* @event skf-select-option:select - {detail: { value: string | null, option: SkfSelectOption }} Fires when the option is selected/deselected.
|
20
|
+
*
|
21
|
+
* @tagname skf-select-option
|
22
|
+
*/
|
23
|
+
export declare class SkfSelectOption extends SkfElement {
|
24
|
+
static styles: CSSResultGroup;
|
25
|
+
static shadowRootOptions: {
|
26
|
+
delegatesFocus: boolean;
|
27
|
+
mode: ShadowRootMode;
|
28
|
+
serializable?: boolean;
|
29
|
+
slotAssignment?: SlotAssignmentMode;
|
30
|
+
};
|
31
|
+
/** @internal */
|
32
|
+
_parent: SkfSelect | null;
|
33
|
+
/** @internal */
|
34
|
+
protected _value?: string;
|
35
|
+
/**
|
36
|
+
* @internal
|
37
|
+
* Do not use directly, instead use `setSelectedDiscrete`.
|
38
|
+
* If true, instantly sets/unsets the selected property, without engaging ui feedback. Primarily for unselecting previous option in single select.
|
39
|
+
*/
|
40
|
+
_shortcutUpdate?: boolean;
|
41
|
+
/** If true, prevents interaction with the option */
|
42
|
+
disabled?: boolean;
|
43
|
+
/** If defined, set an icon */
|
44
|
+
icon?: SkfIcon['name'];
|
45
|
+
/** If defined, sets provided color on the icon */
|
46
|
+
iconColor?: IconColor;
|
47
|
+
/** If true, sets the option as selected */
|
48
|
+
selected?: boolean;
|
49
|
+
/** If defined, sets a short label */
|
50
|
+
shortLabel?: string;
|
51
|
+
/** The option's label text (equivalent to the tags textContent) */
|
52
|
+
set text(slottedTextContent: string);
|
53
|
+
get text(): string;
|
54
|
+
/** Returns or sets the tags value. If value is omitted, defaults to the tags text. */
|
55
|
+
set value(optionValue: string);
|
56
|
+
get value(): string;
|
57
|
+
/** @internal */
|
58
|
+
private _assignedNodes?;
|
59
|
+
constructor();
|
60
|
+
updated(changedProperties: Map<string | number | symbol, unknown>): void;
|
61
|
+
/**
|
62
|
+
* @internal
|
63
|
+
* This internal setter is to change selected state without emitting events triggering other side effects,
|
64
|
+
* e.g deselecting previous selected in a single select. Is used by skf-select in single select mode.
|
65
|
+
*/
|
66
|
+
set setSelectedDiscrete(value: boolean);
|
67
|
+
/**
|
68
|
+
* @internal
|
69
|
+
* Returns the slotted content as a string. If no slotted content, returns an empty string.
|
70
|
+
*/
|
71
|
+
private _getSlottedContent;
|
72
|
+
/** @internal */
|
73
|
+
private get _slotContainsOnlyText();
|
74
|
+
/** @internal */
|
75
|
+
_handleClick: (e: Event) => void;
|
76
|
+
render(): import("lit").TemplateResult<1>;
|
77
|
+
}
|
@@ -0,0 +1,117 @@
|
|
1
|
+
import { SkfElement as p } from "../../internal/components/skf-element.js";
|
2
|
+
import u from "../../styles/component.styles.js";
|
3
|
+
import { LitElement as f, html as h } from "lit";
|
4
|
+
import { property as n, queryAssignedNodes as m } from "lit/decorators.js";
|
5
|
+
import { ifDefined as _ } from "lit/directives/if-defined.js";
|
6
|
+
import "../icon/icon.js";
|
7
|
+
import { styles as y } from "./select-option.styles.js";
|
8
|
+
var v = Object.defineProperty, b = Object.getOwnPropertyDescriptor, o = (d, t, s, i) => {
|
9
|
+
for (var r = i > 1 ? void 0 : i ? b(t, s) : t, a = d.length - 1, c; a >= 0; a--)
|
10
|
+
(c = d[a]) && (r = (i ? c(t, s, r) : c(r)) || r);
|
11
|
+
return i && r && v(t, s, r), r;
|
12
|
+
};
|
13
|
+
const l = class l extends p {
|
14
|
+
constructor() {
|
15
|
+
super(), this._handleClick = (s) => {
|
16
|
+
s.stopPropagation(), this.selected = !this.selected;
|
17
|
+
};
|
18
|
+
const t = this.attachInternals();
|
19
|
+
t.role = "option", this._parent = this.closest("skf-select"), this._shortcutUpdate = !1;
|
20
|
+
}
|
21
|
+
set text(t) {
|
22
|
+
this.textContent = t.trim();
|
23
|
+
}
|
24
|
+
get text() {
|
25
|
+
var t;
|
26
|
+
return ((t = this.textContent) == null ? void 0 : t.trim()) ?? "";
|
27
|
+
}
|
28
|
+
set value(t) {
|
29
|
+
this._value = t.trim();
|
30
|
+
}
|
31
|
+
get value() {
|
32
|
+
var t;
|
33
|
+
return !this._value && this._slotContainsOnlyText ? this._getSlottedContent().trim() : ((t = this._value) == null ? void 0 : t.trim()) ?? this.text;
|
34
|
+
}
|
35
|
+
updated(t) {
|
36
|
+
super.updated(t), t.has("selected") && !this._shortcutUpdate && this.emit("skf-select-option:select", {
|
37
|
+
detail: {
|
38
|
+
value: this.selected ? this.value : null,
|
39
|
+
option: this
|
40
|
+
}
|
41
|
+
});
|
42
|
+
}
|
43
|
+
/**
|
44
|
+
* @internal
|
45
|
+
* This internal setter is to change selected state without emitting events triggering other side effects,
|
46
|
+
* e.g deselecting previous selected in a single select. Is used by skf-select in single select mode.
|
47
|
+
*/
|
48
|
+
set setSelectedDiscrete(t) {
|
49
|
+
(async () => {
|
50
|
+
this._shortcutUpdate = !0, this.selected = t, await this.updateComplete, this._shortcutUpdate = !1;
|
51
|
+
})();
|
52
|
+
}
|
53
|
+
/**
|
54
|
+
* @internal
|
55
|
+
* Returns the slotted content as a string. If no slotted content, returns an empty string.
|
56
|
+
*/
|
57
|
+
_getSlottedContent() {
|
58
|
+
return this._assignedNodes ? [...this._assignedNodes].map((t) => t.nodeType === Node.ELEMENT_NODE ? t.outerHTML : t.textContent).join() : "";
|
59
|
+
}
|
60
|
+
/** @internal */
|
61
|
+
get _slotContainsOnlyText() {
|
62
|
+
return this._assignedNodes ? [...this._assignedNodes].every(
|
63
|
+
(s) => {
|
64
|
+
var i;
|
65
|
+
return s.nodeType === Node.TEXT_NODE && ((i = s.textContent) == null ? void 0 : i.trim()) !== "";
|
66
|
+
}
|
67
|
+
) : "";
|
68
|
+
}
|
69
|
+
render() {
|
70
|
+
return h`
|
71
|
+
<button
|
72
|
+
@click=${this._handleClick}
|
73
|
+
aria-selected=${this.selected ? "true" : "false"}
|
74
|
+
?disabled=${this.disabled}
|
75
|
+
role="option"
|
76
|
+
>
|
77
|
+
<skf-icon id="icon-check" name="check" size="sm"></skf-icon>
|
78
|
+
<slot>${this.text}</slot>
|
79
|
+
<div id="adornments">
|
80
|
+
<slot name="icon">
|
81
|
+
${this.icon && h`<skf-icon name=${this.icon} color=${_(this.iconColor)}></skf-icon>`}
|
82
|
+
</slot>
|
83
|
+
${this.shortLabel && h`<div id="short-label">${this.shortLabel}</div>`}
|
84
|
+
</div>
|
85
|
+
</button>
|
86
|
+
`;
|
87
|
+
}
|
88
|
+
};
|
89
|
+
l.styles = [u, y], l.shadowRootOptions = { ...f.shadowRootOptions, delegatesFocus: !0 };
|
90
|
+
let e = l;
|
91
|
+
o([
|
92
|
+
n({ type: Boolean, reflect: !0 })
|
93
|
+
], e.prototype, "disabled", 2);
|
94
|
+
o([
|
95
|
+
n({ reflect: !0 })
|
96
|
+
], e.prototype, "icon", 2);
|
97
|
+
o([
|
98
|
+
n({ reflect: !0, attribute: "icon-color" })
|
99
|
+
], e.prototype, "iconColor", 2);
|
100
|
+
o([
|
101
|
+
n({ type: Boolean, reflect: !0 })
|
102
|
+
], e.prototype, "selected", 2);
|
103
|
+
o([
|
104
|
+
n({ reflect: !0, attribute: "short-label" })
|
105
|
+
], e.prototype, "shortLabel", 2);
|
106
|
+
o([
|
107
|
+
n({ attribute: !1 })
|
108
|
+
], e.prototype, "text", 1);
|
109
|
+
o([
|
110
|
+
n({ reflect: !0 })
|
111
|
+
], e.prototype, "value", 1);
|
112
|
+
o([
|
113
|
+
m({ flatten: !0 })
|
114
|
+
], e.prototype, "_assignedNodes", 2);
|
115
|
+
export {
|
116
|
+
e as SkfSelectOption
|
117
|
+
};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import type { SkfSelectOption } from '@components/select-option/select-option.component.js';
|
2
|
+
import type { ReactiveController } from 'lit';
|
3
|
+
type ControllerHost = SkfSelectOption;
|
4
|
+
export declare class DeveloperFeedbackController implements ReactiveController {
|
5
|
+
host: ControllerHost;
|
6
|
+
constructor(host: ControllerHost);
|
7
|
+
hostUpdated(): void;
|
8
|
+
}
|
9
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { css as e } from "lit";
|
2
|
+
const o = e`
|
3
|
+
@layer components {
|
4
|
+
button {
|
5
|
+
align-items: center;
|
6
|
+
background-color: var(--_skf-select-option-bg, var(--skf-interactive-bg-color-secondary));
|
7
|
+
block-size: var(--_skf-select-option-height, var(--skf-size-44));
|
8
|
+
color: var(--_skf-select-option-color, inherit);
|
9
|
+
display: flex;
|
10
|
+
gap: var(--skf-spacing-50);
|
11
|
+
padding-inline: var(--skf-spacing-50);
|
12
|
+
width: 100%;
|
13
|
+
|
14
|
+
&:disabled {
|
15
|
+
--_skf-select-option-color: var(--skf-interactive-text-color-disabled);
|
16
|
+
}
|
17
|
+
|
18
|
+
&:is(:hover, :focus):not(:disabled) {
|
19
|
+
--_skf-select-option-bg: var(--skf-interactive-bg-color-secondary-hover);
|
20
|
+
}
|
21
|
+
|
22
|
+
&:active:not(:disabled) {
|
23
|
+
--_skf-select-option-bg: var(--skf-interactive-bg-color-secondary-active);
|
24
|
+
}
|
25
|
+
|
26
|
+
:host-context(skf-select[size='sm']) & {
|
27
|
+
--_skf-select-option-height: var(--skf-size-32);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
#icon-check {
|
32
|
+
opacity: 0;
|
33
|
+
|
34
|
+
:host([selected]) & {
|
35
|
+
opacity: 1;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
#adornments {
|
40
|
+
align-items: inherit;
|
41
|
+
display: inherit;
|
42
|
+
gap: inherit;
|
43
|
+
margin-inline-start: auto;
|
44
|
+
}
|
45
|
+
|
46
|
+
#short-label {
|
47
|
+
color: var(--skf-text-color-tertiary);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
`;
|
51
|
+
export {
|
52
|
+
o as styles
|
53
|
+
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { SkfElement } from '@internal/components/skf-element';
|
2
|
+
import { type CSSResultGroup } from 'lit';
|
3
|
+
/**
|
4
|
+
* The `<skf-select-option-group>` is a component that groups select-options
|
5
|
+
*
|
6
|
+
* @documentation See [InVision DSM](https://skf.invisionapp.com/dsm/ab-skf/4-web-applications/nav/5fa7caf78c01200018354495/asset/6229d63d9fe16020a60657e5) for design principles
|
7
|
+
*
|
8
|
+
* @slot - The component's placeholder content
|
9
|
+
*
|
10
|
+
* @tagname skf-select-option-group
|
11
|
+
*/
|
12
|
+
export declare class SkfSelectOptionGroup extends SkfElement {
|
13
|
+
static styles: CSSResultGroup;
|
14
|
+
label: string;
|
15
|
+
render(): import("lit").TemplateResult<1>;
|
16
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { SkfElement as a } from "../../internal/components/skf-element.js";
|
2
|
+
import f from "../../styles/component.styles.js";
|
3
|
+
import { html as p } from "lit";
|
4
|
+
import { property as d } from "lit/decorators.js";
|
5
|
+
import { styles as n } from "./select-option-group.style.js";
|
6
|
+
var v = Object.defineProperty, u = (o, s, i, b) => {
|
7
|
+
for (var r = void 0, e = o.length - 1, m; e >= 0; e--)
|
8
|
+
(m = o[e]) && (r = m(s, i, r) || r);
|
9
|
+
return r && v(s, i, r), r;
|
10
|
+
};
|
11
|
+
const l = class l extends a {
|
12
|
+
constructor() {
|
13
|
+
super(...arguments), this.label = "Default label";
|
14
|
+
}
|
15
|
+
render() {
|
16
|
+
return p`
|
17
|
+
<div role="group">
|
18
|
+
<div id="label">${this.label}</div>
|
19
|
+
<slot></slot>
|
20
|
+
</div>
|
21
|
+
`;
|
22
|
+
}
|
23
|
+
};
|
24
|
+
l.styles = [f, n];
|
25
|
+
let t = l;
|
26
|
+
u([
|
27
|
+
d({ reflect: !0 })
|
28
|
+
], t.prototype, "label");
|
29
|
+
export {
|
30
|
+
t as SkfSelectOptionGroup
|
31
|
+
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { SkfSelectOptionGroup } from './select-option-group.component';
|
2
|
+
export * from './select-option-group.component';
|
3
|
+
export default SkfSelectOptionGroup;
|
4
|
+
declare global {
|
5
|
+
interface HTMLElementTagNameMap {
|
6
|
+
'skf-select-option-group': SkfSelectOptionGroup;
|
7
|
+
}
|
8
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { css as e } from "lit";
|
2
|
+
const t = e`
|
3
|
+
@layer components {
|
4
|
+
#label {
|
5
|
+
align-items: center;
|
6
|
+
block-size: var(--_skf-select-option-group-height, var(--skf-size-44));
|
7
|
+
display: flex;
|
8
|
+
font-weight: var(--skf-font-weight-bold);
|
9
|
+
|
10
|
+
:host-context(skf-select[size='sm']) & {
|
11
|
+
--_skf-select-option-group-height: var(--skf-size-32);
|
12
|
+
}
|
13
|
+
}
|
14
|
+
}
|
15
|
+
`;
|
16
|
+
export {
|
17
|
+
t as styles
|
18
|
+
};
|