@insforge/react 0.6.10 → 0.7.0

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/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { ConditionalProps, ForgotPassword, ForgotPasswordProps, Protect, ProtectProps, ResetPassword, ResetPasswordProps, SignIn, SignInButton, SignInButtonProps, SignInProps, SignUp, SignUpButton, SignUpButtonProps, SignUpProps, SignedIn, SignedOut, UserButton, UserButtonProps, VerifyEmail, VerifyEmailProps } from './components.cjs';
1
+ export { ConditionalProps, ForgotPassword, ForgotPasswordProps, Protect, ProtectProps, ResetPassword, ResetPasswordProps, SignIn, SignInButton, SignInButtonProps, SignInProps, SignOutButton, SignOutButtonProps, SignUp, SignUpButton, SignUpButtonProps, SignUpProps, SignedIn, SignedOut, UserButton, UserButtonProps, VerifyEmail, VerifyEmailProps } from './components.cjs';
2
2
  export { ForgotPasswordForm, ForgotPasswordFormProps, ResetPasswordForm, ResetPasswordFormProps, SignInForm, SignInFormProps, SignUpForm, SignUpFormProps, VerifyEmailStatus, VerifyEmailStatusProps } from './forms.cjs';
3
3
  export { AuthBranding, AuthContainer, AuthContainerProps, AuthDivider, AuthDividerProps, AuthEmailVerificationStep, AuthErrorBanner, AuthErrorBannerProps, AuthFormField, AuthFormFieldProps, AuthHeader, AuthHeaderProps, AuthLink, AuthLinkProps, AuthOAuthButton, AuthOAuthButtonProps, AuthOAuthProviders, AuthOAuthProvidersProps, AuthPasswordField, AuthPasswordFieldProps, AuthPasswordStrengthIndicator, AuthPasswordStrengthIndicatorProps, AuthResetPasswordVerificationStep, AuthSubmitButton, AuthSubmitButtonProps, AuthVerificationCodeInput, AuthVerificationCodeInputProps } from './atoms.cjs';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { ConditionalProps, ForgotPassword, ForgotPasswordProps, Protect, ProtectProps, ResetPassword, ResetPasswordProps, SignIn, SignInButton, SignInButtonProps, SignInProps, SignUp, SignUpButton, SignUpButtonProps, SignUpProps, SignedIn, SignedOut, UserButton, UserButtonProps, VerifyEmail, VerifyEmailProps } from './components.js';
1
+ export { ConditionalProps, ForgotPassword, ForgotPasswordProps, Protect, ProtectProps, ResetPassword, ResetPasswordProps, SignIn, SignInButton, SignInButtonProps, SignInProps, SignOutButton, SignOutButtonProps, SignUp, SignUpButton, SignUpButtonProps, SignUpProps, SignedIn, SignedOut, UserButton, UserButtonProps, VerifyEmail, VerifyEmailProps } from './components.js';
2
2
  export { ForgotPasswordForm, ForgotPasswordFormProps, ResetPasswordForm, ResetPasswordFormProps, SignInForm, SignInFormProps, SignUpForm, SignUpFormProps, VerifyEmailStatus, VerifyEmailStatusProps } from './forms.js';
3
3
  export { AuthBranding, AuthContainer, AuthContainerProps, AuthDivider, AuthDividerProps, AuthEmailVerificationStep, AuthErrorBanner, AuthErrorBannerProps, AuthFormField, AuthFormFieldProps, AuthHeader, AuthHeaderProps, AuthLink, AuthLinkProps, AuthOAuthButton, AuthOAuthButtonProps, AuthOAuthProviders, AuthOAuthProvidersProps, AuthPasswordField, AuthPasswordFieldProps, AuthPasswordStrengthIndicator, AuthPasswordStrengthIndicatorProps, AuthResetPasswordVerificationStep, AuthSubmitButton, AuthSubmitButtonProps, AuthVerificationCodeInput, AuthVerificationCodeInputProps } from './atoms.js';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
package/dist/index.js CHANGED
@@ -3128,6 +3128,25 @@ function VerifyEmail({ token, onSuccess, onError, ...uiProps }) {
3128
3128
  }, [token, verifyEmail, onSuccess, onError]);
3129
3129
  return /* @__PURE__ */ jsx(VerifyEmailStatus, { status, error, ...uiProps });
3130
3130
  }
3131
+ function SignOutButton({ children, className, afterSignOutUrl = "/" }) {
3132
+ const { signOut } = useInsforge();
3133
+ const handleClick = async () => {
3134
+ await signOut();
3135
+ window.location.href = afterSignOutUrl;
3136
+ };
3137
+ if (children && isValidElement(children)) {
3138
+ const originalOnClick = children.props?.onClick;
3139
+ return cloneElement(children, {
3140
+ onClick: async (e) => {
3141
+ await handleClick();
3142
+ if (originalOnClick) {
3143
+ originalOnClick(e);
3144
+ }
3145
+ }
3146
+ });
3147
+ }
3148
+ return /* @__PURE__ */ jsx("button", { type: "button", className, onClick: () => void handleClick(), children: children || "Sign out" });
3149
+ }
3131
3150
  var UserButtonContainer = styled.div`
3132
3151
  position: relative;
3133
3152
  display: inline-block;
@@ -3243,7 +3262,7 @@ var UserButtonMenuItemIcon = styled.div`
3243
3262
  }
