nve-designsystem 0.3.1 → 0.3.3
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/chunk.FBL77HIN.js +229 -0
- package/components/nve-accordion/nve-accordion.component.d.ts +15 -0
- package/components/nve-accordion/nve-accordion.component.js +29 -0
- package/components/nve-accordion/nve-accordion.styles.d.ts +2 -0
- package/components/nve-accordion/nve-accordion.styles.js +5 -0
- package/components/nve-radio-group/nve-radio-group.styles.js +1 -1
- package/components/nve-relative-time/nve-relative-time.component.js +1368 -1583
- package/custom-elements.json +387 -72
- package/nve-designsystem.d.ts +1 -0
- package/nve-designsystem.js +60 -58
- package/package.json +1 -1
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { i as m, k as u } from "./lit-element.js";
|
|
2
|
+
import { s as p, a as r, g as d, b as n, c as h, w as c } from "./chunk.LHI6QEL2.js";
|
|
3
|
+
import { L as y } from "./chunk.WLV3FVBR.js";
|
|
4
|
+
import { S as f } from "./chunk.ALSPWWWG.js";
|
|
5
|
+
import { w as b } from "./chunk.2FB5TK5H.js";
|
|
6
|
+
import { c as _, b as s, S as w } from "./chunk.5THGRZAA.js";
|
|
7
|
+
import { R as g } from "./class-map.js";
|
|
8
|
+
import { n as l } from "./property.js";
|
|
9
|
+
import { e as a } from "./query.js";
|
|
10
|
+
var v = m`
|
|
11
|
+
:host {
|
|
12
|
+
display: block;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.details {
|
|
16
|
+
border: solid 1px var(--sl-color-neutral-200);
|
|
17
|
+
border-radius: var(--sl-border-radius-medium);
|
|
18
|
+
background-color: var(--sl-color-neutral-0);
|
|
19
|
+
overflow-anchor: none;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.details--disabled {
|
|
23
|
+
opacity: 0.5;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.details__header {
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
border-radius: inherit;
|
|
30
|
+
padding: var(--sl-spacing-medium);
|
|
31
|
+
user-select: none;
|
|
32
|
+
-webkit-user-select: none;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.details__header::-webkit-details-marker {
|
|
37
|
+
display: none;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.details__header:focus {
|
|
41
|
+
outline: none;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.details__header:focus-visible {
|
|
45
|
+
outline: var(--sl-focus-ring);
|
|
46
|
+
outline-offset: calc(1px + var(--sl-focus-ring-offset));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.details--disabled .details__header {
|
|
50
|
+
cursor: not-allowed;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.details--disabled .details__header:focus-visible {
|
|
54
|
+
outline: none;
|
|
55
|
+
box-shadow: none;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.details__summary {
|
|
59
|
+
flex: 1 1 auto;
|
|
60
|
+
display: flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.details__summary-icon {
|
|
65
|
+
flex: 0 0 auto;
|
|
66
|
+
display: flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
transition: var(--sl-transition-medium) rotate ease;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.details--open .details__summary-icon {
|
|
72
|
+
rotate: 90deg;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.details--open.details--rtl .details__summary-icon {
|
|
76
|
+
rotate: -90deg;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.details--open slot[name='expand-icon'],
|
|
80
|
+
.details:not(.details--open) slot[name='collapse-icon'] {
|
|
81
|
+
display: none;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.details__body {
|
|
85
|
+
overflow: hidden;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.details__content {
|
|
89
|
+
display: block;
|
|
90
|
+
padding: var(--sl-spacing-medium);
|
|
91
|
+
}
|
|
92
|
+
`, t = class extends w {
|
|
93
|
+
constructor() {
|
|
94
|
+
super(...arguments), this.localize = new y(this), this.open = !1, this.disabled = !1;
|
|
95
|
+
}
|
|
96
|
+
firstUpdated() {
|
|
97
|
+
this.body.style.height = this.open ? "auto" : "0", this.open && (this.details.open = !0), this.detailsObserver = new MutationObserver((e) => {
|
|
98
|
+
for (const i of e)
|
|
99
|
+
i.type === "attributes" && i.attributeName === "open" && (this.details.open ? this.show() : this.hide());
|
|
100
|
+
}), this.detailsObserver.observe(this.details, { attributes: !0 });
|
|
101
|
+
}
|
|
102
|
+
disconnectedCallback() {
|
|
103
|
+
super.disconnectedCallback(), this.detailsObserver.disconnect();
|
|
104
|
+
}
|
|
105
|
+
handleSummaryClick(e) {
|
|
106
|
+
e.preventDefault(), this.disabled || (this.open ? this.hide() : this.show(), this.header.focus());
|
|
107
|
+
}
|
|
108
|
+
handleSummaryKeyDown(e) {
|
|
109
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), this.open ? this.hide() : this.show()), (e.key === "ArrowUp" || e.key === "ArrowLeft") && (e.preventDefault(), this.hide()), (e.key === "ArrowDown" || e.key === "ArrowRight") && (e.preventDefault(), this.show());
|
|
110
|
+
}
|
|
111
|
+
async handleOpenChange() {
|
|
112
|
+
if (this.open) {
|
|
113
|
+
if (this.details.open = !0, this.emit("sl-show", { cancelable: !0 }).defaultPrevented) {
|
|
114
|
+
this.open = !1, this.details.open = !1;
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
await r(this.body);
|
|
118
|
+
const { keyframes: i, options: o } = d(this, "details.show", { dir: this.localize.dir() });
|
|
119
|
+
await n(this.body, h(i, this.body.scrollHeight), o), this.body.style.height = "auto", this.emit("sl-after-show");
|
|
120
|
+
} else {
|
|
121
|
+
if (this.emit("sl-hide", { cancelable: !0 }).defaultPrevented) {
|
|
122
|
+
this.details.open = !0, this.open = !0;
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
await r(this.body);
|
|
126
|
+
const { keyframes: i, options: o } = d(this, "details.hide", { dir: this.localize.dir() });
|
|
127
|
+
await n(this.body, h(i, this.body.scrollHeight), o), this.body.style.height = "auto", this.details.open = !1, this.emit("sl-after-hide");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/** Shows the details. */
|
|
131
|
+
async show() {
|
|
132
|
+
if (!(this.open || this.disabled))
|
|
133
|
+
return this.open = !0, c(this, "sl-after-show");
|
|
134
|
+
}
|
|
135
|
+
/** Hides the details */
|
|
136
|
+
async hide() {
|
|
137
|
+
if (!(!this.open || this.disabled))
|
|
138
|
+
return this.open = !1, c(this, "sl-after-hide");
|
|
139
|
+
}
|
|
140
|
+
render() {
|
|
141
|
+
const e = this.matches(":dir(rtl)");
|
|
142
|
+
return u`
|
|
143
|
+
<details
|
|
144
|
+
part="base"
|
|
145
|
+
class=${g({
|
|
146
|
+
details: !0,
|
|
147
|
+
"details--open": this.open,
|
|
148
|
+
"details--disabled": this.disabled,
|
|
149
|
+
"details--rtl": e
|
|
150
|
+
})}
|
|
151
|
+
>
|
|
152
|
+
<summary
|
|
153
|
+
part="header"
|
|
154
|
+
id="header"
|
|
155
|
+
class="details__header"
|
|
156
|
+
role="button"
|
|
157
|
+
aria-expanded=${this.open ? "true" : "false"}
|
|
158
|
+
aria-controls="content"
|
|
159
|
+
aria-disabled=${this.disabled ? "true" : "false"}
|
|
160
|
+
tabindex=${this.disabled ? "-1" : "0"}
|
|
161
|
+
@click=${this.handleSummaryClick}
|
|
162
|
+
@keydown=${this.handleSummaryKeyDown}
|
|
163
|
+
>
|
|
164
|
+
<slot name="summary" part="summary" class="details__summary">${this.summary}</slot>
|
|
165
|
+
|
|
166
|
+
<span part="summary-icon" class="details__summary-icon">
|
|
167
|
+
<slot name="expand-icon">
|
|
168
|
+
<sl-icon library="system" name=${e ? "chevron-left" : "chevron-right"}></sl-icon>
|
|
169
|
+
</slot>
|
|
170
|
+
<slot name="collapse-icon">
|
|
171
|
+
<sl-icon library="system" name=${e ? "chevron-left" : "chevron-right"}></sl-icon>
|
|
172
|
+
</slot>
|
|
173
|
+
</span>
|
|
174
|
+
</summary>
|
|
175
|
+
|
|
176
|
+
<div class="details__body" role="region" aria-labelledby="header">
|
|
177
|
+
<slot part="content" id="content" class="details__content"></slot>
|
|
178
|
+
</div>
|
|
179
|
+
</details>
|
|
180
|
+
`;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
t.styles = [_, v];
|
|
184
|
+
t.dependencies = {
|
|
185
|
+
"sl-icon": f
|
|
186
|
+
};
|
|
187
|
+
s([
|
|
188
|
+
a(".details")
|
|
189
|
+
], t.prototype, "details", 2);
|
|
190
|
+
s([
|
|
191
|
+
a(".details__header")
|
|
192
|
+
], t.prototype, "header", 2);
|
|
193
|
+
s([
|
|
194
|
+
a(".details__body")
|
|
195
|
+
], t.prototype, "body", 2);
|
|
196
|
+
s([
|
|
197
|
+
a(".details__expand-icon-slot")
|
|
198
|
+
], t.prototype, "expandIconSlot", 2);
|
|
199
|
+
s([
|
|
200
|
+
l({ type: Boolean, reflect: !0 })
|
|
201
|
+
], t.prototype, "open", 2);
|
|
202
|
+
s([
|
|
203
|
+
l()
|
|
204
|
+
], t.prototype, "summary", 2);
|
|
205
|
+
s([
|
|
206
|
+
l({ type: Boolean, reflect: !0 })
|
|
207
|
+
], t.prototype, "disabled", 2);
|
|
208
|
+
s([
|
|
209
|
+
b("open", { waitUntilFirstUpdate: !0 })
|
|
210
|
+
], t.prototype, "handleOpenChange", 1);
|
|
211
|
+
p("details.show", {
|
|
212
|
+
keyframes: [
|
|
213
|
+
{ height: "0", opacity: "0" },
|
|
214
|
+
{ height: "auto", opacity: "1" }
|
|
215
|
+
],
|
|
216
|
+
options: { duration: 250, easing: "linear" }
|
|
217
|
+
});
|
|
218
|
+
p("details.hide", {
|
|
219
|
+
keyframes: [
|
|
220
|
+
{ height: "auto", opacity: "1" },
|
|
221
|
+
{ height: "0", opacity: "0" }
|
|
222
|
+
],
|
|
223
|
+
options: { duration: 250, easing: "linear" }
|
|
224
|
+
});
|
|
225
|
+
var z = t;
|
|
226
|
+
t.define("sl-details");
|
|
227
|
+
export {
|
|
228
|
+
z as d
|
|
229
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { INveComponent } from '../../interfaces/NveComponent.interface';
|
|
2
|
+
import { default as SlDetails } from '@shoelace-style/shoelace/dist/components/details/details.js';
|
|
3
|
+
/**
|
|
4
|
+
* Viser et kort sammendrag og utvides for å vise ekstra innhold.
|
|
5
|
+
*/
|
|
6
|
+
export default class NveAccordion extends SlDetails implements INveComponent {
|
|
7
|
+
testId: string | undefined;
|
|
8
|
+
static styles: import('lit').CSSResultGroup[];
|
|
9
|
+
constructor();
|
|
10
|
+
}
|
|
11
|
+
declare global {
|
|
12
|
+
interface HTMLElementTagNameMap {
|
|
13
|
+
'nve-accordion': NveAccordion;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { n as m, t as n } from "../../chunks/property.js";
|
|
2
|
+
import v from "./nve-accordion.styles.js";
|
|
3
|
+
import { d as f } from "../../chunks/chunk.FBL77HIN.js";
|
|
4
|
+
import "../../chunks/chunk.WLV3FVBR.js";
|
|
5
|
+
import "../../chunks/chunk.ALSPWWWG.js";
|
|
6
|
+
import "../../chunks/chunk.5THGRZAA.js";
|
|
7
|
+
var a = Object.defineProperty, d = Object.getOwnPropertyDescriptor, c = (l, e, s, r) => {
|
|
8
|
+
for (var t = r > 1 ? void 0 : r ? d(e, s) : e, p = l.length - 1, i; p >= 0; p--)
|
|
9
|
+
(i = l[p]) && (t = (r ? i(e, s, t) : i(t)) || t);
|
|
10
|
+
return r && t && a(e, s, t), t;
|
|
11
|
+
};
|
|
12
|
+
let o = class extends f {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(), this.testId = void 0;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
o.styles = [
|
|
18
|
+
f.styles,
|
|
19
|
+
v
|
|
20
|
+
];
|
|
21
|
+
c([
|
|
22
|
+
m({ reflect: !0, type: String })
|
|
23
|
+
], o.prototype, "testId", 2);
|
|
24
|
+
o = c([
|
|
25
|
+
n("nve-accordion")
|
|
26
|
+
], o);
|
|
27
|
+
export {
|
|
28
|
+
o as default
|
|
29
|
+
};
|