@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
package/src/client/hierarchy.ts
CHANGED
|
@@ -1,16 +1,52 @@
|
|
|
1
1
|
import type { ExpandUnion } from '@getodk/common/types/helpers.d.ts';
|
|
2
2
|
import type { GroupNode } from './GroupNode.ts';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
3
|
+
import type { ModelValueNode } from './ModelValueNode.ts';
|
|
4
|
+
import type { NoteNode } from './NoteNode.ts';
|
|
5
|
+
import type { RepeatInstanceNode } from './repeat/RepeatInstanceNode.ts';
|
|
6
|
+
import type { RepeatRangeControlledNode } from './repeat/RepeatRangeControlledNode.ts';
|
|
7
|
+
import type { RepeatRangeUncontrolledNode } from './repeat/RepeatRangeUncontrolledNode.ts';
|
|
5
8
|
import type { RootNode } from './RootNode.ts';
|
|
6
9
|
import type { SelectNode } from './SelectNode.ts';
|
|
7
10
|
import type { StringNode } from './StringNode.ts';
|
|
8
11
|
import type { SubtreeNode } from './SubtreeNode.ts';
|
|
12
|
+
import type { TriggerNode } from './TriggerNode.ts';
|
|
13
|
+
import type { RangeNode } from './unsupported/RangeNode.ts';
|
|
14
|
+
import type { RankNode } from './unsupported/RankNode.ts';
|
|
15
|
+
import type { UploadNode } from './unsupported/UploadNode.ts';
|
|
9
16
|
|
|
10
17
|
// prettier-ignore
|
|
11
|
-
export type
|
|
18
|
+
export type AnyUnsupportedControlNode =
|
|
19
|
+
| RangeNode
|
|
20
|
+
| RankNode
|
|
21
|
+
| UploadNode;
|
|
22
|
+
|
|
23
|
+
// prettier-ignore
|
|
24
|
+
export type AnyControlNode =
|
|
25
|
+
| NoteNode
|
|
12
26
|
| SelectNode
|
|
13
|
-
| StringNode
|
|
27
|
+
| StringNode
|
|
28
|
+
| TriggerNode;
|
|
29
|
+
|
|
30
|
+
// prettier-ignore
|
|
31
|
+
export type AnyLeafNode =
|
|
32
|
+
| AnyControlNode
|
|
33
|
+
| AnyUnsupportedControlNode
|
|
34
|
+
| ModelValueNode;
|
|
35
|
+
|
|
36
|
+
// prettier-ignore
|
|
37
|
+
export type RepeatRangeNode =
|
|
38
|
+
| RepeatRangeControlledNode
|
|
39
|
+
| RepeatRangeUncontrolledNode;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Any of the concrete node types which may be a parent of non-repeat instance
|
|
43
|
+
* child nodes.
|
|
44
|
+
*/
|
|
45
|
+
export type GeneralParentNode =
|
|
46
|
+
| RootNode // eslint-disable-line @typescript-eslint/sort-type-constituents
|
|
47
|
+
| SubtreeNode
|
|
48
|
+
| GroupNode
|
|
49
|
+
| RepeatInstanceNode;
|
|
14
50
|
|
|
15
51
|
/**
|
|
16
52
|
* Any of the concrete node types which may be a parent of any other node.
|
|
@@ -21,12 +57,10 @@ export type AnyLeafNode =
|
|
|
21
57
|
* - Repeat instances should (continue to) specify {@link RepeatRangeNode}.
|
|
22
58
|
* - All other child nodes should specify {@link GeneralParentNode}.
|
|
23
59
|
*/
|
|
60
|
+
// prettier-ignore
|
|
24
61
|
export type AnyParentNode =
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
| GroupNode
|
|
28
|
-
| RepeatRangeNode
|
|
29
|
-
| RepeatInstanceNode;
|
|
62
|
+
| GeneralParentNode
|
|
63
|
+
| RepeatRangeNode;
|
|
30
64
|
|
|
31
65
|
/**
|
|
32
66
|
* Any of the concrete node types a client may get from the engine's form
|
|
@@ -38,12 +72,6 @@ export type AnyParentNode =
|
|
|
38
72
|
*/
|
|
39
73
|
export type AnyNode = ExpandUnion<AnyLeafNode | AnyParentNode>;
|
|
40
74
|
|
|
41
|
-
/**
|
|
42
|
-
* Any of the concrete node types which may be a parent of non-repeat instance
|
|
43
|
-
* child nodes.
|
|
44
|
-
*/
|
|
45
|
-
export type GeneralParentNode = Exclude<AnyParentNode, RepeatRangeNode>;
|
|
46
|
-
|
|
47
75
|
/**
|
|
48
76
|
* Any of the concrete node types which may be a child of any other node.
|
|
49
77
|
*
|
package/src/client/node-types.ts
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
|
+
// prettier-ignore
|
|
2
|
+
export type UnsupportedControlNodeType =
|
|
3
|
+
| 'range'
|
|
4
|
+
| 'rank'
|
|
5
|
+
| 'upload';
|
|
6
|
+
|
|
7
|
+
// prettier-ignore
|
|
8
|
+
export type RepeatRangeNodeType =
|
|
9
|
+
| 'repeat-range:controlled'
|
|
10
|
+
| 'repeat-range:uncontrolled'
|
|
11
|
+
|
|
1
12
|
// prettier-ignore
|
|
2
13
|
export type InstanceNodeType =
|
|
3
14
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
4
15
|
| 'root'
|
|
5
|
-
|
|
|
16
|
+
| RepeatRangeNodeType
|
|
6
17
|
| 'repeat-instance'
|
|
7
18
|
| 'group'
|
|
8
19
|
| 'subtree'
|
|
20
|
+
| 'model-value'
|
|
21
|
+
| 'note'
|
|
9
22
|
| 'select'
|
|
10
|
-
| 'string'
|
|
23
|
+
| 'string'
|
|
24
|
+
| 'trigger'
|
|
25
|
+
| UnsupportedControlNodeType;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { BaseNode, BaseNodeState } from '
|
|
3
|
-
import type { NodeAppearances } from '
|
|
1
|
+
import type { AnyRepeatRangeDefinition } from '../../parse/model/RepeatRangeDefinition.ts';
|
|
2
|
+
import type { BaseNode, BaseNodeState } from '../BaseNode.ts';
|
|
3
|
+
import type { NodeAppearances } from '../NodeAppearances.ts';
|
|
4
|
+
import type { RootNode } from '../RootNode.ts';
|
|
5
|
+
import type { TextRange } from '../TextRange.ts';
|
|
6
|
+
import type { GeneralParentNode } from '../hierarchy.ts';
|
|
7
|
+
import type { RepeatRangeNodeType } from '../node-types.ts';
|
|
8
|
+
import type { AncestorNodeValidationState } from '../validation.ts';
|
|
4
9
|
import type { RepeatInstanceNode } from './RepeatInstanceNode.ts';
|
|
5
|
-
import type { RootNode } from './RootNode.ts';
|
|
6
|
-
import type { TextRange } from './TextRange.ts';
|
|
7
|
-
import type { GeneralParentNode } from './hierarchy.ts';
|
|
8
10
|
|
|
9
|
-
export interface
|
|
11
|
+
export interface BaseRepeatRangeNodeState extends BaseNodeState {
|
|
10
12
|
get hint(): null;
|
|
11
13
|
get label(): TextRange<'label'> | null;
|
|
12
14
|
|
|
@@ -16,7 +18,7 @@ export interface RepeatRangeNodeState extends BaseNodeState {
|
|
|
16
18
|
* Note: the web-forms engine's representation of this structure differs from
|
|
17
19
|
* the underlying XForms specification's primary instance structure.
|
|
18
20
|
*
|
|
19
|
-
* @see {@link
|
|
21
|
+
* @see {@link BaseRepeatRangeNode} for additional detail.
|
|
20
22
|
*/
|
|
21
23
|
get children(): readonly RepeatInstanceNode[];
|
|
22
24
|
|
|
@@ -24,12 +26,12 @@ export interface RepeatRangeNodeState extends BaseNodeState {
|
|
|
24
26
|
get value(): null;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
export type RepeatRangeNodeAppearances = NodeAppearances<
|
|
29
|
+
export type RepeatRangeNodeAppearances = NodeAppearances<AnyRepeatRangeDefinition>;
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
32
|
* Represents a contiguous set of zero or more {@link RepeatInstanceNode}s
|
|
31
33
|
* (accessed by its
|
|
32
|
-
* {@link
|
|
34
|
+
* {@link BaseRepeatRangeNodeState.children | `currentState.children`}).
|
|
33
35
|
*
|
|
34
36
|
* This structure is modeled as a node, like any other, in the web-forms engine
|
|
35
37
|
* representation, which notably differs from the corresponding structure in the
|
|
@@ -88,17 +90,14 @@ export type RepeatRangeNodeAppearances = NodeAppearances<RepeatRangeDefinition>;
|
|
|
88
90
|
* Importantly, if the state of a given repeat range has no instances, no aspect
|
|
89
91
|
* of these repeats will be present in the underlying XForms primary instance
|
|
90
92
|
* state, but the web-forms engine's representations **retains a reference** to
|
|
91
|
-
* its {@link
|
|
93
|
+
* its {@link BaseRepeatRangeNode}.
|
|
92
94
|
*/
|
|
93
|
-
export interface
|
|
94
|
-
readonly nodeType:
|
|
95
|
+
export interface BaseRepeatRangeNode extends BaseNode {
|
|
96
|
+
readonly nodeType: RepeatRangeNodeType;
|
|
95
97
|
readonly appearances: RepeatRangeNodeAppearances;
|
|
96
|
-
readonly definition:
|
|
98
|
+
readonly definition: AnyRepeatRangeDefinition;
|
|
97
99
|
readonly root: RootNode;
|
|
98
100
|
readonly parent: GeneralParentNode;
|
|
99
|
-
readonly currentState:
|
|
100
|
-
|
|
101
|
-
addInstances(afterIndex?: number, count?: number): RootNode;
|
|
102
|
-
|
|
103
|
-
removeInstances(startIndex: number, count?: number): RootNode;
|
|
101
|
+
readonly currentState: BaseRepeatRangeNodeState;
|
|
102
|
+
readonly validationState: AncestorNodeValidationState;
|
|
104
103
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { RepeatInstanceDefinition } from '
|
|
2
|
-
import type { RepeatTemplateDefinition } from '
|
|
3
|
-
import type { BaseNode, BaseNodeState } from '
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type { RootNode } from '
|
|
7
|
-
import type {
|
|
1
|
+
import type { RepeatInstanceDefinition } from '../../parse/model/RepeatInstanceDefinition.ts';
|
|
2
|
+
import type { RepeatTemplateDefinition } from '../../parse/model/RepeatTemplateDefinition.ts';
|
|
3
|
+
import type { BaseNode, BaseNodeState } from '../BaseNode.ts';
|
|
4
|
+
import type { GeneralChildNode, RepeatRangeNode } from '../hierarchy.ts';
|
|
5
|
+
import type { NodeAppearances } from '../NodeAppearances.ts';
|
|
6
|
+
import type { RootNode } from '../RootNode.ts';
|
|
7
|
+
import type { AncestorNodeValidationState } from '../validation.ts';
|
|
8
|
+
import type { BaseRepeatRangeNode } from './BaseRepeatRangeNode.ts';
|
|
8
9
|
|
|
9
10
|
export interface RepeatInstanceNodeState extends BaseNodeState {
|
|
10
11
|
// TODO(?): Previous iteration included an `index` getter here. I don't see it
|
|
@@ -37,9 +38,10 @@ export interface RepeatInstanceNode extends BaseNode {
|
|
|
37
38
|
* Note: the web-forms engine's representation of this structure differs from
|
|
38
39
|
* the underlying XForms specification's primary instance structure.
|
|
39
40
|
*
|
|
40
|
-
* @see {@link
|
|
41
|
+
* @see {@link BaseRepeatRangeNode} for additional detail.
|
|
41
42
|
*/
|
|
42
43
|
readonly parent: RepeatRangeNode;
|
|
43
44
|
|
|
44
45
|
readonly currentState: RepeatInstanceNodeState;
|
|
46
|
+
readonly validationState: AncestorNodeValidationState;
|
|
45
47
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ControlledRepeatRangeDefinition } from '../../parse/model/RepeatRangeDefinition.ts';
|
|
2
|
+
import type { BaseRepeatRangeNode, BaseRepeatRangeNodeState } from './BaseRepeatRangeNode.ts';
|
|
3
|
+
import type { RepeatRangeUncontrolledNode } from './RepeatRangeUncontrolledNode.ts';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* {@inheritDoc BaseRepeatRangeNodeState}
|
|
7
|
+
* @see {@link BaseRepeatRangeNodeState}
|
|
8
|
+
*/
|
|
9
|
+
export interface RepeatRangeControlledState extends BaseRepeatRangeNodeState {}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Represents a repeat range whose repeat instances are controlled by the
|
|
13
|
+
* engine, and cannot be added or removed by a client. Functionality and
|
|
14
|
+
* semantics are otherwise consistent with an [uncontrolled]
|
|
15
|
+
* {@link RepeatRangeUncontrolledNode}.
|
|
16
|
+
*/
|
|
17
|
+
export interface RepeatRangeControlledNode extends BaseRepeatRangeNode {
|
|
18
|
+
readonly nodeType: 'repeat-range:controlled';
|
|
19
|
+
readonly definition: ControlledRepeatRangeDefinition;
|
|
20
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { UncontrolledRepeatRangeDefinition } from '../../parse/model/RepeatRangeDefinition.ts';
|
|
2
|
+
import type { RootNode } from '../RootNode.ts';
|
|
3
|
+
import type { BaseRepeatRangeNode, BaseRepeatRangeNodeState } from './BaseRepeatRangeNode.ts';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* {@inheritDoc BaseRepeatRangeNodeState}
|
|
7
|
+
* @see {@link BaseRepeatRangeNodeState}
|
|
8
|
+
*/
|
|
9
|
+
export interface RepeatRangeUncontrolledState extends BaseRepeatRangeNodeState {}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* {@inheritDoc BaseRepeatRangeNode}
|
|
13
|
+
* @see {@link BaseRepeatRangeNode}
|
|
14
|
+
*/
|
|
15
|
+
export interface RepeatRangeUncontrolledNode extends BaseRepeatRangeNode {
|
|
16
|
+
readonly nodeType: 'repeat-range:uncontrolled';
|
|
17
|
+
readonly definition: UncontrolledRepeatRangeDefinition;
|
|
18
|
+
|
|
19
|
+
addInstances(afterIndex?: number, count?: number): RootNode;
|
|
20
|
+
removeInstances(startIndex: number, count?: number): RootNode;
|
|
21
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RangeControlDefinition } from '../../parse/body/control/RangeControlDefinition.ts';
|
|
2
|
+
import type {
|
|
3
|
+
UnsupportedControlDefinition,
|
|
4
|
+
UnsupportedControlNode,
|
|
5
|
+
} from './UnsupportedControlNode.ts';
|
|
6
|
+
|
|
7
|
+
export interface RangeNodeDefinition extends UnsupportedControlDefinition {
|
|
8
|
+
readonly bodyElement: RangeControlDefinition;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface RangeNode extends UnsupportedControlNode {
|
|
12
|
+
readonly nodeType: 'range';
|
|
13
|
+
readonly definition: RangeNodeDefinition;
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RankControlDefinition } from '../../parse/body/control/RankControlDefinition.ts';
|
|
2
|
+
import type {
|
|
3
|
+
UnsupportedControlDefinition,
|
|
4
|
+
UnsupportedControlNode,
|
|
5
|
+
} from './UnsupportedControlNode.ts';
|
|
6
|
+
|
|
7
|
+
export interface RankNodeDefinition extends UnsupportedControlDefinition {
|
|
8
|
+
readonly bodyElement: RankControlDefinition;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface RankNode extends UnsupportedControlNode {
|
|
12
|
+
readonly nodeType: 'rank';
|
|
13
|
+
readonly definition: RankNodeDefinition;
|
|
14
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { UnknownAppearanceDefinition } from '../../parse/body/appearance/unknownAppearanceParser.ts';
|
|
2
|
+
import type { RangeControlDefinition } from '../../parse/body/control/RangeControlDefinition.ts';
|
|
3
|
+
import type { RankControlDefinition } from '../../parse/body/control/RankControlDefinition.ts';
|
|
4
|
+
import type { UploadControlDefinition } from '../../parse/body/control/UploadControlDefinition.ts';
|
|
5
|
+
import type { LeafNodeDefinition } from '../../parse/model/LeafNodeDefinition.ts';
|
|
6
|
+
import type { BaseNode, BaseNodeState } from '../BaseNode.ts';
|
|
7
|
+
import type { RootNode } from '../RootNode.ts';
|
|
8
|
+
import type { GeneralParentNode } from '../hierarchy.ts';
|
|
9
|
+
import type { UnsupportedControlNodeType } from '../node-types.ts';
|
|
10
|
+
import type { LeafNodeValidationState } from '../validation.ts';
|
|
11
|
+
|
|
12
|
+
export interface UnsupportedControlNodeState extends BaseNodeState {
|
|
13
|
+
get children(): null;
|
|
14
|
+
get valueOptions(): unknown;
|
|
15
|
+
get value(): unknown;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type UnsupportedControlElementDefinition =
|
|
19
|
+
| RangeControlDefinition
|
|
20
|
+
| RankControlDefinition
|
|
21
|
+
| UploadControlDefinition;
|
|
22
|
+
|
|
23
|
+
export interface UnsupportedControlDefinition extends LeafNodeDefinition {
|
|
24
|
+
readonly bodyElement: UnsupportedControlElementDefinition;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Stub node, for form controls pending further engine support.
|
|
29
|
+
*/
|
|
30
|
+
export interface UnsupportedControlNode extends BaseNode {
|
|
31
|
+
readonly nodeType: UnsupportedControlNodeType;
|
|
32
|
+
readonly appearances: UnknownAppearanceDefinition;
|
|
33
|
+
readonly definition: UnsupportedControlDefinition;
|
|
34
|
+
readonly root: RootNode;
|
|
35
|
+
readonly parent: GeneralParentNode;
|
|
36
|
+
readonly currentState: UnsupportedControlNodeState;
|
|
37
|
+
readonly validationState: LeafNodeValidationState;
|
|
38
|
+
|
|
39
|
+
setValue?(value: never): never;
|
|
40
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { UploadControlDefinition } from '../../parse/body/control/UploadControlDefinition.ts';
|
|
2
|
+
import type {
|
|
3
|
+
UnsupportedControlDefinition,
|
|
4
|
+
UnsupportedControlNode,
|
|
5
|
+
} from './UnsupportedControlNode.ts';
|
|
6
|
+
|
|
7
|
+
export interface UploadNodeDefinition extends UnsupportedControlDefinition {
|
|
8
|
+
readonly bodyElement: UploadControlDefinition;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface UploadNode extends UnsupportedControlNode {
|
|
12
|
+
readonly nodeType: 'upload';
|
|
13
|
+
readonly definition: UploadNodeDefinition;
|
|
14
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import type { NodeID } from '../instance/identity.ts';
|
|
2
|
+
import type { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
3
|
+
import type { OpaqueReactiveObjectFactory } from './OpaqueReactiveObjectFactory.ts';
|
|
4
|
+
import type { RootNode } from './RootNode.ts';
|
|
5
|
+
import type { TextRange } from './TextRange.ts';
|
|
6
|
+
|
|
7
|
+
// This interface exists so that extensions can share JSDoc for `valid`.
|
|
8
|
+
interface BaseValidity {
|
|
9
|
+
/**
|
|
10
|
+
* Specifies the unambiguous validity state for each validity condition of a
|
|
11
|
+
* given node, or for the derived validity of any parent node whose descendants
|
|
12
|
+
* are validated.
|
|
13
|
+
*
|
|
14
|
+
* For {@link ValidationCondition | form-defined conditions}, validity is
|
|
15
|
+
* determined as follows:
|
|
16
|
+
*
|
|
17
|
+
*
|
|
18
|
+
* expression | state | blank | non-blank
|
|
19
|
+
* ------------:|:----------|:-------:|:---------:
|
|
20
|
+
* `constraint` | `true`\* | ✅ | ✅
|
|
21
|
+
* `constraint` | `false` | ✅ | ❌
|
|
22
|
+
* `required` | `false`\* | ✅ | ✅
|
|
23
|
+
* `required` | `true` | ❌ | ✅
|
|
24
|
+
*
|
|
25
|
+
* - \* = default (expression not defined)
|
|
26
|
+
* - ✅ = `valid: true`
|
|
27
|
+
* - ❌ = `valid: false`
|
|
28
|
+
*/
|
|
29
|
+
readonly valid: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Form-defined conditions which determine node validity.
|
|
34
|
+
*
|
|
35
|
+
* @see {@link https://getodk.github.io/xforms-spec/#bind-attributes | `constraint` and `required` bind attributes}
|
|
36
|
+
*/
|
|
37
|
+
export type ValidationCondition = 'constraint' | 'required';
|
|
38
|
+
|
|
39
|
+
interface ValidationConditionMessageRoles {
|
|
40
|
+
readonly constraint: 'constraintMsg';
|
|
41
|
+
readonly required: 'requiredMsg';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type ValidationConditionMessageRole<Condition extends ValidationCondition> =
|
|
45
|
+
ValidationConditionMessageRoles[Condition];
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Source of a condition's violation message.
|
|
49
|
+
*
|
|
50
|
+
* - Form-defined messages (specified by the
|
|
51
|
+
* {@link https://getodk.github.io/xforms-spec/#bind-attributes | `jr:constraintMsg` and `jr:requiredMsg`}
|
|
52
|
+
* attributes) will be favored when provided by the form, and will be
|
|
53
|
+
* translated according to the form's active language (where applicable).
|
|
54
|
+
*
|
|
55
|
+
* - Otherwise, an engine-defined message will be provided as a fallback. This
|
|
56
|
+
* fallback is provided mainly for API consistency, and may be referenced for
|
|
57
|
+
* testing purposes; user-facing clients are expected to provide fallback
|
|
58
|
+
* messaging language most appropriate for their user neeeds. Engine-defined
|
|
59
|
+
* fallback messages **are not translated**. They are intended to be used, if
|
|
60
|
+
* at all, as sentinel values when a form-defined message is not available.
|
|
61
|
+
*/
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
63
|
+
export type ViolationMessageSource = 'form' | 'engine';
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @see {@link ViolationMessage.asString}
|
|
67
|
+
*/
|
|
68
|
+
// prettier-ignore
|
|
69
|
+
type ViolationMessageAsString<
|
|
70
|
+
Source extends ViolationMessageSource,
|
|
71
|
+
Condition extends ValidationCondition,
|
|
72
|
+
> =
|
|
73
|
+
Source extends 'form'
|
|
74
|
+
? string
|
|
75
|
+
: `Condition not satisfied: ${Condition}`;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* A violation message is provided for every violation of a form-defined
|
|
79
|
+
* {@link ValidationCondition}.
|
|
80
|
+
*/
|
|
81
|
+
export interface ViolationMessage<
|
|
82
|
+
Condition extends ValidationCondition,
|
|
83
|
+
Source extends ViolationMessageSource = ViolationMessageSource,
|
|
84
|
+
> extends TextRange<ValidationConditionMessageRole<Condition>> {
|
|
85
|
+
/**
|
|
86
|
+
* - Form-defined violation messages may produce arbitrary text. This text may
|
|
87
|
+
* be translated
|
|
88
|
+
* ({@link https://getodk.github.io/xforms-spec/#fn:jr:itext | `jr:itext`}),
|
|
89
|
+
* and it may be dynamic (translations may reference form state with
|
|
90
|
+
* {@link https://getodk.github.io/xforms-spec/#body-elements | `<output>`}).
|
|
91
|
+
*
|
|
92
|
+
* - When a form-defined violation message is not available, an engine-defined
|
|
93
|
+
* message will be provided in its place. Engine-defined violation messages
|
|
94
|
+
* are statically defined (and therefore not presently translated by the
|
|
95
|
+
* engine). Their static value can also be referenced as a static type, by
|
|
96
|
+
* checking {@link isFallbackMessage}.
|
|
97
|
+
*/
|
|
98
|
+
get asString(): ViolationMessageAsString<Source, Condition>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface ConditionSatisfied<Condition extends ValidationCondition> extends BaseValidity {
|
|
102
|
+
readonly condition: Condition;
|
|
103
|
+
readonly valid: true;
|
|
104
|
+
readonly message: null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface ConditionViolation<Condition extends ValidationCondition> extends BaseValidity {
|
|
108
|
+
readonly condition: Condition;
|
|
109
|
+
readonly valid: false;
|
|
110
|
+
readonly message: ViolationMessage<Condition>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export type ConditionValidation<Condition extends ValidationCondition> =
|
|
114
|
+
| ConditionSatisfied<Condition>
|
|
115
|
+
| ConditionViolation<Condition>;
|
|
116
|
+
|
|
117
|
+
export type AnyViolation = ConditionViolation<ValidationCondition>;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Represents the validation state of a leaf (or value) node.
|
|
121
|
+
*
|
|
122
|
+
* Validity is computed for two conditions:
|
|
123
|
+
*
|
|
124
|
+
* - {@link constraint}: arbitrary form-defined condition which specifies
|
|
125
|
+
* whether a (non-blank) value is considered valid
|
|
126
|
+
*
|
|
127
|
+
* - {@link required}: when a node is required, the node must have a non-blank
|
|
128
|
+
* value to be considered valid
|
|
129
|
+
*
|
|
130
|
+
* Only one of these conditions can be violated (applicability is mutually
|
|
131
|
+
* exclusive). As such, {@link violation} provides a convenient way to determine
|
|
132
|
+
* whether a leaf/value node is valid with a single (null) check.
|
|
133
|
+
*
|
|
134
|
+
* @see {@link BaseValidity.valid} for additional details on how these
|
|
135
|
+
* conditions are evaluated (and how they interact with one another).
|
|
136
|
+
*/
|
|
137
|
+
export interface LeafNodeValidationState {
|
|
138
|
+
get constraint(): ConditionValidation<'constraint'>;
|
|
139
|
+
get required(): ConditionValidation<'required'>;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Violations are mutually exclusive:
|
|
143
|
+
*
|
|
144
|
+
* - {@link constraint} can only be violated by a non-blank value
|
|
145
|
+
* - {@link required} can only be violated by a blank value
|
|
146
|
+
*
|
|
147
|
+
* As such, at most one violation can be present. If none is present,
|
|
148
|
+
* the node is considered valid.
|
|
149
|
+
*/
|
|
150
|
+
get violation(): AnyViolation | null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Provides a reference to any leaf/value node which currently violates either
|
|
155
|
+
* of its validity conditions.
|
|
156
|
+
*
|
|
157
|
+
* Any client can safely assume:
|
|
158
|
+
*
|
|
159
|
+
* - {@link nodeId} will be a stable reference to a node with the same
|
|
160
|
+
* {@link BaseNode.nodeId | `nodeId`}.
|
|
161
|
+
*
|
|
162
|
+
* - {@link node} will have reference equality to the same node object, within
|
|
163
|
+
* the active form instance's {@link RootNode} tree
|
|
164
|
+
*
|
|
165
|
+
* - {@link reference} will be a **current** reference to the same node object's
|
|
166
|
+
* **computed** {@link BaseNodeState.reference | `currentState.reference`}
|
|
167
|
+
*
|
|
168
|
+
* Any client utilizing the engine's reactive APIs (having provided an
|
|
169
|
+
* {@link OpaqueReactiveObjectFactory}) can safely assume that {@link reference}
|
|
170
|
+
* will be recomputed and updated in tandem with the affected node's own
|
|
171
|
+
* computed `currentState.reference` as well.
|
|
172
|
+
*
|
|
173
|
+
* @todo this type currently exposes multiple ways to reference the affected
|
|
174
|
+
* node. This is intended to maximize flexibility: it's not yet clear how
|
|
175
|
+
* clients will be best served by which reference mechanism. It is expected that
|
|
176
|
+
* each property will be directly computed from the affected node.
|
|
177
|
+
*/
|
|
178
|
+
export interface DescendantNodeViolationReference {
|
|
179
|
+
readonly nodeId: NodeID;
|
|
180
|
+
|
|
181
|
+
get reference(): string;
|
|
182
|
+
get violation(): AnyViolation;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Provides access from any ancestor/parent node, to identify any validity
|
|
187
|
+
* violations present on any of its leaf/value node descendants.
|
|
188
|
+
*
|
|
189
|
+
* @see {@link DescendantNodeViolationReference} for details on how descendants
|
|
190
|
+
* may be referenced when such a violation is present.
|
|
191
|
+
*/
|
|
192
|
+
export interface AncestorNodeValidationState {
|
|
193
|
+
get violations(): readonly DescendantNodeViolationReference[];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// prettier-ignore
|
|
197
|
+
export type NodeValidationState =
|
|
198
|
+
| AncestorNodeValidationState
|
|
199
|
+
| LeafNodeValidationState;
|
package/src/index.ts
CHANGED
|
@@ -3,26 +3,38 @@ import { initializeForm as engine__initializeForm } from './instance/index.ts';
|
|
|
3
3
|
|
|
4
4
|
export const initializeForm: InitializeForm = engine__initializeForm;
|
|
5
5
|
|
|
6
|
+
export * as constants from './client/constants.ts';
|
|
6
7
|
export type * from './client/EngineConfig.ts';
|
|
7
8
|
export type * from './client/FormLanguage.ts';
|
|
8
9
|
export type * from './client/GroupNode.ts';
|
|
9
|
-
export type * from './client/OpaqueReactiveObjectFactory.ts';
|
|
10
|
-
export type * from './client/RepeatInstanceNode.ts';
|
|
11
|
-
export type * from './client/RepeatRangeNode.ts';
|
|
12
|
-
export type * from './client/RootNode.ts';
|
|
13
|
-
export type * from './client/SelectNode.ts';
|
|
14
|
-
export type * from './client/StringNode.ts';
|
|
15
|
-
export type * from './client/SubtreeNode.ts';
|
|
16
|
-
export type * from './client/TextRange.ts';
|
|
17
10
|
export type {
|
|
18
11
|
AnyChildNode,
|
|
12
|
+
AnyControlNode,
|
|
19
13
|
AnyLeafNode,
|
|
20
14
|
AnyNode,
|
|
21
15
|
AnyParentNode,
|
|
16
|
+
AnyUnsupportedControlNode,
|
|
22
17
|
GeneralChildNode,
|
|
23
18
|
GeneralParentNode,
|
|
19
|
+
RepeatRangeNode,
|
|
24
20
|
} from './client/hierarchy.ts';
|
|
25
21
|
export type * from './client/index.ts';
|
|
22
|
+
export type * from './client/ModelValueNode.ts';
|
|
23
|
+
export type * from './client/NoteNode.ts';
|
|
24
|
+
export type * from './client/OpaqueReactiveObjectFactory.ts';
|
|
25
|
+
export type * from './client/repeat/RepeatInstanceNode.ts';
|
|
26
|
+
export type * from './client/repeat/RepeatRangeControlledNode.ts';
|
|
27
|
+
export type * from './client/repeat/RepeatRangeUncontrolledNode.ts';
|
|
28
|
+
export type * from './client/RootNode.ts';
|
|
29
|
+
export type * from './client/SelectNode.ts';
|
|
30
|
+
export type * from './client/StringNode.ts';
|
|
31
|
+
export type * from './client/SubtreeNode.ts';
|
|
32
|
+
export type * from './client/TextRange.ts';
|
|
33
|
+
export type * from './client/TriggerNode.ts';
|
|
34
|
+
export type * from './client/unsupported/RangeNode.ts';
|
|
35
|
+
export type * from './client/unsupported/RankNode.ts';
|
|
36
|
+
export type * from './client/unsupported/UploadNode.ts';
|
|
37
|
+
export type * from './client/validation.ts';
|
|
26
38
|
|
|
27
39
|
// TODO: notwithstanding potential conflicts with parallel work on `web-forms`
|
|
28
40
|
// (former `ui-vue`), these are the last remaining references **outside of
|
|
@@ -32,4 +44,4 @@ export type * from './client/index.ts';
|
|
|
32
44
|
export type {
|
|
33
45
|
AnySelectDefinition,
|
|
34
46
|
SelectDefinition,
|
|
35
|
-
} from './body/control/select/SelectDefinition.ts';
|
|
47
|
+
} from './parse/body/control/select/SelectDefinition.ts';
|
package/src/instance/Group.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Accessor } from 'solid-js';
|
|
2
2
|
import type { GroupDefinition, GroupNode, GroupNodeAppearances } from '../client/GroupNode.ts';
|
|
3
|
-
import type { TextRange } from '../
|
|
3
|
+
import type { TextRange } from '../client/TextRange.ts';
|
|
4
|
+
import type { AncestorNodeValidationState } from '../client/validation.ts';
|
|
4
5
|
import type { ChildrenState } from '../lib/reactivity/createChildrenState.ts';
|
|
5
6
|
import { createChildrenState } from '../lib/reactivity/createChildrenState.ts';
|
|
6
7
|
import type { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
|
|
@@ -10,6 +11,7 @@ import type { EngineState } from '../lib/reactivity/node-state/createEngineState
|
|
|
10
11
|
import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
11
12
|
import { createSharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
12
13
|
import { createNodeLabel } from '../lib/reactivity/text/createNodeLabel.ts';
|
|
14
|
+
import { createAggregatedViolations } from '../lib/reactivity/validation/createAggregatedViolations.ts';
|
|
13
15
|
import type { DescendantNodeSharedStateSpec } from './abstract/DescendantNode.ts';
|
|
14
16
|
import { DescendantNode } from './abstract/DescendantNode.ts';
|
|
15
17
|
import { buildChildren } from './children.ts';
|
|
@@ -41,6 +43,7 @@ export class Group
|
|
|
41
43
|
readonly nodeType = 'group';
|
|
42
44
|
readonly appearances: GroupNodeAppearances;
|
|
43
45
|
readonly currentState: MaterializedChildren<CurrentState<GroupStateSpec>, GeneralChildNode>;
|
|
46
|
+
readonly validationState: AncestorNodeValidationState;
|
|
44
47
|
|
|
45
48
|
constructor(parent: GeneralParentNode, definition: GroupDefinition) {
|
|
46
49
|
super(parent, definition);
|
|
@@ -51,6 +54,10 @@ export class Group
|
|
|
51
54
|
|
|
52
55
|
this.childrenState = childrenState;
|
|
53
56
|
|
|
57
|
+
const sharedStateOptions = {
|
|
58
|
+
clientStateFactory: this.engineConfig.stateFactory,
|
|
59
|
+
};
|
|
60
|
+
|
|
54
61
|
const state = createSharedNodeState(
|
|
55
62
|
this.scope,
|
|
56
63
|
{
|
|
@@ -65,9 +72,7 @@ export class Group
|
|
|
65
72
|
valueOptions: null,
|
|
66
73
|
value: null,
|
|
67
74
|
},
|
|
68
|
-
|
|
69
|
-
clientStateFactory: this.engineConfig.stateFactory,
|
|
70
|
-
}
|
|
75
|
+
sharedStateOptions
|
|
71
76
|
);
|
|
72
77
|
|
|
73
78
|
this.state = state;
|
|
@@ -79,6 +84,7 @@ export class Group
|
|
|
79
84
|
);
|
|
80
85
|
|
|
81
86
|
childrenState.setChildren(buildChildren(this));
|
|
87
|
+
this.validationState = createAggregatedViolations(this, sharedStateOptions);
|
|
82
88
|
}
|
|
83
89
|
|
|
84
90
|
getChildren(): readonly GeneralChildNode[] {
|