@wexio/messenger-widget-react 1.2.3 → 1.3.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.
Files changed (26) hide show
  1. package/CHANGELOG.md +57 -1
  2. package/README.md +15 -1
  3. package/dist/{widget-react-DubCiNev.js → widget-react--IUy5lNt.js} +21 -20
  4. package/dist/{widget-react-CIy9jXND.js → widget-react-B7es3n1-.js} +1 -1
  5. package/dist/{widget-react-2tTH7-bO.js → widget-react-BAUpSGhZ.js} +1 -1
  6. package/dist/{widget-react-CtvdaJvy.js → widget-react-BXf2Ty8d.js} +4 -4
  7. package/dist/{widget-react-AwEaD0v2.js → widget-react-BZ-SHa2o.js} +169 -273
  8. package/dist/{widget-react-faSyVXFQ.js → widget-react-BgALABDe.js} +1 -1
  9. package/dist/{widget-react-DXP6EOCM.js → widget-react-BkXA6ytR.js} +1 -1
  10. package/dist/{widget-react-DV3UnggB.js → widget-react-CHSNuztJ.js} +137 -226
  11. package/dist/widget-react-CN_FIvMD.js +834 -0
  12. package/dist/widget-react-CuphoFsN.js +229 -0
  13. package/dist/{widget-react-DNFROpaS.js → widget-react-D8Z8cGhJ.js} +40 -48
  14. package/dist/{widget-react-B9X7Tn7t.js → widget-react-DSUX0aJn.js} +42 -50
  15. package/dist/{widget-react-CAsPo1rw.js → widget-react-DWgRcZF7.js} +127 -127
  16. package/dist/{widget-react-B9XrHKqv.js → widget-react-DbOJZl9F.js} +1238 -2052
  17. package/dist/{widget-react-BlTmXnei.js → widget-react-DgIxSjv7.js} +1 -1
  18. package/dist/widget-react-Ds5J9FbQ.js +27 -0
  19. package/dist/{widget-react-CK8xTxwO.js → widget-react-Dtx_fW3V.js} +4895 -4454
  20. package/dist/{widget-react-B8rXZyxg.js → widget-react-SI7deQTE.js} +1 -1
  21. package/dist/{widget-react-yTVzOzaU.js → widget-react-l5oryxYk.js} +87 -87
  22. package/dist/{widget-react-DDEFbIbU.js → widget-react-vXfa9GKf.js} +95 -117
  23. package/dist/widget-react-wSc9gIfG.js +198 -0
  24. package/dist/widget-react.d.ts +2 -2
  25. package/dist/widget-react.js +9370 -4672
  26. package/package.json +1 -1
