IRunnerProperties interface
đ Descriptionâ
Properties interface for constructing new Runner
instances.
đ Type declarationâ
interface IRunnerProperties { definition: IDefinition | string; mode: "paginated" | "continuous" | "progressive" | "ahead"; namespace?: string;Optional l10n?: L10n.Namespace;Optional start?: boolean;Optional preview?: boolean;Optional test?: boolean;Optional snapshot?: ISnapshot;Optional data?: (instance: Instance) => void;FunctionOptional }
đī¸ Propertiesâ
đˇī¸ definition
â
Specifies the form definition to load. You can either supply the form definition as an object or as a JSON string.
Typeâ
IDefinition
| string
When a string is supplied, JSON.parse
will be used to convert to an object.
đˇī¸ l10n
â
Specifies the l10n namespace to use. This namespace contains translation and locale information for the runner.
Typeâ
đˇī¸ mode
â
Specifies the mode of operation of the runner. It can be one of the following values:
paginated
: Render each section on a separate page (this is the default behavior);continuous
: Render all completed sections and the current section on a page;progressive
: Render all completed (past), current (present) and future sections on a page till the point where one of the sections fails validation;ahead
: Render all completed (past), current (present) and future sections on a page, regardless of the section's validation result.
Typeâ
"paginated" | "continuous" | "progressive" | "ahead"
đˇī¸ namespace
â
Specifies a namespace identifier for the runner. This is a unique identifier for the runner.
Typeâ
string
đˇī¸ preview
â
Specifies if the runner should run in preview mode. This is a special mode that allows the whole form to be shown by the runner UI (basically ignoring all branch conditions, so all branches are taken and shown). This is useful when building a live preview panel that is shown along with the builder.
Typeâ
boolean
When preview
is set to true
and the start
property is omitted, the runner will start immediately after construction.
đˇī¸ snapshot
â
Specifies the snapshot to restore. A snapshot is a saved state of a runner that can be restored later on. To obtain a snapshot you either pause the runner or use snapshot
.
Typeâ
đˇī¸ start
â
Specifies if the runner should immediately start a from instance after construction or that it should wait until an instance is manually started with the start
function.
Typeâ
boolean
đˇī¸ test
â
Specifies if the runner should run in test mode. This is a special mode that runs the whole form normally, but without invoking the data submission events when the form completes. This is useful in a live preview setup where users want to test a form, without generating response data.
Typeâ
boolean
When preview
is set to true
, this supersedes the test mode and the preview mode will be active.
âļī¸ Functionsâ
đ§ data
â
Specifies a function that can supply data to new form instances. This is useful for importing data into forms (prefilling forms). This function is invoked automatically when a form instance is started.
Signatureâ
(instance: Instance) => void
Parametersâ
Name | Type | Optional | Description |
---|---|---|---|
instance | Instance | No | Contains a reference to the form instance. |
Exampleâ
import { Runner, Import } from "@tripetto/runner";
const runner = new Runner({
definition: /* Supply your form definition here */,
mode: "paginated",
data: (instance) => {
// This example assumes the form has two text fields with
// the data identifiers (aliases) `FIRSTNAME` and `LASTNAME`.
Import.fields(instance, [
{
name: "FIRSTNAME",
value: "John",
},
{
name: "LASTNAME",
value: "Doe",
}
]);
// Or use the generated key of each field
Import.fields(instance, [
{
key: "9ef64ab160ef6096ceecb4561f3eecc37007b669337929393a9d3789fa744f3e",
value: "John",
},
{
key: "e14599867b9fd518459e7ecaf974d33f84f2c3b322f644e838f948c2136eec3a",
value: "Doe",
}
]);
}
});