'use client' import * as React from 'react' import { Button } from "@/registry/new-york/ui/button" import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem } from "@/registry/new-york/ui/command" import { Popover, PopoverContent, PopoverTrigger } from "@/registry/new-york/ui/popover" import { cn } from "@/lib/utils" import { Check, ChevronsUpDown } from "lucide-react" import { navigationIcons, type IconType } from '@/lib/icons' interface IconSelectorProps { value?: string onChange: (value: string) => void } export function IconSelector({ value, onChange }: IconSelectorProps) { const [open, setOpen] = React.useState(false) const [searchQuery, setSearchQuery] = React.useState("") // 获取当前选中的图标组件 const SelectedIcon = value && navigationIcons[value as IconType] ? navigationIcons[value as IconType] : null // 过滤图标 const filteredIcons = Object.entries(navigationIcons) .filter(([name]) => name.toLowerCase().includes(searchQuery.toLowerCase()) ) return ( 没有找到图标
{filteredIcons.map(([name]) => ( { onChange(currentValue) setOpen(false) }} > {React.createElement(navigationIcons[name as IconType], { className: "mr-2 h-4 w-4" })} {name} ))}
) }