@levo-so/react 0.1.40 → 0.1.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/{Sonner-5IAqCkBs.js → Sonner-BzW9wsXf.js} +11 -14
- package/dist/Spinner-DBvVyDMF.js +119 -0
- package/dist/Tooltip-BeY_STLA.js +281 -0
- package/dist/cn-C9QoOYNG.js +6 -0
- package/dist/components/Dialog.d.ts +2 -0
- package/dist/components/Dialog.d.ts.map +1 -1
- package/dist/components/DialogWrapper.d.ts +1 -0
- package/dist/components/DialogWrapper.d.ts.map +1 -1
- package/dist/components/Sonner.d.ts.map +1 -1
- package/dist/components/index.js +20 -19
- package/dist/index.css +1 -1
- package/dist/index.js +57 -54
- package/dist/isEmptyObject-BoIi0jMB.js +21 -0
- package/dist/membership/components/Button.d.ts.map +1 -1
- package/dist/membership/components/Container.d.ts +1 -0
- package/dist/membership/components/Container.d.ts.map +1 -1
- package/dist/membership/index.d.ts +1 -0
- package/dist/membership/index.d.ts.map +1 -1
- package/dist/membership/index.js +155 -81
- package/dist/membership/useLevoOAuth.d.ts +17 -0
- package/dist/membership/useLevoOAuth.d.ts.map +1 -0
- package/dist/utils/errorHandler.d.ts.map +1 -1
- package/dist/utils/index.js +2 -2
- package/package.json +2 -2
- package/dist/Tooltip-DcdGb876.js +0 -383
- package/dist/isEmptyObject-B9yh0nbg.js +0 -19
package/dist/membership/index.js
CHANGED
|
@@ -1,147 +1,221 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
import { j as
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
2
|
+
var $ = Object.defineProperty;
|
|
3
|
+
var I = (o, t, n) => t in o ? $(o, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[t] = n;
|
|
4
|
+
var O = (o, t, n) => I(o, typeof t != "symbol" ? t + "" : t, n);
|
|
5
|
+
import { j as g } from "../jsx-runtime-D0AQ1Mn7.js";
|
|
6
|
+
import { S as N } from "../Spinner-DBvVyDMF.js";
|
|
7
|
+
import S, { useState as x, useEffect as L, useMemo as W, useContext as _, useRef as b, useCallback as P } from "react";
|
|
8
|
+
import { useLevo as E } from "../providers/index.js";
|
|
9
|
+
const U = S.createContext({
|
|
9
10
|
urls: null,
|
|
10
11
|
title: "",
|
|
12
|
+
isLoading: !1,
|
|
11
13
|
onSuccess: () => {
|
|
12
14
|
},
|
|
13
15
|
onError: () => {
|
|
14
16
|
}
|
|
15
|
-
}),
|
|
16
|
-
title:
|
|
17
|
+
}), A = ({
|
|
18
|
+
title: o,
|
|
17
19
|
onSuccess: t,
|
|
18
20
|
onError: n,
|
|
19
|
-
children:
|
|
21
|
+
children: c
|
|
20
22
|
}) => {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
const i = E(), l = typeof window < "u" ? window.location.href : "", [s, e] = x(null), [h, f] = x(!1);
|
|
24
|
+
L(() => {
|
|
25
|
+
var r;
|
|
26
|
+
i.membership && (f(!0), (r = i.membership) == null || r.getOAuthURL().then((p) => {
|
|
27
|
+
e(p);
|
|
26
28
|
}).catch(() => {
|
|
27
29
|
n({
|
|
28
30
|
code: "SOMETHING_WENT_WRONG",
|
|
29
31
|
message: "We could not connect with our service for your sign-in."
|
|
30
32
|
});
|
|
33
|
+
}).finally(() => {
|
|
34
|
+
f(!1);
|
|
31
35
|
}));
|
|
32
36
|
}, []);
|
|
33
|
-
const
|
|
34
|
-
() => ({ title:
|
|
35
|
-
[
|
|
37
|
+
const d = W(
|
|
38
|
+
() => ({ title: o, urls: s, isLoading: h, onSuccess: t, onError: n }),
|
|
39
|
+
[o, s, t, n, h]
|
|
36
40
|
);
|
|
37
|
-
return
|
|
38
|
-
if (
|
|
39
|
-
const
|
|
40
|
-
for (const
|
|
41
|
+
return L(() => {
|
|
42
|
+
if (s && l) {
|
|
43
|
+
const r = {}, p = Object.keys(s);
|
|
44
|
+
for (const m of p)
|
|
41
45
|
try {
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
const C =
|
|
47
|
-
C &&
|
|
46
|
+
const w = s[m];
|
|
47
|
+
if (w) {
|
|
48
|
+
const v = new URL(w), y = v.searchParams;
|
|
49
|
+
y.set("redirect_uri", l);
|
|
50
|
+
const C = i.pageContext;
|
|
51
|
+
C && y.set("page_context", JSON.stringify(C)), r[m] = v.toString();
|
|
48
52
|
}
|
|
49
53
|
} catch {
|
|
50
54
|
}
|
|
51
|
-
r
|
|
55
|
+
e(r);
|
|
52
56
|
}
|
|
53
|
-
}, [
|
|
54
|
-
}, k = () =>
|
|
55
|
-
const
|
|
57
|
+
}, [l]), /* @__PURE__ */ g.jsx(U.Provider, { value: d, children: c });
|
|
58
|
+
}, k = () => _(U), T = ({ url: o, title: t, height: n, width: c }) => {
|
|
59
|
+
const i = window.screenX + (window.outerWidth - c) / 2, l = window.screenY + (window.outerHeight - n) / 2.5;
|
|
56
60
|
return window.open(
|
|
57
|
-
|
|
61
|
+
o,
|
|
58
62
|
t,
|
|
59
|
-
`width=${
|
|
63
|
+
`width=${c},height=${n},left=${i},top=${l}`
|
|
60
64
|
);
|
|
61
|
-
},
|
|
62
|
-
title:
|
|
65
|
+
}, G = ({
|
|
66
|
+
title: o = "",
|
|
63
67
|
width: t = 500,
|
|
64
68
|
height: n = 500,
|
|
65
|
-
url:
|
|
66
|
-
children:
|
|
67
|
-
onCode:
|
|
68
|
-
onClose:
|
|
69
|
+
url: c,
|
|
70
|
+
children: i,
|
|
71
|
+
onCode: l,
|
|
72
|
+
onClose: s
|
|
69
73
|
}) => {
|
|
70
|
-
const [
|
|
71
|
-
window.clearInterval(
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
url:
|
|
76
|
-
title:
|
|
74
|
+
const [e, h] = x(), f = b(), d = () => {
|
|
75
|
+
window.clearInterval(f.current);
|
|
76
|
+
}, r = () => {
|
|
77
|
+
h(
|
|
78
|
+
T({
|
|
79
|
+
url: c,
|
|
80
|
+
title: o,
|
|
77
81
|
width: t,
|
|
78
82
|
height: n
|
|
79
83
|
})
|
|
80
84
|
);
|
|
81
85
|
};
|
|
82
|
-
return
|
|
86
|
+
return L(() => (e && (f.current = window.setInterval(() => {
|
|
83
87
|
try {
|
|
84
|
-
const
|
|
85
|
-
if (!
|
|
88
|
+
const p = e.location.href, m = new URL(p).searchParams, w = m.get("code");
|
|
89
|
+
if (!w)
|
|
86
90
|
return;
|
|
87
|
-
|
|
91
|
+
l(w, m), d(), e.close();
|
|
88
92
|
} catch {
|
|
89
93
|
} finally {
|
|
90
|
-
(!
|
|
94
|
+
(!e || e.closed) && (s(), d());
|
|
91
95
|
}
|
|
92
96
|
}, 700)), () => {
|
|
93
|
-
|
|
94
|
-
}), [
|
|
97
|
+
e && e.close(), s && s();
|
|
98
|
+
}), [e]), /* @__PURE__ */ g.jsx(
|
|
95
99
|
"div",
|
|
96
100
|
{
|
|
97
101
|
onClick: () => {
|
|
98
|
-
|
|
102
|
+
r();
|
|
99
103
|
},
|
|
100
|
-
children:
|
|
104
|
+
children: i
|
|
101
105
|
}
|
|
102
106
|
);
|
|
103
|
-
},
|
|
104
|
-
title:
|
|
107
|
+
}, H = ({
|
|
108
|
+
title: o = "Levo",
|
|
105
109
|
url: t,
|
|
106
110
|
children: n,
|
|
107
|
-
onSuccess:
|
|
108
|
-
onError:
|
|
109
|
-
width:
|
|
110
|
-
height:
|
|
111
|
+
onSuccess: c,
|
|
112
|
+
onError: i,
|
|
113
|
+
width: l = 500,
|
|
114
|
+
height: s = 700
|
|
111
115
|
}) => {
|
|
112
|
-
const
|
|
113
|
-
|
|
116
|
+
const e = P((h, f) => {
|
|
117
|
+
h.toLowerCase() === "success" ? c(f) : i(f);
|
|
114
118
|
}, []);
|
|
115
|
-
return /* @__PURE__ */
|
|
116
|
-
|
|
119
|
+
return /* @__PURE__ */ g.jsx(
|
|
120
|
+
G,
|
|
117
121
|
{
|
|
118
|
-
title:
|
|
119
|
-
width:
|
|
120
|
-
height:
|
|
122
|
+
title: o,
|
|
123
|
+
width: l,
|
|
124
|
+
height: s,
|
|
121
125
|
onClose: () => {
|
|
122
126
|
},
|
|
123
127
|
url: t,
|
|
124
|
-
onCode:
|
|
128
|
+
onCode: e,
|
|
125
129
|
children: n
|
|
126
130
|
}
|
|
127
131
|
);
|
|
128
|
-
},
|
|
129
|
-
const { title: n, urls:
|
|
130
|
-
return
|
|
131
|
-
|
|
132
|
+
}, M = ({ children: o, provider: t }) => {
|
|
133
|
+
const { title: n, urls: c, isLoading: i, onSuccess: l, onError: s } = k(), e = c == null ? void 0 : c[t];
|
|
134
|
+
return e ? /* @__PURE__ */ g.jsx(
|
|
135
|
+
H,
|
|
132
136
|
{
|
|
133
137
|
title: n,
|
|
134
138
|
provider: t,
|
|
135
|
-
url:
|
|
136
|
-
onSuccess:
|
|
137
|
-
onError:
|
|
138
|
-
children:
|
|
139
|
+
url: e,
|
|
140
|
+
onSuccess: l,
|
|
141
|
+
onError: s,
|
|
142
|
+
children: i ? /* @__PURE__ */ g.jsx("div", { className: "w-full items-center justify-center", children: /* @__PURE__ */ g.jsx(N, { className: "h-5 w-5 bg-brand" }) }) : o
|
|
139
143
|
}
|
|
140
144
|
) : null;
|
|
145
|
+
}, B = ({ url: o, title: t, height: n, width: c }) => {
|
|
146
|
+
const i = window.screenX + (window.outerWidth - c) / 2, l = window.screenY + (window.outerHeight - n) / 2.5;
|
|
147
|
+
return window.open(
|
|
148
|
+
o,
|
|
149
|
+
t,
|
|
150
|
+
`width=${c},height=${n},left=${i},top=${l}`
|
|
151
|
+
);
|
|
152
|
+
}, D = ({
|
|
153
|
+
title: o = "Levo",
|
|
154
|
+
width: t = 500,
|
|
155
|
+
height: n = 700,
|
|
156
|
+
onSuccess: c
|
|
157
|
+
}) => {
|
|
158
|
+
const i = E(), [l, s] = x(!1), [e, h] = x(null), [f, d] = x(null), [r, p] = x(), m = b(), w = () => {
|
|
159
|
+
window.clearInterval(m.current);
|
|
160
|
+
}, v = P((a, u) => {
|
|
161
|
+
a.toLowerCase() === "success" ? (d(null), c(u)) : d(u);
|
|
162
|
+
}, []);
|
|
163
|
+
L(() => {
|
|
164
|
+
var a;
|
|
165
|
+
i.membership && (s(!0), (a = i.membership) == null || a.getOAuthURL().then((u) => {
|
|
166
|
+
if (u)
|
|
167
|
+
return h(u), u;
|
|
168
|
+
throw new Error();
|
|
169
|
+
}).catch(() => {
|
|
170
|
+
d({
|
|
171
|
+
code: "SOMETHING_WENT_WRONG",
|
|
172
|
+
message: "We could not connect with our service for your sign-in."
|
|
173
|
+
});
|
|
174
|
+
}).finally(() => {
|
|
175
|
+
s(!1);
|
|
176
|
+
}));
|
|
177
|
+
}, []), L(() => (r && (m.current = window.setInterval(() => {
|
|
178
|
+
try {
|
|
179
|
+
const a = r.location.href, u = new URL(a).searchParams, R = u.get("code");
|
|
180
|
+
if (!R)
|
|
181
|
+
return;
|
|
182
|
+
v(R, u), w(), r.close();
|
|
183
|
+
} catch {
|
|
184
|
+
} finally {
|
|
185
|
+
(!r || r.closed) && (w(), d(null));
|
|
186
|
+
}
|
|
187
|
+
}, 700)), () => {
|
|
188
|
+
r && r.close();
|
|
189
|
+
}), [r]);
|
|
190
|
+
const y = P(
|
|
191
|
+
(a) => {
|
|
192
|
+
if (a && e !== null) {
|
|
193
|
+
const u = e == null ? void 0 : e[a];
|
|
194
|
+
u && (r && r.close(), p(
|
|
195
|
+
B({
|
|
196
|
+
url: u,
|
|
197
|
+
title: o,
|
|
198
|
+
width: t,
|
|
199
|
+
height: n
|
|
200
|
+
})
|
|
201
|
+
));
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
[e, r]
|
|
205
|
+
);
|
|
206
|
+
return {
|
|
207
|
+
providers: W(() => e !== null ? Object.keys(e).filter(
|
|
208
|
+
(a) => !!e[a]
|
|
209
|
+
) : [], [e]),
|
|
210
|
+
isLoading: l,
|
|
211
|
+
error: f,
|
|
212
|
+
launchPopup: y
|
|
213
|
+
};
|
|
141
214
|
};
|
|
142
|
-
class
|
|
215
|
+
class j {
|
|
143
216
|
}
|
|
144
|
-
|
|
217
|
+
O(j, "Container", A), O(j, "Button", M);
|
|
145
218
|
export {
|
|
146
|
-
|
|
219
|
+
j as LevoOAuth,
|
|
220
|
+
D as useLevoOAuth
|
|
147
221
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ILevoMembership } from '@levo-so/core';
|
|
2
|
+
export interface IUseLevoOAuthProps {
|
|
3
|
+
title?: string;
|
|
4
|
+
onSuccess: (data: Record<string, string>) => void;
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const useLevoOAuth: ({ title, width, height, onSuccess, }: IUseLevoOAuthProps) => {
|
|
9
|
+
providers: ("google" | "linkedin" | "microsoft")[];
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
error: {
|
|
12
|
+
code: string;
|
|
13
|
+
message: string;
|
|
14
|
+
} | null;
|
|
15
|
+
launchPopup: (provider: ILevoMembership.OAuthURLProvider) => void;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=useLevoOAuth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLevoOAuth.d.ts","sourceRoot":"","sources":["../../src/membership/useLevoOAuth.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAsBrD,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,YAAY,GAAI,sCAK1B,kBAAkB;;;;cAMX,MAAM;iBACH,MAAM;;4BA2EJ,eAAe,CAAC,gBAAgB;CAsC9C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorHandler.d.ts","sourceRoot":"","sources":["../../src/utils/errorHandler.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,GAAI,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"errorHandler.d.ts","sourceRoot":"","sources":["../../src/utils/errorHandler.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,GAAI,OAAO,GAAG,sCAQtC,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as a, e as r, i as t, a as i, c, f as b, d as o } from "../isEmptyObject-
|
|
2
|
-
import { c as d } from "../
|
|
1
|
+
import { b as a, e as r, i as t, a as i, c, f as b, d as o } from "../isEmptyObject-BoIi0jMB.js";
|
|
2
|
+
import { c as d } from "../cn-C9QoOYNG.js";
|
|
3
3
|
export {
|
|
4
4
|
a as byteToSize,
|
|
5
5
|
d as cn,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@levo-so/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.43",
|
|
4
4
|
"author": "Levo Engineering <devs@theinternetfolks.com>",
|
|
5
5
|
"description": "Levo suite for React based applications",
|
|
6
6
|
"type": "module",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"react": ">=18",
|
|
18
18
|
"react-dom": ">=18",
|
|
19
|
-
"@levo-so/core": "0.1.
|
|
19
|
+
"@levo-so/core": "0.1.43"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@radix-ui/react-checkbox": "1.1.1",
|