@playfast/reform-better-hub-ui-primitives 0.2.1 → 0.3.0

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.
@@ -1,172 +1,165 @@
1
- // Adapted from better-hub by Better Auth — https://github.com/better-auth/better-hub
2
- // (apps/web/src/components/ui/command.tsx). Full credit to the Better Auth team.
1
+ import { Command as CommandPrimitive } from 'cmdk'
2
+ import { SearchIcon } from 'lucide-react'
3
+ import type * as React from 'react'
4
+ import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from './dialog'
5
+ import { cn } from '../foundation/cn'
3
6
 
4
- import { Command as CommandPrimitive } from "cmdk";
5
- import { SearchIcon } from "lucide-react";
6
- import type * as React from "react";
7
- import {
8
- Dialog,
9
- DialogContent,
10
- DialogDescription,
11
- DialogHeader,
12
- DialogTitle,
13
- } from "./dialog";
14
- import { cn } from "../foundation/cn";
15
-
16
- function Command({ className, ...props }: React.ComponentProps<typeof CommandPrimitive>): React.JSX.Element {
17
- return (
18
- <CommandPrimitive
19
- data-slot="command"
20
- className={cn(
21
- "bg-background text-foreground flex h-full w-full flex-col overflow-hidden rounded-md",
22
- className,
23
- )}
24
- {...props}
25
- />
26
- );
7
+ function Command({
8
+ className,
9
+ ...props
10
+ }: React.ComponentProps<typeof CommandPrimitive>): React.JSX.Element {
11
+ return (
12
+ <CommandPrimitive
13
+ data-slot="command"
14
+ className={cn(
15
+ 'bg-background text-foreground flex h-full w-full flex-col overflow-hidden rounded-md',
16
+ className,
17
+ )}
18
+ {...props}
19
+ />
20
+ )
27
21
  }
28
22
 
29
23
  type CommandDialogPropsExternalApi = React.ComponentProps<typeof Dialog> & {
30
- title?: string;
31
- description?: string;
32
- className?: string;
33
- showCloseButton?: boolean;
34
- };
24
+ title?: string
25
+ description?: string
26
+ className?: string
27
+ showCloseButton?: boolean
28
+ }
35
29
 
36
30
  function CommandDialog({
37
- title = "Command Palette",
38
- description = "Search for a command to run...",
39
- children,
40
- className,
41
- showCloseButton = true,
42
- ...props
31
+ title = 'Command Palette',
32
+ description = 'Search for a command to run...',
33
+ children,
34
+ className,
35
+ showCloseButton = true,
36
+ ...props
43
37
  }: CommandDialogPropsExternalApi): React.JSX.Element {
44
- return (
45
- <Dialog {...props}>
46
- <DialogContent
47
- className={cn("overflow-hidden p-0", className)}
48
- showCloseButton={showCloseButton}
49
- >
50
- <DialogHeader className="sr-only">
51
- <DialogTitle>{title}</DialogTitle>
52
- <DialogDescription>{description}</DialogDescription>
53
- </DialogHeader>
54
- <Command className="[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
55
- {children}
56
- </Command>
57
- </DialogContent>
58
- </Dialog>
59
- );
38
+ return (
39
+ <Dialog {...props}>
40
+ <DialogContent
41
+ className={cn('overflow-hidden p-0', className)}
42
+ showCloseButton={showCloseButton}
43
+ >
44
+ <DialogHeader className="sr-only">
45
+ <DialogTitle>{title}</DialogTitle>
46
+ <DialogDescription>{description}</DialogDescription>
47
+ </DialogHeader>
48
+ <Command className="[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
49
+ {children}
50
+ </Command>
51
+ </DialogContent>
52
+ </Dialog>
53
+ )
60
54
  }
61
55
 
