@stack-spot/portal-layout 0.0.9 → 0.0.11
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/Layout.d.ts +5 -3
- package/dist/Layout.d.ts.map +1 -1
- package/dist/Layout.js +12 -7
- package/dist/Layout.js.map +1 -1
- package/dist/LayoutOverlayManager.d.ts +3 -0
- package/dist/LayoutOverlayManager.d.ts.map +1 -1
- package/dist/LayoutOverlayManager.js +17 -3
- package/dist/LayoutOverlayManager.js.map +1 -1
- package/dist/components/error/ErrorBoundary.d.ts +2 -1
- package/dist/components/error/ErrorBoundary.d.ts.map +1 -1
- package/dist/components/error/ErrorBoundary.js +7 -2
- package/dist/components/error/ErrorBoundary.js.map +1 -1
- package/dist/components/error/ErrorFeedback.d.ts +1 -1
- package/dist/components/error/ErrorFeedback.d.ts.map +1 -1
- package/dist/components/error/ErrorManager.d.ts +16 -0
- package/dist/components/error/ErrorManager.d.ts.map +1 -0
- package/dist/components/error/ErrorManager.js +23 -0
- package/dist/components/error/ErrorManager.js.map +1 -0
- 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 +23 -3
- package/dist/components/error/SilentErrorBoundary.js.map +1 -1
- package/dist/layout.css +1 -1
- package/dist/toaster.d.ts.map +1 -1
- package/dist/toaster.js.map +1 -1
- package/package.json +4 -4
- package/src/Layout.tsx +13 -6
- package/src/LayoutOverlayManager.tsx +19 -4
- package/src/components/error/ErrorBoundary.tsx +7 -2
- package/src/components/error/ErrorFeedback.tsx +1 -1
- package/src/components/error/{ErrorDescriptor.ts → ErrorManager.ts} +11 -1
- package/src/components/error/SilentErrorBoundary.tsx +27 -4
- package/src/layout.css +1 -1
- package/src/toaster.tsx +1 -2
package/dist/Layout.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WithStyle } from '@stack-spot/portal-theme';
|
|
2
2
|
import '@stack-spot/portal-theme/dist/theme.css';
|
|
3
3
|
import { ReactElement, ReactNode } from 'react';
|
|
4
|
-
import { DescriptionFn } from './components/error/
|
|
4
|
+
import { DescriptionFn, ErrorHandler } from './components/error/ErrorManager';
|
|
5
5
|
import { HeaderProps } from './components/Header';
|
|
6
6
|
import { MenuProps } from './components/menu/types';
|
|
7
7
|
import './layout.css';
|
|
@@ -11,6 +11,7 @@ interface Props extends WithStyle {
|
|
|
11
11
|
children: ReactNode;
|
|
12
12
|
extra?: ReactNode;
|
|
13
13
|
errorDescriptor?: DescriptionFn;
|
|
14
|
+
onError?: ErrorHandler;
|
|
14
15
|
}
|
|
15
16
|
interface RawProps extends WithStyle {
|
|
16
17
|
menuSections?: ReactElement;
|
|
@@ -20,8 +21,9 @@ interface RawProps extends WithStyle {
|
|
|
20
21
|
compactMenu?: boolean;
|
|
21
22
|
extra?: ReactNode;
|
|
22
23
|
errorDescriptor?: DescriptionFn;
|
|
24
|
+
onError?: ErrorHandler;
|
|
23
25
|
}
|
|
24
|
-
export declare const RawLayout: ({ menuSections, menuContent, header, compactMenu, children, extra, errorDescriptor, className, style }: RawProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
-
export declare const Layout: ({ menu, header, children, extra, errorDescriptor, className, style }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export declare const RawLayout: ({ menuSections, menuContent, header, compactMenu, children, extra, errorDescriptor, onError, className, style }: RawProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export declare const Layout: ({ menu, header, children, extra, errorDescriptor, onError, className, style }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
26
28
|
export {};
|
|
27
29
|
//# sourceMappingURL=Layout.d.ts.map
|
package/dist/Layout.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../src/Layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmC,SAAS,EAAE,M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sxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { CSSToCitricAdapter, listToClass } from '@stack-spot/portal-theme';
|
|
3
3
|
import '@stack-spot/portal-theme/dist/theme.css';
|
|
4
|
+
import { useEffect } from 'react';
|
|
4
5
|
import { ErrorBoundary } from './components/error/ErrorBoundary';
|
|
5
|
-
import {
|
|
6
|
+
import { ErrorManager } from './components/error/ErrorManager';
|
|
6
7
|
import { SilentErrorBoundary } from './components/error/SilentErrorBoundary';
|
|
7
8
|
import { Header } from './components/Header';
|
|
8
9
|
import { MenuContent } from './components/menu/MenuContent';
|
|
@@ -10,7 +11,7 @@ import { MenuSections } from './components/menu/MenuSections';
|
|
|
10
11
|
import { Toaster } from './components/Toaster';
|
|
11
12
|
import './layout.css';
|
|
12
13
|
import { overlay } from './LayoutOverlayManager';
|
|
13
|
-
export const RawLayout = ({ menuSections, menuContent, header, compactMenu = true, children, extra, errorDescriptor, className, style }) => {
|
|
14
|
+
export const RawLayout = ({ menuSections, menuContent, header, compactMenu = true, children, extra, errorDescriptor, onError, className, style }) => {
|
|
14
15
|
// @ts-ignore
|
|
15
16
|
const { bottomDialog, modal, rightPanel } = overlay.useOverlays();
|
|
16
17
|
const classes = [
|
|
@@ -19,15 +20,19 @@ export const RawLayout = ({ menuSections, menuContent, header, compactMenu = tru
|
|
|
19
20
|
menuSections ? undefined : 'no-menu-sections',
|
|
20
21
|
className,
|
|
21
22
|
];
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (errorDescriptor)
|
|
25
|
+
ErrorManager.setDescriptionFunction(errorDescriptor);
|
|
26
|
+
if (onError)
|
|
27
|
+
ErrorManager.setErrorHandler(onError);
|
|
28
|
+
}, []);
|
|
29
|
+
return (_jsx(CSSToCitricAdapter, { children: _jsxs("div", { id: "layout", className: listToClass(classes), style: style, children: [_jsx("div", { id: "page", children: _jsx("article", { id: "content", children: _jsx(ErrorBoundary, { children: children }) }) }), extra && _jsx(SilentErrorBoundary, { children: extra }), _jsx("header", { id: "header", children: _jsx(SilentErrorBoundary, { children: header }) }), _jsxs("aside", { id: "menu", children: [_jsx("nav", { id: "menuContent", children: _jsx(SilentErrorBoundary, { children: menuContent }) }), menuSections && _jsx("nav", { id: "menuSections", children: _jsx(SilentErrorBoundary, { children: menuSections }) })] }), _jsx("div", { id: "bottomDialog", children: _jsx(ErrorBoundary, { children: bottomDialog }) }), _jsxs("div", { id: "backdrop", children: [_jsx("div", { id: "rightPanel", children: _jsx(ErrorBoundary, { children: rightPanel }) }), _jsx("div", { id: "modal", children: _jsx(ErrorBoundary, { children: modal }) })] }), _jsx(Toaster, {})] }) }));
|
|
25
30
|
};
|
|
26
31
|
const MenuContentRenderer = ({ content }) => {
|
|
27
32
|
const menuContent = typeof content === 'function' ? content() : content;
|
|
28
33
|
return _jsx(MenuContent, { ...menuContent });
|
|
29
34
|
};
|
|
30
|
-
export const Layout = ({ menu, header, children, extra, errorDescriptor, className, style }) => (_jsx(RawLayout, { header: _jsx(Header, { ...header }), menuSections: menu.sections ? _jsx(MenuSections, { ...menu }) : undefined, menuContent: menu.content
|
|
35
|
+
export const Layout = ({ menu, header, children, extra, errorDescriptor, onError, className, style }) => (_jsx(RawLayout, { header: _jsx(Header, { ...header }), menuSections: menu.sections ? _jsx(MenuSections, { ...menu }) : undefined, menuContent: menu.content
|
|
31
36
|
? _jsx(MenuContentRenderer, { content: menu.content }, 'contentKey' in menu ? menu.contentKey : undefined)
|
|
32
|
-
: undefined, compactMenu: menu.compact, errorDescriptor: errorDescriptor, extra: extra, className: className, style: style, children: children }));
|
|
37
|
+
: undefined, compactMenu: menu.compact, errorDescriptor: errorDescriptor, onError: onError, extra: extra, className: className, style: style, children: children }));
|
|
33
38
|
//# sourceMappingURL=Layout.js.map
|
package/dist/Layout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layout.js","sourceRoot":"","sources":["../src/Layout.tsx"],"names":[],"mappings":";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AAK,UAAU,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAA;IACvE,OAAO,KAAC,WAAW,OAAK,WAAW,GAAI,CAAA;AACzC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAS,EAAE,EAAE,CAAC,CAC9G,KAAC,SAAS,IACR,MAAM,EAAE,KAAC,MAAM,OAAK,MAAM,GAAI,EAC9B,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAC,YAAY,OAAK,IAAI,GAAI,CAAC,CAAC,CAAC,SAAS,EACpE,WAAW,EAAE,IAAI,CAAC,OAAO;QACvB,CAAC,CAAC,KAAC,mBAAmB,IAA0D,OAAO,EAAE,IAAI,CAAC,OAAO,IAAzE,YAAY,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAA2B;QACzG,CAAC,CAAC,SAAS,EAEb,WAAW,EAAE,IAAI,CAAC,OAAO,EACzB,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,YAEX,QAAQ,GACC,CACb,CAAA"}
|
|
@@ -23,6 +23,9 @@ declare class LayoutOverlayManager {
|
|
|
23
23
|
private onModalClose?;
|
|
24
24
|
private setupElements;
|
|
25
25
|
private useOverlays;
|
|
26
|
+
isModalOpen(): boolean;
|
|
27
|
+
isRightPanelOpen(): boolean;
|
|
28
|
+
isBottomDialogOpen(): boolean;
|
|
26
29
|
showCustomModal(content: React.ReactElement, { size, onClose }?: CustomModalOptions): void;
|
|
27
30
|
showModal({ size, ...props }: OverlayContentProps & {
|
|
28
31
|
size?: ModalSize;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutOverlayManager.d.ts","sourceRoot":"","sources":["../src/LayoutOverlayManager.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAA6B,MAAM,OAAO,CAAA;AAC/D,OAAO,EAAU,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAkB,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAGjF,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAG3D,UAAU,YAAa,SAAQ,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC;IAC1D,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,KAAK,mBAAmB,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAA;AACvD,KAAK,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;AAC/C,KAAK,SAAS,GAAG,aAAa,GAAG,WAAW,CAAA;AAiB5C,UAAU,kBAAkB;IAC1B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,UAAU,uBAAuB;IAC/B,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAOD,cAAM,oBAAoB;IACxB,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,oBAAoB,CAAA;IAC/C,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,QAAQ,CAAC,CAAgB;IACjC,OAAO,CAAC,YAAY,CAAC,CAAY;IAEjC,OAAO,CAAC,aAAa;
|
|
1
|
+
{"version":3,"file":"LayoutOverlayManager.d.ts","sourceRoot":"","sources":["../src/LayoutOverlayManager.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAA6B,MAAM,OAAO,CAAA;AAC/D,OAAO,EAAU,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAC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,CAAC,OAAO,CAAC;IAKnE,KAAK,CAAC,EAAE,OAAO,EAAE,UAAiB,EAAE,GAAG,OAAO,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpF,gBAAgB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAiBrF,oBAAoB,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,IAAe,EAAE,OAAO,EAAE,GAAE,uBAA4B;IAYtG,cAAc,CAAC,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,mBAAmB,GAAG;QAAE,IAAI,CAAC,EAAE,WAAW,CAAA;KAAE;IAO/E,UAAU,CAAC,gBAAgB,UAAO;IAgBlC,eAAe,CAAC,gBAAgB,UAAO;IAgBvC,iBAAiB;IAIjB,aAAa,CAAC,OAAO,EAAE,WAAW;IAIlC,kBAAkB,CAAC,OAAO,EAAE,WAAW;IAIvC,WAAW,0BAAmB;CAC/B;AAED,eAAO,MAAM,OAAO,sBAA6B,CAAA"}
|
|
@@ -47,9 +47,10 @@ class LayoutOverlayManager {
|
|
|
47
47
|
rightPanel: document.getElementById(RIGHT_PANEL_ID),
|
|
48
48
|
};
|
|
49
49
|
this.elements.backdrop?.addEventListener('click', (event) => {
|
|
50
|
-
if (this.
|
|
50
|
+
if (this.isModalOpen() && !this.elements?.modal?.contains?.(event.target))
|
|
51
51
|
this.closeModal();
|
|
52
|
-
|
|
52
|
+
if (this.isRightPanelOpen() && !this.elements?.rightPanel?.contains?.(event.target))
|
|
53
|
+
this.closeRightPanel();
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
56
|
// this should actually be like Kotlin's "internal", i.e. private to any user of the lib, but public to the lib itself.
|
|
@@ -67,6 +68,15 @@ class LayoutOverlayManager {
|
|
|
67
68
|
this.setContent.bottomDialog = setBottomDialog;
|
|
68
69
|
return { modal, rightPanel, bottomDialog };
|
|
69
70
|
}
|
|
71
|
+
isModalOpen() {
|
|
72
|
+
return this.elements?.modal?.classList.contains('visible') ?? false;
|
|
73
|
+
}
|
|
74
|
+
isRightPanelOpen() {
|
|
75
|
+
return this.elements?.rightPanel?.classList.contains('visible') ?? false;
|
|
76
|
+
}
|
|
77
|
+
isBottomDialogOpen() {
|
|
78
|
+
return this.elements?.bottomDialog?.classList.contains('visible') ?? false;
|
|
79
|
+
}
|
|
70
80
|
showCustomModal(content, { size = 'medium', onClose } = {}) {
|
|
71
81
|
if (!this.elements?.modal)
|
|
72
82
|
throw new ElementNotFound('modal', MODAL_ID);
|
|
@@ -120,7 +130,10 @@ class LayoutOverlayManager {
|
|
|
120
130
|
this.onModalClose = onClose;
|
|
121
131
|
this.setContent.rightPanel(content);
|
|
122
132
|
this.elements?.rightPanel.classList.add(size);
|
|
123
|
-
setTimeout(() =>
|
|
133
|
+
setTimeout(() => {
|
|
134
|
+
this.elements?.backdrop?.setAttribute('class', 'visible');
|
|
135
|
+
this.elements?.rightPanel?.classList?.add('visible');
|
|
136
|
+
});
|
|
124
137
|
}
|
|
125
138
|
showRightPanel({ size, ...props }) {
|
|
126
139
|
this.showCustomRightPanel(_jsx(OverlayContent, { ...props, onClose: () => this.closeRightPanel(), type: "panel" }), { size, onClose: props.onClose });
|
|
@@ -140,6 +153,7 @@ class LayoutOverlayManager {
|
|
|
140
153
|
}
|
|
141
154
|
closeRightPanel(runCloseListener = true) {
|
|
142
155
|
this.elements?.rightPanel?.classList.remove('visible');
|
|
156
|
+
this.elements?.backdrop?.setAttribute('class', '');
|
|
143
157
|
if (runCloseListener && this.onModalClose) {
|
|
144
158
|
this.onModalClose();
|
|
145
159
|
this.onModalClose = undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutOverlayManager.js","sourceRoot":"","sources":["../src/LayoutOverlayManager.tsx"],"names":[],"mappings":";AAAA,+CAA+C;AAE/C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OA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AC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAClD,CAAC;IAED,kBAAkB,CAAC,OAAoB;QACrC,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IACvD,CAAC;CAGF;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,oBAAoB,EAAE,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
|
-
import { ErrorDescription } from './
|
|
2
|
+
import { ErrorDescription } from './ErrorManager';
|
|
3
3
|
interface State extends ErrorDescription {
|
|
4
4
|
hasError: boolean;
|
|
5
5
|
}
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.d.ts","sourceRoot":"","sources":["../../../src/components/error/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,EAAE,gBAAgB,EAAgB,MAAM,gBAAgB,CAAA;AAE/D,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;IAM5C,kBAAkB,CAAC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC;IAI7C,MAAM;CAKP"}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Component } from 'react';
|
|
3
|
-
import { ErrorDescriptor } from './ErrorDescriptor';
|
|
4
3
|
import { ErrorFeedback } from './ErrorFeedback';
|
|
4
|
+
import { ErrorManager } from './ErrorManager';
|
|
5
5
|
export class ErrorBoundary extends Component {
|
|
6
6
|
constructor(props) {
|
|
7
7
|
super(props);
|
|
8
8
|
this.state = { hasError: false };
|
|
9
9
|
}
|
|
10
10
|
static getDerivedStateFromError(error) {
|
|
11
|
-
return { hasError: true, ...
|
|
11
|
+
return { hasError: true, ...ErrorManager.describe(error) };
|
|
12
12
|
}
|
|
13
13
|
componentDidCatch(error, errorInfo) {
|
|
14
14
|
// eslint-disable-next-line no-console
|
|
15
15
|
console.error(error, errorInfo);
|
|
16
|
+
ErrorManager.runErrorHandler(error);
|
|
17
|
+
}
|
|
18
|
+
componentDidUpdate(prevProps) {
|
|
19
|
+
if (this.props.children !== prevProps.children)
|
|
20
|
+
this.setState({ hasError: false });
|
|
16
21
|
}
|
|
17
22
|
render() {
|
|
18
23
|
return this.state.hasError
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../../../src/components/error/ErrorBoundary.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,
|
|
1
|
+
{"version":3,"file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 @@
|
|
|
1
|
-
import { ErrorDescription } from './
|
|
1
|
+
import { ErrorDescription } from './ErrorManager';
|
|
2
2
|
export declare const ErrorFeedback: ({ code, message, debug }: ErrorDescription) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=ErrorFeedback.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorFeedback.d.ts","sourceRoot":"","sources":["../../../src/components/error/ErrorFeedback.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ErrorFeedback.d.ts","sourceRoot":"","sources":["../../../src/components/error/ErrorFeedback.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAajD,eAAO,MAAM,aAAa,6BAAkC,gBAAgB,4CAgD3E,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ErrorDescription {
|
|
2
|
+
code?: number;
|
|
3
|
+
message?: string;
|
|
4
|
+
debug?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export type DescriptionFn = (error: any) => ErrorDescription;
|
|
7
|
+
export type ErrorHandler = (error: any) => void;
|
|
8
|
+
export declare class ErrorManager {
|
|
9
|
+
private static descriptionFunction;
|
|
10
|
+
private static errorHandler;
|
|
11
|
+
static setDescriptionFunction(fn: DescriptionFn): void;
|
|
12
|
+
static setErrorHandler(handler: ErrorHandler): void;
|
|
13
|
+
static describe(error: any): ErrorDescription;
|
|
14
|
+
static runErrorHandler(error: any): void | undefined;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=ErrorManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorManager.d.ts","sourceRoot":"","sources":["../../../src/components/error/ErrorManager.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,gBAAgB,CAAA;AAC5D,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAA;AAE/C,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAEhC;IACF,OAAO,CAAC,MAAM,CAAC,YAAY,CAA0B;IAErD,MAAM,CAAC,sBAAsB,CAAC,EAAE,EAAE,aAAa;IAI/C,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,YAAY;IAI5C,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG;IAI1B,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,GAAG;CAGlC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export class ErrorManager {
|
|
2
|
+
static setDescriptionFunction(fn) {
|
|
3
|
+
this.descriptionFunction = fn;
|
|
4
|
+
}
|
|
5
|
+
static setErrorHandler(handler) {
|
|
6
|
+
this.errorHandler = handler;
|
|
7
|
+
}
|
|
8
|
+
static describe(error) {
|
|
9
|
+
return this.descriptionFunction(error);
|
|
10
|
+
}
|
|
11
|
+
static runErrorHandler(error) {
|
|
12
|
+
return this.errorHandler?.(error);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(ErrorManager, "descriptionFunction", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true,
|
|
19
|
+
value: error => ({
|
|
20
|
+
message: error.message || `${error}`,
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=ErrorManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorManager.js","sourceRoot":"","sources":["../../../src/components/error/ErrorManager.ts"],"names":[],"mappings":"AASA,MAAM,OAAO,YAAY;IAMvB,MAAM,CAAC,sBAAsB,CAAC,EAAiB;QAC7C,IAAI,CAAC,mBAAmB,GAAG,EAAE,CAAA;IAC/B,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,OAAqB;QAC1C,IAAI,CAAC,YAAY,GAAG,OAAO,CAAA;IAC7B,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,KAAU;QACxB,OAAO,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAA;IACxC,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,KAAU;QAC/B,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,CAAA;IACnC,CAAC;;AAnBc;;;;WAAqC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC5D,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,GAAG,KAAK,EAAE;KACrC,CAAC;GAAA"}
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
|
-
|
|
2
|
+
import { ErrorDescription } from './ErrorManager';
|
|
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,EAAgB,MAAM,gBAAgB,CAAA;AAE/D,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;IAM5C,kBAAkB,CAAC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC;IAI7C,MAAM;CAoBP"}
|
|
@@ -1,19 +1,39 @@
|
|
|
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 { ErrorManager } from './ErrorManager';
|
|
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, ...ErrorManager.describe(error) };
|
|
9
12
|
}
|
|
10
13
|
componentDidCatch(error, errorInfo) {
|
|
11
14
|
// eslint-disable-next-line no-console
|
|
12
15
|
console.error(error, errorInfo);
|
|
16
|
+
ErrorManager.runErrorHandler(error);
|
|
17
|
+
}
|
|
18
|
+
componentDidUpdate(prevProps) {
|
|
19
|
+
if (this.props.children !== prevProps.children)
|
|
20
|
+
this.setState({ hasError: false });
|
|
13
21
|
}
|
|
14
22
|
render() {
|
|
15
23
|
return this.state.hasError
|
|
16
|
-
?
|
|
24
|
+
? _jsx("div", { title: this.state.message ? `Error: ${this.state.message}` : undefined, style: {
|
|
25
|
+
width: '16px',
|
|
26
|
+
height: '16px',
|
|
27
|
+
margin: '16px',
|
|
28
|
+
background: theme.color.danger[500],
|
|
29
|
+
color: theme.color.danger.contrastText,
|
|
30
|
+
display: this.state.debug ? 'flex' : 'none',
|
|
31
|
+
justifyContent: 'center',
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
fontWeight: 'bold',
|
|
34
|
+
fontSize: '10px',
|
|
35
|
+
borderRadius: '50%',
|
|
36
|
+
}, children: "!" })
|
|
17
37
|
: this.props.children;
|
|
18
38
|
}
|
|
19
39
|
}
|
|
@@ -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/components/error/SilentErrorBoundary.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAoB,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAW/D,MAAM,OAAO,mBAAoB,SAAQ,SAAuB;IAC9D,YAAY,KAAY;QACtB,K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,MAAM;oBAChB,YAAY,EAAE,KAAK;iBACpB,kBACK;YACR,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAA;IACzB,CAAC;CACF"}
|
package/dist/layout.css
CHANGED
package/dist/toaster.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toaster.d.ts","sourceRoot":"","sources":["../src/toaster.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"toaster.d.ts","sourceRoot":"","sources":["../src/toaster.tsx"],"names":[],"mappings":";AAGA,OAAO,uCAAuC,CAAA;AAE9C,KAAK,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAA;AAEzD,UAAU,SAAS;IACjB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CAC5B;AAED,UAAU,iBAAkB,SAAQ,SAAS;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,UAAU,gBAAiB,SAAQ,SAAS;IAC1C,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC;CAC7B;AAED,KAAK,KAAK,GAAG,iBAAiB,GAAG,gBAAgB,CAAA;AAqBjD,wBAAgB,WAAW,CAAC,EAAE,IAAa,EAAE,SAAc,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,QAuB7E"}
|
package/dist/toaster.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toaster.js","sourceRoot":"","sources":["../src/toaster.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"toaster.js","sourceRoot":"","sources":["../src/toaster.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAiC,MAAM,cAAc,CAAA;AACrE,OAAO,EA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GAAG,IAAI;QACzD,SAAS,EAAC,cAAc;QACxB,KAAK,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;QACzC,aAAa,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE;QACrC,aAAa,EAAE,YAAY;QAC3B,IAAI,EAAE,SAAS,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAC/B,KAAC,OAAO,IAAC,WAAW,EAAE,EAAmC,YACtD,IAAI,CAAC,OAAO,GACL,CACX,CAAC,CAAC,CAAC,SAAS;KACd,CACF,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stack-spot/portal-layout",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@citric/core": ">=5.
|
|
9
|
-
"@citric/icons": ">=5.
|
|
10
|
-
"@citric/ui": ">=5.
|
|
8
|
+
"@citric/core": ">=5.4.0",
|
|
9
|
+
"@citric/icons": ">=5.4.0",
|
|
10
|
+
"@citric/ui": ">=5.4.0",
|
|
11
11
|
"@stack-spot/portal-theme": ">=0.0.4",
|
|
12
12
|
"@stack-spot/portal-translate": ">=0.0.5",
|
|
13
13
|
"react": ">=18.2.0",
|
package/src/Layout.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CSSToCitricAdapter, listToClass, WithStyle } from '@stack-spot/portal-theme'
|
|
2
2
|
import '@stack-spot/portal-theme/dist/theme.css'
|
|
3
|
-
import { ReactElement, ReactNode } from 'react'
|
|
3
|
+
import { ReactElement, ReactNode, useEffect } from 'react'
|
|
4
4
|
import { ErrorBoundary } from './components/error/ErrorBoundary'
|
|
5
|
-
import { DescriptionFn,
|
|
5
|
+
import { DescriptionFn, ErrorHandler, ErrorManager } from './components/error/ErrorManager'
|
|
6
6
|
import { SilentErrorBoundary } from './components/error/SilentErrorBoundary'
|
|
7
7
|
import { Header, HeaderProps } from './components/Header'
|
|
8
8
|
import { MenuContent } from './components/menu/MenuContent'
|
|
@@ -18,6 +18,7 @@ interface Props extends WithStyle {
|
|
|
18
18
|
children: ReactNode,
|
|
19
19
|
extra?: ReactNode,
|
|
20
20
|
errorDescriptor?: DescriptionFn,
|
|
21
|
+
onError?: ErrorHandler,
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
interface RawProps extends WithStyle {
|
|
@@ -28,10 +29,11 @@ interface RawProps extends WithStyle {
|
|
|
28
29
|
compactMenu?: boolean,
|
|
29
30
|
extra?: ReactNode,
|
|
30
31
|
errorDescriptor?: DescriptionFn,
|
|
32
|
+
onError?: ErrorHandler,
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
export const RawLayout = (
|
|
34
|
-
{ menuSections, menuContent, header, compactMenu = true, children, extra, errorDescriptor, className, style }: RawProps,
|
|
36
|
+
{ menuSections, menuContent, header, compactMenu = true, children, extra, errorDescriptor, onError, className, style }: RawProps,
|
|
35
37
|
) => {
|
|
36
38
|
// @ts-ignore
|
|
37
39
|
const { bottomDialog, modal, rightPanel } = overlay.useOverlays()
|
|
@@ -41,7 +43,11 @@ export const RawLayout = (
|
|
|
41
43
|
menuSections ? undefined : 'no-menu-sections',
|
|
42
44
|
className,
|
|
43
45
|
]
|
|
44
|
-
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (errorDescriptor) ErrorManager.setDescriptionFunction(errorDescriptor)
|
|
49
|
+
if (onError) ErrorManager.setErrorHandler(onError)
|
|
50
|
+
}, [])
|
|
45
51
|
|
|
46
52
|
return (
|
|
47
53
|
<CSSToCitricAdapter>
|
|
@@ -55,9 +61,9 @@ export const RawLayout = (
|
|
|
55
61
|
<nav id="menuContent"><SilentErrorBoundary>{menuContent}</SilentErrorBoundary></nav>
|
|
56
62
|
{menuSections && <nav id="menuSections"><SilentErrorBoundary>{menuSections}</SilentErrorBoundary></nav>}
|
|
57
63
|
</aside>
|
|
58
|
-
<div id="rightPanel"><ErrorBoundary>{rightPanel}</ErrorBoundary></div>
|
|
59
64
|
<div id="bottomDialog"><ErrorBoundary>{bottomDialog}</ErrorBoundary></div>
|
|
60
65
|
<div id="backdrop">
|
|
66
|
+
<div id="rightPanel"><ErrorBoundary>{rightPanel}</ErrorBoundary></div>
|
|
61
67
|
<div id="modal"><ErrorBoundary>{modal}</ErrorBoundary></div>
|
|
62
68
|
</div>
|
|
63
69
|
<Toaster />
|
|
@@ -71,7 +77,7 @@ const MenuContentRenderer = ({ content }: Required<Pick<Props['menu'], 'content'
|
|
|
71
77
|
return <MenuContent {...menuContent} />
|
|
72
78
|
}
|
|
73
79
|
|
|
74
|
-
export const Layout = ({ menu, header, children, extra, errorDescriptor, className, style }: Props) => (
|
|
80
|
+
export const Layout = ({ menu, header, children, extra, errorDescriptor, onError, className, style }: Props) => (
|
|
75
81
|
<RawLayout
|
|
76
82
|
header={<Header {...header} />}
|
|
77
83
|
menuSections={menu.sections ? <MenuSections {...menu} /> : undefined}
|
|
@@ -81,6 +87,7 @@ export const Layout = ({ menu, header, children, extra, errorDescriptor, classNa
|
|
|
81
87
|
}
|
|
82
88
|
compactMenu={menu.compact}
|
|
83
89
|
errorDescriptor={errorDescriptor}
|
|
90
|
+
onError={onError}
|
|
84
91
|
extra={extra}
|
|
85
92
|
className={className}
|
|
86
93
|
style={style}
|
|
@@ -61,9 +61,8 @@ class LayoutOverlayManager {
|
|
|
61
61
|
rightPanel: document.getElementById(RIGHT_PANEL_ID),
|
|
62
62
|
}
|
|
63
63
|
this.elements.backdrop?.addEventListener('click', (event) => {
|
|
64
|
-
if (this.
|
|
65
|
-
|
|
66
|
-
}
|
|
64
|
+
if (this.isModalOpen() && !this.elements?.modal?.contains?.(event.target as Node)) this.closeModal()
|
|
65
|
+
if (this.isRightPanelOpen() && !this.elements?.rightPanel?.contains?.(event.target as Node)) this.closeRightPanel()
|
|
67
66
|
})
|
|
68
67
|
}
|
|
69
68
|
|
|
@@ -82,6 +81,18 @@ class LayoutOverlayManager {
|
|
|
82
81
|
return { modal, rightPanel, bottomDialog }
|
|
83
82
|
}
|
|
84
83
|
|
|
84
|
+
isModalOpen() {
|
|
85
|
+
return this.elements?.modal?.classList.contains('visible') ?? false
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
isRightPanelOpen() {
|
|
89
|
+
return this.elements?.rightPanel?.classList.contains('visible') ?? false
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
isBottomDialogOpen() {
|
|
93
|
+
return this.elements?.bottomDialog?.classList.contains('visible') ?? false
|
|
94
|
+
}
|
|
95
|
+
|
|
85
96
|
showCustomModal(content: React.ReactElement, { size = 'medium', onClose }: CustomModalOptions = {}) {
|
|
86
97
|
if (!this.elements?.modal) throw new ElementNotFound('modal', MODAL_ID)
|
|
87
98
|
if (!this.setContent.modal) throw new LayoutError('unable to show modal, because it has not been setup yet.')
|
|
@@ -149,7 +160,10 @@ class LayoutOverlayManager {
|
|
|
149
160
|
this.onModalClose = onClose
|
|
150
161
|
this.setContent.rightPanel(content)
|
|
151
162
|
this.elements?.rightPanel.classList.add(size)
|
|
152
|
-
setTimeout(() =>
|
|
163
|
+
setTimeout(() => {
|
|
164
|
+
this.elements?.backdrop?.setAttribute('class', 'visible')
|
|
165
|
+
this.elements?.rightPanel?.classList?.add('visible')
|
|
166
|
+
})
|
|
153
167
|
}
|
|
154
168
|
|
|
155
169
|
showRightPanel({ size, ...props }: OverlayContentProps & { size?: OverlaySize }) {
|
|
@@ -177,6 +191,7 @@ class LayoutOverlayManager {
|
|
|
177
191
|
|
|
178
192
|
closeRightPanel(runCloseListener = true) {
|
|
179
193
|
this.elements?.rightPanel?.classList.remove('visible')
|
|
194
|
+
this.elements?.backdrop?.setAttribute('class', '')
|
|
180
195
|
if (runCloseListener && this.onModalClose) {
|
|
181
196
|
this.onModalClose()
|
|
182
197
|
this.onModalClose = undefined
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component } from 'react'
|
|
2
|
-
import { ErrorDescription, ErrorDescriptor } from './ErrorDescriptor'
|
|
3
2
|
import { ErrorFeedback } from './ErrorFeedback'
|
|
3
|
+
import { ErrorDescription, ErrorManager } from './ErrorManager'
|
|
4
4
|
|
|
5
5
|
interface State extends ErrorDescription {
|
|
6
6
|
hasError: boolean,
|
|
@@ -17,12 +17,17 @@ export class ErrorBoundary extends Component<Props, State> {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
static getDerivedStateFromError(error: any) {
|
|
20
|
-
return { hasError: true, ...
|
|
20
|
+
return { hasError: true, ...ErrorManager.describe(error) }
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
componentDidCatch(error: any, errorInfo: any) {
|
|
24
24
|
// eslint-disable-next-line no-console
|
|
25
25
|
console.error(error, errorInfo)
|
|
26
|
+
ErrorManager.runErrorHandler(error)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
componentDidUpdate(prevProps: Readonly<Props>) {
|
|
30
|
+
if (this.props.children !== prevProps.children) this.setState({ hasError: false })
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
render() {
|
|
@@ -6,7 +6,7 @@ import { Logo } from '../../svg/Logo'
|
|
|
6
6
|
import { NotFound } from '../../svg/NotFound'
|
|
7
7
|
import { ServerError } from '../../svg/ServerError'
|
|
8
8
|
import { Unauthenticated } from '../../svg/Unauthenticated'
|
|
9
|
-
import { ErrorDescription } from './
|
|
9
|
+
import { ErrorDescription } from './ErrorManager'
|
|
10
10
|
|
|
11
11
|
const imageStyle: React.CSSProperties = {
|
|
12
12
|
width: '200px',
|
|
@@ -5,17 +5,27 @@ export interface ErrorDescription {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export type DescriptionFn = (error: any) => ErrorDescription
|
|
8
|
+
export type ErrorHandler = (error: any) => void
|
|
8
9
|
|
|
9
|
-
export class
|
|
10
|
+
export class ErrorManager {
|
|
10
11
|
private static descriptionFunction: DescriptionFn = error => ({
|
|
11
12
|
message: error.message || `${error}`,
|
|
12
13
|
})
|
|
14
|
+
private static errorHandler: ErrorHandler | undefined
|
|
13
15
|
|
|
14
16
|
static setDescriptionFunction(fn: DescriptionFn) {
|
|
15
17
|
this.descriptionFunction = fn
|
|
16
18
|
}
|
|
17
19
|
|
|
20
|
+
static setErrorHandler(handler: ErrorHandler) {
|
|
21
|
+
this.errorHandler = handler
|
|
22
|
+
}
|
|
23
|
+
|
|
18
24
|
static describe(error: any) {
|
|
19
25
|
return this.descriptionFunction(error)
|
|
20
26
|
}
|
|
27
|
+
|
|
28
|
+
static runErrorHandler(error: any) {
|
|
29
|
+
return this.errorHandler?.(error)
|
|
30
|
+
}
|
|
21
31
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { theme } from '@stack-spot/portal-theme'
|
|
1
2
|
import { Component } from 'react'
|
|
3
|
+
import { ErrorDescription, ErrorManager } from './ErrorManager'
|
|
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,18 +17,38 @@ 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, ...ErrorManager.describe(error) }
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
componentDidCatch(error: any, errorInfo: any) {
|
|
22
25
|
// eslint-disable-next-line no-console
|
|
23
26
|
console.error(error, errorInfo)
|
|
27
|
+
ErrorManager.runErrorHandler(error)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
componentDidUpdate(prevProps: Readonly<Props>) {
|
|
31
|
+
if (this.props.children !== prevProps.children) this.setState({ hasError: false })
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
render() {
|
|
27
35
|
return this.state.hasError
|
|
28
|
-
?
|
|
36
|
+
? <div
|
|
37
|
+
title={this.state.message ? `Error: ${this.state.message}` : undefined}
|
|
38
|
+
style={{
|
|
39
|
+
width: '16px',
|
|
40
|
+
height: '16px',
|
|
41
|
+
margin: '16px',
|
|
42
|
+
background: theme.color.danger[500],
|
|
43
|
+
color: theme.color.danger.contrastText,
|
|
44
|
+
display: this.state.debug ? 'flex' : 'none',
|
|
45
|
+
justifyContent: 'center',
|
|
46
|
+
alignItems: 'center',
|
|
47
|
+
fontWeight: 'bold',
|
|
48
|
+
fontSize: '10px',
|
|
49
|
+
borderRadius: '50%',
|
|
50
|
+
}}
|
|
51
|
+
>!</div>
|
|
29
52
|
: this.props.children
|
|
30
53
|
}
|
|
31
54
|
}
|
package/src/layout.css
CHANGED
package/src/toaster.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IconBox } from '@citric/core'
|
|
2
|
-
import { OneOfColorSchemesWithVariants } from '@citric/core/utils/theme.types'
|
|
1
|
+
import { IconBox, OneOfColorSchemesWithVariants } from '@citric/core'
|
|
3
2
|
import { CheckCircleFill, ExclamationTriangleFill, InfoCircleFill, TimesCircleFill } from '@citric/icons'
|
|
4
3
|
import { toast } from 'react-toastify'
|
|
5
4
|
import 'react-toastify/dist/ReactToastify.css'
|