nve-designsystem 0.1.86 → 0.1.87
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/components/nve-button/nve-button.component.d.ts +4 -1
- package/components/nve-button/nve-button.component.js +150 -130
- package/components/nve-button/nve-button.styles.js +38 -6
- package/custom-elements.json +29 -857
- package/package.json +1 -1
- package/components/nve-icon-button/nve-icon-button.component.d.ts +0 -23
- package/components/nve-icon-button/nve-icon-button.component.js +0 -49
- package/components/nve-icon-button/nve-icon-button.styles.d.ts +0 -2
- package/components/nve-icon-button/nve-icon-button.styles.js +0 -32
|
@@ -3,13 +3,16 @@ import { INveComponent } from '../../interfaces/NveComponent.interface';
|
|
|
3
3
|
/**
|
|
4
4
|
* Selveste NVE-knappen.
|
|
5
5
|
* Bruk href for å gjøre den om til en link.
|
|
6
|
-
* Disse feltene skal ikke brukes:
|
|
6
|
+
* Disse feltene skal ikke brukes:caret og pill
|
|
7
|
+
* Circle attributte skal brukes kun når man viser bare et ikon.
|
|
7
8
|
*/
|
|
8
9
|
export default class NveButton extends SlButton implements INveComponent {
|
|
9
10
|
constructor();
|
|
10
11
|
static styles: import("lit").CSSResultGroup[];
|
|
11
12
|
size: 'small' | 'medium' | 'large';
|
|
12
13
|
testId: string | undefined;
|
|
14
|
+
firstUpdated(): void;
|
|
15
|
+
updated(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
13
16
|
}
|
|
14
17
|
declare global {
|
|
15
18
|
interface HTMLElementTagNameMap {
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { n as
|
|
1
|
+
import { n as i, t as y } from "../../chunks/property.js";
|
|
2
2
|
import { S as v } from "../../chunks/chunk.I2FDN2OJ.js";
|
|
3
3
|
import { F as C, v as g } from "../../chunks/chunk.UEQZEZFU.js";
|
|
4
4
|
import { b as $ } from "../../chunks/chunk.MGOBPGE5.js";
|
|
5
|
-
import { H as
|
|
6
|
-
import { L as
|
|
7
|
-
import { S
|
|
8
|
-
import { w as
|
|
9
|
-
import { b as
|
|
5
|
+
import { H as _ } from "../../chunks/chunk.NYIIDP5N.js";
|
|
6
|
+
import { L as B } from "../../chunks/chunk.MAS2SHYD.js";
|
|
7
|
+
import { S } from "../../chunks/chunk.2HU27ZWH.js";
|
|
8
|
+
import { w as x } from "../../chunks/chunk.Q6ASPMKT.js";
|
|
9
|
+
import { b as o, S as w } from "../../chunks/chunk.JS655M6J.js";
|
|
10
10
|
import { e as F } from "../../chunks/class-map.js";
|
|
11
11
|
import { s as c, n as f } from "../../chunks/static.js";
|
|
12
|
-
import { o as
|
|
12
|
+
import { o as n } from "../../chunks/if-defined.js";
|
|
13
13
|
import { r as m } from "../../chunks/state.js";
|
|
14
|
-
import { e as
|
|
15
|
-
import
|
|
16
|
-
var
|
|
14
|
+
import { e as I } from "../../chunks/query.js";
|
|
15
|
+
import N from "./nve-button.styles.js";
|
|
16
|
+
var e = class extends w {
|
|
17
17
|
constructor() {
|
|
18
18
|
super(...arguments), this.formControlController = new C(this, {
|
|
19
|
-
form: (
|
|
20
|
-
if (
|
|
21
|
-
const
|
|
22
|
-
return
|
|
19
|
+
form: (t) => {
|
|
20
|
+
if (t.hasAttribute("form")) {
|
|
21
|
+
const r = t.getRootNode(), l = t.getAttribute("form");
|
|
22
|
+
return r.getElementById(l);
|
|
23
23
|
}
|
|
24
|
-
return
|
|
24
|
+
return t.closest("form");
|
|
25
25
|
},
|
|
26
26
|
assumeInteractionOn: ["click"]
|
|
27
|
-
}), this.hasSlotController = new
|
|
27
|
+
}), this.hasSlotController = new _(this, "[default]", "prefix", "suffix"), this.localize = new B(this), this.hasFocus = !1, this.invalid = !1, this.title = "", this.variant = "default", this.size = "medium", this.caret = !1, this.disabled = !1, this.loading = !1, this.outline = !1, this.pill = !1, this.circle = !1, this.type = "button", this.name = "", this.value = "", this.href = "", this.rel = "noreferrer noopener";
|
|
28
28
|
}
|
|
29
29
|
/** Gets the validity state object */
|
|
30
30
|
get validity() {
|
|
@@ -46,8 +46,8 @@ var t = class extends w {
|
|
|
46
46
|
handleClick() {
|
|
47
47
|
this.type === "submit" && this.formControlController.submit(this), this.type === "reset" && this.formControlController.reset(this);
|
|
48
48
|
}
|
|
49
|
-
handleInvalid(
|
|
50
|
-
this.formControlController.setValidity(!1), this.formControlController.emitInvalidEvent(
|
|
49
|
+
handleInvalid(t) {
|
|
50
|
+
this.formControlController.setValidity(!1), this.formControlController.emitInvalidEvent(t);
|
|
51
51
|
}
|
|
52
52
|
isButton() {
|
|
53
53
|
return !this.href;
|
|
@@ -63,8 +63,8 @@ var t = class extends w {
|
|
|
63
63
|
this.button.click();
|
|
64
64
|
}
|
|
65
65
|
/** Sets focus on the button. */
|
|
66
|
-
focus(
|
|
67
|
-
this.button.focus(
|
|
66
|
+
focus(t) {
|
|
67
|
+
this.button.focus(t);
|
|
68
68
|
}
|
|
69
69
|
/** Removes focus from the button. */
|
|
70
70
|
blur() {
|
|
@@ -83,13 +83,13 @@ var t = class extends w {
|
|
|
83
83
|
return this.isButton() ? this.button.reportValidity() : !0;
|
|
84
84
|
}
|
|
85
85
|
/** Sets a custom validation message. Pass an empty string to restore validity. */
|
|
86
|
-
setCustomValidity(
|
|
87
|
-
this.isButton() && (this.button.setCustomValidity(
|
|
86
|
+
setCustomValidity(t) {
|
|
87
|
+
this.isButton() && (this.button.setCustomValidity(t), this.formControlController.updateValidity());
|
|
88
88
|
}
|
|
89
89
|
render() {
|
|
90
|
-
const
|
|
90
|
+
const t = this.isLink(), r = t ? c`a` : c`button`;
|
|
91
91
|
return f`
|
|
92
|
-
<${
|
|
92
|
+
<${r}
|
|
93
93
|
part="base"
|
|
94
94
|
class=${F({
|
|
95
95
|
button: !0,
|
|
@@ -116,16 +116,16 @@ var t = class extends w {
|
|
|
116
116
|
"button--has-prefix": this.hasSlotController.test("prefix"),
|
|
117
117
|
"button--has-suffix": this.hasSlotController.test("suffix")
|
|
118
118
|
})}
|
|
119
|
-
?disabled=${
|
|
120
|
-
type=${
|
|
119
|
+
?disabled=${n(t ? void 0 : this.disabled)}
|
|
120
|
+
type=${n(t ? void 0 : this.type)}
|
|
121
121
|
title=${this.title}
|
|
122
|
-
name=${
|
|
123
|
-
value=${
|
|
124
|
-
href=${
|
|
125
|
-
target=${
|
|
126
|
-
download=${
|
|
127
|
-
rel=${
|
|
128
|
-
role=${
|
|
122
|
+
name=${n(t ? void 0 : this.name)}
|
|
123
|
+
value=${n(t ? void 0 : this.value)}
|
|
124
|
+
href=${n(t ? this.href : void 0)}
|
|
125
|
+
target=${n(t ? this.target : void 0)}
|
|
126
|
+
download=${n(t ? this.download : void 0)}
|
|
127
|
+
rel=${n(t ? this.rel : void 0)}
|
|
128
|
+
role=${n(t ? void 0 : "button")}
|
|
129
129
|
aria-disabled=${this.disabled ? "true" : "false"}
|
|
130
130
|
tabindex=${this.disabled ? "-1" : "0"}
|
|
131
131
|
@blur=${this.handleBlur}
|
|
@@ -138,115 +138,135 @@ var t = class extends w {
|
|
|
138
138
|
<slot name="suffix" part="suffix" class="button__suffix"></slot>
|
|
139
139
|
${this.caret ? f` <sl-icon part="caret" class="button__caret" library="system" name="caret"></sl-icon> ` : ""}
|
|
140
140
|
${this.loading ? f`<sl-spinner part="spinner"></sl-spinner>` : ""}
|
|
141
|
-
</${
|
|
141
|
+
</${r}>
|
|
142
142
|
`;
|
|
143
143
|
}
|
|
144
144
|
};
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
"sl-icon":
|
|
145
|
+
e.styles = $;
|
|
146
|
+
e.dependencies = {
|
|
147
|
+
"sl-icon": S,
|
|
148
148
|
"sl-spinner": v
|
|
149
149
|
};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
],
|
|
153
|
-
|
|
150
|
+
o([
|
|
151
|
+
I(".button")
|
|
152
|
+
], e.prototype, "button", 2);
|
|
153
|
+
o([
|
|
154
154
|
m()
|
|
155
|
-
],
|
|
156
|
-
|
|
155
|
+
], e.prototype, "hasFocus", 2);
|
|
156
|
+
o([
|
|
157
157
|
m()
|
|
158
|
-
],
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
],
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
],
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
],
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
],
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
],
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
],
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
],
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
],
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
],
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
],
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
],
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
],
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
],
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
],
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
],
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
],
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
],
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
],
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
],
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
],
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
],
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
],
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
],
|
|
228
|
-
var b =
|
|
229
|
-
|
|
230
|
-
var
|
|
231
|
-
for (var
|
|
232
|
-
(
|
|
233
|
-
return
|
|
158
|
+
], e.prototype, "invalid", 2);
|
|
159
|
+
o([
|
|
160
|
+
i()
|
|
161
|
+
], e.prototype, "title", 2);
|
|
162
|
+
o([
|
|
163
|
+
i({ reflect: !0 })
|
|
164
|
+
], e.prototype, "variant", 2);
|
|
165
|
+
o([
|
|
166
|
+
i({ reflect: !0 })
|
|
167
|
+
], e.prototype, "size", 2);
|
|
168
|
+
o([
|
|
169
|
+
i({ type: Boolean, reflect: !0 })
|
|
170
|
+
], e.prototype, "caret", 2);
|
|
171
|
+
o([
|
|
172
|
+
i({ type: Boolean, reflect: !0 })
|
|
173
|
+
], e.prototype, "disabled", 2);
|
|
174
|
+
o([
|
|
175
|
+
i({ type: Boolean, reflect: !0 })
|
|
176
|
+
], e.prototype, "loading", 2);
|
|
177
|
+
o([
|
|
178
|
+
i({ type: Boolean, reflect: !0 })
|
|
179
|
+
], e.prototype, "outline", 2);
|
|
180
|
+
o([
|
|
181
|
+
i({ type: Boolean, reflect: !0 })
|
|
182
|
+
], e.prototype, "pill", 2);
|
|
183
|
+
o([
|
|
184
|
+
i({ type: Boolean, reflect: !0 })
|
|
185
|
+
], e.prototype, "circle", 2);
|
|
186
|
+
o([
|
|
187
|
+
i()
|
|
188
|
+
], e.prototype, "type", 2);
|
|
189
|
+
o([
|
|
190
|
+
i()
|
|
191
|
+
], e.prototype, "name", 2);
|
|
192
|
+
o([
|
|
193
|
+
i()
|
|
194
|
+
], e.prototype, "value", 2);
|
|
195
|
+
o([
|
|
196
|
+
i()
|
|
197
|
+
], e.prototype, "href", 2);
|
|
198
|
+
o([
|
|
199
|
+
i()
|
|
200
|
+
], e.prototype, "target", 2);
|
|
201
|
+
o([
|
|
202
|
+
i()
|
|
203
|
+
], e.prototype, "rel", 2);
|
|
204
|
+
o([
|
|
205
|
+
i()
|
|
206
|
+
], e.prototype, "download", 2);
|
|
207
|
+
o([
|
|
208
|
+
i()
|
|
209
|
+
], e.prototype, "form", 2);
|
|
210
|
+
o([
|
|
211
|
+
i({ attribute: "formaction" })
|
|
212
|
+
], e.prototype, "formAction", 2);
|
|
213
|
+
o([
|
|
214
|
+
i({ attribute: "formenctype" })
|
|
215
|
+
], e.prototype, "formEnctype", 2);
|
|
216
|
+
o([
|
|
217
|
+
i({ attribute: "formmethod" })
|
|
218
|
+
], e.prototype, "formMethod", 2);
|
|
219
|
+
o([
|
|
220
|
+
i({ attribute: "formnovalidate", type: Boolean })
|
|
221
|
+
], e.prototype, "formNoValidate", 2);
|
|
222
|
+
o([
|
|
223
|
+
i({ attribute: "formtarget" })
|
|
224
|
+
], e.prototype, "formTarget", 2);
|
|
225
|
+
o([
|
|
226
|
+
x("disabled", { waitUntilFirstUpdate: !0 })
|
|
227
|
+
], e.prototype, "handleDisabledChange", 1);
|
|
228
|
+
var b = e;
|
|
229
|
+
e.define("sl-button");
|
|
230
|
+
var V = Object.defineProperty, z = Object.getOwnPropertyDescriptor, p = (t, r, l, a) => {
|
|
231
|
+
for (var s = a > 1 ? void 0 : a ? z(r, l) : r, u = t.length - 1, d; u >= 0; u--)
|
|
232
|
+
(d = t[u]) && (s = (a ? d(r, l, s) : d(s)) || s);
|
|
233
|
+
return a && s && V(r, l, s), s;
|
|
234
234
|
};
|
|
235
|
-
let
|
|
235
|
+
let h = class extends b {
|
|
236
236
|
constructor() {
|
|
237
237
|
super(), this.size = "large", this.testId = void 0;
|
|
238
238
|
}
|
|
239
|
+
// setter has-icon-only attributtet hvis det er kun ikone i standard sporet. Trengs for riktig styling.
|
|
240
|
+
firstUpdated() {
|
|
241
|
+
var r;
|
|
242
|
+
const t = (r = this.shadowRoot) == null ? void 0 : r.querySelector(".button__label");
|
|
243
|
+
if (t) {
|
|
244
|
+
const l = t.assignedNodes();
|
|
245
|
+
l.length === 1 && l[0].nodeName.toLowerCase() === "nve-icon" && this.setAttribute("has-icon-only", "");
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
// Hvis man har kun ikone i standard sporet og bruker loading attributtet, fjerner vi ikonet.
|
|
249
|
+
updated(t) {
|
|
250
|
+
var r;
|
|
251
|
+
if (super.updated(t), t.has("loading") && this.loading && this.hasAttribute("has-icon-only")) {
|
|
252
|
+
const l = (r = this.shadowRoot) == null ? void 0 : r.querySelector(".button__label");
|
|
253
|
+
if (l) {
|
|
254
|
+
const s = l.assignedNodes().find((u) => u.nodeName.toLowerCase() === "nve-icon");
|
|
255
|
+
s && s.parentNode && s.parentNode.removeChild(s);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
239
259
|
};
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
],
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
],
|
|
247
|
-
|
|
260
|
+
h.styles = [b.styles, N];
|
|
261
|
+
p([
|
|
262
|
+
i({ reflect: !0 })
|
|
263
|
+
], h.prototype, "size", 2);
|
|
264
|
+
p([
|
|
265
|
+
i({ reflect: !0, type: String })
|
|
266
|
+
], h.prototype, "testId", 2);
|
|
267
|
+
h = p([
|
|
248
268
|
y("nve-button")
|
|
249
|
-
],
|
|
269
|
+
], h);
|
|
250
270
|
export {
|
|
251
|
-
|
|
271
|
+
h as default
|
|
252
272
|
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { i as t } from "../../chunks/lit-element.js";
|
|
2
|
-
const
|
|
2
|
+
const a = t`
|
|
3
3
|
/* kan ikke bruke gap fordi den lager rom mellom slots selv om de er tomme */
|
|
4
4
|
/* derfor setter margin på ::part(label) og substraherer margin verdi i horizontal padding i selve .button klassen */
|
|
5
|
+
:host {
|
|
6
|
+
--nve-icon-color: inherit;
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
.button {
|
|
6
10
|
width: fit-content;
|
|
7
11
|
align-items: center;
|
|
@@ -12,6 +16,30 @@ const n = t`
|
|
|
12
16
|
transition: background-color 0.3s ease;
|
|
13
17
|
}
|
|
14
18
|
|
|
19
|
+
:host([has-icon-only])::part(base) {
|
|
20
|
+
gap: unset;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
:host([has-icon-only]) .button--small {
|
|
24
|
+
gap: unset;
|
|
25
|
+
padding: var(--spacing-xx-small);
|
|
26
|
+
min-width: unset;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
:host([has-icon-only]) .button--medium {
|
|
30
|
+
gap: unset;
|
|
31
|
+
padding: var(--spacing-x-small);
|
|
32
|
+
min-width: unset;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
:host([has-icon-only][circle])::part(base) {
|
|
36
|
+
width: unset;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:host([has-icon-only][loading])::part(spinner) {
|
|
40
|
+
margin-right: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
15
43
|
.button ::slotted(nve-badge) {
|
|
16
44
|
position: absolute;
|
|
17
45
|
top: 0;
|
|
@@ -25,16 +53,14 @@ const n = t`
|
|
|
25
53
|
--track-width: 2.5px;
|
|
26
54
|
position: relative;
|
|
27
55
|
top: 0;
|
|
56
|
+
font-size: 24px;
|
|
28
57
|
left: 0;
|
|
29
58
|
margin-right: var(--spacing-x-small);
|
|
30
59
|
}
|
|
31
60
|
|
|
32
61
|
:host ::slotted(nve-icon) {
|
|
33
62
|
font-size: 24px;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
:host([size='small']) ::slotted(nve-icon) {
|
|
37
|
-
font-size: 20px;
|
|
63
|
+
color: var(--nve-icon-color);
|
|
38
64
|
}
|
|
39
65
|
|
|
40
66
|
:host::part(label) {
|
|
@@ -141,6 +167,12 @@ const n = t`
|
|
|
141
167
|
border-radius: var(--border-radius-small, 4px);
|
|
142
168
|
border: none;
|
|
143
169
|
}
|
|
170
|
+
|
|
171
|
+
:host([variant='text'][circle]) .button.button--standard,
|
|
172
|
+
:host([variant='ghost'][circle]) .button.button--standard {
|
|
173
|
+
border-radius: 50%;
|
|
174
|
+
}
|
|
175
|
+
|
|
144
176
|
:host([variant='text']) .button.button--standard:hover:not(.button--disabled),
|
|
145
177
|
:host([variant='ghost']) .button.button--standard:hover:not(.button--disabled) {
|
|
146
178
|
background-color: var(--interactive-ghost-background-hover);
|
|
@@ -175,5 +207,5 @@ const n = t`
|
|
|
175
207
|
}
|
|
176
208
|
`;
|
|
177
209
|
export {
|
|
178
|
-
|
|
210
|
+
a as default
|
|
179
211
|
};
|