dce-reactkit 3.7.9 → 3.7.10-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.
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import React from 'react';
7
7
  import Variant from '../types/Variant';
8
+ import ModalProps from './Modal/ModalProps';
8
9
  type Props = {
9
10
  children: React.ReactNode;
10
11
  };
@@ -61,5 +62,25 @@ export declare const addFatalErrorHandler: (handler: () => void) => void;
61
62
  * @author Gabe Abrams
62
63
  */
63
64
  export declare const showSessionExpiredMessage: () => Promise<void>;
65
+ /**
66
+ * Add a modal to the screen
67
+ * @author Gabe Abrams
68
+ * @param id the uniqueId of the modal
69
+ * @param props the props for the modal
70
+ */
71
+ export declare const addModal: (id: number, props: ModalProps) => Promise<void>;
72
+ /**
73
+ * Update a modal on the screen by id (if it exists) with new props
74
+ * @author Gabe Abrams
75
+ * @param id the uniqueId of the modal
76
+ * @param props the new props for the modal
77
+ */
78
+ export declare const updateModal: (id: number, props: ModalProps) => Promise<void>;
79
+ /**
80
+ * Remove a modal from the screen by id (if it exists)
81
+ * @author Gabe Abrams
82
+ * @param id the uniqueId of the modal
83
+ */
84
+ export declare const removeModal: (id: number) => Promise<void>;
64
85
  declare const AppWrapper: React.FC<Props>;
65
86
  export default AppWrapper;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The displayable modal component (this is the modal that's added to the
3
+ * wrapper, not the one that the programmer renders)
4
+ * @author Gabe Abrams
5
+ */
6
+ import React from 'react';
7
+ import ModalProps from './ModalProps';
8
+ declare const Modal: React.FC<ModalProps>;
9
+ export default Modal;
@@ -1,13 +1,14 @@
1
+ /// <reference types="react" />
2
+ import Variant from '../../types/Variant';
3
+ import ModalButtonType from '../../types/ModalButtonType';
4
+ import ModalSize from '../../types/ModalSize';
5
+ import ModalType from '../../types/ModalType';
1
6
  /**
2
- * A generic popup modal
7
+ * Props for the Modal component
3
8
  * @author Gabe Abrams
4
9
  */
