@levo-so/react 0.1.40 → 0.1.44

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.
@@ -1,147 +1,221 @@
1
1
  "use client";
2
- var O = Object.defineProperty;
3
- var R = (e, t, n) => t in e ? O(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
4
- var m = (e, t, n) => R(e, typeof t != "symbol" ? t + "" : t, n);
5
- import { j as p } from "../jsx-runtime-D0AQ1Mn7.js";
6
- import j, { useState as g, useEffect as x, useMemo as y, useContext as P, useRef as U, useCallback as W } from "react";
7
- import { useLevo as _ } from "../providers/index.js";
8
- const L = j.createContext({
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
- }), b = ({
16
- title: e,
17
+ }), A = ({
18
+ title: o,
17
19
  onSuccess: t,
18
20
  onError: n,
19
- children: s
21
+ children: c
20
22
  }) => {
21
- const c = _(), i = typeof window < "u" ? window.location.href : "", [o, r] = g(null);
22
- x(() => {
23
- var u;
24
- c.membership && ((u = c.membership) == null || u.getOAuthURL().then((a) => {
25
- r(a);
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 f = y(
34
- () => ({ title: e, urls: o, onSuccess: t, onError: n }),
35
- [e, o, t, n]
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 x(() => {
38
- if (o && i) {
39
- const u = {}, a = Object.keys(o);
40
- for (const h of a)
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 l = o[h];
43
- if (l) {
44
- const w = new URL(l), d = w.searchParams;
45
- d.set("redirect_uri", i);
46
- const C = c.pageContext;
47
- C && d.set("page_context", JSON.stringify(C)), u[h] = w.toString();
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(u);
55
+ e(r);
52
56
  }
53
- }, [i]), /* @__PURE__ */ p.jsx(L.Provider, { value: f, children: s });
54
- }, k = () => P(L), A = ({ url: e, title: t, height: n, width: s }) => {
55
- const c = window.screenX + (window.outerWidth - s) / 2, i = window.screenY + (window.outerHeight - n) / 2.5;
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
- e,
61
+ o,
58
62
  t,
59
- `width=${s},height=${n},left=${c},top=${i}`
63
+ `width=${c},height=${n},left=${i},top=${l}`
60
64
  );
61
- }, E = ({
62
- title: e = "",
65
+ }, G = ({
66
+ title: o = "",
63
67
  width: t = 500,
64
68
  height: n = 500,
65
- url: s,
66
- children: c,
67
- onCode: i,
68
- onClose: o
69
+ url: c,
70
+ children: i,
71
+ onCode: l,
72
+ onClose: s
69
73
  }) => {
70
- const [r, f] = g(), u = U(), a = () => {
71
- window.clearInterval(u.current);
72
- }, h = () => {
73
- f(
74
- A({
75
- url: s,
76
- title: e,
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 x(() => (r && (u.current = window.setInterval(() => {
86
+ return L(() => (e && (f.current = window.setInterval(() => {
83
87
  try {
84
- const l = r.location.href, w = new URL(l).searchParams, d = w.get("code");
85
- if (!d)
88
+ const p = e.location.href, m = new URL(p).searchParams, w = m.get("code");
89
+ if (!w)
86
90
  return;
87
- i(d, w), a(), r.close();
91
+ l(w, m), d(), e.close();
88
92
  } catch {
89
93
  } finally {
90
- (!r || r.closed) && (o(), a());
94
+ (!e || e.closed) && (s(), d());
91
95
  }
92
96
  }, 700)), () => {
93
- r && r.close(), o && o();
94
- }), [r]), /* @__PURE__ */ p.jsx(
97
+ e && e.close(), s && s();
98
+ }), [e]), /* @__PURE__ */ g.jsx(
95
99
  "div",
96
100
  {
97
101
  onClick: () => {
98
- h();
102
+ r();
99
103
  },
100
- children: c
104
+ children: i
101
105
  }
102
106
  );
103
- }, S = ({
104
- title: e = "Levo",
107
+ }, H = ({
108
+ title: o = "Levo",
105
109
  url: t,
106
110
  children: n,
107
- onSuccess: s,
108
- onError: c,
109
- width: i = 500,
110
- height: o = 700
111
+ onSuccess: c,
112
+ onError: i,
113
+ width: l = 500,
114
+ height: s = 700
111
115
  }) => {
112
- const r = W((f, u) => {
113
- f.toLowerCase() === "success" ? s(u) : c(u);
116
+ const e = P((h, f) => {
117
+ h.toLowerCase() === "success" ? c(f) : i(f);
114
118
  }, []);
115
- return /* @__PURE__ */ p.jsx(
116
- E,
119
+ return /* @__PURE__ */ g.jsx(
120
+ G,
117
121
  {
118
- title: e,
119
- width: i,
120
- height: o,
122
+ title: o,
123
+ width: l,
124
+ height: s,
121
125
  onClose: () => {
122
126
  },
123
127
  url: t,
124
- onCode: r,
128
+ onCode: e,
125
129
  children: n
126
130
  }
127
131
  );
128
- }, N = ({ children: e, provider: t }) => {
129
- const { title: n, urls: s, onSuccess: c, onError: i } = k(), o = s == null ? void 0 : s[t];
130
- return o ? /* @__PURE__ */ p.jsx(
131
- S,
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: o,
136
- onSuccess: c,
137
- onError: i,
138
- children: e
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 v {
215
+ class j {
143
216
  }
144
- m(v, "Container", b), m(v, "Button", N);
217
+ O(j, "Container", A), O(j, "Button", M);
145
218
  export {
146
- v as LevoOAuth
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,sCAMtC,CAAC"}
1
+ {"version":3,"file":"errorHandler.d.ts","sourceRoot":"","sources":["../../src/utils/errorHandler.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,GAAI,OAAO,GAAG,sCAQtC,CAAC"}
@@ -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-B9yh0nbg.js";
2
- import { c as d } from "../Sonner-5IAqCkBs.js";
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.40",
3
+ "version": "0.1.44",
4
4
  "author": "Levo Engineering <devs@theinternetfolks.com>",
5
5
  "description": "Levo suite for React based applications",
6
6
  "type": "module",
@@ -16,83 +16,39 @@
16
16
  "peerDependencies": {
17
17
  "react": ">=18",
18
18
  "react-dom": ">=18",
19
- "@levo-so/core": "0.1.37"
19
+ "@levo-so/core": "0.1.44"
20
20
  },
21
21
  "dependencies": {
22
- "@radix-ui/react-checkbox": "1.1.1",
23
22
  "@radix-ui/react-dialog": "1.1.1",
24
- "@radix-ui/react-radio-group": "1.2.0",
25
23
  "@radix-ui/react-slot": "1.1.0",
26
- "@radix-ui/react-switch": "1.1.0",
27
24
  "@radix-ui/react-tabs": "1.1.0",
28
25
  "@radix-ui/react-tooltip": "1.1.2",
29
- "@theinternetfolks/mate": "1.0.4",
30
- "@theinternetfolks/snowflake": "1.3.0",
31
- "@tiptap/extension-bold": "2.5.8",
32
- "@tiptap/extension-bullet-list": "2.6.4",
33
- "@tiptap/extension-document": "2.6.4",
34
- "@tiptap/extension-hard-break": "2.5.8",
35
- "@tiptap/extension-history": "2.5.8",
36
- "@tiptap/extension-italic": "2.5.8",
37
- "@tiptap/extension-link": "2.6.4",
38
- "@tiptap/extension-list-item": "2.5.8",
39
- "@tiptap/extension-ordered-list": "2.6.4",
40
- "@tiptap/extension-paragraph": "2.6.4",
41
- "@tiptap/extension-strike": "2.5.8",
42
- "@tiptap/extension-text": "2.5.8",
43
- "@tiptap/extension-text-align": "2.6.4",
44
- "@tiptap/extension-underline": "2.6.4",
45
- "@tiptap/react": "2.6.4",
46
- "altcha": "1.0.7",
47
26
  "class-variance-authority": "0.7.0",
48
27
  "clsx": "2.1.1",
49
- "google-libphonenumber": "3.2.38",
50
- "inflection": "3.0.0",
51
28
  "lodash-es": "4.17.21",
52
29
  "lucide-react": "0.424.0",
53
30
  "react": "18.3.1",
54
- "react-datepicker": "7.3.0",
55
31
  "react-dom": "18.3.1",
56
- "react-dropzone": "14.2.3",
57
- "react-google-autocomplete": "2.7.3",
58
- "react-hook-form": "7.52.2",
59
32
  "react-icons": "5.2.1",
60
- "react-international-phone": "4.3.0",
61
33
  "react-intersection-observer": "9.13.0",
62
- "react-number-format": "5.4.0",
63
- "react-select": "5.8.0",
64
- "react-select-async-paginate": "0.7.5",
65
34
  "sonner": "1.5.0",
66
35
  "tailwind-merge": "2.4.0",
67
- "use-debounce": "10.0.2",
68
- "use-page-lifecycle": "1.1.2",
69
- "validator": "13.12.0",
70
- "validatorjs": "3.22.1",
71
- "wretch": "2.9.0"
36
+ "use-page-lifecycle": "1.1.2"
72
37
  },
73
38
  "devDependencies": {
74
- "@types/google-libphonenumber": "7.4.30",
75
- "@types/google.maps": "3.58.0",
76
39
  "@types/lodash-es": "4.17.12",
77
40
  "@types/react": "18.3.18",
78
41
  "@types/react-dom": "18.3.5",
79
- "@types/validator": "13.12.0",
80
- "@types/validatorjs": "3.15.5",
81
42
  "@vitejs/plugin-react": "4.3.4",
82
- "autoprefixer": "10.4.16",
83
43
  "clsx": "2.1.1",
84
- "postcss": "8.4.41",
85
- "postcss-import": "16.1.0",
86
44
  "rollup-preserve-directives": "1.1.1",
87
45
  "tailwind-merge": "2.4.0",
88
- "tailwindcss": "3.4.1",
89
- "tailwindcss-animate": "1.0.7",
90
46
  "typescript": "5.8.2",
91
47
  "vite": "6.0.5",
92
48
  "vite-plugin-dts": "4.1.0",
93
- "@levo/eslint-config": "0.0.0",
94
49
  "@levo/tw-config": "0.0.0",
95
- "@levo/ts-config": "0.0.0"
50
+ "@levo/ts-config": "0.0.0",
51
+ "@levo/eslint-config": "0.0.0"
96
52
  },
97
53
  "main": "./dist/index.js",
98
54
  "module": "./dist/index.js",