@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,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
2
|
import type { Accessor, Signal } from 'solid-js';
|
|
3
3
|
import type { BaseNode } from '../../client/BaseNode.ts';
|
|
4
4
|
import type { NodeAppearances } from '../../client/NodeAppearances.ts';
|
|
5
|
-
import type {
|
|
5
|
+
import type { FormNodeID } from '../../client/identity.ts';
|
|
6
|
+
import type { InstanceNodeType as ClientInstanceNodeType } from '../../client/node-types.ts';
|
|
7
|
+
import type { SubmissionState } from '../../client/submission/SubmissionState.ts';
|
|
6
8
|
import type { NodeValidationState } from '../../client/validation.ts';
|
|
7
|
-
import type { TextRange } from '../../index.ts';
|
|
9
|
+
import type { ActiveLanguage, TextRange } from '../../index.ts';
|
|
10
|
+
import type { EngineXPathEvaluator } from '../../integration/xpath/EngineXPathEvaluator.ts';
|
|
11
|
+
import type {
|
|
12
|
+
XFormsXPathPrimaryInstanceNode,
|
|
13
|
+
XFormsXPathPrimaryInstanceNodeKind,
|
|
14
|
+
} from '../../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
15
|
+
import type { PrimaryInstanceXPathNode } from '../../integration/xpath/adapter/kind.ts';
|
|
8
16
|
import type { MaterializedChildren } from '../../lib/reactivity/materializeCurrentStateChildren.ts';
|
|
9
17
|
import type { CurrentState } from '../../lib/reactivity/node-state/createCurrentState.ts';
|
|
10
18
|
import type { EngineState } from '../../lib/reactivity/node-state/createEngineState.ts';
|
|
@@ -12,14 +20,19 @@ import type { SharedNodeState } from '../../lib/reactivity/node-state/createShar
|
|
|
12
20
|
import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
13
21
|
import { createReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
14
22
|
import type { SimpleAtomicState } from '../../lib/reactivity/types.ts';
|
|
15
|
-
import type { AnyNodeDefinition } from '../../model/NodeDefinition.ts';
|
|
23
|
+
import type { AnyNodeDefinition } from '../../parse/model/NodeDefinition.ts';
|
|
24
|
+
import type { PrimaryInstance } from '../PrimaryInstance.ts';
|
|
16
25
|
import type { Root } from '../Root.ts';
|
|
17
26
|
import type { AnyChildNode, AnyNode, AnyParentNode } from '../hierarchy.ts';
|
|
18
|
-
import
|
|
19
|
-
import { declareNodeID } from '../identity.ts';
|
|
27
|
+
import { nodeID } from '../identity.ts';
|
|
20
28
|
import type { EvaluationContext } from '../internal-api/EvaluationContext.ts';
|
|
21
29
|
import type { InstanceConfig } from '../internal-api/InstanceConfig.ts';
|
|
22
|
-
|
|
30
|
+
|
|
31
|
+
export type EngineInstanceNodeType = ClientInstanceNodeType | 'primary-instance';
|
|
32
|
+
|
|
33
|
+
export interface BaseEngineNode extends Omit<BaseNode, 'nodeType'> {
|
|
34
|
+
readonly nodeType: EngineInstanceNodeType;
|
|
35
|
+
}
|
|
23
36
|
|
|
24
37
|
export interface InstanceNodeStateSpec<Value = never> {
|
|
25
38
|
readonly reference: Accessor<string> | string;
|
|
@@ -28,7 +41,7 @@ export interface InstanceNodeStateSpec<Value = never> {
|
|
|
28
41
|
readonly required: Accessor<boolean> | boolean;
|
|
29
42
|
readonly label: Accessor<TextRange<'label'> | null> | null;
|
|
30
43
|
readonly hint: Accessor<TextRange<'hint'> | null> | null;
|
|
31
|
-
readonly children: Accessor<readonly
|
|
44
|
+
readonly children: Accessor<readonly FormNodeID[]> | null;
|
|
32
45
|
readonly valueOptions: Accessor<null> | Accessor<readonly unknown[]> | null;
|
|
33
46
|
readonly value: Signal<Value> | SimpleAtomicState<Value> | null;
|
|
34
47
|
}
|
|
@@ -71,19 +84,26 @@ type ComputeInstanceNodeReference = <This extends ComputableReferenceNode>(
|
|
|
71
84
|
|
|
72
85
|
export interface InstanceNodeOptions {
|
|
73
86
|
readonly computeReference?: () => string;
|
|
87
|
+
readonly scope?: ReactiveScope;
|
|
74
88
|
}
|
|
75
89
|
|
|
76
90
|
export abstract class InstanceNode<
|
|
77
91
|
Definition extends AnyNodeDefinition,
|
|
78
92
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
93
|
Spec extends InstanceNodeStateSpec<any>,
|
|
94
|
+
Parent extends AnyParentNode | null,
|
|
80
95
|
Child extends AnyChildNode | null = null,
|
|
81
96
|
>
|
|
82
|
-
implements
|
|
97
|
+
implements BaseEngineNode, XFormsXPathPrimaryInstanceNode, EvaluationContext
|
|
83
98
|
{
|
|
84
99
|
protected abstract readonly state: SharedNodeState<Spec>;
|
|
85
100
|
protected abstract readonly engineState: EngineState<Spec>;
|
|
86
101
|
|
|
102
|
+
// XFormsXPathPrimaryInstanceNode
|
|
103
|
+
abstract readonly [XPathNodeKindKey]: XFormsXPathPrimaryInstanceNodeKind;
|
|
104
|
+
readonly rootDocument: PrimaryInstance;
|
|
105
|
+
abstract readonly root: Root;
|
|
106
|
+
|
|
87
107
|
/**
|
|
88
108
|
* @package Exposed on every node type to facilitate inheritance, as well as
|
|
89
109
|
* conditional behavior for value nodes.
|
|
@@ -109,10 +129,10 @@ export abstract class InstanceNode<
|
|
|
109
129
|
abstract readonly isRelevant: Accessor<boolean>;
|
|
110
130
|
|
|
111
131
|
// BaseNode: identity
|
|
112
|
-
readonly nodeId:
|
|
132
|
+
readonly nodeId: FormNodeID;
|
|
113
133
|
|
|
114
134
|
// BaseNode: node types and variants (e.g. for narrowing)
|
|
115
|
-
abstract readonly nodeType:
|
|
135
|
+
abstract readonly nodeType: EngineInstanceNodeType;
|
|
116
136
|
|
|
117
137
|
abstract readonly appearances: NodeAppearances<Definition>;
|
|
118
138
|
|
|
@@ -120,15 +140,15 @@ export abstract class InstanceNode<
|
|
|
120
140
|
|
|
121
141
|
abstract readonly validationState: NodeValidationState;
|
|
122
142
|
|
|
123
|
-
|
|
124
|
-
abstract readonly root: Root;
|
|
143
|
+
abstract readonly submissionState: SubmissionState;
|
|
125
144
|
|
|
126
145
|
// EvaluationContext: instance-global/shared
|
|
127
|
-
abstract readonly evaluator:
|
|
146
|
+
abstract readonly evaluator: EngineXPathEvaluator;
|
|
147
|
+
abstract readonly getActiveLanguage: Accessor<ActiveLanguage>;
|
|
128
148
|
|
|
129
|
-
// EvaluationContext
|
|
149
|
+
// EvaluationContext: node-specific
|
|
150
|
+
abstract readonly isAttached: Accessor<boolean>;
|
|
130
151
|
readonly scope: ReactiveScope;
|
|
131
|
-
|
|
132
152
|
readonly computeReference: ComputeInstanceNodeReference;
|
|
133
153
|
|
|
134
154
|
protected readonly computeChildStepReference: ComputeInstanceNodeReference = (
|
|
@@ -149,106 +169,92 @@ export abstract class InstanceNode<
|
|
|
149
169
|
return this.computeReference(this.parent, this.definition);
|
|
150
170
|
};
|
|
151
171
|
|
|
152
|
-
|
|
172
|
+
/**
|
|
173
|
+
* Note: it is expected that at least some node subclasses will override this
|
|
174
|
+
* to reflect (or in the case of intermediate abstract base classes, to
|
|
175
|
+
* constrain) their more specific `this` type.
|
|
176
|
+
*/
|
|
177
|
+
readonly contextNode: PrimaryInstanceXPathNode =
|
|
178
|
+
this as AnyInstanceNode as PrimaryInstanceXPathNode;
|
|
153
179
|
|
|
154
180
|
constructor(
|
|
155
181
|
readonly engineConfig: InstanceConfig,
|
|
156
|
-
readonly parent:
|
|
182
|
+
readonly parent: Parent,
|
|
157
183
|
readonly definition: Definition,
|
|
158
184
|
options?: InstanceNodeOptions
|
|
159
185
|
) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
this.scope = createReactiveScope();
|
|
163
|
-
this.engineConfig = engineConfig;
|
|
164
|
-
this.nodeId = declareNodeID(engineConfig.createUniqueId());
|
|
165
|
-
this.definition = definition;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* @package This presently serves a few internal use cases, where certain
|
|
170
|
-
* behaviors depend on arbitrary traversal from any point in the instance
|
|
171
|
-
* tree, without particular regard for the visited node type. It isn't
|
|
172
|
-
* intended for external traversal or any other means of consuming children by
|
|
173
|
-
* a client. This return type intentionally deviates from one structural
|
|
174
|
-
* expectation, requiring even leaf nodes to return an array (though for those
|
|
175
|
-
* nodes it will always be empty). This affords consistency and efficiency of
|
|
176
|
-
* interface for those internal uses.
|
|
177
|
-
*/
|
|
178
|
-
abstract getChildren(this: AnyInstanceNode): readonly AnyChildNode[];
|
|
186
|
+
const self = this as AnyInstanceNode as AnyNode;
|
|
179
187
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (visited.has(this)) {
|
|
186
|
-
return [];
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
visited.add(this);
|
|
190
|
-
|
|
191
|
-
const { nodeset } = this.definition;
|
|
192
|
-
|
|
193
|
-
if (dependencyReference === nodeset) {
|
|
194
|
-
if (this.nodeType === 'repeat-instance') {
|
|
195
|
-
return [this.parent];
|
|
188
|
+
if (parent == null) {
|
|
189
|
+
if (!self.isPrimaryInstance()) {
|
|
190
|
+
throw new Error(
|
|
191
|
+
'Failed to construct node: not a primary instance, no parent node specified'
|
|
192
|
+
);
|
|
196
193
|
}
|
|
197
194
|
|
|
198
|
-
|
|
195
|
+
this.rootDocument = self;
|
|
196
|
+
} else {
|
|
197
|
+
this.rootDocument = parent.rootDocument;
|
|
199
198
|
}
|
|
200
199
|
|
|
201
|
-
|
|
202
|
-
dependencyReference.startsWith(`${nodeset}/`) ||
|
|
203
|
-
dependencyReference.startsWith(`${nodeset}[`)
|
|
204
|
-
) {
|
|
205
|
-
return this.getChildren().flatMap((child) => {
|
|
206
|
-
return child.getNodesByReference(visited, dependencyReference);
|
|
207
|
-
});
|
|
208
|
-
}
|
|
200
|
+
this.computeReference = options?.computeReference ?? this.computeChildStepReference;
|
|
209
201
|
|
|
210
|
-
|
|
202
|
+
this.scope = options?.scope ?? createReactiveScope();
|
|
203
|
+
this.engineConfig = engineConfig;
|
|
204
|
+
this.nodeId = nodeID(engineConfig.createUniqueId());
|
|
205
|
+
this.definition = definition;
|
|
211
206
|
}
|
|
212
207
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
this
|
|
216
|
-
|
|
217
|
-
): readonly SubscribableDependency[] {
|
|
218
|
-
if (this.nodeType === 'root') {
|
|
219
|
-
const visited = new WeakSet<AnyNode>();
|
|
220
|
-
|
|
221
|
-
return this.getNodesByReference(visited, reference);
|
|
222
|
-
}
|
|
208
|
+
/** @package */
|
|
209
|
+
isPrimaryInstance(): this is PrimaryInstance {
|
|
210
|
+
return this.parent == null;
|
|
211
|
+
}
|
|
223
212
|
|
|
224
|
-
|
|
213
|
+
/** @package */
|
|
214
|
+
isRoot(): this is Root {
|
|
215
|
+
return this.parent?.nodeType === 'primary-instance';
|
|
225
216
|
}
|
|
226
217
|
|
|
227
|
-
// SubscribableDependency
|
|
228
218
|
/**
|
|
229
|
-
* This
|
|
230
|
-
*
|
|
231
|
-
*
|
|
219
|
+
* @package This presently serves a growing variety of internal use cases,
|
|
220
|
+
* where certain behaviors depend on arbitrary traversal from any point in the
|
|
221
|
+
* instance tree, without particular regard for the visited node type. It
|
|
222
|
+
* isn't intended for external traversal or any other means of consuming
|
|
223
|
+
* children by a client. This return type intentionally deviates from one
|
|
224
|
+
* structural expectation, requiring even leaf nodes to return an array
|
|
225
|
+
* (though for those nodes it will always be empty). This affords consistency
|
|
226
|
+
* and efficiency of interface for those internal uses.
|
|
232
227
|
*/
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
228
|
+
abstract getChildren(this: AnyInstanceNode): readonly AnyChildNode[];
|
|
229
|
+
|
|
230
|
+
// XFormsXPathNode
|
|
231
|
+
/**
|
|
232
|
+
* @todo Values as text nodes(?)
|
|
233
|
+
*/
|
|
234
|
+
getXPathChildNodes(): readonly AnyChildNode[] {
|
|
235
|
+
return (this as AnyInstanceNode).getChildren().flatMap((child) => {
|
|
236
|
+
switch (child.nodeType) {
|
|
237
|
+
case 'repeat-range:controlled':
|
|
238
|
+
case 'repeat-range:uncontrolled': {
|
|
239
|
+
const repeatInstances = child.getXPathChildNodes();
|
|
240
|
+
|
|
241
|
+
if (repeatInstances.length > 0) {
|
|
242
|
+
return repeatInstances;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return child;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
default:
|
|
249
|
+
return child;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
getXPathValue(): string {
|
|
255
|
+
return (this as AnyInstanceNode as AnyNode)
|
|
256
|
+
.getXPathChildNodes()
|
|
257
|
+
.map((child) => child.getXPathValue())
|
|
258
|
+
.join('');
|
|
253
259
|
}
|
|
254
260
|
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { identity } from '@getodk/common/lib/identity.ts';
|
|
2
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
3
|
+
import type { Accessor } from 'solid-js';
|
|
4
|
+
import type { UnsupportedControlNodeType } from '../../client/node-types.ts';
|
|
5
|
+
import type { SubmissionState } from '../../client/submission/SubmissionState.ts';
|
|
6
|
+
import type { TextRange } from '../../client/TextRange.ts';
|
|
7
|
+
import type {
|
|
8
|
+
UnsupportedControlDefinition,
|
|
9
|
+
UnsupportedControlElementDefinition,
|
|
10
|
+
UnsupportedControlNode,
|
|
11
|
+
} from '../../client/unsupported/UnsupportedControlNode.ts';
|
|
12
|
+
import type { AnyViolation, LeafNodeValidationState } from '../../client/validation.ts';
|
|
13
|
+
import type { XFormsXPathElement } from '../../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
14
|
+
import { createLeafNodeSubmissionState } from '../../lib/client-reactivity/submission/createLeafNodeSubmissionState.ts';
|
|
15
|
+
import { createValueState } from '../../lib/reactivity/createValueState.ts';
|
|
16
|
+
import type { CurrentState } from '../../lib/reactivity/node-state/createCurrentState.ts';
|
|
17
|
+
import type { EngineState } from '../../lib/reactivity/node-state/createEngineState.ts';
|
|
18
|
+
import {
|
|
19
|
+
createSharedNodeState,
|
|
20
|
+
type SharedNodeState,
|
|
21
|
+
} from '../../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
22
|
+
import { createFieldHint } from '../../lib/reactivity/text/createFieldHint.ts';
|
|
23
|
+
import { createNodeLabel } from '../../lib/reactivity/text/createNodeLabel.ts';
|
|
24
|
+
import type { SimpleAtomicState } from '../../lib/reactivity/types.ts';
|
|
25
|
+
import {
|
|
26
|
+
createValidationState,
|
|
27
|
+
type SharedValidationState,
|
|
28
|
+
} from '../../lib/reactivity/validation/createValidation.ts';
|
|
29
|
+
import type { UnknownAppearanceDefinition } from '../../parse/body/appearance/unknownAppearanceParser.ts';
|
|
30
|
+
import type { AnyUnsupportedControl, GeneralParentNode } from '../hierarchy.ts';
|
|
31
|
+
import type { EvaluationContext } from '../internal-api/EvaluationContext.ts';
|
|
32
|
+
import type { ClientReactiveSubmittableLeafNode } from '../internal-api/submission/ClientReactiveSubmittableLeafNode.ts';
|
|
33
|
+
import type { ValidationContext } from '../internal-api/ValidationContext.ts';
|
|
34
|
+
import type { ValueContext } from '../internal-api/ValueContext.ts';
|
|
35
|
+
import { DescendantNode, type DescendantNodeStateSpec } from './DescendantNode.ts';
|
|
36
|
+
|
|
37
|
+
type TypedUnsupportedControlElementDefinition<Type extends UnsupportedControlNodeType> = Extract<
|
|
38
|
+
UnsupportedControlElementDefinition,
|
|
39
|
+
{ readonly type: Type }
|
|
40
|
+
>;
|
|
41
|
+
|
|
42
|
+
interface TypedUnsupportedControlDefinition<Type extends UnsupportedControlNodeType>
|
|
43
|
+
extends UnsupportedControlDefinition {
|
|
44
|
+
readonly bodyElement: TypedUnsupportedControlElementDefinition<Type>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface UnsupportedControlStateSpec extends DescendantNodeStateSpec<unknown> {
|
|
48
|
+
readonly label: Accessor<TextRange<'label'> | null>;
|
|
49
|
+
readonly hint: Accessor<TextRange<'hint'> | null>;
|
|
50
|
+
readonly children: null;
|
|
51
|
+
readonly value: SimpleAtomicState<unknown>;
|
|
52
|
+
readonly valueOptions: never;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
class UnsupportedControlValueEncodeError extends Error {
|
|
56
|
+
constructor(type: UnsupportedControlNodeType) {
|
|
57
|
+
super(`Cannot encode state for node (type: ${type}) - not implemented`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
class UnsupportedControlWriteError extends Error {
|
|
62
|
+
constructor(type: UnsupportedControlNodeType) {
|
|
63
|
+
super(`Cannot write state for node (type: ${type}) - not implemented`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export abstract class UnsupportedControl<Type extends UnsupportedControlNodeType>
|
|
68
|
+
extends DescendantNode<
|
|
69
|
+
TypedUnsupportedControlDefinition<Type>,
|
|
70
|
+
UnsupportedControlStateSpec,
|
|
71
|
+
GeneralParentNode,
|
|
72
|
+
null
|
|
73
|
+
>
|
|
74
|
+
implements
|
|
75
|
+
UnsupportedControlNode,
|
|
76
|
+
XFormsXPathElement,
|
|
77
|
+
EvaluationContext,
|
|
78
|
+
ValidationContext,
|
|
79
|
+
ValueContext<unknown>,
|
|
80
|
+
ClientReactiveSubmittableLeafNode<unknown>
|
|
81
|
+
{
|
|
82
|
+
private readonly validation: SharedValidationState;
|
|
83
|
+
protected readonly state: SharedNodeState<UnsupportedControlStateSpec>;
|
|
84
|
+
|
|
85
|
+
// XFormsXPathElement
|
|
86
|
+
override readonly [XPathNodeKindKey] = 'element';
|
|
87
|
+
|
|
88
|
+
// InstanceNode
|
|
89
|
+
protected readonly engineState: EngineState<UnsupportedControlStateSpec>;
|
|
90
|
+
|
|
91
|
+
// UnsupportedControlNode
|
|
92
|
+
abstract override readonly nodeType: Type;
|
|
93
|
+
|
|
94
|
+
readonly appearances: UnknownAppearanceDefinition;
|
|
95
|
+
readonly currentState: CurrentState<UnsupportedControlStateSpec>;
|
|
96
|
+
|
|
97
|
+
get validationState(): LeafNodeValidationState {
|
|
98
|
+
return this.validation.currentState;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
readonly submissionState: SubmissionState;
|
|
102
|
+
|
|
103
|
+
// ValueContext
|
|
104
|
+
abstract override readonly contextNode: AnyUnsupportedControl & this;
|
|
105
|
+
|
|
106
|
+
readonly encodeValue = (instanceValue: unknown): string => {
|
|
107
|
+
const encoded = instanceValue;
|
|
108
|
+
|
|
109
|
+
if (typeof encoded === 'string') {
|
|
110
|
+
return encoded;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
throw new UnsupportedControlValueEncodeError(this.nodeType);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
readonly decodeValue = (instanceValue: unknown): unknown => {
|
|
117
|
+
return identity(instanceValue);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
constructor(parent: GeneralParentNode, definition: TypedUnsupportedControlDefinition<Type>) {
|
|
121
|
+
super(parent, definition);
|
|
122
|
+
|
|
123
|
+
this.appearances = definition.bodyElement.appearances;
|
|
124
|
+
|
|
125
|
+
const sharedStateOptions = {
|
|
126
|
+
clientStateFactory: this.engineConfig.stateFactory,
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const stateSpec: UnsupportedControlStateSpec = {
|
|
130
|
+
reference: this.contextReference,
|
|
131
|
+
readonly: this.isReadonly,
|
|
132
|
+
relevant: this.isRelevant,
|
|
133
|
+
required: this.isRequired,
|
|
134
|
+
|
|
135
|
+
label: createNodeLabel(this, definition),
|
|
136
|
+
hint: createFieldHint(this, definition),
|
|
137
|
+
children: null,
|
|
138
|
+
valueOptions: null as never,
|
|
139
|
+
value: createValueState<unknown>(this),
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const state = createSharedNodeState(this.scope, stateSpec, sharedStateOptions);
|
|
143
|
+
|
|
144
|
+
this.state = state;
|
|
145
|
+
this.engineState = state.engineState;
|
|
146
|
+
this.currentState = state.currentState;
|
|
147
|
+
this.validation = createValidationState(this, sharedStateOptions);
|
|
148
|
+
this.submissionState = createLeafNodeSubmissionState(this);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// XFormsXPathElement
|
|
152
|
+
override getXPathValue(): string {
|
|
153
|
+
return this.encodeValue(this.engineState.value);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// ValidationContext
|
|
157
|
+
getViolation(): AnyViolation | null {
|
|
158
|
+
return this.validation.engineState.violation;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
isBlank(): boolean {
|
|
162
|
+
return this.engineState.value === '';
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// InstanceNode
|
|
166
|
+
getChildren(): readonly [] {
|
|
167
|
+
return [];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// UnsupportedControlNode
|
|
171
|
+
setValue(_: never): never {
|
|
172
|
+
throw new UnsupportedControlWriteError(this.nodeType);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
|
+
import type { Accessor } from 'solid-js';
|
|
3
|
+
import type { BaseValueNode } from '../../client/BaseValueNode.ts';
|
|
4
|
+
import type { LeafNodeType as ValueNodeType } from '../../client/node-types.ts';
|
|
5
|
+
import type { SubmissionState } from '../../client/submission/SubmissionState.ts';
|
|
6
|
+
import type { AnyViolation, LeafNodeValidationState } from '../../client/validation.ts';
|
|
7
|
+
import type { ValueType } from '../../client/ValueType.ts';
|
|
8
|
+
import type { XFormsXPathElement } from '../../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
9
|
+
import { createValueNodeSubmissionState } from '../../lib/client-reactivity/submission/createValueNodeSubmissionState.ts';
|
|
10
|
+
import type {
|
|
11
|
+
RuntimeValueSetter,
|
|
12
|
+
RuntimeValueState,
|
|
13
|
+
ValueCodec,
|
|
14
|
+
} from '../../lib/codecs/ValueCodec.ts';
|
|
15
|
+
import { createInstanceValueState } from '../../lib/reactivity/createInstanceValueState.ts';
|
|
16
|
+
import type { CurrentState } from '../../lib/reactivity/node-state/createCurrentState.ts';
|
|
17
|
+
import type { EngineState } from '../../lib/reactivity/node-state/createEngineState.ts';
|
|
18
|
+
import type { SharedNodeState } from '../../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
19
|
+
import type { SimpleAtomicState } from '../../lib/reactivity/types.ts';
|
|
20
|
+
import type { SharedValidationState } from '../../lib/reactivity/validation/createValidation.ts';
|
|
21
|
+
import { createValidationState } from '../../lib/reactivity/validation/createValidation.ts';
|
|
22
|
+
import { LeafNodeDefinition } from '../../parse/model/LeafNodeDefinition.ts';
|
|
23
|
+
import type { GeneralParentNode } from '../hierarchy.ts';
|
|
24
|
+
import type { EvaluationContext } from '../internal-api/EvaluationContext.ts';
|
|
25
|
+
import type {
|
|
26
|
+
DecodeInstanceValue,
|
|
27
|
+
InstanceValueContext,
|
|
28
|
+
} from '../internal-api/InstanceValueContext.ts';
|
|
29
|
+
import type { ClientReactiveSubmittableValueNode } from '../internal-api/submission/ClientReactiveSubmittableValueNode.ts';
|
|
30
|
+
import type { ValidationContext } from '../internal-api/ValidationContext.ts';
|
|
31
|
+
import type { DescendantNodeStateSpec } from './DescendantNode.ts';
|
|
32
|
+
import { DescendantNode } from './DescendantNode.ts';
|
|
33
|
+
|
|
34
|
+
export type ValueNodeDefinition<V extends ValueType> = LeafNodeDefinition<V>;
|
|
35
|
+
|
|
36
|
+
export interface ValueNodeStateSpec<RuntimeValue> extends DescendantNodeStateSpec<RuntimeValue> {
|
|
37
|
+
readonly children: null;
|
|
38
|
+
readonly valueOptions: null;
|
|
39
|
+
readonly value: SimpleAtomicState<RuntimeValue>;
|
|
40
|
+
readonly instanceValue: Accessor<string>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export abstract class ValueNode<
|
|
44
|
+
V extends ValueType,
|
|
45
|
+
Definition extends ValueNodeDefinition<V>,
|
|
46
|
+
RuntimeValue extends RuntimeInputValue,
|
|
47
|
+
RuntimeInputValue = RuntimeValue,
|
|
48
|
+
>
|
|
49
|
+
extends DescendantNode<Definition, ValueNodeStateSpec<RuntimeValue>, GeneralParentNode, null>
|
|
50
|
+
implements
|
|
51
|
+
BaseValueNode<V, RuntimeValue>,
|
|
52
|
+
XFormsXPathElement,
|
|
53
|
+
EvaluationContext,
|
|
54
|
+
InstanceValueContext,
|
|
55
|
+
ValidationContext,
|
|
56
|
+
ClientReactiveSubmittableValueNode
|
|
57
|
+
{
|
|
58
|
+
protected readonly validation: SharedValidationState;
|
|
59
|
+
protected readonly getInstanceValue: Accessor<string>;
|
|
60
|
+
protected readonly valueState: RuntimeValueState<RuntimeValue>;
|
|
61
|
+
protected readonly setValueState: RuntimeValueSetter<RuntimeInputValue>;
|
|
62
|
+
|
|
63
|
+
// XFormsXPathElement
|
|
64
|
+
override readonly [XPathNodeKindKey] = 'element';
|
|
65
|
+
override readonly getXPathValue: () => string;
|
|
66
|
+
|
|
67
|
+
// InstanceNode
|
|
68
|
+
protected abstract override readonly state: SharedNodeState<ValueNodeStateSpec<RuntimeValue>>;
|
|
69
|
+
protected abstract override readonly engineState: EngineState<ValueNodeStateSpec<RuntimeValue>>;
|
|
70
|
+
|
|
71
|
+
// InstanceValueContext
|
|
72
|
+
readonly decodeInstanceValue: DecodeInstanceValue;
|
|
73
|
+
|
|
74
|
+
// BaseValueNode
|
|
75
|
+
abstract override readonly nodeType: ValueNodeType;
|
|
76
|
+
readonly valueType: V;
|
|
77
|
+
|
|
78
|
+
abstract override readonly currentState: CurrentState<ValueNodeStateSpec<RuntimeValue>>;
|
|
79
|
+
|
|
80
|
+
get validationState(): LeafNodeValidationState {
|
|
81
|
+
return this.validation.currentState;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
readonly submissionState: SubmissionState;
|
|
85
|
+
|
|
86
|
+
constructor(
|
|
87
|
+
parent: GeneralParentNode,
|
|
88
|
+
definition: Definition,
|
|
89
|
+
codec: ValueCodec<V, RuntimeValue, RuntimeInputValue>
|
|
90
|
+
) {
|
|
91
|
+
super(parent, definition);
|
|
92
|
+
|
|
93
|
+
this.valueType = definition.valueType;
|
|
94
|
+
this.decodeInstanceValue = codec.decodeInstanceValue;
|
|
95
|
+
|
|
96
|
+
const instanceValueState = createInstanceValueState(this, {
|
|
97
|
+
initialValueSource: 'FORM_DEFAULT',
|
|
98
|
+
});
|
|
99
|
+
const valueState = codec.createRuntimeValueState(instanceValueState);
|
|
100
|
+
|
|
101
|
+
const [getInstanceValue] = instanceValueState;
|
|
102
|
+
const [, setValueState] = valueState;
|
|
103
|
+
|
|
104
|
+
this.getInstanceValue = getInstanceValue;
|
|
105
|
+
this.setValueState = setValueState;
|
|
106
|
+
this.getXPathValue = getInstanceValue;
|
|
107
|
+
this.valueState = valueState;
|
|
108
|
+
this.validation = createValidationState(this, {
|
|
109
|
+
clientStateFactory: this.engineConfig.stateFactory,
|
|
110
|
+
});
|
|
111
|
+
this.submissionState = createValueNodeSubmissionState(this);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// ValidationContext
|
|
115
|
+
getViolation(): AnyViolation | null {
|
|
116
|
+
return this.validation.engineState.violation;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
isBlank(): boolean {
|
|
120
|
+
return this.getInstanceValue() === '';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// InstanceNode
|
|
124
|
+
getChildren(): readonly [] {
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
}
|