import { useField, useControl, type FieldName } from "@conform-to/react/future"; import { type FieldProps } from "../field/Field"; import { ColorPicker, RawColor, type Color } from "../../color"; interface Props extends Omit { name: FieldName; allowInherit?: boolean; refColor?: RawColor; } export function HexColorField({ name, id: forcedId, allowInherit = false, ...rest }: Props) { const field = useField(name); const id = forcedId ?? field.id; const control = useControl({ defaultValue: field.defaultValue, }); const value: Color | null = control.value ? { type: "raw", hex: control.value } : null; function handleChange(color: Color | null) { control.change(color?.type === "raw" ? color.hex : null); } return ( <> ); }