onomad 2.0.2 → 2.0.3

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.
@@ -0,0 +1,35 @@
1
+ <script setup lang="ts">
2
+ import { ref, onMounted, onUnmounted, watch } from 'vue';
3
+ import { timeago } from '../onomad';
4
+
5
+ const props = withDefaults(defineProps<{
6
+ date: Date | string;
7
+ updateInterval?: number;
8
+ }>(), {
9
+ updateInterval: 60000
10
+ });
11
+
12
+ const formattedTime = ref(timeago(new Date(props.date)));
13
+ let intervalId: ReturnType<typeof setInterval> | null = null;
14
+
15
+ const updateTime = () => {
16
+ formattedTime.value = timeago(new Date(props.date));
17
+ };
18
+
19
+ onMounted(() => {
20
+ intervalId = setInterval(updateTime, props.updateInterval);
21
+ });
22
+
23
+ onUnmounted(() => {
24
+ if (intervalId) {
25
+ clearInterval(intervalId);
26
+ }
27
+ });
28
+
29
+ // Update immediately if date prop changes
30
+ watch(() => props.date, updateTime);
31
+ </script>
32
+
33
+ <template>
34
+ <span>{{ formattedTime }}</span>
35
+ </template>
package/dist/vue/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/vue/TimeAgo.vue
2
- var TimeAgo_default = "./TimeAgo-2qmfkrw6.vue";
2
+ var TimeAgo_default = "./TimeAgo-ajdd20a8.vue";
3
3
  export {
4
4
  TimeAgo_default as TimeAgo
5
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onomad",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "Time formatting optimized for Serbian language",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",