@almadar/ui 5.122.3 → 5.122.5

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.
@@ -1277,6 +1277,77 @@ var init_Typography = __esm({
1277
1277
  Typography.displayName = "Typography";
1278
1278
  }
1279
1279
  });
1280
+ function isMotionEnabled() {
1281
+ if (typeof document === "undefined") return true;
1282
+ if (motionEnabledCache !== null) return motionEnabledCache;
1283
+ const v = getComputedStyle(document.documentElement).getPropertyValue("--motion-enable").trim().toLowerCase();
1284
+ motionEnabledCache = v !== "off";
1285
+ return motionEnabledCache;
1286
+ }
1287
+ function usePresence(show, opts) {
1288
+ const { animation, animate = true, onExited } = opts;
1289
+ const [mounted, setMounted] = React84.useState(show);
1290
+ const [exiting, setExiting] = React84.useState(false);
1291
+ const prev = React84.useRef(show);
1292
+ const onExitedRef = React84.useRef(onExited);
1293
+ onExitedRef.current = onExited;
1294
+ const safeTimer = React84.useRef(null);
1295
+ const clearSafe = React84.useCallback(() => {
1296
+ if (safeTimer.current) {
1297
+ clearTimeout(safeTimer.current);
1298
+ safeTimer.current = null;
1299
+ }
1300
+ }, []);
1301
+ const finishExit = React84.useCallback(() => {
1302
+ clearSafe();
1303
+ setExiting(false);
1304
+ setMounted(false);
1305
+ onExitedRef.current?.();
1306
+ }, [clearSafe]);
1307
+ React84.useLayoutEffect(() => {
1308
+ const moving = animate && isMotionEnabled();
1309
+ if (show && !prev.current) {
1310
+ setExiting(false);
1311
+ setMounted(true);
1312
+ } else if (!show && prev.current) {
1313
+ if (moving) {
1314
+ setExiting(true);
1315
+ clearSafe();
1316
+ safeTimer.current = setTimeout(finishExit, SAFE_EXIT_MS);
1317
+ } else {
1318
+ setMounted(false);
1319
+ setExiting(false);
1320
+ }
1321
+ }
1322
+ prev.current = show;
1323
+ }, [show, animate, clearSafe, finishExit]);
1324
+ React84.useEffect(() => () => clearSafe(), [clearSafe]);
1325
+ const disabled = !animate || !isMotionEnabled();
1326
+ const className = disabled ? "" : exiting ? `animate-${animation}-out` : `animate-${animation}-in`;
1327
+ const onAnimationEnd = React84.useCallback(
1328
+ (e) => {
1329
+ if (e.target !== e.currentTarget) return;
1330
+ if (exiting) finishExit();
1331
+ },
1332
+ [exiting, finishExit]
1333
+ );
1334
+ return { mounted, exiting, className, onAnimationEnd };
1335
+ }
1336
+ var SAFE_EXIT_MS, motionEnabledCache, Presence;
1337
+ var init_Presence = __esm({
1338
+ "components/core/atoms/Presence.tsx"() {
1339
+ "use client";
1340
+ init_cn();
1341
+ SAFE_EXIT_MS = 1e3;
1342
+ motionEnabledCache = null;
1343
+ Presence = ({ show, className, children, ...opts }) => {
1344
+ const { mounted, className: animClass, onAnimationEnd } = usePresence(show, opts);
1345
+ if (!mounted) return null;
1346
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(animClass, className), onAnimationEnd, children });
1347
+ };
1348
+ Presence.displayName = "Presence";
1349
+ }
1350
+ });
1280
1351
  var sizeClasses2, minWidthClasses, lookStyles, Modal;
