@getodk/xforms-engine 0.3.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 +1 -2
- package/dist/client/EngineConfig.d.ts +0 -1
- package/dist/client/GroupNode.d.ts +2 -3
- package/dist/client/ModelValueNode.d.ts +1 -2
- package/dist/client/NodeAppearances.d.ts +1 -2
- package/dist/client/NoteNode.d.ts +2 -3
- package/dist/client/RootNode.d.ts +2 -3
- package/dist/client/SelectNode.d.ts +2 -3
- package/dist/client/StringNode.d.ts +2 -3
- package/dist/client/SubtreeNode.d.ts +1 -2
- package/dist/client/TextRange.d.ts +3 -4
- package/dist/client/TriggerNode.d.ts +25 -0
- package/dist/client/constants.d.ts +0 -1
- package/dist/client/hierarchy.d.ts +7 -3
- package/dist/client/index.d.ts +0 -1
- package/dist/client/node-types.d.ts +2 -1
- package/dist/client/repeat/BaseRepeatRangeNode.d.ts +1 -2
- package/dist/client/repeat/RepeatInstanceNode.d.ts +2 -3
- package/dist/client/repeat/RepeatRangeControlledNode.d.ts +1 -2
- package/dist/client/repeat/RepeatRangeUncontrolledNode.d.ts +1 -2
- 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 +0 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +39029 -37441
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +0 -1
- package/dist/instance/ModelValue.d.ts +1 -2
- package/dist/instance/Note.d.ts +1 -2
- package/dist/instance/Root.d.ts +3 -4
- package/dist/instance/SelectField.d.ts +3 -4
- package/dist/instance/StringField.d.ts +2 -3
- package/dist/instance/Subtree.d.ts +0 -1
- package/dist/instance/TriggerControl.d.ts +40 -0
- package/dist/instance/abstract/DescendantNode.d.ts +4 -5
- package/dist/instance/abstract/InstanceNode.d.ts +1 -2
- package/dist/instance/abstract/UnsupportedControl.d.ts +46 -0
- package/dist/instance/children.d.ts +0 -1
- package/dist/instance/hierarchy.d.ts +9 -5
- 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 +11 -4
- package/dist/instance/internal-api/ValueContext.d.ts +3 -4
- package/dist/instance/repeat/BaseRepeatRange.d.ts +1 -2
- package/dist/instance/repeat/RepeatInstance.d.ts +0 -1
- package/dist/instance/repeat/RepeatRangeControlled.d.ts +1 -2
- package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +1 -2
- package/dist/instance/resource.d.ts +0 -1
- package/dist/instance/text/TextChunk.d.ts +0 -1
- package/dist/instance/text/TextRange.d.ts +0 -1
- 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 +1 -2
- package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +2 -3
- 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 +0 -1
- package/dist/lib/reactivity/node-state/createSpecifiedPropertyDescriptor.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createSpecifiedState.d.ts +0 -1
- 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 +1 -2
- package/dist/lib/reactivity/text/createNodeLabel.d.ts +1 -2
- package/dist/lib/reactivity/text/createNoteText.d.ts +1 -2
- package/dist/lib/reactivity/text/createTextRange.d.ts +0 -1
- package/dist/lib/reactivity/types.d.ts +0 -1
- package/dist/lib/reactivity/validation/createAggregatedViolations.d.ts +0 -1
- package/dist/lib/reactivity/validation/createValidation.d.ts +0 -1
- 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 +7 -7
- package/dist/{body → parse/body}/RepeatElementDefinition.d.ts +3 -4
- 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 +2 -3
- package/dist/{body → parse/body}/control/select/ItemsetDefinition.d.ts +4 -5
- 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 +2 -3
- 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 +2 -3
- package/dist/parse/expression/abstract/TextChunkExpression.d.ts +17 -0
- package/dist/parse/model/BindDefinition.d.ts +39 -0
- package/dist/{model → parse/model}/DescendentNodeDefinition.d.ts +0 -1
- package/dist/{model → parse/model}/LeafNodeDefinition.d.ts +1 -2
- 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 +0 -1
- package/dist/parse/{NoteNodeDefinition.d.ts → model/NoteNodeDefinition.d.ts} +8 -9
- package/dist/{model → parse/model}/RepeatInstanceDefinition.d.ts +1 -2
- package/dist/{model → parse/model}/RepeatRangeDefinition.d.ts +2 -3
- 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 +2 -3
- package/dist/parse/text/ItemLabelDefinition.d.ts +2 -3
- package/dist/parse/text/ItemsetLabelDefinition.d.ts +3 -4
- package/dist/parse/text/LabelDefinition.d.ts +5 -6
- package/dist/parse/text/MessageDefinition.d.ts +4 -5
- package/dist/parse/text/abstract/TextElementDefinition.d.ts +8 -9
- package/dist/parse/text/abstract/TextRangeDefinition.d.ts +5 -6
- package/dist/parse/xpath/path-resolution.d.ts +0 -1
- package/dist/parse/xpath/predicate-analysis.d.ts +0 -1
- package/dist/parse/xpath/reference-parsing.d.ts +0 -1
- package/dist/parse/xpath/semantic-analysis.d.ts +0 -1
- package/dist/parse/xpath/syntax-traversal.d.ts +0 -1
- package/dist/solid.js +6849 -5247
- package/dist/solid.js.map +1 -1
- package/package.json +11 -11
- package/src/client/BaseNode.ts +1 -1
- package/src/client/GroupNode.ts +2 -2
- package/src/client/ModelValueNode.ts +1 -1
- package/src/client/NodeAppearances.ts +1 -1
- package/src/client/NoteNode.ts +2 -2
- package/src/client/RootNode.ts +2 -2
- package/src/client/SelectNode.ts +2 -2
- package/src/client/StringNode.ts +2 -2
- package/src/client/SubtreeNode.ts +1 -1
- package/src/client/TextRange.ts +4 -5
- package/src/client/TriggerNode.ts +29 -0
- package/src/client/hierarchy.ts +13 -1
- package/src/client/node-types.ts +9 -1
- package/src/client/repeat/BaseRepeatRangeNode.ts +1 -1
- package/src/client/repeat/RepeatInstanceNode.ts +2 -2
- package/src/client/repeat/RepeatRangeControlledNode.ts +1 -1
- package/src/client/repeat/RepeatRangeUncontrolledNode.ts +1 -1
- 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/index.ts +6 -1
- package/src/instance/ModelValue.ts +2 -2
- package/src/instance/Note.ts +2 -2
- package/src/instance/Root.ts +7 -3
- package/src/instance/SelectField.ts +6 -6
- package/src/instance/StringField.ts +3 -3
- package/src/instance/TriggerControl.ts +134 -0
- package/src/instance/abstract/DescendantNode.ts +4 -4
- package/src/instance/abstract/InstanceNode.ts +9 -1
- package/src/instance/abstract/UnsupportedControl.ts +151 -0
- package/src/instance/children.ts +75 -5
- package/src/instance/hierarchy.ts +22 -4
- package/src/instance/index.ts +1 -1
- package/src/instance/internal-api/EvaluationContext.ts +1 -1
- package/src/instance/internal-api/ValidationContext.ts +12 -3
- package/src/instance/internal-api/ValueContext.ts +3 -3
- package/src/instance/repeat/BaseRepeatRange.ts +1 -1
- package/src/instance/repeat/RepeatRangeControlled.ts +1 -1
- package/src/instance/repeat/RepeatRangeUncontrolled.ts +1 -1
- 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 +3 -3
- package/src/lib/reactivity/createNoteReadonlyThunk.ts +2 -2
- package/src/lib/reactivity/createSelectItems.ts +3 -3
- package/src/lib/reactivity/createValueState.ts +3 -3
- package/src/lib/reactivity/node-state/createSpecifiedState.ts +1 -1
- package/src/lib/reactivity/text/createFieldHint.ts +1 -1
- package/src/lib/reactivity/text/createNodeLabel.ts +1 -1
- package/src/lib/reactivity/text/createNoteText.ts +1 -1
- package/src/lib/reactivity/text/createTextRange.ts +4 -4
- package/src/lib/reactivity/validation/createAggregatedViolations.ts +8 -3
- package/src/lib/reactivity/validation/createValidation.ts +1 -1
- 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 +12 -6
- package/src/{body → parse/body}/RepeatElementDefinition.ts +7 -5
- 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 +4 -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 +2 -2
- package/src/{body → parse/body}/control/select/ItemsetDefinition.ts +5 -5
- 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 -22
- package/src/{body → parse/body}/group/PresentationGroupDefinition.ts +1 -1
- package/src/{model/BindComputation.ts → parse/expression/BindComputationExpression.ts} +8 -8
- package/src/{body/control/select → parse/expression}/ItemsetNodesetExpression.ts +2 -2
- package/src/{body/control/select → parse/expression}/ItemsetValueExpression.ts +2 -2
- package/src/parse/expression/RepeatCountControlExpression.ts +2 -2
- package/src/parse/expression/TextLiteralExpression.ts +19 -0
- package/src/parse/{text/OutputChunkDefinition.ts → expression/TextOutputExpression.ts} +4 -4
- package/src/parse/{text/ReferenceChunkDefinition.ts → expression/TextReferenceExpression.ts} +4 -4
- package/src/parse/{text/TranslationChunkDefinition.ts → expression/TextTranslationExpression.ts} +4 -4
- package/src/{expression → parse/expression/abstract}/DependentExpression.ts +4 -4
- package/src/parse/expression/abstract/TextChunkExpression.ts +38 -0
- package/src/{model → parse/model}/BindDefinition.ts +23 -22
- package/src/parse/{NoteNodeDefinition.ts → model/NoteNodeDefinition.ts} +9 -9
- package/src/{model → parse/model}/RepeatRangeDefinition.ts +1 -1
- package/src/{model → parse/model}/RootDefinition.ts +2 -2
- package/src/parse/text/HintDefinition.ts +2 -2
- package/src/parse/text/ItemLabelDefinition.ts +2 -2
- package/src/parse/text/ItemsetLabelDefinition.ts +7 -7
- package/src/parse/text/LabelDefinition.ts +5 -5
- package/src/parse/text/MessageDefinition.ts +7 -7
- package/src/parse/text/abstract/TextElementDefinition.ts +14 -14
- package/src/parse/text/abstract/TextRangeDefinition.ts +5 -5
- package/dist/model/BindDefinition.d.ts +0 -34
- package/dist/parse/text/OutputChunkDefinition.d.ts +0 -8
- package/dist/parse/text/ReferenceChunkDefinition.d.ts +0 -8
- package/dist/parse/text/StaticTextChunkDefinition.d.ts +0 -10
- package/dist/parse/text/TranslationChunkDefinition.d.ts +0 -9
- package/dist/parse/text/abstract/TextChunkDefinition.d.ts +0 -18
- package/src/parse/TODO.md +0 -3
- package/src/parse/text/StaticTextChunkDefinition.ts +0 -19
- package/src/parse/text/abstract/TextChunkDefinition.ts +0 -38
- package/dist/{model → parse/model}/BindElement.d.ts +0 -0
- 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}/BindElement.ts +0 -0
- /package/src/{model → parse/model}/DescendentNodeDefinition.ts +0 -0
- /package/src/{model → parse/model}/LeafNodeDefinition.ts +0 -0
- /package/src/{model → parse/model}/ModelBindMap.ts +0 -0
- /package/src/{model → parse/model}/ModelDefinition.ts +0 -0
- /package/src/{model → parse/model}/NodeDefinition.ts +0 -0
- /package/src/{model → parse/model}/RepeatInstanceDefinition.ts +0 -0
- /package/src/{model → parse/model}/RepeatTemplateDefinition.ts +0 -0
- /package/src/{model → parse/model}/SubtreeDefinition.ts +0 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { Accessor } from 'solid-js';
|
|
2
|
+
import type { TextRange } from '../client/TextRange.ts';
|
|
3
|
+
import type { TriggerNode, TriggerNodeDefinition } from '../client/TriggerNode.ts';
|
|
4
|
+
import type { AnyViolation, LeafNodeValidationState } from '../client/validation.ts';
|
|
5
|
+
import { createValueState } from '../lib/reactivity/createValueState.ts';
|
|
6
|
+
import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
|
|
7
|
+
import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
|
|
8
|
+
import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
9
|
+
import { createSharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
10
|
+
import { createFieldHint } from '../lib/reactivity/text/createFieldHint.ts';
|
|
11
|
+
import { createNodeLabel } from '../lib/reactivity/text/createNodeLabel.ts';
|
|
12
|
+
import type { SimpleAtomicState } from '../lib/reactivity/types.ts';
|
|
13
|
+
import type { SharedValidationState } from '../lib/reactivity/validation/createValidation.ts';
|
|
14
|
+
import { createValidationState } from '../lib/reactivity/validation/createValidation.ts';
|
|
15
|
+
import type { UnknownAppearanceDefinition } from '../parse/body/appearance/unknownAppearanceParser.ts';
|
|
16
|
+
import type { Root } from './Root.ts';
|
|
17
|
+
import type { DescendantNodeStateSpec } from './abstract/DescendantNode.ts';
|
|
18
|
+
import { DescendantNode } from './abstract/DescendantNode.ts';
|
|
19
|
+
import type { GeneralParentNode } from './hierarchy.ts';
|
|
20
|
+
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
21
|
+
import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
|
|
22
|
+
import type { ValidationContext } from './internal-api/ValidationContext.ts';
|
|
23
|
+
import type { ValueContext } from './internal-api/ValueContext.ts';
|
|
24
|
+
|
|
25
|
+
interface TriggerControlStateSpec extends DescendantNodeStateSpec<boolean> {
|
|
26
|
+
readonly label: Accessor<TextRange<'label'> | null>;
|
|
27
|
+
readonly hint: Accessor<TextRange<'hint'> | null>;
|
|
28
|
+
readonly children: null;
|
|
29
|
+
readonly value: SimpleAtomicState<boolean>;
|
|
30
|
+
readonly valueOptions: null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const TRIGGER_ASSIGNED_VALUE = 'OK';
|
|
34
|
+
|
|
35
|
+
export class TriggerControl
|
|
36
|
+
extends DescendantNode<TriggerNodeDefinition, TriggerControlStateSpec, null>
|
|
37
|
+
implements
|
|
38
|
+
TriggerNode,
|
|
39
|
+
EvaluationContext,
|
|
40
|
+
SubscribableDependency,
|
|
41
|
+
ValidationContext,
|
|
42
|
+
ValueContext<boolean>
|
|
43
|
+
{
|
|
44
|
+
private readonly validation: SharedValidationState;
|
|
45
|
+
protected readonly state: SharedNodeState<TriggerControlStateSpec>;
|
|
46
|
+
|
|
47
|
+
// InstanceNode
|
|
48
|
+
protected engineState: EngineState<TriggerControlStateSpec>;
|
|
49
|
+
|
|
50
|
+
// TriggerNode
|
|
51
|
+
readonly nodeType = 'trigger';
|
|
52
|
+
readonly appearances: UnknownAppearanceDefinition;
|
|
53
|
+
readonly currentState: CurrentState<TriggerControlStateSpec>;
|
|
54
|
+
|
|
55
|
+
get validationState(): LeafNodeValidationState {
|
|
56
|
+
return this.validation.currentState;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ValueContext
|
|
60
|
+
readonly encodeValue: (runtimeValue: boolean) => string;
|
|
61
|
+
readonly decodeValue: (instanceValue: string) => boolean;
|
|
62
|
+
|
|
63
|
+
constructor(parent: GeneralParentNode, definition: TriggerNodeDefinition) {
|
|
64
|
+
super(parent, definition);
|
|
65
|
+
|
|
66
|
+
this.appearances = definition.bodyElement.appearances;
|
|
67
|
+
this.encodeValue = (runtimeValue) => {
|
|
68
|
+
return runtimeValue ? TRIGGER_ASSIGNED_VALUE : '';
|
|
69
|
+
};
|
|
70
|
+
this.decodeValue = (instanceValue) => {
|
|
71
|
+
const value = instanceValue.trim();
|
|
72
|
+
|
|
73
|
+
switch (value) {
|
|
74
|
+
case TRIGGER_ASSIGNED_VALUE:
|
|
75
|
+
return true;
|
|
76
|
+
|
|
77
|
+
case '':
|
|
78
|
+
return false;
|
|
79
|
+
|
|
80
|
+
// TODO (robustness principle): Case insensitivity? Handle
|
|
81
|
+
// XPath-semantic booleans?? Other known/common equivalents?
|
|
82
|
+
default:
|
|
83
|
+
throw new Error(`Unexpected trigger value: ${value}`);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const sharedStateOptions = {
|
|
88
|
+
clientStateFactory: this.engineConfig.stateFactory,
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const state = createSharedNodeState(
|
|
92
|
+
this.scope,
|
|
93
|
+
{
|
|
94
|
+
reference: this.contextReference,
|
|
95
|
+
readonly: this.isReadonly,
|
|
96
|
+
relevant: this.isRelevant,
|
|
97
|
+
required: this.isRequired,
|
|
98
|
+
|
|
99
|
+
label: createNodeLabel(this, definition),
|
|
100
|
+
hint: createFieldHint(this, definition),
|
|
101
|
+
children: null,
|
|
102
|
+
valueOptions: null,
|
|
103
|
+
value: createValueState(this),
|
|
104
|
+
},
|
|
105
|
+
sharedStateOptions
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
this.state = state;
|
|
109
|
+
this.engineState = state.engineState;
|
|
110
|
+
this.currentState = state.currentState;
|
|
111
|
+
this.validation = createValidationState(this, sharedStateOptions);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// ValidationContext
|
|
115
|
+
getViolation(): AnyViolation | null {
|
|
116
|
+
return this.validation.engineState.violation;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
isBlank(): boolean {
|
|
120
|
+
return this.engineState.value == null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// InstanceNode
|
|
124
|
+
getChildren(): readonly [] {
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// TriggerNode
|
|
129
|
+
setValue(value: boolean): Root {
|
|
130
|
+
this.state.setProperty('value', value);
|
|
131
|
+
|
|
132
|
+
return this.root;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -3,10 +3,10 @@ import type { Accessor } from 'solid-js';
|
|
|
3
3
|
import type { BaseNode } from '../../client/BaseNode.ts';
|
|
4
4
|
import { createComputedExpression } from '../../lib/reactivity/createComputedExpression.ts';
|
|
5
5
|
import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
6
|
-
import type { AnyDescendantNodeDefinition } from '../../model/DescendentNodeDefinition.ts';
|
|
7
|
-
import type { LeafNodeDefinition } from '../../model/LeafNodeDefinition.ts';
|
|
8
|
-
import type { AnyNodeDefinition } from '../../model/NodeDefinition.ts';
|
|
9
|
-
import type { RepeatInstanceDefinition } from '../../model/RepeatInstanceDefinition.ts';
|
|
6
|
+
import type { AnyDescendantNodeDefinition } from '../../parse/model/DescendentNodeDefinition.ts';
|
|
7
|
+
import type { LeafNodeDefinition } from '../../parse/model/LeafNodeDefinition.ts';
|
|
8
|
+
import type { AnyNodeDefinition } from '../../parse/model/NodeDefinition.ts';
|
|
9
|
+
import type { RepeatInstanceDefinition } from '../../parse/model/RepeatInstanceDefinition.ts';
|
|
10
10
|
import type { AnyChildNode, GeneralParentNode, RepeatRange } from '../hierarchy.ts';
|
|
11
11
|
import type { EvaluationContext } from '../internal-api/EvaluationContext.ts';
|
|
12
12
|
import type { SubscribableDependency } from '../internal-api/SubscribableDependency.ts';
|
|
@@ -12,7 +12,7 @@ import type { SharedNodeState } from '../../lib/reactivity/node-state/createShar
|
|
|
12
12
|
import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
13
13
|
import { createReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
14
14
|
import type { SimpleAtomicState } from '../../lib/reactivity/types.ts';
|
|
15
|
-
import type { AnyNodeDefinition } from '../../model/NodeDefinition.ts';
|
|
15
|
+
import type { AnyNodeDefinition } from '../../parse/model/NodeDefinition.ts';
|
|
16
16
|
import type { Root } from '../Root.ts';
|
|
17
17
|
import type { AnyChildNode, AnyNode, AnyParentNode } from '../hierarchy.ts';
|
|
18
18
|
import type { NodeID } from '../identity.ts';
|
|
@@ -246,9 +246,17 @@ export abstract class InstanceNode<
|
|
|
246
246
|
// subscriptions would be established by evaluation of the expressions
|
|
247
247
|
// themselves (as they traverse instance state and access values), rather
|
|
248
248
|
// than this safer/less focused approach.
|
|
249
|
+
|
|
250
|
+
// TODO: typescript-eslint is right to object to these! We should _at least_
|
|
251
|
+
// make internal reactive reads obvious, i.e. function calls.
|
|
252
|
+
|
|
253
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
249
254
|
engineState.reference;
|
|
255
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
250
256
|
engineState.relevant;
|
|
257
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
251
258
|
engineState.children;
|
|
259
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
252
260
|
engineState.value;
|
|
253
261
|
}
|
|
254
262
|
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { identity } from '@getodk/common/lib/identity.ts';
|
|
2
|
+
import type { Accessor } from 'solid-js';
|
|
3
|
+
import type { UnsupportedControlNodeType } from '../../client/node-types.ts';
|
|
4
|
+
import type { TextRange } from '../../client/TextRange.ts';
|
|
5
|
+
import type {
|
|
6
|
+
UnsupportedControlDefinition,
|
|
7
|
+
UnsupportedControlElementDefinition,
|
|
8
|
+
UnsupportedControlNode,
|
|
9
|
+
} from '../../client/unsupported/UnsupportedControlNode.ts';
|
|
10
|
+
import type { AnyViolation, LeafNodeValidationState } from '../../client/validation.ts';
|
|
11
|
+
import { createValueState } from '../../lib/reactivity/createValueState.ts';
|
|
12
|
+
import type { CurrentState } from '../../lib/reactivity/node-state/createCurrentState.ts';
|
|
13
|
+
import type { EngineState } from '../../lib/reactivity/node-state/createEngineState.ts';
|
|
14
|
+
import {
|
|
15
|
+
createSharedNodeState,
|
|
16
|
+
type SharedNodeState,
|
|
17
|
+
} from '../../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
18
|
+
import { createFieldHint } from '../../lib/reactivity/text/createFieldHint.ts';
|
|
19
|
+
import { createNodeLabel } from '../../lib/reactivity/text/createNodeLabel.ts';
|
|
20
|
+
import type { SimpleAtomicState } from '../../lib/reactivity/types.ts';
|
|
21
|
+
import {
|
|
22
|
+
createValidationState,
|
|
23
|
+
type SharedValidationState,
|
|
24
|
+
} from '../../lib/reactivity/validation/createValidation.ts';
|
|
25
|
+
import type { UnknownAppearanceDefinition } from '../../parse/body/appearance/unknownAppearanceParser.ts';
|
|
26
|
+
import type { GeneralParentNode } from '../hierarchy.ts';
|
|
27
|
+
import type { EvaluationContext } from '../internal-api/EvaluationContext.ts';
|
|
28
|
+
import type { SubscribableDependency } from '../internal-api/SubscribableDependency.ts';
|
|
29
|
+
import type { ValidationContext } from '../internal-api/ValidationContext.ts';
|
|
30
|
+
import type { ValueContext } from '../internal-api/ValueContext.ts';
|
|
31
|
+
import { DescendantNode, type DescendantNodeStateSpec } from './DescendantNode.ts';
|
|
32
|
+
|
|
33
|
+
type TypedUnsupportedControlElementDefinition<Type extends UnsupportedControlNodeType> = Extract<
|
|
34
|
+
UnsupportedControlElementDefinition,
|
|
35
|
+
{ readonly type: Type }
|
|
36
|
+
>;
|
|
37
|
+
|
|
38
|
+
interface TypedUnsupportedControlDefinition<Type extends UnsupportedControlNodeType>
|
|
39
|
+
extends UnsupportedControlDefinition {
|
|
40
|
+
readonly bodyElement: TypedUnsupportedControlElementDefinition<Type>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface UnsupportedControlStateSpec extends DescendantNodeStateSpec<unknown> {
|
|
44
|
+
readonly label: Accessor<TextRange<'label'> | null>;
|
|
45
|
+
readonly hint: Accessor<TextRange<'hint'> | null>;
|
|
46
|
+
readonly children: null;
|
|
47
|
+
readonly value: SimpleAtomicState<unknown>;
|
|
48
|
+
readonly valueOptions: never;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
class UnsupportedControlValueEncodeError extends Error {
|
|
52
|
+
constructor(type: UnsupportedControlNodeType) {
|
|
53
|
+
super(`Cannot encode state for node (type: ${type}) - not implemented`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
class UnsupportedControlWriteError extends Error {
|
|
58
|
+
constructor(type: UnsupportedControlNodeType) {
|
|
59
|
+
super(`Cannot write state for node (type: ${type}) - not implemented`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export abstract class UnsupportedControl<Type extends UnsupportedControlNodeType>
|
|
64
|
+
extends DescendantNode<TypedUnsupportedControlDefinition<Type>, UnsupportedControlStateSpec, null>
|
|
65
|
+
implements
|
|
66
|
+
UnsupportedControlNode,
|
|
67
|
+
EvaluationContext,
|
|
68
|
+
SubscribableDependency,
|
|
69
|
+
ValidationContext,
|
|
70
|
+
ValueContext<unknown>
|
|
71
|
+
{
|
|
72
|
+
private readonly validation: SharedValidationState;
|
|
73
|
+
protected readonly state: SharedNodeState<UnsupportedControlStateSpec>;
|
|
74
|
+
|
|
75
|
+
// InstanceNode
|
|
76
|
+
protected readonly engineState: EngineState<UnsupportedControlStateSpec>;
|
|
77
|
+
|
|
78
|
+
// UnsupportedControlNode
|
|
79
|
+
abstract override readonly nodeType: Type;
|
|
80
|
+
|
|
81
|
+
readonly appearances: UnknownAppearanceDefinition;
|
|
82
|
+
readonly currentState: CurrentState<UnsupportedControlStateSpec>;
|
|
83
|
+
|
|
84
|
+
get validationState(): LeafNodeValidationState {
|
|
85
|
+
return this.validation.currentState;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ValueContext
|
|
89
|
+
readonly encodeValue = (instanceValue: unknown): string => {
|
|
90
|
+
const encoded = instanceValue;
|
|
91
|
+
|
|
92
|
+
if (typeof encoded === 'string') {
|
|
93
|
+
return encoded;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
throw new UnsupportedControlValueEncodeError(this.nodeType);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
readonly decodeValue = (instanceValue: unknown): unknown => {
|
|
100
|
+
return identity(instanceValue);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
constructor(parent: GeneralParentNode, definition: TypedUnsupportedControlDefinition<Type>) {
|
|
104
|
+
super(parent, definition);
|
|
105
|
+
|
|
106
|
+
this.appearances = definition.bodyElement.appearances;
|
|
107
|
+
|
|
108
|
+
const sharedStateOptions = {
|
|
109
|
+
clientStateFactory: this.engineConfig.stateFactory,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const stateSpec: UnsupportedControlStateSpec = {
|
|
113
|
+
reference: this.contextReference,
|
|
114
|
+
readonly: this.isReadonly,
|
|
115
|
+
relevant: this.isRelevant,
|
|
116
|
+
required: this.isRequired,
|
|
117
|
+
|
|
118
|
+
label: createNodeLabel(this, definition),
|
|
119
|
+
hint: createFieldHint(this, definition),
|
|
120
|
+
children: null,
|
|
121
|
+
valueOptions: null as never,
|
|
122
|
+
value: createValueState<unknown>(this),
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const state = createSharedNodeState(this.scope, stateSpec, sharedStateOptions);
|
|
126
|
+
|
|
127
|
+
this.state = state;
|
|
128
|
+
this.engineState = state.engineState;
|
|
129
|
+
this.currentState = state.currentState;
|
|
130
|
+
this.validation = createValidationState(this, sharedStateOptions);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// ValidationContext
|
|
134
|
+
getViolation(): AnyViolation | null {
|
|
135
|
+
return this.validation.engineState.violation;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
isBlank(): boolean {
|
|
139
|
+
return this.engineState.value === '';
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// InstanceNode
|
|
143
|
+
getChildren(): readonly [] {
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// UnsupportedControlNode
|
|
148
|
+
setValue(_: never): never {
|
|
149
|
+
throw new UnsupportedControlWriteError(this.nodeType);
|
|
150
|
+
}
|
|
151
|
+
}
|
package/src/instance/children.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { UnreachableError } from '@getodk/common/lib/error/UnreachableError.ts';
|
|
2
2
|
import type { GroupDefinition } from '../client/GroupNode.ts';
|
|
3
3
|
import type { SubtreeDefinition } from '../client/SubtreeNode.ts';
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import {
|
|
4
|
+
import type { TriggerNodeDefinition } from '../client/TriggerNode.ts';
|
|
5
|
+
import type { RangeNodeDefinition } from '../client/unsupported/RangeNode.ts';
|
|
6
|
+
import type { RankNodeDefinition } from '../client/unsupported/RankNode.ts';
|
|
7
|
+
import type { UnsupportedControlDefinition } from '../client/unsupported/UnsupportedControlNode.ts';
|
|
8
|
+
import type { UploadNodeDefinition } from '../client/unsupported/UploadNode.ts';
|
|
9
|
+
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
10
|
+
import { NoteNodeDefinition } from '../parse/model/NoteNodeDefinition.ts';
|
|
11
|
+
import type { SubtreeDefinition as ModelSubtreeDefinition } from '../parse/model/SubtreeDefinition.ts';
|
|
7
12
|
import { Group } from './Group.ts';
|
|
8
13
|
import type { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
|
|
9
14
|
import { ModelValue, type ModelValueDefinition } from './ModelValue.ts';
|
|
@@ -15,6 +20,10 @@ import { SelectField } from './SelectField.ts';
|
|
|
15
20
|
import type { StringFieldDefinition } from './StringField.ts';
|
|
16
21
|
import { StringField } from './StringField.ts';
|
|
17
22
|
import { Subtree } from './Subtree.ts';
|
|
23
|
+
import { TriggerControl } from './TriggerControl.ts';
|
|
24
|
+
import { RangeControl } from './unsupported/RangeControl.ts';
|
|
25
|
+
import { RankControl } from './unsupported/RankControl.ts';
|
|
26
|
+
import { UploadControl } from './unsupported/UploadControl.ts';
|
|
18
27
|
|
|
19
28
|
const isSubtreeDefinition = (
|
|
20
29
|
definition: ModelSubtreeDefinition
|
|
@@ -22,7 +31,18 @@ const isSubtreeDefinition = (
|
|
|
22
31
|
return definition.bodyElement == null;
|
|
23
32
|
};
|
|
24
33
|
|
|
25
|
-
type
|
|
34
|
+
type AnyUnsupportedControlDefinition =
|
|
35
|
+
| RangeNodeDefinition
|
|
36
|
+
| RankNodeDefinition
|
|
37
|
+
| UploadNodeDefinition;
|
|
38
|
+
|
|
39
|
+
// prettier-ignore
|
|
40
|
+
type ControlNodeDefinition =
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
42
|
+
| SelectFieldDefinition
|
|
43
|
+
| StringFieldDefinition
|
|
44
|
+
| TriggerNodeDefinition
|
|
45
|
+
| AnyUnsupportedControlDefinition;
|
|
26
46
|
|
|
27
47
|
type AnyLeafNodeDefinition = ControlNodeDefinition | ModelValueDefinition;
|
|
28
48
|
|
|
@@ -38,6 +58,36 @@ const isStringFieldDefinition = (
|
|
|
38
58
|
return definition.bodyElement.type === 'input';
|
|
39
59
|
};
|
|
40
60
|
|
|
61
|
+
const isSelectFieldDefinition = (
|
|
62
|
+
definition: ControlNodeDefinition
|
|
63
|
+
): definition is SelectFieldDefinition => {
|
|
64
|
+
return definition.bodyElement.type === 'select' || definition.bodyElement.type === 'select1';
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const isRangeNodeDefinition = (
|
|
68
|
+
definition: UnsupportedControlDefinition
|
|
69
|
+
): definition is RangeNodeDefinition => {
|
|
70
|
+
return definition.bodyElement.type === 'range';
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const isRankNodeDefinition = (
|
|
74
|
+
definition: UnsupportedControlDefinition
|
|
75
|
+
): definition is RankNodeDefinition => {
|
|
76
|
+
return definition.bodyElement.type === 'rank';
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const isTriggerNodeDefinition = (
|
|
80
|
+
definition: ControlNodeDefinition
|
|
81
|
+
): definition is TriggerNodeDefinition => {
|
|
82
|
+
return definition.bodyElement.type === 'trigger';
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const isUploadNodeDefinition = (
|
|
86
|
+
definition: ControlNodeDefinition
|
|
87
|
+
): definition is UploadNodeDefinition => {
|
|
88
|
+
return definition.bodyElement.type === 'upload';
|
|
89
|
+
};
|
|
90
|
+
|
|
41
91
|
export const buildChildren = (parent: GeneralParentNode): GeneralChildNode[] => {
|
|
42
92
|
const { children } = parent.definition;
|
|
43
93
|
|
|
@@ -78,7 +128,27 @@ export const buildChildren = (parent: GeneralParentNode): GeneralChildNode[] =>
|
|
|
78
128
|
return new StringField(parent, leafChild);
|
|
79
129
|
}
|
|
80
130
|
|
|
81
|
-
|
|
131
|
+
if (isSelectFieldDefinition(leafChild)) {
|
|
132
|
+
return new SelectField(parent, leafChild);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (isTriggerNodeDefinition(leafChild)) {
|
|
136
|
+
return new TriggerControl(parent, leafChild);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (isRangeNodeDefinition(leafChild)) {
|
|
140
|
+
return new RangeControl(parent, leafChild);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (isRankNodeDefinition(leafChild)) {
|
|
144
|
+
return new RankControl(parent, leafChild);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (isUploadNodeDefinition(leafChild)) {
|
|
148
|
+
return new UploadControl(parent, leafChild);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
throw new UnreachableError(leafChild);
|
|
82
152
|
}
|
|
83
153
|
|
|
84
154
|
default: {
|
|
@@ -8,9 +8,19 @@ import type { Root } from './Root.ts';
|
|
|
8
8
|
import type { SelectField } from './SelectField.ts';
|
|
9
9
|
import type { StringField } from './StringField.ts';
|
|
10
10
|
import type { Subtree } from './Subtree.ts';
|
|
11
|
+
import type { TriggerControl } from './TriggerControl.ts';
|
|
12
|
+
import type { RangeControl } from './unsupported/RangeControl.ts';
|
|
13
|
+
import type { RankControl } from './unsupported/RankControl.ts';
|
|
14
|
+
import type { UploadControl } from './unsupported/UploadControl.ts';
|
|
11
15
|
|
|
12
16
|
export type RepeatRange = RepeatRangeControlled | RepeatRangeUncontrolled;
|
|
13
17
|
|
|
18
|
+
// prettier-ignore
|
|
19
|
+
export type UnsupportedControl =
|
|
20
|
+
| RangeControl
|
|
21
|
+
| RankControl
|
|
22
|
+
| UploadControl;
|
|
23
|
+
|
|
14
24
|
// prettier-ignore
|
|
15
25
|
export type AnyNode =
|
|
16
26
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
@@ -22,7 +32,9 @@ export type AnyNode =
|
|
|
22
32
|
| Note
|
|
23
33
|
| ModelValue
|
|
24
34
|
| StringField
|
|
25
|
-
| SelectField
|
|
35
|
+
| SelectField
|
|
36
|
+
| TriggerControl
|
|
37
|
+
| UnsupportedControl;
|
|
26
38
|
|
|
27
39
|
// prettier-ignore
|
|
28
40
|
export type AnyParentNode =
|
|
@@ -51,7 +63,9 @@ export type AnyChildNode =
|
|
|
51
63
|
| ModelValue
|
|
52
64
|
| Note
|
|
53
65
|
| StringField
|
|
54
|
-
| SelectField
|
|
66
|
+
| SelectField
|
|
67
|
+
| TriggerControl
|
|
68
|
+
| UnsupportedControl;
|
|
55
69
|
|
|
56
70
|
// prettier-ignore
|
|
57
71
|
export type GeneralChildNode =
|
|
@@ -62,7 +76,9 @@ export type GeneralChildNode =
|
|
|
62
76
|
| ModelValue
|
|
63
77
|
| Note
|
|
64
78
|
| StringField
|
|
65
|
-
| SelectField
|
|
79
|
+
| SelectField
|
|
80
|
+
| TriggerControl
|
|
81
|
+
| UnsupportedControl;
|
|
66
82
|
|
|
67
83
|
// prettier-ignore
|
|
68
84
|
export type AnyValueNode =
|
|
@@ -70,4 +86,6 @@ export type AnyValueNode =
|
|
|
70
86
|
| ModelValue
|
|
71
87
|
| Note
|
|
72
88
|
| StringField
|
|
73
|
-
| SelectField
|
|
89
|
+
| SelectField
|
|
90
|
+
| TriggerControl
|
|
91
|
+
| UnsupportedControl;
|
package/src/instance/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { identity } from '@getodk/common/lib/identity.ts';
|
|
2
|
-
import { XFormDefinition } from '../XFormDefinition.ts';
|
|
3
2
|
import type { RootNode } from '../client/RootNode.ts';
|
|
4
3
|
import type {
|
|
5
4
|
InitializeFormOptions as BaseInitializeFormOptions,
|
|
@@ -8,6 +7,7 @@ import type {
|
|
|
8
7
|
} from '../client/index.ts';
|
|
9
8
|
import { retrieveSourceXMLResource } from '../instance/resource.ts';
|
|
10
9
|
import { createUniqueId } from '../lib/unique-id.ts';
|
|
10
|
+
import { XFormDefinition } from '../parse/XFormDefinition.ts';
|
|
11
11
|
import { Root } from './Root.ts';
|
|
12
12
|
import type { InstanceConfig } from './internal-api/InstanceConfig.ts';
|
|
13
13
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { XFormsXPathEvaluator } from '@getodk/xpath';
|
|
2
2
|
import type { Accessor } from 'solid-js';
|
|
3
|
-
import type { DependentExpression } from '../../expression/DependentExpression.ts';
|
|
4
3
|
import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
4
|
+
import type { DependentExpression } from '../../parse/expression/abstract/DependentExpression.ts';
|
|
5
5
|
import type { SubscribableDependency } from './SubscribableDependency.ts';
|
|
6
6
|
import type { TranslationContext } from './TranslationContext.ts';
|
|
7
7
|
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnyViolation } from '../../client/validation.ts';
|
|
2
|
+
import type { BindComputationExpression } from '../../parse/expression/BindComputationExpression.ts';
|
|
2
3
|
import type { MessageDefinition } from '../../parse/text/MessageDefinition.ts';
|
|
4
|
+
import type { NodeID } from '../identity.ts';
|
|
3
5
|
import type { EvaluationContext } from './EvaluationContext.ts';
|
|
4
6
|
import type { SubscribableDependency } from './SubscribableDependency.ts';
|
|
5
7
|
|
|
8
|
+
interface ValidationContextCurrentState {
|
|
9
|
+
get reference(): string;
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
interface ValidationContextDefinitionBind {
|
|
7
|
-
readonly constraint:
|
|
13
|
+
readonly constraint: BindComputationExpression<'constraint'>;
|
|
8
14
|
readonly constraintMsg: MessageDefinition<'constraintMsg'> | null;
|
|
9
|
-
readonly required:
|
|
15
|
+
readonly required: BindComputationExpression<'required'>;
|
|
10
16
|
readonly requiredMsg: MessageDefinition<'requiredMsg'> | null;
|
|
11
17
|
}
|
|
12
18
|
|
|
@@ -15,8 +21,11 @@ interface ValidationContextDefinition {
|
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
export interface ValidationContext extends EvaluationContext, SubscribableDependency {
|
|
24
|
+
readonly nodeId: NodeID;
|
|
18
25
|
readonly definition: ValidationContextDefinition;
|
|
26
|
+
readonly currentState: ValidationContextCurrentState;
|
|
19
27
|
|
|
28
|
+
getViolation(): AnyViolation | null;
|
|
20
29
|
isRelevant(): boolean;
|
|
21
30
|
isRequired(): boolean;
|
|
22
31
|
isBlank(): boolean;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
2
|
-
import type {
|
|
2
|
+
import type { BindComputationExpression } from '../../parse/expression/BindComputationExpression.ts';
|
|
3
3
|
import type { EvaluationContext } from './EvaluationContext.ts';
|
|
4
4
|
|
|
5
5
|
export type InstanceValue = string;
|
|
6
6
|
|
|
7
7
|
interface ValueContextDefinitionBind {
|
|
8
|
-
readonly calculate:
|
|
9
|
-
readonly readonly:
|
|
8
|
+
readonly calculate: BindComputationExpression<'calculate'> | null;
|
|
9
|
+
readonly readonly: BindComputationExpression<'readonly'>;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export interface ValueContextDefinition {
|
|
@@ -17,7 +17,7 @@ import { createNodeLabel } from '../../lib/reactivity/text/createNodeLabel.ts';
|
|
|
17
17
|
import type {
|
|
18
18
|
AnyRepeatRangeDefinition,
|
|
19
19
|
ControlledRepeatRangeDefinition,
|
|
20
|
-
} from '../../model/RepeatRangeDefinition.ts';
|
|
20
|
+
} from '../../parse/model/RepeatRangeDefinition.ts';
|
|
21
21
|
import type {
|
|
22
22
|
AnyDescendantNode,
|
|
23
23
|
DescendantNodeParent,
|
|
@@ -4,7 +4,7 @@ import type { RepeatRangeControlledNode } from '../../client/repeat/RepeatRangeC
|
|
|
4
4
|
import type { AncestorNodeValidationState } from '../../client/validation.ts';
|
|
5
5
|
import { createComputedExpression } from '../../lib/reactivity/createComputedExpression.ts';
|
|
6
6
|
import { createAggregatedViolations } from '../../lib/reactivity/validation/createAggregatedViolations.ts';
|
|
7
|
-
import type { ControlledRepeatRangeDefinition } from '../../model/RepeatRangeDefinition.ts';
|
|
7
|
+
import type { ControlledRepeatRangeDefinition } from '../../parse/model/RepeatRangeDefinition.ts';
|
|
8
8
|
import type { GeneralParentNode } from '../hierarchy.ts';
|
|
9
9
|
import type { EvaluationContext } from '../internal-api/EvaluationContext.ts';
|
|
10
10
|
import type { SubscribableDependency } from '../internal-api/SubscribableDependency.ts';
|
|
@@ -2,7 +2,7 @@ import type { RepeatRangeNodeAppearances } from '../../client/repeat/BaseRepeatR
|
|
|
2
2
|
import type { RepeatRangeUncontrolledNode } from '../../client/repeat/RepeatRangeUncontrolledNode.ts';
|
|
3
3
|
import type { AncestorNodeValidationState } from '../../client/validation.ts';
|
|
4
4
|
import { createAggregatedViolations } from '../../lib/reactivity/validation/createAggregatedViolations.ts';
|
|
5
|
-
import type { UncontrolledRepeatRangeDefinition } from '../../model/RepeatRangeDefinition.ts';
|
|
5
|
+
import type { UncontrolledRepeatRangeDefinition } from '../../parse/model/RepeatRangeDefinition.ts';
|
|
6
6
|
import type { GeneralParentNode } from '../hierarchy.ts';
|
|
7
7
|
import type { EvaluationContext } from '../internal-api/EvaluationContext.ts';
|
|
8
8
|
import type { SubscribableDependency } from '../internal-api/SubscribableDependency.ts';
|
|
@@ -11,16 +11,20 @@ type TokenListIterator<CanonicalToken extends string> = IterableIterator<
|
|
|
11
11
|
PartiallyKnownString<CanonicalToken>
|
|
12
12
|
>;
|
|
13
13
|
|
|
14
|
+
type PassthroughTokenList = Readonly<Record<string, boolean>>;
|
|
15
|
+
|
|
14
16
|
/**
|
|
15
17
|
* @see {@link TokenListParser}
|
|
16
18
|
*/
|
|
17
19
|
// prettier-ignore
|
|
18
|
-
export type TokenList<CanonicalToken extends string = string> =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
export type TokenList<CanonicalToken extends string = string> =
|
|
21
|
+
& PassthroughTokenList
|
|
22
|
+
& {
|
|
23
|
+
readonly [Key in TokenListKey<CanonicalToken>]:
|
|
24
|
+
Key extends SymbolIterator
|
|
25
|
+
? () => TokenListIterator<CanonicalToken>
|
|
26
|
+
: boolean;
|
|
27
|
+
};
|
|
24
28
|
|
|
25
29
|
interface TokenListAlias<CanonicalToken extends string> {
|
|
26
30
|
readonly fromAlias: string;
|
|
@@ -101,7 +105,7 @@ export class TokenListParser<
|
|
|
101
105
|
private readonly aliases: ReadonlyMap<string, CanonicalToken>;
|
|
102
106
|
|
|
103
107
|
constructor(
|
|
104
|
-
readonly canonicalTokens: readonly CanonicalToken[],
|
|
108
|
+
readonly canonicalTokens: readonly CanonicalToken[] = [],
|
|
105
109
|
options?: TokenListParserOptions<TokenAlias>
|
|
106
110
|
) {
|
|
107
111
|
this.aliases = new Map(
|