nve-designsystem 1.4.6 → 1.5.0
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.
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
/**
|
|
3
3
|
* Et ikon.
|
|
4
|
-
* Vi bruker ikoner fra Material Symbols.
|
|
5
|
-
*
|
|
6
|
-
* Fill
|
|
4
|
+
* Vi bruker ikoner fra Material Symbols, men det er også mulig å bruke ikoner fra egen repo. Det anbefales sterkt å bruke Material-ikonene.
|
|
5
|
+
* Strektykkelsen skal være 400, uavhengig av ikonets størrelse, og kun stilene Sharp og Outlined skal brukes.
|
|
6
|
+
* Fill-stilen bør unngås, da den fyller hele ikonet med farge i stedet for å bruke kun konturer
|
|
7
7
|
* @see https://fonts.google.com/icons
|
|
8
|
+
* @csspart icon - Selve ikon span-element.
|
|
9
|
+
* @cssproperty --icon-size - Størrelse på ikonet. 16px er standard.
|
|
8
10
|
*/
|
|
9
11
|
export default class NveIcon extends LitElement {
|
|
10
12
|
static styles: import('lit').CSSResult[];
|
|
@@ -12,6 +14,8 @@ export default class NveIcon extends LitElement {
|
|
|
12
14
|
library: 'Outlined' | 'Sharp';
|
|
13
15
|
/** Navnet på ikonet i Material Symbols-biblioteket */
|
|
14
16
|
name: string;
|
|
17
|
+
src: string;
|
|
18
|
+
alt: string | undefined;
|
|
15
19
|
/** Boolean som angir om ikonet har hatt tid til å laste. */
|
|
16
20
|
private iconLoaded;
|
|
17
21
|
protected firstUpdated(): void;
|
|
@@ -1,148 +1,164 @@
|
|
|
1
|
-
import { r as U, x as
|
|
2
|
-
import { n as
|
|
1
|
+
import { r as U, x as F } from "../../chunks/lit-element.js";
|
|
2
|
+
import { n as j, t as H } from "../../chunks/property.js";
|
|
3
3
|
import { r as J } from "../../chunks/state.js";
|
|
4
4
|
import K from "./nve-icon.styles.js";
|
|
5
|
-
|
|
5
|
+
import { e as Q } from "../../chunks/class-map.js";
|
|
6
|
+
import { o as V } from "../../chunks/if-defined.js";
|
|
7
|
+
function X(s) {
|
|
6
8
|
return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
|
|
7
9
|
}
|
|
8
|
-
var
|
|
9
|
-
function
|
|
10
|
-
return
|
|
10
|
+
var I = { exports: {} }, q;
|
|
11
|
+
function Y() {
|
|
12
|
+
return q || (q = 1, function(s) {
|
|
11
13
|
(function() {
|
|
12
14
|
function i(e, n) {
|
|
13
15
|
document.addEventListener ? e.addEventListener("scroll", n, !1) : e.attachEvent("scroll", n);
|
|
14
16
|
}
|
|
15
|
-
function
|
|
17
|
+
function T(e) {
|
|
16
18
|
document.body ? e() : document.addEventListener ? document.addEventListener("DOMContentLoaded", function n() {
|
|
17
19
|
document.removeEventListener("DOMContentLoaded", n), e();
|
|
18
20
|
}) : document.attachEvent("onreadystatechange", function n() {
|
|
19
21
|
(document.readyState == "interactive" || document.readyState == "complete") && (document.detachEvent("onreadystatechange", n), e());
|
|
20
22
|
});
|
|
21
23
|
}
|
|
22
|
-
function
|
|
24
|
+
function p(e) {
|
|
23
25
|
this.g = document.createElement("div"), this.g.setAttribute("aria-hidden", "true"), this.g.appendChild(document.createTextNode(e)), this.h = document.createElement("span"), this.i = document.createElement("span"), this.m = document.createElement("span"), this.j = document.createElement("span"), this.l = -1, this.h.style.cssText = "max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;", this.i.style.cssText = "max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;", this.j.style.cssText = "max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;", this.m.style.cssText = "display:inline-block;width:200%;height:200%;font-size:16px;max-width:none;", this.h.appendChild(this.m), this.i.appendChild(this.j), this.g.appendChild(this.h), this.g.appendChild(this.i);
|
|
24
26
|
}
|
|
25
27
|
function r(e, n) {
|
|
26
28
|
e.g.style.cssText = "max-width:none;min-width:20px;min-height:20px;display:inline-block;overflow:hidden;position:absolute;width:auto;margin:0;padding:0;top:-999px;white-space:nowrap;font-synthesis:none;font:" + n + ";";
|
|
27
29
|
}
|
|
28
|
-
function
|
|
30
|
+
function E(e) {
|
|
29
31
|
var n = e.g.offsetWidth, t = n + 100;
|
|
30
32
|
return e.j.style.width = t + "px", e.i.scrollLeft = t, e.h.scrollLeft = e.h.scrollWidth + 100, e.l !== n ? (e.l = n, !0) : !1;
|
|
31
33
|
}
|
|
32
|
-
function
|
|
34
|
+
function y(e, n) {
|
|
33
35
|
function t() {
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
+
var a = u;
|
|
37
|
+
E(a) && a.g.parentNode !== null && n(a.l);
|
|
36
38
|
}
|
|
37
|
-
var
|
|
38
|
-
i(e.h, t), i(e.i, t),
|
|
39
|
+
var u = e;
|
|
40
|
+
i(e.h, t), i(e.i, t), E(e);
|
|
39
41
|
}
|
|
40
|
-
function
|
|
42
|
+
function N(e, n, t) {
|
|
41
43
|
n = n || {}, t = t || window, this.family = e, this.style = n.style || "normal", this.weight = n.weight || "normal", this.stretch = n.stretch || "normal", this.context = t;
|
|
42
44
|
}
|
|
43
|
-
var
|
|
45
|
+
var P = null, _ = null, $ = null, A = null;
|
|
44
46
|
function B(e) {
|
|
45
|
-
return
|
|
47
|
+
return _ === null && (S(e) && /Apple/.test(window.navigator.vendor) ? (e = /AppleWebKit\/([0-9]+)(?:\.([0-9]+))(?:\.([0-9]+))/.exec(window.navigator.userAgent), _ = !!e && 603 > parseInt(e[1], 10)) : _ = !1), _;
|
|
46
48
|
}
|
|
47
|
-
function
|
|
49
|
+
function S(e) {
|
|
48
50
|
return A === null && (A = !!e.document.fonts), A;
|
|
49
51
|
}
|
|
50
|
-
function
|
|
51
|
-
var t = e.style,
|
|
52
|
-
if (
|
|
53
|
-
var
|
|
52
|
+
function g(e, n) {
|
|
53
|
+
var t = e.style, u = e.weight;
|
|
54
|
+
if ($ === null) {
|
|
55
|
+
var a = document.createElement("div");
|
|
54
56
|
try {
|
|
55
|
-
|
|
57
|
+
a.style.font = "condensed 100px sans-serif";
|
|
56
58
|
} catch {
|
|
57
59
|
}
|
|
58
|
-
|
|
60
|
+
$ = a.style.font !== "";
|
|
59
61
|
}
|
|
60
|
-
return [t,
|
|
62
|
+
return [t, u, $ ? e.stretch : "", "100px", n].join(" ");
|
|
61
63
|
}
|
|
62
|
-
|
|
63
|
-
var t = this,
|
|
64
|
-
return new Promise(function(M,
|
|
65
|
-
if (
|
|
66
|
-
var G = new Promise(function(
|
|
64
|
+
N.prototype.load = function(e, n) {
|
|
65
|
+
var t = this, u = e || "BESbswy", a = 0, w = n || 3e3, z = (/* @__PURE__ */ new Date()).getTime();
|
|
66
|
+
return new Promise(function(M, k) {
|
|
67
|
+
if (S(t.context) && !B(t.context)) {
|
|
68
|
+
var G = new Promise(function(b, x) {
|
|
67
69
|
function d() {
|
|
68
|
-
(/* @__PURE__ */ new Date()).getTime() -
|
|
69
|
-
1 <= m.length ?
|
|
70
|
-
},
|
|
70
|
+
(/* @__PURE__ */ new Date()).getTime() - z >= w ? x(Error("" + w + "ms timeout exceeded")) : t.context.document.fonts.load(g(t, '"' + t.family + '"'), u).then(function(m) {
|
|
71
|
+
1 <= m.length ? b() : setTimeout(d, 25);
|
|
72
|
+
}, x);
|
|
71
73
|
}
|
|
72
74
|
d();
|
|
73
|
-
}), R = new Promise(function(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
},
|
|
75
|
+
}), R = new Promise(function(b, x) {
|
|
76
|
+
a = setTimeout(function() {
|
|
77
|
+
x(Error("" + w + "ms timeout exceeded"));
|
|
78
|
+
}, w);
|
|
77
79
|
});
|
|
78
80
|
Promise.race([R, G]).then(function() {
|
|
79
|
-
clearTimeout(
|
|
80
|
-
},
|
|
81
|
-
} else
|
|
82
|
-
function
|
|
81
|
+
clearTimeout(a), M(t);
|
|
82
|
+
}, k);
|
|
83
|
+
} else T(function() {
|
|
84
|
+
function b() {
|
|
83
85
|
var o;
|
|
84
|
-
(o = c != -1 && h != -1 || c != -1 && f != -1 || h != -1 && f != -1) && ((o = c != h && c != f && h != f) || (
|
|
86
|
+
(o = c != -1 && h != -1 || c != -1 && f != -1 || h != -1 && f != -1) && ((o = c != h && c != f && h != f) || (P === null && (o = /AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent), P = !!o && (536 > parseInt(o[1], 10) || parseInt(o[1], 10) === 536 && 11 >= parseInt(o[2], 10))), o = P && (c == D && h == D && f == D || c == O && h == O && f == O || c == W && h == W && f == W)), o = !o), o && (l.parentNode !== null && l.parentNode.removeChild(l), clearTimeout(a), M(t));
|
|
85
87
|
}
|
|
86
|
-
function
|
|
87
|
-
if ((/* @__PURE__ */ new Date()).getTime() -
|
|
88
|
+
function x() {
|
|
89
|
+
if ((/* @__PURE__ */ new Date()).getTime() - z >= w) l.parentNode !== null && l.parentNode.removeChild(l), k(Error("" + w + "ms timeout exceeded"));
|
|
88
90
|
else {
|
|
89
91
|
var o = t.context.document.hidden;
|
|
90
|
-
(o === !0 || o === void 0) && (c = d.g.offsetWidth, h = m.g.offsetWidth, f =
|
|
92
|
+
(o === !0 || o === void 0) && (c = d.g.offsetWidth, h = m.g.offsetWidth, f = C.g.offsetWidth, b()), a = setTimeout(x, 50);
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
|
-
var d = new u
|
|
94
|
-
|
|
95
|
-
c = o,
|
|
96
|
-
}), r(d,
|
|
97
|
-
h = o,
|
|
98
|
-
}), r(m,
|
|
99
|
-
f = o,
|
|
100
|
-
}), r(
|
|
95
|
+
var d = new p(u), m = new p(u), C = new p(u), c = -1, h = -1, f = -1, D = -1, O = -1, W = -1, l = document.createElement("div");
|
|
96
|
+
l.dir = "ltr", r(d, g(t, "sans-serif")), r(m, g(t, "serif")), r(C, g(t, "monospace")), l.appendChild(d.g), l.appendChild(m.g), l.appendChild(C.g), t.context.document.body.appendChild(l), D = d.g.offsetWidth, O = m.g.offsetWidth, W = C.g.offsetWidth, x(), y(d, function(o) {
|
|
97
|
+
c = o, b();
|
|
98
|
+
}), r(d, g(t, '"' + t.family + '",sans-serif')), y(m, function(o) {
|
|
99
|
+
h = o, b();
|
|
100
|
+
}), r(m, g(t, '"' + t.family + '",serif')), y(C, function(o) {
|
|
101
|
+
f = o, b();
|
|
102
|
+
}), r(C, g(t, '"' + t.family + '",monospace'));
|
|
101
103
|
});
|
|
102
104
|
});
|
|
103
|
-
}, s.exports =
|
|
105
|
+
}, s.exports = N;
|
|
104
106
|
})();
|
|
105
|
-
}(
|
|
107
|
+
}(I)), I.exports;
|
|
106
108
|
}
|
|
107
|
-
var
|
|
108
|
-
const
|
|
109
|
-
var
|
|
110
|
-
for (var r =
|
|
111
|
-
(
|
|
112
|
-
return
|
|
109
|
+
var Z = Y();
|
|
110
|
+
const ee = /* @__PURE__ */ X(Z);
|
|
111
|
+
var te = Object.defineProperty, ne = Object.getOwnPropertyDescriptor, L = (s, i, T, p) => {
|
|
112
|
+
for (var r = p > 1 ? void 0 : p ? ne(i, T) : i, E = s.length - 1, y; E >= 0; E--)
|
|
113
|
+
(y = s[E]) && (r = (p ? y(i, T, r) : y(r)) || r);
|
|
114
|
+
return p && r && te(i, T, r), r;
|
|
113
115
|
};
|
|
114
|
-
let
|
|
116
|
+
let v = class extends U {
|
|
115
117
|
constructor() {
|
|
116
|
-
super(...arguments), this.library = "Sharp", this.name = "", this.iconLoaded = !1;
|
|
118
|
+
super(...arguments), this.library = "Sharp", this.name = "", this.src = "", this.alt = void 0, this.iconLoaded = !1;
|
|
117
119
|
}
|
|
118
120
|
firstUpdated() {
|
|
121
|
+
if (this.src) return;
|
|
119
122
|
if (!document.getElementById(`material-icons-${this.library.toLowerCase()}`)) {
|
|
120
123
|
const i = document.createElement("link");
|
|
121
124
|
i.id = `material-icons-${this.library.toLowerCase()}`, i.rel = "stylesheet", i.href = `https://fonts.googleapis.com/css2?family=Material+Symbols+${this.library}:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200`, document.head.appendChild(i);
|
|
122
125
|
}
|
|
123
|
-
new
|
|
126
|
+
new ee(`Material Symbols ${this.library}`).load().then(() => {
|
|
124
127
|
this.iconLoaded = !0, this.requestUpdate();
|
|
125
128
|
}).catch((i) => {
|
|
126
129
|
console.error("Failed to load the icon font:", i);
|
|
127
130
|
});
|
|
128
131
|
}
|
|
129
132
|
render() {
|
|
130
|
-
return this.
|
|
133
|
+
return this.src ? F`<img src=${this.src} alt=${V(this.alt)} />` : !this.src && this.iconLoaded ? F`<span
|
|
134
|
+
part="icon"
|
|
135
|
+
class=${Q({
|
|
136
|
+
"material-outlined": this.library === "Outlined",
|
|
137
|
+
"material-sharp": this.library === "Sharp"
|
|
138
|
+
})}
|
|
139
|
+
>${this.name}</span
|
|
140
|
+
>` : F`<nve-skeleton class="placeholder" effect="sheen"></nve-skeleton>`;
|
|
131
141
|
}
|
|
132
142
|
};
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
],
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
],
|
|
140
|
-
|
|
143
|
+
v.styles = [K];
|
|
144
|
+
L([
|
|
145
|
+
j()
|
|
146
|
+
], v.prototype, "library", 2);
|
|
147
|
+
L([
|
|
148
|
+
j({ type: String, reflect: !0 })
|
|
149
|
+
], v.prototype, "name", 2);
|
|
150
|
+
L([
|
|
151
|
+
j()
|
|
152
|
+
], v.prototype, "src", 2);
|
|
153
|
+
L([
|
|
154
|
+
j()
|
|
155
|
+
], v.prototype, "alt", 2);
|
|
156
|
+
L([
|
|
141
157
|
J()
|
|
142
|
-
],
|
|
143
|
-
|
|
158
|
+
], v.prototype, "iconLoaded", 2);
|
|
159
|
+
v = L([
|
|
144
160
|
H("nve-icon")
|
|
145
|
-
],
|
|
161
|
+
], v);
|
|
146
162
|
export {
|
|
147
|
-
|
|
163
|
+
v as default
|
|
148
164
|
};
|
|
@@ -8,30 +8,41 @@ const n = e`
|
|
|
8
8
|
|
|
9
9
|
/* prevent icon beeing highlighted */
|
|
10
10
|
:host {
|
|
11
|
+
display: flex;
|
|
12
|
+
user-select: none; /* Non-prefixed version, currently supported by Chrome, Edge, Opera and Firefox */
|
|
11
13
|
-webkit-touch-callout: none; /* iOS Safari */
|
|
12
14
|
-webkit-user-select: none; /* Safari */
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
user-select: none; /* Non-prefixed version, currently
|
|
17
|
-
supported by Chrome, Edge, Opera and Firefox */
|
|
15
|
+
--icon-size: 16px;
|
|
16
|
+
font-size: var(--icon-size);
|
|
17
|
+
line-height: var(--icon-size);
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
|
|
20
|
+
:is(img) {
|
|
21
|
+
width: var(--icon-size);
|
|
22
|
+
height: var(--icon-size);
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
/* we need it to center the icon */
|
|
24
26
|
:is(span) {
|
|
25
27
|
display: inline-flex;
|
|
26
|
-
|
|
28
|
+
font-size: inherit;
|
|
29
|
+
line-height: inherit;
|
|
27
30
|
font-weight: var(--font-weight-regular);
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
.placeholder::part(indicator) {
|
|
31
|
-
width:
|
|
32
|
-
height:
|
|
34
|
+
width: var(--icon-size);
|
|
35
|
+
height: var(--icon-size);
|
|
33
36
|
border-radius: 4px;
|
|
34
37
|
}
|
|
38
|
+
|
|
39
|
+
.material-outlined {
|
|
40
|
+
font-family: 'Material Symbols Outlined';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.material-sharp {
|
|
44
|
+
font-family: 'Material Symbols Sharp';
|
|
45
|
+
}
|
|
35
46
|
`;
|
|
36
47
|
export {
|
|
37
48
|
n as default
|