@hexdspace/react 0.1.15 → 0.1.16
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.js +62 -62
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1552,9 +1552,8 @@ var dialogPanelVariants = cva2(
|
|
|
1552
1552
|
"-translate-x-1/2 -translate-y-1/2",
|
|
1553
1553
|
"w-[min(92vw,var(--dialog-width))]",
|
|
1554
1554
|
"pointer-events-auto",
|
|
1555
|
-
"data-[state=open]:
|
|
1556
|
-
"data-[state=closed]:animate-[dialog-fade-out_var(--motion-med)
|
|
1557
|
-
"motion-reduce:animate-none",
|
|
1555
|
+
"data-[state=open]:transition-opacity duration-[var(--motion-med)]",
|
|
1556
|
+
"data-[state=closed]:animate-[dialog-fade-out_var(--motion-med)]",
|
|
1558
1557
|
"data-[state=closed]:pointer-events-none"
|
|
1559
1558
|
)
|
|
1560
1559
|
);
|
|
@@ -1562,20 +1561,15 @@ var dialogOverlayClass = cn(
|
|
|
1562
1561
|
"fixed inset-0 bg-[color:var(--overlay)]",
|
|
1563
1562
|
"data-[state=open]:animate-[dialog-overlay-in_var(--motion-med)_cubic-bezier(0.2,0,0.2,1)]",
|
|
1564
1563
|
"data-[state=closed]:animate-[dialog-overlay-out_var(--motion-med)_cubic-bezier(0.2,0,0.2,1)]",
|
|
1565
|
-
"motion-reduce:animate-none",
|
|
1566
1564
|
"data-[state=closed]:pointer-events-none"
|
|
1567
1565
|
);
|
|
1568
1566
|
function DialogContent({ className, ...props }) {
|
|
1569
1567
|
return /* @__PURE__ */ jsx7("div", { className: cn("DialogContent p-6", className), ...props });
|
|
1570
1568
|
}
|
|
1571
|
-
function AutoHeight({ children
|
|
1569
|
+
function AutoHeight({ children }) {
|
|
1572
1570
|
const ref = React2.useRef(null);
|
|
1573
1571
|
const [height, setHeight] = React2.useState("auto");
|
|
1574
|
-
React2.
|
|
1575
|
-
if (freeze) {
|
|
1576
|
-
setHeight("auto");
|
|
1577
|
-
return;
|
|
1578
|
-
}
|
|
1572
|
+
React2.useLayoutEffect(() => {
|
|
1579
1573
|
const el = ref.current;
|
|
1580
1574
|
if (!el) return;
|
|
1581
1575
|
const dpr = Math.max(1, Math.round(window.devicePixelRatio || 1));
|
|
@@ -1597,15 +1591,19 @@ function AutoHeight({ children, freeze = false }) {
|
|
|
1597
1591
|
ro.disconnect();
|
|
1598
1592
|
cancelAnimationFrame(raf);
|
|
1599
1593
|
};
|
|
1600
|
-
}, [
|
|
1594
|
+
}, []);
|
|
1601
1595
|
return /* @__PURE__ */ jsx7(
|
|
1602
1596
|
"div",
|
|
1603
1597
|
{
|
|
1604
1598
|
className: cn(
|
|
1605
|
-
"transition-[height] duration-(--motion-med) ease motion-reduce:transition-none"
|
|
1606
|
-
freeze && "transition-none"
|
|
1599
|
+
"transition-[height] duration-(--motion-med) ease motion-reduce:transition-none"
|
|
1607
1600
|
),
|
|
1608
|
-
style: {
|
|
1601
|
+
style: {
|
|
1602
|
+
height: height === "auto" ? "auto" : height,
|
|
1603
|
+
maxHeight: "calc(100vh - 4rem)",
|
|
1604
|
+
overflow: "auto",
|
|
1605
|
+
willChange: "height"
|
|
1606
|
+
},
|
|
1609
1607
|
children: /* @__PURE__ */ jsx7("div", { ref, style: { boxSizing: "border-box" }, children })
|
|
1610
1608
|
}
|
|
1611
1609
|
);
|
|
@@ -1632,19 +1630,14 @@ function Dialog({
|
|
|
1632
1630
|
}) {
|
|
1633
1631
|
const fallbackId = React2.useId();
|
|
1634
1632
|
const resolvedRef = React2.useRef(false);
|
|
1635
|
-
const
|
|
1636
|
-
const
|
|
1637
|
-
const
|
|
1633
|
+
const rafRef = React2.useRef(null);
|
|
1634
|
+
const isControlled = open2 !== void 0;
|
|
1635
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React2.useState(defaultOpen ?? false);
|
|
1636
|
+
const currentOpen = isControlled ? open2 : uncontrolledOpen;
|
|
1637
|
+
const [animateSurface, setAnimateSurface] = React2.useState(false);
|
|
1638
1638
|
const Template = template;
|
|
1639
1639
|
const handleOpenChange = (nextOpen) => {
|
|
1640
|
-
if (
|
|
1641
|
-
if (animationTimer.current) window.clearTimeout(animationTimer.current);
|
|
1642
|
-
setIsAnimating(true);
|
|
1643
|
-
animationTimer.current = window.setTimeout(() => {
|
|
1644
|
-
setIsAnimating(false);
|
|
1645
|
-
animationTimer.current = null;
|
|
1646
|
-
}, motionMs);
|
|
1647
|
-
}
|
|
1640
|
+
if (!isControlled) setUncontrolledOpen(nextOpen);
|
|
1648
1641
|
onOpenChange?.(nextOpen);
|
|
1649
1642
|
if (nextOpen) {
|
|
1650
1643
|
resolvedRef.current = false;
|
|
@@ -1663,6 +1656,25 @@ function Dialog({
|
|
|
1663
1656
|
},
|
|
1664
1657
|
[onResolve]
|
|
1665
1658
|
);
|
|
1659
|
+
React2.useEffect(() => {
|
|
1660
|
+
if (rafRef.current) {
|
|
1661
|
+
cancelAnimationFrame(rafRef.current);
|
|
1662
|
+
rafRef.current = null;
|
|
1663
|
+
}
|
|
1664
|
+
if (!currentOpen) {
|
|
1665
|
+
setAnimateSurface(false);
|
|
1666
|
+
return;
|
|
1667
|
+
}
|
|
1668
|
+
setAnimateSurface(false);
|
|
1669
|
+
rafRef.current = requestAnimationFrame(() => {
|
|
1670
|
+
rafRef.current = requestAnimationFrame(() => {
|
|
1671
|
+
setAnimateSurface(true);
|
|
1672
|
+
});
|
|
1673
|
+
});
|
|
1674
|
+
return () => {
|
|
1675
|
+
if (rafRef.current) cancelAnimationFrame(rafRef.current);
|
|
1676
|
+
};
|
|
1677
|
+
}, [currentOpen]);
|
|
1666
1678
|
return /* @__PURE__ */ jsxs3(DialogPrimitive.Root, { open: open2, defaultOpen, onOpenChange: handleOpenChange, modal, children: [
|
|
1667
1679
|
trigger ? /* @__PURE__ */ jsx7(DialogPrimitive.Trigger, { asChild: true, children: trigger }) : null,
|
|
1668
1680
|
/* @__PURE__ */ jsxs3(DialogPrimitive.Portal, { children: [
|
|
@@ -1679,12 +1691,9 @@ function Dialog({
|
|
|
1679
1691
|
className: cn(
|
|
1680
1692
|
"DialogContent",
|
|
1681
1693
|
dialogPanelVariants(),
|
|
1682
|
-
"data-[state=open]:[&_.dialog-surface]:animate-[dialog-surface-in_var(--motion-med)_cubic-bezier(0.16,1,0.3,1)]",
|
|
1683
1694
|
"data-[state=closed]:[&_.dialog-surface]:animate-[dialog-surface-out_var(--motion-med)_cubic-bezier(0.4,0,1,1)]",
|
|
1684
|
-
"motion-reduce:[&_.dialog-surface]:animate-none",
|
|
1685
1695
|
className
|
|
1686
1696
|
),
|
|
1687
|
-
"aria-describedby": void 0,
|
|
1688
1697
|
style: {
|
|
1689
1698
|
...style,
|
|
1690
1699
|
zIndex,
|
|
@@ -1697,43 +1706,34 @@ function Dialog({
|
|
|
1697
1706
|
if (!dismissible) event.preventDefault();
|
|
1698
1707
|
},
|
|
1699
1708
|
...props,
|
|
1700
|
-
children: /* @__PURE__ */ jsxs3(
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1709
|
+
children: /* @__PURE__ */ jsxs3(
|
|
1710
|
+
"div",
|
|
1711
|
+
{
|
|
1712
|
+
className: cn(
|
|
1713
|
+
"dialog-surface relative shell overflow-hidden",
|
|
1714
|
+
currentOpen && !animateSurface ? "opacity-0 translate-y-5" : null,
|
|
1715
|
+
animateSurface ? "animate-[dialog-surface-in_var(--motion-med)_cubic-bezier(0.16,1,0.3,1)]" : null
|
|
1716
|
+
),
|
|
1717
|
+
children: [
|
|
1718
|
+
showClose ? /* @__PURE__ */ jsx7(DialogPrimitive.Close, { asChild: true, children: /* @__PURE__ */ jsx7(
|
|
1719
|
+
Button,
|
|
1720
|
+
{
|
|
1721
|
+
variant: "ghost",
|
|
1722
|
+
size: "icon",
|
|
1723
|
+
leftIcon: /* @__PURE__ */ jsx7(XIcon, { className: "w-5 h-5" }),
|
|
1724
|
+
className: "absolute right-2 top-2 z-10 rounded-full",
|
|
1725
|
+
"aria-label": closeLabel
|
|
1726
|
+
}
|
|
1727
|
+
) }) : null,
|
|
1728
|
+
/* @__PURE__ */ jsx7(AutoHeight, { children: /* @__PURE__ */ jsx7(Template, { id: id ?? fallbackId, payload, onResolve: handleResolve }) })
|
|
1729
|
+
]
|
|
1730
|
+
}
|
|
1731
|
+
)
|
|
1713
1732
|
}
|
|
1714
1733
|
)
|
|
1715
1734
|
] })
|
|
1716
1735
|
] });
|
|
1717
1736
|
}
|
|
1718
|
-
function useMotionDurationMs(token, fallback) {
|
|
1719
|
-
const [ms, setMs] = React2.useState(fallback);
|
|
1720
|
-
React2.useEffect(() => {
|
|
1721
|
-
if (typeof window === "undefined") return;
|
|
1722
|
-
const raw = getComputedStyle(document.documentElement).getPropertyValue(token).trim();
|
|
1723
|
-
const parsed = parseDurationMs(raw);
|
|
1724
|
-
if (parsed !== null) setMs(parsed);
|
|
1725
|
-
}, [token]);
|
|
1726
|
-
return ms;
|
|
1727
|
-
}
|
|
1728
|
-
function parseDurationMs(value) {
|
|
1729
|
-
if (!value) return null;
|
|
1730
|
-
const trimmed = value.trim();
|
|
1731
|
-
const numeric = Number(trimmed.replace(/ms|s/g, ""));
|
|
1732
|
-
if (Number.isNaN(numeric)) return null;
|
|
1733
|
-
if (trimmed.endsWith("ms")) return numeric;
|
|
1734
|
-
if (trimmed.endsWith("s")) return numeric * 1e3;
|
|
1735
|
-
return numeric;
|
|
1736
|
-
}
|
|
1737
1737
|
|
|
1738
1738
|
// src/ui/components/dialog/dialog-variant/ConfirmDialog.tsx
|
|
1739
1739
|
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
@@ -1954,7 +1954,7 @@ var DialogHost = () => {
|
|
|
1954
1954
|
React3.useEffect(() => {
|
|
1955
1955
|
if (typeof window === "undefined") return;
|
|
1956
1956
|
const raw = getComputedStyle(document.documentElement).getPropertyValue("--motion-fast").trim();
|
|
1957
|
-
const parsed =
|
|
1957
|
+
const parsed = parseDurationMs(raw);
|
|
1958
1958
|
if (parsed) setCloseDelayMs(parsed);
|
|
1959
1959
|
}, []);
|
|
1960
1960
|
React3.useEffect(() => {
|
|
@@ -2010,7 +2010,7 @@ var DialogHost = () => {
|
|
|
2010
2010
|
);
|
|
2011
2011
|
}) });
|
|
2012
2012
|
};
|
|
2013
|
-
function
|
|
2013
|
+
function parseDurationMs(value) {
|
|
2014
2014
|
if (!value) return null;
|
|
2015
2015
|
const trimmed = value.trim();
|
|
2016
2016
|
const asNumber = Number(trimmed.replace(/ms|s/g, ""));
|