onomad 1.0.0 → 2.0.1

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/README.md CHANGED
@@ -29,6 +29,38 @@ const lastWeek = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
29
29
  console.log(timeago(lastWeek)); // "pre nedelju dana"
30
30
  ```
31
31
 
32
+ ### Upotreba u Vue.js
33
+
34
+ Onomad dolazi sa gotovom Vue komponentom koja automatski ažurira prikaz vremena.
35
+
36
+ #### Instalacija
37
+
38
+ ```bash
39
+ npm install onomad vue
40
+ ```
41
+
42
+ #### Upotreba komponente
43
+
44
+ ```vue
45
+ <script setup lang="ts">
46
+ import { TimeAgo } from 'onomad/vue';
47
+
48
+ const postDate = new Date(Date.now() - 5 * 60 * 1000);
49
+ </script>
50
+
51
+ <template>
52
+ <div>
53
+ <p>Objavljeno <TimeAgo :date="postDate" /></p>
54
+ </div>
55
+ </template>
56
+ ```
57
+
58
+ Komponenta automatski ažurira prikazan tekst svakih 60 sekundi. Možete prilagoditi interval ažuriranja:
59
+
60
+ ```vue
61
+ <TimeAgo :date="postDate" :update-interval="5000" />
62
+ ```
63
+
32
64
  ## API Referenca
33
65
 
34
66
  ### `timeago(time: Date): string`
@@ -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;
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"}
@@ -0,0 +1,7 @@
1
+ // src/vue/TimeAgo.vue
2
+ var TimeAgo_default = "./TimeAgo-qae5qph7.vue";
3
+ export {
4
+ TimeAgo_default as TimeAgo
5
+ };
6
+
7
+ //# debugId=32AECEC8B9D27CF064756E2164756E21
@@ -0,0 +1,9 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [
5
+ ],
6
+ "mappings": "",
7
+ "debugId": "32AECEC8B9D27CF064756E2164756E21",
8
+ "names": []
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onomad",
3
- "version": "1.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Time formatting optimized for Serbian language",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -10,11 +10,17 @@
10
10
  ".": {
11
11
  "import": "./dist/index.js",
12
12
  "types": "./dist/index.d.ts"
13
+ },
14
+ "./vue": {
15
+ "import": "./dist/vue/index.js",
16
+ "types": "./dist/vue/index.d.ts"
13
17
  }
14
18
  },
15
19
  "scripts": {
16
- "build": "bun build src/index.ts --outdir dist --target node --sourcemap=external && bun run build:types",
17
- "build:types": "tsc --emitDeclarationOnly --declaration --declarationMap",
20
+ "build": "bun run build:core && bun run build:vue && bun run build:types",
21
+ "build:core": "bun build src/index.ts --outdir dist --target node --sourcemap=external",
22
+ "build:vue": "bun build src/vue/index.ts --outdir dist/vue --target node --sourcemap=external --external vue",
23
+ "build:types": "tsc --project tsconfig.build.json",
18
24
  "test": "bun test",
19
25
  "prepublishOnly": "bun run build"
20
26
  },
@@ -36,5 +42,10 @@
36
42
  },
37
43
  "peerDependencies": {
38
44
  "typescript": "^5.0.0"
45
+ },
46
+ "peerDependenciesMeta": {
47
+ "vue": {
48
+ "optional": true
49
+ }
39
50
  }
40
51
  }