scb-wc-test 0.1.114 → 0.1.116
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/mvc/components/scb-accordion/scb-accordion-item.js +43 -7
- package/mvc/components/scb-datepicker/scb-datepicker.js +33 -25
- package/mvc/components/scb-textfield/scb-textfield.js +97 -13
- package/mvc/components/scb-toc/scb-toc-item.js +163 -44
- package/mvc/components/scb-toc/scb-toc.js +1 -1
- package/mvc/scb-wc-test.css +1 -1
- package/package.json +2 -2
- package/scb-accordion/scb-accordion-item.js +70 -34
- package/scb-datepicker/scb-datepicker.d.ts +9 -5
- package/scb-datepicker/scb-datepicker.js +130 -91
- package/scb-textfield/scb-textfield.js +134 -37
- package/scb-toc/scb-toc-item.d.ts +15 -5
- package/scb-toc/scb-toc-item.js +302 -134
- package/scb-wc-test.bundle.js +483 -236
- package/scb-wc-test.css +1 -1
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import { css as m, LitElement as
|
|
2
|
-
import { state as
|
|
1
|
+
import { css as m, LitElement as w, html as a } from "lit";
|
|
2
|
+
import { state as p, property as u, customElement as v } from "lit/decorators.js";
|
|
3
3
|
import "../scb-icon-button/scb-icon-button.js";
|
|
4
4
|
import "../scb-button/scb-button.js";
|
|
5
5
|
import "@material/web/icon/icon.js";
|
|
6
6
|
import "@material/web/ripple/ripple.js";
|
|
7
7
|
import "@material/web/focus/md-focus-ring.js";
|
|
8
8
|
import "../scb-divider/scb-divider.js";
|
|
9
|
-
var
|
|
10
|
-
for (var
|
|
11
|
-
(
|
|
12
|
-
return
|
|
9
|
+
var _ = Object.defineProperty, b = Object.getOwnPropertyDescriptor, h = (e, t, i, d) => {
|
|
10
|
+
for (var r = d > 1 ? void 0 : d ? b(t, i) : t, n = e.length - 1, o; n >= 0; n--)
|
|
11
|
+
(o = e[n]) && (r = (d ? o(t, i, r) : o(r)) || r);
|
|
12
|
+
return d && r && _(t, i, r), r;
|
|
13
13
|
};
|
|
14
|
-
let
|
|
14
|
+
let c = class extends w {
|
|
15
15
|
constructor() {
|
|
16
|
-
super(...arguments), this._currentDate = /* @__PURE__ */ new Date(), this._selectedDate = null, this._showMonthDropdown = !1, this._showYearDropdown = !1, this.variant = "
|
|
17
|
-
this.variant !== "static" && this.open && (e.composedPath().includes(this) || this._close());
|
|
18
|
-
}, this._monthNames = [
|
|
16
|
+
super(...arguments), this._currentDate = /* @__PURE__ */ new Date(), this._selectedDate = null, this._showMonthDropdown = !1, this._showYearDropdown = !1, this.variant = "date", this.lang = "sv", this.selectedValue = "", this.open = !0, this._selectedHour = 0, this._selectedMinute = 0, this._monthNames = [
|
|
19
17
|
this.lang == "sv" ? "Januari" : "January",
|
|
20
18
|
this.lang == "sv" ? "Februari" : "February",
|
|
21
19
|
this.lang == "sv" ? "Mars" : "March",
|
|
@@ -28,50 +26,41 @@ let a = class extends g {
|
|
|
28
26
|
this.lang == "sv" ? "Oktober" : "October",
|
|
29
27
|
(this.lang == "sv", "November"),
|
|
30
28
|
(this.lang == "sv", "December")
|
|
31
|
-
], this.
|
|
29
|
+
], this._outsideClickHandler = (e) => {
|
|
30
|
+
this.open && (e.composedPath().includes(this) || this._close());
|
|
31
|
+
}, this._prevMonth = () => {
|
|
32
|
+
const e = this._currentDate.getFullYear(), t = this._currentDate.getMonth();
|
|
33
|
+
t === 0 ? this._currentDate = new Date(e - 1, 11, 1) : this._currentDate = new Date(e, t - 1, 1);
|
|
34
|
+
}, this._prevYear = () => {
|
|
32
35
|
const e = this._currentDate.getFullYear(), t = this._currentDate.getMonth();
|
|
33
36
|
this._currentDate = new Date(e - 1, t, 1);
|
|
37
|
+
}, this._nextMonth = () => {
|
|
38
|
+
const e = this._currentDate.getFullYear(), t = this._currentDate.getMonth();
|
|
39
|
+
t === 11 ? this._currentDate = new Date(e + 1, 0, 1) : this._currentDate = new Date(e, t + 1, 1);
|
|
34
40
|
}, this._nextYear = () => {
|
|
35
41
|
const e = this._currentDate.getFullYear(), t = this._currentDate.getMonth();
|
|
36
42
|
this._currentDate = new Date(e + 1, t, 1);
|
|
37
|
-
}, this.
|
|
38
|
-
const e =
|
|
39
|
-
this.
|
|
40
|
-
}, this._nextMonth = () => {
|
|
41
|
-
const e = this._currentDate.getFullYear(), t = this._currentDate.getMonth();
|
|
42
|
-
this._currentDate = new Date(e, t + 1, 1);
|
|
43
|
+
}, this._onTimeChange = (e) => {
|
|
44
|
+
const t = e.target.value, [i, d] = t.split(":"), r = parseInt(i, 10), n = parseInt(d, 10);
|
|
45
|
+
this._selectedHour = isNaN(r) ? 0 : Math.max(0, Math.min(23, r)), this._selectedMinute = isNaN(n) ? 0 : Math.max(0, Math.min(59, n)), this._fireDateTimeChange();
|
|
43
46
|
}, this._close = () => {
|
|
44
47
|
this.open = !1, this.dispatchEvent(new CustomEvent("datepicker-closed", {
|
|
45
48
|
bubbles: !0,
|
|
46
49
|
composed: !0
|
|
47
|
-
}))
|
|
50
|
+
}));
|
|
48
51
|
};
|
|
49
52
|
}
|
|
50
53
|
updated(e) {
|
|
51
|
-
if (super.updated(e), this.
|
|
54
|
+
if (super.updated(e), this.open ? window.addEventListener("mousedown", this._outsideClickHandler) : window.removeEventListener("mousedown", this._outsideClickHandler), e.has("selectedValue") && this.selectedValue) {
|
|
52
55
|
const t = new Date(this.selectedValue);
|
|
53
|
-
isNaN(t.getTime()) || (this._selectedDate = t, this._currentDate = new Date(t.getFullYear(), t.getMonth(), 1));
|
|
56
|
+
isNaN(t.getTime()) || (this._selectedDate = t, this._currentDate = new Date(t.getFullYear(), t.getMonth(), 1), this.variant === "datetime-local" && (this._selectedHour = t.getHours(), this._selectedMinute = t.getMinutes()));
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
|
-
_getMonthDays(e, t) {
|
|
57
|
-
const c = new Date(e, t, 1), l = new Date(e, t + 1, 0), i = [];
|
|
58
|
-
let o = [], s = (c.getDay() + 6) % 7;
|
|
59
|
-
for (let r = 0; r < s; r++) o.push(null);
|
|
60
|
-
for (let r = 1; r <= l.getDate(); r++) {
|
|
61
|
-
const u = new Date(e, t, r);
|
|
62
|
-
o.push(u), o.length === 7 && (i.push(o), o = []);
|
|
63
|
-
}
|
|
64
|
-
if (o.length) {
|
|
65
|
-
for (; o.length < 7; ) o.push(null);
|
|
66
|
-
i.push(o);
|
|
67
|
-
}
|
|
68
|
-
return i;
|
|
69
|
-
}
|
|
70
59
|
render() {
|
|
71
|
-
if (!this.open) return
|
|
72
|
-
const e = this._currentDate.getFullYear(), t = this._currentDate.getMonth(),
|
|
73
|
-
return
|
|
74
|
-
<div class="datepicker-popup
|
|
60
|
+
if (!this.open) return a``;
|
|
61
|
+
const e = this._currentDate.getFullYear(), t = this._currentDate.getMonth(), i = /* @__PURE__ */ new Date(), d = this._getMonthDays(e, t), r = Array.from({ length: 101 }, (o, s) => i.getFullYear() - 50 + s), n = this.variant === "datetime-local" && !this._showMonthDropdown && !this._showYearDropdown;
|
|
62
|
+
return a`
|
|
63
|
+
<div class="datepicker-popup popup">
|
|
75
64
|
<div class="header">
|
|
76
65
|
<div class="month-selector ${this._showMonthDropdown ? "open" : ""} ${this._showYearDropdown ? "disable" : ""}">
|
|
77
66
|
<scb-icon-button icon="chevron_left" @click=${this._prevMonth} aria-label=${this.lang == "sv" ? "Föregående månad" : "Previous month"}></scb-icon-button>
|
|
@@ -112,30 +101,30 @@ let a = class extends g {
|
|
|
112
101
|
<scb-icon-button icon="chevron_right" @click=${this._nextYear} aria-label=${this.lang == "sv" ? "Nästa år" : "Next year"}></scb-icon-button>
|
|
113
102
|
</div>
|
|
114
103
|
</div>
|
|
115
|
-
${this._showMonthDropdown || this._showYearDropdown ?
|
|
104
|
+
${this._showMonthDropdown || this._showYearDropdown ? a`<scb-divider></scb-divider>` : ""}
|
|
116
105
|
<div class="datepicker-content" style="position:relative;">
|
|
117
|
-
${this._showMonthDropdown ?
|
|
106
|
+
${this._showMonthDropdown ? a`
|
|
118
107
|
<div class="dropdown-list">
|
|
119
|
-
${this._monthNames.map((o, s) =>
|
|
108
|
+
${this._monthNames.map((o, s) => a`
|
|
120
109
|
<div
|
|
121
|
-
@keydown=${(
|
|
122
|
-
(
|
|
110
|
+
@keydown=${(l) => {
|
|
111
|
+
(l.key === "Enter" || l.key === " ") && (l.preventDefault(), this._onMonthChangeCustom(s));
|
|
123
112
|
}}
|
|
124
113
|
tabindex="0"
|
|
125
114
|
class="dropdown-item${s === t ? " selected" : ""}"
|
|
126
115
|
@click=${() => this._onMonthChangeCustom(s)}
|
|
127
116
|
id=${s === t ? "selected-month" : ""}
|
|
128
117
|
>
|
|
129
|
-
${s === t ?
|
|
118
|
+
${s === t ? a`<md-icon>check</md-icon>` : ""}
|
|
130
119
|
${o}
|
|
131
120
|
<md-ripple></md-ripple><md-focus-ring inward></md-focus-ring>
|
|
132
121
|
</div>
|
|
133
122
|
`)}
|
|
134
123
|
</div>
|
|
135
124
|
` : ""}
|
|
136
|
-
${this._showYearDropdown ?
|
|
125
|
+
${this._showYearDropdown ? a`
|
|
137
126
|
<div class="dropdown-list">
|
|
138
|
-
${
|
|
127
|
+
${r.map((o) => a`
|
|
139
128
|
<div
|
|
140
129
|
@keydown=${(s) => {
|
|
141
130
|
(s.key === "Enter" || s.key === " ") && (s.preventDefault(), this._onYearChangeCustom(o));
|
|
@@ -145,14 +134,14 @@ let a = class extends g {
|
|
|
145
134
|
@click=${() => this._onYearChangeCustom(o)}
|
|
146
135
|
id=${o === e ? "selected-year" : ""}
|
|
147
136
|
>
|
|
148
|
-
${o === e ?
|
|
137
|
+
${o === e ? a`<md-icon>check</md-icon>` : ""}
|
|
149
138
|
${o}
|
|
150
139
|
<md-ripple></md-ripple><md-focus-ring inward></md-focus-ring>
|
|
151
140
|
</div>
|
|
152
141
|
`)}
|
|
153
142
|
</div>
|
|
154
143
|
` : ""}
|
|
155
|
-
${!this._showMonthDropdown && !this._showYearDropdown ?
|
|
144
|
+
${!this._showMonthDropdown && !this._showYearDropdown ? a`
|
|
156
145
|
<div class="datepicker-calendar">
|
|
157
146
|
<table>
|
|
158
147
|
<thead>
|
|
@@ -161,21 +150,21 @@ let a = class extends g {
|
|
|
161
150
|
</tr>
|
|
162
151
|
</thead>
|
|
163
152
|
<tbody>
|
|
164
|
-
${
|
|
153
|
+
${d.map((o) => a`
|
|
165
154
|
<tr>
|
|
166
|
-
${o.map((s) => s ?
|
|
155
|
+
${o.map((s) => s ? a`
|
|
167
156
|
<td>
|
|
168
157
|
<div
|
|
169
|
-
@keydown=${(
|
|
170
|
-
(
|
|
158
|
+
@keydown=${(l) => {
|
|
159
|
+
(l.key === "Enter" || l.key === " ") && (l.preventDefault(), this._selectDate(s));
|
|
171
160
|
}}
|
|
172
161
|
role="button"
|
|
173
162
|
tabindex="0"
|
|
174
|
-
class="day${this._isToday(s,
|
|
163
|
+
class="day${this._isToday(s, i) ? " today" : ""}${this._isSelected(s) ? " selected" : ""}"
|
|
175
164
|
@click=${() => this._selectDate(s)}
|
|
176
165
|
>${s.getDate()}<md-ripple></md-ripple><md-focus-ring></md-focus-ring></div>
|
|
177
166
|
</td>
|
|
178
|
-
` :
|
|
167
|
+
` : a`<td></td>`)}
|
|
179
168
|
</tr>
|
|
180
169
|
`)}
|
|
181
170
|
</tbody>
|
|
@@ -183,14 +172,36 @@ let a = class extends g {
|
|
|
183
172
|
</div>
|
|
184
173
|
` : ""}
|
|
185
174
|
</div>
|
|
175
|
+
${n ? a`
|
|
176
|
+
<div style="padding: 0 24px;">
|
|
177
|
+
<label style="display:flex;align-items:center;gap:8px;">
|
|
178
|
+
<span>${this.lang == "sv" ? "Tid:" : "Time:"}</span>
|
|
179
|
+
<scb-textfield type="time" .value=${`${String(this._selectedHour).padStart(2, "0")}:${String(this._selectedMinute).padStart(2, "0")}`} @blur=${this._onTimeChange} aria-label="${this.lang == "sv" ? "Tid" : "Time"}"></scb-textfield>
|
|
180
|
+
</label>
|
|
181
|
+
</div>
|
|
182
|
+
` : ""}
|
|
186
183
|
<div class="datepicker-footer">
|
|
187
|
-
${!this._showMonthDropdown && !this._showYearDropdown
|
|
184
|
+
${!this._showMonthDropdown && !this._showYearDropdown ? a`
|
|
188
185
|
<scb-button variant="text" label=${this.lang == "sv" ? "Stäng" : "Close"} @click=${this._close}></scb-button>
|
|
189
186
|
` : ""}
|
|
190
187
|
</div>
|
|
191
188
|
</div>
|
|
192
189
|
`;
|
|
193
190
|
}
|
|
191
|
+
_getMonthDays(e, t) {
|
|
192
|
+
const i = new Date(Date.UTC(e, t, 1)), d = new Date(Date.UTC(e, t + 1, 0)), r = [];
|
|
193
|
+
let n = [], o = i.getUTCDay(), s = o === 0 ? 6 : o - 1;
|
|
194
|
+
for (let l = 0; l < s; l++) n.push(null);
|
|
195
|
+
for (let l = 1; l <= d.getUTCDate(); l++) {
|
|
196
|
+
const g = new Date(Date.UTC(e, t, l));
|
|
197
|
+
n.push(g), n.length === 7 && (r.push(n), n = []);
|
|
198
|
+
}
|
|
199
|
+
if (n.length) {
|
|
200
|
+
for (; n.length < 7; ) n.push(null);
|
|
201
|
+
r.push(n);
|
|
202
|
+
}
|
|
203
|
+
return r;
|
|
204
|
+
}
|
|
194
205
|
_toggleMonthDropdown() {
|
|
195
206
|
this._showMonthDropdown = !this._showMonthDropdown, this._showMonthDropdown && (this._showYearDropdown = !1, setTimeout(() => {
|
|
196
207
|
const e = this.renderRoot.querySelector("#selected-month");
|
|
@@ -218,16 +229,38 @@ let a = class extends g {
|
|
|
218
229
|
return this._selectedDate && e.getDate() === this._selectedDate.getDate() && e.getMonth() === this._selectedDate.getMonth() && e.getFullYear() === this._selectedDate.getFullYear();
|
|
219
230
|
}
|
|
220
231
|
_selectDate(e) {
|
|
221
|
-
this._selectedDate = e
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
232
|
+
if (this._selectedDate = e, this.variant === "datetime-local") {
|
|
233
|
+
const t = new Date(e);
|
|
234
|
+
t.setHours(this._selectedHour ?? 0, this._selectedMinute ?? 0, 0, 0), this._selectedHour = t.getHours(), this._selectedMinute = t.getMinutes();
|
|
235
|
+
const i = (r) => r.toString().padStart(2, "0"), d = `${t.getFullYear()}-${i(t.getMonth() + 1)}-${i(t.getDate())} ${i(t.getHours())}:${i(t.getMinutes())}`;
|
|
236
|
+
this.dispatchEvent(new CustomEvent("date-selected", {
|
|
237
|
+
detail: { value: d },
|
|
238
|
+
bubbles: !0,
|
|
239
|
+
composed: !0
|
|
240
|
+
}));
|
|
241
|
+
} else {
|
|
242
|
+
const t = e.toISOString().slice(0, 10);
|
|
243
|
+
this.dispatchEvent(new CustomEvent("date-selected", {
|
|
244
|
+
detail: { value: t },
|
|
245
|
+
bubbles: !0,
|
|
246
|
+
composed: !0
|
|
247
|
+
}));
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
_fireDateTimeChange() {
|
|
251
|
+
if (this.variant === "datetime-local" && this._selectedDate) {
|
|
252
|
+
const e = new Date(this._selectedDate);
|
|
253
|
+
e.setHours(this._selectedHour ?? 0, this._selectedMinute ?? 0, 0, 0);
|
|
254
|
+
const t = (d) => d.toString().padStart(2, "0"), i = `${e.getFullYear()}-${t(e.getMonth() + 1)}-${t(e.getDate())} ${t(e.getHours())}:${t(e.getMinutes())}`;
|
|
255
|
+
this.dispatchEvent(new CustomEvent("date-selected", {
|
|
256
|
+
detail: { value: i },
|
|
257
|
+
bubbles: !0,
|
|
258
|
+
composed: !0
|
|
259
|
+
}));
|
|
260
|
+
}
|
|
228
261
|
}
|
|
229
262
|
};
|
|
230
|
-
|
|
263
|
+
c.styles = [
|
|
231
264
|
m`
|
|
232
265
|
:host {
|
|
233
266
|
--scb-datepicker-width: 380px;
|
|
@@ -396,33 +429,39 @@ a.styles = [
|
|
|
396
429
|
}
|
|
397
430
|
`
|
|
398
431
|
];
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
],
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
],
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
],
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
],
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
],
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
],
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
],
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
],
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
],
|
|
432
|
+
h([
|
|
433
|
+
p()
|
|
434
|
+
], c.prototype, "_currentDate", 2);
|
|
435
|
+
h([
|
|
436
|
+
p()
|
|
437
|
+
], c.prototype, "_selectedDate", 2);
|
|
438
|
+
h([
|
|
439
|
+
p()
|
|
440
|
+
], c.prototype, "_showMonthDropdown", 2);
|
|
441
|
+
h([
|
|
442
|
+
p()
|
|
443
|
+
], c.prototype, "_showYearDropdown", 2);
|
|
444
|
+
h([
|
|
445
|
+
u({ type: String })
|
|
446
|
+
], c.prototype, "variant", 2);
|
|
447
|
+
h([
|
|
448
|
+
u({ type: String })
|
|
449
|
+
], c.prototype, "lang", 2);
|
|
450
|
+
h([
|
|
451
|
+
u({ type: String })
|
|
452
|
+
], c.prototype, "selectedValue", 2);
|
|
453
|
+
h([
|
|
454
|
+
u({ type: Boolean })
|
|
455
|
+
], c.prototype, "open", 2);
|
|
456
|
+
h([
|
|
457
|
+
p()
|
|
458
|
+
], c.prototype, "_selectedHour", 2);
|
|
459
|
+
h([
|
|
460
|
+
p()
|
|
461
|
+
], c.prototype, "_selectedMinute", 2);
|
|
462
|
+
c = h([
|
|
463
|
+
v("scb-datepicker")
|
|
464
|
+
], c);
|
|
426
465
|
export {
|
|
427
|
-
|
|
466
|
+
c as ScbDatepicker
|
|
428
467
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { css as v, LitElement as x, html as
|
|
1
|
+
import { css as v, LitElement as x, html as d } from "lit";
|
|
2
2
|
import { property as a, state as g, customElement as y } from "lit/decorators.js";
|
|
3
3
|
import "@material/web/icon/icon.js";
|
|
4
4
|
import "@material/web/ripple/ripple.js";
|
|
@@ -7,17 +7,17 @@ import "../scb-datepicker/scb-datepicker.js";
|
|
|
7
7
|
import "../scb-icon-button/scb-icon-button.js";
|
|
8
8
|
var w = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, m = (t) => {
|
|
9
9
|
throw TypeError(t);
|
|
10
|
-
}, r = (t, e, i,
|
|
11
|
-
for (var
|
|
12
|
-
(
|
|
13
|
-
return
|
|
14
|
-
},
|
|
10
|
+
}, r = (t, e, i, n) => {
|
|
11
|
+
for (var l = n > 1 ? void 0 : n ? _(e, i) : e, p = t.length - 1, h; p >= 0; p--)
|
|
12
|
+
(h = t[p]) && (l = (n ? h(e, i, l) : h(l)) || l);
|
|
13
|
+
return n && l && w(e, i, l), l;
|
|
14
|
+
}, $ = (t, e, i) => e.has(t) || m("Cannot " + i), k = (t, e, i) => e.has(t) ? m("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, i), c = (t, e, i) => ($(t, e, "access private method"), i), o, f, b, u;
|
|
15
15
|
let s = class extends x {
|
|
16
16
|
constructor() {
|
|
17
|
-
super(),
|
|
18
|
-
t.key === "Tab" && (this._kbShouldShowRing = !0, this._inputFocused &&
|
|
17
|
+
super(), k(this, o), this._internals = null, this._inputFocused = !1, this._kbShouldShowRing = !1, this._onGlobalKeydown = (t) => {
|
|
18
|
+
t.key === "Tab" && (this._kbShouldShowRing = !0, this._inputFocused && c(this, o, u).call(this));
|
|
19
19
|
}, this._onGlobalPointerDown = () => {
|
|
20
|
-
this._kbShouldShowRing = !1, this._inputFocused &&
|
|
20
|
+
this._kbShouldShowRing = !1, this._inputFocused && c(this, o, u).call(this);
|
|
21
21
|
}, this.type = "text", this.label = "", this.supportingText = "", this.errorText = "", this.leadingIcon = "", this.name = "", this.pattern = "", this.value = "", this.underLabel = "", this.error = !1, this.disabled = !1, this.required = !1, this.spacing = "", this.spacingTop = "", this.spacingBottom = "", this._form = null, this._formSubmitHandler = null, this._formResetHandler = null, this._initialValue = "", this._inputId = "", this._showDatepicker = !1, this._toggleDatepicker = () => {
|
|
22
22
|
this._showDatepicker = !this._showDatepicker;
|
|
23
23
|
}, this._onDateSelected = (t) => {
|
|
@@ -39,9 +39,9 @@ let s = class extends x {
|
|
|
39
39
|
}, "attachInternals" in this && (this._internals = this.attachInternals());
|
|
40
40
|
}
|
|
41
41
|
render() {
|
|
42
|
-
const t = this.leadingIcon ?
|
|
42
|
+
const t = this.leadingIcon ? d`<md-icon class="scb-textfield-icon">${this.leadingIcon}</md-icon>` : null, e = this.error ? d`<md-icon class="scb-textfield-error-icon" aria-hidden="true">error</md-icon>` : null;
|
|
43
43
|
this.underLabel = this.error ? this.errorText || "Ogiltig inmatning." : this.supportingText, this.value = this.value || "";
|
|
44
|
-
const i = this.underLabel ? `${this._inputId}-supporting-text` : void 0,
|
|
44
|
+
const i = this.underLabel ? `${this._inputId}-supporting-text` : void 0, n = this.type === "search" && this.value ? d`
|
|
45
45
|
<button
|
|
46
46
|
type="button"
|
|
47
47
|
class="scb-textfield-clear"
|
|
@@ -76,7 +76,7 @@ let s = class extends x {
|
|
|
76
76
|
</svg>
|
|
77
77
|
</button>
|
|
78
78
|
` : null;
|
|
79
|
-
return this.type === "textarea" ?
|
|
79
|
+
return this.type === "textarea" ? d`
|
|
80
80
|
<label class="scb-textfield-label" for="${this._inputId}">${this.label}</label>
|
|
81
81
|
<span
|
|
82
82
|
class="scb-textfield-supporting-text"
|
|
@@ -100,7 +100,7 @@ ${this.value}</textarea
|
|
|
100
100
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
101
101
|
</div>
|
|
102
102
|
</div>
|
|
103
|
-
` : this.type === "date" ?
|
|
103
|
+
` : this.type === "date" ? d`
|
|
104
104
|
<label class="scb-textfield-label" for="${this._inputId}">${this.label}</label>
|
|
105
105
|
<span
|
|
106
106
|
class="scb-textfield-supporting-text"
|
|
@@ -121,25 +121,109 @@ ${this.value}</textarea
|
|
|
121
121
|
aria-invalid=${this.error ? "true" : "false"}
|
|
122
122
|
aria-describedby=${i}
|
|
123
123
|
readonly
|
|
124
|
+
@focus=${this._toggleDatepicker}
|
|
125
|
+
@click=${this._toggleDatepicker}
|
|
124
126
|
/>
|
|
125
|
-
${e}
|
|
126
127
|
<md-ripple></md-ripple>
|
|
127
128
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
128
129
|
</div>
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
${this.error ? e : d`
|
|
131
|
+
<scb-icon-button
|
|
132
|
+
class="scb-textfield-datepicker-button"
|
|
133
|
+
icon="calendar_today"
|
|
134
|
+
@click=${this._toggleDatepicker}
|
|
135
|
+
aria-label="Välj datum"
|
|
136
|
+
></scb-icon-button>`}
|
|
137
|
+
<scb-datepicker
|
|
138
|
+
.selectedValue=${this.value}
|
|
139
|
+
.open=${this._showDatepicker}
|
|
140
|
+
@date-selected=${this._onDateSelected}
|
|
141
|
+
></scb-datepicker>
|
|
142
|
+
</div>
|
|
143
|
+
` : this.type === "datetime-local" ? d`
|
|
144
|
+
<label class="scb-textfield-label" for="${this._inputId}">${this.label}</label>
|
|
145
|
+
<span
|
|
146
|
+
class="scb-textfield-supporting-text"
|
|
147
|
+
id="${this.underLabel ? `${this._inputId}-supporting-text` : ""}"
|
|
148
|
+
>${this.underLabel}</span
|
|
149
|
+
>
|
|
150
|
+
<div class="scb-textfield-wrapper" style="position:relative;">
|
|
151
|
+
${t}
|
|
152
|
+
<div class="ripple-wrapper">
|
|
153
|
+
<input
|
|
154
|
+
class="scb-textfield${this.error ? " has-error-icon" : ""}"
|
|
155
|
+
.value=${this.value}
|
|
156
|
+
type="text"
|
|
157
|
+
name="${this.name}"
|
|
158
|
+
id="${this._inputId}"
|
|
159
|
+
?disabled=${this.disabled}
|
|
160
|
+
?required=${this.required}
|
|
161
|
+
aria-invalid=${this.error ? "true" : "false"}
|
|
162
|
+
aria-describedby=${i}
|
|
163
|
+
readonly
|
|
164
|
+
@focus=${this._toggleDatepicker}
|
|
132
165
|
@click=${this._toggleDatepicker}
|
|
133
|
-
|
|
134
|
-
|
|
166
|
+
/>
|
|
167
|
+
|
|
168
|
+
<md-ripple></md-ripple>
|
|
169
|
+
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
170
|
+
</div>
|
|
171
|
+
|
|
172
|
+
${this.error ? e : d`
|
|
173
|
+
<scb-icon-button
|
|
174
|
+
class="scb-textfield-datepicker-button"
|
|
175
|
+
icon="calendar_today"
|
|
176
|
+
@click=${this._toggleDatepicker}
|
|
177
|
+
aria-label="Välj datum"
|
|
178
|
+
></scb-icon-button>`}
|
|
135
179
|
<scb-datepicker
|
|
136
|
-
variant="
|
|
180
|
+
variant="datetime-local"
|
|
137
181
|
.selectedValue=${this.value}
|
|
138
182
|
.open=${this._showDatepicker}
|
|
139
183
|
@date-selected=${this._onDateSelected}
|
|
140
184
|
></scb-datepicker>
|
|
141
185
|
</div>
|
|
142
|
-
` :
|
|
186
|
+
` : this.type === "time" ? d`
|
|
187
|
+
<label class="scb-textfield-label" for="${this._inputId}">${this.label}</label>
|
|
188
|
+
<span
|
|
189
|
+
class="scb-textfield-supporting-text"
|
|
190
|
+
id="${this.underLabel ? `${this._inputId}-supporting-text` : ""}"
|
|
191
|
+
>${this.underLabel}</span
|
|
192
|
+
>
|
|
193
|
+
<div class="scb-textfield-wrapper">
|
|
194
|
+
${t}
|
|
195
|
+
<div class="ripple-wrapper">
|
|
196
|
+
<input
|
|
197
|
+
class="scb-textfield${this.error ? " has-error-icon" : ""}"
|
|
198
|
+
.value=${this.value}
|
|
199
|
+
type="time"
|
|
200
|
+
name="${this.name}"
|
|
201
|
+
id="${this._inputId}"
|
|
202
|
+
?disabled=${this.disabled}
|
|
203
|
+
?required=${this.required}
|
|
204
|
+
aria-invalid=${this.error ? "true" : "false"}
|
|
205
|
+
aria-describedby=${i}
|
|
206
|
+
@input=${(l) => {
|
|
207
|
+
const p = l.target;
|
|
208
|
+
if (this.value = p.value, this._internals) {
|
|
209
|
+
const h = this.disabled ? null : this.value;
|
|
210
|
+
this._internals.setFormValue(h);
|
|
211
|
+
}
|
|
212
|
+
this.dispatchEvent(new Event("input", { bubbles: !0, composed: !0 })), this.dispatchEvent(
|
|
213
|
+
new CustomEvent("onValueChanged", {
|
|
214
|
+
detail: { value: this.value },
|
|
215
|
+
bubbles: !0,
|
|
216
|
+
composed: !0
|
|
217
|
+
})
|
|
218
|
+
);
|
|
219
|
+
}}
|
|
220
|
+
/>
|
|
221
|
+
${e}
|
|
222
|
+
<md-ripple></md-ripple>
|
|
223
|
+
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
226
|
+
` : d`
|
|
143
227
|
<label class="scb-textfield-label" for="${this._inputId}">${this.label}</label>
|
|
144
228
|
<span
|
|
145
229
|
class="scb-textfield-supporting-text"
|
|
@@ -160,7 +244,7 @@ ${this.value}</textarea
|
|
|
160
244
|
aria-invalid=${this.error ? "true" : "false"}
|
|
161
245
|
aria-describedby=${i}
|
|
162
246
|
/>
|
|
163
|
-
${
|
|
247
|
+
${n}
|
|
164
248
|
${e}
|
|
165
249
|
<md-ripple></md-ripple>
|
|
166
250
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
@@ -177,14 +261,14 @@ ${this.value}</textarea
|
|
|
177
261
|
super.firstUpdated(t), this._initialValue = this.value;
|
|
178
262
|
const e = (i = this.shadowRoot) == null ? void 0 : i.querySelector(".scb-textfield");
|
|
179
263
|
e && (e.addEventListener("input", () => {
|
|
180
|
-
const
|
|
181
|
-
if (this.value =
|
|
182
|
-
const
|
|
183
|
-
this._internals.setFormValue(
|
|
264
|
+
const n = e;
|
|
265
|
+
if (this.value = n.value, this._internals) {
|
|
266
|
+
const l = this.disabled ? null : this.value;
|
|
267
|
+
this._internals.setFormValue(l);
|
|
184
268
|
}
|
|
185
269
|
if (this.pattern) {
|
|
186
|
-
const
|
|
187
|
-
this.error = !
|
|
270
|
+
const l = new RegExp(this.pattern);
|
|
271
|
+
this.error = !l.test(this.value);
|
|
188
272
|
}
|
|
189
273
|
this.dispatchEvent(new Event("input", { bubbles: !0, composed: !0 })), this.dispatchEvent(
|
|
190
274
|
new CustomEvent("onValueChanged", {
|
|
@@ -198,17 +282,17 @@ ${this.value}</textarea
|
|
|
198
282
|
}), e.addEventListener("select", () => {
|
|
199
283
|
this.dispatchEvent(new Event("select", { bubbles: !0, composed: !0 }));
|
|
200
284
|
}), e.addEventListener("focus", () => {
|
|
201
|
-
this._inputFocused = !0,
|
|
285
|
+
this._inputFocused = !0, c(this, o, u).call(this);
|
|
202
286
|
}), e.addEventListener("blur", () => {
|
|
203
|
-
this._inputFocused = !1,
|
|
204
|
-
})),
|
|
287
|
+
this._inputFocused = !1, c(this, o, u).call(this);
|
|
288
|
+
})), c(this, o, f).call(this);
|
|
205
289
|
}
|
|
206
290
|
updated(t) {
|
|
207
291
|
if (super.updated(t), this.toggleAttribute("aria-disabled", this.disabled), this._internals && (t.has("value") || t.has("disabled"))) {
|
|
208
292
|
const e = this.disabled ? null : this.value;
|
|
209
293
|
this._internals.setFormValue(e);
|
|
210
294
|
}
|
|
211
|
-
(t.has("spacing") || t.has("spacingTop") || t.has("spacingBottom")) &&
|
|
295
|
+
(t.has("spacing") || t.has("spacingTop") || t.has("spacingBottom")) && c(this, o, f).call(this);
|
|
212
296
|
}
|
|
213
297
|
// Körs av webbläsaren när formuläret sätter disabled på kontrollen
|
|
214
298
|
formDisabledCallback(t) {
|
|
@@ -238,8 +322,8 @@ ${this.value}</textarea
|
|
|
238
322
|
this.required && !t.value ? t.setCustomValidity(this.errorText || "Ogiltig inmatning.") : t.setCustomValidity("");
|
|
239
323
|
const i = t.reportValidity();
|
|
240
324
|
this.error = !i;
|
|
241
|
-
const
|
|
242
|
-
return i || (this.errorText =
|
|
325
|
+
const n = i ? "" : this.errorText || t.validationMessage || "Ogiltig inmatning.";
|
|
326
|
+
return i || (this.errorText = n), this._internals && (i ? this._internals.setValidity({}) : this._internals.setValidity({ customError: !0 }, n, t)), i;
|
|
243
327
|
}
|
|
244
328
|
return !0;
|
|
245
329
|
}
|
|
@@ -267,16 +351,16 @@ ${this.value}</textarea
|
|
|
267
351
|
};
|
|
268
352
|
o = /* @__PURE__ */ new WeakSet();
|
|
269
353
|
f = function() {
|
|
270
|
-
const t =
|
|
354
|
+
const t = c(this, o, b).call(this, this.spacing), e = c(this, o, b).call(this, this.spacingTop) ?? t, i = c(this, o, b).call(this, this.spacingBottom) ?? t;
|
|
271
355
|
e ? this.style.setProperty("--scb-textfield-spacing-block-start", e) : this.style.removeProperty("--scb-textfield-spacing-block-start"), i ? this.style.setProperty("--scb-textfield-spacing-block-end", i) : this.style.removeProperty("--scb-textfield-spacing-block-end");
|
|
272
356
|
};
|
|
273
|
-
|
|
357
|
+
b = function(t) {
|
|
274
358
|
if (!t) return;
|
|
275
359
|
const e = String(t).trim();
|
|
276
360
|
if (e)
|
|
277
361
|
return /^\d+$/.test(e) ? `var(--spacing-${Math.max(0, Math.min(14, parseInt(e, 10)))})` : e;
|
|
278
362
|
};
|
|
279
|
-
|
|
363
|
+
u = function() {
|
|
280
364
|
var e;
|
|
281
365
|
const t = (e = this.renderRoot) == null ? void 0 : e.querySelector(".ripple-wrapper");
|
|
282
366
|
t && (this._inputFocused && this._kbShouldShowRing ? t.setAttribute("data-kb-focus", "true") : t.removeAttribute("data-kb-focus"));
|
|
@@ -309,6 +393,12 @@ s.styles = [
|
|
|
309
393
|
:host([type='text']) {
|
|
310
394
|
--scb-textfield-max-width: var(--scb-textfield-text-max-width);
|
|
311
395
|
}
|
|
396
|
+
:host([type='date']) {
|
|
397
|
+
--scb-textfield-max-width: var(--scb-textfield-text-max-width);
|
|
398
|
+
}
|
|
399
|
+
:host([type='datetime-local']) {
|
|
400
|
+
--scb-textfield-max-width: var(--scb-textfield-text-max-width);
|
|
401
|
+
}
|
|
312
402
|
:host([type='search']) {
|
|
313
403
|
--scb-textfield-max-width: var(--scb-textfield-search-max-width);
|
|
314
404
|
}
|
|
@@ -330,6 +420,13 @@ s.styles = [
|
|
|
330
420
|
:host([type='date']) {
|
|
331
421
|
--scb-textfield-max-width: var(--scb-textfield-text-max-width);
|
|
332
422
|
}
|
|
423
|
+
:host([type='time']) {
|
|
424
|
+
--scb-textfield-max-width: var(--scb-textfield-text-max-width);
|
|
425
|
+
}
|
|
426
|
+
input[type="time"]::-webkit-calendar-picker-indicator {
|
|
427
|
+
display: none;
|
|
428
|
+
background: none;
|
|
429
|
+
}
|
|
333
430
|
|
|
334
431
|
:host {
|
|
335
432
|
display: flex;
|
|
@@ -5,16 +5,26 @@ export declare class ScbTocItem extends LitElement {
|
|
|
5
5
|
supportingText: string;
|
|
6
6
|
itemHref: string;
|
|
7
7
|
divider: boolean;
|
|
8
|
+
private static _uidPrefix;
|
|
9
|
+
private static _uidSeq;
|
|
10
|
+
private static _uid;
|
|
8
11
|
private _unique;
|
|
12
|
+
private _overflowVisibleTimer;
|
|
9
13
|
static styles: import('lit').CSSResult[];
|
|
10
14
|
private _slotHasContent;
|
|
11
|
-
|
|
12
|
-
disconnectedCallback(): void;
|
|
15
|
+
protected firstUpdated(): void;
|
|
13
16
|
protected updated(changed: Map<string, unknown>): void;
|
|
17
|
+
disconnectedCallback(): void;
|
|
18
|
+
private _applyInertByExpanded;
|
|
19
|
+
private _syncOverflowVisibilityByExpanded;
|
|
20
|
+
private _getTransitionMs;
|
|
14
21
|
private _onSlotChange;
|
|
15
|
-
private
|
|
16
|
-
private
|
|
17
|
-
private
|
|
22
|
+
private _supportsInert;
|
|
23
|
+
private _collectFocusableFromSlot;
|
|
24
|
+
private _removeTabIndexesIfNeeded;
|
|
25
|
+
private _restoreTabIndexesIfNeeded;
|
|
26
|
+
private _collapseSiblingsIfNeeded;
|
|
27
|
+
private _toggleAccordion;
|
|
18
28
|
private _onKeyDown;
|
|
19
29
|
render(): import('lit-html').TemplateResult<1>;
|
|
20
30
|
}
|