@wexio/messenger-widget-react 1.3.0 → 1.4.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/CHANGELOG.md +33 -0
- package/dist/widget-react-BS9kUSRS.js +255 -0
- package/dist/{widget-react-BZ-SHa2o.js → widget-react-BT30ojz0.js} +10 -10
- package/dist/{widget-react-CHSNuztJ.js → widget-react-BgunakAG.js} +129 -129
- package/dist/{widget-react-l5oryxYk.js → widget-react-Bvtklo8g.js} +83 -83
- package/dist/widget-react-BxEjM2it.js +118 -0
- package/dist/{widget-react-DWgRcZF7.js → widget-react-CTdz_dwX.js} +80 -80
- package/dist/{widget-react-Dtx_fW3V.js → widget-react-Ck8JAYqT.js} +1842 -1792
- package/dist/{widget-react-vXfa9GKf.js → widget-react-CyAVDflZ.js} +45 -73
- package/dist/{widget-react-CuphoFsN.js → widget-react-DSAyUf2U.js} +3 -3
- package/dist/widget-react.js +4182 -4096
- package/package.json +1 -1
- package/dist/widget-react-D8Z8cGhJ.js +0 -254
- package/dist/widget-react-DSUX0aJn.js +0 -117
|
@@ -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,
|
|
15
|
-
import { i as
|
|
16
|
-
import { i as
|
|
17
|
-
import { o as
|
|
18
|
-
import { t as
|
|
19
|
-
import { a as
|
|
20
|
-
import { useEffect as
|
|
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-Ck8JAYqT.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-BT30ojz0.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-CyAVDflZ.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
|
|
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 ===
|
|
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:
|
|
46
|
-
let
|
|
47
|
-
if (
|
|
48
|
-
let e =
|
|
49
|
-
return Array.isArray(e) ? e.find((e) => e && typeof e == "object" && e.slug ===
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
]), U = !!H, { data: W, loading:
|
|
51
|
+
F.previewData,
|
|
52
|
+
O,
|
|
53
|
+
p
|
|
54
|
+
]), U = !!H, { data: W, loading: de } = m({
|
|
55
55
|
variables: { args: {
|
|
56
|
-
slug:
|
|
56
|
+
slug: p,
|
|
57
57
|
locale: E
|
|
58
58
|
} },
|
|
59
|
-
skip:
|
|
60
|
-
}), G =
|
|
61
|
-
|
|
62
|
-
|
|
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 =
|
|
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:
|
|
69
|
+
contentFormat: g.MARKDOWN,
|
|
70
70
|
authors: X.authors,
|
|
71
71
|
tags: X.tags,
|
|
72
72
|
reactionCounts: null,
|
|
73
|
-
locale:
|
|
73
|
+
locale: B,
|
|
74
74
|
translations: []
|
|
75
75
|
} : null : U && H ? {
|
|
76
|
-
...
|
|
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:
|
|
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:
|
|
98
|
-
}),
|
|
97
|
+
skip: O || U || !Z?.id || !L
|
|
98
|
+
}), pe = C(() => {
|
|
99
99
|
if (!U || !Z?.id) return [];
|
|
100
|
-
let e = (
|
|
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
|
-
|
|
129
|
-
]), Q = U ?
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
134
|
+
O,
|
|
135
135
|
q
|
|
136
|
-
]),
|
|
137
|
-
|
|
138
|
-
url: `/help/${
|
|
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
|
-
|
|
144
|
+
O,
|
|
145
145
|
U,
|
|
146
|
-
|
|
146
|
+
p,
|
|
147
147
|
J
|
|
148
|
-
]),
|
|
149
|
-
let
|
|
150
|
-
if (!
|
|
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(
|
|
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:
|
|
156
|
+
children: N("articleNotFound")
|
|
157
157
|
})
|
|
158
158
|
}) })
|
|
159
159
|
});
|
|
160
|
-
let
|
|
161
|
-
return !
|
|
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(
|
|
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:
|
|
167
|
+
children: N("articleNotTranslated")
|
|
168
168
|
})
|
|
169
169
|
}) })
|
|
170
|
-
}) : Z ? /* @__PURE__ */ w(
|
|
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:
|
|
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(
|
|
208
|
+
/* @__PURE__ */ w(y, {
|
|
209
209
|
content: Z.content,
|
|
210
|
-
isHtml: Z.contentFormat ===
|
|
210
|
+
isHtml: Z.contentFormat === g.HTML || b(Z.content),
|
|
211
211
|
markdownMarginClass: "mt-3"
|
|
212
212
|
}),
|
|
213
|
-
/* @__PURE__ */ T(
|
|
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:
|
|
219
|
-
...
|
|
220
|
-
children: [/* @__PURE__ */ w(
|
|
221
|
-
ref:
|
|
218
|
+
onClick: ge,
|
|
219
|
+
...z.parentHandlers,
|
|
220
|
+
children: [/* @__PURE__ */ w(ne, {
|
|
221
|
+
ref: z.iconRef,
|
|
222
222
|
size: 16
|
|
223
|
-
}), /* @__PURE__ */ w("span", { children:
|
|
223
|
+
}), /* @__PURE__ */ w("span", { children: N("unresolvedCta") })]
|
|
224
224
|
}),
|
|
225
|
-
Z.id && /* @__PURE__ */ w(
|
|
226
|
-
surface:
|
|
225
|
+
Z.id && /* @__PURE__ */ w(x, {
|
|
226
|
+
surface: v.HELP,
|
|
227
227
|
itemId: Z.id,
|
|
228
228
|
reactionCounts: Z.reactionCounts,
|
|
229
|
-
viewerReaction:
|
|
230
|
-
groupItemIds:
|
|
231
|
-
isDummy:
|
|
232
|
-
showCounts:
|
|
229
|
+
viewerReaction: me,
|
|
230
|
+
groupItemIds: he,
|
|
231
|
+
isDummy: O,
|
|
232
|
+
showCounts: R,
|
|
233
233
|
className: "mt-4"
|
|
234
234
|
}),
|
|
235
|
-
/* @__PURE__ */ w(
|
|
236
|
-
currentLocale:
|
|
237
|
-
locales:
|
|
238
|
-
allowedLocales:
|
|
239
|
-
onSelect:
|
|
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 &&
|
|
241
|
+
t && j?.(t.slug, t.locale);
|
|
242
242
|
},
|
|
243
243
|
className: "mt-6"
|
|
244
244
|
}),
|
|
245
|
-
|
|
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:
|
|
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: () =>
|
|
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(
|
|
268
|
+
}) : /* @__PURE__ */ w(D, {});
|
|
269
269
|
}
|
|
270
|
-
function
|
|
271
|
-
return /* @__PURE__ */ w(
|
|
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:
|
|
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-
|
|
306
|
+
//# sourceMappingURL=widget-react-CTdz_dwX.js.map
|