@insforge/react 0.4.7 → 0.4.9

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/atoms.js CHANGED
@@ -106,34 +106,27 @@ function AuthPasswordStrengthIndicator({
106
106
  config
107
107
  }) {
108
108
  const requirements = createRequirements(config);
109
- return /* @__PURE__ */ jsx("div", { className: "if-passwordStrength if-internal-ps6w3k", children: /* @__PURE__ */ jsx("div", { className: "if-passwordStrength-requirements", children: requirements.map((req) => /* @__PURE__ */ jsxs(
110
- "div",
111
- {
112
- className: `if-passwordStrength-requirement ${req.test(password) ? "met" : "unmet"}`,
113
- children: [
114
- /* @__PURE__ */ jsx(
115
- "div",
116
- {
117
- style: {
118
- display: "flex",
119
- alignItems: "center",
120
- justifyContent: "center",
121
- width: "1rem",
122
- height: "1rem",
123
- borderRadius: "50%",
124
- border: "2px solid",
125
- borderColor: req.test(password) ? "transparent" : "#9ca3af",
126
- backgroundColor: req.test(password) ? "#059669" : "white",
127
- transition: "all 0.2s"
128
- },
129
- children: req.test(password) && /* @__PURE__ */ jsx(Check, { style: { width: "0.75rem", height: "0.75rem", color: "white" } })
130
- }
131
- ),
132
- /* @__PURE__ */ jsx("span", { children: req.label })
133
- ]
134
- },
135
- req.label
136
- )) }) });
109
+ return /* @__PURE__ */ jsx("div", { className: "if-passwordStrength if-internal-ps6w3k", children: /* @__PURE__ */ jsx("div", { className: "if-passwordStrength-requirements", children: requirements.map((req) => /* @__PURE__ */ jsxs("div", { className: "if-passwordStrength-requirement", children: [
110
+ /* @__PURE__ */ jsx(
111
+ "div",
112
+ {
113
+ style: {
114
+ display: "flex",
115
+ alignItems: "center",
116
+ justifyContent: "center",
117
+ width: "1rem",
118
+ height: "1rem",
119
+ borderRadius: "50%",
120
+ border: "2px solid",
121
+ borderColor: req.test(password) ? "transparent" : "#9ca3af",
122
+ backgroundColor: req.test(password) ? "#059669" : "white",
123
+ transition: "all 0.2s"
124
+ },
125
+ children: req.test(password) && /* @__PURE__ */ jsx(Check, { style: { width: "0.75rem", height: "0.75rem", color: "white" } })
126
+ }
127
+ ),
128
+ /* @__PURE__ */ jsx("span", { children: req.label })
129
+ ] }, req.label)) }) });
137
130
  }
