scb-wc-test 0.1.94 → 0.1.95
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 +6 -7
- package/mvc/components/scb-accordion/scb-accordion.js +2 -2
- package/mvc/components/scb-button/scb-button.js +2 -2
- package/mvc/components/scb-chip/scb-chip.js +1 -1
- package/mvc/components/scb-dialog/scb-dialog.js +14 -15
- package/mvc/components/scb-list/scb-list-item.js +2 -2
- package/mvc/components/scb-list/scb-list.js +1 -1
- package/mvc/components/scb-radio-button/scb-radio-button.js +3 -3
- package/mvc/components/scb-switch/scb-switch.js +5 -6
- package/mvc/components/scb-tabs/scb-primary-tab.js +1 -2
- package/mvc/components/scb-tabs/scb-secondary-tab.js +2 -3
- package/mvc/components/scb-tabs/scb-tabs.js +1 -1
- package/mvc/components/scb-textfield/scb-textfield.js +6 -7
- package/mvc/vendor/vendor-material.js +147 -147
- package/mvc/vendor/vendor.js +1 -1
- package/package.json +2 -2
- package/scb-accordion/scb-accordion-item.d.ts +1 -3
- package/scb-accordion/scb-accordion-item.js +49 -49
- package/scb-dialog/scb-dialog.d.ts +0 -3
- package/scb-dialog/scb-dialog.js +74 -94
- package/scb-radio-button/scb-radio-button.js +3 -3
- package/scb-switch/scb-switch.d.ts +1 -2
- package/scb-switch/scb-switch.js +39 -42
- package/scb-tabs/scb-primary-tab.d.ts +0 -1
- package/scb-tabs/scb-primary-tab.js +24 -28
- package/scb-tabs/scb-secondary-tab.d.ts +0 -1
- package/scb-tabs/scb-secondary-tab.js +31 -35
- package/scb-textfield/scb-textfield.d.ts +0 -6
- package/scb-textfield/scb-textfield.js +34 -39
- package/scb-wc-test.bundle.js +684 -684
package/scb-switch/scb-switch.js
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
import { LitElement as b, nothing as h, html as p
|
|
2
|
-
import { property as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
let a = class extends b {
|
|
1
|
+
import { css as d, LitElement as b, nothing as h, html as p } from "lit";
|
|
2
|
+
import { property as r, customElement as f } from "lit/decorators.js";
|
|
3
|
+
import "@material/web/switch/switch.js";
|
|
4
|
+
var u = Object.defineProperty, m = Object.getOwnPropertyDescriptor, l = (e, t, a, n) => {
|
|
5
|
+
for (var i = n > 1 ? void 0 : n ? m(t, a) : t, o = e.length - 1, c; o >= 0; o--)
|
|
6
|
+
(c = e[o]) && (i = (n ? c(t, a, i) : c(i)) || i);
|
|
7
|
+
return n && i && u(t, a, i), i;
|
|
8
|
+
};
|
|
9
|
+
let s = class extends b {
|
|
11
10
|
constructor() {
|
|
12
|
-
super(...arguments), this.label = "", this.ariaLabel = "", this.icons = !1, this.selected = !1, this.disabled = !1, this.fullWidth = !1
|
|
11
|
+
super(...arguments), this.label = "", this.ariaLabel = "", this.icons = !1, this.selected = !1, this.disabled = !1, this.fullWidth = !1;
|
|
13
12
|
}
|
|
14
13
|
updated() {
|
|
15
14
|
this.toggleAttribute("aria-disabled", this.disabled);
|
|
16
15
|
}
|
|
17
|
-
|
|
16
|
+
firstUpdated() {
|
|
18
17
|
var t;
|
|
19
|
-
m(this, o) || (await import("@material/web/switch/switch.js"), x(this, o, !0));
|
|
20
18
|
const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector("md-switch");
|
|
21
|
-
e == null || e.addEventListener("change", (
|
|
22
|
-
this.selected =
|
|
19
|
+
e == null || e.addEventListener("change", (a) => {
|
|
20
|
+
this.selected = a.target.selected, this.dispatchEvent(new CustomEvent("change", {
|
|
23
21
|
detail: { selected: this.selected },
|
|
24
22
|
bubbles: !0,
|
|
25
23
|
composed: !0
|
|
@@ -27,7 +25,7 @@ let a = class extends b {
|
|
|
27
25
|
});
|
|
28
26
|
}
|
|
29
27
|
render() {
|
|
30
|
-
const e = this.label.trim().length > 0, t = e ? h : this.ariaLabel || h,
|
|
28
|
+
const e = this.label.trim().length > 0, t = e ? h : this.ariaLabel || h, a = p`
|
|
31
29
|
<md-switch
|
|
32
30
|
?icons=${this.icons}
|
|
33
31
|
?selected=${this.selected}
|
|
@@ -38,13 +36,12 @@ let a = class extends b {
|
|
|
38
36
|
return e ? p`
|
|
39
37
|
<label class="switch-container" ?disabled=${this.disabled}>
|
|
40
38
|
<span class="switch-label">${this.label}</span>
|
|
41
|
-
${
|
|
39
|
+
${a}
|
|
42
40
|
</label>
|
|
43
|
-
` :
|
|
41
|
+
` : a;
|
|
44
42
|
}
|
|
45
43
|
};
|
|
46
|
-
|
|
47
|
-
a.styles = y`
|
|
44
|
+
s.styles = d`
|
|
48
45
|
:host {
|
|
49
46
|
display: block;
|
|
50
47
|
}
|
|
@@ -85,27 +82,27 @@ a.styles = y`
|
|
|
85
82
|
color: var(--scb-switch-label-color, inherit);
|
|
86
83
|
}
|
|
87
84
|
`;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
],
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
],
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
],
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
],
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
],
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
],
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
],
|
|
85
|
+
l([
|
|
86
|
+
r({ type: String })
|
|
87
|
+
], s.prototype, "label", 2);
|
|
88
|
+
l([
|
|
89
|
+
r({ type: String, reflect: !0, attribute: "aria-label" })
|
|
90
|
+
], s.prototype, "ariaLabel", 2);
|
|
91
|
+
l([
|
|
92
|
+
r({ type: Boolean, reflect: !0 })
|
|
93
|
+
], s.prototype, "icons", 2);
|
|
94
|
+
l([
|
|
95
|
+
r({ type: Boolean, reflect: !0 })
|
|
96
|
+
], s.prototype, "selected", 2);
|
|
97
|
+
l([
|
|
98
|
+
r({ type: Boolean, reflect: !0 })
|
|
99
|
+
], s.prototype, "disabled", 2);
|
|
100
|
+
l([
|
|
101
|
+
r({ type: Boolean, reflect: !0, attribute: "full-width" })
|
|
102
|
+
], s.prototype, "fullWidth", 2);
|
|
103
|
+
s = l([
|
|
104
|
+
f("scb-switch")
|
|
105
|
+
], s);
|
|
109
106
|
export {
|
|
110
|
-
|
|
107
|
+
s as ScbSwitch
|
|
111
108
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { MdPrimaryTab as
|
|
2
|
-
import { property as
|
|
3
|
-
import { css as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { MdPrimaryTab as p } from "@material/web/tabs/primary-tab.js";
|
|
2
|
+
import { property as a, customElement as u } from "lit/decorators.js";
|
|
3
|
+
import { css as h } from "lit";
|
|
4
|
+
import "@material/web/icon/icon.js";
|
|
5
|
+
var d = Object.defineProperty, b = Object.getOwnPropertyDescriptor, s = (t, e, r, n) => {
|
|
6
|
+
for (var i = n > 1 ? void 0 : n ? b(e, r) : e, c = t.length - 1, l; c >= 0; c--)
|
|
7
|
+
(l = t[c]) && (i = (n ? l(e, r, i) : l(i)) || i);
|
|
8
|
+
return n && i && d(e, r, i), i;
|
|
8
9
|
};
|
|
9
|
-
let
|
|
10
|
+
let o = class extends p {
|
|
10
11
|
constructor() {
|
|
11
12
|
super(...arguments), this.iconOnly = !1, this.inlineIcon = !1, this._onActivate = () => {
|
|
12
13
|
var e;
|
|
@@ -48,18 +49,13 @@ let i = class extends d {
|
|
|
48
49
|
e && this.setAttribute("aria-label", e);
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
-
async ensureMdIconLoaded() {
|
|
53
|
-
const t = globalThis;
|
|
54
|
-
t.__mdIconLoaded || (await import("@material/web/icon/icon.js"), t.__mdIconLoaded = !0);
|
|
55
|
-
}
|
|
56
|
-
async updateIconSlot() {
|
|
52
|
+
updateIconSlot() {
|
|
57
53
|
const t = this.querySelector('md-icon[slot="icon"]');
|
|
58
54
|
if (!this._icon) {
|
|
59
55
|
t == null || t.remove();
|
|
60
56
|
return;
|
|
61
57
|
}
|
|
62
|
-
if (
|
|
58
|
+
if (t)
|
|
63
59
|
t.textContent = this._icon;
|
|
64
60
|
else {
|
|
65
61
|
const e = document.createElement("md-icon");
|
|
@@ -67,9 +63,9 @@ let i = class extends d {
|
|
|
67
63
|
}
|
|
68
64
|
}
|
|
69
65
|
};
|
|
70
|
-
|
|
71
|
-
...
|
|
72
|
-
|
|
66
|
+
o.styles = [
|
|
67
|
+
...p.styles,
|
|
68
|
+
h`
|
|
73
69
|
/* Icon-only: dölj textslot */
|
|
74
70
|
:host([icon-only]) slot:not([name='icon']) {
|
|
75
71
|
display: none;
|
|
@@ -77,17 +73,17 @@ i.styles = [
|
|
|
77
73
|
`
|
|
78
74
|
];
|
|
79
75
|
s([
|
|
80
|
-
|
|
81
|
-
],
|
|
76
|
+
a({ type: String })
|
|
77
|
+
], o.prototype, "icon", 1);
|
|
82
78
|
s([
|
|
83
|
-
|
|
84
|
-
],
|
|
79
|
+
a({ type: Boolean, reflect: !0, attribute: "icon-only" })
|
|
80
|
+
], o.prototype, "iconOnly", 2);
|
|
85
81
|
s([
|
|
86
|
-
|
|
87
|
-
],
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
],
|
|
82
|
+
a({ type: Boolean, reflect: !0, attribute: "inline-icon" })
|
|
83
|
+
], o.prototype, "inlineIcon", 2);
|
|
84
|
+
o = s([
|
|
85
|
+
u("scb-primary-tab")
|
|
86
|
+
], o);
|
|
91
87
|
export {
|
|
92
|
-
|
|
88
|
+
o as ScbPrimaryTab
|
|
93
89
|
};
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { MdSecondaryTab as l } from "@material/web/tabs/secondary-tab.js";
|
|
2
|
-
import { property as
|
|
3
|
-
import { css as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { property as p, customElement as h } from "lit/decorators.js";
|
|
3
|
+
import { css as u } from "lit";
|
|
4
|
+
import "@material/web/icon/icon.js";
|
|
5
|
+
var d = Object.defineProperty, b = Object.getOwnPropertyDescriptor, a = (e, t, i, s) => {
|
|
6
|
+
for (var o = s > 1 ? void 0 : s ? b(t, i) : t, r = e.length - 1, c; r >= 0; r--)
|
|
7
|
+
(c = e[r]) && (o = (s ? c(t, i, o) : c(o)) || o);
|
|
8
|
+
return s && o && d(t, i, o), o;
|
|
8
9
|
};
|
|
9
10
|
let n = class extends l {
|
|
10
11
|
constructor() {
|
|
11
12
|
super(...arguments), this.iconOnly = !1, this._onActivate = () => {
|
|
12
|
-
var
|
|
13
|
-
const
|
|
13
|
+
var t;
|
|
14
|
+
const e = ((t = this.textContent) == null ? void 0 : t.trim()) ?? "";
|
|
14
15
|
this.dispatchEvent(
|
|
15
16
|
new CustomEvent("activate", {
|
|
16
|
-
detail: { label:
|
|
17
|
+
detail: { label: e },
|
|
17
18
|
bubbles: !0,
|
|
18
19
|
composed: !0
|
|
19
20
|
})
|
|
@@ -27,19 +28,19 @@ let n = class extends l {
|
|
|
27
28
|
get icon() {
|
|
28
29
|
return this._icon;
|
|
29
30
|
}
|
|
30
|
-
set icon(
|
|
31
|
-
const
|
|
32
|
-
|
|
31
|
+
set icon(e) {
|
|
32
|
+
const t = this._icon;
|
|
33
|
+
t !== e && (this._icon = e, this.requestUpdate("icon", t), this.updateIconSlot());
|
|
33
34
|
}
|
|
34
35
|
/*
|
|
35
|
-
Efter första
|
|
36
|
+
Efter första uppdatering:
|
|
36
37
|
- Sätt fallback aria-label om iconOnly används utan egen label.
|
|
37
38
|
- Fånga click och dispatcha ett 'activate'-event med detail.label.
|
|
38
39
|
*/
|
|
39
|
-
firstUpdated(
|
|
40
|
-
var
|
|
41
|
-
if (super.firstUpdated(
|
|
42
|
-
const i = ((
|
|
40
|
+
firstUpdated(e) {
|
|
41
|
+
var t;
|
|
42
|
+
if (super.firstUpdated(e), this.iconOnly && !this.hasAttribute("aria-label")) {
|
|
43
|
+
const i = ((t = this.textContent) == null ? void 0 : t.trim()) ?? "";
|
|
43
44
|
i && this.setAttribute("aria-label", i);
|
|
44
45
|
}
|
|
45
46
|
this.addEventListener("click", this._onActivate), this._icon && this.updateIconSlot();
|
|
@@ -49,34 +50,29 @@ let n = class extends l {
|
|
|
49
50
|
- Hanterar fallback aria-label för icon-only.
|
|
50
51
|
*/
|
|
51
52
|
updated() {
|
|
52
|
-
var
|
|
53
|
+
var e;
|
|
53
54
|
if (super.updated(), this.iconOnly && !this.hasAttribute("aria-label")) {
|
|
54
|
-
const
|
|
55
|
-
|
|
55
|
+
const t = ((e = this.textContent) == null ? void 0 : e.trim()) ?? "";
|
|
56
|
+
t && this.setAttribute("aria-label", t);
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const t = globalThis;
|
|
61
|
-
t.__mdIconLoaded || (await import("@material/web/icon/icon.js"), t.__mdIconLoaded = !0);
|
|
62
|
-
}
|
|
63
|
-
async updateIconSlot() {
|
|
64
|
-
const t = this.querySelector('md-icon[slot="icon"]');
|
|
59
|
+
updateIconSlot() {
|
|
60
|
+
const e = this.querySelector('md-icon[slot="icon"]');
|
|
65
61
|
if (!this._icon) {
|
|
66
|
-
|
|
62
|
+
e == null || e.remove();
|
|
67
63
|
return;
|
|
68
64
|
}
|
|
69
|
-
if (
|
|
70
|
-
|
|
65
|
+
if (e)
|
|
66
|
+
e.textContent = this._icon;
|
|
71
67
|
else {
|
|
72
|
-
const
|
|
73
|
-
|
|
68
|
+
const t = document.createElement("md-icon");
|
|
69
|
+
t.setAttribute("slot", "icon"), t.textContent = this._icon, this.appendChild(t);
|
|
74
70
|
}
|
|
75
71
|
}
|
|
76
72
|
};
|
|
77
73
|
n.styles = [
|
|
78
74
|
...l.styles,
|
|
79
|
-
|
|
75
|
+
u`
|
|
80
76
|
/* Icon-only: göm all text utom slot="icon" */
|
|
81
77
|
:host([icon-only]) slot:not([name='icon']) {
|
|
82
78
|
display: none;
|
|
@@ -84,10 +80,10 @@ n.styles = [
|
|
|
84
80
|
`
|
|
85
81
|
];
|
|
86
82
|
a([
|
|
87
|
-
|
|
83
|
+
p({ type: String })
|
|
88
84
|
], n.prototype, "icon", 1);
|
|
89
85
|
a([
|
|
90
|
-
|
|
86
|
+
p({ type: Boolean, reflect: !0, attribute: "icon-only" })
|
|
91
87
|
], n.prototype, "iconOnly", 2);
|
|
92
88
|
n = a([
|
|
93
89
|
h("scb-secondary-tab")
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { LitElement, TemplateResult, PropertyValues } from 'lit';
|
|
2
|
-
declare global {
|
|
3
|
-
interface Window {
|
|
4
|
-
__scb_md_icon_loaded?: boolean;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
2
|
export declare class ScbTextField extends LitElement {
|
|
8
3
|
type: 'number' | 'email' | 'password' | 'search' | 'tel' | 'text' | 'url' | 'textarea' | 'color' | 'date' | 'datetime-local' | 'file' | 'month' | 'time' | 'week';
|
|
9
4
|
label: string;
|
|
@@ -36,7 +31,6 @@ export declare class ScbTextField extends LitElement {
|
|
|
36
31
|
* Kallar på reportValidity på den inbyggda input/textarea och sätter felstatus till error-text.
|
|
37
32
|
*/
|
|
38
33
|
reportValidity(): boolean;
|
|
39
|
-
private __ensureMdIconLoaded;
|
|
40
34
|
}
|
|
41
35
|
declare global {
|
|
42
36
|
interface HTMLElementTagNameMap {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { css as h, LitElement as p, html as d } from "lit";
|
|
2
2
|
import { property as a, customElement as u } from "lit/decorators.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import "@material/web/icon/icon.js";
|
|
4
|
+
var b = Object.defineProperty, m = Object.getOwnPropertyDescriptor, s = (t, e, r, l) => {
|
|
5
|
+
for (var o = l > 1 ? void 0 : l ? m(e, r) : e, n = t.length - 1, c; n >= 0; n--)
|
|
6
|
+
(c = t[n]) && (o = (l ? c(e, r, o) : c(o)) || o);
|
|
7
|
+
return l && o && b(e, r, o), o;
|
|
7
8
|
};
|
|
8
|
-
let i = class extends
|
|
9
|
+
let i = class extends p {
|
|
9
10
|
constructor() {
|
|
10
11
|
super(...arguments), 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._form = null, this._formSubmitHandler = null, this._formResetHandler = null, this._initialValue = "", this._inputId = "";
|
|
11
12
|
}
|
|
12
13
|
render() {
|
|
13
|
-
const
|
|
14
|
+
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;
|
|
14
15
|
this.underLabel = this.error ? this.errorText || "Ogiltig inmatning." : this.supportingText, this.value = this.value || "";
|
|
15
16
|
const r = this.underLabel ? `${this._inputId}-supporting-text` : void 0;
|
|
16
17
|
return this.type === "textarea" ? d`
|
|
@@ -34,10 +35,10 @@ let i = class extends h {
|
|
|
34
35
|
<label class="scb-textfield-label" for="${this._inputId}">${this.label}</label>
|
|
35
36
|
<span
|
|
36
37
|
class="scb-textfield-supporting-text"
|
|
37
|
-
id="${this.underLabel ? `${this._inputId}-supporting-text` : ""}
|
|
38
|
-
>${this.underLabel}</span>
|
|
38
|
+
id="${this.underLabel ? `${this._inputId}-supporting-text` : ""}
|
|
39
|
+
">${this.underLabel}</span>
|
|
39
40
|
<div class="scb-textfield-wrapper">
|
|
40
|
-
${
|
|
41
|
+
${t}
|
|
41
42
|
<input
|
|
42
43
|
class="scb-textfield${this.error ? " has-error-icon" : ""}"
|
|
43
44
|
.value=${this.value}
|
|
@@ -49,7 +50,7 @@ let i = class extends h {
|
|
|
49
50
|
aria-invalid=${this.error ? "true" : "false"}
|
|
50
51
|
aria-describedby=${r}
|
|
51
52
|
/>
|
|
52
|
-
${
|
|
53
|
+
${e}
|
|
53
54
|
</div>
|
|
54
55
|
`;
|
|
55
56
|
}
|
|
@@ -57,12 +58,12 @@ let i = class extends h {
|
|
|
57
58
|
Vi re-dispatchar inbyggda "input", "change" och "select" events med { bubbles: true, composed: true },
|
|
58
59
|
så att konsumenter kan lyssna på events direkt från scb-text-field. Vi kör också ett customevent onValueChanged.
|
|
59
60
|
*/
|
|
60
|
-
firstUpdated(
|
|
61
|
+
firstUpdated(t) {
|
|
61
62
|
var r;
|
|
62
|
-
super.firstUpdated(
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
const o =
|
|
63
|
+
super.firstUpdated(t), this._initialValue = this.value;
|
|
64
|
+
const e = (r = this.shadowRoot) == null ? void 0 : r.querySelector(".scb-textfield");
|
|
65
|
+
e && (e.addEventListener("input", (l) => {
|
|
66
|
+
const o = e;
|
|
66
67
|
if (this.value = o.value, this.pattern) {
|
|
67
68
|
const n = new RegExp(this.pattern);
|
|
68
69
|
this.error = !n.test(this.value);
|
|
@@ -72,25 +73,25 @@ let i = class extends h {
|
|
|
72
73
|
bubbles: !0,
|
|
73
74
|
composed: !0
|
|
74
75
|
}));
|
|
75
|
-
}),
|
|
76
|
+
}), e.addEventListener("change", (l) => {
|
|
76
77
|
this.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 }));
|
|
77
|
-
}),
|
|
78
|
+
}), e.addEventListener("select", (l) => {
|
|
78
79
|
this.dispatchEvent(new Event("select", { bubbles: !0, composed: !0 }));
|
|
79
80
|
}));
|
|
80
81
|
}
|
|
81
82
|
/* Reagera på ändringar som kan kräva att md-icon laddas in (leadingIcon / error) */
|
|
82
|
-
updated(
|
|
83
|
-
super.updated(
|
|
83
|
+
updated(t) {
|
|
84
|
+
super.updated(t), this.toggleAttribute("aria-disabled", this.disabled);
|
|
84
85
|
}
|
|
85
86
|
// Om scb-textfield är inuti ett formulär
|
|
86
87
|
connectedCallback() {
|
|
87
|
-
super.connectedCallback(), this._inputId = this.id || `scb-textfield-${Math.random().toString(36).substr(2, 9)}`, this._formSubmitHandler = (
|
|
88
|
-
this.reportValidity() || (
|
|
88
|
+
super.connectedCallback(), this._inputId = this.id || `scb-textfield-${Math.random().toString(36).substr(2, 9)}`, this._formSubmitHandler = (t) => {
|
|
89
|
+
this.reportValidity() || (t.preventDefault(), t.stopPropagation());
|
|
89
90
|
}, this._form = this.closest("form"), this._form && (this._form.addEventListener("submit", this._formSubmitHandler, !0), this._formResetHandler = () => {
|
|
90
|
-
var
|
|
91
|
+
var e;
|
|
91
92
|
this.value = this._initialValue;
|
|
92
|
-
const
|
|
93
|
-
|
|
93
|
+
const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector(".scb-textfield");
|
|
94
|
+
t && (t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement) && (t.value = this._initialValue), this.error = !1;
|
|
94
95
|
}, this._form.addEventListener("reset", this._formResetHandler, !0));
|
|
95
96
|
}
|
|
96
97
|
disconnectedCallback() {
|
|
@@ -100,24 +101,18 @@ let i = class extends h {
|
|
|
100
101
|
* Kallar på reportValidity på den inbyggda input/textarea och sätter felstatus till error-text.
|
|
101
102
|
*/
|
|
102
103
|
reportValidity() {
|
|
103
|
-
var
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
this.required && !
|
|
107
|
-
const r =
|
|
108
|
-
return this.error = !r, r || (this.errorText = this.errorText ||
|
|
104
|
+
var e;
|
|
105
|
+
const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector(".scb-textfield");
|
|
106
|
+
if (t && (t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement)) {
|
|
107
|
+
this.required && !t.value ? t.setCustomValidity(this.errorText || "Ogiltig inmatning.") : t.setCustomValidity("");
|
|
108
|
+
const r = t.reportValidity();
|
|
109
|
+
return this.error = !r, r || (this.errorText = this.errorText || t.validationMessage || "Ogiltig inmatning."), r;
|
|
109
110
|
}
|
|
110
111
|
return !0;
|
|
111
112
|
}
|
|
112
|
-
/*
|
|
113
|
-
Lazy-loader för md-icon
|
|
114
|
-
*/
|
|
115
|
-
async __ensureMdIconLoaded() {
|
|
116
|
-
window.__scb_md_icon_loaded || (await import("@material/web/icon/icon.js"), window.__scb_md_icon_loaded = !0);
|
|
117
|
-
}
|
|
118
113
|
};
|
|
119
114
|
i.styles = [
|
|
120
|
-
|
|
115
|
+
h`
|
|
121
116
|
:host{
|
|
122
117
|
--scb-textfield-number-max-width:280px;
|
|
123
118
|
--scb-textfield-text-max-width:400px;
|
|
@@ -200,7 +195,7 @@ i.styles = [
|
|
|
200
195
|
box-sizing: border-box;
|
|
201
196
|
}
|
|
202
197
|
md-icon + .scb-textfield {
|
|
203
|
-
padding-left: var(--spacing-10); /* Extra padding
|
|
198
|
+
padding-left: var(--spacing-10); /* Extra padding för search icon */
|
|
204
199
|
}
|
|
205
200
|
.scb-textfield-icon {
|
|
206
201
|
position: absolute;
|