@insforge/react 0.4.7 → 0.4.8

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.cjs CHANGED
@@ -545,7 +545,6 @@ function AuthOAuthProviders({
545
545
  function AuthVerificationCodeInput({
546
546
  length = 6,
547
547
  value,
548
- email,
549
548
  onChange,
550
549
  disabled = false,
551
550
  onComplete
@@ -593,33 +592,25 @@ function AuthVerificationCodeInput({
593
592
  }
594
593
  }
595
594
  };
596
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-verificationCode if-internal-vc8m4p", children: [
597
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "if-verificationCode-description", children: [
598
- "We've sent a verification code to your inbox at",
599
- " ",
600
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "if-verificationCode-email", children: email }),
601
- ". Enter it below to proceed."
602
- ] }),
603
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-verificationCode-inputContainer", children: Array.from({ length }).map((_, index) => /* @__PURE__ */ jsxRuntime.jsx(
604
- "input",
605
- {
606
- ref: (el) => {
607
- inputRefs.current[index] = el;
608
- },
609
- type: "text",
610
- inputMode: "numeric",
611
- maxLength: 1,
612
- value: value[index] || "",
613
- onChange: (e) => handleChange(index, e.target.value),
614
- onKeyDown: (e) => handleKeyDown(index, e),
615
- onPaste: handlePaste,
616
- disabled,
617
- className: "if-verificationCode-input",
618
- autoComplete: "one-time-code"
595
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-verificationCode-inputContainer", children: Array.from({ length }).map((_, index) => /* @__PURE__ */ jsxRuntime.jsx(
596
+ "input",
597
+ {
598
+ ref: (el) => {
599
+ inputRefs.current[index] = el;
619
600
  },
620
- index
621
- )) })
622
- ] });
601
+ type: "text",
602
+ inputMode: "numeric",
603
+ maxLength: 1,
604
+ value: value[index] || "",
605
+ onChange: (e) => handleChange(index, e.target.value),
606
+ onKeyDown: (e) => handleKeyDown(index, e),
607
+ onPaste: handlePaste,
608
+ disabled,
609
+ className: "if-verificationCode-input",
610
+ autoComplete: "one-time-code"
611
+ },
612
+ index
613
+ )) });
623
614
  }
624
615
  var InsforgeContext = react.createContext(void 0);
625
616
  function useInsforge() {
@@ -640,7 +631,8 @@ function AuthEmailVerificationStep({
640
631
  const [isSending, setIsSending] = react.useState(false);
641
632
  const [verificationCode, setVerificationCode] = react.useState("");
642
633
  const [isVerifying, setIsVerifying] = react.useState(false);
643
- const defaultDescription = method === "code" ? "We've sent a 6-digit verification code to {email}. Please enter it below to verify your account. The code will expire in 10 minutes." : "We've sent a verification link to {email}. Please check your email and click the link to verify your account. The link will expire in 10 minutes.";
634
+ const isLinkMethod = method === "link";
635
+ const displayDescription = isLinkMethod ? "We have sent an email to {email}. Please check your email to confirm your account before signing in. The confirmation link expires in 10 minutes." : "We've sent a verification code to your inbox at {email}. Enter it below to proceed.";
644
636
  react.useEffect(() => {
645
637
  const sendInitialEmail = async () => {
646
638
  try {
@@ -690,23 +682,29 @@ function AuthEmailVerificationStep({
690
682
  setVerificationCode("");
691
683
  }
692
684
  };
693
- const displayDescription = defaultDescription;
694
- const isLinkMethod = method === "link";
695
685
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-verificationStep", children: [
696
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "if-verificationStep-description", children: displayDescription.split("{email}").map((part, index, array) => /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
697
- part,
698
- index < array.length - 1 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "if-verificationCode-email", children: email })
699
- ] }, index)) }),
686
+ isLinkMethod && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-verificationStep-descriptionContainer", children: [
687
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "if-verificationStep-descriptionTitle", children: "Verify Your Email" }),
688
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "if-verificationStep-description", children: displayDescription.split("{email}").map((part, index, array) => /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
689
+ part,
690
+ index < array.length - 1 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "if-verificationLink-email", children: email })
691
+ ] }, index)) })
692
+ ] }),
700
693
  !isLinkMethod && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-verificationStep-codeContainer", children: [
