scb-wc-test 0.1.109 → 0.1.110
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 +46 -6
- 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 +89 -34
- package/scb-wc-test.bundle.js +391 -351
|
@@ -1,17 +1,23 @@
|
|
|
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, customElement as y } from "lit/decorators.js";
|
|
3
3
|
import "@material/web/icon/icon.js";
|
|
4
4
|
import "../scb-datepicker/scb-datepicker.js";
|
|
5
|
-
|
|
5
|
+
import "@material/web/ripple/ripple.js";
|
|
6
|
+
import "@material/web/focus/md-focus-ring.js";
|
|
7
|
+
var g = Object.defineProperty, w = Object.getOwnPropertyDescriptor, m = (t) => {
|
|
6
8
|
throw TypeError(t);
|
|
7
|
-
}, r = (t, e, i,
|
|
8
|
-
for (var
|
|
9
|
-
(
|
|
10
|
-
return
|
|
11
|
-
}, _ = (t, e, i) => e.has(t) ||
|
|
9
|
+
}, r = (t, e, i, o) => {
|
|
10
|
+
for (var l = o > 1 ? void 0 : o ? w(e, i) : e, u = t.length - 1, b; u >= 0; u--)
|
|
11
|
+
(b = t[u]) && (l = (o ? b(e, i, l) : b(l)) || l);
|
|
12
|
+
return o && l && g(e, i, l), l;
|
|
13
|
+
}, _ = (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), d = (t, e, i) => (_(t, e, "access private method"), i), n, f, h, p;
|
|
12
14
|
let s = class extends x {
|
|
13
15
|
constructor() {
|
|
14
|
-
super(),
|
|
16
|
+
super(), k(this, n), this._internals = null, this._inputFocused = !1, this._kbShouldShowRing = !1, this._onGlobalKeydown = (t) => {
|
|
17
|
+
t.key === "Tab" && (this._kbShouldShowRing = !0, this._inputFocused && d(this, n, p).call(this));
|
|
18
|
+
}, this._onGlobalPointerDown = () => {
|
|
19
|
+
this._kbShouldShowRing = !1, this._inputFocused && d(this, n, p).call(this);
|
|
20
|
+
}, 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
21
|
this._showDatepicker = !this._showDatepicker;
|
|
16
22
|
}, this._onDateSelected = (t) => {
|
|
17
23
|
this.value = t.detail.value, this._showDatepicker = !1, this.dispatchEvent(new Event("input", { bubbles: !0, composed: !0 })), this.dispatchEvent(
|
|
@@ -24,9 +30,9 @@ let s = class extends x {
|
|
|
24
30
|
}, "attachInternals" in this && (this._internals = this.attachInternals());
|
|
25
31
|
}
|
|
26
32
|
render() {
|
|
27
|
-
const t = this.leadingIcon ?
|
|
33
|
+
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
34
|
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,
|
|
35
|
+
const i = this.underLabel ? `${this._inputId}-supporting-text` : void 0, o = this.type === "search" && this.value ? c`
|
|
30
36
|
<button
|
|
31
37
|
type="button"
|
|
32
38
|
class="scb-textfield-clear"
|
|
@@ -61,14 +67,14 @@ let s = class extends x {
|
|
|
61
67
|
</svg>
|
|
62
68
|
</button>
|
|
63
69
|
` : null;
|
|
64
|
-
return this.type === "textarea" ?
|
|
70
|
+
return this.type === "textarea" ? c`
|
|
65
71
|
<label class="scb-textfield-label" for="${this._inputId}">${this.label}</label>
|
|
66
72
|
<span
|
|
67
73
|
class="scb-textfield-supporting-text"
|
|
68
74
|
id="${this.underLabel ? `${this._inputId}-supporting-text` : ""}"
|
|
69
75
|
>${this.underLabel}</span
|
|
70
76
|
>
|
|
71
|
-
<div class="scb-textfield-wrapper">
|
|
77
|
+
<div class="scb-textfield-wrapper ripple-wrapper">
|
|
72
78
|
<textarea
|
|
73
79
|
class="scb-textfield"
|
|
74
80
|
?disabled=${this.disabled}
|
|
@@ -80,8 +86,10 @@ let s = class extends x {
|
|
|
80
86
|
>
|
|
81
87
|
${this.value}</textarea
|
|
82
88
|
>
|
|
89
|
+
<md-ripple></md-ripple>
|
|
90
|
+
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
83
91
|
</div>
|
|
84
|
-
` : this.type === "date" ?
|
|
92
|
+
` : this.type === "date" ? c`
|
|
85
93
|
<label class="scb-textfield-label" for="${this._inputId}">${this.label}</label>
|
|
86
94
|
<span
|
|
87
95
|
class="scb-textfield-supporting-text"
|
|
@@ -111,14 +119,14 @@ ${this.value}</textarea
|
|
|
111
119
|
></scb-datepicker>
|
|
112
120
|
${e}
|
|
113
121
|
</div>
|
|
114
|
-
` :
|
|
122
|
+
` : c`
|
|
115
123
|
<label class="scb-textfield-label" for="${this._inputId}">${this.label}</label>
|
|
116
124
|
<span
|
|
117
125
|
class="scb-textfield-supporting-text"
|
|
118
126
|
id="${this.underLabel ? `${this._inputId}-supporting-text` : ""}"
|
|
119
127
|
>${this.underLabel}</span
|
|
120
128
|
>
|
|
121
|
-
<div class="scb-textfield-wrapper">
|
|
129
|
+
<div class="scb-textfield-wrapper ripple-wrapper">
|
|
122
130
|
${t}
|
|
123
131
|
<input
|
|
124
132
|
class="scb-textfield${this.error ? " has-error-icon" : ""}"
|
|
@@ -131,8 +139,10 @@ ${this.value}</textarea
|
|
|
131
139
|
aria-invalid=${this.error ? "true" : "false"}
|
|
132
140
|
aria-describedby=${i}
|
|
133
141
|
/>
|
|
134
|
-
${
|
|
142
|
+
${o}
|
|
135
143
|
${e}
|
|
144
|
+
<md-ripple></md-ripple>
|
|
145
|
+
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
136
146
|
</div>
|
|
137
147
|
`;
|
|
138
148
|
}
|
|
@@ -145,14 +155,14 @@ ${this.value}</textarea
|
|
|
145
155
|
super.firstUpdated(t), this._initialValue = this.value;
|
|
146
156
|
const e = (i = this.shadowRoot) == null ? void 0 : i.querySelector(".scb-textfield");
|
|
147
157
|
e && (e.addEventListener("input", () => {
|
|
148
|
-
const
|
|
149
|
-
if (this.value =
|
|
150
|
-
const
|
|
151
|
-
this._internals.setFormValue(
|
|
158
|
+
const o = e;
|
|
159
|
+
if (this.value = o.value, this._internals) {
|
|
160
|
+
const l = this.disabled ? null : this.value;
|
|
161
|
+
this._internals.setFormValue(l);
|
|
152
162
|
}
|
|
153
163
|
if (this.pattern) {
|
|
154
|
-
const
|
|
155
|
-
this.error = !
|
|
164
|
+
const l = new RegExp(this.pattern);
|
|
165
|
+
this.error = !l.test(this.value);
|
|
156
166
|
}
|
|
157
167
|
this.dispatchEvent(new Event("input", { bubbles: !0, composed: !0 })), this.dispatchEvent(
|
|
158
168
|
new CustomEvent("onValueChanged", {
|
|
@@ -165,14 +175,18 @@ ${this.value}</textarea
|
|
|
165
175
|
this.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 }));
|
|
166
176
|
}), e.addEventListener("select", () => {
|
|
167
177
|
this.dispatchEvent(new Event("select", { bubbles: !0, composed: !0 }));
|
|
168
|
-
})
|
|
178
|
+
}), e.addEventListener("focus", () => {
|
|
179
|
+
this._inputFocused = !0, d(this, n, p).call(this);
|
|
180
|
+
}), e.addEventListener("blur", () => {
|
|
181
|
+
this._inputFocused = !1, d(this, n, p).call(this);
|
|
182
|
+
})), d(this, n, f).call(this);
|
|
169
183
|
}
|
|
170
184
|
updated(t) {
|
|
171
185
|
if (super.updated(t), this.toggleAttribute("aria-disabled", this.disabled), this._internals && (t.has("value") || t.has("disabled"))) {
|
|
172
186
|
const e = this.disabled ? null : this.value;
|
|
173
187
|
this._internals.setFormValue(e);
|
|
174
188
|
}
|
|
175
|
-
(t.has("spacing") || t.has("spacingTop") || t.has("spacingBottom")) &&
|
|
189
|
+
(t.has("spacing") || t.has("spacingTop") || t.has("spacingBottom")) && d(this, n, f).call(this);
|
|
176
190
|
}
|
|
177
191
|
// Körs av webbläsaren när formuläret sätter disabled på kontrollen
|
|
178
192
|
formDisabledCallback(t) {
|
|
@@ -187,10 +201,10 @@ ${this.value}</textarea
|
|
|
187
201
|
this.value = this._initialValue;
|
|
188
202
|
const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector(".scb-textfield");
|
|
189
203
|
t && (t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement) && (t.value = this._initialValue), this.error = !1;
|
|
190
|
-
}, this._form.addEventListener("reset", this._formResetHandler, !0));
|
|
204
|
+
}, this._form.addEventListener("reset", this._formResetHandler, !0)), window.addEventListener("keydown", this._onGlobalKeydown, !0), window.addEventListener("pointerdown", this._onGlobalPointerDown, !0);
|
|
191
205
|
}
|
|
192
206
|
disconnectedCallback() {
|
|
193
|
-
super.disconnectedCallback(), this._form && this._formSubmitHandler && (this._form.removeEventListener("submit", this._formSubmitHandler, !0), this._formResetHandler && this._form.removeEventListener("reset", this._formResetHandler, !0));
|
|
207
|
+
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
208
|
}
|
|
195
209
|
/**
|
|
196
210
|
* Kallar på reportValidity på den inbyggda input/textarea och sätter felstatus till error-text.
|
|
@@ -202,8 +216,8 @@ ${this.value}</textarea
|
|
|
202
216
|
this.required && !t.value ? t.setCustomValidity(this.errorText || "Ogiltig inmatning.") : t.setCustomValidity("");
|
|
203
217
|
const i = t.reportValidity();
|
|
204
218
|
this.error = !i;
|
|
205
|
-
const
|
|
206
|
-
return i || (this.errorText =
|
|
219
|
+
const o = i ? "" : this.errorText || t.validationMessage || "Ogiltig inmatning.";
|
|
220
|
+
return i || (this.errorText = o), this._internals && (i ? this._internals.setValidity({}) : this._internals.setValidity({ customError: !0 }, o, t)), i;
|
|
207
221
|
}
|
|
208
222
|
return !0;
|
|
209
223
|
}
|
|
@@ -230,19 +244,24 @@ ${this.value}</textarea
|
|
|
230
244
|
}
|
|
231
245
|
};
|
|
232
246
|
n = /* @__PURE__ */ new WeakSet();
|
|
233
|
-
|
|
234
|
-
const t =
|
|
247
|
+
f = function() {
|
|
248
|
+
const t = d(this, n, h).call(this, this.spacing), e = d(this, n, h).call(this, this.spacingTop) ?? t, i = d(this, n, h).call(this, this.spacingBottom) ?? t;
|
|
235
249
|
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
250
|
};
|
|
237
|
-
|
|
251
|
+
h = function(t) {
|
|
238
252
|
if (!t) return;
|
|
239
253
|
const e = String(t).trim();
|
|
240
254
|
if (e)
|
|
241
255
|
return /^\d+$/.test(e) ? `var(--spacing-${Math.max(0, Math.min(14, parseInt(e, 10)))})` : e;
|
|
242
256
|
};
|
|
257
|
+
p = function() {
|
|
258
|
+
var e;
|
|
259
|
+
const t = (e = this.renderRoot) == null ? void 0 : e.querySelector(".ripple-wrapper");
|
|
260
|
+
t && (this._inputFocused && this._kbShouldShowRing ? t.setAttribute("data-kb-focus", "true") : t.removeAttribute("data-kb-focus"));
|
|
261
|
+
};
|
|
243
262
|
s.formAssociated = !0;
|
|
244
263
|
s.styles = [
|
|
245
|
-
|
|
264
|
+
v`
|
|
246
265
|
:host {
|
|
247
266
|
--scb-textfield-number-max-width: 280px;
|
|
248
267
|
--scb-textfield-text-max-width: 400px;
|
|
@@ -258,6 +277,8 @@ s.styles = [
|
|
|
258
277
|
/* Vertikalt avstånd styrs av spacing-attributen via CSS-variabler */
|
|
259
278
|
margin-block-start: var(--scb-textfield-spacing-block-start, 0);
|
|
260
279
|
margin-block-end: var(--scb-textfield-spacing-block-end, 0);
|
|
280
|
+
|
|
281
|
+
-webkit-tap-highlight-color: transparent;
|
|
261
282
|
}
|
|
262
283
|
|
|
263
284
|
:host([type='number']) {
|
|
@@ -337,6 +358,8 @@ s.styles = [
|
|
|
337
358
|
box-sizing: border-box;
|
|
338
359
|
background-color: transparent;
|
|
339
360
|
color: var(--md-sys-color-on-surface);
|
|
361
|
+
position: relative;
|
|
362
|
+
z-index: 1;
|
|
340
363
|
}
|
|
341
364
|
|
|
342
365
|
:host([type='search']) .scb-textfield {
|
|
@@ -354,6 +377,7 @@ s.styles = [
|
|
|
354
377
|
transform: translateY(-50%);
|
|
355
378
|
pointer-events: none;
|
|
356
379
|
font-size: var(--scale-06);
|
|
380
|
+
z-index: 2;
|
|
357
381
|
}
|
|
358
382
|
|
|
359
383
|
.scb-textfield:focus-visible {
|
|
@@ -368,6 +392,35 @@ s.styles = [
|
|
|
368
392
|
width: 100%;
|
|
369
393
|
}
|
|
370
394
|
|
|
395
|
+
/* Wrapper som bär ripple och md-focus-ring */
|
|
396
|
+
.ripple-wrapper {
|
|
397
|
+
position: relative;
|
|
398
|
+
width: 100%;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
md-focus-ring.input-ring {
|
|
402
|
+
position: absolute;
|
|
403
|
+
inset: 0;
|
|
404
|
+
pointer-events: none;
|
|
405
|
+
display: none;
|
|
406
|
+
border-radius: var(--md-sys-shape-corner-small);
|
|
407
|
+
z-index: 3;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
.ripple-wrapper[data-kb-focus='true'] md-focus-ring.input-ring {
|
|
411
|
+
display: block;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
md-ripple {
|
|
415
|
+
border-radius: var(--md-sys-shape-corner-small);
|
|
416
|
+
position: absolute;
|
|
417
|
+
inset: 0;
|
|
418
|
+
z-index: 0;
|
|
419
|
+
pointer-events: none;
|
|
420
|
+
--md-ripple-hover-color: transparent;
|
|
421
|
+
--md-ripple-hover-opacity: 0;
|
|
422
|
+
}
|
|
423
|
+
|
|
371
424
|
input[type='search']::-webkit-search-cancel-button {
|
|
372
425
|
appearance: none;
|
|
373
426
|
display: none;
|
|
@@ -381,6 +434,7 @@ s.styles = [
|
|
|
381
434
|
pointer-events: none;
|
|
382
435
|
font-size: var(--scale-06);
|
|
383
436
|
color: var(--md-sys-color-error);
|
|
437
|
+
z-index: 2;
|
|
384
438
|
}
|
|
385
439
|
|
|
386
440
|
.scb-textfield.has-error-icon {
|
|
@@ -406,6 +460,7 @@ s.styles = [
|
|
|
406
460
|
justify-content: center;
|
|
407
461
|
cursor: pointer;
|
|
408
462
|
color: var(--md-sys-color-on-surface);
|
|
463
|
+
z-index: 2;
|
|
409
464
|
}
|
|
410
465
|
|
|
411
466
|
:host([error]) .scb-textfield-clear {
|
|
@@ -473,7 +528,7 @@ r([
|
|
|
473
528
|
a({ type: Boolean })
|
|
474
529
|
], s.prototype, "_showDatepicker", 2);
|
|
475
530
|
s = r([
|
|
476
|
-
|
|
531
|
+
y("scb-textfield")
|
|
477
532
|
], s);
|
|
478
533
|
export {
|
|
479
534
|
s as ScbTextField
|