@levo-so/react 0.1.86 → 0.1.108
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/audience/components/block.js +31 -0
- package/dist/audience/components/component.js +19 -0
- package/dist/audience/components/page.js +16 -0
- package/dist/components/Dialog.js +57 -0
- package/dist/components/DialogWrapper.js +20 -0
- package/dist/components/Sonner.d.ts +1 -1
- package/dist/components/Sonner.d.ts.map +1 -1
- package/dist/components/Sonner.js +32 -0
- package/dist/components/Spinner.js +7 -0
- package/dist/components/Tabs.js +27 -0
- package/dist/components/Tooltip.js +24 -0
- package/dist/components/button/Button.js +24 -0
- package/dist/components/button/buttonVariants.d.ts +1 -1
- package/dist/components/button/buttonVariants.d.ts.map +1 -1
- package/dist/components/button/buttonVariants.js +38 -0
- package/dist/constants/fileUploadPresets.js +80 -0
- package/dist/index.js +24 -495
- package/dist/membership/components/Button.js +22 -0
- package/dist/membership/components/Container.js +59 -0
- package/dist/membership/components/Core.js +18 -0
- package/dist/membership/components/Popup.js +37 -0
- package/dist/membership/index.js +10 -0
- package/dist/membership/useLevoOAuth.js +57 -0
- package/dist/providers/LevoProvider.js +20 -0
- package/dist/styles/index.css +2 -0
- package/dist/utils/byteToSize.js +18 -0
- package/dist/utils/cn.js +6 -0
- package/dist/utils/errorHandler.js +9 -0
- package/dist/utils/isDateObject.js +4 -0
- package/dist/utils/isEmptyObject.js +5 -0
- package/dist/utils/isNullOrUndefined.js +4 -0
- package/dist/utils/isObject.js +6 -0
- package/package.json +31 -30
- package/dist/index.css +0 -2
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useLevo as e } from "../providers/LevoProvider.js";
|
|
2
|
+
import { getLevoError as t } from "@levo-so/core";
|
|
3
|
+
import { useCallback as n, useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
4
|
+
//#region src/membership/useLevoOAuth.tsx
|
|
5
|
+
var s = ({ url: e, title: t, height: n, width: r }) => {
|
|
6
|
+
let i = window.screenX + (window.outerWidth - r) / 2, a = window.screenY + (window.outerHeight - n) / 2.5;
|
|
7
|
+
return window.open(e, t, `width=${r},height=${n},left=${i},top=${a}`);
|
|
8
|
+
}, c = ({ title: c = "Levo", width: l = 500, height: u = 700, onSuccess: d }) => {
|
|
9
|
+
let f = e(), [p, m] = o(!1), [h, g] = o(null), [_, v] = o(null), [y, b] = o(), x = a(void 0), S = () => {
|
|
10
|
+
window.clearInterval(x.current);
|
|
11
|
+
}, C = n((e, t) => {
|
|
12
|
+
e.toLowerCase() === "success" ? (v(null), d(t)) : v(t);
|
|
13
|
+
}, []);
|
|
14
|
+
r(() => {
|
|
15
|
+
f.membership && (m(!0), f.membership?.getOAuthURL().then((e) => {
|
|
16
|
+
if (e) return g(e), e;
|
|
17
|
+
throw Error();
|
|
18
|
+
}).catch((e) => {
|
|
19
|
+
let n = t(e);
|
|
20
|
+
f.logger?.error("Failed to get OAuth URL", { exception: n }), v({
|
|
21
|
+
code: n?.code || "SOMETHING_WENT_WRONG",
|
|
22
|
+
message: n?.message || "We could not connect with our service for your sign-in."
|
|
23
|
+
});
|
|
24
|
+
}).finally(() => {
|
|
25
|
+
m(!1);
|
|
26
|
+
}));
|
|
27
|
+
}, []), r(() => (y && (x.current = window.setInterval(() => {
|
|
28
|
+
try {
|
|
29
|
+
let e = y.location.href, t = new URL(e).searchParams, n = t.get("code");
|
|
30
|
+
if (!n) return;
|
|
31
|
+
C(n, t), S(), y.close();
|
|
32
|
+
} catch {} finally {
|
|
33
|
+
(!y || y.closed) && (S(), v(null));
|
|
34
|
+
}
|
|
35
|
+
}, 700)), () => {
|
|
36
|
+
y && y.close();
|
|
37
|
+
}), [y]);
|
|
38
|
+
let w = n((e) => {
|
|
39
|
+
if (e && h !== null) {
|
|
40
|
+
let t = h?.[e];
|
|
41
|
+
t && (y && y.close(), b(s({
|
|
42
|
+
url: t,
|
|
43
|
+
title: c,
|
|
44
|
+
width: l,
|
|
45
|
+
height: u
|
|
46
|
+
})));
|
|
47
|
+
}
|
|
48
|
+
}, [h, y]);
|
|
49
|
+
return {
|
|
50
|
+
providers: i(() => h === null ? [] : Object.keys(h).filter((e) => !!h[e]), [h]),
|
|
51
|
+
isLoading: p,
|
|
52
|
+
error: _,
|
|
53
|
+
launchPopup: w
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { c as useLevoOAuth };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext as e, useContext as t } from "react";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
//#region src/providers/LevoProvider.tsx
|
|
5
|
+
var r = e({
|
|
6
|
+
client: null,
|
|
7
|
+
insights: null
|
|
8
|
+
}), i = ({ children: e, client: t, insights: i = null }) => /* @__PURE__ */ n(r.Provider, {
|
|
9
|
+
value: {
|
|
10
|
+
client: t,
|
|
11
|
+
insights: i
|
|
12
|
+
},
|
|
13
|
+
children: e
|
|
14
|
+
}), a = () => {
|
|
15
|
+
let e = t(r);
|
|
16
|
+
if (!e.client) throw Error("useLevo must be used within a LevoProvider. Please ensure you have wrapped your component tree with LevoProvider.");
|
|
17
|
+
return e.client;
|
|
18
|
+
}, o = () => t(r).insights;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { i as LevoProvider, a as useLevo, o as useLevoInsights };
|