nve-designsystem 0.4.12 → 0.4.13
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.
|
@@ -13,16 +13,18 @@ export default class NveSelect extends SlSelect {
|
|
|
13
13
|
*/
|
|
14
14
|
requiredLabel: string;
|
|
15
15
|
/**
|
|
16
|
-
* Brukes til enkel constraint validation til å overskrive default
|
|
16
|
+
* Brukes til enkel constraint validation til å overskrive default nettleser-melding
|
|
17
17
|
*/
|
|
18
18
|
errorMessage?: string;
|
|
19
|
-
connectedCallback(): void;
|
|
20
|
-
disconnectedCallback(): void;
|
|
21
19
|
constructor();
|
|
22
20
|
static styles: import('lit').CSSResultGroup[];
|
|
21
|
+
private slInvalidEventListener;
|
|
22
|
+
connectedCallback(): void;
|
|
23
|
+
disconnectedCallback(): void;
|
|
23
24
|
protected firstUpdated(changedProperties: PropertyValues): void;
|
|
24
25
|
updated(changedProperties: PropertyValues): void;
|
|
25
26
|
focus(): void;
|
|
27
|
+
private valueHasChanged;
|
|
26
28
|
private handleOptionClick;
|
|
27
29
|
private handleDefaultSlotChange;
|
|
28
30
|
private getAllOptions;
|
|
@@ -6,73 +6,76 @@ import "../../chunks/chunk.G6R7BW5E.js";
|
|
|
6
6
|
import "../../chunks/chunk.6CTB5ZDJ.js";
|
|
7
7
|
import "../../chunks/chunk.QCFOL4VF.js";
|
|
8
8
|
import "../../chunks/chunk.EVP45OG4.js";
|
|
9
|
-
import { n as u, t as
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
import { n as u, t as h } from "../../chunks/property.js";
|
|
10
|
+
import { r as d } from "../../chunks/state.js";
|
|
11
|
+
import c from "./nve-select.styles.js";
|
|
12
|
+
var v = Object.defineProperty, f = Object.getOwnPropertyDescriptor, o = (t, e, s, i) => {
|
|
13
|
+
for (var r = i > 1 ? void 0 : i ? f(e, s) : e, n = t.length - 1, a; n >= 0; n--)
|
|
14
|
+
(a = t[n]) && (r = (i ? a(e, s, r) : a(r)) || r);
|
|
15
|
+
return i && r && v(e, s, r), r;
|
|
15
16
|
};
|
|
16
17
|
let l = class extends p {
|
|
17
18
|
constructor() {
|
|
18
|
-
super(), this.requiredLabel = "*Obligatorisk"
|
|
19
|
+
super(), this.requiredLabel = "*Obligatorisk", this.slInvalidEventListener = (t) => {
|
|
20
|
+
t.preventDefault();
|
|
21
|
+
}, this.valueHasChanged = !1;
|
|
19
22
|
}
|
|
20
23
|
connectedCallback() {
|
|
21
|
-
super.connectedCallback(), this.addEventListener("sl-invalid",
|
|
22
|
-
e.preventDefault();
|
|
23
|
-
});
|
|
24
|
+
super.connectedCallback(), this.addEventListener("sl-invalid", this.slInvalidEventListener);
|
|
24
25
|
}
|
|
25
26
|
disconnectedCallback() {
|
|
26
|
-
super.disconnectedCallback(), this.removeEventListener("sl-invalid",
|
|
27
|
-
e.preventDefault();
|
|
28
|
-
});
|
|
27
|
+
super.disconnectedCallback(), this.removeEventListener("sl-invalid", this.slInvalidEventListener);
|
|
29
28
|
}
|
|
30
|
-
firstUpdated(
|
|
29
|
+
firstUpdated(t) {
|
|
31
30
|
var s;
|
|
32
|
-
super.firstUpdated(
|
|
33
|
-
const
|
|
34
|
-
|
|
31
|
+
super.firstUpdated(t), this.requiredLabel && this.style.setProperty("--sl-input-required-content", `"${this.requiredLabel}"`);
|
|
32
|
+
const e = (s = this.shadowRoot) == null ? void 0 : s.querySelector("sl-popup");
|
|
33
|
+
e == null || e.setAttribute("distance", "3");
|
|
35
34
|
}
|
|
36
|
-
updated(
|
|
37
|
-
super.updated(
|
|
38
|
-
const
|
|
39
|
-
|
|
35
|
+
updated(t) {
|
|
36
|
+
super.updated(t);
|
|
37
|
+
const e = this.hasAttribute("data-user-invalid");
|
|
38
|
+
e && (this.errorMessage || (this.errorMessage = this.validationMessage), this.style.setProperty("--nve-input-error-message", `"${this.errorMessage}"`)), e || this.style.setProperty("--nve-input-error-message", "");
|
|
40
39
|
}
|
|
41
40
|
focus() {
|
|
42
|
-
var
|
|
43
|
-
const
|
|
44
|
-
|
|
41
|
+
var e;
|
|
42
|
+
const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector("sl-popup");
|
|
43
|
+
t == null || t.classList.add("select--focused");
|
|
45
44
|
}
|
|
46
|
-
// @ts-
|
|
47
|
-
handleOptionClick(
|
|
48
|
-
const s =
|
|
49
|
-
s && !s.disabled && (this.multiple ? this.toggleOptionSelection(s) : this.setSelectedOptions(s), this.updateComplete.then(() => this.displayInput.focus({ preventScroll: !0 })), this.value !== i && this.updateComplete.then(() => {
|
|
45
|
+
// @ts-expect-error overskriver private method
|
|
46
|
+
handleOptionClick(t) {
|
|
47
|
+
const s = t.target.closest("nve-option"), i = this.value;
|
|
48
|
+
s && !s.disabled && (this.multiple ? this.toggleOptionSelection(s) : this.setSelectedOptions(s), this.updateComplete.then(() => this.displayInput.focus({ preventScroll: !0 })), this.value !== i && (this.valueHasChanged = !0, this.updateComplete.then(() => {
|
|
50
49
|
this.emit("sl-input"), this.emit("sl-change");
|
|
51
|
-
}), this.multiple || (this.hide(), this.displayInput.focus({ preventScroll: !0 })));
|
|
50
|
+
})), this.multiple || (this.hide(), this.displayInput.focus({ preventScroll: !0 })));
|
|
52
51
|
}
|
|
53
52
|
//Lagt til nve-option
|
|
54
53
|
handleDefaultSlotChange() {
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
customElements.get("nve-option") || customElements.whenDefined("nve-option").then(() => this.handleDefaultSlotChange());
|
|
55
|
+
const t = this.getAllOptions(), e = this.valueHasChanged ? this.value : this.defaultValue, s = Array.isArray(e) ? e : [e];
|
|
56
|
+
this.setSelectedOptions(t.filter((i) => s.includes(i.value)));
|
|
57
57
|
}
|
|
58
58
|
//Lagt til nve-option
|
|
59
59
|
getAllOptions() {
|
|
60
60
|
return [...this.querySelectorAll("nve-option")];
|
|
61
61
|
}
|
|
62
|
-
// @ts-
|
|
62
|
+
// @ts-expect-error overskriver private method
|
|
63
63
|
getFirstOption() {
|
|
64
64
|
return this.querySelector("nve-option");
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
l.styles = [p.styles,
|
|
68
|
-
|
|
67
|
+
l.styles = [p.styles, c];
|
|
68
|
+
o([
|
|
69
69
|
u()
|
|
70
70
|
], l.prototype, "requiredLabel", 2);
|
|
71
|
-
|
|
71
|
+
o([
|
|
72
72
|
u({ reflect: !0 })
|
|
73
73
|
], l.prototype, "errorMessage", 2);
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
o([
|
|
75
|
+
d()
|
|
76
|
+
], l.prototype, "valueHasChanged", 2);
|
|
77
|
+
l = o([
|
|
78
|
+
h("nve-select")
|
|
76
79
|
], l);
|
|
77
80
|
export {
|
|
78
81
|
l as default
|
package/custom-elements.json
CHANGED
|
@@ -8208,7 +8208,7 @@
|
|
|
8208
8208
|
"type": {
|
|
8209
8209
|
"text": "string | undefined"
|
|
8210
8210
|
},
|
|
8211
|
-
"description": "Brukes til enkel constraint validation til å overskrive default
|
|
8211
|
+
"description": "Brukes til enkel constraint validation til å overskrive default nettleser-melding"
|
|
8212
8212
|
},
|
|
8213
8213
|
{
|
|
8214
8214
|
"kind": "field",
|
|
@@ -8219,6 +8219,11 @@
|
|
|
8219
8219
|
"static": true,
|
|
8220
8220
|
"default": "[SlSelect.styles, styles]"
|
|
8221
8221
|
},
|
|
8222
|
+
{
|
|
8223
|
+
"kind": "field",
|
|
8224
|
+
"name": "slInvalidEventListener",
|
|
8225
|
+
"privacy": "private"
|
|
8226
|
+
},
|
|
8222
8227
|
{
|
|
8223
8228
|
"kind": "method",
|
|
8224
8229
|
"name": "firstUpdated",
|
|
@@ -8248,6 +8253,15 @@
|
|
|
8248
8253
|
"kind": "method",
|
|
8249
8254
|
"name": "focus"
|
|
8250
8255
|
},
|
|
8256
|
+
{
|
|
8257
|
+
"kind": "field",
|
|
8258
|
+
"name": "valueHasChanged",
|
|
8259
|
+
"type": {
|
|
8260
|
+
"text": "boolean"
|
|
8261
|
+
},
|
|
8262
|
+
"privacy": "private",
|
|
8263
|
+
"default": "false"
|
|
8264
|
+
},
|
|
8251
8265
|
{
|
|
8252
8266
|
"kind": "method",
|
|
8253
8267
|
"name": "handleOptionClick",
|
|
@@ -11391,7 +11405,7 @@
|
|
|
11391
11405
|
"package": {
|
|
11392
11406
|
"name": "nve-designsystem",
|
|
11393
11407
|
"description": "Designsystem for NVE",
|
|
11394
|
-
"version": "0.4.
|
|
11408
|
+
"version": "0.4.12",
|
|
11395
11409
|
"author": {
|
|
11396
11410
|
"name": "NVE",
|
|
11397
11411
|
"email": "nve@nve.no"
|