138
131
  function createRequirements(config) {
139
132
  const requirements = [];
@@ -201,11 +194,12 @@ function AuthPasswordField({
201
194
  onFocus,
202
195
  ...props
203
196
  }) {
197
+ const [searchParams] = useSearchParams();
204
198
  const [showPassword, setShowPassword] = useState(false);
205
199
  const [showStrength, setShowStrength] = useState(false);
206
200
  const resolvedForgotPasswordHref = useMemo(
207
- () => forgotPasswordLink ? resolveAuthPath(forgotPasswordLink.href) : void 0,
208
- [forgotPasswordLink]
201
+ () => forgotPasswordLink ? resolveAuthUrl(forgotPasswordLink.href, searchParams) : void 0,
202
+ [forgotPasswordLink, searchParams]
209
203
  );
210
204
  const handleFocus = (e) => {
211
205
  if (showStrengthIndicator) {
@@ -543,7 +537,6 @@ function AuthOAuthProviders({
543
537
  function AuthVerificationCodeInput({
544
538
  length = 6,
545
539
  value,
546
- email,
547
540
  onChange,
548
541
  disabled = false,
549
542
  onComplete
@@ -591,33 +584,25 @@ function AuthVerificationCodeInput({
591
584
  }
592
585
  }
593
586
  };
594
- return /* @__PURE__ */ jsxs("div", { className: "if-verificationCode if-internal-vc8m4p", children: [
595
- /* @__PURE__ */ jsxs("p", { className: "if-verificationCode-description", children: [
596
- "We've sent a verification code to your inbox at",
597
- " ",
598
- /* @__PURE__ */ jsx("span", { className: "if-verificationCode-email", children: email }),
599
- ". Enter it below to proceed."
600
- ] }),
601
- /* @__PURE__ */ jsx("div", { className: "if-verificationCode-inputContainer", children: Array.from({ length }).map((_, index) => /* @__PURE__ */ jsx(
602
- "input",
603
- {
604
- ref: (el) => {
605
- inputRefs.current[index] = el;
606
- },
607
- type: "text",
608
- inputMode: "numeric",
609
- maxLength: 1,
610
- value: value[index] || "",
611
- onChange: (e) => handleChange(index, e.target.value),
612
- onKeyDown: (e) => handleKeyDown(index, e),
613
- onPaste: handlePaste,
614
- disabled,
615
- className: "if-verificationCode-input",
616
- autoComplete: "one-time-code"
587
+ return /* @__PURE__ */ jsx("div", { className: "if-verificationCode-inputContainer", children: Array.from({ length }).map((_, index) => /* @__PURE__ */ jsx(
588
+ "input",
589
+ {
590
+ ref: (el) => {
591
+ inputRefs.current[index] = el;
617
592
  },
618
- index
619
- )) })
620
- ] });
593
+ type: "text",
594
+ inputMode: "numeric",
595
+ maxLength: 1,
596
+ value: value[index] || "",
597
+ onChange: (e) => handleChange(index, e.target.value),
598
+ onKeyDown: (e) => handleKeyDown(index, e),
599
+ onPaste: handlePaste,
600
+ disabled,
601
+ className: "if-verificationCode-input",
602
+ autoComplete: "one-time-code"
603
+ },
604
+ index
605
+ )) });
621
606
  }
622
607
  var InsforgeContext = createContext(void 0);
623
608
  function useInsforge() {
@@ -629,28 +614,20 @@ function useInsforge() {
629
614
  }
630
615
  function AuthEmailVerificationStep({
631
616
  email,
632
- method = "code",
633
- onVerifyCode
617
+ method,
618
+ onVerifyCode,
619
+ emailSent = false
634
620
  }) {
635
621
  const { sendVerificationEmail } = useInsforge();
636
622
  const [resendDisabled, setResendDisabled] = useState(true);
637
- const [resendCountdown, setResendCountdown] = useState(60);
623
+ const [resendCountdown, setResendCountdown] = useState(emailSent ? 60 : 0);
638
624
  const [isSending, setIsSending] = useState(false);
639
625
  const [verificationCode, setVerificationCode] = useState("");
640
626
  const [isVerifying, setIsVerifying] = useState(false);
641
- 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.";
642
- useEffect(() => {
643
- const sendInitialEmail = async () => {
644
- try {
645
- await sendVerificationEmail(email);
646
- } catch (error) {
647
- console.error("Failed to send verification email:", error);
648
- }
649
- };
650
- void sendInitialEmail();
651
- }, [email, sendVerificationEmail]);
627
+ const isLinkMethod = method === "link";
628
+ const displayDescription = isLinkMethod ? "We've 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.";
652
629
  useEffect(() => {
653
- if (resendCountdown > 0) {
630
+ if (emailSent && resendCountdown > 0) {
654
631
  const timer = setInterval(() => {
655
632
  setResendCountdown((prev) => {
656
633
  if (prev <= 1) {
@@ -662,7 +639,7 @@ function AuthEmailVerificationStep({
662
639
  }, 1e3);
663
640
  return () => clearInterval(timer);
664
641
  }
665
- }, [resendCountdown]);
642
+ }, [emailSent, resendCountdown]);
666
643
  const handleResend = async () => {
667
644
  setResendDisabled(true);
668
645
  setResendCountdown(60);
@@ -688,23 +665,29 @@ function AuthEmailVerificationStep({
688
665
  setVerificationCode("");
689
666
  }
690
667
  };
691
- const displayDescription = defaultDescription;
692
- const isLinkMethod = method === "link";
693
668
  return /* @__PURE__ */ jsxs("div", { className: "if-verificationStep", children: [
694
- /* @__PURE__ */ jsx("p", { className: "if-verificationStep-description", children: displayDescription.split("{email}").map((part, index, array) => /* @__PURE__ */ jsxs("span", { children: [
695
- part,
696
- index < array.length - 1 && /* @__PURE__ */ jsx("span", { className: "if-verificationCode-email", children: email })
697
- ] }, index)) }),
669
+ isLinkMethod && /* @__PURE__ */ jsxs("div", { className: "if-verificationStep-descriptionContainer", children: [
670
+ /* @__PURE__ */ jsx("p", { className: "if-verificationStep-descriptionTitle", children: "Verify Your Email" }),
671
+ /* @__PURE__ */ jsx("p", { className: "if-verificationStep-description", children: displayDescription.split("{email}").map((part, index, array) => /* @__PURE__ */ jsxs("span", { children: [
672
+ part,
673
+ index < array.length - 1 && /* @__PURE__ */ jsx("span", { className: "if-verificationLink-email", children: email })
674
+ ] }, index)) })
675
+ ] }),
698
676
  !isLinkMethod && /* @__PURE__ */ jsxs("div", { className: "if-verificationStep-codeContainer", children: [
699
- /* @__PURE__ */ jsx("div", { className: "if-verificationStep-codeInputWrapper", children: /* @__PURE__ */ jsx(
700
- AuthVerificationCodeInput,
701
- {
702
- value: verificationCode,
703
- onChange: setVerificationCode,
704
- email,
705
- disabled: isVerifying
706
- }
707
- ) }),
677
+ /* @__PURE__ */ jsxs("div", { className: "if-verificationStep-codeInputWrapper", children: [
678
+ /* @__PURE__ */ jsx("p", { className: "if-verificationStep-codeDescription", children: displayDescription.split("{email}").map((part, index, array) => /* @__PURE__ */ jsxs("span", { children: [
679
+ part,
680
+ index < array.length - 1 && /* @__PURE__ */ jsx("span", { className: "if-verificationCode-email", children: email })
681
+ ] }, index)) }),
682
+ /* @__PURE__ */ jsx(
683
+ AuthVerificationCodeInput,
684
+ {
685
+ value: verificationCode,
686
+ onChange: setVerificationCode,
687
+ disabled: isVerifying
688
+ }
689
+ )
690
+ ] }),
708
691
  /* @__PURE__ */ jsx(
709
692
  AuthSubmitButton,
710
693
  {
@@ -714,7 +697,7 @@ function AuthEmailVerificationStep({
714
697
  onClick: () => {
715
698
  void handleSubmit();
716
699
  },
717
- children: isVerifying ? "Verifying..." : "Verify Code"
700
+ children: isVerifying ? "Verifying..." : "Continue"
718
701
  }
719
702
  )
720
703
  ] }),
@@ -746,6 +729,8 @@ function AuthResetPasswordVerificationStep({
746
729
  const [isSending, setIsSending] = useState(false);
747
730
  const [verificationCode, setVerificationCode] = useState("");
748
731
  const [isVerifying, setIsVerifying] = useState(false);
732
+ const isLinkMethod = method === "link";
733
+ 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.";
749
734
  useEffect(() => {
750
735
  if (resendCountdown > 0) {
751
736
  const timer = setInterval(() => {
@@ -785,17 +770,20 @@ function AuthResetPasswordVerificationStep({
785
770
  setVerificationCode("");
786
771
  }
787
772
  };
788
- const isLinkMethod = method === "link";
789
- 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.`;
790
773
  return /* @__PURE__ */ jsxs("div", { className: "if-verificationStep", children: [
791
- /* @__PURE__ */ jsx("p", { className: "if-verificationStep-description", children: description }),
774
+ isLinkMethod && /* @__PURE__ */ jsxs("div", { className: "if-verificationStep-descriptionContainer", children: [
775
+ /* @__PURE__ */ jsx("p", { className: "if-verificationStep-descriptionTitle", children: "Check Your Email" }),
776
+ /* @__PURE__ */ jsx("p", { className: "if-verificationStep-description", children: displayDescription.split("{email}").map((part, index, array) => /* @__PURE__ */ jsxs("span", { children: [
777
+ part,
778
+ index < array.length - 1 && /* @__PURE__ */ jsx("span", { className: "if-verificationLink-email", children: email })
779
+ ] }, index)) })
780
+ ] }),
792
781
  !isLinkMethod && /* @__PURE__ */ jsxs("div", { className: "if-verificationStep-codeContainer", children: [
793
782
  /* @__PURE__ */ jsx("div", { className: "if-verificationStep-codeInputWrapper", children: /* @__PURE__ */ jsx(
794
783
  AuthVerificationCodeInput,
795
784
  {
796
785
  value: verificationCode,
797
786
  onChange: setVerificationCode,
798
- email,
799
787
  disabled: isVerifying
800
788
  }
801
789
  ) }),