@insforge/react 0.4.0 → 0.4.6

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/atoms.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode, InputHTMLAttributes, CSSProperties } from 'react';
3
- import { AuthConfig } from './types.cjs';
3
+ import { AuthConfig, EmailVerificationMethod } from './types.cjs';
4
4
  import { OAuthProvidersSchema } from '@insforge/shared-schemas';
5
5
 
6
6
  /**
@@ -14,6 +14,9 @@ import { OAuthProvidersSchema } from '@insforge/shared-schemas';
14
14
  */
15
15
  declare function AuthBranding(): react_jsx_runtime.JSX.Element;
16
16
 
17
+ interface AuthContainerProps {
18
+ children: ReactNode;
19
+ }
17
20
  /**
18
21
  * Main container component for authentication forms.
19
22
  *
@@ -28,10 +31,12 @@ declare function AuthBranding(): react_jsx_runtime.JSX.Element;
28
31
  *
29
32
  * @param {ReactNode} children - Form content
30
33
  */
31
- declare function AuthContainer({ children }: {
32
- children: ReactNode;
33
- }): react_jsx_runtime.JSX.Element;
34
+ declare function AuthContainer({ children }: AuthContainerProps): react_jsx_runtime.JSX.Element;
34
35
 
36
+ interface AuthHeaderProps {
37
+ title: string;
38
+ subtitle?: string;
39
+ }
35
40
  /**
36
41
  * Header component for authentication forms displaying title and optional subtitle.
37
42
  *
@@ -47,11 +52,11 @@ declare function AuthContainer({ children }: {
47
52
  * @param {string} title - Main heading text
48
53
  * @param {string} [subtitle] - Optional subheading text
49
54
  */
50
- declare function AuthHeader({ title, subtitle }: {
51
- title: string;
52
- subtitle?: string;
53
- }): react_jsx_runtime.JSX.Element;
55
+ declare function AuthHeader({ title, subtitle }: AuthHeaderProps): react_jsx_runtime.JSX.Element;
54
56
 
57
+ interface AuthErrorBannerProps {
58
+ error: string;
59
+ }
55
60
  /**
56
61
  * Error message banner for authentication forms.
57
62
  */
@@ -59,6 +64,10 @@ declare function AuthErrorBanner({ error }: {
59
64
  error?: string;
60
65
  }): react_jsx_runtime.JSX.Element | null;
61
66
 
67
+ interface AuthFormFieldProps extends InputHTMLAttributes<HTMLInputElement> {
68
+ label: string;
69
+ id: string;
70
+ }
62
71
  /**
63
72
  * Standard form input field with label for authentication forms.
64
73
  *
@@ -75,10 +84,7 @@ declare function AuthErrorBanner({ error }: {
75
84
  * @param {string} label - Label text
76
85
  * @param {string} id - Input element ID
77
86
  */
78
- declare function AuthFormField({ label, id, ...props }: {
79
- label: string;
80
- id: string;
81
- } & InputHTMLAttributes<HTMLInputElement>): react_jsx_runtime.JSX.Element;
87
+ declare function AuthFormField({ label, id, ...props }: AuthFormFieldProps): react_jsx_runtime.JSX.Element;
82
88
 
