@getodk/xforms-engine 0.3.0 → 0.5.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 +15 -5
- package/dist/client/BaseValueNode.d.ts +32 -0
- package/dist/client/EngineConfig.d.ts +49 -49
- package/dist/client/GroupNode.d.ts +2 -3
- package/dist/client/InputNode.d.ts +53 -0
- package/dist/client/ModelValueNode.d.ts +13 -9
- package/dist/client/NodeAppearances.d.ts +1 -2
- package/dist/client/NoteNode.d.ts +3 -4
- package/dist/client/RootNode.d.ts +36 -10
- package/dist/client/SelectNode.d.ts +4 -5
- 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/ValueType.d.ts +3 -0
- package/dist/client/constants.d.ts +50 -1
- package/dist/client/hierarchy.d.ts +9 -5
- package/dist/client/identity.d.ts +14 -0
- package/dist/client/index.d.ts +0 -1
- package/dist/client/node-types.d.ts +3 -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/resources.d.ts +93 -0
- package/dist/client/submission/SubmissionData.d.ts +7 -0
- package/dist/client/submission/SubmissionDefinition.d.ts +14 -0
- package/dist/client/submission/SubmissionInstanceFile.d.ts +6 -0
- package/dist/client/submission/SubmissionOptions.d.ts +23 -0
- package/dist/client/submission/SubmissionResult.d.ts +91 -0
- package/dist/client/submission/SubmissionState.d.ts +12 -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 +2 -3
- package/dist/error/ErrorProductionDesignPendingError.d.ts +7 -0
- package/dist/error/ValueTypeInvariantError.d.ts +17 -0
- package/dist/error/XPathFunctionalityError.d.ts +14 -0
- package/dist/error/XPathFunctionalityNotSupportedError.d.ts +7 -0
- package/dist/error/XPathFunctionalityPendingError.d.ts +7 -0
- package/dist/index.d.ts +16 -4
- package/dist/index.js +8559 -4700
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +9 -5
- package/dist/instance/InputControl.d.ts +36 -0
- package/dist/instance/ModelValue.d.ts +16 -27
- package/dist/instance/Note.d.ts +11 -5
- package/dist/instance/PrimaryInstance.d.ts +84 -0
- package/dist/instance/Root.d.ts +31 -28
- package/dist/instance/SelectField.d.ts +13 -6
- package/dist/instance/Subtree.d.ts +10 -6
- package/dist/instance/TriggerControl.d.ts +47 -0
- package/dist/instance/abstract/DescendantNode.d.ts +33 -26
- package/dist/instance/abstract/InstanceNode.d.ts +50 -31
- package/dist/instance/abstract/UnsupportedControl.d.ts +53 -0
- package/dist/instance/abstract/ValueNode.d.ts +48 -0
- package/dist/instance/children.d.ts +0 -1
- package/dist/instance/hierarchy.d.ts +13 -8
- package/dist/instance/identity.d.ts +2 -7
- package/dist/instance/index.d.ts +0 -1
- package/dist/instance/internal-api/EvaluationContext.d.ts +53 -13
- package/dist/instance/internal-api/InstanceConfig.d.ts +8 -3
- package/dist/instance/internal-api/InstanceValueContext.d.ts +20 -0
- package/dist/instance/internal-api/PrimaryInstanceDocument.d.ts +36 -0
- package/dist/instance/internal-api/TranslationContext.d.ts +3 -3
- package/dist/instance/internal-api/ValidationContext.d.ts +12 -6
- package/dist/instance/internal-api/ValueContext.d.ts +5 -5
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableInstance.d.ts +14 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +31 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +18 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +17 -0
- package/dist/instance/repeat/BaseRepeatRange.d.ts +40 -85
- package/dist/instance/repeat/RepeatInstance.d.ts +11 -30
- package/dist/instance/repeat/RepeatRangeControlled.d.ts +3 -4
- package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +3 -4
- package/dist/instance/resource.d.ts +1 -2
- package/dist/instance/text/TextChunk.d.ts +0 -1
- package/dist/instance/text/TextRange.d.ts +1 -2
- package/dist/instance/unsupported/RangeControl.d.ts +6 -0
- package/dist/instance/unsupported/RankControl.d.ts +6 -0
- package/dist/instance/unsupported/UploadControl.d.ts +6 -0
- package/dist/integration/xpath/EngineXPathEvaluator.d.ts +14 -0
- package/dist/integration/xpath/adapter/XFormsXPathNode.d.ts +71 -0
- package/dist/integration/xpath/adapter/engineDOMAdapter.d.ts +5 -0
- package/dist/integration/xpath/adapter/kind.d.ts +32 -0
- package/dist/integration/xpath/adapter/names.d.ts +16 -0
- package/dist/integration/xpath/adapter/traversal.d.ts +25 -0
- package/dist/integration/xpath/adapter/values.d.ts +2 -0
- package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +19 -0
- package/dist/integration/xpath/static-dom/StaticDocument.d.ts +16 -0
- package/dist/integration/xpath/static-dom/StaticElement.d.ts +40 -0
- package/dist/integration/xpath/static-dom/StaticNamedNode.d.ts +17 -0
- package/dist/integration/xpath/static-dom/StaticNode.d.ts +33 -0
- package/dist/integration/xpath/static-dom/StaticText.d.ts +16 -0
- package/dist/lib/TokenListParser.d.ts +3 -3
- package/dist/lib/client-reactivity/submission/createInstanceSubmissionState.d.ts +3 -0
- package/dist/lib/client-reactivity/submission/createLeafNodeSubmissionState.d.ts +3 -0
- package/dist/lib/client-reactivity/submission/createNodeRangeSubmissionState.d.ts +4 -0
- package/dist/lib/client-reactivity/submission/createParentNodeSubmissionState.d.ts +4 -0
- package/dist/lib/client-reactivity/submission/createValueNodeSubmissionState.d.ts +3 -0
- package/dist/lib/client-reactivity/submission/prepareSubmission.d.ts +8 -0
- package/dist/lib/codecs/DecimalValueCodec.d.ts +6 -0
- package/dist/lib/codecs/IntValueCodec.d.ts +6 -0
- package/dist/lib/codecs/StringValueCodec.d.ts +4 -0
- package/dist/lib/codecs/ValueCodec.d.ts +30 -0
- package/dist/lib/codecs/ValueTypePlaceholderCodec.d.ts +12 -0
- package/dist/lib/codecs/getSharedValueCodec.d.ts +47 -0
- package/dist/lib/dom/query.d.ts +4 -2
- package/dist/lib/reactivity/createChildrenState.d.ts +7 -6
- package/dist/lib/reactivity/createComputedExpression.d.ts +19 -7
- package/dist/lib/reactivity/createInstanceValueState.d.ts +40 -0
- package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +2 -3
- package/dist/lib/reactivity/createSelectItems.d.ts +0 -1
- package/dist/lib/reactivity/createTranslationState.d.ts +19 -0
- package/dist/lib/reactivity/createValueState.d.ts +6 -11
- package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +4 -5
- 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/lib/xml-serialization.d.ts +41 -0
- package/dist/parse/XFormDOM.d.ts +42 -0
- package/dist/{XFormDefinition.d.ts → parse/XFormDefinition.d.ts} +3 -5
- package/dist/parse/attachments/FormAttachmentResource.d.ts +27 -0
- package/dist/{body → parse/body}/BodyDefinition.d.ts +16 -11
- 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/parse/body/appearance/inputAppearanceParser.d.ts +3 -0
- 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/control/InputDefinition.d.ts → parse/body/control/InputControlDefinition.d.ts} +2 -3
- 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 +1 -4
- 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/parse/expression/abstract/DependencyContext.d.ts +7 -0
- package/dist/{expression → parse/expression/abstract}/DependentExpression.d.ts +4 -6
- package/dist/parse/expression/abstract/TextChunkExpression.d.ts +17 -0
- package/dist/parse/model/BindDefinition.d.ts +38 -0
- package/dist/parse/model/BindTypeDefinition.d.ts +20 -0
- package/dist/{model → parse/model}/DescendentNodeDefinition.d.ts +0 -2
- package/dist/parse/model/FormSubmissionDefinition.d.ts +8 -0
- package/dist/parse/model/ItextTranslation/ItextTranslationDefinition.d.ts +4 -0
- package/dist/parse/model/ItextTranslation/ItextTranslationRootDefinition.d.ts +8 -0
- package/dist/parse/model/ItextTranslation/ItextTranslationsDefinition.d.ts +8 -0
- package/dist/{model → parse/model}/LeafNodeDefinition.d.ts +4 -3
- package/dist/{model → parse/model}/ModelBindMap.d.ts +1 -2
- package/dist/{model → parse/model}/ModelDefinition.d.ts +3 -2
- package/dist/{model → parse/model}/NodeDefinition.d.ts +0 -2
- package/dist/parse/{NoteNodeDefinition.d.ts → model/NoteNodeDefinition.d.ts} +12 -13
- 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 +5 -5
- package/dist/parse/model/SecondaryInstance/SecondaryInstanceDefinition.d.ts +4 -0
- package/dist/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.d.ts +7 -0
- package/dist/parse/model/SecondaryInstance/SecondaryInstancesDefinition.d.ts +13 -0
- package/dist/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.d.ts +14 -0
- package/dist/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.d.ts +22 -0
- package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.d.ts +23 -0
- package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.d.ts +9 -0
- package/dist/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.d.ts +5 -0
- package/dist/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.d.ts +7 -0
- package/dist/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.d.ts +13 -0
- package/dist/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.d.ts +12 -0
- package/dist/{model → parse/model}/SubtreeDefinition.d.ts +1 -2
- package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +24 -0
- 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 +4 -7
- 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 +5 -1
- package/dist/parse/xpath/syntax-traversal.d.ts +0 -1
- package/dist/solid.js +8398 -4543
- package/dist/solid.js.map +1 -1
- package/package.json +14 -12
- package/src/client/BaseNode.ts +17 -7
- package/src/client/BaseValueNode.ts +35 -0
- package/src/client/EngineConfig.ts +52 -51
- package/src/client/GroupNode.ts +2 -2
- package/src/client/InputNode.ts +77 -0
- package/src/client/ModelValueNode.ts +31 -8
- package/src/client/NodeAppearances.ts +1 -1
- package/src/client/NoteNode.ts +3 -3
- package/src/client/RootNode.ts +39 -9
- package/src/client/SelectNode.ts +5 -5
- package/src/client/SubtreeNode.ts +1 -1
- package/src/client/TextRange.ts +4 -5
- package/src/client/TriggerNode.ts +29 -0
- package/src/client/ValueType.ts +4 -0
- package/src/client/constants.ts +67 -0
- package/src/client/hierarchy.ts +16 -4
- package/src/client/identity.ts +16 -0
- package/src/client/node-types.ts +19 -5
- 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/resources.ts +118 -0
- package/src/client/submission/SubmissionData.ts +12 -0
- package/src/client/submission/SubmissionDefinition.ts +16 -0
- package/src/client/submission/SubmissionInstanceFile.ts +9 -0
- package/src/client/submission/SubmissionOptions.ts +28 -0
- package/src/client/submission/SubmissionResult.ts +124 -0
- package/src/client/submission/SubmissionState.ts +14 -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 +2 -2
- package/src/error/ErrorProductionDesignPendingError.ts +6 -0
- package/src/error/ValueTypeInvariantError.ts +22 -0
- package/src/error/XPathFunctionalityError.ts +26 -0
- package/src/error/XPathFunctionalityNotSupportedError.ts +18 -0
- package/src/error/XPathFunctionalityPendingError.ts +18 -0
- package/src/index.ts +16 -2
- package/src/instance/Group.ts +17 -5
- package/src/instance/InputControl.ts +119 -0
- package/src/instance/ModelValue.ts +47 -54
- package/src/instance/Note.ts +26 -10
- package/src/instance/PrimaryInstance.ts +244 -0
- package/src/instance/Root.ts +64 -132
- package/src/instance/SelectField.ts +62 -25
- package/src/instance/Subtree.ts +19 -7
- package/src/instance/{StringField.ts → TriggerControl.ts} +61 -30
- package/src/instance/abstract/DescendantNode.ts +92 -47
- package/src/instance/abstract/InstanceNode.ts +104 -98
- package/src/instance/abstract/UnsupportedControl.ts +174 -0
- package/src/instance/abstract/ValueNode.ts +127 -0
- package/src/instance/children.ts +83 -14
- package/src/instance/hierarchy.ts +36 -14
- package/src/instance/identity.ts +3 -9
- package/src/instance/index.ts +26 -8
- package/src/instance/internal-api/EvaluationContext.ts +61 -14
- package/src/instance/internal-api/InstanceConfig.ts +9 -2
- package/src/instance/internal-api/InstanceValueContext.ts +24 -0
- package/src/instance/internal-api/PrimaryInstanceDocument.ts +53 -0
- package/src/instance/internal-api/TranslationContext.ts +3 -2
- package/src/instance/internal-api/ValidationContext.ts +13 -5
- package/src/instance/internal-api/ValueContext.ts +5 -4
- package/src/instance/internal-api/submission/ClientReactiveSubmittableInstance.ts +20 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +42 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +25 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +23 -0
- package/src/instance/repeat/BaseRepeatRange.ts +51 -132
- package/src/instance/repeat/RepeatInstance.ts +20 -46
- package/src/instance/repeat/RepeatRangeControlled.ts +6 -6
- package/src/instance/repeat/RepeatRangeUncontrolled.ts +3 -5
- package/src/instance/resource.ts +1 -1
- package/src/instance/text/TextChunk.ts +1 -1
- package/src/instance/unsupported/RangeControl.ts +9 -0
- package/src/instance/unsupported/RankControl.ts +9 -0
- package/src/instance/unsupported/UploadControl.ts +9 -0
- package/src/integration/xpath/EngineXPathEvaluator.ts +22 -0
- package/src/integration/xpath/adapter/XFormsXPathNode.ts +126 -0
- package/src/integration/xpath/adapter/engineDOMAdapter.ts +57 -0
- package/src/integration/xpath/adapter/kind.ts +114 -0
- package/src/integration/xpath/adapter/names.ts +99 -0
- package/src/integration/xpath/adapter/traversal.ts +228 -0
- package/src/integration/xpath/adapter/values.ts +5 -0
- package/src/integration/xpath/static-dom/StaticAttribute.ts +33 -0
- package/src/integration/xpath/static-dom/StaticDocument.ts +38 -0
- package/src/integration/xpath/static-dom/StaticElement.ts +106 -0
- package/src/integration/xpath/static-dom/StaticNamedNode.ts +45 -0
- package/src/integration/xpath/static-dom/StaticNode.ts +68 -0
- package/src/integration/xpath/static-dom/StaticText.ts +28 -0
- package/src/lib/TokenListParser.ts +11 -7
- package/src/lib/client-reactivity/README.md +0 -0
- package/src/lib/client-reactivity/submission/createInstanceSubmissionState.ts +12 -0
- package/src/lib/client-reactivity/submission/createLeafNodeSubmissionState.ts +20 -0
- package/src/lib/client-reactivity/submission/createNodeRangeSubmissionState.ts +17 -0
- package/src/lib/client-reactivity/submission/createParentNodeSubmissionState.ts +22 -0
- package/src/lib/client-reactivity/submission/createValueNodeSubmissionState.ts +21 -0
- package/src/lib/client-reactivity/submission/prepareSubmission.ts +172 -0
- package/src/lib/codecs/DecimalValueCodec.ts +46 -0
- package/src/lib/codecs/IntValueCodec.ts +100 -0
- package/src/lib/codecs/StringValueCodec.ts +11 -0
- package/src/lib/codecs/ValueCodec.ts +106 -0
- package/src/lib/codecs/ValueTypePlaceholderCodec.ts +19 -0
- package/src/lib/codecs/getSharedValueCodec.ts +77 -0
- package/src/lib/dom/query.ts +8 -1
- package/src/lib/reactivity/createChildrenState.ts +8 -6
- package/src/lib/reactivity/createComputedExpression.ts +59 -36
- package/src/lib/reactivity/createInstanceValueState.ts +166 -0
- package/src/lib/reactivity/createNoteReadonlyThunk.ts +12 -7
- package/src/lib/reactivity/createSelectItems.ts +23 -23
- package/src/lib/reactivity/createTranslationState.ts +61 -0
- package/src/lib/reactivity/createValueState.ts +64 -122
- package/src/lib/reactivity/materializeCurrentStateChildren.ts +7 -7
- 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 +8 -7
- package/src/lib/reactivity/validation/createAggregatedViolations.ts +9 -4
- package/src/lib/reactivity/validation/createValidation.ts +2 -3
- package/src/lib/xml-serialization.ts +96 -0
- package/src/{XFormDOM.ts → parse/XFormDOM.ts} +110 -75
- package/src/{XFormDefinition.ts → parse/XFormDefinition.ts} +3 -8
- package/src/parse/attachments/FormAttachmentResource.ts +40 -0
- package/src/{body → parse/body}/BodyDefinition.ts +46 -29
- 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 +2 -2
- 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/{body/control/InputDefinition.ts → parse/body/control/InputControlDefinition.ts} +3 -5
- 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 +1 -6
- 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}/DependencyContext.ts +0 -26
- package/src/{expression → parse/expression/abstract}/DependentExpression.ts +5 -16
- package/src/parse/expression/abstract/TextChunkExpression.ts +38 -0
- package/src/parse/model/BindDefinition.ts +104 -0
- package/src/parse/model/BindTypeDefinition.ts +175 -0
- package/src/{model → parse/model}/DescendentNodeDefinition.ts +0 -6
- package/src/parse/model/FormSubmissionDefinition.ts +44 -0
- package/src/parse/model/ItextTranslation/ItextTranslationDefinition.ts +4 -0
- package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +41 -0
- package/src/parse/model/ItextTranslation/ItextTranslationsDefinition.ts +31 -0
- package/src/{model → parse/model}/LeafNodeDefinition.ts +4 -1
- package/src/{model → parse/model}/ModelBindMap.ts +6 -8
- package/src/parse/model/ModelDefinition.ts +24 -0
- package/src/{model → parse/model}/NodeDefinition.ts +0 -3
- package/src/parse/{NoteNodeDefinition.ts → model/NoteNodeDefinition.ts} +12 -12
- package/src/{model → parse/model}/RepeatRangeDefinition.ts +1 -1
- package/src/{model → parse/model}/RootDefinition.ts +4 -3
- package/src/parse/model/SecondaryInstance/SecondaryInstanceDefinition.ts +4 -0
- package/src/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.ts +12 -0
- package/src/parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts +102 -0
- package/src/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.ts +40 -0
- package/src/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.ts +288 -0
- package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.ts +222 -0
- package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.ts +22 -0
- package/src/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.ts +414 -0
- package/src/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.ts +19 -0
- package/src/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.ts +29 -0
- package/src/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.ts +32 -0
- package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +149 -0
- 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 +4 -10
- package/src/parse/xpath/semantic-analysis.ts +29 -0
- package/dist/XFormDOM.d.ts +0 -32
- package/dist/XFormDataType.d.ts +0 -27
- package/dist/body/appearance/inputAppearanceParser.d.ts +0 -4
- package/dist/client/StringNode.d.ts +0 -47
- package/dist/expression/DependencyContext.d.ts +0 -13
- package/dist/instance/StringField.d.ts +0 -45
- package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -60
- 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/XFormDataType.ts +0 -64
- package/src/client/StringNode.ts +0 -52
- package/src/instance/internal-api/SubscribableDependency.ts +0 -61
- package/src/model/BindDefinition.ts +0 -106
- package/src/model/ModelDefinition.ts +0 -19
- 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/{body → parse/body}/UnsupportedBodyElementDefinition.ts +0 -0
- /package/src/{body → parse/body}/group/LogicalGroupDefinition.ts +0 -0
- /package/src/{body → parse/body}/group/StructuralGroupDefinition.ts +0 -0
- /package/src/{model → parse/model}/BindElement.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,10 +1,13 @@
|
|
|
1
1
|
import { xmlXPathWhitespaceSeparatedList } from '@getodk/common/lib/string/whitespace.ts';
|
|
2
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
3
|
import type { Accessor } from 'solid-js';
|
|
3
|
-
import { untrack } from 'solid-js';
|
|
4
|
-
import type { AnySelectDefinition } from '../body/control/select/SelectDefinition.ts';
|
|
4
|
+
import { createMemo, untrack } from 'solid-js';
|
|
5
5
|
import type { SelectItem, SelectNode, SelectNodeAppearances } from '../client/SelectNode.ts';
|
|
6
6
|
import type { TextRange } from '../client/TextRange.ts';
|
|
7
|
+
import type { SubmissionState } from '../client/submission/SubmissionState.ts';
|
|
7
8
|
import type { AnyViolation, LeafNodeValidationState } from '../client/validation.ts';
|
|
9
|
+
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
10
|
+
import { createLeafNodeSubmissionState } from '../lib/client-reactivity/submission/createLeafNodeSubmissionState.ts';
|
|
8
11
|
import { createSelectItems } from '../lib/reactivity/createSelectItems.ts';
|
|
9
12
|
import { createValueState } from '../lib/reactivity/createValueState.ts';
|
|
10
13
|
import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
|
|
@@ -16,15 +19,16 @@ import { createNodeLabel } from '../lib/reactivity/text/createNodeLabel.ts';
|
|
|
16
19
|
import type { SimpleAtomicState } from '../lib/reactivity/types.ts';
|
|
17
20
|
import type { SharedValidationState } from '../lib/reactivity/validation/createValidation.ts';
|
|
18
21
|
import { createValidationState } from '../lib/reactivity/validation/createValidation.ts';
|
|
19
|
-
import type {
|
|
22
|
+
import type { AnySelectDefinition } from '../parse/body/control/select/SelectDefinition.ts';
|
|
23
|
+
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
20
24
|
import type { Root } from './Root.ts';
|
|
21
25
|
import type { DescendantNodeStateSpec } from './abstract/DescendantNode.ts';
|
|
22
26
|
import { DescendantNode } from './abstract/DescendantNode.ts';
|
|
23
27
|
import type { GeneralParentNode } from './hierarchy.ts';
|
|
24
28
|
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
25
|
-
import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
|
|
26
29
|
import type { ValidationContext } from './internal-api/ValidationContext.ts';
|
|
27
30
|
import type { ValueContext } from './internal-api/ValueContext.ts';
|
|
31
|
+
import type { ClientReactiveSubmittableLeafNode } from './internal-api/submission/ClientReactiveSubmittableLeafNode.ts';
|
|
28
32
|
|
|
29
33
|
export interface SelectFieldDefinition extends LeafNodeDefinition {
|
|
30
34
|
readonly bodyElement: AnySelectDefinition;
|
|
@@ -39,17 +43,21 @@ interface SelectFieldStateSpec extends DescendantNodeStateSpec<readonly SelectIt
|
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
export class SelectField
|
|
42
|
-
extends DescendantNode<SelectFieldDefinition, SelectFieldStateSpec, null>
|
|
46
|
+
extends DescendantNode<SelectFieldDefinition, SelectFieldStateSpec, GeneralParentNode, null>
|
|
43
47
|
implements
|
|
44
48
|
SelectNode,
|
|
49
|
+
XFormsXPathElement,
|
|
45
50
|
EvaluationContext,
|
|
46
|
-
SubscribableDependency,
|
|
47
51
|
ValidationContext,
|
|
48
|
-
ValueContext<readonly SelectItem[]
|
|
52
|
+
ValueContext<readonly SelectItem[]>,
|
|
53
|
+
ClientReactiveSubmittableLeafNode<readonly SelectItem[]>
|
|
49
54
|
{
|
|
50
55
|
private readonly selectExclusive: boolean;
|
|
51
56
|
private readonly validation: SharedValidationState;
|
|
52
57
|
|
|
58
|
+
// XFormsXPathElement
|
|
59
|
+
override readonly [XPathNodeKindKey] = 'element';
|
|
60
|
+
|
|
53
61
|
// InstanceNode
|
|
54
62
|
protected readonly state: SharedNodeState<SelectFieldStateSpec>;
|
|
55
63
|
protected override engineState: EngineState<SelectFieldStateSpec>;
|
|
@@ -63,32 +71,35 @@ export class SelectField
|
|
|
63
71
|
return this.validation.currentState;
|
|
64
72
|
}
|
|
65
73
|
|
|
74
|
+
readonly submissionState: SubmissionState;
|
|
75
|
+
|
|
66
76
|
// ValueContext
|
|
77
|
+
override readonly contextNode = this;
|
|
78
|
+
|
|
67
79
|
readonly encodeValue = (runtimeValue: readonly SelectItem[]): string => {
|
|
68
80
|
const itemValues = new Set(runtimeValue.map(({ value }) => value));
|
|
81
|
+
const selectedItems = this.getValueOptions().filter(({ value }) => {
|
|
82
|
+
return itemValues.has(value);
|
|
83
|
+
});
|
|
69
84
|
|
|
70
|
-
return
|
|
85
|
+
return selectedItems.map(({ value }) => value).join(' ');
|
|
71
86
|
};
|
|
72
87
|
|
|
73
88
|
readonly decodeValue = (instanceValue: string): readonly SelectItem[] => {
|
|
74
|
-
|
|
75
|
-
|
|
89
|
+
const itemValues = new Set(
|
|
90
|
+
xmlXPathWhitespaceSeparatedList(instanceValue, {
|
|
76
91
|
ignoreEmpty: true,
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
const items = this.getSelectItemsByValue();
|
|
92
|
+
})
|
|
93
|
+
);
|
|
80
94
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
})
|
|
85
|
-
.filter((item): item is SelectItem => {
|
|
86
|
-
return item != null;
|
|
87
|
-
});
|
|
95
|
+
// TODO: also want set-like behavior, probably?
|
|
96
|
+
return this.getValueOptions().filter((option) => {
|
|
97
|
+
return itemValues.has(option.value);
|
|
88
98
|
});
|
|
89
99
|
};
|
|
90
100
|
|
|
91
101
|
protected readonly getValueOptions: Accessor<readonly SelectItem[]>;
|
|
102
|
+
protected readonly getValue: Accessor<readonly SelectItem[]>;
|
|
92
103
|
|
|
93
104
|
constructor(parent: GeneralParentNode, definition: SelectFieldDefinition) {
|
|
94
105
|
super(parent, definition);
|
|
@@ -100,6 +111,26 @@ export class SelectField
|
|
|
100
111
|
|
|
101
112
|
this.getValueOptions = valueOptions;
|
|
102
113
|
|
|
114
|
+
const [baseGetValue, setValue] = createValueState(this);
|
|
115
|
+
|
|
116
|
+
const getValue = this.scope.runTask(() => {
|
|
117
|
+
const selectItemsByValue = createMemo((): ReadonlyMap<string, SelectItem> => {
|
|
118
|
+
return new Map(valueOptions().map((item) => [item.value, item]));
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
return createMemo(() => {
|
|
122
|
+
const items = selectItemsByValue();
|
|
123
|
+
|
|
124
|
+
return baseGetValue().filter((item) => {
|
|
125
|
+
return items.has(item.value);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
this.getValue = getValue;
|
|
131
|
+
|
|
132
|
+
const valueState: SimpleAtomicState<readonly SelectItem[]> = [getValue, setValue];
|
|
133
|
+
|
|
103
134
|
const sharedStateOptions = {
|
|
104
135
|
clientStateFactory: this.engineConfig.stateFactory,
|
|
105
136
|
};
|
|
@@ -115,7 +146,7 @@ export class SelectField
|
|
|
115
146
|
label: createNodeLabel(this, definition),
|
|
116
147
|
hint: createFieldHint(this, definition),
|
|
117
148
|
children: null,
|
|
118
|
-
value:
|
|
149
|
+
value: valueState,
|
|
119
150
|
valueOptions,
|
|
120
151
|
},
|
|
121
152
|
sharedStateOptions
|
|
@@ -125,10 +156,7 @@ export class SelectField
|
|
|
125
156
|
this.engineState = state.engineState;
|
|
126
157
|
this.currentState = state.currentState;
|
|
127
158
|
this.validation = createValidationState(this, sharedStateOptions);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
getViolation(): AnyViolation | null {
|
|
131
|
-
return this.validation.engineState.violation;
|
|
159
|
+
this.submissionState = createLeafNodeSubmissionState(this);
|
|
132
160
|
}
|
|
133
161
|
|
|
134
162
|
protected getSelectItemsByValue(
|
|
@@ -167,6 +195,11 @@ export class SelectField
|
|
|
167
195
|
this.updateSelectedItemValues([value]);
|
|
168
196
|
}
|
|
169
197
|
|
|
198
|
+
// XFormsXPathElement
|
|
199
|
+
override getXPathValue(): string {
|
|
200
|
+
return this.encodeValue(this.engineState.value);
|
|
201
|
+
}
|
|
202
|
+
|
|
170
203
|
// SelectNode
|
|
171
204
|
select(selectedItem: SelectItem): Root {
|
|
172
205
|
const { engineState, root } = this;
|
|
@@ -220,6 +253,10 @@ export class SelectField
|
|
|
220
253
|
}
|
|
221
254
|
|
|
222
255
|
// ValidationContext
|
|
256
|
+
getViolation(): AnyViolation | null {
|
|
257
|
+
return this.validation.engineState.violation;
|
|
258
|
+
}
|
|
259
|
+
|
|
223
260
|
isBlank(): boolean {
|
|
224
261
|
return this.engineState.value.length === 0;
|
|
225
262
|
}
|
package/src/instance/Subtree.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
|
+
import type { Accessor } from 'solid-js';
|
|
3
|
+
import type { FormNodeID } from '../client/identity.ts';
|
|
4
|
+
import type { SubmissionState } from '../client/submission/SubmissionState.ts';
|
|
2
5
|
import type { SubtreeDefinition, SubtreeNode } from '../client/SubtreeNode.ts';
|
|
3
6
|
import type { AncestorNodeValidationState } from '../client/validation.ts';
|
|
7
|
+
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
8
|
+
import { createParentNodeSubmissionState } from '../lib/client-reactivity/submission/createParentNodeSubmissionState.ts';
|
|
4
9
|
import type { ChildrenState } from '../lib/reactivity/createChildrenState.ts';
|
|
5
10
|
import { createChildrenState } from '../lib/reactivity/createChildrenState.ts';
|
|
6
11
|
import type { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
|
|
@@ -14,33 +19,39 @@ import type { DescendantNodeSharedStateSpec } from './abstract/DescendantNode.ts
|
|
|
14
19
|
import { DescendantNode } from './abstract/DescendantNode.ts';
|
|
15
20
|
import { buildChildren } from './children.ts';
|
|
16
21
|
import type { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
|
|
17
|
-
import type { NodeID } from './identity.ts';
|
|
18
22
|
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
19
|
-
import type {
|
|
23
|
+
import type { ClientReactiveSubmittableParentNode } from './internal-api/submission/ClientReactiveSubmittableParentNode.ts';
|
|
20
24
|
|
|
21
25
|
interface SubtreeStateSpec extends DescendantNodeSharedStateSpec {
|
|
22
26
|
readonly label: null;
|
|
23
27
|
readonly hint: null;
|
|
24
|
-
readonly children: Accessor<readonly
|
|
28
|
+
readonly children: Accessor<readonly FormNodeID[]>;
|
|
25
29
|
readonly valueOptions: null;
|
|
26
30
|
readonly value: null;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
export class Subtree
|
|
30
|
-
extends DescendantNode<SubtreeDefinition, SubtreeStateSpec, GeneralChildNode>
|
|
31
|
-
implements
|
|
34
|
+
extends DescendantNode<SubtreeDefinition, SubtreeStateSpec, GeneralParentNode, GeneralChildNode>
|
|
35
|
+
implements
|
|
36
|
+
SubtreeNode,
|
|
37
|
+
XFormsXPathElement,
|
|
38
|
+
EvaluationContext,
|
|
39
|
+
ClientReactiveSubmittableParentNode<GeneralChildNode>
|
|
32
40
|
{
|
|
33
41
|
private readonly childrenState: ChildrenState<GeneralChildNode>;
|
|
34
42
|
|
|
43
|
+
override readonly [XPathNodeKindKey] = 'element';
|
|
44
|
+
|
|
35
45
|
// InstanceNode
|
|
36
46
|
protected readonly state: SharedNodeState<SubtreeStateSpec>;
|
|
37
|
-
protected engineState: EngineState<SubtreeStateSpec>;
|
|
47
|
+
protected readonly engineState: EngineState<SubtreeStateSpec>;
|
|
38
48
|
|
|
39
49
|
// SubtreeNode
|
|
40
50
|
readonly nodeType = 'subtree';
|
|
41
51
|
readonly appearances = null;
|
|
42
52
|
readonly currentState: MaterializedChildren<CurrentState<SubtreeStateSpec>, GeneralChildNode>;
|
|
43
53
|
readonly validationState: AncestorNodeValidationState;
|
|
54
|
+
readonly submissionState: SubmissionState;
|
|
44
55
|
|
|
45
56
|
constructor(parent: GeneralParentNode, definition: SubtreeDefinition) {
|
|
46
57
|
super(parent, definition);
|
|
@@ -80,6 +91,7 @@ export class Subtree
|
|
|
80
91
|
|
|
81
92
|
childrenState.setChildren(buildChildren(this));
|
|
82
93
|
this.validationState = createAggregatedViolations(this, sharedStateOptions);
|
|
94
|
+
this.submissionState = createParentNodeSubmissionState(this);
|
|
83
95
|
}
|
|
84
96
|
|
|
85
97
|
getChildren(): readonly GeneralChildNode[] {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
2
|
import type { Accessor } from 'solid-js';
|
|
3
|
-
import type { InputDefinition } from '../body/control/InputDefinition.ts';
|
|
4
|
-
import type { StringNode, StringNodeAppearances } from '../client/StringNode.ts';
|
|
5
3
|
import type { TextRange } from '../client/TextRange.ts';
|
|
4
|
+
import type { TriggerNode, TriggerNodeDefinition } from '../client/TriggerNode.ts';
|
|
5
|
+
import type { SubmissionState } from '../client/submission/SubmissionState.ts';
|
|
6
6
|
import type { AnyViolation, LeafNodeValidationState } from '../client/validation.ts';
|
|
7
|
+
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
8
|
+
import { createLeafNodeSubmissionState } from '../lib/client-reactivity/submission/createLeafNodeSubmissionState.ts';
|
|
7
9
|
import { createValueState } from '../lib/reactivity/createValueState.ts';
|
|
8
10
|
import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
|
|
9
11
|
import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
|
|
@@ -14,61 +16,84 @@ import { createNodeLabel } from '../lib/reactivity/text/createNodeLabel.ts';
|
|
|
14
16
|
import type { SimpleAtomicState } from '../lib/reactivity/types.ts';
|
|
15
17
|
import type { SharedValidationState } from '../lib/reactivity/validation/createValidation.ts';
|
|
16
18
|
import { createValidationState } from '../lib/reactivity/validation/createValidation.ts';
|
|
17
|
-
import type {
|
|
19
|
+
import type { UnknownAppearanceDefinition } from '../parse/body/appearance/unknownAppearanceParser.ts';
|
|
18
20
|
import type { Root } from './Root.ts';
|
|
19
21
|
import type { DescendantNodeStateSpec } from './abstract/DescendantNode.ts';
|
|
20
22
|
import { DescendantNode } from './abstract/DescendantNode.ts';
|
|
21
23
|
import type { GeneralParentNode } from './hierarchy.ts';
|
|
22
24
|
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
23
|
-
import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
|
|
24
25
|
import type { ValidationContext } from './internal-api/ValidationContext.ts';
|
|
25
26
|
import type { ValueContext } from './internal-api/ValueContext.ts';
|
|
27
|
+
import type { ClientReactiveSubmittableLeafNode } from './internal-api/submission/ClientReactiveSubmittableLeafNode.ts';
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
readonly bodyElement: InputDefinition;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface StringFieldStateSpec extends DescendantNodeStateSpec<string> {
|
|
29
|
+
interface TriggerControlStateSpec extends DescendantNodeStateSpec<boolean> {
|
|
32
30
|
readonly label: Accessor<TextRange<'label'> | null>;
|
|
33
31
|
readonly hint: Accessor<TextRange<'hint'> | null>;
|
|
34
32
|
readonly children: null;
|
|
35
|
-
readonly value: SimpleAtomicState<
|
|
33
|
+
readonly value: SimpleAtomicState<boolean>;
|
|
36
34
|
readonly valueOptions: null;
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
const TRIGGER_ASSIGNED_VALUE = 'OK';
|
|
38
|
+
|
|
39
|
+
export class TriggerControl
|
|
40
|
+
extends DescendantNode<TriggerNodeDefinition, TriggerControlStateSpec, GeneralParentNode, null>
|
|
41
41
|
implements
|
|
42
|
-
|
|
42
|
+
TriggerNode,
|
|
43
|
+
XFormsXPathElement,
|
|
43
44
|
EvaluationContext,
|
|
44
|
-
SubscribableDependency,
|
|
45
45
|
ValidationContext,
|
|
46
|
-
ValueContext<
|
|
46
|
+
ValueContext<boolean>,
|
|
47
|
+
ClientReactiveSubmittableLeafNode<boolean>
|
|
47
48
|
{
|
|
48
49
|
private readonly validation: SharedValidationState;
|
|
49
|
-
|
|
50
|
+
|
|
51
|
+
// XFormsXPathElement
|
|
52
|
+
override readonly [XPathNodeKindKey] = 'element';
|
|
50
53
|
|
|
51
54
|
// InstanceNode
|
|
52
|
-
protected
|
|
55
|
+
protected readonly state: SharedNodeState<TriggerControlStateSpec>;
|
|
56
|
+
protected readonly engineState: EngineState<TriggerControlStateSpec>;
|
|
53
57
|
|
|
54
|
-
//
|
|
55
|
-
readonly nodeType = '
|
|
56
|
-
readonly appearances:
|
|
57
|
-
readonly currentState: CurrentState<
|
|
58
|
+
// TriggerNode
|
|
59
|
+
readonly nodeType = 'trigger';
|
|
60
|
+
readonly appearances: UnknownAppearanceDefinition;
|
|
61
|
+
readonly currentState: CurrentState<TriggerControlStateSpec>;
|
|
58
62
|
|
|
59
63
|
get validationState(): LeafNodeValidationState {
|
|
60
64
|
return this.validation.currentState;
|
|
61
65
|
}
|
|
62
66
|
|
|
63
|
-
|
|
64
|
-
readonly encodeValue = identity<string>;
|
|
67
|
+
readonly submissionState: SubmissionState;
|
|
65
68
|
|
|
66
|
-
|
|
69
|
+
// ValueContext
|
|
70
|
+
override readonly contextNode = this;
|
|
71
|
+
readonly encodeValue: (runtimeValue: boolean) => string;
|
|
72
|
+
readonly decodeValue: (instanceValue: string) => boolean;
|
|
67
73
|
|
|
68
|
-
constructor(parent: GeneralParentNode, definition:
|
|
74
|
+
constructor(parent: GeneralParentNode, definition: TriggerNodeDefinition) {
|
|
69
75
|
super(parent, definition);
|
|
70
76
|
|
|
71
77
|
this.appearances = definition.bodyElement.appearances;
|
|
78
|
+
this.encodeValue = (runtimeValue) => {
|
|
79
|
+
return runtimeValue ? TRIGGER_ASSIGNED_VALUE : '';
|
|
80
|
+
};
|
|
81
|
+
this.decodeValue = (instanceValue) => {
|
|
82
|
+
const value = instanceValue.trim();
|
|
83
|
+
|
|
84
|
+
switch (value) {
|
|
85
|
+
case TRIGGER_ASSIGNED_VALUE:
|
|
86
|
+
return true;
|
|
87
|
+
|
|
88
|
+
case '':
|
|
89
|
+
return false;
|
|
90
|
+
|
|
91
|
+
// TODO (robustness principle): Case insensitivity? Handle
|
|
92
|
+
// XPath-semantic booleans?? Other known/common equivalents?
|
|
93
|
+
default:
|
|
94
|
+
throw new Error(`Unexpected trigger value: ${value}`);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
72
97
|
|
|
73
98
|
const sharedStateOptions = {
|
|
74
99
|
clientStateFactory: this.engineConfig.stateFactory,
|
|
@@ -95,15 +120,21 @@ export class StringField
|
|
|
95
120
|
this.engineState = state.engineState;
|
|
96
121
|
this.currentState = state.currentState;
|
|
97
122
|
this.validation = createValidationState(this, sharedStateOptions);
|
|
123
|
+
this.submissionState = createLeafNodeSubmissionState(this);
|
|
98
124
|
}
|
|
99
125
|
|
|
126
|
+
// XFormsXPathElement
|
|
127
|
+
override getXPathValue(): string {
|
|
128
|
+
return this.encodeValue(this.engineState.value);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// ValidationContext
|
|
100
132
|
getViolation(): AnyViolation | null {
|
|
101
133
|
return this.validation.engineState.violation;
|
|
102
134
|
}
|
|
103
135
|
|
|
104
|
-
// ValidationContext
|
|
105
136
|
isBlank(): boolean {
|
|
106
|
-
return this.engineState.value
|
|
137
|
+
return this.engineState.value == null;
|
|
107
138
|
}
|
|
108
139
|
|
|
109
140
|
// InstanceNode
|
|
@@ -111,8 +142,8 @@ export class StringField
|
|
|
111
142
|
return [];
|
|
112
143
|
}
|
|
113
144
|
|
|
114
|
-
//
|
|
115
|
-
setValue(value:
|
|
145
|
+
// TriggerNode
|
|
146
|
+
setValue(value: boolean): Root {
|
|
116
147
|
this.state.setProperty('value', value);
|
|
117
148
|
|
|
118
149
|
return this.root;
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
2
|
import type { Accessor } from 'solid-js';
|
|
3
|
+
import { createMemo } from 'solid-js';
|
|
3
4
|
import type { BaseNode } from '../../client/BaseNode.ts';
|
|
5
|
+
import type { ActiveLanguage } from '../../client/FormLanguage.ts';
|
|
6
|
+
import type { InstanceNodeType } from '../../client/node-types.ts';
|
|
7
|
+
import type { PrimaryInstanceXPathChildNode } from '../../integration/xpath/adapter/kind.ts';
|
|
8
|
+
import type {
|
|
9
|
+
XFormsXPathPrimaryInstanceDescendantNode,
|
|
10
|
+
XFormsXPathPrimaryInstanceDescendantNodeKind,
|
|
11
|
+
} from '../../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
12
|
+
import { XFORMS_XPATH_NODE_RANGE_KIND } from '../../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
13
|
+
import type { EngineXPathEvaluator } from '../../integration/xpath/EngineXPathEvaluator.ts';
|
|
4
14
|
import { createComputedExpression } from '../../lib/reactivity/createComputedExpression.ts';
|
|
5
15
|
import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
6
|
-
import type { AnyDescendantNodeDefinition } from '../../model/DescendentNodeDefinition.ts';
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type { RepeatInstanceDefinition } from '../../model/RepeatInstanceDefinition.ts';
|
|
10
|
-
import type { AnyChildNode, GeneralParentNode, RepeatRange } from '../hierarchy.ts';
|
|
16
|
+
import type { AnyDescendantNodeDefinition } from '../../parse/model/DescendentNodeDefinition.ts';
|
|
17
|
+
import type { AnyNodeDefinition } from '../../parse/model/NodeDefinition.ts';
|
|
18
|
+
import type { AnyChildNode, AnyParentNode, RepeatRange } from '../hierarchy.ts';
|
|
11
19
|
import type { EvaluationContext } from '../internal-api/EvaluationContext.ts';
|
|
12
|
-
import type { SubscribableDependency } from '../internal-api/SubscribableDependency.ts';
|
|
13
20
|
import type { RepeatInstance } from '../repeat/RepeatInstance.ts';
|
|
14
21
|
import type { Root } from '../Root.ts';
|
|
15
22
|
import type { InstanceNodeStateSpec } from './InstanceNode.ts';
|
|
@@ -34,19 +41,13 @@ export type DescendantNodeDefinition = Extract<
|
|
|
34
41
|
AnyDescendantNodeDefinition
|
|
35
42
|
>;
|
|
36
43
|
|
|
37
|
-
// prettier-ignore
|
|
38
|
-
export type DescendantNodeParent<Definition extends DescendantNodeDefinition> =
|
|
39
|
-
Definition extends LeafNodeDefinition
|
|
40
|
-
? GeneralParentNode
|
|
41
|
-
: Definition extends RepeatInstanceDefinition
|
|
42
|
-
? RepeatRange
|
|
43
|
-
: GeneralParentNode;
|
|
44
|
-
|
|
45
44
|
export type AnyDescendantNode = DescendantNode<
|
|
46
45
|
DescendantNodeDefinition,
|
|
47
46
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
47
|
DescendantNodeStateSpec<any>,
|
|
49
48
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
+
any,
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
51
|
any
|
|
51
52
|
>;
|
|
52
53
|
|
|
@@ -58,11 +59,18 @@ export abstract class DescendantNode<
|
|
|
58
59
|
Definition extends DescendantNodeDefinition,
|
|
59
60
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
61
|
Spec extends DescendantNodeStateSpec<any>,
|
|
62
|
+
Parent extends AnyParentNode,
|
|
61
63
|
Child extends AnyChildNode | null = null,
|
|
62
64
|
>
|
|
63
|
-
extends InstanceNode<Definition, Spec, Child>
|
|
64
|
-
implements BaseNode,
|
|
65
|
+
extends InstanceNode<Definition, Spec, Parent, Child>
|
|
66
|
+
implements BaseNode, XFormsXPathPrimaryInstanceDescendantNode, EvaluationContext
|
|
65
67
|
{
|
|
68
|
+
/**
|
|
69
|
+
* Partial implementation of {@link isAttached}, used to check whether `this`
|
|
70
|
+
* is present in {@link parent}'s children state.
|
|
71
|
+
*/
|
|
72
|
+
protected readonly isAttachedDescendant: Accessor<boolean>;
|
|
73
|
+
|
|
66
74
|
readonly hasReadonlyAncestor: Accessor<boolean> = () => {
|
|
67
75
|
const { parent } = this;
|
|
68
76
|
|
|
@@ -97,51 +105,88 @@ export abstract class DescendantNode<
|
|
|
97
105
|
|
|
98
106
|
readonly isRequired: Accessor<boolean>;
|
|
99
107
|
|
|
108
|
+
// XFormsXPathPrimaryInstanceDescendantNode
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* WARNING! Ideally, this would be an abstract property, defined by each
|
|
112
|
+
* concrete subclass (or other intermediate abstract classes, where
|
|
113
|
+
* appropriate). Unfortunately it must be assigned here, so it will be present
|
|
114
|
+
* for certain XPath DOM adapter functionality **during** each concrete node's
|
|
115
|
+
* construction.
|
|
116
|
+
*
|
|
117
|
+
* Those subclasses nevertheless override this same property, assigning the
|
|
118
|
+
* same value, for the purposes of narrowing the XPath node kind semantics
|
|
119
|
+
* appropriate for each node type.
|
|
120
|
+
*/
|
|
121
|
+
override readonly [XPathNodeKindKey]: XFormsXPathPrimaryInstanceDescendantNodeKind;
|
|
100
122
|
readonly root: Root;
|
|
101
|
-
|
|
102
|
-
|
|
123
|
+
|
|
124
|
+
// BaseNode
|
|
125
|
+
abstract override readonly nodeType: InstanceNodeType;
|
|
126
|
+
|
|
127
|
+
// EvaluationContext
|
|
128
|
+
readonly isAttached: Accessor<boolean>;
|
|
129
|
+
readonly evaluator: EngineXPathEvaluator;
|
|
130
|
+
override readonly contextNode: PrimaryInstanceXPathChildNode =
|
|
131
|
+
this as AnyDescendantNode as PrimaryInstanceXPathChildNode;
|
|
132
|
+
readonly getActiveLanguage: Accessor<ActiveLanguage>;
|
|
103
133
|
|
|
104
134
|
constructor(
|
|
105
|
-
override readonly parent:
|
|
135
|
+
override readonly parent: Parent,
|
|
106
136
|
override readonly definition: Definition,
|
|
107
137
|
options?: DescendantNodeOptions
|
|
108
138
|
) {
|
|
109
139
|
super(parent.engineConfig, parent, definition, options);
|
|
110
140
|
|
|
111
|
-
|
|
141
|
+
if (this.isRoot()) {
|
|
142
|
+
this.root = this;
|
|
143
|
+
} else {
|
|
144
|
+
this.root = parent.root;
|
|
145
|
+
}
|
|
112
146
|
|
|
113
|
-
|
|
114
|
-
this.evaluator = evaluator;
|
|
115
|
-
this.contextNode = this.initializeContextNode(parent.contextNode, definition.nodeName);
|
|
147
|
+
const { evaluator } = parent;
|
|
116
148
|
|
|
117
|
-
|
|
149
|
+
// See notes on property declaration
|
|
150
|
+
if (definition.type === 'repeat-range') {
|
|
151
|
+
this[XPathNodeKindKey] = XFORMS_XPATH_NODE_RANGE_KIND;
|
|
152
|
+
} else {
|
|
153
|
+
this[XPathNodeKindKey] = 'element';
|
|
154
|
+
}
|
|
118
155
|
|
|
119
|
-
|
|
120
|
-
this.isSelfRelevant = createComputedExpression(this, relevant);
|
|
121
|
-
this.isRequired = createComputedExpression(this, required);
|
|
122
|
-
}
|
|
156
|
+
const self = this as AnyDescendantNode as AnyChildNode;
|
|
123
157
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
158
|
+
this.isAttachedDescendant = this.scope.runTask(() => {
|
|
159
|
+
return createMemo(() => {
|
|
160
|
+
for (const child of parent.getChildren()) {
|
|
161
|
+
if (child === self) {
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
127
165
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const element = this.createContextNode(parentContextNode, nodeName);
|
|
166
|
+
return false;
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
this.isAttached = this.scope.runTask(() => {
|
|
171
|
+
return createMemo(() => {
|
|
172
|
+
return this.parent.isAttached() && this.isAttachedDescendant();
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
this.evaluator = evaluator;
|
|
177
|
+
this.getActiveLanguage = parent.getActiveLanguage;
|
|
141
178
|
|
|
142
|
-
|
|
179
|
+
const { readonly, relevant, required } = definition.bind;
|
|
143
180
|
|
|
144
|
-
|
|
181
|
+
this.isSelfReadonly = createComputedExpression(this, readonly, {
|
|
182
|
+
defaultValue: true,
|
|
183
|
+
});
|
|
184
|
+
this.isSelfRelevant = createComputedExpression(this, relevant, {
|
|
185
|
+
defaultValue: false,
|
|
186
|
+
});
|
|
187
|
+
this.isRequired = createComputedExpression(this, required, {
|
|
188
|
+
defaultValue: false,
|
|
189
|
+
});
|
|
145
190
|
}
|
|
146
191
|
|
|
147
192
|
/**
|