import React from 'react'; import { colorPickerPreviewValue, colorValueUsesVariable } from '../colorUtils'; import { CommitInput } from './CommitInput'; interface ColorValueFieldProps { label?: string; value: string; onChange: (value: string) => void; variableOptions?: string[]; defaultColor?: string; placeholder?: string; className?: string; hint?: string; } export const ColorValueField: React.FC = ({ label, value, onChange, variableOptions = [], defaultColor = '#111827', placeholder = '#111827', className = '', hint, }) => { const usesVariable = colorValueUsesVariable(value); const pickerValue = colorPickerPreviewValue(value, defaultColor); return (
{label && }
onChange(e.target.value)} className="color-input shrink-0 disabled:opacity-40" title={usesVariable ? '当前为变量颜色,请使用文本框编辑' : undefined} />
{variableOptions.length > 0 && (
{variableOptions.map((v) => ( ))}
)} {hint &&

{hint}

} {!hint && variableOptions.length > 0 && (

支持 hex/rgb/transparent 或 {`{变量名}`};排版印刷色彩模式下按行数据解析

)}
); };