83
89
  interface AuthPasswordFieldProps extends InputHTMLAttributes<HTMLInputElement> {
84
90
  label?: string;
@@ -95,37 +101,51 @@ interface AuthPasswordFieldProps extends InputHTMLAttributes<HTMLInputElement> {
95
101
  */
96
102
  declare function AuthPasswordField({ label, id, showStrengthIndicator, authConfig, forgotPasswordLink, value, onFocus, ...props }: AuthPasswordFieldProps): react_jsx_runtime.JSX.Element;
97
103
 
104
+ interface AuthPasswordStrengthIndicatorProps {
105
+ password: string;
106
+ config: AuthConfig;
107
+ }
98
108
  /**
99
109
  * Password strength indicator showing requirement checklist.
100
110
  */
101
- declare function AuthPasswordStrengthIndicator({ password, config, }: {
102
- password: string;
103
- config: AuthConfig;
104
- }): react_jsx_runtime.JSX.Element;
111
+ declare function AuthPasswordStrengthIndicator({ password, config, }: AuthPasswordStrengthIndicatorProps): react_jsx_runtime.JSX.Element;
105
112
 
113
+ interface AuthSubmitButtonProps {
114
+ children: ReactNode;
115
+ isLoading?: boolean;
116
+ confirmed?: boolean;
117
+ disabled?: boolean;
118
+ type?: 'button' | 'submit';
119
+ onClick?: () => void;
120
+ }
106
121
  /**
107
- * Primary submit button for authentication forms with loading and confirmed states.
122
+ * Primary button for authentication forms with loading and confirmed states.
123
+ *
124
+ * Supports two modes:
125
+ * - **Form submit** (default): type="submit" - triggers form's onSubmit handler
126
+ * - **Action button**: type="button" + onClick - executes custom logic without form submission
108
127
  *
109
128
  * @component
110
129
  * @example
111
130
  * ```tsx
131
+ * // Form submit button (default)
112
132
  * <AuthSubmitButton isLoading={loading}>
113
133
  * Sign In
114
134
  * </AuthSubmitButton>
115
- * ```
116
135
  *
117
- * @param {ReactNode} children - Button text
118
- * @param {boolean} [isLoading] - Loading state (shows spinner)
119
- * @param {boolean} [confirmed] - Confirmed state (shows checkmark)
120
- * @param {boolean} [disabled] - Disabled state
136
+ * // Action button with click handler
137
+ * <AuthSubmitButton type="button" onClick={handleClick} isLoading={loading}>
138
+ * Verify Code
139
+ * </AuthSubmitButton>
140
+ * ```
121
141
  */
122
- declare function AuthSubmitButton({ children, isLoading, confirmed, disabled, }: {
123
- children: ReactNode;
124
- isLoading?: boolean;
125
- confirmed?: boolean;
126
- disabled?: boolean;
127
- }): react_jsx_runtime.JSX.Element;
142
+ declare function AuthSubmitButton({ children, isLoading, confirmed, disabled, type, onClick, }: AuthSubmitButtonProps): react_jsx_runtime.JSX.Element;
128
143
 
144
+ interface AuthLinkProps {
145
+ text: string;
146
+ linkText: string;
147
+ href: string;
148
+ }
129
149
  /**
130
150
  * Call-to-action link component for navigation between auth pages.
131
151
  *
@@ -143,18 +163,15 @@ declare function AuthSubmitButton({ children, isLoading, confirmed, disabled, }:
143
163
  * @param {string} linkText - Clickable link text
144
164
  * @param {string} href - Link URL
145
165
  */
146
- declare function AuthLink({ text, linkText, href, }: {
147
- text?: string;
148
- linkText: string;
149
- href: string;
150
- }): react_jsx_runtime.JSX.Element;
166
+ declare function AuthLink({ text, linkText, href }: AuthLinkProps): react_jsx_runtime.JSX.Element;
151
167
 
168
+ interface AuthDividerProps {
169
+ text?: string;
170
+ }
152
171
  /**
153
172
  * Visual divider with optional centered text for auth forms.
154
173
  */
155
- declare function AuthDivider({ text }: {
156
- text?: string;
157
- }): react_jsx_runtime.JSX.Element;
174
+ declare function AuthDivider({ text }: AuthDividerProps): react_jsx_runtime.JSX.Element;
158
175
 
159
176
  interface AuthOAuthButtonProps {
160
177
  provider: OAuthProvidersSchema;
@@ -198,11 +215,9 @@ interface AuthVerificationCodeInputProps {
198
215
  */
199
216
  declare function AuthVerificationCodeInput({ length, value, email, onChange, disabled, onComplete, }: AuthVerificationCodeInputProps): react_jsx_runtime.JSX.Element;
200
217
 
201
- type VerificationMethod = 'code' | 'link';
202
218
  interface AuthEmailVerificationStepProps {
203
219
  email: string;
204
- description?: string;
205
- method?: VerificationMethod;
220
+ method?: EmailVerificationMethod;
206
221
  onVerifyCode?: (code: string) => Promise<void>;
207
222
  }
208
223
  /**
@@ -217,6 +232,22 @@ interface AuthEmailVerificationStepProps {
217
232
  *
218
233
  * @param method - 'code' for OTP input, 'link' for magic link (default: 'code')
219
234
  */
220
- declare function AuthEmailVerificationStep({ email, description, method, onVerifyCode, }: AuthEmailVerificationStepProps): react_jsx_runtime.JSX.Element;
235
+ declare function AuthEmailVerificationStep({ email, method, onVerifyCode, }: AuthEmailVerificationStepProps): react_jsx_runtime.JSX.Element;
236
+
237
+ interface AuthResetPasswordVerificationStepProps {
238
+ email: string;
239
+ method: EmailVerificationMethod;
240
+ onVerifyCode?: (code: string) => Promise<void>;
241
+ onResendEmail: () => Promise<void>;
242
+ }
243
+ /**
244
+ * Reset password verification step component
245
+ *
246
+ * Handles the verification flow for password reset:
247
+ * - Shows appropriate UI based on method (code input or link message)
248
+ * - Manages countdown timer for resend functionality
249
+ * - Handles code verification for code method
250
+ */
251
+ declare function AuthResetPasswordVerificationStep({ email, method, onVerifyCode, onResendEmail, }: AuthResetPasswordVerificationStepProps): react_jsx_runtime.JSX.Element;
221
252
 
222
- export { AuthBranding, AuthContainer, AuthDivider, AuthEmailVerificationStep, AuthErrorBanner, AuthFormField, AuthHeader, AuthLink, AuthOAuthButton, AuthOAuthProviders, AuthPasswordField, AuthPasswordStrengthIndicator, AuthSubmitButton, AuthVerificationCodeInput };
253
+ export { AuthBranding, AuthContainer, type AuthContainerProps, AuthDivider, type AuthDividerProps, AuthEmailVerificationStep, AuthErrorBanner, type AuthErrorBannerProps, AuthFormField, type AuthFormFieldProps, AuthHeader, type AuthHeaderProps, AuthLink, type AuthLinkProps, AuthOAuthButton, type AuthOAuthButtonProps, AuthOAuthProviders, type AuthOAuthProvidersProps, AuthPasswordField, type AuthPasswordFieldProps, AuthPasswordStrengthIndicator, type AuthPasswordStrengthIndicatorProps, AuthResetPasswordVerificationStep, AuthSubmitButton, type AuthSubmitButtonProps, AuthVerificationCodeInput, type AuthVerificationCodeInputProps };
package/dist/atoms.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode, InputHTMLAttributes, CSSProperties } from 'react';
3
- import { AuthConfig } from './types.js';
3
+ import { AuthConfig, EmailVerificationMethod } from './types.js';
4
4
  import { OAuthProvidersSchema } from '@insforge/shared-schemas';
5
5
 
6
6
  /**
@@ -14,6 +14,9 @@ import { OAuthProvidersSchema } from '@insforge/shared-schemas';
14
14
  */
15
15
  declare function AuthBranding(): react_jsx_runtime.JSX.Element;
16
16
 
17
+ interface AuthContainerProps {
18
+ children: ReactNode;
19
+ }
17
20
  /**
18
21
  * Main container component for authentication forms.
19
22
  *
@@ -28,10 +31,12 @@ declare function AuthBranding(): react_jsx_runtime.JSX.Element;
28
31
  *
29
32
  * @param {ReactNode} children - Form content
30
33
  */
31
- declare function AuthContainer({ children }: {
32
- children: ReactNode;
33
- }): react_jsx_runtime.JSX.Element;
34
+ declare function AuthContainer({ children }: AuthContainerProps): react_jsx_runtime.JSX.Element;
34
35
 
36
+ interface AuthHeaderProps {
37
+ title: string;
38
+ subtitle?: string;
39
+ }
35
40
  /**
36
41
  * Header component for authentication forms displaying title and optional subtitle.
37
42
  *
@@ -47,11 +52,11 @@ declare function AuthContainer({ children }: {
47
52
  * @param {string} title - Main heading text
48
53
  * @param {string} [subtitle] - Optional subheading text
49
54
  */
50
- declare function AuthHeader({ title, subtitle }: {
51
- title: string;
52
- subtitle?: string;
53
- }): react_jsx_runtime.JSX.Element;
55
+ declare function AuthHeader({ title, subtitle }: AuthHeaderProps): react_jsx_runtime.JSX.Element;
54
56
 
57
+ interface AuthErrorBannerProps {
58
+ error: string;
59
+ }
55
60
  /**
56
61
  * Error message banner for authentication forms.
57
62
  */
@@ -59,6 +64,10 @@ declare function AuthErrorBanner({ error }: {
59
64
  error?: string;
60
65
  }): react_jsx_runtime.JSX.Element | null;
61
66
 
67
+ interface AuthFormFieldProps extends InputHTMLAttributes<HTMLInputElement> {
68
+ label: string;
69
+ id: string;
70
+ }
62
71
  /**
63
72
  * Standard form input field with label for authentication forms.
64
73
  *
@@ -75,10 +84,7 @@ declare function AuthErrorBanner({ error }: {
75
84
  * @param {string} label - Label text
76
85
  * @param {string} id - Input element ID
77
86
  */
78
- declare function AuthFormField({ label, id, ...props }: {
79
- label: string;
80
- id: string;
81
- } & InputHTMLAttributes<HTMLInputElement>): react_jsx_runtime.JSX.Element;
87
+ declare function AuthFormField({ label, id, ...props }: AuthFormFieldProps): react_jsx_runtime.JSX.Element;
82
88
 
83
89
  interface AuthPasswordFieldProps extends InputHTMLAttributes<HTMLInputElement> {
84
90
  label?: string;
@@ -95,37 +101,51 @@ interface AuthPasswordFieldProps extends InputHTMLAttributes<HTMLInputElement> {
95
101
  */
96
102
  declare function AuthPasswordField({ label, id, showStrengthIndicator, authConfig, forgotPasswordLink, value, onFocus, ...props }: AuthPasswordFieldProps): react_jsx_runtime.JSX.Element;
97
103
 
104
+ interface AuthPasswordStrengthIndicatorProps {
105
+ password: string;
106
+ config: AuthConfig;
107
+ }
98
108
  /**
99
109
  * Password strength indicator showing requirement checklist.
100
110
  */
101
- declare function AuthPasswordStrengthIndicator({ password, config, }: {
102
- password: string;
103
- config: AuthConfig;
104
- }): react_jsx_runtime.JSX.Element;
111
+ declare function AuthPasswordStrengthIndicator({ password, config, }: AuthPasswordStrengthIndicatorProps): react_jsx_runtime.JSX.Element;
105
112
 
113
+ interface AuthSubmitButtonProps {
114
+ children: ReactNode;
115
+ isLoading?: boolean;
116
+ confirmed?: boolean;
117
+ disabled?: boolean;
118
+ type?: 'button' | 'submit';
119
+ onClick?: () => void;
120
+ }
106
121
  /**
107
- * Primary submit button for authentication forms with loading and confirmed states.
122
+ * Primary button for authentication forms with loading and confirmed states.
123
+ *
124
+ * Supports two modes:
125
+ * - **Form submit** (default): type="submit" - triggers form's onSubmit handler
126
+ * - **Action button**: type="button" + onClick - executes custom logic without form submission
108
127
  *
109
128
  * @component
110
129
  * @example
111
130
  * ```tsx
131
+ * // Form submit button (default)
112
132
  * <AuthSubmitButton isLoading={loading}>
113
133
  * Sign In
114
134
  * </AuthSubmitButton>
115
- * ```
116
135
  *
117
- * @param {ReactNode} children - Button text
118
- * @param {boolean} [isLoading] - Loading state (shows spinner)
119
- * @param {boolean} [confirmed] - Confirmed state (shows checkmark)
120
- * @param {boolean} [disabled] - Disabled state
136
+ * // Action button with click handler
137
+ * <AuthSubmitButton type="button" onClick={handleClick} isLoading={loading}>
138
+ * Verify Code
139
+ * </AuthSubmitButton>
140
+ * ```
121
141
  */
122
- declare function AuthSubmitButton({ children, isLoading, confirmed, disabled, }: {
123
- children: ReactNode;
124
- isLoading?: boolean;
125
- confirmed?: boolean;
126
- disabled?: boolean;
127
- }): react_jsx_runtime.JSX.Element;
142
+ declare function AuthSubmitButton({ children, isLoading, confirmed, disabled, type, onClick, }: AuthSubmitButtonProps): react_jsx_runtime.JSX.Element;
128
143
 
144
+ interface AuthLinkProps {
145
+ text: string;
146
+ linkText: string;
147
+ href: string;
148
+ }
129
149
  /**
130
150
  * Call-to-action link component for navigation between auth pages.
131
151
  *
@@ -143,18 +163,15 @@ declare function AuthSubmitButton({ children, isLoading, confirmed, disabled, }:
143
163
  * @param {string} linkText - Clickable link text
144
164
  * @param {string} href - Link URL
145
165
  */
146
- declare function AuthLink({ text, linkText, href, }: {
147
- text?: string;
148
- linkText: string;
149
- href: string;
150
- }): react_jsx_runtime.JSX.Element;
166
+ declare function AuthLink({ text, linkText, href }: AuthLinkProps): react_jsx_runtime.JSX.Element;
151
167
 
168
+ interface AuthDividerProps {
169
+ text?: string;
170
+ }
152
171
  /**
153
172
  * Visual divider with optional centered text for auth forms.
154
173
  */
155
- declare function AuthDivider({ text }: {
156
- text?: string;
157
- }): react_jsx_runtime.JSX.Element;
174
+ declare function AuthDivider({ text }: AuthDividerProps): react_jsx_runtime.JSX.Element;
158
175
 
159
176
  interface AuthOAuthButtonProps {
160
177
  provider: OAuthProvidersSchema;
@@ -198,11 +215,9 @@ interface AuthVerificationCodeInputProps {
198
215
  */
199
216
  declare function AuthVerificationCodeInput({ length, value, email, onChange, disabled, onComplete, }: AuthVerificationCodeInputProps): react_jsx_runtime.JSX.Element;
200
217
 
201
- type VerificationMethod = 'code' | 'link';
202
218
  interface AuthEmailVerificationStepProps {
203
219
  email: string;
204
- description?: string;
205
- method?: VerificationMethod;
220
+ method?: EmailVerificationMethod;
206
221
  onVerifyCode?: (code: string) => Promise<void>;
207
222
  }
208
223
  /**
@@ -217,6 +232,22 @@ interface AuthEmailVerificationStepProps {
217
232
  *
218
233
  * @param method - 'code' for OTP input, 'link' for magic link (default: 'code')
219
234
  */
220
- declare function AuthEmailVerificationStep({ email, description, method, onVerifyCode, }: AuthEmailVerificationStepProps): react_jsx_runtime.JSX.Element;
235
+ declare function AuthEmailVerificationStep({ email, method, onVerifyCode, }: AuthEmailVerificationStepProps): react_jsx_runtime.JSX.Element;
236
+
237
+ interface AuthResetPasswordVerificationStepProps {
238
+ email: string;
239
+ method: EmailVerificationMethod;
240
+ onVerifyCode?: (code: string) => Promise<void>;
241
+ onResendEmail: () => Promise<void>;
242
+ }
243
+ /**
244
+ * Reset password verification step component
245
+ *
246
+ * Handles the verification flow for password reset:
247
+ * - Shows appropriate UI based on method (code input or link message)
248
+ * - Manages countdown timer for resend functionality
249
+ * - Handles code verification for code method
250
+ */
251
+ declare function AuthResetPasswordVerificationStep({ email, method, onVerifyCode, onResendEmail, }: AuthResetPasswordVerificationStepProps): react_jsx_runtime.JSX.Element;
221
252
 
222
- export { AuthBranding, AuthContainer, AuthDivider, AuthEmailVerificationStep, AuthErrorBanner, AuthFormField, AuthHeader, AuthLink, AuthOAuthButton, AuthOAuthProviders, AuthPasswordField, AuthPasswordStrengthIndicator, AuthSubmitButton, AuthVerificationCodeInput };
253
+ export { AuthBranding, AuthContainer, type AuthContainerProps, AuthDivider, type AuthDividerProps, AuthEmailVerificationStep, AuthErrorBanner, type AuthErrorBannerProps, AuthFormField, type AuthFormFieldProps, AuthHeader, type AuthHeaderProps, AuthLink, type AuthLinkProps, AuthOAuthButton, type AuthOAuthButtonProps, AuthOAuthProviders, type AuthOAuthProvidersProps, AuthPasswordField, type AuthPasswordFieldProps, AuthPasswordStrengthIndicator, type AuthPasswordStrengthIndicatorProps, AuthResetPasswordVerificationStep, AuthSubmitButton, type AuthSubmitButtonProps, AuthVerificationCodeInput, type AuthVerificationCodeInputProps };