import type { ColumnSchema, FieldValidation, GetRecordsOptions, GetRecordsResult, TableViewConfig, ValueField } from '@stonecrop/schema'; /** * Controls the level of user interaction for a field, container, or table. * `'edit'` — interactive; `'read'` — non-interactive with form chrome; * `'display'` — non-interactive plain-text rendering. * @public */ export type { InteractionMode } from '@stonecrop/schema'; /** * A resolved scalar field. Derived from ValueField with `cardinality` omitted * (consumed by resolveSchema) and an optional `doctype` added for unresolved Link fields. * @public */ export type ResolvedScalar = Omit & { /** Doctype slug for unresolved Link fields — added by resolveSchema when AFormLink is available */ doctype?: string; }; /** * A resolved Link field with cardinality `one` or `atMostOne` — embedded as a nested form. * @public */ export interface ResolvedLink { /** Discriminator */ kind: 'link'; /** Field identifier */ fieldname: string; /** Component to render; defaults to `'AForm'` */ component: string; /** Human-readable label */ label?: string; /** Interaction mode */ mode?: import('@stonecrop/schema').InteractionMode; /** Resolved child fields */ schema: ResolvedField[]; /** Preserved from the original ValueField */ required?: boolean; /** Preserved from the original ValueField */ readOnly?: boolean; /** Preserved from the original ValueField */ hidden?: boolean; /** Preserved from the original ValueField */ default?: unknown; /** Preserved from the original ValueField */ validation?: FieldValidation; } /** * A resolved table — either from a Link with `noneOrMany`/`atLeastOne` cardinality, * or from an inline TableField. ATable receives columns via `:schema` (ColumnSchema[]) * and row data via `:rows` from formData at render time. * * Note the key rename: an authoring `TableField` declares its columns under `columns`; * `resolveSchema` moves them to `schema` here, because `schema` is the ATable prop that * runs `schemaToColumns()` (ATable's own `columns` prop means already-converted * `TableColumn[]`). A hand-authored table must therefore use `schema`, not `columns`. * * Rows are never part of the schema. AForm sources them from the data model at * `dataModel[fieldname]`, so a `rows` key placed on this object is ignored. * @public */ export interface ResolvedTable { /** Discriminator */ kind: 'table'; /** Field identifier */ fieldname: string; /** Component to render; defaults to `'ATable'` */ component: string; /** Human-readable label */ label?: string; /** Interaction mode for all cells */ mode?: import('@stonecrop/schema').InteractionMode; /** Column definitions — passed to ATable's `:schema` prop */ schema: ColumnSchema[]; /** View configuration — always present; defaults to `{ view: 'list' }` */ config: TableViewConfig; /** Preserved from the original ValueField or TableField */ required?: boolean; /** Preserved from the original ValueField or TableField */ readOnly?: boolean; /** Preserved from the original ValueField or TableField */ hidden?: boolean; /** Preserved from the original ValueField or TableField */ default?: unknown; /** Preserved from the original ValueField or TableField */ validation?: FieldValidation; /** When set, ATable fetches list pages through this callback (server paging). */ getRecords?: (options?: GetRecordsOptions) => Promise; /** When this changes, ATable refetches from offset 0. */ sourceKey?: string; } /** * A resolved fieldset — groups child fields inside an AFieldset component. * @public */ export interface ResolvedFieldset { /** Discriminator */ kind: 'fieldset'; /** Field identifier */ fieldname: string; /** Component to render; defaults to `'AFieldset'` */ component?: string; /** Human-readable label for the legend */ label?: string; /** Whether the fieldset can be collapsed */ collapsible?: boolean; /** Interaction mode for all children */ mode?: import('@stonecrop/schema').InteractionMode; /** Resolved child fields */ schema: ResolvedField[]; } /** * The discriminated union of all resolved field types — what AForm consumes, * usually after `resolveSchema()` has transformed the authoring `DoctypeField[]`, * but also valid hand-authored for view chrome with no backing doctype. * Narrowed by `kind`: `'field'` | `'link'` | `'table'` | `'fieldset'`. * * `kind` is required — AForm dispatches on it alone and does not infer a field's * type from its structure. * @public */ export type ResolvedField = ResolvedScalar | ResolvedLink | ResolvedTable | ResolvedFieldset; /** * Defined props for AForm components * @public */ export type ComponentProps = { /** * The schema object to pass to the component * @public */ schema?: ResolvedField; /** * The label to display in the component * @public */ label?: string; selectRange?: boolean; /** * The mask to apply to inputs inside the component. Accepts either a plain * mask string (e.g. `"(###) ###-####"`) or a stringified arrow function that * receives `locale` and returns a mask string * (e.g. `"(locale) => locale === 'en-US' ? '(###) ###-####' : '####-######'"`). * @public */ mask?: string; /** * Indicate whether input is required for text and/or select elements inside the component * @public */ required?: boolean; /** * The rendering mode for the component * @public */ mode?: import('@stonecrop/schema').InteractionMode; /** * Set a unique identifier for elements inside the component * @public */ uuid?: string; /** * Validation options for elements inside the component * @public */ validation?: { /** * The error message to display when validation fails * @public */ errorMessage: string; [key: string]: any; }; /** * Inline validation error messages to display on this field. Fed by the host * (e.g. mapped from the core validation store) — the renderer stays dumb and just * shows what it is given. Takes precedence over the static `validation.errorMessage`. * @public */ errors?: string[]; }; /** * The value shape for AFormLink — a linked document reference with optional display text * @public */ export interface AFormLinkValue { /** The FK/linked document ID. `id: 0` is a valid ID. */ id: string | number; /** Display text shown in the input. Falls back to `String(id)` if omitted. */ displayText?: string; /** Additional properties passed through to the underlying input component */ [extra: string]: any; } /** * What AFormLink accepts as its `v-model`. * * Wider than {@link AFormLinkValue} because a link is as often bound straight to its FK column as * to a resolved reference: a record loaded from the DB carries the raw scalar, and a parent bound * to that column coerces every update it receives back to a scalar. The component reads through * `linkId`/`linkDisplayText`/`asLinkValue`, so all three shapes render and resolve identically. * * Emitting is narrower — AFormLink always writes back an {@link AFormLinkValue}. * @public */ export type AFormLinkModelValue = AFormLinkValue | string | number; /** * Navigation contract for AFormLink. Provide via `provide('aformLinkNavigator', ...)` in the app plugin. * @public */ export interface AFormLinkNavigator { /** Navigate to the linked document. Implementation is app-defined. */ navigate(doctype: string, id: string | number): void; } /** * The value shape for AQuantityInput — a quantity paired with its unit of measure, plus the * derived stock-equivalent quantity/UOM. `conversionFactor` is carried on the value so it * round-trips with the record even though it is never shown in the UI. * @public */ export interface QuantityValue { /** The entered quantity, in `uom` units */ qty: number; /** Unit of measure the user entered `qty` in */ uom: string; /** `qty` converted into `stockUom` units — `qty * conversionFactor` */ stockQty: number; /** The item's base/stock unit of measure — fixed, not user-editable */ stockUom: string; /** Multiplier from `uom` to `stockUom` — hidden from the UI, drives `stockQty` */ conversionFactor: number; } /** * Type-specific configuration for AQuantityInput, passed via the field's `options` property. * @public */ export interface QuantityOptions { /** Dropdown choices for the `uom` field */ uoms?: string[]; /** The item's base/stock unit of measure — fixed, not user-editable */ stockUom?: string; /** Conversion factor lookup for each non-stock UOM, relative to `stockUom` (which is implicitly `1`) */ conversionFactors?: Record; } /** * The value shape for ACurrencyInput — an amount paired with its currency (an * {@link AFormLinkValue} FK reference), plus the derived base-currency-equivalent amount. * `exchangeRate` is carried on the value so it round-trips with the record even though it is * never directly edited by the user. * @public */ export interface CurrencyValue { /** The entered amount, in `currency` units */ amount: number; /** FK reference to the Currency doctype the user entered `amount` in */ currency: AFormLinkValue; /** `amount` converted into `baseCurrency` units — `amount * exchangeRate` */ baseAmount: number; /** The record's base currency — fixed, not user-editable */ baseCurrency: AFormLinkValue; /** Multiplier from `currency` to `baseCurrency` — hidden from the UI, drives `baseAmount` */ exchangeRate: number; } /** * Type-specific configuration for ACurrencyInput, passed via the field's `options` property. * @public */ export interface CurrencyOptions { /** Currency doctype name, used for FK resolution via `aformLinkResolver`. The currency picker is embedded, so it renders no navigate button. */ doctype?: string; /** The record's base currency — fixed, not user-editable. A bare id resolves to displayText via `aformLinkResolver`. */ baseCurrency?: AFormLinkValue | string; /** Exchange rate lookup for each non-base currency id, relative to `baseCurrency` (which is implicitly `1`) */ exchangeRates?: Record; /** Decimal places to round the derived `baseAmount` to — the base currency's scale (JPY carries 0, most carry 2, KWD 3). Applies only to `baseAmount`; the entered `amount` is left as typed. Omit to round only enough to shed binary floating-point noise, which never discards a digit the rate actually produced. A non-integer or out-of-range value falls back to that default. */ precision?: number; /** Search function backing the `currency` autocomplete dropdown — see AFormLink's `filterFunction` */ filterFunction?: string | ((search: string) => AFormLinkValue[] | Promise); /** Whether `filterFunction` results should show a loading state — see AFormLink's `isAsync` */ isAsync?: boolean; } //# sourceMappingURL=index.d.ts.map