vue-toasts-lite 0.1.3 → 0.1.4
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/README.md +17 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +33 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -125,7 +125,23 @@ await toasts.promise(
|
|
|
125
125
|
|
|
126
126
|
## Styling
|
|
127
127
|
|
|
128
|
-
Customize colors and appearance with CSS variables
|
|
128
|
+
Customize colors and appearance with CSS variables or by passing custom classes to `ToastsLiteProvider`:
|
|
129
|
+
|
|
130
|
+
### Custom Classes
|
|
131
|
+
|
|
132
|
+
You can pass custom classes to `ToastsLiteProvider`:
|
|
133
|
+
|
|
134
|
+
```vue
|
|
135
|
+
<ToastsLiteProvider
|
|
136
|
+
container-class="custom-container"
|
|
137
|
+
wrapper-class="custom-wrapper"
|
|
138
|
+
item-class="custom-item"
|
|
139
|
+
/>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
- `container-class` - class for toast container
|
|
143
|
+
- `wrapper-class` - class for toast wrapper
|
|
144
|
+
- `item-class` - class for individual toast items
|
|
129
145
|
|
|
130
146
|
### CSS Variables
|
|
131
147
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { ComponentOptionsMixin } from 'vue';
|
|
2
2
|
import { ComponentProvideOptions } from 'vue';
|
|
3
3
|
import { DefineComponent } from 'vue';
|
|
4
|
+
import { HTMLAttributes } from 'vue';
|
|
4
5
|
import { PublicProps } from 'vue';
|
|
5
6
|
|
|
7
|
+
declare type __VLS_Props = {
|
|
8
|
+
containerClass?: HTMLAttributes["class"];
|
|
9
|
+
wrapperClass?: HTMLAttributes["class"];
|
|
10
|
+
itemClass?: HTMLAttributes["class"];
|
|
11
|
+
};
|
|
12
|
+
|
|
6
13
|
declare type Id = string;
|
|
7
14
|
|
|
8
15
|
declare interface IToastsController {
|
|
@@ -306,7 +313,7 @@ declare class ToastsController implements IToastsController {
|
|
|
306
313
|
|
|
307
314
|
export declare type ToastSimpleOptions = Partial<Omit<Toast, "message">>;
|
|
308
315
|
|
|
309
|
-
export declare const ToastsLiteProvider: DefineComponent<
|
|
316
|
+
export declare const ToastsLiteProvider: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
310
317
|
|
|
311
318
|
export declare type ToastType = "success" | "loading" | "error" | "warn";
|
|
312
319
|
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var M = Object.defineProperty;
|
|
2
2
|
var $ = (r, t, e) => t in r ? M(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
-
var
|
|
4
|
-
import { ref as h, defineComponent as
|
|
3
|
+
var m = (r, t, e) => $(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { ref as h, defineComponent as D, watch as L, onMounted as U, onUnmounted as k, createElementBlock as y, openBlock as d, withModifiers as A, normalizeStyle as E, createCommentVNode as x, createElementVNode as p, normalizeClass as g, toDisplayString as B, computed as P, createBlock as C, Teleport as I, Fragment as b, renderList as w, unref as v, createVNode as N, TransitionGroup as R, withCtx as S } from "vue";
|
|
5
5
|
class V extends Map {
|
|
6
6
|
constructor() {
|
|
7
7
|
super(...arguments);
|
|
8
|
-
|
|
8
|
+
m(this, "subscribers", []);
|
|
9
9
|
}
|
|
10
10
|
set(e, o) {
|
|
11
11
|
return super.set(e, o), this.notify(), this;
|
|
@@ -26,7 +26,7 @@ class V extends Map {
|
|
|
26
26
|
this.subscribers.forEach((e) => e(Array.from(this.values())));
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const T = {
|
|
30
30
|
type: "success",
|
|
31
31
|
message: "Hello from Toasts Lite",
|
|
32
32
|
autoClose: !0,
|
|
@@ -35,8 +35,8 @@ const w = {
|
|
|
35
35
|
};
|
|
36
36
|
class j {
|
|
37
37
|
constructor() {
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
m(this, "counter", 0);
|
|
39
|
+
m(this, "toasts");
|
|
40
40
|
this.toasts = new V();
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
@@ -292,15 +292,15 @@ class j {
|
|
|
292
292
|
return this.toasts.set(e, { ...this.mergeWithDefaultOptions(o), id: e }), e;
|
|
293
293
|
}
|
|
294
294
|
mergeWithDefaultOptions(t) {
|
|
295
|
-
const e = Object.assign({},
|
|
296
|
-
for (let o in
|
|
295
|
+
const e = Object.assign({}, T);
|
|
296
|
+
for (let o in T) {
|
|
297
297
|
const n = o, s = t[n];
|
|
298
298
|
s != null && (e[n] = s);
|
|
299
299
|
}
|
|
300
300
|
return e;
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
|
-
const
|
|
303
|
+
const O = new j();
|
|
304
304
|
function z() {
|
|
305
305
|
const r = h(/* @__PURE__ */ new Map());
|
|
306
306
|
function t(n, s, a) {
|
|
@@ -325,7 +325,7 @@ function z() {
|
|
|
325
325
|
const F = {
|
|
326
326
|
key: 0,
|
|
327
327
|
class: "toasts-lite__icon"
|
|
328
|
-
}, W = { class: "toasts-lite__content" }, G = { class: "toasts-lite__content-message" }, H = /* @__PURE__ */
|
|
328
|
+
}, W = { class: "toasts-lite__content" }, G = { class: "toasts-lite__content-message" }, H = /* @__PURE__ */ D({
|
|
329
329
|
__name: "ToastsLiteItem",
|
|
330
330
|
props: {
|
|
331
331
|
id: {},
|
|
@@ -362,14 +362,14 @@ const F = {
|
|
|
362
362
|
}), t({
|
|
363
363
|
pause: u,
|
|
364
364
|
resume: l
|
|
365
|
-
}), (_, J) => (d(),
|
|
365
|
+
}), (_, J) => (d(), y("div", {
|
|
366
366
|
class: "toasts-lite__toast",
|
|
367
367
|
style: E(`--toast-duration: ${r.duration}s;`),
|
|
368
368
|
onClick: A(c, ["prevent"])
|
|
369
369
|
}, [
|
|
370
|
-
["success", "error", "loading", "warn"].includes(r.type) ? (d(),
|
|
370
|
+
["success", "error", "loading", "warn"].includes(r.type) ? (d(), y("div", F, [
|
|
371
371
|
p("div", {
|
|
372
|
-
class:
|
|
372
|
+
class: g(`toasts-lite__${r.type}`)
|
|
373
373
|
}, null, 2)
|
|
374
374
|
])) : x("", !0),
|
|
375
375
|
p("div", W, [
|
|
@@ -377,11 +377,16 @@ const F = {
|
|
|
377
377
|
])
|
|
378
378
|
], 4));
|
|
379
379
|
}
|
|
380
|
-
}), q = ["onMouseenter", "onMouseleave"], X = /* @__PURE__ */
|
|
380
|
+
}), q = ["onMouseenter", "onMouseleave"], X = /* @__PURE__ */ D({
|
|
381
381
|
__name: "ToastsLiteProvider",
|
|
382
|
+
props: {
|
|
383
|
+
containerClass: {},
|
|
384
|
+
wrapperClass: {},
|
|
385
|
+
itemClass: {}
|
|
386
|
+
},
|
|
382
387
|
setup(r) {
|
|
383
388
|
const t = ["top-left", "top-center", "top-right", "middle-center", "bottom-left", "bottom-center", "bottom-right"], e = h([]), { setRef: o, pauseAll: n, resumeAll: s } = z();
|
|
384
|
-
|
|
389
|
+
O.onToastsListChange((i) => {
|
|
385
390
|
e.value = i;
|
|
386
391
|
});
|
|
387
392
|
const a = P(() => {
|
|
@@ -391,42 +396,43 @@ const F = {
|
|
|
391
396
|
i.has(u) || i.set(u, []), i.get(u).push(c);
|
|
392
397
|
}), i;
|
|
393
398
|
});
|
|
394
|
-
return (i, c) => (d(),
|
|
395
|
-
(d(),
|
|
399
|
+
return (i, c) => (d(), C(I, { to: "body" }, [
|
|
400
|
+
(d(), y(b, null, w(t, (u) => p("div", {
|
|
396
401
|
key: u,
|
|
397
|
-
class:
|
|
402
|
+
class: g(["toasts-lite__toast-container", [r.containerClass, `toasts-lite__${u}`]])
|
|
398
403
|
}, [
|
|
399
404
|
p("div", {
|
|
400
|
-
class: "toasts-lite__toast-wrapper",
|
|
401
|
-
onMouseenter: (l) =>
|
|
402
|
-
onMouseleave: (l) =>
|
|
405
|
+
class: g(["toasts-lite__toast-wrapper", r.wrapperClass]),
|
|
406
|
+
onMouseenter: (l) => v(n)(u),
|
|
407
|
+
onMouseleave: (l) => v(s)(u)
|
|
403
408
|
}, [
|
|
404
409
|
N(R, {
|
|
405
410
|
name: "toasts-lite",
|
|
406
411
|
appear: ""
|
|
407
412
|
}, {
|
|
408
413
|
default: S(() => [
|
|
409
|
-
(d(!0),
|
|
414
|
+
(d(!0), y(b, null, w(a.value.get(u) || [], (l, f) => (d(), C(H, {
|
|
410
415
|
id: l.id,
|
|
411
416
|
ref_for: !0,
|
|
412
|
-
ref: (_) =>
|
|
417
|
+
ref: (_) => v(o)(u, f, _),
|
|
413
418
|
key: l.id,
|
|
414
419
|
type: l.type,
|
|
415
420
|
message: l.message,
|
|
416
421
|
"auto-close": l.autoClose,
|
|
417
422
|
duration: l.duration,
|
|
418
423
|
position: l.position,
|
|
419
|
-
|
|
420
|
-
|
|
424
|
+
class: g(r.itemClass),
|
|
425
|
+
onClose: (_) => v(O).remove(l.id)
|
|
426
|
+
}, null, 8, ["id", "type", "message", "auto-close", "duration", "position", "class", "onClose"]))), 128))
|
|
421
427
|
]),
|
|
422
428
|
_: 2
|
|
423
429
|
}, 1024)
|
|
424
|
-
],
|
|
430
|
+
], 42, q)
|
|
425
431
|
], 2)), 64))
|
|
426
432
|
]));
|
|
427
433
|
}
|
|
428
434
|
});
|
|
429
435
|
export {
|
|
430
436
|
X as ToastsLiteProvider,
|
|
431
|
-
|
|
437
|
+
O as toasts
|
|
432
438
|
};
|