@abpjs/theme-shared 0.7.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.
Files changed (36) hide show
  1. package/LICENSE +165 -0
  2. package/README.md +568 -0
  3. package/dist/components/confirmation/Confirmation.d.ts +27 -0
  4. package/dist/components/confirmation/index.d.ts +1 -0
  5. package/dist/components/index.d.ts +4 -0
  6. package/dist/components/modal/Modal.d.ts +114 -0
  7. package/dist/components/modal/index.d.ts +1 -0
  8. package/dist/components/toast/Toast.d.ts +43 -0
  9. package/dist/components/toast/index.d.ts +1 -0
  10. package/dist/components/ui/Alert.d.ts +50 -0
  11. package/dist/components/ui/Button.d.ts +70 -0
  12. package/dist/components/ui/Checkbox.d.ts +64 -0
  13. package/dist/components/ui/FormField.d.ts +50 -0
  14. package/dist/components/ui/color-mode.d.ts +19 -0
  15. package/dist/components/ui/index.d.ts +16 -0
  16. package/dist/components/ui/provider.d.ts +2 -0
  17. package/dist/components/ui/toaster.d.ts +3 -0
  18. package/dist/components/ui/tooltip.d.ts +11 -0
  19. package/dist/contexts/confirmation.context.d.ts +100 -0
  20. package/dist/contexts/index.d.ts +2 -0
  21. package/dist/contexts/toaster.context.d.ts +91 -0
  22. package/dist/handlers/error.handler.d.ts +110 -0
  23. package/dist/handlers/index.d.ts +1 -0
  24. package/dist/hooks/index.d.ts +3 -0
  25. package/dist/index.d.ts +17 -0
  26. package/dist/index.js +1305 -0
  27. package/dist/index.mjs +1281 -0
  28. package/dist/models/confirmation.d.ts +21 -0
  29. package/dist/models/index.d.ts +2 -0
  30. package/dist/models/toaster.d.ts +48 -0
  31. package/dist/providers/ThemeSharedProvider.d.ts +135 -0
  32. package/dist/providers/index.d.ts +1 -0
  33. package/dist/theme/index.d.ts +42 -0
  34. package/dist/utils/index.d.ts +1 -0
  35. package/dist/utils/styles.d.ts +14 -0
  36. package/package.json +57 -0
@@ -0,0 +1,110 @@
1
+ import { Toaster } from '../models';
2
+ type NavigateFunction = (to: string) => void;
3
+ /**
4
+ * HTTP error response structure (matching ABP error format).
5
+ */
6
+ export interface HttpErrorResponse {
7
+ status: number;
8
+ statusText?: string;
9
+ error?: {
10
+ error?: {
11
+ message?: string;
12
+ details?: string;
13
+ code?: string;
14
+ validationErrors?: Array<{
15
+ message: string;
16
+ members: string[];
17
+ }>;
18
+ };
19
+ };
20
+ }
21
+ /**
22
+ * Error handler interface.
23
+ */
24
+ export interface ErrorHandler {
25
+ /** Handle an HTTP error response */
26
+ handleError: (error: HttpErrorResponse) => Promise<void>;
27
+ /** Show an error message in a confirmation dialog */
28
+ showError: (message: string, title?: string) => Promise<Toaster.Status>;
29
+ /** Navigate to the login page */
30
+ navigateToLogin: () => void;
31
+ }
32
+ export interface UseErrorHandlerOptions {
33
+ /**
34
+ * Custom navigate function. If not provided, navigation to login will be a no-op.
35
+ * Pass `useNavigate()` from react-router-dom if you want navigation support.
36
+ */
37
+ navigate?: NavigateFunction;
38
+ /**
39
+ * Custom login path. Defaults to '/account/login'.
40
+ */
41
+ loginPath?: string;
42
+ }
43
+ /**
44
+ * useErrorHandler - Hook for global error handling.
45
+ *
46
+ * This is the React equivalent of Angular's ErrorHandler service.
47
+ * It provides methods to handle HTTP errors and display error dialogs.
48
+ *
49
+ * @param options - Optional configuration including navigate function
50
+ *
51
+ * @example
52
+ * ```tsx
53
+ * import { useNavigate } from 'react-router-dom';
54
+ *
55
+ * function MyComponent() {
56
+ * const navigate = useNavigate();
57
+ * const errorHandler = useErrorHandler({ navigate });
58
+ *
59
+ * const handleApiCall = async () => {
60
+ * try {
61
+ * await fetchData();
62
+ * } catch (error) {
63
+ * await errorHandler.handleError(error as HttpErrorResponse);
64
+ * }
65
+ * };
66
+ *
67
+ * return <button onClick={handleApiCall}>Fetch</button>;
68
+ * }
69
+ * ```
70
+ *
71
+ * @example
72
+ * ```tsx
73
+ * // Without navigation (will only show error dialogs)
74
+ * function MyComponent() {
75
+ * const errorHandler = useErrorHandler();
76
+ * // 401 errors will show dialog but won't redirect
77
+ * }
78
+ * ```
79
+ */
80
+ export declare function useErrorHandler(options?: UseErrorHandlerOptions): ErrorHandler;
81
+ /**
82
+ * createErrorInterceptor - Creates an axios response error interceptor.
83
+ *
84
+ * This can be used to set up global error handling for axios.
85
+ *
86
+ * @param errorHandler - The error handler to use
87
+ * @returns An error interceptor function
88
+ *
89
+ * @example
90
+ * ```tsx
91
+ * function SetupInterceptors() {
92
+ * const errorHandler = useErrorHandler();
93
+ *
94
+ * useEffect(() => {
95
+ * const interceptor = axios.interceptors.response.use(
96
+ * (response) => response,
97
+ * createErrorInterceptor(errorHandler)
98
+ * );
99
+ *
100
+ * return () => {
101
+ * axios.interceptors.response.eject(interceptor);
102
+ * };
103
+ * }, [errorHandler]);
104
+ *
105
+ * return null;
106
+ * }
107
+ * ```
108
+ */
109
+ export declare function createErrorInterceptor(errorHandler: ErrorHandler): (error: unknown) => Promise<never>;
110
+ export default useErrorHandler;
@@ -0,0 +1 @@
1
+ export * from './error.handler';
@@ -0,0 +1,3 @@
1
+ export { useToaster, useToasts, useToasterContext } from '../contexts/toaster.context';
2
+ export { useConfirmation, useConfirmationState, useConfirmationContext } from '../contexts/confirmation.context';
3
+ export { useErrorHandler } from '../handlers/error.handler';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @abpjs/theme-shared
3
+ *
4
+ * ABP Framework Theme Shared components for React.
5
+ * Translated from @abp/ng.theme.shared v0.7.6
6
+ *
7
+ * This package provides shared UI components, services, and utilities
8
+ * for theme/modal management in ABP Framework React applications.
9
+ */
10
+ export * from './models';
11
+ export * from './contexts';
12
+ export * from './hooks';
13
+ export * from './components';
14
+ export * from './providers';
15
+ export * from './handlers';
16
+ export * from './utils';
17
+ export * from './theme';