@paramms/chat-widget 1.0.42 → 1.0.43

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/react.js CHANGED
@@ -19,10 +19,10 @@ function Y({ size: o = 22 }) {
19
19
  }
20
20
  function Q({
21
21
  url: o,
22
- apiUrl: i,
22
+ apiUrl: r,
23
23
  profileId: s,
24
24
  token: n,
25
- refreshToken: r,
25
+ refreshToken: i,
26
26
  userId: l,
27
27
  userName: d,
28
28
  userEmail: u,
@@ -30,15 +30,15 @@ function Q({
30
30
  contextTitle: m,
31
31
  contextSubtitle: p,
32
32
  contextStatus: h,
33
- subjectId: L,
34
- accent: C,
33
+ subjectId: C,
34
+ accent: R,
35
35
  launcher: b,
36
36
  position: t,
37
37
  launcherMessage: f,
38
- quickReplies: R,
39
- height: S = "100%",
40
- i18n: j,
41
- translateLang: M,
38
+ quickReplies: j,
39
+ height: M = "100%",
40
+ i18n: L,
41
+ translateLang: S,
42
42
  inbox: a,
43
43
  inboxScope: $
44
44
  }) {
@@ -49,11 +49,11 @@ function Q({
49
49
  return (z = c.current) == null || z.close(), c.current = H({
50
50
  el: w.current,
51
51
  url: o,
52
- ...i ? { apiUrl: i } : {},
52
+ ...r ? { apiUrl: r } : {},
53
53
  profileId: s,
54
- ...L ? { subjectId: L } : {},
54
+ ...C ? { subjectId: C } : {},
55
55
  ...n ? { token: n } : {},
56
- ...r ? { refreshToken: r } : {},
56
+ ...i ? { refreshToken: i } : {},
57
57
  ...l ? { userId: l } : {},
58
58
  ...l || d || u || v ? {
59
59
  user: {
@@ -69,37 +69,37 @@ function Q({
69
69
  ...h ? { status: h } : {}
70
70
  }
71
71
  } : {},
72
- ...R ? { quickReplies: R } : {},
73
- ...C ? { accent: C } : {},
74
- ...M ? { translateLang: M } : {},
75
- ...j ? { i18n: j } : {},
72
+ ...j ? { quickReplies: j } : {},
73
+ ...R ? { accent: R } : {},
74
+ ...S ? { translateLang: S } : {},
75
+ ...L ? { i18n: L } : {},
76
76
  ...a && !b ? { onBack: () => g(!0) } : {},
77
77
  ...b ? { launcher: b, position: t ?? "bottom-right", ...f ? { launcherMessage: f } : {} } : {}
78
78
  }), () => {
79
79
  var y;
80
80
  (y = c.current) == null || y.close(), c.current = null;
81
81
  };
82
- }, [o, i, s, L, n, l, d, u, C, b, t, f, M, a, x]), a && !b && x ? /* @__PURE__ */ e(
82
+ }, [o, r, s, C, n, l, d, u, R, b, t, f, S, a, x]), a && !b && x ? /* @__PURE__ */ e(
83
83
  A,
84
84
  {
85
85
  url: o,
86
- ...i ? { apiUrl: i } : {},
86
+ ...r ? { apiUrl: r } : {},
87
87
  profileId: s,
88
88
  ...n ? { token: n } : {},
89
- ...r ? { refreshToken: r } : {},
89
+ ...i ? { refreshToken: i } : {},
90
90
  ...l ? { userId: l } : {},
91
91
  ...d ? { userName: d } : {},
92
92
  ...u ? { userEmail: u } : {},
93
- ...C ? { accent: C } : {},
93
+ ...R ? { accent: R } : {},
94
94
  scope: $ ?? "tenant",
95
- height: S,
95
+ height: M,
96
96
  onClose: () => g(!1)
97
97
  }
98
98
  ) : /* @__PURE__ */ e(
99
99
  "div",
100
100
  {
101
101
  ref: w,
102
- style: b ? { width: 0, height: 0, overflow: "hidden" } : { width: "100%", height: S, minHeight: S === "100%" ? "480px" : void 0 }
102
+ style: b ? { width: 0, height: 0, overflow: "hidden" } : { width: "100%", height: M, minHeight: M === "100%" ? "480px" : void 0 }
103
103
  }
104
104
  );
105
105
  }
@@ -110,10 +110,10 @@ const q = [
110
110
  ];
111
111
  function V({
112
112
  url: o,
113
- apiUrl: i,
113
+ apiUrl: r,
114
114
  profileId: s,
115
115
  token: n,
116
- refreshToken: r,
116
+ refreshToken: i,
117
117
  listingId: l,
118
118
  listingTitle: d,
119
119
  listingMeta: u,
@@ -121,15 +121,15 @@ function V({
121
121
  listingStatus: m,
122
122
  userId: p,
123
123
  userName: h,
124
- userEmail: L,
125
- userAvatar: C,
124
+ userEmail: C,
125
+ userAvatar: R,
126
126
  accent: b,
127
127
  launcher: t,
128
128
  position: f,
129
- launcherMessage: R,
130
- quickReplies: S,
131
- height: j = "100%",
132
- i18n: M,
129
+ launcherMessage: j,
130
+ quickReplies: M,
131
+ height: L = "100%",
132
+ i18n: S,
133
133
  translateLang: a,
134
134
  inbox: $,
135
135
  inboxScope: w
@@ -143,17 +143,17 @@ function V({
143
143
  y || !c.current || ((W = x.current) == null || W.close(), x.current = H({
144
144
  el: c.current,
145
145
  url: o,
146
- ...i ? { apiUrl: i } : {},
146
+ ...r ? { apiUrl: r } : {},
147
147
  profileId: s,
148
148
  ...l ? { subjectId: `listing_${l}` } : {},
149
149
  ...n ? { token: n } : {},
150
- ...r ? { refreshToken: r } : {},
150
+ ...i ? { refreshToken: i } : {},
151
151
  ...p ? { userId: p } : {},
152
- ...p || h || L || C ? {
152
+ ...p || h || C || R ? {
153
153
  user: {
154
154
  ...h ? { name: h } : {},
155
- ...L ? { email: L } : {},
156
- ...C ? { avatar: C } : {},
155
+ ...C ? { email: C } : {},
156
+ ...R ? { avatar: R } : {},
157
157
  ...l ? { meta: { listingId: l } } : {}
158
158
  }
159
159
  } : {},
@@ -165,58 +165,58 @@ function V({
165
165
  ...m ? { status: m } : {}
166
166
  }
167
167
  } : {},
168
- quickReplies: S ?? q,
168
+ quickReplies: M ?? q,
169
169
  ...b ? { accent: b } : {},
170
170
  ...a ? { translateLang: a } : {},
171
- ...M ? { i18n: M } : {},
171
+ ...S ? { i18n: S } : {},
172
172
  ...$ && !t ? { onBack: () => z(!0) } : {},
173
- ...t ? { launcher: t, position: f ?? "bottom-right", ...R ? { launcherMessage: R } : {} } : {}
173
+ ...t ? { launcher: t, position: f ?? "bottom-right", ...j ? { launcherMessage: j } : {} } : {}
174
174
  }));
175
175
  }, 0);
176
176
  return () => {
177
177
  var W;
178
178
  y = !0, clearTimeout(F), (W = x.current) == null || W.close(), x.current = null;
179
179
  };
180
- }, [o, i, s, l, n, p, b, t, f, R, a, $, g]), $ && !t && g ? /* @__PURE__ */ e(
180
+ }, [o, r, s, l, n, p, b, t, f, j, a, $, g]), $ && !t && g ? /* @__PURE__ */ e(
181
181
  A,
182
182
  {
183
183
  url: o,
184
- ...i ? { apiUrl: i } : {},
184
+ ...r ? { apiUrl: r } : {},
185
185
  profileId: s,
186
186
  ...n ? { token: n } : {},
187
- ...r ? { refreshToken: r } : {},
187
+ ...i ? { refreshToken: i } : {},
188
188
  ...p ? { userId: p } : {},
189
189
  ...h ? { userName: h } : {},
190
- ...L ? { userEmail: L } : {},
190
+ ...C ? { userEmail: C } : {},
191
191
  ...b ? { accent: b } : {},
192
192
  scope: w ?? "tenant",
193
- height: j,
193
+ height: L,
194
194
  onClose: () => z(!1)
195
195
  }
196
196
  ) : /* @__PURE__ */ e(
197
197
  "div",
198
198
  {
199
199
  ref: c,
200
- style: t ? { width: 0, height: 0, overflow: "hidden" } : { width: "100%", height: j, minHeight: j === "100%" ? "480px" : void 0 }
200
+ style: t ? { width: 0, height: 0, overflow: "hidden" } : { width: "100%", height: L, minHeight: L === "100%" ? "480px" : void 0 }
201
201
  }
202
202
  );
203
203
  }
204
204
  function K(o) {
205
- const [i, s] = k(
205
+ const [r, s] = k(
206
206
  typeof window < "u" && window.innerWidth <= o
207
207
  );
208
208
  return D(() => {
209
209
  if (typeof window > "u" || !window.matchMedia) return;
210
- const n = window.matchMedia(`(max-width: ${o}px)`), r = (l) => s(l.matches);
211
- return s(n.matches), n.addEventListener("change", r), () => n.removeEventListener("change", r);
212
- }, [o]), i;
210
+ const n = window.matchMedia(`(max-width: ${o}px)`), i = (l) => s(l.matches);
211
+ return s(n.matches), n.addEventListener("change", i), () => n.removeEventListener("change", i);
212
+ }, [o]), r;
213
213
  }
214
214
  function A({
215
215
  url: o,
216
- apiUrl: i,
216
+ apiUrl: r,
217
217
  profileId: s,
218
218
  tenantId: n,
219
- token: r,
219
+ token: i,
220
220
  refreshToken: l,
221
221
  userId: d,
222
222
  userName: u,
@@ -224,23 +224,26 @@ function A({
224
224
  accent: m,
225
225
  height: p = "100%",
226
226
  i18n: h,
227
- onClose: L,
228
- scope: C = "tenant"
227
+ onClose: C,
228
+ scope: R = "tenant"
229
229
  }) {
230
- const b = !s && !n, [t, f] = k(null), [R, S] = k(!1), j = B(null), M = B(null), a = B(null), $ = B(null);
230
+ const b = !s && !n, [t, f] = k(null), [j, M] = k(!1), L = B(null), S = B(null), a = B(null), $ = B(null);
231
231
  return D(() => {
232
- if (!j.current) return;
232
+ if (!L.current) return;
233
233
  let w = !1;
234
- return import("./chatlist.js").catch((c) => (console.error("[relay] could not load the conversation list module.", c), w || S(!0), null)).then((c) => {
234
+ return import("./chatlist.js").catch((c) => (console.error("[relay] could not load the conversation list module.", c), w || M(!0), null)).then((c) => {
235
235
  if (!c) return;
236
236
  const { mountChatList: x } = c;
237
- w || !j.current || (a.current = x({
238
- el: j.current,
237
+ w || !L.current || (a.current = x({
238
+ el: L.current,
239
239
  url: o,
240
- ...i ? { apiUrl: i } : {},
240
+ ...r ? { apiUrl: r } : {},
241
241
  ...s ? { profileId: s } : {},
242
242
  ...n ? { tenantId: n } : {},
243
- scope: C,
243
+ scope: R,
244
+ // We overlay a ✕ at top-right when `onClose` is given — tell the list to
245
+ // keep its header clear so the ✕ doesn't land on the ✎ compose button.
246
+ ...C ? { reserveCloseSpace: !0 } : {},
244
247
  onSelect: (g) => f(g),
245
248
  // Compose (✎) opens the chatroom's general support thread — without
246
249
  // this a user with no conversations yet had an empty list and no way
@@ -252,7 +255,7 @@ function A({
252
255
  const g = (z = a.current) == null ? void 0 : z.defaultProfileId();
253
256
  g && f({ id: "__new__", profileId: g, state: "open", updatedAt: Date.now() });
254
257
  },
255
- ...r ? { token: r } : {},
258
+ ...i ? { token: i } : {},
256
259
  ...d ? { userId: d } : {},
257
260
  ...m ? { accent: m } : {},
258
261
  ...h ? { i18n: h } : {}
@@ -261,20 +264,20 @@ function A({
261
264
  var c;
262
265
  w = !0, (c = a.current) == null || c.close(), a.current = null;
263
266
  };
264
- }, [o, i, s, n, r, d, C]), D(() => {
267
+ }, [o, r, s, n, i, d, R]), D(() => {
265
268
  var c;
266
- if (!M.current || !t) return;
269
+ if (!S.current || !t) return;
267
270
  (c = $.current) == null || c.close(), $.current = H({
268
- el: M.current,
271
+ el: S.current,
269
272
  url: o,
270
- ...i ? { apiUrl: i } : {},
273
+ ...r ? { apiUrl: r } : {},
271
274
  profileId: t.profileId ?? s,
272
275
  // rows always carry theirs; compose sets one explicitly
273
276
  // DM rows open as direct conversations (kind + peer). Opening them via
274
277
  // their dm:… subjectId only works for the participant that OWNS the
275
278
  // thread key — the other side would silently fork a duplicate.
276
279
  ...t.kind === "direct" && t.peerId ? { kind: "direct", peerId: t.peerId } : t.subjectId ? { subjectId: t.subjectId } : {},
277
- ...r ? { token: r } : {},
280
+ ...i ? { token: i } : {},
278
281
  ...l ? { refreshToken: l } : {},
279
282
  ...d ? { userId: d } : {},
280
283
  ...d || u || v ? {
@@ -308,10 +311,10 @@ function A({
308
311
  /* @__PURE__ */ e("code", { children: "tenantId" }),
309
312
  "."
310
313
  ] }) : /* @__PURE__ */ _("div", { style: { position: "relative", width: "100%", height: p, minHeight: "400px", overflow: "hidden", background: "#fff" }, children: [
311
- L && !t && /* @__PURE__ */ e(
314
+ C && !t && /* @__PURE__ */ e(
312
315
  "button",
313
316
  {
314
- onClick: L,
317
+ onClick: C,
315
318
  "aria-label": (h == null ? void 0 : h.close) ?? "Close",
316
319
  style: {
317
320
  position: "absolute",
@@ -339,16 +342,16 @@ function A({
339
342
  inset: 0,
340
343
  display: t ? "none" : "flex",
341
344
  flexDirection: "column"
342
- }, children: R ? /* @__PURE__ */ e("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", width: "100%", height: "100%", padding: 16, font: "13px system-ui", color: "#b91c1c", textAlign: "center" }, children: (h == null ? void 0 : h.error) ?? "Could not load conversations." }) : /* @__PURE__ */ e("div", { ref: j, style: { width: "100%", height: "100%" } }) }),
343
- t && /* @__PURE__ */ e("div", { style: { position: "absolute", inset: 0, display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ e("div", { ref: M, style: { width: "100%", height: "100%" } }) })
345
+ }, children: j ? /* @__PURE__ */ e("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", width: "100%", height: "100%", padding: 16, font: "13px system-ui", color: "#b91c1c", textAlign: "center" }, children: (h == null ? void 0 : h.error) ?? "Could not load conversations." }) : /* @__PURE__ */ e("div", { ref: L, style: { width: "100%", height: "100%" } }) }),
346
+ t && /* @__PURE__ */ e("div", { style: { position: "absolute", inset: 0, display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ e("div", { ref: S, style: { width: "100%", height: "100%" } }) })
344
347
  ] });
345
348
  }
346
349
  function X({
347
350
  url: o,
348
- apiUrl: i,
351
+ apiUrl: r,
349
352
  profileId: s,
350
353
  tenantId: n,
351
- token: r,
354
+ token: i,
352
355
  refreshToken: l,
353
356
  userId: d,
354
357
  userName: u,
@@ -356,26 +359,26 @@ function X({
356
359
  scope: m,
357
360
  accent: p = "#4F63F5",
358
361
  floating: h = !0,
359
- position: L = "bottom-right",
360
- label: C,
362
+ position: C = "bottom-right",
363
+ label: R,
361
364
  panelWidth: b,
362
365
  panelHeight: t = "600px"
363
366
  }) {
364
- const [f, R] = k(!1), S = B(null), j = L === "bottom-right", M = C ?? (h ? void 0 : "Messages"), a = K(479);
367
+ const [f, j] = k(!1), M = B(null), L = C === "bottom-right", S = R ?? (h ? void 0 : "Messages"), a = K(479);
365
368
  if (D(() => {
366
369
  const y = (F) => {
367
- F.key === "Escape" && R(!1);
370
+ F.key === "Escape" && j(!1);
368
371
  };
369
372
  return document.addEventListener("keydown", y), () => document.removeEventListener("keydown", y);
370
373
  }, []), h)
371
374
  return /* @__PURE__ */ _("div", { style: {
372
375
  position: "fixed",
373
- [j ? "right" : "left"]: "20px",
376
+ [L ? "right" : "left"]: "20px",
374
377
  bottom: "20px",
375
378
  zIndex: 9999,
376
379
  display: "flex",
377
380
  flexDirection: "column",
378
- alignItems: j ? "flex-end" : "flex-start",
381
+ alignItems: L ? "flex-end" : "flex-start",
379
382
  gap: "12px"
380
383
  }, children: [
381
384
  /* @__PURE__ */ e("div", { style: {
@@ -396,16 +399,16 @@ function X({
396
399
  background: "#fff",
397
400
  display: f ? "flex" : "none",
398
401
  flexDirection: "column",
399
- transformOrigin: `bottom ${j ? "right" : "left"}`,
402
+ transformOrigin: `bottom ${L ? "right" : "left"}`,
400
403
  animation: f ? "ocl-pop-in .18s ease" : "none"
401
404
  }, children: /* @__PURE__ */ e(
402
405
  A,
403
406
  {
404
407
  url: o,
405
- ...i ? { apiUrl: i } : {},
408
+ ...r ? { apiUrl: r } : {},
406
409
  ...s ? { profileId: s } : {},
407
410
  ...n ? { tenantId: n } : {},
408
- ...r ? { token: r } : {},
411
+ ...i ? { token: i } : {},
409
412
  ...l ? { refreshToken: l } : {},
410
413
  ...d ? { userId: d } : {},
411
414
  ...u ? { userName: u } : {},
@@ -413,15 +416,15 @@ function X({
413
416
  ...m ? { scope: m } : {},
414
417
  accent: p,
415
418
  height: "100%",
416
- onClose: () => R(!1)
419
+ onClose: () => j(!1)
417
420
  }
418
421
  ) }),
419
422
  /* @__PURE__ */ e(
420
423
  "button",
421
424
  {
422
- ref: S,
423
- onClick: () => R((y) => !y),
424
- "aria-label": f ? "Close chat" : typeof M == "string" ? M : "Open chat",
425
+ ref: M,
426
+ onClick: () => j((y) => !y),
427
+ "aria-label": f ? "Close chat" : typeof S == "string" ? S : "Open chat",
425
428
  "aria-expanded": f,
426
429
  style: {
427
430
  width: "56px",
@@ -445,19 +448,19 @@ function X({
445
448
  onMouseLeave: (y) => {
446
449
  y.currentTarget.style.transform = "scale(1)";
447
450
  },
448
- children: f ? /* @__PURE__ */ e(Y, {}) : C ?? /* @__PURE__ */ e(G, {})
451
+ children: f ? /* @__PURE__ */ e(Y, {}) : R ?? /* @__PURE__ */ e(G, {})
449
452
  }
450
453
  ),
451
454
  /* @__PURE__ */ e("style", { children: "@keyframes ocl-pop-in { from { opacity:0; transform:scale(.95) } to { opacity:1; transform:scale(1) } }" })
452
455
  ] });
453
456
  const $ = `min(${b ?? "420px"}, calc(100vw - 16px))`, [w, c] = k(null), x = () => {
454
- !f && S.current && c(S.current.getBoundingClientRect()), R((y) => !y);
457
+ !f && M.current && c(M.current.getBoundingClientRect()), j((y) => !y);
455
458
  }, g = w ? w.bottom + 8 : 0, z = w ? Math.max(8, window.innerWidth - w.right) : 0;
456
459
  return /* @__PURE__ */ _(O, { children: [
457
460
  /* @__PURE__ */ _(
458
461
  "button",
459
462
  {
460
- ref: S,
463
+ ref: M,
461
464
  onClick: x,
462
465
  style: {
463
466
  display: "inline-flex",
@@ -476,7 +479,7 @@ function X({
476
479
  children: [
477
480
  /* @__PURE__ */ e(G, { size: 16 }),
478
481
  " ",
479
- M
482
+ S
480
483
  ]
481
484
  }
482
485
  ),
@@ -484,7 +487,7 @@ function X({
484
487
  /* @__PURE__ */ e(
485
488
  "div",
486
489
  {
487
- onClick: () => R(!1),
490
+ onClick: () => j(!1),
488
491
  style: { position: "fixed", inset: 0, zIndex: 9998 }
489
492
  }
490
493
  ),
@@ -511,10 +514,10 @@ function X({
511
514
  A,
512
515
  {
513
516
  url: o,
514
- ...i ? { apiUrl: i } : {},
517
+ ...r ? { apiUrl: r } : {},
515
518
  ...s ? { profileId: s } : {},
516
519
  ...n ? { tenantId: n } : {},
517
- ...r ? { token: r } : {},
520
+ ...i ? { token: i } : {},
518
521
  ...l ? { refreshToken: l } : {},
519
522
  ...d ? { userId: d } : {},
520
523
  ...u ? { userName: u } : {},
@@ -522,7 +525,7 @@ function X({
522
525
  ...m ? { scope: m } : {},
523
526
  accent: p,
524
527
  height: "100%",
525
- onClose: () => R(!1)
528
+ onClose: () => j(!1)
526
529
  }
527
530
  ) }),
528
531
  /* @__PURE__ */ e("style", { children: "@keyframes ocl-slide-in { from { opacity:0; transform:translateY(-8px) } to { opacity:1; transform:translateY(0) } }" })