@hexdspace/react 0.1.16 → 0.1.17
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/css/component.css +4 -0
- package/dist/index.js +67 -54
- package/package.json +1 -1
package/dist/css/component.css
CHANGED
|
@@ -181,18 +181,22 @@
|
|
|
181
181
|
|
|
182
182
|
@keyframes dialog-surface-in {
|
|
183
183
|
from {
|
|
184
|
+
opacity: 0;
|
|
184
185
|
transform: translateY(1.25rem);
|
|
185
186
|
}
|
|
186
187
|
to {
|
|
188
|
+
opacity: 1;
|
|
187
189
|
transform: translateY(0);
|
|
188
190
|
}
|
|
189
191
|
}
|
|
190
192
|
|
|
191
193
|
@keyframes dialog-surface-out {
|
|
192
194
|
from {
|
|
195
|
+
opacity: 1;
|
|
193
196
|
transform: translateY(0);
|
|
194
197
|
}
|
|
195
198
|
to {
|
|
199
|
+
opacity: 0;
|
|
196
200
|
transform: translateY(1.25rem);
|
|
197
201
|
}
|
|
198
202
|
}
|
package/dist/index.js
CHANGED
|
@@ -1559,16 +1559,26 @@ var dialogPanelVariants = cva2(
|
|
|
1559
1559
|
);
|
|
1560
1560
|
var dialogOverlayClass = cn(
|
|
1561
1561
|
"fixed inset-0 bg-[color:var(--overlay)]",
|
|
1562
|
-
"data-[state=open]:animate-[dialog-overlay-in_var(--motion-med)_cubic-bezier(0.2,0,0.2,1)]",
|
|
1563
1562
|
"data-[state=closed]:animate-[dialog-overlay-out_var(--motion-med)_cubic-bezier(0.2,0,0.2,1)]",
|
|
1564
1563
|
"data-[state=closed]:pointer-events-none"
|
|
1565
1564
|
);
|
|
1566
1565
|
function DialogContent({ className, ...props }) {
|
|
1567
1566
|
return /* @__PURE__ */ jsx7("div", { className: cn("DialogContent p-6", className), ...props });
|
|
1568
1567
|
}
|
|
1569
|
-
function AutoHeight({
|
|
1568
|
+
function AutoHeight({
|
|
1569
|
+
children,
|
|
1570
|
+
onReady,
|
|
1571
|
+
resetKey
|
|
1572
|
+
}) {
|
|
1570
1573
|
const ref = React2.useRef(null);
|
|
1571
1574
|
const [height, setHeight] = React2.useState("auto");
|
|
1575
|
+
const readyRef = React2.useRef(false);
|
|
1576
|
+
const resetKeyRef = React2.useRef(resetKey);
|
|
1577
|
+
React2.useEffect(() => {
|
|
1578
|
+
if (resetKeyRef.current === resetKey) return;
|
|
1579
|
+
resetKeyRef.current = resetKey;
|
|
1580
|
+
readyRef.current = false;
|
|
1581
|
+
});
|
|
1572
1582
|
React2.useLayoutEffect(() => {
|
|
1573
1583
|
const el = ref.current;
|
|
1574
1584
|
if (!el) return;
|
|
@@ -1584,6 +1594,12 @@ function AutoHeight({ children }) {
|
|
|
1584
1594
|
if (prevNum < 0 || Math.abs(snapped - prevNum) >= 2) return snapped;
|
|
1585
1595
|
return prev;
|
|
1586
1596
|
});
|
|
1597
|
+
if (!readyRef.current) {
|
|
1598
|
+
readyRef.current = true;
|
|
1599
|
+
requestAnimationFrame(() => {
|
|
1600
|
+
onReady?.();
|
|
1601
|
+
});
|
|
1602
|
+
}
|
|
1587
1603
|
});
|
|
1588
1604
|
});
|
|
1589
1605
|
ro.observe(el);
|
|
@@ -1591,13 +1607,11 @@ function AutoHeight({ children }) {
|
|
|
1591
1607
|
ro.disconnect();
|
|
1592
1608
|
cancelAnimationFrame(raf);
|
|
1593
1609
|
};
|
|
1594
|
-
}, []);
|
|
1610
|
+
}, [onReady]);
|
|
1595
1611
|
return /* @__PURE__ */ jsx7(
|
|
1596
1612
|
"div",
|
|
1597
1613
|
{
|
|
1598
|
-
className: cn(
|
|
1599
|
-
"transition-[height] duration-(--motion-med) ease motion-reduce:transition-none"
|
|
1600
|
-
),
|
|
1614
|
+
className: cn("transition-[height] duration-(--motion-med) ease motion-reduce:transition-none"),
|
|
1601
1615
|
style: {
|
|
1602
1616
|
height: height === "auto" ? "auto" : height,
|
|
1603
1617
|
maxHeight: "calc(100vh - 4rem)",
|
|
@@ -1630,11 +1644,13 @@ function Dialog({
|
|
|
1630
1644
|
}) {
|
|
1631
1645
|
const fallbackId = React2.useId();
|
|
1632
1646
|
const resolvedRef = React2.useRef(false);
|
|
1633
|
-
const rafRef = React2.useRef(null);
|
|
1634
1647
|
const isControlled = open2 !== void 0;
|
|
1635
1648
|
const [uncontrolledOpen, setUncontrolledOpen] = React2.useState(defaultOpen ?? false);
|
|
1636
|
-
const
|
|
1637
|
-
const
|
|
1649
|
+
const isOpen = isControlled ? open2 : uncontrolledOpen;
|
|
1650
|
+
const prevOpenRef = React2.useRef(false);
|
|
1651
|
+
const [contentCycle, setContentCycle] = React2.useState(0);
|
|
1652
|
+
const [surfaceReady, setSurfaceReady] = React2.useState(false);
|
|
1653
|
+
const [overlayReady, setOverlayReady] = React2.useState(false);
|
|
1638
1654
|
const Template = template;
|
|
1639
1655
|
const handleOpenChange = (nextOpen) => {
|
|
1640
1656
|
if (!isControlled) setUncontrolledOpen(nextOpen);
|
|
@@ -1657,34 +1673,41 @@ function Dialog({
|
|
|
1657
1673
|
[onResolve]
|
|
1658
1674
|
);
|
|
1659
1675
|
React2.useEffect(() => {
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1676
|
+
const wasOpen = prevOpenRef.current;
|
|
1677
|
+
prevOpenRef.current = Boolean(isOpen);
|
|
1678
|
+
if (isOpen && !wasOpen) {
|
|
1679
|
+
setContentCycle((value) => value + 1);
|
|
1680
|
+
setSurfaceReady(false);
|
|
1681
|
+
setOverlayReady(false);
|
|
1666
1682
|
return;
|
|
1667
1683
|
}
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1684
|
+
if (!isOpen && wasOpen) {
|
|
1685
|
+
setSurfaceReady(false);
|
|
1686
|
+
setOverlayReady(false);
|
|
1687
|
+
}
|
|
1688
|
+
}, [isOpen]);
|
|
1689
|
+
const handleAutoHeightReady = React2.useCallback(() => {
|
|
1690
|
+
if (!isOpen) return;
|
|
1691
|
+
requestAnimationFrame(() => {
|
|
1692
|
+
setSurfaceReady(true);
|
|
1693
|
+
setOverlayReady(true);
|
|
1673
1694
|
});
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1695
|
+
}, [isOpen]);
|
|
1696
|
+
const overlayClassName = cn(
|
|
1697
|
+
"DialogOverlay",
|
|
1698
|
+
dialogOverlayClass,
|
|
1699
|
+
isOpen && !overlayReady ? "opacity-0" : null,
|
|
1700
|
+
overlayReady ? "animate-[dialog-overlay-in_var(--motion-med)_cubic-bezier(0.2,0,0.2,1)] [animation-fill-mode:both]" : null
|
|
1701
|
+
);
|
|
1702
|
+
const surfaceClassName = cn(
|
|
1703
|
+
"dialog-surface relative shell overflow-hidden",
|
|
1704
|
+
isOpen && !surfaceReady ? "opacity-0 translate-y-5" : null,
|
|
1705
|
+
surfaceReady ? "animate-[dialog-surface-in_var(--motion-med)_cubic-bezier(0.16,1,0.3,1)] [animation-fill-mode:both]" : null
|
|
1706
|
+
);
|
|
1678
1707
|
return /* @__PURE__ */ jsxs3(DialogPrimitive.Root, { open: open2, defaultOpen, onOpenChange: handleOpenChange, modal, children: [
|
|
1679
1708
|
trigger ? /* @__PURE__ */ jsx7(DialogPrimitive.Trigger, { asChild: true, children: trigger }) : null,
|
|
1680
1709
|
/* @__PURE__ */ jsxs3(DialogPrimitive.Portal, { children: [
|
|
1681
|
-
modal ? /* @__PURE__ */ jsx7(
|
|
1682
|
-
DialogPrimitive.Overlay,
|
|
1683
|
-
{
|
|
1684
|
-
className: cn("DialogOverlay", dialogOverlayClass),
|
|
1685
|
-
style: { zIndex: zIndex - 1 }
|
|
1686
|
-
}
|
|
1687
|
-
) : null,
|
|
1710
|
+
modal ? /* @__PURE__ */ jsx7(DialogPrimitive.Overlay, { className: overlayClassName, style: { zIndex: zIndex - 1 } }) : null,
|
|
1688
1711
|
/* @__PURE__ */ jsx7(
|
|
1689
1712
|
DialogPrimitive.Content,
|
|
1690
1713
|
{
|
|
@@ -1706,29 +1729,19 @@ function Dialog({
|
|
|
1706
1729
|
if (!dismissible) event.preventDefault();
|
|
1707
1730
|
},
|
|
1708
1731
|
...props,
|
|
1709
|
-
children: /* @__PURE__ */ jsxs3(
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
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
|
-
)
|
|
1732
|
+
children: /* @__PURE__ */ jsxs3("div", { className: surfaceClassName, children: [
|
|
1733
|
+
showClose ? /* @__PURE__ */ jsx7(DialogPrimitive.Close, { asChild: true, children: /* @__PURE__ */ jsx7(
|
|
1734
|
+
Button,
|
|
1735
|
+
{
|
|
1736
|
+
variant: "ghost",
|
|
1737
|
+
size: "icon",
|
|
1738
|
+
leftIcon: /* @__PURE__ */ jsx7(XIcon, { className: "w-5 h-5" }),
|
|
1739
|
+
className: "absolute right-2 top-2 z-10 rounded-full",
|
|
1740
|
+
"aria-label": closeLabel
|
|
1741
|
+
}
|
|
1742
|
+
) }) : null,
|
|
1743
|
+
/* @__PURE__ */ jsx7(AutoHeight, { onReady: handleAutoHeightReady, resetKey: contentCycle, children: /* @__PURE__ */ jsx7(Template, { id: id ?? fallbackId, payload, onResolve: handleResolve }) })
|
|
1744
|
+
] })
|
|
1732
1745
|
}
|
|
1733
1746
|
)
|
|
1734
1747
|
] })
|