@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
|
@@ -12,7 +12,7 @@ import "react-dom";
|
|
|
12
12
|
import "react/jsx-runtime";
|
|
13
13
|
import "react-dom/client";
|
|
14
14
|
import { t as e } from "./widget-react-DbOJZl9F.js";
|
|
15
|
-
import {
|
|
15
|
+
import { D as t, Dt as n, H as r, O as i, R as a, T as o, V as s, a as c, i as l, n as u, t as d } from "./widget-react-Ck8JAYqT.js";
|
|
16
16
|
import { i as f, n as p } from "./widget-react-krPPnv02.js";
|
|
17
17
|
import { n as m } from "./widget-react-wSc9gIfG.js";
|
|
18
18
|
import { useCallback as h, useEffect as g, useMemo as _, useRef as v, useState as y } from "react";
|
|
@@ -38,44 +38,16 @@ function T(e, t) {
|
|
|
38
38
|
}, [e, t]);
|
|
39
39
|
}
|
|
40
40
|
//#endregion
|
|
41
|
-
//#region lib/use-demo-translator.ts
|
|
42
|
-
var E = ["en", "uk"];
|
|
43
|
-
async function D(e) {
|
|
44
|
-
switch (e) {
|
|
45
|
-
case "uk": return (await import("./widget-react-DSUX0aJn.js")).default;
|
|
46
|
-
default: return (await import("./widget-react-D8Z8cGhJ.js")).default;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function O(e) {
|
|
50
|
-
return (t) => {
|
|
51
|
-
let n = e;
|
|
52
|
-
for (let e of t.split(".")) if (n && typeof n == "object" && e in n) n = n[e];
|
|
53
|
-
else return;
|
|
54
|
-
return n;
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
function k(e, t) {
|
|
58
|
-
let [n, r] = y(null);
|
|
59
|
-
return g(() => {
|
|
60
|
-
let t = !0;
|
|
61
|
-
return D(e).then((e) => {
|
|
62
|
-
t && r({ raw: O(e) });
|
|
63
|
-
}), () => {
|
|
64
|
-
t = !1;
|
|
65
|
-
};
|
|
66
|
-
}, [e]), n ?? t;
|
|
67
|
-
}
|
|
68
|
-
//#endregion
|
|
69
41
|
//#region lib/article-prose.ts
|
|
70
|
-
var
|
|
42
|
+
var E = (/* @__PURE__ */ "prose max-w-none text-sm leading-relaxed text-wx-fg,[&_p]:my-3 [&_strong]:font-semibold [&_em]:italic,[&_a]:text-wx-primary [&_a]:underline [&_a]:underline-offset-2,[&_a]:transition-opacity [&_a:hover]:opacity-70,[&_code]:rounded-[6px] [&_code]:bg-wx-bg-elevated [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.85em],[&_pre]:my-4 [&_pre]:overflow-x-auto [&_pre]:rounded-lg [&_pre]:border [&_pre]:border-wx-border,[&_pre]:bg-[#0f1115] [&_pre]:text-zinc-100 [&_pre]:p-4 [&_pre]:text-[12.5px] [&_pre]:leading-relaxed,[&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-zinc-100,[&_.hljs-keyword]:text-violet-300 [&_.hljs-built_in]:text-violet-300 [&_.hljs-type]:text-violet-300,[&_.hljs-string]:text-emerald-300,[&_.hljs-number]:text-amber-300 [&_.hljs-literal]:text-amber-300,[&_.hljs-comment]:text-zinc-500 [&_.hljs-comment]:italic,[&_.hljs-attr]:text-sky-300 [&_.hljs-attribute]:text-sky-300,[&_.hljs-title]:text-zinc-100 [&_.hljs-title]:font-medium,[&_.hljs-tag]:text-rose-300 [&_.hljs-name]:text-rose-300,[&_h1]:mt-6 [&_h1]:mb-3 [&_h1]:text-xl [&_h1]:font-semibold [&_h1]:tracking-tight,[&_h2]:mt-5 [&_h2]:mb-2 [&_h2]:text-base [&_h2]:font-semibold [&_h2]:tracking-tight,[&_h3]:mt-4 [&_h3]:mb-1.5 [&_h3]:text-sm [&_h3]:font-semibold,[&_h1]:scroll-mt-16 [&_h2]:scroll-mt-16 [&_h3]:scroll-mt-16,[&_ul]:my-3 [&_ul]:list-disc [&_ul]:pl-5 [&_ul]:marker:text-wx-fg-subtle,[&_ol]:my-3 [&_ol]:list-decimal [&_ol]:pl-5 [&_ol]:marker:text-wx-fg-subtle,[&_li]:my-1,[&_ul[data-type=taskList]]:list-none! [&_ul[data-type=taskList]]:pl-0!,[&_ul[data-type=taskList]_li]:my-1.5 [&_ul[data-type=taskList]_li]:flex! [&_ul[data-type=taskList]_li]:items-start [&_ul[data-type=taskList]_li]:gap-2 [&_ul[data-type=taskList]_li]:pl-0,[&_ul[data-type=taskList]_li]:marker:content-none,[&_ul[data-type=taskList]_li>label]:m-0 [&_ul[data-type=taskList]_li>label]:inline-flex [&_ul[data-type=taskList]_li>label]:h-5 [&_ul[data-type=taskList]_li>label]:items-center [&_ul[data-type=taskList]_li>label]:shrink-0 [&_ul[data-type=taskList]_li>label]:select-none,[&_ul[data-type=taskList]_li>label]:pointer-events-none [&_ul[data-type=taskList]_li>label]:cursor-default,[&_ul[data-type=taskList]_input]:accent-wx-primary [&_ul[data-type=taskList]_input]:h-3.5 [&_ul[data-type=taskList]_input]:w-3.5,[&_ul[data-type=taskList]_li>label>span]:hidden,[&_ul[data-type=taskList]_li>div]:min-w-0 [&_ul[data-type=taskList]_li>div]:flex-1,[&_ul[data-type=taskList]_li>div>p]:my-0! [&_ul[data-type=taskList]_li>div>p]:leading-snug,[&_ul[data-type=taskList]_li[data-checked=true]>div]:text-wx-fg-muted [&_ul[data-type=taskList]_li[data-checked=true]>div]:line-through,[&_blockquote]:my-4 [&_blockquote]:border-l-2 [&_blockquote]:border-wx-primary/40,[&_blockquote]:pl-3 [&_blockquote]:italic [&_blockquote]:text-wx-fg-muted,[&_hr]:my-6 [&_hr]:border-wx-border,[&_img]:my-3 [&_img]:mx-auto [&_img]:block [&_img]:max-w-full,[&_figure]:my-5 [&_figure]:flex [&_figure]:flex-col [&_figure]:items-center [&_figure]:text-center,[&_figure_img]:my-0,[&_figcaption]:mt-2 [&_figcaption]:text-xs [&_figcaption]:italic [&_figcaption]:text-wx-fg-muted,[&_table]:my-3 [&_table]:w-full [&_table]:table-fixed [&_table]:border-collapse [&_table]:text-xs,[&_table]:overflow-hidden [&_table]:rounded-lg [&_table]:border [&_table]:border-wx-border,[&_thead]:bg-wx-bg-elevated,[&_th]:px-2.5 [&_th]:py-1.5 [&_th]:text-left [&_th]:font-medium [&_th]:text-wx-fg,[&_th]:border-b [&_th]:border-wx-border,[&_th+th]:border-l [&_th+th]:border-wx-border,[&_td]:px-2.5 [&_td]:py-1.5 [&_td]:text-wx-fg [&_td]:align-top,[&_td+td]:border-l [&_td+td]:border-wx-border,[&_tbody_tr]:border-t [&_tbody_tr]:border-wx-border,[&_tbody_tr:nth-child(odd)]:bg-wx-bg-elevated/40,[&_th_p]:my-0 [&_td_p]:my-0 [&_th_p]:inline [&_td_p]:inline,[&_details]:my-2 [&_details]:overflow-hidden [&_details]:rounded-lg [&_details]:border [&_details]:border-wx-border [&_details]:bg-wx-bg-elevated/40,[&_details+details]:mt-2,[&_summary]:relative [&_summary]:cursor-pointer [&_summary]:list-none [&_summary]:px-4 [&_summary]:py-3,[&_summary]:pr-10 [&_summary]:text-sm [&_summary]:font-medium [&_summary]:text-wx-fg,[&_summary::-webkit-details-marker]:hidden [&_summary::marker]:hidden,[&_summary]:after:absolute [&_summary]:after:right-4 [&_summary]:after:top-1/2,[&_summary]:after:-translate-y-1/2 [&_summary]:after:text-wx-fg-subtle,[&_summary]:after:text-base [&_summary]:after:leading-none,[&_summary]:after:transition-transform [&_summary]:after:content-['\\203A'],[&_details[open]_summary]:after:rotate-90,[&_details[open]_summary]:border-b [&_details[open]_summary]:border-wx-border,[&_details]:[&>:not(summary)]:px-4 [&_details]:[&>:not(summary)]:py-3,[&_details]:[&>:not(summary):first-of-type]:pt-3".split(",")).join(" ");
|
|
71
43
|
//#endregion
|
|
72
44
|
//#region components/widget/article-body.tsx
|
|
73
|
-
function
|
|
45
|
+
function D({ content: e, isHtml: t, markdownMarginClass: n }) {
|
|
74
46
|
return t ? /* @__PURE__ */ b(u, {
|
|
75
47
|
html: e,
|
|
76
|
-
className: `mt-0 ${
|
|
48
|
+
className: `mt-0 ${E}`
|
|
77
49
|
}) : /* @__PURE__ */ b("div", {
|
|
78
|
-
className: `${n} ${
|
|
50
|
+
className: `${n} ${E}`,
|
|
79
51
|
children: /* @__PURE__ */ b(c, {
|
|
80
52
|
remarkPlugins: [l],
|
|
81
53
|
children: e
|
|
@@ -84,12 +56,12 @@ function j({ content: e, isHtml: t, markdownMarginClass: n }) {
|
|
|
84
56
|
}
|
|
85
57
|
//#endregion
|
|
86
58
|
//#region components/widget/language-selector/index.tsx
|
|
87
|
-
function
|
|
59
|
+
function O({ currentLocale: n, locales: r, allowedLocales: a, onSelect: s, className: c }) {
|
|
88
60
|
let l = f("languageSelector"), [u, h] = y(!1), _ = v(null);
|
|
89
61
|
g(() => {
|
|
90
62
|
if (!u) return;
|
|
91
63
|
let e = (e) => {
|
|
92
|
-
_.current && !
|
|
64
|
+
_.current && !e.composedPath().includes(_.current) && h(!1);
|
|
93
65
|
}, t = (e) => {
|
|
94
66
|
e.key === "Escape" && h(!1);
|
|
95
67
|
};
|
|
@@ -99,7 +71,7 @@ function M({ currentLocale: t, locales: r, allowedLocales: a, onSelect: o, class
|
|
|
99
71
|
}, [u]);
|
|
100
72
|
let S = a && a.length > 0 ? new Set(a.map((e) => e.split("-")[0].toLowerCase())) : null, C = Array.from(new Set(r.filter(Boolean))).filter((e) => !S || S.has(e.split("-")[0].toLowerCase()));
|
|
101
73
|
if (C.length <= 1) return null;
|
|
102
|
-
let w =
|
|
74
|
+
let w = n.split("-")[0].toLowerCase();
|
|
103
75
|
return /* @__PURE__ */ x("div", {
|
|
104
76
|
ref: _,
|
|
105
77
|
className: p("relative", c),
|
|
@@ -116,15 +88,15 @@ function M({ currentLocale: t, locales: r, allowedLocales: a, onSelect: o, class
|
|
|
116
88
|
"aria-label": l("ariaLabel"),
|
|
117
89
|
className: p("flex w-full items-center gap-2 rounded-wx-sm border border-wx-border bg-wx-bg px-3 py-2", "text-sm font-medium text-wx-fg transition-colors hover:bg-wx-bg-elevated", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-wx-primary"),
|
|
118
90
|
children: [
|
|
119
|
-
/* @__PURE__ */ b(
|
|
91
|
+
/* @__PURE__ */ b(o, {
|
|
120
92
|
size: 15,
|
|
121
93
|
className: "shrink-0 text-wx-fg-muted"
|
|
122
94
|
}),
|
|
123
95
|
/* @__PURE__ */ b("span", {
|
|
124
96
|
className: "min-w-0 flex-1 truncate text-left",
|
|
125
|
-
children: d(
|
|
97
|
+
children: d(n)
|
|
126
98
|
}),
|
|
127
|
-
/* @__PURE__ */ b(
|
|
99
|
+
/* @__PURE__ */ b(t, {
|
|
128
100
|
size: 15,
|
|
129
101
|
className: p("shrink-0 text-wx-fg-subtle transition-transform", u && "rotate-180")
|
|
130
102
|
})
|
|
@@ -153,7 +125,7 @@ function M({ currentLocale: t, locales: r, allowedLocales: a, onSelect: o, class
|
|
|
153
125
|
role: "option",
|
|
154
126
|
"aria-selected": t,
|
|
155
127
|
onClick: () => {
|
|
156
|
-
|
|
128
|
+
s(e), h(!1);
|
|
157
129
|
},
|
|
158
130
|
className: p("flex w-full items-center gap-2 px-3 py-2 text-left text-sm transition-colors", t ? "font-semibold text-wx-primary" : "text-wx-fg hover:bg-wx-bg-elevated"),
|
|
159
131
|
children: [/* @__PURE__ */ b("span", {
|
|
@@ -171,7 +143,7 @@ function M({ currentLocale: t, locales: r, allowedLocales: a, onSelect: o, class
|
|
|
171
143
|
}
|
|
172
144
|
//#endregion
|
|
173
145
|
//#region components/widget/reaction-bar.tsx
|
|
174
|
-
var
|
|
146
|
+
var k = (e, t) => `wexio:reaction:${e}:${t}`, A = [
|
|
175
147
|
{
|
|
176
148
|
slotIndex: 0,
|
|
177
149
|
emoji: "🎉"
|
|
@@ -184,70 +156,70 @@ var N = (e, t) => `wexio:reaction:${e}:${t}`, P = [
|
|
|
184
156
|
slotIndex: 2,
|
|
185
157
|
emoji: "👍"
|
|
186
158
|
}
|
|
187
|
-
],
|
|
159
|
+
], j = {
|
|
188
160
|
[w.NEWS]: "NewsPost",
|
|
189
161
|
[w.HELP]: "HelpArticle"
|
|
190
162
|
};
|
|
191
|
-
function
|
|
192
|
-
let S = f("reactions"), C =
|
|
193
|
-
variables: { surface:
|
|
163
|
+
function M({ surface: t, itemId: i, reactionCounts: o, viewerReaction: c, groupItemIds: l, readonly: u = !1, showCounts: d = !0, isDummy: m = !1, className: v }) {
|
|
164
|
+
let S = f("reactions"), C = n(), { data: w, loading: T } = r({
|
|
165
|
+
variables: { surface: t },
|
|
194
166
|
fetchPolicy: "cache-first",
|
|
195
167
|
skip: m
|
|
196
|
-
}), [E, { loading: D }] =
|
|
168
|
+
}), [E, { loading: D }] = s(), O = a(), M = _(() => m ? A : w?.visitorReactionSet?.slots ?? [], [m, w]), N = m ? !0 : w?.visitorReactionSet?.enabled ?? !0, P = k(t, i), [F, I] = y(null);
|
|
197
169
|
g(() => {
|
|
198
170
|
if (!m) {
|
|
199
171
|
I(c ?? null);
|
|
200
172
|
return;
|
|
201
173
|
}
|
|
202
174
|
if (typeof window > "u") return;
|
|
203
|
-
let e = window.localStorage.getItem(
|
|
175
|
+
let e = window.localStorage.getItem(P);
|
|
204
176
|
I(e === null ? null : Number(e));
|
|
205
177
|
}, [
|
|
206
178
|
m,
|
|
207
|
-
|
|
179
|
+
P,
|
|
208
180
|
c
|
|
209
181
|
]);
|
|
210
|
-
let [L, R] = y({}), z = (e) => (
|
|
211
|
-
let r =
|
|
212
|
-
for (let
|
|
182
|
+
let [L, R] = y({}), z = (e) => (o?.[String(e)] ?? 0) + (m ? L[e] ?? 0 : 0), B = h((e, n) => {
|
|
183
|
+
let r = j[t], a = l?.length ? l : [i];
|
|
184
|
+
for (let t of a) {
|
|
213
185
|
let i = C.cache.identify({
|
|
214
186
|
__typename: r,
|
|
215
|
-
_id:
|
|
187
|
+
_id: t
|
|
216
188
|
});
|
|
217
189
|
i && C.cache.modify({
|
|
218
190
|
id: i,
|
|
219
191
|
fields: {
|
|
220
|
-
viewerReaction: () =>
|
|
221
|
-
reactionCounts: (
|
|
222
|
-
let r = { ...
|
|
223
|
-
return
|
|
192
|
+
viewerReaction: () => n,
|
|
193
|
+
reactionCounts: (t) => {
|
|
194
|
+
let r = { ...t ?? {} };
|
|
195
|
+
return n !== null && (r[n] = (r[n] ?? 0) + 1), e !== null && (r[e] = Math.max(0, (r[e] ?? 0) - 1)), r;
|
|
224
196
|
}
|
|
225
197
|
}
|
|
226
198
|
});
|
|
227
199
|
}
|
|
228
200
|
}, [
|
|
229
201
|
C,
|
|
230
|
-
|
|
202
|
+
t,
|
|
231
203
|
l,
|
|
232
204
|
i
|
|
233
205
|
]), V = async (e) => {
|
|
234
|
-
if (u || D ||
|
|
235
|
-
let
|
|
206
|
+
if (u || D || F === e) return;
|
|
207
|
+
let n = F;
|
|
236
208
|
if (I(e), m) {
|
|
237
|
-
typeof window < "u" && window.localStorage.setItem(
|
|
238
|
-
...
|
|
239
|
-
[e]: (
|
|
240
|
-
...
|
|
209
|
+
typeof window < "u" && window.localStorage.setItem(P, String(e)), R((t) => ({
|
|
210
|
+
...t,
|
|
211
|
+
[e]: (t[e] ?? 0) + 1,
|
|
212
|
+
...n === null ? {} : { [n]: (t[n] ?? 0) - 1 }
|
|
241
213
|
}));
|
|
242
214
|
return;
|
|
243
215
|
}
|
|
244
|
-
if (B(
|
|
216
|
+
if (B(n, e), O) {
|
|
245
217
|
O.enqueue({
|
|
246
218
|
op: "reaction",
|
|
247
219
|
semantics: "convergence",
|
|
248
|
-
convergenceKey: `reaction:${
|
|
220
|
+
convergenceKey: `reaction:${t}:${i}`,
|
|
249
221
|
payload: {
|
|
250
|
-
surface:
|
|
222
|
+
surface: t,
|
|
251
223
|
itemId: i,
|
|
252
224
|
slotIndex: e
|
|
253
225
|
}
|
|
@@ -256,20 +228,20 @@ function I({ surface: n, itemId: i, reactionCounts: s, viewerReaction: c, groupI
|
|
|
256
228
|
}
|
|
257
229
|
try {
|
|
258
230
|
await E({ variables: { input: {
|
|
259
|
-
surface:
|
|
231
|
+
surface: t,
|
|
260
232
|
itemId: i,
|
|
261
233
|
slotIndex: e
|
|
262
234
|
} } });
|
|
263
235
|
} catch {
|
|
264
|
-
B(e,
|
|
236
|
+
B(e, n), I(n);
|
|
265
237
|
}
|
|
266
238
|
};
|
|
267
|
-
return T || !
|
|
239
|
+
return T || !N || M.length === 0 ? null : /* @__PURE__ */ b("div", {
|
|
268
240
|
className: p("flex flex-wrap items-center justify-center gap-2", v),
|
|
269
241
|
role: "group",
|
|
270
242
|
"aria-label": S("ariaLabel"),
|
|
271
|
-
children:
|
|
272
|
-
let n =
|
|
243
|
+
children: M.map((t) => {
|
|
244
|
+
let n = F === t.slotIndex, r = z(t.slotIndex);
|
|
273
245
|
return /* @__PURE__ */ x(e.button, {
|
|
274
246
|
type: "button",
|
|
275
247
|
disabled: u || D,
|
|
@@ -296,6 +268,6 @@ function I({ surface: n, itemId: i, reactionCounts: s, viewerReaction: c, groupI
|
|
|
296
268
|
});
|
|
297
269
|
}
|
|
298
270
|
//#endregion
|
|
299
|
-
export {
|
|
271
|
+
export { C as a, T as i, O as n, w as o, D as r, S as s, M as t };
|
|
300
272
|
|
|
301
|
-
//# sourceMappingURL=widget-react-
|
|
273
|
+
//# sourceMappingURL=widget-react-CyAVDflZ.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.
|
|
72
|
-
y.current
|
|
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-
|
|
229
|
+
//# sourceMappingURL=widget-react-DSAyUf2U.js.map
|