dce-reactkit 2.0.12 → 3.0.0-beta.1
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/cjs/index.js +36424 -0
- package/dist/cjs/index.js.map +1 -0
- package/{lib → dist/cjs/types}/components/AppWrapper.d.ts +9 -4
- package/{lib → dist/cjs/types}/components/ErrorBox.d.ts +0 -0
- package/{lib → dist/cjs/types}/components/LoadingSpinner.d.ts +1 -0
- package/{lib → dist/cjs/types}/components/Modal.d.ts +5 -36
- package/{lib → dist/cjs/types}/components/TabBox.d.ts +0 -0
- package/{lib → dist/cjs/types}/errors/ErrorWithCode.d.ts +0 -0
- package/{lib → dist/cjs/types}/helpers/abbreviate.d.ts +1 -0
- package/{lib → dist/cjs/types}/helpers/avg.d.ts +0 -0
- package/{lib → dist/cjs/types}/helpers/ceilToNumDecimals.d.ts +0 -0
- package/{lib → dist/cjs/types}/helpers/floorToNumDecimals.d.ts +0 -0
- package/{lib → dist/cjs/types}/helpers/forceNumIntoBounds.d.ts +0 -0
- package/{lib → dist/cjs/types}/helpers/padDecimalZeros.d.ts +0 -0
- package/{lib → dist/cjs/types}/helpers/padZerosLeft.d.ts +0 -0
- package/{lib → dist/cjs/types}/helpers/roundToNumDecimals.d.ts +0 -0
- package/{lib → dist/cjs/types}/helpers/sum.d.ts +0 -0
- package/{lib → dist/cjs/types}/helpers/waitMs.d.ts +0 -0
- package/dist/cjs/types/index.d.ts +22 -0
- package/dist/cjs/types/types/ModalButtonType.d.ts +17 -0
- package/dist/cjs/types/types/ModalSize.d.ts +11 -0
- package/dist/cjs/types/types/ModalType.d.ts +16 -0
- package/{lib → dist/cjs/types}/types/ReactKitErrorCode.d.ts +0 -0
- package/{lib → dist/cjs/types}/types/Variant.d.ts +0 -0
- package/dist/esm/index.js +36375 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types/components/AppWrapper.d.ts +40 -0
- package/dist/esm/types/components/ErrorBox.d.ts +12 -0
- package/dist/esm/types/components/LoadingSpinner.d.ts +7 -0
- package/dist/esm/types/components/Modal.d.ts +40 -0
- package/dist/esm/types/components/TabBox.d.ts +11 -0
- package/dist/esm/types/errors/ErrorWithCode.d.ts +9 -0
- package/dist/esm/types/helpers/abbreviate.d.ts +10 -0
- package/dist/esm/types/helpers/avg.d.ts +8 -0
- package/{src/helpers/ceilToNumDecimals.tsx → dist/esm/types/helpers/ceilToNumDecimals.d.ts} +1 -5
- package/{src/helpers/floorToNumDecimals.tsx → dist/esm/types/helpers/floorToNumDecimals.d.ts} +1 -5
- package/{src/helpers/forceNumIntoBounds.tsx → dist/esm/types/helpers/forceNumIntoBounds.d.ts} +1 -10
- package/dist/esm/types/helpers/padDecimalZeros.d.ts +10 -0
- package/{src/helpers/padZerosLeft.tsx → dist/esm/types/helpers/padZerosLeft.d.ts} +1 -13
- package/{src/helpers/roundToNumDecimals.tsx → dist/esm/types/helpers/roundToNumDecimals.d.ts} +1 -5
- package/{src/helpers/sum.tsx → dist/esm/types/helpers/sum.d.ts} +1 -9
- package/{src/helpers/waitMs.tsx → dist/esm/types/helpers/waitMs.d.ts} +1 -6
- package/dist/esm/types/index.d.ts +22 -0
- package/dist/esm/types/types/ModalButtonType.d.ts +17 -0
- package/dist/esm/types/types/ModalSize.d.ts +11 -0
- package/dist/esm/types/types/ModalType.d.ts +16 -0
- package/dist/esm/types/types/ReactKitErrorCode.d.ts +13 -0
- package/dist/esm/types/types/Variant.d.ts +15 -0
- package/dist/index.d.ts +274 -0
- package/package.json +23 -22
- package/.eslintrc.js +0 -95
- package/lib/components/AppWrapper.js +0 -277
- package/lib/components/AppWrapper.js.map +0 -1
- package/lib/components/ErrorBox.js +0 -65
- package/lib/components/ErrorBox.js.map +0 -1
- package/lib/components/LoadingSpinner.js +0 -41
- package/lib/components/LoadingSpinner.js.map +0 -1
- package/lib/components/Modal.js +0 -321
- package/lib/components/Modal.js.map +0 -1
- package/lib/components/TabBox.js +0 -42
- package/lib/components/TabBox.js.map +0 -1
- package/lib/errors/ErrorWithCode.js +0 -33
- package/lib/errors/ErrorWithCode.js.map +0 -1
- package/lib/helpers/abbreviate.js +0 -21
- package/lib/helpers/abbreviate.js.map +0 -1
- package/lib/helpers/alert.d.ts +0 -2
- package/lib/helpers/alert.js +0 -6
- package/lib/helpers/alert.js.map +0 -1
- package/lib/helpers/avg.js +0 -24
- package/lib/helpers/avg.js.map +0 -1
- package/lib/helpers/ceilToNumDecimals.js +0 -15
- package/lib/helpers/ceilToNumDecimals.js.map +0 -1
- package/lib/helpers/confirm.d.ts +0 -2
- package/lib/helpers/confirm.js +0 -6
- package/lib/helpers/confirm.js.map +0 -1
- package/lib/helpers/floorToNumDecimals.js +0 -15
- package/lib/helpers/floorToNumDecimals.js.map +0 -1
- package/lib/helpers/forceNumIntoBounds.js +0 -15
- package/lib/helpers/forceNumIntoBounds.js.map +0 -1
- package/lib/helpers/handleError.d.ts +0 -14
- package/lib/helpers/handleError.js +0 -54
- package/lib/helpers/handleError.js.map +0 -1
- package/lib/helpers/handleSuccess.d.ts +0 -8
- package/lib/helpers/handleSuccess.js +0 -20
- package/lib/helpers/handleSuccess.js.map +0 -1
- package/lib/helpers/padDecimalZeros.js +0 -30
- package/lib/helpers/padDecimalZeros.js.map +0 -1
- package/lib/helpers/padZerosLeft.js +0 -21
- package/lib/helpers/padZerosLeft.js.map +0 -1
- package/lib/helpers/parseRequest.d.ts +0 -21
- package/lib/helpers/parseRequest.js +0 -240
- package/lib/helpers/parseRequest.js.map +0 -1
- package/lib/helpers/roundToNumDecimals.js +0 -15
- package/lib/helpers/roundToNumDecimals.js.map +0 -1
- package/lib/helpers/showFatalError.d.ts +0 -2
- package/lib/helpers/showFatalError.js +0 -6
- package/lib/helpers/showFatalError.js.map +0 -1
- package/lib/helpers/sum.js +0 -15
- package/lib/helpers/sum.js.map +0 -1
- package/lib/helpers/visitServerEndpoint.d.ts +0 -23
- package/lib/helpers/visitServerEndpoint.js +0 -135
- package/lib/helpers/visitServerEndpoint.js.map +0 -1
- package/lib/helpers/waitMs.js +0 -55
- package/lib/helpers/waitMs.js.map +0 -1
- package/lib/types/ParamType.d.ts +0 -17
- package/lib/types/ParamType.js +0 -21
- package/lib/types/ParamType.js.map +0 -1
- package/lib/types/ReactKitErrorCode.js +0 -18
- package/lib/types/ReactKitErrorCode.js.map +0 -1
- package/lib/types/Variant.js +0 -19
- package/lib/types/Variant.js.map +0 -1
- package/src/components/AppWrapper.tsx +0 -369
- package/src/components/ErrorBox.tsx +0 -124
- package/src/components/LoadingSpinner.tsx +0 -105
- package/src/components/Modal.tsx +0 -461
- package/src/components/TabBox.tsx +0 -136
- package/src/errors/ErrorWithCode.tsx +0 -15
- package/src/helpers/abbreviate.tsx +0 -23
- package/src/helpers/alert.tsx +0 -5
- package/src/helpers/avg.tsx +0 -22
- package/src/helpers/confirm.tsx +0 -5
- package/src/helpers/handleError.ts +0 -65
- package/src/helpers/handleSuccess.ts +0 -18
- package/src/helpers/padDecimalZeros.tsx +0 -32
- package/src/helpers/parseRequest.ts +0 -299
- package/src/helpers/showFatalError.tsx +0 -5
- package/src/helpers/visitServerEndpoint.tsx +0 -110
- package/src/types/ParamType.ts +0 -18
- package/src/types/ReactKitErrorCode.tsx +0 -16
- package/src/types/Variant.tsx +0 -16
- package/tsconfig.json +0 -24
package/lib/types/ParamType.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* API param types
|
|
3
|
-
* @author Gabe Abrams
|
|
4
|
-
*/
|
|
5
|
-
declare enum ParamType {
|
|
6
|
-
Boolean = "boolean",
|
|
7
|
-
BooleanOptional = "boolean-optional",
|
|
8
|
-
Float = "float",
|
|
9
|
-
FloatOptional = "float-optional",
|
|
10
|
-
Int = "int",
|
|
11
|
-
IntOptional = "int-optional",
|
|
12
|
-
JSON = "json",
|
|
13
|
-
JSONOptional = "json-optional",
|
|
14
|
-
String = "string",
|
|
15
|
-
StringOptional = "string-optional"
|
|
16
|
-
}
|
|
17
|
-
export default ParamType;
|
package/lib/types/ParamType.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* API param types
|
|
5
|
-
* @author Gabe Abrams
|
|
6
|
-
*/
|
|
7
|
-
var ParamType;
|
|
8
|
-
(function (ParamType) {
|
|
9
|
-
ParamType["Boolean"] = "boolean";
|
|
10
|
-
ParamType["BooleanOptional"] = "boolean-optional";
|
|
11
|
-
ParamType["Float"] = "float";
|
|
12
|
-
ParamType["FloatOptional"] = "float-optional";
|
|
13
|
-
ParamType["Int"] = "int";
|
|
14
|
-
ParamType["IntOptional"] = "int-optional";
|
|
15
|
-
ParamType["JSON"] = "json";
|
|
16
|
-
ParamType["JSONOptional"] = "json-optional";
|
|
17
|
-
ParamType["String"] = "string";
|
|
18
|
-
ParamType["StringOptional"] = "string-optional";
|
|
19
|
-
})(ParamType || (ParamType = {}));
|
|
20
|
-
exports.default = ParamType;
|
|
21
|
-
//# sourceMappingURL=ParamType.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ParamType.js","sourceRoot":"","sources":["../../src/types/ParamType.ts"],"names":[],"mappings":";;AAAA;;;GAGG;AACH,IAAK,SAWJ;AAXD,WAAK,SAAS;IACZ,gCAAmB,CAAA;IACnB,iDAAoC,CAAA;IACpC,4BAAe,CAAA;IACf,6CAAgC,CAAA;IAChC,wBAAW,CAAA;IACX,yCAA4B,CAAA;IAC5B,0BAAa,CAAA;IACb,2CAA8B,CAAA;IAC9B,8BAAiB,CAAA;IACjB,+CAAkC,CAAA;AACpC,CAAC,EAXI,SAAS,KAAT,SAAS,QAWb;AAED,kBAAe,SAAS,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Highest error code = DRK2
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
/**
|
|
5
|
-
* List of error codes built into the react kit
|
|
6
|
-
* @author Gabe Abrams
|
|
7
|
-
*/
|
|
8
|
-
var ReactKitErrorCode;
|
|
9
|
-
(function (ReactKitErrorCode) {
|
|
10
|
-
ReactKitErrorCode["NoResponse"] = "DRK1";
|
|
11
|
-
ReactKitErrorCode["NoCode"] = "DRK2";
|
|
12
|
-
ReactKitErrorCode["SessionExpired"] = "DRK3";
|
|
13
|
-
ReactKitErrorCode["MissingParameter"] = "DRK4";
|
|
14
|
-
ReactKitErrorCode["InvalidParameter"] = "DRK5";
|
|
15
|
-
ReactKitErrorCode["WrongCourse"] = "DRK6";
|
|
16
|
-
})(ReactKitErrorCode || (ReactKitErrorCode = {}));
|
|
17
|
-
exports.default = ReactKitErrorCode;
|
|
18
|
-
//# sourceMappingURL=ReactKitErrorCode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactKitErrorCode.js","sourceRoot":"","sources":["../../src/types/ReactKitErrorCode.tsx"],"names":[],"mappings":";AAAA,4BAA4B;;AAE5B;;;GAGG;AACH,IAAK,iBAOJ;AAPD,WAAK,iBAAiB;IACpB,wCAAmB,CAAA;IACnB,oCAAe,CAAA;IACf,4CAAuB,CAAA;IACvB,8CAAyB,CAAA;IACzB,8CAAyB,CAAA;IACzB,yCAAoB,CAAA;AACtB,CAAC,EAPI,iBAAiB,KAAjB,iBAAiB,QAOrB;AAED,kBAAe,iBAAiB,CAAC"}
|
package/lib/types/Variant.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Bootstrap variants
|
|
5
|
-
* @author Gabe Abrams
|
|
6
|
-
*/
|
|
7
|
-
var Variant;
|
|
8
|
-
(function (Variant) {
|
|
9
|
-
Variant["Primary"] = "primary";
|
|
10
|
-
Variant["Secondary"] = "secondary";
|
|
11
|
-
Variant["Success"] = "success";
|
|
12
|
-
Variant["Warning"] = "warning";
|
|
13
|
-
Variant["Info"] = "info";
|
|
14
|
-
Variant["Danger"] = "danger";
|
|
15
|
-
Variant["Light"] = "light";
|
|
16
|
-
Variant["Dark"] = "dark";
|
|
17
|
-
})(Variant || (Variant = {}));
|
|
18
|
-
exports.default = Variant;
|
|
19
|
-
//# sourceMappingURL=Variant.js.map
|
package/lib/types/Variant.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Variant.js","sourceRoot":"","sources":["../../src/types/Variant.tsx"],"names":[],"mappings":";;AAAA;;;GAGG;AACH,IAAK,OASJ;AATD,WAAK,OAAO;IACV,8BAAmB,CAAA;IACnB,kCAAuB,CAAA;IACvB,8BAAmB,CAAA;IACnB,8BAAmB,CAAA;IACnB,wBAAa,CAAA;IACb,4BAAiB,CAAA;IACjB,0BAAe,CAAA;IACf,wBAAa,CAAA;AACf,CAAC,EATI,OAAO,KAAP,OAAO,QASX;AAED,kBAAe,OAAO,CAAC"}
|
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A wrapper for the entire React app that adds global functionality like
|
|
3
|
-
* handling for fatal error messages
|
|
4
|
-
* @author Gabe Abrams
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// Import React
|
|
8
|
-
import React, { useState, useEffect } from 'react';
|
|
9
|
-
|
|
10
|
-
// Import shared components
|
|
11
|
-
import ErrorBox from './ErrorBox';
|
|
12
|
-
|
|
13
|
-
// Import helpers
|
|
14
|
-
import { setSessionExpiryHandler } from '../helpers/visitServerEndpoint';
|
|
15
|
-
|
|
16
|
-
// Import shared types
|
|
17
|
-
import ReactKitErrorCode from '../types/ReactKitErrorCode';
|
|
18
|
-
|
|
19
|
-
// Import shared components
|
|
20
|
-
import Modal from './Modal';
|
|
21
|
-
|
|
22
|
-
// Import custom errors
|
|
23
|
-
import ErrorWithCode from '../errors/ErrorWithCode';
|
|
24
|
-
|
|
25
|
-
/*------------------------------------------------------------------------*/
|
|
26
|
-
/* Props */
|
|
27
|
-
/*------------------------------------------------------------------------*/
|
|
28
|
-
|
|
29
|
-
type Props = {
|
|
30
|
-
// The entire app
|
|
31
|
-
children: React.ReactNode,
|
|
32
|
-
// True if this app is a dark-themed app
|
|
33
|
-
dark?: boolean,
|
|
34
|
-
// Custom session expired message
|
|
35
|
-
sessionExpiredMessage?: string,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/*------------------------------------------------------------------------*/
|
|
39
|
-
/* Static Helpers */
|
|
40
|
-
/*------------------------------------------------------------------------*/
|
|
41
|
-
|
|
42
|
-
/*----------------------------------------*/
|
|
43
|
-
/* Alert */
|
|
44
|
-
/*----------------------------------------*/
|
|
45
|
-
|
|
46
|
-
// Stored copies of setters
|
|
47
|
-
let setAlertInfo: (info: { title: string, text: string }) => void;
|
|
48
|
-
let onAlertClosed: () => void;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Show an alert modal with an "Okay" button
|
|
52
|
-
* @author Gabe Abrams
|
|
53
|
-
* @param title the title text to display at the top of the alert
|
|
54
|
-
* @param text the text to display in the alert
|
|
55
|
-
*/
|
|
56
|
-
export const _alert = async (title: string, text: string) => {
|
|
57
|
-
// Fallback if alert not available
|
|
58
|
-
if (!setAlertInfo) {
|
|
59
|
-
return window.alert(`${title}\n\n${text}`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Return promise that resolves when alert is closed
|
|
63
|
-
return new Promise((resolve) => {
|
|
64
|
-
// Setup handler
|
|
65
|
-
onAlertClosed = () => {
|
|
66
|
-
resolve(null);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// Show the alert
|
|
70
|
-
setAlertInfo({
|
|
71
|
-
title,
|
|
72
|
-
text,
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
/*----------------------------------------*/
|
|
78
|
-
/* Confirm */
|
|
79
|
-
/*----------------------------------------*/
|
|
80
|
-
|
|
81
|
-
// Stored copies of setters
|
|
82
|
-
let setConfirmInfo: (info: { title: string, text: string }) => void;
|
|
83
|
-
let onConfirmClosed: (confirmed: boolean) => void;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Show a confirmation modal with an "Okay" and a "Cancel" button
|
|
87
|
-
* @author Gabe Abrams
|
|
88
|
-
* @param title the title text to display at the top of the alert
|
|
89
|
-
* @param text the text to display in the alert
|
|
90
|
-
* @returns true if the user confirmed
|
|
91
|
-
*/
|
|
92
|
-
export const _confirm = async (
|
|
93
|
-
title: string,
|
|
94
|
-
text: string,
|
|
95
|
-
): Promise<boolean> => {
|
|
96
|
-
// Fallback if confirm is not available
|
|
97
|
-
if (!setConfirmInfo) {
|
|
98
|
-
return window.confirm(`${title}\n\n${text}`);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Return promise that resolves with result of confirmation
|
|
102
|
-
return new Promise((resolve) => {
|
|
103
|
-
// Setup handler
|
|
104
|
-
onConfirmClosed = (confirmed: boolean) => {
|
|
105
|
-
resolve(confirmed)
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
// Show the confirm
|
|
109
|
-
setConfirmInfo({
|
|
110
|
-
title,
|
|
111
|
-
text,
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
/*----------------------------------------*/
|
|
117
|
-
/* Fatal Error */
|
|
118
|
-
/*----------------------------------------*/
|
|
119
|
-
|
|
120
|
-
// Stored copies of setters
|
|
121
|
-
let setFatalErrorMessage: (message: string) => void;
|
|
122
|
-
let setFatalErrorCode: (code: string) => void;
|
|
123
|
-
let setFatalErrorTitle: (title: string) => void;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Show a fatal error message
|
|
127
|
-
* @author Gabe Abrams
|
|
128
|
-
* @param error the error to show
|
|
129
|
-
* @param [errorTitle] title of the error box
|
|
130
|
-
*/
|
|
131
|
-
export const _showFatalError = (
|
|
132
|
-
error: any,
|
|
133
|
-
errorTitle: string = 'An Error Occurred',
|
|
134
|
-
) => {
|
|
135
|
-
// Determine message and code
|
|
136
|
-
const message: string = (
|
|
137
|
-
typeof error === 'string'
|
|
138
|
-
? error.trim()
|
|
139
|
-
: String(error.message ?? 'An unknown error occurred.')
|
|
140
|
-
);
|
|
141
|
-
const code: string = (
|
|
142
|
-
typeof error === 'string'
|
|
143
|
-
? ReactKitErrorCode.NoCode
|
|
144
|
-
: String(error.code ?? ReactKitErrorCode.NoCode)
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
// Handle case where app hasn't loaded
|
|
148
|
-
if (!setFatalErrorMessage || !setFatalErrorCode) {
|
|
149
|
-
return _alert(
|
|
150
|
-
errorTitle,
|
|
151
|
-
`${message} (code: ${code}). Please contact support.`,
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// Use setters
|
|
156
|
-
setFatalErrorMessage(message);
|
|
157
|
-
setFatalErrorCode(code);
|
|
158
|
-
setFatalErrorTitle(errorTitle);
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
/*------------------------------------------------------------------------*/
|
|
162
|
-
/* Component */
|
|
163
|
-
/*------------------------------------------------------------------------*/
|
|
164
|
-
|
|
165
|
-
const AppWrapper = (props: Props): React.ReactElement => {
|
|
166
|
-
/*------------------------------------------------------------------------*/
|
|
167
|
-
/* Setup */
|
|
168
|
-
/*------------------------------------------------------------------------*/
|
|
169
|
-
|
|
170
|
-
/* -------------- Props ------------- */
|
|
171
|
-
|
|
172
|
-
const {
|
|
173
|
-
children,
|
|
174
|
-
dark,
|
|
175
|
-
sessionExpiredMessage = 'Your session has expired. Please go back to Canvas and start over.',
|
|
176
|
-
} = props;
|
|
177
|
-
|
|
178
|
-
/* -------------- State ------------- */
|
|
179
|
-
|
|
180
|
-
// Fatal error
|
|
181
|
-
const [
|
|
182
|
-
fatalErrorMessage,
|
|
183
|
-
setFatalErrorMessageInner,
|
|
184
|
-
] = useState<string | undefined>();
|
|
185
|
-
setFatalErrorMessage = setFatalErrorMessageInner;
|
|
186
|
-
const [
|
|
187
|
-
fatalErrorCode,
|
|
188
|
-
setFatalErrorCodeInner,
|
|
189
|
-
] = useState<string | undefined>();
|
|
190
|
-
setFatalErrorCode = setFatalErrorCodeInner;
|
|
191
|
-
const [
|
|
192
|
-
fatalErrorTitle,
|
|
193
|
-
setFatalErrorTitleInner,
|
|
194
|
-
] = useState<string | undefined>();
|
|
195
|
-
setFatalErrorTitle = setFatalErrorTitleInner;
|
|
196
|
-
|
|
197
|
-
// Alert
|
|
198
|
-
const [
|
|
199
|
-
alertInfo,
|
|
200
|
-
setAlertInfoInner,
|
|
201
|
-
] = useState<{
|
|
202
|
-
title: string,
|
|
203
|
-
text: string
|
|
204
|
-
}>();
|
|
205
|
-
setAlertInfo = setAlertInfoInner;
|
|
206
|
-
|
|
207
|
-
// Confirm
|
|
208
|
-
const [
|
|
209
|
-
confirmInfo,
|
|
210
|
-
setConfirmInfoInner,
|
|
211
|
-
] = useState<{
|
|
212
|
-
title: string,
|
|
213
|
-
text: string
|
|
214
|
-
}>();
|
|
215
|
-
setConfirmInfo = setConfirmInfoInner;
|
|
216
|
-
|
|
217
|
-
// Session expired
|
|
218
|
-
const [
|
|
219
|
-
sessionHasExpired,
|
|
220
|
-
setSessionHasExpired,
|
|
221
|
-
] = useState<boolean>(false);
|
|
222
|
-
|
|
223
|
-
/*------------------------------------------------------------------------*/
|
|
224
|
-
/* Lifecycle Functions */
|
|
225
|
-
/*------------------------------------------------------------------------*/
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Mount
|
|
229
|
-
* @author Gabe Abrams
|
|
230
|
-
*/
|
|
231
|
-
useEffect(
|
|
232
|
-
() => {
|
|
233
|
-
// Add session expired handler
|
|
234
|
-
setSessionExpiryHandler(() => {
|
|
235
|
-
// Session expired!
|
|
236
|
-
setSessionHasExpired(true);
|
|
237
|
-
});
|
|
238
|
-
},
|
|
239
|
-
[],
|
|
240
|
-
);
|
|
241
|
-
|
|
242
|
-
/*------------------------------------------------------------------------*/
|
|
243
|
-
/* Render */
|
|
244
|
-
/*------------------------------------------------------------------------*/
|
|
245
|
-
|
|
246
|
-
/*----------------------------------------*/
|
|
247
|
-
/* Modal */
|
|
248
|
-
/*----------------------------------------*/
|
|
249
|
-
|
|
250
|
-
// Modal that may be defined
|
|
251
|
-
let modal: React.ReactNode;
|
|
252
|
-
|
|
253
|
-
/* -------------- Alert ------------- */
|
|
254
|
-
|
|
255
|
-
if (alertInfo) {
|
|
256
|
-
modal = (
|
|
257
|
-
<Modal
|
|
258
|
-
title={alertInfo.title}
|
|
259
|
-
type={Modal.ModalType.Okay}
|
|
260
|
-
onClose={() => {
|
|
261
|
-
// Alert closed
|
|
262
|
-
if (onAlertClosed) {
|
|
263
|
-
onAlertClosed();
|
|
264
|
-
}
|
|
265
|
-
}}
|
|
266
|
-
onTopOfOtherModals
|
|
267
|
-
>
|
|
268
|
-
{alertInfo.text}
|
|
269
|
-
</Modal>
|
|
270
|
-
);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/* ------------- Confirm ------------ */
|
|
274
|
-
|
|
275
|
-
if (confirmInfo) {
|
|
276
|
-
modal = (
|
|
277
|
-
<Modal
|
|
278
|
-
title={confirmInfo.title}
|
|
279
|
-
type={Modal.ModalType.OkayCancel}
|
|
280
|
-
onClose={(buttonType) => {
|
|
281
|
-
if (onConfirmClosed) {
|
|
282
|
-
onConfirmClosed(buttonType === Modal.ButtonType.Okay);
|
|
283
|
-
}
|
|
284
|
-
}}
|
|
285
|
-
dontAllowBackdropExit
|
|
286
|
-
>
|
|
287
|
-
|
|
288
|
-
</Modal>
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/*----------------------------------------*/
|
|
293
|
-
/* Views */
|
|
294
|
-
/*----------------------------------------*/
|
|
295
|
-
|
|
296
|
-
// Body that will be filled with the current view
|
|
297
|
-
let body: React.ReactNode;
|
|
298
|
-
|
|
299
|
-
/* ----------- Fatal Error ---------- */
|
|
300
|
-
|
|
301
|
-
if (fatalErrorMessage || fatalErrorCode || sessionHasExpired) {
|
|
302
|
-
// Re-encapsulate in an error
|
|
303
|
-
const error = (
|
|
304
|
-
sessionHasExpired
|
|
305
|
-
? new ErrorWithCode(
|
|
306
|
-
fatalErrorMessage,
|
|
307
|
-
fatalErrorCode,
|
|
308
|
-
)
|
|
309
|
-
: new ErrorWithCode(
|
|
310
|
-
sessionExpiredMessage,
|
|
311
|
-
ReactKitErrorCode.SessionExpired,
|
|
312
|
-
)
|
|
313
|
-
);
|
|
314
|
-
|
|
315
|
-
// Build error screen
|
|
316
|
-
body = (
|
|
317
|
-
<div
|
|
318
|
-
style={{
|
|
319
|
-
display: 'block',
|
|
320
|
-
width: '100vw',
|
|
321
|
-
minHeight: '100vh',
|
|
322
|
-
paddingTop: '10rem',
|
|
323
|
-
backgroundColor: (
|
|
324
|
-
dark
|
|
325
|
-
? '#222'
|
|
326
|
-
: '#fff'
|
|
327
|
-
),
|
|
328
|
-
}}
|
|
329
|
-
>
|
|
330
|
-
<ErrorBox
|
|
331
|
-
title={(
|
|
332
|
-
sessionHasExpired
|
|
333
|
-
? 'Session Expired'
|
|
334
|
-
: fatalErrorTitle
|
|
335
|
-
)}
|
|
336
|
-
error={error}
|
|
337
|
-
/>
|
|
338
|
-
</div>
|
|
339
|
-
);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/* --------------- App -------------- */
|
|
343
|
-
|
|
344
|
-
if (!body) {
|
|
345
|
-
body = (
|
|
346
|
-
<>
|
|
347
|
-
{children}
|
|
348
|
-
</>
|
|
349
|
-
);
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
/*----------------------------------------*/
|
|
353
|
-
/* Main UI */
|
|
354
|
-
/*----------------------------------------*/
|
|
355
|
-
|
|
356
|
-
return (
|
|
357
|
-
<>
|
|
358
|
-
{modal}
|
|
359
|
-
{body}
|
|
360
|
-
</>
|
|
361
|
-
);
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
/*------------------------------------------------------------------------*/
|
|
365
|
-
/* Wrap Up */
|
|
366
|
-
/*------------------------------------------------------------------------*/
|
|
367
|
-
|
|
368
|
-
// Export component
|
|
369
|
-
export default AppWrapper;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Displays an error
|
|
3
|
-
* @author Gabe Abrams
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// Import React
|
|
7
|
-
import React from 'react';
|
|
8
|
-
|
|
9
|
-
// Import FontAwesome Icons
|
|
10
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
11
|
-
import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons';
|
|
12
|
-
|
|
13
|
-
// Import shared types
|
|
14
|
-
import ReactKitErrorCode from '../types/ReactKitErrorCode';
|
|
15
|
-
|
|
16
|
-
/*------------------------------------------------------------------------*/
|
|
17
|
-
/* Types */
|
|
18
|
-
/*------------------------------------------------------------------------*/
|
|
19
|
-
|
|
20
|
-
type Props = {
|
|
21
|
-
// Error to display
|
|
22
|
-
error: any,
|
|
23
|
-
// Customized title of error box
|
|
24
|
-
title?: string,
|
|
25
|
-
// Handler for close,
|
|
26
|
-
onClose?: () => void,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/*------------------------------------------------------------------------*/
|
|
30
|
-
/* Component */
|
|
31
|
-
/*------------------------------------------------------------------------*/
|
|
32
|
-
|
|
33
|
-
const ErrorBox: React.FC<Props> = (props) => {
|
|
34
|
-
/*------------------------------------------------------------------------*/
|
|
35
|
-
/* Setup */
|
|
36
|
-
/*------------------------------------------------------------------------*/
|
|
37
|
-
|
|
38
|
-
/* -------------- Props ------------- */
|
|
39
|
-
|
|
40
|
-
const {
|
|
41
|
-
error,
|
|
42
|
-
title = 'An Error Occurred',
|
|
43
|
-
onClose,
|
|
44
|
-
} = props;
|
|
45
|
-
|
|
46
|
-
/*------------------------------------------------------------------------*/
|
|
47
|
-
/* Render */
|
|
48
|
-
/*------------------------------------------------------------------------*/
|
|
49
|
-
|
|
50
|
-
// Determine error text
|
|
51
|
-
const errorText: string = (
|
|
52
|
-
typeof error === 'string'
|
|
53
|
-
? error.trim()
|
|
54
|
-
: String(error.message || 'An unknown error occurred. Please contact support.')
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
// Error code box
|
|
58
|
-
let errorCodeBox;
|
|
59
|
-
if (error && (error as any).code) {
|
|
60
|
-
errorCodeBox = (
|
|
61
|
-
<span>
|
|
62
|
-
{' '}
|
|
63
|
-
<span
|
|
64
|
-
style={{
|
|
65
|
-
backgroundColor: 'white',
|
|
66
|
-
borderRadius: '5px',
|
|
67
|
-
paddingLeft: '3px',
|
|
68
|
-
paddingRight: '3px',
|
|
69
|
-
color: '#DC4150',
|
|
70
|
-
fontVariant: 'small-caps',
|
|
71
|
-
fontSize: '80%',
|
|
72
|
-
whiteSpace: 'nowrap',
|
|
73
|
-
}}
|
|
74
|
-
>
|
|
75
|
-
code:
|
|
76
|
-
{' '}
|
|
77
|
-
{String((error as any).code ?? ReactKitErrorCode.NoCode).toUpperCase()}
|
|
78
|
-
</span>
|
|
79
|
-
</span>
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Main UI
|
|
84
|
-
return (
|
|
85
|
-
<div
|
|
86
|
-
className="alert alert-danger text-center"
|
|
87
|
-
style={{
|
|
88
|
-
maxWidth: '650px',
|
|
89
|
-
margin: 'auto',
|
|
90
|
-
}}
|
|
91
|
-
>
|
|
92
|
-
<h4 className="mb-1">
|
|
93
|
-
<FontAwesomeIcon
|
|
94
|
-
icon={faExclamationTriangle}
|
|
95
|
-
className="me-2"
|
|
96
|
-
/>
|
|
97
|
-
{title}
|
|
98
|
-
</h4>
|
|
99
|
-
<div>
|
|
100
|
-
{errorText}
|
|
101
|
-
{errorCodeBox}
|
|
102
|
-
</div>
|
|
103
|
-
{onClose && (
|
|
104
|
-
<div className="mt-2">
|
|
105
|
-
<button
|
|
106
|
-
type="button"
|
|
107
|
-
className="btn btn-light"
|
|
108
|
-
aria-label="dismiss error and close this activity or view"
|
|
109
|
-
onClick={onClose}
|
|
110
|
-
>
|
|
111
|
-
Close
|
|
112
|
-
</button>
|
|
113
|
-
</div>
|
|
114
|
-
)}
|
|
115
|
-
</div>
|
|
116
|
-
);
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
/*------------------------------------------------------------------------*/
|
|
120
|
-
/* Wrap Up */
|
|
121
|
-
/*------------------------------------------------------------------------*/
|
|
122
|
-
|
|
123
|
-
// Export component
|
|
124
|
-
export default ErrorBox;
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Loading spinner/indicator
|
|
3
|
-
* @author Gabe Abrams
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// Import FontAwesome Icons
|
|
7
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
8
|
-
import { faCircle } from '@fortawesome/free-solid-svg-icons';
|
|
9
|
-
|
|
10
|
-
/*------------------------------------------------------------------------*/
|
|
11
|
-
/* Style */
|
|
12
|
-
/*------------------------------------------------------------------------*/
|
|
13
|
-
|
|
14
|
-
const style = `
|
|
15
|
-
/* Blips */
|
|
16
|
-
.LoadingSpinner-blip-1,
|
|
17
|
-
.LoadingSpinner-blip-2,
|
|
18
|
-
.LoadingSpinner-blip-3,
|
|
19
|
-
.LoadingSpinner-blip-4 {
|
|
20
|
-
font-size: 25px;
|
|
21
|
-
opacity: 0.6;
|
|
22
|
-
margin-top: 20px;
|
|
23
|
-
margin-bottom: 20px;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/* First Blip */
|
|
27
|
-
.LoadingSpinner-blip-1 {
|
|
28
|
-
animation: LoadingSpinner-pop-animation 2s infinite;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/* Second Blip */
|
|
32
|
-
.LoadingSpinner-blip-2 {
|
|
33
|
-
animation: LoadingSpinner-pop-animation 2s infinite;
|
|
34
|
-
-webkit-animation-delay: 0.1s;
|
|
35
|
-
animation-delay: 0.1s;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/* Third Blip */
|
|
39
|
-
.LoadingSpinner-blip-3 {
|
|
40
|
-
animation: LoadingSpinner-pop-animation 2s infinite;
|
|
41
|
-
animation-delay: 0.2s;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/* Fourth Blip */
|
|
45
|
-
.LoadingSpinner-blip-4 {
|
|
46
|
-
animation: LoadingSpinner-pop-animation 2s infinite;
|
|
47
|
-
animation-delay: 0.3s;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/* Pop Animation for Each Blip */
|
|
51
|
-
@keyframes LoadingSpinner-pop-animation {
|
|
52
|
-
0% {
|
|
53
|
-
transform: scale(1.0);
|
|
54
|
-
}
|
|
55
|
-
10% {
|
|
56
|
-
transform: scale(1.5);
|
|
57
|
-
}
|
|
58
|
-
30% {
|
|
59
|
-
transform: scale(1.0);
|
|
60
|
-
}
|
|
61
|
-
100% {
|
|
62
|
-
transform: scale(1.0);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
`;
|
|
66
|
-
|
|
67
|
-
/*------------------------------------------------------------------------*/
|
|
68
|
-
/* Component */
|
|
69
|
-
/*------------------------------------------------------------------------*/
|
|
70
|
-
|
|
71
|
-
const LoadingSpinner = () => {
|
|
72
|
-
/*------------------------------------------------------------------------*/
|
|
73
|
-
/* Render */
|
|
74
|
-
/*------------------------------------------------------------------------*/
|
|
75
|
-
|
|
76
|
-
// Add all four blips to a container
|
|
77
|
-
return (
|
|
78
|
-
<div className="text-center LoadingSpinner LoadingSpinner-container">
|
|
79
|
-
<style>{style}</style>
|
|
80
|
-
<FontAwesomeIcon
|
|
81
|
-
icon={faCircle}
|
|
82
|
-
className="LoadingSpinner-blip-1 me-1"
|
|
83
|
-
/>
|
|
84
|
-
<FontAwesomeIcon
|
|
85
|
-
icon={faCircle}
|
|
86
|
-
className="LoadingSpinner-blip-2 me-1"
|
|
87
|
-
/>
|
|
88
|
-
<FontAwesomeIcon
|
|
89
|
-
icon={faCircle}
|
|
90
|
-
className="LoadingSpinner-blip-3 me-1"
|
|
91
|
-
/>
|
|
92
|
-
<FontAwesomeIcon
|
|
93
|
-
icon={faCircle}
|
|
94
|
-
className="LoadingSpinner-blip-4"
|
|
95
|
-
/>
|
|
96
|
-
</div>
|
|
97
|
-
);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
/*------------------------------------------------------------------------*/
|
|
101
|
-
/* Wrap Up */
|
|
102
|
-
/*------------------------------------------------------------------------*/
|
|
103
|
-
|
|
104
|
-
// Export component
|
|
105
|
-
export default LoadingSpinner;
|