@erikey/react 0.4.33 → 0.4.35

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/ui/index.mjs CHANGED
@@ -8214,7 +8214,11 @@ function AuthCallback({ redirectTo }) {
8214
8214
  }
8215
8215
 
8216
8216
  // src/ui/components/auth/auth-flow.tsx
8217
- import { useCallback as useCallback9, useMemo as useMemo5, useState as useState16 } from "react";
8217
+ import {
8218
+ useCallback as useCallback9,
8219
+ useMemo as useMemo5,
8220
+ useState as useState16
8221
+ } from "react";
8218
8222
 
8219
8223
  // src/ui/components/auth/auth-view.tsx
8220
8224
  import { useContext as useContext29, useEffect as useEffect23, useState as useState15 } from "react";
@@ -15410,7 +15414,9 @@ var flowViewToPathKey = {
15410
15414
  TWO_FACTOR: "TWO_FACTOR",
15411
15415
  FORGOT_PASSWORD: "FORGOT_PASSWORD",
15412
15416
  RESET_PASSWORD: "RESET_PASSWORD",
15413
- MAGIC_LINK: "MAGIC_LINK"
15417
+ MAGIC_LINK: "MAGIC_LINK",
15418
+ EMAIL_OTP: "EMAIL_OTP",
15419
+ RECOVER_ACCOUNT: "RECOVER_ACCOUNT"
15414
15420
  };
15415
15421
  function parsePathToView(path) {
15416
15422
  const url = new URL(path, "http://localhost");
@@ -15434,8 +15440,17 @@ function parsePathToView(path) {
15434
15440
  if (pathname.includes("magic-link")) {
15435
15441
  return { view: "MAGIC_LINK", email };
15436
15442
  }
15443
+ if (pathname.includes("email-otp")) {
15444
+ return { view: "SIGN_IN", email };
15445
+ }
15446
+ if (pathname.includes("recover-account")) {
15447
+ return { view: "TWO_FACTOR", email };
15448
+ }
15437
15449
  return { view: "SIGN_IN", email };
15438
15450
  }
15451
+ function isAuthPath(href) {
15452
+ return href.includes("sign-in") || href.includes("sign-up") || href.includes("email-verification") || href.includes("two-factor") || href.includes("forgot-password") || href.includes("reset-password") || href.includes("magic-link") || href.includes("email-otp") || href.includes("recover-account");
15453
+ }
15439
15454
  function AuthFlow({
15440
15455
  mode = "internal",
15441
15456
  onEvent,
@@ -15451,6 +15466,7 @@ function AuthFlow({
15451
15466
  // AuthUIProvider props
15452
15467
  authClient,
15453
15468
  basePath = "/auth",
15469
+ Link: ExternalLink,
15454
15470
  ...providerProps
15455
15471
  }) {
15456
15472
  const [currentView, setCurrentView] = useState16(initialView);
@@ -15474,6 +15490,55 @@ function AuthFlow({
15474
15490
  },
15475
15491
  [mode, externalNavigate, onEvent]
15476
15492
  );
15493
+ const InternalLink = useCallback9(
15494
+ ({
15495
+ href,
15496
+ children,
15497
+ className: linkClassName,
15498
+ ...rest
15499
+ }) => {
15500
+ const handleClick = (e) => {
15501
+ if (mode === "internal" && isAuthPath(href)) {
15502
+ e.preventDefault();
15503
+ handleNavigate(href);
15504
+ }
15505
+ };
15506
+ if (mode === "internal" && isAuthPath(href)) {
15507
+ return /* @__PURE__ */ jsx38(
15508
+ "a",
15509
+ {
15510
+ href,
15511
+ className: linkClassName,
15512
+ onClick: handleClick,
15513
+ ...rest,
15514
+ children
15515
+ }
15516
+ );
15517
+ }
15518
+ if (ExternalLink) {
15519
+ return /* @__PURE__ */ jsx38(
15520
+ ExternalLink,
15521
+ {
15522
+ href,
15523
+ className: linkClassName,
15524
+ ...rest,
15525
+ children
15526
+ }
15527
+ );
15528
+ }
15529
+ return /* @__PURE__ */ jsx38(
15530
+ "a",
15531
+ {
15532
+ href,
15533
+ className: linkClassName,
15534
+ onClick: handleClick,
15535
+ ...rest,
15536
+ children
15537
+ }
15538
+ );
15539
+ },
15540
+ [mode, handleNavigate, ExternalLink]
15541
+ );
15477
15542
  const handleAuthEvent = useCallback9(
15478
15543
  (event) => {
15479
15544
  onEvent?.(event);
@@ -15501,6 +15566,7 @@ function AuthFlow({
15501
15566
  navigate: handleNavigate,
15502
15567
  onAuthEvent: handleAuthEvent,
15503
15568
  redirectTo,
15569
+ Link: InternalLink,
15504
15570
  ...providerProps,
15505
15571
  children: /* @__PURE__ */ jsx38(
15506
15572
  AuthView,