dce-reactkit 3.8.2 → 3.9.0-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.
@@ -38,5 +38,7 @@ type ModalProps = {
38
38
  confirmLabel?: string;
39
39
  confirmVariant?: Variant;
40
40
  onTopOfOtherModals?: boolean;
41
+ isLoading?: boolean;
42
+ isLoadingCancelable?: boolean;
41
43
  };
42
44
  export default ModalProps;
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
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 } from '@fortawesome/free-solid-svg-icons';
3
+ import { faExclamationTriangle, faCircle, faHourglassEnd, faDotCircle, faCheckSquare, faHourglass, faClipboard, faChevronDown, faChevronRight, faCloudDownloadAlt, faMinus, faCheckCircle, faXmarkCircle, faSort, faSortDown, faSortUp, faCalendar, faTag, faHammer, faList, faTimes, faSave, faTrash, faCog, faPlus } from '@fortawesome/free-solid-svg-icons';
4
4
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
5
5
  import ReactDOM, { createPortal } from 'react-dom';
6
6
  import { faCircle as faCircle$1, faSquareMinus, faSquare } from '@fortawesome/free-regular-svg-icons';
@@ -191,6 +191,98 @@ const waitMs = (ms = 0) => __awaiter(void 0, void 0, void 0, function* () {
191
191
  });
192
192
  });
193
193
 
194
+ /**
195
+ * Loading spinner/indicator
196
+ * @author Gabe Abrams
197
+ */
198
+ /*------------------------------------------------------------------------*/
199
+ /* -------------------------------- Style ------------------------------- */
200
+ /*------------------------------------------------------------------------*/
201
+ const style$a = `
202
+ /* Container fades in */
203
+ .LoadingSpinner-container {
204
+ animation-name: LoadingSpinner-container-fade-in;
205
+ animation-duration: 0.3s;
206
+ animation-delay: 0.4s;
207
+ animation-fill-mode: both;
208
+ animation-timing-function: ease-out;
209
+ }
210
+ @keyframes LoadingSpinner-container-fade-in {
211
+ 0% {
212
+ opacity: 0;
213
+ }
214
+ 100% {
215
+ opacity: 1;
216
+ }
217
+ }
218
+
219
+ /* Blips */
220
+ .LoadingSpinner-blip-1,
221
+ .LoadingSpinner-blip-2,
222
+ .LoadingSpinner-blip-3,
223
+ .LoadingSpinner-blip-4 {
224
+ font-size: 1.8rem;
225
+ opacity: 0.6;
226
+ margin-top: 1rem;
227
+ margin-bottom: 1rem;
228
+ }
229
+
230
+ /* First Blip */
231
+ .LoadingSpinner-blip-1 {
232
+ animation: LoadingSpinner-pop-animation 2s infinite;
233
+ }
234
+
235
+ /* Second Blip */
236
+ .LoadingSpinner-blip-2 {
237
+ animation: LoadingSpinner-pop-animation 2s infinite;
238
+ -webkit-animation-delay: 0.1s;
239
+ animation-delay: 0.1s;
240
+ }
241
+
242
+ /* Third Blip */
243
+ .LoadingSpinner-blip-3 {
244
+ animation: LoadingSpinner-pop-animation 2s infinite;
245
+ animation-delay: 0.2s;
246
+ }
247
+
248
+ /* Fourth Blip */
249
+ .LoadingSpinner-blip-4 {
250
+ animation: LoadingSpinner-pop-animation 2s infinite;
251
+ animation-delay: 0.3s;
252
+ }
253
+
254
+ /* Pop Animation for Each Blip */
255
+ @keyframes LoadingSpinner-pop-animation {
256
+ 0% {
257
+ transform: scale(1.0);
258
+ }
259
+ 10% {
260
+ transform: scale(1.5);
261
+ }
262
+ 30% {
263
+ transform: scale(1.0);
264
+ }
265
+ 100% {
266
+ transform: scale(1.0);
267
+ }
268
+ }
269
+ `;
270
+ /*------------------------------------------------------------------------*/
271
+ /* ------------------------------ Component ----------------------------- */
272
+ /*------------------------------------------------------------------------*/
273
+ const LoadingSpinner = () => {
274
+ /*------------------------------------------------------------------------*/
275
+ /* ------------------------------- Render ------------------------------- */
276
+ /*------------------------------------------------------------------------*/
277
+ // Add all four blips to a container
278
+ return (React__default.createElement("div", { className: "text-center LoadingSpinner LoadingSpinner-container" },
279
+ React__default.createElement("style", null, style$a),
280
+ React__default.createElement(FontAwesomeIcon, { icon: faCircle, className: "LoadingSpinner-blip-1 me-1" }),
281
+ React__default.createElement(FontAwesomeIcon, { icon: faCircle, className: "LoadingSpinner-blip-2 me-1" }),
282
+ React__default.createElement(FontAwesomeIcon, { icon: faCircle, className: "LoadingSpinner-blip-3 me-1" }),
283
+ React__default.createElement(FontAwesomeIcon, { icon: faCircle, className: "LoadingSpinner-blip-4" })));
284
+ };
285
+
194
286
  /**
195
287
  * Modal sizes
196
288
  * @author Gabe Abrams
@@ -410,7 +502,7 @@ const getNextUniqueId = () => {
410
502
  /*------------------------------------------------------------------------*/
