@marktiderman/genesis-forms 0.5.0 → 0.6.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.
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- import { a as FieldBlock, J as Json, C as ContentBlock, P as PageBreakBlock, O as OptionsSource, F as FormDefinition, H as HiddenInput, b as FormLayout, L as LogicRule, E as Ending, c as FormSettings, d as Condition, B as Block } from './types-BhYUbLJ-.cjs';
2
- export { e as FormEvent, f as Operand, g as Operator } from './types-BhYUbLJ-.cjs';
3
- import { F as FormEngine, a as FormState } from './engine-BDq0XJ21.cjs';
4
- export { C as CreateFormOptions, c as createForm, i as isFormEvent, b as isJson, r as replay } from './engine-BDq0XJ21.cjs';
5
- import { F as FieldValidator } from './validate-BsZ0YTQS.cjs';
6
- export { C as ChoiceOption, a as FieldTypeManifest, H as HostOptions, O as OTHER_MAX_LENGTH, R as REQUIRED_MESSAGE, S as StandardSchemaV1, c as choiceOptions, d as dateLimits, g as getFieldType, i as isEmptyValue, b as isIsoDate, e as isOtherValue, f as isSensitive, l as listFieldTypes, n as normalizeValue, h as numberLimits, o as optionsSource, j as otherOption, r as ratingDisplay, k as registerFieldType, s as scaleLabels, m as summarizeValue, v as validateField, w as withHostOptions } from './validate-BsZ0YTQS.cjs';
1
+ import { a as FieldBlock, J as Json, C as ContentBlock, P as PageBreakBlock, O as OptionsSource, F as FormDefinition, H as HiddenInput, b as FormLayout, L as LogicRule, E as Ending, c as FormSettings, d as Condition, B as Block } from './types-oAckGR_Z.cjs';
2
+ export { e as FormEvent, f as Operand, g as Operator } from './types-oAckGR_Z.cjs';
3
+ import { F as FormEngine, a as FormState } from './engine-DC4YTPdr.cjs';
4
+ export { C as CreateFormOptions, c as createForm, i as isFormEvent, b as isJson, r as replay } from './engine-DC4YTPdr.cjs';
5
+ import { F as FieldValidator } from './validate-B5WKHbst.cjs';
6
+ export { A as AnswerSnapshot, C as CHOICE_FIELD_TYPES, a as ChoiceOption, b as FieldTypeManifest, H as HostOptions, L as LinkParams, M as MAX_PREFILL_PARAM_LENGTH, O as OPTION_LIMITS, c as OTHER_MAX_LENGTH, d as OptionSnapshot, P as PrefillSetting, e as PrefillState, R as REQUIRED_MESSAGE, f as RestoredAnswers, S as SEARCHABLE_OPTION_COUNT, g as StandardSchemaV1, h as answerSnapshots, i as answersFromSnapshots, j as answersOnPath, k as choiceOptions, l as clearFilteredAnswers, m as dateLimits, n as filteredChoiceError, o as getFieldType, p as hasOptionFilters, q as hiddenByPrefill, r as isEmptyValue, s as isHttpsUrl, t as isIsoDate, u as isOtherValue, v as isPrefillParam, w as isSearchable, x as isSensitive, y as listFieldTypes, z as normalizeValue, B as numberLimits, D as optionFilter, E as optionJson, G as optionMatches, I as optionsSource, J as otherOption, K as prefillFromLink, N as prefillSetting, Q as ratingDisplay, T as readOption, U as registerFieldType, V as respondentPath, W as scaleLabels, X as searchOptions, Y as summarizeValue, Z as validateField, _ as visibleOptions, $ as withHostOptions } from './validate-B5WKHbst.cjs';
7
7
 
8
8
  /**
9
9
  * The `photo` field type: a respondent attaches up to a few photos, such as a
@@ -87,6 +87,9 @@ interface ChoiceFieldOptions<O extends string> extends FieldOptions {
87
87
  options?: readonly {
88
88
  value: O;
89
89
  label?: string;
90
+ description?: string;
91
+ image?: string;
92
+ attributes?: Record<string, string | string[]>;
90
93
  }[] | undefined;
91
94
  /**
92
95
  * Options the app showing the form supplies, by key (`OptionsSource`), such
@@ -101,6 +104,17 @@ interface ChoiceFieldOptions<O extends string> extends FieldOptions {
101
104
  other?: boolean | {
102
105
  label?: string;
103
106
  } | undefined;
107
+ /**
108
+ * Preselect from the link the form was opened from: `{ param: "location" }` takes
109
+ * `?location=…` when it is one of the options; `hideWhenPrefilled` then skips the question.
110
+ * See `prefillFromLink`.
111
+ */
112
+ prefill?: {
113
+ param: string;
114
+ hideWhenPrefilled?: boolean;
115
+ } | undefined;
116
+ /** A search box over the options: true or false, or by default when there are more than 10 (`isSearchable`). */
117
+ searchable?: boolean | undefined;
104
118
  }
