@heritsilavo/react-error-boundary 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/next/CustomError.d.ts +5 -0
- package/dist/next/ErrorBoundary.d.ts +6 -0
- package/dist/next/ErrorContext.d.ts +19 -0
- package/dist/next/components/DefaultErrorComponents.d.ts +42 -0
- package/dist/next/index.d.ts +4 -0
- package/dist/next/index.js +4432 -0
- package/dist/next/index.js.map +1 -0
- package/dist/next/index.mjs +4425 -0
- package/dist/next/index.mjs.map +1 -0
- package/dist/react/index.js +4432 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/index.mjs +4425 -0
- package/dist/react/index.mjs.map +1 -0
- package/dist/react/next/CustomError.d.ts +5 -0
- package/dist/react/next/ErrorBoundary.d.ts +6 -0
- package/dist/react/next/ErrorContext.d.ts +19 -0
- package/dist/react/next/components/DefaultErrorComponents.d.ts +42 -0
- package/dist/react/next/index.d.ts +4 -0
- package/dist/react/react/CustomError.d.ts +5 -0
- package/dist/react/react/ErrorBoundary.d.ts +6 -0
- package/dist/react/react/ErrorContext.d.ts +19 -0
- package/dist/react/react/components/DefaultErrorComponents.d.ts +42 -0
- package/dist/react/react/index.d.ts +4 -0
- package/package.json +50 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { CustomError } from './CustomError';
|
3
|
+
import { ErrorComponentType } from './components/DefaultErrorComponents';
|
4
|
+
interface ContextType {
|
5
|
+
handleError: (error: Error) => void;
|
6
|
+
error: CustomError | null;
|
7
|
+
clearError: () => void;
|
8
|
+
}
|
9
|
+
interface ErrorProviderProps {
|
10
|
+
children: React.ReactNode;
|
11
|
+
ErrorComponent?: React.ComponentType<ErrorComponentType>;
|
12
|
+
autoHideDelay?: number;
|
13
|
+
onError?: () => void;
|
14
|
+
closeErrorComponetOnClick?: boolean;
|
15
|
+
}
|
16
|
+
export declare const ErrorProvider: React.FC<ErrorProviderProps>;
|
17
|
+
export declare const useError: () => ContextType;
|
18
|
+
export declare const useThrowError: () => (code: string, message: string, description: string) => void;
|
19
|
+
export {};
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import { z } from "zod";
|
2
|
+
import './style.css';
|
3
|
+
import React from "react";
|
4
|
+
declare const ErrorComponentPropsSchema: z.ZodObject<{
|
5
|
+
error: z.ZodObject<{
|
6
|
+
code: z.ZodString;
|
7
|
+
message: z.ZodString;
|
8
|
+
description: z.ZodOptional<z.ZodString>;
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
10
|
+
code: string;
|
11
|
+
message: string;
|
12
|
+
description?: string | undefined;
|
13
|
+
}, {
|
14
|
+
code: string;
|
15
|
+
message: string;
|
16
|
+
description?: string | undefined;
|
17
|
+
}>;
|
18
|
+
onClose: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodVoid>;
|
19
|
+
closeOnClick: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
20
|
+
visiblityTime: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
22
|
+
error: {
|
23
|
+
code: string;
|
24
|
+
message: string;
|
25
|
+
description?: string | undefined;
|
26
|
+
};
|
27
|
+
onClose: (...args: unknown[]) => void;
|
28
|
+
closeOnClick: boolean;
|
29
|
+
visiblityTime: number;
|
30
|
+
}, {
|
31
|
+
error: {
|
32
|
+
code: string;
|
33
|
+
message: string;
|
34
|
+
description?: string | undefined;
|
35
|
+
};
|
36
|
+
onClose: (...args: unknown[]) => void;
|
37
|
+
closeOnClick?: boolean | undefined;
|
38
|
+
visiblityTime?: number | undefined;
|
39
|
+
}>;
|
40
|
+
export type ErrorComponentType = z.infer<typeof ErrorComponentPropsSchema>;
|
41
|
+
export declare const DefaultErrorComponent: React.FC<ErrorComponentType>;
|
42
|
+
export default DefaultErrorComponent;
|