@getodk/xforms-engine 0.2.0 → 0.4.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/client/BaseNode.d.ts +69 -4
- package/dist/client/EngineConfig.d.ts +0 -1
- package/dist/client/GroupNode.d.ts +4 -3
- package/dist/client/ModelValueNode.d.ts +36 -0
- package/dist/client/NodeAppearances.d.ts +1 -2
- package/dist/client/NoteNode.d.ts +52 -0
- package/dist/client/RootNode.d.ts +4 -3
- package/dist/client/SelectNode.d.ts +6 -5
- package/dist/client/StringNode.d.ts +6 -5
- package/dist/client/SubtreeNode.d.ts +3 -2
- package/dist/client/TextRange.d.ts +85 -3
- package/dist/client/TriggerNode.d.ts +25 -0
- package/dist/client/constants.d.ts +8 -0
- package/dist/client/hierarchy.d.ts +19 -10
- package/dist/client/index.d.ts +0 -1
- package/dist/client/node-types.d.ts +3 -1
- package/dist/client/{RepeatRangeNode.d.ts → repeat/BaseRepeatRangeNode.d.ts} +18 -18
- package/dist/client/{RepeatInstanceNode.d.ts → repeat/RepeatInstanceNode.d.ts} +9 -9
- package/dist/client/repeat/RepeatRangeControlledNode.d.ts +18 -0
- package/dist/client/repeat/RepeatRangeUncontrolledNode.d.ts +19 -0
- package/dist/client/unsupported/RangeNode.d.ts +9 -0
- package/dist/client/unsupported/RankNode.d.ts +9 -0
- package/dist/client/unsupported/UnsupportedControlNode.d.ts +32 -0
- package/dist/client/unsupported/UploadNode.d.ts +9 -0
- package/dist/client/validation.d.ts +162 -0
- package/dist/index.d.ts +14 -6
- package/dist/index.js +39696 -36151
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +3 -2
- package/dist/instance/ModelValue.d.ts +39 -0
- package/dist/instance/Note.d.ts +41 -0
- package/dist/instance/Root.d.ts +5 -4
- package/dist/instance/SelectField.d.ts +11 -6
- package/dist/instance/StringField.d.ts +12 -7
- package/dist/instance/Subtree.d.ts +2 -1
- package/dist/instance/TriggerControl.d.ts +40 -0
- package/dist/instance/abstract/DescendantNode.d.ts +8 -10
- package/dist/instance/abstract/InstanceNode.d.ts +3 -2
- package/dist/instance/abstract/UnsupportedControl.d.ts +46 -0
- package/dist/instance/children.d.ts +0 -1
- package/dist/instance/hierarchy.d.ts +15 -6
- package/dist/instance/index.d.ts +0 -1
- package/dist/instance/internal-api/EvaluationContext.d.ts +0 -1
- package/dist/instance/internal-api/InstanceConfig.d.ts +0 -1
- package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -1
- package/dist/instance/internal-api/TranslationContext.d.ts +0 -1
- package/dist/instance/internal-api/ValidationContext.d.ts +28 -0
- package/dist/instance/internal-api/ValueContext.d.ts +3 -4
- package/dist/instance/{RepeatRange.d.ts → repeat/BaseRepeatRange.d.ts} +46 -46
- package/dist/instance/{RepeatInstance.d.ts → repeat/RepeatInstance.d.ts} +13 -13
- package/dist/instance/repeat/RepeatRangeControlled.d.ts +15 -0
- package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +34 -0
- package/dist/instance/resource.d.ts +0 -1
- package/dist/instance/text/TextChunk.d.ts +0 -1
- package/dist/instance/text/TextRange.d.ts +4 -5
- package/dist/instance/unsupported/RangeControl.d.ts +4 -0
- package/dist/instance/unsupported/RankControl.d.ts +4 -0
- package/dist/instance/unsupported/UploadControl.d.ts +4 -0
- package/dist/lib/TokenListParser.d.ts +3 -3
- package/dist/lib/dom/query.d.ts +1 -2
- package/dist/lib/reactivity/createChildrenState.d.ts +0 -1
- package/dist/lib/reactivity/createComputedExpression.d.ts +7 -3
- package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +4 -0
- package/dist/lib/reactivity/createSelectItems.d.ts +0 -1
- package/dist/lib/reactivity/createValueState.d.ts +0 -1
- package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createClientState.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createCurrentState.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createEngineState.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createSharedNodeState.d.ts +1 -2
- package/dist/lib/reactivity/node-state/createSpecifiedPropertyDescriptor.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createSpecifiedState.d.ts +1 -2
- package/dist/lib/reactivity/node-state/representations.d.ts +0 -1
- package/dist/lib/reactivity/scope.d.ts +0 -1
- package/dist/lib/reactivity/text/createFieldHint.d.ts +3 -4
- package/dist/lib/reactivity/text/createNodeLabel.d.ts +3 -4
- package/dist/lib/reactivity/text/createNoteText.d.ts +24 -0
- package/dist/lib/reactivity/text/createTextRange.d.ts +5 -8
- package/dist/lib/reactivity/types.d.ts +0 -1
- package/dist/lib/reactivity/validation/createAggregatedViolations.d.ts +8 -0
- package/dist/lib/reactivity/validation/createValidation.d.ts +17 -0
- package/dist/{XFormDOM.d.ts → parse/XFormDOM.d.ts} +1 -2
- package/dist/{XFormDataType.d.ts → parse/XFormDataType.d.ts} +2 -4
- package/dist/{XFormDefinition.d.ts → parse/XFormDefinition.d.ts} +2 -3
- package/dist/{body → parse/body}/BodyDefinition.d.ts +15 -10
- package/dist/{body → parse/body}/BodyElementDefinition.d.ts +8 -7
- package/dist/{body → parse/body}/RepeatElementDefinition.d.ts +4 -5
- package/dist/{body → parse/body}/UnsupportedBodyElementDefinition.d.ts +0 -1
- package/dist/{body → parse/body}/appearance/inputAppearanceParser.d.ts +1 -2
- package/dist/{body → parse/body}/appearance/selectAppearanceParser.d.ts +1 -2
- package/dist/{body → parse/body}/appearance/structureElementAppearanceParser.d.ts +1 -2
- package/dist/parse/body/appearance/unknownAppearanceParser.d.ts +3 -0
- package/dist/{body → parse/body}/control/ControlDefinition.d.ts +3 -4
- package/dist/{body → parse/body}/control/InputDefinition.d.ts +1 -2
- package/dist/parse/body/control/RangeControlDefinition.d.ts +11 -0
- package/dist/parse/body/control/RankControlDefinition.d.ts +11 -0
- package/dist/parse/body/control/TriggerControlDefinition.d.ts +11 -0
- package/dist/parse/body/control/UploadControlDefinition.d.ts +11 -0
- package/dist/{body → parse/body}/control/select/ItemDefinition.d.ts +3 -4
- package/dist/{body → parse/body}/control/select/ItemsetDefinition.d.ts +7 -7
- package/dist/{body → parse/body}/control/select/ItemsetNodesetContext.d.ts +2 -3
- package/dist/{body → parse/body}/control/select/SelectDefinition.d.ts +3 -12
- package/dist/{body → parse/body}/group/BaseGroupDefinition.d.ts +3 -5
- package/dist/{body → parse/body}/group/LogicalGroupDefinition.d.ts +0 -1
- package/dist/{body → parse/body}/group/PresentationGroupDefinition.d.ts +1 -2
- package/dist/{body → parse/body}/group/StructuralGroupDefinition.d.ts +0 -1
- package/dist/{model/BindComputation.d.ts → parse/expression/BindComputationExpression.d.ts} +5 -6
- package/dist/{body/control/select → parse/expression}/ItemsetNodesetExpression.d.ts +2 -3
- package/dist/{body/control/select → parse/expression}/ItemsetValueExpression.d.ts +2 -3
- package/dist/parse/expression/RepeatCountControlExpression.d.ts +18 -0
- package/dist/parse/expression/TextLiteralExpression.d.ts +9 -0
- package/dist/parse/expression/TextOutputExpression.d.ts +7 -0
- package/dist/parse/expression/TextReferenceExpression.d.ts +7 -0
- package/dist/parse/expression/TextTranslationExpression.d.ts +8 -0
- package/dist/{expression → parse/expression/abstract}/DependencyContext.d.ts +0 -1
- package/dist/{expression → parse/expression/abstract}/DependentExpression.d.ts +13 -10
- package/dist/parse/expression/abstract/TextChunkExpression.d.ts +17 -0
- package/dist/parse/model/BindDefinition.d.ts +39 -0
- package/dist/{model → parse/model}/BindElement.d.ts +1 -0
- package/dist/{model → parse/model}/DescendentNodeDefinition.d.ts +0 -1
- package/dist/{model/ValueNodeDefinition.d.ts → parse/model/LeafNodeDefinition.d.ts} +3 -4
- package/dist/{model → parse/model}/ModelBindMap.d.ts +0 -1
- package/dist/{model → parse/model}/ModelDefinition.d.ts +1 -2
- package/dist/{model → parse/model}/NodeDefinition.d.ts +8 -9
- package/dist/parse/model/NoteNodeDefinition.d.ts +30 -0
- package/dist/{model → parse/model}/RepeatInstanceDefinition.d.ts +3 -4
- package/dist/{model → parse/model}/RepeatRangeDefinition.d.ts +14 -5
- package/dist/{model → parse/model}/RepeatTemplateDefinition.d.ts +2 -3
- package/dist/{model → parse/model}/RootDefinition.d.ts +2 -3
- package/dist/{model → parse/model}/SubtreeDefinition.d.ts +1 -2
- package/dist/parse/text/HintDefinition.d.ts +8 -0
- package/dist/parse/text/ItemLabelDefinition.d.ts +8 -0
- package/dist/parse/text/ItemsetLabelDefinition.d.ts +12 -0
- package/dist/parse/text/LabelDefinition.d.ts +14 -0
- package/dist/parse/text/MessageDefinition.d.ts +14 -0
- package/dist/parse/text/abstract/TextElementDefinition.d.ts +22 -0
- package/dist/parse/text/abstract/TextRangeDefinition.d.ts +34 -0
- package/dist/parse/xpath/dependency-analysis.d.ts +40 -0
- package/dist/parse/xpath/path-resolution.d.ts +69 -0
- package/dist/parse/xpath/predicate-analysis.d.ts +29 -0
- package/dist/parse/xpath/reference-parsing.d.ts +17 -0
- package/dist/parse/xpath/semantic-analysis.d.ts +97 -0
- package/dist/parse/xpath/syntax-traversal.d.ts +68 -0
- package/dist/solid.js +8745 -5186
- package/dist/solid.js.map +1 -1
- package/package.json +15 -16
- package/src/client/BaseNode.ts +74 -8
- package/src/client/GroupNode.ts +4 -2
- package/src/client/ModelValueNode.ts +40 -0
- package/src/client/NodeAppearances.ts +1 -1
- package/src/client/NoteNode.ts +74 -0
- package/src/client/README.md +1 -0
- package/src/client/RootNode.ts +4 -2
- package/src/client/SelectNode.ts +6 -4
- package/src/client/StringNode.ts +6 -4
- package/src/client/SubtreeNode.ts +3 -1
- package/src/client/TextRange.ts +98 -2
- package/src/client/TriggerNode.ts +29 -0
- package/src/client/constants.ts +10 -0
- package/src/client/hierarchy.ts +43 -15
- package/src/client/node-types.ts +17 -2
- package/src/client/{RepeatRangeNode.ts → repeat/BaseRepeatRangeNode.ts} +18 -19
- package/src/client/{RepeatInstanceNode.ts → repeat/RepeatInstanceNode.ts} +10 -8
- package/src/client/repeat/RepeatRangeControlledNode.ts +20 -0
- package/src/client/repeat/RepeatRangeUncontrolledNode.ts +21 -0
- package/src/client/unsupported/RangeNode.ts +14 -0
- package/src/client/unsupported/RankNode.ts +14 -0
- package/src/client/unsupported/UnsupportedControlNode.ts +40 -0
- package/src/client/unsupported/UploadNode.ts +14 -0
- package/src/client/validation.ts +199 -0
- package/src/index.ts +21 -9
- package/src/instance/Group.ts +10 -4
- package/src/instance/ModelValue.ts +104 -0
- package/src/instance/Note.ts +142 -0
- package/src/instance/Root.ts +16 -6
- package/src/instance/SelectField.ts +29 -7
- package/src/instance/StringField.ts +36 -10
- package/src/instance/Subtree.ts +9 -3
- package/src/instance/TriggerControl.ts +134 -0
- package/src/instance/abstract/DescendantNode.ts +9 -10
- package/src/instance/abstract/InstanceNode.ts +29 -7
- package/src/instance/abstract/UnsupportedControl.ts +151 -0
- package/src/instance/children.ts +113 -16
- package/src/instance/hierarchy.ts +42 -5
- package/src/instance/index.ts +1 -1
- package/src/instance/internal-api/EvaluationContext.ts +1 -1
- package/src/instance/internal-api/ValidationContext.ts +32 -0
- package/src/instance/internal-api/ValueContext.ts +3 -3
- package/src/instance/{RepeatRange.ts → repeat/BaseRepeatRange.ts} +114 -99
- package/src/instance/{RepeatInstance.ts → repeat/RepeatInstance.ts} +27 -22
- package/src/instance/repeat/RepeatRangeControlled.ts +82 -0
- package/src/instance/repeat/RepeatRangeUncontrolled.ts +67 -0
- package/src/instance/text/TextRange.ts +10 -4
- package/src/instance/unsupported/RangeControl.ts +5 -0
- package/src/instance/unsupported/RankControl.ts +5 -0
- package/src/instance/unsupported/UploadControl.ts +5 -0
- package/src/lib/TokenListParser.ts +11 -7
- package/src/lib/dom/query.ts +1 -1
- package/src/lib/reactivity/createComputedExpression.ts +25 -27
- package/src/lib/reactivity/createNoteReadonlyThunk.ts +33 -0
- package/src/lib/reactivity/createSelectItems.ts +23 -16
- package/src/lib/reactivity/createValueState.ts +3 -3
- package/src/lib/reactivity/node-state/createSharedNodeState.ts +1 -1
- package/src/lib/reactivity/node-state/createSpecifiedState.ts +1 -1
- package/src/lib/reactivity/text/createFieldHint.ts +9 -7
- package/src/lib/reactivity/text/createNodeLabel.ts +8 -6
- package/src/lib/reactivity/text/createNoteText.ts +72 -0
- package/src/lib/reactivity/text/createTextRange.ts +17 -90
- package/src/lib/reactivity/validation/createAggregatedViolations.ts +75 -0
- package/src/lib/reactivity/validation/createValidation.ts +196 -0
- package/src/{XFormDataType.ts → parse/XFormDataType.ts} +1 -3
- package/src/{XFormDefinition.ts → parse/XFormDefinition.ts} +2 -2
- package/src/{body → parse/body}/BodyDefinition.ts +44 -27
- package/src/{body → parse/body}/BodyElementDefinition.ts +13 -6
- package/src/{body → parse/body}/RepeatElementDefinition.ts +10 -20
- package/src/{body → parse/body}/appearance/inputAppearanceParser.ts +1 -1
- package/src/{body → parse/body}/appearance/selectAppearanceParser.ts +1 -1
- package/src/{body → parse/body}/appearance/structureElementAppearanceParser.ts +1 -1
- package/src/parse/body/appearance/unknownAppearanceParser.ts +5 -0
- package/src/{body → parse/body}/control/ControlDefinition.ts +5 -4
- package/src/parse/body/control/RangeControlDefinition.ts +26 -0
- package/src/parse/body/control/RankControlDefinition.ts +27 -0
- package/src/parse/body/control/TriggerControlDefinition.ts +26 -0
- package/src/parse/body/control/UploadControlDefinition.ts +26 -0
- package/src/{body → parse/body}/control/select/ItemDefinition.ts +4 -4
- package/src/parse/body/control/select/ItemsetDefinition.ts +53 -0
- package/src/{body → parse/body}/control/select/ItemsetNodesetContext.ts +2 -2
- package/src/{body → parse/body}/control/select/SelectDefinition.ts +3 -11
- package/src/{body → parse/body}/group/BaseGroupDefinition.ts +11 -21
- package/src/{body → parse/body}/group/PresentationGroupDefinition.ts +1 -1
- package/src/{model/BindComputation.ts → parse/expression/BindComputationExpression.ts} +8 -12
- package/src/parse/expression/ItemsetNodesetExpression.ts +8 -0
- package/src/{body/control/select → parse/expression}/ItemsetValueExpression.ts +2 -2
- package/src/parse/expression/RepeatCountControlExpression.ts +44 -0
- package/src/parse/expression/TextLiteralExpression.ts +19 -0
- package/src/parse/expression/TextOutputExpression.ts +25 -0
- package/src/parse/expression/TextReferenceExpression.ts +14 -0
- package/src/parse/expression/TextTranslationExpression.ts +38 -0
- package/src/{expression → parse/expression/abstract}/DependentExpression.ts +46 -28
- package/src/parse/expression/abstract/TextChunkExpression.ts +38 -0
- package/src/{model → parse/model}/BindDefinition.ts +30 -27
- package/src/{model → parse/model}/BindElement.ts +1 -0
- package/src/{model/ValueNodeDefinition.ts → parse/model/LeafNodeDefinition.ts} +4 -4
- package/src/{model → parse/model}/ModelBindMap.ts +4 -0
- package/src/{model → parse/model}/NodeDefinition.ts +12 -12
- package/src/parse/model/NoteNodeDefinition.ts +70 -0
- package/src/{model → parse/model}/RepeatInstanceDefinition.ts +2 -2
- package/src/parse/model/RepeatRangeDefinition.ts +94 -0
- package/src/{model → parse/model}/RootDefinition.ts +8 -4
- package/src/parse/text/HintDefinition.ts +25 -0
- package/src/parse/text/ItemLabelDefinition.ts +25 -0
- package/src/parse/text/ItemsetLabelDefinition.ts +44 -0
- package/src/parse/text/LabelDefinition.ts +61 -0
- package/src/parse/text/MessageDefinition.ts +49 -0
- package/src/parse/text/abstract/TextElementDefinition.ts +71 -0
- package/src/parse/text/abstract/TextRangeDefinition.ts +70 -0
- package/src/parse/xpath/dependency-analysis.ts +105 -0
- package/src/parse/xpath/path-resolution.ts +475 -0
- package/src/parse/xpath/predicate-analysis.ts +61 -0
- package/src/parse/xpath/reference-parsing.ts +90 -0
- package/src/parse/xpath/semantic-analysis.ts +466 -0
- package/src/parse/xpath/syntax-traversal.ts +129 -0
- package/dist/body/text/HintDefinition.d.ts +0 -11
- package/dist/body/text/LabelDefinition.d.ts +0 -22
- package/dist/body/text/TextElementDefinition.d.ts +0 -33
- package/dist/body/text/TextElementOutputPart.d.ts +0 -13
- package/dist/body/text/TextElementPart.d.ts +0 -13
- package/dist/body/text/TextElementReferencePart.d.ts +0 -7
- package/dist/body/text/TextElementStaticPart.d.ts +0 -7
- package/dist/lib/xpath/analysis.d.ts +0 -23
- package/dist/model/BindDefinition.d.ts +0 -32
- package/src/body/control/select/ItemsetDefinition.ts +0 -36
- package/src/body/control/select/ItemsetNodesetExpression.ts +0 -8
- package/src/body/text/HintDefinition.ts +0 -26
- package/src/body/text/LabelDefinition.ts +0 -68
- package/src/body/text/TextElementDefinition.ts +0 -97
- package/src/body/text/TextElementOutputPart.ts +0 -27
- package/src/body/text/TextElementPart.ts +0 -31
- package/src/body/text/TextElementReferencePart.ts +0 -21
- package/src/body/text/TextElementStaticPart.ts +0 -26
- package/src/lib/xpath/analysis.ts +0 -241
- package/src/model/RepeatRangeDefinition.ts +0 -53
- package/src/{XFormDOM.ts → parse/XFormDOM.ts} +0 -0
- package/src/{body → parse/body}/UnsupportedBodyElementDefinition.ts +0 -0
- package/src/{body → parse/body}/control/InputDefinition.ts +1 -1
- /package/src/{body → parse/body}/group/LogicalGroupDefinition.ts +0 -0
- /package/src/{body → parse/body}/group/StructuralGroupDefinition.ts +0 -0
- /package/src/{expression → parse/expression/abstract}/DependencyContext.ts +0 -0
- /package/src/{model → parse/model}/DescendentNodeDefinition.ts +0 -0
- /package/src/{model → parse/model}/ModelDefinition.ts +0 -0
- /package/src/{model → parse/model}/RepeatTemplateDefinition.ts +0 -0
- /package/src/{model → parse/model}/SubtreeDefinition.ts +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AnyNodeDefinition } from '../model/NodeDefinition.ts';
|
|
1
|
+
import { AnyNodeDefinition } from '../parse/model/NodeDefinition.ts';
|
|
2
2
|
import { NodeAppearances } from './NodeAppearances.ts';
|
|
3
3
|
import { TextRange } from './TextRange.ts';
|
|
4
4
|
import { InstanceNodeType } from './node-types.ts';
|
|
5
|
-
|
|
5
|
+
import { NodeValidationState } from './validation.ts';
|
|
6
6
|
export interface BaseNodeState {
|
|
7
7
|
/**
|
|
8
8
|
* Location path reference to the node's primary instance state. This property
|
|
@@ -38,6 +38,17 @@ export interface BaseNodeState {
|
|
|
38
38
|
* {@link BaseNode.parent | parent node}.
|
|
39
39
|
*/
|
|
40
40
|
get relevant(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Specifies whether the node must have a non-blank value to be valid (see
|
|
43
|
+
* {@link value} for details).
|
|
44
|
+
*
|
|
45
|
+
* @see {@link https://getodk.github.io/xforms-spec/#bind-attributes}
|
|
46
|
+
*
|
|
47
|
+
* @default false
|
|
48
|
+
*
|
|
49
|
+
* @todo What is the expected behavior of `required` expressions defined for
|
|
50
|
+
* non-leaf/value nodes?
|
|
51
|
+
*/
|
|
41
52
|
get required(): boolean;
|
|
42
53
|
/**
|
|
43
54
|
* Interfaces for nodes which cannot provide a label should override this to
|
|
@@ -91,6 +102,14 @@ export interface BaseNodeState {
|
|
|
91
102
|
*
|
|
92
103
|
* Parent nodes, i.e. nodes which can contain {@link children}, do not store a
|
|
93
104
|
* value state. For those nodes, their value state should always be `null`.
|
|
105
|
+
*
|
|
106
|
+
* A node's value is considered "blank" when its primary instance state is an
|
|
107
|
+
* empty string, and it is considered "non-blank" otherwise. The engine may
|
|
108
|
+
* represent node values according to aspects of the node's definition (such
|
|
109
|
+
* as its defined data type, its associated control type if any). The node's
|
|
110
|
+
* value being blank or non-blank may contribute to satisfying conditions of
|
|
111
|
+
* the node's validity ({@link constraint}, {@link required}). Otherwise, it
|
|
112
|
+
* is an internal engine consideration.
|
|
94
113
|
*/
|
|
95
114
|
get value(): unknown;
|
|
96
115
|
}
|
|
@@ -136,9 +155,55 @@ export interface BaseNode {
|
|
|
136
155
|
*/
|
|
137
156
|
readonly parent: BaseNode | null;
|
|
138
157
|
/**
|
|
139
|
-
* Each node provides a discrete object representing the stateful aspects of
|
|
140
|
-
* that node which will change over time. When a client provides a
|
|
158
|
+
* Each node provides a discrete object representing the stateful aspects\* of
|
|
159
|
+
* that node which will change over time. When a client provides a
|
|
160
|
+
* {@link OpaqueReactiveObjectFactory}, the engine will update the properties
|
|
161
|
+
* of this object as their respective states change, so a client can implement
|
|
162
|
+
* reactive updates that respond to changes as they occur.
|
|
163
|
+
*
|
|
164
|
+
* \* This includes state which is either client-/user-mutable, or state which
|
|
165
|
+
* is computed based on the core XForms computation model. Each node also
|
|
166
|
+
* exposes {@link validationState}, which reflects the validity of the
|
|
167
|
+
* node, or its descendants.
|
|
141
168
|
*/
|
|
142
169
|
readonly currentState: BaseNodeState;
|
|
170
|
+
/**
|
|
171
|
+
* Represents the validation state of a the node itself, or its descendants.
|
|
172
|
+
*
|
|
173
|
+
* @see {@link AncestorNodeValidationState} and
|
|
174
|
+
* {@link LeafNodeValidationState} for additional details.
|
|
175
|
+
*
|
|
176
|
+
* While filling a form (i.e. prior to submission), validation state can be
|
|
177
|
+
* viewed as computed metadata about the form state. The validation conditions
|
|
178
|
+
* and their violation messages produced by a node _may be computed on
|
|
179
|
+
* demand_. Clients should assume:
|
|
180
|
+
*
|
|
181
|
+
* 1. Validation state **will be current** when directly read by the client.
|
|
182
|
+
* Accessing validation state _may_ invoke engine computation of that state
|
|
183
|
+
* _at that time_.
|
|
184
|
+
*
|
|
185
|
+
* It **may** also be pre-computed by the engine so that direct reads are
|
|
186
|
+
* less computationally expensive, but such optimizations cannot be
|
|
187
|
+
* guaranteed by the engine at this time.
|
|
188
|
+
*
|
|
189
|
+
* 2. For clients providing an {@link OpaqueReactiveObjectFactory}, accessing
|
|
190
|
+
* validation state within a reactive context **will produce updates** to
|
|
191
|
+
* the validation state, as long as the client retains a subscription to
|
|
192
|
+
* that state.
|
|
193
|
+
*
|
|
194
|
+
* If it is possible to detect interruption of such client- reactive
|
|
195
|
+
* subscriptions, the engine _may defer computations_ until subsequent
|
|
196
|
+
* client read/re-subscription, in order to reduce unnecessary
|
|
197
|
+
* computational overhead. Again, such optimizations cannot be guaranteed
|
|
198
|
+
* by the engine at this time.
|
|
199
|
+
*
|
|
200
|
+
* @todo it's easier to conceive a reliable, general solution to optimizing
|
|
201
|
+
* the direct read case, than it is for the client-reactive case (largely
|
|
202
|
+
* because our solution for client reactivity is intentionally opaque). If it
|
|
203
|
+
* turns out that such optimizations are crucial for overall usability, the
|
|
204
|
+
* client-reactive case may best be served by additional APIs for reactive
|
|
205
|
+
* clients to explicitly pause and resume recomputation.
|
|
206
|
+
*/
|
|
207
|
+
readonly validationState: NodeValidationState;
|
|
143
208
|
}
|
|
144
209
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { AnyGroupElementDefinition } from '../body/BodyDefinition.ts';
|
|
2
|
-
import { SubtreeDefinition } from '../model/SubtreeDefinition.ts';
|
|
1
|
+
import { AnyGroupElementDefinition } from '../parse/body/BodyDefinition.ts';
|
|
2
|
+
import { SubtreeDefinition } from '../parse/model/SubtreeDefinition.ts';
|
|
3
3
|
import { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
4
4
|
import { NodeAppearances } from './NodeAppearances.ts';
|
|
5
5
|
import { RootNode } from './RootNode.ts';
|
|
6
6
|
import { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
|
|
7
|
-
|
|
7
|
+
import { AncestorNodeValidationState } from './validation.ts';
|
|
8
8
|
export interface GroupNodeState extends BaseNodeState {
|
|
9
9
|
get hint(): null;
|
|
10
10
|
get children(): readonly GeneralChildNode[];
|
|
@@ -25,4 +25,5 @@ export interface GroupNode extends BaseNode {
|
|
|
25
25
|
readonly root: RootNode;
|
|
26
26
|
readonly parent: GeneralParentNode;
|
|
27
27
|
readonly currentState: GroupNodeState;
|
|
28
|
+
readonly validationState: AncestorNodeValidationState;
|
|
28
29
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
2
|
+
import { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
3
|
+
import { GeneralParentNode } from './hierarchy.ts';
|
|
4
|
+
import { RootNode } from './RootNode.ts';
|
|
5
|
+
import { LeafNodeValidationState } from './validation.ts';
|
|
6
|
+
export interface ModelValueNodeState extends BaseNodeState {
|
|
7
|
+
get label(): null;
|
|
8
|
+
get hint(): null;
|
|
9
|
+
get children(): null;
|
|
10
|
+
get valueOptions(): null;
|
|
11
|
+
/**
|
|
12
|
+
* Reflects the current value of a {@link ModelValueNode}. This value may be
|
|
13
|
+
* populated when a form is loaded, and it may be updated by certain
|
|
14
|
+
* computations defined by the form.
|
|
15
|
+
*/
|
|
16
|
+
get value(): string;
|
|
17
|
+
}
|
|
18
|
+
export interface ModelValueDefinition extends LeafNodeDefinition {
|
|
19
|
+
readonly bodyElement: null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A node which is:
|
|
23
|
+
*
|
|
24
|
+
* - model-only (i.e. it has no corresponding body element)
|
|
25
|
+
* - a leaf/value node (i.e. it has no element children; it may be defined in
|
|
26
|
+
* the form's `<model>` as either an {@link Element} or {@link Attr})
|
|
27
|
+
*/
|
|
28
|
+
export interface ModelValueNode extends BaseNode {
|
|
29
|
+
readonly nodeType: 'model-value';
|
|
30
|
+
readonly appearances: null;
|
|
31
|
+
readonly definition: ModelValueDefinition;
|
|
32
|
+
readonly root: RootNode;
|
|
33
|
+
readonly parent: GeneralParentNode;
|
|
34
|
+
readonly currentState: ModelValueNodeState;
|
|
35
|
+
readonly validationState: LeafNodeValidationState;
|
|
36
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ParsedTokenList } from '../lib/TokenListParser.ts';
|
|
2
|
-
import { NodeDefinition } from '../model/NodeDefinition.ts';
|
|
3
|
-
|
|
2
|
+
import { NodeDefinition } from '../parse/model/NodeDefinition.ts';
|
|
4
3
|
/**
|
|
5
4
|
* - Provides a means to distinguish between internal and client-facing names
|
|
6
5
|
* for the same {@link ParsedTokenList} types.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { InputDefinition } from '../parse/body/control/InputDefinition.ts';
|
|
2
|
+
import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
3
|
+
import { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
4
|
+
import { GeneralParentNode } from './hierarchy.ts';
|
|
5
|
+
import { NodeAppearances } from './NodeAppearances.ts';
|
|
6
|
+
import { RootNode } from './RootNode.ts';
|
|
7
|
+
import { TextRange } from './TextRange.ts';
|
|
8
|
+
import { LeafNodeValidationState } from './validation.ts';
|
|
9
|
+
export interface NoteNodeState extends BaseNodeState {
|
|
10
|
+
/**
|
|
11
|
+
* Note-specific specialization: a note will always have a non-null value in
|
|
12
|
+
* at least one of:
|
|
13
|
+
*
|
|
14
|
+
* - {@link label}
|
|
15
|
+
* - {@link hint}
|
|
16
|
+
*
|
|
17
|
+
* This is an alias to whichever is present, with precedent to {@link label}
|
|
18
|
+
* if both are present.
|
|
19
|
+
*/
|
|
20
|
+
get noteText(): NonNullable<this['label'] | this['hint']>;
|
|
21
|
+
/**
|
|
22
|
+
* A note will **always** be `readonly`.
|
|
23
|
+
*/
|
|
24
|
+
readonly readonly: true;
|
|
25
|
+
get label(): TextRange<'label', 'form'> | null;
|
|
26
|
+
get hint(): TextRange<'hint', 'form'> | null;
|
|
27
|
+
get children(): null;
|
|
28
|
+
get valueOptions(): null;
|
|
29
|
+
/**
|
|
30
|
+
* Reflects the readonly value of a {@link NoteNode}, or `null` if blank.
|
|
31
|
+
*/
|
|
32
|
+
get value(): string | null;
|
|
33
|
+
}
|
|
34
|
+
export interface NoteDefinition extends LeafNodeDefinition {
|
|
35
|
+
readonly bodyElement: InputDefinition;
|
|
36
|
+
}
|
|
37
|
+
export type NoteNodeAppearances = NodeAppearances<NoteDefinition>;
|
|
38
|
+
/**
|
|
39
|
+
* A node which is:
|
|
40
|
+
*
|
|
41
|
+
* - associated with an input, with at least one text element (label or hint)
|
|
42
|
+
* - guaranteed to be {@link NoteNodeState.readonly | readonly}
|
|
43
|
+
*/
|
|
44
|
+
export interface NoteNode extends BaseNode {
|
|
45
|
+
readonly nodeType: 'note';
|
|
46
|
+
readonly appearances: NoteNodeAppearances;
|
|
47
|
+
readonly definition: NoteDefinition;
|
|
48
|
+
readonly root: RootNode;
|
|
49
|
+
readonly parent: GeneralParentNode;
|
|
50
|
+
readonly currentState: NoteNodeState;
|
|
51
|
+
readonly validationState: LeafNodeValidationState;
|
|
52
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BodyClassList } from '../body/BodyDefinition.ts';
|
|
2
|
-
import { RootDefinition } from '../model/RootDefinition.ts';
|
|
1
|
+
import { BodyClassList } from '../parse/body/BodyDefinition.ts';
|
|
2
|
+
import { RootDefinition } from '../parse/model/RootDefinition.ts';
|
|
3
3
|
import { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
4
4
|
import { ActiveLanguage, FormLanguage, FormLanguages } from './FormLanguage.ts';
|
|
5
5
|
import { GeneralChildNode } from './hierarchy.ts';
|
|
6
|
-
|
|
6
|
+
import { AncestorNodeValidationState } from './validation.ts';
|
|
7
7
|
export interface RootNodeState extends BaseNodeState {
|
|
8
8
|
/**
|
|
9
9
|
* This, along with {@link RootNode.languages} is the most significant break
|
|
@@ -42,6 +42,7 @@ export interface RootNode extends BaseNode {
|
|
|
42
42
|
readonly root: RootNode;
|
|
43
43
|
readonly parent: null;
|
|
44
44
|
readonly currentState: RootNodeState;
|
|
45
|
+
readonly validationState: AncestorNodeValidationState;
|
|
45
46
|
/**
|
|
46
47
|
* @todo as with {@link RootNodeState.activeLanguage}, this is the most
|
|
47
48
|
* significant break in consistency across node types.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { AnySelectDefinition } from '../body/control/select/SelectDefinition.ts';
|
|
2
|
-
import {
|
|
1
|
+
import { AnySelectDefinition } from '../parse/body/control/select/SelectDefinition.ts';
|
|
2
|
+
import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
3
3
|
import { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
4
4
|
import { NodeAppearances } from './NodeAppearances.ts';
|
|
5
5
|
import { RootNode } from './RootNode.ts';
|
|
6
6
|
import { TextRange } from './TextRange.ts';
|
|
7
7
|
import { GeneralParentNode } from './hierarchy.ts';
|
|
8
|
-
|
|
8
|
+
import { LeafNodeValidationState } from './validation.ts';
|
|
9
9
|
export interface SelectItem {
|
|
10
10
|
get value(): string;
|
|
11
|
-
get label(): TextRange<'label'> | null;
|
|
11
|
+
get label(): TextRange<'item-label'> | null;
|
|
12
12
|
}
|
|
13
13
|
export interface SelectNodeState extends BaseNodeState {
|
|
14
14
|
get children(): null;
|
|
@@ -30,7 +30,7 @@ export interface SelectNodeState extends BaseNodeState {
|
|
|
30
30
|
*/
|
|
31
31
|
get value(): readonly SelectItem[];
|
|
32
32
|
}
|
|
33
|
-
export interface SelectDefinition extends
|
|
33
|
+
export interface SelectDefinition extends LeafNodeDefinition {
|
|
34
34
|
readonly bodyElement: AnySelectDefinition;
|
|
35
35
|
}
|
|
36
36
|
export type SelectNodeAppearances = NodeAppearances<SelectDefinition>;
|
|
@@ -41,6 +41,7 @@ export interface SelectNode extends BaseNode {
|
|
|
41
41
|
readonly root: RootNode;
|
|
42
42
|
readonly parent: GeneralParentNode;
|
|
43
43
|
readonly currentState: SelectNodeState;
|
|
44
|
+
readonly validationState: LeafNodeValidationState;
|
|
44
45
|
/**
|
|
45
46
|
* For use by a client to update the selection of a select node where:
|
|
46
47
|
*
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { InputDefinition } from '../body/control/InputDefinition.ts';
|
|
2
|
-
import {
|
|
1
|
+
import { InputDefinition } from '../parse/body/control/InputDefinition.ts';
|
|
2
|
+
import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
3
3
|
import { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
4
4
|
import { NodeAppearances } from './NodeAppearances.ts';
|
|
5
5
|
import { RootNode } from './RootNode.ts';
|
|
6
6
|
import { GeneralParentNode } from './hierarchy.ts';
|
|
7
|
-
|
|
7
|
+
import { LeafNodeValidationState } from './validation.ts';
|
|
8
8
|
export interface StringNodeState extends BaseNodeState {
|
|
9
9
|
get children(): null;
|
|
10
10
|
get valueOptions(): null;
|
|
@@ -16,8 +16,8 @@ export interface StringNodeState extends BaseNodeState {
|
|
|
16
16
|
*/
|
|
17
17
|
get value(): string;
|
|
18
18
|
}
|
|
19
|
-
export interface StringDefinition extends
|
|
20
|
-
readonly bodyElement: InputDefinition
|
|
19
|
+
export interface StringDefinition extends LeafNodeDefinition {
|
|
20
|
+
readonly bodyElement: InputDefinition;
|
|
21
21
|
}
|
|
22
22
|
export type StringNodeAppearances = NodeAppearances<StringDefinition>;
|
|
23
23
|
/**
|
|
@@ -34,6 +34,7 @@ export interface StringNode extends BaseNode {
|
|
|
34
34
|
readonly root: RootNode;
|
|
35
35
|
readonly parent: GeneralParentNode;
|
|
36
36
|
readonly currentState: StringNodeState;
|
|
37
|
+
readonly validationState: LeafNodeValidationState;
|
|
37
38
|
/**
|
|
38
39
|
* For use by a client to update the value of a string node.
|
|
39
40
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { SubtreeDefinition as BaseSubtreeDefinition } from '../model/SubtreeDefinition.ts';
|
|
1
|
+
import { SubtreeDefinition as BaseSubtreeDefinition } from '../parse/model/SubtreeDefinition.ts';
|
|
2
2
|
import { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
3
3
|
import { RootNode } from './RootNode.ts';
|
|
4
4
|
import { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
|
|
5
|
-
|
|
5
|
+
import { AncestorNodeValidationState } from './validation.ts';
|
|
6
6
|
export interface SubtreeNodeState extends BaseNodeState {
|
|
7
7
|
get label(): null;
|
|
8
8
|
get hint(): null;
|
|
@@ -51,4 +51,5 @@ export interface SubtreeNode extends BaseNode {
|
|
|
51
51
|
readonly root: RootNode;
|
|
52
52
|
readonly parent: GeneralParentNode;
|
|
53
53
|
readonly currentState: SubtreeNodeState;
|
|
54
|
+
readonly validationState: AncestorNodeValidationState;
|
|
54
55
|
}
|
|
@@ -1,6 +1,62 @@
|
|
|
1
1
|
import { ActiveLanguage } from './FormLanguage.ts';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* **COMMENTARY**
|
|
4
|
+
*
|
|
5
|
+
* The spec makes naming and mapping these cases a bit more complex than would
|
|
6
|
+
* be ideal. The intent is to clearly identify distinct text definitions (and
|
|
7
|
+
* sub-structural parts) from a source form, in a way that semantically lines up
|
|
8
|
+
* with the ways they will need to be handled at runtime and conveyed to
|
|
9
|
+
* clients. This is the mapping:
|
|
10
|
+
*
|
|
11
|
+
* - 'output': All output values, i.e.:
|
|
12
|
+
* - `output/@value`
|
|
13
|
+
*
|
|
14
|
+
* - 'translation':
|
|
15
|
+
*
|
|
16
|
+
* - Valid XPath translation expressions, in a context accepting mixed
|
|
17
|
+
* translation/static syntax, i.e.:
|
|
18
|
+
*
|
|
19
|
+
* - `h:head//bind/@jr:constraintMsg[is-translation-expr()]`
|
|
20
|
+
* - `h:head//bind/@jr:requiredMsg[is-translation-expr()]`
|
|
21
|
+
*
|
|
22
|
+
* Here, `is-translation-expr()` is a fictional shorthand for checking
|
|
23
|
+
* that the attribute's value is a valid `jr:itext(...)` FunctionCall
|
|
24
|
+
* expression. Note that, per spec, these attributes **do not accept
|
|
25
|
+
* arbitrary XPath expressions**! The non-translation case is treated as
|
|
26
|
+
* static text, not parsed for e.g. an XPath [string] Literal expression.
|
|
27
|
+
* This is why we have introduced this 'translation' case, distinct from
|
|
28
|
+
* 'reference', which previously handled translated labels and hints.
|
|
29
|
+
*
|
|
30
|
+
* - Valid XPath translation expressions, in a context accepting arbitrary
|
|
31
|
+
* XPath expressions, i.e.:
|
|
32
|
+
*
|
|
33
|
+
* - `h:body//label/@ref[is-translation-expr()]`
|
|
34
|
+
*
|
|
35
|
+
* - 'literal':
|
|
36
|
+
* - `h:head//bind/@jr:constraintMsg[not(is-translation-expr())]`
|
|
37
|
+
* - `h:head//bind/@jr:requiredMsg[not(is-translation-expr())]`
|
|
38
|
+
* - `h:body//label/text()`
|
|
39
|
+
* - `h:body//hint/text()`
|
|
40
|
+
*
|
|
41
|
+
* (See notes above for clarification of `is-translation-expr()`.)
|
|
42
|
+
*
|
|
43
|
+
* - 'reference': Any XPath **non-translation** expression defined as a label's
|
|
44
|
+
* (or hint's) `ref` attribute, i.e.
|
|
45
|
+
* - `h:body//label/@ref[not(is-translation-expr())]`
|
|
46
|
+
* - `h:body//hint/@ref[not(is-translation-expr())]`
|
|
47
|
+
*
|
|
48
|
+
* (See notes above for clarification of `is-translation-expr()`.)
|
|
49
|
+
*
|
|
50
|
+
* @todo It's unclear whether this will all become simpler or more compelex when
|
|
51
|
+
* we add support for outputs in translations. In theory, the actual translation
|
|
52
|
+
* `<text>` nodes map quite well to the `TextRange` concept (i.e. they are a
|
|
53
|
+
* range of static and output chunks, just like labels and hints). The potential
|
|
54
|
+
* for complications arise from XPath implementation details being largely
|
|
55
|
+
* opaque (as in, the `jr:itext` implementation is encapsulated in the `xpath`
|
|
56
|
+
* package, and the engine doesn't really deal with itext translations at the
|
|
57
|
+
* node level at all).
|
|
58
|
+
*/
|
|
59
|
+
export type TextChunkSource = 'literal' | 'output' | 'reference' | 'translation';
|
|
4
60
|
/**
|
|
5
61
|
* @todo This (and everything else to do with {@link TextRange}s is for
|
|
6
62
|
* illustration purposes, as a starting point where any particular detail is of
|
|
@@ -18,6 +74,31 @@ export interface TextChunk {
|
|
|
18
74
|
get asString(): string;
|
|
19
75
|
get formatted(): unknown;
|
|
20
76
|
}
|
|
77
|
+
export type ElementTextRole = 'hint' | 'label' | 'item-label';
|
|
78
|
+
export type ValidationTextRole = 'constraintMsg' | 'requiredMsg';
|
|
79
|
+
export type TextRole = ElementTextRole | ValidationTextRole;
|
|
80
|
+
/**
|
|
81
|
+
* Specifies the origin of a {@link TextRange}.
|
|
82
|
+
*
|
|
83
|
+
* - 'form': text is computed from the form definition, as specified for the
|
|
84
|
+
* {@link TextRole}. User-facing clients should present text with this origin
|
|
85
|
+
* where appropriate.
|
|
86
|
+
*
|
|
87
|
+
* - 'form-derived': the form definition lacks a text definition for the
|
|
88
|
+
* {@link TextRole}, but an appropriate one has been derived from a related
|
|
89
|
+
* (and semantically appropriate) aspect of the form (example: a select item
|
|
90
|
+
* without a label may derive that label from the item's value). User-facing
|
|
91
|
+
* clients should generally present text with this origin where provided; this
|
|
92
|
+
* origin clarifies the source of such text.
|
|
93
|
+
*
|
|
94
|
+
* - 'engine': the form definition lacks a definition for the {@link TextRole},
|
|
95
|
+
* but provides a constant default in its absence. User facing clients may
|
|
96
|
+
* disregard these constant text values, or may use them where a sensible
|
|
97
|
+
* default is desired. Clients may also use these constants as keys for
|
|
98
|
+
* translation purposes, as appropriate. Non-user facing clients may reference
|
|
99
|
+
* these constants for e.g. testing purposes.
|
|
100
|
+
*/
|
|
101
|
+
export type TextOrigin = 'form' | 'form-derived' | 'engine';
|
|
21
102
|
/**
|
|
22
103
|
* Represents aspects of a form which produce text, which _might_ be:
|
|
23
104
|
*
|
|
@@ -48,7 +129,8 @@ export interface TextChunk {
|
|
|
48
129
|
* a text range's role may correspond to the "short" or "guidance" `form` of a
|
|
49
130
|
* {@link https://getodk.github.io/xforms-spec/#languages | translation}).
|
|
50
131
|
*/
|
|
51
|
-
export interface TextRange<Role extends
|
|
132
|
+
export interface TextRange<Role extends TextRole, Origin extends TextOrigin = TextOrigin> {
|
|
133
|
+
readonly origin: Origin;
|
|
52
134
|
readonly role: Role;
|
|
53
135
|
[Symbol.iterator](): Iterable<TextChunk>;
|
|
54
136
|
get asString(): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { UnknownAppearanceDefinition } from '../parse/body/appearance/unknownAppearanceParser.ts';
|
|
2
|
+
import { TriggerControlDefinition } from '../parse/body/control/TriggerControlDefinition.ts';
|
|
3
|
+
import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
4
|
+
import { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
5
|
+
import { GeneralParentNode } from './hierarchy.ts';
|
|
6
|
+
import { RootNode } from './RootNode.ts';
|
|
7
|
+
import { LeafNodeValidationState } from './validation.ts';
|
|
8
|
+
export interface TriggerNodeState extends BaseNodeState {
|
|
9
|
+
get children(): null;
|
|
10
|
+
get valueOptions(): null;
|
|
11
|
+
get value(): boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface TriggerNodeDefinition extends LeafNodeDefinition {
|
|
14
|
+
readonly bodyElement: TriggerControlDefinition;
|
|
15
|
+
}
|
|
16
|
+
export interface TriggerNode extends BaseNode {
|
|
17
|
+
readonly nodeType: 'trigger';
|
|
18
|
+
readonly definition: TriggerNodeDefinition;
|
|
19
|
+
readonly appearances: UnknownAppearanceDefinition;
|
|
20
|
+
readonly root: RootNode;
|
|
21
|
+
readonly parent: GeneralParentNode;
|
|
22
|
+
readonly currentState: TriggerNodeState;
|
|
23
|
+
readonly validationState: LeafNodeValidationState;
|
|
24
|
+
setValue(value: boolean): RootNode;
|
|
25
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ValidationTextRole } from './TextRange.ts';
|
|
2
|
+
export declare const VALIDATION_TEXT: {
|
|
3
|
+
readonly constraintMsg: "Condition not satisfied: constraint";
|
|
4
|
+
readonly requiredMsg: "Condition not satisfied: required";
|
|
5
|
+
};
|
|
6
|
+
type ValidationTextDefaults = typeof VALIDATION_TEXT;
|
|
7
|
+
export type ValidationTextDefault<Role extends ValidationTextRole> = ValidationTextDefaults[Role];
|
|
8
|
+
export {};
|
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
import { ExpandUnion } from '../../../common/types/helpers.d.ts';
|
|
2
2
|
import { GroupNode } from './GroupNode.ts';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { ModelValueNode } from './ModelValueNode.ts';
|
|
4
|
+
import { NoteNode } from './NoteNode.ts';
|
|
5
|
+
import { RepeatInstanceNode } from './repeat/RepeatInstanceNode.ts';
|
|
6
|
+
import { RepeatRangeControlledNode } from './repeat/RepeatRangeControlledNode.ts';
|
|
7
|
+
import { RepeatRangeUncontrolledNode } from './repeat/RepeatRangeUncontrolledNode.ts';
|
|
5
8
|
import { RootNode } from './RootNode.ts';
|
|
6
9
|
import { SelectNode } from './SelectNode.ts';
|
|
7
10
|
import { StringNode } from './StringNode.ts';
|
|
8
11
|
import { SubtreeNode } from './SubtreeNode.ts';
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
import { TriggerNode } from './TriggerNode.ts';
|
|
13
|
+
import { RangeNode } from './unsupported/RangeNode.ts';
|
|
14
|
+
import { RankNode } from './unsupported/RankNode.ts';
|
|
15
|
+
import { UploadNode } from './unsupported/UploadNode.ts';
|
|
16
|
+
export type AnyUnsupportedControlNode = RangeNode | RankNode | UploadNode;
|
|
17
|
+
export type AnyControlNode = NoteNode | SelectNode | StringNode | TriggerNode;
|
|
18
|
+
export type AnyLeafNode = AnyControlNode | AnyUnsupportedControlNode | ModelValueNode;
|
|
19
|
+
export type RepeatRangeNode = RepeatRangeControlledNode | RepeatRangeUncontrolledNode;
|
|
20
|
+
/**
|
|
21
|
+
* Any of the concrete node types which may be a parent of non-repeat instance
|
|
22
|
+
* child nodes.
|
|
23
|
+
*/
|
|
24
|
+
export type GeneralParentNode = RootNode | SubtreeNode | GroupNode | RepeatInstanceNode;
|
|
11
25
|
/**
|
|
12
26
|
* Any of the concrete node types which may be a parent of any other node.
|
|
13
27
|
*
|
|
@@ -17,7 +31,7 @@ export type AnyLeafNode = SelectNode | StringNode;
|
|
|
17
31
|
* - Repeat instances should (continue to) specify {@link RepeatRangeNode}.
|
|
18
32
|
* - All other child nodes should specify {@link GeneralParentNode}.
|
|
19
33
|
*/
|
|
20
|
-
export type AnyParentNode =
|
|
34
|
+
export type AnyParentNode = GeneralParentNode | RepeatRangeNode;
|
|
21
35
|
/**
|
|
22
36
|
* Any of the concrete node types a client may get from the engine's form
|
|
23
37
|
* representation. This union should be updated when any new concrete node type
|
|
@@ -27,11 +41,6 @@ export type AnyParentNode = RootNode | SubtreeNode | GroupNode | RepeatRangeNode
|
|
|
27
41
|
* @see {@link GeneralChildNode}, which is derived from this type
|
|
28
42
|
*/
|
|
29
43
|
export type AnyNode = ExpandUnion<AnyLeafNode | AnyParentNode>;
|
|
30
|
-
/**
|
|
31
|
-
* Any of the concrete node types which may be a parent of non-repeat instance
|
|
32
|
-
* child nodes.
|
|
33
|
-
*/
|
|
34
|
-
export type GeneralParentNode = Exclude<AnyParentNode, RepeatRangeNode>;
|
|
35
44
|
/**
|
|
36
45
|
* Any of the concrete node types which may be a child of any other node.
|
|
37
46
|
*
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type UnsupportedControlNodeType = 'range' | 'rank' | 'upload';
|
|
2
|
+
export type RepeatRangeNodeType = 'repeat-range:controlled' | 'repeat-range:uncontrolled';
|
|
3
|
+
export type InstanceNodeType = 'root' | RepeatRangeNodeType | 'repeat-instance' | 'group' | 'subtree' | 'model-value' | 'note' | 'select' | 'string' | 'trigger' | UnsupportedControlNodeType;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseNode, BaseNodeState } from '
|
|
3
|
-
import { NodeAppearances } from '
|
|
1
|
+
import { AnyRepeatRangeDefinition } from '../../parse/model/RepeatRangeDefinition.ts';
|
|
2
|
+
import { BaseNode, BaseNodeState } from '../BaseNode.ts';
|
|
3
|
+
import { NodeAppearances } from '../NodeAppearances.ts';
|
|
4
|
+
import { RootNode } from '../RootNode.ts';
|
|
5
|
+
import { TextRange } from '../TextRange.ts';
|
|
6
|
+
import { GeneralParentNode } from '../hierarchy.ts';
|
|
7
|
+
import { RepeatRangeNodeType } from '../node-types.ts';
|
|
8
|
+
import { AncestorNodeValidationState } from '../validation.ts';
|
|
4
9
|
import { RepeatInstanceNode } from './RepeatInstanceNode.ts';
|
|
5
|
-
|
|
6
|
-
import { TextRange } from './TextRange.ts';
|
|
7
|
-
import { GeneralParentNode } from './hierarchy.ts';
|
|
8
|
-
|
|
9
|
-
export interface RepeatRangeNodeState extends BaseNodeState {
|
|
10
|
+
export interface BaseRepeatRangeNodeState extends BaseNodeState {
|
|
10
11
|
get hint(): null;
|
|
11
12
|
get label(): TextRange<'label'> | null;
|
|
12
13
|
/**
|
|
@@ -15,17 +16,17 @@ export interface RepeatRangeNodeState extends BaseNodeState {
|
|
|
15
16
|
* Note: the web-forms engine's representation of this structure differs from
|
|
16
17
|
* the underlying XForms specification's primary instance structure.
|
|
17
18
|
*
|
|
18
|
-
* @see {@link
|
|
19
|
+
* @see {@link BaseRepeatRangeNode} for additional detail.
|
|
19
20
|
*/
|
|
20
21
|
get children(): readonly RepeatInstanceNode[];
|
|
21
22
|
get valueOptions(): null;
|
|
22
23
|
get value(): null;
|
|
23
24
|
}
|
|
24
|
-
export type RepeatRangeNodeAppearances = NodeAppearances<
|
|
25
|
+
export type RepeatRangeNodeAppearances = NodeAppearances<AnyRepeatRangeDefinition>;
|
|
25
26
|
/**
|
|
26
27
|
* Represents a contiguous set of zero or more {@link RepeatInstanceNode}s
|
|
27
28
|
* (accessed by its
|
|
28
|
-
* {@link
|
|
29
|
+
* {@link BaseRepeatRangeNodeState.children | `currentState.children`}).
|
|
29
30
|
*
|
|
30
31
|
* This structure is modeled as a node, like any other, in the web-forms engine
|
|
31
32
|
* representation, which notably differs from the corresponding structure in the
|
|
@@ -84,15 +85,14 @@ export type RepeatRangeNodeAppearances = NodeAppearances<RepeatRangeDefinition>;
|
|
|
84
85
|
* Importantly, if the state of a given repeat range has no instances, no aspect
|
|
85
86
|
* of these repeats will be present in the underlying XForms primary instance
|
|
86
87
|
* state, but the web-forms engine's representations **retains a reference** to
|
|
87
|
-
* its {@link
|
|
88
|
+
* its {@link BaseRepeatRangeNode}.
|
|
88
89
|
*/
|
|
89
|
-
export interface
|
|
90
|
-
readonly nodeType:
|
|
90
|
+
export interface BaseRepeatRangeNode extends BaseNode {
|
|
91
|
+
readonly nodeType: RepeatRangeNodeType;
|
|
91
92
|
readonly appearances: RepeatRangeNodeAppearances;
|
|
92
|
-
readonly definition:
|
|
93
|
+
readonly definition: AnyRepeatRangeDefinition;
|
|
93
94
|
readonly root: RootNode;
|
|
94
95
|
readonly parent: GeneralParentNode;
|
|
95
|
-
readonly currentState:
|
|
96
|
-
|
|
97
|
-
removeInstances(startIndex: number, count?: number): RootNode;
|
|
96
|
+
readonly currentState: BaseRepeatRangeNodeState;
|
|
97
|
+
readonly validationState: AncestorNodeValidationState;
|
|
98
98
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { RepeatInstanceDefinition } from '
|
|
2
|
-
import { RepeatTemplateDefinition } from '
|
|
3
|
-
import { BaseNode, BaseNodeState } from '
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { RootNode } from '
|
|
7
|
-
import {
|
|
8
|
-
|
|
1
|
+
import { RepeatInstanceDefinition } from '../../parse/model/RepeatInstanceDefinition.ts';
|
|
2
|
+
import { RepeatTemplateDefinition } from '../../parse/model/RepeatTemplateDefinition.ts';
|
|
3
|
+
import { BaseNode, BaseNodeState } from '../BaseNode.ts';
|
|
4
|
+
import { GeneralChildNode, RepeatRangeNode } from '../hierarchy.ts';
|
|
5
|
+
import { NodeAppearances } from '../NodeAppearances.ts';
|
|
6
|
+
import { RootNode } from '../RootNode.ts';
|
|
7
|
+
import { AncestorNodeValidationState } from '../validation.ts';
|
|
9
8
|
export interface RepeatInstanceNodeState extends BaseNodeState {
|
|
10
9
|
get hint(): null;
|
|
11
10
|
get children(): readonly GeneralChildNode[];
|
|
@@ -25,8 +24,9 @@ export interface RepeatInstanceNode extends BaseNode {
|
|
|
25
24
|
* Note: the web-forms engine's representation of this structure differs from
|
|
26
25
|
* the underlying XForms specification's primary instance structure.
|
|
27
26
|
*
|
|
28
|
-
* @see {@link
|
|
27
|
+
* @see {@link BaseRepeatRangeNode} for additional detail.
|
|
29
28
|
*/
|
|
30
29
|
readonly parent: RepeatRangeNode;
|
|
31
30
|
readonly currentState: RepeatInstanceNodeState;
|
|
31
|
+
readonly validationState: AncestorNodeValidationState;
|
|
32
32
|
}
|