3244
3263
  `;
3245
3264
  function UserButton({ afterSignOutUrl = "/", mode = "detailed" }) {
3246
- const { user, signOut } = useInsforge();
3265
+ const { user } = useInsforge();
3247
3266
  const [isOpen, setIsOpen] = useState(false);
3248
3267
  const [imageError, setImageError] = useState(false);
3249
3268
  const dropdownRef = useRef(null);
@@ -3284,11 +3303,6 @@ function UserButton({ afterSignOutUrl = "/", mode = "detailed" }) {
3284
3303
  document.removeEventListener("mousedown", handleClickOutside);
3285
3304
  };
3286
3305
  }, [isOpen]);
3287
- async function handleSignOut() {
3288
- await signOut();
3289
- setIsOpen(false);
3290
- window.location.href = afterSignOutUrl;
3291
- }
3292
3306
  if (!user) {
3293
3307
  return null;
3294
3308
  }
@@ -3317,10 +3331,10 @@ function UserButton({ afterSignOutUrl = "/", mode = "detailed" }) {
3317
3331
  ]
3318
3332
  }
3319
3333
  ),
3320
- isOpen && /* @__PURE__ */ jsx(UserButtonMenu, { children: /* @__PURE__ */ jsxs(UserButtonMenuItem, { $signout: true, onClick: () => void handleSignOut(), children: [
3334
+ isOpen && /* @__PURE__ */ jsx(UserButtonMenu, { children: /* @__PURE__ */ jsx(SignOutButton, { afterSignOutUrl, children: /* @__PURE__ */ jsxs(UserButtonMenuItem, { $signout: true, onClick: () => setIsOpen(false), children: [
3321
3335
  /* @__PURE__ */ jsx(UserButtonMenuItemIcon, { children: /* @__PURE__ */ jsx(LogOut, {}) }),
3322
3336
  "Sign out"
3323
- ] }) })
3337
+ ] }) }) })
3324
3338
  ] });
3325
3339
  }
3326
3340
  function Protect({
@@ -3429,6 +3443,6 @@ function useUser() {
3429
3443
  return { user, isLoaded, updateUser, setUser };
3430
3444
  }
3431
3445
 
3432
- export { AuthBranding, AuthContainer, AuthDivider, AuthEmailVerificationStep, AuthErrorBanner, AuthFormField, AuthHeader, AuthLink, AuthOAuthButton, AuthOAuthProviders, AuthPasswordField, AuthPasswordStrengthIndicator, AuthResetPasswordVerificationStep, AuthSubmitButton, AuthVerificationCodeInput, BrowserNavigationAdapter, ForgotPassword, ForgotPasswordForm, InsforgeProvider, InsforgeProviderCore, NavigationProvider, OAUTH_PROVIDER_CONFIG, Protect, ResetPassword, ResetPasswordForm, SignIn, SignInButton, SignInForm, SignUp, SignUpButton, SignUpForm, SignedIn, SignedOut, StyleProvider, UserButton, VerifyEmail, VerifyEmailStatus, checkPasswordStrength, createPasswordSchema, emailSchema, getAllProviderConfigs, getProviderConfig, passwordSchema, resolveAuthPath, resolveAuthUrl, theme, useAuth, useInsforge, useNavigationAdapter, usePublicAuthConfig, useSearchParams, useUser, validateEmail, validatePassword };
3446
+ export { AuthBranding, AuthContainer, AuthDivider, AuthEmailVerificationStep, AuthErrorBanner, AuthFormField, AuthHeader, AuthLink, AuthOAuthButton, AuthOAuthProviders, AuthPasswordField, AuthPasswordStrengthIndicator, AuthResetPasswordVerificationStep, AuthSubmitButton, AuthVerificationCodeInput, BrowserNavigationAdapter, ForgotPassword, ForgotPasswordForm, InsforgeProvider, InsforgeProviderCore, NavigationProvider, OAUTH_PROVIDER_CONFIG, Protect, ResetPassword, ResetPasswordForm, SignIn, SignInButton, SignInForm, SignOutButton, SignUp, SignUpButton, SignUpForm, SignedIn, SignedOut, StyleProvider, UserButton, VerifyEmail, VerifyEmailStatus, checkPasswordStrength, createPasswordSchema, emailSchema, getAllProviderConfigs, getProviderConfig, passwordSchema, resolveAuthPath, resolveAuthUrl, theme, useAuth, useInsforge, useNavigationAdapter, usePublicAuthConfig, useSearchParams, useUser, validateEmail, validatePassword };
3433
3447
  //# sourceMappingURL=index.js.map
3434
3448
  //# sourceMappingURL=index.js.map