nve-designsystem 0.1.80 → 0.1.82
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/chunks/watch.js +21 -0
- package/components/nve-darkmode-switch/nve-darkmode-switch.component.d.ts +28 -0
- package/components/nve-darkmode-switch/nve-darkmode-switch.component.js +53 -0
- package/components/nve-radio-group/nve-radio-group.component.js +95 -112
- package/components/nve-stepper/nve-step/nve-step.component.js +1 -1
- package/components/nve-stepper/nve-step/nve-step.styles.js +1 -1
- package/components/nve-switch/nve-switch.component.d.ts +53 -0
- package/components/nve-switch/nve-switch.component.js +129 -0
- package/components/nve-switch/nve-switch.styles.d.ts +2 -0
- package/components/nve-switch/nve-switch.styles.js +86 -0
- package/custom-elements.json +419 -72
- package/nve-designsystem.d.ts +2 -0
- package/nve-designsystem.js +42 -38
- package/package.json +1 -1
package/chunks/watch.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
function u(t, c) {
|
|
2
|
+
const l = {
|
|
3
|
+
waitUntilFirstUpdate: !1,
|
|
4
|
+
...c
|
|
5
|
+
};
|
|
6
|
+
return (a, o) => {
|
|
7
|
+
const { update: d } = a, f = Array.isArray(t) ? t : [t];
|
|
8
|
+
a.update = function(i) {
|
|
9
|
+
f.forEach((h) => {
|
|
10
|
+
const s = h;
|
|
11
|
+
if (i.has(s)) {
|
|
12
|
+
const n = i.get(s), e = this[s];
|
|
13
|
+
n !== e && (!l.waitUntilFirstUpdate || this.hasUpdated) && this[o](n, e);
|
|
14
|
+
}
|
|
15
|
+
}), d.call(this, i);
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
u as w
|
|
21
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { INveComponent } from '../../interfaces/NveComponent.interface';
|
|
2
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
3
|
+
/**
|
|
4
|
+
* Komponent for å sette .darkmode-klasse på root.
|
|
5
|
+
* Må kun være en av dem på siden, de vil ikke synkronisere data.
|
|
6
|
+
*
|
|
7
|
+
* Hvorvidt bruker foretrekker dark-mode eller ikke hentes fra browser via "prefers-color-scheme".
|
|
8
|
+
* Dersom bruker setter darkmode ved å klikke på komponenten, lagres valget i localstorage.
|
|
9
|
+
*
|
|
10
|
+
* Man kan bruke "darkmodeclass" for å sette klassen som legges til dersom den ikke er "darkmode"
|
|
11
|
+
*/
|
|
12
|
+
export default class NveDarkmodeSwitch extends LitElement implements INveComponent {
|
|
13
|
+
constructor();
|
|
14
|
+
testId: string;
|
|
15
|
+
darkmode: boolean;
|
|
16
|
+
darkmodeclass: string;
|
|
17
|
+
localStorageVariable: string;
|
|
18
|
+
private toggleDarkmode;
|
|
19
|
+
private checkFocus;
|
|
20
|
+
private checkInput;
|
|
21
|
+
connectedCallback(): void;
|
|
22
|
+
render(): TemplateResult;
|
|
23
|
+
}
|
|
24
|
+
declare global {
|
|
25
|
+
interface HTMLElementTagNameMap {
|
|
26
|
+
'nve-darkmode-switch': NveDarkmodeSwitch;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { s as n, x as m } from "../../chunks/lit-element.js";
|
|
2
|
+
import { n as i, t as h } from "../../chunks/property.js";
|
|
3
|
+
var u = Object.defineProperty, k = Object.getOwnPropertyDescriptor, a = (t, e, c, s) => {
|
|
4
|
+
for (var o = s > 1 ? void 0 : s ? k(e, c) : e, d = t.length - 1, l; d >= 0; d--)
|
|
5
|
+
(l = t[d]) && (o = (s ? l(e, c, o) : l(o)) || o);
|
|
6
|
+
return s && o && u(e, c, o), o;
|
|
7
|
+
};
|
|
8
|
+
let r = class extends n {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(), this.testId = "", this.darkmode = !1, this.darkmodeclass = "darkmode", this.localStorageVariable = "preferdarkmode";
|
|
11
|
+
}
|
|
12
|
+
toggleDarkmode(t) {
|
|
13
|
+
console.dir(1), this.darkmode = !!t.target.checked, localStorage.setItem(this.localStorageVariable, this.darkmode.toString()), this.darkmode ? document.documentElement.classList.add(this.darkmodeclass) : document.documentElement.classList.remove(this.darkmodeclass);
|
|
14
|
+
}
|
|
15
|
+
checkFocus() {
|
|
16
|
+
console.dir(2);
|
|
17
|
+
}
|
|
18
|
+
checkInput() {
|
|
19
|
+
console.dir(3);
|
|
20
|
+
}
|
|
21
|
+
connectedCallback() {
|
|
22
|
+
super.connectedCallback();
|
|
23
|
+
const t = localStorage.getItem(this.localStorageVariable);
|
|
24
|
+
let e = !1;
|
|
25
|
+
t === null ? window.matchMedia("(prefers-color-scheme: dark)").matches && (e = !0) : e = t === "true", e ? (this.darkmode = !0, document.documentElement.classList.add(this.darkmodeclass)) : (this.darkmode = !1, document.documentElement.classList.remove(this.darkmodeclass));
|
|
26
|
+
}
|
|
27
|
+
render() {
|
|
28
|
+
return m`<nve-switch
|
|
29
|
+
@change=${this.toggleDarkmode}
|
|
30
|
+
@focus=${this.checkFocus}
|
|
31
|
+
@input=${this.checkInput}
|
|
32
|
+
?checked=${this.darkmode}
|
|
33
|
+
>
|
|
34
|
+
<nve-icon slot="onicon" name="dark_mode"></nve-icon>
|
|
35
|
+
<nve-icon slot="officon" name="light_mode"></nve-icon>
|
|
36
|
+
</nve-switch>`;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
a([
|
|
40
|
+
i({ reflect: !0, type: String })
|
|
41
|
+
], r.prototype, "testId", 2);
|
|
42
|
+
a([
|
|
43
|
+
i({ attribute: !1, type: Boolean })
|
|
44
|
+
], r.prototype, "darkmode", 2);
|
|
45
|
+
a([
|
|
46
|
+
i({ attribute: !0, type: String })
|
|
47
|
+
], r.prototype, "darkmodeclass", 2);
|
|
48
|
+
r = a([
|
|
49
|
+
h("nve-darkmode-switch")
|
|
50
|
+
], r);
|
|
51
|
+
export {
|
|
52
|
+
r as default
|
|
53
|
+
};
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { n, t as
|
|
1
|
+
import { n, t as E } from "../../chunks/property.js";
|
|
2
2
|
import { r as p } from "../../chunks/state.js";
|
|
3
|
-
import { f as
|
|
4
|
-
import { c as
|
|
5
|
-
import { i as
|
|
6
|
-
import { F as
|
|
7
|
-
import { e as
|
|
8
|
-
import { H as
|
|
9
|
-
import { w as
|
|
10
|
-
import { e as
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
${
|
|
3
|
+
import { f as V } from "../../chunks/chunk.SI4ACBFK.js";
|
|
4
|
+
import { c as y, b as l, S as C } from "../../chunks/chunk.JS655M6J.js";
|
|
5
|
+
import { i as _, x as g } from "../../chunks/lit-element.js";
|
|
6
|
+
import { F as x, c as k, a as M, v as S } from "../../chunks/chunk.UEQZEZFU.js";
|
|
7
|
+
import { e as b } from "../../chunks/query.js";
|
|
8
|
+
import { H as A } from "../../chunks/chunk.NYIIDP5N.js";
|
|
9
|
+
import { w as R } from "../../chunks/chunk.Q6ASPMKT.js";
|
|
10
|
+
import { e as $ } from "../../chunks/class-map.js";
|
|
11
|
+
import q from "./nve-radio-group.styles.js";
|
|
12
|
+
import { w as I } from "../../chunks/watch.js";
|
|
13
|
+
import { t as v } from "../../chunks/updateInvalidProperty.js";
|
|
14
|
+
var L = _`
|
|
15
|
+
${y}
|
|
16
|
+
${V}
|
|
16
17
|
|
|
17
18
|
:host {
|
|
18
19
|
display: block;
|
|
@@ -45,8 +46,8 @@ var O = E`
|
|
|
45
46
|
white-space: nowrap;
|
|
46
47
|
border: 0;
|
|
47
48
|
}
|
|
48
|
-
`,
|
|
49
|
-
${
|
|
49
|
+
`, B = _`
|
|
50
|
+
${y}
|
|
50
51
|
|
|
51
52
|
:host {
|
|
52
53
|
display: inline-block;
|
|
@@ -56,31 +57,31 @@ var O = E`
|
|
|
56
57
|
display: flex;
|
|
57
58
|
flex-wrap: nowrap;
|
|
58
59
|
}
|
|
59
|
-
`,
|
|
60
|
+
`, f = class extends C {
|
|
60
61
|
constructor() {
|
|
61
62
|
super(...arguments), this.disableRole = !1, this.label = "";
|
|
62
63
|
}
|
|
63
64
|
handleFocus(t) {
|
|
64
|
-
const e =
|
|
65
|
+
const e = m(t.target);
|
|
65
66
|
e == null || e.classList.add("sl-button-group__button--focus");
|
|
66
67
|
}
|
|
67
68
|
handleBlur(t) {
|
|
68
|
-
const e =
|
|
69
|
+
const e = m(t.target);
|
|
69
70
|
e == null || e.classList.remove("sl-button-group__button--focus");
|
|
70
71
|
}
|
|
71
72
|
handleMouseOver(t) {
|
|
72
|
-
const e =
|
|
73
|
+
const e = m(t.target);
|
|
73
74
|
e == null || e.classList.add("sl-button-group__button--hover");
|
|
74
75
|
}
|
|
75
76
|
handleMouseOut(t) {
|
|
76
|
-
const e =
|
|
77
|
+
const e = m(t.target);
|
|
77
78
|
e == null || e.classList.remove("sl-button-group__button--hover");
|
|
78
79
|
}
|
|
79
80
|
handleSlotChange() {
|
|
80
81
|
const t = [...this.defaultSlot.assignedElements({ flatten: !0 })];
|
|
81
82
|
t.forEach((e) => {
|
|
82
|
-
const s = t.indexOf(e),
|
|
83
|
-
|
|
83
|
+
const s = t.indexOf(e), i = m(e);
|
|
84
|
+
i && (i.classList.add("sl-button-group__button"), i.classList.toggle("sl-button-group__button--first", s === 0), i.classList.toggle("sl-button-group__button--inner", s > 0 && s < t.length - 1), i.classList.toggle("sl-button-group__button--last", s === t.length - 1), i.classList.toggle("sl-button-group__button--radio", i.tagName.toLowerCase() === "sl-radio-button"));
|
|
84
85
|
});
|
|
85
86
|
}
|
|
86
87
|
render() {
|
|
@@ -100,29 +101,29 @@ var O = E`
|
|
|
100
101
|
`;
|
|
101
102
|
}
|
|
102
103
|
};
|
|
103
|
-
|
|
104
|
+
f.styles = B;
|
|
104
105
|
l([
|
|
105
|
-
|
|
106
|
-
],
|
|
106
|
+
b("slot")
|
|
107
|
+
], f.prototype, "defaultSlot", 2);
|
|
107
108
|
l([
|
|
108
109
|
p()
|
|
109
|
-
],
|
|
110
|
+
], f.prototype, "disableRole", 2);
|
|
110
111
|
l([
|
|
111
112
|
n()
|
|
112
|
-
],
|
|
113
|
-
function
|
|
113
|
+
], f.prototype, "label", 2);
|
|
114
|
+
function m(t) {
|
|
114
115
|
var e;
|
|
115
116
|
const s = "sl-button, sl-radio-button";
|
|
116
117
|
return (e = t.closest(s)) != null ? e : t.querySelector(s);
|
|
117
118
|
}
|
|
118
|
-
var a = class extends
|
|
119
|
+
var a = class extends C {
|
|
119
120
|
constructor() {
|
|
120
|
-
super(...arguments), this.formControlController = new
|
|
121
|
+
super(...arguments), this.formControlController = new x(this), this.hasSlotController = new A(this, "help-text", "label"), this.customValidityMessage = "", this.hasButtonGroup = !1, this.errorMessage = "", this.defaultValue = "", this.label = "", this.helpText = "", this.name = "option", this.value = "", this.size = "medium", this.form = "", this.required = !1;
|
|
121
122
|
}
|
|
122
123
|
/** Gets the validity state object */
|
|
123
124
|
get validity() {
|
|
124
125
|
const t = this.required && !this.value;
|
|
125
|
-
return this.customValidityMessage !== "" ?
|
|
126
|
+
return this.customValidityMessage !== "" ? k : t ? M : S;
|
|
126
127
|
}
|
|
127
128
|
/** Gets the validation message */
|
|
128
129
|
get validationMessage() {
|
|
@@ -139,21 +140,21 @@ var a = class extends w {
|
|
|
139
140
|
return [...this.querySelectorAll("sl-radio, sl-radio-button")];
|
|
140
141
|
}
|
|
141
142
|
handleRadioClick(t) {
|
|
142
|
-
const e = t.target.closest("sl-radio, sl-radio-button"), s = this.getAllRadios(),
|
|
143
|
-
e.disabled || (this.value = e.value, s.forEach((
|
|
143
|
+
const e = t.target.closest("sl-radio, sl-radio-button"), s = this.getAllRadios(), i = this.value;
|
|
144
|
+
e.disabled || (this.value = e.value, s.forEach((o) => o.checked = o === e), this.value !== i && (this.emit("sl-change"), this.emit("sl-input")));
|
|
144
145
|
}
|
|
145
146
|
handleKeyDown(t) {
|
|
146
147
|
var e;
|
|
147
148
|
if (!["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", " "].includes(t.key))
|
|
148
149
|
return;
|
|
149
|
-
const s = this.getAllRadios().filter((
|
|
150
|
-
let r = s.indexOf(
|
|
151
|
-
r < 0 && (r = s.length - 1), r > s.length - 1 && (r = 0), this.getAllRadios().forEach((
|
|
152
|
-
|
|
153
|
-
}), this.value = s[r].value, s[r].checked = !0, this.hasButtonGroup ? s[r].shadowRoot.querySelector("button").focus() : (s[r].tabIndex = 0, s[r].focus()), this.value !==
|
|
150
|
+
const s = this.getAllRadios().filter((c) => !c.disabled), i = (e = s.find((c) => c.checked)) != null ? e : s[0], o = t.key === " " ? 0 : ["ArrowUp", "ArrowLeft"].includes(t.key) ? -1 : 1, h = this.value;
|
|
151
|
+
let r = s.indexOf(i) + o;
|
|
152
|
+
r < 0 && (r = s.length - 1), r > s.length - 1 && (r = 0), this.getAllRadios().forEach((c) => {
|
|
153
|
+
c.checked = !1, this.hasButtonGroup || (c.tabIndex = -1);
|
|
154
|
+
}), this.value = s[r].value, s[r].checked = !0, this.hasButtonGroup ? s[r].shadowRoot.querySelector("button").focus() : (s[r].tabIndex = 0, s[r].focus()), this.value !== h && (this.emit("sl-change"), this.emit("sl-input")), t.preventDefault();
|
|
154
155
|
}
|
|
155
156
|
handleLabelClick() {
|
|
156
|
-
const t = this.getAllRadios(), s = t.find((
|
|
157
|
+
const t = this.getAllRadios(), s = t.find((i) => i.checked) || t[0];
|
|
157
158
|
s && s.focus();
|
|
158
159
|
}
|
|
159
160
|
handleInvalid(t) {
|
|
@@ -164,18 +165,18 @@ var a = class extends w {
|
|
|
164
165
|
const s = this.getAllRadios();
|
|
165
166
|
if (await Promise.all(
|
|
166
167
|
// Sync the checked state and size
|
|
167
|
-
s.map(async (
|
|
168
|
-
await
|
|
168
|
+
s.map(async (i) => {
|
|
169
|
+
await i.updateComplete, i.checked = i.value === this.value, i.size = this.size;
|
|
169
170
|
})
|
|
170
|
-
), this.hasButtonGroup = s.some((
|
|
171
|
+
), this.hasButtonGroup = s.some((i) => i.tagName.toLowerCase() === "sl-radio-button"), !s.some((i) => i.checked))
|
|
171
172
|
if (this.hasButtonGroup) {
|
|
172
|
-
const
|
|
173
|
-
|
|
173
|
+
const i = (t = s[0].shadowRoot) == null ? void 0 : t.querySelector("button");
|
|
174
|
+
i && (i.tabIndex = 0);
|
|
174
175
|
} else
|
|
175
176
|
s[0].tabIndex = 0;
|
|
176
177
|
if (this.hasButtonGroup) {
|
|
177
|
-
const
|
|
178
|
-
|
|
178
|
+
const i = (e = this.shadowRoot) == null ? void 0 : e.querySelector("sl-button-group");
|
|
179
|
+
i && (i.disableRole = !0);
|
|
179
180
|
}
|
|
180
181
|
}
|
|
181
182
|
syncRadios() {
|
|
@@ -213,20 +214,20 @@ var a = class extends w {
|
|
|
213
214
|
this.customValidityMessage = t, this.errorMessage = t, this.validationInput.setCustomValidity(t), this.formControlController.updateValidity();
|
|
214
215
|
}
|
|
215
216
|
render() {
|
|
216
|
-
const t = this.hasSlotController.test("label"), e = this.hasSlotController.test("help-text"), s = this.label ? !0 : !!t,
|
|
217
|
+
const t = this.hasSlotController.test("label"), e = this.hasSlotController.test("help-text"), s = this.label ? !0 : !!t, i = this.helpText ? !0 : !!e, o = g`
|
|
217
218
|
<slot @slotchange=${this.syncRadios} @click=${this.handleRadioClick} @keydown=${this.handleKeyDown}></slot>
|
|
218
219
|
`;
|
|
219
220
|
return g`
|
|
220
221
|
<fieldset
|
|
221
222
|
part="form-control"
|
|
222
|
-
class=${
|
|
223
|
+
class=${$({
|
|
223
224
|
"form-control": !0,
|
|
224
225
|
"form-control--small": this.size === "small",
|
|
225
226
|
"form-control--medium": this.size === "medium",
|
|
226
227
|
"form-control--large": this.size === "large",
|
|
227
228
|
"form-control--radio-group": !0,
|
|
228
229
|
"form-control--has-label": s,
|
|
229
|
-
"form-control--has-help-text":
|
|
230
|
+
"form-control--has-help-text": i
|
|
230
231
|
})}
|
|
231
232
|
role="radiogroup"
|
|
232
233
|
aria-labelledby="label"
|
|
@@ -260,16 +261,16 @@ var a = class extends w {
|
|
|
260
261
|
|
|
261
262
|
${this.hasButtonGroup ? g`
|
|
262
263
|
<sl-button-group part="button-group" exportparts="base:button-group__base" role="presentation">
|
|
263
|
-
${
|
|
264
|
+
${o}
|
|
264
265
|
</sl-button-group>
|
|
265
|
-
` :
|
|
266
|
+
` : o}
|
|
266
267
|
</div>
|
|
267
268
|
|
|
268
269
|
<div
|
|
269
270
|
part="form-control-help-text"
|
|
270
271
|
id="help-text"
|
|
271
272
|
class="form-control__help-text"
|
|
272
|
-
aria-hidden=${
|
|
273
|
+
aria-hidden=${i ? "false" : "true"}
|
|
273
274
|
>
|
|
274
275
|
<slot name="help-text">${this.helpText}</slot>
|
|
275
276
|
</div>
|
|
@@ -277,13 +278,13 @@ var a = class extends w {
|
|
|
277
278
|
`;
|
|
278
279
|
}
|
|
279
280
|
};
|
|
280
|
-
a.styles =
|
|
281
|
-
a.dependencies = { "sl-button-group":
|
|
281
|
+
a.styles = L;
|
|
282
|
+
a.dependencies = { "sl-button-group": f };
|
|
282
283
|
l([
|
|
283
|
-
|
|
284
|
+
b("slot:not([name])")
|
|
284
285
|
], a.prototype, "defaultSlot", 2);
|
|
285
286
|
l([
|
|
286
|
-
|
|
287
|
+
b(".radio-group__validation-input")
|
|
287
288
|
], a.prototype, "validationInput", 2);
|
|
288
289
|
l([
|
|
289
290
|
p()
|
|
@@ -316,37 +317,19 @@ l([
|
|
|
316
317
|
n({ type: Boolean, reflect: !0 })
|
|
317
318
|
], a.prototype, "required", 2);
|
|
318
319
|
l([
|
|
319
|
-
|
|
320
|
+
R("size", { waitUntilFirstUpdate: !0 })
|
|
320
321
|
], a.prototype, "handleSizeChange", 1);
|
|
321
322
|
l([
|
|
322
|
-
|
|
323
|
+
R("value")
|
|
323
324
|
], a.prototype, "handleValueChange", 1);
|
|
324
|
-
var
|
|
325
|
+
var w = a;
|
|
325
326
|
a.define("sl-radio-group");
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
};
|
|
331
|
-
return (o, i) => {
|
|
332
|
-
const { update: u } = o, r = Array.isArray(t) ? t : [t];
|
|
333
|
-
o.update = function(h) {
|
|
334
|
-
r.forEach((x) => {
|
|
335
|
-
const b = x;
|
|
336
|
-
if (h.has(b)) {
|
|
337
|
-
const y = h.get(b), C = this[b];
|
|
338
|
-
y !== C && (!s.waitUntilFirstUpdate || this.hasUpdated) && this[i](y, C);
|
|
339
|
-
}
|
|
340
|
-
}), u.call(this, h);
|
|
341
|
-
};
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
var T = Object.defineProperty, U = Object.getOwnPropertyDescriptor, c = (t, e, s, o) => {
|
|
345
|
-
for (var i = o > 1 ? void 0 : o ? U(e, s) : e, u = t.length - 1, r; u >= 0; u--)
|
|
346
|
-
(r = t[u]) && (i = (o ? r(e, s, i) : r(i)) || i);
|
|
347
|
-
return o && i && T(e, s, i), i;
|
|
327
|
+
var G = Object.defineProperty, O = Object.getOwnPropertyDescriptor, u = (t, e, s, i) => {
|
|
328
|
+
for (var o = i > 1 ? void 0 : i ? O(e, s) : e, h = t.length - 1, r; h >= 0; h--)
|
|
329
|
+
(r = t[h]) && (o = (i ? r(e, s, o) : r(o)) || o);
|
|
330
|
+
return i && o && G(e, s, o), o;
|
|
348
331
|
};
|
|
349
|
-
let d = class extends
|
|
332
|
+
let d = class extends w {
|
|
350
333
|
constructor() {
|
|
351
334
|
super(), this.orientation = "vertical", this.disabled = !1, this.requiredLabel = "*Obligatorisk", this.testId = "", this.alreadyInvalid = !1, this.errorMessageCopy = "", this.getAllRadios = function() {
|
|
352
335
|
return [
|
|
@@ -356,35 +339,35 @@ let d = class extends k {
|
|
|
356
339
|
)
|
|
357
340
|
];
|
|
358
341
|
}, this.handleRadioClick = function(t) {
|
|
359
|
-
const e = t.target.closest("sl-radio, sl-radio-button, nve-radio, nve-radio-button"), s = this.getAllRadios(),
|
|
342
|
+
const e = t.target.closest("sl-radio, sl-radio-button, nve-radio, nve-radio-button"), s = this.getAllRadios(), i = this.value;
|
|
360
343
|
if (!e || e.disabled)
|
|
361
344
|
return;
|
|
362
|
-
const
|
|
363
|
-
|
|
345
|
+
const o = e.shadowRoot.querySelectorAll("span[part='base']");
|
|
346
|
+
o.length > 0 && o[0].focus(), this.value = e.value, s.forEach((h) => h.checked = h === e), this.value !== i && (this.emit("sl-change"), this.emit("sl-input"));
|
|
364
347
|
}, this.syncRadioElements = async function() {
|
|
365
|
-
var e, s,
|
|
348
|
+
var e, s, i;
|
|
366
349
|
const t = this.getAllRadios();
|
|
367
350
|
if (await Promise.all(
|
|
368
351
|
// Sync the checked state and size
|
|
369
352
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
370
|
-
t.map(async (
|
|
371
|
-
await
|
|
353
|
+
t.map(async (o) => {
|
|
354
|
+
await o.updateComplete, o.checked = o.value === this.value, o.size = this.size;
|
|
372
355
|
})
|
|
373
356
|
), this.hasButtonGroup = t.some(
|
|
374
357
|
// @ts-ignore
|
|
375
|
-
(
|
|
376
|
-
), !t.some((
|
|
358
|
+
(o) => o.tagName.toLowerCase() === "sl-radio-button" || o.tagName.toLowerCase() === "nve-radio-button"
|
|
359
|
+
), !t.some((o) => o.checked))
|
|
377
360
|
if (this.hasButtonGroup) {
|
|
378
|
-
const
|
|
379
|
-
|
|
361
|
+
const o = (e = t[0].shadowRoot) == null ? void 0 : e.querySelector("button");
|
|
362
|
+
o && (o.tabIndex = 0);
|
|
380
363
|
} else
|
|
381
364
|
t[0].tabIndex = 0;
|
|
382
365
|
if (this.hasButtonGroup) {
|
|
383
|
-
const
|
|
366
|
+
const o = (
|
|
384
367
|
// @ts-ignore
|
|
385
|
-
((s = this.shadowRoot) == null ? void 0 : s.querySelector("sl-button-group")) || ((
|
|
368
|
+
((s = this.shadowRoot) == null ? void 0 : s.querySelector("sl-button-group")) || ((i = this.shadowRoot) == null ? void 0 : i.querySelector("nve-button-group"))
|
|
386
369
|
);
|
|
387
|
-
|
|
370
|
+
o && (o.disableRole = !0);
|
|
388
371
|
}
|
|
389
372
|
}, this.syncRadios = function() {
|
|
390
373
|
if (customElements.get("sl-radio") && customElements.get("sl-radio-button") || // lagt til nve-radio og nve-radio-button
|
|
@@ -409,46 +392,46 @@ let d = class extends k {
|
|
|
409
392
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
410
393
|
handlePropChange(t, e) {
|
|
411
394
|
const s = this.getAllRadios();
|
|
412
|
-
return e !== t ? (s.forEach((
|
|
413
|
-
|
|
395
|
+
return e !== t ? (s.forEach((o) => {
|
|
396
|
+
o.was_disabled === void 0 ? o.was_disabled = o.disabled : t === !0 ? o.disabled = o.was_disabled : (o.was_disabled = o.disabled, o.disabled = !0);
|
|
414
397
|
}), !0) : !1;
|
|
415
398
|
}
|
|
416
399
|
makeInvalid() {
|
|
417
400
|
const t = this.getAllRadios();
|
|
418
|
-
|
|
401
|
+
v(t, !0, "data-invalid"), this.errorMessageCopy || (this.errorMessageCopy = this.validationMessage), this.setCustomValidity(this.errorMessageCopy), this.style.setProperty("--radio-group-error-message", `"${this.errorMessageCopy}"`);
|
|
419
402
|
}
|
|
420
403
|
resetValidation() {
|
|
421
404
|
const t = this.getAllRadios();
|
|
422
|
-
this.errorMessageCopy = "",
|
|
405
|
+
this.errorMessageCopy = "", v(t, !1, "data-invalid"), this.setCustomValidity(""), this.style.removeProperty("--radio-group-error-message");
|
|
423
406
|
}
|
|
424
407
|
};
|
|
425
|
-
d.styles = [
|
|
426
|
-
|
|
408
|
+
d.styles = [w.styles, q];
|
|
409
|
+
u([
|
|
427
410
|
n({ reflect: !0 })
|
|
428
411
|
], d.prototype, "orientation", 2);
|
|
429
|
-
|
|
412
|
+
u([
|
|
430
413
|
n({ type: Boolean, reflect: !0 })
|
|
431
414
|
], d.prototype, "disabled", 2);
|
|
432
|
-
|
|
415
|
+
u([
|
|
433
416
|
n({ reflect: !0 })
|
|
434
417
|
], d.prototype, "errorMessage", 2);
|
|
435
|
-
|
|
418
|
+
u([
|
|
436
419
|
n()
|
|
437
420
|
], d.prototype, "requiredLabel", 2);
|
|
438
|
-
|
|
421
|
+
u([
|
|
439
422
|
n({ reflect: !0, type: String })
|
|
440
423
|
], d.prototype, "testId", 2);
|
|
441
|
-
|
|
424
|
+
u([
|
|
442
425
|
p()
|
|
443
426
|
], d.prototype, "alreadyInvalid", 2);
|
|
444
|
-
|
|
427
|
+
u([
|
|
445
428
|
p()
|
|
446
429
|
], d.prototype, "errorMessageCopy", 2);
|
|
447
|
-
|
|
448
|
-
|
|
430
|
+
u([
|
|
431
|
+
I("disabled")
|
|
449
432
|
], d.prototype, "connectedCallback", 1);
|
|
450
|
-
d =
|
|
451
|
-
|
|
433
|
+
d = u([
|
|
434
|
+
E("nve-radio-group")
|
|
452
435
|
], d);
|
|
453
436
|
export {
|
|
454
437
|
d as default
|
|
@@ -137,7 +137,7 @@ let e = class extends h {
|
|
|
137
137
|
return this.isLast ? "" : c`
|
|
138
138
|
<div class="vertical-divider-container">
|
|
139
139
|
<div
|
|
140
|
-
style="${this.isOrientationVertical() ? `height:${this.spaceBetweenSteps}px` :
|
|
140
|
+
style="${this.isOrientationVertical() ? `height:${this.spaceBetweenSteps}px` : ""}"
|
|
141
141
|
class="${t} ${this.getDividerColorClass()}"
|
|
142
142
|
></div>
|
|
143
143
|
</div>`;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { INveComponent } from '../../interfaces/NveComponent.interface';
|
|
2
|
+
import { CSSResultArray, LitElement, TemplateResult } from 'lit';
|
|
3
|
+
/**
|
|
4
|
+
* En vippe-bryter med støtte for ikoner.
|
|
5
|
+
*
|
|
6
|
+
* @slot - Tekst etter bryteren
|
|
7
|
+
* @slot onicon - Det første ikonet (til venstre). Synlig når status er PÅ
|
|
8
|
+
* @slot officon - Det andre ikonet (til høyre). Synlig når status er AV
|
|
9
|
+
*
|
|
10
|
+
* @event blur Bryter mister fokus
|
|
11
|
+
* @event change Bryter endres
|
|
12
|
+
* @event input Bryter endres
|
|
13
|
+
* @event focus Bryter får fokus
|
|
14
|
+
*
|
|
15
|
+
* @csspart base Topp-element
|
|
16
|
+
* @csspart control Element rundt bryteren
|
|
17
|
+
* @csspart thumb Bryter-indikatoren
|
|
18
|
+
* @csspart label Tekst bak bryteren
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
export default class NveSwitch extends LitElement implements INveComponent {
|
|
22
|
+
constructor();
|
|
23
|
+
testId: string;
|
|
24
|
+
/** Hidden checkbox som holder state */
|
|
25
|
+
input: HTMLInputElement;
|
|
26
|
+
private hasFocus;
|
|
27
|
+
title: string;
|
|
28
|
+
/** Navn på switch */
|
|
29
|
+
name: string;
|
|
30
|
+
/** Switchens verdi, bruk i forms */
|
|
31
|
+
value: string;
|
|
32
|
+
disabled: boolean;
|
|
33
|
+
/** Verdien til switchen. */
|
|
34
|
+
checked: boolean;
|
|
35
|
+
static styles: CSSResultArray;
|
|
36
|
+
private emit;
|
|
37
|
+
private handleBlur;
|
|
38
|
+
private handleInput;
|
|
39
|
+
private handleClick;
|
|
40
|
+
private handleFocus;
|
|
41
|
+
private handleKeyDown;
|
|
42
|
+
handleCheckedChange(): void;
|
|
43
|
+
/** click, focus og blur sendes til input (checkbox) */
|
|
44
|
+
click(): void;
|
|
45
|
+
focus(options?: FocusOptions): void;
|
|
46
|
+
blur(): void;
|
|
47
|
+
render(): TemplateResult;
|
|
48
|
+
}
|
|
49
|
+
declare global {
|
|
50
|
+
interface HTMLElementTagNameMap {
|
|
51
|
+
'nve-switch': NveSwitch;
|
|
52
|
+
}
|
|
53
|
+
}
|