@pubflow/react 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.
Files changed (38) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +539 -0
  3. package/dist/index.d.ts +1908 -0
  4. package/dist/index.esm.js +9922 -0
  5. package/dist/index.esm.js.map +1 -0
  6. package/dist/index.js +9954 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/types/components/AdvancedFilter.d.ts +113 -0
  9. package/dist/types/components/BridgeForm/index.d.ts +6 -0
  10. package/dist/types/components/BridgeForm/styles.d.ts +62 -0
  11. package/dist/types/components/BridgeForm/types.d.ts +128 -0
  12. package/dist/types/components/BridgeForm/utils.d.ts +60 -0
  13. package/dist/types/components/BridgeList.d.ts +157 -0
  14. package/dist/types/components/BridgeTable.d.ts +110 -0
  15. package/dist/types/components/BridgeView.d.ts +39 -0
  16. package/dist/types/components/OfflineIndicator.d.ts +58 -0
  17. package/dist/types/components/auth/AccountCreationForm.d.ts +60 -0
  18. package/dist/types/components/auth/LoginForm.d.ts +76 -0
  19. package/dist/types/components/auth/PasswordResetForm.d.ts +60 -0
  20. package/dist/types/components/auth/index.d.ts +8 -0
  21. package/dist/types/components/theme/ThemeProvider.d.ts +255 -0
  22. package/dist/types/components/theme/index.d.ts +6 -0
  23. package/dist/types/context/PubflowProvider.d.ts +100 -0
  24. package/dist/types/hooks/useAuth.d.ts +32 -0
  25. package/dist/types/hooks/useBridgeApi.d.ts +14 -0
  26. package/dist/types/hooks/useBridgeApiRaw.d.ts +91 -0
  27. package/dist/types/hooks/useBridgeCrud.d.ts +193 -0
  28. package/dist/types/hooks/useBridgeMutation.d.ts +69 -0
  29. package/dist/types/hooks/useBridgeQuery.d.ts +44 -0
  30. package/dist/types/hooks/useSearchQueryBuilder.d.ts +152 -0
  31. package/dist/types/hooks/useServerAuth.d.ts +45 -0
  32. package/dist/types/index.d.ts +26 -0
  33. package/dist/types/storage/BrowserStorageAdapter.d.ts +112 -0
  34. package/dist/types/test/setup.d.ts +4 -0
  35. package/dist/types/utils/auth-utils.d.ts +37 -0
  36. package/dist/types/utils/index.d.ts +5 -0
  37. package/dist/types/utils/persistent-cache.d.ts +57 -0
  38. package/package.json +70 -0
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Offline Indicator Component for React
3
+ *
4
+ * Displays a banner when the user is offline
5
+ */
6
+ import React from 'react';
7
+ /**
8
+ * Offline Indicator props
9
+ */
10
+ export interface OfflineIndicatorProps {
11
+ /**
12
+ * Text to display when offline
13
+ */
14
+ offlineText?: string;
15
+ /**
16
+ * Text to display when back online
17
+ */
18
+ onlineText?: string;
19
+ /**
20
+ * Duration to show the online message (in ms)
21
+ */
22
+ onlineDuration?: number;
23
+ /**
24
+ * Style for the container
25
+ */
26
+ style?: React.CSSProperties;
27
+ /**
28
+ * Style for the offline text
29
+ */
30
+ offlineTextStyle?: React.CSSProperties;
31
+ /**
32
+ * Style for the online text
33
+ */
34
+ onlineTextStyle?: React.CSSProperties;
35
+ /**
36
+ * Whether to show the indicator
37
+ */
38
+ visible?: boolean;
39
+ /**
40
+ * Position of the indicator
41
+ */
42
+ position?: 'top' | 'bottom';
43
+ /**
44
+ * Custom CSS class
45
+ */
46
+ className?: string;
47
+ }
48
+ /**
49
+ * Component for displaying an offline indicator
50
+ */
51
+ export declare function OfflineIndicator({ offlineText, onlineText, onlineDuration, style, offlineTextStyle, onlineTextStyle, visible, position, className }: OfflineIndicatorProps): import("react/jsx-runtime").JSX.Element | null;
52
+ /**
53
+ * Hook to get network status
54
+ */
55
+ export declare function useNetworkStatus(): {
56
+ isOnline: boolean;
57
+ isOffline: boolean;
58
+ };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Account Creation Form Component for React
3
+ *
4
+ * Professional account creation form with validation
5
+ */
6
+ import React from 'react';
7
+ /**
8
+ * Account creation form configuration
9
+ */
10
+ export interface AccountCreationFormConfig {
11
+ /**
12
+ * Primary color for branding
13
+ */
14
+ primaryColor?: string;
15
+ /**
16
+ * Application name
17
+ */
18
+ appName?: string;
19
+ /**
20
+ * Logo URL or component
21
+ */
22
+ logo?: string | React.ReactNode;
23
+ /**
24
+ * API base URL
25
+ */
26
+ apiBaseUrl?: string;
27
+ /**
28
+ * Custom styling
29
+ */
30
+ className?: string;
31
+ /**
32
+ * Required fields
33
+ */
34
+ requiredFields?: string[];
35
+ }
36
+ /**
37
+ * Account creation form props
38
+ */
39
+ export interface AccountCreationFormProps {
40
+ /**
41
+ * Configuration options
42
+ */
43
+ config?: AccountCreationFormConfig;
44
+ /**
45
+ * Success callback
46
+ */
47
+ onSuccess?: () => void;
48
+ /**
49
+ * Error callback
50
+ */
51
+ onError?: (error: string) => void;
52
+ /**
53
+ * Back to login callback
54
+ */
55
+ onBackToLogin?: () => void;
56
+ }
57
+ /**
58
+ * Professional account creation form component
59
+ */
60
+ export declare function AccountCreationForm({ config, onSuccess, onError, onBackToLogin }: AccountCreationFormProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Login Form Component for React
3
+ *
4
+ * Professional login form with dynamic styling based on environment variables
5
+ */
6
+ import React from 'react';
7
+ /**
8
+ * Login form configuration
9
+ */
10
+ export interface LoginFormConfig {
11
+ /**
12
+ * Primary color for branding
13
+ */
14
+ primaryColor?: string;
15
+ /**
16
+ * Secondary color for accents
17
+ */
18
+ secondaryColor?: string;
19
+ /**
20
+ * Application name
21
+ */
22
+ appName?: string;
23
+ /**
24
+ * Logo URL or component
25
+ */
26
+ logo?: string | React.ReactNode;
27
+ /**
28
+ * Show password reset link
29
+ */
30
+ showPasswordReset?: boolean;
31
+ /**
32
+ * Show account creation link
33
+ */
34
+ showAccountCreation?: boolean;
35
+ /**
36
+ * Custom styling
37
+ */
38
+ className?: string;
39
+ /**
40
+ * Redirect path after successful login
41
+ */
42
+ redirectPath?: string;
43
+ }
44
+ /**
45
+ * Login form props
46
+ */
47
+ export interface LoginFormProps {
48
+ /**
49
+ * Configuration options
50
+ */
51
+ config?: LoginFormConfig;
52
+ /**
53
+ * Success callback
54
+ */
55
+ onSuccess?: (user: any) => void;
56
+ /**
57
+ * Error callback
58
+ */
59
+ onError?: (error: string) => void;
60
+ /**
61
+ * Password reset callback
62
+ */
63
+ onPasswordReset?: () => void;
64
+ /**
65
+ * Account creation callback
66
+ */
67
+ onAccountCreation?: () => void;
68
+ /**
69
+ * Pubflow instance ID
70
+ */
71
+ instanceId?: string;
72
+ }
73
+ /**
74
+ * Professional login form component
75
+ */
76
+ export declare function LoginForm({ config, onSuccess, onError, onPasswordReset, onAccountCreation, instanceId }: LoginFormProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Password Reset Form Component for React
3
+ *
4
+ * Professional password reset form with step-by-step flow
5
+ */
6
+ import React from 'react';
7
+ /**
8
+ * Password reset form configuration
9
+ */
10
+ export interface PasswordResetFormConfig {
11
+ /**
12
+ * Primary color for branding
13
+ */
14
+ primaryColor?: string;
15
+ /**
16
+ * Application name
17
+ */
18
+ appName?: string;
19
+ /**
20
+ * Logo URL or component
21
+ */
22
+ logo?: string | React.ReactNode;
23
+ /**
24
+ * API base URL
25
+ */
26
+ apiBaseUrl?: string;
27
+ /**
28
+ * Custom styling
29
+ */
30
+ className?: string;
31
+ }
32
+ /**
33
+ * Password reset form props
34
+ */
35
+ export interface PasswordResetFormProps {
36
+ /**
37
+ * Configuration options
38
+ */
39
+ config?: PasswordResetFormConfig;
40
+ /**
41
+ * Success callback
42
+ */
43
+ onSuccess?: () => void;
44
+ /**
45
+ * Error callback
46
+ */
47
+ onError?: (error: string) => void;
48
+ /**
49
+ * Back to login callback
50
+ */
51
+ onBackToLogin?: () => void;
52
+ /**
53
+ * Reset token from URL (for reset step)
54
+ */
55
+ resetToken?: string;
56
+ }
57
+ /**
58
+ * Professional password reset form component
59
+ */
60
+ export declare function PasswordResetForm({ config, onSuccess, onError, onBackToLogin, resetToken }: PasswordResetFormProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Authentication Components
3
+ *
4
+ * Export all authentication-related components
5
+ */
6
+ export * from './LoginForm';
7
+ export * from './PasswordResetForm';
8
+ export * from './AccountCreationForm';
@@ -0,0 +1,255 @@
1
+ /**
2
+ * Theme Provider for React
3
+ *
4
+ * Provides dynamic styling system based on environment variables
5
+ */
6
+ import { ReactNode } from 'react';
7
+ /**
8
+ * Theme configuration interface
9
+ */
10
+ export interface ThemeConfig {
11
+ /**
12
+ * Primary color for branding
13
+ */
14
+ primaryColor: string;
15
+ /**
16
+ * Secondary color for accents
17
+ */
18
+ secondaryColor: string;
19
+ /**
20
+ * Application name
21
+ */
22
+ appName: string;
23
+ /**
24
+ * Logo URL or component
25
+ */
26
+ logo?: string | ReactNode;
27
+ /**
28
+ * Success color
29
+ */
30
+ successColor: string;
31
+ /**
32
+ * Error color
33
+ */
34
+ errorColor: string;
35
+ /**
36
+ * Warning color
37
+ */
38
+ warningColor: string;
39
+ /**
40
+ * Background colors
41
+ */
42
+ backgroundColor: string;
43
+ surfaceColor: string;
44
+ /**
45
+ * Text colors
46
+ */
47
+ textPrimary: string;
48
+ textSecondary: string;
49
+ textMuted: string;
50
+ /**
51
+ * Border colors
52
+ */
53
+ borderColor: string;
54
+ borderColorFocus: string;
55
+ /**
56
+ * Shadow colors
57
+ */
58
+ shadowColor: string;
59
+ /**
60
+ * Font family
61
+ */
62
+ fontFamily: string;
63
+ /**
64
+ * Border radius
65
+ */
66
+ borderRadius: {
67
+ small: string;
68
+ medium: string;
69
+ large: string;
70
+ };
71
+ /**
72
+ * Spacing
73
+ */
74
+ spacing: {
75
+ xs: string;
76
+ sm: string;
77
+ md: string;
78
+ lg: string;
79
+ xl: string;
80
+ };
81
+ }
82
+ /**
83
+ * Theme provider props
84
+ */
85
+ export interface ThemeProviderProps {
86
+ children: ReactNode;
87
+ theme?: Partial<ThemeConfig>;
88
+ }
89
+ /**
90
+ * Theme provider component
91
+ */
92
+ export declare function ThemeProvider({ children, theme }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
93
+ /**
94
+ * Hook to use theme
95
+ */
96
+ export declare function useTheme(): ThemeConfig;
97
+ /**
98
+ * Generate CSS variables from theme
99
+ */
100
+ export declare function generateCSSVariables(theme: ThemeConfig): Record<string, string>;
101
+ /**
102
+ * CSS-in-JS style generator
103
+ */
104
+ export declare function createStyles(theme: ThemeConfig): {
105
+ container: {
106
+ maxWidth: string;
107
+ margin: string;
108
+ padding: string;
109
+ backgroundColor: string;
110
+ borderRadius: string;
111
+ boxShadow: string;
112
+ border: string;
113
+ fontFamily: string;
114
+ };
115
+ logoSection: {
116
+ textAlign: "center";
117
+ marginBottom: string;
118
+ };
119
+ logo: {
120
+ maxWidth: string;
121
+ height: string;
122
+ marginBottom: string;
123
+ };
124
+ title: {
125
+ fontSize: string;
126
+ fontWeight: string;
127
+ color: string;
128
+ marginBottom: string;
129
+ letterSpacing: string;
130
+ };
131
+ subtitle: {
132
+ fontSize: string;
133
+ color: string;
134
+ fontWeight: string;
135
+ marginBottom: string;
136
+ };
137
+ inputGroup: {
138
+ marginBottom: string;
139
+ };
140
+ inputLabel: {
141
+ fontSize: string;
142
+ fontWeight: string;
143
+ color: string;
144
+ marginBottom: string;
145
+ letterSpacing: string;
146
+ display: string;
147
+ };
148
+ inputContainer: {
149
+ position: "relative";
150
+ display: string;
151
+ alignItems: string;
152
+ backgroundColor: string;
153
+ borderRadius: string;
154
+ border: string;
155
+ padding: string;
156
+ height: string;
157
+ boxShadow: string;
158
+ transition: string;
159
+ };
160
+ inputContainerFocus: {
161
+ borderColor: string;
162
+ };
163
+ input: {
164
+ flex: number;
165
+ fontSize: string;
166
+ color: string;
167
+ border: string;
168
+ outline: string;
169
+ backgroundColor: string;
170
+ fontWeight: string;
171
+ };
172
+ button: {
173
+ width: string;
174
+ borderRadius: string;
175
+ height: string;
176
+ backgroundColor: string;
177
+ color: string;
178
+ fontSize: string;
179
+ fontWeight: string;
180
+ border: string;
181
+ cursor: string;
182
+ marginTop: string;
183
+ boxShadow: string;
184
+ letterSpacing: string;
185
+ display: string;
186
+ alignItems: string;
187
+ justifyContent: string;
188
+ gap: string;
189
+ transition: string;
190
+ };
191
+ buttonSecondary: {
192
+ backgroundColor: string;
193
+ boxShadow: string;
194
+ };
195
+ buttonDisabled: {
196
+ opacity: number;
197
+ cursor: string;
198
+ };
199
+ linkButton: {
200
+ background: string;
201
+ border: string;
202
+ color: string;
203
+ fontSize: string;
204
+ fontWeight: string;
205
+ cursor: string;
206
+ textDecoration: string;
207
+ padding: string;
208
+ textAlign: "center";
209
+ };
210
+ errorContainer: {
211
+ display: string;
212
+ alignItems: string;
213
+ backgroundColor: string;
214
+ padding: string;
215
+ borderRadius: string;
216
+ marginBottom: string;
217
+ border: string;
218
+ };
219
+ successContainer: {
220
+ display: string;
221
+ alignItems: string;
222
+ backgroundColor: string;
223
+ padding: string;
224
+ borderRadius: string;
225
+ marginBottom: string;
226
+ border: string;
227
+ };
228
+ warningContainer: {
229
+ display: string;
230
+ alignItems: string;
231
+ backgroundColor: string;
232
+ padding: string;
233
+ borderRadius: string;
234
+ marginBottom: string;
235
+ border: string;
236
+ };
237
+ errorText: {
238
+ color: string;
239
+ fontSize: string;
240
+ marginLeft: string;
241
+ fontWeight: string;
242
+ };
243
+ successText: {
244
+ color: string;
245
+ fontSize: string;
246
+ marginLeft: string;
247
+ fontWeight: string;
248
+ };
249
+ warningText: {
250
+ color: string;
251
+ fontSize: string;
252
+ marginLeft: string;
253
+ fontWeight: string;
254
+ };
255
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Theme Components
3
+ *
4
+ * Export all theme-related components and utilities
5
+ */
6
+ export * from './ThemeProvider';
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Pubflow Provider for React
3
+ *
4
+ * Provides a context provider for Pubflow in React applications
5
+ */
6
+ import React from 'react';
7
+ import { PubflowInstanceConfig, ApiClient, AuthService, User } from '@pubflow/core';
8
+ /**
9
+ * Pubflow context value
10
+ */
11
+ export interface PubflowContextValue {
12
+ instances: Record<string, PubflowInstance>;
13
+ defaultInstance: string;
14
+ }
15
+ /**
16
+ * Pubflow instance
17
+ */
18
+ export interface PubflowInstance {
19
+ config: PubflowInstanceConfig;
20
+ apiClient: ApiClient;
21
+ authService: AuthService;
22
+ user: User | null | undefined;
23
+ isAuthenticated: boolean;
24
+ isLoading: boolean;
25
+ login: (credentials: {
26
+ email?: string;
27
+ userName?: string;
28
+ password: string;
29
+ }) => Promise<any>;
30
+ logout: () => Promise<void>;
31
+ validateSession: () => Promise<{
32
+ isValid: boolean;
33
+ expiresAt?: string;
34
+ user?: User;
35
+ }>;
36
+ }
37
+ /**
38
+ * Create Pubflow context
39
+ */
40
+ export declare const PubflowContext: React.Context<PubflowContextValue>;
41
+ /**
42
+ * Persistent cache configuration
43
+ */
44
+ export interface PersistentCacheConfig {
45
+ /**
46
+ * Whether to enable persistent cache
47
+ */
48
+ enabled: boolean;
49
+ /**
50
+ * Cache provider function
51
+ */
52
+ provider?: () => Map<any, any>;
53
+ /**
54
+ * Cache options
55
+ */
56
+ options?: any;
57
+ }
58
+ /**
59
+ * Pubflow provider props
60
+ */
61
+ export interface PubflowProviderProps {
62
+ children: React.ReactNode;
63
+ config?: PubflowInstanceConfig;
64
+ instances?: PubflowInstanceConfig[];
65
+ defaultInstance?: string;
66
+ onSessionExpired?: () => void;
67
+ onSessionRefreshed?: () => void;
68
+ showSessionAlerts?: boolean;
69
+ /**
70
+ * Persistent cache configuration
71
+ */
72
+ persistentCache?: PersistentCacheConfig;
73
+ /**
74
+ * Login redirect path (for automatic redirects)
75
+ */
76
+ loginRedirectPath?: string;
77
+ /**
78
+ * Public paths that don't require authentication
79
+ */
80
+ publicPaths?: string[];
81
+ /**
82
+ * Enable debug tools
83
+ * When enabled, debug utilities will be available
84
+ * Default: false
85
+ */
86
+ enableDebugTools?: boolean;
87
+ /**
88
+ * Theme configuration
89
+ */
90
+ theme?: {
91
+ primaryColor?: string;
92
+ secondaryColor?: string;
93
+ appName?: string;
94
+ logo?: string | React.ReactNode;
95
+ };
96
+ }
97
+ /**
98
+ * Pubflow provider for React
99
+ */
100
+ export declare function PubflowProvider({ children, config, instances, defaultInstance, onSessionExpired, onSessionRefreshed, showSessionAlerts, persistentCache, loginRedirectPath, publicPaths, enableDebugTools, theme }: PubflowProviderProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Authentication Hook for React
3
+ *
4
+ * Provides a hook for accessing authentication functionality
5
+ */
6
+ import { User } from '@pubflow/core';
7
+ /**
8
+ * Authentication hook result
9
+ */
10
+ export interface UseAuthResult {
11
+ user: User | null;
12
+ isAuthenticated: boolean;
13
+ isLoading: boolean;
14
+ login: (credentials: {
15
+ email?: string;
16
+ userName?: string;
17
+ password: string;
18
+ }) => Promise<any>;
19
+ logout: () => Promise<void>;
20
+ validateSession: () => Promise<{
21
+ isValid: boolean;
22
+ expiresAt?: string;
23
+ }>;
24
+ refreshUser: () => Promise<User | null>;
25
+ }
26
+ /**
27
+ * Hook for accessing authentication functionality
28
+ *
29
+ * @param instanceId Pubflow instance ID
30
+ * @returns Authentication hook result
31
+ */
32
+ export declare function useAuth(instanceId?: string): UseAuthResult;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Bridge API Hook for React
3
+ *
4
+ * Provides a hook for accessing Bridge API functionality
5
+ */
6
+ import { BridgeApiService, EntityConfig, EntityData } from '@pubflow/core';
7
+ /**
8
+ * Hook for accessing Bridge API functionality
9
+ *
10
+ * @param config Entity configuration
11
+ * @param instanceId Pubflow instance ID
12
+ * @returns Bridge API service
13
+ */
14
+ export declare function useBridgeApi<T extends EntityData>(config: EntityConfig, instanceId?: string): BridgeApiService<T>;