@@ -8,8 +8,6 @@ import { TbSearch } from "solid-icons/tb"
88import { cn } from "~/lib/utils"
99import { Dialog , DialogContent } from "~/registry/ui/dialog"
1010
11- export const CommandItemLabel = ComboboxPrimitive . ItemLabel
12-
1311type CommandProps < Option , OptGroup > = Omit <
1412 ComboboxPrimitive . ComboboxRootProps < Option , OptGroup > ,
1513 | "open"
@@ -22,7 +20,7 @@ type CommandProps<Option, OptGroup> = Omit<
2220 | "allowsEmptyCollection"
2321>
2422
25- export const Command = < Option , OptGroup > ( props : CommandProps < Option , OptGroup > ) => {
23+ const Command = < Option , OptGroup > ( props : CommandProps < Option , OptGroup > ) => {
2624 const [ local , rest ] = splitProps ( props , [ "class" ] )
2725
2826 return (
@@ -41,21 +39,7 @@ export const Command = <Option, OptGroup>(props: CommandProps<Option, OptGroup>)
4139 )
4240}
4341
44- export const CommandList = < Option , OptGroup > (
45- props : VoidProps < ComboboxPrimitive . ComboboxListboxProps < Option , OptGroup > >
46- ) => {
47- const [ local , rest ] = splitProps ( props , [ "class" ] )
48-
49- return (
50- < ComboboxPrimitive . Listbox
51- cmdk-list = ""
52- class = { cn ( "max-h-[300px] overflow-y-auto overflow-x-hidden p-1" , local . class ) }
53- { ...rest }
54- />
55- )
56- }
57-
58- export const CommandInput : VoidComponent < ComboboxPrimitive . ComboboxInputProps > = ( props ) => {
42+ const CommandInput : VoidComponent < ComboboxPrimitive . ComboboxInputProps > = ( props ) => {
5943 const [ local , rest ] = splitProps ( props , [ "class" ] )
6044
6145 return (
@@ -73,7 +57,21 @@ export const CommandInput: VoidComponent<ComboboxPrimitive.ComboboxInputProps> =
7357 )
7458}
7559
76- export const CommandItem : ParentComponent < ComboboxPrimitive . ComboboxItemProps > = ( props ) => {
60+ const CommandList = < Option , OptGroup > (
61+ props : VoidProps < ComboboxPrimitive . ComboboxListboxProps < Option , OptGroup > >
62+ ) => {
63+ const [ local , rest ] = splitProps ( props , [ "class" ] )
64+
65+ return (
66+ < ComboboxPrimitive . Listbox
67+ cmdk-list = ""
68+ class = { cn ( "max-h-[300px] overflow-y-auto overflow-x-hidden p-1" , local . class ) }
69+ { ...rest }
70+ />
71+ )
72+ }
73+
74+ const CommandItem : ParentComponent < ComboboxPrimitive . ComboboxItemProps > = ( props ) => {
7775 const [ local , rest ] = splitProps ( props , [ "class" , "item" ] )
7876
7977 return (
@@ -89,27 +87,29 @@ export const CommandItem: ParentComponent<ComboboxPrimitive.ComboboxItemProps> =
8987 )
9088}
9189
92- export const CommandShortcut : ParentComponent < ComponentProps < "span" > > = ( props ) => {
90+ const CommandItemLabel = ComboboxPrimitive . ItemLabel
91+
92+ const CommandHeading : ParentComponent < ComboboxPrimitive . ComboboxSectionProps > = ( props ) => {
9393 const [ local , rest ] = splitProps ( props , [ "class" ] )
9494
9595 return (
96- < span
97- class = { cn ( "ml-auto text-xs tracking-widest text-muted-foreground" , local . class ) }
96+ < ComboboxPrimitive . Section
97+ cmdk-heading = ""
98+ class = { cn (
99+ "px-2 py-1.5 text-xs font-medium text-muted-foreground [&:not(&:first-of-type)]:mt-2" ,
100+ local . class
101+ ) }
98102 { ...rest }
99103 />
100104 )
101105}
102106
103- export const CommandHeading : ParentComponent < ComboboxPrimitive . ComboboxSectionProps > = ( props ) => {
107+ const CommandItemShortcut : ParentComponent < ComponentProps < "span" > > = ( props ) => {
104108 const [ local , rest ] = splitProps ( props , [ "class" ] )
105109
106110 return (
107- < ComboboxPrimitive . Section
108- cmdk-heading = ""
109- class = { cn (
110- "px-2 py-1.5 text-xs font-medium text-muted-foreground [&:not(&:first-of-type)]:mt-2" ,
111- local . class
112- ) }
111+ < span
112+ class = { cn ( "ml-auto text-xs tracking-widest text-muted-foreground" , local . class ) }
113113 { ...rest }
114114 />
115115 )
@@ -118,14 +118,30 @@ export const CommandHeading: ParentComponent<ComboboxPrimitive.ComboboxSectionPr
118118type CommandDialogProps < Option , OptGroup > = DialogPrimitive . DialogRootProps &
119119 CommandProps < Option , OptGroup >
120120
121- export const CommandDialog = < Option , OptGroup > ( props : CommandDialogProps < Option , OptGroup > ) => {
121+ const CommandDialog = < Option , OptGroup > ( props : CommandDialogProps < Option , OptGroup > ) => {
122122 const [ local , rest ] = splitProps ( props , [ "children" ] )
123123
124124 return (
125125 < Dialog { ...rest } >
126126 < DialogContent class = "overflow-hidden p-0" >
127- < Command { ...rest } > { local . children } </ Command >
127+ < Command
128+ class = "[&_[cmdk-heading]]:px-2 [&_[cmdk-heading]]:font-medium [&_[cmdk-heading]]:text-muted-foreground [&_[cmdk-input-wrapper]_svg]:size-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:size-5 [&_[cmdk-list]:not([hidden])_~[cmdk-list]]:pt-0 [&_[cmdk-list]]:px-2"
129+ { ...rest }
130+ >
131+ { local . children }
132+ </ Command >
128133 </ DialogContent >
129134 </ Dialog >
130135 )
131136}
137+
138+ export {
139+ Command ,
140+ CommandInput ,
141+ CommandList ,
142+ CommandItem ,
143+ CommandItemLabel ,
144+ CommandItemShortcut ,
145+ CommandHeading ,
146+ CommandDialog
147+ }
0 commit comments