dce-reactkit 3.6.4 → 3.6.6

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.
@@ -3,10 +3,14 @@
3
3
  * @author Gabe Abrams
4
4
  */
5
5
  import React from 'react';
6
+ import { IconProp } from '@fortawesome/fontawesome-svg-core';
7
+ import Variant from '../types/Variant';
6
8
  type Props = {
7
9
  error: any;
8
10
  title?: string;
9
11
  onClose?: () => void;
12
+ variant?: Variant;
13
+ icon?: IconProp;
10
14
  };
11
15
  declare const ErrorBox: React.FC<Props>;
12
16
  export default ErrorBox;
package/dist/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { useState, useRef, useEffect, useReducer, forwardRef, useContext, useLayoutEffect, createContext, useMemo, useCallback, Component, Fragment } from 'react';
3
+ import { faExclamationTriangle, faHourglassEnd, faCircle, faDotCircle, faCheckSquare, faHourglass, faClipboard, faChevronDown, faChevronRight, faCloudDownloadAlt, faMinus, faCheckCircle, faXmarkCircle, faSort, faSortDown, faSortUp, faCalendar, faTag, faHammer, faList, faTimes, faSave, faTrash, faCog, faPlus, faCaretDown } from '@fortawesome/free-solid-svg-icons';
3
4
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4
- import { faExclamationTriangle, faCircle, faDotCircle, faCheckSquare, faHourglass, faClipboard, faChevronDown, faChevronRight, faCloudDownloadAlt, faMinus, faCheckCircle, faXmarkCircle, faSort, faSortDown, faSortUp, faCalendar, faTag, faHammer, faList, faTimes, faSave, faTrash, faCog, faPlus, faCaretDown } from '@fortawesome/free-solid-svg-icons';
5
5
  import { faCircle as faCircle$1, faSquareMinus, faSquare } from '@fortawesome/free-regular-svg-icons';
6
6
 
7
7
  /******************************************************************************
@@ -52,6 +52,23 @@ var ReactKitErrorCode;
52
52
  })(ReactKitErrorCode || (ReactKitErrorCode = {}));
53
53
  var ReactKitErrorCode$1 = ReactKitErrorCode;
54
54
 
55
+ /**
56
+ * Bootstrap variants
57
+ * @author Gabe Abrams
58
+ */
59
+ var Variant;
60
+ (function (Variant) {
61
+ Variant["Primary"] = "primary";
62
+ Variant["Secondary"] = "secondary";
63
+ Variant["Success"] = "success";
64
+ Variant["Warning"] = "warning";
65
+ Variant["Info"] = "info";
66
+ Variant["Danger"] = "danger";
67
+ Variant["Light"] = "light";
68
+ Variant["Dark"] = "dark";
69
+ })(Variant || (Variant = {}));
70
+ var Variant$1 = Variant;
71
+
55
72
  /**
56
73
  * Displays an error
57
74
  * @author Gabe Abrams
@@ -65,7 +82,7 @@ const ErrorBox = (props) => {
65
82
  /*------------------------------------------------------------------------*/
66
83
  var _a;
67
84
  /* -------------- Props ------------- */
68
- const { error, title = 'An Error Occurred', onClose, } = props;
85
+ const { error, title = 'An Error Occurred', onClose, variant = Variant$1.Danger, icon = faExclamationTriangle, } = props;
69
86
  /*------------------------------------------------------------------------*/
70
87
  /* ------------------------------- Render ------------------------------- */
71
88
  /*------------------------------------------------------------------------*/
@@ -93,12 +110,12 @@ const ErrorBox = (props) => {
93
110
  String((_a = error.code) !== null && _a !== void 0 ? _a : ReactKitErrorCode$1.NoCode).toUpperCase())));
94
111
  }
95
112
  // Main UI
96
- return (React__default.createElement("div", { className: "alert alert-danger text-center", style: {
113
+ return (React__default.createElement("div", { className: `alert alert-${variant} text-center`, style: {
97
114
  maxWidth: '40rem',
98
115
  margin: 'auto',
99
116
  } },
100
117
  React__default.createElement("h4", { className: "mb-1" },
101
- React__default.createElement(FontAwesomeIcon, { icon: faExclamationTriangle, className: "me-2" }),
118
+ React__default.createElement(FontAwesomeIcon, { icon: icon, className: "me-2" }),
102
119
  title),
103
120
  React__default.createElement("div", null,
104
121
  errorText,
@@ -173,23 +190,6 @@ const waitMs = (ms = 0) => __awaiter(void 0, void 0, void 0, function* () {
173
190
  });
174
191
  });
175
192
 
176
- /**
177
- * Bootstrap variants
178
- * @author Gabe Abrams
179
- */
180
- var Variant;
181
- (function (Variant) {
182
- Variant["Primary"] = "primary";
183
- Variant["Secondary"] = "secondary";
184
- Variant["Success"] = "success";
185
- Variant["Warning"] = "warning";
186
- Variant["Info"] = "info";
187
- Variant["Danger"] = "danger";
188
- Variant["Light"] = "light";
189
- Variant["Dark"] = "dark";
190
- })(Variant || (Variant = {}));
191
- var Variant$1 = Variant;
192
-
193
193
  /**
194
194
  * Modal sizes
195
195
  * @author Gabe Abrams
@@ -1122,6 +1122,13 @@ const AppWrapper = (props) => {
1122
1122
  const error = (sessionHasExpired
1123
1123
  ? new ErrorWithCode(getSessionExpiredMessage(), ReactKitErrorCode$1.SessionExpired)
1124
1124
  : new ErrorWithCode((fatalErrorMessage !== null && fatalErrorMessage !== void 0 ? fatalErrorMessage : 'An unknown error has occurred. Please contact support.'), (fatalErrorCode !== null && fatalErrorCode !== void 0 ? fatalErrorCode : ReactKitErrorCode$1.NoCode)));
1125
+ // Choose error box variant
1126
+ let errorBoxVariant = Variant$1.Danger;
1127
+ if (sessionHasExpired) {
1128
+ errorBoxVariant = (isDarkModeOn()
1129
+ ? Variant$1.Light
1130
+ : Variant$1.Secondary);
1131
+ }
1125
1132
  // Build error screen
1126
1133
  body = (React__default.createElement("div", { style: {
1127
1134
  display: 'block',
@@ -1134,7 +1141,7 @@ const AppWrapper = (props) => {
1134
1141
  } },
1135
1142
  React__default.createElement(ErrorBox, { title: (sessionHasExpired
1136
1143
  ? 'Session Expired'
1137
- : fatalErrorTitle), error: error })));
1144
+ : fatalErrorTitle), error: error, variant: errorBoxVariant, icon: faHourglassEnd })));
1138
1145
  }
1139
1146
  /* --------------- App -------------- */
1140
1147
  if (!body) {