@insforge/react 0.3.0 → 0.3.2

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.
@@ -766,7 +766,6 @@ function AuthVerificationCodeInput({
766
766
  }
767
767
  function AuthEmailVerificationStep({
768
768
  email,
769
- title = "Verify Your Email",
770
769
  description,
771
770
  method = "code",
772
771
  onVerifyCode
@@ -843,29 +842,29 @@ function AuthEmailVerificationStep({
843
842
  }
844
843
  };
845
844
  const displayDescription = description || defaultDescription;
846
- return /* @__PURE__ */ jsxs("div", { className: "w-full flex flex-col gap-6 items-center", children: [
847
- /* @__PURE__ */ jsxs("div", { className: "w-full bg-neutral-100 dark:bg-neutral-800 rounded-lg px-4 pt-4 pb-6 flex flex-col gap-4", children: [
848
- /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-black dark:text-white", children: title }),
849
- /* @__PURE__ */ jsx("p", { className: "text-neutral-600 dark:text-neutral-400 text-sm leading-relaxed", children: displayDescription.split("{email}").map((part, index, array) => /* @__PURE__ */ jsxs("span", { children: [
850
- part,
851
- index < array.length - 1 && /* @__PURE__ */ jsx("span", { className: "font-medium text-black dark:text-white", children: email })
852
- ] }, index)) }),
853
- method === "code" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 mt-2", children: [
854
- /* @__PURE__ */ jsx(
855
- AuthVerificationCodeInput,
856
- {
857
- value: verificationCode,
858
- onChange: setVerificationCode,
859
- email,
860
- disabled: isVerifying,
861
- onComplete: (code) => {
862
- void handleVerifyCode(code);
863
- }
845
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6 items-stretch", children: [
846
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-neutral-600 dark:text-neutral-400 leading-relaxed", children: displayDescription.split("{email}").map((part, index, array) => /* @__PURE__ */ jsxs("span", { children: [
847
+ part,
848
+ index < array.length - 1 && /* @__PURE__ */ jsx("span", { className: "font-medium text-black dark:text-white", children: email })
849
+ ] }, index)) }),
850
+ verificationError && /* @__PURE__ */ jsx("div", { className: "pl-3 py-2 pr-2 bg-red-50 border-2 border-red-600 rounded", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
851
+ /* @__PURE__ */ jsx("svg", { className: "w-6 h-6 text-red-500 shrink-0", fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" }) }),
852
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-red-600 flex-1", children: verificationError })
853
+ ] }) }),
854
+ method === "code" && /* @__PURE__ */ jsxs("div", { className: "w-full bg-neutral-100 dark:bg-neutral-800 rounded-lg px-4 pt-4 pb-6 flex flex-col gap-4", children: [
855
+ /* @__PURE__ */ jsx(
856
+ AuthVerificationCodeInput,
857
+ {
858
+ value: verificationCode,
859
+ onChange: setVerificationCode,
860
+ email,
861
+ disabled: isVerifying,
862
+ onComplete: (code) => {
863
+ void handleVerifyCode(code);
864
864
  }
865
- ),
866
- verificationError && /* @__PURE__ */ jsx("p", { className: "text-sm text-red-600 dark:text-red-400 text-center", children: verificationError }),
867
- isVerifying && /* @__PURE__ */ jsx("p", { className: "text-sm text-neutral-600 dark:text-neutral-400 text-center", children: "Verifying..." })
868
- ] })
865
+ }
866
+ ),
867
+ isVerifying && /* @__PURE__ */ jsx("p", { className: "text-sm text-neutral-600 dark:text-neutral-400 text-center", children: "Verifying..." })
869
868
  ] }),
