@wexio/messenger-widget-react 1.1.2 → 1.1.4

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,11 +11,11 @@ import "react";
11
11
  import "react-dom";
12
12
  import "react/jsx-runtime";
13
13
  import "react-dom/client";
14
- import { E as e, S as t, r as n } from "./widget-react-D4IN0PAd.js";
15
- import { a as r, c as i, i as a, l as o, n as s, o as c, r as l, t as u } from "./widget-react-qdPNeB-W.js";
16
- import { i as d, n as f, o as p } from "./widget-react-CQ0DMi7b.js";
17
- import { d as m, h, m as g, n as _, r as v } from "./widget-react-CQ0MdjMO.js";
18
- import { t as y } from "./widget-react-DP-dfZKt.js";
14
+ import { T as e, k as t, o as n } from "./widget-react-BFgpQWPW.js";
15
+ import { i as r, n as i, o as a } from "./widget-react-BGCZpMUT.js";
16
+ import { d as o, h as s, m as c, n as l, r as u } from "./widget-react-BDd1HJHs.js";
17
+ import { t as d } from "./widget-react-D_1wQTaz.js";
18
+ import { a as f, c as p, i as m, l as h, n as g, o as _, r as v, t as y } from "./widget-react-CPnUEeex.js";
19
19
  import { useState as b } from "react";
20
20
  import { jsx as x, jsxs as S } from "react/jsx-runtime";
21
21
  //#region components/widget/news-article-view/helpers.ts
@@ -81,10 +81,10 @@ function C(e) {
81
81
  }
82
82
  //#endregion
83
83
  //#region components/widget/news-article-view/related-news-list.tsx
