import { RadioGroup, RadioGroupItem } from "@repo/shadcn-ui/components/radio-group"; import { EntityTable } from "./entity-list"; import type { PickerOption } from "./option-picker-dialog"; /** Listado de selección única con búsqueda; el diálogo conserva la confirmación provisional. */ export function OptionPickerList({ title, options, value, onChange, labels, locale, loading = false, }: { title: string; options: readonly PickerOption[]; value: string; onChange: (id: string) => void; labels: { selection: string; name: string; entity: (count: number) => string; description: string; search: string; }; locale: string; loading?: boolean; }) { const choose = (id: string) => { if (!loading && options.some((option) => option.id === id && !option.disabled)) { onChange(id); } }; return ( { if (typeof id === "string") { choose(id); } }} value={value} > ( ), }, { id: "name", label: labels.name, hideable: false, value: (option) => option.label, render: (option) => {option.label}, }, { id: "description", label: labels.description, value: (option) => option.description, render: (option) => option.description || "—", }, ]} entityLabel={labels.entity} items={options} layout="fill" loading={loading} locale={locale} onRowClick={(option) => choose(option.id)} rowClassName={(option) => (option.disabled ? "cursor-not-allowed!" : "")} searchPlaceholder={labels.search} title={title} /> ); }