@marktiderman/genesis-forms 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { e as FormEvent, J as Json, F as FormDefinition, a as FieldBlock, B as Block } from './types-BBKBQ8sp.js';
2
- import { F as FieldValidator } from './validate-BjNwF1UE.js';
1
+ import { e as FormEvent, J as Json, F as FormDefinition, a as FieldBlock, B as Block } from './types-BhYUbLJ-.cjs';
2
+ import { F as FieldValidator, H as HostOptions } from './validate-BsZ0YTQS.cjs';
3
3
 
4
4
  /** Guards and helpers for event logs and other untrusted JSON. No dependencies. */
5
5
 
@@ -29,6 +29,11 @@ interface FormState {
29
29
  current: string | null;
30
30
  /** Visited blocks, for Back. */
31
31
  history: string[];
32
+ /**
33
+ * The furthest block reached by moving on (`next`), kept after going back;
34
+ * the first block until then. `formProgress` reads it.
35
+ */
36
+ furthest: string | null;
32
37
  errors: Record<string, string>;
33
38
  status: "in_progress" | "completed";
34
39
  /** The ending reached once completed. */
@@ -43,8 +48,26 @@ interface CreateFormOptions {
43
48
  validators?: Record<string, FieldValidator> | undefined;
44
49
  /** Timestamps on events. Pass `() => undefined` to record none (anonymous forms). */
45
50
  clock?: (() => number | undefined) | undefined;
51
+ /**
52
+ * Pick up where the respondent was (with `initialValues` holding their saved
53
+ * answers): a block id, usually `formProgress`'s `fieldId` from an earlier
54
+ * visit. The form moves on from the first block with Next, as they did, until
55
+ * it reaches this one, so Back still walks their path; it stops early at a
56
+ * step that no longer passes (a question since made required), and does
57
+ * nothing when the block isn't on the path.
58
+ */
59
+ resumeAt?: string | null | undefined;
60
+ /**
61
+ * The option lists this app supplies, by key, for choice fields with
62
+ * `props.optionsFrom: { source: "host", key }` (see `withHostOptions`).
63
+ * `engine.definition` is the definition with them filled in, so renderers
64
+ * show them and validation accepts only them (and the field's own options).
65
+ * Pass the same lists to `validateSubmission` on the server.
66
+ */
67
+ hostOptions?: HostOptions | undefined;
46
68
  }
47
69
  interface FormEngine {
70
+ /** The definition being filled in, with `hostOptions` filled in (`withHostOptions`). */
48
71
  readonly definition: FormDefinition;
49
72
  getState(): FormState;
50
73
  subscribe(listener: () => void): () => void;
@@ -1,5 +1,5 @@
1
- import { e as FormEvent, J as Json, F as FormDefinition, a as FieldBlock, B as Block } from './types-BBKBQ8sp.cjs';
2
- import { F as FieldValidator } from './validate-BXXqi0fq.cjs';
1
+ import { e as FormEvent, J as Json, F as FormDefinition, a as FieldBlock, B as Block } from './types-BhYUbLJ-.js';
2
+ import { F as FieldValidator, H as HostOptions } from './validate-Bs1lyoOl.js';
3
3
 
4
4
  /** Guards and helpers for event logs and other untrusted JSON. No dependencies. */
5
5
 
@@ -29,6 +29,11 @@ interface FormState {
29
29
  current: string | null;
30
30
  /** Visited blocks, for Back. */
31
31
  history: string[];
32
+ /**
33
+ * The furthest block reached by moving on (`next`), kept after going back;
34
+ * the first block until then. `formProgress` reads it.
35
+ */
36
+ furthest: string | null;
32
37
  errors: Record<string, string>;
33
38
  status: "in_progress" | "completed";
34
39
  /** The ending reached once completed. */
@@ -43,8 +48,26 @@ interface CreateFormOptions {
43
48
  validators?: Record<string, FieldValidator> | undefined;
44
49
  /** Timestamps on events. Pass `() => undefined` to record none (anonymous forms). */
45
50
  clock?: (() => number | undefined) | undefined;
51
+ /**
52
+ * Pick up where the respondent was (with `initialValues` holding their saved
53
+ * answers): a block id, usually `formProgress`'s `fieldId` from an earlier
54
+ * visit. The form moves on from the first block with Next, as they did, until
55
+ * it reaches this one, so Back still walks their path; it stops early at a
56
+ * step that no longer passes (a question since made required), and does
57
+ * nothing when the block isn't on the path.
58
+ */
59
+ resumeAt?: string | null | undefined;
60
+ /**
61
+ * The option lists this app supplies, by key, for choice fields with
62
+ * `props.optionsFrom: { source: "host", key }` (see `withHostOptions`).
63
+ * `engine.definition` is the definition with them filled in, so renderers
64
+ * show them and validation accepts only them (and the field's own options).
65
+ * Pass the same lists to `validateSubmission` on the server.
66
+ */
67
+ hostOptions?: HostOptions | undefined;
46
68
  }
47
69
  interface FormEngine {
70
+ /** The definition being filled in, with `hostOptions` filled in (`withHostOptions`). */
48
71
  readonly definition: FormDefinition;
49
72
  getState(): FormState;
50
73
  subscribe(listener: () => void): () => void;