@wexio/messenger-widget-react 1.1.1 → 1.1.3
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/dist/widget-react.js +41 -35
- package/package.json +1 -1
package/dist/widget-react.js
CHANGED
|
@@ -1099,13 +1099,13 @@ function Cr(e) {
|
|
|
1099
1099
|
}
|
|
1100
1100
|
//#endregion
|
|
1101
1101
|
//#region lib/use-visitor-unread.ts
|
|
1102
|
-
function wr({ chatId: e, isDummy: t }) {
|
|
1103
|
-
let
|
|
1102
|
+
function wr({ chatId: e, isDummy: t, isLoading: n }) {
|
|
1103
|
+
let r = V("demo"), [i, a] = X(!1), [o, s] = X(0), [c, l] = X(null), u = Y(/* @__PURE__ */ new Set()), d = Y(null), f = Y(!1), [p] = cn({ fetchPolicy: "network-only" });
|
|
1104
1104
|
J(() => {
|
|
1105
|
-
t || !e ||
|
|
1106
|
-
if (
|
|
1105
|
+
t || !e || d.current !== e && (d.current = e, u.current = /* @__PURE__ */ new Set(), f.current = !1, p({ variables: { chatId: e } }).then((e) => {
|
|
1106
|
+
if (f.current) return;
|
|
1107
1107
|
let t = e.data?.visitorChatUnread;
|
|
1108
|
-
if (t) if (
|
|
1108
|
+
if (t) if (s(t.count ?? 0), t.lastMessage) {
|
|
1109
1109
|
let e = {
|
|
1110
1110
|
id: t.lastMessage.id,
|
|
1111
1111
|
text: t.lastMessage.text ?? null,
|
|
@@ -1116,32 +1116,32 @@ function wr({ chatId: e, isDummy: t }) {
|
|
|
1116
1116
|
},
|
|
1117
1117
|
buttons: Er(t.lastMessage.buttons)
|
|
1118
1118
|
};
|
|
1119
|
-
|
|
1120
|
-
} else
|
|
1119
|
+
u.current.add(e.id), l(e);
|
|
1120
|
+
} else l(null);
|
|
1121
1121
|
}).catch(() => {}));
|
|
1122
1122
|
}, [
|
|
1123
1123
|
e,
|
|
1124
1124
|
t,
|
|
1125
|
-
|
|
1125
|
+
p
|
|
1126
1126
|
]);
|
|
1127
|
-
let
|
|
1127
|
+
let m = q(() => {
|
|
1128
1128
|
if (t) {
|
|
1129
|
-
|
|
1129
|
+
a(!0);
|
|
1130
1130
|
return;
|
|
1131
1131
|
}
|
|
1132
|
-
|
|
1133
|
-
}, [t]),
|
|
1132
|
+
s(0), l(null), f.current = !0;
|
|
1133
|
+
}, [t]), h = q((e) => {
|
|
1134
1134
|
if (t || e.kind === "typing" || e.kind === "read-receipt" || e.kind === "assignment") return;
|
|
1135
1135
|
let n = e.from ?? e.sender;
|
|
1136
1136
|
if (n?.kind === "visitor") return;
|
|
1137
1137
|
let r = e.externalMessageId;
|
|
1138
|
-
if (!r ||
|
|
1139
|
-
|
|
1138
|
+
if (!r || u.current.has(r)) return;
|
|
1139
|
+
u.current.add(r), s((e) => e + 1);
|
|
1140
1140
|
let i = Array.isArray(e.buttons) ? e.buttons.map((e) => ({
|
|
1141
1141
|
text: e.label,
|
|
1142
1142
|
payload: e.value
|
|
1143
1143
|
})) : [];
|
|
1144
|
-
|
|
1144
|
+
l({
|
|
1145
1145
|
id: r,
|
|
1146
1146
|
text: e.text ?? null,
|
|
1147
1147
|
sender: {
|
|
@@ -1151,28 +1151,28 @@ function wr({ chatId: e, isDummy: t }) {
|
|
|
1151
1151
|
},
|
|
1152
1152
|
buttons: i
|
|
1153
1153
|
});
|
|
1154
|
-
}, [t]),
|
|
1154
|
+
}, [t]), g = q((e) => {
|
|
1155
1155
|
if (t || e.length === 0) return;
|
|
1156
1156
|
let n = 0;
|
|
1157
|
-
for (let t of e)
|
|
1158
|
-
n > 0 &&
|
|
1157
|
+
for (let t of e) u.current.has(t) && (u.current.delete(t), n += 1);
|
|
1158
|
+
n > 0 && s((e) => Math.max(0, e - n)), l((t) => t && (e.includes(t.id) ? null : t));
|
|
1159
1159
|
}, [t]);
|
|
1160
|
-
if (t) {
|
|
1161
|
-
let e =
|
|
1160
|
+
if (t && !n) {
|
|
1161
|
+
let e = i ? null : Tr(r);
|
|
1162
1162
|
return {
|
|
1163
1163
|
count: +!!e,
|
|
1164
1164
|
lastMessage: e,
|
|
1165
|
-
clear:
|
|
1166
|
-
noteInbound:
|
|
1167
|
-
noteRead:
|
|
1165
|
+
clear: m,
|
|
1166
|
+
noteInbound: h,
|
|
1167
|
+
noteRead: g
|
|
1168
1168
|
};
|
|
1169
1169
|
}
|
|
1170
1170
|
return {
|
|
1171
|
-
count:
|
|
1172
|
-
lastMessage:
|
|
1173
|
-
clear:
|
|
1174
|
-
noteInbound:
|
|
1175
|
-
noteRead:
|
|
1171
|
+
count: o,
|
|
1172
|
+
lastMessage: c,
|
|
1173
|
+
clear: m,
|
|
1174
|
+
noteInbound: h,
|
|
1175
|
+
noteRead: g
|
|
1176
1176
|
};
|
|
1177
1177
|
}
|
|
1178
1178
|
function Tr(e) {
|
|
@@ -19977,12 +19977,16 @@ function Iv({ isOpen: e, onToggle: t, unreadCount: i = 0, newsUnread: o = !1, po
|
|
|
19977
19977
|
onHoverEnd: m.onMouseLeave,
|
|
19978
19978
|
...m,
|
|
19979
19979
|
className: H(c ? "absolute" : "fixed", "bottom-4 z-2147483600", s === "left" ? "left-4" : "right-4", "flex h-14 w-14 items-center justify-center rounded-full", "bg-wx-launcher-bg text-wx-launcher-fg", "shadow-[0_8px_24px_rgba(0,0,0,0.18)]", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-wx-launcher-bg focus-visible:ring-offset-2 focus-visible:ring-offset-white"),
|
|
19980
|
-
children: [/* @__PURE__ */ Z(
|
|
19981
|
-
|
|
19982
|
-
|
|
19983
|
-
|
|
19984
|
-
|
|
19985
|
-
|
|
19980
|
+
children: [/* @__PURE__ */ Z("span", {
|
|
19981
|
+
"aria-hidden": !0,
|
|
19982
|
+
className: "contents",
|
|
19983
|
+
children: /* @__PURE__ */ Z(xi, {
|
|
19984
|
+
count: g ? h : 0,
|
|
19985
|
+
dot: _,
|
|
19986
|
+
label: _ ? d("unread") : void 0,
|
|
19987
|
+
size: "md",
|
|
19988
|
+
className: "absolute -top-1 -right-1 z-10"
|
|
19989
|
+
})
|
|
19986
19990
|
}), /* @__PURE__ */ Z(ne, {
|
|
19987
19991
|
mode: "wait",
|
|
19988
19992
|
initial: !1,
|
|
@@ -20289,7 +20293,8 @@ function $v() {
|
|
|
20289
20293
|
]);
|
|
20290
20294
|
let _e = wr({
|
|
20291
20295
|
chatId: M.chatId,
|
|
20292
|
-
isDummy: o
|
|
20296
|
+
isDummy: o,
|
|
20297
|
+
isLoading: s
|
|
20293
20298
|
}), ve = Pn({
|
|
20294
20299
|
enabled: i === "production" && !o && !!a.features.news,
|
|
20295
20300
|
locale: t
|
|
@@ -20483,6 +20488,7 @@ function $v() {
|
|
|
20483
20488
|
return /* @__PURE__ */ Q(Ft, { children: [
|
|
20484
20489
|
/* @__PURE__ */ Q(n.div, {
|
|
20485
20490
|
"aria-hidden": !de,
|
|
20491
|
+
inert: !de,
|
|
20486
20492
|
initial: !1,
|
|
20487
20493
|
animate: de ? {
|
|
20488
20494
|
opacity: 1,
|
package/package.json
CHANGED