scb-wc-test 0.1.109 → 0.1.111
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/blazor/ScbBlazorInteropBase.cs +313 -12
- package/blazor/scb-blazor-bridge.js +603 -8
- package/mvc/components/scb-search/scb-search.js +2 -2
- package/mvc/components/scb-textfield/scb-textfield.js +110 -44
- package/mvc/scb-blazor-bridge.js +603 -8
- package/package.json +2 -2
- package/scb-search/scb-search.js +2 -2
- package/scb-textfield/scb-textfield.d.ts +4 -0
- package/scb-textfield/scb-textfield.js +160 -70
- package/scb-wc-test.bundle.js +456 -390
|
@@ -1,20 +1,35 @@
|
|
|
1
|
-
import { css as
|
|
2
|
-
import { property as a, customElement as
|
|
1
|
+
import { css as v, LitElement as x, html as c } from "lit";
|
|
2
|
+
import { property as a, state as g, customElement as y } from "lit/decorators.js";
|
|
3
3
|
import "@material/web/icon/icon.js";
|
|
4
|
+
import "@material/web/ripple/ripple.js";
|
|
5
|
+
import "@material/web/focus/md-focus-ring.js";
|
|
4
6
|
import "../scb-datepicker/scb-datepicker.js";
|
|
5
|
-
|
|
7
|
+
import "../scb-icon-button/scb-icon-button.js";
|
|
8
|
+
var w = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, m = (t) => {
|
|
6
9
|
throw TypeError(t);
|
|
7
10
|
}, r = (t, e, i, l) => {
|
|
8
|
-
for (var
|
|
9
|
-
(
|
|
10
|
-
return l &&
|
|
11
|
-
},
|
|
11
|
+
for (var n = l > 1 ? void 0 : l ? _(e, i) : e, u = t.length - 1, b; u >= 0; u--)
|
|
12
|
+
(b = t[u]) && (n = (l ? b(e, i, n) : b(n)) || n);
|
|
13
|
+
return l && n && w(e, i, n), n;
|
|
14
|
+
}, k = (t, e, i) => e.has(t) || m("Cannot " + i), $ = (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), d = (t, e, i) => (k(t, e, "access private method"), i), o, f, h, p;
|
|
12
15
|
let s = class extends x {
|
|
13
16
|
constructor() {
|
|
14
|
-
super(),
|
|
17
|
+
super(), $(this, o), this._internals = null, this._inputFocused = !1, this._kbShouldShowRing = !1, this._onGlobalKeydown = (t) => {
|
|
18
|
+
t.key === "Tab" && (this._kbShouldShowRing = !0, this._inputFocused && d(this, o, p).call(this));
|
|
19
|
+
}, this._onGlobalPointerDown = () => {
|
|
20
|
+
this._kbShouldShowRing = !1, this._inputFocused && d(this, o, p).call(this);
|
|
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 = () => {
|
|
15
22
|
this._showDatepicker = !this._showDatepicker;
|
|
16
23
|
}, this._onDateSelected = (t) => {
|
|
17
|
-
this.value = t.detail.value, this._showDatepicker = !1, this.
|
|
24
|
+
if (this.value = t.detail.value, this._showDatepicker = !1, this._internals) {
|
|
25
|
+
const e = this.disabled ? null : this.value;
|
|
26
|
+
this._internals.setFormValue(e);
|
|
27
|
+
}
|
|
28
|
+
if (this.pattern) {
|
|
29
|
+
const e = new RegExp(this.pattern);
|
|
30
|
+
this.error = !e.test(this.value);
|
|
31
|
+
}
|
|
32
|
+
this.dispatchEvent(new Event("input", { bubbles: !0, composed: !0 })), this.dispatchEvent(
|
|
18
33
|
new CustomEvent("onValueChanged", {
|
|
19
34
|
detail: { value: this.value },
|
|
20
35
|
bubbles: !0,
|
|
@@ -24,9 +39,9 @@ let s = class extends x {
|
|
|
24
39
|
}, "attachInternals" in this && (this._internals = this.attachInternals());
|
|
25
40
|
}
|
|
26
41
|
render() {
|
|
27
|
-
const t = this.leadingIcon ?
|
|
42
|
+
const t = this.leadingIcon ? c`<md-icon class="scb-textfield-icon">${this.leadingIcon}</md-icon>` : null, e = this.error ? c`<md-icon class="scb-textfield-error-icon" aria-hidden="true">error</md-icon>` : null;
|
|
28
43
|
this.underLabel = this.error ? this.errorText || "Ogiltig inmatning." : this.supportingText, this.value = this.value || "";
|
|
29
|
-
const i = this.underLabel ? `${this._inputId}-supporting-text` : void 0, l = this.type === "search" && this.value ?
|
|
44
|
+
const i = this.underLabel ? `${this._inputId}-supporting-text` : void 0, l = this.type === "search" && this.value ? c`
|
|
30
45
|
<button
|
|
31
46
|
type="button"
|
|
32
47
|
class="scb-textfield-clear"
|
|
@@ -61,7 +76,7 @@ let s = class extends x {
|
|
|
61
76
|
</svg>
|
|
62
77
|
</button>
|
|
63
78
|
` : null;
|
|
64
|
-
return this.type === "textarea" ?
|
|
79
|
+
return this.type === "textarea" ? c`
|
|
65
80
|
<label class="scb-textfield-label" for="${this._inputId}">${this.label}</label>
|
|
66
81
|
<span
|
|
67
82
|
class="scb-textfield-supporting-text"
|
|
@@ -69,49 +84,62 @@ let s = class extends x {
|
|
|
69
84
|
>${this.underLabel}</span
|
|
70
85
|
>
|
|
71
86
|
<div class="scb-textfield-wrapper">
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
87
|
+
<div class="ripple-wrapper">
|
|
88
|
+
<textarea
|
|
89
|
+
class="scb-textfield"
|
|
90
|
+
?disabled=${this.disabled}
|
|
91
|
+
name="${this.name}"
|
|
92
|
+
id="${this._inputId}"
|
|
93
|
+
?required=${this.required}
|
|
94
|
+
aria-invalid=${this.error ? "true" : "false"}
|
|
95
|
+
aria-describedby=${i}
|
|
96
|
+
>
|
|
81
97
|
${this.value}</textarea
|
|
82
|
-
|
|
98
|
+
>
|
|
99
|
+
<md-ripple></md-ripple>
|
|
100
|
+
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
101
|
+
</div>
|
|
83
102
|
</div>
|
|
84
|
-
` : this.type === "date" ?
|
|
103
|
+
` : this.type === "date" ? c`
|
|
85
104
|
<label class="scb-textfield-label" for="${this._inputId}">${this.label}</label>
|
|
86
105
|
<span
|
|
87
106
|
class="scb-textfield-supporting-text"
|
|
88
107
|
id="${this.underLabel ? `${this._inputId}-supporting-text` : ""}"
|
|
89
108
|
>${this.underLabel}</span
|
|
90
109
|
>
|
|
91
|
-
<div class="scb-textfield-wrapper"
|
|
110
|
+
<div class="scb-textfield-wrapper">
|
|
92
111
|
${t}
|
|
93
|
-
<
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
112
|
+
<div class="ripple-wrapper">
|
|
113
|
+
<input
|
|
114
|
+
class="scb-textfield${this.error ? " has-error-icon" : ""}"
|
|
115
|
+
.value=${this.value}
|
|
116
|
+
type="text"
|
|
117
|
+
name="${this.name}"
|
|
118
|
+
id="${this._inputId}"
|
|
119
|
+
?disabled=${this.disabled}
|
|
120
|
+
?required=${this.required}
|
|
121
|
+
aria-invalid=${this.error ? "true" : "false"}
|
|
122
|
+
aria-describedby=${i}
|
|
123
|
+
readonly
|
|
124
|
+
/>
|
|
125
|
+
${e}
|
|
126
|
+
<md-ripple></md-ripple>
|
|
127
|
+
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
128
|
+
</div>
|
|
129
|
+
<scb-icon-button
|
|
130
|
+
class="scb-textfield-datepicker-button"
|
|
131
|
+
icon="calendar_today"
|
|
132
|
+
@click=${this._toggleDatepicker}
|
|
133
|
+
aria-label="Välj datum"
|
|
134
|
+
></scb-icon-button>
|
|
106
135
|
<scb-datepicker
|
|
107
136
|
variant="popup"
|
|
108
137
|
.selectedValue=${this.value}
|
|
109
138
|
.open=${this._showDatepicker}
|
|
110
139
|
@date-selected=${this._onDateSelected}
|
|
111
140
|
></scb-datepicker>
|
|
112
|
-
${e}
|
|
113
141
|
</div>
|
|
114
|
-
` :
|
|
142
|
+
` : c`
|
|
115
143
|
<label class="scb-textfield-label" for="${this._inputId}">${this.label}</label>
|
|
116
144
|
<span
|
|
117
145
|
class="scb-textfield-supporting-text"
|
|
@@ -120,19 +148,23 @@ ${this.value}</textarea
|
|
|
120
148
|
>
|
|
121
149
|
<div class="scb-textfield-wrapper">
|
|
122
150
|
${t}
|
|
123
|
-
<
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
151
|
+
<div class="ripple-wrapper">
|
|
152
|
+
<input
|
|
153
|
+
class="scb-textfield${this.error ? " has-error-icon" : ""}"
|
|
154
|
+
.value=${this.value}
|
|
155
|
+
type="${this.type}"
|
|
156
|
+
name="${this.name}"
|
|
157
|
+
id="${this._inputId}"
|
|
158
|
+
?disabled=${this.disabled}
|
|
159
|
+
?required=${this.required}
|
|
160
|
+
aria-invalid=${this.error ? "true" : "false"}
|
|
161
|
+
aria-describedby=${i}
|
|
162
|
+
/>
|
|
163
|
+
${l}
|
|
164
|
+
${e}
|
|
165
|
+
<md-ripple></md-ripple>
|
|
166
|
+
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
167
|
+
</div>
|
|
136
168
|
</div>
|
|
137
169
|
`;
|
|
138
170
|
}
|
|
@@ -147,12 +179,12 @@ ${this.value}</textarea
|
|
|
147
179
|
e && (e.addEventListener("input", () => {
|
|
148
180
|
const l = e;
|
|
149
181
|
if (this.value = l.value, this._internals) {
|
|
150
|
-
const
|
|
151
|
-
this._internals.setFormValue(
|
|
182
|
+
const n = this.disabled ? null : this.value;
|
|
183
|
+
this._internals.setFormValue(n);
|
|
152
184
|
}
|
|
153
185
|
if (this.pattern) {
|
|
154
|
-
const
|
|
155
|
-
this.error = !
|
|
186
|
+
const n = new RegExp(this.pattern);
|
|
187
|
+
this.error = !n.test(this.value);
|
|
156
188
|
}
|
|
157
189
|
this.dispatchEvent(new Event("input", { bubbles: !0, composed: !0 })), this.dispatchEvent(
|
|
158
190
|
new CustomEvent("onValueChanged", {
|
|
@@ -165,14 +197,18 @@ ${this.value}</textarea
|
|
|
165
197
|
this.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 }));
|
|
166
198
|
}), e.addEventListener("select", () => {
|
|
167
199
|
this.dispatchEvent(new Event("select", { bubbles: !0, composed: !0 }));
|
|
168
|
-
})
|
|
200
|
+
}), e.addEventListener("focus", () => {
|
|
201
|
+
this._inputFocused = !0, d(this, o, p).call(this);
|
|
202
|
+
}), e.addEventListener("blur", () => {
|
|
203
|
+
this._inputFocused = !1, d(this, o, p).call(this);
|
|
204
|
+
})), d(this, o, f).call(this);
|
|
169
205
|
}
|
|
170
206
|
updated(t) {
|
|
171
207
|
if (super.updated(t), this.toggleAttribute("aria-disabled", this.disabled), this._internals && (t.has("value") || t.has("disabled"))) {
|
|
172
208
|
const e = this.disabled ? null : this.value;
|
|
173
209
|
this._internals.setFormValue(e);
|
|
174
210
|
}
|
|
175
|
-
(t.has("spacing") || t.has("spacingTop") || t.has("spacingBottom")) &&
|
|
211
|
+
(t.has("spacing") || t.has("spacingTop") || t.has("spacingBottom")) && d(this, o, f).call(this);
|
|
176
212
|
}
|
|
177
213
|
// Körs av webbläsaren när formuläret sätter disabled på kontrollen
|
|
178
214
|
formDisabledCallback(t) {
|
|
@@ -187,10 +223,10 @@ ${this.value}</textarea
|
|
|
187
223
|
this.value = this._initialValue;
|
|
188
224
|
const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector(".scb-textfield");
|
|
189
225
|
t && (t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement) && (t.value = this._initialValue), this.error = !1;
|
|
190
|
-
}, this._form.addEventListener("reset", this._formResetHandler, !0));
|
|
226
|
+
}, this._form.addEventListener("reset", this._formResetHandler, !0)), window.addEventListener("keydown", this._onGlobalKeydown, !0), window.addEventListener("pointerdown", this._onGlobalPointerDown, !0);
|
|
191
227
|
}
|
|
192
228
|
disconnectedCallback() {
|
|
193
|
-
super.disconnectedCallback(), this._form && this._formSubmitHandler && (this._form.removeEventListener("submit", this._formSubmitHandler, !0), this._formResetHandler && this._form.removeEventListener("reset", this._formResetHandler, !0));
|
|
229
|
+
super.disconnectedCallback(), this._form && this._formSubmitHandler && (this._form.removeEventListener("submit", this._formSubmitHandler, !0), this._formResetHandler && this._form.removeEventListener("reset", this._formResetHandler, !0)), window.removeEventListener("keydown", this._onGlobalKeydown, !0), window.removeEventListener("pointerdown", this._onGlobalPointerDown, !0);
|
|
194
230
|
}
|
|
195
231
|
/**
|
|
196
232
|
* Kallar på reportValidity på den inbyggda input/textarea och sätter felstatus till error-text.
|
|
@@ -229,20 +265,25 @@ ${this.value}</textarea
|
|
|
229
265
|
}
|
|
230
266
|
}
|
|
231
267
|
};
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const t =
|
|
268
|
+
o = /* @__PURE__ */ new WeakSet();
|
|
269
|
+
f = function() {
|
|
270
|
+
const t = d(this, o, h).call(this, this.spacing), e = d(this, o, h).call(this, this.spacingTop) ?? t, i = d(this, o, h).call(this, this.spacingBottom) ?? t;
|
|
235
271
|
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");
|
|
236
272
|
};
|
|
237
|
-
|
|
273
|
+
h = function(t) {
|
|
238
274
|
if (!t) return;
|
|
239
275
|
const e = String(t).trim();
|
|
240
276
|
if (e)
|
|
241
277
|
return /^\d+$/.test(e) ? `var(--spacing-${Math.max(0, Math.min(14, parseInt(e, 10)))})` : e;
|
|
242
278
|
};
|
|
279
|
+
p = function() {
|
|
280
|
+
var e;
|
|
281
|
+
const t = (e = this.renderRoot) == null ? void 0 : e.querySelector(".ripple-wrapper");
|
|
282
|
+
t && (this._inputFocused && this._kbShouldShowRing ? t.setAttribute("data-kb-focus", "true") : t.removeAttribute("data-kb-focus"));
|
|
283
|
+
};
|
|
243
284
|
s.formAssociated = !0;
|
|
244
285
|
s.styles = [
|
|
245
|
-
|
|
286
|
+
v`
|
|
246
287
|
:host {
|
|
247
288
|
--scb-textfield-number-max-width: 280px;
|
|
248
289
|
--scb-textfield-text-max-width: 400px;
|
|
@@ -258,6 +299,8 @@ s.styles = [
|
|
|
258
299
|
/* Vertikalt avstånd styrs av spacing-attributen via CSS-variabler */
|
|
259
300
|
margin-block-start: var(--scb-textfield-spacing-block-start, 0);
|
|
260
301
|
margin-block-end: var(--scb-textfield-spacing-block-end, 0);
|
|
302
|
+
|
|
303
|
+
-webkit-tap-highlight-color: transparent;
|
|
261
304
|
}
|
|
262
305
|
|
|
263
306
|
:host([type='number']) {
|
|
@@ -266,9 +309,6 @@ s.styles = [
|
|
|
266
309
|
:host([type='text']) {
|
|
267
310
|
--scb-textfield-max-width: var(--scb-textfield-text-max-width);
|
|
268
311
|
}
|
|
269
|
-
:host([type='date']) {
|
|
270
|
-
--scb-textfield-max-width: var(--scb-textfield-text-max-width);
|
|
271
|
-
}
|
|
272
312
|
:host([type='search']) {
|
|
273
313
|
--scb-textfield-max-width: var(--scb-textfield-search-max-width);
|
|
274
314
|
}
|
|
@@ -287,6 +327,9 @@ s.styles = [
|
|
|
287
327
|
:host([type='textarea']) {
|
|
288
328
|
--scb-textfield-max-width: var(--scb-textfield-textarea-max-width);
|
|
289
329
|
}
|
|
330
|
+
:host([type='date']) {
|
|
331
|
+
--scb-textfield-max-width: var(--scb-textfield-text-max-width);
|
|
332
|
+
}
|
|
290
333
|
|
|
291
334
|
:host {
|
|
292
335
|
display: flex;
|
|
@@ -337,12 +380,18 @@ s.styles = [
|
|
|
337
380
|
box-sizing: border-box;
|
|
338
381
|
background-color: transparent;
|
|
339
382
|
color: var(--md-sys-color-on-surface);
|
|
383
|
+
position: relative;
|
|
384
|
+
z-index: 1;
|
|
340
385
|
}
|
|
341
386
|
|
|
342
387
|
:host([type='search']) .scb-textfield {
|
|
343
388
|
padding-right: var(--spacing-11);
|
|
344
389
|
}
|
|
345
390
|
|
|
391
|
+
:host([type='date']) .scb-textfield {
|
|
392
|
+
padding-right: var(--spacing-11);
|
|
393
|
+
}
|
|
394
|
+
|
|
346
395
|
md-icon + .scb-textfield {
|
|
347
396
|
padding-left: var(--spacing-10);
|
|
348
397
|
}
|
|
@@ -354,6 +403,7 @@ s.styles = [
|
|
|
354
403
|
transform: translateY(-50%);
|
|
355
404
|
pointer-events: none;
|
|
356
405
|
font-size: var(--scale-06);
|
|
406
|
+
z-index: 2;
|
|
357
407
|
}
|
|
358
408
|
|
|
359
409
|
.scb-textfield:focus-visible {
|
|
@@ -368,6 +418,35 @@ s.styles = [
|
|
|
368
418
|
width: 100%;
|
|
369
419
|
}
|
|
370
420
|
|
|
421
|
+
/* Wrapper som bär ripple och md-focus-ring */
|
|
422
|
+
.ripple-wrapper {
|
|
423
|
+
position: relative;
|
|
424
|
+
width: 100%;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
md-focus-ring.input-ring {
|
|
428
|
+
position: absolute;
|
|
429
|
+
inset: 0;
|
|
430
|
+
pointer-events: none;
|
|
431
|
+
display: none;
|
|
432
|
+
border-radius: var(--md-sys-shape-corner-small);
|
|
433
|
+
z-index: 3;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
.ripple-wrapper[data-kb-focus='true'] md-focus-ring.input-ring {
|
|
437
|
+
display: block;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
md-ripple {
|
|
441
|
+
border-radius: var(--md-sys-shape-corner-small);
|
|
442
|
+
position: absolute;
|
|
443
|
+
inset: 0;
|
|
444
|
+
z-index: 0;
|
|
445
|
+
pointer-events: none;
|
|
446
|
+
--md-ripple-hover-color: transparent;
|
|
447
|
+
--md-ripple-hover-opacity: 0;
|
|
448
|
+
}
|
|
449
|
+
|
|
371
450
|
input[type='search']::-webkit-search-cancel-button {
|
|
372
451
|
appearance: none;
|
|
373
452
|
display: none;
|
|
@@ -381,6 +460,7 @@ s.styles = [
|
|
|
381
460
|
pointer-events: none;
|
|
382
461
|
font-size: var(--scale-06);
|
|
383
462
|
color: var(--md-sys-color-error);
|
|
463
|
+
z-index: 2;
|
|
384
464
|
}
|
|
385
465
|
|
|
386
466
|
.scb-textfield.has-error-icon {
|
|
@@ -406,6 +486,7 @@ s.styles = [
|
|
|
406
486
|
justify-content: center;
|
|
407
487
|
cursor: pointer;
|
|
408
488
|
color: var(--md-sys-color-on-surface);
|
|
489
|
+
z-index: 2;
|
|
409
490
|
}
|
|
410
491
|
|
|
411
492
|
:host([error]) .scb-textfield-clear {
|
|
@@ -422,6 +503,15 @@ s.styles = [
|
|
|
422
503
|
height: 100%;
|
|
423
504
|
display: block;
|
|
424
505
|
}
|
|
506
|
+
|
|
507
|
+
/* Datumknappen ovanför input/ripple */
|
|
508
|
+
.scb-textfield-datepicker-button {
|
|
509
|
+
position: absolute;
|
|
510
|
+
right: var(--spacing-4);
|
|
511
|
+
top: 50%;
|
|
512
|
+
transform: translateY(-50%);
|
|
513
|
+
z-index: 4;
|
|
514
|
+
}
|
|
425
515
|
`
|
|
426
516
|
];
|
|
427
517
|
r([
|
|
@@ -470,10 +560,10 @@ r([
|
|
|
470
560
|
a({ type: String, attribute: "spacing-bottom", reflect: !0 })
|
|
471
561
|
], s.prototype, "spacingBottom", 2);
|
|
472
562
|
r([
|
|
473
|
-
|
|
563
|
+
g()
|
|
474
564
|
], s.prototype, "_showDatepicker", 2);
|
|
475
565
|
s = r([
|
|
476
|
-
|
|
566
|
+
y("scb-textfield")
|
|
477
567
|
], s);
|
|
478
568
|
export {
|
|
479
569
|
s as ScbTextField
|