mirror of
https://github.com/supabase/supabase.git
synced 2026-06-12 17:27:58 +08:00
## Problem The `_Shadcn_` suffix isn't needed anymore on `Command` components ## Solution - Remove the `_Shadcn_` suffix - Simplify UI package exports - Apply prettier <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Simplified command component imports and exports across the UI library by removing internal naming aliases and adopting direct component references. Updated the public UI package barrel export to use wildcard re-exports for cleaner API surface. <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46153?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import { cn, Command, CommandGroup, CommandItem, CommandList } from 'ui'
|
|
|
|
import type { ResourcePickerRenderProps } from './SecondLevelNav.Layout'
|
|
|
|
type NamedResource = { name: string }
|
|
|
|
type ResourcePickerListProps = ResourcePickerRenderProps & {
|
|
items: NamedResource[]
|
|
emptyMessage: string
|
|
}
|
|
|
|
export const ResourcePickerList = ({
|
|
items,
|
|
emptyMessage,
|
|
selectedResource,
|
|
onSelect,
|
|
closePopover,
|
|
}: ResourcePickerListProps) => {
|
|
const handleSelect = (value: string) => {
|
|
onSelect(value)
|
|
closePopover()
|
|
}
|
|
|
|
return (
|
|
<Command>
|
|
<CommandList>
|
|
<CommandGroup>
|
|
{items.length === 0 && (
|
|
<CommandItem disabled className="cursor-default px-4">
|
|
<p className="text-foreground-light">{emptyMessage}</p>
|
|
</CommandItem>
|
|
)}
|
|
{items.map((item) => {
|
|
const isActive = item.name === selectedResource
|
|
return (
|
|
<CommandItem
|
|
key={item.name}
|
|
className={cn(
|
|
'cursor-pointer px-4',
|
|
isActive ? 'text-foreground bg-selection' : 'text-foreground-light'
|
|
)}
|
|
onSelect={() => handleSelect(item.name)}
|
|
>
|
|
<p className="truncate">{item.name}</p>
|
|
</CommandItem>
|
|
)
|
|
})}
|
|
</CommandGroup>
|
|
</CommandList>
|
|
</Command>
|
|
)
|
|
}
|