@equinor/fusion-react-errorboundary 0.1.9 → 1.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.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -13
  3. package/dist/index.d.ts +1 -11
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +1 -16
  6. package/dist/index.js.map +1 -1
  7. package/dist/legacy/ErrorBoundary.d.ts +6 -0
  8. package/dist/legacy/ErrorBoundary.d.ts.map +1 -0
  9. package/dist/legacy/ErrorBoundary.js +16 -0
  10. package/dist/legacy/ErrorBoundary.js.map +1 -0
  11. package/dist/legacy/Fallback.d.ts +14 -0
  12. package/dist/legacy/Fallback.d.ts.map +1 -0
  13. package/dist/legacy/Fallback.js +51 -0
  14. package/dist/legacy/Fallback.js.map +1 -0
  15. package/dist/legacy/FallbackIcon.d.ts +7 -0
  16. package/dist/legacy/FallbackIcon.d.ts.map +1 -0
  17. package/dist/legacy/FallbackIcon.js +31 -0
  18. package/dist/legacy/FallbackIcon.js.map +1 -0
  19. package/dist/legacy/fallbackRender.d.ts +6 -0
  20. package/dist/legacy/fallbackRender.d.ts.map +1 -0
  21. package/dist/legacy/fallbackRender.js +8 -0
  22. package/dist/legacy/fallbackRender.js.map +1 -0
  23. package/dist/legacy/index.d.ts +4 -0
  24. package/dist/legacy/index.d.ts.map +1 -0
  25. package/dist/legacy/index.js +4 -0
  26. package/dist/legacy/index.js.map +1 -0
  27. package/dist/legacy/types.d.ts +2 -0
  28. package/dist/legacy/types.d.ts.map +1 -0
  29. package/dist/legacy/types.js.map +1 -0
  30. package/package.json +41 -15
  31. package/dist/ErrorMessage.d.ts +0 -5
  32. package/dist/ErrorMessage.d.ts.map +0 -1
  33. package/dist/ErrorMessage.js +0 -56
  34. package/dist/ErrorMessage.js.map +0 -1
  35. package/dist/types.d.ts +0 -14
  36. package/dist/types.d.ts.map +0 -1
  37. package/dist/types.js.map +0 -1
  38. package/dist/useErrorStyles.d.ts +0 -3
  39. package/dist/useErrorStyles.d.ts.map +0 -1
  40. package/dist/useErrorStyles.js +0 -28
  41. package/dist/useErrorStyles.js.map +0 -1
  42. /package/dist/{types.js → legacy/types.js} +0 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Equinor
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,15 +1,5 @@
1
- # @equinor/fusion-react-errorboundary
1
+ Display a Error message if error is thrown in children
2
2
 