870
869
  /* @__PURE__ */ jsxs("div", { className: "w-full text-sm text-center text-neutral-600 dark:text-neutral-400", children: [
871
870
  "Didn't receive the email?",
@@ -910,7 +909,11 @@ function SignInForm({
910
909
  signUpText = "Don't have an account?",
911
910
  signUpLinkText = "Sign Up Now",
912
911
  signUpUrl = "/sign-up",
913
- dividerText = "or"
912
+ dividerText = "or",
913
+ // Email verification step props
914
+ showVerificationStep = false,
915
+ onVerifyCode,
916
+ verificationDescription
914
917
  }) {
915
918
  return /* @__PURE__ */ jsxs(
916
919
  AuthContainer,
@@ -923,8 +926,8 @@ function SignInForm({
923
926
  /* @__PURE__ */ jsx(
924
927
  AuthHeader,
925
928
  {
926
- title,
927
- subtitle,
929
+ title: showVerificationStep ? "Verify Your Email" : title,
930
+ subtitle: showVerificationStep ? "" : subtitle,
928
931
  appearance: {
929
932
  containerClassName: appearance.header?.container,
930
933
  titleClassName: appearance.header?.title,
@@ -939,7 +942,14 @@ function SignInForm({
939
942
  className: appearance.errorBanner
940
943
  }
941
944
  ),
942
- /* @__PURE__ */ jsxs(
945
+ showVerificationStep ? /* @__PURE__ */ jsx(
946
+ AuthEmailVerificationStep,
947
+ {
948
+ email,
949
+ description: verificationDescription,
950
+ onVerifyCode
951
+ }
952
+ ) : /* @__PURE__ */ jsxs(
943
953
  "form",
944
954
  {
945
955
  onSubmit,
@@ -998,39 +1008,41 @@ function SignInForm({
998
1008
  ]
999
1009
  }
1000
1010
  ),
1001
- /* @__PURE__ */ jsx(
1002
- AuthLink,
1003
- {
1004
- text: signUpText,
1005
- linkText: signUpLinkText,
1006
- href: signUpUrl,
1007
- appearance: {
1008
- containerClassName: appearance.link?.container,
1009
- linkClassName: appearance.link?.link
1010
- }
1011
- }
1012
- ),
1013
- availableProviders.length > 0 && onOAuthClick && /* @__PURE__ */ jsxs(Fragment, { children: [
1014
- /* @__PURE__ */ jsx(
1015
- AuthDivider,
1016
- {
1017
- text: dividerText,
1018
- className: appearance.divider
1019
- }
1020
- ),
1011
+ !showVerificationStep && /* @__PURE__ */ jsxs(Fragment, { children: [
1021
1012
  /* @__PURE__ */ jsx(
1022
- AuthOAuthProviders,
1013
+ AuthLink,
1023
1014
  {
1024
- providers: availableProviders,
1025
- onClick: onOAuthClick,
1026
- disabled: loading || oauthLoading !== null,
1027
- loading: oauthLoading,
1015
+ text: signUpText,
1016
+ linkText: signUpLinkText,
1017
+ href: signUpUrl,
1028
1018
  appearance: {
1029
- containerClassName: appearance.oauth?.container,
1030
- buttonClassName: appearance.oauth?.button
1019
+ containerClassName: appearance.link?.container,
1020
+ linkClassName: appearance.link?.link
1031
1021
  }
1032
1022
  }
1033
- )
1023
+ ),
1024
+ availableProviders.length > 0 && onOAuthClick && /* @__PURE__ */ jsxs(Fragment, { children: [
1025
+ /* @__PURE__ */ jsx(
1026
+ AuthDivider,
1027
+ {
1028
+ text: dividerText,
1029
+ className: appearance.divider
1030
+ }
1031
+ ),
1032
+ /* @__PURE__ */ jsx(
1033
+ AuthOAuthProviders,
1034
+ {
1035
+ providers: availableProviders,
1036
+ onClick: onOAuthClick,
1037
+ disabled: loading || oauthLoading !== null,
1038
+ loading: oauthLoading,
1039
+ appearance: {
1040
+ containerClassName: appearance.oauth?.container,
1041
+ buttonClassName: appearance.oauth?.button
1042
+ }
1043
+ }
1044
+ )
1045
+ ] })
1034
1046
  ] })
1035
1047
  ]
1036
1048
  }
@@ -1112,7 +1124,7 @@ function SignIn({
1112
1124
  if (!emailConfig) {
1113
1125
  return null;
1114
1126
  }
1115
- return step === "form" ? /* @__PURE__ */ jsx(
1127
+ return /* @__PURE__ */ jsx(
1116
1128
  SignInForm,
1117
1129
  {
1118
1130
  email,
@@ -1126,14 +1138,10 @@ function SignIn({
1126
1138
  availableProviders: emailConfig?.oAuthProviders || [],
1127
1139
  onOAuthClick: handleOAuth,
1128
1140
  emailAuthConfig: emailConfig,
1141
+ showVerificationStep: step === "awaiting-verification",
1142
+ onVerifyCode: handleVerifyCode,
1129
1143
  ...uiProps
1130
1144
  }
1131
- ) : /* @__PURE__ */ jsx(
1132
- AuthEmailVerificationStep,
1133
- {
1134
- email,
1135
- onVerifyCode: handleVerifyCode
1136
- }
1137
1145
  );
1138
1146
  }
1139
1147
  function SignUpForm({
@@ -1160,7 +1168,11 @@ function SignUpForm({
1160
1168
  signInText = "Already have an account?",
1161
1169
  signInLinkText = "Login Now",
1162
1170
  signInUrl = "/sign-in",
1163
- dividerText = "or"
1171
+ dividerText = "or",
1172
+ // Email verification step props
1173
+ showVerificationStep = false,
1174
+ onVerifyCode,
1175
+ verificationDescription
1164
1176
  }) {
1165
1177
  return /* @__PURE__ */ jsxs(
1166
1178
  AuthContainer,
@@ -1173,8 +1185,8 @@ function SignUpForm({
1173
1185
  /* @__PURE__ */ jsx(
1174
1186
  AuthHeader,
1175
1187
  {
1176
- title,
1177
- subtitle,
1188
+ title: showVerificationStep ? "Verify Your Email" : title,
1189
+ subtitle: showVerificationStep ? "" : subtitle,
1178
1190
  appearance: {
1179
1191
  containerClassName: appearance.header?.container,
1180
1192
  titleClassName: appearance.header?.title,
@@ -1189,7 +1201,14 @@ function SignUpForm({
1189
1201
  className: appearance.errorBanner
1190
1202
  }
1191
1203
  ),
1192
- /* @__PURE__ */ jsxs(
1204
+ showVerificationStep ? /* @__PURE__ */ jsx(
1205
+ AuthEmailVerificationStep,
1206
+ {
1207
+ email,
1208
+ description: verificationDescription,
1209
+ onVerifyCode
1210
+ }
1211
+ ) : /* @__PURE__ */ jsxs(
1193
1212
  "form",
1194
1213
  {
1195
1214
  onSubmit,
@@ -1246,39 +1265,41 @@ function SignUpForm({
1246
1265
  ]
1247
1266
  }
1248
1267
  ),
1249
- /* @__PURE__ */ jsx(
1250
- AuthLink,
1251
- {
1252
- text: signInText,
1253
- linkText: signInLinkText,
1254
- href: signInUrl,
1255
- appearance: {
1256
- containerClassName: appearance.link?.container,
1257
- linkClassName: appearance.link?.link
1258
- }
1259
- }
1260
- ),
1261
- availableProviders.length > 0 && onOAuthClick && /* @__PURE__ */ jsxs(Fragment, { children: [
1262
- /* @__PURE__ */ jsx(
1263
- AuthDivider,
1264
- {
1265
- text: dividerText,
1266
- className: appearance.divider
1267
- }
1268
- ),
1268
+ !showVerificationStep && /* @__PURE__ */ jsxs(Fragment, { children: [
1269
1269
  /* @__PURE__ */ jsx(
1270
- AuthOAuthProviders,
1270
+ AuthLink,
1271
1271
  {
1272
- providers: availableProviders,
1273
- onClick: onOAuthClick,
1274
- disabled: loading || oauthLoading !== null,
1275
- loading: oauthLoading,
1272
+ text: signInText,
1273
+ linkText: signInLinkText,
1274
+ href: signInUrl,
1276
1275
  appearance: {
1277
- containerClassName: appearance.oauth?.container,
1278
- buttonClassName: appearance.oauth?.button
1276
+ containerClassName: appearance.link?.container,
1277
+ linkClassName: appearance.link?.link
1279
1278
  }
1280
1279
  }
1281
- )
1280
+ ),
1281
+ availableProviders.length > 0 && onOAuthClick && /* @__PURE__ */ jsxs(Fragment, { children: [
1282
+ /* @__PURE__ */ jsx(
1283
+ AuthDivider,
1284
+ {
1285
+ text: dividerText,
1286
+ className: appearance.divider
1287
+ }
1288
+ ),
1289
+ /* @__PURE__ */ jsx(
1290
+ AuthOAuthProviders,
1291
+ {
1292
+ providers: availableProviders,
1293
+ onClick: onOAuthClick,
1294
+ disabled: loading || oauthLoading !== null,
1295
+ loading: oauthLoading,
1296
+ appearance: {
1297
+ containerClassName: appearance.oauth?.container,
1298
+ buttonClassName: appearance.oauth?.button
1299
+ }
1300
+ }
1301
+ )
1302
+ ] })
1282
1303
  ] })
1283
1304
  ]
1284
1305
  }
@@ -1415,7 +1436,7 @@ function SignUp({
1415
1436
  if (!emailConfig) {
1416
1437
  return null;
1417
1438
  }
1418
- return step === "form" ? /* @__PURE__ */ jsx(
1439
+ return /* @__PURE__ */ jsx(
1419
1440
  SignUpForm,
1420
1441
  {
1421
1442
  email,
@@ -1429,14 +1450,10 @@ function SignUp({
1429
1450
  availableProviders: emailConfig?.oAuthProviders || [],
1430
1451
  onOAuthClick: handleOAuth,
1431
1452
  emailAuthConfig: emailConfig,
1453
+ showVerificationStep: step === "awaiting-verification",
1454
+ onVerifyCode: handleVerifyCode,
1432
1455
  ...uiProps
1433
1456
  }
1434
- ) : /* @__PURE__ */ jsx(
1435
- AuthEmailVerificationStep,
1436
- {
1437
- email,
1438
- onVerifyCode: handleVerifyCode
1439
- }
1440
1457
  );
1441
1458
  }
1442
1459
  function ForgotPasswordForm({
@@ -1563,6 +1580,7 @@ function ResetPasswordForm({
1563
1580
  onSubmit,
1564
1581
  error,
1565
1582
  loading = false,
1583
+ success = false,
1566
1584
  emailAuthConfig,
1567
1585
  appearance = {},
1568
1586
  title = "Reset Password",
@@ -1574,8 +1592,27 @@ function ResetPasswordForm({
1574
1592
  submitButtonText = "Reset Password",
1575
1593
  loadingButtonText = "Resetting...",
1576
1594
  backToSignInText = "",
1577
- backToSignInUrl = "/sign-in"
1595
+ backToSignInUrl = "/sign-in",
1596
+ successTitle = "Password Reset Successful!",
1597
+ successMessage = "Your password has been successfully reset. You can now sign in with your new password."
1578
1598
  }) {
1599
+ if (success) {
1600
+ return /* @__PURE__ */ jsx(
1601
+ AuthContainer,
1602
+ {
1603
+ appearance: {
1604
+ containerClassName: appearance.container,
1605
+ cardClassName: appearance.card
1606
+ },
1607
+ children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-4", children: [
1608
+ /* @__PURE__ */ jsx("div", { className: "w-16 h-16 rounded-full bg-green-100 dark:bg-green-900 flex items-center justify-center", children: /* @__PURE__ */ jsx("svg", { className: "w-8 h-8 text-green-600 dark:text-green-400", fill: "none", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M5 13l4 4L19 7" }) }) }),
1609
+ /* @__PURE__ */ jsx("h2", { className: "text-2xl font-semibold text-black dark:text-white text-center", children: successTitle }),
1610
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-neutral-600 dark:text-neutral-400 text-center", children: successMessage }),
1611
+ /* @__PURE__ */ jsx("a", { href: backToSignInUrl, className: "mt-4 text-black dark:text-white font-medium", children: "Back to Sign In" })
1612
+ ] })
1613
+ }
1614
+ );
1615
+ }
1579
1616
  return /* @__PURE__ */ jsxs(
1580
1617
  AuthContainer,
1581
1618
  {
@@ -1659,13 +1696,18 @@ function ResetPasswordForm({
1659
1696
  ]
1660
1697
  }
1661
1698
  ),
1662
- /* @__PURE__ */ jsxs("p", { className: appearance.backToSignIn || "text-center text-sm text-gray-600 dark:text-gray-400", children: [
1663
- backToSignInText && /* @__PURE__ */ jsxs("span", { children: [
1664
- backToSignInText,
1665
- " "
1666
- ] }),
1667
- /* @__PURE__ */ jsx("a", { href: backToSignInUrl, className: "text-black dark:text-white font-medium", children: "Back to Sign In" })
1668
- ] })
1699
+ /* @__PURE__ */ jsx(
1700
+ AuthLink,
1701
+ {
1702
+ text: backToSignInText,
1703
+ linkText: "Back to Sign In",
1704
+ href: backToSignInUrl,
1705
+ appearance: {
1706
+ containerClassName: appearance.link?.container,
1707
+ linkClassName: appearance.link?.link
1708
+ }
1709
+ }
1710
+ )
1669
1711
  ]
1670
1712
  }
1671
1713
  );
@@ -1683,6 +1725,7 @@ function ResetPassword({
1683
1725
  const [confirmPassword, setConfirmPassword] = useState("");
1684
1726
  const [error, setError] = useState("");
1685
1727
  const [loading, setLoading] = useState(false);
1728
+ const [success, setSuccess] = useState(false);
1686
1729
  async function handleSubmit(e) {
1687
1730
  e.preventDefault();
1688
1731
  setLoading(true);
@@ -1719,6 +1762,7 @@ function ResetPassword({
1719
1762
  try {
1720
1763
  const result = await resetPassword(token, newPassword);
1721
1764
  if (result?.message) {
1765
+ setSuccess(true);
1722
1766
  if (onSuccess) {
1723
1767
  onSuccess(result.redirectTo);
1724
1768
  }
@@ -1752,6 +1796,7 @@ function ResetPassword({
1752
1796
  onSubmit: handleSubmit,
1753
1797
  error,
1754
1798
  loading,
1799
+ success,
1755
1800
  emailAuthConfig: emailConfig,
1756
1801
  backToSignInUrl,
1757
1802
  ...uiProps
@@ -1868,10 +1913,14 @@ function ForgotPassword({
1868
1913
  setIsSendingCode(false);
1869
1914
  }
1870
1915
  }, [email, sendPasswordResetCode]);
1871
- function handlePasswordResetSuccess() {
1916
+ function handlePasswordResetSuccess(redirectTo) {
1917
+ const targetUrl = redirectTo || backToSignInUrl;
1872
1918
  if (onSuccess) {
1873
1919
  onSuccess();
1874
1920
  }
1921
+ setTimeout(() => {
1922
+ window.location.href = targetUrl;
1923
+ }, 1500);
1875
1924
  }
1876
1925
  if (!emailConfig) {
1877
1926
  return null;