@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.
@@ -1,18 +1,56 @@
1
1
  'use strict';
2
2
 
3
3
  var react = require('react');
4
- var reactRouterDom = require('react-router-dom');
5
- require('@insforge/sdk');
6
4
  var jsxRuntime = require('react/jsx-runtime');
5
+ require('@insforge/sdk');
7
6
  var lucideReact = require('lucide-react');
8
7
  var zod = require('zod');
9
8
 
10
9
  // src/components/SignIn.tsx
10
+ var NavigationContext = react.createContext(null);
11
+ function useNavigationAdapter() {
12
+ const adapter = react.useContext(NavigationContext);
13
+ if (!adapter) {
14
+ throw new Error("useNavigationAdapter must be used within NavigationProvider");
15
+ }
16
+ return adapter;
17
+ }
18
+
19
+ // src/navigation/useSearchParams.ts
20
+ function useSearchParams() {
21
+ const adapter = useNavigationAdapter();
22
+ return adapter.useSearchParams();
23
+ }
11
24
  var InsforgeContext = react.createContext(void 0);
12
25
  function useInsforge() {
13
26
  const context = react.useContext(InsforgeContext);
14
27
  if (!context) {
15
- throw new Error("useInsforge must be used within InsforgeProvider");
28
+ if (typeof window !== "undefined") {
29
+ throw new Error("useInsforge must be used within InsforgeProvider");
30
+ }
31
+ return {
32
+ user: null,
33
+ isLoaded: false,
34
+ isSignedIn: false,
35
+ setUser: () => {
36
+ },
37
+ signIn: async () => ({ error: "SSR mode" }),
38
+ signUp: async () => ({ error: "SSR mode" }),
39
+ signOut: async () => {
40
+ },
41
+ updateUser: async () => {
42
+ },
43
+ reloadAuth: async () => ({ success: false, error: "SSR mode" }),
44
+ sendVerificationEmail: async () => null,
45
+ sendResetPasswordEmail: async () => null,
46
+ resetPassword: async () => null,
47
+ verifyEmail: async () => null,
48
+ exchangeResetPasswordToken: async () => ({ error: { message: "SSR mode" } }),
49
+ loginWithOAuth: async () => {
50
+ },
51
+ getPublicAuthConfig: async () => null,
52
+ baseUrl: ""
53
+ };
16
54
  }
17
55
  return context;
18
56
  }
@@ -225,7 +263,8 @@ function AuthPasswordField({
225
263
  onFocus,
226
264
  ...props
227
265
  }) {
228
- const [searchParams] = reactRouterDom.useSearchParams();
266
+ const searchParams = useSearchParams();
267
+ const { Link } = useNavigationAdapter();
229
268
  const [showPassword, setShowPassword] = react.useState(false);
230
269
  const [showStrength, setShowStrength] = react.useState(false);
231
270
  const resolvedForgotPasswordHref = react.useMemo(
@@ -241,7 +280,7 @@ function AuthPasswordField({
241
280
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-passwordField if-internal-p5w9m7", children: [
242
281
  (label || forgotPasswordLink) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-passwordField-labelRow", children: [
243
282
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, className: "if-passwordField-label", children: label }),
244
- forgotPasswordLink && resolvedForgotPasswordHref && /* @__PURE__ */ jsxRuntime.jsx("a", { href: resolvedForgotPasswordHref, className: "if-passwordField-forgotLink", children: forgotPasswordLink.text || "Forget Password?" })
283
+ forgotPasswordLink && resolvedForgotPasswordHref && /* @__PURE__ */ jsxRuntime.jsx(Link, { href: resolvedForgotPasswordHref, className: "if-passwordField-forgotLink", children: forgotPasswordLink.text || "Forget Password?" })
245
284
  ] }),
246
285
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-passwordField-inputWrapper", children: [
247
286
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -293,12 +332,13 @@ function AuthSubmitButton({
293
332
  );
294
333
  }
295
334
  function AuthLink({ text, linkText, href }) {
296
- const [searchParams] = reactRouterDom.useSearchParams();
335
+ const searchParams = useSearchParams();
336
+ const { Link } = useNavigationAdapter();
297
337
  const finalHref = resolveAuthUrl(href, searchParams);
298
338
  return /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "if-authLink if-internal-al5w9p", children: [
299
339
  text && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "if-authLink-text", children: text }),
300
340
  text && " ",
301
- /* @__PURE__ */ jsxRuntime.jsx("a", { href: finalHref, className: "if-authLink-link", children: linkText })
341
+ /* @__PURE__ */ jsxRuntime.jsx(Link, { href: finalHref, className: "if-authLink-link", children: linkText })
302
342
  ] });
303
343
  }
304
344
  function AuthDivider({ text = "or" }) {
@@ -938,7 +978,7 @@ function SignIn({ onError, ...uiProps }) {
938
978
  const [loading, setLoading] = react.useState(false);
939
979
  const [step, setStep] = react.useState("form");
940
980
  const [oauthLoading] = react.useState(null);
941
- const [searchParams] = reactRouterDom.useSearchParams();
981
+ const searchParams = useSearchParams();
942
982
  const redirectUrl = searchParams.get("redirect");
943
983
  async function handleSubmit(e) {
944
984
  e.preventDefault();
@@ -1147,7 +1187,7 @@ function SignUp({ onError, ...uiProps }) {
1147
1187
  const [loading, setLoading] = react.useState(false);
1148
1188
  const [step, setStep] = react.useState("form");
1149
1189
  const [oauthLoading] = react.useState(null);
1150
- const [searchParams] = reactRouterDom.useSearchParams();
1190
+ const searchParams = useSearchParams();
1151
1191
  const redirectUrl = searchParams.get("redirect");
1152
1192
  async function handleSubmit(e) {
1153
1193
  e.preventDefault();
@@ -1412,7 +1452,7 @@ function ResetPasswordForm({
1412
1452
  function ForgotPassword({ onError, ...uiProps }) {
1413
1453
  const { sendResetPasswordEmail, exchangeResetPasswordToken, resetPassword } = useInsforge();
1414
1454
  const { authConfig } = usePublicAuthConfig();
1415
- const [searchParams] = reactRouterDom.useSearchParams();
1455
+ const searchParams = useSearchParams();
1416
1456
  const [step, setStep] = react.useState("email");
1417
1457
  const [email, setEmail] = react.useState("");
1418
1458
  const [resetToken, setResetToken] = react.useState("");
@@ -1568,7 +1608,7 @@ function ForgotPassword({ onError, ...uiProps }) {
1568
1608
  );
1569
1609
  }
1570
1610
  function ResetPassword({ onError, ...uiProps }) {
1571
- const [searchParams] = reactRouterDom.useSearchParams();
1611
+ const searchParams = useSearchParams();
1572
1612
  const token = searchParams.get("token");
1573
1613
  const { resetPassword } = useInsforge();
1574
1614
  const { authConfig } = usePublicAuthConfig();