@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
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { UpsertableMap } from '@getodk/common/lib/collections/UpsertableMap.ts';
|
|
2
|
+
import { getLabelElement } from '../../../lib/dom/query.ts';
|
|
3
|
+
import { LabelDefinition } from '../../text/LabelDefinition.ts';
|
|
2
4
|
import type { XFormDefinition } from '../../XFormDefinition.ts';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
5
|
+
import { parseNodesetReference } from '../../xpath/reference-parsing.ts';
|
|
6
|
+
import type { StructureElementAppearanceDefinition } from '../appearance/structureElementAppearanceParser.ts';
|
|
7
|
+
import { structureElementAppearanceParser } from '../appearance/structureElementAppearanceParser.ts';
|
|
6
8
|
import {
|
|
7
|
-
BodyDefinition,
|
|
8
9
|
type BodyElementDefinitionArray,
|
|
9
10
|
type BodyElementParentContext,
|
|
10
11
|
} from '../BodyDefinition.ts';
|
|
11
12
|
import { BodyElementDefinition } from '../BodyElementDefinition.ts';
|
|
12
|
-
import type { StructureElementAppearanceDefinition } from '../appearance/structureElementAppearanceParser.ts';
|
|
13
|
-
import { structureElementAppearanceParser } from '../appearance/structureElementAppearanceParser.ts';
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* These type names are derived from **and expand upon** the language used in
|
|
@@ -73,28 +72,18 @@ export abstract class BaseGroupDefinition<
|
|
|
73
72
|
readonly appearances: StructureElementAppearanceDefinition;
|
|
74
73
|
override readonly label: LabelDefinition | null;
|
|
75
74
|
|
|
76
|
-
constructor(
|
|
77
|
-
form: XFormDefinition,
|
|
78
|
-
parent: BodyElementParentContext,
|
|
79
|
-
element: Element,
|
|
80
|
-
children?: BodyElementDefinitionArray
|
|
81
|
-
) {
|
|
75
|
+
constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element) {
|
|
82
76
|
super(form, parent, element);
|
|
83
77
|
|
|
84
|
-
|
|
85
|
-
this.reference = parseNodesetReference(parent, element, 'ref');
|
|
86
|
-
this.appearances = structureElementAppearanceParser.parseFrom(element, 'appearance');
|
|
87
|
-
this.label = LabelDefinition.forGroup(form, this);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
getChildren(element: Element): BodyElementDefinitionArray {
|
|
91
|
-
const { form } = this;
|
|
92
|
-
const children = Array.from(element.children).filter((child) => {
|
|
78
|
+
const childElements = Array.from(element.children).filter((child) => {
|
|
93
79
|
const childName = child.localName;
|
|
94
80
|
|
|
95
81
|
return childName !== 'label';
|
|
96
82
|
});
|
|
97
83
|
|
|
98
|
-
|
|
84
|
+
this.children = this.body.getChildElementDefinitions(form, this, element, childElements);
|
|
85
|
+
this.reference = parseNodesetReference(parent, element, 'ref');
|
|
86
|
+
this.appearances = structureElementAppearanceParser.parseFrom(element, 'appearance');
|
|
87
|
+
this.label = LabelDefinition.forGroup(form, this);
|
|
99
88
|
}
|
|
100
89
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { LabelDefinition } from '../../text/LabelDefinition.ts';
|
|
1
2
|
import type { XFormDefinition } from '../../XFormDefinition.ts';
|
|
2
|
-
import { LabelDefinition } from '../../parse/text/LabelDefinition.ts';
|
|
3
3
|
import type { BodyElementParentContext } from '../BodyDefinition.ts';
|
|
4
4
|
import { BaseGroupDefinition } from './BaseGroupDefinition.ts';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { BindDefinition } from '../model/BindDefinition.ts';
|
|
2
|
+
import { DependentExpression } from './abstract/DependentExpression.ts';
|
|
3
3
|
|
|
4
4
|
const defaultBindComputationExpressions = {
|
|
5
5
|
calculate: null,
|
|
@@ -16,8 +16,8 @@ export type BindComputationType = keyof DefaultBindComputationExpressions;
|
|
|
16
16
|
|
|
17
17
|
type BindComputationFactoryResult<Type extends BindComputationType> =
|
|
18
18
|
DefaultBindComputationExpressions[Type] extends null
|
|
19
|
-
?
|
|
20
|
-
:
|
|
19
|
+
? BindComputationExpression<Type> | null
|
|
20
|
+
: BindComputationExpression<Type>;
|
|
21
21
|
|
|
22
22
|
const bindComputationResultTypes = {
|
|
23
23
|
calculate: 'string',
|
|
@@ -33,10 +33,10 @@ type BindComputationResultTypes = typeof bindComputationResultTypes;
|
|
|
33
33
|
export type BindComputationResultType<Computation extends BindComputationType> =
|
|
34
34
|
BindComputationResultTypes[Computation];
|
|
35
35
|
|
|
36
|
-
export class
|
|
37
|
-
|
|
38
|
-
> {
|
|
39
|
-
static
|
|
36
|
+
export class BindComputationExpression<
|
|
37
|
+
Computation extends BindComputationType,
|
|
38
|
+
> extends DependentExpression<BindComputationResultType<Computation>> {
|
|
39
|
+
static forComputation<Type extends BindComputationType>(
|
|
40
40
|
bind: BindDefinition,
|
|
41
41
|
computation: Type
|
|
42
42
|
): BindComputationFactoryResult<Type> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { ItemsetDefinition } from '../body/control/select/ItemsetDefinition.ts';
|
|
2
|
+
import { DependentExpression } from './abstract/DependentExpression.ts';
|
|
3
3
|
|
|
4
4
|
export class ItemsetNodesetExpression extends DependentExpression<'nodes'> {
|
|
5
5
|
constructor(itemset: ItemsetDefinition, nodesetExpression: string) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { ItemsetDefinition } from '../body/control/select/ItemsetDefinition.ts';
|
|
2
|
+
import { DependentExpression } from './abstract/DependentExpression.ts';
|
|
3
3
|
|
|
4
4
|
export class ItemsetValueExpression extends DependentExpression<'string'> {
|
|
5
5
|
constructor(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { RepeatElementDefinition } from '../../body/RepeatElementDefinition.ts';
|
|
2
1
|
import type { RepeatRangeControlledNode } from '../../client/repeat/RepeatRangeControlledNode.ts';
|
|
3
|
-
import {
|
|
2
|
+
import { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
|
|
4
3
|
import { isConstantTruthyExpression } from '../xpath/semantic-analysis.ts';
|
|
4
|
+
import { DependentExpression } from './abstract/DependentExpression.ts';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Represents either of these
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AnyTextRangeDefinition } from '../text/abstract/TextRangeDefinition.ts';
|
|
2
|
+
import { TextChunkExpression } from './abstract/TextChunkExpression.ts';
|
|
3
|
+
|
|
4
|
+
export type TextLiteralSourceNode = Attr | Text;
|
|
5
|
+
|
|
6
|
+
export class TextLiteralExpression extends TextChunkExpression<'literal'> {
|
|
7
|
+
static from(context: AnyTextRangeDefinition, stringValue: string): TextLiteralExpression {
|
|
8
|
+
return new this(context, stringValue);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
readonly source = 'literal';
|
|
12
|
+
|
|
13
|
+
private constructor(
|
|
14
|
+
context: AnyTextRangeDefinition,
|
|
15
|
+
override readonly stringValue: string
|
|
16
|
+
) {
|
|
17
|
+
super(context, 'null');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { KnownAttributeLocalNamedElement } from '@getodk/common/types/dom.ts';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import type { AnyTextRangeDefinition } from '../text/abstract/TextRangeDefinition.ts';
|
|
3
|
+
import { TextChunkExpression } from './abstract/TextChunkExpression.ts';
|
|
4
4
|
|
|
5
5
|
interface OutputElement extends KnownAttributeLocalNamedElement<'output', 'value'> {}
|
|
6
6
|
|
|
@@ -8,8 +8,8 @@ const isOutputElement = (element: Element): element is OutputElement => {
|
|
|
8
8
|
return element.localName === 'output' && element.hasAttribute('value');
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
export class
|
|
12
|
-
static from(context: AnyTextRangeDefinition, element: Element):
|
|
11
|
+
export class TextOutputExpression extends TextChunkExpression<'output'> {
|
|
12
|
+
static from(context: AnyTextRangeDefinition, element: Element): TextOutputExpression | null {
|
|
13
13
|
if (isOutputElement(element)) {
|
|
14
14
|
return new this(context, element);
|
|
15
15
|
}
|
package/src/parse/{text/ReferenceChunkDefinition.ts → expression/TextReferenceExpression.ts}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { AnyTextRangeDefinition } from '../text/abstract/TextRangeDefinition.ts';
|
|
2
|
+
import { TextChunkExpression } from './abstract/TextChunkExpression.ts';
|
|
3
3
|
|
|
4
|
-
export class
|
|
5
|
-
static from(context: AnyTextRangeDefinition, refExpression: string):
|
|
4
|
+
export class TextReferenceExpression extends TextChunkExpression<'reference'> {
|
|
5
|
+
static from(context: AnyTextRangeDefinition, refExpression: string): TextReferenceExpression {
|
|
6
6
|
return new this(context, refExpression);
|
|
7
7
|
}
|
|
8
8
|
|
package/src/parse/{text/TranslationChunkDefinition.ts → expression/TextTranslationExpression.ts}
RENAMED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { expressionParser } from '@getodk/xpath/expressionParser.js';
|
|
2
|
+
import type { AnyTextRangeDefinition } from '../text/abstract/TextRangeDefinition.ts';
|
|
2
3
|
import type { TranslationExpression } from '../xpath/semantic-analysis.ts';
|
|
3
4
|
import { isTranslationExpression } from '../xpath/semantic-analysis.ts';
|
|
4
|
-
import {
|
|
5
|
-
import type { AnyTextRangeDefinition } from './abstract/TextRangeDefinition.ts';
|
|
5
|
+
import { TextChunkExpression } from './abstract/TextChunkExpression.ts';
|
|
6
6
|
|
|
7
|
-
export class
|
|
7
|
+
export class TextTranslationExpression extends TextChunkExpression<'translation'> {
|
|
8
8
|
static fromMessage(
|
|
9
9
|
context: AnyTextRangeDefinition,
|
|
10
10
|
maybeExpression: string
|
|
11
|
-
):
|
|
11
|
+
): TextTranslationExpression | null {
|
|
12
12
|
try {
|
|
13
13
|
expressionParser.parse(maybeExpression);
|
|
14
14
|
} catch {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { XFormsXPathEvaluator } from '@getodk/xpath';
|
|
2
|
-
import { resolveDependencyNodesets } from '
|
|
2
|
+
import { resolveDependencyNodesets } from '../../xpath/dependency-analysis.ts';
|
|
3
3
|
import type {
|
|
4
4
|
ConstantExpression,
|
|
5
5
|
ConstantTruthyExpression,
|
|
6
|
-
} from '
|
|
6
|
+
} from '../../xpath/semantic-analysis.ts';
|
|
7
7
|
import {
|
|
8
8
|
isConstantExpression,
|
|
9
9
|
isConstantTruthyExpression,
|
|
10
10
|
isTranslationExpression,
|
|
11
|
-
} from '
|
|
11
|
+
} from '../../xpath/semantic-analysis.ts';
|
|
12
12
|
import type { DependencyContext } from './DependencyContext.ts';
|
|
13
13
|
|
|
14
14
|
const evaluatorMethodsByResultType = {
|
|
@@ -54,7 +54,7 @@ export interface ConstantTruthyDependentExpression extends ConstantDependentExpr
|
|
|
54
54
|
readonly expression: ConstantTruthyExpression;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
export class DependentExpression<Type extends DependentExpressionResultType> {
|
|
57
|
+
export abstract class DependentExpression<Type extends DependentExpressionResultType> {
|
|
58
58
|
readonly dependencyReferences: ReadonlySet<string> = new Set();
|
|
59
59
|
readonly isTranslated: boolean = false;
|
|
60
60
|
readonly evaluatorMethod: DependentExpressionEvaluatorMethod<Type>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { TextChunkSource } from '../../../client/TextRange.ts';
|
|
2
|
+
import type { AnyTextRangeDefinition } from '../../text/abstract/TextRangeDefinition.ts';
|
|
3
|
+
import type { TextLiteralExpression } from '../TextLiteralExpression.ts';
|
|
4
|
+
import type { TextOutputExpression } from '../TextOutputExpression.ts';
|
|
5
|
+
import type { TextReferenceExpression } from '../TextReferenceExpression.ts';
|
|
6
|
+
import type { TextTranslationExpression } from '../TextTranslationExpression.ts';
|
|
7
|
+
import { DependentExpression } from './DependentExpression.ts';
|
|
8
|
+
|
|
9
|
+
interface TextChunkExpressionOptions {
|
|
10
|
+
readonly isTranslated?: true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export abstract class TextChunkExpression<
|
|
14
|
+
Source extends TextChunkSource,
|
|
15
|
+
> extends DependentExpression<'string'> {
|
|
16
|
+
abstract readonly source: Source;
|
|
17
|
+
readonly stringValue?: string;
|
|
18
|
+
|
|
19
|
+
constructor(
|
|
20
|
+
context: AnyTextRangeDefinition,
|
|
21
|
+
expression: string,
|
|
22
|
+
options: TextChunkExpressionOptions = {}
|
|
23
|
+
) {
|
|
24
|
+
super(context, 'string', expression, {
|
|
25
|
+
semanticDependencies: {
|
|
26
|
+
translations: options.isTranslated,
|
|
27
|
+
},
|
|
28
|
+
ignoreContextReference: true,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// prettier-ignore
|
|
34
|
+
export type AnyTextChunkExpression =
|
|
35
|
+
| TextLiteralExpression
|
|
36
|
+
| TextOutputExpression
|
|
37
|
+
| TextReferenceExpression
|
|
38
|
+
| TextTranslationExpression;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { DependencyContext } from '../expression/abstract/DependencyContext.ts';
|
|
2
|
+
import type { DependentExpression } from '../expression/abstract/DependentExpression.ts';
|
|
3
|
+
import { BindComputationExpression } from '../expression/BindComputationExpression.ts';
|
|
4
|
+
import { MessageDefinition } from '../text/MessageDefinition.ts';
|
|
1
5
|
import type { XFormDataType } from '../XFormDataType.ts';
|
|
2
6
|
import { bindDataType } from '../XFormDataType.ts';
|
|
3
7
|
import type { XFormDefinition } from '../XFormDefinition.ts';
|
|
4
|
-
import { DependencyContext } from '../expression/DependencyContext.ts';
|
|
5
|
-
import type { DependentExpression } from '../expression/DependentExpression.ts';
|
|
6
|
-
import { MessageDefinition } from '../parse/text/MessageDefinition.ts';
|
|
7
|
-
import { BindComputation } from './BindComputation.ts';
|
|
8
8
|
import type { BindElement } from './BindElement.ts';
|
|
9
9
|
import type { ModelDefinition } from './ModelDefinition.ts';
|
|
10
10
|
|
|
@@ -13,27 +13,28 @@ export class BindDefinition extends DependencyContext {
|
|
|
13
13
|
readonly dataType: XFormDataType;
|
|
14
14
|
readonly parentNodeset: string | null;
|
|
15
15
|
|
|
16
|
-
readonly calculate:
|
|
17
|
-
readonly readonly:
|
|
18
|
-
readonly relevant:
|
|
19
|
-
readonly required:
|
|
16
|
+
readonly calculate: BindComputationExpression<'calculate'> | null;
|
|
17
|
+
readonly readonly: BindComputationExpression<'readonly'>;
|
|
18
|
+
readonly relevant: BindComputationExpression<'relevant'>;
|
|
19
|
+
readonly required: BindComputationExpression<'required'>;
|
|
20
20
|
|
|
21
|
-
// According to
|
|
22
|
-
//
|
|
23
|
-
// this is not stored in the DAG. In contrast, we do compute constraint
|
|
24
|
-
// dependencies, but self-references are ignored (handled by `BindComputation`
|
|
25
|
-
// and its `DependentExpression` parent class).
|
|
26
21
|
/**
|
|
27
|
-
* Diverges from
|
|
22
|
+
* Diverges from
|
|
23
|
+
* {@link https://github.com/getodk/javarosa/blob/059321160e6f8dbb3e81d9add61d68dd35b13cc8/dag.md | JavaRosa's},
|
|
24
|
+
* which excludes `constraint` expressions. We compute `constraint`
|
|
25
|
+
* dependencies like the other <bind> computation expressions, but explicitly
|
|
26
|
+
* ignore self-references (this is currently handled by
|
|
27
|
+
* {@link BindComputationExpression}, via its {@link DependentExpression}
|
|
28
|
+
* super class).
|
|
28
29
|
*/
|
|
29
|
-
readonly constraint:
|
|
30
|
+
readonly constraint: BindComputationExpression<'constraint'>;
|
|
30
31
|
|
|
31
32
|
readonly constraintMsg: MessageDefinition<'constraintMsg'> | null;
|
|
32
33
|
readonly requiredMsg: MessageDefinition<'requiredMsg'> | null;
|
|
33
34
|
|
|
34
35
|
// TODO: it is unclear whether this will need to be supported.
|
|
35
36
|
// https://github.com/getodk/collect/issues/3758 mentions deprecation.
|
|
36
|
-
readonly saveIncomplete:
|
|
37
|
+
readonly saveIncomplete: BindComputationExpression<'saveIncomplete'>;
|
|
37
38
|
|
|
38
39
|
// TODO: these are deferred until prioritized
|
|
39
40
|
// readonly preload: string | null;
|
|
@@ -84,12 +85,12 @@ export class BindDefinition extends DependencyContext {
|
|
|
84
85
|
const parentNodeset = nodeset.replace(/\/[^/]+$/, '');
|
|
85
86
|
|
|
86
87
|
this.parentNodeset = parentNodeset.length > 1 ? parentNodeset : null;
|
|
87
|
-
this.calculate =
|
|
88
|
-
this.readonly =
|
|
89
|
-
this.relevant =
|
|
90
|
-
this.required =
|
|
91
|
-
this.constraint =
|
|
92
|
-
this.saveIncomplete =
|
|
88
|
+
this.calculate = BindComputationExpression.forComputation(this, 'calculate');
|
|
89
|
+
this.readonly = BindComputationExpression.forComputation(this, 'readonly');
|
|
90
|
+
this.relevant = BindComputationExpression.forComputation(this, 'relevant');
|
|
91
|
+
this.required = BindComputationExpression.forComputation(this, 'required');
|
|
92
|
+
this.constraint = BindComputationExpression.forComputation(this, 'constraint');
|
|
93
|
+
this.saveIncomplete = BindComputationExpression.forComputation(this, 'saveIncomplete');
|
|
93
94
|
this.constraintMsg = MessageDefinition.from(this, 'constraintMsg');
|
|
94
95
|
this.requiredMsg = MessageDefinition.from(this, 'requiredMsg');
|
|
95
96
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
import type { NoteNode } from '../../client/NoteNode.ts';
|
|
1
2
|
import type { AnyBodyElementDefinition } from '../body/BodyDefinition.ts';
|
|
2
3
|
import type { InputDefinition } from '../body/control/InputDefinition.ts';
|
|
3
|
-
import
|
|
4
|
-
import type { ConstantTruthyDependentExpression } from '../expression/DependentExpression.ts';
|
|
5
|
-
import {
|
|
6
|
-
import type {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import type {
|
|
10
|
-
import type { LabelDefinition } from './text/LabelDefinition.ts';
|
|
4
|
+
import { BindComputationExpression } from '../expression/BindComputationExpression.ts';
|
|
5
|
+
import type { ConstantTruthyDependentExpression } from '../expression/abstract/DependentExpression.ts';
|
|
6
|
+
import type { HintDefinition } from '../text/HintDefinition.ts';
|
|
7
|
+
import type { LabelDefinition } from '../text/LabelDefinition.ts';
|
|
8
|
+
import type { BindDefinition } from './BindDefinition.ts';
|
|
9
|
+
import { LeafNodeDefinition } from './LeafNodeDefinition.ts';
|
|
10
|
+
import type { ParentNodeDefinition } from './NodeDefinition.ts';
|
|
11
11
|
|
|
12
12
|
// prettier-ignore
|
|
13
13
|
export type NoteReadonlyDefinition =
|
|
14
|
-
&
|
|
14
|
+
& BindComputationExpression<'readonly'>
|
|
15
15
|
& ConstantTruthyDependentExpression;
|
|
16
16
|
|
|
17
17
|
export interface NoteBindDefinition extends BindDefinition {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
|
|
2
|
-
import { RepeatCountControlExpression } from '../
|
|
2
|
+
import { RepeatCountControlExpression } from '../expression/RepeatCountControlExpression.ts';
|
|
3
3
|
import type { BindDefinition } from './BindDefinition.ts';
|
|
4
4
|
import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
|
|
5
5
|
import type { NodeDefinition, ParentNodeDefinition } from './NodeDefinition.ts';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { XFormDefinition } from '../XFormDefinition.ts';
|
|
2
1
|
import type { BodyClassList } from '../body/BodyDefinition.ts';
|
|
3
|
-
import {
|
|
2
|
+
import type { XFormDefinition } from '../XFormDefinition.ts';
|
|
4
3
|
import type { BindDefinition } from './BindDefinition.ts';
|
|
5
4
|
import { LeafNodeDefinition } from './LeafNodeDefinition.ts';
|
|
6
5
|
import type { ModelDefinition } from './ModelDefinition.ts';
|
|
@@ -9,6 +8,7 @@ import type {
|
|
|
9
8
|
NodeDefinition,
|
|
10
9
|
ParentNodeDefinition,
|
|
11
10
|
} from './NodeDefinition.ts';
|
|
11
|
+
import { NoteNodeDefinition } from './NoteNodeDefinition.ts';
|
|
12
12
|
import { RepeatRangeDefinition } from './RepeatRangeDefinition.ts';
|
|
13
13
|
import { SubtreeDefinition } from './SubtreeDefinition.ts';
|
|
14
14
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { LocalNamedElement } from '@getodk/common/types/dom.ts';
|
|
2
|
-
import type { XFormDefinition } from '../../XFormDefinition.ts';
|
|
3
|
-
import type { AnyControlDefinition } from '../../body/control/ControlDefinition.ts';
|
|
4
2
|
import { getHintElement } from '../../lib/dom/query.ts';
|
|
3
|
+
import type { XFormDefinition } from '../../parse/XFormDefinition.ts';
|
|
4
|
+
import type { AnyControlDefinition } from '../body/control/ControlDefinition.ts';
|
|
5
5
|
import { TextElementDefinition } from './abstract/TextElementDefinition.ts';
|
|
6
6
|
|
|
7
7
|
interface HintElement extends LocalNamedElement<'hint'> {}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { LocalNamedElement } from '@getodk/common/types/dom.ts';
|
|
2
|
-
import type { XFormDefinition } from '../../XFormDefinition.ts';
|
|
3
|
-
import type { ItemDefinition } from '../../body/control/select/ItemDefinition.ts';
|
|
4
2
|
import { getLabelElement } from '../../lib/dom/query.ts';
|
|
3
|
+
import type { XFormDefinition } from '../../parse/XFormDefinition.ts';
|
|
4
|
+
import type { ItemDefinition } from '../body/control/select/ItemDefinition.ts';
|
|
5
5
|
import { TextElementDefinition } from './abstract/TextElementDefinition.ts';
|
|
6
6
|
|
|
7
7
|
interface LabelElement extends LocalNamedElement<'label'> {}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { LocalNamedElement } from '@getodk/common/types/dom.ts';
|
|
2
|
-
import type { XFormDefinition } from '../../XFormDefinition.ts';
|
|
3
|
-
import type { ItemDefinition } from '../../body/control/select/ItemDefinition.ts';
|
|
4
|
-
import type { ItemsetDefinition } from '../../body/control/select/ItemsetDefinition.ts';
|
|
5
2
|
import { getLabelElement } from '../../lib/dom/query.ts';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import type { XFormDefinition } from '../../parse/XFormDefinition.ts';
|
|
4
|
+
import type { ItemDefinition } from '../body/control/select/ItemDefinition.ts';
|
|
5
|
+
import type { ItemsetDefinition } from '../body/control/select/ItemsetDefinition.ts';
|
|
6
|
+
import { TextReferenceExpression } from '../expression/TextReferenceExpression.ts';
|
|
7
|
+
import { TextTranslationExpression } from '../expression/TextTranslationExpression.ts';
|
|
8
8
|
import type { RefAttributeChunk } from './abstract/TextElementDefinition.ts';
|
|
9
9
|
import { TextRangeDefinition } from './abstract/TextRangeDefinition.ts';
|
|
10
10
|
|
|
@@ -36,8 +36,8 @@ export class ItemsetLabelDefinition extends TextRangeDefinition<'item-label'> {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
const refChunk =
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
TextTranslationExpression.from(this, refExpression) ??
|
|
40
|
+
TextReferenceExpression.from(this, refExpression);
|
|
41
41
|
|
|
42
42
|
this.chunks = [refChunk];
|
|
43
43
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { LocalNamedElement } from '@getodk/common/types/dom.ts';
|
|
2
|
-
import type { XFormDefinition } from '../../XFormDefinition.ts';
|
|
3
|
-
import type { AnyGroupElementDefinition } from '../../body/BodyDefinition.ts';
|
|
4
|
-
import type { RepeatElementDefinition } from '../../body/RepeatElementDefinition.ts';
|
|
5
|
-
import type { AnyControlDefinition } from '../../body/control/ControlDefinition.ts';
|
|
6
|
-
import type { BaseGroupDefinition } from '../../body/group/BaseGroupDefinition.ts';
|
|
7
2
|
import { getLabelElement, getRepeatGroupLabelElement } from '../../lib/dom/query.ts';
|
|
3
|
+
import type { XFormDefinition } from '../../parse/XFormDefinition.ts';
|
|
4
|
+
import type { AnyGroupElementDefinition } from '../../parse/body/BodyDefinition.ts';
|
|
5
|
+
import type { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
|
|
6
|
+
import type { AnyControlDefinition } from '../body/control/ControlDefinition.ts';
|
|
7
|
+
import type { BaseGroupDefinition } from '../body/group/BaseGroupDefinition.ts';
|
|
8
8
|
import { TextElementDefinition } from './abstract/TextElementDefinition.ts';
|
|
9
9
|
|
|
10
10
|
// prettier-ignore
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JAVAROSA_NAMESPACE_URI } from '@getodk/common/constants/xmlns.ts';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { TextLiteralExpression } from '../expression/TextLiteralExpression.ts';
|
|
3
|
+
import { TextTranslationExpression } from '../expression/TextTranslationExpression.ts';
|
|
4
|
+
import type { BindDefinition } from '../model/BindDefinition.ts';
|
|
5
5
|
import type { TextBindAttributeLocalName, TextSourceNode } from './abstract/TextRangeDefinition.ts';
|
|
6
6
|
import { TextRangeDefinition } from './abstract/TextRangeDefinition.ts';
|
|
7
7
|
|
|
@@ -9,8 +9,8 @@ export type MessageSourceNode = TextSourceNode<TextBindAttributeLocalName>;
|
|
|
9
9
|
|
|
10
10
|
// prettier-ignore
|
|
11
11
|
type MessageChunk =
|
|
12
|
-
|
|
|
13
|
-
|
|
|
12
|
+
| TextLiteralExpression
|
|
13
|
+
| TextTranslationExpression;
|
|
14
14
|
|
|
15
15
|
export class MessageDefinition<
|
|
16
16
|
Type extends TextBindAttributeLocalName,
|
|
@@ -38,8 +38,8 @@ export class MessageDefinition<
|
|
|
38
38
|
super(bind.form, bind, null);
|
|
39
39
|
|
|
40
40
|
const chunk: MessageChunk =
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
TextTranslationExpression.fromMessage(this, message) ??
|
|
42
|
+
TextLiteralExpression.from(this, message);
|
|
43
43
|
|
|
44
44
|
this.chunks = [chunk];
|
|
45
45
|
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { isElementNode, isTextNode } from '@getodk/common/lib/dom/predicates.ts';
|
|
2
|
-
import type { XFormDefinition } from '../../../XFormDefinition.ts';
|
|
3
|
-
import type { ItemDefinition } from '../../../body/control/select/ItemDefinition.ts';
|
|
4
2
|
import type { ElementTextRole } from '../../../client/TextRange.ts';
|
|
3
|
+
import type { XFormDefinition } from '../../../parse/XFormDefinition.ts';
|
|
4
|
+
import type { ItemDefinition } from '../../body/control/select/ItemDefinition.ts';
|
|
5
|
+
import { TextLiteralExpression } from '../../expression/TextLiteralExpression.ts';
|
|
6
|
+
import { TextOutputExpression } from '../../expression/TextOutputExpression.ts';
|
|
7
|
+
import { TextReferenceExpression } from '../../expression/TextReferenceExpression.ts';
|
|
8
|
+
import { TextTranslationExpression } from '../../expression/TextTranslationExpression.ts';
|
|
5
9
|
import { parseNodesetReference } from '../../xpath/reference-parsing.ts';
|
|
6
10
|
import type { HintDefinition } from '../HintDefinition.ts';
|
|
7
11
|
import type { ItemLabelDefinition } from '../ItemLabelDefinition.ts';
|
|
8
12
|
import type { ItemsetLabelDefinition } from '../ItemsetLabelDefinition.ts';
|
|
9
13
|
import type { LabelDefinition, LabelOwner } from '../LabelDefinition.ts';
|
|
10
|
-
import { OutputChunkDefinition } from '../OutputChunkDefinition.ts';
|
|
11
|
-
import { ReferenceChunkDefinition } from '../ReferenceChunkDefinition.ts';
|
|
12
|
-
import { StaticTextChunkDefinition } from '../StaticTextChunkDefinition.ts';
|
|
13
|
-
import { TranslationChunkDefinition } from '../TranslationChunkDefinition.ts';
|
|
14
14
|
import type { TextSourceNode } from './TextRangeDefinition.ts';
|
|
15
15
|
import { TextRangeDefinition } from './TextRangeDefinition.ts';
|
|
16
16
|
|
|
17
17
|
// prettier-ignore
|
|
18
18
|
export type RefAttributeChunk =
|
|
19
|
-
|
|
|
20
|
-
|
|
|
19
|
+
| TextReferenceExpression
|
|
20
|
+
| TextTranslationExpression;
|
|
21
21
|
|
|
22
22
|
// prettier-ignore
|
|
23
23
|
type TextElementChildChunk =
|
|
24
|
-
|
|
|
25
|
-
|
|
|
24
|
+
| TextOutputExpression
|
|
25
|
+
| TextLiteralExpression;
|
|
26
26
|
|
|
27
27
|
// prettier-ignore
|
|
28
28
|
type TextElementChunks =
|
|
@@ -45,19 +45,19 @@ export abstract class TextElementDefinition<
|
|
|
45
45
|
if (refExpression == null) {
|
|
46
46
|
this.chunks = Array.from(sourceNode.childNodes).flatMap((childNode) => {
|
|
47
47
|
if (isElementNode(childNode)) {
|
|
48
|
-
return
|
|
48
|
+
return TextOutputExpression.from(context, childNode) ?? [];
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
if (isTextNode(childNode)) {
|
|
52
|
-
return
|
|
52
|
+
return TextLiteralExpression.from(context, childNode.data);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
return [];
|
|
56
56
|
});
|
|
57
57
|
} else {
|
|
58
58
|
const refChunk =
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
TextTranslationExpression.from(context, refExpression) ??
|
|
60
|
+
TextReferenceExpression.from(context, refExpression);
|
|
61
61
|
this.chunks = [refChunk];
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { LocalNamedElement } from '@getodk/common/types/dom.ts';
|
|
2
|
-
import type { XFormDefinition } from '../../../XFormDefinition.ts';
|
|
3
2
|
import type { TextRole } from '../../../client/TextRange.ts';
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
3
|
+
import type { XFormDefinition } from '../../../parse/XFormDefinition.ts';
|
|
4
|
+
import { DependencyContext } from '../../expression/abstract/DependencyContext.ts';
|
|
5
|
+
import type { AnyDependentExpression } from '../../expression/abstract/DependentExpression.ts';
|
|
6
|
+
import type { AnyTextChunkExpression } from '../../expression/abstract/TextChunkExpression.ts';
|
|
6
7
|
import type { AnyMessageDefinition } from '../MessageDefinition.ts';
|
|
7
|
-
import type { AnyTextChunkDefinition } from './TextChunkDefinition.ts';
|
|
8
8
|
import type { AnyTextElementDefinition } from './TextElementDefinition.ts';
|
|
9
9
|
|
|
10
10
|
export type TextBindAttributeLocalName = 'constraintMsg' | 'requiredMsg';
|
|
@@ -25,7 +25,7 @@ export abstract class TextRangeDefinition<Role extends TextRole> extends Depende
|
|
|
25
25
|
readonly parentReference: string | null;
|
|
26
26
|
readonly reference: string | null;
|
|
27
27
|
|
|
28
|
-
abstract readonly chunks: readonly
|
|
28
|
+
abstract readonly chunks: readonly AnyTextChunkExpression[];
|
|
29
29
|
|
|
30
30
|
override get isTranslated(): boolean {
|
|
31
31
|
return (
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { XFormDataType } from '../XFormDataType.ts';
|
|
2
|
-
import { XFormDefinition } from '../XFormDefinition.ts';
|
|
3
|
-
import { DependencyContext } from '../expression/DependencyContext.ts';
|
|
4
|
-
import { MessageDefinition } from '../parse/text/MessageDefinition.ts';
|
|
5
|
-
import { BindComputation } from './BindComputation.ts';
|
|
6
|
-
import { BindElement } from './BindElement.ts';
|
|
7
|
-
import { ModelDefinition } from './ModelDefinition.ts';
|
|
8
|
-
|
|
9
|
-
export declare class BindDefinition extends DependencyContext {
|
|
10
|
-
readonly form: XFormDefinition;
|
|
11
|
-
protected readonly model: ModelDefinition;
|
|
12
|
-
readonly nodeset: string;
|
|
13
|
-
readonly bindElement: BindElement;
|
|
14
|
-
readonly bindType: string | null;
|
|
15
|
-
readonly dataType: XFormDataType;
|
|
16
|
-
readonly parentNodeset: string | null;
|
|
17
|
-
readonly calculate: BindComputation<'calculate'> | null;
|
|
18
|
-
readonly readonly: BindComputation<'readonly'>;
|
|
19
|
-
readonly relevant: BindComputation<'relevant'>;
|
|
20
|
-
readonly required: BindComputation<'required'>;
|
|
21
|
-
/**
|
|
22
|
-
* Diverges from {@link https://github.com/getodk/javarosa/blob/059321160e6f8dbb3e81d9add61d68dd35b13cc8/dag.md | JavaRosa's}, which excludes `constraint` expressions. We compute `constraint` dependencies like the other <bind> computation expressions, but explicitly ignore self-references (this is currently handled by {@link BindComputation}, via its {@link DependentExpression} parent class).
|
|
23
|
-
*/
|
|
24
|
-
readonly constraint: BindComputation<'constraint'>;
|
|
25
|
-
readonly constraintMsg: MessageDefinition<'constraintMsg'> | null;
|
|
26
|
-
readonly requiredMsg: MessageDefinition<'requiredMsg'> | null;
|
|
27
|
-
readonly saveIncomplete: BindComputation<'saveIncomplete'>;
|
|
28
|
-
protected _parentBind: BindDefinition | null | undefined;
|
|
29
|
-
get parentBind(): BindDefinition | null;
|
|
30
|
-
get reference(): string;
|
|
31
|
-
get parentReference(): string | null;
|
|
32
|
-
constructor(form: XFormDefinition, model: ModelDefinition, nodeset: string, bindElement: BindElement);
|
|
33
|
-
toJSON(): Omit<this, "model" | "toJSON" | "form" | "reference" | "parentReference" | "isTranslated" | "registerDependentExpression" | "dependencyExpressions" | "bindElement" | "parentBind">;
|
|
34
|
-
}
|