@tranzakpackage/cards-vue 0.0.0-stage → 2.0.0

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
@@ -1,3 +1,11 @@
1
- # Temporary Holding Version
1
+ # Tranzak Cards - Vue 3 / Nuxt
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A Tranzak card component for Vue 3 and Nuxt.
4
+
5
+ ```bash
6
+ npm install @tranzakpackage/cards-vue
7
+ ```
8
+
9
+ Full documentation and API reference: https://docs.tranzak.co (Cards section).
10
+
11
+ Proprietary software of Lomotec LLC. All rights reserved.
package/package.json CHANGED
@@ -1,6 +1,25 @@
1
1
  {
2
2
  "name": "@tranzakpackage/cards-vue",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.0.0",
4
+ "description": "Tranzak Cards for Vue 3 and Nuxt.",
5
+ "type": "module",
6
+ "main": "src/index.js",
7
+ "module": "src/index.js",
8
+ "types": "src/index.d.ts",
9
+ "sideEffects": false,
10
+ "peerDependencies": {
11
+ "vue": ">=3.2"
12
+ },
13
+ "dependencies": {
14
+ "@tranzakpackage/cards-core": "2.0.0"
15
+ },
16
+ "license": "UNLICENSED",
17
+ "files": [
18
+ "src",
19
+ "README.md"
20
+ ],
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "homepage": "https://docs.tranzak.co"
25
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import type { DefineComponent } from 'vue';
2
+ import type { FramedWidget, InlineWidget } from '@tranzakpackage/cards-core';
3
+
4
+ export const TranzakCard: DefineComponent<{ widget?: InlineWidget | FramedWidget; url?: string }>;
5
+ export default TranzakCard;
package/src/index.js ADDED
@@ -0,0 +1,49 @@
1
+ import { defineComponent, h, onBeforeUnmount, onMounted, ref, watch } from 'vue';
2
+ import { mount } from '@tranzakpackage/cards-core';
3
+
4
+ /**
5
+ * <TranzakCard :widget="widget" @frozen="..." /> : la carte s'affiche dans cette zone de votre page (Vue 3, Nuxt).
6
+ * Le composant ne touche à `window` qu'après le montage, donc le rendu serveur (Nuxt) est sûr.
7
+ * Un nouvel objet `widget` (nouvelle session) remonte la carte.
8
+ */
9
+ export const TranzakCard = defineComponent({
10
+ name: 'TranzakCard',
11
+ props: {
12
+ widget: { type: Object, default: undefined },
13
+ url: { type: String, default: undefined },
14
+ },
15
+ emits: ['ready', 'frozen', 'unfrozen', 'resize', 'state-change', 'error'],
16
+ setup(props, { emit }) {
17
+ const el = ref(null);
18
+ let mounted = null;
19
+
20
+ function start() {
21
+ stop();
22
+ const key = props.widget ? JSON.stringify(props.widget) : props.url;
23
+ if (!el.value || !key) return;
24
+ mounted = mount({
25
+ container: el.value,
26
+ widget: props.widget,
27
+ url: props.url,
28
+ onReady: () => emit('ready'),
29
+ onFrozen: () => emit('frozen'),
30
+ onUnfrozen: () => emit('unfrozen'),
31
+ onResize: (e) => emit('resize', e),
32
+ onStateChange: (s) => emit('state-change', s),
33
+ onError: (e) => emit('error', e),
34
+ });
35
+ }
36
+
37
+ function stop() {
38
+ if (mounted) { mounted.destroy(); mounted = null; }
39
+ }
40
+
41
+ onMounted(start);
42
+ onBeforeUnmount(stop);
43
+ watch(() => (props.widget ? JSON.stringify(props.widget) : props.url), start);
44
+
45
+ return () => h('div', { ref: el, 'data-tranzak-card': '' });
46
+ },
47
+ });
48
+
49
+ export default TranzakCard;