@insforge/react 0.4.11 → 0.5.0
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/atoms.cjs +21 -5
- package/dist/atoms.cjs.map +1 -1
- package/dist/atoms.js +21 -5
- package/dist/atoms.js.map +1 -1
- package/dist/components.cjs +26 -10
- package/dist/components.cjs.map +1 -1
- package/dist/components.js +26 -10
- package/dist/components.js.map +1 -1
- package/dist/forms.cjs +21 -5
- package/dist/forms.cjs.map +1 -1
- package/dist/forms.js +21 -5
- package/dist/forms.js.map +1 -1
- package/dist/hooks.cjs +2 -0
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.js +2 -0
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +58 -48
- 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 +56 -49
- package/dist/index.js.map +1 -1
- package/dist/lib.cjs +1 -0
- package/dist/lib.cjs.map +1 -1
- package/dist/lib.js +1 -0
- package/dist/lib.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 -44
- 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 -42
- package/dist/router.js.map +0 -1
package/dist/components.js
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
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
|
|
|
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
|
+
}
|
|
8
22
|
var InsforgeContext = createContext(void 0);
|
|
9
23
|
function useInsforge() {
|
|
10
24
|
const context = useContext(InsforgeContext);
|
|
@@ -222,7 +236,8 @@ function AuthPasswordField({
|
|
|
222
236
|
onFocus,
|
|
223
237
|
...props
|
|
224
238
|
}) {
|
|
225
|
-
const
|
|
239
|
+
const searchParams = useSearchParams();
|
|
240
|
+
const { Link } = useNavigationAdapter();
|
|
226
241
|
const [showPassword, setShowPassword] = useState(false);
|
|
227
242
|
const [showStrength, setShowStrength] = useState(false);
|
|
228
243
|
const resolvedForgotPasswordHref = useMemo(
|
|
@@ -238,7 +253,7 @@ function AuthPasswordField({
|
|
|
238
253
|
return /* @__PURE__ */ jsxs("div", { className: "if-passwordField if-internal-p5w9m7", children: [
|
|
239
254
|
(label || forgotPasswordLink) && /* @__PURE__ */ jsxs("div", { className: "if-passwordField-labelRow", children: [
|
|
240
255
|
/* @__PURE__ */ jsx("label", { htmlFor: id, className: "if-passwordField-label", children: label }),
|
|
241
|
-
forgotPasswordLink && resolvedForgotPasswordHref && /* @__PURE__ */ jsx(
|
|
256
|
+
forgotPasswordLink && resolvedForgotPasswordHref && /* @__PURE__ */ jsx(Link, { href: resolvedForgotPasswordHref, className: "if-passwordField-forgotLink", children: forgotPasswordLink.text || "Forget Password?" })
|
|
242
257
|
] }),
|
|
243
258
|
/* @__PURE__ */ jsxs("div", { className: "if-passwordField-inputWrapper", children: [
|
|
244
259
|
/* @__PURE__ */ jsx(
|
|
@@ -290,12 +305,13 @@ function AuthSubmitButton({
|
|
|
290
305
|
);
|
|
291
306
|
}
|
|
292
307
|
function AuthLink({ text, linkText, href }) {
|
|
293
|
-
const
|
|
308
|
+
const searchParams = useSearchParams();
|
|
309
|
+
const { Link } = useNavigationAdapter();
|
|
294
310
|
const finalHref = resolveAuthUrl(href, searchParams);
|
|
295
311
|
return /* @__PURE__ */ jsxs("p", { className: "if-authLink if-internal-al5w9p", children: [
|
|
296
312
|
text && /* @__PURE__ */ jsx("span", { className: "if-authLink-text", children: text }),
|
|
297
313
|
text && " ",
|
|
298
|
-
/* @__PURE__ */ jsx(
|
|
314
|
+
/* @__PURE__ */ jsx(Link, { href: finalHref, className: "if-authLink-link", children: linkText })
|
|
299
315
|
] });
|
|
300
316
|
}
|
|
301
317
|
function AuthDivider({ text = "or" }) {
|
|
@@ -935,7 +951,7 @@ function SignIn({ onError, ...uiProps }) {
|
|
|
935
951
|
const [loading, setLoading] = useState(false);
|
|
936
952
|
const [step, setStep] = useState("form");
|
|
937
953
|
const [oauthLoading] = useState(null);
|
|
938
|
-
const
|
|
954
|
+
const searchParams = useSearchParams();
|
|
939
955
|
const redirectUrl = searchParams.get("redirect");
|
|
940
956
|
async function handleSubmit(e) {
|
|
941
957
|
e.preventDefault();
|
|
@@ -1144,7 +1160,7 @@ function SignUp({ onError, ...uiProps }) {
|
|
|
1144
1160
|
const [loading, setLoading] = useState(false);
|
|
1145
1161
|
const [step, setStep] = useState("form");
|
|
1146
1162
|
const [oauthLoading] = useState(null);
|
|
1147
|
-
const
|
|
1163
|
+
const searchParams = useSearchParams();
|
|
1148
1164
|
const redirectUrl = searchParams.get("redirect");
|
|
1149
1165
|
async function handleSubmit(e) {
|
|
1150
1166
|
e.preventDefault();
|
|
@@ -1409,7 +1425,7 @@ function ResetPasswordForm({
|
|
|
1409
1425
|
function ForgotPassword({ onError, ...uiProps }) {
|
|
1410
1426
|
const { sendResetPasswordEmail, exchangeResetPasswordToken, resetPassword } = useInsforge();
|
|
1411
1427
|
const { authConfig } = usePublicAuthConfig();
|
|
1412
|
-
const
|
|
1428
|
+
const searchParams = useSearchParams();
|
|
1413
1429
|
const [step, setStep] = useState("email");
|
|
1414
1430
|
const [email, setEmail] = useState("");
|
|
1415
1431
|
const [resetToken, setResetToken] = useState("");
|
|
@@ -1565,7 +1581,7 @@ function ForgotPassword({ onError, ...uiProps }) {
|
|
|
1565
1581
|
);
|
|
1566
1582
|
}
|
|
1567
1583
|
function ResetPassword({ onError, ...uiProps }) {
|
|
1568
|
-
const
|
|
1584
|
+
const searchParams = useSearchParams();
|
|
1569
1585
|
const token = searchParams.get("token");
|
|
1570
1586
|
const { resetPassword } = useInsforge();
|
|
1571
1587
|
const { authConfig } = usePublicAuthConfig();
|