robbyson-frontend-library 1.0.118 → 1.0.119

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.
@@ -27,6 +27,7 @@ import { IoC } from "../../ioc";
27
27
  import { PageContainer, Header, Title, ContextMenu, Content, LeftArrowLarge, GenericButton, } from "./base-app-page.styles";
28
28
  import { RobbysonNavigate } from "../../utils";
29
29
  import { QueryParamsFactory } from "../../factories/query-params.factory";
30
+ import { ErrorBoundary } from "./error-boundary";
30
31
  var BaseAppPage = /** @class */ (function (_super) {
31
32
  __extends(BaseAppPage, _super);
32
33
  function BaseAppPage(props) {
@@ -105,7 +106,8 @@ var BaseAppPage = /** @class */ (function (_super) {
105
106
  ? this._baseAppPageTitle
106
107
  : this.translate(this.headerLocale) }, this.translate(this.headerLocale))),
107
108
  !this._avoidContextMenu && (React.createElement(ContextMenu, { className: "body-2-book" }, this.contextMenu()))),
108
- React.createElement(Content, { contentMarginTop: this._contentMarginTop, usePageHeader: this._usePageHeader, avoidContextMenu: this._avoidContextMenu }, this.renderPage())));
109
+ React.createElement(Content, { contentMarginTop: this._contentMarginTop, usePageHeader: this._usePageHeader, avoidContextMenu: this._avoidContextMenu },
110
+ React.createElement(ErrorBoundary, null, this.renderPage()))));
109
111
  };
110
112
  return BaseAppPage;
111
113
  }(React.Component));
@@ -0,0 +1,49 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ import React from "react";
17
+ import { IoC } from "../../ioc";
18
+ var ErrorBoundary = /** @class */ (function (_super) {
19
+ __extends(ErrorBoundary, _super);
20
+ function ErrorBoundary(props) {
21
+ var _this = _super.call(this, props) || this;
22
+ _this.state = {
23
+ hasError: false,
24
+ };
25
+ _this._localeService = IoC.GetInstance("LocaleService");
26
+ return _this;
27
+ }
28
+ ErrorBoundary.getDerivedStateFromError = function () {
29
+ return { hasError: true };
30
+ };
31
+ ErrorBoundary.prototype.componentDidCatch = function (error, stack) {
32
+ if (process.env.NODE_ENV === "development") {
33
+ console.log({ error: error, stack: stack });
34
+ }
35
+ };
36
+ ErrorBoundary.prototype.render = function () {
37
+ if (this.state.hasError) {
38
+ return (React.createElement("div", { className: "d-flex w-100 h-100 justify-content-center align-items-center text-center" },
39
+ React.createElement("div", null,
40
+ React.createElement("h6", { className: "mb-2" }, this._localeService.getLocaleByHandle("access_page_error_title")),
41
+ React.createElement("span", { className: "body-1-book" }, this._localeService.getLocaleByHandle("access_page_error_subtitle")))));
42
+ }
43
+ else {
44
+ return React.createElement(React.Suspense, null, this.props.children);
45
+ }
46
+ };
47
+ return ErrorBoundary;
48
+ }(React.Component));
49
+ export { ErrorBoundary };
@@ -5,6 +5,9 @@ var LayoutUtils = /** @class */ (function () {
5
5
  LayoutUtils.isMobile = function () {
6
6
  return window.innerWidth <= LayoutDimensions.width.horizontalIpadMini;
7
7
  };
8
+ LayoutUtils.isSmallerMobiles = function () {
9
+ return window.innerWidth <= LayoutDimensions.width.smallerMobiles;
10
+ };
8
11
  return LayoutUtils;
9
12
  }());
10
13
  export { LayoutUtils };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "robbyson-frontend-library",
3
- "version": "1.0.118",
3
+ "version": "1.0.119",
4
4
  "description": "Robbyson frontend Library",
5
5
  "main": "./dist/index.js",
6
6
  "license": "MIT",
@@ -12,6 +12,7 @@ import {
12
12
  } from "./base-app-page.styles";
13
13
  import { RobbysonNavigate } from "../../utils";
14
14
  import { QueryParamsFactory } from "../../factories/query-params.factory";
15
+ import { ErrorBoundary } from "./error-boundary";
15
16
 
16
17
  export abstract class BaseAppPage<T, T1> extends React.Component<T, T1> {
17
18
  protected headerLocale: string = "Header Locale";
@@ -141,7 +142,7 @@ export abstract class BaseAppPage<T, T1> extends React.Component<T, T1> {
141
142
  usePageHeader={this._usePageHeader}
142
143
  avoidContextMenu={this._avoidContextMenu}
143
144
  >
144
- {this.renderPage()}
145
+ <ErrorBoundary>{this.renderPage()}</ErrorBoundary>
145
146
  </Content>
146
147
  </PageContainer>
147
148
  );
@@ -0,0 +1,54 @@
1
+ import React from "react";
2
+ import { ILocaleService } from "../../services";
3
+ import { IoC } from "../../ioc";
4
+
5
+ interface ErrorBoundaryProps {
6
+ children: React.ReactNode;
7
+ }
8
+
9
+ interface ErrorBoundaryState {
10
+ hasError: boolean;
11
+ }
12
+
13
+ export class ErrorBoundary extends React.Component<
14
+ ErrorBoundaryProps,
15
+ ErrorBoundaryState
16
+ > {
17
+ readonly state: ErrorBoundaryState = {
18
+ hasError: false,
19
+ };
20
+
21
+ private _localeService: ILocaleService;
22
+
23
+ constructor(props: ErrorBoundaryProps) {
24
+ super(props)
25
+ this._localeService = IoC.GetInstance<ILocaleService>("LocaleService");
26
+ }
27
+
28
+ static getDerivedStateFromError() {
29
+ return { hasError: true };
30
+ }
31
+
32
+ componentDidCatch(error: any, stack: any) {
33
+ if (process.env.NODE_ENV === "development") {
34
+ console.log({ error, stack });
35
+ }
36
+ }
37
+
38
+ public render() {
39
+ if (this.state.hasError) {
40
+ return (
41
+ <div className="d-flex w-100 h-100 justify-content-center align-items-center text-center">
42
+ <div>
43
+ <h6 className="mb-2">{this._localeService.getLocaleByHandle("access_page_error_title")}</h6>
44
+ <span className="body-1-book">
45
+ {this._localeService.getLocaleByHandle("access_page_error_subtitle")}
46
+ </span>
47
+ </div>
48
+ </div>
49
+ );
50
+ } else {
51
+ return <React.Suspense>{this.props.children}</React.Suspense>;
52
+ }
53
+ }
54
+ }
@@ -4,4 +4,8 @@ export class LayoutUtils {
4
4
  static isMobile(): boolean {
5
5
  return window.innerWidth <= LayoutDimensions.width.horizontalIpadMini;
6
6
  }
7
+
8
+ static isSmallerMobiles(): boolean {
9
+ return window.innerWidth <= LayoutDimensions.width.smallerMobiles;
10
+ }
7
11
  }