A flow is a guided form: steps with typed fields, conditions, validation, a review page with change links, and one
proposal to the host when the reader submits. It is the CanopyX view for setup, connection, schedule and edit tasks.
CanopyX never writes: the flow collects the answers and raises canopyx:flowSubmit, and the host applies the change and
answers with what happened.
Information steps can carry up to 32 read-only facts, each with a plain label and value. In C#, add
new CanopyFlowFact(label, value) to an information step's Facts. The existing answer-list layout wraps the complete
value, up to 32,768 characters; facts do not become editable answers, dirty state or submission values.
The submit callback also receives detail.signal, cancelled when its operation retires through changed answers, reset,
destruction or settlement. Pass it to host transport where useful. It is not serialized with the submission, and cancelling
a browser operation cannot undo a write the server has already committed.
A flow is a document, like a grid view. C# writes it with CanopyFlow; the browser reads it with CanopyX.createFlow.
The document shape on this page is the flow contract. CanopyX owns it, and any host can map its own model onto it
(docs/schema/canopyx-flow-1.schema.json describes it as a JSON Schema).
The flow ships as the lazily loaded flow part with a slim entry point of its own (canopyx-flow-entry.js,
@evotecit/canopyx/flow). A page with only forms loads no grid code, and the flow entry point carries the
UI factories too, so menus, selects, toasts and dialogs beside a form need no other entry
point. Grid pages know the part too: CanopyX.createFlow
loads it on first use. Flows share their editors and validation with grid editing, the record drawer's edit form and the
calendar's event form through the forms part.
- Quick start
- The flow document
- Steps and sections
- Fields
- Conditions
- Validation
- Layouts
- The review page
- The proposal and the host's answer
- Secrets
- Host-connected flows: server checks, host options and dependent fields, records fields, pick steps, task lists, dialogs and drawers, the equivalent command, presets, drafts, deep links, the preview and consent on the review page
- An endpoint: MapCanopyFlow and reading a proposal on the server
- JavaScript API
- Labels and right to left
- Accessibility
- Packaging and size
var flow = new CanopyFlow("mail-server", "Connect a mail server") { Submit = new CanopyFlowSubmit("Save settings") };
flow.Step("server", "Which server sends the mail?", step => step
.Text("host", "Server name", f => f.Required().Help("A host name or an IP address, such as mail.example.com").Path("mail.host"))
.Number("port", "Port", f => f.Default(587).Range(1, 65535).Half().Path("mail.port"))
.Choice("security", "Connection security", f => f
.Option("starttls", "STARTTLS", "Upgrades a plain connection. Port 587 is usual.")
.Option("tls", "TLS from the start", "Port 465 is usual.")
.Option("none", "None", "Only inside a trusted network.")
.Default("starttls").Path("mail.security")));
flow.Step("sign-in", "How does it sign in?", step => step
.Text("user", "User name", f => f.Path("mail.user"))
.Secret("password", "Password", f => f.Path("mail.password"))
.Toggle("verify", "Check the server certificate", f => f.Default(true)
.When(CanopyFlowCondition.NotEqual("security", "none")).Path("mail.verifyCertificate")));
flow.Review(review => review.Declaration("The settings apply to new messages."));
File.WriteAllText("mail-server.html", flow.ToHtml(new CanopyHtmlOptions { Title = "Connect a mail server" }));The host answers the proposal in the page:
document.addEventListener("canopyx:flowSubmit", event => {
const { values, secrets } = event.detail; // never the password itself
const password = event.detail.secret("password"); // once, inside the handler
event.detail.respondWith(fetch("/api/mail", { method: "POST", body: JSON.stringify({ values, password }) })
.then(response => response.ok ? { status: "saved", message: "Mail settings saved." } : { status: "error", message: "Not saved." }));
});A JavaScript host builds the same flow from the document itself:
import { createFlow } from "@evotecit/canopyx/flow";
const flow = createFlow(document.getElementById("setup"), { flow: documentFromServer, onSubmit: detail => save(detail) });ToHtml and ToHtmlFragment can use CanopyHtmlOptions.CompressConfig to shrink a large embedded flow. The Flow
entry point reads it at mount, including when a deferred flow mounts for print. The ToContract JSON stays the same.
See compressed HTML configuration for hosts that read the script.
{
"kind": "flow", "version": 1, "id": "mail-server", "title": "Connect a mail server",
"mode": "linear", "layout": { "orientation": "auto" },
"steps": [
{ "id": "server", "title": "Which server sends the mail?", "fields": [
{ "id": "host", "type": "text", "label": "Server name", "required": true, "path": "mail.host" },
{ "id": "port", "type": "number", "label": "Port", "default": 587, "width": "half", "validation": { "min": 1, "max": 65535 } } ] },
{ "id": "review", "type": "review", "title": "Check your answers" }
],
"submit": { "label": "Save settings" }
}| Field | Meaning |
|---|---|
kind, version |
"flow" and 1. A reader rejects any other pair. |
id |
The flow's identifier: a letter, then up to 63 letters, digits, - and _. |
title, description |
The flow's heading and an optional line under it. Plain text. |
mode |
linear (default): a step opens when the steps before it are valid. free: any visible step opens at any time and the review page checks everything. tasks: a task list. |
layout |
{ "orientation": "auto" | "horizontal" | "vertical", "container": "inline" | "dialog" | "drawer", "launch", "launchTone", "hideLaunch", "stickyFooter", "hideSingleStepTitle" }. auto (default) uses the horizontal stepper for up to six visible steps whose titles fit the width, and the vertical one otherwise. Narrow hosts (below 640 px) stack the steps; a flow with one visible step shows no rail. container opens the flow in a dialog or drawer from a button labelled launch (default the title). Set launchTone to danger for a destructive action. See Layouts for the footer and single-step heading options. |
density |
compact, normal (default) or comfortable, as the grid densities. |
timeZone |
utc (default) or local: the zone date-and-time fields show and enter. |
steps |
1 to 64 steps. A review step, when present, is the last. |
initial |
Edit mode: the values the flow edits, by field id (see Edit mode). |
held |
Edit mode: ids of the fields whose initial value is held, outside the value limits (see stored values outside the limits). The C# writer lists exactly those fields. |
storedSecrets |
Edit mode: ids of secret fields that already have a stored value. Never the values. |
baseline |
Edit mode: the host's revision of the edited settings, echoed in the proposal. |
hideOptionalMarks |
true hides the optional field mark. Required checks and optional steps retain their behavior. Default false. |
submit |
{ "label", "tone" }. The label defaults to "Submit". Set tone to danger for a destructive action. Both button tones default to primary. |
labels |
Translations of the texts the flow writes itself (flow… and the shared gridEdit… messages). |
command |
{ "name", "style", "variants" }: the equivalent command the review page shows. |
presets |
Up to 32 presets: { "id", "label", "description", "values" }. |
draft |
none (default), session, local or host: where the draft lives. |
deepLinks |
true: the page's address names the open step (deep links). |
endpoint |
{ "url", "routes" }: routes that answer the hooks (an endpoint). |
Every text in the document is plain text; nothing is read as HTML.
{ "id": "tls", "title": "Certificate checks", "description": "Shown only with a secure connection.",
"when": { "operator": "and", "filters": [{ "field": "security", "operator": "ne", "values": ["none"] }] },
"sections": [{ "id": "client", "label": "Client certificate", "fields": [ … ] }] }| Step field | Meaning |
|---|---|
id, title |
Required. Titles are questions or nouns ("Which server sends the mail?"), never "Step 3". |
description |
A line under the title. |
type |
form (default), info (text only), pick (a pick step) or review (the review page). |
fields, sections |
The step's fields, then its sections. A section has id, label, optional description, fields and when, and uses the record panel's label/value layout. A section with "source": "host" takes its fields from the host (host sections). |
checks |
Form steps: up to 8 server checks. |
group |
Task lists: the heading the task sits under. |
pick |
Pick steps: the picker. |
when |
A condition: the step shows only while it holds. |
optional |
The rail marks the step optional. Its fields still follow their own required. |
declaration, changesOnly |
Review steps only: text above the submit button, and whether edit mode shows only changed answers first (default true). |
confirm, acknowledge |
Review steps only: typed confirmation and an acknowledgement. |
preview |
Review steps only: true says the page shows the host's preview (C# review.ShowsPreview()). |
Branching is ordered steps with conditions, not jumps. A hidden step or field keeps its answer while the reader goes back and forth, and is left out of the proposal. The rail shows only visible steps, so "Step 3 of 5" stays true.
Every field has id (unique in the flow), type and label, and optionally:
| Field | Meaning |
|---|---|
help |
A line under the label, before the input. |
placeholder |
The empty input's hint (text, number, lookup, text area, list), drawn fainter and in italics. Keep it a short hint about the expected format, such as "For example: name@example.com"; a sample answer belongs in help. |
required |
An empty answer is an error. Optional fields say "(optional)" in their label; nothing gets an asterisk. |
default |
The starting value in create mode. |
readOnly |
Shown, not changed. |
when |
A condition for the field. |
width |
full (default) or half: two half fields share a row on wide forms. |
parameter |
The parameter name in the equivalent command. |
path |
The setting the field writes, as dot-separated names (mail.smtp.host): the JSON patch of the proposal uses it. |
sensitive |
A non-secret value the host keeps out of drafts and exports. It still shows on the review page. |
validation |
The checks below. |
source, dependsOn |
"source": "host" loads the options of a select, choice, multiple-choice or lookup field from the host; dependsOn names up to 16 fields whose change reloads them, or empties a field without host options (host options). |
type |
Value | Notes |
|---|---|---|
text |
string | Grid editor. validation: minLength, maxLength, pattern, message, and format (an IP or MAC address, a GUID, a phone number, a date or time as text, …); mask: a hint of the shape such as AAA-0000. See input formats. |
number |
number | Grid editor: reads numbers as the page language writes them. step; validation: min, max. |
date |
yyyy-MM-dd |
Grid editor. |
datetime |
ISO 8601 UTC | Grid editor, in the flow's time zone. validation: min, max as ISO moments. |
time |
HH:mm |
Grid editor. |
select |
option value | Grid editor: a drop-down for short lists. |
toggle |
boolean | Grid editor, drawn as a switch. onText, offText name the two states on the review page. |
lookup |
option value | Grid combobox: suggestions from options (at least one) as the reader types. |
choice |
option value | A radio group, or choice cards with a title, description, badge and disabled reason. display: cards or list; cards by default up to five options. |
multiChoice |
array of option values | Check boxes with "Select all", "Clear" and a "3 of 12 selected" count. validation: minItems, maxItems. Options may name a group. |
textarea |
string | rows (2 to 20, default 4). Same text checks as text. |
list |
array of strings | One value per row with Add and Remove; pasted lines become rows. validation: minItems, maxItems (at most 1,000), item (email, host, ip, cidr, url), itemPattern. |
secret |
never in values | A masked input with a reveal button (reveal: false leaves it out). keepWhenBlank (default true when storedSecrets lists it); clearable lets the reader clear a stored value; validation: minLength, maxLength, pattern. See Secrets. |
signature |
{ svg, png } |
A pad to draw on, or a typed name; Undo and Clear. No default or parameter. See signatures. |
rating |
whole number, 1 to scale |
Stars over native radio buttons. scale: 2 to 10 stars (default 5). An optional rating clears when the reader chooses its value again or presses Delete; the review page says "4 of 5" (flowRatingValue). C#: step.Rating(id, label, f => f.Scale(4)). |
duration |
ISO 8601 duration (PT15M, PT1.5S) |
A number and a unit. units: some of seconds, minutes, hours, days (default minutes, hours, days); validation: min, max as durations. Seconds take up to seven decimal places, so a stored TimeSpan such as 00:00:01.5 is PT1.5S and comes back unchanged; a starting value that needs seconds adds them to the units. CanopyFlowDurations.Format and TryParse convert between TimeSpan and the wire form (TryParse also reads 00:00:01.5). |
records |
array of rows | A small table of typed rows with Add and Remove (records fields). columns; validation: minItems, maxItems. |
custom |
the editor's | editor names an editor a plugin or the host registers (editors, as in grid editing). |
Options are { "value", "label", "description", "badge", "disabledReason", "group" }, where value is a string, number or
boolean and only value is required; a field takes at most 1,000. Labels, titles and option labels hold up to 200 characters and
help, descriptions and declarations up to 1,000; the layout keeps a few texts shorter: a badge up to 40 characters, a
disabled reason up to 400, onText and offText up to 60 and the submit label up to 80.
A flow that edits existing settings carries their current values in initial (and storedSecrets, baseline). The
fields start from those values, the review page shows what changed as "was / now" and, by default, only the changes, and
the proposal carries the changes and a JSON patch. In create mode fields start from their default.
An empty initial: {} also selects edit mode, for example when only stored secrets are being edited. In C#, set
IsEditMode = true to write that empty baseline; adding values to Initial also selects edit mode. Optional collection
answers can be null or an empty array, both of which count as empty during validation.
Stored secrets or a baseline revision also select edit mode. Missing edit-mode fields start empty; create-mode defaults
do not become changes to existing settings. A host can supply explicit starting answers through values.
Settings saved by another tool, or before a field's limits changed, can hold a value the field would not accept now: a
number above max, a text longer than maxLength, a duration outside its range, a records row whose cell breaks its
column's checks. Such a value still has to fit the field's type (a number for a number field, an ISO duration for a duration);
a value of the wrong type is refused as before.
A value of the right type that breaks the limits is held: the field shows it read-only with a note that names the problem
("This saved value is outside the field's limits, so it is kept as it is. Retries must be at most 10.", flowHeld) and a
Change value button (flowHeldChange). The rest of the form works as usual, and the step counts as complete. While the answer
is still the stored value, the field's own checks do not count against it, so the reader can save their other changes and
the value stays exactly as stored. Once the reader chooses Change value and edits it, the answer is checked as usual.
CanopyFlowSubmission.Parse applies the same rule on the server: an answer equal to its initial value is not checked against
the limits it already broke, and every other answer is checked as before. Option availability and host validators still apply.
Some stored values break the value rules themselves, not just the field's limits. These are held the same way, so a page
that loads settings from its own store renders instead of failing, in C# (ToContract, ToHtml, ToHtmlFragment) and
in the browser:
| Stored value | Note |
|---|---|
A select, choice or lookup value that is not one of the document's options ("none", 0) |
"Choose Mode from the list." The select shows the stored value as its own entry; Change value lets the reader pick an option. |
A list of more than 1,000 items, or with null items |
"Hosts allows at most 1000." or "Hosts does not have the expected format." |
| A nested records list above its column limit, or more than 20,000 nested items in one field | The parent row and the column limit ("Row 2: Permissions allows at most 100."), or the field's limit. |
A records cell of those kinds, or a text or list cell item over 4,096 characters |
The row and column, as for any cell ("Row 2: Notes allows at most 4096 characters."). |
The document writes such a value as stored and lists its field in held; the browser accepts one only for a field held
lists, and held naming a field whose value fits is an error. Submitting it unchanged gives back the stored value, and
CanopyFlowSubmission.Parse and the hook requests accept it while it equals initial. A changed answer must fit the value
rules as before, so a reader can never enter such a value. Still refused, in C# and in the browser: a value of the wrong
type, a held list or nested records cell of more than 10,000 items, more than 100,000 nested items in one field, more than 1,000 top-level records rows, a records cell of the wrong type, and choices of
a field whose options the host loads (those fit by shape). Multiple-choice values outside the options are refused as before.
CanopyX limits Flow JSON documents and requests to 4 MiB of text. A document with held values must fit this limit when
written. HTTP endpoints also enforce their configured request body size.
Conditions are data, never script. They use the filter builder's grammar (the same groups and operators as grid filter
groups and formatting conditions), with field naming a field where a grid names a
column:
{ "operator": "and" | "or" | "none", "filters": [{ "field": "port", "operator": "gt", "values": [1024] }], "groups": [ … ] }| Operators | Values |
|---|---|
eq, ne, gt, ge, lt, le |
one |
contains, notContains, startsWith, endsWith |
one |
matches, notMatches |
one bounded pattern, as in formatting |
in, notIn |
1 to 1,000 |
between (inclusive) |
two, lower first |
isNull, isNotNull |
none |
Text compares without case, with the search folding, and orders by UTF-16 code units after folding; numbers compare as
numbers and booleans only with eq and ne. Values never convert: a number compared with text is not equal to it (ne
and notIn are true, the other operators false). A field that is hidden reads as empty, so a condition never depends on an
answer the proposal leaves out. An empty answer (missing, null, empty text or no items) matches only isNull, as in grid
filters: every other operator, ne, notIn, notContains and notMatches included, is false for it. For array values
(multiChoice, list) contains and notContains test one item, in and notIn test whether any item is listed, and
the comparison operators (eq to le, between, startsWith, endsWith, matches) are false. Patterns test the first
4,096 UTF-16 code units without case. A condition never reads a secret field. A condition holds at most eight levels, 64 groups
and 64 predicates. C# evaluates the same conditions (CanopyFlowCondition.Evaluate), and the shared fixtures in
tests/fixtures/flow-conditions.json prove that both agree.
| Level | What runs | When |
|---|---|---|
| Field | Type, required, the field's validation, then the host's validators[field](value, values) |
When the reader leaves a field, and as the reader types or chooses once the field shows a problem |
| Step | Every visible field of the step, then the host's validateStep(stepId, values) |
On Next, and when Review opens the step |
| Flow | Every visible step, then the host's validateFlow(values) |
On the review page and on submit |
Validators answer a message, null, or a promise of one. validateStep and validateFlow answer null, a message, or
{ errors: [], warnings: [], fieldErrors: { field: message } }. Errors block Next and submit; warnings show on the review
page. Messages sit under their field (aria-describedby), and a summary at the top of the step links to each one. Field
messages use the grid's editing labels (gridEditRequired, gridEditMin, …) with the field's label as {column}.
- Horizontal stepper: numbered markers with titles in a rail above the form. Only the current step uses the accent; complete steps carry a quiet check; steps with errors carry a count.
- Vertical stepper: the rail on the inline start side with titles and state text, for long flows.
- Narrow hosts (below 640 px): the steps stack as an accordion and the current step opens under its title.
- One step: a single visible step has no rail. Set
CanopyFlow.HideSingleStepTitle = true(layout.hideSingleStepTitle) when the flow declares just one step and the flow title already introduces it. The heading still names the region and receives focus on navigation.
The form column caps at a readable width; half fields pair up on wide forms. The action bar keeps Back on the start side
and Next or the submit button on the end side, mirrored in right-to-left pages. The bar sticks to the bottom of the
scrolling area by default. Set CanopyFlow.StickyFooter = false (layout.stickyFooter) to place it after the fields so it
scrolls with the form. Stacked steps already place it after the fields. Keyboard focus scrolls clear of a sticky footer.
- One summary list per visible step, with the label, the displayed answer and a Change button whose accessible name says what it changes ("Change Server name"). Change opens the step; Next on it returns to the review page.
- Skipped optional answers read "Not provided". Secrets read "Set", "Unchanged" or "Not set".
- A banner says "Ready to submit" or how many errors and warnings there are, with links to the steps.
- In edit mode, changed answers show what they were. Records show which rows and column values changed, including nested rows. "Show changes only" (on by default) hides unchanged answers.
- The declaration sits above the submit button.
On submit the flow validates everything and raises canopyx:flowSubmit (cancelable) with a flowSubmission:
{ "kind": "flowSubmission", "flow": "mail-server", "version": 1, "mode": "edit", "baseline": "rev-12",
"values": { "host": "smtp.example.com", "port": 587, "security": "starttls", "verify": true },
"secrets": { "password": { "state": "keep" } },
"changes": [{ "field": "host", "path": "mail.host", "from": "old.example.com", "to": "smtp.example.com" }],
"patch": [{ "op": "replace", "path": "/mail/host", "value": "smtp.example.com" }] }valuesholds the visible answers only; hidden steps and fields are left out. Secrets are never in it.secretsholds each visible secret field's state:set(a new value was typed) orkeep(left blank, a stored value stays). An optional secret left blank without a stored value is left out.changes(edit mode) lists each visible field whose answer differs frominitial.patchis a JSON Patch built from fieldpaths:add,replaceandremoveusing the field baseline in edit mode,addfor every answered field in create mode. Secret fields never appear in it.
The host applies patch to its configuration object. Every parent object in a path must already exist, as JSON Patch
requires: an add at /mail/host works against { "mail": {} }, but not against {}. In create mode, and when enabling
a new settings section in edit mode, the host prepares the required containers before applying the proposal. CanopyX
does not add parent objects: replacing one could discard settings that the flow does not describe. The host also checks
the baseline and authorizes the write before applying any operation.
The detail also has respondWith(answer) and secret(id). The host answers with an object, or a promise of one, through
respondWith, the onSubmit callback's return value, or hooks.submit:
{ "status": "saved" | "accepted" | "error" | "conflict", "message": "…",
"fieldErrors": { "host": "Not reachable from the service." }, "stepErrors": { "server": "…" },
"result": [{ "label": "Key", "value": "…", "once": true }], "links": [{ "label": "Open the dashboard", "href": "/admin" }] }| Status | What the flow shows |
|---|---|
saved |
The result panel: the message, result rows and links, and "Start another". Rows marked once get Copy and "I have saved it"; Start another stays disabled until each is acknowledged, and they leave the page with the panel. |
accepted |
The host started longer work: a progress panel with the message. The host updates it with setProgress({ done, total, message }) and finishes with complete(answer). |
error |
Back to the review page with the message and the field and step errors in place. |
conflict |
Back to the review page with the conflict message and "Reload current settings", which raises canopyx:flowReload with { baseline }. |
Without any answer the flow returns to the review page and says that no host received the answers. Links use http,
https, mailto or relative addresses; others are dropped.
Call await api.proposal() to pass unsaved settings to a readiness check. It returns the same FlowSubmitDetail that
submit() would send for those answers. A host can use proposal.values, proposal.patch and proposal.signal to
check an external service before the reader submits.
The call uses submit's validation rules, including required check results, task states and review consent. A
readiness check that calls proposal() from its own check hook must be optional and independent of review consent.
A check required by the step or named by applicable consent needs a current result before the proposal is available.
A proposal resolves to null when validation fails, the flow is busy or showing a result or progress panel, or the
request is retired before it completes. If a visible host section's field definitions have yet to load, visit that step
to load them before calling proposal(). It runs the configured validation hooks and leaves field errors, completion,
navigation, focus, the saved draft and panels as they are. Use validate() or submit() when the reader should see
validation messages.
Pass { steps: ["settings"] } to read only some steps: their visible answers are validated and read, and the rest of the
flow is left out, so a required answer on a later step doesn't stop the read. Such a proposal skips the flow's
validateFlow hook, consent, task states, the preset, the checks and the equivalent command. It is also available while
Next or submit waits for a check, so a check on a later step can read the earlier answers it tests. Name only steps without
checks that wait for the reading check, or the two wait on each other.
proposal() emits no submit events and calls no submit handlers. If you pass an answer or promise to its respondWith,
settlement only releases that proposal. Call proposal.respondWith({ status: "accepted" }) when your check finishes
to release the proposal regardless of the check's outcome.
CanopyX holds secrets in the inputs and provides one read per visible secret through detail.secret(id) when submitting
or inspecting a draft proposal. A check can read only the secrets it names. Secret values stay out of values,
getValues(), getState(), the review page, the patch, serialized events and the DOM outside the input. The input uses
type="password" and autocomplete="new-password". The reveal button switches it to text until the step changes.
The button reads Show or Hide on screen. Its accessible name includes the field label and the enclosing section label,
or the step title for an unsectioned field in a multi-step flow. Customize the names with flowSecretReveal and
flowSecretConceal ({action} is the visible button text and {field} is the field label). flowSecretContext
combines that {name} with the section or step {context}.
A submission's accessor closes when its answer settles or the submission is retired. A draft proposal's accessor closes
at the earliest of settlement through respondWith, the configured timeout (30 seconds by default, measured from
the start of proposal()), a new proposal, submission, a change to the answers or required check evidence, reset or
destruction. Closing clears unread values and aborts the proposal's signal. Further reads return null. A value already
read belongs to the caller.
With keepWhenBlank (the default for a field listed in storedSecrets) the input starts empty with the hint "A value is
saved. Leave blank to keep it.", and a blank answer is keep. A required secret without a stored value must be typed.
An optional stored secret marked clearable (C# IsClearable) has a "Clear the saved value" button beside the input. Once
pressed, the input empties and locks, the hint says the saved value is removed on submit, the button reads "Keep the saved
value" and undoes it, the review page says "Cleared", and the proposal says { "state": "clear" }. Clearing counts as a
change for isDirty() and the review. canopyx:flowValueChanged for a secret carries state (set, keep, clear or
null), never the value, so a host can follow what the submission will say. CanopyFlowSubmission.Parse accepts clear
only for a clearable field listed in storedSecrets.
The flows above run on the document alone. A flow can also ask its host while the reader works: run a check, load options
or fields, list task states, preview what submitting does, keep a draft. Each is a hook of createFlow's hooks (or
CanopyX.configure), or a route of an endpoint that answers them without script. Every
asynchronous hook receives an AbortSignal that a newer request, Cancel, destroy() or the timeout aborts; the timeout is
the timeout option (30 seconds by default, 100 ms to 10 minutes). A late answer to an aborted request is dropped, and a
hook that throws, rejects or times out fails in place with its message and an error event.
flow.Step("sign-in", "How does it sign in?", step => step
.Text("user", "User name", f => f.Required().Path("mail.user"))
.Secret("password", "Password", f => f.Required())
.Check("sign-in-test", "Test sign-in", check => {
check.Heading = "Connection details";
check.Field("host").Field("user").Field("password").RequirePass();
}));"checks": [{ "id": "sign-in-test", "label": "Test sign-in", "heading": "Connection details", "fields": ["host", "user", "password"], "required": "pass" }]A check is a named host action on a form step, such as "Send a test message" or "Test sign-in". Its button runs
hooks.check(checkId, values, { signal, secret }), which answers { status: "pass" | "warning" | "fail", message, details: [{ label, value, tone?, was? }], fieldErrors }. The step shows running (with Cancel), passed, warning or failed with the time, the message
and the details. Field messages show beside their fields. Set heading (C# Heading, up to 200 characters) to name the
section on both the form and review. It defaults to the localized “Checks”. Adjacent checks with the same heading share a section.
List up to 64 field IDs in fields (C# FieldIds). Changing a named answer, an answer that controls its visibility, or a
controller of the check step's visibility marks the result stale and cancels a running check. A check with omitted or
empty fields has no field dependencies. Its result survives unrelated edits. It stales when a controller of its step's
visibility changes or the host calls invalidateChecks. A required check applies when its step and at least one named field
are visible. A check with no fields applies whenever its step is visible.
Each detail has a text label and a current value. The optional was adds the previous value, using the same “Was” line
and emphasis as changed answers. Both values can be text, a number or a boolean in JavaScript. The browser displays
them as text. An optional tone of info, success, warning or danger adds a localized status label and colour.
For example, a C# check can add .Detail("Port", "587", Tone.Warning, was: "25"). A result can carry at most 200 rows.
The form and review show 25 at a time with a range, a total and buttons to reach every row. The review uses the full
content width. A result over 200 rows fails with its count and the limit. Summarize larger results in the host before replying.
required |
Next on the step |
|---|---|
| (none) | Never waits for the check. |
run |
Runs the check when it has no current result, then needs it not to have failed; a warning needs "Continue despite the warning" ticked. |
pass |
Runs the check when it has no current result, then needs a pass. |
A check can list only secret fields. Changing a named secret marks the check stale even when the field stays filled.
secret(id) reads a visible, newly typed secret once per run, only for a named field, and returns null when that field
has no new value. An endpoint accepts only named, visible secrets and exposes them through request.ReadSecret(id).
Stored secrets stay with the host. Return display-safe messages, detail rows and field errors. Keep secret values out of those results and
out of host errors and logs. Drafts, events and the check dependency tracking carry no secret values.
The review page shows the current result and its detail rows with Run again. A stale result is marked on review, and the
previous details remain on the form step. The page revalidates when a check finishes. The proposal's checks carries
{ status, at } for current results, plus a revision for checks named by review consent. The host must verify any check it
relies on before applying the submission. api.runCheck(id) runs a check from script. canopyx:flowCheck and
onCheck report the completed display result.
A host whose tested settings also change outside the flow calls api.invalidateChecks(["sign-in-test"]), or
api.invalidateChecks() for every check. Completed results are marked stale. Matching running checks are cancelled,
their secrets are revoked, and late answers cannot replace a newer result. Pending validation, draft proposals and
submissions that relied on the invalidated evidence are retired too, including their secret readers. Field values and the
form's dirty state stay unchanged. Required checks need a current result at the next validation or submission. An empty
array does nothing; unknown ids are rejected before any check changes. Await api.ready first, as for other synchronous
members. Flows with no checks do not load the checks part and reject this operation.
.Select("region", "Data centre", f => f.Option("eu", "Europe").Option("us", "United States"))
.Select("relay", "Relay", f => f.FromHost().DependsOn("region"))A field with "source": "host" asks hooks.options(fieldId, values, { signal }) for its options as the reader reaches it,
and again when a field in dependsOn changes. The field says "Loading options…" meanwhile; a failure says why, with Try
again. An answer the new options still allow (and do not disable) is kept; any other is cleared. A field with dependsOn
but document options starts empty again when what it depends on changes. api.refreshOptions(id) loads again from script.
Conditions and dependencies never read secrets, and dependencies never run in a circle.
.Section("engine-options", "Engine options", section => section.FromHost().DependsOn("engine"))A section with "source": "host" has no fields of its own: hooks.fields(sectionId, values, { signal }) answers up to 64
field definitions as the step opens, and again when a field in dependsOn changes. They are read as strictly as the
document's, of the plain types (text, number, date, date-and-time, time, select, toggle, lookup, choice, multiple choice,
text area, list, duration), without path, parameter, source or dependsOn; their conditions may read the flow's own fields. Their
answers join the proposal like any other, and the server checks them against the same definitions
(reading a proposal).
.Records("rules", "Routing rules", f => f
.Column("severity", "Severity", CanopyFlowRecordColumnKind.Select, c => c.Option("error", "Errors").Option("info", "Information").Required())
.Column("address", "Send to", CanopyFlowRecordColumnKind.Text, c => c.Required())
.Column("quiet", "Quiet hours", CanopyFlowRecordColumnKind.Toggle)
.Count(null, 10).Path("mail.rules"))A records field is a small table: up to 16 typed table columns (and up to 32 detail columns besides them) and up to 1,000 rows, each { column: value }, with Add row and a
Remove button per row. Each cell uses the shared editor of its type, labelled "Severity, row 2". Columns take required,
options (select), width, detail, key and validation (min, max for number and byte-size columns, minLength,
maxLength, pattern for text columns, and message). The field takes minItems and maxItems. An invalid cell carries
its row's message. Next focuses that cell, or its row's Edit button for a detail. Opening Edit takes focus to the invalid
detail or to the affected nested row's Edit button. A row-count error belongs to the records field. Records answers have
no command-line form.
Column type |
Cell value | Editor |
|---|---|---|
text (default), number, date, time, select, toggle |
as the field type of the same name | The shared editor of that type. |
list (CanopyFlowRecordColumnKind.List) |
array of strings | A text box with one item per line; blank lines are dropped, and no items is an empty cell. At most 1,000 items of 4,096 characters. |
duration (Duration) |
ISO 8601 duration (PT15M, PT1.5S) |
The duration field's number and unit, offering seconds to days; seconds take decimals. |
records (Records) |
ordered array of objects keyed by sub-column id | A nested table in the row’s Edit dialog. |
byteSize (ByteSize) |
whole number of bytes, 0 or more | A number and a unit: B, KB, MB, GB or TB. The units are binary: 1 KB is 1,024 bytes, 1 MB is 1,024 KB, and so on. A stored size shows in the largest unit that holds it in at most two decimals (1,572,864 is 1.5 MB); min and max are in bytes. |
An untouched toggle cell with no starting value stays unset. Required toggle cells accept both checked and unchecked values.
A step with a visible records field uses the available form width. A column's width (Width in C#) sets a minimum in
pixels, from 60 to 480. The table scrolls sideways inside the field, including on phones. When a row has more fields
than fit across, mark the columns that do not need to be scanned as detail: true (column.Detail() in C#): they leave the
table, and each row gets an Edit button that opens a dialog with every field of that row under its label. The key value
titles the dialog when present. Otherwise the dialog uses the row number. Done (or Enter in a one-line box) keeps the
changes. Cancel and Escape ask before dropping changes and close an unchanged dialog directly. Focus returns to Edit
when the dialog closes. An invalid edit or missing required detail keeps the dialog open and focuses the field with the
error. At least one column stays in the table. Detail
columns do not count against the 16 table columns; a field takes up to 32 of them.
Untouched list, duration and byte-size cells keep their stored values. A byte-size edit must convert to a whole number of bytes.
Use a secret column for credentials that belong to a row, including detail columns and columns in a nested list.
It takes required, reveal, keepWhenBlank and the same length and pattern rules as a secret field. The table shows
the secret's status and the row editor offers keep, replacement and (when optional) clear. A secret column cannot be
a key. Its cells have no input value in the ordinary record and cannot be sorted, filtered, copied or pasted as table data.
Put stored markers in storedRecordSecrets. Each marker names the records field, a row and the secret column.
For a sub-record, the marker also has a parent with the outer row and the nested records column.
Each row address is { "key": <original scalar> } when its list declares a key, or { "index": <zero-based baseline position> }
otherwise. The address must resolve to a row in initial. The document contains only the markers and ordinary cells.
A proposal carries recordRows for each visible records field with secrets. An array follows the current order of
that field's rows. Each entry has from for a surviving row's baseline address. New rows omit from. The optional
children object maps a nested records column to an array of the same shape, relative to that parent's original row.
Moves and key edits carry the original address. Newly added rows have no original address, even when their cells match
a baseline row. A row deleted from the answer has no current position. Where a key is declared, both lists must have
unique, nonblank keys at submission. Whitespace and a byte-order mark alone do not count as a key.
Each original address may be used only once per list. Duration keys compare by duration on both sides. The server
exposes those original keys in canonical ISO 8601 form.
Secret states share the proposal's secrets object. A cell's id is field/index/column, or
field/parentIndex/recordsColumn/index/column for a sub-record, with zero-based current positions.
An optional empty cell has no state unless it clears a stored value. Only set has a value to read through
secret(id) or ReadSecret(id). Check hooks get the row mapping and can read newly typed secrets only for visible
records fields the check names. Check hooks also receive recordSecretStates and the baseline when they name those fields.
The endpoint shares that metadata and carries typed values in the separate secrets object. Its handler gets the
validated addresses and states through request.RecordSecrets, including kept values that stay with the host.
The server validates the current row, original address, column, visibility, state and value against its own flow and
baseline. Use the validated record secret targets with the ordinary patch. A keep takes the stored value from its
original address before applying any row changes. A set writes the supplied value to the current row and a clear
leaves the target empty. Removed rows bring no secrets forward. Apply both together against the same baseline, with
the same authorization the host uses for changing the records. The browser's row mapping describes the requested
edit, so the host still authorizes the affected source and destination rows before it commits.
Plaintext travels only through the short-lived secret readers and their check or submit transport. It stays out of initial values, drafts, presets, ordinary values and patches, commands, review and print. Closing a row editor clears its input, and cancelling discards its pending edits. The review names credentials removed with their rows. The server leaves secret values out of its errors. The browser suppresses echoed record secrets in submit answers, progress and completion.
A replacement supplied through a preset or through setValues or setState creates new rows when the ordinary
answer changes. Use the row editors to retain the original addresses while editing. A reset restores the baseline rows.
Drafts can restore original addresses when the document has the same nonempty baseline. A draft without a matching
baseline skips records fields with stored secrets, and typed or cleared secrets always need to be entered again.
In C#, add a marker with
flow.StoredRecordSecrets.Add(new("shares", CanopyFlowRecordRow.ByKey("Reports"), "password")).
Use CanopyFlowRecordRow.AtIndex(0) for an unkeyed list. Read each validated target in submission.RecordSecrets
and take a replacement once with submission.ReadSecret(target.Id).
Set key: true (IsKey = true in C#) on at most one scalar column per list, including each nested list.
Review matches rows by exact typed key value when all keys are nonblank and unique in each version of that list. It
matches by position if there is no key or either version has a missing, blank or duplicate key. Changing a unique key
appears as a removal and an addition. Keyed rows report moves when their positions and their order relative to other
retained rows change. Positional matching shows edits at each position, with additions or removals at the end.
Review shows the changed columns with their previous and current values and reports added, removed and moved rows. It shows up to 40 row and column entries per records field, including nested lists, and reports how many other rows or columns it omitted. Long values end in an ellipsis. When two stored values display alike, the review still marks the cell as changed. Secret fields show only their state.
A records column must be a detail (IsDetail = true or detail: true). The main table shows its row count beside Edit.
In the row dialog, the nested table shows items in stored order. Content and declared widths size its columns.
Long headers wrap between words. When the table is wider than the dialog, its own region scrolls sideways and
brings focused row actions into view. Add row or Edit opens a dialog for one item. Remove and the
up and down buttons change the order directly. Done in the parent dialog applies those changes. Cancel or Escape asks
before discarding changes in the current dialog.
.Records("shares", "Share pairs", f => f
.Column("share", "Share", configure: c => c.IsKey = true)
.Column("permissions", "Folder permissions", CanopyFlowRecordColumnKind.Records, c => {
c.IsDetail = true;
c.MaxItems = 100;
c.Columns.Add(new("identity", "Identity") { IsRequired = true, IsKey = true });
c.Columns.Add(new("rights", "Rights"));
c.Columns.Add(new CanopyFlowRecordColumn("type", "Type", CanopyFlowRecordColumnKind.Select)
.Option("allow", "Allow").Option("deny", "Deny"));
})
.Path("folders.shares"))Each nested column defines 1 to 16 scalar sub-columns in columns (Columns in C#). They use the existing column kinds and
checks, including required cells, select options and the 4,096-character text limit. Sub-columns cannot be details or
contain records of their own. The column's maxItems (MaxItems in C#) accepts 1 to 1,000 and defaults to 100. A required
records cell needs at least one item. One answer holds at most 20,000 nested items across all of its rows, in the browser and
on the server. Stored values above a column's limit or this total follow the held-value rules.
The same array travels in each row of the field's value, including in the submission's values, changes and patch.
The nested table has no sorting, filtering or export.
[{ "share": "Reports", "permissions": [{ "identity": "Finance", "rights": "Read", "type": "allow" }] }]flow.Pick("servers", "Which servers?", servers, picker => {
picker.LabelColumn("name");
picker.Field.Count(1, 20).Required();
});A pick step embeds an ordinary grid or tree view: its search, facets, filters, saved views and record drawer all work.
The selection is the answer of the step's one field: the picked records as [{ id, label }], where label is the text of
the label column when the record was picked, so the review page and the proposal can list them without the view. A tray
beside the view lists what is chosen, with Remove buttons and Clear; it survives searches and paging (tray: false leaves
it out). minItems and maxItems count the picks; maxItems: 1 picks one record. Conditions read the picked ids.
Picked record ids are at most 256 characters; the display label snapshot is limited to 400 characters.
"Select all matching" names a query rather than records, so a pick step returns to the records it can list. A host gives
the view options of its own (a remote source, for example) with hooks.pickers[stepId].
A flat grid in a pick step can use toolbarMode to collect its tools in one menu and
reporting.responsiveDisclosure: "compact" to put hidden-column details beside the last visible value.
The pick tray and its selection rules still apply.
A pick step needs grids and trees: C# writes a flow with one for the reporting entry point, whose grids pick with row
check boxes; on a grid page CanopyX.createFlow uses the page's entry point. The flow entry point carries no grid code and
refuses a pick step.
var flow = new CanopyFlow("service-setup", "Set up the reporting service") { Mode = CanopyFlowMode.Tasks };
flow.Step("database", "Connect the database", step => step.Group("Connect") /* fields */);"mode": "tasks" opens the flow on a hub: its visible steps as task rows under their group headings, each a button with
its state in words ("Not started", "Complete", "Needs action", "Cannot start yet", "Optional"), the host's one-line summary
and its blockers, under "2 of 4 tasks complete". A task opens as a step; Save and return validates it and comes back, with
focus on the task's row. The host sets states through hooks.status(values, { signal }), which answers
{ stepId: { state, summary, blockers } } as the hub opens and after answers change, or api.setStepState(id, state).
A blocked task does not open. Review and submit opens once every required task (not optional) is complete.
"layout": { "container": "dialog" } (or "drawer") puts a launch button in the host; it opens the flow as a modal
dialog, centred, or along the inline end for a drawer, full screen on phones. Focus stays inside and returns to the launch
button when it closes. Escape, the close button and Cancel ask "Discard your answers?" in place when answers changed: the
host hears the cancelable canopyx:flowLeaving (or onLeaving returning false) first. A flow that saved starts afresh the
next time it opens. api.open() and api.close() drive it from script.
Set flow.HideLaunch = true (layout.hideLaunch) when the host provides its own launch control. Call
api.open({ returnFocus: button }) to return focus to that control on close, even when a pointer press leaves focus elsewhere.
Without that option, a flow with its own launcher returns focus to the launcher. A flow with a hidden launcher returns focus to
the control that had it when the flow opened. If that control is hidden or removed while the flow is open, focus can return to the
enclosing dialog or drawer. Escape in a flow opened over a CanopyX drawer, dialog or menu belongs to the flow.
For a destructive action, set flow.LaunchTone = CanopyFlowActionTone.Danger for the launcher, and
flow.Submit = new CanopyFlowSubmit("Delete") { Tone = CanopyFlowActionTone.Danger } for the final button.
CanopyFlowActionTone.Neutral styles either one as a plain button, for an action beside the page's main one.
Set flow.HideOptionalMarks = true to omit optional field marks for the flow.
flow.Command = new CanopyFlowCommand("Set-MailServer").Variant("csharp", "C#");The review page shows the answers as a command line in a collapsible "Equivalent command" panel, with tabs for the
variants the host writes (hooks.commands[variantId](values)), the JSON patch, and Copy. The command uses each visible
field's parameter and leaves out hidden, empty and unchanged answers (the default in create mode, the edited value in
edit mode). Lists join with commas, values are quoted for the style (powershell, the default, posix or windows), a
switch that was on and is now off becomes -Name:$false or --no-name, and a typed secret is <secret>, never its value.
The proposal's command carries the line. C# writes the same line with CanopyFlow.FormatCommand, and the server computes
it again from the answers; the shared fixture tests/fixtures/flow-commands.json keeps the browser and C# in step.
Windows-style quoted values escape backslashes before quotes and at the end of a value, so paths ending in \ preserve
the arguments that follow them.
flow.Preset("office", "Office relay", preset => preset.Value("host", "relay.office.example.com").Value("port", 25d));A "Start from" menu above the steps lists the presets (and, with hooks.presetStore.list(flowId), the host's saved ones).
Choosing one sets its answers on top of the plain start; answers the reader changes afterwards carry a quiet "Changed" mark,
and the review page says "Based on Office relay, 2 changes". With presetStore.save(flowId, preset), "Save as preset" keeps
the current answers that fit their fields' value rules. Secrets and sensitive answers are omitted. Held values stay with the
settings. The proposal's preset names the preset the answers started from.
"draft": "session" (or "local", or "host" with hooks.draftStore { load, save, clear }) keeps a draft: the answers,
never secrets or sensitive fields, the open step, the completed steps, the preset and the baseline. It saves a moment after
each change and on Save draft. A flow that finds a draft offers "Resume where you left off" or "Start again"; when the draft's
baseline is not the flow's, it warns that the settings changed after the draft was saved. Answers that no longer fit their
field are left out. A draft can restore a held answer while it still equals the document's initial value. A saved or
accepted answer clears the draft. If the browser refuses storage, the flow continues without drafts.
With "deepLinks": true the page's address names the open step, #flow-id/step-id (#flow-id for a task list's hub),
replacing the history entry rather than adding one. Opening the page or following such a link opens that step, a dialog
flow included; in a linear flow a step past one whose answers are missing opens that step instead. formatLink(stepId) and
parseLink(fragment) give a host a scheme of its own. Answers never go in the address.
hooks.preview(values, { signal }) answers what submitting will do, as rows [{ label, value, tone }] or { title, rows, notes } (tone: info, success, warning, danger). The review page shows it under "Preview", loading as it opens.
A document that relies on it says so with "preview": true on its review step (C# review.ShowsPreview()), and an endpoint
with the preview route does the same: the page then loads the preview part with the flow. A preview hook alone loads the
part too, but a page that cannot load it still shows the review page, without the preview.
A destructive flow asks for consent before its submit button works. This example links the acknowledgement to the
flow's retirement-impact check.
flow.Review(review => {
review.Confirm("Type {text} to confirm", "RETIRE");
review.Acknowledge("I understand that their history is removed.", CanopyFlowCondition.Equal("history", "remove"));
review.Acknowledgement!.CheckIds.Add("retirement-impact");
});confirm asks the reader to type a text exactly (text), or the answer of a field (field, such as the domain being
removed); acknowledge asks for a ticked box, only while its condition holds. Submitting without them says what is missing
and moves focus there.
Set dependsOnChecks (C# Confirmation.CheckIds or Acknowledgement.CheckIds) on each consent that refers to check
results. Use up to 64 distinct check IDs from the flow. A consent without this list, or with an empty list, is independent
of checks. A linked consent waits for each named check that applies. A named check applies while its step is visible
and it has no fields or at least one of its named fields is visible. Review hides linked checks while they are
inapplicable. Running one through the API in that state leaves consent unchanged.
After the reader gives linked consent, changing a dependency of a named check, invalidating that check, or rerunning it with a different status, message, detail rows or field errors clears the consent and announces that it needs to be given again. An identical result on unchanged inputs preserves consent. A running check temporarily blocks use of its linked consent, and starting the run retires pending proposals that could use that consent. A cancelled rerun can keep the prior result when the inputs are unchanged.
A consent edit or a check change can retire a submission already delivered to the host. The flow aborts the proposal's signal and revokes its secret readers. Submit stays unavailable until all outstanding responses settle. Settle the response when the request's outcome is known. The host owns concurrency and retries for background work or writes whose outcome the browser cannot observe.
The proposal includes a consent object only for applicable linked consents. Its confirm or acknowledge entry maps
each applicable check ID to the same positive integer revision in checks. The map is empty if all named checks are
inapplicable. The typed text never travels. CanopyFlowSubmission.Parse checks which receipts apply, whether they match
the submitted claims and whether those claims meet the declared check requirements. These are browser claims. The host
must verify fresh results and any consent it relies on under its own policy.
CanopyX.AspNetCore maps a flow's hooks to routes, so a page needs no script of its own:
var handlers = new CanopyFlowHandlers {
Check = async (context, request) => await mail.TestAsync(request.Values, request.ReadSecret("password")),
Options = (context, request) => Task.FromResult(relays.For(request.Values.TryGetValue("region", out var region) ? region as string : null)),
Preview = (context, request) => Task.FromResult(new CanopyFlowPreview().Row("Applies", "At once", Tone.Success)),
Drafts = new MyDraftStore(),
Submit = async (context, submission) => submission.IsCurrent
? await settings.ApplyAsync(submission.Patch, submission.ReadSecret("password"))
: CanopyFlowAnswer.Conflict()
};
app.MapCanopyFlow("/api/flows/mail", context => MailFlow(context), handlers, options => options.AuthorizationPolicy = "Mail.Admin");
// The page: flow.Endpoint(new CanopyFlowEndpoint("/api/flows/mail", handlers.Routes))Each handler that is set maps its route below the pattern: POST options, fields, check, validate, preview, status
and submit, and GET/PUT/DELETE draft. The document's endpoint names the routes, and the browser posts JSON to
<url>/<route> on the page's own origin with the page's cookies and the headers option (an antiforgery token, for
example) for every hook the host left unset. Secrets travel only to check (the ones the check tests) and submit (the
ones the proposal sets).
The flow callback builds the flow for each request as the page did (edit-mode values, stored secrets and baseline
included): the server reads every request against it and never trusts the browser's copy. The routes require
authorization (the default policy, or AuthorizationPolicy) unless AllowAnonymous is set; bodies must be JSON
(application/json, 1 MiB by default, MaxRequestBytes), so cross-origin pages go through a CORS preflight. Malformed
requests answer 400 with { "error", "message" }, an oversized body 413, another content type 415; server failures answer
a generic 500 and are logged. Apply rate limiting, CORS and antiforgery to the returned route group.
The submit route reads the proposal with CanopyFlowSubmission.ParseRequestAsync, using the Fields handler for host
sections and the Options handler (or the endpoint's HostOptions callback) for host options, so an answer the host no
longer offers is refused. Answers that fail the flow's checks answer an error with the messages beside
the fields, without calling the handler. With RejectStaleBaseline enabled (the default), the route checks the proposal's
baseline before validating its answers and returns a conflict when the settings have changed. A PUT draft keeps only
a well-formed draft of the flow without secrets or sensitive answers (CanopyFlowResponses.DraftAsync). The draft reader uses the same host-section field definitions as the
submission reader, so a host field marked sensitive cannot enter the store. MapCanopyFlow loads those definitions through
the Fields handler. Standalone readers use CanopyFlowReadOptions.SectionFields with Draft, or SectionFieldsAsync
with DraftAsync; a draft containing host answers is refused when their field definitions are unavailable.
CanopyX.Data reads proposals without ASP.NET Core:
var submission = CanopyFlowSubmission.Parse(flow, proposalJson, secrets, new CanopyFlowReadOptions { SectionFields = EngineFields });| Member | What it holds |
|---|---|
Values |
The answers of the visible, non-secret fields (host-section fields included), in their canonical form. |
Secrets, ReadSecret(id) |
Each visible secret's state (Set, Keep, Clear), and a typed value, once. |
Changes, Patch, PatchToJson() |
Edit-mode changes and the JSON patch, computed from CanopyFlow.Initial and the answers. |
Command |
The equivalent command, computed from the answers. |
Checks |
The check results the browser reports: claims, to run again before relying on them. |
Baseline, IsCurrent |
The baseline the proposal echoes, and whether it is the flow's. |
PresetId, IsEdit |
The preset the answers started from, and the mode. |
Parse reads the proposal against the flow: answers of hidden, unknown or secret fields, values of the wrong type, secrets
the proposal does not set and anything outside the contract throw CanopyRequestException (400). Every visible field is
checked with the browser's rules (required, ranges and steps, lengths and patterns, counts, item rules, records cells,
enabled document options and current host options); failures throw CanopyFlowSubmissionException, whose ToAnswer() is the error answer the browser
shows beside the fields; they use the flow's labels, with numbers and moments written invariantly (the browser writes them
in the page's language). The browser's own changes, patch and command are never used. CanopyFlowRequest.Parse reads
the hooks' requests the same way, and CanopyFlowAnswer, CanopyFlowCheckResult, CanopyFlowValidationResult,
CanopyFlowPreview, CanopyFlowStepStatus and CanopyFlowResponses write their answers.
const flow = CanopyX.createFlow(host, {
flow, // the document
values, // starting values on top of defaults or initial
labels,
hooks: { validators: { host(value, values) {} }, validateStep(stepId, values) {}, validateFlow(values) {}, submit(detail) {},
options, fields, check, preview, status, commands: {}, draftStore: {}, presetStore: {}, pickers: {} },
editors: { stars: { create(context) {} } },
timeout: 30000, // asynchronous hooks, in milliseconds
headers: {}, // an endpoint's requests
onReady, onStepChange, onValueChange, onSubmit, onSubmitted, onReload, onCheck, onLeaving, formatLink, parseLink
});Fragments written by C# mount automatically and take options through CanopyX.configure(flowId, options).
data-cx-mount="manual" waits for CanopyX.mount. Set MountWhenVisible to defer a Flow fragment in a tab or drawer
until the host comes near the viewport. A page can use the same policy for embedded change lists.
A change list inside a Flow drawer can keep a reason open while the host saves its action.
Await api.ready before calling synchronous members such as getValues(), setValues() or reset(). They throw a clear
not-ready error while the lazy implementation is loading. Asynchronous members (next, back, goTo, setState,
validate and submit) wait for readiness. After destruction, synchronous calls throw and asynchronous calls reject;
destroying a flow also releases its host so CanopyX.mount(host) can mount it again.
| Member | Result |
|---|---|
next(), back(), goTo(stepId) |
Navigation; next validates the current step first. Each resolves with whether the step changed. |
getStep() |
The current step id. |
getValues() |
The visible answers, never secrets. |
setValues(partial) |
Sets answers (not secrets), as a host change. |
getState(), setState(state) |
The current step and the answers, never secrets. |
isDirty(), reset() |
Whether an answer changed from its start, and back to the start. |
validate(stepId?) |
Resolves with { valid, errors, warnings } for a step or the whole flow. |
setFieldError(fieldId, message) |
Shows a host message on a field (null clears it). |
proposal(options?) |
Validates without recording errors. Resolves with the same detail as submit, or null if unavailable. { steps } reads only those steps. |
submit() |
Validates and raises flowSubmit; resolves with the host's answer. |
setProgress({ done, total, message }), complete(answer) |
Drive an accepted answer to its end. |
runCheck(checkId) |
Runs a check; resolves with its result, or null when it was cancelled. |
invalidateChecks(checkIds?) |
Marks selected checks stale (all when omitted), cancels their runs and ignores late answers after an external dependency changes. |
refreshOptions(fieldId) |
Loads a host-option field's options again. |
setStepState(stepId, state) |
Sets a task's state as the host sees it; null returns it to what the answers say. |
saveDraft(), setPreset(presetId) |
Saves the draft now; starts from a preset (null for the plain start). |
open(), close() |
Opens and closes a dialog or drawer flow; close asks first when answers would be lost. |
destroy(), ready |
Removes the flow; a promise for the first paint. |
If answers change while a submission is waiting for the host, its response does not settle the changed form. The host may already have applied the captured proposal; it remains responsible for authorization and persistence. The reader can submit the current answers immediately, even if the earlier response is still pending. Next retires obsolete validation in the same way. Reset and destruction also retire pending navigation and submission waits. Retiring browser state does not cancel the host's work or undo a write. Public validation retries changing answers a bounded number of times; if it cannot obtain a stable snapshot, it reports a generic failure and does not attach errors from an earlier answer.
setProgress and complete target the flow's current accepted operation. If host work can outlive reset() or reuse of the
flow, the host must stop forwarding that earlier work's progress and completion callbacks.
| Event | Cancelable | Detail |
|---|---|---|
canopyx:flowReady |
{ flow, step } |
|
canopyx:flowStepChanging |
yes | { from, to, direction } |
canopyx:flowStepChanged |
{ from, to } |
|
canopyx:flowValueChanged |
{ field, value, previous, source }; for secrets only { field, source, state } |
|
canopyx:flowSubmit |
yes | the flowSubmission with respondWith(answer), secret(id) and signal |
canopyx:flowSubmitted |
the host's answer | |
canopyx:flowReload |
{ baseline } |
|
canopyx:flowCheck |
{ check, result: { status, message, details, at } } |
|
canopyx:flowLeaving |
yes | { reason: "close" }: a dialog or drawer flow is closing with changed answers |
canopyx:error |
{ error, hook } |
Every hook runs isolated: an exception or rejection becomes an error event and a message in place, and the flow keeps
working. Cancelling flowSubmit with preventDefault() leaves the flow on the review page.
TypeScript types: FlowDocument, FlowField, FlowCondition, FlowSubmission, FlowAnswer, FlowApi, FlowOptions,
FlowHooks, FlowCheckResult, FlowStepState, FlowPreview, FlowDraft and FlowPickedRecord from @evotecit/canopyx/flow.
The texts the flow writes itself are the flow… labels, translated in the five label packs (CanopyLabels.Polish() and
the others, @evotecit/canopyx/locales/pl and the others) together with the shared gridEdit… messages. A flow written
with Labels = CanopyLabels.German() carries them in its document. The labels of a host-connected feature come with its
part; a flow that does not use the feature ignores them. The stylesheet uses logical properties only, so a page
with dir="rtl" mirrors the rail, the fields and the action bar.
- The rail is a
navwith an ordered list; the current step hasaria-current="step"and locked steps say why. - Each step is a section labelled by its heading. On a step change focus moves to the heading and a polite live region says "Step 3 of 5, Certificate checks".
- Fields have real labels; help and messages are linked with
aria-describedby, errors setaria-invalid, and the step's error summary is an alert with links to the fields. - Choice cards are native radio buttons (arrow keys move), multiple choice is a group of check boxes with a live count.
- Enter in a single-line field moves to the next step; Ctrl+Enter submits from the review page.
- Pointer targets are at least 24 px, 44 px on phones; forced colours and reduced motion are respected.
A screen-reader speech pass (NVDA, Narrator) is backlog by owner decision; ARIA and keyboard support are designed in and covered by the automated checks.
| Asset | What it holds | Size guard (gzip) |
|---|---|---|
canopyx-flow-entry.js, canopyx-flow-entry.css |
The flow entry point: the theme tokens, the part loader, createFlow, configure, the fragment mount, which feature parts a document needs, and the UI factories (mountUi, notify, select, menu, dialog and the others). No grid or tree code. @evotecit/canopyx/flow is its ES module. |
13 KiB (12.0 KiB measured) |
canopyx-forms.js, canopyx-forms.css |
The forms part: the typed editors, number and date parsing, the lookup combobox and the field checks. Grid editing requires it too. |
7 KiB (5.4 KiB) |
canopyx-flow.js, canopyx-flow.css |
The flow part: the document reader, conditions, fields, steps, validation, the review page and the proposal. |
31 KiB + 448 B |
canopyx-flow-host.js, .css |
What the host-connected parts share: hooks with a timeout, answers the flow sets itself, loading lines. The parts marked † require it. | 3 KiB (1.9 KiB) |
canopyx-flow-checks.js, .css † |
Server checks. | 6 KiB (4.4 KiB) |
canopyx-flow-options.js † |
Host options, dependent fields and host sections. | 4 KiB (3.2 KiB) |
canopyx-flow-pick.js, .css † |
Pick steps and their tray. | 5 KiB (3.8 KiB) |
canopyx-flow-records.js, .css |
Records fields, with list, duration, byte-size and secret cells, nested records, row dialogs and record diffs. | 14 KiB |
canopyx-flow-drafts.js, .css † |
Drafts and presets. | 6 KiB (4.6 KiB) |
canopyx-flow-preview.js, .css † |
The host's preview. | 2 KiB (1.7 KiB) |
canopyx-flow-command.js, .css |
The equivalent command and the JSON patch. | 4 KiB (3.4 KiB) |
canopyx-flow-tasks.js, .css † |
Task lists. | 5 KiB (4.0 KiB) |
canopyx-flow-dialog.js, .css † |
Dialogs and drawers. | 3 KiB (2.1 KiB) |
canopyx-flow-links.js † |
Deep links. | 2 KiB (1.1 KiB) |
canopyx-flow-endpoint.js † |
An endpoint that answers the hooks. | 2 KiB (1.6 KiB) |
canopyx-flow-consent.js, .css |
The review page's typed confirmation and acknowledgement. | 3 KiB (1.9 KiB) |
A plain form loads the entry point, forms and flow only. A feature part loads with them when the document uses its
keys (a step's checks, a field's source or dependsOn, a pick step, a records field, presets or draft, a review
step's "preview": true, command, "mode": "tasks", a layout container, deepLinks, endpoint, a review step's
confirm or acknowledge). CanopyHtmlAssets.GetRequiredParts(CanopyFlow) makes the same decisions, so a single-file page
carries exactly those payloads. A preview hook or a preset store alone loads its part too; a page that cannot load it shows
the flow without the feature.
A page with only flows includes the flow entry point; the parts load on first use from the files beside it, or from the
payloads a single-file page carries. The data-grid and reporting entry points know the same parts, so a grid page creates
flows with CanopyX.createFlow and mounts flow fragments without a second entry point. A single-file grid page that creates flows from script carries the parts too: add "flow" to CanopyHtmlOptions.Parts (it brings forms), and the feature parts its flows use ("flow-checks", which brings flow-host, …), since there are no files beside the page to load them from. Include one entry point per page. A grid or tree mounted on that page also uses its page PDF fonts when it has no fonts of its own.
CanopyX.Html writes flow pages with the flow entry point (CanopyRuntime.Flow), or with the reporting entry point when a pick step embeds a grid or tree (CanopyHtmlAssets.GetRuntime(CanopyFlow)); CanopyHtmlAssets.GetRequiredParts(CanopyFlow) adds the parts the embedded views need.
An embedded grid can read a shared dataset supplied by the page. Destroy all its mounted readers before removing the dataset, including any grid still open in a pick step.
Information-step facts load the flow-facts runtime part only when present. They reuse the flow answer-list styles and do not increase the base flow budget.