dce-reactkit 3.5.4 → 3.5.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 CHANGED
@@ -778,10 +778,10 @@ const logClientEvent = (opts) => __awaiter(void 0, void 0, void 0, function* ()
778
778
  * @author Gabe Abrams
779
779
  */
780
780
  /*------------------------------------------------------------------------*/
781
- /* Static Helpers */
781
+ /* --------------------------- Static Helpers --------------------------- */
782
782
  /*------------------------------------------------------------------------*/
783
783
  /*----------------------------------------*/
784
- /* Alert */
784
+ /* ---------------- Alert --------------- */
785
785
  /*----------------------------------------*/
786
786
  // Stored copies of setters
787
787
  let setAlertInfo;
@@ -795,6 +795,7 @@ let onAlertClosed;
795
795
  const alert$1 = (title, text) => __awaiter(void 0, void 0, void 0, function* () {
796
796
  // Fallback if alert not available
797
797
  if (!setAlertInfo) {
798
+ // eslint-disable-next-line no-alert
798
799
  window.alert(`${title}\n\n${text}`);
799
800
  return undefined;
800
801
  }
@@ -812,7 +813,7 @@ const alert$1 = (title, text) => __awaiter(void 0, void 0, void 0, function* ()
812
813
  });
813
814
  });
814
815
  /*----------------------------------------*/
815
- /* Confirm */
816
+ /* --------------- Confirm -------------- */
816
817
  /*----------------------------------------*/
817
818
  // Stored copies of setters
818
819
  let setConfirmInfo;
@@ -835,6 +836,7 @@ let onConfirmClosed;
835
836
  const confirm = (title, text, opts) => __awaiter(void 0, void 0, void 0, function* () {
836
837
  // Fallback if confirm is not available
837
838
  if (!setConfirmInfo) {
839
+ // eslint-disable-next-line no-alert
838
840
  return window.confirm(`${title}\n\n${text}`);
839
841
  }
840
842
  // Return promise that resolves with result of confirmation
@@ -852,12 +854,14 @@ const confirm = (title, text, opts) => __awaiter(void 0, void 0, void 0, functio
852
854
  });
853
855
  });
854
856
  /*----------------------------------------*/
855
- /* Fatal Error */
857
+ /* ------------- Fatal Error ------------ */
856
858
  /*----------------------------------------*/
857
859
  // Stored copies of setters
858
860
  let setFatalErrorMessage;
859
861
  let setFatalErrorCode;
860
862
  let setFatalErrorTitle;
863
+ // Fatal error listeners
864
+ const fatalErrorHandlers = [];
861
865
  /**
862
866
  * Show a fatal error message
863
867
  * @author Gabe Abrams
@@ -873,6 +877,15 @@ const showFatalError = (error, errorTitle = 'An Error Occurred') => {
873
877
  const code = (typeof error === 'string'
874
878
  ? ReactKitErrorCode$1.NoCode
875
879
  : String((_b = error.code) !== null && _b !== void 0 ? _b : ReactKitErrorCode$1.NoCode));
880
+ // Call all fatal error listeners
881
+ try {
882
+ fatalErrorHandlers.forEach((handler) => {
883
+ handler();
884
+ });
885
+ }
886
+ catch (err) {
887
+ // Ignore listener errors
888
+ }
876
889
  // Add log
877
890
  logClientEvent({
878
891
  context: LogBuiltInMetadata.Context.ClientFatalError,
@@ -896,12 +909,19 @@ const showFatalError = (error, errorTitle = 'An Error Occurred') => {
896
909
  setFatalErrorTitle(errorTitle);
897
910
  return undefined;
898
911
  };
912
+ /**
913
+ * Add a handler for when a fatal error occurs
914
+ * @author Gabe Abrams
915
+ */
916
+ const addFatalErrorHandler = (handler) => {
917
+ fatalErrorHandlers.push(handler);
918
+ };
899
919
  /*------------------------------------------------------------------------*/
900
- /* Component */
920
+ /* ------------------------------ Component ----------------------------- */
901
921
  /*------------------------------------------------------------------------*/
