@insforge/react 0.5.6 → 0.5.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.
@@ -255,4 +255,52 @@ interface ConditionalProps {
255
255
  */
256
256
  declare function SignedOut({ children }: ConditionalProps): react_jsx_runtime.JSX.Element | null;
257
257
 
258
- export { type ConditionalProps$1 as ConditionalProps, ForgotPassword, type ForgotPasswordProps, Protect, type ProtectProps, ResetPassword, type ResetPasswordProps, SignIn, type SignInProps, SignUp, type SignUpProps, SignedIn, SignedOut, UserButton, type UserButtonProps, VerifyEmail, type VerifyEmailProps };
258
+ interface SignInButtonProps {
259
+ children?: React.ReactNode;
260
+ className?: string;
261
+ }
262
+ /**
263
+ * SignInButton Component
264
+ *
265
+ * A simple unstyled button that redirects to the hosted sign-in page.
266
+ * If children is a valid React element, it will be rendered with the redirect logic attached.
267
+ *
268
+ * @example
269
+ * ```tsx
270
+ * <SignInButton />
271
+ * ```
272
+ *
273
+ * @example
274
+ * ```tsx
275
+ * <SignInButton>
276
+ * <button className="your-button">Login</button>
277
+ * </SignInButton>
278
+ * ```
279
+ */
280
+ declare function SignInButton({ children, className }: SignInButtonProps): react_jsx_runtime.JSX.Element;
281
+
282
+ interface SignUpButtonProps {
283
+ children?: React.ReactNode;
284
+ className?: string;
285
+ }
286
+ /**
287
+ * SignUpButton Component
288
+ *
289
+ * A simple unstyled button that redirects to the hosted sign-up page.
290
+ * If children is a valid React element, it will be rendered with the redirect logic attached.
291
+ *
292
+ * @example
293
+ * ```tsx
294
+ * <SignUpButton />
295
+ * ```
296
+ *
297
+ * @example
298
+ * ```tsx
299
+ * <SignUpButton>
300
+ * <button className="fancy-button">Register Now</button>
301
+ * </SignUpButton>
302
+ * ```
303
+ */
304
+ declare function SignUpButton({ children, className }: SignUpButtonProps): react_jsx_runtime.JSX.Element;
305
+
306
+ export { type ConditionalProps$1 as ConditionalProps, ForgotPassword, type ForgotPasswordProps, Protect, type ProtectProps, ResetPassword, type ResetPasswordProps, SignIn, SignInButton, type SignInButtonProps, type SignInProps, SignUp, SignUpButton, type SignUpButtonProps, type SignUpProps, SignedIn, SignedOut, UserButton, type UserButtonProps, VerifyEmail, type VerifyEmailProps };
@@ -255,4 +255,52 @@ interface ConditionalProps {
255
255
  */
256
256
  declare function SignedOut({ children }: ConditionalProps): react_jsx_runtime.JSX.Element | null;
257
257
 
258
- export { type ConditionalProps$1 as ConditionalProps, ForgotPassword, type ForgotPasswordProps, Protect, type ProtectProps, ResetPassword, type ResetPasswordProps, SignIn, type SignInProps, SignUp, type SignUpProps, SignedIn, SignedOut, UserButton, type UserButtonProps, VerifyEmail, type VerifyEmailProps };
258
+ interface SignInButtonProps {
259
+ children?: React.ReactNode;
260
+ className?: string;
261
+ }
262
+ /**
263
+ * SignInButton Component
264
+ *
265
+ * A simple unstyled button that redirects to the hosted sign-in page.
266
+ * If children is a valid React element, it will be rendered with the redirect logic attached.
267
+ *
268
+ * @example
269
+ * ```tsx
270
+ * <SignInButton />
271
+ * ```
272
+ *
273
+ * @example
274
+ * ```tsx
275
+ * <SignInButton>
276
+ * <button className="your-button">Login</button>
277
+ * </SignInButton>
278
+ * ```
279
+ */
280
+ declare function SignInButton({ children, className }: SignInButtonProps): react_jsx_runtime.JSX.Element;
281
+
282
+ interface SignUpButtonProps {
283
+ children?: React.ReactNode;
284
+ className?: string;
285
+ }
286
+ /**
287
+ * SignUpButton Component
288
+ *
289
+ * A simple unstyled button that redirects to the hosted sign-up page.
290
+ * If children is a valid React element, it will be rendered with the redirect logic attached.
291
+ *
292
+ * @example
293
+ * ```tsx
294
+ * <SignUpButton />
295
+ * ```
296
+ *
297
+ * @example
298
+ * ```tsx
299
+ * <SignUpButton>
300
+ * <button className="fancy-button">Register Now</button>
301
+ * </SignUpButton>
302
+ * ```
303
+ */
304
+ declare function SignUpButton({ children, className }: SignUpButtonProps): react_jsx_runtime.JSX.Element;
305
+
306
+ export { type ConditionalProps$1 as ConditionalProps, ForgotPassword, type ForgotPasswordProps, Protect, type ProtectProps, ResetPassword, type ResetPasswordProps, SignIn, SignInButton, type SignInButtonProps, type SignInProps, SignUp, SignUpButton, type SignUpButtonProps, type SignUpProps, SignedIn, SignedOut, UserButton, type UserButtonProps, VerifyEmail, type VerifyEmailProps };
@@ -1,4 +1,4 @@
1
- import { createContext, useState, useMemo, useRef, useEffect, useCallback, useContext } from 'react';
1
+ import { createContext, useState, useMemo, useRef, useEffect, useCallback, isValidElement, cloneElement, useContext } from 'react';
2
2
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
3
3
  import '@insforge/sdk';
4
4
  import { AlertTriangle, Check, EyeOff, Eye, Loader2, CircleCheck, LogOut } from 'lucide-react';
@@ -2015,7 +2015,49 @@ function SignedOut({ children }) {
2015
2015
  }
2016
2016
  return /* @__PURE__ */ jsx(Fragment, { children });
2017
2017
  }
2018
+ function SignInButton({ children, className }) {
2019
+ const { afterSignInUrl, baseUrl } = useInsforge();
2020
+ const handleClick = () => {
2021
+ const redirectUrl = new URL(afterSignInUrl, window.location.origin).href;
2022
+ const authUrl = new URL("/auth/sign-in", baseUrl);
2023
+ authUrl.searchParams.set("redirect", redirectUrl);
2024
+ window.location.replace(authUrl.toString());
2025
+ };
2026
+ if (children && isValidElement(children)) {
2027
+ const originalOnClick = children.props?.onClick;
2028
+ return cloneElement(children, {
2029
+ onClick: (e) => {
2030
+ handleClick();
2031
+ if (originalOnClick) {
2032
+ originalOnClick(e);
2033
+ }
2034
+ }
2035
+ });
2036
+ }
2037
+ return /* @__PURE__ */ jsx("button", { type: "button", className, onClick: handleClick, children: children || "Sign in" });
2038
+ }
2039
+ function SignUpButton({ children, className }) {
2040
+ const { afterSignInUrl, baseUrl } = useInsforge();
2041
+ const handleClick = () => {
2042
+ const redirectUrl = new URL(afterSignInUrl, window.location.origin).href;
2043
+ const authUrl = new URL("/auth/sign-up", baseUrl);
2044
+ authUrl.searchParams.set("redirect", redirectUrl);
2045
+ window.location.replace(authUrl.toString());
2046
+ };
2047
+ if (children && isValidElement(children)) {
2048
+ const originalOnClick = children.props?.onClick;
2049
+ return cloneElement(children, {
2050
+ onClick: (e) => {
2051
+ handleClick();
2052
+ if (originalOnClick) {
2053
+ originalOnClick(e);
2054
+ }
2055
+ }
2056
+ });
2057
+ }
2058
+ return /* @__PURE__ */ jsx("button", { type: "button", className, onClick: handleClick, children: children || "Sign up" });
2059
+ }
2018
2060
 
2019
- export { AuthBranding, AuthContainer, AuthDivider, AuthEmailVerificationStep, AuthErrorBanner, AuthFormField, AuthHeader, AuthLink, AuthOAuthButton, AuthOAuthProviders, AuthPasswordField, AuthPasswordStrengthIndicator, AuthResetPasswordVerificationStep, AuthSubmitButton, AuthVerificationCodeInput, ForgotPassword, ForgotPasswordForm, Protect, ResetPassword, ResetPasswordForm, SignIn, SignInForm, SignUp, SignUpForm, SignedIn, SignedOut, UserButton, VerifyEmail, VerifyEmailStatus };
2061
+ export { AuthBranding, AuthContainer, AuthDivider, AuthEmailVerificationStep, AuthErrorBanner, AuthFormField, AuthHeader, AuthLink, AuthOAuthButton, AuthOAuthProviders, AuthPasswordField, AuthPasswordStrengthIndicator, AuthResetPasswordVerificationStep, AuthSubmitButton, AuthVerificationCodeInput, ForgotPassword, ForgotPasswordForm, Protect, ResetPassword, ResetPasswordForm, SignIn, SignInButton, SignInForm, SignUp, SignUpButton, SignUpForm, SignedIn, SignedOut, UserButton, VerifyEmail, VerifyEmailStatus };
2020
2062
  //# sourceMappingURL=components.js.map
2021
2063
  //# sourceMappingURL=components.js.map