@heritsilavo/react-error-boundary 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ export declare class CustomError extends Error {
2
+ code: string;
3
+ description: string;
4
+ constructor(code: string, message: string, description: string);
5
+ }
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ type WrapperPropsType = {
3
+ children: React.ReactNode;
4
+ };
5
+ export declare const ErrorBoundary: React.FC<WrapperPropsType>;
6
+ export {};
@@ -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;
@@ -0,0 +1,4 @@
1
+ export * from "./CustomError";
2
+ export * from "./ErrorBoundary";
3
+ export * from "./ErrorContext";
4
+ export * from "./components/DefaultErrorComponents";