@wexio/messenger-widget-react 1.3.0 → 1.3.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.
@@ -11,23 +11,23 @@ import "react";
11
11
  import "react-dom";
12
12
  import "react/jsx-runtime";
13
13
  import "react-dom/client";
14
- import { F as e, M as t, b as n, c as r, ht as i, it as a, k as o, l as ee, rt as te, u as s, y as c } from "./widget-react-Dtx_fW3V.js";
15
- import { i as l, n as u } from "./widget-react-krPPnv02.js";
16
- import { i as d } from "./widget-react-CN_FIvMD.js";
17
- import { o as f, p as ne, s as p, t as m } from "./widget-react-BZ-SHa2o.js";
18
- import { t as re } from "./widget-react-SI7deQTE.js";
19
- import { a as ie, c as ae, i as h, l as g, n as _, o as oe, r as v, s as y, t as b } from "./widget-react-vXfa9GKf.js";
20
- import { useEffect as x, useMemo as S, useRef as C, useState as se } from "react";
14
+ import { F as e, I as t, M as n, N as r, b as i, c as a, ct as ee, k as te, l as o, st as s, u as c, y as l, yt as u, z as d } from "./widget-react-C6lzldez.js";
15
+ import { i as f, n as p } from "./widget-react-krPPnv02.js";
16
+ import { i as ne } from "./widget-react-CN_FIvMD.js";
17
+ import { o as re, p as ie, s as m, t as h } from "./widget-react-bPokx9L5.js";
18
+ import { t as ae } from "./widget-react-SI7deQTE.js";
19
+ import { a as g, i as _, n as oe, o as v, r as y, s as b, t as x } from "./widget-react-BfO-uP4o.js";
20
+ import { useEffect as S, useMemo as C, useRef as se, useState as ce } from "react";
21
21
  import { jsx as w, jsxs as T } from "react/jsx-runtime";
22
22
  //#region components/widget/help-article-view/helpers.ts