701
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-verificationStep-codeInputWrapper", children: /* @__PURE__ */ jsxRuntime.jsx(
702
- AuthVerificationCodeInput,
703
- {
704
- value: verificationCode,
705
- onChange: setVerificationCode,
706
- email,
707
- disabled: isVerifying
708
- }
709
- ) }),
694
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-verificationStep-codeInputWrapper", children: [
695
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "if-verificationStep-codeDescription", children: displayDescription.split("{email}").map((part, index, array) => /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
696
+ part,
697
+ index < array.length - 1 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "if-verificationCode-email", children: email })
698
+ ] }, index)) }),
699
+ /* @__PURE__ */ jsxRuntime.jsx(
700
+ AuthVerificationCodeInput,
701
+ {
702
+ value: verificationCode,
703
+ onChange: setVerificationCode,
704
+ disabled: isVerifying
705
+ }
706
+ )
707
+ ] }),
710
708
  /* @__PURE__ */ jsxRuntime.jsx(
711
709
  AuthSubmitButton,
712
710
  {
@@ -716,7 +714,7 @@ function AuthEmailVerificationStep({
716
714
  onClick: () => {
717
715
  void handleSubmit();
718
716
  },
719
- children: isVerifying ? "Verifying..." : "Verify Code"
717
+ children: isVerifying ? "Verifying..." : "Continue"
720
718
  }
721
719
  )
722
720
  ] }),
@@ -748,6 +746,8 @@ function AuthResetPasswordVerificationStep({
748
746
  const [isSending, setIsSending] = react.useState(false);
749
747
  const [verificationCode, setVerificationCode] = react.useState("");
750
748
  const [isVerifying, setIsVerifying] = react.useState(false);
749
+ const isLinkMethod = method === "link";
750
+ const displayDescription = isLinkMethod ? "We have sent an email to {email}. Please check your email to reset your password. The link expires in 10 minutes." : "We've sent a reset password code to your inbox at {email}. Enter it below to proceed.";
751
751
  react.useEffect(() => {
752
752
  if (resendCountdown > 0) {
753
753
  const timer = setInterval(() => {
@@ -787,17 +787,20 @@ function AuthResetPasswordVerificationStep({
787
787
  setVerificationCode("");
788
788
  }
789
789
  };
790
- const isLinkMethod = method === "link";
791
- const description = isLinkMethod ? `We've sent a password reset link to ${email}. Please check your email and click the link to reset your password. The link will expire in 10 minutes.` : `We've sent a 6-digit verification code to ${email}. Please enter it below to reset your password. The code will expire in 10 minutes.`;
792
790
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-verificationStep", children: [
793
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "if-verificationStep-description", children: description }),
791
+ isLinkMethod && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-verificationStep-descriptionContainer", children: [
792
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "if-verificationStep-descriptionTitle", children: "Check Your Email" }),
793
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "if-verificationStep-description", children: displayDescription.split("{email}").map((part, index, array) => /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
794
+ part,
795
+ index < array.length - 1 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "if-verificationLink-email", children: email })
796
+ ] }, index)) })
797
+ ] }),
794
798
  !isLinkMethod && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-verificationStep-codeContainer", children: [
795
799
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-verificationStep-codeInputWrapper", children: /* @__PURE__ */ jsxRuntime.jsx(
796
800
  AuthVerificationCodeInput,
797
801
  {
798
802
  value: verificationCode,
799
803
  onChange: setVerificationCode,
800
- email,
801
804
  disabled: isVerifying
802
805
  }
803
806
  ) }),