411
503
  /* -------------------------------- Style ------------------------------- */
412
504
  /*------------------------------------------------------------------------*/
413
- const style$a = `
505
+ const style$9 = `
414
506
  .Modal-backdrop {
415
507
  position: fixed;
416
508
  top: 0;
@@ -482,13 +574,14 @@ const Modal = (props) => {
482
574
  /*------------------------------------------------------------------------*/
483
575
  var _a;
484
576
  /* -------------- Props ------------- */
485
- const { type = ModalType$1.NoButtons, size = ModalSize$1.Large, title, largeTitle, children, onClose, dontAllowBackdropExit, dontShowXButton, onTopOfOtherModals, } = props;
577
+ const { type = ModalType$1.NoButtons, size = ModalSize$1.Large, title, largeTitle, children, onClose, dontAllowBackdropExit, dontShowXButton, onTopOfOtherModals, isLoading, isLoadingCancelable, } = props;
486
578
  // Determine if no header either
487
579
  const noHeader = (!title && type === ModalType$1.NoButtons);
488
580
  /* -------------- State ------------- */
489
581
  // True if animation is in use
490
582
  const [animatingIn, setAnimatingIn] = useState(true);
491
583
  const [animatingPop, setAnimatingPop] = useState(false);
584
+ const [showModal, setShowModal] = useState(false);
492
585
  /* -------------- Refs -------------- */
493
586
  // Keep track of whether modal is still mounted
494
587
  const mounted = useRef(false);
@@ -514,6 +607,14 @@ const Modal = (props) => {
514
607
  // Update to state after animated in
515
608
  if (mounted.current) {
516
609
  setAnimatingIn(false);
610
+ if (isLoading) {
611
+ // wait 1 second before showing modal
612
+ yield waitMs(1000);
613
+ setShowModal(true);
614
+ }
615
+ else {
616
+ setShowModal(true);
617
+ }
517
618
  }
518
619
  }))();
519
620
  return () => {
@@ -589,7 +690,7 @@ const Modal = (props) => {
589
690
  left: 0,
590
691
  right: 0,
591
692
  } },