@@ -32,4 +32,4 @@ function n() {
32
32
  //#endregion
33
33
  export { n as t };
34
34
 
35
- //# sourceMappingURL=widget-react-B8rXZyxg.js.map
35
+ //# sourceMappingURL=widget-react-SI7deQTE.js.map
@@ -11,15 +11,15 @@ import "react";
11
11
  import "react-dom";
12
12
  import "react/jsx-runtime";
13
13
  import "react-dom/client";
14
- import { N as e, c as t, k as n, l as r } from "./widget-react-CK8xTxwO.js";
15
- import { i, n as a, o } from "./widget-react-krPPnv02.js";
16
- import { d as s, h as c, m as l, n as u, r as d } from "./widget-react-DV3UnggB.js";
17
- import { t as f } from "./widget-react-CIy9jXND.js";
18
- import { a as p, c as ee, i as m, l as h, n as g, o as _, r as v, t as y } from "./widget-react-DDEFbIbU.js";
19
- import { useEffect as b, useRef as x, useState as S } from "react";
20
- import { jsx as C, jsxs as w } from "react/jsx-runtime";
14
+ import { F as e, M as t, c as n, dt as r, k as i, l as a, rt as o, u as s } from "./widget-react-Dtx_fW3V.js";
15
+ import { i as c, n as l, o as u } from "./widget-react-krPPnv02.js";
16
+ import { h as d, m as f, n as p, r as m } from "./widget-react-CHSNuztJ.js";
17
+ import { t as h } from "./widget-react-B7es3n1-.js";
18
+ import { a as g, c as _, i as v, l as y, n as ee, o as b, r as x, t as S } from "./widget-react-vXfa9GKf.js";
19
+ import { useEffect as C, useRef as w, useState as T } from "react";
20
+ import { jsx as E, jsxs as D } from "react/jsx-runtime";
21
21
  //#region components/widget/news-article-view/helpers.ts
22
- function T(e) {
22
+ function O(e) {
23
23
  if (!e || typeof e != "object") return null;
24
24
  let t = e, n = String(t._id ?? t.id ?? "");
25
25
  if (!n) return null;
@@ -81,10 +81,10 @@ function T(e) {
81
81
  }
82
82
  //#endregion
83
83
  //#region components/widget/news-article-view/related-news-list.tsx
84
- function E({ currentId: e, currentCategoryIds: t, currentTagIds: n, previewPostsById: r, visitorRelatedRaw: a, isDummy: o, onOpen: s }) {
85
- let c = i("news"), l = (() => {
86
- if (o) return [];
87
- if (Array.isArray(a) && a.length > 0) return a.filter((e) => !!e && typeof e == "object").map((e) => {
84
+ function k({ currentId: e, currentCategoryIds: t, currentTagIds: n, previewPostsById: r, visitorRelatedRaw: i, isDummy: a, onOpen: o }) {
85
+ let s = c("news"), l = (() => {
86
+ if (a) return [];
87
+ if (Array.isArray(i) && i.length > 0) return i.filter((e) => !!e && typeof e == "object").map((e) => {
88
88
  let t = e.coverImageUrl?.url ?? e.externalCoverImageUrl;
89
89
  return {
90
90
  id: String(e._id ?? e.id ?? ""),
@@ -124,22 +124,22 @@ function E({ currentId: e, currentCategoryIds: t, currentTagIds: n, previewPosts
124
124
  }
125
125
  return [];
126
126
  })();
127
- return l.length === 0 ? null : /* @__PURE__ */ w("section", {
127
+ return l.length === 0 ? null : /* @__PURE__ */ D("section", {
128
128
  className: "mt-6",
129
- children: [/* @__PURE__ */ C("p", {
129
+ children: [/* @__PURE__ */ E("p", {
130
130
  className: "mb-2 text-xs font-semibold tracking-wide text-wx-fg-muted uppercase",
131
- children: c("relatedTitle")
132
- }), /* @__PURE__ */ C("ul", {
131
+ children: s("relatedTitle")
132
+ }), /* @__PURE__ */ E("ul", {
133
133
  className: "flex flex-col gap-2",
134
- children: l.map((e) => /* @__PURE__ */ C("li", { children: /* @__PURE__ */ w("button", {
134
+ children: l.map((e) => /* @__PURE__ */ E("li", { children: /* @__PURE__ */ D("button", {
135
135
  type: "button",
136
- onClick: () => s(e.id),
136
+ onClick: () => o(e.id),
137
137
  className: "flex w-full items-center gap-3 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",
138
- children: [/* @__PURE__ */ C("span", {
138
+ children: [/* @__PURE__ */ E("span", {
139
139
  className: "aspect-square w-12 shrink-0 rounded-wx-sm bg-cover bg-center",
140
140
  style: e.coverImageUrl ? { backgroundImage: `url(${e.coverImageUrl})` } : { background: "linear-gradient(135deg, #1e1f21, #121314)" },
141
141
  "aria-hidden": "true"
142
- }), /* @__PURE__ */ C("span", {
142
+ }), /* @__PURE__ */ E("span", {
143
143
  className: "min-w-0 flex-1 truncate text-sm font-medium text-wx-fg",
144
144
  children: e.title
145
145
  })]
@@ -149,23 +149,23 @@ function E({ currentId: e, currentCategoryIds: t, currentTagIds: n, previewPosts
149
149
  }
150
150
  //#endregion
151
151
  //#region components/widget/news-article-view/index.tsx
152
- function D({ id: D, isDummy: k, onOpenRelated: A, onTitleResolved: j }) {
153
- let M = i("news"), N = i("demo"), P = o(), F = e(), { config: I } = n(), L = I.messenger?.showRelatedNews ?? !0, R = I.messenger?.showReactionCounts ?? !0, { trackLinkClick: z } = t(), B = x(null), V = (e) => {
154
- A?.(e);
155
- }, [H, U] = S(P), W = p(H, N), G = k ? null : F.previewData?.newsPostsById?.[D], K = !!G, { data: q, loading: J } = l({
152
+ function A({ id: A, isDummy: j, onOpenRelated: ne, onTitleResolved: re }) {
153
+ let M = c("news"), N = c("demo"), P = u(), F = t(), { config: I } = i(), L = I.messenger?.showRelatedNews ?? !0, R = I.messenger?.showReactionCounts ?? !0, { trackLinkClick: z } = n(), B = w(null), V = (e) => {
154
+ ne?.(e);
155
+ }, [H, U] = T(P), W = g(H, N), G = j ? null : F.previewData?.newsPostsById?.[A], K = !!G, { data: q, loading: J } = f({
156
156
  variables: { args: {
157
- id: D,
157
+ id: A,
158
158
  locale: P
159
159
  } },
160
- skip: k || K || !D
161
- }), { data: Y } = c({
160
+ skip: j || K || !A
161
+ }), Y = o(), ie = a(Y && !j && !K && A ? e.newsPost(Y, A, P) : null, q), { data: ae } = d({
162
162
  variables: {
163
- postId: D,
163
+ postId: A,
164
164
  limit: 5,
165
165
  locale: P
166
166
  },
167
- skip: k || K || !D || !L
168
- }), X = k ? s(W).find((e) => e.id === D) ?? null : null, Z = X ? {
167
+ skip: j || K || !A || !L
168
+ }), X = j ? r(W).find((e) => e.id === A) ?? null : null, Z = X ? {
169
169
  id: X.id,
170
170
  title: X.title,
171
171
  excerpt: X.excerpt,
@@ -179,130 +179,130 @@ function D({ id: D, isDummy: k, onOpenRelated: A, onTitleResolved: j }) {
179
179
  authors: X.authors,
180
180
  category: X.category,
181
181
  locale: H
182
- } : T(K ? G : q?.visitorNewsPost);
183
- if (_(Z?.title, j), b(() => {
184
- k || K || !Z?.id || B.current !== Z.id && (B.current = Z.id, z({
182
+ } : O(K ? G : ie?.visitorNewsPost);
183
+ if (b(Z?.title, re), C(() => {
184
+ j || K || !Z?.id || B.current !== Z.id && (B.current = Z.id, z({
185
185
  url: `/news/${Z.id}`,
186
186
  targetType: "NEWS_POST",
187
187
  targetRefId: Z.id
188
188
  }));
189
189
  }, [
190
190
  Z?.id,
191
- k,
191
+ j,
192
192
  K,
193
193
  z
194
- ]), !Z) return J ? /* @__PURE__ */ C(O, {}) : /* @__PURE__ */ C("div", {
194
+ ]), !Z) return J ? /* @__PURE__ */ E(te, {}) : /* @__PURE__ */ E("div", {
195
195
  className: "flex flex-1 items-center justify-center px-6 py-12 text-center",
196
- children: /* @__PURE__ */ C("p", {
196
+ children: /* @__PURE__ */ E("p", {
197
197
  className: "text-sm text-wx-fg-muted",
198
198
  children: M("articleNotFound")
199
199
  })
200
200
  });
201
- let te = P.split("-")[0].toLowerCase(), Q = Z.locale ? Z.locale.split("-")[0].toLowerCase() : null;
202
- if (!k && !K && !I.contentLocaleFallback && Q !== null && Q !== te) return /* @__PURE__ */ C("div", {
201
+ let oe = P.split("-")[0].toLowerCase(), Q = Z.locale ? Z.locale.split("-")[0].toLowerCase() : null;
202
+ if (!j && !K && !I.contentLocaleFallback && Q !== null && Q !== oe) return /* @__PURE__ */ E("div", {
203
203
  className: "flex flex-1 items-center justify-center px-6 py-12 text-center",
204
- children: /* @__PURE__ */ C("p", {
204
+ children: /* @__PURE__ */ E("p", {
205
205
  className: "text-sm text-wx-fg-muted",
206
206
  children: M("articleNotTranslated")
207
207
  })
208
208
  });
209
209
  let $ = Z.coverGradient ?? ["#1e1f21", "#121314"];
210
- return /* @__PURE__ */ C(r, {
210
+ return /* @__PURE__ */ E(s, {
211
211
  className: "flex-1",
212
- children: /* @__PURE__ */ w("div", {
212
+ children: /* @__PURE__ */ D("div", {
213
213
  className: "flex flex-col",
214
- children: [/* @__PURE__ */ C("div", {
215
- className: a("relative w-full"),
214
+ children: [/* @__PURE__ */ E("div", {
215
+ className: l("relative w-full"),
216
216
  style: {
217
217
  aspectRatio: "16 / 9",
218
218
  background: Z.coverImageUrl ? `url(${Z.coverImageUrl}) center/cover` : `linear-gradient(135deg, ${$[0]}, ${$[1]})`
219
219
  },
220
220
  "aria-hidden": "true"
221
- }), /* @__PURE__ */ w("div", {
221
+ }), /* @__PURE__ */ D("div", {
222
222
  className: "flex flex-col gap-3 px-5 pt-5 pb-12",
223
223
  children: [
224
- Z.category && /* @__PURE__ */ C("p", {
224
+ Z.category && /* @__PURE__ */ E("p", {
225
225
  className: "text-[11px] font-semibold tracking-[0.14em] text-wx-primary uppercase",
226
226
  children: Z.category.label
227
227
  }),
228
- /* @__PURE__ */ w("p", {
228
+ /* @__PURE__ */ D("p", {
229
229
  className: "flex items-center gap-2 text-xs text-wx-fg-subtle",
230
- children: [/* @__PURE__ */ C("span", { children: new Date(Z.publishedAt).toLocaleDateString(P, {
230
+ children: [/* @__PURE__ */ E("span", { children: new Date(Z.publishedAt).toLocaleDateString(P, {
231
231
  month: "long",
232
232
  day: "numeric",
233
233
  year: "numeric"
234
- }) }), d(Z) && Z.upstreamUpdatedAt && /* @__PURE__ */ C("span", {
234
+ }) }), m(Z) && Z.upstreamUpdatedAt && /* @__PURE__ */ E("span", {
235
235
  className: "rounded-full bg-wx-bg-elevated px-1.5 py-0.5 text-[10px] font-medium text-wx-fg-muted",
236
236
  title: new Date(Z.upstreamUpdatedAt).toLocaleString(P),
237
- children: M("editedAt", { when: u(Z.upstreamUpdatedAt) })
237
+ children: M("editedAt", { when: p(Z.upstreamUpdatedAt) })
238
238
  })]
239
239
  }),
240
- /* @__PURE__ */ C("h2", {
240
+ /* @__PURE__ */ E("h2", {
241
241
  className: "text-2xl leading-tight font-bold text-wx-fg",
242
242
  children: Z.title
243
243
  }),
244
- Z.authors && Z.authors.length > 0 && /* @__PURE__ */ w("p", {
244
+ Z.authors && Z.authors.length > 0 && /* @__PURE__ */ D("p", {
245
245
  className: "flex items-center gap-2 text-xs text-wx-fg-muted",
246
- children: [/* @__PURE__ */ C("span", {
246
+ children: [/* @__PURE__ */ E("span", {
247
247
  className: "flex -space-x-1.5",
248
- children: Z.authors.slice(0, 3).map((e) => /* @__PURE__ */ C("span", {
248
+ children: Z.authors.slice(0, 3).map((e) => /* @__PURE__ */ E("span", {
249
249
  className: "h-5 w-5 overflow-hidden rounded-full bg-wx-bg-elevated ring-1 ring-wx-bg",
250
250
  "aria-hidden": "true",
251
- children: /* @__PURE__ */ C("img", {
251
+ children: /* @__PURE__ */ E("img", {
252
252
  src: e.photo.url,
253
253
  alt: "",
254
254
  className: "h-full w-full object-cover"
255
255
  })
256
256
  }, e._id))
257
- }), /* @__PURE__ */ C("span", { children: M("writtenBy", { names: Z.authors.map((e) => e.name).join(", ") }) })]
257
+ }), /* @__PURE__ */ E("span", { children: M("writtenBy", { names: Z.authors.map((e) => e.name).join(", ") }) })]
258
258
  }),
259
- Z.tags && Z.tags.length > 0 && /* @__PURE__ */ C("div", {
259
+ Z.tags && Z.tags.length > 0 && /* @__PURE__ */ E("div", {
260
260
  className: "flex flex-wrap gap-1",
261
- children: Z.tags.map((e) => /* @__PURE__ */ C("span", {
261
+ children: Z.tags.map((e) => /* @__PURE__ */ E("span", {
262
262
  className: "rounded-full bg-wx-bg-elevated px-2 py-0.5 text-[11px] font-medium text-wx-fg-muted",
263
263
  children: e.label
264
264
  }, e.slug))
265
265
  }),
266
- Z.excerpt && /* @__PURE__ */ C("p", {
266
+ Z.excerpt && /* @__PURE__ */ E("p", {
267
267
  className: "text-base leading-relaxed text-wx-fg-muted",
268
268
  children: Z.excerpt
269
269
  }),
270
- Z.contentMarkdown && /* @__PURE__ */ C(v, {
270
+ Z.contentMarkdown && /* @__PURE__ */ E(x, {
271
271
  content: Z.contentMarkdown,
272
- isHtml: Z.bodyFormat === "html" || h(Z.contentMarkdown),
272
+ isHtml: Z.bodyFormat === "html" || y(Z.contentMarkdown),
273
273
  markdownMarginClass: "mt-3"
274
274
  }),
275
- Z.sourceUrl && /* @__PURE__ */ w("a", {
275
+ Z.sourceUrl && /* @__PURE__ */ D("a", {
276
276
  href: Z.sourceUrl,
277
277
  target: "_blank",
278
278
  rel: "noopener noreferrer",
279
279
  className: "mt-4 flex items-center justify-center gap-1.5 text-xs text-wx-primary underline underline-offset-2 transition-opacity hover:opacity-80",
280
- children: [/* @__PURE__ */ C(f, { size: 12 }), /* @__PURE__ */ C("span", { children: M("readOriginal") })]
280
+ children: [/* @__PURE__ */ E(h, { size: 12 }), /* @__PURE__ */ E("span", { children: M("readOriginal") })]
281
281
  }),
282
- L && /* @__PURE__ */ C(E, {
282
+ L && /* @__PURE__ */ E(k, {
283
283
  currentId: Z.id,
284
284
  currentCategoryIds: Z.categoryIds ?? [],
285
285
  currentTagIds: Z.tagIds ?? [],
286
- previewPostsById: k ? void 0 : F.previewData?.newsPostsById,
287
- visitorRelatedRaw: Y?.visitorNewsRelated,
288
- isDummy: k,
286
+ previewPostsById: j ? void 0 : F.previewData?.newsPostsById,
287
+ visitorRelatedRaw: ae?.visitorNewsRelated,
288
+ isDummy: j,
289
289
  onOpen: V
290
290
  }),
291
- Z.id && /* @__PURE__ */ C(y, {
292
- surface: ee.NEWS,
291
+ Z.id && /* @__PURE__ */ E(S, {
292
+ surface: _.NEWS,
293
293
  itemId: Z.id,
294
294
  reactionCounts: Z.reactionCounts ?? null,
295
295
  viewerReaction: Z.viewerReaction ?? null,
296
296
  groupItemIds: [Z.id, ...(Z.translations ?? []).map((e) => e.id)],
297
- isDummy: k,
297
+ isDummy: j,
298
298
  showCounts: R,
299
299
  className: "mt-6"
300
300
  }),
301
- /* @__PURE__ */ C(g, {
302
- currentLocale: k ? H : Z.locale ?? P,
303
- locales: k ? [...m] : (Z.translations ?? []).map((e) => e.locale),
304
- allowedLocales: k ? void 0 : I.supportedLocales,
305
- onSelect: k ? (e) => U(e) : (e) => {
301
+ /* @__PURE__ */ E(ee, {
302
+ currentLocale: j ? H : Z.locale ?? P,
303
+ locales: j ? [...v] : (Z.translations ?? []).map((e) => e.locale),
304
+ allowedLocales: j ? void 0 : I.supportedLocales,
305
+ onSelect: j ? (e) => U(e) : (e) => {
306
306
  let t = (Z.translations ?? []).find((t) => t.locale === e);
307
307
  t && V(t.id);
308
308
  },
@@ -313,28 +313,28 @@ function D({ id: D, isDummy: k, onOpenRelated: A, onTitleResolved: j }) {
313
313
  })
314
314
  });
315
315
  }
316
- function O() {
317
- return /* @__PURE__ */ C(r, {
316
+ function te() {
317
+ return /* @__PURE__ */ E(s, {
318
318
  className: "flex-1",
319
- children: /* @__PURE__ */ w("div", {
319
+ children: /* @__PURE__ */ D("div", {
320
320
  className: "flex flex-col",
321
321
  "aria-busy": "true",
322
322
  "aria-live": "polite",
323
- children: [/* @__PURE__ */ C("div", {
323
+ children: [/* @__PURE__ */ E("div", {
324
324
  className: "w-full animate-pulse bg-wx-bg-elevated",
325
325
  style: { aspectRatio: "16 / 9" }
326
- }), /* @__PURE__ */ w("div", {
326
+ }), /* @__PURE__ */ D("div", {
327
327
  className: "px-5 pt-5 pb-12",
328
328
  children: [
329
- /* @__PURE__ */ w("div", {
329
+ /* @__PURE__ */ D("div", {
330
330
  className: "animate-pulse space-y-2.5",
331
- children: [/* @__PURE__ */ C("div", { className: "h-5 w-3/4 rounded-md bg-wx-bg-elevated" }), /* @__PURE__ */ C("div", { className: "h-5 w-1/2 rounded-md bg-wx-bg-elevated" })]
331
+ children: [/* @__PURE__ */ E("div", { className: "h-5 w-3/4 rounded-md bg-wx-bg-elevated" }), /* @__PURE__ */ E("div", { className: "h-5 w-1/2 rounded-md bg-wx-bg-elevated" })]
332
332
  }),
333
- /* @__PURE__ */ C("div", {
333
+ /* @__PURE__ */ E("div", {
334
334
  className: "mt-4 flex items-center gap-2 animate-pulse",
335
- children: /* @__PURE__ */ C("div", { className: "h-3 w-24 rounded-md bg-wx-bg-elevated" })
335
+ children: /* @__PURE__ */ E("div", { className: "h-3 w-24 rounded-md bg-wx-bg-elevated" })
336
336
  }),
337
- /* @__PURE__ */ C("div", {
337
+ /* @__PURE__ */ E("div", {
338
338
  className: "mt-6 space-y-2.5 animate-pulse",
339
339
  children: [
340
340
  "w-full",
@@ -343,7 +343,7 @@ function O() {
343
343
  "w-full",
344
344
  "w-9/12",
345
345
  "w-7/12"
346
- ].map((e, t) => /* @__PURE__ */ C("div", { className: a("h-3 rounded-md bg-wx-bg-elevated", e) }, t))
346
+ ].map((e, t) => /* @__PURE__ */ E("div", { className: l("h-3 rounded-md bg-wx-bg-elevated", e) }, t))
347
347
  })
348
348
  ]
349
349
  })]
@@ -351,6 +351,6 @@ function O() {
351
351
  });
352
352
  }
353
353
  //#endregion
354
- export { D as NewsArticleView };
354
+ export { A as NewsArticleView };
355
355
 
356
- //# sourceMappingURL=widget-react-yTVzOzaU.js.map
356
+ //# sourceMappingURL=widget-react-l5oryxYk.js.map