@sonic-equipment/ui 233.0.0 → 235.0.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.
@@ -9,6 +9,9 @@ export interface ErrorBoundaryProps {
9
9
  ignoreGlobalUnhandledErrors?: boolean;
10
10
  onError?: (error: Error, errorInfo: ErrorInfo, context: ErrorContext | undefined) => void;
11
11
  onReset?: () => void;
12
+ shouldCaptureError?: (error: Error, errorInfo?: React.ErrorInfo) => boolean;
12
13
  showErrorDetails?: boolean;
13
14
  }
14
- export declare function ErrorBoundary({ children, ...props }: ErrorBoundaryProps): import("react/jsx-runtime").JSX.Element;
15
+ export declare function ErrorBoundary({ children, persistError, ...props }: ErrorBoundaryProps & {
16
+ persistError?: boolean;
17
+ }): ReactNode;
@@ -63,7 +63,17 @@ class InternalErrorBoundary extends Component {
63
63
  };
64
64
  }
65
65
  componentDidCatch(error, errorInfo) {
66
- const { context, onError, showErrorDetails } = this.props;
66
+ const { context, onError, shouldCaptureError, showErrorDetails } = this.props;
67
+ if (shouldCaptureError && !shouldCaptureError(error, errorInfo)) {
68
+ return this.setState({
69
+ error: null,
70
+ errorCount: 0,
71
+ errorInfo: null,
72
+ hasError: false,
73
+ }, () => {
74
+ throw error;
75
+ });
76
+ }
67
77
  this.setState(prevState => ({
68
78
  errorCount: prevState.errorCount + 1,
69
79
  errorInfo,
@@ -115,8 +125,8 @@ Object.defineProperty(InternalErrorBoundary, "displayName", {
115
125
  writable: true,
116
126
  value: 'SonicErrorBoundary'
117
127
  });
118
- function ErrorBoundary({ children, ...props }) {
119
- return (jsx(InternalErrorBoundary, { ...props, children: props.ignoreGlobalUnhandledErrors ? (children) : (jsx(GlobalUnhandledErrorHandler, { context: props.context, children: children })) }));
128
+ function ErrorBoundary({ children, persistError = false, ...props }) {
129
+ return (jsx(InternalErrorBoundary, { ...props, children: props.ignoreGlobalUnhandledErrors ? (children) : (jsx(GlobalUnhandledErrorHandler, { context: props.context, children: children })) }, persistError ? undefined : Math.random().toString()));
120
130
  }
121
131
 
122
132
  export { ErrorBoundary };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "233.0.0",
3
+ "version": "235.0.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {