@insforge/react 0.4.6 → 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/atoms.cjs +79 -62
- package/dist/atoms.cjs.map +1 -1
- package/dist/atoms.d.cts +1 -2
- package/dist/atoms.d.ts +1 -2
- package/dist/atoms.js +80 -63
- package/dist/atoms.js.map +1 -1
- package/dist/components.cjs +96 -98
- package/dist/components.cjs.map +1 -1
- package/dist/components.js +97 -99
- package/dist/components.js.map +1 -1
- package/dist/forms.cjs +86 -86
- package/dist/forms.cjs.map +1 -1
- package/dist/forms.js +87 -87
- package/dist/forms.js.map +1 -1
- package/dist/index.cjs +110 -120
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +110 -122
- package/dist/index.js.map +1 -1
- package/dist/lib.cjs +24 -0
- package/dist/lib.cjs.map +1 -1
- package/dist/lib.d.cts +36 -1
- package/dist/lib.d.ts +36 -1
- package/dist/lib.js +23 -1
- package/dist/lib.js.map +1 -1
- package/dist/router.cjs +11 -21
- package/dist/router.cjs.map +1 -1
- package/dist/router.d.cts +5 -4
- package/dist/router.d.ts +5 -4
- package/dist/router.js +11 -21
- package/dist/router.js.map +1 -1
- package/dist/styles.css +43 -63
- package/package.json +1 -1
package/dist/forms.js
CHANGED
|
@@ -1,6 +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
|
-
import { createContext, useState, useEffect, useCallback, useContext, useRef } from 'react';
|
|
3
|
+
import { createContext, useState, useEffect, useMemo, useCallback, useContext, useRef } from 'react';
|
|
4
4
|
import { useSearchParams } from 'react-router-dom';
|
|
5
5
|
import '@insforge/sdk';
|
|
6
6
|
|
|
@@ -169,6 +169,28 @@ function createRequirements(config) {
|
|
|
169
169
|
}
|
|
170
170
|
return requirements;
|
|
171
171
|
}
|
|
172
|
+
|
|
173
|
+
// src/lib/path-utils.ts
|
|
174
|
+
function resolveAuthPath(targetPath) {
|
|
175
|
+
if (typeof window === "undefined") {
|
|
176
|
+
return targetPath;
|
|
177
|
+
}
|
|
178
|
+
const currentPath = window.location.pathname;
|
|
179
|
+
if (currentPath.startsWith("/auth/")) {
|
|
180
|
+
if (targetPath.startsWith("/auth/")) {
|
|
181
|
+
return targetPath;
|
|
182
|
+
}
|
|
183
|
+
return `/auth${targetPath}`;
|
|
184
|
+
}
|
|
185
|
+
return targetPath;
|
|
186
|
+
}
|
|
187
|
+
function resolveAuthUrl(targetPath, searchParams) {
|
|
188
|
+
const resolvedPath = resolveAuthPath(targetPath);
|
|
189
|
+
if (!searchParams || searchParams.toString() === "") {
|
|
190
|
+
return resolvedPath;
|
|
191
|
+
}
|
|
192
|
+
return `${resolvedPath}?${searchParams.toString()}`;
|
|
193
|
+
}
|
|
172
194
|
function AuthPasswordField({
|
|
173
195
|
label,
|
|
174
196
|
id,
|
|
@@ -181,6 +203,10 @@ function AuthPasswordField({
|
|
|
181
203
|
}) {
|
|
182
204
|
const [showPassword, setShowPassword] = useState(false);
|
|
183
205
|
const [showStrength, setShowStrength] = useState(false);
|
|
206
|
+
const resolvedForgotPasswordHref = useMemo(
|
|
207
|
+
() => forgotPasswordLink ? resolveAuthPath(forgotPasswordLink.href) : void 0,
|
|
208
|
+
[forgotPasswordLink]
|
|
209
|
+
);
|
|
184
210
|
const handleFocus = (e) => {
|
|
185
211
|
if (showStrengthIndicator) {
|
|
186
212
|
setShowStrength(true);
|
|
@@ -190,7 +216,7 @@ function AuthPasswordField({
|
|
|
190
216
|
return /* @__PURE__ */ jsxs("div", { className: "if-passwordField if-internal-p5w9m7", children: [
|
|
191
217
|
(label || forgotPasswordLink) && /* @__PURE__ */ jsxs("div", { className: "if-passwordField-labelRow", children: [
|
|
192
218
|
/* @__PURE__ */ jsx("label", { htmlFor: id, className: "if-passwordField-label", children: label }),
|
|
193
|
-
forgotPasswordLink && /* @__PURE__ */ jsx("a", { href:
|
|
219
|
+
forgotPasswordLink && resolvedForgotPasswordHref && /* @__PURE__ */ jsx("a", { href: resolvedForgotPasswordHref, className: "if-passwordField-forgotLink", children: forgotPasswordLink.text || "Forget Password?" })
|
|
194
220
|
] }),
|
|
195
221
|
/* @__PURE__ */ jsxs("div", { className: "if-passwordField-inputWrapper", children: [
|
|
196
222
|
/* @__PURE__ */ jsx(
|
|
@@ -243,19 +269,7 @@ function AuthSubmitButton({
|
|
|
243
269
|
}
|
|
244
270
|
function AuthLink({ text, linkText, href }) {
|
|
245
271
|
const [searchParams] = useSearchParams();
|
|
246
|
-
const
|
|
247
|
-
const finalHref = (() => {
|
|
248
|
-
if (!currentSearch) {
|
|
249
|
-
return href;
|
|
250
|
-
}
|
|
251
|
-
try {
|
|
252
|
-
const url = new URL(href, window.location.origin);
|
|
253
|
-
url.search = currentSearch;
|
|
254
|
-
return url.pathname + url.search;
|
|
255
|
-
} catch {
|
|
256
|
-
return href;
|
|
257
|
-
}
|
|
258
|
-
})();
|
|
272
|
+
const finalHref = resolveAuthUrl(href, searchParams);
|
|
259
273
|
return /* @__PURE__ */ jsxs("p", { className: "if-authLink if-internal-al5w9p", children: [
|
|
260
274
|
text && /* @__PURE__ */ jsx("span", { className: "if-authLink-text", children: text }),
|
|
261
275
|
text && " ",
|
|
@@ -529,7 +543,6 @@ function AuthOAuthProviders({
|
|
|
529
543
|
function AuthVerificationCodeInput({
|
|
530
544
|
length = 6,
|
|
531
545
|
value,
|
|
532
|
-
email,
|
|
533
546
|
onChange,
|
|
534
547
|
disabled = false,
|
|
535
548
|
onComplete
|
|
@@ -577,33 +590,25 @@ function AuthVerificationCodeInput({
|
|
|
577
590
|
}
|
|
578
591
|
}
|
|
579
592
|
};
|
|
580
|
-
return /* @__PURE__ */
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
". Enter it below to proceed."
|
|
586
|
-
] }),
|
|
587
|
-
/* @__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;
|
|
592
|
-
},
|
|
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"
|
|
593
|
+
return /* @__PURE__ */ jsx("div", { className: "if-verificationCode-inputContainer", children: Array.from({ length }).map((_, index) => /* @__PURE__ */ jsx(
|
|
594
|
+
"input",
|
|
595
|
+
{
|
|
596
|
+
ref: (el) => {
|
|
597
|
+
inputRefs.current[index] = el;
|
|
603
598
|
},
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
599
|
+
type: "text",
|
|
600
|
+
inputMode: "numeric",
|
|
601
|
+
maxLength: 1,
|
|
602
|
+
value: value[index] || "",
|
|
603
|
+
onChange: (e) => handleChange(index, e.target.value),
|
|
604
|
+
onKeyDown: (e) => handleKeyDown(index, e),
|
|
605
|
+
onPaste: handlePaste,
|
|
606
|
+
disabled,
|
|
607
|
+
className: "if-verificationCode-input",
|
|
608
|
+
autoComplete: "one-time-code"
|
|
609
|
+
},
|
|
610
|
+
index
|
|
611
|
+
)) });
|
|
607
612
|
}
|
|
608
613
|
var InsforgeContext = createContext(void 0);
|
|
609
614
|
function useInsforge() {
|
|
@@ -624,7 +629,8 @@ function AuthEmailVerificationStep({
|
|
|
624
629
|
const [isSending, setIsSending] = useState(false);
|
|
625
630
|
const [verificationCode, setVerificationCode] = useState("");
|
|
626
631
|
const [isVerifying, setIsVerifying] = useState(false);
|
|
627
|
-
const
|
|
632
|
+
const isLinkMethod = method === "link";
|
|
633
|
+
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.";
|
|
628
634
|
useEffect(() => {
|
|
629
635
|
const sendInitialEmail = async () => {
|
|
630
636
|
try {
|
|
@@ -674,23 +680,29 @@ function AuthEmailVerificationStep({
|
|
|
674
680
|
setVerificationCode("");
|
|
675
681
|
}
|
|
676
682
|
};
|
|
677
|
-
const displayDescription = defaultDescription;
|
|
678
|
-
const isLinkMethod = method === "link";
|
|
679
683
|
return /* @__PURE__ */ jsxs("div", { className: "if-verificationStep", children: [
|
|
680
|
-
/* @__PURE__ */
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
+
isLinkMethod && /* @__PURE__ */ jsxs("div", { className: "if-verificationStep-descriptionContainer", children: [
|
|
685
|
+
/* @__PURE__ */ jsx("p", { className: "if-verificationStep-descriptionTitle", children: "Verify Your Email" }),
|
|
686
|
+
/* @__PURE__ */ jsx("p", { className: "if-verificationStep-description", children: displayDescription.split("{email}").map((part, index, array) => /* @__PURE__ */ jsxs("span", { children: [
|
|
687
|
+
part,
|
|
688
|
+
index < array.length - 1 && /* @__PURE__ */ jsx("span", { className: "if-verificationLink-email", children: email })
|
|
689
|
+
] }, index)) })
|
|
690
|
+
] }),
|
|
684
691
|
!isLinkMethod && /* @__PURE__ */ jsxs("div", { className: "if-verificationStep-codeContainer", children: [
|
|
685
|
-
/* @__PURE__ */
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
692
|
+
/* @__PURE__ */ jsxs("div", { className: "if-verificationStep-codeInputWrapper", children: [
|
|
693
|
+
/* @__PURE__ */ jsx("p", { className: "if-verificationStep-codeDescription", children: displayDescription.split("{email}").map((part, index, array) => /* @__PURE__ */ jsxs("span", { children: [
|
|
694
|
+
part,
|
|
695
|
+
index < array.length - 1 && /* @__PURE__ */ jsx("span", { className: "if-verificationCode-email", children: email })
|
|
696
|
+
] }, index)) }),
|
|
697
|
+
/* @__PURE__ */ jsx(
|
|
698
|
+
AuthVerificationCodeInput,
|
|
699
|
+
{
|
|
700
|
+
value: verificationCode,
|
|
701
|
+
onChange: setVerificationCode,
|
|
702
|
+
disabled: isVerifying
|
|
703
|
+
}
|
|
704
|
+
)
|
|
705
|
+
] }),
|
|
694
706
|
/* @__PURE__ */ jsx(
|
|
695
707
|
AuthSubmitButton,
|
|
696
708
|
{
|
|
@@ -700,7 +712,7 @@ function AuthEmailVerificationStep({
|
|
|
700
712
|
onClick: () => {
|
|
701
713
|
void handleSubmit();
|
|
702
714
|
},
|
|
703
|
-
children: isVerifying ? "Verifying..." : "
|
|
715
|
+
children: isVerifying ? "Verifying..." : "Continue"
|
|
704
716
|
}
|
|
705
717
|
)
|
|
706
718
|
] }),
|
|
@@ -732,6 +744,8 @@ function AuthResetPasswordVerificationStep({
|
|
|
732
744
|
const [isSending, setIsSending] = useState(false);
|
|
733
745
|
const [verificationCode, setVerificationCode] = useState("");
|
|
734
746
|
const [isVerifying, setIsVerifying] = useState(false);
|
|
747
|
+
const isLinkMethod = method === "link";
|
|
748
|
+
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.";
|
|
735
749
|
useEffect(() => {
|
|
736
750
|
if (resendCountdown > 0) {
|
|
737
751
|
const timer = setInterval(() => {
|
|
@@ -771,17 +785,20 @@ function AuthResetPasswordVerificationStep({
|
|
|
771
785
|
setVerificationCode("");
|
|
772
786
|
}
|
|
773
787
|
};
|
|
774
|
-
const isLinkMethod = method === "link";
|
|
775
|
-
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.`;
|
|
776
788
|
return /* @__PURE__ */ jsxs("div", { className: "if-verificationStep", children: [
|
|
777
|
-
/* @__PURE__ */
|
|
789
|
+
isLinkMethod && /* @__PURE__ */ jsxs("div", { className: "if-verificationStep-descriptionContainer", children: [
|
|
790
|
+
/* @__PURE__ */ jsx("p", { className: "if-verificationStep-descriptionTitle", children: "Check Your Email" }),
|
|
791
|
+
/* @__PURE__ */ jsx("p", { className: "if-verificationStep-description", children: displayDescription.split("{email}").map((part, index, array) => /* @__PURE__ */ jsxs("span", { children: [
|
|
792
|
+
part,
|
|
793
|
+
index < array.length - 1 && /* @__PURE__ */ jsx("span", { className: "if-verificationLink-email", children: email })
|
|
794
|
+
] }, index)) })
|
|
795
|
+
] }),
|
|
778
796
|
!isLinkMethod && /* @__PURE__ */ jsxs("div", { className: "if-verificationStep-codeContainer", children: [
|
|
779
797
|
/* @__PURE__ */ jsx("div", { className: "if-verificationStep-codeInputWrapper", children: /* @__PURE__ */ jsx(
|
|
780
798
|
AuthVerificationCodeInput,
|
|
781
799
|
{
|
|
782
800
|
value: verificationCode,
|
|
783
801
|
onChange: setVerificationCode,
|
|
784
|
-
email,
|
|
785
802
|
disabled: isVerifying
|
|
786
803
|
}
|
|
787
804
|
) }),
|
|
@@ -834,7 +851,7 @@ function SignInForm({
|
|
|
834
851
|
passwordLabel = "Password",
|
|
835
852
|
passwordPlaceholder = "\u2022\u2022\u2022\u2022\u2022\u2022",
|
|
836
853
|
forgotPasswordText = "Forget Password?",
|
|
837
|
-
forgotPasswordUrl,
|
|
854
|
+
forgotPasswordUrl = "/forgot-password",
|
|
838
855
|
submitButtonText = "Sign In",
|
|
839
856
|
loadingButtonText = "Signing in...",
|
|
840
857
|
signUpText = "Don't have an account?",
|
|
@@ -845,13 +862,7 @@ function SignInForm({
|
|
|
845
862
|
onVerifyCode
|
|
846
863
|
}) {
|
|
847
864
|
return /* @__PURE__ */ jsxs(AuthContainer, { children: [
|
|
848
|
-
/* @__PURE__ */ jsx(
|
|
849
|
-
AuthHeader,
|
|
850
|
-
{
|
|
851
|
-
title: showVerificationStep ? "Verify Your Email" : title,
|
|
852
|
-
subtitle: showVerificationStep ? "" : subtitle
|
|
853
|
-
}
|
|
854
|
-
),
|
|
865
|
+
/* @__PURE__ */ jsx(AuthHeader, { title, subtitle }),
|
|
855
866
|
/* @__PURE__ */ jsx(AuthErrorBanner, { error: error || "" }),
|
|
856
867
|
showVerificationStep ? /* @__PURE__ */ jsx(AuthEmailVerificationStep, { email, onVerifyCode }) : /* @__PURE__ */ jsxs("form", { onSubmit, noValidate: true, className: "if-form if-internal-fm9k2p", children: [
|
|
857
868
|
/* @__PURE__ */ jsx(
|
|
@@ -931,13 +942,7 @@ function SignUpForm({
|
|
|
931
942
|
onVerifyCode
|
|
932
943
|
}) {
|
|
933
944
|
return /* @__PURE__ */ jsxs(AuthContainer, { children: [
|
|
934
|
-
/* @__PURE__ */ jsx(
|
|
935
|
-
AuthHeader,
|
|
936
|
-
{
|
|
937
|
-
title: showVerificationStep ? "Verify Your Email" : title,
|
|
938
|
-
subtitle: showVerificationStep ? "" : subtitle
|
|
939
|
-
}
|
|
940
|
-
),
|
|
945
|
+
/* @__PURE__ */ jsx(AuthHeader, { title, subtitle }),
|
|
941
946
|
/* @__PURE__ */ jsx(AuthErrorBanner, { error: error || "" }),
|
|
942
947
|
showVerificationStep ? /* @__PURE__ */ jsx(AuthEmailVerificationStep, { email, onVerifyCode }) : /* @__PURE__ */ jsxs("form", { onSubmit, noValidate: true, className: "if-form if-internal-fm9k2p", children: [
|
|
943
948
|
/* @__PURE__ */ jsx(
|
|
@@ -994,10 +999,10 @@ function ForgotPasswordForm({
|
|
|
994
999
|
error,
|
|
995
1000
|
loading = false,
|
|
996
1001
|
title = "Forgot Password?",
|
|
997
|
-
subtitle = "Enter your email address and we'll send you a
|
|
1002
|
+
subtitle = "Enter your email address and we'll send you a {method} to reset your password.",
|
|
998
1003
|
emailLabel = "Email",
|
|
999
1004
|
emailPlaceholder = "example@email.com",
|
|
1000
|
-
submitButtonText = "
|
|
1005
|
+
submitButtonText = "Reset Password",
|
|
1001
1006
|
loadingButtonText = "Sending...",
|
|
1002
1007
|
backToSignInText = "Remember your password?",
|
|
1003
1008
|
backToSignInUrl = "/sign-in",
|
|
@@ -1006,14 +1011,9 @@ function ForgotPasswordForm({
|
|
|
1006
1011
|
onVerifyCode,
|
|
1007
1012
|
onResendEmail
|
|
1008
1013
|
}) {
|
|
1014
|
+
const displaySubtitle = subtitle.replace("{method}", resetPasswordMethod);
|
|
1009
1015
|
return /* @__PURE__ */ jsxs(AuthContainer, { children: [
|
|
1010
|
-
/* @__PURE__ */ jsx(
|
|
1011
|
-
AuthHeader,
|
|
1012
|
-
{
|
|
1013
|
-
title: showVerificationStep ? resetPasswordMethod === "link" ? "Check Your Email" : "Enter Reset Code" : title,
|
|
1014
|
-
subtitle: showVerificationStep ? "" : subtitle
|
|
1015
|
-
}
|
|
1016
|
-
),
|
|
1016
|
+
/* @__PURE__ */ jsx(AuthHeader, { title, subtitle: displaySubtitle }),
|
|
1017
1017
|
/* @__PURE__ */ jsx(AuthErrorBanner, { error: error || "" }),
|
|
1018
1018
|
showVerificationStep ? /* @__PURE__ */ jsx(
|
|
1019
1019
|
AuthResetPasswordVerificationStep,
|