@stack-spot/portal-layout 0.0.9 → 0.0.10
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.
- package/dist/components/error/ErrorBoundary.d.ts +1 -0
- package/dist/components/error/ErrorBoundary.d.ts.map +1 -1
- package/dist/components/error/ErrorBoundary.js +4 -0
- package/dist/components/error/ErrorBoundary.js.map +1 -1
- package/dist/components/error/SilentErrorBoundary.d.ts +9 -3
- package/dist/components/error/SilentErrorBoundary.d.ts.map +1 -1
- package/dist/components/error/SilentErrorBoundary.js +22 -3
- package/dist/components/error/SilentErrorBoundary.js.map +1 -1
- package/package.json +1 -1
- package/src/components/error/ErrorBoundary.tsx +4 -0
- package/src/components/error/SilentErrorBoundary.tsx +26 -4
|
@@ -15,6 +15,7 @@ export declare class ErrorBoundary extends Component<Props, State> {
|
|
|
15
15
|
hasError: boolean;
|
|
16
16
|
};
|
|
17
17
|
componentDidCatch(error: any, errorInfo: any): void;
|
|
18
|
+
componentDidUpdate(prevProps: Readonly<Props>): void;
|
|
18
19
|
render(): string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<import("react").ReactNode> | null | undefined;
|
|
19
20
|
}
|
|
20
21
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorBoundary.d.ts","sourceRoot":"","sources":["../../../src/components/error/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,gBAAgB,EAAmB,MAAM,mBAAmB,CAAA;AAGrE,UAAU,KAAM,SAAQ,gBAAgB;IACtC,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,UAAU,KAAK;IACb,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,qBAAa,aAAc,SAAQ,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;gBAC5C,KAAK,EAAE,KAAK;IAKxB,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,GAAG;;;;;;IAI1C,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG;IAK5C,MAAM;CAKP"}
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.d.ts","sourceRoot":"","sources":["../../../src/components/error/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,gBAAgB,EAAmB,MAAM,mBAAmB,CAAA;AAGrE,UAAU,KAAM,SAAQ,gBAAgB;IACtC,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,UAAU,KAAK;IACb,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,qBAAa,aAAc,SAAQ,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;gBAC5C,KAAK,EAAE,KAAK;IAKxB,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,GAAG;;;;;;IAI1C,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG;IAK5C,kBAAkB,CAAC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC;IAI7C,MAAM;CAKP"}
|
|
@@ -14,6 +14,10 @@ export class ErrorBoundary extends Component {
|
|
|
14
14
|
// eslint-disable-next-line no-console
|
|
15
15
|
console.error(error, errorInfo);
|
|
16
16
|
}
|
|
17
|
+
componentDidUpdate(prevProps) {
|
|
18
|
+
if (this.props.children !== prevProps.children)
|
|
19
|
+
this.setState({ hasError: false });
|
|
20
|
+
}
|
|
17
21
|
render() {
|
|
18
22
|
return this.state.hasError
|
|
19
23
|
? _jsx(ErrorFeedback, { code: this.state.code, message: this.state.message, debug: this.state.debug })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../../../src/components/error/ErrorBoundary.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO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G,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAA;IAClC,CAAC;IAED,MAAM,CAAC,wBAAwB,CAAC,KAAU;QACxC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAA;IAC/D,CAAC;IAED,iBAAiB,CAAC,KAAU,EAAE,SAAc;QAC1C,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IACjC,CAAC;IAED,kBAAkB,CAAC,SAA0B;QAC3C,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,QAAQ;YAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA;IACpF,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ;YACxB,CAAC,CAAC,KAAC,aAAa,IAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAI;YAChG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAA;IACzB,CAAC;CACF"}
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
|
-
|
|
2
|
+
import { ErrorDescription } from './ErrorDescriptor';
|
|
3
|
+
interface State extends ErrorDescription {
|
|
3
4
|
hasError: boolean;
|
|
5
|
+
message?: string;
|
|
4
6
|
}
|
|
5
7
|
interface Props {
|
|
6
8
|
children: React.ReactNode;
|
|
7
9
|
}
|
|
8
10
|
export declare class SilentErrorBoundary extends Component<Props, State> {
|
|
9
11
|
constructor(props: Props);
|
|
10
|
-
static getDerivedStateFromError(): {
|
|
12
|
+
static getDerivedStateFromError(error: any): {
|
|
13
|
+
code?: number | undefined;
|
|
14
|
+
message?: string | undefined;
|
|
15
|
+
debug?: boolean | undefined;
|
|
11
16
|
hasError: boolean;
|
|
12
17
|
};
|
|
13
18
|
componentDidCatch(error: any, errorInfo: any): void;
|
|
14
|
-
|
|
19
|
+
componentDidUpdate(prevProps: Readonly<Props>): void;
|
|
20
|
+
render(): string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<import("react").ReactNode> | null | undefined;
|
|
15
21
|
}
|
|
16
22
|
export {};
|
|
17
23
|
//# sourceMappingURL=SilentErrorBoundary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SilentErrorBoundary.d.ts","sourceRoot":"","sources":["../../../src/components/error/SilentErrorBoundary.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SilentErrorBoundary.d.ts","sourceRoot":"","sources":["../../../src/components/error/SilentErrorBoundary.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,gBAAgB,EAAmB,MAAM,mBAAmB,CAAA;AAErE,UAAU,KAAM,SAAQ,gBAAgB;IACtC,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,KAAK;IACb,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,qBAAa,mBAAoB,SAAQ,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;gBAClD,KAAK,EAAE,KAAK;IAKxB,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,GAAG;;;;;;IAI1C,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG;IAK5C,kBAAkB,CAAC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC;IAI7C,MAAM;CAoBP"}
|
|
@@ -1,19 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { theme } from '@stack-spot/portal-theme';
|
|
1
3
|
import { Component } from 'react';
|
|
4
|
+
import { ErrorDescriptor } from './ErrorDescriptor';
|
|
2
5
|
export class SilentErrorBoundary extends Component {
|
|
3
6
|
constructor(props) {
|
|
4
7
|
super(props);
|
|
5
8
|
this.state = { hasError: false };
|
|
6
9
|
}
|
|
7
|
-
static getDerivedStateFromError() {
|
|
8
|
-
return { hasError: true };
|
|
10
|
+
static getDerivedStateFromError(error) {
|
|
11
|
+
return { hasError: true, ...ErrorDescriptor.describe(error) };
|
|
9
12
|
}
|
|
10
13
|
componentDidCatch(error, errorInfo) {
|
|
11
14
|
// eslint-disable-next-line no-console
|
|
12
15
|
console.error(error, errorInfo);
|
|
13
16
|
}
|
|
17
|
+
componentDidUpdate(prevProps) {
|
|
18
|
+
if (this.props.children !== prevProps.children)
|
|
19
|
+
this.setState({ hasError: false });
|
|
20
|
+
}
|
|
14
21
|
render() {
|
|
15
22
|
return this.state.hasError
|
|
16
|
-
?
|
|
23
|
+
? _jsx("div", { title: this.state.message ? `Error: ${this.state.message}` : undefined, style: {
|
|
24
|
+
width: '16px',
|
|
25
|
+
height: '16px',
|
|
26
|
+
margin: '16px',
|
|
27
|
+
background: theme.color.danger[500],
|
|
28
|
+
color: theme.color.danger.contrastText,
|
|
29
|
+
display: this.state.debug ? 'flex' : 'none',
|
|
30
|
+
justifyContent: 'center',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
fontWeight: 'bold',
|
|
33
|
+
fontSize: '10px',
|
|
34
|
+
borderRadius: '50%',
|
|
35
|
+
}, children: "!" })
|
|
17
36
|
: this.props.children;
|
|
18
37
|
}
|
|
19
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SilentErrorBoundary.js","sourceRoot":"","sources":["../../../src/components/error/SilentErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"SilentErrorBoundary.js","sourceRoot":"","sources":["../../../src/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AAC,YAAY;oBACtC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;oBAC3C,cAAc,EAAE,QAAQ;oBACxB,UAAU,EAAE,QAAQ;oBACpB,UAAU,EAAE,MAAM;oBAClB,QAAQ,EAAE,MAAM;oBAChB,YAAY,EAAE,KAAK;iBACpB,kBACK;YACR,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAA;IACzB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -25,6 +25,10 @@ export class ErrorBoundary extends Component<Props, State> {
|
|
|
25
25
|
console.error(error, errorInfo)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
componentDidUpdate(prevProps: Readonly<Props>) {
|
|
29
|
+
if (this.props.children !== prevProps.children) this.setState({ hasError: false })
|
|
30
|
+
}
|
|
31
|
+
|
|
28
32
|
render() {
|
|
29
33
|
return this.state.hasError
|
|
30
34
|
? <ErrorFeedback code={this.state.code} message={this.state.message} debug={this.state.debug} />
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { theme } from '@stack-spot/portal-theme'
|
|
1
2
|
import { Component } from 'react'
|
|
3
|
+
import { ErrorDescription, ErrorDescriptor } from './ErrorDescriptor'
|
|
2
4
|
|
|
3
|
-
interface State {
|
|
5
|
+
interface State extends ErrorDescription {
|
|
4
6
|
hasError: boolean,
|
|
7
|
+
message?: string,
|
|
5
8
|
}
|
|
6
9
|
|
|
7
10
|
interface Props {
|
|
@@ -14,8 +17,8 @@ export class SilentErrorBoundary extends Component<Props, State> {
|
|
|
14
17
|
this.state = { hasError: false }
|
|
15
18
|
}
|
|
16
19
|
|
|
17
|
-
static getDerivedStateFromError() {
|
|
18
|
-
return { hasError: true }
|
|
20
|
+
static getDerivedStateFromError(error: any) {
|
|
21
|
+
return { hasError: true, ...ErrorDescriptor.describe(error) }
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
componentDidCatch(error: any, errorInfo: any) {
|
|
@@ -23,9 +26,28 @@ export class SilentErrorBoundary extends Component<Props, State> {
|
|
|
23
26
|
console.error(error, errorInfo)
|
|
24
27
|
}
|
|
25
28
|
|
|
29
|
+
componentDidUpdate(prevProps: Readonly<Props>) {
|
|
30
|
+
if (this.props.children !== prevProps.children) this.setState({ hasError: false })
|
|
31
|
+
}
|
|
32
|
+
|
|
26
33
|
render() {
|
|
27
34
|
return this.state.hasError
|
|
28
|
-
?
|
|
35
|
+
? <div
|
|
36
|
+
title={this.state.message ? `Error: ${this.state.message}` : undefined}
|
|
37
|
+
style={{
|
|
38
|
+
width: '16px',
|
|
39
|
+
height: '16px',
|
|
40
|
+
margin: '16px',
|
|
41
|
+
background: theme.color.danger[500],
|
|
42
|
+
color: theme.color.danger.contrastText,
|
|
43
|
+
display: this.state.debug ? 'flex' : 'none',
|
|
44
|
+
justifyContent: 'center',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
fontWeight: 'bold',
|
|
47
|
+
fontSize: '10px',
|
|
48
|
+
borderRadius: '50%',
|
|
49
|
+
}}
|
|
50
|
+
>!</div>
|
|
29
51
|
: this.props.children
|
|
30
52
|
}
|
|
31
53
|
}
|