@insforge/react 0.4.8 → 0.4.10
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/README.md +55 -95
- package/dist/atoms.cjs +31 -46
- package/dist/atoms.cjs.map +1 -1
- package/dist/atoms.d.cts +3 -2
- package/dist/atoms.d.ts +3 -2
- package/dist/atoms.js +31 -46
- package/dist/atoms.js.map +1 -1
- package/dist/components.cjs +71 -59
- package/dist/components.cjs.map +1 -1
- package/dist/components.js +71 -59
- package/dist/components.js.map +1 -1
- package/dist/forms.cjs +53 -55
- package/dist/forms.cjs.map +1 -1
- package/dist/forms.d.cts +2 -4
- package/dist/forms.d.ts +2 -4
- package/dist/forms.js +53 -55
- package/dist/forms.js.map +1 -1
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +80 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -4
- package/dist/index.d.ts +1 -4
- package/dist/index.js +80 -63
- package/dist/index.js.map +1 -1
- package/dist/styles.css +0 -8
- package/package.json +2 -2
package/dist/forms.cjs
CHANGED
|
@@ -108,34 +108,27 @@ function AuthPasswordStrengthIndicator({
|
|
|
108
108
|
config
|
|
109
109
|
}) {
|
|
110
110
|
const requirements = createRequirements(config);
|
|
111
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-passwordStrength if-internal-ps6w3k", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-passwordStrength-requirements", children: requirements.map((req) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
"
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
),
|
|
134
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: req.label })
|
|
135
|
-
]
|
|
136
|
-
},
|
|
137
|
-
req.label
|
|
138
|
-
)) }) });
|
|
111
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-passwordStrength if-internal-ps6w3k", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-passwordStrength-requirements", children: requirements.map((req) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-passwordStrength-requirement", children: [
|
|
112
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
113
|
+
"div",
|
|
114
|
+
{
|
|
115
|
+
style: {
|
|
116
|
+
display: "flex",
|
|
117
|
+
alignItems: "center",
|
|
118
|
+
justifyContent: "center",
|
|
119
|
+
width: "1rem",
|
|
120
|
+
height: "1rem",
|
|
121
|
+
borderRadius: "50%",
|
|
122
|
+
border: "2px solid",
|
|
123
|
+
borderColor: req.test(password) ? "transparent" : "#9ca3af",
|
|
124
|
+
backgroundColor: req.test(password) ? "#059669" : "white",
|
|
125
|
+
transition: "all 0.2s"
|
|
126
|
+
},
|
|
127
|
+
children: req.test(password) && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { style: { width: "0.75rem", height: "0.75rem", color: "white" } })
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: req.label })
|
|
131
|
+
] }, req.label)) }) });
|
|
139
132
|
}
|
|
140
133
|
function createRequirements(config) {
|
|
141
134
|
const requirements = [];
|
|
@@ -203,11 +196,12 @@ function AuthPasswordField({
|
|
|
203
196
|
onFocus,
|
|
204
197
|
...props
|
|
205
198
|
}) {
|
|
199
|
+
const [searchParams] = reactRouterDom.useSearchParams();
|
|
206
200
|
const [showPassword, setShowPassword] = react.useState(false);
|
|
207
201
|
const [showStrength, setShowStrength] = react.useState(false);
|
|
208
202
|
const resolvedForgotPasswordHref = react.useMemo(
|
|
209
|
-
() => forgotPasswordLink ?
|
|
210
|
-
[forgotPasswordLink]
|
|
203
|
+
() => forgotPasswordLink ? resolveAuthUrl(forgotPasswordLink.href, searchParams) : void 0,
|
|
204
|
+
[forgotPasswordLink, searchParams]
|
|
211
205
|
);
|
|
212
206
|
const handleFocus = (e) => {
|
|
213
207
|
if (showStrengthIndicator) {
|
|
@@ -622,29 +616,20 @@ function useInsforge() {
|
|
|
622
616
|
}
|
|
623
617
|
function AuthEmailVerificationStep({
|
|
624
618
|
email,
|
|
625
|
-
method
|
|
626
|
-
onVerifyCode
|
|
619
|
+
method,
|
|
620
|
+
onVerifyCode,
|
|
621
|
+
emailSent = false
|
|
627
622
|
}) {
|
|
628
623
|
const { sendVerificationEmail } = useInsforge();
|
|
629
624
|
const [resendDisabled, setResendDisabled] = react.useState(true);
|
|
630
|
-
const [resendCountdown, setResendCountdown] = react.useState(60);
|
|
625
|
+
const [resendCountdown, setResendCountdown] = react.useState(emailSent ? 60 : 0);
|
|
631
626
|
const [isSending, setIsSending] = react.useState(false);
|
|
632
627
|
const [verificationCode, setVerificationCode] = react.useState("");
|
|
633
628
|
const [isVerifying, setIsVerifying] = react.useState(false);
|
|
634
629
|
const isLinkMethod = method === "link";
|
|
635
|
-
const displayDescription = isLinkMethod ? "We
|
|
630
|
+
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.";
|
|
636
631
|
react.useEffect(() => {
|
|
637
|
-
|
|
638
|
-
try {
|
|
639
|
-
await sendVerificationEmail(email);
|
|
640
|
-
} catch (error) {
|
|
641
|
-
console.error("Failed to send verification email:", error);
|
|
642
|
-
}
|
|
643
|
-
};
|
|
644
|
-
void sendInitialEmail();
|
|
645
|
-
}, [email, sendVerificationEmail]);
|
|
646
|
-
react.useEffect(() => {
|
|
647
|
-
if (resendCountdown > 0) {
|
|
632
|
+
if (emailSent && resendCountdown > 0) {
|
|
648
633
|
const timer = setInterval(() => {
|
|
649
634
|
setResendCountdown((prev) => {
|
|
650
635
|
if (prev <= 1) {
|
|
@@ -656,7 +641,7 @@ function AuthEmailVerificationStep({
|
|
|
656
641
|
}, 1e3);
|
|
657
642
|
return () => clearInterval(timer);
|
|
658
643
|
}
|
|
659
|
-
}, [resendCountdown]);
|
|
644
|
+
}, [emailSent, resendCountdown]);
|
|
660
645
|
const handleResend = async () => {
|
|
661
646
|
setResendDisabled(true);
|
|
662
647
|
setResendCountdown(60);
|
|
@@ -843,7 +828,6 @@ function SignInForm({
|
|
|
843
828
|
error,
|
|
844
829
|
loading = false,
|
|
845
830
|
oauthLoading = null,
|
|
846
|
-
availableProviders = [],
|
|
847
831
|
onOAuthClick,
|
|
848
832
|
authConfig,
|
|
849
833
|
title = "Welcome Back",
|
|
@@ -866,7 +850,15 @@ function SignInForm({
|
|
|
866
850
|
return /* @__PURE__ */ jsxRuntime.jsxs(AuthContainer, { children: [
|
|
867
851
|
/* @__PURE__ */ jsxRuntime.jsx(AuthHeader, { title, subtitle }),
|
|
868
852
|
/* @__PURE__ */ jsxRuntime.jsx(AuthErrorBanner, { error: error || "" }),
|
|
869
|
-
showVerificationStep ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
853
|
+
showVerificationStep ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
854
|
+
AuthEmailVerificationStep,
|
|
855
|
+
{
|
|
856
|
+
email,
|
|
857
|
+
method: authConfig.verifyEmailMethod,
|
|
858
|
+
onVerifyCode,
|
|
859
|
+
emailSent: false
|
|
860
|
+
}
|
|
861
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit, noValidate: true, className: "if-form if-internal-fm9k2p", children: [
|
|
870
862
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
871
863
|
AuthFormField,
|
|
872
864
|
{
|
|
@@ -901,12 +893,12 @@ function SignInForm({
|
|
|
901
893
|
] }),
|
|
902
894
|
!showVerificationStep && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
903
895
|
/* @__PURE__ */ jsxRuntime.jsx(AuthLink, { text: signUpText, linkText: signUpLinkText, href: signUpUrl }),
|
|
904
|
-
|
|
896
|
+
authConfig.oAuthProviders.length > 0 && onOAuthClick && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
905
897
|
/* @__PURE__ */ jsxRuntime.jsx(AuthDivider, { text: dividerText }),
|
|
906
898
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
907
899
|
AuthOAuthProviders,
|
|
908
900
|
{
|
|
909
|
-
providers:
|
|
901
|
+
providers: authConfig.oAuthProviders,
|
|
910
902
|
onClick: onOAuthClick,
|
|
911
903
|
disabled: loading || oauthLoading !== null,
|
|
912
904
|
loading: oauthLoading
|
|
@@ -925,7 +917,6 @@ function SignUpForm({
|
|
|
925
917
|
error,
|
|
926
918
|
loading = false,
|
|
927
919
|
oauthLoading = null,
|
|
928
|
-
availableProviders = [],
|
|
929
920
|
onOAuthClick,
|
|
930
921
|
authConfig,
|
|
931
922
|
title = "Get Started",
|
|
@@ -946,7 +937,15 @@ function SignUpForm({
|
|
|
946
937
|
return /* @__PURE__ */ jsxRuntime.jsxs(AuthContainer, { children: [
|
|
947
938
|
/* @__PURE__ */ jsxRuntime.jsx(AuthHeader, { title, subtitle }),
|
|
948
939
|
/* @__PURE__ */ jsxRuntime.jsx(AuthErrorBanner, { error: error || "" }),
|
|
949
|
-
showVerificationStep ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
940
|
+
showVerificationStep ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
941
|
+
AuthEmailVerificationStep,
|
|
942
|
+
{
|
|
943
|
+
email,
|
|
944
|
+
method: authConfig.verifyEmailMethod,
|
|
945
|
+
onVerifyCode,
|
|
946
|
+
emailSent: true
|
|
947
|
+
}
|
|
948
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit, noValidate: true, className: "if-form if-internal-fm9k2p", children: [
|
|
950
949
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
951
950
|
AuthFormField,
|
|
952
951
|
{
|
|
@@ -969,7 +968,6 @@ function SignUpForm({
|
|
|
969
968
|
value: password,
|
|
970
969
|
onChange: (e) => onPasswordChange(e.target.value),
|
|
971
970
|
required: true,
|
|
972
|
-
minLength: authConfig.passwordMinLength,
|
|
973
971
|
autoComplete: "new-password",
|
|
974
972
|
showStrengthIndicator: true,
|
|
975
973
|
authConfig
|
|
@@ -979,12 +977,12 @@ function SignUpForm({
|
|
|
979
977
|
] }),
|
|
980
978
|
!showVerificationStep && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
981
979
|
/* @__PURE__ */ jsxRuntime.jsx(AuthLink, { text: signInText, linkText: signInLinkText, href: signInUrl }),
|
|
982
|
-
|
|
980
|
+
authConfig.oAuthProviders.length > 0 && onOAuthClick && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
983
981
|
/* @__PURE__ */ jsxRuntime.jsx(AuthDivider, { text: dividerText }),
|
|
984
982
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
985
983
|
AuthOAuthProviders,
|
|
986
984
|
{
|
|
987
|
-
providers:
|
|
985
|
+
providers: authConfig.oAuthProviders,
|
|
988
986
|
onClick: onOAuthClick,
|
|
989
987
|
disabled: loading || oauthLoading !== null,
|
|
990
988
|
loading: oauthLoading
|