@mond-design-system/react 3.0.0 → 3.0.2
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/index.cjs +16 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +12 -5
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -481,20 +481,34 @@ function useOverlay(options) {
|
|
|
481
481
|
}
|
|
482
482
|
function usePresence(open, durationMs) {
|
|
483
483
|
const [mounted, setMounted] = react.useState(open);
|
|
484
|
+
const [visible, setVisible] = react.useState(false);
|
|
484
485
|
if (open && !mounted) setMounted(true);
|
|
486
|
+
if (!open && visible) setVisible(false);
|
|
487
|
+
react.useEffect(() => {
|
|
488
|
+
if (!open) return;
|
|
489
|
+
let second = 0;
|
|
490
|
+
const first = requestAnimationFrame(() => {
|
|
491
|
+
second = requestAnimationFrame(() => setVisible(true));
|
|
492
|
+
});
|
|
493
|
+
return () => {
|
|
494
|
+
cancelAnimationFrame(first);
|
|
495
|
+
cancelAnimationFrame(second);
|
|
496
|
+
};
|
|
497
|
+
}, [open]);
|
|
485
498
|
react.useEffect(() => {
|
|
486
499
|
if (open) return;
|
|
487
500
|
const timer = setTimeout(() => setMounted(false), durationMs);
|
|
488
501
|
return () => clearTimeout(timer);
|
|
489
502
|
}, [open, durationMs]);
|
|
490
|
-
return { mounted: open || mounted, visible
|
|
503
|
+
return { mounted: open || mounted, visible };
|
|
491
504
|
}
|
|
492
505
|
|
|
493
506
|
// mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Overlay/Overlay.module.css?mds-scoped
|
|
494
507
|
var Overlay_module_default = { "scrim": "mds-Overlay__scrim", "variant-modal": "mds-Overlay__variant-modal", "variant-sheet": "mds-Overlay__variant-sheet" };
|
|
495
508
|
var OVERLAY_EXIT_MS = 200;
|
|
509
|
+
var SHEET_EXIT_MS = 320;
|
|
496
510
|
function Overlay({ open, onClose, label, variant, role = "dialog", closeOnScrimClick, panelClassName, children }) {
|
|
497
|
-
const { mounted, visible } = usePresence(open, OVERLAY_EXIT_MS);
|
|
511
|
+
const { mounted, visible } = usePresence(open, variant === "sheet" ? SHEET_EXIT_MS : OVERLAY_EXIT_MS);
|
|
498
512
|
const ref = useOverlay({ open, onClose });
|
|
499
513
|
if (!mounted) return null;
|
|
500
514
|
return reactDom.createPortal(
|