/* ───────────────────────────────────────────────────────────────────────── PixelPasswordInput — password field with show/hide toggle. ───────────────────────────────────────────────────────────────────────── */ import React, { forwardRef, useId, useState } from 'react'; import { Tone, Size, Surface, cn, toneMap, focusRing, inputBase, sizeHeight, surfaceClasses, useEffectiveSurface, FieldShell, } from '../common'; /** Public prop bag for {@link PixelPasswordInput}. */ export interface PixelPasswordInputProps extends Omit, 'type' | 'size'> { /** Floating label rendered above the input shell. */ label?: string; /** Helper text shown below the field. Hidden when `error` is set. */ hint?: string; /** Error message shown below the field; flips visual state to invalid. */ error?: string; /** Visual tone for focus ring + border emphasis. Default: `'neutral'`. */ tone?: Tone; /** Field height token. Default: `'md'`. */ size?: Size; /** Surface variant. Inherits from `PxlKitSurfaceProvider` when omitted. */ surface?: Surface; /** Text for the visibility toggle, in `[showLabel, hideLabel]` form. */ toggleLabels?: [string, string]; } export const PixelPasswordInput = forwardRef(function PixelPasswordInput( { label, hint, error, tone = 'neutral', size = 'md', surface: surfaceProp, toggleLabels = ['Show', 'Hide'], className, ...rest }, ref, ) { const surface = useEffectiveSurface(surfaceProp); const s = surfaceClasses(surface); const [visible, setVisible] = useState(false); const reactId = useId(); const inputId = rest.id ?? `pxl-password-${reactId}`; return ( ); });