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