dce-reactkit 3.6.3 → 3.6.5
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 +56 -80
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/ErrorBox.d.ts +4 -0
- package/dist/cjs/types/helpers/visitServerEndpoint.d.ts +0 -6
- package/dist/esm/index.js +56 -80
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/ErrorBox.d.ts +4 -0
- package/dist/esm/types/helpers/visitServerEndpoint.d.ts +0 -6
- package/dist/index.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/AppWrapper.tsx +9 -0
- package/src/components/ErrorBox.tsx +10 -2
- package/src/helpers/visitServerEndpoint.tsx +5 -75
package/dist/cjs/index.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var reactFontawesome = require('@fortawesome/react-fontawesome');
|
|
7
6
|
var freeSolidSvgIcons = require('@fortawesome/free-solid-svg-icons');
|
|
7
|
+
var reactFontawesome = require('@fortawesome/react-fontawesome');
|
|
8
8
|
var freeRegularSvgIcons = require('@fortawesome/free-regular-svg-icons');
|
|
9
9
|
|
|
10
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -78,6 +78,23 @@ var ReactKitErrorCode;
|
|
|
78
78
|
})(ReactKitErrorCode || (ReactKitErrorCode = {}));
|
|
79
79
|
var ReactKitErrorCode$1 = ReactKitErrorCode;
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Bootstrap variants
|
|
83
|
+
* @author Gabe Abrams
|
|
84
|
+
*/
|
|
85
|
+
var Variant;
|
|
86
|
+
(function (Variant) {
|
|
87
|
+
Variant["Primary"] = "primary";
|
|
88
|
+
Variant["Secondary"] = "secondary";
|
|
89
|
+
Variant["Success"] = "success";
|
|
90
|
+
Variant["Warning"] = "warning";
|
|
91
|
+
Variant["Info"] = "info";
|
|
92
|
+
Variant["Danger"] = "danger";
|
|
93
|
+
Variant["Light"] = "light";
|
|
94
|
+
Variant["Dark"] = "dark";
|
|
95
|
+
})(Variant || (Variant = {}));
|
|
96
|
+
var Variant$1 = Variant;
|
|
97
|
+
|
|
81
98
|
/**
|
|
82
99
|
* Displays an error
|
|
83
100
|
* @author Gabe Abrams
|
|
@@ -91,7 +108,7 @@ const ErrorBox = (props) => {
|
|
|
91
108
|
/*------------------------------------------------------------------------*/
|
|
92
109
|
var _a;
|
|
93
110
|
/* -------------- Props ------------- */
|
|
94
|
-
const { error, title = 'An Error Occurred', onClose, } = props;
|
|
111
|
+
const { error, title = 'An Error Occurred', onClose, variant = Variant$1.Danger, icon = freeSolidSvgIcons.faExclamationTriangle, } = props;
|
|
95
112
|
/*------------------------------------------------------------------------*/
|
|
96
113
|
/* ------------------------------- Render ------------------------------- */
|
|
97
114
|
/*------------------------------------------------------------------------*/
|
|
@@ -119,12 +136,12 @@ const ErrorBox = (props) => {
|
|
|
119
136
|
String((_a = error.code) !== null && _a !== void 0 ? _a : ReactKitErrorCode$1.NoCode).toUpperCase())));
|
|
120
137
|
}
|
|
121
138
|
// Main UI
|
|
122
|
-
return (React__default["default"].createElement("div", { className:
|
|
139
|
+
return (React__default["default"].createElement("div", { className: `alert alert-${variant} text-center`, style: {
|
|
123
140
|
maxWidth: '40rem',
|
|
124
141
|
margin: 'auto',
|
|
125
142
|
} },
|
|
126
143
|
React__default["default"].createElement("h4", { className: "mb-1" },
|
|
127
|
-
React__default["default"].createElement(reactFontawesome.FontAwesomeIcon, { icon:
|
|
144
|
+
React__default["default"].createElement(reactFontawesome.FontAwesomeIcon, { icon: icon, className: "me-2" }),
|
|
128
145
|
title),
|
|
129
146
|
React__default["default"].createElement("div", null,
|
|
130
147
|
errorText,
|
|
@@ -199,23 +216,6 @@ const waitMs = (ms = 0) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
199
216
|
});
|
|
200
217
|
});
|
|
201
218
|
|
|
202
|
-
/**
|
|
203
|
-
* Bootstrap variants
|
|
204
|
-
* @author Gabe Abrams
|
|
205
|
-
*/
|
|
206
|
-
var Variant;
|
|
207
|
-
(function (Variant) {
|
|
208
|
-
Variant["Primary"] = "primary";
|
|
209
|
-
Variant["Secondary"] = "secondary";
|
|
210
|
-
Variant["Success"] = "success";
|
|
211
|
-
Variant["Warning"] = "warning";
|
|
212
|
-
Variant["Info"] = "info";
|
|
213
|
-
Variant["Danger"] = "danger";
|
|
214
|
-
Variant["Light"] = "light";
|
|
215
|
-
Variant["Dark"] = "dark";
|
|
216
|
-
})(Variant || (Variant = {}));
|
|
217
|
-
var Variant$1 = Variant;
|
|
218
|
-
|
|
219
219
|
/**
|
|
220
220
|
* Modal sizes
|
|
221
221
|
* @author Gabe Abrams
|
|
@@ -670,38 +670,6 @@ var LogLevel;
|
|
|
670
670
|
})(LogLevel || (LogLevel = {}));
|
|
671
671
|
var LogLevel$1 = LogLevel;
|
|
672
672
|
|
|
673
|
-
/*------------------------------------------------------------------------*/
|
|
674
|
-
/* --------------------------- Static Helpers --------------------------- */
|
|
675
|
-
/*------------------------------------------------------------------------*/
|
|
676
|
-
// Timestamp after initialization when helpers should be available
|
|
677
|
-
const timestampWhenHelpersShouldBeAvailable$1 = Date.now() + 2000;
|
|
678
|
-
/**
|
|
679
|
-
* Wait for a little while for a helper to exist
|
|
680
|
-
* @author Gabe Abrams
|
|
681
|
-
* @param checkForHelper a function that returns true if the helper exists
|
|
682
|
-
* @returns true if the helper exists, false if the process timed out
|
|
683
|
-
*/
|
|
684
|
-
const waitForHelper$1 = (checkForHelper) => __awaiter(void 0, void 0, void 0, function* () {
|
|
685
|
-
// Wait for helper to exist
|
|
686
|
-
while (!checkForHelper()) {
|
|
687
|
-
// Check if we should stop waiting
|
|
688
|
-
if (Date.now() > timestampWhenHelpersShouldBeAvailable$1) {
|
|
689
|
-
// Stop waiting
|
|
690
|
-
return false;
|
|
691
|
-
}
|
|
692
|
-
// Wait a little while
|
|
693
|
-
yield waitMs(10);
|
|
694
|
-
}
|
|
695
|
-
// Helper exists
|
|
696
|
-
return true;
|
|
697
|
-
});
|
|
698
|
-
/*------------------------------------------------------------------------*/
|
|
699
|
-
/* Listener */
|
|
700
|
-
/*------------------------------------------------------------------------*/
|
|
701
|
-
// Handler for session expiry
|
|
702
|
-
let sessionExpiryHandler;
|
|
703
|
-
// Keep track of whether or not session expiry has already been handled
|
|
704
|
-
let sessionAlreadyExpired = false;
|
|
705
673
|
/*------------------------------------------------------------------------*/
|
|
706
674
|
/* Stub Logic */
|
|
707
675
|
/*------------------------------------------------------------------------*/
|
|
@@ -784,24 +752,7 @@ const visitServerEndpoint = (opts) => __awaiter(void 0, void 0, void 0, function
|
|
|
784
752
|
if (!response.body.success) {
|
|
785
753
|
// Session expired
|
|
786
754
|
if (response.body.code === ReactKitErrorCode$1.SessionExpired) {
|
|
787
|
-
|
|
788
|
-
if (sessionAlreadyExpired) {
|
|
789
|
-
// Never return (browser is already reloading)
|
|
790
|
-
yield new Promise(() => {
|
|
791
|
-
// Promise that never returns
|
|
792
|
-
});
|
|
793
|
-
}
|
|
794
|
-
sessionAlreadyExpired = true;
|
|
795
|
-
// Wait for helper to exist
|
|
796
|
-
yield waitForHelper$1(() => {
|
|
797
|
-
return !!sessionExpiryHandler;
|
|
798
|
-
});
|
|
799
|
-
// Show session expiration message
|
|
800
|
-
{
|
|
801
|
-
// Fallback to alert
|
|
802
|
-
// eslint-disable-next-line no-alert
|
|
803
|
-
alert('Your session has expired. Please start over.');
|
|
804
|
-
}
|
|
755
|
+
showSessionExpiredMessage();
|
|
805
756
|
// Never return (don't continue execution)
|
|
806
757
|
yield new Promise(() => {
|
|
807
758
|
// Promise that never returns
|
|
@@ -929,7 +880,7 @@ let onAlertClosed;
|
|
|
929
880
|
* @param title the title text to display at the top of the alert
|
|
930
881
|
* @param text the text to display in the alert
|
|
931
882
|
*/
|
|
932
|
-
const alert
|
|
883
|
+
const alert = (title, text) => __awaiter(void 0, void 0, void 0, function* () {
|
|
933
884
|
// Wait for helper to exist
|
|
934
885
|
yield waitForHelper(() => {
|
|
935
886
|
return !!setAlertInfo;
|
|
@@ -1050,7 +1001,7 @@ const showFatalError = (error, errorTitle = 'An Error Occurred') => __awaiter(vo
|
|
|
1050
1001
|
});
|
|
1051
1002
|
// Handle case where app hasn't loaded
|
|
1052
1003
|
if (!setFatalErrorMessage || !setFatalErrorCode) {
|
|
1053
|
-
alert
|
|
1004
|
+
alert(errorTitle, `${message} (code: ${code}). Please contact support.`);
|
|
1054
1005
|
return;
|
|
1055
1006
|
}
|
|
1056
1007
|
// Use setters
|
|
@@ -1065,6 +1016,28 @@ const showFatalError = (error, errorTitle = 'An Error Occurred') => __awaiter(vo
|
|
|
1065
1016
|
const addFatalErrorHandler = (handler) => {
|
|
1066
1017
|
fatalErrorHandlers.push(handler);
|
|
1067
1018
|
};
|
|
1019
|
+
/*----------------------------------------*/
|
|
1020
|
+
/* ----------- Session Expired ---------- */
|
|
1021
|
+
/*----------------------------------------*/
|
|
1022
|
+
// Stored copies of setters
|
|
1023
|
+
let setSessionHasExpired;
|
|
1024
|
+
/**
|
|
1025
|
+
* Show the "session expired" message
|
|
1026
|
+
* @author Gabe Abrams
|
|
1027
|
+
*/
|
|
1028
|
+
const showSessionExpiredMessage = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1029
|
+
// Wait for helper to exist
|
|
1030
|
+
yield waitForHelper(() => {
|
|
1031
|
+
return !!setSessionHasExpired;
|
|
1032
|
+
});
|
|
1033
|
+
// Show session expired message
|
|
1034
|
+
if (setSessionHasExpired) {
|
|
1035
|
+
setSessionHasExpired(true);
|
|
1036
|
+
}
|
|
1037
|
+
else {
|
|
1038
|
+
showFatalError('Your session has expired. Please start over.', 'Session Expired');
|
|
1039
|
+
}
|
|
1040
|
+
});
|
|
1068
1041
|
/*------------------------------------------------------------------------*/
|
|
1069
1042
|
/* -------------------------------- Style ------------------------------- */
|
|
1070
1043
|
/*------------------------------------------------------------------------*/
|
|
@@ -1117,6 +1090,7 @@ const AppWrapper = (props) => {
|
|
|
1117
1090
|
setConfirmInfo = setConfirmInfoInner;
|
|
1118
1091
|
// Session expired
|
|
1119
1092
|
const [sessionHasExpired, setSessionHasExpiredInner,] = React.useState(false);
|
|
1093
|
+
setSessionHasExpired = setSessionHasExpiredInner;
|
|
1120
1094
|
/*------------------------------------------------------------------------*/
|
|
1121
1095
|
/* ------------------------------- Render ------------------------------- */
|
|
1122
1096
|
/*------------------------------------------------------------------------*/
|
|
@@ -1186,7 +1160,9 @@ const AppWrapper = (props) => {
|
|
|
1186
1160
|
} },
|
|
1187
1161
|
React__default["default"].createElement(ErrorBox, { title: (sessionHasExpired
|
|
1188
1162
|
? 'Session Expired'
|
|
1189
|
-
: fatalErrorTitle), error: error
|
|
1163
|
+
: fatalErrorTitle), error: error, variant: (isDarkModeOn()
|
|
1164
|
+
? Variant$1.Light
|
|
1165
|
+
: Variant$1.Secondary), icon: freeSolidSvgIcons.faHourglassEnd })));
|
|
1190
1166
|
}
|
|
1191
1167
|
/* --------------- App -------------- */
|
|
1192
1168
|
if (!body) {
|
|
@@ -2143,7 +2119,7 @@ const CopiableBox = (props) => {
|
|
|
2143
2119
|
yield navigator.clipboard.writeText(text);
|
|
2144
2120
|
}
|
|
2145
2121
|
catch (err) {
|
|
2146
|
-
return alert
|
|
2122
|
+
return alert('Unable to copy', 'Oops! We couldn\'t copy that to the clipboard. Please copy the text manually.');
|
|
2147
2123
|
}
|
|
2148
2124
|
// Show copied notice
|
|
2149
2125
|
dispatch({
|
|
@@ -2732,7 +2708,7 @@ const IntelliTable = (props) => {
|
|
|
2732
2708
|
return !isSelected;
|
|
2733
2709
|
}));
|
|
2734
2710
|
if (noColumnsSelected) {
|
|
2735
|
-
return alert
|
|
2711
|
+
return alert('Choose at least one column', 'To continue, you have to choose at least one column to show');
|
|
2736
2712
|
}
|
|
2737
2713
|
dispatch({
|
|
2738
2714
|
type: ActionType$6.ToggleColVisCusModalVisibility,
|
|
@@ -3744,7 +3720,7 @@ const LogReviewer = (props) => {
|
|
|
3744
3720
|
|| (year === dateFilterState.startDate.year
|
|
3745
3721
|
&& month === dateFilterState.startDate.month
|
|
3746
3722
|
&& day < dateFilterState.startDate.day)) {
|
|
3747
|
-
return alert
|
|
3723
|
+
return alert('Invalid Start Date', 'The start date cannot be before the end date.');
|
|
3748
3724
|
}
|
|
3749
3725
|
dateFilterState.endDate = { month, day, year };
|
|
3750
3726
|
handleDateRangeUpdated(dateFilterState);
|
|
@@ -40241,7 +40217,7 @@ const AddOrEditDBEntry = (props) => {
|
|
|
40241
40217
|
React__default["default"].createElement("button", { type: "button", id: "AddOrEditDBEntry-save-changes-button", className: "btn btn-primary btn-lg me-1", "aria-label": "Save changes", onClick: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
40242
40218
|
// Show validation errors
|
|
40243
40219
|
if (validationError && validationError.length > 0) {
|
|
40244
|
-
return alert
|
|
40220
|
+
return alert('Please fix the following error', validationError);
|
|
40245
40221
|
}
|
|
40246
40222
|
// Run the included validator if it exists
|
|
40247
40223
|
if (validateEntry) {
|
|
@@ -40249,7 +40225,7 @@ const AddOrEditDBEntry = (props) => {
|
|
|
40249
40225
|
yield validateEntry(entry);
|
|
40250
40226
|
}
|
|
40251
40227
|
catch (error) {
|
|
40252
|
-
return alert
|
|
40228
|
+
return alert('Please fix the following error', String(error));
|
|
40253
40229
|
}
|
|
40254
40230
|
}
|
|
40255
40231
|
save();
|
|
@@ -43174,7 +43150,7 @@ exports.Variant = Variant$1;
|
|
|
43174
43150
|
exports.abbreviate = abbreviate;
|
|
43175
43151
|
exports.addDBEditorEndpoints = addDBEditorEndpoints;
|
|
43176
43152
|
exports.addFatalErrorHandler = addFatalErrorHandler;
|
|
43177
|
-
exports.alert = alert
|
|
43153
|
+
exports.alert = alert;
|
|
43178
43154
|
exports.avg = avg;
|
|
43179
43155
|
exports.canReviewLogs = canReviewLogs;
|
|
43180
43156
|
exports.ceilToNumDecimals = ceilToNumDecimals;
|