import { Button } from "@repo/shadcn-ui/components/button"; import { Input } from "@repo/shadcn-ui/components/input"; import type { ReactNode } from "react"; import { useId, useState } from "react"; import { FormActions, FormBody, FormDialog } from "./form-dialog"; import type { RemotePickerOption } from "./remote-option-list"; import { RemoteOptionList } from "./remote-option-list"; export type { RemotePickerOption } from "./remote-option-list"; /** Presenta exclusivamente la página recibida; el consumidor controla consulta, filtros y paginación remota. */ export function RemoteOptionPicker({ title, items, pending, error, search, onSearch, onRetry, onSelect, onClose, pagination, labels, }: { title: string; items: readonly RemotePickerOption[]; pending: boolean; error: string | undefined; search: string; onSearch: (search: string) => void; onRetry: () => Promise; onSelect: (option: RemotePickerOption) => void; onClose: () => void; pagination: ReactNode; labels: { search: string; selection: string; name: string; description: string; empty: string; loading: string; confirm: string; cancel: string; retry: string; }; }) { const id = useId(); const [selected, setSelected] = useState(); return ( { if (!open) { onClose(); } }} open size="medium" title={title} > onSearch(event.target.value)} placeholder={labels.search} value={search} /> {pending &&

{labels.loading}

} {error && (

{error}

)} {pagination}
); }