@insforge/react 0.1.6 → 0.2.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.
@@ -0,0 +1,190 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { SignInProps, SignUpProps, UserButtonProps, ProtectProps, ConditionalProps } from './types.mjs';
3
+ import * as react from 'react';
4
+ import { ReactNode } from 'react';
5
+ export { ForgotPasswordForm, ResetPasswordForm, SignInForm, SignUpForm, VerifyEmailStatus } from './forms.mjs';
6
+ export { AuthBranding, AuthContainer, AuthDivider, AuthErrorBanner, AuthFormField, AuthHeader, AuthLink, AuthOAuthButton, AuthOAuthProviders, AuthPasswordField, AuthPasswordStrengthIndicator, AuthSubmitButton, AuthVerificationCodeInput, validatePasswordStrength } from './atoms.mjs';
7
+ import '@insforge/shared-schemas';
8
+
9
+ /**
10
+ * Pre-built sign-in component with full authentication logic.
11
+ *
12
+ * @component
13
+ * @example
14
+ * ```tsx
15
+ * <SignIn afterSignInUrl="/dashboard" />
16
+ *
17
+ * // With custom callbacks
18
+ * <SignIn
19
+ * onSuccess={(user) => console.log('Signed in:', user)}
20
+ * onError={(error) => console.error('Error:', error)}
21
+ * />
22
+ * ```
23
+ */
24
+ declare function SignIn({ afterSignInUrl, onSuccess, onError, onRedirect, ...uiProps }: SignInProps): react_jsx_runtime.JSX.Element | null;
25
+
26
+ /**
27
+ * Pre-built sign-up component with full authentication logic.
28
+ *
29
+ * @component
30
+ * @example
31
+ * ```tsx
32
+ * <SignUp afterSignUpUrl="/onboarding" />
33
+ *
34
+ * // With custom callbacks
35
+ * <SignUp
36
+ * onSuccess={(user) => console.log('Signed up:', user)}
37
+ * onError={(error) => console.error('Error:', error)}
38
+ * />
39
+ * ```
40
+ */
41
+ declare function SignUp({ afterSignUpUrl, onSuccess, onError, onRedirect, ...uiProps }: SignUpProps): react_jsx_runtime.JSX.Element | null;
42
+
43
+ /**
44
+ * User profile button with dropdown menu and sign-out functionality.
45
+ *
46
+ * @component
47
+ * @example
48
+ * ```tsx
49
+ * <UserButton afterSignOutUrl="/" />
50
+ *
51
+ * // Simple mode
52
+ * <UserButton mode="simple" />
53
+ *
54
+ * // With custom styling
55
+ * <UserButton
56
+ * appearance={{
57
+ * buttonClassName: "hover:bg-white/10",
58
+ * dropdownClassName: "bg-gray-900"
59
+ * }}
60
+ * />
61
+ * ```
62
+ *
63
+ * @param {string} [afterSignOutUrl='/'] - URL to redirect to after sign-out
64
+ * @param {'detailed'|'simple'} [mode='detailed'] - Display mode
65
+ * @param {object} [appearance] - Custom Tailwind classes
66
+ */
67
+ declare function UserButton({ afterSignOutUrl, mode, appearance, }: UserButtonProps): react_jsx_runtime.JSX.Element | null;
68
+
69
+ /**
70
+ * Protected route component that redirects unauthenticated users.
71
+ *
72
+ * @component
73
+ * @example
74
+ * ```tsx
75
+ * // Basic usage
76
+ * <Protect redirectTo="/sign-in">
77
+ * <Dashboard />
78
+ * </Protect>
79
+ *
80
+ * // With custom redirect handler (e.g., for Next.js router)
81
+ * <Protect
82
+ * redirectTo="/sign-in"
83
+ * onRedirect={(url) => router.push(url)}
84
+ * >
85
+ * <AdminPanel />
86
+ * </Protect>
87
+ *
88
+ * // With custom condition (role-based access)
89
+ * <Protect
90
+ * redirectTo="/unauthorized"
91
+ * condition={(user) => user.role === 'admin'}
92
+ * >
93
+ * <AdminContent />
94
+ * </Protect>
95
+ * ```
96
+ *
97
+ * @param {ReactNode} children - Content to protect
98
+ * @param {ReactNode} [fallback] - Fallback UI while loading
99
+ * @param {string} [redirectTo='/sign-in'] - Redirect URL
100
+ * @param {function} [condition] - Custom access condition
101
+ * @param {function} [onRedirect] - Custom redirect handler (default: window.location)
102
+ */
103
+ declare function Protect({ children, fallback, redirectTo, condition, onRedirect, }: ProtectProps): string | number | bigint | true | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null;
104
+
105
+ /**
106
+ * Conditional component that renders children only when user is signed in.
107
+ *
108
+ * @component
109
+ * @example
110
+ * ```tsx
111
+ * <SignedIn>
112
+ * <Dashboard />
113
+ * </SignedIn>
114
+ * ```
115
+ *
116
+ * @param {ReactNode} children - React nodes to render when user is authenticated
117
+ * @returns {JSX.Element | null} Renders children when signed in, null otherwise
118
+ */
119
+ declare function SignedIn({ children }: ConditionalProps): react_jsx_runtime.JSX.Element | null;
120
+
121
+ /**
122
+ * Conditional component that renders children only when user is signed out.
123
+ *
124
+ * @component
125
+ * @example
126
+ * ```tsx
127
+ * <SignedOut>
128
+ * <SignIn />
129
+ * </SignedOut>
130
+ * ```
131
+ *
132
+ * @param {ReactNode} children - React nodes to render when user is not authenticated
133
+ * @returns {JSX.Element | null} Renders children when signed out, null otherwise
134
+ */
135
+ declare function SignedOut({ children }: ConditionalProps): react_jsx_runtime.JSX.Element | null;
136
+
137
+ interface InsforgeCallbackProps {
138
+ /**
139
+ * Redirect destination after successful authentication
140
+ */
141
+ redirectTo?: string;
142
+ /**
143
+ * Callback fired on successful authentication
144
+ */
145
+ onSuccess?: () => void;
146
+ /**
147
+ * Callback fired on authentication error
148
+ */
149
+ onError?: (error: string) => void;
150
+ /**
151
+ * Custom loading component
152
+ */
153
+ loadingComponent?: ReactNode;
154
+ /**
155
+ * Custom redirect handler (default: window.location)
156
+ */
157
+ onRedirect?: (url: string) => void;
158
+ }
159
+ /**
160
+ * InsforgeCallback - Handles OAuth and email/password authentication callbacks
161
+ *
162
+ * Place this component on your `/auth/callback` page.
163
+ *
164
+ * @example
165
+ * ```tsx
166
+ * // Minimal usage
167
+ * export default function CallbackPage() {
168
+ * return <InsforgeCallback />;
169
+ * }
170
+ * ```
171
+ *
172
+ * @example
173
+ * ```tsx
174
+ * // With Next.js router
175
+ * import { useRouter } from 'next/navigation';
176
+ *
177
+ * export default function CallbackPage() {
178
+ * const router = useRouter();
179
+ * return (
180
+ * <InsforgeCallback
181
+ * redirectTo="/dashboard"
182
+ * onRedirect={(url) => router.push(url)}
183
+ * />
184
+ * );
185
+ * }
186
+ * ```
187
+ */
188
+ declare function InsforgeCallback({ redirectTo, onSuccess, onError, loadingComponent, onRedirect, }: InsforgeCallbackProps): 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;
189
+
190
+ export { InsforgeCallback, type InsforgeCallbackProps, Protect, SignIn, SignUp, SignedIn, SignedOut, UserButton };
@@ -0,0 +1,190 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { SignInProps, SignUpProps, UserButtonProps, ProtectProps, ConditionalProps } from './types.js';
3
+ import * as react from 'react';
4
+ import { ReactNode } from 'react';
5
+ export { ForgotPasswordForm, ResetPasswordForm, SignInForm, SignUpForm, VerifyEmailStatus } from './forms.js';
6
+ export { AuthBranding, AuthContainer, AuthDivider, AuthErrorBanner, AuthFormField, AuthHeader, AuthLink, AuthOAuthButton, AuthOAuthProviders, AuthPasswordField, AuthPasswordStrengthIndicator, AuthSubmitButton, AuthVerificationCodeInput, validatePasswordStrength } from './atoms.js';
7
+ import '@insforge/shared-schemas';
8
+
9
+ /**
10
+ * Pre-built sign-in component with full authentication logic.
11
+ *
12
+ * @component
13
+ * @example
14
+ * ```tsx
15
+ * <SignIn afterSignInUrl="/dashboard" />
16
+ *
17
+ * // With custom callbacks
18
+ * <SignIn
19
+ * onSuccess={(user) => console.log('Signed in:', user)}
20
+ * onError={(error) => console.error('Error:', error)}
21
+ * />
22
+ * ```
23
+ */
24
+ declare function SignIn({ afterSignInUrl, onSuccess, onError, onRedirect, ...uiProps }: SignInProps): react_jsx_runtime.JSX.Element | null;
25
+
26
+ /**
27
+ * Pre-built sign-up component with full authentication logic.
28
+ *
29
+ * @component
30
+ * @example
31
+ * ```tsx
32
+ * <SignUp afterSignUpUrl="/onboarding" />
33
+ *
34
+ * // With custom callbacks
35
+ * <SignUp
36
+ * onSuccess={(user) => console.log('Signed up:', user)}
37
+ * onError={(error) => console.error('Error:', error)}
38
+ * />
39
+ * ```
40
+ */
41
+ declare function SignUp({ afterSignUpUrl, onSuccess, onError, onRedirect, ...uiProps }: SignUpProps): react_jsx_runtime.JSX.Element | null;
42
+
43
+ /**
44
+ * User profile button with dropdown menu and sign-out functionality.
45
+ *
46
+ * @component
47
+ * @example
48
+ * ```tsx
49
+ * <UserButton afterSignOutUrl="/" />
50
+ *
51
+ * // Simple mode
52
+ * <UserButton mode="simple" />
53
+ *
54
+ * // With custom styling
55
+ * <UserButton
56
+ * appearance={{
57
+ * buttonClassName: "hover:bg-white/10",
58
+ * dropdownClassName: "bg-gray-900"
59
+ * }}
60
+ * />
61
+ * ```
62
+ *
63
+ * @param {string} [afterSignOutUrl='/'] - URL to redirect to after sign-out
64
+ * @param {'detailed'|'simple'} [mode='detailed'] - Display mode
65
+ * @param {object} [appearance] - Custom Tailwind classes
66
+ */
67
+ declare function UserButton({ afterSignOutUrl, mode, appearance, }: UserButtonProps): react_jsx_runtime.JSX.Element | null;
68
+
69
+ /**
70
+ * Protected route component that redirects unauthenticated users.
71
+ *
72
+ * @component
73
+ * @example
74
+ * ```tsx
75
+ * // Basic usage
76
+ * <Protect redirectTo="/sign-in">
77
+ * <Dashboard />
78
+ * </Protect>
79
+ *
80
+ * // With custom redirect handler (e.g., for Next.js router)
81
+ * <Protect
82
+ * redirectTo="/sign-in"
83
+ * onRedirect={(url) => router.push(url)}
84
+ * >
85
+ * <AdminPanel />
86
+ * </Protect>
87
+ *
88
+ * // With custom condition (role-based access)
89
+ * <Protect
90
+ * redirectTo="/unauthorized"
91
+ * condition={(user) => user.role === 'admin'}
92
+ * >
93
+ * <AdminContent />
94
+ * </Protect>
95
+ * ```
96
+ *
97
+ * @param {ReactNode} children - Content to protect
98
+ * @param {ReactNode} [fallback] - Fallback UI while loading
99
+ * @param {string} [redirectTo='/sign-in'] - Redirect URL
100
+ * @param {function} [condition] - Custom access condition
101
+ * @param {function} [onRedirect] - Custom redirect handler (default: window.location)
102
+ */
103
+ declare function Protect({ children, fallback, redirectTo, condition, onRedirect, }: ProtectProps): string | number | bigint | true | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null;
104
+
105
+ /**
106
+ * Conditional component that renders children only when user is signed in.
107
+ *
108
+ * @component
109
+ * @example
110
+ * ```tsx
111
+ * <SignedIn>
112
+ * <Dashboard />
113
+ * </SignedIn>
114
+ * ```
115
+ *
116
+ * @param {ReactNode} children - React nodes to render when user is authenticated
117
+ * @returns {JSX.Element | null} Renders children when signed in, null otherwise
118
+ */
119
+ declare function SignedIn({ children }: ConditionalProps): react_jsx_runtime.JSX.Element | null;
120
+
121
+ /**
122
+ * Conditional component that renders children only when user is signed out.
123
+ *
124
+ * @component
125
+ * @example
126
+ * ```tsx
127
+ * <SignedOut>
128
+ * <SignIn />
129
+ * </SignedOut>
130
+ * ```
131
+ *
132
+ * @param {ReactNode} children - React nodes to render when user is not authenticated
133
+ * @returns {JSX.Element | null} Renders children when signed out, null otherwise
134
+ */
135
+ declare function SignedOut({ children }: ConditionalProps): react_jsx_runtime.JSX.Element | null;
136
+
137
+ interface InsforgeCallbackProps {
138
+ /**
139
+ * Redirect destination after successful authentication
140
+ */
141
+ redirectTo?: string;
142
+ /**
143
+ * Callback fired on successful authentication
144
+ */
145
+ onSuccess?: () => void;
146
+ /**
147
+ * Callback fired on authentication error
148
+ */
149
+ onError?: (error: string) => void;
150
+ /**
151
+ * Custom loading component
152
+ */
153
+ loadingComponent?: ReactNode;
154
+ /**
155
+ * Custom redirect handler (default: window.location)
156
+ */
157
+ onRedirect?: (url: string) => void;
158
+ }
159
+ /**
160
+ * InsforgeCallback - Handles OAuth and email/password authentication callbacks
161
+ *
162
+ * Place this component on your `/auth/callback` page.
163
+ *
164
+ * @example
165
+ * ```tsx
166
+ * // Minimal usage
167
+ * export default function CallbackPage() {
168
+ * return <InsforgeCallback />;
169
+ * }
170
+ * ```
171
+ *
172
+ * @example
173
+ * ```tsx
174
+ * // With Next.js router
175
+ * import { useRouter } from 'next/navigation';
176
+ *
177
+ * export default function CallbackPage() {
178
+ * const router = useRouter();
179
+ * return (
180
+ * <InsforgeCallback
181
+ * redirectTo="/dashboard"
182
+ * onRedirect={(url) => router.push(url)}
183
+ * />
184
+ * );
185
+ * }
186
+ * ```
187
+ */
188
+ declare function InsforgeCallback({ redirectTo, onSuccess, onError, loadingComponent, onRedirect, }: InsforgeCallbackProps): 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;
189
+
190
+ export { InsforgeCallback, type InsforgeCallbackProps, Protect, SignIn, SignUp, SignedIn, SignedOut, UserButton };