dce-reactkit 3.7.8 → 3.7.10-beta.0

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;
@@ -1,7 +1,7 @@
1
1
  import AppWrapper, { alert, confirm, showFatalError, addFatalErrorHandler, leaveToURL } from './components/AppWrapper';
2
2
  import LoadingSpinner from './components/LoadingSpinner';
3
3
  import ErrorBox from './components/ErrorBox';
4
- import Modal from './components/Modal';
4
+ import Modal from './components/Modal/ModalForWrapper';
5
5
  import TabBox from './components/TabBox';
6
6
  import RadioButton from './components/RadioButton';
7
7
  import CheckboxButton from './components/CheckboxButton';
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;
@@ -448,10 +448,6 @@ const style$a = `
448
448
  opacity: 1;
449
449
  }
450
450
  }
451
-
452
- .modal-dialog-scrollable {
453
- height: 100% !important;
454
- }
455
451
  `;
456
452
  /*------------------------------------------------------------------------*/
457
453
  /* ------------------------------ Component ----------------------------- */
@@ -531,7 +527,7 @@ const Modal = (props) => {
531
527
  // Check if this button is last
532
528
  const last = (i === ModalButtonTypes.length - 1);
533
529
  // Create the button
534
- 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: () => {
535
531
  handleClose(modalButtonType);
536
532
  } }, label));
537
533
  });
@@ -543,11 +539,11 @@ const Modal = (props) => {
543
539
  let animationClass = '';
544
540
  let backdropAnimationClass = '';
545
541
  if (animatingIn) {
546
- animationClass = 'Modal-animating-in';
547
- backdropAnimationClass = 'Modal-fading-in';
542
+ animationClass = 'ModalForWrapper-animating-in';
543
+ backdropAnimationClass = 'ModalForWrapper-fading-in';
548
544
  }
549
545
  else if (animatingPop) {
550
- animationClass = 'Modal-animating-pop';
546
+ animationClass = 'ModalForWrapper-animating-pop';
551
547
  }
552
548
  // Render the modal
553
549
  return (React__default.createElement("div", { className: "modal show", tabIndex: -1, style: {
@@ -560,7 +556,7 @@ const Modal = (props) => {
560
556
  right: 0,
561
557
  } },
562
558
  React__default.createElement("style", null, style$a),
563
- React__default.createElement("div", { className: `Modal-backdrop ${backdropAnimationClass}`, style: {
559
+ React__default.createElement("div", { className: `ModalForWrapper-backdrop ${backdropAnimationClass}`, style: {
564
560
  zIndex: 5000000003,
565
561
  }, onClick: () => __awaiter(void 0, void 0, void 0, function* () {
566
562
  // Skip if exit via backdrop not allowed
@@ -599,7 +595,7 @@ const Modal = (props) => {
599
595
  React__default.createElement("h5", { className: "modal-title", style: {
600
596
  fontWeight: 'bold',
601
597
  } }, title),
602
- (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: {
603
599
  backgroundColor: (isDarkModeOn()
604
600
  ? 'white'
605
601
  : undefined),
@@ -1109,6 +1105,8 @@ const AppWrapper = (props) => {
1109
1105
  // Session expired
1110
1106
  const [sessionHasExpired, setSessionHasExpiredInner,] = useState(false);
1111
1107
  setSessionHasExpired = setSessionHasExpiredInner;
1108
+ // Modals
1109
+ const [modalsFromState, setModalsInner,] = useState([]);
1112
1110
  /*------------------------------------------------------------------------*/
1113
1111
  /* ------------------------------- Render ------------------------------- */
1114
1112
  /*------------------------------------------------------------------------*/
@@ -1136,6 +1134,14 @@ const AppWrapper = (props) => {
1136
1134
  }
1137
1135
  }, dontAllowBackdropExit: true }, confirmInfo.text));
1138
1136
  }
1137
+ /* ---------- Custom Modals --------- */
1138
+ // List of modals added outside reactkit via the Modal component
1139
+ const customModals = [];
1140
+ // Add custom modals
1141
+ modalsFromState.forEach((modalTuple) => {
1142
+ var _a;
1143
+ customModals.push(React__default.createElement(Modal, Object.assign({ key: String((_a = modalTuple.props.key) !== null && _a !== void 0 ? _a : modalTuple.id) }, modalTuple.props)));
1144
+ });
1139
1145
  /*----------------------------------------*/
1140
1146
  /* ---------------- Views --------------- */
1141
1147
  /*----------------------------------------*/
@@ -1200,10 +1206,12 @@ const AppWrapper = (props) => {
1200
1206
  background-color: white;
1201
1207
  color: black;
1202
1208
  border: 0.1rem solid black;
1209
+ pointer-events: none;
1203
1210
  }
1204
1211
  div[data-popper-placement="top"] .tooltip-arrow::before {
1205
1212
  border-top-color: white !important;
1206
1213
  transform: translate(0, -0.05rem);
1214
+ pointer-events: none;
1207
1215
  }
1208
1216
  `
1209
1217
  : `
@@ -1211,10 +1219,12 @@ const AppWrapper = (props) => {
1211
1219
  background-color: black;
1212
1220
  color: black;
1213
1221
  border: 0.1rem solid white;
1222
+ pointer-events: none;
1214
1223
  }
1215
1224
  div[data-popper-placement="top"] .tooltip-arrow::before {
1216
1225
  border-top-color: black !important;
1217
1226
  transform: translate(0, -0.05rem);
1227
+ pointer-events: none;
1218
1228
  }
1219
1229
  `);
1220
1230
  /*----------------------------------------*/
@@ -1224,6 +1234,7 @@ const AppWrapper = (props) => {
1224
1234
  React__default.createElement("style", null, style$9),
1225
1235
  React__default.createElement("style", null, tooltipStyle),
1226
1236
  modal,
1237
+ customModals,
1227
1238
  body));
1228
1239
  };
1229
1240