592
- React__default.createElement("style", null, style$a),
693
+ React__default.createElement("style", null, style$9),
593
694
  React__default.createElement("div", { className: `Modal-backdrop ${backdropAnimationClass}`, style: {
594
695
  zIndex: baseZIndex + 1,
595
696
  }, onClick: () => __awaiter(void 0, void 0, void 0, function* () {
@@ -607,11 +708,11 @@ const Modal = (props) => {
607
708
  // Handle close
608
709
  handleClose(ModalButtonType$1.Cancel);
609
710
  }) }),
610
- React__default.createElement("div", { className: `modal-dialog modal-${size} ${animationClass} modal-dialog-scrollable modal-dialog-centered`, style: {
711
+ showModal && (React__default.createElement("div", { className: `modal-dialog modal-${size} ${animationClass} modal-dialog-scrollable modal-dialog-centered`, style: {
611
712
  zIndex: baseZIndex + 2,
612
713
  // Override sizes for even larger for XL
613
714
  width: (size === ModalSize$1.ExtraLarge
614
- ? 'calc(100vw - 1rem)'
715
+ ? 'calc(100vw - 3rem)'
615
716
  : undefined),
616
717
  maxWidth: (size === ModalSize$1.ExtraLarge
617
718
  ? '80rem'
@@ -639,7 +740,7 @@ const Modal = (props) => {
639
740
  ? '1.6rem'
640
741
  : undefined),
641
742
  } }, title),
642
- (onClose && !dontShowXButton) && (React__default.createElement("button", { type: "button", className: "Modal-x-button btn-close", "aria-label": "Close", style: {
743
+ (onClose && !dontShowXButton && !(isLoading && !isLoadingCancelable)) && (React__default.createElement("button", { type: "button", className: "Modal-x-button btn-close", "aria-label": "Close", style: {
643
744
  backgroundColor: (isDarkModeOn()
644
745
  ? 'white'
645
746
  : undefined),
@@ -647,7 +748,17 @@ const Modal = (props) => {
647
748
  // Handle close
648
749
  handleClose(ModalButtonType$1.Cancel);
649
750
  } })))),
650
- children && (React__default.createElement("div", { className: "modal-body", style: {
751
+ isLoading && (React__default.createElement("div", { className: "modal-body", style: {
752
+ color: (isDarkModeOn()
753
+ ? 'white'
754
+ : undefined),
755
+ backgroundColor: (isDarkModeOn()
756
+ ? '#444'
757
+ : undefined),
758
+ } },
759
+ React__default.createElement(LoadingSpinner, null),
760
+ React__default.createElement("span", { className: "sr-only" }, "Content loading"))),
761
+ children && !isLoading && (React__default.createElement("div", { className: "modal-body", style: {
651
762
  color: (isDarkModeOn()
652
763
  ? 'white'
653
764
  : undefined),
@@ -665,7 +776,7 @@ const Modal = (props) => {
665
776
  borderTop: (isDarkModeOn()
666
777
  ? '0.1rem solid gray'
667
778
  : undefined),
668
- } }, footer))))));
779
+ } }, footer)))))));
669
780
  // Determine which portal to use
670
781
  const portalNumber = id.current % NUM_MODAL_PORTALS;
671
782
  // Render in a portal
@@ -1145,7 +1256,7 @@ const showSessionExpiredMessage = () => __awaiter(void 0, void 0, void 0, functi
1145
1256
  /*------------------------------------------------------------------------*/
1146
1257
  /* -------------------------------- Style ------------------------------- */
1147
1258
  /*------------------------------------------------------------------------*/
1148
- const style$9 = `
1259
+ const style$8 = `
1149
1260
  .AppWrapper-leave-to-url-notice {
1150
1261
  opacity: 0;
1151
1262
 
@@ -1320,105 +1431,13 @@ const AppWrapper = (props) => {
1320
1431
  /* --------------- Main UI -------------- */
1321
1432
  /*----------------------------------------*/
1322
1433
  return (React__default.createElement(React__default.Fragment, null,
1323
- React__default.createElement("style", null, style$9),
1434
+ React__default.createElement("style", null, style$8),
1324
1435
  React__default.createElement("style", null, tooltipStyle),
1325
1436
  modal,
1326
1437
  customModalPortals,
1327
1438
  body));
1328
1439
  };
1329
1440
 
1330
- /**
1331
- * Loading spinner/indicator
1332
- * @author Gabe Abrams
1333
- */
1334
- /*------------------------------------------------------------------------*/
1335
- /* -------------------------------- Style ------------------------------- */
1336
- /*------------------------------------------------------------------------*/
1337
- const style$8 = `
1338
- /* Container fades in */
1339
- .LoadingSpinner-container {
1340
- animation-name: LoadingSpinner-container-fade-in;
1341
- animation-duration: 0.3s;
1342
- animation-delay: 0.4s;
1343
- animation-fill-mode: both;
1344
- animation-timing-function: ease-out;
1345
- }
1346
- @keyframes LoadingSpinner-container-fade-in {
1347
- 0% {
1348
- opacity: 0;
1349
- }
1350
- 100% {
1351
- opacity: 1;
1352
- }
1353
- }
1354
-
1355
- /* Blips */
1356
- .LoadingSpinner-blip-1,
1357
- .LoadingSpinner-blip-2,
1358
- .LoadingSpinner-blip-3,
1359
- .LoadingSpinner-blip-4 {
1360
- font-size: 1.8rem;
1361
- opacity: 0.6;
1362
- margin-top: 1rem;
1363
- margin-bottom: 1rem;
1364
- }
1365
-
1366
- /* First Blip */
1367
- .LoadingSpinner-blip-1 {
1368
- animation: LoadingSpinner-pop-animation 2s infinite;
1369
- }
1370
-
1371
- /* Second Blip */
1372
- .LoadingSpinner-blip-2 {
1373
- animation: LoadingSpinner-pop-animation 2s infinite;
1374
- -webkit-animation-delay: 0.1s;
1375
- animation-delay: 0.1s;
1376
- }
1377
-
1378
- /* Third Blip */
1379
- .LoadingSpinner-blip-3 {
1380
- animation: LoadingSpinner-pop-animation 2s infinite;
1381
- animation-delay: 0.2s;
1382
- }
1383
-
1384
- /* Fourth Blip */
1385
- .LoadingSpinner-blip-4 {
1386
- animation: LoadingSpinner-pop-animation 2s infinite;
1387
- animation-delay: 0.3s;
1388
- }
1389
-
1390
- /* Pop Animation for Each Blip */
1391
- @keyframes LoadingSpinner-pop-animation {
1392
- 0% {
1393
- transform: scale(1.0);
1394
- }
1395
- 10% {
1396
- transform: scale(1.5);
1397
- }
1398
- 30% {
1399
- transform: scale(1.0);
1400
- }
1401
- 100% {
1402
- transform: scale(1.0);
1403
- }
1404
- }
1405
- `;
1406
- /*------------------------------------------------------------------------*/
1407
- /* ------------------------------ Component ----------------------------- */
1408
- /*------------------------------------------------------------------------*/
1409
- const LoadingSpinner = () => {
1410
- /*------------------------------------------------------------------------*/
1411
- /* ------------------------------- Render ------------------------------- */
1412
- /*------------------------------------------------------------------------*/
1413
- // Add all four blips to a container
1414
- return (React__default.createElement("div", { className: "text-center LoadingSpinner LoadingSpinner-container" },
1415
- React__default.createElement("style", null, style$8),
1416
- React__default.createElement(FontAwesomeIcon, { icon: faCircle, className: "LoadingSpinner-blip-1 me-1" }),
1417
- React__default.createElement(FontAwesomeIcon, { icon: faCircle, className: "LoadingSpinner-blip-2 me-1" }),
1418
- React__default.createElement(FontAwesomeIcon, { icon: faCircle, className: "LoadingSpinner-blip-3 me-1" }),
1419
- React__default.createElement(FontAwesomeIcon, { icon: faCircle, className: "LoadingSpinner-blip-4" })));
1420
- };
1421
-
1422
1441
  /**
1423
1442
  * A box with a tab on the top that holds buttons and other content
1424
1443
  * @author Gabe Abrams