902
922
  const AppWrapper = (props) => {
903
923
  /*------------------------------------------------------------------------*/
904
- /* Setup */
924
+ /* -------------------------------- Setup ------------------------------- */
905
925
  /*------------------------------------------------------------------------*/
906
926
  /* -------------- Props ------------- */
907
927
  const { children, dark, } = props;
@@ -922,10 +942,10 @@ const AppWrapper = (props) => {
922
942
  // Session expired
923
943
  const [sessionHasExpired, setSessionHasExpiredInner,] = React.useState(false);
924
944
  /*------------------------------------------------------------------------*/
925
- /* Render */
945
+ /* ------------------------------- Render ------------------------------- */
926
946
  /*------------------------------------------------------------------------*/
927
947
  /*----------------------------------------*/
928
- /* Modal */
948
+ /* ---------------- Modal --------------- */
929
949
  /*----------------------------------------*/
930
950
  // Modal that may be defined
931
951
  let modal;
@@ -949,7 +969,7 @@ const AppWrapper = (props) => {
949
969
  }, dontAllowBackdropExit: true }, confirmInfo.text));
950
970
  }
951
971
  /*----------------------------------------*/
952
- /* Views */
972
+ /* ---------------- Views --------------- */
953
973
  /*----------------------------------------*/
954
974
  // Body that will be filled with the current view
955
975
  let body;
@@ -975,7 +995,7 @@ const AppWrapper = (props) => {
975
995
  }
976
996
  /* --------------- App -------------- */
977
997
  if (!body) {
978
- body = (React__default["default"].createElement(React__default["default"].Fragment, null, children));
998
+ body = children;
979
999
  }
980
1000
  /*----------------------------------------*/
981
1001
  /* Main UI */
@@ -40656,6 +40676,39 @@ const Tooltip = (props) => {
40656
40676
  React__default["default"].createElement("span", { className: "Tooltip-text" }, text))))));
40657
40677
  };
40658
40678
 
40679
+ /**
40680
+ * A toggle switch that toggles on or off
40681
+ * @author Alessandra De Lucas
40682
+ * @author Gabe Abrams
40683
+ */
40684
+ /*------------------------------------------------------------------------*/
40685
+ /* ------------------------------ Component ----------------------------- */
40686
+ /*------------------------------------------------------------------------*/
40687
+ const ToggleSwitch = (props) => {
40688
+ /*------------------------------------------------------------------------*/
40689
+ /* -------------------------------- Setup ------------------------------- */
40690
+ /*------------------------------------------------------------------------*/
40691
+ /* -------------- Props ------------- */
40692
+ // Destructure all props
40693
+ const { isOn, onToggle, id, description, backgroundVariantWhenOn = Variant$1.Info, } = props;
40694
+ /*------------------------------------------------------------------------*/
40695
+ /* ------------------------------- Render ------------------------------- */
40696
+ /*------------------------------------------------------------------------*/
40697
+ /*----------------------------------------*/
40698
+ /* --------------- Main UI -------------- */
40699
+ /*----------------------------------------*/
40700
+ const backgroundVariant = (isOn
40701
+ ? backgroundVariantWhenOn
40702
+ : 'secondary');
40703
+ return (React__default["default"].createElement("button", { id: id, "aria-label": `If on, ${description}. Currently ${isOn ? 'on' : 'off'}. Click to turn ${isOn ? 'off' : 'on'}.`, className: `alert alert-${backgroundVariant} bg-${backgroundVariant} mb-0 rounded-pill d-inline-block pt-0 pb-0 px-3`, onClick: () => {
40704
+ onToggle(!isOn);
40705
+ }, type: "button" },
40706
+ React__default["default"].createElement(reactFontawesome.FontAwesomeIcon, { icon: freeSolidSvgIcons.faCircle, className: "text-light", style: {
40707
+ transform: `translateX(${isOn ? '' : '-'}0.7rem)`,
40708
+ transition: '0.3s transform ease-in-out',
40709
+ } })));
40710
+ };
40711
+
40659
40712
  /**
40660
40713
  * One minute in ms
40661
40714
  * @author Gabe Abrams
@@ -42570,10 +42623,12 @@ exports.RadioButton = RadioButton;
42570
42623
  exports.ReactKitErrorCode = ReactKitErrorCode$1;
42571
42624
  exports.SimpleDateChooser = SimpleDateChooser;
42572
42625
  exports.TabBox = TabBox;
42626
+ exports.ToggleSwitch = ToggleSwitch;
42573
42627
  exports.Tooltip = Tooltip;
42574
42628
  exports.Variant = Variant$1;
42575
42629
  exports.abbreviate = abbreviate;
42576
42630
  exports.addDBEditorEndpoints = addDBEditorEndpoints;
42631
+ exports.addFatalErrorHandler = addFatalErrorHandler;
42577
42632
  exports.alert = alert$1;
42578
42633
  exports.avg = avg;
42579
42634
  exports.canReviewLogs = canReviewLogs;