@hexdspace/react 0.1.16 → 0.1.18
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.d.ts +6 -3
- package/dist/index.js +108 -62
- 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.d.ts
CHANGED
|
@@ -546,9 +546,11 @@ declare class DialogController {
|
|
|
546
546
|
}
|
|
547
547
|
declare const dialogController: DialogController;
|
|
548
548
|
|
|
549
|
-
declare const
|
|
549
|
+
declare const dialogSurfaceVariants: (props?: ({
|
|
550
|
+
chrome?: "flat" | "glass" | "glow" | "hairline" | null | undefined;
|
|
551
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
550
552
|
declare function DialogContent({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
|
|
551
|
-
interface DialogProps<TPayload = unknown> extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>, VariantProps<typeof
|
|
553
|
+
interface DialogProps<TPayload = unknown> extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>, VariantProps<typeof dialogSurfaceVariants> {
|
|
552
554
|
id: string;
|
|
553
555
|
template: DialogTemplate<TPayload>;
|
|
554
556
|
payload: TPayload;
|
|
@@ -565,7 +567,7 @@ interface DialogProps<TPayload = unknown> extends Omit<React.HTMLAttributes<HTML
|
|
|
565
567
|
open?: boolean;
|
|
566
568
|
defaultOpen?: boolean;
|
|
567
569
|
}
|
|
568
|
-
declare function Dialog<TPayload>({ id, template, payload, trigger, modal, dismissible, zIndex, maxWidthPx, onDismiss, onResolve, onOpenChange, showClose, closeLabel, open, defaultOpen, className, style, ...props }: DialogProps<TPayload>): react_jsx_runtime.JSX.Element;
|
|
570
|
+
declare function Dialog<TPayload>({ id, template, payload, trigger, modal, dismissible, zIndex, maxWidthPx, onDismiss, onResolve, onOpenChange, showClose, closeLabel, open, defaultOpen, chrome, className, style, ...props }: DialogProps<TPayload>): react_jsx_runtime.JSX.Element;
|
|
569
571
|
|
|
570
572
|
type ControlLikeProps = {
|
|
571
573
|
id?: string;
|
|
@@ -610,6 +612,7 @@ declare const skeletonVariants: (props?: ({
|
|
|
610
612
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
611
613
|
interface SkeletonProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof skeletonVariants> {
|
|
612
614
|
animate?: boolean;
|
|
615
|
+
asChild?: boolean;
|
|
613
616
|
}
|
|
614
617
|
declare const Skeleton: React.ForwardRefExoticComponent<SkeletonProps & React.RefAttributes<HTMLDivElement>>;
|
|
615
618
|
|
package/dist/index.js
CHANGED
|
@@ -1559,16 +1559,55 @@ 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
|
);
|
|
1565
|
+
var dialogSurfaceVariants = cva2("dialog-surface relative overflow-hidden", {
|
|
1566
|
+
variants: {
|
|
1567
|
+
chrome: {
|
|
1568
|
+
flat: "shell",
|
|
1569
|
+
glass: cn(
|
|
1570
|
+
"border border-[color:color-mix(in_oklab,var(--border),transparent_50%)]",
|
|
1571
|
+
"bg-[color:color-mix(in_oklab,var(--surface-1),transparent_25%)]",
|
|
1572
|
+
"backdrop-blur-[6px]",
|
|
1573
|
+
"rounded-[var(--radius-shell)]",
|
|
1574
|
+
"shadow-[0_18px_40px_rgba(0,0,0,0.18)]"
|
|
1575
|
+
),
|
|
1576
|
+
glow: cn(
|
|
1577
|
+
"rounded-[var(--radius-shell)]",
|
|
1578
|
+
"border border-[color:color-mix(in_oklab,var(--border),transparent_60%)]",
|
|
1579
|
+
"bg-[color:var(--surface-1)]",
|
|
1580
|
+
"shadow-[0_0_0_1px_color-mix(in_oklab,var(--border),transparent_55%),0_16px_36px_color-mix(in_oklab,var(--border),transparent_70%)]"
|
|
1581
|
+
),
|
|
1582
|
+
hairline: cn(
|
|
1583
|
+
"rounded-[var(--radius-shell)]",
|
|
1584
|
+
"border border-[color:color-mix(in_oklab,var(--border),transparent_70%)]",
|
|
1585
|
+
"bg-transparent",
|
|
1586
|
+
"shadow-none"
|
|
1587
|
+
)
|
|
1588
|
+
}
|
|
1589
|
+
},
|
|
1590
|
+
defaultVariants: {
|
|
1591
|
+
chrome: "flat"
|
|
1592
|
+
}
|
|
1593
|
+
});
|
|
1566
1594
|
function DialogContent({ className, ...props }) {
|
|
1567
1595
|
return /* @__PURE__ */ jsx7("div", { className: cn("DialogContent p-6", className), ...props });
|
|
1568
1596
|
}
|
|
1569
|
-
function AutoHeight({
|
|
1597
|
+
function AutoHeight({
|
|
1598
|
+
children,
|
|
1599
|
+
onReady,
|
|
1600
|
+
resetKey
|
|
1601
|
+
}) {
|
|
1570
1602
|
const ref = React2.useRef(null);
|
|
1571
1603
|
const [height, setHeight] = React2.useState("auto");
|
|
1604
|
+
const readyRef = React2.useRef(false);
|
|
1605
|
+
const resetKeyRef = React2.useRef(resetKey);
|
|
1606
|
+
React2.useEffect(() => {
|
|
1607
|
+
if (resetKeyRef.current === resetKey) return;
|
|
1608
|
+
resetKeyRef.current = resetKey;
|
|
1609
|
+
readyRef.current = false;
|
|
1610
|
+
});
|
|
1572
1611
|
React2.useLayoutEffect(() => {
|
|
1573
1612
|
const el = ref.current;
|
|
1574
1613
|
if (!el) return;
|
|
@@ -1584,6 +1623,12 @@ function AutoHeight({ children }) {
|
|
|
1584
1623
|
if (prevNum < 0 || Math.abs(snapped - prevNum) >= 2) return snapped;
|
|
1585
1624
|
return prev;
|
|
1586
1625
|
});
|
|
1626
|
+
if (!readyRef.current) {
|
|
1627
|
+
readyRef.current = true;
|
|
1628
|
+
requestAnimationFrame(() => {
|
|
1629
|
+
onReady?.();
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1587
1632
|
});
|
|
1588
1633
|
});
|
|
1589
1634
|
ro.observe(el);
|
|
@@ -1591,13 +1636,11 @@ function AutoHeight({ children }) {
|
|
|
1591
1636
|
ro.disconnect();
|
|
1592
1637
|
cancelAnimationFrame(raf);
|
|
1593
1638
|
};
|
|
1594
|
-
}, []);
|
|
1639
|
+
}, [onReady]);
|
|
1595
1640
|
return /* @__PURE__ */ jsx7(
|
|
1596
1641
|
"div",
|
|
1597
1642
|
{
|
|
1598
|
-
className: cn(
|
|
1599
|
-
"transition-[height] duration-(--motion-med) ease motion-reduce:transition-none"
|
|
1600
|
-
),
|
|
1643
|
+
className: cn("transition-[height] duration-(--motion-med) ease"),
|
|
1601
1644
|
style: {
|
|
1602
1645
|
height: height === "auto" ? "auto" : height,
|
|
1603
1646
|
maxHeight: "calc(100vh - 4rem)",
|
|
@@ -1624,17 +1667,20 @@ function Dialog({
|
|
|
1624
1667
|
closeLabel = "Close dialog",
|
|
1625
1668
|
open: open2,
|
|
1626
1669
|
defaultOpen,
|
|
1670
|
+
chrome,
|
|
1627
1671
|
className,
|
|
1628
1672
|
style,
|
|
1629
1673
|
...props
|
|
1630
1674
|
}) {
|
|
1631
1675
|
const fallbackId = React2.useId();
|
|
1632
1676
|
const resolvedRef = React2.useRef(false);
|
|
1633
|
-
const rafRef = React2.useRef(null);
|
|
1634
1677
|
const isControlled = open2 !== void 0;
|
|
1635
1678
|
const [uncontrolledOpen, setUncontrolledOpen] = React2.useState(defaultOpen ?? false);
|
|
1636
|
-
const
|
|
1637
|
-
const
|
|
1679
|
+
const isOpen = isControlled ? open2 : uncontrolledOpen;
|
|
1680
|
+
const prevOpenRef = React2.useRef(false);
|
|
1681
|
+
const [contentCycle, setContentCycle] = React2.useState(0);
|
|
1682
|
+
const [surfaceReady, setSurfaceReady] = React2.useState(false);
|
|
1683
|
+
const [overlayReady, setOverlayReady] = React2.useState(false);
|
|
1638
1684
|
const Template = template;
|
|
1639
1685
|
const handleOpenChange = (nextOpen) => {
|
|
1640
1686
|
if (!isControlled) setUncontrolledOpen(nextOpen);
|
|
@@ -1657,34 +1703,41 @@ function Dialog({
|
|
|
1657
1703
|
[onResolve]
|
|
1658
1704
|
);
|
|
1659
1705
|
React2.useEffect(() => {
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1706
|
+
const wasOpen = prevOpenRef.current;
|
|
1707
|
+
prevOpenRef.current = Boolean(isOpen);
|
|
1708
|
+
if (isOpen && !wasOpen) {
|
|
1709
|
+
setContentCycle((value) => value + 1);
|
|
1710
|
+
setSurfaceReady(false);
|
|
1711
|
+
setOverlayReady(false);
|
|
1666
1712
|
return;
|
|
1667
1713
|
}
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1714
|
+
if (!isOpen && wasOpen) {
|
|
1715
|
+
setSurfaceReady(false);
|
|
1716
|
+
setOverlayReady(false);
|
|
1717
|
+
}
|
|
1718
|
+
}, [isOpen]);
|
|
1719
|
+
const handleAutoHeightReady = React2.useCallback(() => {
|
|
1720
|
+
if (!isOpen) return;
|
|
1721
|
+
requestAnimationFrame(() => {
|
|
1722
|
+
setSurfaceReady(true);
|
|
1723
|
+
setOverlayReady(true);
|
|
1673
1724
|
});
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1725
|
+
}, [isOpen]);
|
|
1726
|
+
const overlayClassName = cn(
|
|
1727
|
+
"DialogOverlay",
|
|
1728
|
+
dialogOverlayClass,
|
|
1729
|
+
isOpen && !overlayReady ? "opacity-0" : null,
|
|
1730
|
+
overlayReady ? "animate-[dialog-overlay-in_var(--motion-med)_cubic-bezier(0.2,0,0.2,1)] [animation-fill-mode:both]" : null
|
|
1731
|
+
);
|
|
1732
|
+
const surfaceClassName = cn(
|
|
1733
|
+
dialogSurfaceVariants({ chrome }),
|
|
1734
|
+
isOpen && !surfaceReady ? "opacity-0 translate-y-5" : null,
|
|
1735
|
+
surfaceReady ? "animate-[dialog-surface-in_var(--motion-med)_cubic-bezier(0.16,1,0.3,1)] [animation-fill-mode:both]" : null
|
|
1736
|
+
);
|
|
1678
1737
|
return /* @__PURE__ */ jsxs3(DialogPrimitive.Root, { open: open2, defaultOpen, onOpenChange: handleOpenChange, modal, children: [
|
|
1679
1738
|
trigger ? /* @__PURE__ */ jsx7(DialogPrimitive.Trigger, { asChild: true, children: trigger }) : null,
|
|
1680
1739
|
/* @__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,
|
|
1740
|
+
modal ? /* @__PURE__ */ jsx7(DialogPrimitive.Overlay, { className: overlayClassName, style: { zIndex: zIndex - 1 } }) : null,
|
|
1688
1741
|
/* @__PURE__ */ jsx7(
|
|
1689
1742
|
DialogPrimitive.Content,
|
|
1690
1743
|
{
|
|
@@ -1706,29 +1759,19 @@ function Dialog({
|
|
|
1706
1759
|
if (!dismissible) event.preventDefault();
|
|
1707
1760
|
},
|
|
1708
1761
|
...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
|
-
)
|
|
1762
|
+
children: /* @__PURE__ */ jsxs3("div", { className: surfaceClassName, style: { willChange: "transform" }, children: [
|
|
1763
|
+
showClose ? /* @__PURE__ */ jsx7(DialogPrimitive.Close, { asChild: true, children: /* @__PURE__ */ jsx7(
|
|
1764
|
+
Button,
|
|
1765
|
+
{
|
|
1766
|
+
variant: "ghost",
|
|
1767
|
+
size: "icon",
|
|
1768
|
+
leftIcon: /* @__PURE__ */ jsx7(XIcon, { className: "w-5 h-5" }),
|
|
1769
|
+
className: "absolute right-2 top-2 z-10 rounded-full",
|
|
1770
|
+
"aria-label": closeLabel
|
|
1771
|
+
}
|
|
1772
|
+
) }) : null,
|
|
1773
|
+
/* @__PURE__ */ jsx7(AutoHeight, { onReady: handleAutoHeightReady, resetKey: contentCycle, children: /* @__PURE__ */ jsx7(Template, { id: id ?? fallbackId, payload, onResolve: handleResolve }) })
|
|
1774
|
+
] })
|
|
1732
1775
|
}
|
|
1733
1776
|
)
|
|
1734
1777
|
] })
|
|
@@ -1739,7 +1782,7 @@ function Dialog({
|
|
|
1739
1782
|
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1740
1783
|
var ConfirmDialog = (props) => {
|
|
1741
1784
|
const p = props.payload ?? { title: "Are you sure?" };
|
|
1742
|
-
const confirmVariant = p.variant ?? (p.danger ? "danger" : "
|
|
1785
|
+
const confirmVariant = p.variant ?? (p.danger ? "danger" : "success");
|
|
1743
1786
|
return /* @__PURE__ */ jsxs4(DialogContent, { children: [
|
|
1744
1787
|
/* @__PURE__ */ jsx8(DialogPrimitive2.Title, { className: "text-lg font-semibold", children: p.title }),
|
|
1745
1788
|
p.children && p.children,
|
|
@@ -2207,6 +2250,7 @@ Input.displayName = "Input";
|
|
|
2207
2250
|
|
|
2208
2251
|
// src/ui/components/Skeleton.tsx
|
|
2209
2252
|
import { cva as cva4 } from "class-variance-authority";
|
|
2253
|
+
import { Slot as Slot2 } from "radix-ui";
|
|
2210
2254
|
import * as React7 from "react";
|
|
2211
2255
|
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
2212
2256
|
var skeletonBase = cn(
|
|
@@ -2219,7 +2263,7 @@ var shimmerEffect = cn(
|
|
|
2219
2263
|
"before:content-[''] before:absolute before:inset-0",
|
|
2220
2264
|
"before:bg-[linear-gradient(110deg,transparent_0%,color-mix(in_oklab,var(--skeleton-shimmer),transparent_100%)_25%,color-mix(in_oklab,var(--skeleton-shimmer),transparent_55%)_50%,color-mix(in_oklab,var(--skeleton-shimmer),transparent_100%)_75%,transparent_100%)]",
|
|
2221
2265
|
"before:[background-size:200%_100%]",
|
|
2222
|
-
"before:animate-[skeleton-shimmer_1.6s_linear_infinite]
|
|
2266
|
+
"before:animate-[skeleton-shimmer_1.6s_linear_infinite]"
|
|
2223
2267
|
);
|
|
2224
2268
|
var skeletonVariants = cva4(skeletonBase, {
|
|
2225
2269
|
variants: {
|
|
@@ -2242,7 +2286,7 @@ var skeletonVariants = cva4(skeletonBase, {
|
|
|
2242
2286
|
fullWidth: { true: "w-full", false: "w-auto" },
|
|
2243
2287
|
animation: {
|
|
2244
2288
|
none: "",
|
|
2245
|
-
pulse: "animate-pulse
|
|
2289
|
+
pulse: "animate-pulse",
|
|
2246
2290
|
shimmer: shimmerEffect
|
|
2247
2291
|
},
|
|
2248
2292
|
preset: {
|
|
@@ -2263,10 +2307,11 @@ var skeletonVariants = cva4(skeletonBase, {
|
|
|
2263
2307
|
}
|
|
2264
2308
|
});
|
|
2265
2309
|
var Skeleton = React7.forwardRef(
|
|
2266
|
-
({ variant, size, radius, fullWidth, animation, preset, animate, className, ...props }, ref) => {
|
|
2310
|
+
({ variant, size, radius, fullWidth, animation, preset, animate, asChild, className, children, ...props }, ref) => {
|
|
2267
2311
|
const resolvedAnimation = animation ?? (animate === false ? "none" : animate ? "pulse" : void 0);
|
|
2312
|
+
const Component = asChild ? Slot2.Root : "div";
|
|
2268
2313
|
return /* @__PURE__ */ jsx15(
|
|
2269
|
-
|
|
2314
|
+
Component,
|
|
2270
2315
|
{
|
|
2271
2316
|
ref,
|
|
2272
2317
|
className: cn(
|
|
@@ -2280,7 +2325,9 @@ var Skeleton = React7.forwardRef(
|
|
|
2280
2325
|
}),
|
|
2281
2326
|
className
|
|
2282
2327
|
),
|
|
2283
|
-
|
|
2328
|
+
"aria-hidden": props["aria-hidden"] ?? true,
|
|
2329
|
+
...props,
|
|
2330
|
+
children: asChild ? /* @__PURE__ */ jsx15(Slot2.Slottable, { children }) : children
|
|
2284
2331
|
}
|
|
2285
2332
|
);
|
|
2286
2333
|
}
|
|
@@ -2426,8 +2473,7 @@ var tooltipContentBase = cn(
|
|
|
2426
2473
|
"data-[side=right]:[--tooltip-x:-4px] data-[side=right]:[--tooltip-y:0px]",
|
|
2427
2474
|
"data-[state=delayed-open]:animate-[tooltip-in_140ms_ease-out]",
|
|
2428
2475
|
"data-[state=instant-open]:animate-[tooltip-in_140ms_ease-out]",
|
|
2429
|
-
"data-[state=closed]:animate-[tooltip-out_120ms_ease-in]"
|
|
2430
|
-
"motion-reduce:animate-none"
|
|
2476
|
+
"data-[state=closed]:animate-[tooltip-out_120ms_ease-in]"
|
|
2431
2477
|
);
|
|
2432
2478
|
function Tooltip({
|
|
2433
2479
|
children,
|