@open-lakehouse/ui-kit 0.0.0-stage → 0.0.2
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/CHANGELOG.md +14 -0
- package/DESIGN.md +105 -0
- package/README.md +48 -2
- package/dist/ThemeProvider.d.ts +11 -0
- package/dist/ThemeProvider.d.ts.map +1 -0
- package/dist/ThemeProvider.js +40 -0
- package/dist/ThemeProvider.js.map +1 -0
- package/dist/badge.d.ts +10 -0
- package/dist/badge.d.ts.map +1 -0
- package/dist/badge.js +22 -0
- package/dist/badge.js.map +1 -0
- package/dist/button.d.ts +12 -0
- package/dist/button.d.ts.map +1 -0
- package/dist/button.js +34 -0
- package/dist/button.js.map +1 -0
- package/dist/card.d.ts +9 -0
- package/dist/card.d.ts.map +1 -0
- package/dist/card.js +20 -0
- package/dist/card.js.map +1 -0
- package/dist/commit-history.d.ts +76 -0
- package/dist/commit-history.d.ts.map +1 -0
- package/dist/commit-history.js +121 -0
- package/dist/commit-history.js.map +1 -0
- package/dist/dialog.d.ts +22 -0
- package/dist/dialog.d.ts.map +1 -0
- package/dist/dialog.js +27 -0
- package/dist/dialog.js.map +1 -0
- package/dist/dropdown-menu.d.ts +16 -0
- package/dist/dropdown-menu.d.ts.map +1 -0
- package/dist/dropdown-menu.js +23 -0
- package/dist/dropdown-menu.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/input.d.ts +4 -0
- package/dist/input.d.ts.map +1 -0
- package/dist/input.js +11 -0
- package/dist/input.js.map +1 -0
- package/dist/label.d.ts +5 -0
- package/dist/label.d.ts.map +1 -0
- package/dist/label.js +8 -0
- package/dist/label.js.map +1 -0
- package/dist/resizable.d.ts +29 -0
- package/dist/resizable.d.ts.map +1 -0
- package/dist/resizable.js +54 -0
- package/dist/resizable.js.map +1 -0
- package/dist/select.d.ts +10 -0
- package/dist/select.d.ts.map +1 -0
- package/dist/select.js +23 -0
- package/dist/select.js.map +1 -0
- package/dist/separator.d.ts +6 -0
- package/dist/separator.d.ts.map +1 -0
- package/dist/separator.js +7 -0
- package/dist/separator.js.map +1 -0
- package/dist/sheet.d.ts +23 -0
- package/dist/sheet.d.ts.map +1 -0
- package/dist/sheet.js +37 -0
- package/dist/sheet.js.map +1 -0
- package/dist/sonner.d.ts +3 -0
- package/dist/sonner.d.ts.map +1 -0
- package/dist/sonner.js +15 -0
- package/dist/sonner.js.map +1 -0
- package/dist/switch.d.ts +8 -0
- package/dist/switch.d.ts.map +1 -0
- package/dist/switch.js +9 -0
- package/dist/switch.js.map +1 -0
- package/dist/tabs.d.ts +8 -0
- package/dist/tabs.d.ts.map +1 -0
- package/dist/tabs.js +13 -0
- package/dist/tabs.js.map +1 -0
- package/dist/textarea.d.ts +4 -0
- package/dist/textarea.d.ts.map +1 -0
- package/dist/textarea.js +11 -0
- package/dist/textarea.js.map +1 -0
- package/dist/tooltip.d.ts +8 -0
- package/dist/tooltip.d.ts.map +1 -0
- package/dist/tooltip.js +11 -0
- package/dist/tooltip.js.map +1 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +6 -0
- package/dist/utils.js.map +1 -0
- package/package.json +54 -4
- package/src/ThemeProvider.tsx +57 -0
- package/src/badge.tsx +34 -0
- package/src/button.tsx +56 -0
- package/src/card.tsx +87 -0
- package/src/commit-history.tsx +339 -0
- package/src/dialog.tsx +119 -0
- package/src/dropdown-menu.tsx +99 -0
- package/src/index.ts +87 -0
- package/src/input.tsx +27 -0
- package/src/label.tsx +21 -0
- package/src/resizable.tsx +95 -0
- package/src/select.tsx +127 -0
- package/src/separator.tsx +25 -0
- package/src/sheet.tsx +131 -0
- package/src/sonner.tsx +26 -0
- package/src/switch.tsx +47 -0
- package/src/tabs.tsx +53 -0
- package/src/textarea.tsx +25 -0
- package/src/tooltip.tsx +28 -0
- package/src/utils.ts +6 -0
package/src/dialog.tsx
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { X } from "lucide-react";
|
|
2
|
+
import { Dialog as DialogPrimitive } from "radix-ui";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "./utils.js";
|
|
6
|
+
|
|
7
|
+
const Dialog = DialogPrimitive.Root;
|
|
8
|
+
const DialogTrigger = DialogPrimitive.Trigger;
|
|
9
|
+
const DialogPortal = DialogPrimitive.Portal;
|
|
10
|
+
const DialogClose = DialogPrimitive.Close;
|
|
11
|
+
|
|
12
|
+
const DialogOverlay = React.forwardRef<
|
|
13
|
+
React.ComponentRef<typeof DialogPrimitive.Overlay>,
|
|
14
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
15
|
+
>(({ className, ...props }, ref) => (
|
|
16
|
+
<DialogPrimitive.Overlay
|
|
17
|
+
ref={ref}
|
|
18
|
+
className={cn(
|
|
19
|
+
"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
20
|
+
className,
|
|
21
|
+
)}
|
|
22
|
+
{...props}
|
|
23
|
+
/>
|
|
24
|
+
));
|
|
25
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
26
|
+
|
|
27
|
+
const DialogContent = React.forwardRef<
|
|
28
|
+
React.ComponentRef<typeof DialogPrimitive.Content>,
|
|
29
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {
|
|
30
|
+
showClose?: boolean;
|
|
31
|
+
}
|
|
32
|
+
>(({ className, children, showClose = true, ...props }, ref) => (
|
|
33
|
+
<DialogPortal>
|
|
34
|
+
<DialogOverlay />
|
|
35
|
+
<DialogPrimitive.Content
|
|
36
|
+
ref={ref}
|
|
37
|
+
className={cn(
|
|
38
|
+
"fixed left-1/2 top-1/2 z-50 grid w-full max-w-md -translate-x-1/2 -translate-y-1/2 gap-4 border bg-card p-0 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:rounded-lg",
|
|
39
|
+
className,
|
|
40
|
+
)}
|
|
41
|
+
{...props}
|
|
42
|
+
>
|
|
43
|
+
{children}
|
|
44
|
+
{showClose && (
|
|
45
|
+
<DialogPrimitive.Close className="absolute right-3 top-3 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none">
|
|
46
|
+
<X className="h-4 w-4" />
|
|
47
|
+
<span className="sr-only">Close</span>
|
|
48
|
+
</DialogPrimitive.Close>
|
|
49
|
+
)}
|
|
50
|
+
</DialogPrimitive.Content>
|
|
51
|
+
</DialogPortal>
|
|
52
|
+
));
|
|
53
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
54
|
+
|
|
55
|
+
function DialogHeader({
|
|
56
|
+
className,
|
|
57
|
+
...props
|
|
58
|
+
}: React.HTMLAttributes<HTMLDivElement>) {
|
|
59
|
+
return (
|
|
60
|
+
<div
|
|
61
|
+
className={cn(
|
|
62
|
+
"flex flex-col space-y-1.5 border-b px-5 py-3 text-left",
|
|
63
|
+
className,
|
|
64
|
+
)}
|
|
65
|
+
{...props}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
DialogHeader.displayName = "DialogHeader";
|
|
70
|
+
|
|
71
|
+
function DialogFooter({
|
|
72
|
+
className,
|
|
73
|
+
...props
|
|
74
|
+
}: React.HTMLAttributes<HTMLDivElement>) {
|
|
75
|
+
return (
|
|
76
|
+
<div
|
|
77
|
+
className={cn("flex justify-end gap-2 border-t px-5 py-3", className)}
|
|
78
|
+
{...props}
|
|
79
|
+
/>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
DialogFooter.displayName = "DialogFooter";
|
|
83
|
+
|
|
84
|
+
const DialogTitle = React.forwardRef<
|
|
85
|
+
React.ComponentRef<typeof DialogPrimitive.Title>,
|
|
86
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
87
|
+
>(({ className, ...props }, ref) => (
|
|
88
|
+
<DialogPrimitive.Title
|
|
89
|
+
ref={ref}
|
|
90
|
+
className={cn("text-sm font-semibold leading-none", className)}
|
|
91
|
+
{...props}
|
|
92
|
+
/>
|
|
93
|
+
));
|
|
94
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
95
|
+
|
|
96
|
+
const DialogDescription = React.forwardRef<
|
|
97
|
+
React.ComponentRef<typeof DialogPrimitive.Description>,
|
|
98
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
99
|
+
>(({ className, ...props }, ref) => (
|
|
100
|
+
<DialogPrimitive.Description
|
|
101
|
+
ref={ref}
|
|
102
|
+
className={cn("text-xs text-muted-foreground", className)}
|
|
103
|
+
{...props}
|
|
104
|
+
/>
|
|
105
|
+
));
|
|
106
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
107
|
+
|
|
108
|
+
export {
|
|
109
|
+
Dialog,
|
|
110
|
+
DialogClose,
|
|
111
|
+
DialogContent,
|
|
112
|
+
DialogDescription,
|
|
113
|
+
DialogFooter,
|
|
114
|
+
DialogHeader,
|
|
115
|
+
DialogOverlay,
|
|
116
|
+
DialogPortal,
|
|
117
|
+
DialogTitle,
|
|
118
|
+
DialogTrigger,
|
|
119
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "./utils.js";
|
|
5
|
+
|
|
6
|
+
const DropdownMenu = DropdownMenuPrimitive.Root;
|
|
7
|
+
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
8
|
+
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
9
|
+
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
|
10
|
+
|
|
11
|
+
const DropdownMenuContent = React.forwardRef<
|
|
12
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.Content>,
|
|
13
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
|
|
14
|
+
>(({ className, sideOffset = 4, ...props }, ref) => (
|
|
15
|
+
<DropdownMenuPrimitive.Portal>
|
|
16
|
+
<DropdownMenuPrimitive.Content
|
|
17
|
+
ref={ref}
|
|
18
|
+
sideOffset={sideOffset}
|
|
19
|
+
className={cn(
|
|
20
|
+
"z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",
|
|
21
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
22
|
+
className,
|
|
23
|
+
)}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
</DropdownMenuPrimitive.Portal>
|
|
27
|
+
));
|
|
28
|
+
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
29
|
+
|
|
30
|
+
const DropdownMenuItem = React.forwardRef<
|
|
31
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.Item>,
|
|
32
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
|
33
|
+
variant?: "default" | "destructive";
|
|
34
|
+
}
|
|
35
|
+
>(({ className, variant = "default", ...props }, ref) => (
|
|
36
|
+
<DropdownMenuPrimitive.Item
|
|
37
|
+
ref={ref}
|
|
38
|
+
className={cn(
|
|
39
|
+
"relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0",
|
|
40
|
+
variant === "destructive" &&
|
|
41
|
+
"text-destructive focus:bg-destructive/10 focus:text-destructive",
|
|
42
|
+
className,
|
|
43
|
+
)}
|
|
44
|
+
{...props}
|
|
45
|
+
/>
|
|
46
|
+
));
|
|
47
|
+
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
|
48
|
+
|
|
49
|
+
const DropdownMenuLabel = React.forwardRef<
|
|
50
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.Label>,
|
|
51
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label>
|
|
52
|
+
>(({ className, ...props }, ref) => (
|
|
53
|
+
<DropdownMenuPrimitive.Label
|
|
54
|
+
ref={ref}
|
|
55
|
+
className={cn(
|
|
56
|
+
"px-2 py-1 text-[11px] font-medium uppercase tracking-wider text-muted-foreground",
|
|
57
|
+
className,
|
|
58
|
+
)}
|
|
59
|
+
{...props}
|
|
60
|
+
/>
|
|
61
|
+
));
|
|
62
|
+
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
|
63
|
+
|
|
64
|
+
const DropdownMenuSeparator = React.forwardRef<
|
|
65
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.Separator>,
|
|
66
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
|
|
67
|
+
>(({ className, ...props }, ref) => (
|
|
68
|
+
<DropdownMenuPrimitive.Separator
|
|
69
|
+
ref={ref}
|
|
70
|
+
className={cn("-mx-1 my-1 h-px bg-border", className)}
|
|
71
|
+
{...props}
|
|
72
|
+
/>
|
|
73
|
+
));
|
|
74
|
+
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
|
75
|
+
|
|
76
|
+
/** A hint at an item's end, e.g. a file extension. */
|
|
77
|
+
function DropdownMenuShortcut({
|
|
78
|
+
className,
|
|
79
|
+
...props
|
|
80
|
+
}: React.HTMLAttributes<HTMLSpanElement>) {
|
|
81
|
+
return (
|
|
82
|
+
<span
|
|
83
|
+
className={cn("ml-auto text-xs text-muted-foreground", className)}
|
|
84
|
+
{...props}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
DropdownMenu,
|
|
91
|
+
DropdownMenuContent,
|
|
92
|
+
DropdownMenuGroup,
|
|
93
|
+
DropdownMenuItem,
|
|
94
|
+
DropdownMenuLabel,
|
|
95
|
+
DropdownMenuPortal,
|
|
96
|
+
DropdownMenuSeparator,
|
|
97
|
+
DropdownMenuShortcut,
|
|
98
|
+
DropdownMenuTrigger,
|
|
99
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Public surface of the shared UI kit: the shadcn/Radix primitives, the `cn`
|
|
2
|
+
// class-merge helper, and the theme context. Every Open Lakehouse web UI
|
|
3
|
+
// (trestle's env-editor, mangrove's Unity Catalog UI, headwaters' lineage UI)
|
|
4
|
+
// depends on this package rather than carrying its own copy of the primitives.
|
|
5
|
+
// The token contract lives in ./DESIGN.md.
|
|
6
|
+
|
|
7
|
+
export { Badge, type BadgeProps, badgeVariants } from "./badge.js";
|
|
8
|
+
export { Button, type ButtonProps, buttonVariants } from "./button.js";
|
|
9
|
+
export {
|
|
10
|
+
Card,
|
|
11
|
+
CardContent,
|
|
12
|
+
CardDescription,
|
|
13
|
+
CardFooter,
|
|
14
|
+
CardHeader,
|
|
15
|
+
CardTitle,
|
|
16
|
+
} from "./card.js";
|
|
17
|
+
export {
|
|
18
|
+
type CommitAuthor,
|
|
19
|
+
type CommitDayGroup,
|
|
20
|
+
CommitHistory,
|
|
21
|
+
type CommitHistoryEntry,
|
|
22
|
+
type CommitHistoryProps,
|
|
23
|
+
formatRelativeTime,
|
|
24
|
+
groupByDay,
|
|
25
|
+
} from "./commit-history.js";
|
|
26
|
+
export {
|
|
27
|
+
Dialog,
|
|
28
|
+
DialogClose,
|
|
29
|
+
DialogContent,
|
|
30
|
+
DialogDescription,
|
|
31
|
+
DialogFooter,
|
|
32
|
+
DialogHeader,
|
|
33
|
+
DialogOverlay,
|
|
34
|
+
DialogPortal,
|
|
35
|
+
DialogTitle,
|
|
36
|
+
DialogTrigger,
|
|
37
|
+
} from "./dialog.js";
|
|
38
|
+
export {
|
|
39
|
+
DropdownMenu,
|
|
40
|
+
DropdownMenuContent,
|
|
41
|
+
DropdownMenuGroup,
|
|
42
|
+
DropdownMenuItem,
|
|
43
|
+
DropdownMenuLabel,
|
|
44
|
+
DropdownMenuPortal,
|
|
45
|
+
DropdownMenuSeparator,
|
|
46
|
+
DropdownMenuShortcut,
|
|
47
|
+
DropdownMenuTrigger,
|
|
48
|
+
} from "./dropdown-menu.js";
|
|
49
|
+
export { Input } from "./input.js";
|
|
50
|
+
export { Label } from "./label.js";
|
|
51
|
+
export {
|
|
52
|
+
ResizeHandle,
|
|
53
|
+
type ResizeHandleProps,
|
|
54
|
+
usePaneSize,
|
|
55
|
+
} from "./resizable.js";
|
|
56
|
+
export {
|
|
57
|
+
Select,
|
|
58
|
+
SelectContent,
|
|
59
|
+
SelectGroup,
|
|
60
|
+
SelectItem,
|
|
61
|
+
SelectTrigger,
|
|
62
|
+
SelectValue,
|
|
63
|
+
} from "./select.js";
|
|
64
|
+
export { Separator } from "./separator.js";
|
|
65
|
+
export {
|
|
66
|
+
Sheet,
|
|
67
|
+
SheetClose,
|
|
68
|
+
SheetContent,
|
|
69
|
+
SheetDescription,
|
|
70
|
+
SheetHeader,
|
|
71
|
+
SheetOverlay,
|
|
72
|
+
SheetPortal,
|
|
73
|
+
SheetTitle,
|
|
74
|
+
SheetTrigger,
|
|
75
|
+
} from "./sheet.js";
|
|
76
|
+
export { Toaster } from "./sonner.js";
|
|
77
|
+
export { Switch, type SwitchProps } from "./switch.js";
|
|
78
|
+
export { ThemeProvider, useTheme } from "./ThemeProvider.js";
|
|
79
|
+
export { Tabs, TabsContent, TabsList, TabsTrigger } from "./tabs.js";
|
|
80
|
+
export { Textarea } from "./textarea.js";
|
|
81
|
+
export {
|
|
82
|
+
Tooltip,
|
|
83
|
+
TooltipContent,
|
|
84
|
+
TooltipProvider,
|
|
85
|
+
TooltipTrigger,
|
|
86
|
+
} from "./tooltip.js";
|
|
87
|
+
export { cn } from "./utils.js";
|
package/src/input.tsx
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "./utils.js";
|
|
4
|
+
|
|
5
|
+
const Input = React.forwardRef<
|
|
6
|
+
HTMLInputElement,
|
|
7
|
+
React.InputHTMLAttributes<HTMLInputElement>
|
|
8
|
+
>(({ className, type, ...props }, ref) => (
|
|
9
|
+
<input
|
|
10
|
+
type={type}
|
|
11
|
+
ref={ref}
|
|
12
|
+
// Identifier/data fields: suppress the browser's text-correction so it
|
|
13
|
+
// doesn't capitalize or "fix" what the user typed. Listed before {...props}
|
|
14
|
+
// so a specific field can opt back in (e.g. a free-text comment).
|
|
15
|
+
autoCapitalize="off"
|
|
16
|
+
autoCorrect="off"
|
|
17
|
+
spellCheck={false}
|
|
18
|
+
className={cn(
|
|
19
|
+
"flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",
|
|
20
|
+
className,
|
|
21
|
+
)}
|
|
22
|
+
{...props}
|
|
23
|
+
/>
|
|
24
|
+
));
|
|
25
|
+
Input.displayName = "Input";
|
|
26
|
+
|
|
27
|
+
export { Input };
|
package/src/label.tsx
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Label as LabelPrimitive } from "radix-ui";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "./utils.js";
|
|
5
|
+
|
|
6
|
+
const Label = React.forwardRef<
|
|
7
|
+
React.ComponentRef<typeof LabelPrimitive.Root>,
|
|
8
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
|
|
9
|
+
>(({ className, ...props }, ref) => (
|
|
10
|
+
<LabelPrimitive.Root
|
|
11
|
+
ref={ref}
|
|
12
|
+
className={cn(
|
|
13
|
+
"text-xs font-medium text-muted-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
14
|
+
className,
|
|
15
|
+
)}
|
|
16
|
+
{...props}
|
|
17
|
+
/>
|
|
18
|
+
));
|
|
19
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
20
|
+
|
|
21
|
+
export { Label };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "./utils.js";
|
|
4
|
+
|
|
5
|
+
export interface ResizeHandleProps
|
|
6
|
+
extends Omit<React.HTMLAttributes<HTMLDivElement>, "onResize"> {
|
|
7
|
+
/** `vertical` sits between side-by-side panes (drag left/right);
|
|
8
|
+
* `horizontal` between stacked ones (drag up/down). */
|
|
9
|
+
orientation: "vertical" | "horizontal";
|
|
10
|
+
/** Called with how far the pointer moved since the last call, in pixels:
|
|
11
|
+
* positive is right / down. */
|
|
12
|
+
onResize: (delta: number) => void;
|
|
13
|
+
/** The size of the pane it resizes, in pixels (its `aria-valuenow`). */
|
|
14
|
+
size: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A draggable divider between two panes. It reports pointer movement; the
|
|
19
|
+
* owner keeps the pane's size (see {@link usePaneSize}). Arrow keys nudge it
|
|
20
|
+
* when focused.
|
|
21
|
+
*/
|
|
22
|
+
function ResizeHandle({
|
|
23
|
+
orientation,
|
|
24
|
+
onResize,
|
|
25
|
+
size,
|
|
26
|
+
className,
|
|
27
|
+
...props
|
|
28
|
+
}: ResizeHandleProps) {
|
|
29
|
+
const last = React.useRef<number | null>(null);
|
|
30
|
+
const vertical = orientation === "vertical";
|
|
31
|
+
return (
|
|
32
|
+
// biome-ignore lint/a11y/useSemanticElements: a draggable splitter, not a rule
|
|
33
|
+
<div
|
|
34
|
+
role="separator"
|
|
35
|
+
aria-orientation={vertical ? "vertical" : "horizontal"}
|
|
36
|
+
aria-valuenow={size}
|
|
37
|
+
tabIndex={0}
|
|
38
|
+
className={cn(
|
|
39
|
+
"relative shrink-0 bg-border transition-colors hover:bg-primary/60 focus-visible:bg-primary focus-visible:outline-none",
|
|
40
|
+
vertical ? "w-px cursor-col-resize" : "h-px cursor-row-resize",
|
|
41
|
+
// A wider invisible grab area around the 1px line.
|
|
42
|
+
vertical
|
|
43
|
+
? "after:absolute after:inset-y-0 after:-left-1 after:-right-1"
|
|
44
|
+
: "after:absolute after:inset-x-0 after:-top-1 after:-bottom-1",
|
|
45
|
+
className,
|
|
46
|
+
)}
|
|
47
|
+
onPointerDown={(e) => {
|
|
48
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
49
|
+
last.current = vertical ? e.clientX : e.clientY;
|
|
50
|
+
}}
|
|
51
|
+
onPointerMove={(e) => {
|
|
52
|
+
if (last.current === null) return;
|
|
53
|
+
const at = vertical ? e.clientX : e.clientY;
|
|
54
|
+
onResize(at - last.current);
|
|
55
|
+
last.current = at;
|
|
56
|
+
}}
|
|
57
|
+
onPointerUp={(e) => {
|
|
58
|
+
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
59
|
+
last.current = null;
|
|
60
|
+
}}
|
|
61
|
+
onKeyDown={(e) => {
|
|
62
|
+
const step = e.shiftKey ? 48 : 12;
|
|
63
|
+
const back = vertical ? "ArrowLeft" : "ArrowUp";
|
|
64
|
+
const forward = vertical ? "ArrowRight" : "ArrowDown";
|
|
65
|
+
if (e.key === back) onResize(-step);
|
|
66
|
+
else if (e.key === forward) onResize(step);
|
|
67
|
+
else return;
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
}}
|
|
70
|
+
{...props}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A pane size in pixels, clamped to `[min, max]`, with a `resize(delta)` for a
|
|
77
|
+
* {@link ResizeHandle}. `invert` flips the delta, for a pane on the far side of
|
|
78
|
+
* its handle (a right sidebar, a bottom panel).
|
|
79
|
+
*/
|
|
80
|
+
function usePaneSize(
|
|
81
|
+
initial: number,
|
|
82
|
+
{ min, max, invert = false }: { min: number; max: number; invert?: boolean },
|
|
83
|
+
): [number, (delta: number) => void] {
|
|
84
|
+
const [size, setSize] = React.useState(initial);
|
|
85
|
+
const resize = React.useCallback(
|
|
86
|
+
(delta: number) =>
|
|
87
|
+
setSize((s) =>
|
|
88
|
+
Math.min(max, Math.max(min, s + (invert ? -delta : delta))),
|
|
89
|
+
),
|
|
90
|
+
[min, max, invert],
|
|
91
|
+
);
|
|
92
|
+
return [size, resize];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export { ResizeHandle, usePaneSize };
|
package/src/select.tsx
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Check, ChevronDown, ChevronUp } from "lucide-react";
|
|
2
|
+
import { Select as SelectPrimitive } from "radix-ui";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "./utils.js";
|
|
6
|
+
|
|
7
|
+
const Select = SelectPrimitive.Root;
|
|
8
|
+
const SelectGroup = SelectPrimitive.Group;
|
|
9
|
+
const SelectValue = SelectPrimitive.Value;
|
|
10
|
+
|
|
11
|
+
const SelectTrigger = React.forwardRef<
|
|
12
|
+
React.ComponentRef<typeof SelectPrimitive.Trigger>,
|
|
13
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
|
|
14
|
+
>(({ className, children, ...props }, ref) => (
|
|
15
|
+
<SelectPrimitive.Trigger
|
|
16
|
+
ref={ref}
|
|
17
|
+
className={cn(
|
|
18
|
+
"flex h-9 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
|
|
19
|
+
className,
|
|
20
|
+
)}
|
|
21
|
+
{...props}
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
<SelectPrimitive.Icon asChild>
|
|
25
|
+
<ChevronDown className="h-4 w-4 opacity-50" />
|
|
26
|
+
</SelectPrimitive.Icon>
|
|
27
|
+
</SelectPrimitive.Trigger>
|
|
28
|
+
));
|
|
29
|
+
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
30
|
+
|
|
31
|
+
const SelectScrollUpButton = React.forwardRef<
|
|
32
|
+
React.ComponentRef<typeof SelectPrimitive.ScrollUpButton>,
|
|
33
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
|
|
34
|
+
>(({ className, ...props }, ref) => (
|
|
35
|
+
<SelectPrimitive.ScrollUpButton
|
|
36
|
+
ref={ref}
|
|
37
|
+
className={cn(
|
|
38
|
+
"flex cursor-default items-center justify-center py-1",
|
|
39
|
+
className,
|
|
40
|
+
)}
|
|
41
|
+
{...props}
|
|
42
|
+
>
|
|
43
|
+
<ChevronUp className="h-4 w-4" />
|
|
44
|
+
</SelectPrimitive.ScrollUpButton>
|
|
45
|
+
));
|
|
46
|
+
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
47
|
+
|
|
48
|
+
const SelectScrollDownButton = React.forwardRef<
|
|
49
|
+
React.ComponentRef<typeof SelectPrimitive.ScrollDownButton>,
|
|
50
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
|
|
51
|
+
>(({ className, ...props }, ref) => (
|
|
52
|
+
<SelectPrimitive.ScrollDownButton
|
|
53
|
+
ref={ref}
|
|
54
|
+
className={cn(
|
|
55
|
+
"flex cursor-default items-center justify-center py-1",
|
|
56
|
+
className,
|
|
57
|
+
)}
|
|
58
|
+
{...props}
|
|
59
|
+
>
|
|
60
|
+
<ChevronDown className="h-4 w-4" />
|
|
61
|
+
</SelectPrimitive.ScrollDownButton>
|
|
62
|
+
));
|
|
63
|
+
SelectScrollDownButton.displayName =
|
|
64
|
+
SelectPrimitive.ScrollDownButton.displayName;
|
|
65
|
+
|
|
66
|
+
const SelectContent = React.forwardRef<
|
|
67
|
+
React.ComponentRef<typeof SelectPrimitive.Content>,
|
|
68
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
|
|
69
|
+
>(({ className, children, position = "popper", ...props }, ref) => (
|
|
70
|
+
<SelectPrimitive.Portal>
|
|
71
|
+
<SelectPrimitive.Content
|
|
72
|
+
ref={ref}
|
|
73
|
+
className={cn(
|
|
74
|
+
"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
|
|
75
|
+
position === "popper" &&
|
|
76
|
+
"data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1",
|
|
77
|
+
className,
|
|
78
|
+
)}
|
|
79
|
+
position={position}
|
|
80
|
+
{...props}
|
|
81
|
+
>
|
|
82
|
+
<SelectScrollUpButton />
|
|
83
|
+
<SelectPrimitive.Viewport
|
|
84
|
+
className={cn(
|
|
85
|
+
"p-1",
|
|
86
|
+
position === "popper" &&
|
|
87
|
+
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]",
|
|
88
|
+
)}
|
|
89
|
+
>
|
|
90
|
+
{children}
|
|
91
|
+
</SelectPrimitive.Viewport>
|
|
92
|
+
<SelectScrollDownButton />
|
|
93
|
+
</SelectPrimitive.Content>
|
|
94
|
+
</SelectPrimitive.Portal>
|
|
95
|
+
));
|
|
96
|
+
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
97
|
+
|
|
98
|
+
const SelectItem = React.forwardRef<
|
|
99
|
+
React.ComponentRef<typeof SelectPrimitive.Item>,
|
|
100
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
|
|
101
|
+
>(({ className, children, ...props }, ref) => (
|
|
102
|
+
<SelectPrimitive.Item
|
|
103
|
+
ref={ref}
|
|
104
|
+
className={cn(
|
|
105
|
+
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
106
|
+
className,
|
|
107
|
+
)}
|
|
108
|
+
{...props}
|
|
109
|
+
>
|
|
110
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
111
|
+
<SelectPrimitive.ItemIndicator>
|
|
112
|
+
<Check className="h-4 w-4" />
|
|
113
|
+
</SelectPrimitive.ItemIndicator>
|
|
114
|
+
</span>
|
|
115
|
+
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
116
|
+
</SelectPrimitive.Item>
|
|
117
|
+
));
|
|
118
|
+
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
119
|
+
|
|
120
|
+
export {
|
|
121
|
+
Select,
|
|
122
|
+
SelectContent,
|
|
123
|
+
SelectGroup,
|
|
124
|
+
SelectItem,
|
|
125
|
+
SelectTrigger,
|
|
126
|
+
SelectValue,
|
|
127
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "./utils.js";
|
|
4
|
+
|
|
5
|
+
function Separator({
|
|
6
|
+
className,
|
|
7
|
+
orientation = "horizontal",
|
|
8
|
+
...props
|
|
9
|
+
}: React.HTMLAttributes<HTMLDivElement> & {
|
|
10
|
+
orientation?: "horizontal" | "vertical";
|
|
11
|
+
}) {
|
|
12
|
+
return (
|
|
13
|
+
<div
|
|
14
|
+
aria-hidden="true"
|
|
15
|
+
className={cn(
|
|
16
|
+
"shrink-0 bg-border",
|
|
17
|
+
orientation === "horizontal" ? "h-px w-full" : "h-full w-px",
|
|
18
|
+
className,
|
|
19
|
+
)}
|
|
20
|
+
{...props}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { Separator };
|