dce-reactkit 3.6.3 → 3.6.4

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.
@@ -1,9 +1,3 @@
1
- /**
2
- * Set the session expiry handler
3
- * @author Gabe Abrams
4
- * @param handler new handler to use when session expires
5
- */
6
- export declare const setSessionExpiryHandler: (handler: () => void) => void;
7
1
  /**
8
2
  * Add a stub response
9
3
  * @author Gabe Abrams
package/dist/esm/index.js CHANGED
@@ -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
- // Skip notice if session was already expired
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$1 = (title, text) => __awaiter(void 0, void 0, void 0, function* () {
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$1(errorTitle, `${message} (code: ${code}). Please contact support.`);
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
  /*------------------------------------------------------------------------*/
@@ -2117,7 +2091,7 @@ const CopiableBox = (props) => {
2117
2091
  yield navigator.clipboard.writeText(text);
2118
2092
  }
2119
2093
  catch (err) {
2120
- return alert$1('Unable to copy', 'Oops! We couldn\'t copy that to the clipboard. Please copy the text manually.');
2094
+ return alert('Unable to copy', 'Oops! We couldn\'t copy that to the clipboard. Please copy the text manually.');
2121
2095
  }
2122
2096
  // Show copied notice
2123
2097
  dispatch({
@@ -2706,7 +2680,7 @@ const IntelliTable = (props) => {
2706
2680
  return !isSelected;
2707
2681
  }));
2708
2682
  if (noColumnsSelected) {
2709
- return alert$1('Choose at least one column', 'To continue, you have to choose at least one column to show');
2683
+ return alert('Choose at least one column', 'To continue, you have to choose at least one column to show');
2710
2684
  }
2711
2685
  dispatch({
2712
2686
  type: ActionType$6.ToggleColVisCusModalVisibility,
@@ -3718,7 +3692,7 @@ const LogReviewer = (props) => {
3718
3692
  || (year === dateFilterState.startDate.year
3719
3693
  && month === dateFilterState.startDate.month
3720
3694
  && day < dateFilterState.startDate.day)) {
3721
- return alert$1('Invalid Start Date', 'The start date cannot be before the end date.');
3695
+ return alert('Invalid Start Date', 'The start date cannot be before the end date.');
3722
3696
  }
3723
3697
  dateFilterState.endDate = { month, day, year };
3724
3698
  handleDateRangeUpdated(dateFilterState);
@@ -40215,7 +40189,7 @@ const AddOrEditDBEntry = (props) => {
40215
40189
  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
40190
  // Show validation errors
40217
40191
  if (validationError && validationError.length > 0) {
40218
- return alert$1('Please fix the following error', validationError);
40192
+ return alert('Please fix the following error', validationError);
40219
40193
  }
40220
40194
  // Run the included validator if it exists
40221
40195
  if (validateEntry) {
@@ -40223,7 +40197,7 @@ const AddOrEditDBEntry = (props) => {
40223
40197
  yield validateEntry(entry);
40224
40198
  }
40225
40199
  catch (error) {
40226
- return alert$1('Please fix the following error', String(error));
40200
+ return alert('Please fix the following error', String(error));
40227
40201
  }
40228
40202
  }
40229
40203
  save();
@@ -43106,5 +43080,5 @@ var DayOfWeek;
43106
43080
  })(DayOfWeek || (DayOfWeek = {}));
43107
43081
  var DayOfWeek$1 = DayOfWeek;
43108
43082
 
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$1 as 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 };
43083
+ 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
43084
  //# sourceMappingURL=index.js.map