@wexio/messenger-widget-vue 1.5.3 → 1.6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @wexio/messenger-widget-vue
2
2
 
3
+ ## 1.6.1
4
+
5
+ ## 1.6.0
6
+
7
+ ### Minor Changes
8
+
9
+ - cdbf505: Open-state and navigation props on every embed: `defaultOpen`, controlled `open` and `previewTab` (React props, web-component `default-open` / `open` attributes and `previewTab` property, Vue / Angular / Ember wrappers, and `Wexio('open' | 'close' | 'navigate')` + `wexioSettings.defaultOpen` for the script tag). New integration-level `theme.launcherOffset` (px, clamped 0..200) moves the launcher, peek and panel in all three embeds; a host offset wins. Fixes: a persisted `sending` outbox op is retried after a reload, and Enter that confirms an IME candidate no longer sends the message.
10
+
3
11
  ## 1.5.3
4
12
 
5
13
  ### Patch Changes
package/README.md CHANGED
@@ -157,12 +157,16 @@ const user: VisitorIdentity = {
157
157
  | `prefill-email` | `string` | Unverified prechat prefill. |
158
158
  | `prefill-phone` | `string` | Unverified prechat prefill. |
159
159
  | `user` | `VisitorIdentity \| null` | Known-user identity proof. Pass `null` to log out. |
160
+ | `default-open` | `boolean` | Open the panel on mount (uncontrolled afterwards). |
161
+ | `open` | `boolean` | Controlled open state; keep it in sync from the `open` / `close` events. Leave unset for uncontrolled. |
162
+ | `preview-tab` | `PreviewTabSignal` | Navigate to a tab (`{ tab, nonce, article? }`) without a remount; opens the panel. A new `nonce` re-issues the request. |
160
163
 
161
164
  ## Events
162
165
 
163
166
  | Event | Payload | When |
164
167
  | -------- | -------------------------------------- | --------------------------------------------------- |
165
168
  | `resize` | `{ width: number; height: number }` | Panel dimensions changed (open ↔ closed). |
169
+ | `open` | — | The panel opened. |
166
170
  | `close` | — | Visitor closed the panel. |
167
171
 
168
172
  ```vue
package/dist/index.d.ts CHANGED
@@ -15,6 +15,14 @@ export interface VisitorIdentity {
15
15
  attributes?: Record<string, unknown>;
16
16
  }
17
17
 
18
+ /** Navigation request: go to a tab (and optionally a help article / news
19
+ * post) without a remount and open the panel. A new `nonce` re-issues it. */
20
+ export interface PreviewTabSignal {
21
+ tab: "home" | "messages" | "help" | "news" | "profile";
22
+ nonce: number;
23
+ article?: { kind: "help"; slug: string } | { kind: "news"; id: string };
24
+ }
25
+
18
26
  export interface WexioWidgetProps {
19
27
  /** Wexio integration public key (`pk_live_...`). Omit for demo mode. */
20
28
  publicKey?: string;
@@ -29,11 +37,19 @@ export interface WexioWidgetProps {
29
37
  prefillPhone?: string;
30
38
  /** Known-user identity proof. Pass `null` to log out. */
31
39
  user?: VisitorIdentity | null;
40
+ /** Open the panel on mount (uncontrolled afterwards). */
41
+ defaultOpen?: boolean;
42
+ /** Controlled open state; keep it in sync from the `open` / `close` events. */
43
+ open?: boolean;
44
+ /** Navigate to a tab / article without a remount (and open the panel). */
45
+ previewTab?: PreviewTabSignal;
32
46
  }
33
47
 
34
48
  export interface WexioWidgetEmits {
35
49
  /** Fires every time panel dimensions change (open ↔ closed). */
36
50
  resize: [size: { width: number; height: number }];
51
+ /** Fires when the panel opens. */
52
+ open: [];
37
53
  /** Fires when the visitor closes the panel. */
38
54
  close: [];
39
55
  }
package/dist/index.js CHANGED
@@ -55,6 +55,11 @@ function ensureRuntime() {
55
55
  document.head.appendChild(script);
56
56
  }
57
57
 
58
+ /** `true`/`false` -> "true"/"false"; undefined -> undefined (attribute absent = unset). */
59
+ function boolAttr(value) {
60
+ return value === undefined ? undefined : String(value);
61
+ }
62
+
58
63
  export const WexioWidget = defineComponent({
59
64
  name: "WexioWidget",
60
65
  props: {
@@ -74,12 +79,21 @@ export const WexioWidget = defineComponent({
74
79
  prefillPhone: { type: String, default: undefined },
75
80
  /** Known-user identity proof. Pass `null` to log out. */
76
81
  user: { type: [Object, null], default: undefined },
82
+ /** Open the panel on mount (uncontrolled afterwards). */
83
+ defaultOpen: { type: Boolean, default: undefined },
84
+ /** Controlled open state; keep it in sync from the `open` / `close`
85
+ * events. Leave undefined for an uncontrolled widget. */
86
+ open: { type: Boolean, default: undefined },
87
+ /** Navigate to a tab / article without a remount (and open the panel):
88
+ * `{ tab, nonce, article? }`. A new `nonce` re-issues the request. */
89
+ previewTab: { type: Object, default: undefined },
77
90
  },
78
91
  emits: {
79
92
  resize: (payload) =>
80
93
  payload &&
81
94
  typeof payload.width === "number" &&
82
95
  typeof payload.height === "number",
96
+ open: () => true,
83
97
  close: () => true,
84
98
  },
85
99
  setup(props, { emit }) {
@@ -88,6 +102,7 @@ export const WexioWidget = defineComponent({
88
102
  const onResize = (event) => {
89
103
  if (event && event.detail) emit("resize", event.detail);
90
104
  };
105
+ const onOpen = () => emit("open");
91
106
  const onClose = () => emit("close");
92
107
 
93
108
  onMounted(() => {
@@ -95,7 +110,10 @@ export const WexioWidget = defineComponent({
95
110
  const el = elRef.value;
96
111
  if (!el) return;
97
112
  el.addEventListener("wexio:resize", onResize);
113
+ el.addEventListener("wexio:open", onOpen);
98
114
  el.addEventListener("wexio:close", onClose);
115
+ // `previewTab` is an object, so it goes through the element's JS property.
116
+ if (props.previewTab) el.previewTab = props.previewTab;
99
117
  if (props.user) el.identify?.(props.user);
100
118
  });
101
119
 
@@ -103,9 +121,18 @@ export const WexioWidget = defineComponent({
103
121
  const el = elRef.value;
104
122
  if (!el) return;
105
123
  el.removeEventListener("wexio:resize", onResize);
124
+ el.removeEventListener("wexio:open", onOpen);
106
125
  el.removeEventListener("wexio:close", onClose);
107
126
  });
108
127
 
128
+ watch(
129
+ () => props.previewTab,
130
+ (next) => {
131
+ const el = elRef.value;
132
+ if (el) el.previewTab = next;
133
+ },
134
+ );
135
+
109
136
  // Identity is set imperatively rather than as a reactive attribute —
110
137
  // mirrors the React component's `user` prop semantics. `null` /
111
138
  // `undefined` logs the visitor out.
@@ -127,6 +154,9 @@ export const WexioWidget = defineComponent({
127
154
  "prefill-name": props.prefillName,
128
155
  "prefill-email": props.prefillEmail,
129
156
  "prefill-phone": props.prefillPhone,
157
+ // "true" / "false" strings; undefined removes the attribute (unset).
158
+ "default-open": boolAttr(props.defaultOpen),
159
+ open: boolAttr(props.open),
130
160
  });
131
161
  },
132
162
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wexio/messenger-widget-vue",
3
- "version": "1.5.3",
3
+ "version": "1.6.1",
4
4
  "description": "Vue 3 component embed for the Wexio web messenger. Thin reactive wrapper around the <wexio-widget> web component — same WidgetShell runtime, same Shadow-DOM isolation.",
5
5
  "license": "MIT",
6
6
  "private": false,