@aaspai/react 0.0.0 → 0.0.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.
Files changed (55) hide show
  1. package/README.md +720 -8
  2. package/dist/atoms.cjs +3565 -0
  3. package/dist/atoms.cjs.map +1 -0
  4. package/dist/atoms.d.cts +255 -0
  5. package/dist/atoms.d.ts +255 -0
  6. package/dist/atoms.js +3530 -0
  7. package/dist/atoms.js.map +1 -0
  8. package/dist/components.cjs +5397 -0
  9. package/dist/components.cjs.map +1 -0
  10. package/dist/components.d.cts +362 -0
  11. package/dist/components.d.ts +362 -0
  12. package/dist/components.js +5344 -0
  13. package/dist/components.js.map +1 -0
  14. package/dist/forms.cjs +3928 -0
  15. package/dist/forms.cjs.map +1 -0
  16. package/dist/forms.d.cts +135 -0
  17. package/dist/forms.d.ts +135 -0
  18. package/dist/forms.js +3903 -0
  19. package/dist/forms.js.map +1 -0
  20. package/dist/hooks.cjs +74 -0
  21. package/dist/hooks.cjs.map +1 -0
  22. package/dist/hooks.d.cts +138 -0
  23. package/dist/hooks.d.ts +138 -0
  24. package/dist/hooks.js +70 -0
  25. package/dist/hooks.js.map +1 -0
  26. package/dist/index.cjs +6030 -0
  27. package/dist/index.cjs.map +1 -0
  28. package/dist/index.d.cts +248 -0
  29. package/dist/index.d.ts +248 -0
  30. package/dist/index.js +5952 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/lib.cjs +139 -0
  33. package/dist/lib.cjs.map +1 -0
  34. package/dist/lib.d.cts +111 -0
  35. package/dist/lib.d.ts +111 -0
  36. package/dist/lib.js +128 -0
  37. package/dist/lib.js.map +1 -0
  38. package/dist/navigation.cjs +56 -0
  39. package/dist/navigation.cjs.map +1 -0
  40. package/dist/navigation.d.cts +65 -0
  41. package/dist/navigation.d.ts +65 -0
  42. package/dist/navigation.js +51 -0
  43. package/dist/navigation.js.map +1 -0
  44. package/dist/styles.css +839 -0
  45. package/dist/types.cjs +4 -0
  46. package/dist/types.cjs.map +1 -0
  47. package/dist/types.d.cts +17 -0
  48. package/dist/types.d.ts +17 -0
  49. package/dist/types.js +3 -0
  50. package/dist/types.js.map +1 -0
  51. package/package.json +67 -28
  52. package/index.cjs +0 -10
  53. package/index.d.ts +0 -6
  54. package/index.js +0 -5
  55. package/styles.css +0 -1
