@insforge/react 0.5.7 → 0.5.9

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.
@@ -1,6 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { UserSchema } from '@insforge/sdk';
3
- import * as react from 'react';
4
3
  import { ReactNode } from 'react';
5
4
  import { InsforgeUser } from './types.cjs';
6
5
  export { ForgotPasswordForm, ForgotPasswordFormProps, ResetPasswordForm, ResetPasswordFormProps, SignInForm, SignInFormProps, SignUpForm, SignUpFormProps, VerifyEmailStatus, VerifyEmailStatusProps } from './forms.cjs';
@@ -215,7 +214,7 @@ interface ProtectProps {
215
214
  * @param {function} [condition] - Custom access condition
216
215
  * @param {function} [onRedirect] - Custom redirect handler (default: window.location)
217
216
  */
218
- declare function Protect({ children, fallback, redirectTo, condition, onRedirect, }: ProtectProps): string | number | bigint | true | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null;
217
+ declare function Protect({ children, fallback, redirectTo, condition, onRedirect, }: ProtectProps): ReactNode;
219
218
 
220
219
  interface ConditionalProps$1 {
221
220
  children: ReactNode;
@@ -255,4 +254,52 @@ interface ConditionalProps {
255
254
  */
256
255
  declare function SignedOut({ children }: ConditionalProps): react_jsx_runtime.JSX.Element | null;
257
256
 
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 };
257
+ interface SignInButtonProps {
258
+ children?: React.ReactNode;
259
+ className?: string;
260
+ }
261
+ /**
262
+ * SignInButton Component
263
+ *
264
+ * A simple unstyled button that redirects to the hosted sign-in page.
265
+ * If children is a valid React element, it will be rendered with the redirect logic attached.
266
+ *
267
+ * @example
268
+ * ```tsx
269
+ * <SignInButton />
270
+ * ```
271
+ *
272
+ * @example
273
+ * ```tsx
274
+ * <SignInButton>
275
+ * <button className="your-button">Login</button>
276
+ * </SignInButton>
277
+ * ```
278
+ */
279
+ declare function SignInButton({ children, className }: SignInButtonProps): react_jsx_runtime.JSX.Element;
280
+
281
+ interface SignUpButtonProps {
282
+ children?: React.ReactNode;
283
+ className?: string;
284
+ }
285
+ /**
286
+ * SignUpButton Component
287
+ *
288
+ * A simple unstyled button that redirects to the hosted sign-up page.
289
+ * If children is a valid React element, it will be rendered with the redirect logic attached.
290
+ *
291
+ * @example
292
+ * ```tsx
293
+ * <SignUpButton />
294
+ * ```
295
+ *
296
+ * @example
297
+ * ```tsx
298
+ * <SignUpButton>
299
+ * <button className="fancy-button">Register Now</button>
300
+ * </SignUpButton>
301
+ * ```
302
+ */
303
+ declare function SignUpButton({ children, className }: SignUpButtonProps): react_jsx_runtime.JSX.Element;
304
+
305
+ 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,6 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { UserSchema } from '@insforge/sdk';
3
- import * as react from 'react';
4
3
  import { ReactNode } from 'react';
5
4
  import { InsforgeUser } from './types.js';
6
5
  export { ForgotPasswordForm, ForgotPasswordFormProps, ResetPasswordForm, ResetPasswordFormProps, SignInForm, SignInFormProps, SignUpForm, SignUpFormProps, VerifyEmailStatus, VerifyEmailStatusProps } from './forms.js';
@@ -215,7 +214,7 @@ interface ProtectProps {
215
214
  * @param {function} [condition] - Custom access condition
216
215
  * @param {function} [onRedirect] - Custom redirect handler (default: window.location)
217
216
  */
218
- declare function Protect({ children, fallback, redirectTo, condition, onRedirect, }: ProtectProps): string | number | bigint | true | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null;
217
+ declare function Protect({ children, fallback, redirectTo, condition, onRedirect, }: ProtectProps): ReactNode;
219
218
 
220
219
  interface ConditionalProps$1 {
221
220
  children: ReactNode;
@@ -255,4 +254,52 @@ interface ConditionalProps {
255
254
  */
256
255
  declare function SignedOut({ children }: ConditionalProps): react_jsx_runtime.JSX.Element | null;
257
256
 
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 };
257
+ interface SignInButtonProps {
258
+ children?: React.ReactNode;
259
+ className?: string;
260
+ }
261
+ /**
262
+ * SignInButton Component
263
+ *
264
+ * A simple unstyled button that redirects to the hosted sign-in page.
265
+ * If children is a valid React element, it will be rendered with the redirect logic attached.
266
+ *
267
+ * @example
268
+ * ```tsx
269
+ * <SignInButton />
270
+ * ```
271
+ *
272
+ * @example
273
+ * ```tsx
274
+ * <SignInButton>
275
+ * <button className="your-button">Login</button>
276
+ * </SignInButton>
277
+ * ```
278
+ */
279
+ declare function SignInButton({ children, className }: SignInButtonProps): react_jsx_runtime.JSX.Element;
280
+
281
+ interface SignUpButtonProps {
282
+ children?: React.ReactNode;
283
+ className?: string;
284
+ }
285
+ /**
286
+ * SignUpButton Component
287
+ *
288
+ * A simple unstyled button that redirects to the hosted sign-up page.
289
+ * If children is a valid React element, it will be rendered with the redirect logic attached.
290
+ *
291
+ * @example
292
+ * ```tsx
293
+ * <SignUpButton />
294
+ * ```
295
+ *
296
+ * @example
297
+ * ```tsx
298
+ * <SignUpButton>
299
+ * <button className="fancy-button">Register Now</button>
300
+ * </SignUpButton>
301
+ * ```
302
+ */
303
+ declare function SignUpButton({ children, className }: SignUpButtonProps): react_jsx_runtime.JSX.Element;
304
+
305
+ 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