@heritsilavo/react-error-boundary 2.1.0 → 2.1.2

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.
@@ -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";
@@ -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";
package/package.json CHANGED
@@ -1,56 +1,56 @@
1
- {
2
- "name": "@heritsilavo/react-error-boundary",
3
- "version": "2.1.0",
4
- "type": "module",
5
- "main": "./dist/react/index.js",
6
- "module": "./dist/react/index.mjs",
7
- "types": "./dist/react/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "import": "./dist/react/index.mjs",
11
- "require": "./dist/react/index.js",
12
- "types": "./dist/react/index.d.ts"
13
- },
14
- "./next": {
15
- "import": "./dist/next/index.mjs",
16
- "require": "./dist/next/index.js",
17
- "types": "./dist/next/index.d.ts"
18
- }
19
- },
20
- "keywords": [
21
- "react",
22
- "error",
23
- "boundary",
24
- "next",
25
- "typescript"
26
- ],
27
- "author": "heritsilavo (heritsilavo4835@gmail.com)",
28
- "license": "ISC",
29
- "description": "A React error boundary component for React and Next.js",
30
- "files": [
31
- "dist"
32
- ],
33
- "peerDependencies": {
34
- "next": "^13.0.0",
35
- "react": "^18.0.0",
36
- "react-dom": "^18.0.0"
37
- },
38
- "scripts": {
39
- "build:react": "rollup -c rollup.react.config.js",
40
- "build:next": "rollup -c rollup.next.config.js",
41
- "build": "npm run build:react && npm run build:next"
42
- },
43
- "devDependencies": {
44
- "@rollup/plugin-commonjs": "^24.0.0",
45
- "@rollup/plugin-node-resolve": "^15.0.0",
46
- "@rollup/plugin-typescript": "^11.0.0",
47
- "@types/react": "^18.0.0",
48
- "@types/react-dom": "^18.0.0",
49
- "rollup": "^3.20.0",
50
- "rollup-plugin-banner2": "^1.3.0",
51
- "rollup-plugin-peer-deps-external": "^2.2.4",
52
- "rollup-plugin-postcss": "^4.0.0",
53
- "tslib": "^2.8.1",
54
- "typescript": "^5.0.0"
55
- }
56
- }
1
+ {
2
+ "name": "@heritsilavo/react-error-boundary",
3
+ "version": "2.1.2",
4
+ "type": "module",
5
+ "main": "./dist/react/index.js",
6
+ "module": "./dist/react/index.mjs",
7
+ "types": "./dist/react/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/react/index.mjs",
11
+ "require": "./dist/react/index.js",
12
+ "types": "./dist/react/index.d.ts"
13
+ },
14
+ "./next": {
15
+ "import": "./dist/next/index.mjs",
16
+ "require": "./dist/next/index.js",
17
+ "types": "./dist/next/index.d.ts"
18
+ }
19
+ },
20
+ "keywords": [
21
+ "react",
22
+ "error",
23
+ "boundary",
24
+ "next",
25
+ "typescript"
26
+ ],
27
+ "author": "heritsilavo (heritsilavo4835@gmail.com)",
28
+ "license": "ISC",
29
+ "description": "A React error boundary component for React and Next.js",
30
+ "files": [
31
+ "dist"
32
+ ],
33
+ "peerDependencies": {
34
+ "next": "^15.3.1",
35
+ "react": "^18.0.0",
36
+ "react-dom": "^18.0.0"
37
+ },
38
+ "scripts": {
39
+ "build:react": "rollup -c rollup.react.config.js",
40
+ "build:next": "rollup -c rollup.next.config.js",
41
+ "build": "npm run build:react && npm run build:next"
42
+ },
43
+ "devDependencies": {
44
+ "@rollup/plugin-commonjs": "^24.0.0",
45
+ "@rollup/plugin-node-resolve": "^15.0.0",
46
+ "@rollup/plugin-typescript": "^11.0.0",
47
+ "@types/react": "^18.0.0",
48
+ "@types/react-dom": "^18.0.0",
49
+ "rollup": "^3.20.0",
50
+ "rollup-plugin-peer-deps-external": "^2.2.4",
51
+ "rollup-plugin-postcss": "^4.0.0",
52
+ "tslib": "^2.8.1",
53
+ "typescript": "^5.0.0",
54
+ "zod": "^3.23.8"
55
+ }
56
+ }