import React, { forwardRef } from 'react'; import { Tone, Size, Surface, cn, toneMap, surfaceClasses, useEffectiveSurface, CloseIcon, } from '../common'; import { variantClasses, PixelBadgeVariant } from './_internal/variantClasses'; /* ───────────────────────────────────────────────────────────────────────── PixelChip — label tag, optionally removable / clickable. Upgraded additively: `variant`, `size`, `iconLeft`, `onClick` (chip becomes button), and `deletable` + `onDelete` (X button on the right). `onRemove` stays as the legacy delete handler alias. ───────────────────────────────────────────────────────────────────────── */ const chipSizeCls: Record = { sm: 'px-2 py-0.5 text-[11px] gap-1 tracking-wide', md: 'px-2.5 py-1 text-xs gap-1.5 tracking-wide', lg: 'px-3 py-1.5 text-sm gap-2 tracking-wide', }; export interface PixelChipProps extends Omit, 'onClick'> { /** Chip label. */ label: string; /** Selection value consumed by a wrapping PixelChipGroup. Never rendered to the DOM. */ value?: string; /** Tone tint. Defaults to `'cyan'`. */ tone?: Tone; /** Visual surface override. */ surface?: Surface; /** Variant axis shared with PixelBadge. */ variant?: PixelBadgeVariant; /** Size scale. Defaults to `'md'`. */ size?: Size; /** Optional leading icon. */ iconLeft?: React.ReactNode; /** Legacy alias for `onDelete`. */ onRemove?: () => void; /** When true (or when onDelete is provided), renders an X button on the right. */ deletable?: boolean; /** Called when the X button is activated. */ onDelete?: () => void; /** When provided the root renders as a ` )} ); if (onClick) { return ( ); } return ( } className={cls} {...rest} > {inner} ); }); PixelChip.displayName = 'PixelChip';