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