import "./reference_field.css"; import { type ReactNode } from "react"; import type * as React from "react"; import { useRender } from "@base-ui/react/use-render"; import { type StyleProps } from "./style_props"; /** * A REFERENCE to another record, rendered as a FIELD VALUE. * * ONE act on the surface, the rest one layer in: * press the value → the facts, in a popover * Change / Clear → the LINK: point it elsewhere, or leave it empty * Edit → the RECORD's own facts, as a draft, committed by Save * Open → the referenced record's page (optional; the departure) */ export interface ReferenceFact { label: string; value: string; /** * The key this fact SAVES under. Its presence is what makes the fact * editable — a fact without one stays read-only in the draft. */ name?: string; /** A value that runs past one line — an address, a bank account block. */ multiline?: boolean; /** * What the draft edits this fact WITH. `text` (default) is a text input; * `date` is the kit's `DatePicker`, and the value is its ISO string. */ type?: "text" | "date"; /** A verb ABOUT this value — an `InlineButton`. Rendered at REST, never inside * the draft: an action acts on the RECORD, while a draft holds values seeded * before it ran, so Save would write them back over whatever it fetched. */ action?: ReactNode; /** THIS VALUE'S OWN EDITOR, outside the draft — a control that COMMITS ON THE * PICK, never `action`, which renders the `value` beside it. A pick-committed * control only: the peek is dismissed by an outside press, so a * blur-committed editor would lose the edit to the dismissing click. */ control?: ReactNode; } export interface ReferenceFieldProps extends StyleProps { name: string; code?: string; facts: ReferenceFact[]; /** Announced name of the peek trigger, e.g. "Harbor Freight Lines — details". */ accessibilityLabel: string; /** The referenced record's own page; omit it and the peek carries no Open. */ onOpen?: () => void; openLabel?: string; /** * Point this field at a DIFFERENT record. * * Unsets the reference so the call site's picker returns, and the caller * should hand that picker focus. */ onChange?: () => void; /** * Leave the reference EMPTY — the plain detach. The SAME write as `onChange`; * they differ only in FOLLOW-THROUGH, and nothing downstream can tell "unset * it" from "unset it, I'm about to pick another". * * They come as a PAIR — both, or neither. **Omitting BOTH is the read-only * reference.** Whether empty is VALID is the row's business. */ onClear?: () => void; /** Commit the draft. Receives ONLY the facts the reader STATED a value for, * keyed by `name` — never a full snapshot, so a lock or a `before_update` * hook sees the edit the reader made. A fact typed back to the string it * already held is stated, and travels. */ onSave?: (patch: Record) => void | Promise; testID?: string; ref?: React.Ref; render?: useRender.RenderProp; } export declare function ReferenceField(props: ReferenceFieldProps): React.JSX.Element;