@fy-/fws-vue 0.6.7 → 0.6.9

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.
@@ -14,7 +14,6 @@ import {
14
14
  import { useEventBus } from "../../composables/event-bus";
15
15
  import type { Component } from "vue";
16
16
  import FadeTransition from "./transitions/FadeTransition.vue";
17
- import { on } from "events";
18
17
  interface NotifProps {
19
18
  imgSrc?: string;
20
19
  imgIcon?: Component;
@@ -29,9 +28,9 @@ interface NotifProps {
29
28
  const notif = ref<HTMLElement | null>(null);
30
29
  const eventBus = useEventBus();
31
30
  const currentNotif = ref<NotifProps | null>(null);
32
-
31
+ let currentTimeout: any | null = null;
33
32
  const onCall = (props: NotifProps) => {
34
- if (currentNotif.value) {
33
+ if (currentNotif.value !== null) {
35
34
  hideNotif();
36
35
  }
37
36
  const actualIcon = ref(props.imgIcon);
@@ -44,7 +43,7 @@ const onCall = (props: NotifProps) => {
44
43
  actualIcon.value = CheckCircleIcon;
45
44
  }
46
45
  }
47
- if (!props.time) {
46
+ if (!props.time || props.time < 1000) {
48
47
  props.time = 5000;
49
48
  }
50
49
 
@@ -58,22 +57,16 @@ const onCall = (props: NotifProps) => {
58
57
  ctaAction: props.ctaAction,
59
58
  };
60
59
 
61
- showNotif();
60
+ currentTimeout = setTimeout(() => {
61
+ hideNotif();
62
+ }, currentNotif.value.time);
62
63
  };
63
64
 
64
- const visible = ref(false);
65
- const showNotif = () => {
66
- visible.value = true;
67
- setTimeout(
68
- () => {
69
- hideNotif();
70
- },
71
- currentNotif.value?.time,
72
- );
73
- };
74
65
  const hideNotif = () => {
75
- visible.value = false;
76
66
  currentNotif.value = null;
67
+ if (currentTimeout !== null) {
68
+ clearTimeout(currentTimeout);
69
+ }
77
70
  };
78
71
  onMounted(() => {
79
72
  eventBus.on("main-notif", onCall);
@@ -89,7 +82,7 @@ onUnmounted(() => {
89
82
  ref="notif"
90
83
  class="w-full max-w-xs p-4 text-fv-neutral-500 bg-white rounded-lg shadow dark:bg-fv-neutral-800 dark:text-fv-neutral-400 absolute bottom-4 right-4 z-[16]"
91
84
  role="alert"
92
- v-if="visible && currentNotif"
85
+ v-if="currentNotif !== null"
93
86
  >
94
87
  <div class="flex">
95
88
  <img
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fy-/fws-vue",
3
- "version": "0.6.7",
3
+ "version": "0.6.9",
4
4
  "author": "Florian 'Fy' Gasquez <m@fy.to>",
5
5
  "license": "MIT",
6
6
  "repository": {