23
- function ce(e) {
23
+ function le(e) {
24
24
  let t = (e) => Array.isArray(e) ? e : [];
25
25
  return {
26
26
  id: String(e._id ?? ""),
27
27
  title: typeof e.title == "string" ? e.title : "",
28
28
  excerpt: typeof e.excerpt == "string" ? e.excerpt : "",
29
29
  content: typeof e.content == "string" ? e.content : "",
30
- contentFormat: e.contentFormat === y.HTML ? y.HTML : y.MARKDOWN,
30
+ contentFormat: e.contentFormat === g.HTML ? g.HTML : g.MARKDOWN,
31
31
  authors: t(e.authors).filter((e) => !!e && typeof e == "object").map((e) => ({
32
32
  _id: String(e._id ?? ""),
33
33
  name: typeof e.name == "string" ? e.name : null,
@@ -42,38 +42,38 @@ function ce(e) {
42
42
  }
43
43
  //#endregion
44
44
  //#region components/widget/help-article-view/index.tsx
45
- function E({ slug: u, locale: E, isDummy: D, onHandoff: O, onOpenArticle: k, onOpenTranslation: A, onTitleResolved: j }) {
46
- let M = l("help"), N = l("demo"), P = t(), { config: F } = o(), I = F.messenger?.showRelatedHelpArticles ?? !0, L = F.messenger?.showReactionCounts ?? !0, R = re(), [z, B] = se(E), V = ie(z, N), H = S(() => {
47
- if (D) return null;
48
- let e = P.previewData?.helpArticles;
49
- return Array.isArray(e) ? e.find((e) => e && typeof e == "object" && e.slug === u) ?? null : null;
45
+ function E({ slug: p, locale: E, isDummy: O, onHandoff: k, onOpenArticle: A, onOpenTranslation: j, onTitleResolved: M }) {
46
+ let N = f("help"), P = e(), F = n(), { config: I } = te(), L = I.messenger?.showRelatedHelpArticles ?? !0, R = I.messenger?.showReactionCounts ?? !0, z = ae(), [B, ue] = ce(E), V = t(B, P), H = C(() => {
47
+ if (O) return null;
48
+ let e = F.previewData?.helpArticles;
49
+ return Array.isArray(e) ? e.find((e) => e && typeof e == "object" && e.slug === p) ?? null : null;
50
50
  }, [
51
- P.previewData,
52
- D,
53
- u
54
- ]), U = !!H, { data: W, loading: ue } = p({
51
+ F.previewData,
52
+ O,
53
+ p
54
+ ]), U = !!H, { data: W, loading: de } = m({
55
55
  variables: { args: {
56
- slug: u,
56
+ slug: p,
57
57
  locale: E
58
58
  } },
59
- skip: D || U
60
- }), G = te(), K = ee(G && !D && !U ? e.article(G, u, E) : null, W), [q] = f(), { trackLinkClick: J } = r(), Y = C(null), X = S(() => D ? i(V).find((e) => e.slug === u) : null, [
61
- D,
62
- u,
59
+ skip: O || U
60
+ }), G = s(), K = o(G && !O && !U ? d.article(G, p, E) : null, W), [q] = re(), { trackLinkClick: J } = a(), Y = se(null), X = C(() => O ? u(V).find((e) => e.slug === p) : null, [
61
+ O,
62
+ p,
63
63
  V
64
- ]), Z = D ? X ? {
64
+ ]), Z = O ? X ? {
65
65
  id: X.id,
66
66
  title: X.title,
67
67
  excerpt: X.excerpt,
68
68
  content: X.contentMarkdown,
69
- contentFormat: y.MARKDOWN,
69
+ contentFormat: g.MARKDOWN,
70
70
  authors: X.authors,
71
71
  tags: X.tags,
72
72
  reactionCounts: null,
73
- locale: z,
73
+ locale: B,
74
74
  translations: []
75
75
  } : null : U && H ? {
76
- ...ce(H),
76
+ ...le(H),
77
77
  reactionCounts: H.reactionCounts ?? null,
78
78
  locale: E,
79
79
  translations: []
@@ -88,16 +88,16 @@ function E({ slug: u, locale: E, isDummy: D, onHandoff: O, onOpenArticle: k, onO
88
88
  reactionCounts: K.visitorHelpArticle.reactionCounts ?? null,
89
89
  locale: K.visitorHelpArticle.locale,
90
90
  translations: K.visitorHelpArticle.translations
91
- } : null, { data: de } = ne({
91
+ } : null, { data: fe } = ie({
92
92
  variables: {
93
93
  articleId: Z?.id ?? "",
94
94
  limit: 5,
95
95
  locale: E
96
96
  },
97
- skip: D || U || !Z?.id || !I
98
- }), fe = S(() => {
97
+ skip: O || U || !Z?.id || !L
98
+ }), pe = C(() => {
99
99
  if (!U || !Z?.id) return [];
100
- let e = (P.previewData?.helpArticles ?? []).filter((e) => !!e && typeof e == "object"), t = new Set((Z.tags ?? []).map((e) => typeof e == "object" && e && "slug" in e ? String(e.slug) : null).filter((e) => !!e)), n = (() => {
100
+ let e = (F.previewData?.helpArticles ?? []).filter((e) => !!e && typeof e == "object"), t = new Set((Z.tags ?? []).map((e) => typeof e == "object" && e && "slug" in e ? String(e.slug) : null).filter((e) => !!e)), n = (() => {
101
101
  let e = H;
102
102
  if (!e) return null;
103
103
  let t = e.folderId;
@@ -125,49 +125,49 @@ function E({ slug: u, locale: E, isDummy: D, onHandoff: O, onOpenArticle: k, onO
125
125
  U,
126
126
  Z,
127
127
  H,
128
- P.previewData
129
- ]), Q = U ? fe : de?.visitorHelpRelated ?? [], pe = D || U ? null : W?.visitorHelpArticle?.viewerReaction ?? null, me = !D && !U && W?.visitorHelpArticle ? [W.visitorHelpArticle._id, ...(W.visitorHelpArticle.translations ?? []).map((e) => e._id)] : Z?.id ? [Z.id] : [];
130
- x(() => {
131
- D || !Z?.id || !a() || q({ variables: { articleId: Z.id } }).catch(() => {});
128
+ F.previewData
129
+ ]), Q = U ? pe : fe?.visitorHelpRelated ?? [], me = O || U ? null : W?.visitorHelpArticle?.viewerReaction ?? null, he = !O && !U && W?.visitorHelpArticle ? [W.visitorHelpArticle._id, ...(W.visitorHelpArticle.translations ?? []).map((e) => e._id)] : Z?.id ? [Z.id] : [];
130
+ S(() => {
131
+ O || !Z?.id || !ee() || q({ variables: { articleId: Z.id } }).catch(() => {});
132
132
  }, [
133
133
  Z?.id,
134
- D,
134
+ O,
135
135
  q
136
- ]), x(() => {
137
- D || U || !Z?.id || Y.current !== Z.id && (Y.current = Z.id, J({
138
- url: `/help/${u}`,
136
+ ]), S(() => {
137
+ O || U || !Z?.id || Y.current !== Z.id && (Y.current = Z.id, J({
138
+ url: `/help/${p}`,
139
139
  targetType: "HELP_ARTICLE",
140
140
  targetRefId: Z.id
141
141
  }));
142
142
  }, [
143
143
  Z?.id,
144
- D,
144
+ O,
145
145
  U,
146
- u,
146
+ p,
147
147
  J
148
- ]), oe(Z?.title, j);
149
- let he = () => O();
150
- if (!ue && !Z) return /* @__PURE__ */ w("div", {
148
+ ]), _(Z?.title, M);
149
+ let ge = () => k();
150
+ if (!de && !Z) return /* @__PURE__ */ w("div", {
151
151
  className: "flex flex-1 flex-col items-center justify-center px-6 py-12",
152
- children: /* @__PURE__ */ w(c, { children: /* @__PURE__ */ w(n, {
152
+ children: /* @__PURE__ */ w(l, { children: /* @__PURE__ */ w(i, {
153
153
  className: "py-8 text-center",
154
154
  children: /* @__PURE__ */ w("p", {
155
155
  className: "text-sm font-semibold text-wx-fg",
156
- children: M("articleNotFound")
156
+ children: N("articleNotFound")
157
157
  })
158
158
  }) })
159
159
  });
160
- let ge = E.split("-")[0].toLowerCase(), $ = Z ? Z.locale.split("-")[0].toLowerCase() : null;
161
- return !D && !U && !F.contentLocaleFallback && $ !== null && $ !== ge ? /* @__PURE__ */ w("div", {
160
+ let _e = E.split("-")[0].toLowerCase(), $ = Z ? Z.locale.split("-")[0].toLowerCase() : null;
161
+ return !O && !U && !I.contentLocaleFallback && $ !== null && $ !== _e ? /* @__PURE__ */ w("div", {
162
162
  className: "flex flex-1 flex-col items-center justify-center px-6 py-12",
163
- children: /* @__PURE__ */ w(c, { children: /* @__PURE__ */ w(n, {
163
+ children: /* @__PURE__ */ w(l, { children: /* @__PURE__ */ w(i, {
164
164
  className: "py-8 text-center",
165
165
  children: /* @__PURE__ */ w("p", {
166
166
  className: "text-sm font-semibold text-wx-fg",
167
- children: M("articleNotTranslated")
167
+ children: N("articleNotTranslated")
168
168
  })
169
169
  }) })
170
- }) : Z ? /* @__PURE__ */ w(s, {
170
+ }) : Z ? /* @__PURE__ */ w(c, {
171
171
  className: "flex-1",
172
172
  children: /* @__PURE__ */ T("div", {
173
173
  className: "flex flex-col px-5 pt-5 pb-12",
@@ -192,7 +192,7 @@ function E({ slug: u, locale: E, isDummy: D, onHandoff: O, onOpenArticle: k, onO
192
192
  children: (e.name ?? "?").charAt(0)
193
193
  })
194
194
  }, e._id))
195
- }), /* @__PURE__ */ w("span", { children: M("writtenBy", { names: Z.authors.map((e) => e.name ?? "").filter(Boolean).join(", ") }) })]
195
+ }), /* @__PURE__ */ w("span", { children: N("writtenBy", { names: Z.authors.map((e) => e.name ?? "").filter(Boolean).join(", ") }) })]
196
196
  }),
197
197
  Z.tags.length > 0 && /* @__PURE__ */ w("div", {
198
198
  className: "mt-2 flex flex-wrap gap-1",
@@ -205,53 +205,53 @@ function E({ slug: u, locale: E, isDummy: D, onHandoff: O, onOpenArticle: k, onO
205
205
  className: "mt-2 mb-5 text-sm text-wx-fg-muted",
206
206
  children: Z.excerpt
207
207
  }),
208
- /* @__PURE__ */ w(v, {
208
+ /* @__PURE__ */ w(y, {
209
209
  content: Z.content,
210
- isHtml: Z.contentFormat === y.HTML || g(Z.content),
210
+ isHtml: Z.contentFormat === g.HTML || b(Z.content),
211
211
  markdownMarginClass: "mt-3"
212
212
  }),
213
- /* @__PURE__ */ T(m, {
213
+ /* @__PURE__ */ T(h, {
214
214
  type: "button",
215
215
  variant: "solid",
216
216
  size: "lg",
217
217
  className: "mt-6 w-full shrink-0 min-h-12",
218
- onClick: he,
219
- ...R.parentHandlers,
220
- children: [/* @__PURE__ */ w(d, {
221
- ref: R.iconRef,
218
+ onClick: ge,
219
+ ...z.parentHandlers,
220
+ children: [/* @__PURE__ */ w(ne, {
221
+ ref: z.iconRef,
222
222
  size: 16
223
- }), /* @__PURE__ */ w("span", { children: M("unresolvedCta") })]
223
+ }), /* @__PURE__ */ w("span", { children: N("unresolvedCta") })]
224
224
  }),
225
- Z.id && /* @__PURE__ */ w(b, {
226
- surface: ae.HELP,
225
+ Z.id && /* @__PURE__ */ w(x, {
226
+ surface: v.HELP,
227
227
  itemId: Z.id,
228
228
  reactionCounts: Z.reactionCounts,
229
- viewerReaction: pe,
230
- groupItemIds: me,
231
- isDummy: D,
232
- showCounts: L,
229
+ viewerReaction: me,
230
+ groupItemIds: he,
231
+ isDummy: O,
232
+ showCounts: R,
233
233
  className: "mt-4"
234
234
  }),
235
- /* @__PURE__ */ w(_, {
236
- currentLocale: D ? z : Z.locale,
237
- locales: D ? [...h] : Z.translations.map((e) => e.locale),
238
- allowedLocales: D ? void 0 : F.supportedLocales,
239
- onSelect: D ? (e) => B(e) : (e) => {
235
+ /* @__PURE__ */ w(oe, {
236
+ currentLocale: O ? B : Z.locale,
237
+ locales: O ? [...r] : Z.translations.map((e) => e.locale),
238
+ allowedLocales: O ? void 0 : I.supportedLocales,
239
+ onSelect: O ? (e) => ue(e) : (e) => {
240
240
  let t = Z.translations.find((t) => t.locale === e);
241
- t && A?.(t.slug, t.locale);
241
+ t && j?.(t.slug, t.locale);
242
242
  },
243
243
  className: "mt-6"
244
244
  }),
245
- I && Q.length > 0 && /* @__PURE__ */ T("section", {
245
+ L && Q.length > 0 && /* @__PURE__ */ T("section", {
246
246
  className: "mt-6",
247
247
  children: [/* @__PURE__ */ w("p", {
248
248
  className: "mb-2 text-xs font-semibold tracking-wide text-wx-fg-muted uppercase",
249
- children: M("relatedTitle")
249
+ children: N("relatedTitle")
250
250
  }), /* @__PURE__ */ w("ul", {
251
251
  className: "flex flex-col gap-1.5",
252
252
  children: Q.map((e) => /* @__PURE__ */ w("li", { children: /* @__PURE__ */ T("button", {
253
253
  type: "button",
254
- onClick: () => k?.(e.slug),
254
+ onClick: () => A?.(e.slug),
255
255
  className: "flex w-full flex-col items-start gap-0.5 rounded-wx-lg bg-wx-bg-elevated px-3 py-2 text-left transition-colors hover:bg-wx-bg-elevated/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-wx-primary",
256
256
  children: [/* @__PURE__ */ w("span", {
257
257
  className: "block truncate text-sm font-medium text-wx-fg",
@@ -265,10 +265,10 @@ function E({ slug: u, locale: E, isDummy: D, onHandoff: O, onOpenArticle: k, onO
265
265
  })
266
266
  ]
267
267
  })
268
- }) : /* @__PURE__ */ w(le, {});
268
+ }) : /* @__PURE__ */ w(D, {});
269
269
  }
270
- function le() {
271
- return /* @__PURE__ */ w(s, {
270
+ function D() {
271
+ return /* @__PURE__ */ w(c, {
272
272
  className: "flex-1",
273
273
  children: /* @__PURE__ */ T("div", {
274
274
  className: "flex flex-col px-5 pt-5 pb-12",
@@ -294,7 +294,7 @@ function le() {
294
294
  "w-full",
295
295
  "w-11/12",
296
296
  "w-7/12"
297
- ].map((e, t) => /* @__PURE__ */ w("div", { className: u("h-3 rounded-md bg-wx-bg-elevated", e) }, t))
297
+ ].map((e, t) => /* @__PURE__ */ w("div", { className: p("h-3 rounded-md bg-wx-bg-elevated", e) }, t))
298
298
  })
299
299
  ]
300
300
  })
@@ -303,4 +303,4 @@ function le() {
303
303
  //#endregion
304
304
  export { E as HelpArticleView };
305
305
 
306
- //# sourceMappingURL=widget-react-DWgRcZF7.js.map
306
+ //# sourceMappingURL=widget-react-DRER1XF_.js.map
@@ -68,8 +68,8 @@ function p({ open: p, onClose: m, fetchPage: h, onPick: g, anchorRef: _ }) {
68
68
  ]), s(() => {
69
69
  if (!p) return;
70
70
  let e = (e) => {
71
- let t = e.target;
72
- y.current?.contains(t) || _?.current?.contains(t) || m();
71
+ let t = e.composedPath();
72
+ y.current && t.includes(y.current) || _?.current && t.includes(_.current) || m();
73
73
  }, t = (e) => {
74
74
  e.key === "Escape" && m();
75
75
  };
@@ -226,4 +226,4 @@ function p({ open: p, onClose: m, fetchPage: h, onPick: g, anchorRef: _ }) {
226
226
  //#endregion
227
227
  export { p as GiphyPicker };
228
228
 
229
- //# sourceMappingURL=widget-react-CuphoFsN.js.map
229
+ //# sourceMappingURL=widget-react-DSAyUf2U.js.map