export * as state from "./state"; export { default as Wizard } from "./components/Wizard"; export { StyleProvider } from "./components/StyleProvider"; export { track, trackEvent } from "./utils/tracking"; export * as dsl from "./utils/dsl"; export * as Primitives from "./primitives"; import { Expression, ValidationError, ValidationResult } from "./utils/dsl"; export type NodeTitles = Record; export type Metadata = { title: string; name: string; footer?: string; pdfServiceUrl?: string; localStorageKey?: string; }; /** * The known node types */ export type NodeType = | "Page" | "Result" | "Error" | "ErrorOk" | "Group" | "Result" | "Answer" | "Image" | "Text" | "Branch" | "Reference" | "Checkbox" | "Radio" | "Select" | "Input" | "Number" | "Textarea" | "Cell" | "Heading" | "Table" | "FetchOrg" | "Evaluation" | "Information" | "Signature" | "Sum"; type ImageSrc = { url: string; alt: string; text?: string }; /** * Properties common to all nodes that support visibility filters by use of show/hide expressions */ type VisibilityFilter = { show?: Expression; hide?: Expression; /** * @deprecated Use `hide` instead */ hidden?: Expression; }; type CommonOptions = { heading: string; text?: string; image?: ImageSrc; }; export type NodeBase = { type: T; } & (I extends true ? { id: string } : {}) & VisibilityFilter; export type InputNodeBase = NodeBase & CommonOptions & { id: string; property: string; summary?: string; details?: string; }; export type Answer = NodeBase<"Answer"> & { heading: string; text?: string; value: any; disabled?: Expression; messages?: Array<{ message: string; warning?: boolean; hide?: Expression; show?: Expression; hidden?: Expression; }>; image?: ImageSrc; }; export type Page = NodeBase<"Page"> & { type: "Page"; heading: string; lead?: string; details?: string; children: Node[]; }; export type Result = NodeBase<"Result"> & { type: "Result"; children?: Node[]; exporter?: string; heading: | string | { complete: string; completeWithError: string; incomplete: string; incompleteWithError: string; }; lead?: | string | { complete: string; completeWithError: string; incomplete: string; incompleteWithError: string; }; }; export type Error = NodeBase<"Error"> & { heading?: string; lead?: string; children: Node[]; }; export type ErrorOk = NodeBase<"ErrorOk"> & { heading: string; lead?: string; children: Node[]; }; export type BranchNode = { test: Expression; children: Node[]; }; export type Branch = NodeBase<"Branch"> & { branches: BranchNode[]; }; export type Checkbox = InputNodeBase<"Checkbox"> & { allMandatory?: boolean; disabled?: Expression; optional?: boolean; options: Array; grid?: boolean; /** * List of options to clear when the value of this checkbox group changes */ update?: string[]; }; export type Radio = InputNodeBase<"Radio"> & { disabled?: Expression; options: Array; grid?: boolean; /** * List of options to clear when the value of this radio group changes */ clear?: string[]; }; export type Select = InputNodeBase<"Select"> & { options: Array; autocomplete?: string; defaultOption?: string; }; export type Group = NodeBase<"Group"> & VisibilityFilter & { heading?: string; text?: string; children: Node[]; }; type WithValidator = { validator?: ( | { test?: undefined; pattern: string; object?: string; } | { test: Expression; } ) & { error: string }; }; export type Text = NodeBase<"Text"> & { heading?: string; text?: string; warning?: boolean; /** * Show only when printing */ printonly?: boolean; /** * Hide when printing */ printhide?: boolean; }; type Information = Omit & { type: "Information" }; export type Textarea = InputNodeBase<"Textarea"> & WithValidator & { information?: string; placeholder?: string; optional?: boolean; autocomplete?: string; }; export type Input = InputNodeBase<"Input"> & WithValidator & { placeholder?: string; optional?: boolean; disabled?: Expression; autocomplete?: string; inputType?: string; }; export type Number = InputNodeBase<"Number"> & WithValidator & { text?: string; placeholder?: string; disabled?: Expression; optional?: boolean; minimum?: number; maximum?: number; step?: number; autocomplete?: string; unit?: string; }; export type FetchOrg = InputNodeBase<"FetchOrg"> & WithValidator & { source: string; text?: string; placeholder?: string; information?: string; invalidapproval?: string; invalidOrg?: string; SGheading?: string; SGsource?: string; SGtext?: string; optional?: boolean; fetchSG?: boolean; autocomplete?: string; }; export type Evaluation = NodeBase<"Evaluation"> & { /** * The id of the node, or two nodes, to evaluate */ testing?: string | [string, string]; /** * The text string to be used when sad state */ sad: string; /** * The text string to be used when happy state */ happy: string; showValue?: boolean; unit?: string; optional?: boolean; groupedSimple?: boolean; }; export type Image = NodeBase<"Image"> & { text?: string; image: ImageSrc; }; type Cell = NodeBase<"Cell"> & { text: string; rowSpan?: number; colSpan?: number; test?: Expression; }; type Heading = NodeBase<"Heading"> & { text: string; rowSpan?: number; colSpan?: number; test?: Expression; }; export type Table = NodeBase<"Table"> & CommonOptions & { cells: Array>; simple?: boolean; }; export type Sum = InputNodeBase<"Sum"> & CommonOptions & { values: Array; operations: Array<"+" | "-" | "*" | "/" | "-/" | "%">; details?: string; final?: boolean; minimum?: number; summary?: string; unit?: string; groupedSimple?: boolean; }; export type Reference = NodeBase<"Reference", false> & { nodeId: string; }; type Signature = NodeBase<"Signature">; export type Node = | Page | Result | Error | ErrorOk | Group | Checkbox | Radio | Select | Input | Number | Textarea | Answer | Image | Cell | Heading | Table | Branch | FetchOrg | Reference | Text | Evaluation | Information | Signature | Sum; /** * Renderable answer type has a boolean for the disabled prop * (after evaluation of the expression) */ export type RenderableAnswer = WithError< Omit & { disabled?: boolean; } >; /** * The renderable branch node has its children replaced with * renderable children */ type RenderableBranchNode = WithError< Omit & { children: RenderableNode[]; } >; export type RenderableError = WithError< Omit & { children: RenderableNode[]; heading: string; } >; export type RenderableErrorOk = WithError< Omit & { children: RenderableNode[]; heading: string; } >; export type RenderableResult = WithError< Omit & { children: RenderableNode[]; heading: string; } >; export type RenderablePage = WithError< Omit & { children: RenderableNode[]; heading: string; } >; type RenderableGroup = WithError< Omit & { children: RenderableNode[] } >; type RenderableBranch = WithError< Omit & { branches: RenderableBranchNode[]; } >; type RenderableCheckbox = WithError< Omit & { disabled?: boolean; options: RenderableAnswer[]; } >; type RenderableRadio = WithError< Omit & { disabled?: boolean; options: RenderableAnswer[]; } >; type RenderableSelect = WithError< Omit & { options: RenderableAnswer[]; } >; type RenderableInput = WithError< Omit & { disabled?: boolean } >; type RenderableNumber = WithError< Omit & { disabled?: boolean } >; type RenderableFetchOrg = WithError< Omit & { disabled?: boolean } >; type RenderableTable = WithError< Omit & { cells: Array & { inactive?: boolean }>>; } >; type RenderableTextarea = WithError