CRUDUI

Home > @polyspec/crudui-generator-core > FormInstance

FormInstance class

One editable form instance over a shared template. All row operations are scoped to a collection path; no global string replacement touches siblings. Data, undo history and view state (collapsed rows) are separate; view state is never submitted.

Signature:

export declare class FormInstance 

Constructors

Constructor

Modifiers

Description

(constructor)(template, data, options)

Create an instance with independent record data.

Properties

Property

Modifiers

Type

Description

description

readonly

string

The template's root description translated for the instance language; empty text when none.

getSnapshot

() => FormSnapshot

Return the current subscription snapshot.

keyPrefix

readonly

string | undefined

Effective root prefix for submitted input names.

messages

readonly

FormMessages

Interface text for the instance language.

subscribe

(listener: () => void) => (() => void)

Subscribe to injection, editing, row operations and view changes. Returns an unsubscribe function.

template

readonly

FormTemplate

Shared immutable structure.

Methods

Method

Modifiers

Description

addRow(path, options)

Insert a blank/defaulted row, or supplied row data, with one new identity.

copyRow(path, key, options)

Copy current values and give every descendant repeated row a fresh key.

getData()

Detached submission data, retaining keyed nested collections.

getValue(path)

Read a detached value relative to the data root.

moveRow(path, key, toIndex)

Change order without changing row keys, values or descendant identities.

redo()

Reapply the most recently undone data change.

rekeyRow(path, oldKey, newKey)

Apply a saved seq key to exactly one row. Descendant paths and view state follow.

removeRow(path, key)

Remove one row unless the minimum count would be violated.

setAllExpanded(expanded)

Expand or collapse every collapsible row.

setData(data)

Replace the record after an asynchronous load or save; history and view state restart.

setValue(path, value)

Update one data path and reevaluate affected form presentation.

toggleRow(path, key)

Expand a collapsed row or collapse an expanded one.

undo()

Restore the record before the last data change.