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
|
@@ -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:
|
|
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:
|
|
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
|
|
@@ -644,38 +644,6 @@ var LogLevel;
|
|
|
644
644
|
})(LogLevel || (LogLevel = {}));
|
|
645
645
|
var LogLevel$1 = LogLevel;
|
|
646
646
|
|
|
647
|
-
/*------------------------------------------------------------------------*/
|
|
648
|
-
/* --------------------------- Static Helpers --------------------------- */
|
|
649
|
-
/*------------------------------------------------------------------------*/
|
|
650
|
-
// Timestamp after initialization when helpers should be available
|
|
651
|
-
const timestampWhenHelpersShouldBeAvailable$1 = Date.now() + 2000;
|
|
652
|
-
/**
|
|
653
|
-
* Wait for a little while for a helper to exist
|
|
654
|
-
* @author Gabe Abrams
|
|
655
|
-
* @param checkForHelper a function that returns true if the helper exists
|
|
656
|
-
* @returns true if the helper exists, false if the process timed out
|
|
657
|
-
*/
|
|
658
|
-
const waitForHelper$1 = (checkForHelper) => __awaiter(void 0, void 0, void 0, function* () {
|
|
659
|
-
// Wait for helper to exist
|
|
660
|
-
while (!checkForHelper()) {
|
|
661
|
-
// Check if we should stop waiting
|
|
662
|
-
if (Date.now() > timestampWhenHelpersShouldBeAvailable$1) {
|
|
663
|
-
// Stop waiting
|
|
664
|
-
return false;
|
|
665
|
-
}
|
|
666
|
-
// Wait a little while
|
|
667
|
-
yield waitMs(10);
|
|
668
|
-
}
|
|
669
|
-
// Helper exists
|
|
670
|
-
return true;
|
|
671
|
-
});
|
|
672
|
-
/*------------------------------------------------------------------------*/
|
|
673
|
-
/* Listener */
|
|
674
|
-
/*------------------------------------------------------------------------*/
|
|
675
|
-
// Handler for session expiry
|
|
676
|
-
let sessionExpiryHandler;
|
|
677
|
-
// Keep track of whether or not session expiry has already been handled
|
|
678
|
-
let sessionAlreadyExpired = false;
|
|
679
647
|
/*------------------------------------------------------------------------*/
|
|
680
648
|
/* Stub Logic */
|
|
681
649
|
/*------------------------------------------------------------------------*/
|
|
@@ -758,24 +726,7 @@ const visitServerEndpoint = (opts) => __awaiter(void 0, void 0, void 0, function
|
|
|
758
726
|
if (!response.body.success) {
|
|
759
727
|
// Session expired
|
|
760
728
|
if (response.body.code === ReactKitErrorCode$1.SessionExpired) {
|
|
761
|
-
|
|
762
|
-
if (sessionAlreadyExpired) {
|
|
763
|
-
// Never return (browser is already reloading)
|
|
764
|
-
yield new Promise(() => {
|
|
765
|
-
// Promise that never returns
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
sessionAlreadyExpired = true;
|
|
769
|
-
// Wait for helper to exist
|
|
770
|
-
yield waitForHelper$1(() => {
|
|
771
|
-
return !!sessionExpiryHandler;
|
|
772
|
-
});
|
|
773
|
-
// Show session expiration message
|
|
774
|
-
{
|
|
775
|
-
// Fallback to alert
|
|
776
|
-
// eslint-disable-next-line no-alert
|
|
777
|
-
alert('Your session has expired. Please start over.');
|
|
778
|
-
}
|
|
729
|
+
showSessionExpiredMessage();
|
|
779
730
|
// Never return (don't continue execution)
|
|
780
731
|
yield new Promise(() => {
|
|
781
732
|
// Promise that never returns
|
|
@@ -903,7 +854,7 @@ let onAlertClosed;
|
|
|
903
854
|
* @param title the title text to display at the top of the alert
|
|
904
855
|
* @param text the text to display in the alert
|
|
905
856
|
*/
|
|
906
|
-
const alert
|
|
857
|
+
const alert = (title, text) => __awaiter(void 0, void 0, void 0, function* () {
|
|
907
858
|
// Wait for helper to exist
|
|
908
859
|
yield waitForHelper(() => {
|
|
909
860
|
return !!setAlertInfo;
|
|
@@ -1024,7 +975,7 @@ const showFatalError = (error, errorTitle = 'An Error Occurred') => __awaiter(vo
|
|
|
1024
975
|
});
|
|
1025
976
|
// Handle case where app hasn't loaded
|
|
1026
977
|
if (!setFatalErrorMessage || !setFatalErrorCode) {
|
|
1027
|
-
alert
|
|
978
|
+
alert(errorTitle, `${message} (code: ${code}). Please contact support.`);
|
|
1028
979
|
return;
|
|
1029
980
|
}
|
|
1030
981
|
// Use setters
|
|
@@ -1039,6 +990,28 @@ const showFatalError = (error, errorTitle = 'An Error Occurred') => __awaiter(vo
|
|
|
1039
990
|
const addFatalErrorHandler = (handler) => {
|
|
1040
991
|
fatalErrorHandlers.push(handler);
|
|
1041
992
|
};
|
|
993
|
+
/*----------------------------------------*/
|
|
994
|
+
/* ----------- Session Expired ---------- */
|
|
995
|
+
/*----------------------------------------*/
|
|
996
|
+
// Stored copies of setters
|
|
997
|
+
let setSessionHasExpired;
|
|
998
|
+
/**
|
|
999
|
+
* Show the "session expired" message
|
|
1000
|
+
* @author Gabe Abrams
|
|
1001
|
+
*/
|
|
1002
|
+
const showSessionExpiredMessage = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1003
|
+
// Wait for helper to exist
|
|
1004
|
+
yield waitForHelper(() => {
|
|
1005
|
+
return !!setSessionHasExpired;
|
|
1006
|
+
});
|
|
1007
|
+
// Show session expired message
|
|
1008
|
+
if (setSessionHasExpired) {
|
|
1009
|
+
setSessionHasExpired(true);
|
|
1010
|
+
}
|
|
1011
|
+
else {
|
|
1012
|
+
showFatalError('Your session has expired. Please start over.', 'Session Expired');
|
|
1013
|
+
}
|
|
1014
|
+
});
|
|
1042
1015
|
/*------------------------------------------------------------------------*/
|
|
1043
1016
|
/* -------------------------------- Style ------------------------------- */
|
|
1044
1017
|
/*------------------------------------------------------------------------*/
|
|
@@ -1091,6 +1064,7 @@ const AppWrapper = (props) => {
|
|
|
1091
1064
|
setConfirmInfo = setConfirmInfoInner;
|
|
1092
1065
|
// Session expired
|
|
1093
1066
|
const [sessionHasExpired, setSessionHasExpiredInner,] = useState(false);
|
|
1067
|
+
setSessionHasExpired = setSessionHasExpiredInner;
|
|
1094
1068
|
/*------------------------------------------------------------------------*/
|
|
1095
1069
|
/* ------------------------------- Render ------------------------------- */
|
|
1096
1070
|
/*------------------------------------------------------------------------*/
|
|
@@ -1160,7 +1134,9 @@ const AppWrapper = (props) => {
|
|
|
1160
1134
|
} },
|
|
1161
1135
|
React__default.createElement(ErrorBox, { title: (sessionHasExpired
|
|
1162
1136
|
? 'Session Expired'
|
|
1163
|
-
: fatalErrorTitle), error: error
|
|
1137
|
+
: fatalErrorTitle), error: error, variant: (isDarkModeOn()
|
|
1138
|
+
? Variant$1.Light
|
|
1139
|
+
: Variant$1.Secondary), icon: faHourglassEnd })));
|
|
1164
1140
|
}
|
|
1165
1141
|
/* --------------- App -------------- */
|
|
1166
1142
|
if (!body) {
|
|
@@ -2117,7 +2093,7 @@ const CopiableBox = (props) => {
|
|
|
2117
2093
|
yield navigator.clipboard.writeText(text);
|
|
2118
2094
|
}
|
|
2119
2095
|
catch (err) {
|
|
2120
|
-
return alert
|
|
2096
|
+
return alert('Unable to copy', 'Oops! We couldn\'t copy that to the clipboard. Please copy the text manually.');
|
|
2121
2097
|
}
|
|
2122
2098
|
// Show copied notice
|
|
2123
2099
|
dispatch({
|
|
@@ -2706,7 +2682,7 @@ const IntelliTable = (props) => {
|
|
|
2706
2682
|
return !isSelected;
|
|
2707
2683
|
}));
|
|
2708
2684
|
if (noColumnsSelected) {
|
|
2709
|
-
return alert
|
|
2685
|
+
return alert('Choose at least one column', 'To continue, you have to choose at least one column to show');
|
|
2710
2686
|
}
|
|
2711
2687
|
dispatch({
|
|
2712
2688
|
type: ActionType$6.ToggleColVisCusModalVisibility,
|
|
@@ -3718,7 +3694,7 @@ const LogReviewer = (props) => {
|
|
|
3718
3694
|
|| (year === dateFilterState.startDate.year
|
|
3719
3695
|
&& month === dateFilterState.startDate.month
|
|
3720
3696
|
&& day < dateFilterState.startDate.day)) {
|
|
3721
|
-
return alert
|
|
3697
|
+
return alert('Invalid Start Date', 'The start date cannot be before the end date.');
|
|
3722
3698
|
}
|
|
3723
3699
|
dateFilterState.endDate = { month, day, year };
|
|
3724
3700
|
handleDateRangeUpdated(dateFilterState);
|
|
@@ -40215,7 +40191,7 @@ const AddOrEditDBEntry = (props) => {
|
|
|
40215
40191
|
React__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* () {
|
|
40216
40192
|
// Show validation errors
|
|
40217
40193
|
if (validationError && validationError.length > 0) {
|
|
40218
|
-
return alert
|
|
40194
|
+
return alert('Please fix the following error', validationError);
|
|
40219
40195
|
}
|
|
40220
40196
|
// Run the included validator if it exists
|
|
40221
40197
|
if (validateEntry) {
|
|
@@ -40223,7 +40199,7 @@ const AddOrEditDBEntry = (props) => {
|
|
|
40223
40199
|
yield validateEntry(entry);
|
|
40224
40200
|
}
|
|
40225
40201
|
catch (error) {
|
|
40226
|
-
return alert
|
|
40202
|
+
return alert('Please fix the following error', String(error));
|
|
40227
40203
|
}
|
|
40228
40204
|
}
|
|
40229
40205
|
save();
|
|
@@ -43106,5 +43082,5 @@ var DayOfWeek;
|
|
|
43106
43082
|
})(DayOfWeek || (DayOfWeek = {}));
|
|
43107
43083
|
var DayOfWeek$1 = DayOfWeek;
|
|
43108
43084
|
|
|
43109
|
-
export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntryFieldType$1 as DBEntryFieldType, DBEntryManagerPanel, DayOfWeek$1 as DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogReviewer, LogSource$1 as LogSource, LogType$1 as LogType, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant$1 as Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert
|
|
43085
|
+
export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntryFieldType$1 as DBEntryFieldType, DBEntryManagerPanel, DayOfWeek$1 as DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogReviewer, LogSource$1 as LogSource, LogType$1 as LogType, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant$1 as Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert, avg, canReviewLogs, ceilToNumDecimals, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
|
|
43110
43086
|
//# sourceMappingURL=index.js.map
|