84
- function w({ currentId: e, currentCategoryIds: t, currentTagIds: n, previewPostsById: r, visitorRelatedRaw: i, isDummy: a, onOpen: o }) {
85
- let s = d("news"), c = (() => {
86
- if (a) return [];
87
- if (Array.isArray(i) && i.length > 0) return i.filter((e) => !!e && typeof e == "object").map((e) => {
84
+ function w({ currentId: e, currentCategoryIds: t, currentTagIds: n, previewPostsById: i, visitorRelatedRaw: a, isDummy: o, onOpen: s }) {
85
+ let c = r("news"), l = (() => {
86
+ if (o) return [];
87
+ if (Array.isArray(a) && a.length > 0) return a.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 ?? ""),
@@ -92,11 +92,11 @@ function w({ currentId: e, currentCategoryIds: t, currentTagIds: n, previewPosts
92
92
  coverImageUrl: typeof t == "string" ? t : void 0
93
93
  };
94
94
  }).filter((e) => e.id && e.title);
95
- if (r && Object.keys(r).length > 0 && (t.length > 0 || n.length > 0)) {
96
- let i = new Set(t), a = new Set(n), o = [];
97
- for (let [t, n] of Object.entries(r)) {
95
+ if (i && Object.keys(i).length > 0 && (t.length > 0 || n.length > 0)) {
96
+ let r = new Set(t), a = new Set(n), o = [];
97
+ for (let [t, n] of Object.entries(i)) {
98
98
  if (t === e || !n || typeof n != "object") continue;
99
- let r = n, s = Array.isArray(r.categories) ? r.categories : [], c = Array.isArray(r.tags) ? r.tags : [], l = (e) => {
99
+ let i = n, s = Array.isArray(i.categories) ? i.categories : [], c = Array.isArray(i.tags) ? i.tags : [], l = (e) => {
100
100
  let t = /* @__PURE__ */ new Set();
101
101
  for (let n of e) if (n && typeof n == "object") {
102
102
  let e = n._id ?? n.id;
@@ -104,16 +104,16 @@ function w({ currentId: e, currentCategoryIds: t, currentTagIds: n, previewPosts
104
104
  }
105
105
  return t;
106
106
  }, u = l(s), d = l(c), f = 0;
107
- for (let e of u) i.has(e) && f++;
107
+ for (let e of u) r.has(e) && f++;
108
108
  for (let e of d) a.has(e) && f++;
109
109
  if (f === 0) continue;
110
- let p = r.coverImageUrl?.url ?? r.externalCoverImageUrl;
110
+ let p = i.coverImageUrl?.url ?? i.externalCoverImageUrl;
111
111
  o.push({
112
112
  id: t,
113
- title: typeof r.title == "string" ? r.title : "",
113
+ title: typeof i.title == "string" ? i.title : "",
114
114
  coverImageUrl: typeof p == "string" ? p : void 0,
115
115
  overlap: f,
116
- publishedAt: typeof r.publishedAt == "string" ? r.publishedAt : ""
116
+ publishedAt: typeof i.publishedAt == "string" ? i.publishedAt : ""
117
117
  });
118
118
  }
119
119
  return o.sort((e, t) => t.overlap === e.overlap ? t.publishedAt.localeCompare(e.publishedAt) : t.overlap - e.overlap), o.slice(0, 5).map(({ id: e, title: t, coverImageUrl: n }) => ({
@@ -124,16 +124,16 @@ function w({ currentId: e, currentCategoryIds: t, currentTagIds: n, previewPosts
124
124
  }
125
125
  return [];
126
126
  })();
127
- return c.length === 0 ? null : /* @__PURE__ */ S("section", {
127
+ return l.length === 0 ? null : /* @__PURE__ */ S("section", {
128
128
  className: "mt-6",
129
129
  children: [/* @__PURE__ */ x("p", {
130
130
  className: "mb-2 text-xs font-semibold tracking-wide text-wx-fg-muted uppercase",
131
- children: s("relatedTitle")
131
+ children: c("relatedTitle")
132
132
  }), /* @__PURE__ */ x("ul", {
133
133
  className: "flex flex-col gap-2",
134
- children: c.map((e) => /* @__PURE__ */ x("li", { children: /* @__PURE__ */ S("button", {
134
+ children: l.map((e) => /* @__PURE__ */ x("li", { children: /* @__PURE__ */ S("button", {
135
135
  type: "button",
136
- onClick: () => o(e.id),
136
+ onClick: () => s(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
138
  children: [/* @__PURE__ */ x("span", {
139
139
  className: "aspect-square w-12 shrink-0 rounded-wx-sm bg-cover bg-center",
@@ -150,20 +150,20 @@ function w({ currentId: e, currentCategoryIds: t, currentTagIds: n, previewPosts
150
150
  //#endregion
151
151
  //#region components/widget/news-article-view/index.tsx
152
152
  function T({ id: T, isDummy: D, onOpenRelated: O, onTitleResolved: k }) {
153
- let A = d("news"), j = d("demo"), M = p(), N = e(), { config: P } = t(), F = P.messenger?.showRelatedNews ?? !0, I = P.messenger?.showReactionCounts ?? !0, [L, R] = b(M), z = r(L, j), B = D ? null : N.previewData?.newsPostsById?.[T], V = !!B, { data: H, loading: U } = g({
153
+ let A = r("news"), j = r("demo"), M = a(), N = t(), { config: P } = e(), F = P.messenger?.showRelatedNews ?? !0, I = P.messenger?.showReactionCounts ?? !0, [L, R] = b(M), z = f(L, j), B = D ? null : N.previewData?.newsPostsById?.[T], V = !!B, { data: H, loading: U } = c({
154
154
  variables: { args: {
155
155
  id: T,
156
156
  locale: M
157
157
  } },
158
158
  skip: D || V || !T
159
- }), { data: W } = h({
159
+ }), { data: W } = s({
160
160
  variables: {
161
161
  postId: T,
162
162
  limit: 5,
163
163
  locale: M
164
164
  },
165
165
  skip: D || V || !T || !F
166
- }), G = D ? m(z).find((e) => e.id === T) ?? null : null, K = G ? {
166
+ }), G = D ? o(z).find((e) => e.id === T) ?? null : null, K = G ? {
167
167
  id: G.id,
168
168
  title: G.title,
169
169
  excerpt: G.excerpt,
@@ -178,7 +178,7 @@ function T({ id: T, isDummy: D, onOpenRelated: O, onTitleResolved: k }) {
178
178
  category: G.category,
179
179
  locale: L
180
180
  } : C(V ? B : H?.visitorNewsPost);
181
- if (c(K?.title, k), !K) return U ? /* @__PURE__ */ x(E, {}) : /* @__PURE__ */ x("div", {
181
+ if (_(K?.title, k), !K) return U ? /* @__PURE__ */ x(E, {}) : /* @__PURE__ */ x("div", {
182
182
  className: "flex flex-1 items-center justify-center px-6 py-12 text-center",
183
183
  children: /* @__PURE__ */ x("p", {
184
184
  className: "text-sm text-wx-fg-muted",
@@ -199,7 +199,7 @@ function T({ id: T, isDummy: D, onOpenRelated: O, onTitleResolved: k }) {
199
199
  children: /* @__PURE__ */ S("div", {
200
200
  className: "flex flex-col",
201
201
  children: [/* @__PURE__ */ x("div", {
202
- className: f("relative w-full"),
202
+ className: i("relative w-full"),
203
203
  style: {
204
204
  aspectRatio: "16 / 9",
205
205
  background: K.coverImageUrl ? `url(${K.coverImageUrl}) center/cover` : `linear-gradient(135deg, ${Y[0]}, ${Y[1]})`
@@ -218,10 +218,10 @@ function T({ id: T, isDummy: D, onOpenRelated: O, onTitleResolved: k }) {
218
218
  month: "long",
219
219
  day: "numeric",
220
220
  year: "numeric"
221
- }) }), v(K) && K.upstreamUpdatedAt && /* @__PURE__ */ x("span", {
221
+ }) }), u(K) && K.upstreamUpdatedAt && /* @__PURE__ */ x("span", {
222
222
  className: "rounded-full bg-wx-bg-elevated px-1.5 py-0.5 text-[10px] font-medium text-wx-fg-muted",
223
223
  title: new Date(K.upstreamUpdatedAt).toLocaleString(M),
224
- children: A("editedAt", { when: _(K.upstreamUpdatedAt) })
224
+ children: A("editedAt", { when: l(K.upstreamUpdatedAt) })
225
225
  })]
226
226
  }),
227
227
  /* @__PURE__ */ x("h2", {
@@ -254,9 +254,9 @@ function T({ id: T, isDummy: D, onOpenRelated: O, onTitleResolved: k }) {
254
254
  className: "text-base leading-relaxed text-wx-fg-muted",
255
255
  children: K.excerpt
256
256
  }),
257
- K.contentMarkdown && /* @__PURE__ */ x(l, {
257
+ K.contentMarkdown && /* @__PURE__ */ x(v, {
258
258
  content: K.contentMarkdown,
259
- isHtml: K.bodyFormat === "html" || o(K.contentMarkdown),
259
+ isHtml: K.bodyFormat === "html" || h(K.contentMarkdown),
260
260
  markdownMarginClass: "mt-3"
261
261
  }),
262
262
  K.sourceUrl && /* @__PURE__ */ S("a", {
@@ -264,7 +264,7 @@ function T({ id: T, isDummy: D, onOpenRelated: O, onTitleResolved: k }) {
264
264
  target: "_blank",
265
265
  rel: "noopener noreferrer",
266
266
  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",
267
- children: [/* @__PURE__ */ x(y, { size: 12 }), /* @__PURE__ */ x("span", { children: A("readOriginal") })]
267
+ children: [/* @__PURE__ */ x(d, { size: 12 }), /* @__PURE__ */ x("span", { children: A("readOriginal") })]
268
268
  }),
269
269
  F && /* @__PURE__ */ x(w, {
270
270
  currentId: K.id,
@@ -275,8 +275,8 @@ function T({ id: T, isDummy: D, onOpenRelated: O, onTitleResolved: k }) {
275
275
  isDummy: D,
276
276
  onOpen: O ?? (() => {})
277
277
  }),
278
- K.id && /* @__PURE__ */ x(u, {
279
- surface: i.NEWS,
278
+ K.id && /* @__PURE__ */ x(y, {
279
+ surface: p.NEWS,
280
280
  itemId: K.id,
281
281
  reactionCounts: K.reactionCounts ?? null,
282
282
  viewerReaction: K.viewerReaction ?? null,
@@ -285,9 +285,9 @@ function T({ id: T, isDummy: D, onOpenRelated: O, onTitleResolved: k }) {
285
285
  showCounts: I,
286
286
  className: "mt-6"
287
287
  }),
288
- /* @__PURE__ */ x(s, {
288
+ /* @__PURE__ */ x(g, {
289
289
  currentLocale: D ? L : K.locale ?? M,
290
- locales: D ? [...a] : (K.translations ?? []).map((e) => e.locale),
290
+ locales: D ? [...m] : (K.translations ?? []).map((e) => e.locale),
291
291
  allowedLocales: D ? void 0 : P.supportedLocales,
292
292
  onSelect: D ? (e) => R(e) : (e) => {
293
293
  let t = (K.translations ?? []).find((t) => t.locale === e);
@@ -330,7 +330,7 @@ function E() {
330
330
  "w-full",
331
331
  "w-9/12",
332
332
  "w-7/12"
333
- ].map((e, t) => /* @__PURE__ */ x("div", { className: f("h-3 rounded-md bg-wx-bg-elevated", e) }, t))
333
+ ].map((e, t) => /* @__PURE__ */ x("div", { className: i("h-3 rounded-md bg-wx-bg-elevated", e) }, t))
334
334
  })
335
335
  ]
336
336
  })]
@@ -340,4 +340,4 @@ function E() {
340
340
  //#endregion
341
341
  export { T as NewsArticleView };
342
342
 
343
- //# sourceMappingURL=widget-react-CN_ZiUtH2.js.map
343
+ //# sourceMappingURL=widget-react-D7Q1S5E02.js.map
@@ -11,9 +11,9 @@ import "react";
11
11
  import "react-dom";
12
12
  import "react/jsx-runtime";
13
13
  import "react-dom/client";
14
- import { i as e, n as t } from "./widget-react-CQ0DMi7b.js";
15
- import { t as n } from "./widget-react-DP-dfZKt.js";
16
- import { n as r, r as i, t as a } from "./widget-react-TZUXHkN3.js";
14
+ import { i as e, n as t } from "./widget-react-BGCZpMUT.js";
15
+ import { t as n } from "./widget-react-D_1wQTaz.js";
16
+ import { n as r, r as i, t as a } from "./widget-react-BVRYDaf5.js";
17
17
  import { t as o } from "./widget-react-D9b9f-j_2.js";
18
18
  import { memo as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
19
19
  import { jsx as f, jsxs as p } from "react/jsx-runtime";
@@ -361,4 +361,4 @@ function A(e, t) {
361
361
  //#endregion
362
362
  export { O as AudioBubblePlayer };
363
363
 
364
- //# sourceMappingURL=widget-react-BKH1V5yP2.js.map
364
+ //# sourceMappingURL=widget-react-DWO5MXt62.js.map
@@ -11,7 +11,7 @@ import "react";
11
11
  import "react-dom";
12
12
  import "react/jsx-runtime";
13
13
  import "react-dom/client";
14
- import { t as e } from "./widget-react-CQ0DMi7b.js";
14
+ import { t as e } from "./widget-react-BGCZpMUT.js";
15
15
  var t = e("external-link", [
16
16
  ["path", {
17
17
  d: "M15 3h6v6",
@@ -29,4 +29,4 @@ var t = e("external-link", [
29
29
  //#endregion
30
30
  export { t };
31
31
 
32
- //# sourceMappingURL=widget-react-DP-dfZKt.js.map
32
+ //# sourceMappingURL=widget-react-D_1wQTaz.js.map