import type { StyleCategory } from '../utils/style' import { STYLE_CATEGORIES, CUSTOM_PREFIX } from '../utils/style' import styles from './StyleSelector.module.css' interface StyleSelectorProps { value: Record onChange: (key: string, value: string) => void compact?: boolean categories?: StyleCategory[] customTags?: string[] } const CUSTOM_TAG_CATEGORY: StyleCategory = { key: '', // unused, pills use custom: prefix directly label: '自定义标签', options: [], } export default function StyleSelector({ value, onChange, compact, categories, customTags, }: StyleSelectorProps) { const cats = categories ?? STYLE_CATEGORIES return (
{cats.map(cat => (
{cat.label}
{cat.options.map(opt => ( ))}
))} {customTags && customTags.length > 0 && (
{CUSTOM_TAG_CATEGORY.label}
{customTags.map(tag => { const key = `${CUSTOM_PREFIX}${tag}` const isActive = value[key] === 'true' return ( ) })}
)}
) }