import { Button } from "@repo/shadcn-ui/components/button"; import type { ReactNode } from "react"; import { useState } from "react"; import { EmptyState } from "./empty-state"; import type { PickerOption } from "./option-picker-dialog"; import { OptionPickerDialog } from "./option-picker-dialog"; import { SelectionSummaryCard } from "./selection-summary-card"; /** Selección visual con estado vacío, ficha y listado; no conoce consultas ni entidades. */ export function OptionSelectionField({ title, description, icon, options, value, onChange, labels, locale, disabled = false, locked = false, loading = false, createAction, clearLabel, }: { title: string; description: string; icon: ReactNode; options: readonly PickerOption[]; value: string; onChange: (id: string) => void; labels: { select: string; change: string; selection: string; name: string; description: string; confirm: string; cancel: string; search: string; }; locale: string; disabled?: boolean; locked?: boolean; loading?: boolean; createAction?: { label: string; onClick: () => void; disabled?: boolean } | undefined; clearLabel?: string | undefined; }) { const [open, setOpen] = useState(false); const selected = options.find((option) => option.id === value); const actions = ( <> {createAction && !locked && ( )} {selected && clearLabel && ( )} > ); return ( <> {selected ? (