5
- import React from 'react';
6
- import Variant from '../types/Variant';
7
- import ModalButtonType from '../types/ModalButtonType';
8
- import ModalSize from '../types/ModalSize';
9
- import ModalType from '../types/ModalType';
10
- type Props = {
10
+ type ModalProps = {
11
+ key?: string;
11
12
  type?: ModalType;
12
13
  size?: ModalSize;
13
14
  title?: React.ReactNode;
@@ -37,5 +38,4 @@ type Props = {
37
38
  confirmVariant?: Variant;
38
39
  onTopOfOtherModals?: boolean;
39
40
  };
40
- declare const Modal: React.FC<Props>;
41
- export default Modal;
41
+ export default ModalProps;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * General use modal component
3
+ * @author Gabe Abrams
4
+ */
5
+ import React from 'react';
6
+ import ModalProps from './ModalProps';
7
+ declare const Modal: React.FC<ModalProps>;
8
+ export default Modal;
package/dist/esm/index.js CHANGED
@@ -387,7 +387,7 @@ const getModalButtonTypeToLabelAndVariant = () => {
387
387
  /* -------------------------------- Style ------------------------------- */
388
388
  /*------------------------------------------------------------------------*/
389
389
  const style$a = `
390
- .Modal-backdrop {
390
+ .ModalForWrapper-backdrop {
391
391
  position: fixed;
392
392
  top: 0;
393
393
  left: 0;
@@ -395,7 +395,7 @@ const style$a = `
395
395
  height: 200vh;
396
396
  background-color: rgba(0, 0, 0, 0.7);
397
397
  }
398
- .Modal-fading-in {
398
+ .ModalForWrapper-fading-in {
399
399
  animation-name: Modal-fading-in;
400
400
  animation-duration: ${Math.floor(MS_TO_ANIMATE * 2)}ms;
401
401
  animation-iteration-count: 1;
@@ -410,7 +410,7 @@ const style$a = `
410
410
  opacity: 1;
411
411
  }
412
412
  }
413
- .Modal-animating-in {
413
+ .ModalForWrapper-animating-in {
414
414
  animation-name: Modal-animating-in;
415
415
  animation-duration: ${MS_TO_ANIMATE}ms;
416
416
  animation-iteration-count: 1;
@@ -427,14 +427,14 @@ const style$a = `
427
427
  opacity: 1;
428
428
  }
429
429
  }
430
- .Modal-animating-pop {
431
- animation-name: Modal-animating-pop;
430
+ .ModalForWrapper-animating-pop {
431
+ animation-name: ModalForWrapper-animating-pop;
432
432
  animation-duration: ${MS_TO_ANIMATE}ms;
433
433
  animation-iteration-count: 1;
434
434
  animation-fill-mode: both;
435
435
  animation-timing-function: ease-in-out;
436
436
  }
437
- @keyframes Modal-animating-pop {
437
+ @keyframes ModalForWrapper-animating-pop {
438
438
  0% {
439
439
  transform: scale(1);
440
440
  opacity: 1;
@@ -452,7 +452,7 @@ const style$a = `
452
452
  /*------------------------------------------------------------------------*/
453
453
  /* ------------------------------ Component ----------------------------- */
454
454
  /*------------------------------------------------------------------------*/
455
- const Modal = (props) => {
455
+ const Modal$1 = (props) => {
456
456
  /*------------------------------------------------------------------------*/
457
457
  /* -------------------------------- Setup ------------------------------- */
458
458
  /*------------------------------------------------------------------------*/
@@ -527,7 +527,7 @@ const Modal = (props) => {
527
527
  // Check if this button is last
528
528
  const last = (i === ModalButtonTypes.length - 1);
529
529
  // Create the button
530
- return (React__default.createElement("button", { key: modalButtonType, type: "button", className: `Modal-${modalButtonType}-button btn btn-${variant} ${last ? '' : 'me-1'}`, onClick: () => {
530
+ return (React__default.createElement("button", { key: modalButtonType, type: "button", className: `ModalForWrapper-${modalButtonType}-button btn btn-${variant} ${last ? '' : 'me-1'}`, onClick: () => {
531
531
  handleClose(modalButtonType);
532
532
  } }, label));
533
533
  });
@@ -539,11 +539,11 @@ const Modal = (props) => {
539
539
  let animationClass = '';
540
540
  let backdropAnimationClass = '';
541
541
  if (animatingIn) {
542
- animationClass = 'Modal-animating-in';
543
- backdropAnimationClass = 'Modal-fading-in';
542
+ animationClass = 'ModalForWrapper-animating-in';
543
+ backdropAnimationClass = 'ModalForWrapper-fading-in';
544
544
  }
545
545
  else if (animatingPop) {
546
- animationClass = 'Modal-animating-pop';
546
+ animationClass = 'ModalForWrapper-animating-pop';
547
547
  }
548
548
  // Render the modal
549
549
  return (React__default.createElement("div", { className: "modal show", tabIndex: -1, style: {
@@ -556,7 +556,7 @@ const Modal = (props) => {
556
556
  right: 0,
557
557
  } },
558
558
  React__default.createElement("style", null, style$a),
559
- React__default.createElement("div", { className: `Modal-backdrop ${backdropAnimationClass}`, style: {
559
+ React__default.createElement("div", { className: `ModalForWrapper-backdrop ${backdropAnimationClass}`, style: {
560
560
  zIndex: 5000000003,
561
561
  }, onClick: () => __awaiter(void 0, void 0, void 0, function* () {
562
562
  // Skip if exit via backdrop not allowed
@@ -595,7 +595,7 @@ const Modal = (props) => {
595
595
  React__default.createElement("h5", { className: "modal-title", style: {
596
596
  fontWeight: 'bold',
597
597
  } }, title),
598
- (onClose && !dontShowXButton) && (React__default.createElement("button", { type: "button", className: "Modal-x-button btn-close", "aria-label": "Close", style: {
598
+ (onClose && !dontShowXButton) && (React__default.createElement("button", { type: "button", className: "ModalForWrapper-x-button btn-close", "aria-label": "Close", style: {
599
599
  backgroundColor: (isDarkModeOn()
600
600
  ? 'white'
601
601
  : undefined),
@@ -1052,6 +1052,70 @@ const showSessionExpiredMessage = () => __awaiter(void 0, void 0, void 0, functi
1052
1052
  showFatalError('Your session has expired. Please start over.', 'Session Expired');
1053
1053
  }
1054
1054
  });
1055
+ // Stored copies of setters
1056
+ let setModals;
1057
+ // Stored copies of modals
1058
+ let modals = [];
1059
+ /**
1060
+ * Add a modal to the screen
1061
+ * @author Gabe Abrams
1062
+ * @param id the uniqueId of the modal
1063
+ * @param props the props for the modal
1064
+ */
1065
+ const addModal = (id, props) => __awaiter(void 0, void 0, void 0, function* () {
1066
+ // Wait for helper to exist
1067
+ yield waitForHelper(() => {
1068
+ return !!setModals;
1069
+ });
1070
+ // Add modal
1071
+ modals.push({
1072
+ id,
1073
+ props,
1074
+ });
1075
+ // Update modals
1076
+ setModals(modals);
1077
+ });
1078
+ /**
1079
+ * Update a modal on the screen by id (if it exists) with new props
1080
+ * @author Gabe Abrams
1081
+ * @param id the uniqueId of the modal
1082
+ * @param props the new props for the modal
1083
+ */
1084
+ const updateModal = (id, props) => __awaiter(void 0, void 0, void 0, function* () {
1085
+ // Wait for helper to exist
1086
+ yield waitForHelper(() => {
1087
+ return !!setModals;
1088
+ });
1089
+ // Update modal
1090
+ modals = modals.map((modal) => {
1091
+ if (modal.id === id) {
1092
+ return {
1093
+ id,
1094
+ props,
1095
+ };
1096
+ }
1097
+ return modal;
1098
+ });
1099
+ // Update modals
1100
+ setModals(modals);
1101
+ });
1102
+ /**
1103
+ * Remove a modal from the screen by id (if it exists)
1104
+ * @author Gabe Abrams
1105
+ * @param id the uniqueId of the modal
1106
+ */
1107
+ const removeModal = (id) => __awaiter(void 0, void 0, void 0, function* () {
1108
+ // Wait for helper to exist
1109
+ yield waitForHelper(() => {
1110
+ return !!setModals;
1111
+ });
1112
+ // Remove modal
1113
+ modals = modals.filter((modal) => {
1114
+ return modal.id !== id;
1115
+ });
1116
+ // Update modals
1117
+ setModals(modals);
1118
+ });
1055
1119
  /*------------------------------------------------------------------------*/
1056
1120
  /* -------------------------------- Style ------------------------------- */
1057
1121
  /*------------------------------------------------------------------------*/
@@ -1105,6 +1169,9 @@ const AppWrapper = (props) => {
1105
1169
  // Session expired
1106
1170
  const [sessionHasExpired, setSessionHasExpiredInner,] = useState(false);
1107
1171
  setSessionHasExpired = setSessionHasExpiredInner;
1172
+ // Modals
1173
+ const [modalsFromState, setModalsInner,] = useState([]);
1174
+ setModals = setModalsInner;
1108
1175
  /*------------------------------------------------------------------------*/
1109
1176
  /* ------------------------------- Render ------------------------------- */
1110
1177
  /*------------------------------------------------------------------------*/
@@ -1115,7 +1182,7 @@ const AppWrapper = (props) => {
1115
1182
  let modal;
1116
1183
  /* -------------- Alert ------------- */
1117
1184
  if (alertInfo) {
1118
- modal = (React__default.createElement(Modal, { key: `alert-${alertInfo.title}-${alertInfo.text}`, title: alertInfo.title, type: ModalType$1.Okay, onClose: () => {
1185
+ modal = (React__default.createElement(Modal$1, { key: `alert-${alertInfo.title}-${alertInfo.text}`, title: alertInfo.title, type: ModalType$1.Okay, onClose: () => {
1119
1186
  // Alert closed
1120
1187
  setAlertInfo(undefined);
1121
1188
  if (onAlertClosed) {
@@ -1125,13 +1192,21 @@ const AppWrapper = (props) => {
1125
1192
  }
1126
1193
  /* ------------- Confirm ------------ */
1127
1194
  if (confirmInfo) {
1128
- modal = (React__default.createElement(Modal, { key: `confirm-${confirmInfo.title}-${confirmInfo.text}`, title: confirmInfo.title, type: ModalType$1.OkayCancel, okayLabel: confirmInfo.opts.confirmButtonText, okayVariant: confirmInfo.opts.confirmButtonVariant, cancelLabel: confirmInfo.opts.cancelButtonText, cancelVariant: confirmInfo.opts.cancelButtonVariant, onClose: (buttonType) => {
1195
+ modal = (React__default.createElement(Modal$1, { key: `confirm-${confirmInfo.title}-${confirmInfo.text}`, title: confirmInfo.title, type: ModalType$1.OkayCancel, okayLabel: confirmInfo.opts.confirmButtonText, okayVariant: confirmInfo.opts.confirmButtonVariant, cancelLabel: confirmInfo.opts.cancelButtonText, cancelVariant: confirmInfo.opts.cancelButtonVariant, onClose: (buttonType) => {
1129
1196
  setConfirmInfo(undefined);
1130
1197
  if (onConfirmClosed) {
1131
1198
  onConfirmClosed(buttonType === ModalButtonType$1.Okay);
1132
1199
  }
1133
1200
  }, dontAllowBackdropExit: true }, confirmInfo.text));
1134
1201
  }
1202
+ /* ---------- Custom Modals --------- */
1203
+ // List of modals added outside reactkit via the Modal component
1204
+ const customModals = [];
1205
+ // Add custom modals
1206
+ modalsFromState.forEach((modalTuple) => {
1207
+ var _a;
1208
+ customModals.push(React__default.createElement(Modal$1, Object.assign({ key: String((_a = modalTuple.props.key) !== null && _a !== void 0 ? _a : modalTuple.id) }, modalTuple.props)));
1209
+ });
1135
1210
  /*----------------------------------------*/
1136
1211
  /* ---------------- Views --------------- */
1137
1212
  /*----------------------------------------*/
@@ -1196,10 +1271,12 @@ const AppWrapper = (props) => {
1196
1271
  background-color: white;
1197
1272
  color: black;
1198
1273
  border: 0.1rem solid black;
1274
+ pointer-events: none;
1199
1275
  }
1200
1276
  div[data-popper-placement="top"] .tooltip-arrow::before {
1201
1277
  border-top-color: white !important;
1202
1278
  transform: translate(0, -0.05rem);
1279
+ pointer-events: none;
1203
1280
  }
1204
1281
  `
1205
1282
  : `
@@ -1207,10 +1284,12 @@ const AppWrapper = (props) => {
1207
1284
  background-color: black;
1208
1285
  color: black;
1209
1286
  border: 0.1rem solid white;
1287
+ pointer-events: none;
1210
1288
  }
1211
1289
  div[data-popper-placement="top"] .tooltip-arrow::before {
1212
1290
  border-top-color: black !important;
1213
1291
  transform: translate(0, -0.05rem);
1292
+ pointer-events: none;
1214
1293
  }
1215
1294
  `);
1216
1295
  /*----------------------------------------*/
@@ -1220,6 +1299,7 @@ const AppWrapper = (props) => {
1220
1299
  React__default.createElement("style", null, style$9),
1221
1300
  React__default.createElement("style", null, tooltipStyle),
1222
1301
  modal,
1302
+ customModals,
1223
1303
  body));
1224
1304
  };
1225
1305
 
@@ -1315,6 +1395,71 @@ const LoadingSpinner = () => {
1315
1395
  React__default.createElement(FontAwesomeIcon, { icon: faCircle, className: "LoadingSpinner-blip-4" })));
1316
1396
  };
1317
1397
 
1398
+ /**
1399
+ * General use modal component
1400
+ * @author Gabe Abrams
1401
+ */
1402
+ /*------------------------------------------------------------------------*/
1403
+ /* --------------------------- Static Helpers --------------------------- */
1404
+ /*------------------------------------------------------------------------*/
1405
+ // Next unique id
1406
+ let nextUniqueId = 0;
1407
+ /**
1408
+ * Get a new unique id for this modal
1409
+ * @author Gabe Abrams
1410
+ * @returns new unique id
1411
+ */
1412
+ const getNextUniqueId = () => {
1413
+ // eslint-disable-next-line no-plusplus
1414
+ return nextUniqueId++;
1415
+ };
1416
+ /*------------------------------------------------------------------------*/
1417
+ /* ------------------------------ Component ----------------------------- */
1418
+ /*------------------------------------------------------------------------*/
1419
+ const Modal = (props) => {
1420
+ /*------------------------------------------------------------------------*/
1421
+ /* -------------------------------- Setup ------------------------------- */
1422
+ /*------------------------------------------------------------------------*/
1423
+ /* -------------- Refs -------------- */
1424
+ // Initialize refs
1425
+ const id = useRef(getNextUniqueId());
1426
+ /*------------------------------------------------------------------------*/
1427
+ /* ------------------------- Lifecycle Functions ------------------------ */
1428
+ /*------------------------------------------------------------------------*/
1429
+ /**
1430
+ * Mount: add to app wrapper
1431
+ * @author Gabe Abrams
1432
+ */
1433
+ useEffect(() => {
1434
+ addModal(id.current, props);
1435
+ }, []);
1436
+ /**
1437
+ * Update: update modal props in app wrapper when props change
1438
+ * @author Gabe Abrams
1439
+ */
1440
+ useEffect(() => {
1441
+ // Update modal props
1442
+ updateModal(id.current, props);
1443
+ }, [props]);
1444
+ /**
1445
+ * Unmount: remove from app wrapper when unmounting
1446
+ * @author Gabe Abrams
1447
+ */
1448
+ useEffect(() => {
1449
+ return () => {
1450
+ // Remove modal
1451
+ removeModal(id.current);
1452
+ };
1453
+ }, []);
1454
+ /*------------------------------------------------------------------------*/
1455
+ /* ------------------------------- Render ------------------------------- */
1456
+ /*------------------------------------------------------------------------*/
1457
+ /*----------------------------------------*/
1458
+ /* --------------- Main UI -------------- */
1459
+ /*----------------------------------------*/
1460
+ return (React__default.createElement("div", { className: "Modal-shell d-none" }));
1461
+ };
1462
+
1318
1463
  /**
1319
1464
  * A box with a tab on the top that holds buttons and other content
1320
1465
  * @author Gabe Abrams
@@ -2755,7 +2900,7 @@ const IntelliTable = (props) => {
2755
2900
  /* ------- Col Vis Customization Modal ------ */
2756
2901
  if (columnVisibilityCustomizationModalVisible) {
2757
2902
  // Create modal
2758
- modal = (React__default.createElement(Modal, { type: ModalType$1.Okay, title: "Choose columns to show:", onClose: () => {
2903
+ modal = (React__default.createElement(Modal$1, { type: ModalType$1.Okay, title: "Choose columns to show:", onClose: () => {
2759
2904
  const noColumnsSelected = (Object.values(columnVisibilityMap)
2760
2905
  .every((isSelected) => {
2761
2906
  return !isSelected;