@@ -850,7 +853,7 @@ function SignInForm({
850
853
  passwordLabel = "Password",
851
854
  passwordPlaceholder = "\u2022\u2022\u2022\u2022\u2022\u2022",
852
855
  forgotPasswordText = "Forget Password?",
853
- forgotPasswordUrl,
856
+ forgotPasswordUrl = "/forgot-password",
854
857
  submitButtonText = "Sign In",
855
858
  loadingButtonText = "Signing in...",
856
859
  signUpText = "Don't have an account?",
@@ -861,13 +864,7 @@ function SignInForm({
861
864
  onVerifyCode
862
865
  }) {
863
866
  return /* @__PURE__ */ jsxRuntime.jsxs(AuthContainer, { children: [
864
- /* @__PURE__ */ jsxRuntime.jsx(
865
- AuthHeader,
866
- {
867
- title: showVerificationStep ? "Verify Your Email" : title,
868
- subtitle: showVerificationStep ? "" : subtitle
869
- }
870
- ),
867
+ /* @__PURE__ */ jsxRuntime.jsx(AuthHeader, { title, subtitle }),
871
868
  /* @__PURE__ */ jsxRuntime.jsx(AuthErrorBanner, { error: error || "" }),
872
869
  showVerificationStep ? /* @__PURE__ */ jsxRuntime.jsx(AuthEmailVerificationStep, { email, onVerifyCode }) : /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit, noValidate: true, className: "if-form if-internal-fm9k2p", children: [
873
870
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -947,13 +944,7 @@ function SignUpForm({
947
944
  onVerifyCode
948
945
  }) {
949
946
  return /* @__PURE__ */ jsxRuntime.jsxs(AuthContainer, { children: [
950
- /* @__PURE__ */ jsxRuntime.jsx(
951
- AuthHeader,
952
- {
953
- title: showVerificationStep ? "Verify Your Email" : title,
954
- subtitle: showVerificationStep ? "" : subtitle
955
- }
956
- ),
947
+ /* @__PURE__ */ jsxRuntime.jsx(AuthHeader, { title, subtitle }),
957
948
  /* @__PURE__ */ jsxRuntime.jsx(AuthErrorBanner, { error: error || "" }),
958
949
  showVerificationStep ? /* @__PURE__ */ jsxRuntime.jsx(AuthEmailVerificationStep, { email, onVerifyCode }) : /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit, noValidate: true, className: "if-form if-internal-fm9k2p", children: [
959
950
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1010,10 +1001,10 @@ function ForgotPasswordForm({
1010
1001
  error,
1011
1002
  loading = false,
1012
1003
  title = "Forgot Password?",
1013
- subtitle = "Enter your email address and we'll send you a code to reset your password.",
1004
+ subtitle = "Enter your email address and we'll send you a {method} to reset your password.",
1014
1005
  emailLabel = "Email",
1015
1006
  emailPlaceholder = "example@email.com",
1016
- submitButtonText = "Send Reset Code",
1007
+ submitButtonText = "Reset Password",
1017
1008
  loadingButtonText = "Sending...",
1018
1009
  backToSignInText = "Remember your password?",
1019
1010
  backToSignInUrl = "/sign-in",
@@ -1022,14 +1013,9 @@ function ForgotPasswordForm({
1022
1013
  onVerifyCode,
1023
1014
  onResendEmail
1024
1015
  }) {
1016
+ const displaySubtitle = subtitle.replace("{method}", resetPasswordMethod);
1025
1017
  return /* @__PURE__ */ jsxRuntime.jsxs(AuthContainer, { children: [
1026
- /* @__PURE__ */ jsxRuntime.jsx(
1027
- AuthHeader,
1028
- {
1029
- title: showVerificationStep ? resetPasswordMethod === "link" ? "Check Your Email" : "Enter Reset Code" : title,
1030
- subtitle: showVerificationStep ? "" : subtitle
1031
- }
1032
- ),
1018
+ /* @__PURE__ */ jsxRuntime.jsx(AuthHeader, { title, subtitle: displaySubtitle }),
1033
1019
  /* @__PURE__ */ jsxRuntime.jsx(AuthErrorBanner, { error: error || "" }),
1034
1020
  showVerificationStep ? /* @__PURE__ */ jsxRuntime.jsx(
1035
1021
  AuthResetPasswordVerificationStep,