import type { Translate } from './server-error'; import type { ActionFieldDef } from './types'; import { type ActionMetadata, type ActionModalProps } from '@asteby/metacore-sdk'; export type { ActionMetadata, ActionModalProps }; export interface PrefillSpec { $prefillFromRecord: string; map?: Record; remaining?: { target: string; of: string; minus?: string; }; /** * Item-field keys to lock (render read-only) in the prefilled rows — e.g. the * product of a receive-goods line is dictated by the source document, so it * is shown as a resolved name but cannot be changed. Editable in the create * flow (which carries no prefill spec); only the prefilled action locks them. */ lock?: string[]; /** * Key of a SIBLING action field (a dynamic_select with a `ref`) whose selected * value is the id of the document the rows are seeded from. Without it the * rows come from the record the action was opened on (row actions); with it * a `create`-placed action — which has no record — seeds its grid as soon as * the user picks the source document (e.g. a goods receipt picking its * purchase order). `$prefillFromRecord` then names a one_to_many relation of * the REFERENCED model. Clearing the selection empties the grid. */ fromField?: string; } export declare function isPrefillSpec(v: unknown): v is PrefillSpec; export declare function applyPrefillLock(field: ActionFieldDef): ActionFieldDef; export declare function buildPrefillRows(spec: PrefillSpec, record: any): Array>; export interface PrefillRelationRequest { fieldKey: string; spec: PrefillSpec; endpoint: string; params: Record; } export declare function prefillRelationRequests(fields: ActionFieldDef[] | undefined, record: any, relations: Array<{ name?: string; kind?: string; through?: string; foreign_key?: string; scope?: Record; }>): PrefillRelationRequest[]; export interface PrefillFromFieldRequest { fieldKey: string; spec: PrefillSpec; /** Model key the sibling field references (its `ref`). */ refModel: string; /** Selected document id; '' when nothing is selected (grid must clear). */ refId: string; } export declare function prefillFromFieldRequests(fields: ActionFieldDef[] | undefined, formData: Record): PrefillFromFieldRequest[]; export declare function prefillFromFieldRelationRequest(req: PrefillFromFieldRequest, relations: Array<{ name?: string; kind?: string; through?: string; foreign_key?: string; scope?: Record; }>): { endpoint: string; params: Record; } | null; export declare function unwrapRecordScalar(value: unknown): unknown; export declare function readRecordPath(record: any, path: string): unknown; /** * ¿`ref` (FK de un campo) apunta al modelo `model` de la fila? Tolera prefijo de * addon, PascalCase vs tabla y el plural de la tabla (`Invoice` ↔ `invoices`, * `CustomerAddress` ↔ `customer_addresses`). */ export declare function refTargetsModel(ref: string | undefined | null, model: string | undefined | null): boolean; /** * Scalar seed for one action field from the row being acted on. * * Sin `default_from_record` declarado, un campo se siembra con la columna * homónima de la fila; y un selector que apunta al MISMO modelo de la fila y * que la fila no tiene como columna (`invoice_id` → Invoice en «Registrar pago» * de una factura) se siembra con el id de esa fila: la acción se abrió desde * ella (retest Pitsline 2026-10-05). */ export declare function scalarDefaultFromRecord(field: ActionFieldDef, record: any, model?: string): unknown; export declare function ActionModalDispatcher({ open, onOpenChange, action, model, record, endpoint, onSuccess: onSuccessProp, }: ActionModalProps): import("react").JSX.Element | null; /** How long an action with `modal` waits for its federated component. */ export declare const FEDERATED_ACTION_MODAL_TIMEOUT_MS = 20000; /** Text for the in-dialog error banner of a failed action (PIT-046, #1023): a * 422 with per-field `errors` -> "Revisa los campos" + each localized line; any * other failure (500, network) -> the server's own message and cause. Unlike * the toast it stays on screen until the next attempt. */ export declare function actionErrorBannerMessage(err: unknown, fields: readonly ActionFieldDef[] | undefined, t: Translate, language?: string): string; /** Context a declared field default is resolved against. */ export interface FieldDefaultContext { /** Org IANA timezone: `$today` is the org's day, not the browser's or UTC's. */ timeZone?: string; /** Clock (tests). */ now?: Date; } /** * The declared scalar default of a field, resolved: `defaultValue` (host * camelCase) or `default` (raw manifest, the kernel serves action/document-form * fields without renaming it). A date field may declare `$today` / `today` and * gets the org's calendar day. An unknown `$token` never lands in a date field * (undefined): a literal "$today" posted as invoice_date is a 422, an empty * field is just a required field to fill. */ export declare function resolveFieldDefault(field: ActionFieldDef, ctx?: FieldDefaultContext): unknown; export declare function buildFieldDefaults(fields: ActionFieldDef[], record: any, model?: string, ctx?: FieldDefaultContext): Record; export declare function seedOptionFromRecord(field: ActionFieldDef, value: any, record?: Record): import('./use-options-resolver').ResolvedOption | undefined; /** Renders one action field (same widgets as the action modals). Shared with DocumentFormDialog. */ export declare function renderField(field: ActionFieldDef, value: any, onChange: (value: any) => void, formValues?: Record, record?: Record, fieldErrors?: Record): import("react").JSX.Element; //# sourceMappingURL=action-modal-dispatcher.d.ts.map