lkt-toast 1.1.4 → 1.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.
package/dist/build.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- declare function $(e: any): void;
2
- declare namespace se {
3
- function install(e: any): void;
1
+ import { closeToast as oe } from "lkt-vue-kernel";
2
+ declare namespace Z {
3
+ function install(t: any): void;
4
4
  }
5
- declare function te(e: any): void;
6
- declare function ne(e: any): void;
7
- export { $ as closeToast, se as default, te as openToast, ne as setToastCanvas };
5
+ import { openToast as ne } from "lkt-vue-kernel";
6
+ declare function ee(t: any): void;
7
+ export { oe as closeToast, Z as default, ne as openToast, ee as setToastCanvas };
package/dist/build.js CHANGED
@@ -1,38 +1,12 @@
1
- import { defineComponent as D, mergeDefaults as N, ref as m, computed as c, onMounted as w, resolveComponent as E, createElementBlock as p, openBlock as l, normalizeClass as k, createElementVNode as r, createVNode as U, createBlock as C, createCommentVNode as j, unref as M, getCurrentInstance as A, Fragment as R, renderList as V, mergeProps as X } from "vue";
2
- import { extractI18nValue as P, LktSettings as F, getDefaultValues as S, Toast as q } from "lkt-vue-kernel";
3
- const z = class z {
4
- };
5
- z.canvas = void 0, z.defaultCloseIcon = "";
6
- let f = z;
7
- const a = class a {
8
- static open(s) {
9
- a.components.push({ ...s, zIndex: a.zIndex }), ++a.zIndex;
10
- }
11
- static close(s) {
12
- const n = a.components.findIndex((u) => u.zIndex === s);
13
- n >= 0 && (a.components.splice(n, 1), a.components.length === 0 && (a.zIndex = 1e3));
14
- }
15
- };
16
- a.components = [], a.zIndex = 1e3;
17
- let v = a;
18
- const te = (e) => {
19
- if (!f.canvas) {
20
- console.warn("ToastCanvas not defined");
21
- return;
22
- }
23
- v.open(e), f.canvas.refresh();
24
- }, $ = (e) => {
25
- if (!f.canvas) {
26
- console.warn("ToastCanvas not defined");
27
- return;
28
- }
29
- v.close(e), f.canvas.refresh();
30
- }, G = {
1
+ import { defineComponent as H, mergeDefaults as D, ref as m, computed as r, onMounted as $, resolveComponent as z, createElementBlock as d, openBlock as n, normalizeClass as v, createElementVNode as o, createVNode as S, createBlock as h, createCommentVNode as B, unref as i, mergeProps as T, getCurrentInstance as E, Fragment as V, renderList as R } from "vue";
2
+ import { extractI18nValue as P, LktSettings as F, closeToast as b, ProgressValueFormat as N, ProgressAnimation as A, getDefaultValues as U, Toast as j, ToastController as y } from "lkt-vue-kernel";
3
+ import { closeToast as oe, openToast as ne } from "lkt-vue-kernel";
4
+ const O = {
31
5
  class: "lkt-toast-inner",
32
6
  ref: "inner"
33
- }, J = { class: "lkt-toast-header" }, K = { class: "lkt-toast-header-text" }, O = ["innerHTML"], Q = ["innerHTML"], T = /* @__PURE__ */ D({
7
+ }, q = { class: "lkt-toast-header" }, w = { class: "lkt-toast-header-text" }, G = ["innerHTML"], J = ["innerHTML"], L = /* @__PURE__ */ H({
34
8
  __name: "LktToast",
35
- props: /* @__PURE__ */ N({
9
+ props: /* @__PURE__ */ D({
36
10
  type: {},
37
11
  text: {},
38
12
  details: {},
@@ -41,127 +15,136 @@ const te = (e) => {
41
15
  duration: {},
42
16
  buttonConfig: {},
43
17
  zIndex: {}
44
- }, S(q)),
45
- setup(e) {
46
- const s = e, n = m(100), u = s.duration ?? 1e4, d = m(null), h = m(!1), g = c(() => {
47
- let i = [];
48
- return h.value && i.push("is-visible"), s.positionX && i.push(`animation-${s.positionX}`), i.join(" ");
49
- }), x = c(() => P(s.text)), _ = c(() => P(s.details)), L = F.defaultCloseToastIcon, y = () => {
50
- $(s.zIndex);
51
- }, I = () => {
52
- d.value.pause();
53
- }, o = () => {
54
- d.value.start();
18
+ }, U(j)),
19
+ setup(t) {
20
+ const a = t, l = m(100), u = a.duration ?? 1e4, c = m(null), p = m(!1), k = r(() => {
21
+ let e = [];
22
+ return p.value && e.push("is-visible"), a.positionX && e.push(`animation-${a.positionX}`), e.join(" ");
23
+ }), _ = r(() => P(a.text)), g = r(() => P(a.details)), I = F.defaultCloseToastIcon, x = () => {
24
+ c.value.pause();
25
+ }, M = () => {
26
+ c.value.start();
55
27
  };
56
- return w(() => {
28
+ return $(() => {
57
29
  setTimeout(() => {
58
- h.value = !0;
30
+ p.value = !0;
59
31
  }, 100);
60
- }), (i, t) => {
61
- const H = E("lkt-icon"), B = E("lkt-progress");
62
- return l(), p("section", {
63
- class: k(["lkt-toast", g.value]),
32
+ }), (e, f) => {
33
+ const s = z("lkt-icon"), X = z("lkt-progress");
34
+ return n(), d("section", {
35
+ class: v(["lkt-toast", k.value]),
64
36
  role: "status",
65
37
  "aria-live": "polite",
66
38
  "aria-atomic": "true",
67
- onMouseenter: I,
68
- onMousemove: I,
69
- onMouseleave: o
39
+ onMouseenter: x,
40
+ onMousemove: x,
41
+ onMouseleave: M
70
42
  }, [
71
- r("div", G, [
72
- r("div", J, [
73
- r("div", K, [
74
- i.icon ? (l(), C(H, {
43
+ o("div", O, [
44
+ o("div", q, [
45
+ o("div", w, [
46
+ t.icon ? (n(), h(s, {
75
47
  key: 0,
76
- icon: i.icon
77
- }, null, 8, ["icon"])) : j("", !0),
78
- r("div", {
48
+ icon: t.icon
49
+ }, null, 8, ["icon"])) : B("", !0),
50
+ o("div", {
79
51
  class: "lkt-toast-text",
80
- innerHTML: x.value
81
- }, null, 8, O)
52
+ innerHTML: _.value
53
+ }, null, 8, G)
82
54
  ]),
83
- r("div", {
55
+ o("div", {
84
56
  class: "lkt-toast-close",
85
- onClick: t[0] || (t[0] = (b) => M($)(i.zIndex))
57
+ onClick: f[0] || (f[0] = (C) => i(b)(t.zIndex))
86
58
  }, [
87
- r("i", {
88
- class: k(M(L))
59
+ o("i", {
60
+ class: v(i(I))
89
61
  }, null, 2)
90
62
  ])
91
63
  ]),
92
- r("div", {
64
+ o("div", {
93
65
  class: "lkt-toast-details",
94
- innerHTML: _.value
95
- }, null, 8, Q),
96
- U(B, {
66
+ innerHTML: g.value
67
+ }, null, 8, J),
68
+ S(X, T({
97
69
  ref_key: "progressRef",
98
- ref: d,
99
- modelValue: n.value,
100
- "onUpdate:modelValue": t[1] || (t[1] = (b) => n.value = b),
101
- duration: M(u),
102
- type: "decremental",
103
- "value-format": "hidden",
104
- "pause-on-hover": "",
105
- onEnd: y
106
- }, null, 8, ["modelValue", "duration"])
70
+ ref: c,
71
+ modelValue: l.value,
72
+ "onUpdate:modelValue": f[1] || (f[1] = (C) => l.value = C)
73
+ }, {
74
+ duration: i(u),
75
+ animation: {
76
+ type: i(A).Decremental,
77
+ autoplay: !0,
78
+ externalControl: !1,
79
+ to: 0,
80
+ from: 100
81
+ },
82
+ valueFormat: i(N).Hidden,
83
+ pauseOnHover: !0,
84
+ events: {
85
+ updatedVisibleProgress: (C) => {
86
+ C === 0 && i(b)(a.zIndex);
87
+ }
88
+ }
89
+ }), null, 16, ["modelValue"])
107
90
  ], 512)
108
91
  ], 34);
109
92
  };
110
93
  }
111
- }), W = { class: "lkt-toast-canvas" }, Y = /* @__PURE__ */ D({
94
+ }), K = { class: "lkt-toast-canvas" }, Q = /* @__PURE__ */ H({
112
95
  __name: "LktToastCanvas",
113
- setup(e, { expose: s }) {
114
- const n = m(0), u = A(), d = m([]), h = () => {
115
- n.value = n.value + 1, setTimeout(() => {
116
- var o;
117
- (o = u == null ? void 0 : u.proxy) == null || o.$forceUpdate();
96
+ setup(t, { expose: a }) {
97
+ const l = m(0), u = E(), c = m([]), p = () => {
98
+ l.value = l.value + 1, setTimeout(() => {
99
+ var e;
100
+ (e = u == null ? void 0 : u.proxy) == null || e.$forceUpdate();
118
101
  }, 1);
119
- }, g = c(() => (n.value, v.components.filter((o) => o.positionX === "left"))), x = c(() => (n.value, v.components.filter((o) => o.positionX === "center"))), _ = c(() => (n.value, v.components.filter((o) => o.positionX === "right"))), L = c(() => g.value.length === 0 ? "" : "is-visible"), y = c(() => x.value.length === 0 ? "" : "is-visible"), I = c(() => _.value.length === 0 ? "" : "is-visible");
120
- return s({
121
- refresh: h
122
- }), (o, i) => (l(), p("section", W, [
123
- r("div", {
124
- class: k(["lkt-toast-stack left-stack", L.value])
102
+ }, k = r(() => (l.value, y.components.filter((e) => e.positionX === "left"))), _ = r(() => (l.value, y.components.filter((e) => e.positionX === "center"))), g = r(() => (l.value, y.components.filter((e) => e.positionX === "right"))), I = r(() => k.value.length === 0 ? "" : "is-visible"), x = r(() => _.value.length === 0 ? "" : "is-visible"), M = r(() => g.value.length === 0 ? "" : "is-visible");
103
+ return a({
104
+ refresh: p
105
+ }), (e, f) => (n(), d("section", K, [
106
+ o("div", {
107
+ class: v(["lkt-toast-stack left-stack", I.value])
125
108
  }, [
126
- (l(!0), p(R, null, V(g.value, (t) => (l(), C(T, X({
109
+ (n(!0), d(V, null, R(k.value, (s) => (n(), h(L, T({
127
110
  ref_for: !0,
128
111
  ref_key: "instanceReferences",
129
- ref: d,
130
- key: t.zIndex
131
- }, t), null, 16))), 128))
112
+ ref: c,
113
+ key: s.zIndex
114
+ }, { ref_for: !0 }, s), null, 16))), 128))
132
115
  ], 2),
133
- r("div", {
134
- class: k(["lkt-toast-stack center-stack", y.value])
116
+ o("div", {
117
+ class: v(["lkt-toast-stack center-stack", x.value])
135
118
  }, [
136
- (l(!0), p(R, null, V(x.value, (t) => (l(), C(T, X({
119
+ (n(!0), d(V, null, R(_.value, (s) => (n(), h(L, T({
137
120
  ref_for: !0,
138
121
  ref_key: "instanceReferences",
139
- ref: d,
140
- key: t.zIndex
141
- }, t), null, 16))), 128))
122
+ ref: c,
123
+ key: s.zIndex
124
+ }, { ref_for: !0 }, s), null, 16))), 128))
142
125
  ], 2),
143
- r("div", {
144
- class: k(["lkt-toast-stack right-stack", I.value])
126
+ o("div", {
127
+ class: v(["lkt-toast-stack right-stack", M.value])
145
128
  }, [
146
- (l(!0), p(R, null, V(_.value, (t) => (l(), C(T, X({
129
+ (n(!0), d(V, null, R(g.value, (s) => (n(), h(L, T({
147
130
  ref_for: !0,
148
131
  ref_key: "instanceReferences",
149
- ref: d,
150
- key: t.zIndex
151
- }, t), null, 16))), 128))
132
+ ref: c,
133
+ key: s.zIndex
134
+ }, { ref_for: !0 }, s), null, 16))), 128))
152
135
  ], 2)
153
136
  ]));
154
137
  }
155
- }), se = {
156
- install: (e) => {
157
- e.component("lkt-toast-canvas") === void 0 && e.component("lkt-toast-canvas", Y), e.component("lkt-toast") === void 0 && e.component("lkt-toast", T);
138
+ }), Z = {
139
+ install: (t) => {
140
+ t.component("lkt-toast-canvas") === void 0 && t.component("lkt-toast-canvas", Q), t.component("lkt-toast") === void 0 && t.component("lkt-toast", L);
158
141
  }
159
- }, ne = (e) => {
160
- f.canvas = e;
142
+ }, ee = (t) => {
143
+ y.canvas = t;
161
144
  };
162
145
  export {
163
- $ as closeToast,
164
- se as default,
165
- te as openToast,
166
- ne as setToastCanvas
146
+ oe as closeToast,
147
+ Z as default,
148
+ ne as openToast,
149
+ ee as setToastCanvas
167
150
  };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Plugin } from 'vue';
2
2
  import "./../lkt-toast.css";
3
- import { ValidCanvas } from "./types/ValidCanvas";
4
- export { closeToast, openToast } from './functions/functions';
3
+ import { ToastCanvasInterface } from "lkt-vue-kernel";
4
+ export { closeToast, openToast } from 'lkt-vue-kernel';
5
5
  declare const LktToast: Plugin;
6
6
  export default LktToast;
7
- export declare const setToastCanvas: (component: ValidCanvas) => void;
7
+ export declare const setToastCanvas: (component: ToastCanvasInterface) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkt-toast",
3
- "version": "1.1.4",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "module": "./dist/build.js",
@@ -1,7 +1,16 @@
1
1
  <script lang="ts" setup>
2
- import {computed, onMounted, ref} from 'vue';
3
- import {extractI18nValue, getDefaultValues, LktSettings, Toast, ToastConfig} from "lkt-vue-kernel";
4
- import {closeToast} from "../functions/functions";
2
+ import {computed, onMounted, ref, watch} from 'vue';
3
+ import {
4
+ closeToast,
5
+ extractI18nValue,
6
+ getDefaultValues,
7
+ LktSettings,
8
+ ProgressAnimation,
9
+ ProgressConfig,
10
+ ProgressValueFormat,
11
+ Toast,
12
+ ToastConfig
13
+ } from "lkt-vue-kernel";
5
14
 
6
15
  const props = withDefaults(defineProps<ToastConfig>(), getDefaultValues(Toast));
7
16
 
@@ -23,7 +32,9 @@ const classes = computed(() => {
23
32
  const calculatedCloseIcon = LktSettings.defaultCloseToastIcon
24
33
 
25
34
  const onProgressEnd = () => {
26
- closeToast(props.zIndex);
35
+ if (progressPercentage.value === 0) {
36
+ closeToast(props.zIndex);
37
+ }
27
38
  },
28
39
  onProgressMouseEnter = () => {
29
40
  //@ts-ignore
@@ -65,11 +76,25 @@ onMounted(() => {
65
76
  <lkt-progress
66
77
  ref="progressRef"
67
78
  v-model="progressPercentage"
68
- :duration="timeoutDuration"
69
- type="decremental"
70
- value-format="hidden"
71
- pause-on-hover
72
- @end="onProgressEnd"
79
+ v-bind="<ProgressConfig>{
80
+ duration: timeoutDuration,
81
+ animation: {
82
+ type: ProgressAnimation.Decremental,
83
+ autoplay: true,
84
+ externalControl: false,
85
+ to: 0,
86
+ from: 100,
87
+ },
88
+ valueFormat: ProgressValueFormat.Hidden,
89
+ pauseOnHover: true,
90
+ events: {
91
+ updatedVisibleProgress: (v) => {
92
+ if (v === 0) {
93
+ closeToast(props.zIndex);
94
+ }
95
+ }
96
+ }
97
+ }"
73
98
  />
74
99
  </div>
75
100
  </section>
@@ -1,8 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import {computed, getCurrentInstance, ref} from 'vue';
3
3
  import LktToast from "../lib-components/LktToast.vue";
4
- import {ToastConfig} from "lkt-vue-kernel";
5
- import {ToastController} from "../classes/ToastController";
4
+ import {ToastConfig, ToastController} from "lkt-vue-kernel";
6
5
 
7
6
  const refresher = ref(0);
8
7
  const instance = getCurrentInstance();