@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/atoms.cjs
CHANGED
|
@@ -171,6 +171,28 @@ function createRequirements(config) {
|
|
|
171
171
|
}
|
|
172
172
|
return requirements;
|
|
173
173
|
}
|
|
174
|
+
|
|
175
|
+
// src/lib/path-utils.ts
|
|
176
|
+
function resolveAuthPath(targetPath) {
|
|
177
|
+
if (typeof window === "undefined") {
|
|
178
|
+
return targetPath;
|
|
179
|
+
}
|
|
180
|
+
const currentPath = window.location.pathname;
|
|
181
|
+
if (currentPath.startsWith("/auth/")) {
|
|
182
|
+
if (targetPath.startsWith("/auth/")) {
|
|
183
|
+
return targetPath;
|
|
184
|
+
}
|
|
185
|
+
return `/auth${targetPath}`;
|
|
186
|
+
}
|
|
187
|
+
return targetPath;
|
|
188
|
+
}
|
|
189
|
+
function resolveAuthUrl(targetPath, searchParams) {
|
|
190
|
+
const resolvedPath = resolveAuthPath(targetPath);
|
|
191
|
+
if (!searchParams || searchParams.toString() === "") {
|
|
192
|
+
return resolvedPath;
|
|
193
|
+
}
|
|
194
|
+
return `${resolvedPath}?${searchParams.toString()}`;
|
|
195
|
+
}
|
|
174
196
|
function AuthPasswordField({
|
|
175
197
|
label,
|
|
176
198
|
id,
|
|
@@ -183,6 +205,10 @@ function AuthPasswordField({
|
|
|
183
205
|
}) {
|
|
184
206
|
const [showPassword, setShowPassword] = react.useState(false);
|
|
185
207
|
const [showStrength, setShowStrength] = react.useState(false);
|
|
208
|
+
const resolvedForgotPasswordHref = react.useMemo(
|
|
209
|
+
() => forgotPasswordLink ? resolveAuthPath(forgotPasswordLink.href) : void 0,
|
|
210
|
+
[forgotPasswordLink]
|
|
211
|
+
);
|
|
186
212
|
const handleFocus = (e) => {
|
|
187
213
|
if (showStrengthIndicator) {
|
|
188
214
|
setShowStrength(true);
|
|
@@ -192,7 +218,7 @@ function AuthPasswordField({
|
|
|
192
218
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-passwordField if-internal-p5w9m7", children: [
|
|
193
219
|
(label || forgotPasswordLink) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-passwordField-labelRow", children: [
|
|
194
220
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, className: "if-passwordField-label", children: label }),
|
|
195
|
-
forgotPasswordLink && /* @__PURE__ */ jsxRuntime.jsx("a", { href:
|
|
221
|
+
forgotPasswordLink && resolvedForgotPasswordHref && /* @__PURE__ */ jsxRuntime.jsx("a", { href: resolvedForgotPasswordHref, className: "if-passwordField-forgotLink", children: forgotPasswordLink.text || "Forget Password?" })
|
|
196
222
|
] }),
|
|
197
223
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-passwordField-inputWrapper", children: [
|
|
198
224
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -245,19 +271,7 @@ function AuthSubmitButton({
|
|
|
245
271
|
}
|
|
246
272
|
function AuthLink({ text, linkText, href }) {
|
|
247
273
|
const [searchParams] = reactRouterDom.useSearchParams();
|
|
248
|
-
const
|
|
249
|
-
const finalHref = (() => {
|
|
250
|
-
if (!currentSearch) {
|
|
251
|
-
return href;
|
|
252
|
-
}
|
|
253
|
-
try {
|
|
254
|
-
const url = new URL(href, window.location.origin);
|
|
255
|
-
url.search = currentSearch;
|
|
256
|
-
return url.pathname + url.search;
|
|
257
|
-
} catch {
|
|
258
|
-
return href;
|
|
259
|
-
}
|
|
260
|
-
})();
|
|
274
|
+
const finalHref = resolveAuthUrl(href, searchParams);
|
|
261
275
|
return /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "if-authLink if-internal-al5w9p", children: [
|
|
262
276
|
text && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "if-authLink-text", children: text }),
|
|
263
277
|
text && " ",
|
|
@@ -531,7 +545,6 @@ function AuthOAuthProviders({
|
|
|
531
545
|
function AuthVerificationCodeInput({
|
|
532
546
|
length = 6,
|
|
533
547
|
value,
|
|
534
|
-
email,
|
|
535
548
|
onChange,
|
|
536
549
|
disabled = false,
|
|
537
550
|
onComplete
|
|
@@ -579,33 +592,25 @@ function AuthVerificationCodeInput({
|
|
|
579
592
|
}
|
|
580
593
|
}
|
|
581
594
|
};
|
|
582
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
". Enter it below to proceed."
|
|
588
|
-
] }),
|
|
589
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-verificationCode-inputContainer", children: Array.from({ length }).map((_, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
590
|
-
"input",
|
|
591
|
-
{
|
|
592
|
-
ref: (el) => {
|
|
593
|
-
inputRefs.current[index] = el;
|
|
594
|
-
},
|
|
595
|
-
type: "text",
|
|
596
|
-
inputMode: "numeric",
|
|
597
|
-
maxLength: 1,
|
|
598
|
-
value: value[index] || "",
|
|
599
|
-
onChange: (e) => handleChange(index, e.target.value),
|
|
600
|
-
onKeyDown: (e) => handleKeyDown(index, e),
|
|
601
|
-
onPaste: handlePaste,
|
|
602
|
-
disabled,
|
|
603
|
-
className: "if-verificationCode-input",
|
|
604
|
-
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;
|
|
605
600
|
},
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
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
|
+
)) });
|
|
609
614
|
}
|
|
610
615
|
var InsforgeContext = react.createContext(void 0);
|
|
611
616
|
function useInsforge() {
|
|
@@ -626,7 +631,8 @@ function AuthEmailVerificationStep({
|
|
|
626
631
|
const [isSending, setIsSending] = react.useState(false);
|
|
627
632
|
const [verificationCode, setVerificationCode] = react.useState("");
|
|
628
633
|
const [isVerifying, setIsVerifying] = react.useState(false);
|
|
629
|
-
const
|
|
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.";
|
|
630
636
|
react.useEffect(() => {
|
|
631
637
|
const sendInitialEmail = async () => {
|
|
632
638
|
try {
|
|
@@ -676,23 +682,29 @@ function AuthEmailVerificationStep({
|
|
|
676
682
|
setVerificationCode("");
|
|
677
683
|
}
|
|
678
684
|
};
|
|
679
|
-
const displayDescription = defaultDescription;
|
|
680
|
-
const isLinkMethod = method === "link";
|
|
681
685
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-verificationStep", children: [
|
|
682
|
-
/* @__PURE__ */ jsxRuntime.
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
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
|
+
] }),
|
|
686
693
|
!isLinkMethod && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-verificationStep-codeContainer", children: [
|
|
687
|
-
/* @__PURE__ */ jsxRuntime.
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
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
|
+
] }),
|
|
696
708
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
697
709
|
AuthSubmitButton,
|
|
698
710
|
{
|
|
@@ -702,7 +714,7 @@ function AuthEmailVerificationStep({
|
|
|
702
714
|
onClick: () => {
|
|
703
715
|
void handleSubmit();
|
|
704
716
|
},
|
|
705
|
-
children: isVerifying ? "Verifying..." : "
|
|
717
|
+
children: isVerifying ? "Verifying..." : "Continue"
|
|
706
718
|
}
|
|
707
719
|
)
|
|
708
720
|
] }),
|
|
@@ -734,6 +746,8 @@ function AuthResetPasswordVerificationStep({
|
|
|
734
746
|
const [isSending, setIsSending] = react.useState(false);
|
|
735
747
|
const [verificationCode, setVerificationCode] = react.useState("");
|
|
736
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.";
|
|
737
751
|
react.useEffect(() => {
|
|
738
752
|
if (resendCountdown > 0) {
|
|
739
753
|
const timer = setInterval(() => {
|
|
@@ -773,17 +787,20 @@ function AuthResetPasswordVerificationStep({
|
|
|
773
787
|
setVerificationCode("");
|
|
774
788
|
}
|
|
775
789
|
};
|
|
776
|
-
const isLinkMethod = method === "link";
|
|
777
|
-
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.`;
|
|
778
790
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-verificationStep", children: [
|
|
779
|
-
/* @__PURE__ */ jsxRuntime.
|
|
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
|
+
] }),
|
|
780
798
|
!isLinkMethod && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "if-verificationStep-codeContainer", children: [
|
|
781
799
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "if-verificationStep-codeInputWrapper", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
782
800
|
AuthVerificationCodeInput,
|
|
783
801
|
{
|
|
784
802
|
value: verificationCode,
|
|
785
803
|
onChange: setVerificationCode,
|
|
786
|
-
email,
|
|
787
804
|
disabled: isVerifying
|
|
788
805
|
}
|
|
789
806
|
) }),
|