@reqdesk/widget 0.2.0 → 0.3.1
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/README.md +334 -334
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{react-DYAKyC3I.d.ts → react-Bmwfo1Qg.d.ts} +7 -7
- package/dist/{react-DYAKyC3I.d.ts.map → react-Bmwfo1Qg.d.ts.map} +1 -1
- package/dist/{react-PYPqwxcj.d.cts → react-cnsZAJCx.d.cts} +7 -7
- package/dist/{react-PYPqwxcj.d.cts.map → react-cnsZAJCx.d.cts.map} +1 -1
- package/dist/react.cjs +21 -11
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +21 -11
- package/dist/react.js.map +1 -1
- package/dist/{storage-PjDHb5v7.js → storage-BG7rsgWE.js} +34 -2
- package/dist/storage-BG7rsgWE.js.map +1 -0
- package/dist/{storage-DqhhTxeh.cjs → storage-Cx5p1yP-.cjs} +38 -0
- package/package.json +81 -81
- package/dist/storage-PjDHb5v7.js.map +0 -1
package/dist/react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as configureWidgetClient, S as uploadAttachment, _ as resolveWidgetUser, a as saveTrackingToken, b as submitTrackingReply, c as getWidgetStyles, d as ar, f as en, g as listMyTickets, h as getTicketDetail, i as loadWidgetEmail, l as themeToStyle, m as getCategories, n as getTrackingTokens, o as saveWidgetConfig, p as closeTicket, r as loadWidgetConfig, s as saveWidgetEmail, t as clearWidgetEmail, v as submitReply, w as setOidcTokenProvider, x as trackTicket, y as submitTicket } from "./storage-BG7rsgWE.js";
|
|
2
2
|
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { QueryClient, QueryClientProvider, keepPreviousData, queryOptions, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -31,10 +31,15 @@ function onAuthStateChange(listener) {
|
|
|
31
31
|
listeners = listeners.filter((l) => l !== listener);
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
function initWidgetAuth(config) {
|
|
35
|
+
initPromise = _initWidgetAuth(config);
|
|
36
|
+
return initPromise;
|
|
37
|
+
}
|
|
38
|
+
async function _initWidgetAuth(config) {
|
|
35
39
|
setState({ isLoading: true });
|
|
36
40
|
try {
|
|
37
|
-
const { createOidc } = await import("oidc-spa/core");
|
|
41
|
+
const { createOidc, oidcEarlyInit } = await import("oidc-spa/core");
|
|
42
|
+
oidcEarlyInit();
|
|
38
43
|
const oidc = await createOidc({
|
|
39
44
|
issuerUri: config.issuerUri,
|
|
40
45
|
clientId: config.clientId
|
|
@@ -68,8 +73,13 @@ async function initWidgetAuth(config) {
|
|
|
68
73
|
});
|
|
69
74
|
}
|
|
70
75
|
}
|
|
76
|
+
let initPromise = null;
|
|
71
77
|
async function login() {
|
|
72
|
-
if (!oidcInstance)
|
|
78
|
+
if (!oidcInstance && initPromise) await initPromise;
|
|
79
|
+
if (!oidcInstance) {
|
|
80
|
+
console.warn("[reqdesk-widget] Cannot login: OIDC not initialized. Check auth config.");
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
73
83
|
await oidcInstance.login({ doesCurrentHrefRequiresAuth: false });
|
|
74
84
|
}
|
|
75
85
|
async function logout() {
|
|
@@ -297,7 +307,7 @@ function TicketForm({ mode = "inline", onTicketCreated, onError, className, styl
|
|
|
297
307
|
onError,
|
|
298
308
|
t
|
|
299
309
|
]);
|
|
300
|
-
const cssVars =
|
|
310
|
+
const cssVars = themeToStyle(ctx.theme);
|
|
301
311
|
const content = success ? /* @__PURE__ */ jsxs("div", {
|
|
302
312
|
className: "rqd-success",
|
|
303
313
|
style: {
|
|
@@ -435,7 +445,7 @@ function TicketForm({ mode = "inline", onTicketCreated, onError, className, styl
|
|
|
435
445
|
className,
|
|
436
446
|
style: {
|
|
437
447
|
...style,
|
|
438
|
-
|
|
448
|
+
...cssVars
|
|
439
449
|
},
|
|
440
450
|
children: /* @__PURE__ */ jsx("div", {
|
|
441
451
|
className: "rqd-body",
|
|
@@ -444,7 +454,7 @@ function TicketForm({ mode = "inline", onTicketCreated, onError, className, styl
|
|
|
444
454
|
}) });
|
|
445
455
|
return /* @__PURE__ */ jsx(ShadowRoot, { children: /* @__PURE__ */ jsx("div", {
|
|
446
456
|
className: `rqd-inline ${className ?? ""}`,
|
|
447
|
-
style:
|
|
457
|
+
style: cssVars,
|
|
448
458
|
children: /* @__PURE__ */ jsx("div", {
|
|
449
459
|
className: "rqd-body",
|
|
450
460
|
children: content
|
|
@@ -456,10 +466,10 @@ function TicketForm({ mode = "inline", onTicketCreated, onError, className, styl
|
|
|
456
466
|
function SupportPortal({ className }) {
|
|
457
467
|
const ctx = useReqdeskContext();
|
|
458
468
|
const { isLoading } = useReqdesk();
|
|
459
|
-
const cssVars =
|
|
469
|
+
const cssVars = themeToStyle(ctx.theme);
|
|
460
470
|
return /* @__PURE__ */ jsx(ShadowRoot, { children: /* @__PURE__ */ jsx("div", {
|
|
461
471
|
className: `rqd-inline ${className ?? ""}`,
|
|
462
|
-
style:
|
|
472
|
+
style: cssVars,
|
|
463
473
|
children: /* @__PURE__ */ jsx("div", {
|
|
464
474
|
className: "rqd-body",
|
|
465
475
|
children: isLoading ? /* @__PURE__ */ jsx("p", {
|
|
@@ -1552,7 +1562,7 @@ function FloatingWidget({ position = "bottom-right", contained = false, onTicket
|
|
|
1552
1562
|
return (translations[activeLang] ?? translations.en)[key] ?? key;
|
|
1553
1563
|
}, [activeLang, ctx.translations]);
|
|
1554
1564
|
const isRtl = activeLang === "ar";
|
|
1555
|
-
const cssVars =
|
|
1565
|
+
const cssVars = themeToStyle(activeTheme);
|
|
1556
1566
|
const posClass = `rqd-${position}`;
|
|
1557
1567
|
const containedClass = contained ? " rqd-contained" : "";
|
|
1558
1568
|
const brandName = ctx.theme?.brandName;
|
|
@@ -1794,7 +1804,7 @@ function FloatingWidget({ position = "bottom-right", contained = false, onTicket
|
|
|
1794
1804
|
const canGoBack = view !== "home";
|
|
1795
1805
|
const goBackTarget = view === "ticket-detail" ? "my-tickets" : "home";
|
|
1796
1806
|
return /* @__PURE__ */ jsx(ShadowRoot, { children: /* @__PURE__ */ jsxs("div", {
|
|
1797
|
-
style:
|
|
1807
|
+
style: cssVars,
|
|
1798
1808
|
...isRtl ? { dir: "rtl" } : {},
|
|
1799
1809
|
children: [/* @__PURE__ */ jsx("button", {
|
|
1800
1810
|
className: `rqd-fab ${posClass}${containedClass}`,
|