1281
1352
  var init_Modal = __esm({
1282
1353
  "components/core/molecules/Modal.tsx"() {
@@ -1287,6 +1358,7 @@ var init_Modal = __esm({
1287
1358
  init_Typography();
1288
1359
  init_cn();
1289
1360
  init_useEventBus();
1361
+ init_Presence();
1290
1362
  sizeClasses2 = {
1291
1363
  sm: "max-w-md",
1292
1364
  md: "max-w-2xl",
@@ -1331,18 +1403,10 @@ var init_Modal = __esm({
1331
1403
  const [dragY, setDragY] = React84.useState(0);
1332
1404
  const dragStartY = React84.useRef(0);
1333
1405
  const isDragging = React84.useRef(false);
1334
- const [closing, setClosing] = React84.useState(false);
1335
- const wasOpenRef = React84.useRef(isOpen);
1336
- React84.useEffect(() => {
1337
- if (wasOpenRef.current && !isOpen) setClosing(true);
1338
- wasOpenRef.current = isOpen;
1339
- }, [isOpen]);
1340
- const handleAnimEnd = (e) => {
1341
- if (closing && e.target === e.currentTarget) {
1342
- setClosing(false);
1343
- onExited?.();
1344
- }
1345
- };
1406
+ const { mounted, exiting, onAnimationEnd: handleAnimEnd } = usePresence(isOpen, {
1407
+ animation: "modal",
1408
+ onExited
1409
+ });
1346
1410
  React84.useEffect(() => {
1347
1411
  if (isOpen) {
1348
1412
  previousActiveElement.current = document.activeElement;
@@ -1377,10 +1441,9 @@ var init_Modal = __esm({
1377
1441
  };
1378
1442
  }, [isOpen]);
1379
1443
  if (typeof document === "undefined") return null;
1380
- const renderOpen = isOpen || closing;
1381
- if (!renderOpen) return null;
1382
- const dialogAnim = closing ? "animate-modal-out" : "animate-modal-in";
1383
- const overlayAnim = closing ? "animate-overlay-out" : "animate-overlay-in";
1444
+ if (!mounted) return null;
1445
+ const dialogAnim = exiting ? "animate-modal-out" : "animate-modal-in";
1446
+ const overlayAnim = exiting ? "animate-overlay-out" : "animate-overlay-in";
1384
1447
  const handleClose = () => {
1385
1448
  if (closeEvent) eventBus.emit(`UI:${closeEvent}`, {});
1386
1449
  onClose();
@@ -1511,77 +1574,6 @@ var init_Modal = __esm({
1511
1574
  Modal.displayName = "Modal";
1512
1575
  }
1513
1576
  });
1514
- function isMotionEnabled() {
1515
- if (typeof document === "undefined") return true;
1516
- if (motionEnabledCache !== null) return motionEnabledCache;
1517
- const v = getComputedStyle(document.documentElement).getPropertyValue("--motion-enable").trim().toLowerCase();
1518
- motionEnabledCache = v !== "off";
1519
- return motionEnabledCache;
1520
- }
1521
- function usePresence(show, opts) {
1522
- const { animation, animate = true, onExited } = opts;
1523
- const [mounted, setMounted] = React84.useState(show);
1524
- const [exiting, setExiting] = React84.useState(false);
1525
- const prev = React84.useRef(show);
1526
- const onExitedRef = React84.useRef(onExited);
1527
- onExitedRef.current = onExited;
1528
- const safeTimer = React84.useRef(null);
1529
- const clearSafe = React84.useCallback(() => {
1530
- if (safeTimer.current) {
1531
- clearTimeout(safeTimer.current);
1532
- safeTimer.current = null;
1533
- }
1534
- }, []);
1535
- const finishExit = React84.useCallback(() => {
1536
- clearSafe();
1537
- setExiting(false);
1538
- setMounted(false);
1539
- onExitedRef.current?.();
1540
- }, [clearSafe]);
1541
- React84.useEffect(() => {
1542
- const moving = animate && isMotionEnabled();
1543
- if (show && !prev.current) {
1544
- setExiting(false);
1545
- setMounted(true);
1546
- } else if (!show && prev.current) {
1547
- if (moving) {
1548
- setExiting(true);
1549
- clearSafe();
1550
- safeTimer.current = setTimeout(finishExit, SAFE_EXIT_MS);
1551
- } else {
1552
- setMounted(false);
1553
- setExiting(false);
1554
- }
1555
- }
1556
- prev.current = show;
1557
- }, [show, animate, clearSafe, finishExit]);
1558
- React84.useEffect(() => () => clearSafe(), [clearSafe]);
1559
- const disabled = !animate || !isMotionEnabled();
1560
- const className = disabled ? "" : exiting ? `animate-${animation}-out` : `animate-${animation}-in`;
1561
- const onAnimationEnd = React84.useCallback(
1562
- (e) => {
1563
- if (e.target !== e.currentTarget) return;
1564
- if (exiting) finishExit();
1565
- },
1566
- [exiting, finishExit]
1567
- );
1568
- return { mounted, exiting, className, onAnimationEnd };
1569
- }
1570
- var SAFE_EXIT_MS, motionEnabledCache, Presence;
1571
- var init_Presence = __esm({
1572
- "components/core/atoms/Presence.tsx"() {
1573
- "use client";
1574
- init_cn();
1575
- SAFE_EXIT_MS = 1e3;
1576
- motionEnabledCache = null;
1577
- Presence = ({ show, className, children, ...opts }) => {
1578
- const { mounted, className: animClass, onAnimationEnd } = usePresence(show, opts);
1579
- if (!mounted) return null;
1580
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(animClass, className), onAnimationEnd, children });
1581
- };
1582
- Presence.displayName = "Presence";
1583
- }
1584
- });
1585
1577
  var Overlay;
1586
1578
  var init_Overlay = __esm({
1587
1579
  "components/core/atoms/Overlay.tsx"() {
@@ -1,5 +1,5 @@
1
1
  import * as React84 from 'react';
2
- import React84__default, { createContext, useContext, useMemo, useRef, useEffect, useCallback, Suspense, useState, lazy, useLayoutEffect, useId, useSyncExternalStore } from 'react';
2
+ import React84__default, { createContext, useContext, useMemo, useRef, useEffect, useCallback, Suspense, useState, useLayoutEffect, lazy, useId, useSyncExternalStore } from 'react';
3
3
  import { EventBusContext, useTraitScopeChain, useEntitySchemaOptional, TraitScopeProvider, useCurrentPagePath, useGameAudioContextOptional } from '@almadar/ui/providers';
4
4
  import { createLogger, isLogLevelEnabled } from '@almadar/logger';
5
5
  import { clsx } from 'clsx';
@@ -1232,6 +1232,77 @@ var init_Typography = __esm({
1232
1232
  Typography.displayName = "Typography";
1233
1233
  }
1234
1234
  });
1235
+ function isMotionEnabled() {
1236
+ if (typeof document === "undefined") return true;
1237
+ if (motionEnabledCache !== null) return motionEnabledCache;
1238
+ const v = getComputedStyle(document.documentElement).getPropertyValue("--motion-enable").trim().toLowerCase();
1239
+ motionEnabledCache = v !== "off";
1240
+ return motionEnabledCache;
1241
+ }
1242
+ function usePresence(show, opts) {
1243
+ const { animation, animate = true, onExited } = opts;
1244
+ const [mounted, setMounted] = useState(show);
1245
+ const [exiting, setExiting] = useState(false);
1246
+ const prev = useRef(show);
1247
+ const onExitedRef = useRef(onExited);
1248
+ onExitedRef.current = onExited;
1249
+ const safeTimer = useRef(null);
1250
+ const clearSafe = useCallback(() => {
1251
+ if (safeTimer.current) {
1252
+ clearTimeout(safeTimer.current);
1253
+ safeTimer.current = null;
1254
+ }
1255
+ }, []);
1256
+ const finishExit = useCallback(() => {
1257
+ clearSafe();
1258
+ setExiting(false);
1259
+ setMounted(false);
1260
+ onExitedRef.current?.();
1261
+ }, [clearSafe]);
1262
+ useLayoutEffect(() => {
1263
+ const moving = animate && isMotionEnabled();
1264
+ if (show && !prev.current) {
1265
+ setExiting(false);
1266
+ setMounted(true);
1267
+ } else if (!show && prev.current) {
1268
+ if (moving) {
1269
+ setExiting(true);
1270
+ clearSafe();
1271
+ safeTimer.current = setTimeout(finishExit, SAFE_EXIT_MS);
1272
+ } else {
1273
+ setMounted(false);
1274
+ setExiting(false);
1275
+ }
1276
+ }
1277
+ prev.current = show;
1278
+ }, [show, animate, clearSafe, finishExit]);
1279
+ useEffect(() => () => clearSafe(), [clearSafe]);
1280
+ const disabled = !animate || !isMotionEnabled();
1281
+ const className = disabled ? "" : exiting ? `animate-${animation}-out` : `animate-${animation}-in`;
1282
+ const onAnimationEnd = useCallback(
1283
+ (e) => {
1284
+ if (e.target !== e.currentTarget) return;
1285
+ if (exiting) finishExit();
1286
+ },
1287
+ [exiting, finishExit]
1288
+ );
1289
+ return { mounted, exiting, className, onAnimationEnd };
1290
+ }
1291
+ var SAFE_EXIT_MS, motionEnabledCache, Presence;
1292
+ var init_Presence = __esm({
1293
+ "components/core/atoms/Presence.tsx"() {
1294
+ "use client";
1295
+ init_cn();
1296
+ SAFE_EXIT_MS = 1e3;
1297
+ motionEnabledCache = null;
1298
+ Presence = ({ show, className, children, ...opts }) => {
1299
+ const { mounted, className: animClass, onAnimationEnd } = usePresence(show, opts);
1300
+ if (!mounted) return null;
1301
+ return /* @__PURE__ */ jsx("div", { className: cn(animClass, className), onAnimationEnd, children });
1302
+ };
1303
+ Presence.displayName = "Presence";
1304
+ }
1305
+ });
1235
1306
  var sizeClasses2, minWidthClasses, lookStyles, Modal;
1236
1307
  var init_Modal = __esm({
1237
1308
  "components/core/molecules/Modal.tsx"() {
@@ -1242,6 +1313,7 @@ var init_Modal = __esm({
1242
1313
  init_Typography();
1243
1314
  init_cn();
1244
1315
  init_useEventBus();
1316
+ init_Presence();
1245
1317
  sizeClasses2 = {
1246
1318
  sm: "max-w-md",
1247
1319
  md: "max-w-2xl",
@@ -1286,18 +1358,10 @@ var init_Modal = __esm({
1286
1358
  const [dragY, setDragY] = useState(0);
1287
1359
  const dragStartY = useRef(0);
1288
1360
  const isDragging = useRef(false);
1289
- const [closing, setClosing] = useState(false);
1290
- const wasOpenRef = useRef(isOpen);
1291
- useEffect(() => {
1292
- if (wasOpenRef.current && !isOpen) setClosing(true);
1293
- wasOpenRef.current = isOpen;
1294
- }, [isOpen]);
1295
- const handleAnimEnd = (e) => {
1296
- if (closing && e.target === e.currentTarget) {
1297
- setClosing(false);
1298
- onExited?.();
1299
- }
1300
- };
1361
+ const { mounted, exiting, onAnimationEnd: handleAnimEnd } = usePresence(isOpen, {
1362
+ animation: "modal",
1363
+ onExited
1364
+ });
1301
1365
  useEffect(() => {
1302
1366
  if (isOpen) {
1303
1367
  previousActiveElement.current = document.activeElement;
@@ -1332,10 +1396,9 @@ var init_Modal = __esm({
1332
1396
  };
1333
1397
  }, [isOpen]);
1334
1398
  if (typeof document === "undefined") return null;
1335
- const renderOpen = isOpen || closing;
1336
- if (!renderOpen) return null;
1337
- const dialogAnim = closing ? "animate-modal-out" : "animate-modal-in";
1338
- const overlayAnim = closing ? "animate-overlay-out" : "animate-overlay-in";
1399
+ if (!mounted) return null;
1400
+ const dialogAnim = exiting ? "animate-modal-out" : "animate-modal-in";
1401
+ const overlayAnim = exiting ? "animate-overlay-out" : "animate-overlay-in";
1339
1402
  const handleClose = () => {
1340
1403
  if (closeEvent) eventBus.emit(`UI:${closeEvent}`, {});
1341
1404
  onClose();
@@ -1466,77 +1529,6 @@ var init_Modal = __esm({
1466
1529
  Modal.displayName = "Modal";
1467
1530
  }
1468
1531
  });
1469
- function isMotionEnabled() {
1470
- if (typeof document === "undefined") return true;
1471
- if (motionEnabledCache !== null) return motionEnabledCache;
1472
- const v = getComputedStyle(document.documentElement).getPropertyValue("--motion-enable").trim().toLowerCase();
1473
- motionEnabledCache = v !== "off";
1474
- return motionEnabledCache;
1475
- }
1476
- function usePresence(show, opts) {
1477
- const { animation, animate = true, onExited } = opts;
1478
- const [mounted, setMounted] = useState(show);
1479
- const [exiting, setExiting] = useState(false);
1480
- const prev = useRef(show);
1481
- const onExitedRef = useRef(onExited);
1482
- onExitedRef.current = onExited;
1483
- const safeTimer = useRef(null);
1484
- const clearSafe = useCallback(() => {
1485
- if (safeTimer.current) {
1486
- clearTimeout(safeTimer.current);
1487
- safeTimer.current = null;
1488
- }
1489
- }, []);
1490
- const finishExit = useCallback(() => {
1491
- clearSafe();
1492
- setExiting(false);
1493
- setMounted(false);
1494
- onExitedRef.current?.();
1495
- }, [clearSafe]);
1496
- useEffect(() => {
1497
- const moving = animate && isMotionEnabled();
1498
- if (show && !prev.current) {
1499
- setExiting(false);
1500
- setMounted(true);
1501
- } else if (!show && prev.current) {
1502
- if (moving) {
1503
- setExiting(true);
1504
- clearSafe();
1505
- safeTimer.current = setTimeout(finishExit, SAFE_EXIT_MS);
1506
- } else {
1507
- setMounted(false);
1508
- setExiting(false);
1509
- }
1510
- }
1511
- prev.current = show;
1512
- }, [show, animate, clearSafe, finishExit]);
1513
- useEffect(() => () => clearSafe(), [clearSafe]);
1514
- const disabled = !animate || !isMotionEnabled();
1515
- const className = disabled ? "" : exiting ? `animate-${animation}-out` : `animate-${animation}-in`;
1516
- const onAnimationEnd = useCallback(
1517
- (e) => {
1518
- if (e.target !== e.currentTarget) return;
1519
- if (exiting) finishExit();
1520
- },
1521
- [exiting, finishExit]
1522
- );
1523
- return { mounted, exiting, className, onAnimationEnd };
1524
- }
1525
- var SAFE_EXIT_MS, motionEnabledCache, Presence;
1526
- var init_Presence = __esm({
1527
- "components/core/atoms/Presence.tsx"() {
1528
- "use client";
1529
- init_cn();
1530
- SAFE_EXIT_MS = 1e3;
1531
- motionEnabledCache = null;
1532
- Presence = ({ show, className, children, ...opts }) => {
1533
- const { mounted, className: animClass, onAnimationEnd } = usePresence(show, opts);
1534
- if (!mounted) return null;
1535
- return /* @__PURE__ */ jsx("div", { className: cn(animClass, className), onAnimationEnd, children });
1536
- };
1537
- Presence.displayName = "Presence";
1538
- }
1539
- });
1540
1532
  var Overlay;
1541
1533
  var init_Overlay = __esm({
1542
1534
  "components/core/atoms/Overlay.tsx"() {
@@ -1755,6 +1755,77 @@ var init_Typography = __esm({
1755
1755
  Typography.displayName = "Typography";
1756
1756
  }
1757
1757
  });
1758
+ function isMotionEnabled() {
1759
+ if (typeof document === "undefined") return true;
1760
+ if (motionEnabledCache !== null) return motionEnabledCache;
1761
+ const v = getComputedStyle(document.documentElement).getPropertyValue("--motion-enable").trim().toLowerCase();
1762
+ motionEnabledCache = v !== "off";
1763
+ return motionEnabledCache;
1764
+ }
1765
+ function usePresence(show, opts) {
1766
+ const { animation, animate = true, onExited } = opts;
1767
+ const [mounted, setMounted] = React82.useState(show);
1768
+ const [exiting, setExiting] = React82.useState(false);
1769
+ const prev = React82.useRef(show);
1770
+ const onExitedRef = React82.useRef(onExited);
1771
+ onExitedRef.current = onExited;
1772
+ const safeTimer = React82.useRef(null);
1773
+ const clearSafe = React82.useCallback(() => {
1774
+ if (safeTimer.current) {
1775
+ clearTimeout(safeTimer.current);
1776
+ safeTimer.current = null;
1777
+ }
1778
+ }, []);
1779
+ const finishExit = React82.useCallback(() => {
1780
+ clearSafe();
1781
+ setExiting(false);
1782
+ setMounted(false);
1783
+ onExitedRef.current?.();
1784
+ }, [clearSafe]);
1785
+ React82.useLayoutEffect(() => {
1786
+ const moving = animate && isMotionEnabled();
1787
+ if (show && !prev.current) {
1788
+ setExiting(false);
1789
+ setMounted(true);
1790
+ } else if (!show && prev.current) {
1791
+ if (moving) {
1792
+ setExiting(true);
1793
+ clearSafe();
1794
+ safeTimer.current = setTimeout(finishExit, SAFE_EXIT_MS);
1795
+ } else {
1796
+ setMounted(false);
1797
+ setExiting(false);
1798
+ }
1799
+ }
1800
+ prev.current = show;
1801
+ }, [show, animate, clearSafe, finishExit]);
1802
+ React82.useEffect(() => () => clearSafe(), [clearSafe]);
1803
+ const disabled = !animate || !isMotionEnabled();
1804
+ const className = disabled ? "" : exiting ? `animate-${animation}-out` : `animate-${animation}-in`;
1805
+ const onAnimationEnd = React82.useCallback(
1806
+ (e) => {
1807
+ if (e.target !== e.currentTarget) return;
1808
+ if (exiting) finishExit();
1809
+ },
1810
+ [exiting, finishExit]
1811
+ );
1812
+ return { mounted, exiting, className, onAnimationEnd };
1813
+ }
1814
+ var SAFE_EXIT_MS, motionEnabledCache, Presence;
1815
+ var init_Presence = __esm({
1816
+ "components/core/atoms/Presence.tsx"() {
1817
+ "use client";
1818
+ init_cn();
1819
+ SAFE_EXIT_MS = 1e3;
1820
+ motionEnabledCache = null;
1821
+ Presence = ({ show, className, children, ...opts }) => {
1822
+ const { mounted, className: animClass, onAnimationEnd } = usePresence(show, opts);
1823
+ if (!mounted) return null;
1824
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(animClass, className), onAnimationEnd, children });
1825
+ };
1826
+ Presence.displayName = "Presence";
1827
+ }
1828
+ });
1758
1829
  var sizeClasses2, minWidthClasses, lookStyles, Modal;
1759
1830
  var init_Modal = __esm({
1760
1831
  "components/core/molecules/Modal.tsx"() {
@@ -1765,6 +1836,7 @@ var init_Modal = __esm({
1765
1836
  init_Typography();
1766
1837
  init_cn();
1767
1838
  init_useEventBus();
1839
+ init_Presence();
1768
1840
  sizeClasses2 = {
1769
1841
  sm: "max-w-md",
1770
1842
  md: "max-w-2xl",
@@ -1809,18 +1881,10 @@ var init_Modal = __esm({
1809
1881
  const [dragY, setDragY] = React82.useState(0);
1810
1882
  const dragStartY = React82.useRef(0);
1811
1883
  const isDragging = React82.useRef(false);
1812
- const [closing, setClosing] = React82.useState(false);
1813
- const wasOpenRef = React82.useRef(isOpen);
1814
- React82.useEffect(() => {
1815
- if (wasOpenRef.current && !isOpen) setClosing(true);
1816
- wasOpenRef.current = isOpen;
1817
- }, [isOpen]);
1818
- const handleAnimEnd = (e) => {
1819
- if (closing && e.target === e.currentTarget) {
1820
- setClosing(false);
1821
- onExited?.();
1822
- }
1823
- };
1884
+ const { mounted, exiting, onAnimationEnd: handleAnimEnd } = usePresence(isOpen, {
1885
+ animation: "modal",
1886
+ onExited
1887
+ });
1824
1888
  React82.useEffect(() => {
1825
1889
  if (isOpen) {
1826
1890
  previousActiveElement.current = document.activeElement;
@@ -1855,10 +1919,9 @@ var init_Modal = __esm({
1855
1919
  };
1856
1920
  }, [isOpen]);
1857
1921
  if (typeof document === "undefined") return null;
1858
- const renderOpen = isOpen || closing;
1859
- if (!renderOpen) return null;
1860
- const dialogAnim = closing ? "animate-modal-out" : "animate-modal-in";
1861
- const overlayAnim = closing ? "animate-overlay-out" : "animate-overlay-in";
1922
+ if (!mounted) return null;
1923
+ const dialogAnim = exiting ? "animate-modal-out" : "animate-modal-in";
1924
+ const overlayAnim = exiting ? "animate-overlay-out" : "animate-overlay-in";
1862
1925
  const handleClose = () => {
1863
1926
  if (closeEvent) eventBus.emit(`UI:${closeEvent}`, {});
1864
1927
  onClose();
@@ -1989,77 +2052,6 @@ var init_Modal = __esm({
1989
2052
  Modal.displayName = "Modal";
1990
2053
  }
1991
2054
  });
1992
- function isMotionEnabled() {
1993
- if (typeof document === "undefined") return true;
1994
- if (motionEnabledCache !== null) return motionEnabledCache;
1995
- const v = getComputedStyle(document.documentElement).getPropertyValue("--motion-enable").trim().toLowerCase();
1996
- motionEnabledCache = v !== "off";
1997
- return motionEnabledCache;
1998
- }
1999
- function usePresence(show, opts) {
2000
- const { animation, animate = true, onExited } = opts;
2001
- const [mounted, setMounted] = React82.useState(show);
2002
- const [exiting, setExiting] = React82.useState(false);
2003
- const prev = React82.useRef(show);
2004
- const onExitedRef = React82.useRef(onExited);
2005
- onExitedRef.current = onExited;
2006
- const safeTimer = React82.useRef(null);
2007
- const clearSafe = React82.useCallback(() => {
2008
- if (safeTimer.current) {
2009
- clearTimeout(safeTimer.current);
2010
- safeTimer.current = null;
2011
- }
2012
- }, []);
2013
- const finishExit = React82.useCallback(() => {
2014
- clearSafe();
2015
- setExiting(false);
2016
- setMounted(false);
2017
- onExitedRef.current?.();
2018
- }, [clearSafe]);
2019
- React82.useEffect(() => {
2020
- const moving = animate && isMotionEnabled();
2021
- if (show && !prev.current) {
2022
- setExiting(false);
2023
- setMounted(true);
2024
- } else if (!show && prev.current) {
2025
- if (moving) {
2026
- setExiting(true);
2027
- clearSafe();
2028
- safeTimer.current = setTimeout(finishExit, SAFE_EXIT_MS);
2029
- } else {
2030
- setMounted(false);
2031
- setExiting(false);
2032
- }
2033
- }
2034
- prev.current = show;
2035
- }, [show, animate, clearSafe, finishExit]);
2036
- React82.useEffect(() => () => clearSafe(), [clearSafe]);
2037
- const disabled = !animate || !isMotionEnabled();
2038
- const className = disabled ? "" : exiting ? `animate-${animation}-out` : `animate-${animation}-in`;
2039
- const onAnimationEnd = React82.useCallback(
2040
- (e) => {
2041
- if (e.target !== e.currentTarget) return;
2042
- if (exiting) finishExit();
2043
- },
2044
- [exiting, finishExit]
2045
- );
2046
- return { mounted, exiting, className, onAnimationEnd };
2047
- }
2048
- var SAFE_EXIT_MS, motionEnabledCache, Presence;
2049
- var init_Presence = __esm({
2050
- "components/core/atoms/Presence.tsx"() {
2051
- "use client";
2052
- init_cn();
2053
- SAFE_EXIT_MS = 1e3;
2054
- motionEnabledCache = null;
2055
- Presence = ({ show, className, children, ...opts }) => {
2056
- const { mounted, className: animClass, onAnimationEnd } = usePresence(show, opts);
2057
- if (!mounted) return null;
2058
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(animClass, className), onAnimationEnd, children });
2059
- };
2060
- Presence.displayName = "Presence";
2061
- }
2062
- });
2063
2055
  var Overlay;
2064
2056
  var init_Overlay = __esm({
2065
2057
  "components/core/atoms/Overlay.tsx"() {