@insforge/react 0.4.12 → 0.5.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 +426 -439
- package/dist/atoms.cjs +46 -6
- package/dist/atoms.cjs.map +1 -1
- package/dist/atoms.js +46 -6
- package/dist/atoms.js.map +1 -1
- package/dist/components.cjs +51 -11
- package/dist/components.cjs.map +1 -1
- package/dist/components.js +51 -11
- package/dist/components.js.map +1 -1
- package/dist/forms.cjs +46 -6
- package/dist/forms.cjs.map +1 -1
- package/dist/forms.js +46 -6
- package/dist/forms.js.map +1 -1
- package/dist/hooks.cjs +27 -1
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.js +27 -1
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +83 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +81 -50
- package/dist/index.js.map +1 -1
- package/dist/navigation.cjs +53 -0
- package/dist/navigation.cjs.map +1 -0
- package/dist/navigation.d.cts +64 -0
- package/dist/navigation.d.ts +64 -0
- package/dist/navigation.js +48 -0
- package/dist/navigation.js.map +1 -0
- package/package.json +6 -7
- package/dist/router.cjs +0 -45
- package/dist/router.cjs.map +0 -1
- package/dist/router.d.cts +0 -79
- package/dist/router.d.ts +0 -79
- package/dist/router.js +0 -43
- package/dist/router.js.map +0 -1
package/dist/components.js
CHANGED
|
@@ -1,16 +1,54 @@
|
|
|
1
1
|
import { createContext, useState, useMemo, useRef, useEffect, useCallback, useContext } from 'react';
|
|
2
|
-
import { useSearchParams } from 'react-router-dom';
|
|
3
|
-
import '@insforge/sdk';
|
|
4
2
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import '@insforge/sdk';
|
|
5
4
|
import { AlertTriangle, Check, EyeOff, Eye, Loader2, CircleCheck, LogOut } from 'lucide-react';
|
|
6
5
|
import { z } from 'zod';
|
|
7
6
|
|
|
8
7
|
// src/components/SignIn.tsx
|
|
8
|
+
var NavigationContext = createContext(null);
|
|
9
|
+
function useNavigationAdapter() {
|
|
10
|
+
const adapter = useContext(NavigationContext);
|
|
11
|
+
if (!adapter) {
|
|
12
|
+
throw new Error("useNavigationAdapter must be used within NavigationProvider");
|
|
13
|
+
}
|
|
14
|
+
return adapter;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// src/navigation/useSearchParams.ts
|
|
18
|
+
function useSearchParams() {
|
|
19
|
+
const adapter = useNavigationAdapter();
|
|
20
|
+
return adapter.useSearchParams();
|
|
21
|
+
}
|
|
9
22
|
var InsforgeContext = createContext(void 0);
|
|
10
23
|
function useInsforge() {
|
|
11
24
|
const context = useContext(InsforgeContext);
|
|
12
25
|
if (!context) {
|
|
13
|
-
|
|
26
|
+
if (typeof window !== "undefined") {
|
|
27
|
+
throw new Error("useInsforge must be used within InsforgeProvider");
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
user: null,
|
|
31
|
+
isLoaded: false,
|
|
32
|
+
isSignedIn: false,
|
|
33
|
+
setUser: () => {
|
|
34
|
+
},
|
|
35
|
+
signIn: async () => ({ error: "SSR mode" }),
|
|
36
|
+
signUp: async () => ({ error: "SSR mode" }),
|
|
37
|
+
signOut: async () => {
|
|
38
|
+
},
|
|
39
|
+
updateUser: async () => {
|
|
40
|
+
},
|
|
41
|
+
reloadAuth: async () => ({ success: false, error: "SSR mode" }),
|
|
42
|
+
sendVerificationEmail: async () => null,
|
|
43
|
+
sendResetPasswordEmail: async () => null,
|
|
44
|
+
resetPassword: async () => null,
|
|
45
|
+
verifyEmail: async () => null,
|
|
46
|
+
exchangeResetPasswordToken: async () => ({ error: { message: "SSR mode" } }),
|
|
47
|
+
loginWithOAuth: async () => {
|
|
48
|
+
},
|
|
49
|
+
getPublicAuthConfig: async () => null,
|
|
50
|
+
baseUrl: ""
|
|
51
|
+
};
|
|
14
52
|
}
|
|
15
53
|
return context;
|
|
16
54
|
}
|
|
@@ -223,7 +261,8 @@ function AuthPasswordField({
|
|
|
223
261
|
onFocus,
|
|
224
262
|
...props
|
|
225
263
|
}) {
|
|
226
|
-
const
|
|
264
|
+
const searchParams = useSearchParams();
|
|
265
|
+
const { Link } = useNavigationAdapter();
|
|
227
266
|
const [showPassword, setShowPassword] = useState(false);
|
|
228
267
|
const [showStrength, setShowStrength] = useState(false);
|
|
229
268
|
const resolvedForgotPasswordHref = useMemo(
|
|
@@ -239,7 +278,7 @@ function AuthPasswordField({
|
|
|
239
278
|
return /* @__PURE__ */ jsxs("div", { className: "if-passwordField if-internal-p5w9m7", children: [
|
|
240
279
|
(label || forgotPasswordLink) && /* @__PURE__ */ jsxs("div", { className: "if-passwordField-labelRow", children: [
|
|
241
280
|
/* @__PURE__ */ jsx("label", { htmlFor: id, className: "if-passwordField-label", children: label }),
|
|
242
|
-
forgotPasswordLink && resolvedForgotPasswordHref && /* @__PURE__ */ jsx(
|
|
281
|
+
forgotPasswordLink && resolvedForgotPasswordHref && /* @__PURE__ */ jsx(Link, { href: resolvedForgotPasswordHref, className: "if-passwordField-forgotLink", children: forgotPasswordLink.text || "Forget Password?" })
|
|
243
282
|
] }),
|
|
244
283
|
/* @__PURE__ */ jsxs("div", { className: "if-passwordField-inputWrapper", children: [
|
|
245
284
|
/* @__PURE__ */ jsx(
|
|
@@ -291,12 +330,13 @@ function AuthSubmitButton({
|
|
|
291
330
|
);
|
|
292
331
|
}
|
|
293
332
|
function AuthLink({ text, linkText, href }) {
|
|
294
|
-
const
|
|
333
|
+
const searchParams = useSearchParams();
|
|
334
|
+
const { Link } = useNavigationAdapter();
|
|
295
335
|
const finalHref = resolveAuthUrl(href, searchParams);
|
|
296
336
|
return /* @__PURE__ */ jsxs("p", { className: "if-authLink if-internal-al5w9p", children: [
|
|
297
337
|
text && /* @__PURE__ */ jsx("span", { className: "if-authLink-text", children: text }),
|
|
298
338
|
text && " ",
|
|
299
|
-
/* @__PURE__ */ jsx(
|
|
339
|
+
/* @__PURE__ */ jsx(Link, { href: finalHref, className: "if-authLink-link", children: linkText })
|
|
300
340
|
] });
|
|
301
341
|
}
|
|
302
342
|
function AuthDivider({ text = "or" }) {
|
|
@@ -936,7 +976,7 @@ function SignIn({ onError, ...uiProps }) {
|
|
|
936
976
|
const [loading, setLoading] = useState(false);
|
|
937
977
|
const [step, setStep] = useState("form");
|
|
938
978
|
const [oauthLoading] = useState(null);
|
|
939
|
-
const
|
|
979
|
+
const searchParams = useSearchParams();
|
|
940
980
|
const redirectUrl = searchParams.get("redirect");
|
|
941
981
|
async function handleSubmit(e) {
|
|
942
982
|
e.preventDefault();
|
|
@@ -1145,7 +1185,7 @@ function SignUp({ onError, ...uiProps }) {
|
|
|
1145
1185
|
const [loading, setLoading] = useState(false);
|
|
1146
1186
|
const [step, setStep] = useState("form");
|
|
1147
1187
|
const [oauthLoading] = useState(null);
|
|
1148
|
-
const
|
|
1188
|
+
const searchParams = useSearchParams();
|
|
1149
1189
|
const redirectUrl = searchParams.get("redirect");
|
|
1150
1190
|
async function handleSubmit(e) {
|
|
1151
1191
|
e.preventDefault();
|
|
@@ -1410,7 +1450,7 @@ function ResetPasswordForm({
|
|
|
1410
1450
|
function ForgotPassword({ onError, ...uiProps }) {
|
|
1411
1451
|
const { sendResetPasswordEmail, exchangeResetPasswordToken, resetPassword } = useInsforge();
|
|
1412
1452
|
const { authConfig } = usePublicAuthConfig();
|
|
1413
|
-
const
|
|
1453
|
+
const searchParams = useSearchParams();
|
|
1414
1454
|
const [step, setStep] = useState("email");
|
|
1415
1455
|
const [email, setEmail] = useState("");
|
|
1416
1456
|
const [resetToken, setResetToken] = useState("");
|
|
@@ -1566,7 +1606,7 @@ function ForgotPassword({ onError, ...uiProps }) {
|
|
|
1566
1606
|
);
|
|
1567
1607
|
}
|
|
1568
1608
|
function ResetPassword({ onError, ...uiProps }) {
|
|
1569
|
-
const
|
|
1609
|
+
const searchParams = useSearchParams();
|
|
1570
1610
|
const token = searchParams.get("token");
|
|
1571
1611
|
const { resetPassword } = useInsforge();
|
|
1572
1612
|
const { authConfig } = usePublicAuthConfig();
|