@@ -0,0 +1,362 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { VerifyEmailResponse } from '@aaspai/shared-schemas';
3
+ import * as react from 'react';
4
+ import { ReactNode } from 'react';
5
+ import { AaspaiUser } from '@aaspai/shared';
6
+ export { ForgotPasswordForm, ForgotPasswordFormProps, ResetPasswordForm, ResetPasswordFormProps, SignInForm, SignInFormProps, SignUpForm, SignUpFormProps, VerifyEmailStatus, VerifyEmailStatusProps } from './forms.cjs';
7
+ 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';
8
+ import './types.cjs';
9
+
10
+ interface SignInProps {
11
+ title?: string;
12
+ subtitle?: string;
13
+ emailLabel?: string;
14
+ emailPlaceholder?: string;
15
+ passwordLabel?: string;
16
+ passwordPlaceholder?: string;
17
+ forgotPasswordText?: string;
18
+ forgotPasswordUrl?: string;
19
+ submitButtonText?: string;
20
+ loadingButtonText?: string;
21
+ signUpText?: string;
22
+ signUpLinkText?: string;
23
+ signUpUrl?: string;
24
+ dividerText?: string;
25
+ onError?: (error: Error) => void;
26
+ }
27
+ /**
28
+ * Pre-built sign-in component with full authentication logic.
29
+ *
30
+ * @component
31
+ * @example
32
+ * ```tsx
33
+ * <SignIn
34
+ * onError={(error) => console.error('Error:', error)}
35
+ * />
36
+ * ```
37
+ */
38
+ declare function SignIn({ onError, ...uiProps }: SignInProps): react_jsx_runtime.JSX.Element | null;
39
+
40
+ interface SignUpProps {
41
+ title?: string;
42
+ subtitle?: string;
43
+ emailLabel?: string;
44
+ emailPlaceholder?: string;
45
+ passwordLabel?: string;
46
+ passwordPlaceholder?: string;
47
+ submitButtonText?: string;
48
+ loadingButtonText?: string;
49
+ signInText?: string;
50
+ signInLinkText?: string;
51
+ signInUrl?: string;
52
+ dividerText?: string;
53
+ onError?: (error: Error) => void;
54
+ emailRedirectTo?: string;
55
+ }
56
+ /**
57
+ * Pre-built sign-up component with full authentication logic.
58
+ *
59
+ * @component
60
+ * @example
61
+ * ```tsx
62
+ * <SignUp
63
+ * onError={(error) => console.error('Error:', error)}
64
+ * />
65
+ *
66
+ * ```
67
+ */
68
+ declare function SignUp({ onError, emailRedirectTo, ...uiProps }: SignUpProps): react_jsx_runtime.JSX.Element | null;
69
+
70
+ interface ForgotPasswordProps {
71
+ /** Text customization */
72
+ title?: string;
73
+ subtitle?: string;
74
+ emailLabel?: string;
75
+ emailPlaceholder?: string;
76
+ submitButtonText?: string;
77
+ loadingButtonText?: string;
78
+ backToSignInText?: string;
79
+ /** Callback when an error occurs */
80
+ onError?: (error: Error) => void;
81
+ }
82
+ /**
83
+ * Pre-built forgot password component with full business logic.
84
+ *
85
+ * Supports two password reset methods (auto-detected from backend config):
86
+ * - **Link method**: Two-step flow (email → check email message)
87
+ * User receives an email with a reset link to complete the process in a new tab
88
+ * - **Code method**: Three-step flow (email → verify code → reset password)
89
+ * User receives a verification code, enters it, then sets a new password
90
+ *
91
+ * @component
92
+ * @example
93
+ * ```tsx
94
+ * <ForgotPassword
95
+ * onError={(error) => console.error('Error:', error)}
96
+ * />
97
+ * ```
98
+ */
99
+ declare function ForgotPassword({ onError, ...uiProps }: ForgotPasswordProps): react_jsx_runtime.JSX.Element | null;
100
+
101
+ interface ResetPasswordProps {
102
+ /** Text customization */
103
+ title?: string;
104
+ subtitle?: string;
105
+ newPasswordLabel?: string;
106
+ newPasswordPlaceholder?: string;
107
+ confirmPasswordLabel?: string;
108
+ confirmPasswordPlaceholder?: string;
109
+ submitButtonText?: string;
110
+ loadingButtonText?: string;
111
+ /** Callback when an error occurs */
112
+ onError?: (error: Error) => void;
113
+ }
114
+ /**
115
+ * Pre-built reset password page component with full business logic.
116
+ *
117
+ * Automatically reads the reset token from URL query parameter (?token=xxx).
118
+ * Shows an error if token is missing.
119
+ *
120
+ * @component
121
+ * @example
122
+ * ```tsx
123
+ * // Used at /reset-password?token=xxxxx
124
+ * <ResetPassword />
125
+ * ```
126
+ */
127
+ declare function ResetPassword({ onError, ...uiProps }: ResetPasswordProps): react_jsx_runtime.JSX.Element | null;
128
+
129
+ interface VerifyEmailProps {
130
+ /** Verification token (from URL query params) */
131
+ token: string;
132
+ /** Text customization */
133
+ verifyingTitle?: string;
134
+ successTitle?: string;
135
+ successMessage?: string;
136
+ errorTitle?: string;
137
+ /** Callback when verification is successful */
138
+ onSuccess?: (data: VerifyEmailResponse) => void;
139
+ /** Callback when verification fails */
140
+ onError?: (error: Error) => void;
141
+ }
142
+ /**
143
+ * Pre-built email verification component with full business logic.
144
+ *
145
+ * Automatically verifies the email when mounted using the provided token.
146
+ *
147
+ * @component
148
+ * @example
149
+ * ```tsx
150
+ * const token = new URLSearchParams(window.location.search).get('token');
151
+ *
152
+ * <VerifyEmail
153
+ * token={token || ''}
154
+ * onSuccess={(data) => {
155
+ * console.log('Email verified!', data);
156
+ * // Optionally navigate or close window
157
+ * }}
158
+ * onError={(error) => console.error('Verification failed:', error)}
159
+ * />
160
+ * ```
161
+ */
162
+ declare function VerifyEmail({ token, onSuccess, onError, ...uiProps }: VerifyEmailProps): react_jsx_runtime.JSX.Element;
163
+
164
+ interface UserButtonProps {
165
+ afterSignOutUrl?: string;
166
+ mode?: 'detailed' | 'simple';
167
+ /** Whether to show the Profile menu item (default: true) */
168
+ showProfile?: boolean;
169
+ /** Callback when profile update fails */
170
+ onProfileError?: (error: string) => void;
171
+ }
172
+ /**
173
+ * User profile button with dropdown menu and sign-out functionality.
174
+ *
175
+ * Styles are powered by Emotion CSS-in-JS to prevent FOUC in SSR environments.
176
+ */
177
+ declare function UserButton({ afterSignOutUrl, mode, showProfile, onProfileError, }: UserButtonProps): react_jsx_runtime.JSX.Element | null;
178
+
179
+ interface UserProfileModalProps {
180
+ /** Called when the modal is closed */
181
+ onClose: () => void;
182
+ /** Called when an error occurs */
183
+ onError?: (error: string) => void;
184
+ }
185
+ /**
186
+ * User profile modal component.
187
+ * Displays user profile information with edit capability for name.
188
+ */
189
+ declare function UserProfileModal({ onClose, onError }: UserProfileModalProps): react.ReactPortal | null;
190
+
191
+ interface ProtectProps {
192
+ children: ReactNode;
193
+ fallback?: ReactNode;
194
+ redirectTo?: string;
195
+ condition?: (user: AaspaiUser) => boolean;
196
+ onRedirect?: (url: string) => void;
197
+ }
198
+ /**
199
+ * Protected route component that redirects unauthenticated users.
200
+ *
201
+ * @component
202
+ * @example
203
+ * ```tsx
204
+ * // Basic usage
205
+ * <Protect redirectTo="/sign-in">
206
+ * <Dashboard />
207
+ * </Protect>
208
+ *
209
+ * // With custom redirect handler (e.g., for Next.js router)
210
+ * <Protect
211
+ * redirectTo="/sign-in"
212
+ * onRedirect={(url) => router.push(url)}
213
+ * >
214
+ * <AdminPanel />
215
+ * </Protect>
216
+ *
217
+ * // With custom condition (role-based access)
218
+ * <Protect
219
+ * redirectTo="/unauthorized"
220
+ * condition={(user) => user.role === 'admin'}
221
+ * >
222
+ * <AdminContent />
223
+ * </Protect>
224
+ * ```
225
+ *
226
+ * @param {ReactNode} children - Content to protect
227
+ * @param {ReactNode} [fallback] - Fallback UI while loading
228
+ * @param {string} [redirectTo='/sign-in'] - Redirect URL
229
+ * @param {function} [condition] - Custom access condition
230
+ * @param {function} [onRedirect] - Custom redirect handler (default: window.location)
231
+ */
232
+ declare function Protect({ children, fallback, redirectTo, condition, onRedirect, }: ProtectProps): ReactNode;
233
+
234
+ interface ConditionalProps$1 {
235
+ children: ReactNode;
236
+ }
237
+ /**
238
+ * Conditional component that renders children only when user is signed in.
239
+ *
240
+ * Uses userId to determine rendering:
241
+ * - undefined = not loaded yet (SSR or before hydration) -> render null
242
+ * - null = loaded, user signed out -> render null
243
+ * - string = loaded, user signed in -> render children
244
+ *
245
+ * This prevents hydration mismatches in Next.js SSR by ensuring
246
+ * consistent rendering between server and client initial render.
247
+ *
248
+ * @component
249
+ * @example
250
+ * ```tsx
251
+ * <SignedIn>
252
+ * <Dashboard />
253
+ * </SignedIn>
254
+ * ```
255
+ *
256
+ * @param {ReactNode} children - React nodes to render when user is authenticated
257
+ * @returns {JSX.Element | null} Renders children when signed in, null otherwise
258
+ */
259
+ declare function SignedIn({ children }: ConditionalProps$1): react_jsx_runtime.JSX.Element | null;
260
+
261
+ interface ConditionalProps {
262
+ children: ReactNode;
263
+ }
264
+ /**
265
+ * Conditional component that renders children only when user is signed out.
266
+ *
267
+ * Uses userId to determine rendering:
268
+ * - undefined = not loaded yet (SSR or before hydration) -> render null
269
+ * - null = loaded, user signed out -> render children
270
+ * - string = loaded, user signed in -> render null
271
+ *
272
+ * This prevents hydration mismatches in Next.js SSR by ensuring
273
+ * consistent rendering between server and client initial render.
274
+ *
275
+ * @component
276
+ * @example
277
+ * ```tsx
278
+ * <SignedOut>
279
+ * <SignIn />
280
+ * </SignedOut>
281
+ * ```
282
+ *
283
+ * @param {ReactNode} children - React nodes to render when user is not authenticated
284
+ * @returns {JSX.Element | null} Renders children when signed out, null otherwise
285
+ */
286
+ declare function SignedOut({ children }: ConditionalProps): react_jsx_runtime.JSX.Element | null;
287
+
288
+ interface SignInButtonProps {
289
+ children?: React.ReactNode;
290
+ className?: string;
291
+ }
292
+ /**
293
+ * SignInButton Component
294
+ *
295
+ * A simple unstyled button that redirects to the hosted sign-in page.
296
+ * If children is a valid React element, it will be rendered with the redirect logic attached.
297
+ *
298
+ * @example
299
+ * ```tsx
300
+ * <SignInButton />
301
+ * ```
302
+ *
303
+ * @example
304
+ * ```tsx
305
+ * <SignInButton>
306
+ * <button className="your-button">Login</button>
307
+ * </SignInButton>
308
+ * ```
309
+ */
310
+ declare function SignInButton({ children, className }: SignInButtonProps): react_jsx_runtime.JSX.Element;
311
+
312
+ interface SignUpButtonProps {
313
+ children?: React.ReactNode;
314
+ className?: string;
315
+ }
316
+ /**
317
+ * SignUpButton Component
318
+ *
319
+ * A simple unstyled button that redirects to the hosted sign-up page.
320
+ * If children is a valid React element, it will be rendered with the redirect logic attached.
321
+ *
322
+ * @example
323
+ * ```tsx
324
+ * <SignUpButton />
325
+ * ```
326
+ *
327
+ * @example
328
+ * ```tsx
329
+ * <SignUpButton>
330
+ * <button className="fancy-button">Register Now</button>
331
+ * </SignUpButton>
332
+ * ```
333
+ */
334
+ declare function SignUpButton({ children, className }: SignUpButtonProps): react_jsx_runtime.JSX.Element;
335
+
336
+ interface SignOutButtonProps {
337
+ children?: React.ReactNode;
338
+ className?: string;
339
+ afterSignOutUrl?: string;
340
+ }
341
+ /**
342
+ * SignOutButton Component
343
+ *
344
+ * A simple unstyled button that signs out the current user.
345
+ * If children is a valid React element, it will be rendered with the sign-out logic attached.
346
+ *
347
+ * @example
348
+ * ```tsx
349
+ * <SignOutButton />
350
+ * ```
351
+ *
352
+ * @example
353
+ * ```tsx
354
+ * <SignOutButton afterSignOutUrl="/goodbye">
355
+ * <button className="custom-button">Logout</button>
356
+ * </SignOutButton>
357
+ * ```
358
+ */
359
+ declare function SignOutButton({ children, className, afterSignOutUrl }: SignOutButtonProps): react_jsx_runtime.JSX.Element;
360
+
361
+ export { type ConditionalProps$1 as ConditionalProps, ForgotPassword, type ForgotPasswordProps, Protect, type ProtectProps, ResetPassword, type ResetPasswordProps, SignIn, SignInButton, type SignInButtonProps, type SignInProps, SignOutButton, type SignOutButtonProps, SignUp, SignUpButton, type SignUpButtonProps, type SignUpProps, SignedIn, SignedOut, UserButton, type UserButtonProps, UserProfileModal, type UserProfileModalProps, VerifyEmail, type VerifyEmailProps };
362
+