3
- [![Published on npm](https://img.shields.io/npm/v/@equinor/fusion-react-errorboundary.svg)](https://www.npmjs.com/package/@equinor/fusion-react-errorboundary)
3
+ > this component uses the `react-error-boundary` with a predefined `Fallback`
4
4
 
5
- [Storybook](https://equinor.github.io/fusion-react-components/?path=/docs/errorboundary)
6
-
7
- ## Installation
8
-
9
- ```sh
10
- npm install @equinor/fusion-react-errorboundary
11
- ```
12
-
13
- ### Description
14
-
15
- Display a Error message if error is trown in children
5
+ atm this component is under `@equinor/fusion-react-errorboundary/legacy` since there is a WIP to create a generic component in the future
package/dist/index.d.ts CHANGED
@@ -1,12 +1,2 @@
1
- import { Component, PropsWithChildren } from 'react';
2
- import type { ErrorBoundaryProps } from './types';
3
- export { ErrorBoundaryProps } from './types';
4
- export declare class ErrorBoundary extends Component<PropsWithChildren<ErrorBoundaryProps>> {
5
- state: {
6
- hasError: boolean;
7
- };
8
- componentDidCatch(): void;
9
- render(): JSX.Element;
10
- }
11
- export default ErrorBoundary;
1
+ export * from 'react-error-boundary';
12
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAGrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,qBAAa,aAAc,SAAQ,SAAS,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;IACjF,KAAK;;MAAuB;IAE5B,iBAAiB;IAIjB,MAAM;CAOP;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -1,17 +1,2 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Component } from 'react';
3
- import ErrorMessage from './ErrorMessage';
4
- export class ErrorBoundary extends Component {
5
- constructor() {
6
- super(...arguments);
7
- this.state = { hasError: false };
8
- }
9
- componentDidCatch() {
10
- this.setState({ hasError: true });
11
- }
12
- render() {
13
- return (_jsx(ErrorMessage, { hasError: this.state.hasError, ...this.props, children: this.props.children }));
14
- }
15
- }
16
- export default ErrorBoundary;
1
+ export * from 'react-error-boundary';
17
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAqB,MAAM,OAAO,CAAC;AAErD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAK1C,MAAM,OAAO,aAAc,SAAQ,SAAgD;IAAnF;;QACE,UAAK,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAa9B,CAAC;IAXC,iBAAiB;QACf,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACpC,CAAC;IAED,MAAM;QACJ,OAAO,CACL,KAAC,YAAY,IAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,KAAM,IAAI,CAAC,KAAK,YACxD,IAAI,CAAC,KAAK,CAAC,QAAQ,GACP,CAChB,CAAC;IACJ,CAAC;CACF;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { ErrorBoundaryProps as ReactReactErrorBoundary } from 'react-error-boundary';
3
+ export type ErrorBoundaryProps = Partial<ReactReactErrorBoundary>;
4
+ export declare const ErrorBoundary: (props: ErrorBoundaryProps) => JSX.Element;
5
+ export default ErrorBoundary;
6
+ //# sourceMappingURL=ErrorBoundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorBoundary.d.ts","sourceRoot":"","sources":["../../src/legacy/ErrorBoundary.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,kBAAkB,IAAI,uBAAuB,EAC9C,MAAM,sBAAsB,CAAC;AAG9B,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAIlE,eAAO,MAAM,aAAa,UAAW,kBAAkB,KAAG,WASzD,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ErrorBoundary as ReactErrorBoundary, } from 'react-error-boundary';
3
+ import { fallbackRender } from './fallbackRender';
4
+ const reload = () => window.location.reload();
5
+ export const ErrorBoundary = (props) => {
6
+ const args = { ...props };
7
+ if (!args.fallbackRender && !args.FallbackComponent && !args.fallback) {
8
+ args.fallbackRender = fallbackRender;
9
+ }
10
+ if (!args.onReset) {
11
+ args.onReset = reload;
12
+ }
13
+ return _jsx(ReactErrorBoundary, { ...args });
14
+ };
15
+ export default ErrorBoundary;
16
+ //# sourceMappingURL=ErrorBoundary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../../src/legacy/ErrorBoundary.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,IAAI,kBAAkB,GAEpC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIlD,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;AAE9C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAyB,EAAe,EAAE;IACtE,MAAM,IAAI,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC;IAC1B,IAAI,CAAC,IAAI,CAAC,cAAc,IAAI,CAAC,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;QACrE,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;KACtC;IACD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;QACjB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;KACvB;IACD,OAAO,KAAC,kBAAkB,OAAM,IAAgC,GAAI,CAAC;AACvE,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ import type { ErrorType } from './types';
3
+ export type FallbackProps = {
4
+ readonly error: unknown;
5
+ readonly errorType?: ErrorType;
6
+ readonly message?: React.ReactNode;
7
+ readonly resourceName?: string;
8
+ readonly title?: React.ReactNode;
9
+ readonly icon?: React.ReactNode;
10
+ readonly action?: string;
11
+ readonly onTakeAction?: (event?: React.SyntheticEvent<Element, Event>) => void;
12
+ };
13
+ export declare const Fallback: (props: FallbackProps) => JSX.Element;
14
+ //# sourceMappingURL=Fallback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Fallback.d.ts","sourceRoot":"","sources":["../../src/legacy/Fallback.tsx"],"names":[],"mappings":";AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAsBzC,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACnC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,IAAI,CAAC;CAChF,CAAC;AAmBF,eAAO,MAAM,QAAQ,UAAW,aAAa,KAAG,WAoC/C,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Typography, Button, Accordion } from '@equinor/eds-core-react';
3
+ import { tokens } from '@equinor/eds-tokens';
4
+ import { styled } from 'styled-components';
5
+ import { FallbackIcon } from './FallbackIcon';
6
+ import { useCallback } from 'react';
7
+ import { useErrorBoundary } from 'react-error-boundary';
8
+ const Styled = {
9
+ root: styled.div `
10
+ display: flex;
11
+ flex-flow: column;
12
+ align-items: center;
13
+ gap: ${tokens.spacings.comfortable.medium};
14
+ `,
15
+ stacktrace: styled.pre `
16
+ overflow: auto;
17
+ max-width: 100%;
18
+ color: ${tokens.colors.interactive.danger__resting.hex};
19
+ font-size: 0.8em;
20
+ line-height: 1em;
21
+ margin: 0;
22
+ `,
23
+ };
24
+ const generateTitle = (errorType, resourceName = '<unknown resource>') => {
25
+ switch (errorType) {
26
+ case 'accessDenied':
27
+ return "It seems like you don't have access to this content";
28
+ case 'notFound':
29
+ return `The ${resourceName} could not be found`;
30
+ case 'noData':
31
+ return `Unfortunately, we could not find any data for this component`;
32
+ case 'failedDependency': // 424
33
+ return `Unfortunately, we had problem with communicate with dependent system, ${resourceName}`;
34
+ case 'throttle': // 429
35
+ return `Unfortunately, we experience too many request for resource ${resourceName}`;
36
+ default:
37
+ return 'Oops! Something went wrong!';
38
+ }
39
+ };
40
+ export const Fallback = (props) => {
41
+ const { errorType, resourceName, title, message, error, action, onTakeAction } = props;
42
+ const { resetBoundary } = useErrorBoundary();
43
+ const onClick = useCallback(() => {
44
+ if (onTakeAction) {
45
+ onTakeAction();
46
+ }
47
+ resetBoundary();
48
+ }, [resetBoundary, onTakeAction]);
49
+ return (_jsx(Styled.root, { children: _jsxs(_Fragment, { children: [props.icon ?? _jsx(FallbackIcon, { errorType: errorType }), _jsx(Typography, { variant: "h3", children: title ?? generateTitle(errorType, resourceName) }), _jsx(Typography, { variant: "ingress", token: { color: tokens.colors.text.static_icons__tertiary.hex }, children: message ?? error.message }), action && (_jsx(Button, { variant: "outlined", onClick: onClick, children: action })), error && (_jsx(Accordion, { headerLevel: "h5", chevronPosition: "right", style: { width: '100%' }, children: _jsxs(Accordion.Item, { children: [_jsx(Accordion.Header, { style: { height: 'auto' }, children: "Error details" }), _jsx(Accordion.Panel, { children: _jsx(Styled.stacktrace, { children: error.stack }) })] }) }))] }) }));
50
+ };
51
+ //# sourceMappingURL=Fallback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Fallback.js","sourceRoot":"","sources":["../../src/legacy/Fallback.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,MAAM,GAAG;IACb,IAAI,EAAE,MAAM,CAAC,GAAG,CAAA;;;;WAIP,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM;GAC1C;IACD,UAAU,EAAE,MAAM,CAAC,GAAG,CAAA;;;aAGX,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,GAAG;;;;GAIvD;CACF,CAAC;AAaF,MAAM,aAAa,GAAG,CAAC,SAAqB,EAAE,YAAY,GAAG,oBAAoB,EAAE,EAAE;IACnF,QAAQ,SAAS,EAAE;QACjB,KAAK,cAAc;YACjB,OAAO,qDAAqD,CAAC;QAC/D,KAAK,UAAU;YACb,OAAO,OAAO,YAAY,qBAAqB,CAAC;QAClD,KAAK,QAAQ;YACX,OAAO,8DAA8D,CAAC;QACxE,KAAK,kBAAkB,EAAE,MAAM;YAC7B,OAAO,yEAAyE,YAAY,EAAE,CAAC;QACjG,KAAK,UAAU,EAAE,MAAM;YACrB,OAAO,8DAA8D,YAAY,EAAE,CAAC;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BAAkC,EAC7E,KAAC,SAAS,CAAC,KAAK,cACd,KAAC,MAAM,CAAC,UAAU,cAAG,KAAe,CAAC,KAAK,GAAqB,GAC/C,IACH,GACP,CACb,IACA,GACS,CACf,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import type { ErrorType } from './types';
3
+ export declare const FallbackIcon: (props: {
4
+ readonly errorType?: ErrorType;
5
+ }) => JSX.Element;
6
+ export default FallbackIcon;
7
+ //# sourceMappingURL=FallbackIcon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FallbackIcon.d.ts","sourceRoot":"","sources":["../../src/legacy/FallbackIcon.tsx"],"names":[],"mappings":";AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAazC,eAAO,MAAM,YAAY,UAAW;IAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAE,KAAG,WAcxE,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import { Icon } from '@equinor/eds-core-react';
4
+ import { tokens } from '@equinor/eds-tokens';
5
+ import { block, warning_outlined, sync_off } from '@equinor/eds-icons';
6
+ import { styled } from 'styled-components';
7
+ Icon.add({ block, warning_outlined, sync_off });
8
+ const Styled = {
9
+ icon: styled(Icon) `
10
+ height: 5rem;
11
+ width: 5rem;
12
+ color: ${tokens.colors.infographic.primary__energy_red_55.rgba};
13
+ `,
14
+ };
15
+ export const FallbackIcon = (props) => {
16
+ const name = useMemo(() => {
17
+ switch (props.errorType) {
18
+ case 'accessDenied':
19
+ return 'block';
20
+ case 'noData':
21
+ case 'failedDependency':
22
+ case 'throttle':
23
+ return 'sync_off';
24
+ default:
25
+ return 'warning_outlined';
26
+ }
27
+ }, [props.errorType]);
28
+ return _jsx(Styled.icon, { name: name });
29
+ };
30
+ export default FallbackIcon;
31
+ //# sourceMappingURL=FallbackIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FallbackIcon.js","sourceRoot":"","sources":["../../src/legacy/FallbackIcon.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAiB,MAAM,oBAAoB,CAAC;AAGtF,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,CAAC,CAAC;AAEhD,MAAM,MAAM,GAAG;IACb,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;;;aAGP,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,sBAAsB,CAAC,IAAI;GAC/D;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAyC,EAAe,EAAE;IACrF,MAAM,IAAI,GAAG,OAAO,CAAC,GAAa,EAAE;QAClC,QAAQ,KAAK,CAAC,SAAS,EAAE;YACvB,KAAK,cAAc;gBACjB,OAAO,OAAO,CAAC;YACjB,KAAK,QAAQ,CAAC;YACd,KAAK,kBAAkB,CAAC;YACxB,KAAK,UAAU;gBACb,OAAO,UAAU,CAAC;YACpB;gBACE,OAAO,kBAAkB,CAAC;SAC7B;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;IACtB,OAAO,KAAC,MAAM,CAAC,IAAI,IAAC,IAAI,EAAE,IAAI,GAAI,CAAC;AACrC,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { ErrorBoundaryProps } from 'react-error-boundary';
2
+ import { FallbackProps } from './Fallback';
3
+ export declare const fallbackRender: ErrorBoundaryProps['fallbackRender'];
4
+ export declare const createFallbackRender: (args?: Omit<FallbackProps, 'error'>) => ErrorBoundaryProps['fallbackRender'];
5
+ export default fallbackRender;
6
+ //# sourceMappingURL=fallbackRender.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fallbackRender.d.ts","sourceRoot":"","sources":["../../src/legacy/fallbackRender.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAErD,eAAO,MAAM,cAAc,EAAE,kBAAkB,CAAC,gBAAgB,CAA+C,CAAC;AAEhH,eAAO,MAAM,oBAAoB,UACvB,KAAK,aAAa,EAAE,OAAO,CAAC,KAAG,kBAAkB,CAAC,gBAAgB,CAErB,CAAC;AAExD,eAAe,cAAc,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Fallback } from './Fallback';
3
+ export const fallbackRender = (props) => _jsx(Fallback, { error: props.error });
4
+ export const createFallbackRender = (args) =>
5
+ /* eslint-disable-next-line react/display-name, react/function-component-definition, react/prop-types*/
6
+ (props) => _jsx(Fallback, { error: props.error, ...args });
7
+ export default fallbackRender;
8
+ //# sourceMappingURL=fallbackRender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fallbackRender.js","sourceRoot":"","sources":["../../src/legacy/fallbackRender.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,EAAiB,MAAM,YAAY,CAAC;AAErD,MAAM,CAAC,MAAM,cAAc,GAAyC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,CAAC,KAAK,GAAI,CAAC;AAEhH,MAAM,CAAC,MAAM,oBAAoB,GAC/B,CAAC,IAAmC,EAAwC,EAAE;AAC9E,uGAAuG;AACvG,CAAC,KAAK,EAAE,EAAE,CAAC,KAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,CAAC,KAAK,KAAM,IAAI,GAAI,CAAC;AAExD,eAAe,cAAc,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { ErrorBoundary, type ErrorBoundaryProps } from './ErrorBoundary';
2
+ export { Fallback, type FallbackProps } from './Fallback';
3
+ export { createFallbackRender } from './fallbackRender';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/legacy/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { ErrorBoundary } from './ErrorBoundary';
2
+ export { Fallback } from './Fallback';
3
+ export { createFallbackRender } from './fallbackRender';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/legacy/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA2B,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAsB,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type ErrorType = 'error' | 'accessDenied' | 'notFound' | 'noData' | 'failedDependency' | 'throttle';
2
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/legacy/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,cAAc,GAAG,UAAU,GAAG,QAAQ,GAAG,kBAAkB,GAAG,UAAU,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/legacy/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@equinor/fusion-react-errorboundary",
3
- "version": "0.1.9",
4
- "description": "React component for errorboundary",
3
+ "version": "1.0.0",
4
+ "description": "React component for error boundary",
5
5
  "keywords": [
6
- "errorboundary",
6
+ "error-boundary",
7
7
  "react",
8
8
  "fusion",
9
9
  "equinor"
@@ -11,6 +11,21 @@
11
11
  "homepage": "https://github.com/equinor/fusion-react-components/tree/master/packages/errorboundary#readme",
12
12
  "license": "ISC",
13
13
  "main": "dist/index.js",
14
+ "exports": {
15
+ ".": "./dist/index.js",
16
+ "./legacy": "./dist/legacy/index.js",
17
+ "./package.json": "./package.json",
18
+ "./README.md": "./README.md",
19
+ "./CHANGELOG.md": "./CHANGELOG.md"
20
+ },
21
+ "types": "dist/index.d.ts",
22
+ "typesVersions": {
23
+ "*": {
24
+ "legacy": [
25
+ "dist/legacy/index.d.ts"
26
+ ]
27
+ }
28
+ },
14
29
  "directories": {
15
30
  "dist": "dist"
16
31
  },
@@ -24,20 +39,31 @@
24
39
  "type": "git",
25
40
  "url": "git+https://github.com/equinor/fusion-react-components.git"
26
41
  },
27
- "scripts": {
28
- "build": "tsc -b",
29
- "lint": "eslint --ext .ts,.tsx,.js src/",
30
- "lint:fix": "eslint --ext .ts,.tsx,.js src/ --fix",
31
- "prepack": "npm run build"
32
- },
33
42
  "bugs": {
34
43
  "url": "https://github.com/equinor/fusion-react-components/issues"
35
44
  },
36
45
  "dependencies": {
37
- "@equinor/fusion-react-button": "^0.8.4",
38
- "@equinor/fusion-react-icon": "^0.2.17",
39
- "@equinor/fusion-react-styles": "^0.5.11",
40
- "@equinor/fusion-react-utils": "^2.0.5"
46
+ "@equinor/fusion-react-button": "^0.9.0",
47
+ "@equinor/fusion-react-icon": "^0.3.0",
48
+ "@equinor/fusion-react-styles": "^0.6.0",
49
+ "@equinor/fusion-react-utils": "^2.1.0",
50
+ "react-error-boundary": "^4.0.11"
41
51
  },
42
- "gitHead": "83a3bda4a059bb34609263bff7d17089ec6cd823"
43
- }
52
+ "devDependencies": {
53
+ "@equinor/eds-icons": "^0.19.3",
54
+ "@equinor/eds-tokens": "^0.9.2",
55
+ "@types/react": "^18.2.24",
56
+ "react": "^18.2.0",
57
+ "styled-components": "^6.1.1"
58
+ },
59
+ "peerDependencies": {
60
+ "@equinor/eds-core-react": "^0.34.0",
61
+ "@equinor/eds-icons": "^0.19.3",
62
+ "styled-components": "^6.1.1"
63
+ },
64
+ "scripts": {
65
+ "build": "tsc -b",
66
+ "lint": "eslint --ext .ts,.tsx,.js src/",
67
+ "lint:fix": "eslint --ext .ts,.tsx,.js src/ --fix"
68
+ }
69
+ }
@@ -1,5 +0,0 @@
1
- import { PropsWithChildren } from 'react';
2
- import type { ErrorBoundaryProps } from './types';
3
- export declare const ErrorMessage: ({ hasError, errorType, message, resourceName, title, children, icon, action, onTakeAction, }: PropsWithChildren<ErrorBoundaryProps>) => JSX.Element;
4
- export default ErrorMessage;
5
- //# sourceMappingURL=ErrorMessage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ErrorMessage.d.ts","sourceRoot":"","sources":["../src/ErrorMessage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAQnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,eAAO,MAAM,YAAY,iGAUtB,kBAAkB,kBAAkB,CAAC,KAAG,WAgE1C,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,56 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useMemo } from 'react';
3
- import { Button } from '@equinor/fusion-react-button';
4
- import { clsx } from '@equinor/fusion-react-styles';
5
- import { Icon } from '@equinor/fusion-react-icon';
6
- import useErrorStyles from './useErrorStyles';
7
- export const ErrorMessage = ({ hasError, errorType = 'error', message, resourceName, title, children, icon, action, onTakeAction, }) => {
8
- const styles = useErrorStyles();
9
- const getErrorMessageForType = (errorType) => {
10
- const iconProps = {
11
- width: 80,
12
- height: 80,
13
- cursor: 'default',
14
- color: '#666666',
15
- };
16
- switch (errorType) {
17
- case 'accessDenied':
18
- return {
19
- title: "It seems like you don't have access to this content",
20
- icon: _jsx(Icon, { icon: "block", ...iconProps }),
21
- };
22
- case 'notFound':
23
- return {
24
- title: `The ${resourceName} could not be found`,
25
- icon: _jsx(Icon, { icon: "warning_outlined", ...iconProps }),
26
- };
27
- case 'noData':
28
- return {
29
- title: `Unfortunately, we could not find any data for this component`,
30
- icon: _jsx(Icon, { icon: "sync_off", ...iconProps }),
31
- };
32
- case 'failedDependency': // 424
33
- return {
34
- title: `Unfortunately, we had problem with communicate with dependent system, ${resourceName}`,
35
- icon: _jsx(Icon, { icon: "sync_off", ...iconProps }),
36
- };
37
- case 'throttle': // 429
38
- return {
39
- title: `Unfortunately, we experience too many request for resource ${resourceName}`,
40
- icon: _jsx(Icon, { icon: "sync_off", ...iconProps }),
41
- };
42
- default:
43
- return {
44
- title: 'Oops! Something went wrong!',
45
- icon: _jsx(Icon, { icon: "warning_outlined", ...iconProps }),
46
- };
47
- }
48
- };
49
- const error = useMemo(() => getErrorMessageForType(errorType), [errorType]);
50
- if (!hasError) {
51
- return _jsx(_Fragment, { children: children });
52
- }
53
- return (_jsx("div", { className: styles.container, children: _jsxs("div", { className: clsx(styles.messageContainer, 'comfortable'), children: [_jsx("div", { className: styles.icon, children: icon || error.icon }), _jsx("div", { className: styles.title, children: title || error.title }), _jsx("div", { className: styles.message, children: message }), action ? (_jsx(Button, { variant: "outlined", onClick: onTakeAction, children: action })) : null] }) }));
54
- };
55
- export default ErrorMessage;
56
- //# sourceMappingURL=ErrorMessage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ErrorMessage.js","sourceRoot":"","sources":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react" />
2
- type ErrorTypes = 'error' | 'accessDenied' | 'notFound' | 'noData' | 'failedDependency' | 'throttle';
3
- export type ErrorBoundaryProps = {
4
- hasError?: boolean;
5
- errorType?: ErrorTypes;
6
- message?: string;
7
- resourceName?: string;
8
- title?: string;
9
- icon?: string;
10
- action?: string;
11
- onTakeAction?: (event?: React.SyntheticEvent<Element, Event>) => void;
12
- };
13
- export {};
14
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AACA,KAAK,UAAU,GAAG,OAAO,GAAG,cAAc,GAAG,UAAU,GAAG,QAAQ,GAAG,kBAAkB,GAAG,UAAU,CAAC;AAErG,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,IAAI,CAAC;CACvE,CAAC"}
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- declare const useErrorStyles: (props?: {} | undefined) => import("@equinor/fusion-react-styles").ClassNameMap<"container" | "icon" | "messageContainer" | "title" | "message">;
2
- export default useErrorStyles;
3
- //# sourceMappingURL=useErrorStyles.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useErrorStyles.d.ts","sourceRoot":"","sources":["../src/useErrorStyles.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,cAAc,kJA0BnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1,28 +0,0 @@
1
- import { createStyles, makeStyles } from '@equinor/fusion-react-styles';
2
- const useErrorStyles = makeStyles(() => createStyles({
3
- container: {
4
- display: 'flex',
5
- alignItems: 'center',
6
- justifyContent: 'center',
7
- width: '100%',
8
- height: '100%',
9
- },
10
- messageContainer: {
11
- textAlign: 'center',
12
- color: 'var(--color-primary-accent)',
13
- },
14
- icon: {
15
- color: 'rgb(102, 102, 102)',
16
- fontSize: 36,
17
- margiBottom: '1em',
18
- },
19
- title: {
20
- fontSize: 28,
21
- margin: '1em 0',
22
- },
23
- message: {
24
- fontSize: 20,
25
- },
26
- }));
27
- export default useErrorStyles;
28
- //# sourceMappingURL=useErrorStyles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useErrorStyles.js","sourceRoot":"","sources":["../src/useErrorStyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AACxE,MAAM,cAAc,GAAG,UAAU,CAAC,GAAG,EAAE,CACrC,YAAY,CAAC;IACX,SAAS,EAAE;QACT,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;QACxB,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;KACf;IACD,gBAAgB,EAAE;QAChB,SAAS,EAAE,QAAQ;QACnB,KAAK,EAAE,6BAA6B;KACrC;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,oBAAoB;QAC3B,QAAQ,EAAE,EAAE;QACZ,WAAW,EAAE,KAAK;KACnB;IACD,KAAK,EAAE;QACL,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,OAAO;KAChB;IACD,OAAO,EAAE;QACP,QAAQ,EAAE,EAAE;KACb;CACF,CAAC,CACH,CAAC;AAEF,eAAe,cAAc,CAAC"}
File without changes