onomad 2.0.0 → 2.0.2

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,2 @@
1
+ export { timeago } from "./onomad";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare function timeago(date: Date): string;
2
+ export { timeago };
3
+ //# sourceMappingURL=onomad.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onomad.d.ts","sourceRoot":"","sources":["../src/onomad.ts"],"names":[],"mappings":"AACA,iBAAS,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CA+EnC;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -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(props.date));
13
+ let intervalId: ReturnType<typeof setInterval> | null = null;
14
+
15
+ const updateTime = () => {
16
+ formattedTime.value = timeago(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>
@@ -0,0 +1,2 @@
1
+ export { default as TimeAgo } from "./TimeAgo.vue";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vue/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,eAAe,CAAC"}
package/dist/vue/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/vue/TimeAgo.vue
2
- var TimeAgo_default = "./TimeAgo-qae5qph7.vue";
2
+ var TimeAgo_default = "./TimeAgo-2qmfkrw6.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.0",
3
+ "version": "2.0.2",
4
4
  "description": "Time formatting optimized for Serbian language",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -47,5 +47,8 @@
47
47
  "vue": {
48
48
  "optional": true
49
49
  }
50
+ },
51
+ "dependencies": {
52
+ "onomad": "^2.0.1"
50
53
  }
51
54
  }