@getodk/xforms-engine 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/BaseNode.d.ts +69 -4
- package/dist/client/EngineConfig.d.ts +0 -1
- package/dist/client/GroupNode.d.ts +4 -3
- package/dist/client/ModelValueNode.d.ts +36 -0
- package/dist/client/NodeAppearances.d.ts +1 -2
- package/dist/client/NoteNode.d.ts +52 -0
- package/dist/client/RootNode.d.ts +4 -3
- package/dist/client/SelectNode.d.ts +6 -5
- package/dist/client/StringNode.d.ts +6 -5
- package/dist/client/SubtreeNode.d.ts +3 -2
- package/dist/client/TextRange.d.ts +85 -3
- package/dist/client/TriggerNode.d.ts +25 -0
- package/dist/client/constants.d.ts +8 -0
- package/dist/client/hierarchy.d.ts +19 -10
- package/dist/client/index.d.ts +0 -1
- package/dist/client/node-types.d.ts +3 -1
- package/dist/client/{RepeatRangeNode.d.ts → repeat/BaseRepeatRangeNode.d.ts} +18 -18
- package/dist/client/{RepeatInstanceNode.d.ts → repeat/RepeatInstanceNode.d.ts} +9 -9
- package/dist/client/repeat/RepeatRangeControlledNode.d.ts +18 -0
- package/dist/client/repeat/RepeatRangeUncontrolledNode.d.ts +19 -0
- package/dist/client/unsupported/RangeNode.d.ts +9 -0
- package/dist/client/unsupported/RankNode.d.ts +9 -0
- package/dist/client/unsupported/UnsupportedControlNode.d.ts +32 -0
- package/dist/client/unsupported/UploadNode.d.ts +9 -0
- package/dist/client/validation.d.ts +162 -0
- package/dist/index.d.ts +14 -6
- package/dist/index.js +39696 -36151
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +3 -2
- package/dist/instance/ModelValue.d.ts +39 -0
- package/dist/instance/Note.d.ts +41 -0
- package/dist/instance/Root.d.ts +5 -4
- package/dist/instance/SelectField.d.ts +11 -6
- package/dist/instance/StringField.d.ts +12 -7
- package/dist/instance/Subtree.d.ts +2 -1
- package/dist/instance/TriggerControl.d.ts +40 -0
- package/dist/instance/abstract/DescendantNode.d.ts +8 -10
- package/dist/instance/abstract/InstanceNode.d.ts +3 -2
- package/dist/instance/abstract/UnsupportedControl.d.ts +46 -0
- package/dist/instance/children.d.ts +0 -1
- package/dist/instance/hierarchy.d.ts +15 -6
- package/dist/instance/index.d.ts +0 -1
- package/dist/instance/internal-api/EvaluationContext.d.ts +0 -1
- package/dist/instance/internal-api/InstanceConfig.d.ts +0 -1
- package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -1
- package/dist/instance/internal-api/TranslationContext.d.ts +0 -1
- package/dist/instance/internal-api/ValidationContext.d.ts +28 -0
- package/dist/instance/internal-api/ValueContext.d.ts +3 -4
- package/dist/instance/{RepeatRange.d.ts → repeat/BaseRepeatRange.d.ts} +46 -46
- package/dist/instance/{RepeatInstance.d.ts → repeat/RepeatInstance.d.ts} +13 -13
- package/dist/instance/repeat/RepeatRangeControlled.d.ts +15 -0
- package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +34 -0
- package/dist/instance/resource.d.ts +0 -1
- package/dist/instance/text/TextChunk.d.ts +0 -1
- package/dist/instance/text/TextRange.d.ts +4 -5
- package/dist/instance/unsupported/RangeControl.d.ts +4 -0
- package/dist/instance/unsupported/RankControl.d.ts +4 -0
- package/dist/instance/unsupported/UploadControl.d.ts +4 -0
- package/dist/lib/TokenListParser.d.ts +3 -3
- package/dist/lib/dom/query.d.ts +1 -2
- package/dist/lib/reactivity/createChildrenState.d.ts +0 -1
- package/dist/lib/reactivity/createComputedExpression.d.ts +7 -3
- package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +4 -0
- package/dist/lib/reactivity/createSelectItems.d.ts +0 -1
- package/dist/lib/reactivity/createValueState.d.ts +0 -1
- package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createClientState.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createCurrentState.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createEngineState.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createSharedNodeState.d.ts +1 -2
- package/dist/lib/reactivity/node-state/createSpecifiedPropertyDescriptor.d.ts +0 -1
- package/dist/lib/reactivity/node-state/createSpecifiedState.d.ts +1 -2
- package/dist/lib/reactivity/node-state/representations.d.ts +0 -1
- package/dist/lib/reactivity/scope.d.ts +0 -1
- package/dist/lib/reactivity/text/createFieldHint.d.ts +3 -4
- package/dist/lib/reactivity/text/createNodeLabel.d.ts +3 -4
- package/dist/lib/reactivity/text/createNoteText.d.ts +24 -0
- package/dist/lib/reactivity/text/createTextRange.d.ts +5 -8
- package/dist/lib/reactivity/types.d.ts +0 -1
- package/dist/lib/reactivity/validation/createAggregatedViolations.d.ts +8 -0
- package/dist/lib/reactivity/validation/createValidation.d.ts +17 -0
- package/dist/{XFormDOM.d.ts → parse/XFormDOM.d.ts} +1 -2
- package/dist/{XFormDataType.d.ts → parse/XFormDataType.d.ts} +2 -4
- package/dist/{XFormDefinition.d.ts → parse/XFormDefinition.d.ts} +2 -3
- package/dist/{body → parse/body}/BodyDefinition.d.ts +15 -10
- package/dist/{body → parse/body}/BodyElementDefinition.d.ts +8 -7
- package/dist/{body → parse/body}/RepeatElementDefinition.d.ts +4 -5
- package/dist/{body → parse/body}/UnsupportedBodyElementDefinition.d.ts +0 -1
- package/dist/{body → parse/body}/appearance/inputAppearanceParser.d.ts +1 -2
- package/dist/{body → parse/body}/appearance/selectAppearanceParser.d.ts +1 -2
- package/dist/{body → parse/body}/appearance/structureElementAppearanceParser.d.ts +1 -2
- package/dist/parse/body/appearance/unknownAppearanceParser.d.ts +3 -0
- package/dist/{body → parse/body}/control/ControlDefinition.d.ts +3 -4
- package/dist/{body → parse/body}/control/InputDefinition.d.ts +1 -2
- package/dist/parse/body/control/RangeControlDefinition.d.ts +11 -0
- package/dist/parse/body/control/RankControlDefinition.d.ts +11 -0
- package/dist/parse/body/control/TriggerControlDefinition.d.ts +11 -0
- package/dist/parse/body/control/UploadControlDefinition.d.ts +11 -0
- package/dist/{body → parse/body}/control/select/ItemDefinition.d.ts +3 -4
- package/dist/{body → parse/body}/control/select/ItemsetDefinition.d.ts +7 -7
- package/dist/{body → parse/body}/control/select/ItemsetNodesetContext.d.ts +2 -3
- package/dist/{body → parse/body}/control/select/SelectDefinition.d.ts +3 -12
- package/dist/{body → parse/body}/group/BaseGroupDefinition.d.ts +3 -5
- package/dist/{body → parse/body}/group/LogicalGroupDefinition.d.ts +0 -1
- package/dist/{body → parse/body}/group/PresentationGroupDefinition.d.ts +1 -2
- package/dist/{body → parse/body}/group/StructuralGroupDefinition.d.ts +0 -1
- package/dist/{model/BindComputation.d.ts → parse/expression/BindComputationExpression.d.ts} +5 -6
- package/dist/{body/control/select → parse/expression}/ItemsetNodesetExpression.d.ts +2 -3
- package/dist/{body/control/select → parse/expression}/ItemsetValueExpression.d.ts +2 -3
- package/dist/parse/expression/RepeatCountControlExpression.d.ts +18 -0
- package/dist/parse/expression/TextLiteralExpression.d.ts +9 -0
- package/dist/parse/expression/TextOutputExpression.d.ts +7 -0
- package/dist/parse/expression/TextReferenceExpression.d.ts +7 -0
- package/dist/parse/expression/TextTranslationExpression.d.ts +8 -0
- package/dist/{expression → parse/expression/abstract}/DependencyContext.d.ts +0 -1
- package/dist/{expression → parse/expression/abstract}/DependentExpression.d.ts +13 -10
- package/dist/parse/expression/abstract/TextChunkExpression.d.ts +17 -0
- package/dist/parse/model/BindDefinition.d.ts +39 -0
- package/dist/{model → parse/model}/BindElement.d.ts +1 -0
- package/dist/{model → parse/model}/DescendentNodeDefinition.d.ts +0 -1
- package/dist/{model/ValueNodeDefinition.d.ts → parse/model/LeafNodeDefinition.d.ts} +3 -4
- package/dist/{model → parse/model}/ModelBindMap.d.ts +0 -1
- package/dist/{model → parse/model}/ModelDefinition.d.ts +1 -2
- package/dist/{model → parse/model}/NodeDefinition.d.ts +8 -9
- package/dist/parse/model/NoteNodeDefinition.d.ts +30 -0
- package/dist/{model → parse/model}/RepeatInstanceDefinition.d.ts +3 -4
- package/dist/{model → parse/model}/RepeatRangeDefinition.d.ts +14 -5
- package/dist/{model → parse/model}/RepeatTemplateDefinition.d.ts +2 -3
- package/dist/{model → parse/model}/RootDefinition.d.ts +2 -3
- package/dist/{model → parse/model}/SubtreeDefinition.d.ts +1 -2
- package/dist/parse/text/HintDefinition.d.ts +8 -0
- package/dist/parse/text/ItemLabelDefinition.d.ts +8 -0
- package/dist/parse/text/ItemsetLabelDefinition.d.ts +12 -0
- package/dist/parse/text/LabelDefinition.d.ts +14 -0
- package/dist/parse/text/MessageDefinition.d.ts +14 -0
- package/dist/parse/text/abstract/TextElementDefinition.d.ts +22 -0
- package/dist/parse/text/abstract/TextRangeDefinition.d.ts +34 -0
- package/dist/parse/xpath/dependency-analysis.d.ts +40 -0
- package/dist/parse/xpath/path-resolution.d.ts +69 -0
- package/dist/parse/xpath/predicate-analysis.d.ts +29 -0
- package/dist/parse/xpath/reference-parsing.d.ts +17 -0
- package/dist/parse/xpath/semantic-analysis.d.ts +97 -0
- package/dist/parse/xpath/syntax-traversal.d.ts +68 -0
- package/dist/solid.js +8745 -5186
- package/dist/solid.js.map +1 -1
- package/package.json +15 -16
- package/src/client/BaseNode.ts +74 -8
- package/src/client/GroupNode.ts +4 -2
- package/src/client/ModelValueNode.ts +40 -0
- package/src/client/NodeAppearances.ts +1 -1
- package/src/client/NoteNode.ts +74 -0
- package/src/client/README.md +1 -0
- package/src/client/RootNode.ts +4 -2
- package/src/client/SelectNode.ts +6 -4
- package/src/client/StringNode.ts +6 -4
- package/src/client/SubtreeNode.ts +3 -1
- package/src/client/TextRange.ts +98 -2
- package/src/client/TriggerNode.ts +29 -0
- package/src/client/constants.ts +10 -0
- package/src/client/hierarchy.ts +43 -15
- package/src/client/node-types.ts +17 -2
- package/src/client/{RepeatRangeNode.ts → repeat/BaseRepeatRangeNode.ts} +18 -19
- package/src/client/{RepeatInstanceNode.ts → repeat/RepeatInstanceNode.ts} +10 -8
- package/src/client/repeat/RepeatRangeControlledNode.ts +20 -0
- package/src/client/repeat/RepeatRangeUncontrolledNode.ts +21 -0
- package/src/client/unsupported/RangeNode.ts +14 -0
- package/src/client/unsupported/RankNode.ts +14 -0
- package/src/client/unsupported/UnsupportedControlNode.ts +40 -0
- package/src/client/unsupported/UploadNode.ts +14 -0
- package/src/client/validation.ts +199 -0
- package/src/index.ts +21 -9
- package/src/instance/Group.ts +10 -4
- package/src/instance/ModelValue.ts +104 -0
- package/src/instance/Note.ts +142 -0
- package/src/instance/Root.ts +16 -6
- package/src/instance/SelectField.ts +29 -7
- package/src/instance/StringField.ts +36 -10
- package/src/instance/Subtree.ts +9 -3
- package/src/instance/TriggerControl.ts +134 -0
- package/src/instance/abstract/DescendantNode.ts +9 -10
- package/src/instance/abstract/InstanceNode.ts +29 -7
- package/src/instance/abstract/UnsupportedControl.ts +151 -0
- package/src/instance/children.ts +113 -16
- package/src/instance/hierarchy.ts +42 -5
- package/src/instance/index.ts +1 -1
- package/src/instance/internal-api/EvaluationContext.ts +1 -1
- package/src/instance/internal-api/ValidationContext.ts +32 -0
- package/src/instance/internal-api/ValueContext.ts +3 -3
- package/src/instance/{RepeatRange.ts → repeat/BaseRepeatRange.ts} +114 -99
- package/src/instance/{RepeatInstance.ts → repeat/RepeatInstance.ts} +27 -22
- package/src/instance/repeat/RepeatRangeControlled.ts +82 -0
- package/src/instance/repeat/RepeatRangeUncontrolled.ts +67 -0
- package/src/instance/text/TextRange.ts +10 -4
- package/src/instance/unsupported/RangeControl.ts +5 -0
- package/src/instance/unsupported/RankControl.ts +5 -0
- package/src/instance/unsupported/UploadControl.ts +5 -0
- package/src/lib/TokenListParser.ts +11 -7
- package/src/lib/dom/query.ts +1 -1
- package/src/lib/reactivity/createComputedExpression.ts +25 -27
- package/src/lib/reactivity/createNoteReadonlyThunk.ts +33 -0
- package/src/lib/reactivity/createSelectItems.ts +23 -16
- package/src/lib/reactivity/createValueState.ts +3 -3
- package/src/lib/reactivity/node-state/createSharedNodeState.ts +1 -1
- package/src/lib/reactivity/node-state/createSpecifiedState.ts +1 -1
- package/src/lib/reactivity/text/createFieldHint.ts +9 -7
- package/src/lib/reactivity/text/createNodeLabel.ts +8 -6
- package/src/lib/reactivity/text/createNoteText.ts +72 -0
- package/src/lib/reactivity/text/createTextRange.ts +17 -90
- package/src/lib/reactivity/validation/createAggregatedViolations.ts +75 -0
- package/src/lib/reactivity/validation/createValidation.ts +196 -0
- package/src/{XFormDataType.ts → parse/XFormDataType.ts} +1 -3
- package/src/{XFormDefinition.ts → parse/XFormDefinition.ts} +2 -2
- package/src/{body → parse/body}/BodyDefinition.ts +44 -27
- package/src/{body → parse/body}/BodyElementDefinition.ts +13 -6
- package/src/{body → parse/body}/RepeatElementDefinition.ts +10 -20
- package/src/{body → parse/body}/appearance/inputAppearanceParser.ts +1 -1
- package/src/{body → parse/body}/appearance/selectAppearanceParser.ts +1 -1
- package/src/{body → parse/body}/appearance/structureElementAppearanceParser.ts +1 -1
- package/src/parse/body/appearance/unknownAppearanceParser.ts +5 -0
- package/src/{body → parse/body}/control/ControlDefinition.ts +5 -4
- package/src/parse/body/control/RangeControlDefinition.ts +26 -0
- package/src/parse/body/control/RankControlDefinition.ts +27 -0
- package/src/parse/body/control/TriggerControlDefinition.ts +26 -0
- package/src/parse/body/control/UploadControlDefinition.ts +26 -0
- package/src/{body → parse/body}/control/select/ItemDefinition.ts +4 -4
- package/src/parse/body/control/select/ItemsetDefinition.ts +53 -0
- package/src/{body → parse/body}/control/select/ItemsetNodesetContext.ts +2 -2
- package/src/{body → parse/body}/control/select/SelectDefinition.ts +3 -11
- package/src/{body → parse/body}/group/BaseGroupDefinition.ts +11 -21
- package/src/{body → parse/body}/group/PresentationGroupDefinition.ts +1 -1
- package/src/{model/BindComputation.ts → parse/expression/BindComputationExpression.ts} +8 -12
- package/src/parse/expression/ItemsetNodesetExpression.ts +8 -0
- package/src/{body/control/select → parse/expression}/ItemsetValueExpression.ts +2 -2
- package/src/parse/expression/RepeatCountControlExpression.ts +44 -0
- package/src/parse/expression/TextLiteralExpression.ts +19 -0
- package/src/parse/expression/TextOutputExpression.ts +25 -0
- package/src/parse/expression/TextReferenceExpression.ts +14 -0
- package/src/parse/expression/TextTranslationExpression.ts +38 -0
- package/src/{expression → parse/expression/abstract}/DependentExpression.ts +46 -28
- package/src/parse/expression/abstract/TextChunkExpression.ts +38 -0
- package/src/{model → parse/model}/BindDefinition.ts +30 -27
- package/src/{model → parse/model}/BindElement.ts +1 -0
- package/src/{model/ValueNodeDefinition.ts → parse/model/LeafNodeDefinition.ts} +4 -4
- package/src/{model → parse/model}/ModelBindMap.ts +4 -0
- package/src/{model → parse/model}/NodeDefinition.ts +12 -12
- package/src/parse/model/NoteNodeDefinition.ts +70 -0
- package/src/{model → parse/model}/RepeatInstanceDefinition.ts +2 -2
- package/src/parse/model/RepeatRangeDefinition.ts +94 -0
- package/src/{model → parse/model}/RootDefinition.ts +8 -4
- package/src/parse/text/HintDefinition.ts +25 -0
- package/src/parse/text/ItemLabelDefinition.ts +25 -0
- package/src/parse/text/ItemsetLabelDefinition.ts +44 -0
- package/src/parse/text/LabelDefinition.ts +61 -0
- package/src/parse/text/MessageDefinition.ts +49 -0
- package/src/parse/text/abstract/TextElementDefinition.ts +71 -0
- package/src/parse/text/abstract/TextRangeDefinition.ts +70 -0
- package/src/parse/xpath/dependency-analysis.ts +105 -0
- package/src/parse/xpath/path-resolution.ts +475 -0
- package/src/parse/xpath/predicate-analysis.ts +61 -0
- package/src/parse/xpath/reference-parsing.ts +90 -0
- package/src/parse/xpath/semantic-analysis.ts +466 -0
- package/src/parse/xpath/syntax-traversal.ts +129 -0
- package/dist/body/text/HintDefinition.d.ts +0 -11
- package/dist/body/text/LabelDefinition.d.ts +0 -22
- package/dist/body/text/TextElementDefinition.d.ts +0 -33
- package/dist/body/text/TextElementOutputPart.d.ts +0 -13
- package/dist/body/text/TextElementPart.d.ts +0 -13
- package/dist/body/text/TextElementReferencePart.d.ts +0 -7
- package/dist/body/text/TextElementStaticPart.d.ts +0 -7
- package/dist/lib/xpath/analysis.d.ts +0 -23
- package/dist/model/BindDefinition.d.ts +0 -32
- package/src/body/control/select/ItemsetDefinition.ts +0 -36
- package/src/body/control/select/ItemsetNodesetExpression.ts +0 -8
- package/src/body/text/HintDefinition.ts +0 -26
- package/src/body/text/LabelDefinition.ts +0 -68
- package/src/body/text/TextElementDefinition.ts +0 -97
- package/src/body/text/TextElementOutputPart.ts +0 -27
- package/src/body/text/TextElementPart.ts +0 -31
- package/src/body/text/TextElementReferencePart.ts +0 -21
- package/src/body/text/TextElementStaticPart.ts +0 -26
- package/src/lib/xpath/analysis.ts +0 -241
- package/src/model/RepeatRangeDefinition.ts +0 -53
- package/src/{XFormDOM.ts → parse/XFormDOM.ts} +0 -0
- package/src/{body → parse/body}/UnsupportedBodyElementDefinition.ts +0 -0
- package/src/{body → parse/body}/control/InputDefinition.ts +1 -1
- /package/src/{body → parse/body}/group/LogicalGroupDefinition.ts +0 -0
- /package/src/{body → parse/body}/group/StructuralGroupDefinition.ts +0 -0
- /package/src/{expression → parse/expression/abstract}/DependencyContext.ts +0 -0
- /package/src/{model → parse/model}/DescendentNodeDefinition.ts +0 -0
- /package/src/{model → parse/model}/ModelDefinition.ts +0 -0
- /package/src/{model → parse/model}/RepeatTemplateDefinition.ts +0 -0
- /package/src/{model → parse/model}/SubtreeDefinition.ts +0 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { Accessor } from 'solid-js';
|
|
2
|
+
import { createMemo } from 'solid-js';
|
|
3
|
+
import type { OpaqueReactiveObjectFactory } from '../../../client/OpaqueReactiveObjectFactory.ts';
|
|
4
|
+
import type {
|
|
5
|
+
TextRange as ClientTextRange,
|
|
6
|
+
ValidationTextRole,
|
|
7
|
+
} from '../../../client/TextRange.ts';
|
|
8
|
+
import { VALIDATION_TEXT } from '../../../client/constants.ts';
|
|
9
|
+
import type {
|
|
10
|
+
AnyViolation,
|
|
11
|
+
ConditionSatisfied,
|
|
12
|
+
ConditionValidation,
|
|
13
|
+
ConditionViolation,
|
|
14
|
+
ValidationCondition,
|
|
15
|
+
} from '../../../client/validation.ts';
|
|
16
|
+
import type { ValidationContext } from '../../../instance/internal-api/ValidationContext.ts';
|
|
17
|
+
import { TextChunk } from '../../../instance/text/TextChunk.ts';
|
|
18
|
+
import { TextRange } from '../../../instance/text/TextRange.ts';
|
|
19
|
+
import type { MessageDefinition } from '../../../parse/text/MessageDefinition.ts';
|
|
20
|
+
import { createComputedExpression } from '../createComputedExpression.ts';
|
|
21
|
+
import type {
|
|
22
|
+
SharedNodeState,
|
|
23
|
+
SharedNodeStateOptions,
|
|
24
|
+
} from '../node-state/createSharedNodeState.ts';
|
|
25
|
+
import { createSharedNodeState } from '../node-state/createSharedNodeState.ts';
|
|
26
|
+
import type { ReactiveScope } from '../scope.ts';
|
|
27
|
+
import { createTextRange } from '../text/createTextRange.ts';
|
|
28
|
+
|
|
29
|
+
type EngineViolationMessage<Role extends ValidationTextRole> = ClientTextRange<Role, 'engine'>;
|
|
30
|
+
|
|
31
|
+
const engineViolationMessage = <Role extends ValidationTextRole>(
|
|
32
|
+
context: ValidationContext,
|
|
33
|
+
role: Role
|
|
34
|
+
): Accessor<EngineViolationMessage<Role>> => {
|
|
35
|
+
const messageText = VALIDATION_TEXT[role];
|
|
36
|
+
const chunk = new TextChunk(context.root, 'literal', messageText);
|
|
37
|
+
const message = new TextRange('engine', role, [chunk]);
|
|
38
|
+
|
|
39
|
+
return () => message;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const createViolationMessage = <Role extends ValidationTextRole>(
|
|
43
|
+
context: ValidationContext,
|
|
44
|
+
role: Role,
|
|
45
|
+
definition: MessageDefinition<Role> | null
|
|
46
|
+
) => {
|
|
47
|
+
if (definition == null) {
|
|
48
|
+
return engineViolationMessage(context, role);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return createTextRange(context, role, definition);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// prettier-ignore
|
|
55
|
+
type ComputedConditionValidation<
|
|
56
|
+
Condition extends ValidationCondition
|
|
57
|
+
> = Accessor<ConditionValidation<Condition>>;
|
|
58
|
+
|
|
59
|
+
const constraintValid = (): ConditionSatisfied<'constraint'> => {
|
|
60
|
+
return {
|
|
61
|
+
condition: 'constraint',
|
|
62
|
+
valid: true,
|
|
63
|
+
message: null,
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const createConstraintValidation = (
|
|
68
|
+
context: ValidationContext
|
|
69
|
+
): ComputedConditionValidation<'constraint'> => {
|
|
70
|
+
return context.scope.runTask(() => {
|
|
71
|
+
const { constraint, constraintMsg } = context.definition.bind;
|
|
72
|
+
|
|
73
|
+
if (constraint == null) {
|
|
74
|
+
return constraintValid;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const isValid = createComputedExpression(context, constraint, {
|
|
78
|
+
arbitraryDependencies: [context],
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const message = createViolationMessage(context, 'constraintMsg', constraintMsg);
|
|
82
|
+
|
|
83
|
+
return createMemo(() => {
|
|
84
|
+
if (!context.isRelevant() || context.isBlank() || isValid()) {
|
|
85
|
+
return constraintValid();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
condition: 'constraint',
|
|
90
|
+
valid: false,
|
|
91
|
+
message: message(),
|
|
92
|
+
} as const;
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const requiredValid = (): ConditionSatisfied<'required'> => {
|
|
98
|
+
return {
|
|
99
|
+
condition: 'required',
|
|
100
|
+
valid: true,
|
|
101
|
+
message: null,
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const createRequiredValidation = (
|
|
106
|
+
context: ValidationContext
|
|
107
|
+
): ComputedConditionValidation<'required'> => {
|
|
108
|
+
return context.scope.runTask(() => {
|
|
109
|
+
const { required, requiredMsg } = context.definition.bind;
|
|
110
|
+
|
|
111
|
+
if (required.isDefaultExpression) {
|
|
112
|
+
return requiredValid;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const isValid = () => {
|
|
116
|
+
if (context.isRequired()) {
|
|
117
|
+
return !context.isBlank();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return true;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const message = createViolationMessage(context, 'requiredMsg', requiredMsg);
|
|
124
|
+
|
|
125
|
+
return createMemo(() => {
|
|
126
|
+
if (!context.isRelevant() || isValid()) {
|
|
127
|
+
return requiredValid();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
condition: 'required',
|
|
132
|
+
valid: false,
|
|
133
|
+
message: message(),
|
|
134
|
+
} as const;
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
type OptionalViolation<Condition extends ValidationCondition> =
|
|
140
|
+
Accessor<ConditionViolation<Condition> | null>;
|
|
141
|
+
|
|
142
|
+
const createComputedViolation = <Condition extends ValidationCondition>(
|
|
143
|
+
scope: ReactiveScope,
|
|
144
|
+
validateCondition: ComputedConditionValidation<Condition>
|
|
145
|
+
): OptionalViolation<Condition> => {
|
|
146
|
+
return scope.runTask(() => {
|
|
147
|
+
return createMemo(() => {
|
|
148
|
+
const validation = validateCondition();
|
|
149
|
+
|
|
150
|
+
if (validation.valid) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return validation;
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
type ComputedViolation = Accessor<AnyViolation | null>;
|
|
160
|
+
|
|
161
|
+
interface ValidationStateSpec {
|
|
162
|
+
readonly constraint: ComputedConditionValidation<'constraint'>;
|
|
163
|
+
readonly required: ComputedConditionValidation<'required'>;
|
|
164
|
+
readonly violation: ComputedViolation;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export type SharedValidationState = SharedNodeState<ValidationStateSpec>;
|
|
168
|
+
|
|
169
|
+
interface ValidationStateOptions<Factory extends OpaqueReactiveObjectFactory>
|
|
170
|
+
extends SharedNodeStateOptions<Factory, ValidationStateSpec> {}
|
|
171
|
+
|
|
172
|
+
export const createValidationState = <Factory extends OpaqueReactiveObjectFactory>(
|
|
173
|
+
context: ValidationContext,
|
|
174
|
+
options: ValidationStateOptions<Factory>
|
|
175
|
+
): SharedValidationState => {
|
|
176
|
+
const { scope } = context;
|
|
177
|
+
|
|
178
|
+
return scope.runTask(() => {
|
|
179
|
+
const constraint = createConstraintValidation(context);
|
|
180
|
+
const constraintViolation = createComputedViolation(scope, constraint);
|
|
181
|
+
const required = createRequiredValidation(context);
|
|
182
|
+
const requiredViolation = createComputedViolation(scope, required);
|
|
183
|
+
|
|
184
|
+
const violation = createMemo(() => {
|
|
185
|
+
return constraintViolation() ?? requiredViolation();
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
const spec: ValidationStateSpec = {
|
|
189
|
+
constraint,
|
|
190
|
+
required,
|
|
191
|
+
violation,
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
return createSharedNodeState(scope, spec, options);
|
|
195
|
+
});
|
|
196
|
+
};
|
|
@@ -10,9 +10,7 @@ export type UnsupportedDataType = typeof UNSUPPORTED_DATA_TYPE;
|
|
|
10
10
|
/**
|
|
11
11
|
* Like JavaRosa. Presumably for e.g. groups with explicit binds (`relevant` etc)?
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export type NullDataType = typeof NULL_DATA_TYPE;
|
|
13
|
+
export type NullDataType = 'NULL';
|
|
16
14
|
|
|
17
15
|
/**
|
|
18
16
|
* As in ODK XForms Spec.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BodyDefinition } from './body/BodyDefinition.ts';
|
|
1
|
+
import { BodyDefinition } from '../parse/body/BodyDefinition.ts';
|
|
3
2
|
import { ModelDefinition } from './model/ModelDefinition.ts';
|
|
3
|
+
import { XFormDOM } from './XFormDOM.ts';
|
|
4
4
|
|
|
5
5
|
export class XFormDefinition {
|
|
6
6
|
readonly xformDOM: XFormDOM;
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
import { RepeatElementDefinition } from './RepeatElementDefinition.ts';
|
|
6
|
-
import { UnsupportedBodyElementDefinition } from './UnsupportedBodyElementDefinition.ts';
|
|
1
|
+
import type { ParsedTokenList } from '../../lib/TokenListParser.ts';
|
|
2
|
+
import { TokenListParser } from '../../lib/TokenListParser.ts';
|
|
3
|
+
import type { XFormDefinition } from '../../parse/XFormDefinition.ts';
|
|
4
|
+
import { DependencyContext } from '../expression/abstract/DependencyContext.ts';
|
|
7
5
|
import { ControlDefinition } from './control/ControlDefinition.ts';
|
|
8
6
|
import { InputDefinition } from './control/InputDefinition.ts';
|
|
7
|
+
import { RangeControlDefinition } from './control/RangeControlDefinition.ts';
|
|
8
|
+
import { RankControlDefinition } from './control/RankControlDefinition.ts';
|
|
9
9
|
import type { AnySelectDefinition } from './control/select/SelectDefinition.ts';
|
|
10
10
|
import { SelectDefinition } from './control/select/SelectDefinition.ts';
|
|
11
|
+
import { TriggerControlDefinition } from './control/TriggerControlDefinition.ts';
|
|
12
|
+
import { UploadControlDefinition } from './control/UploadControlDefinition.ts';
|
|
11
13
|
import { LogicalGroupDefinition } from './group/LogicalGroupDefinition.ts';
|
|
12
14
|
import { PresentationGroupDefinition } from './group/PresentationGroupDefinition.ts';
|
|
13
15
|
import { StructuralGroupDefinition } from './group/StructuralGroupDefinition.ts';
|
|
16
|
+
import { RepeatElementDefinition } from './RepeatElementDefinition.ts';
|
|
17
|
+
import { UnsupportedBodyElementDefinition } from './UnsupportedBodyElementDefinition.ts';
|
|
14
18
|
|
|
15
19
|
export interface BodyElementParentContext {
|
|
20
|
+
readonly body: BodyDefinition;
|
|
16
21
|
readonly reference: string | null;
|
|
17
22
|
readonly element: Element;
|
|
18
23
|
}
|
|
@@ -20,7 +25,11 @@ export interface BodyElementParentContext {
|
|
|
20
25
|
// prettier-ignore
|
|
21
26
|
export type ControlElementDefinition =
|
|
22
27
|
| AnySelectDefinition
|
|
23
|
-
| InputDefinition
|
|
28
|
+
| InputDefinition
|
|
29
|
+
| RangeControlDefinition
|
|
30
|
+
| RankControlDefinition
|
|
31
|
+
| TriggerControlDefinition
|
|
32
|
+
| UploadControlDefinition;
|
|
24
33
|
|
|
25
34
|
type SupportedBodyElementDefinition =
|
|
26
35
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
@@ -40,6 +49,10 @@ const BodyElementDefinitionConstructors = [
|
|
|
40
49
|
StructuralGroupDefinition,
|
|
41
50
|
InputDefinition,
|
|
42
51
|
SelectDefinition,
|
|
52
|
+
RangeControlDefinition,
|
|
53
|
+
RankControlDefinition,
|
|
54
|
+
TriggerControlDefinition,
|
|
55
|
+
UploadControlDefinition,
|
|
43
56
|
] as const satisfies readonly BodyElementDefinitionConstructor[];
|
|
44
57
|
|
|
45
58
|
export type AnyBodyElementDefinition =
|
|
@@ -145,25 +158,8 @@ const bodyClassParser = new TokenListParser(['pages' /*, 'theme-grid' */]);
|
|
|
145
158
|
|
|
146
159
|
export type BodyClassList = ParsedTokenList<typeof bodyClassParser>;
|
|
147
160
|
|
|
148
|
-
export class BodyDefinition extends DependencyContext {
|
|
149
|
-
|
|
150
|
-
form: XFormDefinition,
|
|
151
|
-
parent: BodyElementParentContext,
|
|
152
|
-
parentElement: Element,
|
|
153
|
-
children: readonly Element[] = Array.from(parentElement.children)
|
|
154
|
-
): readonly AnyBodyElementDefinition[] {
|
|
155
|
-
return Array.from(children).map((element) => {
|
|
156
|
-
const { localName } = element;
|
|
157
|
-
|
|
158
|
-
for (const Constructor of BodyElementDefinitionConstructors) {
|
|
159
|
-
if (Constructor.isCompatible(localName, element)) {
|
|
160
|
-
return new Constructor(form, parent, element);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return new UnsupportedBodyElementDefinition(form, parent, element);
|
|
165
|
-
});
|
|
166
|
-
}
|
|
161
|
+
export class BodyDefinition extends DependencyContext implements BodyElementParentContext {
|
|
162
|
+
readonly body: BodyDefinition;
|
|
167
163
|
|
|
168
164
|
readonly element: Element;
|
|
169
165
|
|
|
@@ -196,12 +192,14 @@ export class BodyDefinition extends DependencyContext {
|
|
|
196
192
|
constructor(protected readonly form: XFormDefinition) {
|
|
197
193
|
super();
|
|
198
194
|
|
|
195
|
+
this.body = this;
|
|
196
|
+
|
|
199
197
|
const { body: element } = form.xformDOM;
|
|
200
198
|
|
|
201
199
|
this.reference = form.rootReference;
|
|
202
200
|
this.element = element;
|
|
203
201
|
this.classes = bodyClassParser.parseFrom(element, 'class');
|
|
204
|
-
this.elements =
|
|
202
|
+
this.elements = this.getChildElementDefinitions(form, this, element);
|
|
205
203
|
this.elementsByReference = new BodyElementMap(this.elements);
|
|
206
204
|
}
|
|
207
205
|
|
|
@@ -209,6 +207,25 @@ export class BodyDefinition extends DependencyContext {
|
|
|
209
207
|
return this.elementsByReference.get(reference) ?? null;
|
|
210
208
|
}
|
|
211
209
|
|
|
210
|
+
getChildElementDefinitions(
|
|
211
|
+
form: XFormDefinition,
|
|
212
|
+
parent: BodyElementParentContext,
|
|
213
|
+
parentElement: Element,
|
|
214
|
+
children: readonly Element[] = Array.from(parentElement.children)
|
|
215
|
+
): readonly AnyBodyElementDefinition[] {
|
|
216
|
+
return Array.from(children).map((element) => {
|
|
217
|
+
const { localName } = element;
|
|
218
|
+
|
|
219
|
+
for (const Constructor of BodyElementDefinitionConstructors) {
|
|
220
|
+
if (Constructor.isCompatible(localName, element)) {
|
|
221
|
+
return new Constructor(form, parent, element);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return new UnsupportedBodyElementDefinition(form, parent, element);
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
212
229
|
toJSON() {
|
|
213
230
|
const { form, ...rest } = this;
|
|
214
231
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { DependencyContext } from '../expression/abstract/DependencyContext.ts';
|
|
2
|
+
import type { HintDefinition } from '../text/HintDefinition.ts';
|
|
3
|
+
import type { ItemLabelDefinition } from '../text/ItemLabelDefinition.ts';
|
|
4
|
+
import type { LabelDefinition } from '../text/LabelDefinition.ts';
|
|
1
5
|
import type { XFormDefinition } from '../XFormDefinition.ts';
|
|
2
|
-
import {
|
|
3
|
-
import type { BodyElementParentContext } from './BodyDefinition.ts';
|
|
4
|
-
import type { HintDefinition } from './text/HintDefinition.ts';
|
|
5
|
-
import type { LabelDefinition } from './text/LabelDefinition.ts';
|
|
6
|
+
import type { BodyDefinition, BodyElementParentContext } from './BodyDefinition.ts';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* These category names roughly correspond to each of the ODK XForms spec's
|
|
@@ -11,7 +12,10 @@ import type { LabelDefinition } from './text/LabelDefinition.ts';
|
|
|
11
12
|
*/
|
|
12
13
|
type BodyElementCategory = 'control' | 'structure' | 'support' | 'UNSUPPORTED';
|
|
13
14
|
|
|
14
|
-
export abstract class BodyElementDefinition<Type extends string>
|
|
15
|
+
export abstract class BodyElementDefinition<Type extends string>
|
|
16
|
+
extends DependencyContext
|
|
17
|
+
implements BodyElementParentContext
|
|
18
|
+
{
|
|
15
19
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
20
|
// @ts-ignore
|
|
17
21
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -19,10 +23,12 @@ export abstract class BodyElementDefinition<Type extends string> extends Depende
|
|
|
19
23
|
throw new Error('Must be overridden by BodyElementDefinition subclass');
|
|
20
24
|
}
|
|
21
25
|
|
|
26
|
+
readonly body: BodyDefinition;
|
|
27
|
+
|
|
22
28
|
abstract readonly category: BodyElementCategory;
|
|
23
29
|
abstract readonly type: Type;
|
|
24
30
|
readonly hint: HintDefinition | null = null;
|
|
25
|
-
readonly label: LabelDefinition | null = null;
|
|
31
|
+
readonly label: ItemLabelDefinition | LabelDefinition | null = null;
|
|
26
32
|
|
|
27
33
|
readonly reference: string | null = null;
|
|
28
34
|
readonly parentReference: string | null;
|
|
@@ -33,6 +39,7 @@ export abstract class BodyElementDefinition<Type extends string> extends Depende
|
|
|
33
39
|
readonly element: Element
|
|
34
40
|
) {
|
|
35
41
|
super();
|
|
42
|
+
this.body = parent.body;
|
|
36
43
|
this.parentReference = parent.reference;
|
|
37
44
|
}
|
|
38
45
|
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { JAVAROSA_NAMESPACE_URI } from '@getodk/common/constants/xmlns.ts';
|
|
2
2
|
import type { XFormDefinition } from '../XFormDefinition.ts';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
3
|
+
import type {
|
|
4
|
+
BodyElementDefinitionArray,
|
|
5
|
+
BodyElementParentContext,
|
|
6
|
+
} from '../body/BodyDefinition.ts';
|
|
7
|
+
import { LabelDefinition } from '../text/LabelDefinition.ts';
|
|
8
|
+
import { parseNodesetReference } from '../xpath/reference-parsing.ts';
|
|
5
9
|
import { BodyElementDefinition } from './BodyElementDefinition.ts';
|
|
6
10
|
import type { StructureElementAppearanceDefinition } from './appearance/structureElementAppearanceParser.ts';
|
|
7
11
|
import { structureElementAppearanceParser } from './appearance/structureElementAppearanceParser.ts';
|
|
8
|
-
import { LabelDefinition } from './text/LabelDefinition.ts';
|
|
9
12
|
|
|
10
13
|
export class RepeatElementDefinition extends BodyElementDefinition<'repeat'> {
|
|
11
14
|
static override isCompatible(localName: string): boolean {
|
|
@@ -18,11 +21,8 @@ export class RepeatElementDefinition extends BodyElementDefinition<'repeat'> {
|
|
|
18
21
|
readonly appearances: StructureElementAppearanceDefinition;
|
|
19
22
|
override readonly label: LabelDefinition | null;
|
|
20
23
|
|
|
21
|
-
// TODO: this will fall into the growing category of non-`BindExpression`
|
|
22
|
-
// cases which have roughly the same design story.
|
|
23
24
|
readonly countExpression: string | null;
|
|
24
|
-
|
|
25
|
-
readonly isFixedCount: boolean;
|
|
25
|
+
readonly noAddRemoveExpression: string | null;
|
|
26
26
|
|
|
27
27
|
readonly children: BodyElementDefinitionArray;
|
|
28
28
|
|
|
@@ -31,7 +31,7 @@ export class RepeatElementDefinition extends BodyElementDefinition<'repeat'> {
|
|
|
31
31
|
|
|
32
32
|
this.label = LabelDefinition.forRepeatGroup(form, this);
|
|
33
33
|
|
|
34
|
-
const reference = element
|
|
34
|
+
const reference = parseNodesetReference(parent, element, 'nodeset');
|
|
35
35
|
|
|
36
36
|
if (reference == null) {
|
|
37
37
|
throw new Error('Invalid repeat: missing `nodeset` reference');
|
|
@@ -40,26 +40,16 @@ export class RepeatElementDefinition extends BodyElementDefinition<'repeat'> {
|
|
|
40
40
|
this.reference = reference;
|
|
41
41
|
this.appearances = structureElementAppearanceParser.parseFrom(element, 'appearance');
|
|
42
42
|
this.countExpression = element.getAttributeNS(JAVAROSA_NAMESPACE_URI, 'count');
|
|
43
|
+
this.noAddRemoveExpression = element.getAttributeNS(JAVAROSA_NAMESPACE_URI, 'noAddRemove');
|
|
43
44
|
|
|
44
45
|
const childElements = Array.from(element.children).filter((childElement) => {
|
|
45
46
|
const { localName } = childElement;
|
|
46
47
|
|
|
47
48
|
return localName !== 'label' && localName !== 'group-label';
|
|
48
49
|
});
|
|
49
|
-
const children =
|
|
50
|
+
const children = this.body.getChildElementDefinitions(form, this, element, childElements);
|
|
50
51
|
|
|
51
52
|
this.children = children;
|
|
52
|
-
|
|
53
|
-
// Spec says this can be either `true()` or `false()`. That said, it
|
|
54
|
-
// could also presumably be `true ( )` or whatever.
|
|
55
|
-
const noAddRemove =
|
|
56
|
-
element
|
|
57
|
-
.getAttributeNS(JAVAROSA_NAMESPACE_URI, 'noAddRemove')
|
|
58
|
-
?.trim()
|
|
59
|
-
.replaceAll(/\s+/g, '') ?? 'false()';
|
|
60
|
-
|
|
61
|
-
// TODO: **probably** safe to disregard anything else?
|
|
62
|
-
this.isFixedCount = noAddRemove === 'true()';
|
|
63
53
|
}
|
|
64
54
|
|
|
65
55
|
override toJSON() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TokenListParser, type ParsedTokenList } from '
|
|
1
|
+
import { TokenListParser, type ParsedTokenList } from '../../../lib/TokenListParser.ts';
|
|
2
2
|
|
|
3
3
|
export const structureElementAppearanceParser = new TokenListParser(['field-list', 'table-list']);
|
|
4
4
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import type { ParsedTokenList } from '../../../lib/TokenListParser.ts';
|
|
2
|
+
import { HintDefinition } from '../../text/HintDefinition.ts';
|
|
3
|
+
import { LabelDefinition } from '../../text/LabelDefinition.ts';
|
|
1
4
|
import type { XFormDefinition } from '../../XFormDefinition.ts';
|
|
2
|
-
import
|
|
5
|
+
import { parseNodesetReference } from '../../xpath/reference-parsing.ts';
|
|
3
6
|
import type { BodyElementParentContext } from '../BodyDefinition.ts';
|
|
4
7
|
import { BodyElementDefinition } from '../BodyElementDefinition.ts';
|
|
5
|
-
import { HintDefinition } from '../text/HintDefinition.ts';
|
|
6
|
-
import { LabelDefinition } from '../text/LabelDefinition.ts';
|
|
7
8
|
|
|
8
9
|
// prettier-ignore
|
|
9
10
|
type ControlType =
|
|
@@ -30,7 +31,7 @@ export abstract class ControlDefinition<
|
|
|
30
31
|
constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element) {
|
|
31
32
|
super(form, parent, element);
|
|
32
33
|
|
|
33
|
-
const reference = element
|
|
34
|
+
const reference = parseNodesetReference(parent, element, 'ref');
|
|
34
35
|
|
|
35
36
|
if (reference == null) {
|
|
36
37
|
throw new Error(`Invalid control: missing ref attribute`);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { XFormDefinition } from '../../XFormDefinition.ts';
|
|
2
|
+
import {
|
|
3
|
+
unknownAppearanceParser,
|
|
4
|
+
type UnknownAppearanceDefinition,
|
|
5
|
+
} from '../appearance/unknownAppearanceParser.ts';
|
|
6
|
+
import type { BodyElementParentContext } from '../BodyDefinition.ts';
|
|
7
|
+
import { ControlDefinition } from './ControlDefinition.ts';
|
|
8
|
+
|
|
9
|
+
export class RangeControlDefinition extends ControlDefinition<'range'> {
|
|
10
|
+
static override isCompatible(localName: string): boolean {
|
|
11
|
+
return localName === 'range';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
readonly type = 'range';
|
|
15
|
+
readonly appearances: UnknownAppearanceDefinition;
|
|
16
|
+
|
|
17
|
+
constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element) {
|
|
18
|
+
super(form, parent, element);
|
|
19
|
+
|
|
20
|
+
this.appearances = unknownAppearanceParser.parseFrom(element, 'appearance');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override toJSON(): object {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ODK_NAMESPACE_URI } from '@getodk/common/constants/xmlns.ts';
|
|
2
|
+
import type { XFormDefinition } from '../../XFormDefinition.ts';
|
|
3
|
+
import {
|
|
4
|
+
unknownAppearanceParser,
|
|
5
|
+
type UnknownAppearanceDefinition,
|
|
6
|
+
} from '../appearance/unknownAppearanceParser.ts';
|
|
7
|
+
import type { BodyElementParentContext } from '../BodyDefinition.ts';
|
|
8
|
+
import { ControlDefinition } from './ControlDefinition.ts';
|
|
9
|
+
|
|
10
|
+
export class RankControlDefinition extends ControlDefinition<'rank'> {
|
|
11
|
+
static override isCompatible(localName: string, element: Element): boolean {
|
|
12
|
+
return localName === 'rank' && element.namespaceURI === ODK_NAMESPACE_URI;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
readonly type = 'rank';
|
|
16
|
+
readonly appearances: UnknownAppearanceDefinition;
|
|
17
|
+
|
|
18
|
+
constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element) {
|
|
19
|
+
super(form, parent, element);
|
|
20
|
+
|
|
21
|
+
this.appearances = unknownAppearanceParser.parseFrom(element, 'appearance');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
override toJSON(): object {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { XFormDefinition } from '../../XFormDefinition.ts';
|
|
2
|
+
import {
|
|
3
|
+
unknownAppearanceParser,
|
|
4
|
+
type UnknownAppearanceDefinition,
|
|
5
|
+
} from '../appearance/unknownAppearanceParser.ts';
|
|
6
|
+
import type { BodyElementParentContext } from '../BodyDefinition.ts';
|
|
7
|
+
import { ControlDefinition } from './ControlDefinition.ts';
|
|
8
|
+
|
|
9
|
+
export class TriggerControlDefinition extends ControlDefinition<'trigger'> {
|
|
10
|
+
static override isCompatible(localName: string): boolean {
|
|
11
|
+
return localName === 'trigger';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
readonly type = 'trigger';
|
|
15
|
+
readonly appearances: UnknownAppearanceDefinition;
|
|
16
|
+
|
|
17
|
+
constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element) {
|
|
18
|
+
super(form, parent, element);
|
|
19
|
+
|
|
20
|
+
this.appearances = unknownAppearanceParser.parseFrom(element, 'appearance');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override toJSON(): object {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { XFormDefinition } from '../../XFormDefinition.ts';
|
|
2
|
+
import {
|
|
3
|
+
unknownAppearanceParser,
|
|
4
|
+
type UnknownAppearanceDefinition,
|
|
5
|
+
} from '../appearance/unknownAppearanceParser.ts';
|
|
6
|
+
import type { BodyElementParentContext } from '../BodyDefinition.ts';
|
|
7
|
+
import { ControlDefinition } from './ControlDefinition.ts';
|
|
8
|
+
|
|
9
|
+
export class UploadControlDefinition extends ControlDefinition<'upload'> {
|
|
10
|
+
static override isCompatible(localName: string): boolean {
|
|
11
|
+
return localName === 'upload';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
readonly type = 'upload';
|
|
15
|
+
readonly appearances: UnknownAppearanceDefinition;
|
|
16
|
+
|
|
17
|
+
constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element) {
|
|
18
|
+
super(form, parent, element);
|
|
19
|
+
|
|
20
|
+
this.appearances = unknownAppearanceParser.parseFrom(element, 'appearance');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override toJSON(): object {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { getValueElement, type ItemElement } from '
|
|
1
|
+
import { getValueElement, type ItemElement } from '../../../../lib/dom/query.ts';
|
|
2
|
+
import { ItemLabelDefinition } from '../../../text/ItemLabelDefinition.ts';
|
|
2
3
|
import type { XFormDefinition } from '../../../XFormDefinition.ts';
|
|
3
4
|
import { BodyElementDefinition } from '../../BodyElementDefinition.ts';
|
|
4
|
-
import { LabelDefinition } from '../../text/LabelDefinition.ts';
|
|
5
5
|
import type { AnySelectDefinition } from './SelectDefinition.ts';
|
|
6
6
|
|
|
7
7
|
export class ItemDefinition extends BodyElementDefinition<'item'> {
|
|
8
8
|
override readonly category = 'support';
|
|
9
9
|
override readonly type = 'item';
|
|
10
10
|
|
|
11
|
-
override readonly label:
|
|
11
|
+
override readonly label: ItemLabelDefinition | null;
|
|
12
12
|
readonly value: string;
|
|
13
13
|
|
|
14
14
|
constructor(
|
|
@@ -25,7 +25,7 @@ export class ItemDefinition extends BodyElementDefinition<'item'> {
|
|
|
25
25
|
|
|
26
26
|
super(form, parent, element);
|
|
27
27
|
|
|
28
|
-
this.label =
|
|
28
|
+
this.label = ItemLabelDefinition.from(form, this);
|
|
29
29
|
this.value = value;
|
|
30
30
|
}
|
|
31
31
|
}
|