nve-designsystem 2.0.2 → 2.2.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,343 +0,0 @@
1
- import { b as g } from "./chunk.LD4M4QGE.js";
2
- import { S as w } from "./chunk.7E4JTYWU.js";
3
- import { s as u, g as n } from "./chunk.K7JGTRV7.js";
4
- import { s as l, a as c, w as d } from "./chunk.B4BZKR24.js";
5
- import { H as _ } from "./chunk.NYIIDP5N.js";
6
- import { L as b } from "./chunk.6CTB5ZDJ.js";
7
- import { a as y, x as s } from "./lit-element.js";
8
- import { w as m } from "./chunk.GMYPQTFK.js";
9
- import { c as k, d as a, S as T } from "./chunk.4TUIT776.js";
10
- import { e as h } from "./class-map.js";
11
- import { n as i } from "./property.js";
12
- import { r as S } from "./state.js";
13
- import { e as p } from "./query.js";
14
- var C = y`
15
- :host {
16
- display: contents;
17
-
18
- /* For better DX, we'll reset the margin here so the base part can inherit it */
19
- margin: 0;
20
- }
21
-
22
- .alert {
23
- position: relative;
24
- display: flex;
25
- align-items: stretch;
26
- background-color: var(--sl-panel-background-color);
27
- border: solid var(--sl-panel-border-width) var(--sl-panel-border-color);
28
- border-top-width: calc(var(--sl-panel-border-width) * 3);
29
- border-radius: var(--sl-border-radius-medium);
30
- font-family: var(--sl-font-sans);
31
- font-size: var(--sl-font-size-small);
32
- font-weight: var(--sl-font-weight-normal);
33
- line-height: 1.6;
34
- color: var(--sl-color-neutral-700);
35
- margin: inherit;
36
- overflow: hidden;
37
- }
38
-
39
- .alert:not(.alert--has-icon) .alert__icon,
40
- .alert:not(.alert--closable) .alert__close-button {
41
- display: none;
42
- }
43
-
44
- .alert__icon {
45
- flex: 0 0 auto;
46
- display: flex;
47
- align-items: center;
48
- font-size: var(--sl-font-size-large);
49
- padding-inline-start: var(--sl-spacing-large);
50
- }
51
-
52
- .alert--has-countdown {
53
- border-bottom: none;
54
- }
55
-
56
- .alert--primary {
57
- border-top-color: var(--sl-color-primary-600);
58
- }
59
-
60
- .alert--primary .alert__icon {
61
- color: var(--sl-color-primary-600);
62
- }
63
-
64
- .alert--success {
65
- border-top-color: var(--sl-color-success-600);
66
- }
67
-
68
- .alert--success .alert__icon {
69
- color: var(--sl-color-success-600);
70
- }
71
-
72
- .alert--neutral {
73
- border-top-color: var(--sl-color-neutral-600);
74
- }
75
-
76
- .alert--neutral .alert__icon {
77
- color: var(--sl-color-neutral-600);
78
- }
79
-
80
- .alert--warning {
81
- border-top-color: var(--sl-color-warning-600);
82
- }
83
-
84
- .alert--warning .alert__icon {
85
- color: var(--sl-color-warning-600);
86
- }
87
-
88
- .alert--danger {
89
- border-top-color: var(--sl-color-danger-600);
90
- }
91
-
92
- .alert--danger .alert__icon {
93
- color: var(--sl-color-danger-600);
94
- }
95
-
96
- .alert__message {
97
- flex: 1 1 auto;
98
- display: block;
99
- padding: var(--sl-spacing-large);
100
- overflow: hidden;
101
- }
102
-
103
- .alert__close-button {
104
- flex: 0 0 auto;
105
- display: flex;
106
- align-items: center;
107
- font-size: var(--sl-font-size-medium);
108
- margin-inline-end: var(--sl-spacing-medium);
109
- align-self: center;
110
- }
111
-
112
- .alert__countdown {
113
- position: absolute;
114
- bottom: 0;
115
- left: 0;
116
- width: 100%;
117
- height: calc(var(--sl-panel-border-width) * 3);
118
- background-color: var(--sl-panel-border-color);
119
- display: flex;
120
- }
121
-
122
- .alert__countdown--ltr {
123
- justify-content: flex-end;
124
- }
125
-
126
- .alert__countdown .alert__countdown-elapsed {
127
- height: 100%;
128
- width: 0;
129
- }
130
-
131
- .alert--primary .alert__countdown-elapsed {
132
- background-color: var(--sl-color-primary-600);
133
- }
134
-
135
- .alert--success .alert__countdown-elapsed {
136
- background-color: var(--sl-color-success-600);
137
- }
138
-
139
- .alert--neutral .alert__countdown-elapsed {
140
- background-color: var(--sl-color-neutral-600);
141
- }
142
-
143
- .alert--warning .alert__countdown-elapsed {
144
- background-color: var(--sl-color-warning-600);
145
- }
146
-
147
- .alert--danger .alert__countdown-elapsed {
148
- background-color: var(--sl-color-danger-600);
149
- }
150
-
151
- .alert__timer {
152
- display: none;
153
- }
154
- `, e = class r extends T {
155
- constructor() {
156
- super(...arguments), this.hasSlotController = new _(this, "icon", "suffix"), this.localize = new b(this), this.open = !1, this.closable = !1, this.variant = "primary", this.duration = 1 / 0, this.remainingTime = this.duration;
157
- }
158
- static get toastStack() {
159
- return this.currentToastStack || (this.currentToastStack = Object.assign(document.createElement("div"), {
160
- className: "sl-toast-stack"
161
- })), this.currentToastStack;
162
- }
163
- firstUpdated() {
164
- this.base.hidden = !this.open;
165
- }
166
- restartAutoHide() {
167
- this.handleCountdownChange(), clearTimeout(this.autoHideTimeout), clearInterval(this.remainingTimeInterval), this.open && this.duration < 1 / 0 && (this.autoHideTimeout = window.setTimeout(() => this.hide(), this.duration), this.remainingTime = this.duration, this.remainingTimeInterval = window.setInterval(() => {
168
- this.remainingTime -= 100;
169
- }, 100));
170
- }
171
- pauseAutoHide() {
172
- var t;
173
- (t = this.countdownAnimation) == null || t.pause(), clearTimeout(this.autoHideTimeout), clearInterval(this.remainingTimeInterval);
174
- }
175
- resumeAutoHide() {
176
- var t;
177
- this.duration < 1 / 0 && (this.autoHideTimeout = window.setTimeout(() => this.hide(), this.remainingTime), this.remainingTimeInterval = window.setInterval(() => {
178
- this.remainingTime -= 100;
179
- }, 100), (t = this.countdownAnimation) == null || t.play());
180
- }
181
- handleCountdownChange() {
182
- if (this.open && this.duration < 1 / 0 && this.countdown) {
183
- const { countdownElement: t } = this, o = "100%", f = "0";
184
- this.countdownAnimation = t.animate([{ width: o }, { width: f }], {
185
- duration: this.duration,
186
- easing: "linear"
187
- });
188
- }
189
- }
190
- handleCloseClick() {
191
- this.hide();
192
- }
193
- async handleOpenChange() {
194
- if (this.open) {
195
- this.emit("sl-show"), this.duration < 1 / 0 && this.restartAutoHide(), await l(this.base), this.base.hidden = !1;
196
- const { keyframes: t, options: o } = n(this, "alert.show", { dir: this.localize.dir() });
197
- await c(this.base, t, o), this.emit("sl-after-show");
198
- } else {
199
- g(this), this.emit("sl-hide"), clearTimeout(this.autoHideTimeout), clearInterval(this.remainingTimeInterval), await l(this.base);
200
- const { keyframes: t, options: o } = n(this, "alert.hide", { dir: this.localize.dir() });
201
- await c(this.base, t, o), this.base.hidden = !0, this.emit("sl-after-hide");
202
- }
203
- }
204
- handleDurationChange() {
205
- this.restartAutoHide();
206
- }
207
- /** Shows the alert. */
208
- async show() {
209
- if (!this.open)
210
- return this.open = !0, d(this, "sl-after-show");
211
- }
212
- /** Hides the alert */
213
- async hide() {
214
- if (this.open)
215
- return this.open = !1, d(this, "sl-after-hide");
216
- }
217
- /**
218
- * Displays the alert as a toast notification. This will move the alert out of its position in the DOM and, when
219
- * dismissed, it will be removed from the DOM completely. By storing a reference to the alert, you can reuse it by
220
- * calling this method again. The returned promise will resolve after the alert is hidden.
221
- */
222
- async toast() {
223
- return new Promise((t) => {
224
- this.handleCountdownChange(), r.toastStack.parentElement === null && document.body.append(r.toastStack), r.toastStack.appendChild(this), requestAnimationFrame(() => {
225
- this.clientWidth, this.show();
226
- }), this.addEventListener(
227
- "sl-after-hide",
228
- () => {
229
- r.toastStack.removeChild(this), t(), r.toastStack.querySelector("sl-alert") === null && r.toastStack.remove();
230
- },
231
- { once: !0 }
232
- );
233
- });
234
- }
235
- render() {
236
- return s`
237
- <div
238
- part="base"
239
- class=${h({
240
- alert: !0,
241
- "alert--open": this.open,
242
- "alert--closable": this.closable,
243
- "alert--has-countdown": !!this.countdown,
244
- "alert--has-icon": this.hasSlotController.test("icon"),
245
- "alert--primary": this.variant === "primary",
246
- "alert--success": this.variant === "success",
247
- "alert--neutral": this.variant === "neutral",
248
- "alert--warning": this.variant === "warning",
249
- "alert--danger": this.variant === "danger"
250
- })}
251
- role="alert"
252
- aria-hidden=${this.open ? "false" : "true"}
253
- @mouseenter=${this.pauseAutoHide}
254
- @mouseleave=${this.resumeAutoHide}
255
- >
256
- <div part="icon" class="alert__icon">
257
- <slot name="icon"></slot>
258
- </div>
259
-
260
- <div part="message" class="alert__message" aria-live="polite">
261
- <slot></slot>
262
- </div>
263
-
264
- ${this.closable ? s`
265
- <sl-icon-button
266
- part="close-button"
267
- exportparts="base:close-button__base"
268
- class="alert__close-button"
269
- name="x-lg"
270
- library="system"
271
- label=${this.localize.term("close")}
272
- @click=${this.handleCloseClick}
273
- ></sl-icon-button>
274
- ` : ""}
275
-
276
- <div role="timer" class="alert__timer">${this.remainingTime}</div>
277
-
278
- ${this.countdown ? s`
279
- <div
280
- class=${h({
281
- alert__countdown: !0,
282
- "alert__countdown--ltr": this.countdown === "ltr"
283
- })}
284
- >
285
- <div class="alert__countdown-elapsed"></div>
286
- </div>
287
- ` : ""}
288
- </div>
289
- `;
290
- }
291
- };
292
- e.styles = [k, C];
293
- e.dependencies = { "sl-icon-button": w };
294
- a([
295
- p('[part~="base"]')
296
- ], e.prototype, "base", 2);
297
- a([
298
- p(".alert__countdown-elapsed")
299
- ], e.prototype, "countdownElement", 2);
300
- a([
301
- i({ type: Boolean, reflect: !0 })
302
- ], e.prototype, "open", 2);
303
- a([
304
- i({ type: Boolean, reflect: !0 })
305
- ], e.prototype, "closable", 2);
306
- a([
307
- i({ reflect: !0 })
308
- ], e.prototype, "variant", 2);
309
- a([
310
- i({ type: Number })
311
- ], e.prototype, "duration", 2);
312
- a([
313
- i({ type: String, reflect: !0 })
314
- ], e.prototype, "countdown", 2);
315
- a([
316
- S()
317
- ], e.prototype, "remainingTime", 2);
318
- a([
319
- m("open", { waitUntilFirstUpdate: !0 })
320
- ], e.prototype, "handleOpenChange", 1);
321
- a([
322
- m("duration")
323
- ], e.prototype, "handleDurationChange", 1);
324
- var v = e;
325
- u("alert.show", {
326
- keyframes: [
327
- { opacity: 0, scale: 0.8 },
328
- { opacity: 1, scale: 1 }
329
- ],
330
- options: { duration: 250, easing: "ease" }
331
- });
332
- u("alert.hide", {
333
- keyframes: [
334
- { opacity: 1, scale: 1 },
335
- { opacity: 0, scale: 0.8 }
336
- ],
337
- options: { duration: 250, easing: "ease" }
338
- });
339
- var j = v;
340
- v.define("sl-alert");
341
- export {
342
- j as a
343
- };