@playfast/reform-better-hub-ui-primitives 0.0.3 → 0.0.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.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playfast/reform-better-hub-ui-primitives",
|
|
3
3
|
"playbook": "./playbook",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "React UI primitives adapted from better-hub by Better Auth (https://github.com/better-auth/better-hub). Full credit to the Better Auth team.",
|
|
7
7
|
"keywords": [
|
|
@@ -28,7 +28,10 @@ function PopoverContent({
|
|
|
28
28
|
align={align}
|
|
29
29
|
sideOffset={sideOffset}
|
|
30
30
|
className={cn(
|
|
31
|
-
|
|
31
|
+
// NOTE: `--popover` is not defined in this design system (only --background/--card/…),
|
|
32
|
+
// so `bg-popover` rendered transparent. Use the defined `bg-background`/`text-foreground`
|
|
33
|
+
// (exactly what DropdownMenuContent uses) so a portaled popover is opaque.
|
|
34
|
+
"z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border bg-background p-4 text-foreground shadow-md outline-hidden data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
|
32
35
|
className,
|
|
33
36
|
)}
|
|
34
37
|
{...props}
|
|
@@ -7,14 +7,18 @@ import type { MouseEvent as ReactMouseEvent } from "react";
|
|
|
7
7
|
import { cn } from "../foundation/cn";
|
|
8
8
|
|
|
9
9
|
interface ResizeHandleProps {
|
|
10
|
-
/** Called continuously during drag with
|
|
11
|
-
|
|
10
|
+
/** Called continuously during drag with the pointer position on the resize axis
|
|
11
|
+
* (clientX for `axis: "x"`, clientY for `axis: "y"`). */
|
|
12
|
+
onResize: (clientPos: number) => void;
|
|
12
13
|
/** Called when drag starts */
|
|
13
14
|
onDragStart?: () => void;
|
|
14
15
|
/** Called when drag ends */
|
|
15
16
|
onDragEnd?: () => void;
|
|
16
17
|
/** Double click handler (e.g. reset to default) */
|
|
17
18
|
onDoubleClick?: () => void;
|
|
19
|
+
/** Resize axis: "x" (vertical handle, horizontal drag — default) or "y" (horizontal
|
|
20
|
+
* handle, vertical drag — for a top/bottom panel edge). */
|
|
21
|
+
axis?: "x" | "y";
|
|
18
22
|
className?: string;
|
|
19
23
|
}
|
|
20
24
|
|
|
@@ -23,9 +27,11 @@ export function ResizeHandle({
|
|
|
23
27
|
onDragStart,
|
|
24
28
|
onDragEnd,
|
|
25
29
|
onDoubleClick,
|
|
30
|
+
axis = "x",
|
|
26
31
|
className,
|
|
27
32
|
}: ResizeHandleProps): React.JSX.Element {
|
|
28
33
|
const [isDragging, setIsDragging] = useState(false);
|
|
34
|
+
const vertical = axis === "y";
|
|
29
35
|
|
|
30
36
|
const handleMouseDown = useCallback(
|
|
31
37
|
(e: ReactMouseEvent) => {
|
|
@@ -40,7 +46,7 @@ export function ResizeHandle({
|
|
|
40
46
|
if (!isDragging) return;
|
|
41
47
|
|
|
42
48
|
const handleMouseMove = (e: MouseEvent) => {
|
|
43
|
-
onResize(e.clientX);
|
|
49
|
+
onResize(vertical ? e.clientY : e.clientX);
|
|
44
50
|
};
|
|
45
51
|
|
|
46
52
|
const handleMouseUp = () => {
|
|
@@ -51,7 +57,7 @@ export function ResizeHandle({
|
|
|
51
57
|
document.addEventListener("mousemove", handleMouseMove);
|
|
52
58
|
document.addEventListener("mouseup", handleMouseUp);
|
|
53
59
|
document.body.style.userSelect = "none";
|
|
54
|
-
document.body.style.cursor = "col-resize";
|
|
60
|
+
document.body.style.cursor = vertical ? "row-resize" : "col-resize";
|
|
55
61
|
|
|
56
62
|
return () => {
|
|
57
63
|
document.removeEventListener("mousemove", handleMouseMove);
|
|
@@ -59,23 +65,30 @@ export function ResizeHandle({
|
|
|
59
65
|
document.body.style.userSelect = "";
|
|
60
66
|
document.body.style.cursor = "";
|
|
61
67
|
};
|
|
62
|
-
}, [isDragging, onResize, onDragEnd]);
|
|
68
|
+
}, [isDragging, onResize, onDragEnd, vertical]);
|
|
63
69
|
|
|
64
70
|
return (
|
|
65
71
|
<div
|
|
66
72
|
onMouseDown={handleMouseDown}
|
|
67
73
|
onDoubleClick={onDoubleClick}
|
|
68
74
|
className={cn(
|
|
69
|
-
"relative shrink-0
|
|
75
|
+
"relative shrink-0 group/resize z-10",
|
|
76
|
+
vertical ? "h-0 cursor-row-resize" : "w-0 cursor-col-resize",
|
|
70
77
|
className,
|
|
71
78
|
)}
|
|
72
79
|
>
|
|
73
80
|
{/* Wider invisible hit area */}
|
|
74
|
-
<div
|
|
81
|
+
<div
|
|
82
|
+
className={cn(
|
|
83
|
+
"absolute",
|
|
84
|
+
vertical ? "inset-x-0 -top-[5px] h-[11px]" : "inset-y-0 -left-[5px] w-[11px]",
|
|
85
|
+
)}
|
|
86
|
+
/>
|
|
75
87
|
{/* Visible line */}
|
|
76
88
|
<div
|
|
77
89
|
className={cn(
|
|
78
|
-
"absolute
|
|
90
|
+
"absolute transition-all duration-150",
|
|
91
|
+
vertical ? "inset-x-0 -top-px h-[2px]" : "inset-y-0 -left-px w-[2px]",
|
|
79
92
|
isDragging
|
|
80
93
|
? "bg-foreground/25"
|
|
81
94
|
: "bg-transparent group-hover/resize:bg-foreground/15",
|