@rationalbloks/frontblok-components 0.1.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.
- package/README.md +129 -0
- package/dist/index.cjs +6541 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +256 -0
- package/dist/index.js +6525 -0
- package/dist/index.js.map +1 -0
- package/package.json +66 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
import { default as default_2 } from 'react';
|
|
3
|
+
import { ErrorInfo } from 'react';
|
|
4
|
+
import { JSX } from 'react/jsx-runtime';
|
|
5
|
+
import { JSXElementConstructor } from 'react';
|
|
6
|
+
import { ReactElement } from 'react';
|
|
7
|
+
import { ReactNode } from 'react';
|
|
8
|
+
import { ReactPortal } from 'react';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Auth API interface - matches frontblok-auth's authApi.
|
|
12
|
+
* Components need these methods to work.
|
|
13
|
+
*/
|
|
14
|
+
export declare interface AuthApi {
|
|
15
|
+
requestPasswordReset: (email: string) => Promise<{
|
|
16
|
+
message: string;
|
|
17
|
+
dev_token?: string;
|
|
18
|
+
}>;
|
|
19
|
+
resetPassword: (token: string, newPassword: string) => Promise<{
|
|
20
|
+
message: string;
|
|
21
|
+
}>;
|
|
22
|
+
verifyEmail: (token: string) => Promise<{
|
|
23
|
+
message: string;
|
|
24
|
+
}>;
|
|
25
|
+
googleLogin: (credential: string) => Promise<{
|
|
26
|
+
is_new_user?: boolean;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Auth hook return type - matches useClientAuth from frontblok-auth.
|
|
32
|
+
*/
|
|
33
|
+
export declare interface AuthHook {
|
|
34
|
+
login: (email: string, password: string) => Promise<boolean>;
|
|
35
|
+
register: (email: string, password: string, firstName: string, lastName: string) => Promise<boolean>;
|
|
36
|
+
isLoading: boolean;
|
|
37
|
+
error: string | null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export declare const AuthView: default_2.FC<AuthViewProps>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Props for AuthView which also needs the auth hook and nonce generator.
|
|
44
|
+
*/
|
|
45
|
+
export declare interface AuthViewProps extends ViewProps {
|
|
46
|
+
/** Auth hook (login, register, isLoading, error) */
|
|
47
|
+
useAuth: () => AuthHook;
|
|
48
|
+
/** Generate OAuth nonce for Google login */
|
|
49
|
+
generateOAuthNonce: () => string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export declare interface BrandConfig {
|
|
53
|
+
name: string;
|
|
54
|
+
logo: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Branding configuration passed to components.
|
|
59
|
+
* Customize the look and feel of auth components.
|
|
60
|
+
*/
|
|
61
|
+
export declare interface Branding {
|
|
62
|
+
/** App name displayed in headers */
|
|
63
|
+
appName: string;
|
|
64
|
+
/** Short tagline for auth pages */
|
|
65
|
+
tagline: string;
|
|
66
|
+
/** Single letter for logo icon */
|
|
67
|
+
logoLetter: string;
|
|
68
|
+
/** CSS gradient for primary buttons and logo */
|
|
69
|
+
primaryGradient: string;
|
|
70
|
+
/** CSS gradient for hover state */
|
|
71
|
+
primaryGradientHover: string;
|
|
72
|
+
/** Box shadow for logo */
|
|
73
|
+
logoShadow: string;
|
|
74
|
+
/** Route to redirect after login */
|
|
75
|
+
dashboardRoute: string;
|
|
76
|
+
/** Success messages */
|
|
77
|
+
messages: {
|
|
78
|
+
loginSuccess: string;
|
|
79
|
+
registerSuccess: string;
|
|
80
|
+
googleNewUser: string;
|
|
81
|
+
};
|
|
82
|
+
/** Security badge text */
|
|
83
|
+
securityBadge: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export declare const ConfirmationModal: default_2.FC<ConfirmationModalProps_2>;
|
|
87
|
+
|
|
88
|
+
export declare interface ConfirmationModalProps {
|
|
89
|
+
open: boolean;
|
|
90
|
+
onClose: () => void;
|
|
91
|
+
onConfirm: () => void;
|
|
92
|
+
title: string;
|
|
93
|
+
message: string | ReactNode;
|
|
94
|
+
confirmText?: string;
|
|
95
|
+
cancelText?: string;
|
|
96
|
+
severity?: ConfirmationModalSeverity;
|
|
97
|
+
isLoading?: boolean;
|
|
98
|
+
warning?: string;
|
|
99
|
+
details?: {
|
|
100
|
+
label: string;
|
|
101
|
+
oldValue: string;
|
|
102
|
+
newValue: string;
|
|
103
|
+
}[];
|
|
104
|
+
bulletPoints?: string[];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
declare interface ConfirmationModalProps_2 {
|
|
108
|
+
open: boolean;
|
|
109
|
+
onClose: () => void;
|
|
110
|
+
onConfirm: () => void;
|
|
111
|
+
title: string;
|
|
112
|
+
message: string | default_2.ReactNode;
|
|
113
|
+
confirmText?: string;
|
|
114
|
+
cancelText?: string;
|
|
115
|
+
severity?: ConfirmationModalSeverity_2;
|
|
116
|
+
isLoading?: boolean;
|
|
117
|
+
warning?: string;
|
|
118
|
+
details?: {
|
|
119
|
+
label: string;
|
|
120
|
+
oldValue: string;
|
|
121
|
+
newValue: string;
|
|
122
|
+
}[];
|
|
123
|
+
bulletPoints?: string[];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Props for ConfirmationModal.
|
|
128
|
+
*/
|
|
129
|
+
export declare type ConfirmationModalSeverity = 'info' | 'warning' | 'error' | 'success';
|
|
130
|
+
|
|
131
|
+
declare type ConfirmationModalSeverity_2 = 'info' | 'warning' | 'error' | 'success';
|
|
132
|
+
|
|
133
|
+
export declare function createNavbar(config: NavbarConfig): () => JSX.Element;
|
|
134
|
+
|
|
135
|
+
export declare class ErrorBoundary extends Component<Props, State> {
|
|
136
|
+
constructor(props: Props);
|
|
137
|
+
static getDerivedStateFromError(error: Error): Partial<State>;
|
|
138
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
139
|
+
resetError: () => void;
|
|
140
|
+
render(): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | ReactPortal | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | JSX.Element | null | undefined;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Props for ErrorBoundary.
|
|
145
|
+
*/
|
|
146
|
+
export declare interface ErrorBoundaryProps {
|
|
147
|
+
children: ReactNode;
|
|
148
|
+
supportEmail?: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export declare const ErrorFallback: default_2.FC<ErrorFallbackProps>;
|
|
152
|
+
|
|
153
|
+
export declare interface ErrorFallbackProps {
|
|
154
|
+
error: Error | null;
|
|
155
|
+
errorInfo: default_2.ErrorInfo | null;
|
|
156
|
+
resetError: () => void;
|
|
157
|
+
supportEmail: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export declare function ForgotPasswordView({ authApi, authRoute }: ForgotPasswordViewProps): JSX.Element;
|
|
161
|
+
|
|
162
|
+
export declare interface ForgotPasswordViewProps {
|
|
163
|
+
/** Auth API object with requestPasswordReset method */
|
|
164
|
+
authApi: {
|
|
165
|
+
requestPasswordReset: (email: string) => Promise<{
|
|
166
|
+
dev_token?: string;
|
|
167
|
+
}>;
|
|
168
|
+
};
|
|
169
|
+
/** Route to navigate back to login (default: '/auth') */
|
|
170
|
+
authRoute?: string;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export declare interface NavbarAuthHookResult {
|
|
174
|
+
user: {
|
|
175
|
+
first_name?: string;
|
|
176
|
+
last_name?: string;
|
|
177
|
+
email?: string;
|
|
178
|
+
} | null;
|
|
179
|
+
isAuthenticated: boolean;
|
|
180
|
+
logout: () => void;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export declare interface NavbarConfig {
|
|
184
|
+
brand: BrandConfig;
|
|
185
|
+
navigation: NavigationConfig;
|
|
186
|
+
useAuth: () => NavbarAuthHookResult;
|
|
187
|
+
/** Gradient colors for navbar background */
|
|
188
|
+
navbarGradient: {
|
|
189
|
+
start: string;
|
|
190
|
+
end: string;
|
|
191
|
+
};
|
|
192
|
+
userRoleLabel?: string;
|
|
193
|
+
authRoute?: string;
|
|
194
|
+
settingsRoute?: string;
|
|
195
|
+
isActiveOverride?: (path: string, locationPath: string) => boolean;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export declare interface NavigationConfig {
|
|
199
|
+
public: NavigationItem[];
|
|
200
|
+
authenticated: NavigationItem[];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export declare interface NavigationItem {
|
|
204
|
+
id: string;
|
|
205
|
+
label: string;
|
|
206
|
+
icon: default_2.ReactElement;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
declare interface Props {
|
|
210
|
+
children: ReactNode;
|
|
211
|
+
supportEmail?: string;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export declare function ResetPasswordView({ authApi, authRoute }: ResetPasswordViewProps): JSX.Element;
|
|
215
|
+
|
|
216
|
+
export declare interface ResetPasswordViewProps {
|
|
217
|
+
/** Auth API object with resetPassword method */
|
|
218
|
+
authApi: {
|
|
219
|
+
resetPassword: (token: string, newPassword: string) => Promise<void>;
|
|
220
|
+
};
|
|
221
|
+
/** Route to navigate after successful reset (default: '/auth') */
|
|
222
|
+
authRoute?: string;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
declare interface State {
|
|
226
|
+
hasError: boolean;
|
|
227
|
+
error: Error | null;
|
|
228
|
+
errorInfo: ErrorInfo | null;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export declare const SupportView: () => JSX.Element;
|
|
232
|
+
|
|
233
|
+
export declare function VerifyEmailView({ authApi, successRoute, errorRoute }: VerifyEmailViewProps): JSX.Element;
|
|
234
|
+
|
|
235
|
+
export declare interface VerifyEmailViewProps {
|
|
236
|
+
/** Auth API object with verifyEmail method */
|
|
237
|
+
authApi: {
|
|
238
|
+
verifyEmail: (token: string) => Promise<void>;
|
|
239
|
+
};
|
|
240
|
+
/** Route to navigate after successful verification (default: '/projects') */
|
|
241
|
+
successRoute?: string;
|
|
242
|
+
/** Route to navigate on error (default: '/settings') */
|
|
243
|
+
errorRoute?: string;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Common props for all views that need auth and branding.
|
|
248
|
+
*/
|
|
249
|
+
export declare interface ViewProps {
|
|
250
|
+
/** Branding configuration */
|
|
251
|
+
branding: Branding;
|
|
252
|
+
/** Auth API instance */
|
|
253
|
+
authApi: AuthApi;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export { }
|