105
119
  interface HiddenOptions {
106
120
  source?: HiddenInput["source"] | undefined;
@@ -721,4 +735,12 @@ declare function explain(source: FormEngine | ExplainInput, blockId: string, opt
721
735
  /** A condition as a plain-English clause: `contact_me is not Yes`. */
722
736
  declare function describeCondition(condition: Condition, def: FormDefinition, fields?: Map<string, FieldBlock>): string;
723
737
 
724
- export { type AnswersOf, Block, CALCULATED_TYPE, COMPUTED_FIELD_TYPES, type CalculatedFormat, type CalculatedProps, type ChoiceFieldOptions, type CoerceHiddenOptions, type CoercedHidden, Condition, ContentBlock, DEFAULT_PHOTO_FILES, DEFAULT_PHOTO_SIZE_MB, Ending, type ExplainInput, type ExplainOptions, type Explanation, FORMULA_FUNCTIONS, FieldBlock, type FieldOptions, type FieldSpec, type FieldValidation, FieldValidator, type Form, FormDefinition, FormEngine, type FormInput, type FormIssue, FormLayout, type FormProgress, FormSettings, FormState, type FormulaFunction, type FormulaNode, type FormulaParseResult, type FormulaReader, type FormulaRef, type FormulaValue, HIGHLIGHT_NOTE_MESSAGE, HiddenInput, type Highlight, Json, type JumpTrace, type KeyResolver, LogicRule, MAX_CALCULATED_DECIMALS, MAX_FORMULA_ITEMS, MAX_FORMULA_LENGTH, MAX_FORM_FORMULA_LENGTH, MAX_HIDDEN_STRING_LENGTH, MAX_HIGHLIGHT_NOTE_LENGTH, MAX_HIGHLIGHT_QUOTE_LENGTH, MAX_PHOTO_FILES, MAX_PHOTO_ID_LENGTH, MAX_PHOTO_NAME_LENGTH, MAX_PHOTO_SIZE_MB, MAX_SETTLE_ITEMS, MAX_TABLE_CELL_LENGTH, MAX_TABLE_COLUMNS, MAX_TIMESTAMP_SECONDS, type MediaNote, OptionsSource, PHOTO_FORMATS, PHOTO_TYPE, PageBreakBlock, type ParseResult, type PathResult, type PhotoFormat, type PhotoLimits, type PhotoRef, type RuleSpec, type RuleTrace, STRUCTURED_FIELD_TYPES, type TableColumn, UPLOAD_FIELD_TYPES, calculatedProps, calculatedValue, canonicalJson, coerceHidden, coerceHiddenValue, computePath, defineForm, describeCondition, evaluate, evaluateFormula, explain, f, fingerprint, formProgress, formatCalculated, formatTimestamp, formulaInput, formulaNumber, formulaRefs, furthestReached, isPhotoFormat, isPhotoRef, listLimits, parseForm, parseFormula, parseTimestamp, photoCountMessage, photoFormatList, photoLimits, photoRefs, photoSizeMessage, photoTypeMessage, recall, renameFormulaKey, ruleVisible, steps, tableColumns, tableLimits, when };
738
+ /**
739
+ * Answers given to one version of a form, as answers to another (by field id), matched
740
+ * by field key: what an edit link prefills when the form has a newer version. Answers
741
+ * to fields the other version doesn't have are dropped; `extra` (by key) fills fields
742
+ * the stored answers leave out, such as contact details kept apart.
743
+ */
744
+ declare function carryAnswers(from: FormDefinition, to: FormDefinition, answers: Record<string, Json>, extra?: Record<string, Json | null | undefined>): Record<string, Json>;
745
+
746
+ export { type AnswersOf, Block, CALCULATED_TYPE, COMPUTED_FIELD_TYPES, type CalculatedFormat, type CalculatedProps, type ChoiceFieldOptions, type CoerceHiddenOptions, type CoercedHidden, Condition, ContentBlock, DEFAULT_PHOTO_FILES, DEFAULT_PHOTO_SIZE_MB, Ending, type ExplainInput, type ExplainOptions, type Explanation, FORMULA_FUNCTIONS, FieldBlock, type FieldOptions, type FieldSpec, type FieldValidation, FieldValidator, type Form, FormDefinition, FormEngine, type FormInput, type FormIssue, FormLayout, type FormProgress, FormSettings, FormState, type FormulaFunction, type FormulaNode, type FormulaParseResult, type FormulaReader, type FormulaRef, type FormulaValue, HIGHLIGHT_NOTE_MESSAGE, HiddenInput, type Highlight, Json, type JumpTrace, type KeyResolver, LogicRule, MAX_CALCULATED_DECIMALS, MAX_FORMULA_ITEMS, MAX_FORMULA_LENGTH, MAX_FORM_FORMULA_LENGTH, MAX_HIDDEN_STRING_LENGTH, MAX_HIGHLIGHT_NOTE_LENGTH, MAX_HIGHLIGHT_QUOTE_LENGTH, MAX_PHOTO_FILES, MAX_PHOTO_ID_LENGTH, MAX_PHOTO_NAME_LENGTH, MAX_PHOTO_SIZE_MB, MAX_SETTLE_ITEMS, MAX_TABLE_CELL_LENGTH, MAX_TABLE_COLUMNS, MAX_TIMESTAMP_SECONDS, type MediaNote, OptionsSource, PHOTO_FORMATS, PHOTO_TYPE, PageBreakBlock, type ParseResult, type PathResult, type PhotoFormat, type PhotoLimits, type PhotoRef, type RuleSpec, type RuleTrace, STRUCTURED_FIELD_TYPES, type TableColumn, UPLOAD_FIELD_TYPES, calculatedProps, calculatedValue, canonicalJson, carryAnswers, coerceHidden, coerceHiddenValue, computePath, defineForm, describeCondition, evaluate, evaluateFormula, explain, f, fingerprint, formProgress, formatCalculated, formatTimestamp, formulaInput, formulaNumber, formulaRefs, furthestReached, isPhotoFormat, isPhotoRef, listLimits, parseForm, parseFormula, parseTimestamp, photoCountMessage, photoFormatList, photoLimits, photoRefs, photoSizeMessage, photoTypeMessage, recall, renameFormulaKey, ruleVisible, steps, tableColumns, tableLimits, when };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { a as FieldBlock, J as Json, C as ContentBlock, P as PageBreakBlock, O as OptionsSource, F as FormDefinition, H as HiddenInput, b as FormLayout, L as LogicRule, E as Ending, c as FormSettings, d as Condition, B as Block } from './types-BhYUbLJ-.js';
2
- export { e as FormEvent, f as Operand, g as Operator } from './types-BhYUbLJ-.js';
3
- import { F as FormEngine, a as FormState } from './engine-Qzp6bX6O.js';
4
- export { C as CreateFormOptions, c as createForm, i as isFormEvent, b as isJson, r as replay } from './engine-Qzp6bX6O.js';
5
- import { F as FieldValidator } from './validate-Bs1lyoOl.js';
6
- export { C as ChoiceOption, a as FieldTypeManifest, H as HostOptions, O as OTHER_MAX_LENGTH, R as REQUIRED_MESSAGE, S as StandardSchemaV1, c as choiceOptions, d as dateLimits, g as getFieldType, i as isEmptyValue, b as isIsoDate, e as isOtherValue, f as isSensitive, l as listFieldTypes, n as normalizeValue, h as numberLimits, o as optionsSource, j as otherOption, r as ratingDisplay, k as registerFieldType, s as scaleLabels, m as summarizeValue, v as validateField, w as withHostOptions } from './validate-Bs1lyoOl.js';
1
+ import { a as FieldBlock, J as Json, C as ContentBlock, P as PageBreakBlock, O as OptionsSource, F as FormDefinition, H as HiddenInput, b as FormLayout, L as LogicRule, E as Ending, c as FormSettings, d as Condition, B as Block } from './types-oAckGR_Z.js';
2
+ export { e as FormEvent, f as Operand, g as Operator } from './types-oAckGR_Z.js';
3
+ import { F as FormEngine, a as FormState } from './engine-CpfOz8FN.js';
4
+ export { C as CreateFormOptions, c as createForm, i as isFormEvent, b as isJson, r as replay } from './engine-CpfOz8FN.js';
5
+ import { F as FieldValidator } from './validate-GpTXPwyl.js';
6
+ export { A as AnswerSnapshot, C as CHOICE_FIELD_TYPES, a as ChoiceOption, b as FieldTypeManifest, H as HostOptions, L as LinkParams, M as MAX_PREFILL_PARAM_LENGTH, O as OPTION_LIMITS, c as OTHER_MAX_LENGTH, d as OptionSnapshot, P as PrefillSetting, e as PrefillState, R as REQUIRED_MESSAGE, f as RestoredAnswers, S as SEARCHABLE_OPTION_COUNT, g as StandardSchemaV1, h as answerSnapshots, i as answersFromSnapshots, j as answersOnPath, k as choiceOptions, l as clearFilteredAnswers, m as dateLimits, n as filteredChoiceError, o as getFieldType, p as hasOptionFilters, q as hiddenByPrefill, r as isEmptyValue, s as isHttpsUrl, t as isIsoDate, u as isOtherValue, v as isPrefillParam, w as isSearchable, x as isSensitive, y as listFieldTypes, z as normalizeValue, B as numberLimits, D as optionFilter, E as optionJson, G as optionMatches, I as optionsSource, J as otherOption, K as prefillFromLink, N as prefillSetting, Q as ratingDisplay, T as readOption, U as registerFieldType, V as respondentPath, W as scaleLabels, X as searchOptions, Y as summarizeValue, Z as validateField, _ as visibleOptions, $ as withHostOptions } from './validate-GpTXPwyl.js';
7
7
 
8
8
  /**
9
9
  * The `photo` field type: a respondent attaches up to a few photos, such as a
@@ -87,6 +87,9 @@ interface ChoiceFieldOptions<O extends string> extends FieldOptions {
87
87
  options?: readonly {
88
88
  value: O;
89
89
  label?: string;
90
+ description?: string;
91
+ image?: string;
92
+ attributes?: Record<string, string | string[]>;
90
93
  }[] | undefined;
91
94
  /**
92
95
  * Options the app showing the form supplies, by key (`OptionsSource`), such
@@ -101,6 +104,17 @@ interface ChoiceFieldOptions<O extends string> extends FieldOptions {
101
104
  other?: boolean | {
102
105
  label?: string;
103
106
  } | undefined;
107
+ /**
108
+ * Preselect from the link the form was opened from: `{ param: "location" }` takes
109
+ * `?location=…` when it is one of the options; `hideWhenPrefilled` then skips the question.
110
+ * See `prefillFromLink`.
111
+ */
112
+ prefill?: {
113
+ param: string;
114
+ hideWhenPrefilled?: boolean;
115
+ } | undefined;
116
+ /** A search box over the options: true or false, or by default when there are more than 10 (`isSearchable`). */
117
+ searchable?: boolean | undefined;
104
118
  }
105
119
  interface HiddenOptions {
106
120
  source?: HiddenInput["source"] | undefined;
@@ -721,4 +735,12 @@ declare function explain(source: FormEngine | ExplainInput, blockId: string, opt
721
735
  /** A condition as a plain-English clause: `contact_me is not Yes`. */
722
736
  declare function describeCondition(condition: Condition, def: FormDefinition, fields?: Map<string, FieldBlock>): string;
723
737
 
724
- export { type AnswersOf, Block, CALCULATED_TYPE, COMPUTED_FIELD_TYPES, type CalculatedFormat, type CalculatedProps, type ChoiceFieldOptions, type CoerceHiddenOptions, type CoercedHidden, Condition, ContentBlock, DEFAULT_PHOTO_FILES, DEFAULT_PHOTO_SIZE_MB, Ending, type ExplainInput, type ExplainOptions, type Explanation, FORMULA_FUNCTIONS, FieldBlock, type FieldOptions, type FieldSpec, type FieldValidation, FieldValidator, type Form, FormDefinition, FormEngine, type FormInput, type FormIssue, FormLayout, type FormProgress, FormSettings, FormState, type FormulaFunction, type FormulaNode, type FormulaParseResult, type FormulaReader, type FormulaRef, type FormulaValue, HIGHLIGHT_NOTE_MESSAGE, HiddenInput, type Highlight, Json, type JumpTrace, type KeyResolver, LogicRule, MAX_CALCULATED_DECIMALS, MAX_FORMULA_ITEMS, MAX_FORMULA_LENGTH, MAX_FORM_FORMULA_LENGTH, MAX_HIDDEN_STRING_LENGTH, MAX_HIGHLIGHT_NOTE_LENGTH, MAX_HIGHLIGHT_QUOTE_LENGTH, MAX_PHOTO_FILES, MAX_PHOTO_ID_LENGTH, MAX_PHOTO_NAME_LENGTH, MAX_PHOTO_SIZE_MB, MAX_SETTLE_ITEMS, MAX_TABLE_CELL_LENGTH, MAX_TABLE_COLUMNS, MAX_TIMESTAMP_SECONDS, type MediaNote, OptionsSource, PHOTO_FORMATS, PHOTO_TYPE, PageBreakBlock, type ParseResult, type PathResult, type PhotoFormat, type PhotoLimits, type PhotoRef, type RuleSpec, type RuleTrace, STRUCTURED_FIELD_TYPES, type TableColumn, UPLOAD_FIELD_TYPES, calculatedProps, calculatedValue, canonicalJson, coerceHidden, coerceHiddenValue, computePath, defineForm, describeCondition, evaluate, evaluateFormula, explain, f, fingerprint, formProgress, formatCalculated, formatTimestamp, formulaInput, formulaNumber, formulaRefs, furthestReached, isPhotoFormat, isPhotoRef, listLimits, parseForm, parseFormula, parseTimestamp, photoCountMessage, photoFormatList, photoLimits, photoRefs, photoSizeMessage, photoTypeMessage, recall, renameFormulaKey, ruleVisible, steps, tableColumns, tableLimits, when };
738
+ /**
739
+ * Answers given to one version of a form, as answers to another (by field id), matched
740
+ * by field key: what an edit link prefills when the form has a newer version. Answers
741
+ * to fields the other version doesn't have are dropped; `extra` (by key) fills fields
742
+ * the stored answers leave out, such as contact details kept apart.
743
+ */
744
+ declare function carryAnswers(from: FormDefinition, to: FormDefinition, answers: Record<string, Json>, extra?: Record<string, Json | null | undefined>): Record<string, Json>;
745
+
746
+ export { type AnswersOf, Block, CALCULATED_TYPE, COMPUTED_FIELD_TYPES, type CalculatedFormat, type CalculatedProps, type ChoiceFieldOptions, type CoerceHiddenOptions, type CoercedHidden, Condition, ContentBlock, DEFAULT_PHOTO_FILES, DEFAULT_PHOTO_SIZE_MB, Ending, type ExplainInput, type ExplainOptions, type Explanation, FORMULA_FUNCTIONS, FieldBlock, type FieldOptions, type FieldSpec, type FieldValidation, FieldValidator, type Form, FormDefinition, FormEngine, type FormInput, type FormIssue, FormLayout, type FormProgress, FormSettings, FormState, type FormulaFunction, type FormulaNode, type FormulaParseResult, type FormulaReader, type FormulaRef, type FormulaValue, HIGHLIGHT_NOTE_MESSAGE, HiddenInput, type Highlight, Json, type JumpTrace, type KeyResolver, LogicRule, MAX_CALCULATED_DECIMALS, MAX_FORMULA_ITEMS, MAX_FORMULA_LENGTH, MAX_FORM_FORMULA_LENGTH, MAX_HIDDEN_STRING_LENGTH, MAX_HIGHLIGHT_NOTE_LENGTH, MAX_HIGHLIGHT_QUOTE_LENGTH, MAX_PHOTO_FILES, MAX_PHOTO_ID_LENGTH, MAX_PHOTO_NAME_LENGTH, MAX_PHOTO_SIZE_MB, MAX_SETTLE_ITEMS, MAX_TABLE_CELL_LENGTH, MAX_TABLE_COLUMNS, MAX_TIMESTAMP_SECONDS, type MediaNote, OptionsSource, PHOTO_FORMATS, PHOTO_TYPE, PageBreakBlock, type ParseResult, type PathResult, type PhotoFormat, type PhotoLimits, type PhotoRef, type RuleSpec, type RuleTrace, STRUCTURED_FIELD_TYPES, type TableColumn, UPLOAD_FIELD_TYPES, calculatedProps, calculatedValue, canonicalJson, carryAnswers, coerceHidden, coerceHiddenValue, computePath, defineForm, describeCondition, evaluate, evaluateFormula, explain, f, fingerprint, formProgress, formatCalculated, formatTimestamp, formulaInput, formulaNumber, formulaRefs, furthestReached, isPhotoFormat, isPhotoRef, listLimits, parseForm, parseFormula, parseTimestamp, photoCountMessage, photoFormatList, photoLimits, photoRefs, photoSizeMessage, photoTypeMessage, recall, renameFormulaKey, ruleVisible, steps, tableColumns, tableLimits, when };