@hexdspace/react 0.1.13 → 0.1.15
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 +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +72 -30
- package/package.json +1 -1
package/dist/css/component.css
CHANGED
|
@@ -181,7 +181,7 @@
|
|
|
181
181
|
|
|
182
182
|
@keyframes dialog-surface-in {
|
|
183
183
|
from {
|
|
184
|
-
transform: translateY(
|
|
184
|
+
transform: translateY(1.25rem);
|
|
185
185
|
}
|
|
186
186
|
to {
|
|
187
187
|
transform: translateY(0);
|
|
@@ -193,7 +193,7 @@
|
|
|
193
193
|
transform: translateY(0);
|
|
194
194
|
}
|
|
195
195
|
to {
|
|
196
|
-
transform: translateY(
|
|
196
|
+
transform: translateY(1.25rem);
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1552,26 +1552,30 @@ 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]:animate-[dialog-fade-in_var(--motion-med)_cubic-bezier(0.
|
|
1556
|
-
"data-[state=closed]:animate-[dialog-fade-out_var(--motion-med)_cubic-bezier(0.
|
|
1555
|
+
"data-[state=open]:animate-[dialog-fade-in_var(--motion-med)_cubic-bezier(0.2,0,0.2,1)]",
|
|
1556
|
+
"data-[state=closed]:animate-[dialog-fade-out_var(--motion-med)_cubic-bezier(0.2,0,0.2,1)]",
|
|
1557
1557
|
"motion-reduce:animate-none",
|
|
1558
1558
|
"data-[state=closed]:pointer-events-none"
|
|
1559
1559
|
)
|
|
1560
1560
|
);
|
|
1561
1561
|
var dialogOverlayClass = cn(
|
|
1562
1562
|
"fixed inset-0 bg-[color:var(--overlay)]",
|
|
1563
|
-
"data-[state=open]:animate-[dialog-overlay-in_var(--motion-med)_cubic-bezier(0.
|
|
1564
|
-
"data-[state=closed]:animate-[dialog-overlay-out_var(--motion-med)_cubic-bezier(0.
|
|
1563
|
+
"data-[state=open]:animate-[dialog-overlay-in_var(--motion-med)_cubic-bezier(0.2,0,0.2,1)]",
|
|
1564
|
+
"data-[state=closed]:animate-[dialog-overlay-out_var(--motion-med)_cubic-bezier(0.2,0,0.2,1)]",
|
|
1565
1565
|
"motion-reduce:animate-none",
|
|
1566
1566
|
"data-[state=closed]:pointer-events-none"
|
|
1567
1567
|
);
|
|
1568
1568
|
function DialogContent({ className, ...props }) {
|
|
1569
1569
|
return /* @__PURE__ */ jsx7("div", { className: cn("DialogContent p-6", className), ...props });
|
|
1570
1570
|
}
|
|
1571
|
-
function AutoHeight({ children }) {
|
|
1571
|
+
function AutoHeight({ children, freeze = false }) {
|
|
1572
1572
|
const ref = React2.useRef(null);
|
|
1573
1573
|
const [height, setHeight] = React2.useState("auto");
|
|
1574
|
-
React2.
|
|
1574
|
+
React2.useEffect(() => {
|
|
1575
|
+
if (freeze) {
|
|
1576
|
+
setHeight("auto");
|
|
1577
|
+
return;
|
|
1578
|
+
}
|
|
1575
1579
|
const el = ref.current;
|
|
1576
1580
|
if (!el) return;
|
|
1577
1581
|
const dpr = Math.max(1, Math.round(window.devicePixelRatio || 1));
|
|
@@ -1593,11 +1597,14 @@ function AutoHeight({ children }) {
|
|
|
1593
1597
|
ro.disconnect();
|
|
1594
1598
|
cancelAnimationFrame(raf);
|
|
1595
1599
|
};
|
|
1596
|
-
}, []);
|
|
1600
|
+
}, [freeze]);
|
|
1597
1601
|
return /* @__PURE__ */ jsx7(
|
|
1598
1602
|
"div",
|
|
1599
1603
|
{
|
|
1600
|
-
className:
|
|
1604
|
+
className: cn(
|
|
1605
|
+
"transition-[height] duration-(--motion-med) ease motion-reduce:transition-none",
|
|
1606
|
+
freeze && "transition-none"
|
|
1607
|
+
),
|
|
1601
1608
|
style: { height: height === "auto" ? "auto" : height, overflow: "hidden", willChange: "height" },
|
|
1602
1609
|
children: /* @__PURE__ */ jsx7("div", { ref, style: { boxSizing: "border-box" }, children })
|
|
1603
1610
|
}
|
|
@@ -1625,8 +1632,19 @@ function Dialog({
|
|
|
1625
1632
|
}) {
|
|
1626
1633
|
const fallbackId = React2.useId();
|
|
1627
1634
|
const resolvedRef = React2.useRef(false);
|
|
1635
|
+
const [isAnimating, setIsAnimating] = React2.useState(false);
|
|
1636
|
+
const animationTimer = React2.useRef(null);
|
|
1637
|
+
const motionMs = useMotionDurationMs("--motion-med", 160);
|
|
1628
1638
|
const Template = template;
|
|
1629
1639
|
const handleOpenChange = (nextOpen) => {
|
|
1640
|
+
if (typeof window !== "undefined") {
|
|
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
|
+
}
|
|
1630
1648
|
onOpenChange?.(nextOpen);
|
|
1631
1649
|
if (nextOpen) {
|
|
1632
1650
|
resolvedRef.current = false;
|
|
@@ -1666,6 +1684,7 @@ function Dialog({
|
|
|
1666
1684
|
"motion-reduce:[&_.dialog-surface]:animate-none",
|
|
1667
1685
|
className
|
|
1668
1686
|
),
|
|
1687
|
+
"aria-describedby": void 0,
|
|
1669
1688
|
style: {
|
|
1670
1689
|
...style,
|
|
1671
1690
|
zIndex,
|
|
@@ -1689,13 +1708,32 @@ function Dialog({
|
|
|
1689
1708
|
"aria-label": closeLabel
|
|
1690
1709
|
}
|
|
1691
1710
|
) }) : null,
|
|
1692
|
-
/* @__PURE__ */ jsx7(AutoHeight, { children: /* @__PURE__ */ jsx7(Template, { id: id ?? fallbackId, payload, onResolve: handleResolve }) })
|
|
1711
|
+
/* @__PURE__ */ jsx7(AutoHeight, { freeze: isAnimating, children: /* @__PURE__ */ jsx7(Template, { id: id ?? fallbackId, payload, onResolve: handleResolve }) })
|
|
1693
1712
|
] })
|
|
1694
1713
|
}
|
|
1695
1714
|
)
|
|
1696
1715
|
] })
|
|
1697
1716
|
] });
|
|
1698
1717
|
}
|
|
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
|
+
}
|
|
1699
1737
|
|
|
1700
1738
|
// src/ui/components/dialog/dialog-variant/ConfirmDialog.tsx
|
|
1701
1739
|
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
@@ -1703,9 +1741,9 @@ var ConfirmDialog = (props) => {
|
|
|
1703
1741
|
const p = props.payload ?? { title: "Are you sure?" };
|
|
1704
1742
|
const confirmVariant = p.variant ?? (p.danger ? "danger" : "secondary");
|
|
1705
1743
|
return /* @__PURE__ */ jsxs4(DialogContent, { children: [
|
|
1706
|
-
/* @__PURE__ */ jsx8(
|
|
1744
|
+
/* @__PURE__ */ jsx8(DialogPrimitive2.Title, { className: "text-lg font-semibold", children: p.title }),
|
|
1707
1745
|
p.children && p.children,
|
|
1708
|
-
p.message ? /* @__PURE__ */ jsx8(
|
|
1746
|
+
p.message ? /* @__PURE__ */ jsx8(DialogPrimitive2.Description, { className: "mt-2 text-sm opacity-80", children: p.message }) : null,
|
|
1709
1747
|
/* @__PURE__ */ jsxs4("div", { className: "mt-5 flex items-center justify-end gap-4", children: [
|
|
1710
1748
|
/* @__PURE__ */ jsx8(DialogPrimitive2.Close, { asChild: true, children: /* @__PURE__ */ jsx8(Button, { variant: "secondary", children: p.cancelText ?? "Cancel" }) }),
|
|
1711
1749
|
/* @__PURE__ */ jsx8(DialogPrimitive2.Close, { asChild: true, children: /* @__PURE__ */ jsx8(Button, { variant: confirmVariant, onClick: () => props.onResolve?.({ confirmed: true }), children: p.confirmText ?? "Confirm" }) })
|
|
@@ -1714,21 +1752,25 @@ var ConfirmDialog = (props) => {
|
|
|
1714
1752
|
};
|
|
1715
1753
|
|
|
1716
1754
|
// src/ui/components/dialog/dialog-variant/CustomDialog.tsx
|
|
1717
|
-
import {
|
|
1755
|
+
import { Dialog as DialogPrimitive3 } from "radix-ui";
|
|
1756
|
+
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1718
1757
|
var CustomDialog = (props) => {
|
|
1719
1758
|
const p = props.payload ?? { children: /* @__PURE__ */ jsx9("div", { children: "Empty custom dialog" }) };
|
|
1720
|
-
return /* @__PURE__ */
|
|
1759
|
+
return /* @__PURE__ */ jsxs5(DialogContent, { children: [
|
|
1760
|
+
/* @__PURE__ */ jsx9(DialogPrimitive3.Title, { className: "sr-only", children: p.title ?? "Dialog" }),
|
|
1761
|
+
p.children
|
|
1762
|
+
] });
|
|
1721
1763
|
};
|
|
1722
1764
|
|
|
1723
1765
|
// src/ui/components/dialog/dialog-variant/InfoDialog.tsx
|
|
1724
|
-
import { Dialog as
|
|
1725
|
-
import { jsx as jsx10, jsxs as
|
|
1766
|
+
import { Dialog as DialogPrimitive4 } from "radix-ui";
|
|
1767
|
+
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1726
1768
|
var InfoDialog = (props) => {
|
|
1727
1769
|
const p = props.payload ?? { title: "Information" };
|
|
1728
|
-
return /* @__PURE__ */
|
|
1729
|
-
/* @__PURE__ */ jsx10(
|
|
1730
|
-
p.children,
|
|
1731
|
-
/* @__PURE__ */ jsx10("div", { className: "mt-5 flex items-center justify-end gap-4", children: /* @__PURE__ */ jsx10(
|
|
1770
|
+
return /* @__PURE__ */ jsxs6(DialogContent, { children: [
|
|
1771
|
+
/* @__PURE__ */ jsx10(DialogPrimitive4.Title, { className: "text-lg font-semibold", children: p.title }),
|
|
1772
|
+
p.children ? /* @__PURE__ */ jsx10(DialogPrimitive4.Description, { asChild: true, children: /* @__PURE__ */ jsx10("div", { className: "mt-2 text-sm opacity-80", children: p.children }) }) : null,
|
|
1773
|
+
/* @__PURE__ */ jsx10("div", { className: "mt-5 flex items-center justify-end gap-4", children: /* @__PURE__ */ jsx10(DialogPrimitive4.Close, { asChild: true, children: /* @__PURE__ */ jsx10(Button, { variant: "secondary", children: p.confirmText || "Dismiss" }) }) })
|
|
1732
1774
|
] });
|
|
1733
1775
|
};
|
|
1734
1776
|
|
|
@@ -1912,7 +1954,7 @@ var DialogHost = () => {
|
|
|
1912
1954
|
React3.useEffect(() => {
|
|
1913
1955
|
if (typeof window === "undefined") return;
|
|
1914
1956
|
const raw = getComputedStyle(document.documentElement).getPropertyValue("--motion-fast").trim();
|
|
1915
|
-
const parsed =
|
|
1957
|
+
const parsed = parseDurationMs2(raw);
|
|
1916
1958
|
if (parsed) setCloseDelayMs(parsed);
|
|
1917
1959
|
}, []);
|
|
1918
1960
|
React3.useEffect(() => {
|
|
@@ -1968,7 +2010,7 @@ var DialogHost = () => {
|
|
|
1968
2010
|
);
|
|
1969
2011
|
}) });
|
|
1970
2012
|
};
|
|
1971
|
-
function
|
|
2013
|
+
function parseDurationMs2(value) {
|
|
1972
2014
|
if (!value) return null;
|
|
1973
2015
|
const trimmed = value.trim();
|
|
1974
2016
|
const asNumber = Number(trimmed.replace(/ms|s/g, ""));
|
|
@@ -2014,7 +2056,7 @@ var Label = React4.forwardRef(
|
|
|
2014
2056
|
Label.displayName = "Label";
|
|
2015
2057
|
|
|
2016
2058
|
// src/ui/components/Field.tsx
|
|
2017
|
-
import { jsx as jsx13, jsxs as
|
|
2059
|
+
import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2018
2060
|
function Field({ label, hint, error, required, disabled, id, children, className, ...props }) {
|
|
2019
2061
|
const reactId = React5.useId();
|
|
2020
2062
|
const controlId = id ?? `field-${reactId}`;
|
|
@@ -2033,10 +2075,10 @@ function Field({ label, hint, error, required, disabled, id, children, className
|
|
|
2033
2075
|
invalid,
|
|
2034
2076
|
"aria-describedby": ariaDescribedBy
|
|
2035
2077
|
});
|
|
2036
|
-
return /* @__PURE__ */
|
|
2037
|
-
label ? /* @__PURE__ */ jsx13("div", { className: "flex items-center justify-between gap-3", children: /* @__PURE__ */
|
|
2078
|
+
return /* @__PURE__ */ jsxs7("div", { className: cn("grid gap-1.5", className), ...props, children: [
|
|
2079
|
+
label ? /* @__PURE__ */ jsx13("div", { className: "flex items-center justify-between gap-3", children: /* @__PURE__ */ jsxs7(Label, { htmlFor: controlId, children: [
|
|
2038
2080
|
label,
|
|
2039
|
-
resolvedRequired ? /* @__PURE__ */
|
|
2081
|
+
resolvedRequired ? /* @__PURE__ */ jsxs7("span", { "aria-hidden": "true", className: "text-(--muted)", children: [
|
|
2040
2082
|
" ",
|
|
2041
2083
|
"*"
|
|
2042
2084
|
] }) : null
|
|
@@ -2050,7 +2092,7 @@ function Field({ label, hint, error, required, disabled, id, children, className
|
|
|
2050
2092
|
// src/ui/components/Input.tsx
|
|
2051
2093
|
import { cva as cva3 } from "class-variance-authority";
|
|
2052
2094
|
import * as React6 from "react";
|
|
2053
|
-
import { jsx as jsx14, jsxs as
|
|
2095
|
+
import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2054
2096
|
var controlShellBase = cn(
|
|
2055
2097
|
"relative inline-flex items-center gap-2",
|
|
2056
2098
|
"rounded-[var(--radius-input)]",
|
|
@@ -2123,7 +2165,7 @@ var Input = React6.forwardRef(
|
|
|
2123
2165
|
const isDisabled = Boolean(disabled);
|
|
2124
2166
|
const showLeftSlot = Boolean(leftSlot || reserveLeftSlot);
|
|
2125
2167
|
const showRightSlot = Boolean(rightSlot || reserveRightSlot);
|
|
2126
|
-
return /* @__PURE__ */
|
|
2168
|
+
return /* @__PURE__ */ jsxs8(
|
|
2127
2169
|
"div",
|
|
2128
2170
|
{
|
|
2129
2171
|
className: cn(controlShellVariants({ variant, size, fullWidth }), className),
|
|
@@ -2374,7 +2416,7 @@ Textarea.displayName = "Textarea";
|
|
|
2374
2416
|
|
|
2375
2417
|
// src/ui/components/Tooltip.tsx
|
|
2376
2418
|
import { Tooltip as TooltipPrimitive } from "radix-ui";
|
|
2377
|
-
import { jsx as jsx17, jsxs as
|
|
2419
|
+
import { jsx as jsx17, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2378
2420
|
var tooltipContentBase = cn(
|
|
2379
2421
|
"panel shadow-none px-4 py-2.5 text-xs z-5000 select-none",
|
|
2380
2422
|
"origin-center will-change-[transform,opacity]",
|
|
@@ -2396,9 +2438,9 @@ function Tooltip({
|
|
|
2396
2438
|
maxWidthPx = 240,
|
|
2397
2439
|
preserveWhitespace = false
|
|
2398
2440
|
}) {
|
|
2399
|
-
return /* @__PURE__ */ jsx17(TooltipPrimitive.Provider, { delayDuration: delayMs, children: /* @__PURE__ */
|
|
2441
|
+
return /* @__PURE__ */ jsx17(TooltipPrimitive.Provider, { delayDuration: delayMs, children: /* @__PURE__ */ jsxs9(TooltipPrimitive.Root, { children: [
|
|
2400
2442
|
/* @__PURE__ */ jsx17(TooltipPrimitive.Trigger, { asChild: true, children }),
|
|
2401
|
-
/* @__PURE__ */ jsx17(TooltipPrimitive.Portal, { children: /* @__PURE__ */
|
|
2443
|
+
/* @__PURE__ */ jsx17(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsxs9(
|
|
2402
2444
|
TooltipPrimitive.Content,
|
|
2403
2445
|
{
|
|
2404
2446
|
side,
|