lkt-toast 1.1.4 → 1.1.5

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