@mackin.com/styleguide 8.0.0-beta.20 → 8.0.0-beta.21
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/index.js +14 -12
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1123,7 +1123,7 @@ const useLogger = (componentName, enabled) => {
|
|
|
1123
1123
|
return (...messages) => {
|
|
1124
1124
|
if (enabled) {
|
|
1125
1125
|
// tslint:disable-next-line
|
|
1126
|
-
console.log(componentName
|
|
1126
|
+
console.log(`[${componentName}]`, ...messages);
|
|
1127
1127
|
}
|
|
1128
1128
|
};
|
|
1129
1129
|
};
|
|
@@ -1463,17 +1463,22 @@ const Modal = (p) => {
|
|
|
1463
1463
|
const theme = useThemeSafely();
|
|
1464
1464
|
const hasHeader = p.closeButton || p.heading;
|
|
1465
1465
|
const contentRef = React__default['default'].useRef(null);
|
|
1466
|
-
const log = useLogger(
|
|
1466
|
+
const log = useLogger((_a = p.id) !== null && _a !== void 0 ? _a : 'Modal', (_b = p.__debug) !== null && _b !== void 0 ? _b : false);
|
|
1467
|
+
const tryRemoveBodyStyles = () => {
|
|
1468
|
+
if (backdrop.showCount <= 1 && htmlBodyStyles) {
|
|
1469
|
+
log('backdrop.showCount', backdrop.showCount, 'removing singleton htmlBodyStyles');
|
|
1470
|
+
document.body.classList.remove(htmlBodyStyles);
|
|
1471
|
+
}
|
|
1472
|
+
};
|
|
1467
1473
|
React.useEffect(() => {
|
|
1468
1474
|
log('mounted');
|
|
1469
1475
|
return () => {
|
|
1470
1476
|
var _a;
|
|
1471
1477
|
// handle the use of modals that are rendered only as show=true and then unmounted.
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
document.body.classList.remove(htmlBodyStyles);
|
|
1478
|
+
if (p.show) {
|
|
1479
|
+
backdrop.setShow(false, (_a = p.id) !== null && _a !== void 0 ? _a : 'Modal');
|
|
1480
|
+
log('backdrop.setShow', false);
|
|
1481
|
+
tryRemoveBodyStyles();
|
|
1477
1482
|
}
|
|
1478
1483
|
log('un-mounted');
|
|
1479
1484
|
};
|
|
@@ -1491,14 +1496,11 @@ const Modal = (p) => {
|
|
|
1491
1496
|
});
|
|
1492
1497
|
}
|
|
1493
1498
|
if (show) {
|
|
1494
|
-
log('adding htmlBodyStyles');
|
|
1499
|
+
log('adding singleton htmlBodyStyles');
|
|
1495
1500
|
document.body.classList.add(htmlBodyStyles);
|
|
1496
1501
|
}
|
|
1497
1502
|
else {
|
|
1498
|
-
|
|
1499
|
-
log('backdrop.showCount', backdrop.showCount, 'removing htmlBodyStyles');
|
|
1500
|
-
document.body.classList.remove(htmlBodyStyles);
|
|
1501
|
-
}
|
|
1503
|
+
tryRemoveBodyStyles();
|
|
1502
1504
|
}
|
|
1503
1505
|
}, p.show);
|
|
1504
1506
|
React__default['default'].useLayoutEffect(() => {
|