@webority/support-react 0.17.2 → 0.17.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.
@@ -74,16 +74,16 @@ function ee(e, t = "/api/support") {
74
74
  }
75
75
  //#endregion
76
76
  //#region src/context.js
77
- var B = e(null);
78
- function V() {
79
- let e = n(B);
77
+ var te = e(null);
78
+ function B() {
79
+ let e = n(te);
80
80
  if (!e) throw Error("Support components and hooks must be used inside <SupportProvider>.");
81
81
  return e;
82
82
  }
83
- function H() {
84
- return V().client;
83
+ function V() {
84
+ return B().client;
85
85
  }
86
- function U(e, n, i = !0) {
86
+ function H(e, n, i = !0) {
87
87
  let [a, c] = s({
88
88
  data: null,
89
89
  loading: i,
@@ -132,8 +132,8 @@ function U(e, n, i = !0) {
132
132
  setData: m
133
133
  };
134
134
  }
135
- function W() {
136
- let { loadConfig: e } = V(), { data: t, loading: n, error: r, reload: i } = U(e, "config");
135
+ function U() {
136
+ let { loadConfig: e } = B(), { data: t, loading: n, error: r, reload: i } = H(e, "config");
137
137
  return {
138
138
  config: t,
139
139
  loading: n,
@@ -141,8 +141,8 @@ function W() {
141
141
  reload: i
142
142
  };
143
143
  }
144
- function te(e = {}) {
145
- let t = H(), { status: n, search: r, page: i, pageSize: a } = e, { data: o, loading: s, error: c, reload: l } = U(() => t.listTickets({
144
+ function ne(e = {}) {
145
+ let t = V(), { status: n, search: r, page: i, pageSize: a } = e, { data: o, loading: s, error: c, reload: l } = H(() => t.listTickets({
146
146
  status: n,
147
147
  search: r,
148
148
  page: i,
@@ -163,8 +163,8 @@ function te(e = {}) {
163
163
  reload: l
164
164
  };
165
165
  }
166
- function ne() {
167
- let e = H(), { data: t, loading: n, error: r, reload: i } = U(() => e.getTicketCounts(), "ticket-counts");
166
+ function W() {
167
+ let e = V(), { data: t, loading: n, error: r, reload: i } = H(() => e.getTicketCounts(), "ticket-counts");
168
168
  return {
169
169
  counts: t,
170
170
  loading: n,
@@ -172,8 +172,8 @@ function ne() {
172
172
  reload: i
173
173
  };
174
174
  }
175
- function G(e) {
176
- let n = H(), { data: r, loading: i, error: a, reload: o, setData: s } = U(() => n.getTicket(e), e ?? "", !!e), c = t(async (e) => {
175
+ function re(e) {
176
+ let n = V(), { data: r, loading: i, error: a, reload: o, setData: s } = H(() => n.getTicket(e), e ?? "", !!e), c = t(async (e) => {
177
177
  let t = await e();
178
178
  return s(t), t;
179
179
  }, [s]);
@@ -201,7 +201,7 @@ function G(e) {
201
201
  }
202
202
  //#endregion
203
203
  //#region src/lib/format.js
204
- var re = new Intl.DateTimeFormat(void 0, {
204
+ var ie = new Intl.DateTimeFormat(void 0, {
205
205
  day: "numeric",
206
206
  month: "short",
207
207
  year: "numeric",
@@ -209,12 +209,12 @@ var re = new Intl.DateTimeFormat(void 0, {
209
209
  minute: "2-digit",
210
210
  timeZoneName: "short"
211
211
  });
212
- function K(e) {
212
+ function G(e) {
213
213
  if (!e) return "-";
214
214
  let t = new Date(e);
215
- return Number.isNaN(t.getTime()) ? "-" : re.format(t);
215
+ return Number.isNaN(t.getTime()) ? "-" : ie.format(t);
216
216
  }
217
- function q(e) {
217
+ function K(e) {
218
218
  if (!Number.isFinite(e) || e < 0) return "-";
219
219
  if (e < 1024) return `${e} B`;
220
220
  if (e < 1024 * 1024) return `${Math.round(e / 1024)} KB`;
@@ -223,10 +223,10 @@ function q(e) {
223
223
  }
224
224
  //#endregion
225
225
  //#region src/lib/files.js
226
- function ie(e) {
226
+ function ae(e) {
227
227
  return (e?.allowedContentTypes ?? []).join(",");
228
228
  }
229
- function ae(e, t) {
229
+ function oe(e, t) {
230
230
  if (t.length === 0) return !0;
231
231
  let n = (e || "").toLowerCase();
232
232
  return t.some((e) => {
@@ -234,17 +234,17 @@ function ae(e, t) {
234
234
  return t.endsWith("/*") ? n.startsWith(t.slice(0, -1)) : n === t;
235
235
  });
236
236
  }
237
- function J(e, t) {
237
+ function q(e, t) {
238
238
  let n = e ?? [], r = t?.maxAttachmentsPerMessage ?? 0, i = t?.maxAttachmentBytes ?? 0, a = t?.allowedContentTypes ?? [];
239
239
  if (r > 0 && n.length > r) return r === 1 ? "You can attach one file." : `You can attach up to ${r} files.`;
240
240
  for (let e of n) {
241
241
  let t = e.name || "This file";
242
- if (!ae(e.type, a)) return `${t} is a file type we cannot accept.`;
243
- if (i > 0 && e.size > i) return `${t} is larger than ${q(i)}.`;
242
+ if (!oe(e.type, a)) return `${t} is a file type we cannot accept.`;
243
+ if (i > 0 && e.size > i) return `${t} is larger than ${K(i)}.`;
244
244
  }
245
245
  return null;
246
246
  }
247
- function Y(e) {
247
+ function J(e) {
248
248
  let t = Array.from(e.clipboardData?.items ?? []), n = Date.now();
249
249
  return t.filter((e) => e.kind === "file" && e.type.startsWith("image/")).map((e) => e.getAsFile()).filter(Boolean).map((e, t) => {
250
250
  let r = (e.type.split("/")[1] || "png").replace("jpeg", "jpg");
@@ -253,7 +253,7 @@ function Y(e) {
253
253
  }
254
254
  //#endregion
255
255
  //#region src/components/AttachmentField.jsx
256
- function X({ id: e, label: t = "Attachments", files: n, onChange: r, config: i, error: a }) {
256
+ function Y({ id: e, label: t = "Attachments", files: n, onChange: r, config: i, error: a }) {
257
257
  let o = i?.maxAttachmentBytes ?? 0, s = o > 0 ? Math.max(.1, Math.round(o / (1024 * 1024) * 10) / 10) : 0;
258
258
  return /* @__PURE__ */ j(h, {
259
259
  id: e,
@@ -262,7 +262,7 @@ function X({ id: e, label: t = "Attachments", files: n, onChange: r, config: i,
262
262
  multiple: !0,
263
263
  value: n,
264
264
  onChange: r,
265
- accept: ie(i),
265
+ accept: ae(i),
266
266
  maxSizeMb: s,
267
267
  validate: !1,
268
268
  error: a || void 0
@@ -270,23 +270,23 @@ function X({ id: e, label: t = "Attachments", files: n, onChange: r, config: i,
270
270
  }
271
271
  //#endregion
272
272
  //#region src/components/TicketForm.jsx
273
- function oe(e, t) {
273
+ function se(e, t) {
274
274
  return t && e.includes(t) ? t : e[0] ?? "";
275
275
  }
276
- function se({ id: e, config: t, defaultCategory: n, extraFiles: r = [], onSubmit: i, onBusyChange: a, children: o }) {
277
- let l = t?.categories ?? [], [u, d] = s(() => oe(l, n)), [f, p] = s(""), [m, h] = s(""), [g, _] = s([]), [y, b] = s({}), [x, C] = s(""), w = (e) => {
276
+ function X({ id: e, config: t, defaultCategory: n, extraFiles: r = [], onSubmit: i, onBusyChange: a, children: o }) {
277
+ let l = t?.categories ?? [], [u, d] = s(() => se(l, n)), [f, p] = s(""), [m, h] = s(""), [g, _] = s([]), [y, b] = s({}), [x, C] = s(""), w = (e) => {
278
278
  _(e), b((n) => ({
279
279
  ...n,
280
- files: J([...r, ...e], t) ?? void 0
280
+ files: q([...r, ...e], t) ?? void 0
281
281
  }));
282
282
  }, T = (e) => {
283
- let t = Y(e);
283
+ let t = J(e);
284
284
  t.length > 0 && w([...g, ...t]);
285
285
  };
286
286
  function E() {
287
287
  let e = {};
288
288
  u || (e.category = "Choose a category."), f.trim() || (e.subject = "Give your ticket a subject."), m.trim() || (e.body = "Tell us what happened.");
289
- let n = J([...r, ...g], t);
289
+ let n = q([...r, ...g], t);
290
290
  return n && (e.files = n), b(e), Object.keys(e).length === 0;
291
291
  }
292
292
  async function D(e) {
@@ -353,7 +353,7 @@ function se({ id: e, config: t, defaultCategory: n, extraFiles: r = [], onSubmit
353
353
  error: y.body
354
354
  }),
355
355
  o,
356
- /* @__PURE__ */ j(X, {
356
+ /* @__PURE__ */ j(Y, {
357
357
  id: `${e}-files`,
358
358
  files: g,
359
359
  onChange: w,
@@ -403,7 +403,7 @@ function fe({ file: e, onRemove: t }) {
403
403
  });
404
404
  }
405
405
  function pe({ label: e = "Report an issue", floating: t = !1, defaultCategory: n = "Bug report", appVersion: r, getTicketHref: a, onOpenTicket: o, onCreated: l, className: u, style: f }) {
406
- let p = H(), { config: m, error: h } = W(), g = `support-report-${i().replace(/[^a-zA-Z0-9-]/g, "")}`, [_, v] = s(!1), [y, x] = s(!1), [S, C] = s(null), [w, T] = s(!1), [E, D] = s(!1), [O, k] = s(null);
406
+ let p = V(), { config: m, error: h } = U(), g = `support-report-${i().replace(/[^a-zA-Z0-9-]/g, "")}`, [_, v] = s(!1), [y, x] = s(!1), [S, C] = s(null), [w, T] = s(!1), [E, D] = s(!1), [O, k] = s(null);
407
407
  async function N() {
408
408
  x(!0), k(null);
409
409
  try {
@@ -484,7 +484,7 @@ function pe({ label: e = "Report an issue", floating: t = !1, defaultCategory: n
484
484
  role: "status",
485
485
  title: `Ticket ${O.number} is with the support team`,
486
486
  children: "We reply by email. You can follow the ticket on your support page."
487
- }) : m ? /* @__PURE__ */ j(se, {
487
+ }) : m ? /* @__PURE__ */ j(X, {
488
488
  id: g,
489
489
  config: m,
490
490
  defaultCategory: n,
@@ -507,7 +507,7 @@ function pe({ label: e = "Report an issue", floating: t = !1, defaultCategory: n
507
507
  //#endregion
508
508
  //#region src/components/NewTicketModal.jsx
509
509
  function me({ open: e, onClose: t, onCreated: n, config: r, defaultCategory: a, appVersion: o }) {
510
- let c = H(), l = `support-new-${i().replace(/[^a-zA-Z0-9-]/g, "")}`, [u, f] = s(!1);
510
+ let c = V(), l = `support-new-${i().replace(/[^a-zA-Z0-9-]/g, "")}`, [u, f] = s(!1);
511
511
  async function p(e) {
512
512
  n(await c.createTicket({
513
513
  ...e,
@@ -539,7 +539,7 @@ function me({ open: e, onClose: t, onCreated: n, config: r, defaultCategory: a,
539
539
  children: "Send ticket"
540
540
  })]
541
541
  }),
542
- children: e && /* @__PURE__ */ j(se, {
542
+ children: e && /* @__PURE__ */ j(X, {
543
543
  id: l,
544
544
  config: r,
545
545
  defaultCategory: a,
@@ -566,7 +566,7 @@ var _e = {
566
566
  maxWidth: "100%"
567
567
  }, ve = { height: 84 };
568
568
  function ye({ attachment: e }) {
569
- let t = H(), n = (e.contentType || "").startsWith("image/"), [i, a] = s(null), [o, c] = s(!1);
569
+ let t = V(), n = (e.contentType || "").startsWith("image/"), [i, a] = s(null), [o, c] = s(!1);
570
570
  r(() => {
571
571
  let n = !0, r = null;
572
572
  return a(null), c(!1), t.fetchAttachment(e.id).then((e) => {
@@ -580,7 +580,7 @@ function ye({ attachment: e }) {
580
580
  children: [
581
581
  e.fileName,
582
582
  ", ",
583
- q(e.sizeBytes)
583
+ K(e.sizeBytes)
584
584
  ]
585
585
  });
586
586
  return o ? /* @__PURE__ */ M("span", {
@@ -632,7 +632,7 @@ function xe({ messages: e }) {
632
632
  let t = /* @__PURE__ */ j("time", {
633
633
  dateTime: e.createdDateTimeUtc,
634
634
  className: "wui-text-xs text-body-secondary text-nowrap",
635
- children: K(e.createdDateTimeUtc)
635
+ children: G(e.createdDateTimeUtc)
636
636
  });
637
637
  if (e.authorKind === "System") return /* @__PURE__ */ M("li", {
638
638
  className: "text-center wui-text-xs text-body-secondary",
@@ -753,9 +753,9 @@ function Se({ satisfaction: e, comment: t, canRate: n = !1, commentMaxLength: r,
753
753
  //#region src/components/ReplyBox.jsx
754
754
  function Ce({ onSend: e, config: t, reopens: n = !1 }) {
755
755
  let r = i(), [a, o] = s(""), [l, u] = s([]), [f, p] = s(""), [m, h] = s(""), [g, _] = s(!1), v = (e) => {
756
- u(e), p(J(e, t) ?? "");
756
+ u(e), p(q(e, t) ?? "");
757
757
  }, y = (e) => {
758
- let t = Y(e);
758
+ let t = J(e);
759
759
  t.length > 0 && v([...l, ...t]);
760
760
  };
761
761
  async function b(n) {
@@ -765,7 +765,7 @@ function Ce({ onSend: e, config: t, reopens: n = !1 }) {
765
765
  h("Write a message before you send it.");
766
766
  return;
767
767
  }
768
- let i = J(l, t);
768
+ let i = q(l, t);
769
769
  if (i) {
770
770
  p(i);
771
771
  return;
@@ -804,7 +804,7 @@ function Ce({ onSend: e, config: t, reopens: n = !1 }) {
804
804
  hint: n ? "Sending a reply reopens this ticket. You can paste an image into the message." : "You can paste an image into the message.",
805
805
  required: !0
806
806
  }),
807
- /* @__PURE__ */ j(X, {
807
+ /* @__PURE__ */ j(Y, {
808
808
  id: `${r}-files`,
809
809
  files: l,
810
810
  onChange: v,
@@ -838,7 +838,7 @@ function Z({ label: e, children: t }) {
838
838
  });
839
839
  }
840
840
  function we({ ticketId: e, onBack: t, onChanged: n }) {
841
- let { config: r } = W(), { ticket: i, loading: a, error: o, reload: l, reply: u, reopen: f, rate: p } = G(e), [m, h] = s(!1), [g, _] = s(""), v = async (e) => {
841
+ let { config: r } = U(), { ticket: i, loading: a, error: o, reload: l, reply: u, reopen: f, rate: p } = re(e), [m, h] = s(!1), [g, _] = s(""), v = async (e) => {
842
842
  let t = await e();
843
843
  return n?.(), t;
844
844
  };
@@ -912,14 +912,14 @@ function we({ ticketId: e, onBack: t, onChanged: n }) {
912
912
  label: "Opened",
913
913
  children: /* @__PURE__ */ j("time", {
914
914
  dateTime: i.createdDateTimeUtc,
915
- children: K(i.createdDateTimeUtc)
915
+ children: G(i.createdDateTimeUtc)
916
916
  })
917
917
  }),
918
918
  /* @__PURE__ */ j(Z, {
919
919
  label: "Last update",
920
920
  children: /* @__PURE__ */ j("time", {
921
921
  dateTime: i.updatedDateTimeUtc,
922
- children: K(i.updatedDateTimeUtc)
922
+ children: G(i.updatedDateTimeUtc)
923
923
  })
924
924
  })
925
925
  ]
@@ -1091,7 +1091,7 @@ function ke({ tickets: e, loading: t, error: n, onRetry: r, onOpen: i, status: a
1091
1091
  cellClassName: "wui-text-sm text-body-secondary text-nowrap",
1092
1092
  render: (e) => /* @__PURE__ */ j("time", {
1093
1093
  dateTime: e.updatedDateTimeUtc,
1094
- children: K(e.updatedDateTimeUtc)
1094
+ children: G(e.updatedDateTimeUtc)
1095
1095
  })
1096
1096
  }
1097
1097
  ],
@@ -1128,18 +1128,18 @@ function Ae(e, t) {
1128
1128
  //#region src/SupportCenter.jsx
1129
1129
  var je = 300, Me = 10;
1130
1130
  function Ne({ initialTicketId: e, defaultCategory: t, appVersion: n }) {
1131
- let { config: i, error: a, reload: o } = W(), [l, u] = s("all"), [f, p] = s(""), m = Ae(f.trim(), je), [h, g] = s(Me), _ = `${l}|${m}|${h}`, [v, y] = s({
1131
+ let { config: i, error: a, reload: o } = U(), [l, u] = s("all"), [f, p] = s(""), m = Ae(f.trim(), je), [h, g] = s(Me), _ = `${l}|${m}|${h}`, [v, y] = s({
1132
1132
  key: _,
1133
1133
  page: 1
1134
1134
  }), b = v.key === _ ? v.page : 1, x = (e) => y({
1135
1135
  key: _,
1136
1136
  page: e
1137
- }), S = te({
1137
+ }), S = ne({
1138
1138
  status: l === "all" ? void 0 : l,
1139
1139
  search: m || void 0,
1140
1140
  page: b,
1141
1141
  pageSize: h
1142
- }), { counts: C, reload: w } = ne(), [T, E] = s(() => e || Te()), [D, O] = s(!1), k = S.totalPages;
1142
+ }), { counts: C, reload: w } = W(), [T, E] = s(() => e || Te()), [D, O] = s(!1), k = S.totalPages;
1143
1143
  r(() => {
1144
1144
  k > 0 && b > k && y({
1145
1145
  key: _,
@@ -1160,13 +1160,11 @@ function Ne({ initialTicketId: e, defaultCategory: t, appVersion: n }) {
1160
1160
  onBack: () => N(null),
1161
1161
  onChanged: A
1162
1162
  }, T);
1163
- let P = S.totalCount === 0 ? 0 : (b - 1) * h + 1, F = {
1163
+ let P = {
1164
1164
  page: b,
1165
1165
  totalPages: Math.max(1, S.totalPages),
1166
1166
  pageSize: h,
1167
1167
  total: S.totalCount,
1168
- firstRow: P,
1169
- lastRow: Math.min(S.totalCount, P + S.tickets.length - 1),
1170
1168
  setPage: x,
1171
1169
  setPageSize: g
1172
1170
  };
@@ -1211,7 +1209,7 @@ function Ne({ initialTicketId: e, defaultCategory: t, appVersion: n }) {
1211
1209
  counts: C,
1212
1210
  search: f,
1213
1211
  onSearchChange: p,
1214
- pagination: F
1212
+ pagination: P
1215
1213
  }),
1216
1214
  i && /* @__PURE__ */ j(me, {
1217
1215
  open: D,
@@ -1230,7 +1228,7 @@ function Ne({ initialTicketId: e, defaultCategory: t, appVersion: n }) {
1230
1228
  //#region src/SupportContact.jsx
1231
1229
  var $ = (e) => typeof e == "string" && e.trim() !== "";
1232
1230
  function Pe({ className: e }) {
1233
- let { config: t } = W();
1231
+ let { config: t } = U();
1234
1232
  if (!t) return null;
1235
1233
  let n = [];
1236
1234
  return $(t.supportEmail) && n.push({
@@ -1289,10 +1287,10 @@ function Fe({ client: e, children: n }) {
1289
1287
  client: e,
1290
1288
  loadConfig: i
1291
1289
  }), [e, i]);
1292
- return /* @__PURE__ */ j(B.Provider, {
1290
+ return /* @__PURE__ */ j(te.Provider, {
1293
1291
  value: s,
1294
1292
  children: n
1295
1293
  });
1296
1294
  }
1297
1295
  //#endregion
1298
- export { pe as ReportIssue, P as SupportApiError, Ne as SupportCenter, Pe as SupportContact, Fe as SupportProvider, ee as createSupportClient, H as useSupportClient, W as useSupportConfig, G as useSupportTicket, ne as useSupportTicketCounts, te as useSupportTickets };
1296
+ export { pe as ReportIssue, P as SupportApiError, Ne as SupportCenter, Pe as SupportContact, Fe as SupportProvider, ee as createSupportClient, V as useSupportClient, U as useSupportConfig, re as useSupportTicket, W as useSupportTicketCounts, ne as useSupportTickets };
@@ -13,7 +13,7 @@
13
13
  * @param {import('../client.js').TicketCounts|null} [props.counts] Labels the tabs once loaded.
14
14
  * @param {string} props.search What is in the search box.
15
15
  * @param {(search: string) => void} props.onSearchChange
16
- * @param {{ page: number, totalPages: number, pageSize: number, total: number, firstRow: number, lastRow: number, setPage: (page: number) => void, setPageSize: (size: number) => void }} props.pagination
16
+ * @param {{ page: number, totalPages: number, pageSize: number, total: number, setPage: (page: number) => void, setPageSize: (size: number) => void }} props.pagination
17
17
  */
18
18
  export default function TicketList({ tickets, loading, error, onRetry, onOpen, status, onStatusChange, counts, search, onSearchChange, pagination, }: {
19
19
  tickets: any[];
@@ -31,8 +31,6 @@ export default function TicketList({ tickets, loading, error, onRetry, onOpen, s
31
31
  totalPages: number;
32
32
  pageSize: number;
33
33
  total: number;
34
- firstRow: number;
35
- lastRow: number;
36
34
  setPage: (page: number) => void;
37
35
  setPageSize: (size: number) => void;
38
36
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/support-react",
3
- "version": "0.17.2",
3
+ "version": "0.17.4",
4
4
  "description": "Webority customer support for React portals: ticket centre, report-an-issue with a page screenshot, and support contact details, built on @webority/ui-react.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -32,7 +32,7 @@
32
32
  "react": "^19.0.0",
33
33
  "react-bootstrap": "^2.10.0",
34
34
  "react-dom": "^19.0.0",
35
- "@webority/ui-react": "0.17.2"
35
+ "@webority/ui-react": "0.17.4"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@testing-library/dom": "10.4.2",
@@ -50,7 +50,7 @@
50
50
  "typescript": "^7.0.2",
51
51
  "vite": "^8.0.12",
52
52
  "vitest": "5.0.1",
53
- "@webority/ui-react": "0.17.2"
53
+ "@webority/ui-react": "0.17.4"
54
54
  },
55
55
  "dependencies": {
56
56
  "html-to-image": "^1.11.13"