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