/* ───────────────────────────────────────────────────────────────────────── PixelCheckbox — chunky pixel check mark. ───────────────────────────────────────────────────────────────────────── */ import React, { forwardRef } from 'react'; import { Tone, Surface, cn, toneMap, surfaceClasses, useEffectiveSurface, CheckIcon, } from '../common'; import { useControllableState } from '../hooks/useControllableState'; /** Public prop bag for {@link PixelCheckbox}. */ export interface PixelCheckboxProps { /** Label rendered next to the box. */ label: string; /** Controlled checked state. */ checked?: boolean; /** Uncontrolled initial checked state. */ defaultChecked?: boolean; /** Fires with the next checked value when clicked. */ onChange?: (next: boolean) => void; /** Disables interaction + grays out the control. */ disabled?: boolean; /** Visual tone for the checked state. Default: `'green'`. */ tone?: Tone; /** Surface variant. Inherits from `PxlKitSurfaceProvider` when omitted. */ surface?: Surface; /** Form-serialization name. Hidden mirror input sends `'on'` / `''`. */ name?: string; /** HTML form value when checked. Defaults to `'on'`. */ value?: string; /** Marks the field as required for native form validation. */ required?: boolean; /** DOM `id` forwarded to the trigger. */ id?: string; } export const PixelCheckbox = forwardRef(function PixelCheckbox( { label, checked, defaultChecked, onChange, disabled = false, tone = 'green', surface: surfaceProp, name, value = 'on', required, id, }, ref, ) { const surface = useEffectiveSurface(surfaceProp); const s = surfaceClasses(surface); const [internalChecked, setInternalChecked] = useControllableState({ value: checked, defaultValue: defaultChecked ?? false, onChange, }); const isChecked = internalChecked ?? false; return ( <> {name && isChecked && } ); });