62
56
  function CommandInput({
63
- className,
64
- ...props
57
+ className,
58
+ ...props
65
59
  }: React.ComponentProps<typeof CommandPrimitive.Input>): React.JSX.Element {
66
- return (
67
- <div
68
- data-slot="command-input-wrapper"
69
- className="flex h-9 items-center gap-2 border-b px-3"
70
- >
71
- <SearchIcon className="size-4 shrink-0 opacity-50" />
72
- <CommandPrimitive.Input
73
- data-slot="command-input"
74
- className={cn(
75
- "placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
76
- className,
77
- )}
78
- {...props}
79
- />
80
- </div>
81
- );
60
+ return (
61
+ <div data-slot="command-input-wrapper" className="flex h-9 items-center gap-2 border-b px-3">
62
+ <SearchIcon className="size-4 shrink-0 opacity-50" />
63
+ <CommandPrimitive.Input
64
+ data-slot="command-input"
65
+ className={cn(
66
+ 'placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
67
+ className,
68
+ )}
69
+ {...props}
70
+ />
71
+ </div>
72
+ )
82
73
  }
83
74
 
84
- function CommandList({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.List>): React.JSX.Element {
85
- return (
86
- <CommandPrimitive.List
87
- data-slot="command-list"
88
- className={cn(
89
- "max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",
90
- className,
91
- )}
92
- {...props}
93
- />
94
- );
75
+ function CommandList({
76
+ className,
77
+ ...props
78
+ }: React.ComponentProps<typeof CommandPrimitive.List>): React.JSX.Element {
79
+ return (
80
+ <CommandPrimitive.List
81
+ data-slot="command-list"
82
+ className={cn('max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto', className)}
83
+ {...props}
84
+ />
85
+ )
95
86
  }
96
87
 
97
- function CommandEmpty({ ...props }: React.ComponentProps<typeof CommandPrimitive.Empty>): React.JSX.Element {
98
- return (
99
- <CommandPrimitive.Empty
100
- data-slot="command-empty"
101
- className="py-6 text-center text-sm"
102
- {...props}
103
- />
104
- );
88
+ function CommandEmpty({
89
+ ...props
90
+ }: React.ComponentProps<typeof CommandPrimitive.Empty>): React.JSX.Element {
91
+ return (
92
+ <CommandPrimitive.Empty
93
+ data-slot="command-empty"
94
+ className="py-6 text-center text-sm"
95
+ {...props}
96
+ />
97
+ )
105
98
  }
106
99
 
107
100
  function CommandGroup({
108
- className,
109
- ...props
101
+ className,
102
+ ...props
110
103
  }: React.ComponentProps<typeof CommandPrimitive.Group>): React.JSX.Element {
111
- return (
112
- <CommandPrimitive.Group
113
- data-slot="command-group"
114
- className={cn(
115
- "text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",
116
- className,
117
- )}
118
- {...props}
119
- />
120
- );
104
+ return (
105
+ <CommandPrimitive.Group
106
+ data-slot="command-group"
107
+ className={cn(
108
+ 'text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium',
109
+ className,
110
+ )}
111
+ {...props}
112
+ />
113
+ )
121
114
  }
122
115
 
123
116
  function CommandSeparator({
124
- className,
125
- ...props
117
+ className,
118
+ ...props
126
119
  }: React.ComponentProps<typeof CommandPrimitive.Separator>): React.JSX.Element {
127
- return (
128
- <CommandPrimitive.Separator
129
- data-slot="command-separator"
130
- className={cn("bg-border -mx-1 h-px", className)}
131
- {...props}
132
- />
133
- );
120
+ return (
121
+ <CommandPrimitive.Separator
122
+ data-slot="command-separator"
123
+ className={cn('bg-border -mx-1 h-px', className)}
124
+ {...props}
125
+ />
126
+ )
134
127
  }
135
128
 
136
- function CommandItem({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Item>): React.JSX.Element {
137
- return (
138
- <CommandPrimitive.Item
139
- data-slot="command-item"
140
- className={cn(
141
- "data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
142
- className,
143
- )}
144
- {...props}
145
- />
146
- );
129
+ function CommandItem({
130
+ className,
131
+ ...props
132
+ }: React.ComponentProps<typeof CommandPrimitive.Item>): React.JSX.Element {
133
+ return (
134
+ <CommandPrimitive.Item
135
+ data-slot="command-item"
136
+ className={cn(
137
+ "data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
138
+ className,
139
+ )}
140
+ {...props}
141
+ />
142
+ )
147
143
  }
148
144
 
149
- function CommandShortcut({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element {
150
- return (
151
- <span
152
- data-slot="command-shortcut"
153
- className={cn(
154
- "text-muted-foreground ml-auto text-xs tracking-widest",
155
- className,
156
- )}
157
- {...props}
158
- />
159
- );
145
+ function CommandShortcut({ className, ...props }: React.ComponentProps<'span'>): React.JSX.Element {
146
+ return (
147
+ <span
148
+ data-slot="command-shortcut"
149
+ className={cn('text-muted-foreground ml-auto text-xs tracking-widest', className)}
150
+ {...props}
151
+ />
152
+ )
160
153
  }
161
154
 
162
155
  export {
163
- Command,
164
- CommandDialog,
165
- CommandInput,
166
- CommandList,
167
- CommandEmpty,
168
- CommandGroup,
169
- CommandItem,
170
- CommandShortcut,
171
- CommandSeparator,
172
- };
156
+ Command,
157
+ CommandDialog,
158
+ CommandInput,
159
+ CommandList,
160
+ CommandEmpty,
161
+ CommandGroup,
162
+ CommandItem,
163
+ CommandShortcut,
164
+ CommandSeparator,
165
+ }
@@ -1,131 +1,136 @@
1
- // Adapted from better-hub by Better Auth — https://github.com/better-auth/better-hub
2
- // (apps/web/src/components/ui/dialog.tsx). Full credit to the Better Auth team.
1
+ import * as DialogPrimitive from '@radix-ui/react-dialog'
2
+ import { XIcon } from 'lucide-react'
3
+ import type * as React from 'react'
4
+ import { cn } from '../foundation/cn'
3
5
 
4
- import * as DialogPrimitive from "@radix-ui/react-dialog";
5
- import { XIcon } from "lucide-react";
6
- import type * as React from "react";
7
- import { cn } from "../foundation/cn";
8
-
9
- function Dialog({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>): React.JSX.Element {
10
- return <DialogPrimitive.Root data-slot="dialog" {...props} />;
6
+ function Dialog({
7
+ ...props
8
+ }: React.ComponentProps<typeof DialogPrimitive.Root>): React.JSX.Element {
9
+ return <DialogPrimitive.Root data-slot="dialog" {...props} />
11
10
  }
12
11
 
13
- function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>): React.JSX.Element {
14
- return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />;
12
+ function DialogTrigger({
13
+ ...props
14
+ }: React.ComponentProps<typeof DialogPrimitive.Trigger>): React.JSX.Element {
15
+ return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
15
16
  }
16
17
 
17
- function DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>): React.JSX.Element {
18
- return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />;
18
+ function DialogPortal({
19
+ ...props
20
+ }: React.ComponentProps<typeof DialogPrimitive.Portal>): React.JSX.Element {
21
+ return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
19
22
  }
20
23
 
21
- function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>): React.JSX.Element {
22
- return <DialogPrimitive.Close data-slot="dialog-close" {...props} />;
24
+ function DialogClose({
25
+ ...props
26
+ }: React.ComponentProps<typeof DialogPrimitive.Close>): React.JSX.Element {
27
+ return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
23
28
  }
24
29
 
25
30
  function DialogOverlay({
26
- className,
27
- ...props
31
+ className,
32
+ ...props
28
33
  }: React.ComponentProps<typeof DialogPrimitive.Overlay>): React.JSX.Element {
29
- return (
30
- <DialogPrimitive.Overlay
31
- data-slot="dialog-overlay"
32
- className={cn(
33
- "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/25 dark:bg-black/70 backdrop-blur-[2px]",
34
- className,
35
- )}
36
- {...props}
37
- />
38
- );
34
+ return (
35
+ <DialogPrimitive.Overlay
36
+ data-slot="dialog-overlay"
37
+ className={cn(
38
+ 'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/25 dark:bg-black/70 backdrop-blur-[2px]',
39
+ className,
40
+ )}
41
+ {...props}
42
+ />
43
+ )
39
44
  }
40
45
 
41
46
  type DialogContentPropsExternalApi = React.ComponentProps<typeof DialogPrimitive.Content> & {
42
- showCloseButton?: boolean;
43
- };
47
+ showCloseButton?: boolean
48
+ }
44
49
 
45
50
  function DialogContent({
46
- className,
47
- children,
48
- showCloseButton = true,
49
- ...props
51
+ className,
52
+ children,
53
+ showCloseButton = true,
54
+ ...props
50
55
  }: DialogContentPropsExternalApi): React.JSX.Element {
51
- return (
52
- <DialogPortal>
53
- <DialogOverlay />
54
- <DialogPrimitive.Content
55
- data-slot="dialog-content"
56
- className={cn(
57
- "overflow-y-auto bg-background 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 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] max-h-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
58
- className,
59
- )}
60
- {...props}
61
- >
62
- {children}
63
- {showCloseButton && (
64
- <DialogPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4">
65
- <XIcon />
66
- <span className="sr-only">Close</span>
67
- </DialogPrimitive.Close>
68
- )}
69
- </DialogPrimitive.Content>
70
- </DialogPortal>
71
- );
56
+ return (
57
+ <DialogPortal>
58
+ <DialogOverlay />
59
+ <DialogPrimitive.Content
60
+ data-slot="dialog-content"
61
+ className={cn(
62
+ 'overflow-y-auto bg-background 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 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] max-h-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg',
63
+ className,
64
+ )}
65
+ {...props}
66
+ >
67
+ {children}
68
+ {showCloseButton && (
69
+ <DialogPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4">
70
+ <XIcon />
71
+ <span className="sr-only">Close</span>
72
+ </DialogPrimitive.Close>
73
+ )}
74
+ </DialogPrimitive.Content>
75
+ </DialogPortal>
76
+ )
72
77
  }
73
78
 
74
- function DialogHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element {
75
- return (
76
- <div
77
- data-slot="dialog-header"
78
- className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
79
- {...props}
80
- />
81
- );
79
+ function DialogHeader({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element {
80
+ return (
81
+ <div
82
+ data-slot="dialog-header"
83
+ className={cn('flex flex-col gap-2 text-center sm:text-left', className)}
84
+ {...props}
85
+ />
86
+ )
82
87
  }
83
88
 
84
- function DialogFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element {
85
- return (
86
- <div
87
- data-slot="dialog-footer"
88
- className={cn(
89
- "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
90
- className,
91
- )}
92
- {...props}
93
- />
94
- );
89
+ function DialogFooter({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element {
90
+ return (
91
+ <div
92
+ data-slot="dialog-footer"
93
+ className={cn('flex flex-col-reverse gap-2 sm:flex-row sm:justify-end', className)}
94
+ {...props}
95
+ />
96
+ )
95
97
  }
96
98
 
97
- function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>): React.JSX.Element {
98
- return (
99
- <DialogPrimitive.Title
100
- data-slot="dialog-title"
101
- className={cn("text-lg leading-none font-semibold", className)}
102
- {...props}
103
- />
104
- );
99
+ function DialogTitle({
100
+ className,
101
+ ...props
102
+ }: React.ComponentProps<typeof DialogPrimitive.Title>): React.JSX.Element {
103
+ return (
104
+ <DialogPrimitive.Title
105
+ data-slot="dialog-title"
106
+ className={cn('text-lg leading-none font-semibold', className)}
107
+ {...props}
108
+ />
109
+ )
105
110
  }
106
111
 
107
112
  function DialogDescription({
108
- className,
109
- ...props
113
+ className,
114
+ ...props
110
115
  }: React.ComponentProps<typeof DialogPrimitive.Description>): React.JSX.Element {
111
- return (
112
- <DialogPrimitive.Description
113
- data-slot="dialog-description"
114
- className={cn("text-muted-foreground text-sm", className)}
115
- {...props}
116
- />
117
- );
116
+ return (
117
+ <DialogPrimitive.Description
118
+ data-slot="dialog-description"
119
+ className={cn('text-muted-foreground text-sm', className)}
120
+ {...props}
121
+ />
122
+ )
118
123
  }
119
124
 
120
125
  export {
121
- Dialog,
122
- DialogClose,
123
- DialogContent,
124
- DialogDescription,
125
- DialogFooter,
126
- DialogHeader,
127
- DialogOverlay,
128
- DialogPortal,
129
- DialogTitle,
130
- DialogTrigger,
131
- };
126
+ Dialog,
127
+ DialogClose,
128
+ DialogContent,
129
+ DialogDescription,
130
+ DialogFooter,
131
+ DialogHeader,
132
+ DialogOverlay,
133
+ DialogPortal,
134
+ DialogTitle,
135
+ DialogTrigger,
136
+ }