scb-wc-test 0.1.63 → 0.1.65
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/all.js +4 -0
- package/index.d.ts +2 -0
- package/index.js +40 -36
- package/mvc/components/all.js +2 -0
- package/mvc/components/scb-accordion/scb-accordion-item.js +43 -42
- package/mvc/components/scb-segmented-button/scb-segmented-button.js +21 -0
- package/mvc/components/scb-segmented-button/scb-segmented-item.js +72 -0
- package/package.json +10 -2
- package/scb-accordion/scb-accordion-item.d.ts +7 -9
- package/scb-accordion/scb-accordion-item.js +123 -132
- package/scb-segmented-button/scb-segmented-button.d.ts +25 -0
- package/scb-segmented-button/scb-segmented-button.js +87 -0
- package/scb-segmented-button/scb-segmented-item.d.ts +15 -0
- package/scb-segmented-button/scb-segmented-item.js +116 -0
- package/scb-wc-test.bundle.js +451 -359
|
@@ -1,137 +1,117 @@
|
|
|
1
|
-
import { css as
|
|
2
|
-
import { property as o, customElement as
|
|
1
|
+
import { css as m, LitElement as v, nothing as p, html as l } from "lit";
|
|
2
|
+
import { property as o, customElement as h } from "lit/decorators.js";
|
|
3
3
|
import "@material/web/focus/md-focus-ring.js";
|
|
4
|
-
var u = Object.defineProperty,
|
|
5
|
-
for (var n = r > 1 ? void 0 : r ?
|
|
6
|
-
(
|
|
7
|
-
return r && n && u(
|
|
4
|
+
var u = Object.defineProperty, b = Object.getOwnPropertyDescriptor, a = (t, i, s, r) => {
|
|
5
|
+
for (var n = r > 1 ? void 0 : r ? b(i, s) : i, c = t.length - 1, d; c >= 0; c--)
|
|
6
|
+
(d = t[c]) && (n = (r ? d(i, s, n) : d(n)) || n);
|
|
7
|
+
return r && n && u(i, s, n), n;
|
|
8
8
|
};
|
|
9
|
-
let
|
|
9
|
+
let e = class extends v {
|
|
10
10
|
constructor() {
|
|
11
|
-
super(...arguments), this.
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
super(...arguments), this.open = !1, this.title = "", this.content = "", this.overline = "", this.supportingText = "", this.leading = !1, this.leadingVariant = "", this.leadingIcon = "", this.imgHrefImage = "", this.avatarLabel = "", this.avatarAlt = "", this.avatarVariant = "icon", this.avatarSrc = "", this.density = 0, this._unique = e._uid(), this._onToggle = (t) => {
|
|
12
|
+
const i = t.currentTarget;
|
|
13
|
+
this.open = !!i.open;
|
|
14
|
+
const s = this.closest("scb-accordion");
|
|
15
|
+
this.open && s && !s.hasAttribute("detached") && s.querySelectorAll("scb-accordion-item").forEach((n) => {
|
|
16
|
+
n !== this && n.setOpen(!1);
|
|
17
|
+
}), this._applyInertByOpen(), this.dispatchEvent(new CustomEvent("open-changed", {
|
|
18
|
+
detail: { open: this.open, title: this.title },
|
|
19
|
+
bubbles: !0,
|
|
20
|
+
composed: !0
|
|
21
|
+
}));
|
|
16
22
|
};
|
|
17
23
|
}
|
|
18
24
|
static _uid() {
|
|
19
|
-
var
|
|
20
|
-
return ((
|
|
25
|
+
var t, i;
|
|
26
|
+
return ((i = (t = globalThis.crypto) == null ? void 0 : t.randomUUID) == null ? void 0 : i.call(t)) ?? `${e._uidPrefix}-${++e._uidSeq}`;
|
|
21
27
|
}
|
|
22
28
|
async firstUpdated() {
|
|
23
|
-
|
|
29
|
+
e._mdIconLoaded || (await import("@material/web/icon/icon.js"), e._mdIconLoaded = !0), e._mdRippleLoaded || (await import("@material/web/ripple/ripple.js"), e._mdRippleLoaded = !0), this._applyInertByOpen();
|
|
24
30
|
}
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
_applyInertByOpen() {
|
|
32
|
+
const t = this.renderRoot.querySelector(".scb-accordion-bottom"), i = this.renderRoot.querySelector("details");
|
|
33
|
+
!t || !i || (i.open ? (t.removeAttribute("inert"), t.setAttribute("aria-hidden", "false")) : (t.setAttribute("inert", ""), t.setAttribute("aria-hidden", "true")));
|
|
27
34
|
}
|
|
28
|
-
_onKeyDown(
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
break;
|
|
35
|
+
_onKeyDown(t) {
|
|
36
|
+
const i = this.closest("scb-accordion"), r = Array.from((i == null ? void 0 : i.querySelectorAll("scb-accordion-item")) || []).map((d) => {
|
|
37
|
+
var g;
|
|
38
|
+
return ((g = d.renderRoot.querySelector("details")) == null ? void 0 : g.querySelector(".scb-accordion-top")) || null;
|
|
39
|
+
}).filter((d) => !!d), n = t.currentTarget, c = r.indexOf(n);
|
|
40
|
+
switch (t.key) {
|
|
35
41
|
case "ArrowDown":
|
|
36
|
-
|
|
42
|
+
t.preventDefault(), c < r.length - 1 && r[c + 1].focus();
|
|
37
43
|
break;
|
|
38
44
|
case "ArrowUp":
|
|
39
|
-
|
|
45
|
+
t.preventDefault(), c > 0 && r[c - 1].focus();
|
|
40
46
|
break;
|
|
41
47
|
case "Home":
|
|
42
|
-
|
|
48
|
+
t.preventDefault(), r.length && r[0].focus();
|
|
43
49
|
break;
|
|
44
50
|
case "End":
|
|
45
|
-
|
|
51
|
+
t.preventDefault(), r.length && r[r.length - 1].focus();
|
|
46
52
|
break;
|
|
47
53
|
}
|
|
48
54
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return l`<md-icon>${this.leadingIcon}</md-icon>`;
|
|
54
|
-
case "avatar":
|
|
55
|
-
return l`
|
|
56
|
-
<scb-avatar
|
|
57
|
-
label=${this.avatarLabel}
|
|
58
|
-
alt=${this.avatarAlt}
|
|
59
|
-
src=${this.avatarVariant === "image" ? this.avatarSrc : ""}
|
|
60
|
-
size="medium"
|
|
61
|
-
shape="circular"
|
|
62
|
-
variant=${this.avatarVariant}
|
|
63
|
-
></scb-avatar>
|
|
64
|
-
`;
|
|
65
|
-
case "image":
|
|
66
|
-
return this.imgHrefImage ? l`<img part="leading-image" class="img" src="${this.imgHrefImage}" alt="" />` : p;
|
|
67
|
-
default:
|
|
68
|
-
return p;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
_applyInert() {
|
|
72
|
-
const e = this.renderRoot.querySelector(".scb-accordion-bottom");
|
|
73
|
-
e && (this.expanded ? (e.removeAttribute("inert"), e.setAttribute("aria-hidden", "false")) : (e.setAttribute("inert", ""), e.setAttribute("aria-hidden", "true")));
|
|
74
|
-
}
|
|
75
|
-
_emitExpandedChanged() {
|
|
76
|
-
this.dispatchEvent(new CustomEvent("expanded-changed", {
|
|
77
|
-
detail: { expanded: this.expanded, label: this.label },
|
|
78
|
-
bubbles: !0,
|
|
79
|
-
composed: !0
|
|
80
|
-
}));
|
|
55
|
+
setOpen(t) {
|
|
56
|
+
this.open = !!t;
|
|
57
|
+
const i = this.renderRoot.querySelector("details");
|
|
58
|
+
i && (i.open = this.open), this._applyInertByOpen();
|
|
81
59
|
}
|
|
82
|
-
updated(
|
|
83
|
-
|
|
60
|
+
updated(t) {
|
|
61
|
+
if (t.has("open")) {
|
|
62
|
+
const i = this.renderRoot.querySelector("details");
|
|
63
|
+
i && i.open !== this.open && (i.open = this.open), this._applyInertByOpen();
|
|
64
|
+
}
|
|
84
65
|
}
|
|
85
66
|
render() {
|
|
86
|
-
const
|
|
67
|
+
const t = `bottom-${this._unique}`, i = `header-${this._unique}`, s = this.leading ? this.leadingVariant === "image" && this.imgHrefImage ? l`<img part="leading-image" class="img" src="${this.imgHrefImage}" alt="" />` : this.leadingVariant === "avatar" ? l`
|
|
68
|
+
<scb-avatar
|
|
69
|
+
label=${this.avatarLabel}
|
|
70
|
+
alt=${this.avatarAlt}
|
|
71
|
+
src=${this.avatarVariant === "image" ? this.avatarSrc : ""}
|
|
72
|
+
size="medium"
|
|
73
|
+
shape="circular"
|
|
74
|
+
variant=${this.avatarVariant}
|
|
75
|
+
></scb-avatar>
|
|
76
|
+
` : this.leadingVariant === "icon" ? l`<md-icon>${this.leadingIcon}</md-icon>` : p : p;
|
|
87
77
|
return l`
|
|
88
|
-
<
|
|
89
|
-
<
|
|
90
|
-
id=${
|
|
78
|
+
<details class="scb-accordion-item" ?open=${this.open} @toggle=${this._onToggle}>
|
|
79
|
+
<summary
|
|
80
|
+
id=${i}
|
|
91
81
|
class="scb-accordion-top"
|
|
92
|
-
|
|
93
|
-
role="button"
|
|
94
|
-
aria-expanded=${this.expanded}
|
|
95
|
-
aria-controls=${e}
|
|
96
|
-
@click=${this.toggleAccordion}
|
|
82
|
+
aria-controls=${t}
|
|
97
83
|
@keydown=${this._onKeyDown}
|
|
98
84
|
>
|
|
99
85
|
<md-ripple></md-ripple>
|
|
100
86
|
|
|
101
|
-
${this.leading ? l`<div class="leading">${
|
|
87
|
+
${this.leading ? l`<div class="leading">${s}</div>` : p}
|
|
102
88
|
|
|
103
89
|
<div class="texts">
|
|
104
90
|
${this.overline ? l`<div class="overline">${this.overline}</div>` : p}
|
|
105
|
-
<div class="
|
|
91
|
+
<div class="title">${this.title}</div>
|
|
106
92
|
${this.supportingText ? l`<div class="supporting-text">${this.supportingText}</div>` : p}
|
|
107
93
|
</div>
|
|
108
94
|
|
|
109
|
-
<md-icon class="chevron"
|
|
110
|
-
</
|
|
95
|
+
<md-icon class="chevron">keyboard_arrow_down</md-icon>
|
|
96
|
+
</summary>
|
|
111
97
|
|
|
112
|
-
<div
|
|
113
|
-
id=${e}
|
|
114
|
-
class="scb-accordion-bottom ${this.expanded ? "expanded" : ""}"
|
|
115
|
-
role="region"
|
|
116
|
-
aria-labelledby=${a}
|
|
117
|
-
aria-hidden=${this.expanded ? "false" : "true"}
|
|
118
|
-
>
|
|
98
|
+
<div id=${t} class="scb-accordion-bottom" role="region" aria-labelledby=${i}>
|
|
119
99
|
<div class="bottom-inner">
|
|
120
100
|
<slot>${this.content}</slot>
|
|
121
101
|
</div>
|
|
122
102
|
</div>
|
|
123
|
-
</
|
|
103
|
+
</details>
|
|
124
104
|
|
|
125
|
-
<md-focus-ring for=${
|
|
105
|
+
<md-focus-ring for=${i} inward></md-focus-ring>
|
|
126
106
|
`;
|
|
127
107
|
}
|
|
128
108
|
};
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
109
|
+
e._uidPrefix = `uid-${Math.random().toString(36).slice(2)}`;
|
|
110
|
+
e._uidSeq = 0;
|
|
111
|
+
e._mdIconLoaded = !1;
|
|
112
|
+
e._mdRippleLoaded = !1;
|
|
113
|
+
e.styles = [
|
|
114
|
+
m`
|
|
135
115
|
:host {
|
|
136
116
|
display: block;
|
|
137
117
|
position: relative;
|
|
@@ -152,28 +132,29 @@ t.styles = [
|
|
|
152
132
|
.scb-accordion-item {
|
|
153
133
|
border-bottom: var(--stroke-border, 1px) solid var(--md-sys-color-outline-variant);
|
|
154
134
|
margin-bottom: calc(var(--stroke-border, 1px) * -1);
|
|
155
|
-
display: flex;
|
|
156
|
-
flex-direction: column;
|
|
157
135
|
color: var(--md-sys-color-on-surface);
|
|
158
136
|
font-family: var(--brand-font);
|
|
159
137
|
}
|
|
160
138
|
|
|
139
|
+
/* Header */
|
|
161
140
|
.scb-accordion-top {
|
|
141
|
+
list-style: none;
|
|
162
142
|
display: flex;
|
|
163
143
|
flex-direction: row;
|
|
164
144
|
align-items: center;
|
|
165
145
|
cursor: pointer;
|
|
166
146
|
padding-block: var(--spacing-7, 24px);
|
|
167
147
|
padding-inline: var(--spacing-5, 16px);
|
|
168
|
-
outline: none;
|
|
169
148
|
border-radius: var(--radius-none, 0px);
|
|
170
149
|
gap: var(--spacing-5, 16px);
|
|
171
150
|
color: var(--md-sys-color-on-surface);
|
|
172
151
|
position: relative;
|
|
173
|
-
overflow:
|
|
152
|
+
overflow: hidden;
|
|
174
153
|
-webkit-tap-highlight-color: transparent;
|
|
154
|
+
outline: none;
|
|
175
155
|
}
|
|
176
|
-
.scb-accordion-top
|
|
156
|
+
.scb-accordion-top::-webkit-details-marker { display: none; }
|
|
157
|
+
summary::marker { content: ''; }
|
|
177
158
|
|
|
178
159
|
:host([density="-2"]) .scb-accordion-top,
|
|
179
160
|
:host-context([data-density="-2"]) .scb-accordion-top {
|
|
@@ -184,6 +165,7 @@ t.styles = [
|
|
|
184
165
|
padding-block: var(--spacing-4, 12px);
|
|
185
166
|
}
|
|
186
167
|
|
|
168
|
+
/* Panelinnehåll + animationer (grid 0fr -> 1fr) */
|
|
187
169
|
.scb-accordion-bottom {
|
|
188
170
|
display: grid;
|
|
189
171
|
grid-template-rows: 0fr;
|
|
@@ -196,7 +178,7 @@ t.styles = [
|
|
|
196
178
|
padding-block: var(--scb-accordion-panel-padding-closed);
|
|
197
179
|
padding-inline: var(--spacing-5, 16px);
|
|
198
180
|
}
|
|
199
|
-
.scb-accordion-bottom
|
|
181
|
+
details[open] .scb-accordion-bottom {
|
|
200
182
|
grid-template-rows: 1fr;
|
|
201
183
|
opacity: 1;
|
|
202
184
|
padding-top: var(--spacing-2, 4px);
|
|
@@ -206,7 +188,7 @@ t.styles = [
|
|
|
206
188
|
}
|
|
207
189
|
.bottom-inner { overflow: hidden; }
|
|
208
190
|
|
|
209
|
-
.
|
|
191
|
+
.title {
|
|
210
192
|
font-family: var(--brand-font);
|
|
211
193
|
font-size: var(--md-sys-typescale-title-large-size);
|
|
212
194
|
line-height: var(--md-sys-typescale-title-large-line-height);
|
|
@@ -240,7 +222,14 @@ t.styles = [
|
|
|
240
222
|
}
|
|
241
223
|
|
|
242
224
|
.texts { display: grid; gap: var(--spacing-1, 2px); }
|
|
243
|
-
|
|
225
|
+
|
|
226
|
+
.chevron {
|
|
227
|
+
margin-left: auto;
|
|
228
|
+
padding-top: var(--scb-accordion-chevron-nudge-y, 3px);
|
|
229
|
+
font-size: var(--icon-size-small, 24px);
|
|
230
|
+
transition: transform var(--scb-accordion-transition-duration) var(--scb-accordion-transition-easing);
|
|
231
|
+
}
|
|
232
|
+
details[open] .chevron { transform: rotate(180deg); }
|
|
244
233
|
|
|
245
234
|
md-ripple {
|
|
246
235
|
border-radius: inherit;
|
|
@@ -249,54 +238,56 @@ t.styles = [
|
|
|
249
238
|
pointer-events: none;
|
|
250
239
|
overflow: hidden;
|
|
251
240
|
}
|
|
252
|
-
@media (prefers-reduced-motion: reduce) {
|
|
241
|
+
@media (prefers-reduced-motion: reduce) {
|
|
242
|
+
md-ripple { display: none; }
|
|
243
|
+
}
|
|
253
244
|
`
|
|
254
245
|
];
|
|
255
|
-
|
|
256
|
-
o({ type: Boolean })
|
|
257
|
-
],
|
|
258
|
-
|
|
246
|
+
a([
|
|
247
|
+
o({ type: Boolean, reflect: !0 })
|
|
248
|
+
], e.prototype, "open", 2);
|
|
249
|
+
a([
|
|
259
250
|
o({ type: String, reflect: !0 })
|
|
260
|
-
],
|
|
261
|
-
|
|
251
|
+
], e.prototype, "title", 2);
|
|
252
|
+
a([
|
|
262
253
|
o({ type: String })
|
|
263
|
-
],
|
|
264
|
-
|
|
254
|
+
], e.prototype, "content", 2);
|
|
255
|
+
a([
|
|
265
256
|
o({ type: String, attribute: "overline" })
|
|
266
|
-
],
|
|
267
|
-
|
|
257
|
+
], e.prototype, "overline", 2);
|
|
258
|
+
a([
|
|
268
259
|
o({ type: String, attribute: "supporting-text" })
|
|
269
|
-
],
|
|
270
|
-
|
|
260
|
+
], e.prototype, "supportingText", 2);
|
|
261
|
+
a([
|
|
271
262
|
o({ type: Boolean })
|
|
272
|
-
],
|
|
273
|
-
|
|
263
|
+
], e.prototype, "leading", 2);
|
|
264
|
+
a([
|
|
274
265
|
o({ type: String, attribute: "leading-variant", reflect: !0 })
|
|
275
|
-
],
|
|
276
|
-
|
|
266
|
+
], e.prototype, "leadingVariant", 2);
|
|
267
|
+
a([
|
|
277
268
|
o({ type: String, attribute: "leading-icon" })
|
|
278
|
-
],
|
|
279
|
-
|
|
269
|
+
], e.prototype, "leadingIcon", 2);
|
|
270
|
+
a([
|
|
280
271
|
o({ type: String, attribute: "img-href-image", reflect: !0 })
|
|
281
|
-
],
|
|
282
|
-
|
|
272
|
+
], e.prototype, "imgHrefImage", 2);
|
|
273
|
+
a([
|
|
283
274
|
o({ type: String, attribute: "avatar-label" })
|
|
284
|
-
],
|
|
285
|
-
|
|
275
|
+
], e.prototype, "avatarLabel", 2);
|
|
276
|
+
a([
|
|
286
277
|
o({ type: String, attribute: "avatar-alt" })
|
|
287
|
-
],
|
|
288
|
-
|
|
278
|
+
], e.prototype, "avatarAlt", 2);
|
|
279
|
+
a([
|
|
289
280
|
o({ type: String, attribute: "avatar-variant" })
|
|
290
|
-
],
|
|
291
|
-
|
|
281
|
+
], e.prototype, "avatarVariant", 2);
|
|
282
|
+
a([
|
|
292
283
|
o({ type: String, attribute: "avatar-src" })
|
|
293
|
-
],
|
|
294
|
-
|
|
284
|
+
], e.prototype, "avatarSrc", 2);
|
|
285
|
+
a([
|
|
295
286
|
o({ type: Number, reflect: !0 })
|
|
296
|
-
],
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
],
|
|
287
|
+
], e.prototype, "density", 2);
|
|
288
|
+
e = a([
|
|
289
|
+
h("scb-accordion-item")
|
|
290
|
+
], e);
|
|
300
291
|
export {
|
|
301
|
-
|
|
292
|
+
e as ScbAccordionItem
|
|
302
293
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* En komponent för segmenterade knappar (segmented button).
|
|
4
|
+
*
|
|
5
|
+
* @slot - Plats för knappar eller segment.
|
|
6
|
+
* @fires change - När valt segment ändras (detail: { value })
|
|
7
|
+
*/
|
|
8
|
+
export declare class ScbSegmentedButton extends LitElement {
|
|
9
|
+
/**
|
|
10
|
+
* Variant: 'single-select' (default) eller 'multi-select'.
|
|
11
|
+
*/
|
|
12
|
+
variant: 'single-select' | 'multi-select';
|
|
13
|
+
/**
|
|
14
|
+
* Aktuellt valt värde (single) eller array av värden (multi)
|
|
15
|
+
*/
|
|
16
|
+
value: string;
|
|
17
|
+
values: string[];
|
|
18
|
+
disabled: boolean;
|
|
19
|
+
static styles: import('lit').CSSResult;
|
|
20
|
+
private onSlotClick;
|
|
21
|
+
private updateSegments;
|
|
22
|
+
firstUpdated(): void;
|
|
23
|
+
updated(): void;
|
|
24
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { css as u, LitElement as c, html as m } from "lit";
|
|
2
|
+
import { property as d, customElement as h } from "lit/decorators.js";
|
|
3
|
+
import "./scb-segmented-item.js";
|
|
4
|
+
var f = Object.defineProperty, p = Object.getOwnPropertyDescriptor, a = (i, t, s, e) => {
|
|
5
|
+
for (var r = e > 1 ? void 0 : e ? p(t, s) : t, l = i.length - 1, n; l >= 0; l--)
|
|
6
|
+
(n = i[l]) && (r = (e ? n(t, s, r) : n(r)) || r);
|
|
7
|
+
return e && r && f(t, s, r), r;
|
|
8
|
+
};
|
|
9
|
+
let o = class extends c {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments), this.variant = "single-select", this.value = "", this.values = [], this.disabled = !1;
|
|
12
|
+
}
|
|
13
|
+
onSlotClick(i) {
|
|
14
|
+
let t = i.target;
|
|
15
|
+
if (!t || !t.closest) return;
|
|
16
|
+
const s = t.closest("scb-segmented-item");
|
|
17
|
+
if (!s || this.disabled || s.hasAttribute("disabled")) return;
|
|
18
|
+
const e = s.getAttribute("value") || "";
|
|
19
|
+
e && (this.variant === "multi-select" ? (this.values.indexOf(e) === -1 ? this.values = [...this.values, e] : this.values = this.values.filter((l) => l !== e), this.dispatchEvent(new CustomEvent("change", { detail: { values: this.values }, bubbles: !0, composed: !0 })), this.updateSegments()) : e !== this.value && (this.value = e, this.dispatchEvent(new CustomEvent("change", { detail: { value: e }, bubbles: !0, composed: !0 })), this.updateSegments()));
|
|
20
|
+
}
|
|
21
|
+
updateSegments() {
|
|
22
|
+
var s;
|
|
23
|
+
const i = (s = this.shadowRoot) == null ? void 0 : s.querySelector("slot");
|
|
24
|
+
if (!i) return;
|
|
25
|
+
i.assignedElements().forEach((e) => {
|
|
26
|
+
if (e.tagName === "SCB-SEGMENTED-ITEM") {
|
|
27
|
+
const r = e.getAttribute("value") || "";
|
|
28
|
+
if (r) {
|
|
29
|
+
let l = !1;
|
|
30
|
+
this.variant === "multi-select" ? l = !!this.values && this.values.includes(r) : l = r === this.value, e.setAttribute("aria-pressed", l ? "true" : "false");
|
|
31
|
+
}
|
|
32
|
+
this.disabled && e.setAttribute("disabled", "true");
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
firstUpdated() {
|
|
37
|
+
var t;
|
|
38
|
+
this.updateSegments();
|
|
39
|
+
const i = (t = this.shadowRoot) == null ? void 0 : t.querySelector("slot");
|
|
40
|
+
i && i.addEventListener("click", (s) => this.onSlotClick(s));
|
|
41
|
+
}
|
|
42
|
+
updated() {
|
|
43
|
+
this.updateSegments();
|
|
44
|
+
}
|
|
45
|
+
render() {
|
|
46
|
+
return m`<slot></slot>`;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
o.styles = u`
|
|
50
|
+
:host {
|
|
51
|
+
display: flex;
|
|
52
|
+
}
|
|
53
|
+
/* Border radius only on first and last button */
|
|
54
|
+
::slotted(scb-segmented-item:first-child .segmented-item),
|
|
55
|
+
::slotted([role="button"]:first-child .segmented-item) {
|
|
56
|
+
border-top-left-radius: var(--md-sys-shape-corner-full);
|
|
57
|
+
border-bottom-left-radius: var(--md-sys-shape-corner-full);
|
|
58
|
+
}
|
|
59
|
+
::slotted(scb-segmented-item:last-child .segmented-item),
|
|
60
|
+
::slotted([role="button"]:last-child .segmented-item) {
|
|
61
|
+
border-top-right-radius: var(--md-sys-shape-corner-full);
|
|
62
|
+
border-bottom-right-radius: var(--md-sys-shape-corner-full);
|
|
63
|
+
}
|
|
64
|
+
/* First button gets left border */
|
|
65
|
+
::slotted(scb-segmented-item:first-child .segmented-item),
|
|
66
|
+
::slotted([role="button"]:first-child .segmented-item) {
|
|
67
|
+
border-left: 1px solid var(--md-sys-color-outline);
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
a([
|
|
71
|
+
d({ type: String, reflect: !0 })
|
|
72
|
+
], o.prototype, "variant", 2);
|
|
73
|
+
a([
|
|
74
|
+
d({ type: String, reflect: !0 })
|
|
75
|
+
], o.prototype, "value", 2);
|
|
76
|
+
a([
|
|
77
|
+
d({ type: Array })
|
|
78
|
+
], o.prototype, "values", 2);
|
|
79
|
+
a([
|
|
80
|
+
d({ type: Boolean, reflect: !0 })
|
|
81
|
+
], o.prototype, "disabled", 2);
|
|
82
|
+
o = a([
|
|
83
|
+
h("scb-segmented-button")
|
|
84
|
+
], o);
|
|
85
|
+
export {
|
|
86
|
+
o as ScbSegmentedButton
|
|
87
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Ett segment (option) i en segmented button.
|
|
4
|
+
* @slot - Label och ev. ikon
|
|
5
|
+
*/
|
|
6
|
+
export declare class ScbSegmentedItem extends LitElement {
|
|
7
|
+
label: string;
|
|
8
|
+
value: string;
|
|
9
|
+
selected: boolean;
|
|
10
|
+
icon: string;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
static styles: import('lit').CSSResult;
|
|
13
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
14
|
+
firstUpdated(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { css as p, LitElement as m, html as c } from "lit";
|
|
2
|
+
import { property as l, customElement as u } from "lit/decorators.js";
|
|
3
|
+
import "@material/web/icon/icon.js";
|
|
4
|
+
import "@material/web/focus/md-focus-ring.js";
|
|
5
|
+
import "@material/web/ripple/ripple.js";
|
|
6
|
+
var h = Object.defineProperty, b = Object.getOwnPropertyDescriptor, a = (e, o, i, s) => {
|
|
7
|
+
for (var r = s > 1 ? void 0 : s ? b(o, i) : o, d = e.length - 1, n; d >= 0; d--)
|
|
8
|
+
(n = e[d]) && (r = (s ? n(o, i, r) : n(r)) || r);
|
|
9
|
+
return s && r && h(o, i, r), r;
|
|
10
|
+
};
|
|
11
|
+
let t = class extends m {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.label = "", this.value = "", this.selected = !1, this.icon = "", this.disabled = !1;
|
|
14
|
+
}
|
|
15
|
+
render() {
|
|
16
|
+
var s;
|
|
17
|
+
const e = this.parentElement, o = (s = e == null ? void 0 : e.hasAttribute) == null ? void 0 : s.call(e, "disabled"), i = this.disabled || o;
|
|
18
|
+
return c`
|
|
19
|
+
<div class="segmented-item" aria-disabled="${i ? "true" : "false"}">
|
|
20
|
+
<md-ripple ?disabled="${i}"></md-ripple>
|
|
21
|
+
${this.icon ? c`<md-icon>${this.icon}</md-icon>` : ""}
|
|
22
|
+
<span>${this.label}</span>
|
|
23
|
+
<md-focus-ring inward></md-focus-ring>
|
|
24
|
+
</div>
|
|
25
|
+
`;
|
|
26
|
+
}
|
|
27
|
+
firstUpdated() {
|
|
28
|
+
this.setAttribute("tabindex", this.disabled ? "-1" : "0"), this.setAttribute("role", "button");
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
t.styles = p`
|
|
32
|
+
.segmented-item {
|
|
33
|
+
display: flex;
|
|
34
|
+
gap: var(--spacing-3);
|
|
35
|
+
border: 1px solid var(--md-sys-color-outline);
|
|
36
|
+
border-left: none;
|
|
37
|
+
background-color: var(--md-sys-color-surface);
|
|
38
|
+
padding: var(--spacing-3) var(--spacing-8);
|
|
39
|
+
font: inherit;
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
position: relative;
|
|
42
|
+
font-size: var(--md-sys-typescale-label-medium-size);
|
|
43
|
+
line-height: var(--md-sys-typescale-label-medium-line-height);
|
|
44
|
+
font-weight: var(--md-sys-typescale-label-medium-weight);
|
|
45
|
+
letter-spacing: var(--md-sys-typescale-label-medium-tracking);
|
|
46
|
+
color: var(--md-sys-color-on-surface);
|
|
47
|
+
opacity: 1;
|
|
48
|
+
pointer-events: auto;
|
|
49
|
+
transition: opacity 0.2s;
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
md-icon {
|
|
53
|
+
font-size: 20px;
|
|
54
|
+
width: 18px;
|
|
55
|
+
height: 18px;
|
|
56
|
+
}
|
|
57
|
+
:host([disabled]) .segmented-item,
|
|
58
|
+
.segmented-item[aria-disabled="true"] {
|
|
59
|
+
opacity: 0.5;
|
|
60
|
+
cursor: not-allowed;
|
|
61
|
+
pointer-events: none;
|
|
62
|
+
filter: grayscale(0.5);
|
|
63
|
+
}
|
|
64
|
+
:host([aria-pressed="true"]) .segmented-item {
|
|
65
|
+
background-color: var(--md-sys-color-secondary-container);
|
|
66
|
+
color: var(--md-sys-color-primary);
|
|
67
|
+
}
|
|
68
|
+
:host(:focus){
|
|
69
|
+
outline: none;
|
|
70
|
+
}
|
|
71
|
+
md-focus-ring {
|
|
72
|
+
position: absolute;
|
|
73
|
+
inset: 0;
|
|
74
|
+
pointer-events: none;
|
|
75
|
+
display: none;
|
|
76
|
+
border-radius: inherit;
|
|
77
|
+
}
|
|
78
|
+
:host(:focus) md-focus-ring,
|
|
79
|
+
md-focus-ring[data-show="true"] {
|
|
80
|
+
display: block;
|
|
81
|
+
}
|
|
82
|
+
:host([disabled]):host(:focus) md-focus-ring,
|
|
83
|
+
:host([disabled]) md-focus-ring[data-show="true"] {
|
|
84
|
+
display: none;
|
|
85
|
+
}
|
|
86
|
+
:host(:first-child) .segmented-item{
|
|
87
|
+
border: 1px solid var(--md-sys-color-outline);
|
|
88
|
+
border-top-left-radius: var(--md-sys-shape-corner-full);
|
|
89
|
+
border-bottom-left-radius: var(--md-sys-shape-corner-full);
|
|
90
|
+
}
|
|
91
|
+
:host(:last-child) .segmented-item {
|
|
92
|
+
border-top-right-radius: var(--md-sys-shape-corner-full);
|
|
93
|
+
border-bottom-right-radius: var(--md-sys-shape-corner-full);
|
|
94
|
+
}
|
|
95
|
+
`;
|
|
96
|
+
a([
|
|
97
|
+
l({ type: String, reflect: !0 })
|
|
98
|
+
], t.prototype, "label", 2);
|
|
99
|
+
a([
|
|
100
|
+
l({ type: String, reflect: !0 })
|
|
101
|
+
], t.prototype, "value", 2);
|
|
102
|
+
a([
|
|
103
|
+
l({ type: Boolean, reflect: !0 })
|
|
104
|
+
], t.prototype, "selected", 2);
|
|
105
|
+
a([
|
|
106
|
+
l({ type: String, reflect: !0 })
|
|
107
|
+
], t.prototype, "icon", 2);
|
|
108
|
+
a([
|
|
109
|
+
l({ type: Boolean, reflect: !0 })
|
|
110
|
+
], t.prototype, "disabled", 2);
|
|
111
|
+
t = a([
|
|
112
|
+
u("scb-segmented-item")
|
|
113
|
+
], t);
|
|
114
|
+
export {
|
|
115
|
+
t as ScbSegmentedItem
|
|
116
|
+
};
|