// RecordPickerActions — create/edit affordances of the shared // (record-picker.tsx), the ONE "pick a related record" control of the runtime. // Every picker (DynamicSelectField, EntitySelect, the business pickers) gets // the same contract from here: // // - nothing selected → "+" joined to the trigger: opens the model's CREATE // modal and the new record ends up selected; // - a record selected → pencil joined to the trigger: opens THAT record's // EDIT modal and the label refreshes on save; // - "Crear …" at the foot of the result list, so creating is one step away // from a search with no hits (prefilled with the searched text). // // The action renders as a segment of the trigger (shared border, no gap) so the // control reads as a single field instead of a select plus a loose button. // // The create/edit modals themselves are the HOST's (decoupled window events the // host's RecordCreateBridge listens for) or, for hand-written screens, the // in-tree (see record-picker-dialog.tsx). import type { ReactNode } from 'react' import { Pencil, Plus } from 'lucide-react' import { Button, CommandGroup, CommandItem, CommandSeparator } from '@asteby/metacore-ui/primitives' /** Classes for a trigger that has a joined action segment on its right. */ export const JOINED_TRIGGER_CLASS = 'rounded-r-none focus-visible:z-10' export interface RecordPickerActionProps { /** Current value: drives create (+) vs edit (pencil). */ hasValue: boolean /** Human label of the referenced model / field, for the accessible name. */ label: string onCreate?: () => void onEdit?: () => void disabled?: boolean /** Accessible name override for the "+" (default `Crear