dce-reactkit 3.8.1 → 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.
- package/dist/cjs/index.js +120 -101
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/Modal/ModalProps.d.ts +2 -0
- package/dist/esm/index.js +121 -102
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/Modal/ModalProps.d.ts +2 -0
- package/dist/index.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/Modal/ModalProps.ts +4 -0
- package/src/components/Modal/index.tsx +38 -2
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -69,6 +69,10 @@ type ModalProps = {
|
|
|
69
69
|
confirmVariant?: Variant,
|
|
70
70
|
// True if modal should be on top of other modals
|
|
71
71
|
onTopOfOtherModals?: boolean,
|
|
72
|
+
// If true, the modal is loading
|
|
73
|
+
isLoading?: boolean,
|
|
74
|
+
// If true, the loading is cancelable
|
|
75
|
+
isLoadingCancelable?: boolean,
|
|
72
76
|
};
|
|
73
77
|
|
|
74
78
|
export default ModalProps;
|
|
@@ -15,6 +15,7 @@ import ReactDOM from 'react-dom';
|
|
|
15
15
|
|
|
16
16
|
// Import other components
|
|
17
17
|
import waitMs from '../../helpers/waitMs';
|
|
18
|
+
import LoadingSpinner from '../LoadingSpinner';
|
|
18
19
|
|
|
19
20
|
// Import types
|
|
20
21
|
import Variant from '../../types/Variant';
|
|
@@ -253,6 +254,8 @@ const Modal: React.FC<ModalProps> = (props) => {
|
|
|
253
254
|
dontAllowBackdropExit,
|
|
254
255
|
dontShowXButton,
|
|
255
256
|
onTopOfOtherModals,
|
|
257
|
+
isLoading,
|
|
258
|
+
isLoadingCancelable,
|
|
256
259
|
} = props;
|
|
257
260
|
|
|
258
261
|
// Determine if no header either
|
|
@@ -263,6 +266,7 @@ const Modal: React.FC<ModalProps> = (props) => {
|
|
|
263
266
|
// True if animation is in use
|
|
264
267
|
const [animatingIn, setAnimatingIn] = useState(true);
|
|
265
268
|
const [animatingPop, setAnimatingPop] = useState(false);
|
|
269
|
+
const [showModal, setShowModal] = useState(false);
|
|
266
270
|
|
|
267
271
|
/* -------------- Refs -------------- */
|
|
268
272
|
|
|
@@ -294,6 +298,13 @@ const Modal: React.FC<ModalProps> = (props) => {
|
|
|
294
298
|
// Update to state after animated in
|
|
295
299
|
if (mounted.current) {
|
|
296
300
|
setAnimatingIn(false);
|
|
301
|
+
if (isLoading) {
|
|
302
|
+
// wait 1 second before showing modal
|
|
303
|
+
await waitMs(1000);
|
|
304
|
+
setShowModal(true);
|
|
305
|
+
} else {
|
|
306
|
+
setShowModal(true);
|
|
307
|
+
}
|
|
297
308
|
}
|
|
298
309
|
})();
|
|
299
310
|
|
|
@@ -433,6 +444,8 @@ const Modal: React.FC<ModalProps> = (props) => {
|
|
|
433
444
|
handleClose(ModalButtonType.Cancel);
|
|
434
445
|
}}
|
|
435
446
|
/>
|
|
447
|
+
|
|
448
|
+
{ showModal && (
|
|
436
449
|
<div
|
|
437
450
|
className={`modal-dialog modal-${size} ${animationClass} modal-dialog-scrollable modal-dialog-centered`}
|
|
438
451
|
style={{
|
|
@@ -495,7 +508,7 @@ const Modal: React.FC<ModalProps> = (props) => {
|
|
|
495
508
|
{title}
|
|
496
509
|
</h5>
|
|
497
510
|
|
|
498
|
-
{(onClose && !dontShowXButton) && (
|
|
511
|
+
{(onClose && !dontShowXButton && !(isLoading && !isLoadingCancelable)) && (
|
|
499
512
|
<button
|
|
500
513
|
type="button"
|
|
501
514
|
className="Modal-x-button btn-close"
|
|
@@ -515,7 +528,29 @@ const Modal: React.FC<ModalProps> = (props) => {
|
|
|
515
528
|
)}
|
|
516
529
|
</div>
|
|
517
530
|
)}
|
|
518
|
-
|
|
531
|
+
|
|
532
|
+
{isLoading && (
|
|
533
|
+
<div
|
|
534
|
+
className="modal-body"
|
|
535
|
+
style={{
|
|
536
|
+
color: (
|
|
537
|
+
isDarkModeOn()
|
|
538
|
+
? 'white'
|
|
539
|
+
: undefined
|
|
540
|
+
),
|
|
541
|
+
backgroundColor: (
|
|
542
|
+
isDarkModeOn()
|
|
543
|
+
? '#444'
|
|
544
|
+
: undefined
|
|
545
|
+
),
|
|
546
|
+
}}
|
|
547
|
+
>
|
|
548
|
+
<LoadingSpinner />
|
|
549
|
+
<span className="sr-only">Content loading</span>
|
|
550
|
+
</div>
|
|
551
|
+
)}
|
|
552
|
+
|
|
553
|
+
{children && !isLoading && (
|
|
519
554
|
<div
|
|
520
555
|
className="modal-body"
|
|
521
556
|
style={{
|
|
@@ -560,6 +595,7 @@ const Modal: React.FC<ModalProps> = (props) => {
|
|
|
560
595
|
)}
|
|
561
596
|
</div>
|
|
562
597
|
</div>
|
|
598
|
+
)}
|
|
563
599
|
</div>
|
|
564
600
|
);
|
|
565
601
|
|