Skip to content

toolmark-monorepo / @toolmark/core / FormAdapter

Interface: FormAdapter<V> ​

Defined in: packages/core/src/forms/types.ts:22

Bridges a form library to form tools (spec §8.1). Overwrite decisions, validation and undo live in the form-tool core, not the adapter.

Type Parameters ​

V ​

V extends Record<string, unknown> = Record<string, unknown>

Methods ​

dirtyPaths() ​

dirtyPaths(): string[]

Defined in: packages/core/src/forms/types.ts:35

Dot paths the user (or the agent) has changed since load. Returns LEAF paths only (never a parent object path): adapters must flatten nested dirty state.

Returns ​

string[]


fields() ​

fields(): FieldInfo[]

Defined in: packages/core/src/forms/types.ts:39

Known fields.

Returns ​

FieldInfo[]


getValues() ​

getValues(): V

Defined in: packages/core/src/forms/types.ts:24

Current values.

Returns ​

V


onUserInteraction()? ​

optional onUserInteraction(cb): () => void

Defined in: packages/core/src/forms/types.ts:50

Subscribes to user-originated interactions with the form (tour hooks, spec §13). Adapters call cb only for trusted user events (isTrusted, or the form library's own user-change signal), never for their own setValues/submit, and pass the field's dot path only, never its value. kind: 'submit' uses path: ''. Form tools subscribe once while registered and turn each call into an interaction event.

Parameters ​

cb ​

(e) => void

Receives { path, kind } per interaction: path is the field's dot path ('' for a whole-form submit); kind is input (the user changed a value), focus or submit.

Returns ​

An unsubscribe function.

() => void


setValues() ​

setValues(values, opts): void

Defined in: packages/core/src/forms/types.ts:30

Writes values by flat dot path; null clears a field.

Parameters ​

values ​

Record<string, unknown>

Flat { path: value } map.

opts ​

Who writes: the agent (fill) or an undo.

source ​

"agent" | "undo"

Returns ​

void


submit() ​

submit(): Promise<ToolResult<unknown>>

Defined in: packages/core/src/forms/types.ts:37

Submits the form.

Returns ​

Promise<ToolResult<unknown>>