@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/dist/forms.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
2
  import { AlertTriangle, EyeOff, Eye, Loader2, CircleCheck, Check } from 'lucide-react';
3
3
  import { createContext, useState, useEffect, useMemo, useCallback, useContext, useRef } from 'react';
4
- import { useSearchParams } from 'react-router-dom';
5
4
  import '@insforge/sdk';
6
5
 
7
6
  // src/components/atoms/AuthBranding.tsx
@@ -102,6 +101,20 @@ function AuthFormField({ label, id, ...props }) {
102
101
  /* @__PURE__ */ jsx("input", { id, className: "if-formField-input if-internal-i2v8k4", ...props })
103
102
  ] });
104
103
  }
104
+ var NavigationContext = createContext(null);
105
+ function useNavigationAdapter() {
106
+ const adapter = useContext(NavigationContext);
107
+ if (!adapter) {
108
+ throw new Error("useNavigationAdapter must be used within NavigationProvider");
109
+ }
110
+ return adapter;
111
+ }
112
+
113
+ // src/navigation/useSearchParams.ts
114
+ function useSearchParams() {
115
+ const adapter = useNavigationAdapter();
116
+ return adapter.useSearchParams();
117
+ }
105
118
  function AuthPasswordStrengthIndicator({
106
119
  password,
107
120
  config
@@ -195,7 +208,8 @@ function AuthPasswordField({
195
208
  onFocus,
196
209
  ...props
197
210
  }) {
198
- const [searchParams] = useSearchParams();
211
+ const searchParams = useSearchParams();
212
+ const { Link } = useNavigationAdapter();
199
213
  const [showPassword, setShowPassword] = useState(false);
200
214
  const [showStrength, setShowStrength] = useState(false);
201
215
  const resolvedForgotPasswordHref = useMemo(
@@ -211,7 +225,7 @@ function AuthPasswordField({
211
225
  return /* @__PURE__ */ jsxs("div", { className: "if-passwordField if-internal-p5w9m7", children: [
212
226
  (label || forgotPasswordLink) && /* @__PURE__ */ jsxs("div", { className: "if-passwordField-labelRow", children: [
213
227
  /* @__PURE__ */ jsx("label", { htmlFor: id, className: "if-passwordField-label", children: label }),
214
- forgotPasswordLink && resolvedForgotPasswordHref && /* @__PURE__ */ jsx("a", { href: resolvedForgotPasswordHref, className: "if-passwordField-forgotLink", children: forgotPasswordLink.text || "Forget Password?" })
228
+ forgotPasswordLink && resolvedForgotPasswordHref && /* @__PURE__ */ jsx(Link, { href: resolvedForgotPasswordHref, className: "if-passwordField-forgotLink", children: forgotPasswordLink.text || "Forget Password?" })
215
229
  ] }),
216
230
  /* @__PURE__ */ jsxs("div", { className: "if-passwordField-inputWrapper", children: [
217
231
  /* @__PURE__ */ jsx(
@@ -263,12 +277,13 @@ function AuthSubmitButton({
263
277
  );
264
278
  }
265
279
  function AuthLink({ text, linkText, href }) {
266
- const [searchParams] = useSearchParams();
280
+ const searchParams = useSearchParams();
281
+ const { Link } = useNavigationAdapter();
267
282
  const finalHref = resolveAuthUrl(href, searchParams);
268
283
  return /* @__PURE__ */ jsxs("p", { className: "if-authLink if-internal-al5w9p", children: [
269
284
  text && /* @__PURE__ */ jsx("span", { className: "if-authLink-text", children: text }),
270
285
  text && " ",
271
- /* @__PURE__ */ jsx("a", { href: finalHref, className: "if-authLink-link", children: linkText })
286
+ /* @__PURE__ */ jsx(Link, { href: finalHref, className: "if-authLink-link", children: linkText })
272
287
  ] });
273
288
  }
274
289
  function AuthDivider({ text = "or" }) {
@@ -609,7 +624,32 @@ var InsforgeContext = createContext(void 0);
609
624
  function useInsforge() {
610
625
  const context = useContext(InsforgeContext);
611
626
  if (!context) {
612
- throw new Error("useInsforge must be used within InsforgeProvider");
627
+ if (typeof window !== "undefined") {
628
+ throw new Error("useInsforge must be used within InsforgeProvider");
629
+ }
630
+ return {
631
+ user: null,
632
+ isLoaded: false,
633
+ isSignedIn: false,
634
+ setUser: () => {
635
+ },
636
+ signIn: async () => ({ error: "SSR mode" }),
637
+ signUp: async () => ({ error: "SSR mode" }),
638
+ signOut: async () => {
639
+ },
640
+ updateUser: async () => {
641
+ },
642
+ reloadAuth: async () => ({ success: false, error: "SSR mode" }),
643
+ sendVerificationEmail: async () => null,
644
+ sendResetPasswordEmail: async () => null,
645
+ resetPassword: async () => null,
646
+ verifyEmail: async () => null,
647
+ exchangeResetPasswordToken: async () => ({ error: { message: "SSR mode" } }),
648
+ loginWithOAuth: async () => {
649
+ },
650
+ getPublicAuthConfig: async () => null,
651
+ baseUrl: ""
652
+ };
613
653
  }
614
654
  return context;
615
655
  }