import { ChevronDown } from "lucide-react"; import type { ReactNode } from "react"; import { cn } from "../utils/cn"; export interface ParamPillProps { /** Left cap — dim label (e.g., "account", "period"). */ label: ReactNode; /** Middle cell — the current value, rendered in fg. Monospace when `mono`. */ value: ReactNode; /** Mono the value cell (for identifiers and dates). Default false. */ mono?: boolean; /** Click opens an editor / picker. If omitted, the pill is static. */ onClick?: () => void; /** Show the trailing chevron "▾". Default true when onClick is provided. */ dropdown?: boolean; /** Replaces the automatic chevron affordance — e.g., a clear ✕. */ trailing?: ReactNode; /** True when the pill is the currently open one in a popover dance. */ active?: boolean; /** Adds a small colored dot before the label (e.g., status indicator). */ dot?: string; className?: string; } /** Segmented [ label | value | chevron ] pill. * * The target's parameter / facet bar uses a pill with three visual cells * separated by hairlines: a dim "label" cap, the "value", and a dropdown * chevron. We use it for report params and table filters — any place the * UI says "here is a dimension that's been set to a value you can change". * Height tracks the bar tier (24px). The label cell picks up a slightly * warmer tint (`bg-sap-proj-chip-kbd`) so the eye reads the three regions at * a glance. */ export function ParamPill({ label, value, mono = false, onClick, dropdown, trailing, active = false, dot, className, }: ParamPillProps) { const showChevron = trailing == null && (dropdown ?? onClick != null); const isInteractive = onClick != null; const Wrapper: "button" | "div" = isInteractive ? "button" : "div"; const borderColor = active ? "border-sap-brand" : "border-sap-border"; return ( {dot && ( )} {label} {value} {trailing != null && ( {trailing} )} {showChevron && ( )} ); }