@getodk/xforms-engine 0.4.0 → 0.6.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/README.md +1 -1
- package/dist/client/BaseNode.d.ts +18 -3
- package/dist/client/BaseValueNode.d.ts +32 -0
- package/dist/client/EngineConfig.d.ts +49 -48
- package/dist/client/GroupNode.d.ts +1 -0
- package/dist/client/InputNode.d.ts +82 -0
- package/dist/client/ModelValueNode.d.ts +13 -7
- package/dist/client/NoteNode.d.ts +26 -9
- package/dist/client/RangeNode.d.ts +36 -0
- package/dist/client/RankNode.d.ts +46 -0
- package/dist/client/RootNode.d.ts +37 -7
- package/dist/client/SelectNode.d.ts +47 -25
- package/dist/client/SubtreeNode.d.ts +1 -0
- package/dist/client/TriggerNode.d.ts +10 -6
- package/dist/client/ValueType.d.ts +3 -0
- package/dist/client/constants.d.ts +50 -0
- package/dist/client/hierarchy.d.ts +8 -8
- package/dist/client/identity.d.ts +14 -0
- package/dist/client/node-types.d.ts +3 -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/UnsupportedControlNode.d.ts +1 -3
- package/dist/client/validation.d.ts +2 -2
- package/dist/error/ErrorProductionDesignPendingError.d.ts +7 -0
- package/dist/error/RankMissingValueError.d.ts +3 -0
- package/dist/error/RankValueTypeError.d.ts +6 -0
- package/dist/error/SelectValueTypeError.d.ts +15 -0
- package/dist/error/ValueTypeInvariantError.d.ts +17 -0
- package/dist/error/XFormsSpecViolationError.d.ts +2 -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 +12 -4
- package/dist/index.js +17864 -14655
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +10 -4
- package/dist/instance/InputControl.d.ts +38 -0
- package/dist/instance/ModelValue.d.ts +17 -25
- package/dist/instance/Note.d.ts +16 -21
- package/dist/instance/PrimaryInstance.d.ts +85 -0
- package/dist/instance/RangeControl.d.ts +34 -0
- package/dist/instance/RankControl.d.ts +40 -0
- package/dist/instance/Root.d.ts +30 -25
- package/dist/instance/SelectControl.d.ts +66 -0
- package/dist/instance/Subtree.d.ts +11 -5
- package/dist/instance/TriggerControl.d.ts +13 -19
- package/dist/instance/abstract/DescendantNode.d.ts +32 -25
- package/dist/instance/abstract/InstanceNode.d.ts +52 -30
- package/dist/instance/abstract/UnsupportedControl.d.ts +11 -3
- package/dist/instance/abstract/ValueNode.d.ts +47 -0
- package/dist/instance/hierarchy.d.ts +13 -12
- package/dist/instance/identity.d.ts +2 -7
- package/dist/instance/internal-api/EvaluationContext.d.ts +53 -12
- package/dist/instance/internal-api/InstanceConfig.d.ts +8 -2
- package/dist/instance/internal-api/InstanceValueContext.d.ts +22 -0
- package/dist/instance/internal-api/PrimaryInstanceDocument.d.ts +36 -0
- package/dist/instance/internal-api/TranslationContext.d.ts +3 -2
- package/dist/instance/internal-api/ValidationContext.d.ts +3 -4
- package/dist/instance/internal-api/ValueContext.d.ts +2 -1
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableInstance.d.ts +14 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +32 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +19 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +18 -0
- package/dist/instance/repeat/BaseRepeatRange.d.ts +40 -83
- package/dist/instance/repeat/RepeatInstance.d.ts +12 -29
- package/dist/instance/repeat/RepeatRangeControlled.d.ts +2 -2
- package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +2 -2
- package/dist/instance/resource.d.ts +1 -1
- package/dist/instance/text/TextRange.d.ts +1 -1
- package/dist/instance/unsupported/UploadControl.d.ts +3 -1
- 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 +6 -0
- package/dist/integration/xpath/adapter/traversal.d.ts +26 -0
- package/dist/integration/xpath/adapter/values.d.ts +2 -0
- package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +26 -0
- package/dist/integration/xpath/static-dom/StaticDocument.d.ts +15 -0
- package/dist/integration/xpath/static-dom/StaticElement.d.ts +48 -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/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/createRootSubmissionState.d.ts +3 -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/Geopoint/Geopoint.d.ts +48 -0
- package/dist/lib/codecs/Geopoint/GeopointValueCodec.d.ts +5 -0
- package/dist/lib/codecs/IntValueCodec.d.ts +6 -0
- package/dist/lib/codecs/NoteCodec.d.ts +8 -0
- package/dist/lib/codecs/RangeCodec.d.ts +8 -0
- package/dist/lib/codecs/StringValueCodec.d.ts +4 -0
- package/dist/lib/codecs/TriggerCodec.d.ts +7 -0
- package/dist/lib/codecs/ValueArrayCodec.d.ts +11 -0
- package/dist/lib/codecs/ValueCodec.d.ts +30 -0
- package/dist/lib/codecs/ValueTypePlaceholderCodec.d.ts +12 -0
- package/dist/lib/codecs/getNoteCodec.d.ts +3 -0
- package/dist/lib/codecs/getSelectCodec.d.ts +5 -0
- package/dist/lib/codecs/getSharedValueCodec.d.ts +48 -0
- package/dist/lib/codecs/items/BaseItemCodec.d.ts +9 -0
- package/dist/lib/codecs/items/MultipleValueItemCodec.d.ts +14 -0
- package/dist/lib/codecs/items/SingleValueItemCodec.d.ts +24 -0
- package/dist/lib/dom/query.d.ts +4 -2
- package/dist/lib/names/NamespaceDeclaration.d.ts +45 -0
- package/dist/lib/names/NamespaceDeclarationMap.d.ts +137 -0
- package/dist/lib/names/NamespaceURL.d.ts +30 -0
- package/dist/lib/names/QualifiedName.d.ts +113 -0
- package/dist/lib/number-parsers.d.ts +2 -0
- package/dist/lib/reactivity/createChildrenState.d.ts +7 -5
- package/dist/lib/reactivity/createComputedExpression.d.ts +18 -5
- package/dist/lib/reactivity/createInstanceValueState.d.ts +40 -0
- package/dist/lib/reactivity/createItemCollection.d.ts +21 -0
- package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +2 -2
- package/dist/lib/reactivity/createTranslationState.d.ts +19 -0
- package/dist/lib/reactivity/createValueState.d.ts +6 -10
- package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +4 -4
- package/dist/lib/xml-serialization.d.ts +50 -0
- package/dist/parse/XFormDOM.d.ts +18 -7
- package/dist/parse/XFormDefinition.d.ts +1 -2
- package/dist/parse/attachments/FormAttachmentResource.d.ts +27 -0
- package/dist/parse/body/BodyDefinition.d.ts +4 -4
- package/dist/parse/body/RepeatElementDefinition.d.ts +1 -1
- package/dist/parse/body/appearance/inputAppearanceParser.d.ts +1 -1
- package/dist/parse/body/appearance/rangeAppearanceParser.d.ts +3 -0
- package/dist/parse/body/control/{InputDefinition.d.ts → InputControlDefinition.d.ts} +4 -1
- package/dist/parse/body/control/ItemDefinition.d.ts +14 -0
- package/dist/parse/body/control/ItemsetDefinition.d.ts +18 -0
- package/dist/parse/body/control/RangeControlDefinition.d.ts +31 -2
- package/dist/parse/body/control/RankControlDefinition.d.ts +7 -3
- package/dist/parse/body/control/{select/SelectDefinition.d.ts → SelectControlDefinition.d.ts} +9 -9
- package/dist/parse/expression/ItemsetNodesetExpression.d.ts +1 -1
- package/dist/parse/expression/ItemsetValueExpression.d.ts +1 -1
- package/dist/parse/expression/abstract/DependencyContext.d.ts +0 -5
- package/dist/parse/expression/abstract/DependentExpression.d.ts +2 -3
- package/dist/parse/model/BindDefinition.d.ts +6 -5
- package/dist/parse/model/BindPreloadDefinition.d.ts +42 -0
- package/dist/parse/model/BindTypeDefinition.d.ts +20 -0
- package/dist/parse/model/DescendentNodeDefinition.d.ts +4 -14
- 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 +9 -0
- package/dist/parse/model/ItextTranslation/ItextTranslationsDefinition.d.ts +8 -0
- package/dist/parse/model/LeafNodeDefinition.d.ts +9 -4
- package/dist/parse/model/ModelBindMap.d.ts +1 -1
- package/dist/parse/model/ModelDefinition.d.ts +2 -0
- package/dist/parse/model/NodeDefinition.d.ts +16 -20
- package/dist/parse/model/NoteNodeDefinition.d.ts +9 -8
- package/dist/parse/model/RangeNodeDefinition.d.ts +41 -0
- package/dist/parse/model/RepeatInstanceDefinition.d.ts +7 -4
- package/dist/parse/model/RepeatRangeDefinition.d.ts +7 -4
- package/dist/parse/model/RepeatTemplateDefinition.d.ts +7 -4
- package/dist/parse/model/RootAttributeDefinition.d.ts +24 -0
- package/dist/parse/model/RootAttributeMap.d.ts +23 -0
- package/dist/parse/model/RootDefinition.d.ts +12 -9
- 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/parse/model/SubtreeDefinition.d.ts +7 -4
- package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +23 -0
- package/dist/parse/text/ItemLabelDefinition.d.ts +1 -1
- package/dist/parse/text/ItemsetLabelDefinition.d.ts +2 -2
- package/dist/parse/text/abstract/TextElementDefinition.d.ts +1 -1
- package/dist/parse/text/abstract/TextRangeDefinition.d.ts +0 -2
- package/dist/parse/xpath/semantic-analysis.d.ts +6 -3
- package/dist/solid.js +15437 -12246
- package/dist/solid.js.map +1 -1
- package/package.json +18 -13
- package/src/client/BaseNode.ts +21 -6
- package/src/client/BaseValueNode.ts +35 -0
- package/src/client/EngineConfig.ts +52 -51
- package/src/client/GroupNode.ts +1 -0
- package/src/client/InputNode.ts +113 -0
- package/src/client/ModelValueNode.ts +31 -7
- package/src/client/NoteNode.ts +45 -9
- package/src/client/RangeNode.ts +51 -0
- package/src/client/RankNode.ts +54 -0
- package/src/client/RootNode.ts +43 -7
- package/src/client/SelectNode.ts +53 -26
- package/src/client/SubtreeNode.ts +1 -0
- package/src/client/TriggerNode.ts +12 -6
- package/src/client/ValueType.ts +4 -0
- package/src/client/constants.ts +67 -0
- package/src/client/hierarchy.ts +12 -13
- package/src/client/identity.ts +16 -0
- package/src/client/node-types.ts +13 -7
- 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/UnsupportedControlNode.ts +2 -6
- package/src/client/validation.ts +2 -2
- package/src/error/ErrorProductionDesignPendingError.ts +6 -0
- package/src/error/RankMissingValueError.ts +5 -0
- package/src/error/RankValueTypeError.ts +13 -0
- package/src/error/SelectValueTypeError.ts +22 -0
- package/src/error/ValueTypeInvariantError.ts +22 -0
- package/src/error/XFormsSpecViolationError.ts +1 -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 +12 -13
- package/src/instance/Group.ts +18 -5
- package/src/instance/InputControl.ts +159 -0
- package/src/instance/ModelValue.ts +48 -53
- package/src/instance/Note.ts +40 -49
- package/src/instance/PrimaryInstance.ts +245 -0
- package/src/instance/RangeControl.ts +113 -0
- package/src/instance/RankControl.ts +199 -0
- package/src/instance/Root.ts +63 -134
- package/src/instance/SelectControl.ts +219 -0
- package/src/instance/Subtree.ts +20 -7
- package/src/instance/TriggerControl.ts +44 -66
- package/src/instance/abstract/DescendantNode.ts +91 -51
- package/src/instance/abstract/InstanceNode.ts +113 -107
- package/src/instance/abstract/UnsupportedControl.ts +29 -5
- package/src/instance/abstract/ValueNode.ts +128 -0
- package/src/instance/children.ts +80 -40
- package/src/instance/hierarchy.ts +39 -30
- package/src/instance/identity.ts +3 -9
- package/src/instance/index.ts +25 -7
- package/src/instance/internal-api/EvaluationContext.ts +60 -13
- package/src/instance/internal-api/InstanceConfig.ts +9 -2
- package/src/instance/internal-api/InstanceValueContext.ts +26 -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 +3 -4
- package/src/instance/internal-api/ValueContext.ts +2 -1
- package/src/instance/internal-api/submission/ClientReactiveSubmittableInstance.ts +20 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +43 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +26 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +24 -0
- package/src/instance/repeat/BaseRepeatRange.ts +52 -131
- package/src/instance/repeat/RepeatInstance.ts +21 -46
- package/src/instance/repeat/RepeatRangeControlled.ts +5 -5
- package/src/instance/repeat/RepeatRangeUncontrolled.ts +2 -4
- package/src/instance/resource.ts +5 -2
- package/src/instance/text/TextChunk.ts +1 -1
- package/src/instance/unsupported/UploadControl.ts +5 -1
- 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 +148 -0
- package/src/integration/xpath/adapter/traversal.ts +229 -0
- package/src/integration/xpath/adapter/values.ts +5 -0
- package/src/integration/xpath/static-dom/StaticAttribute.ts +41 -0
- package/src/integration/xpath/static-dom/StaticDocument.ts +36 -0
- package/src/integration/xpath/static-dom/StaticElement.ts +119 -0
- package/src/integration/xpath/static-dom/StaticNode.ts +68 -0
- package/src/integration/xpath/static-dom/StaticText.ts +28 -0
- 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/createRootSubmissionState.ts +19 -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/Geopoint/Geopoint.ts +150 -0
- package/src/lib/codecs/Geopoint/GeopointValueCodec.ts +20 -0
- package/src/lib/codecs/IntValueCodec.ts +100 -0
- package/src/lib/codecs/NoteCodec.ts +32 -0
- package/src/lib/codecs/RangeCodec.ts +65 -0
- package/src/lib/codecs/StringValueCodec.ts +11 -0
- package/src/lib/codecs/TriggerCodec.ts +64 -0
- package/src/lib/codecs/ValueArrayCodec.ts +42 -0
- package/src/lib/codecs/ValueCodec.ts +106 -0
- package/src/lib/codecs/ValueTypePlaceholderCodec.ts +19 -0
- package/src/lib/codecs/getNoteCodec.ts +27 -0
- package/src/lib/codecs/getSelectCodec.ts +27 -0
- package/src/lib/codecs/getSharedValueCodec.ts +79 -0
- package/src/lib/codecs/items/BaseItemCodec.ts +20 -0
- package/src/lib/codecs/items/MultipleValueItemCodec.ts +28 -0
- package/src/lib/codecs/items/SingleValueItemCodec.ts +67 -0
- package/src/lib/dom/query.ts +8 -2
- package/src/lib/names/NamespaceDeclaration.ts +106 -0
- package/src/lib/names/NamespaceDeclarationMap.ts +228 -0
- package/src/lib/names/NamespaceURL.ts +44 -0
- package/src/lib/names/QualifiedName.ts +170 -0
- package/src/lib/number-parsers.ts +25 -0
- package/src/lib/reactivity/createChildrenState.ts +8 -6
- package/src/lib/reactivity/createComputedExpression.ts +57 -34
- package/src/lib/reactivity/createInstanceValueState.ts +216 -0
- package/src/lib/reactivity/createItemCollection.ts +173 -0
- package/src/lib/reactivity/createNoteReadonlyThunk.ts +12 -7
- package/src/lib/reactivity/createTranslationState.ts +61 -0
- package/src/lib/reactivity/createValueState.ts +62 -120
- package/src/lib/reactivity/materializeCurrentStateChildren.ts +7 -7
- package/src/lib/reactivity/text/createTextRange.ts +4 -3
- package/src/lib/reactivity/validation/createAggregatedViolations.ts +1 -1
- package/src/lib/reactivity/validation/createValidation.ts +2 -3
- package/src/lib/xml-serialization.ts +163 -0
- package/src/parse/XFormDOM.ts +231 -76
- package/src/parse/XFormDefinition.ts +2 -10
- package/src/parse/attachments/FormAttachmentResource.ts +40 -0
- package/src/parse/body/BodyDefinition.ts +7 -7
- package/src/parse/body/appearance/inputAppearanceParser.ts +1 -1
- package/src/parse/body/appearance/rangeAppearanceParser.ts +11 -0
- package/src/parse/body/control/InputControlDefinition.ts +29 -0
- package/src/parse/body/control/{select/ItemDefinition.ts → ItemDefinition.ts} +8 -6
- package/src/parse/body/control/{select/ItemsetDefinition.ts → ItemsetDefinition.ts} +11 -9
- package/src/parse/body/control/RangeControlDefinition.ts +91 -6
- package/src/parse/body/control/RankControlDefinition.ts +25 -7
- package/src/parse/body/control/{select/SelectDefinition.ts → SelectControlDefinition.ts} +9 -9
- package/src/parse/expression/ItemsetNodesetExpression.ts +1 -1
- package/src/parse/expression/ItemsetValueExpression.ts +1 -1
- package/src/parse/expression/abstract/DependencyContext.ts +0 -26
- package/src/parse/expression/abstract/DependentExpression.ts +2 -13
- package/src/parse/model/BindDefinition.ts +9 -8
- package/src/parse/model/BindPreloadDefinition.ts +100 -0
- package/src/parse/model/BindTypeDefinition.ts +175 -0
- package/src/parse/model/DescendentNodeDefinition.ts +7 -31
- package/src/parse/model/FormSubmissionDefinition.ts +44 -0
- package/src/parse/model/ItextTranslation/ItextTranslationDefinition.ts +4 -0
- package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +42 -0
- package/src/parse/model/ItextTranslation/ItextTranslationsDefinition.ts +31 -0
- package/src/parse/model/LeafNodeDefinition.ts +15 -5
- package/src/parse/model/ModelBindMap.ts +6 -8
- package/src/parse/model/ModelDefinition.ts +6 -1
- package/src/parse/model/NodeDefinition.ts +24 -48
- package/src/parse/model/NoteNodeDefinition.ts +11 -10
- package/src/parse/model/RangeNodeDefinition.ts +118 -0
- package/src/parse/model/RepeatInstanceDefinition.ts +11 -7
- package/src/parse/model/RepeatRangeDefinition.ts +11 -7
- package/src/parse/model/RepeatTemplateDefinition.ts +11 -7
- package/src/parse/model/RootAttributeDefinition.ts +45 -0
- package/src/parse/model/RootAttributeMap.ts +44 -0
- package/src/parse/model/RootDefinition.ts +31 -29
- 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 +415 -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/model/SubtreeDefinition.ts +12 -12
- package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +149 -0
- package/src/parse/text/ItemLabelDefinition.ts +1 -1
- package/src/parse/text/ItemsetLabelDefinition.ts +2 -2
- package/src/parse/text/abstract/TextElementDefinition.ts +1 -1
- package/src/parse/text/abstract/TextRangeDefinition.ts +0 -6
- package/src/parse/xpath/semantic-analysis.ts +33 -3
- package/dist/client/StringNode.d.ts +0 -46
- package/dist/client/unsupported/RangeNode.d.ts +0 -9
- package/dist/client/unsupported/RankNode.d.ts +0 -9
- package/dist/instance/SelectField.d.ts +0 -50
- package/dist/instance/StringField.d.ts +0 -44
- package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -59
- package/dist/instance/unsupported/RangeControl.d.ts +0 -4
- package/dist/instance/unsupported/RankControl.d.ts +0 -4
- package/dist/lib/reactivity/createSelectItems.d.ts +0 -16
- package/dist/parse/XFormDataType.d.ts +0 -25
- package/dist/parse/body/control/select/ItemDefinition.d.ts +0 -13
- package/dist/parse/body/control/select/ItemsetDefinition.d.ts +0 -17
- package/dist/parse/body/control/select/ItemsetNodesetContext.d.ts +0 -11
- package/src/client/StringNode.ts +0 -52
- package/src/client/unsupported/RangeNode.ts +0 -14
- package/src/client/unsupported/RankNode.ts +0 -14
- package/src/instance/SelectField.ts +0 -226
- package/src/instance/StringField.ts +0 -120
- package/src/instance/internal-api/SubscribableDependency.ts +0 -61
- package/src/instance/unsupported/RangeControl.ts +0 -5
- package/src/instance/unsupported/RankControl.ts +0 -5
- package/src/lib/reactivity/createSelectItems.ts +0 -168
- package/src/parse/XFormDataType.ts +0 -62
- package/src/parse/body/control/InputDefinition.ts +0 -22
- package/src/parse/body/control/select/ItemsetNodesetContext.ts +0 -26
|
@@ -1,65 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { ModelValueNode } from '../client/ModelValueNode.ts';
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
|
+
import type { ModelValueDefinition, ModelValueNode } from '../client/ModelValueNode.ts';
|
|
3
|
+
import type { ValueType } from '../client/ValueType.ts';
|
|
4
|
+
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
5
|
+
import type { RuntimeInputValue, RuntimeValue } from '../lib/codecs/getSharedValueCodec.ts';
|
|
6
|
+
import { getSharedValueCodec } from '../lib/codecs/getSharedValueCodec.ts';
|
|
5
7
|
import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
|
|
6
8
|
import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
|
|
7
9
|
import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
8
10
|
import { createSharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
9
|
-
import type
|
|
10
|
-
import type { SharedValidationState } from '../lib/reactivity/validation/createValidation.ts';
|
|
11
|
-
import { createValidationState } from '../lib/reactivity/validation/createValidation.ts';
|
|
12
|
-
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
13
|
-
import type { DescendantNodeStateSpec } from './abstract/DescendantNode.ts';
|
|
14
|
-
import { DescendantNode } from './abstract/DescendantNode.ts';
|
|
11
|
+
import { ValueNode, type ValueNodeStateSpec } from './abstract/ValueNode.ts';
|
|
15
12
|
import type { GeneralParentNode } from './hierarchy.ts';
|
|
16
13
|
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
17
|
-
import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
|
|
18
14
|
import type { ValidationContext } from './internal-api/ValidationContext.ts';
|
|
19
|
-
import type {
|
|
15
|
+
import type { ClientReactiveSubmittableValueNode } from './internal-api/submission/ClientReactiveSubmittableValueNode.ts';
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
readonly bodyElement: null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
interface ModelValueStateSpec extends DescendantNodeStateSpec<string> {
|
|
17
|
+
interface ModelValueStateSpec<V extends ValueType> extends ValueNodeStateSpec<RuntimeValue<V>> {
|
|
26
18
|
readonly label: null;
|
|
27
19
|
readonly hint: null;
|
|
28
|
-
readonly children: null;
|
|
29
|
-
readonly value: SimpleAtomicState<string>;
|
|
30
20
|
readonly valueOptions: null;
|
|
31
21
|
}
|
|
32
22
|
|
|
33
|
-
export class ModelValue
|
|
34
|
-
extends
|
|
23
|
+
export class ModelValue<V extends ValueType = ValueType>
|
|
24
|
+
extends ValueNode<V, ModelValueDefinition<V>, RuntimeValue<V>, RuntimeInputValue<V>>
|
|
35
25
|
implements
|
|
36
|
-
ModelValueNode
|
|
26
|
+
ModelValueNode<V>,
|
|
27
|
+
XFormsXPathElement,
|
|
37
28
|
EvaluationContext,
|
|
38
|
-
SubscribableDependency,
|
|
39
29
|
ValidationContext,
|
|
40
|
-
|
|
30
|
+
ClientReactiveSubmittableValueNode
|
|
41
31
|
{
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
static from(parent: GeneralParentNode, definition: ModelValueDefinition): AnyModelValue;
|
|
33
|
+
static from<V extends ValueType>(
|
|
34
|
+
parent: GeneralParentNode,
|
|
35
|
+
definition: ModelValueDefinition<V>
|
|
36
|
+
): ModelValue<V> {
|
|
37
|
+
return new this(parent, definition);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// XFormsXPathElement
|
|
41
|
+
override readonly [XPathNodeKindKey] = 'element';
|
|
44
42
|
|
|
45
43
|
// InstanceNode
|
|
46
|
-
protected
|
|
44
|
+
protected readonly state: SharedNodeState<ModelValueStateSpec<V>>;
|
|
45
|
+
protected readonly engineState: EngineState<ModelValueStateSpec<V>>;
|
|
47
46
|
|
|
48
47
|
// ModelValueNode
|
|
49
48
|
readonly nodeType = 'model-value';
|
|
50
49
|
readonly appearances = null;
|
|
51
|
-
readonly
|
|
50
|
+
readonly nodeOptions = null;
|
|
51
|
+
readonly currentState: CurrentState<ModelValueStateSpec<V>>;
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// ValueContext
|
|
58
|
-
readonly encodeValue = identity<string>;
|
|
59
|
-
readonly decodeValue = identity<string>;
|
|
53
|
+
constructor(parent: GeneralParentNode, definition: ModelValueDefinition<V>) {
|
|
54
|
+
const codec = getSharedValueCodec(definition.valueType);
|
|
60
55
|
|
|
61
|
-
|
|
62
|
-
super(parent, definition);
|
|
56
|
+
super(parent, definition, codec);
|
|
63
57
|
|
|
64
58
|
const sharedStateOptions = {
|
|
65
59
|
clientStateFactory: this.engineConfig.stateFactory,
|
|
@@ -77,7 +71,8 @@ export class ModelValue
|
|
|
77
71
|
hint: null,
|
|
78
72
|
children: null,
|
|
79
73
|
valueOptions: null,
|
|
80
|
-
value:
|
|
74
|
+
value: this.valueState,
|
|
75
|
+
instanceValue: this.getInstanceValue,
|
|
81
76
|
},
|
|
82
77
|
sharedStateOptions
|
|
83
78
|
);
|
|
@@ -85,20 +80,20 @@ export class ModelValue
|
|
|
85
80
|
this.state = state;
|
|
86
81
|
this.engineState = state.engineState;
|
|
87
82
|
this.currentState = state.currentState;
|
|
88
|
-
this.validation = createValidationState(this, sharedStateOptions);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// ValidationContext
|
|
92
|
-
getViolation(): AnyViolation | null {
|
|
93
|
-
return this.validation.engineState.violation;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
isBlank(): boolean {
|
|
97
|
-
return this.engineState.value === '';
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// InstanceNode
|
|
101
|
-
getChildren(): readonly [] {
|
|
102
|
-
return [];
|
|
103
83
|
}
|
|
104
84
|
}
|
|
85
|
+
|
|
86
|
+
export type AnyModelValue =
|
|
87
|
+
| ModelValue<'barcode'>
|
|
88
|
+
| ModelValue<'binary'>
|
|
89
|
+
| ModelValue<'boolean'>
|
|
90
|
+
| ModelValue<'date'>
|
|
91
|
+
| ModelValue<'dateTime'>
|
|
92
|
+
| ModelValue<'decimal'>
|
|
93
|
+
| ModelValue<'geopoint'>
|
|
94
|
+
| ModelValue<'geoshape'>
|
|
95
|
+
| ModelValue<'geotrace'>
|
|
96
|
+
| ModelValue<'int'>
|
|
97
|
+
| ModelValue<'intent'>
|
|
98
|
+
| ModelValue<'string'>
|
|
99
|
+
| ModelValue<'time'>;
|
package/src/instance/Note.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { UnreachableError } from '@getodk/common/lib/error/UnreachableError.ts';
|
|
2
|
-
import {
|
|
2
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
3
3
|
import type { Accessor } from 'solid-js';
|
|
4
|
-
import type { NoteNode, NoteNodeAppearances } from '../client/NoteNode.ts';
|
|
4
|
+
import type { NoteNode, NoteNodeAppearances, NoteValue } from '../client/NoteNode.ts';
|
|
5
5
|
import type { TextRange } from '../client/TextRange.ts';
|
|
6
|
-
import type {
|
|
6
|
+
import type { ValueType } from '../client/ValueType.ts';
|
|
7
|
+
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
8
|
+
import { getNoteCodec } from '../lib/codecs/getNoteCodec.ts';
|
|
9
|
+
import type { NoteInputValue, NoteRuntimeValue } from '../lib/codecs/NoteCodec.ts';
|
|
7
10
|
import { createNoteReadonlyThunk } from '../lib/reactivity/createNoteReadonlyThunk.ts';
|
|
8
|
-
import { createValueState } from '../lib/reactivity/createValueState.ts';
|
|
9
11
|
import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
|
|
10
12
|
import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
|
|
11
13
|
import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
@@ -13,59 +15,47 @@ import { createSharedNodeState } from '../lib/reactivity/node-state/createShared
|
|
|
13
15
|
import { createFieldHint } from '../lib/reactivity/text/createFieldHint.ts';
|
|
14
16
|
import { createNodeLabel } from '../lib/reactivity/text/createNodeLabel.ts';
|
|
15
17
|
import { createNoteText, type ComputedNoteText } from '../lib/reactivity/text/createNoteText.ts';
|
|
16
|
-
import type { SimpleAtomicState } from '../lib/reactivity/types.ts';
|
|
17
|
-
import type { SharedValidationState } from '../lib/reactivity/validation/createValidation.ts';
|
|
18
|
-
import { createValidationState } from '../lib/reactivity/validation/createValidation.ts';
|
|
19
18
|
import type { NoteNodeDefinition } from '../parse/model/NoteNodeDefinition.ts';
|
|
20
|
-
import type
|
|
21
|
-
import { DescendantNode } from './abstract/DescendantNode.ts';
|
|
19
|
+
import { ValueNode, type ValueNodeStateSpec } from './abstract/ValueNode.ts';
|
|
22
20
|
import type { GeneralParentNode } from './hierarchy.ts';
|
|
23
21
|
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
24
|
-
import type {
|
|
22
|
+
import type { ClientReactiveSubmittableValueNode } from './internal-api/submission/ClientReactiveSubmittableValueNode.ts';
|
|
25
23
|
import type { ValidationContext } from './internal-api/ValidationContext.ts';
|
|
26
|
-
import type { ValueContext } from './internal-api/ValueContext.ts';
|
|
27
24
|
|
|
28
|
-
interface NoteStateSpec extends
|
|
25
|
+
interface NoteStateSpec<V extends ValueType> extends ValueNodeStateSpec<NoteValue<V>> {
|
|
29
26
|
readonly readonly: Accessor<true>;
|
|
30
27
|
readonly noteText: ComputedNoteText;
|
|
31
28
|
readonly label: Accessor<TextRange<'label', 'form'> | null>;
|
|
32
29
|
readonly hint: Accessor<TextRange<'hint', 'form'> | null>;
|
|
33
|
-
readonly children: null;
|
|
34
|
-
readonly value: SimpleAtomicState<string>;
|
|
35
30
|
readonly valueOptions: null;
|
|
36
31
|
}
|
|
37
32
|
|
|
38
|
-
export class Note
|
|
39
|
-
extends
|
|
33
|
+
export class Note<V extends ValueType = ValueType>
|
|
34
|
+
extends ValueNode<V, NoteNodeDefinition<V>, NoteRuntimeValue<V>, NoteInputValue<V>>
|
|
40
35
|
implements
|
|
41
36
|
NoteNode,
|
|
37
|
+
XFormsXPathElement,
|
|
42
38
|
EvaluationContext,
|
|
43
|
-
SubscribableDependency,
|
|
44
39
|
ValidationContext,
|
|
45
|
-
|
|
40
|
+
ClientReactiveSubmittableValueNode
|
|
46
41
|
{
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
// XFormsXPathElement
|
|
43
|
+
override readonly [XPathNodeKindKey] = 'element';
|
|
49
44
|
|
|
50
45
|
// InstanceNode
|
|
51
|
-
protected
|
|
46
|
+
protected readonly state: SharedNodeState<NoteStateSpec<V>>;
|
|
47
|
+
protected readonly engineState: EngineState<NoteStateSpec<V>>;
|
|
52
48
|
|
|
53
49
|
// NoteNode
|
|
54
50
|
readonly nodeType = 'note';
|
|
55
51
|
readonly appearances: NoteNodeAppearances;
|
|
56
|
-
readonly
|
|
52
|
+
readonly nodeOptions = null;
|
|
53
|
+
readonly currentState: CurrentState<NoteStateSpec<V>>;
|
|
57
54
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// ValueContext
|
|
63
|
-
readonly encodeValue = identity<string>;
|
|
64
|
-
|
|
65
|
-
readonly decodeValue = identity<string>;
|
|
55
|
+
constructor(parent: GeneralParentNode, definition: NoteNodeDefinition<V>) {
|
|
56
|
+
const codec = getNoteCodec(definition.valueType);
|
|
66
57
|
|
|
67
|
-
|
|
68
|
-
super(parent, definition);
|
|
58
|
+
super(parent, definition, codec);
|
|
69
59
|
|
|
70
60
|
this.appearances = definition.bodyElement.appearances;
|
|
71
61
|
|
|
@@ -73,7 +63,7 @@ export class Note
|
|
|
73
63
|
clientStateFactory: this.engineConfig.stateFactory,
|
|
74
64
|
};
|
|
75
65
|
|
|
76
|
-
const isReadonly = createNoteReadonlyThunk(this, definition
|
|
66
|
+
const isReadonly = createNoteReadonlyThunk(this, definition);
|
|
77
67
|
const noteTextComputation = createNoteText(this, definition.noteTextDefinition);
|
|
78
68
|
|
|
79
69
|
let noteText: ComputedNoteText;
|
|
@@ -115,7 +105,8 @@ export class Note
|
|
|
115
105
|
|
|
116
106
|
children: null,
|
|
117
107
|
valueOptions: null,
|
|
118
|
-
value:
|
|
108
|
+
value: this.valueState,
|
|
109
|
+
instanceValue: this.getInstanceValue,
|
|
119
110
|
},
|
|
120
111
|
sharedStateOptions
|
|
121
112
|
);
|
|
@@ -123,20 +114,20 @@ export class Note
|
|
|
123
114
|
this.state = state;
|
|
124
115
|
this.engineState = state.engineState;
|
|
125
116
|
this.currentState = state.currentState;
|
|
126
|
-
this.validation = createValidationState(this, sharedStateOptions);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// ValidationContext
|
|
130
|
-
getViolation(): AnyViolation | null {
|
|
131
|
-
return this.validation.engineState.violation;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
isBlank(): boolean {
|
|
135
|
-
return this.engineState.value === '';
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// InstanceNode
|
|
139
|
-
getChildren(): readonly [] {
|
|
140
|
-
return [];
|
|
141
117
|
}
|
|
142
118
|
}
|
|
119
|
+
|
|
120
|
+
export type AnyNote =
|
|
121
|
+
| Note<'barcode'>
|
|
122
|
+
| Note<'binary'>
|
|
123
|
+
| Note<'boolean'>
|
|
124
|
+
| Note<'date'>
|
|
125
|
+
| Note<'dateTime'>
|
|
126
|
+
| Note<'decimal'>
|
|
127
|
+
| Note<'geopoint'>
|
|
128
|
+
| Note<'geoshape'>
|
|
129
|
+
| Note<'geotrace'>
|
|
130
|
+
| Note<'int'>
|
|
131
|
+
| Note<'intent'>
|
|
132
|
+
| Note<'string'>
|
|
133
|
+
| Note<'time'>;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
|
+
import type { Accessor } from 'solid-js';
|
|
3
|
+
import { createSignal } from 'solid-js';
|
|
4
|
+
import type { ActiveLanguage, FormLanguage, FormLanguages } from '../client/FormLanguage.ts';
|
|
5
|
+
import type { FormNodeID } from '../client/identity.ts';
|
|
6
|
+
import type { RootNode } from '../client/RootNode.ts';
|
|
7
|
+
import type {
|
|
8
|
+
SubmissionChunkedType,
|
|
9
|
+
SubmissionOptions,
|
|
10
|
+
} from '../client/submission/SubmissionOptions.ts';
|
|
11
|
+
import type { SubmissionResult } from '../client/submission/SubmissionResult.ts';
|
|
12
|
+
import type { SubmissionState } from '../client/submission/SubmissionState.ts';
|
|
13
|
+
import type { AncestorNodeValidationState } from '../client/validation.ts';
|
|
14
|
+
import type { XFormsXPathDocument } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
15
|
+
import { EngineXPathEvaluator } from '../integration/xpath/EngineXPathEvaluator.ts';
|
|
16
|
+
import { createInstanceSubmissionState } from '../lib/client-reactivity/submission/createInstanceSubmissionState.ts';
|
|
17
|
+
import { prepareSubmission } from '../lib/client-reactivity/submission/prepareSubmission.ts';
|
|
18
|
+
import { createChildrenState } from '../lib/reactivity/createChildrenState.ts';
|
|
19
|
+
import { createTranslationState } from '../lib/reactivity/createTranslationState.ts';
|
|
20
|
+
import type { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
|
|
21
|
+
import { materializeCurrentStateChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
|
|
22
|
+
import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
|
|
23
|
+
import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
|
|
24
|
+
import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
25
|
+
import { createSharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
26
|
+
import type { ReactiveScope } from '../lib/reactivity/scope.ts';
|
|
27
|
+
import type { SimpleAtomicStateSetter } from '../lib/reactivity/types.ts';
|
|
28
|
+
import type { BodyClassList } from '../parse/body/BodyDefinition.ts';
|
|
29
|
+
import type { ModelDefinition } from '../parse/model/ModelDefinition.ts';
|
|
30
|
+
import type { RootDefinition } from '../parse/model/RootDefinition.ts';
|
|
31
|
+
import type { SecondaryInstancesDefinition } from '../parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts';
|
|
32
|
+
import { InstanceNode } from './abstract/InstanceNode.ts';
|
|
33
|
+
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
34
|
+
import type { InstanceConfig } from './internal-api/InstanceConfig.ts';
|
|
35
|
+
import type { PrimaryInstanceDocument } from './internal-api/PrimaryInstanceDocument.ts';
|
|
36
|
+
import type { ClientReactiveSubmittableInstance } from './internal-api/submission/ClientReactiveSubmittableInstance.ts';
|
|
37
|
+
import type { TranslationContext } from './internal-api/TranslationContext.ts';
|
|
38
|
+
import { Root } from './Root.ts';
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* As specified by {@link | XPath 1.0}:
|
|
42
|
+
*
|
|
43
|
+
* > A `/` by itself selects the root node of the document containing the
|
|
44
|
+
* > context node.
|
|
45
|
+
*
|
|
46
|
+
* Important note: "root node" here references the same semantics currently
|
|
47
|
+
* represented by `@getodk/xpath` as {@link XPathDocument}. It is an infortunate
|
|
48
|
+
* historical mistake that our internal representation of a primary instance has
|
|
49
|
+
* conflated the same "root" term to represent the "document element" with the
|
|
50
|
+
* same semantic name.
|
|
51
|
+
*
|
|
52
|
+
* {@link PrimaryInstance} exists specifically to provide XPath document
|
|
53
|
+
* semantics. At time of writing, it is expected that every XPath evaluation
|
|
54
|
+
* will be performed with a context node either:
|
|
55
|
+
*
|
|
56
|
+
* - somewhere in this primary instance document's hierarchy; or
|
|
57
|
+
* - in a related subtree where the primary instance document is still
|
|
58
|
+
* semantically represented as the context root node
|
|
59
|
+
*/
|
|
60
|
+
const PRIMARY_INSTANCE_REFERENCE = '/';
|
|
61
|
+
|
|
62
|
+
interface PrimaryInstanceStateSpec {
|
|
63
|
+
readonly reference: string;
|
|
64
|
+
readonly readonly: boolean;
|
|
65
|
+
readonly relevant: boolean;
|
|
66
|
+
readonly required: boolean;
|
|
67
|
+
readonly label: null;
|
|
68
|
+
readonly hint: null;
|
|
69
|
+
readonly children: Accessor<readonly FormNodeID[]>;
|
|
70
|
+
readonly valueOptions: null;
|
|
71
|
+
readonly value: null;
|
|
72
|
+
|
|
73
|
+
// Root-specific
|
|
74
|
+
readonly activeLanguage: Accessor<ActiveLanguage>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export class PrimaryInstance
|
|
78
|
+
extends InstanceNode<RootDefinition, PrimaryInstanceStateSpec, null, Root>
|
|
79
|
+
implements
|
|
80
|
+
PrimaryInstanceDocument,
|
|
81
|
+
XFormsXPathDocument,
|
|
82
|
+
TranslationContext,
|
|
83
|
+
EvaluationContext,
|
|
84
|
+
ClientReactiveSubmittableInstance
|
|
85
|
+
{
|
|
86
|
+
// InstanceNode
|
|
87
|
+
protected readonly state: SharedNodeState<PrimaryInstanceStateSpec>;
|
|
88
|
+
protected readonly engineState: EngineState<PrimaryInstanceStateSpec>;
|
|
89
|
+
readonly getChildren: Accessor<readonly Root[]>;
|
|
90
|
+
|
|
91
|
+
readonly hasReadonlyAncestor = () => false;
|
|
92
|
+
readonly isReadonly = () => false;
|
|
93
|
+
readonly hasNonRelevantAncestor = () => false;
|
|
94
|
+
readonly isRelevant = () => true;
|
|
95
|
+
|
|
96
|
+
// TranslationContext (support)
|
|
97
|
+
private readonly setActiveLanguage: SimpleAtomicStateSetter<FormLanguage>;
|
|
98
|
+
|
|
99
|
+
// XFormsXPathDocument
|
|
100
|
+
readonly [XPathNodeKindKey] = 'document';
|
|
101
|
+
|
|
102
|
+
// PrimaryInstanceDocument, ClientReactiveSubmittableInstance
|
|
103
|
+
readonly nodeType = 'primary-instance';
|
|
104
|
+
readonly appearances = null;
|
|
105
|
+
readonly nodeOptions = null;
|
|
106
|
+
readonly classes: BodyClassList;
|
|
107
|
+
readonly root: Root;
|
|
108
|
+
readonly currentState: MaterializedChildren<CurrentState<PrimaryInstanceStateSpec>, Root>;
|
|
109
|
+
readonly validationState: AncestorNodeValidationState;
|
|
110
|
+
readonly submissionState: SubmissionState;
|
|
111
|
+
readonly languages: FormLanguages;
|
|
112
|
+
|
|
113
|
+
// TranslationContext (+ EvaluationContext)
|
|
114
|
+
readonly getActiveLanguage: Accessor<ActiveLanguage>;
|
|
115
|
+
|
|
116
|
+
// EvaluationContext
|
|
117
|
+
readonly isAttached: Accessor<boolean>;
|
|
118
|
+
readonly evaluator: EngineXPathEvaluator;
|
|
119
|
+
override readonly contextNode = this;
|
|
120
|
+
|
|
121
|
+
constructor(
|
|
122
|
+
scope: ReactiveScope,
|
|
123
|
+
model: ModelDefinition,
|
|
124
|
+
secondaryInstances: SecondaryInstancesDefinition,
|
|
125
|
+
engineConfig: InstanceConfig
|
|
126
|
+
) {
|
|
127
|
+
const { root: definition } = model;
|
|
128
|
+
|
|
129
|
+
super(engineConfig, null, definition, {
|
|
130
|
+
scope,
|
|
131
|
+
computeReference: () => PRIMARY_INSTANCE_REFERENCE,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const [isAttached, setIsAttached] = createSignal(false);
|
|
135
|
+
|
|
136
|
+
this.isAttached = isAttached;
|
|
137
|
+
|
|
138
|
+
const evaluator = new EngineXPathEvaluator({
|
|
139
|
+
rootNode: this,
|
|
140
|
+
itextTranslationsByLanguage: model.itextTranslations,
|
|
141
|
+
secondaryInstancesById: secondaryInstances,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const { languages, getActiveLanguage, setActiveLanguage } = createTranslationState(
|
|
145
|
+
scope,
|
|
146
|
+
evaluator
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
this.languages = languages;
|
|
150
|
+
this.getActiveLanguage = getActiveLanguage;
|
|
151
|
+
this.setActiveLanguage = setActiveLanguage;
|
|
152
|
+
|
|
153
|
+
this.evaluator = evaluator;
|
|
154
|
+
this.classes = definition.classes;
|
|
155
|
+
|
|
156
|
+
const childrenState = createChildrenState<this, Root>(this);
|
|
157
|
+
|
|
158
|
+
this.getChildren = childrenState.getChildren;
|
|
159
|
+
|
|
160
|
+
const stateSpec: PrimaryInstanceStateSpec = {
|
|
161
|
+
activeLanguage: getActiveLanguage,
|
|
162
|
+
reference: PRIMARY_INSTANCE_REFERENCE,
|
|
163
|
+
label: null,
|
|
164
|
+
hint: null,
|
|
165
|
+
readonly: false,
|
|
166
|
+
relevant: true,
|
|
167
|
+
required: false,
|
|
168
|
+
valueOptions: null,
|
|
169
|
+
value: null,
|
|
170
|
+
children: childrenState.childIds,
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const state = createSharedNodeState(scope, stateSpec, {
|
|
174
|
+
clientStateFactory: engineConfig.stateFactory,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
this.state = state;
|
|
178
|
+
this.engineState = state.engineState;
|
|
179
|
+
this.currentState = materializeCurrentStateChildren(scope, state.currentState, childrenState);
|
|
180
|
+
|
|
181
|
+
const root = new Root(this);
|
|
182
|
+
|
|
183
|
+
this.root = root;
|
|
184
|
+
|
|
185
|
+
this.validationState = {
|
|
186
|
+
get violations() {
|
|
187
|
+
return root.validationState.violations;
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
this.submissionState = createInstanceSubmissionState(this);
|
|
191
|
+
|
|
192
|
+
childrenState.setChildren([root]);
|
|
193
|
+
setIsAttached(true);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// PrimaryInstanceDocument
|
|
197
|
+
/**
|
|
198
|
+
* @todo Note that this method's signature is intentionally derived from
|
|
199
|
+
* {@link RootNode.setLanguage}, but its return type differs! The design
|
|
200
|
+
* intent of returning {@link RootNode} from all of the client-facing state
|
|
201
|
+
* setter methods has proven… interesting philosophically. But nothing
|
|
202
|
+
* downstream has availed itself of that philosophy, and otherwise it's not
|
|
203
|
+
* particularly pragmatic or ergonomic (internally or for clients alike).
|
|
204
|
+
*
|
|
205
|
+
* Since this class is (currently) engine-internal, this seems like an
|
|
206
|
+
* excellent place to start a discussion around what we want longer term for
|
|
207
|
+
* state setter signatures in _client-facing_ APIs. As a first pass, it seems
|
|
208
|
+
* reasonable to borrow the idiomatic convention of returning the effective
|
|
209
|
+
* value assigned by the setter.
|
|
210
|
+
*
|
|
211
|
+
* @see
|
|
212
|
+
* {@link https://github.com/getodk/web-forms/issues/45#issuecomment-1967932261 | Initial read interface design between engine and UI - design summary comment}
|
|
213
|
+
* (and some of the comments leading up to it) for background on the
|
|
214
|
+
* philosophical reasoning behind the existing signature convention.
|
|
215
|
+
*/
|
|
216
|
+
setLanguage(language: FormLanguage): FormLanguage {
|
|
217
|
+
const availableFormLanguage = this.languages.find(
|
|
218
|
+
(formLanguage): formLanguage is FormLanguage => {
|
|
219
|
+
return (
|
|
220
|
+
formLanguage.isSyntheticDefault == null && formLanguage.language === language.language
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
if (availableFormLanguage == null) {
|
|
226
|
+
throw new Error(`Language "${language.language}" not available`);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
this.evaluator.setActiveLanguage(availableFormLanguage.language);
|
|
230
|
+
|
|
231
|
+
return this.setActiveLanguage(availableFormLanguage);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// PrimaryInstanceDocument, ClientReactiveSubmittableInstance
|
|
235
|
+
prepareSubmission<ChunkedType extends SubmissionChunkedType = 'monolithic'>(
|
|
236
|
+
options?: SubmissionOptions<ChunkedType>
|
|
237
|
+
): Promise<SubmissionResult<ChunkedType>> {
|
|
238
|
+
const result = prepareSubmission(this, {
|
|
239
|
+
chunked: (options?.chunked ?? 'monolithic') as ChunkedType,
|
|
240
|
+
maxSize: options?.maxSize ?? Infinity,
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
return Promise.resolve(result);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
|
+
import type { Accessor } from 'solid-js';
|
|
3
|
+
import type {
|
|
4
|
+
RangeInputValue,
|
|
5
|
+
RangeNode,
|
|
6
|
+
RangeNodeAppearances,
|
|
7
|
+
RangeValue,
|
|
8
|
+
} from '../client/RangeNode.ts';
|
|
9
|
+
import type { TextRange } from '../client/TextRange.ts';
|
|
10
|
+
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
11
|
+
import { RangeCodec } from '../lib/codecs/RangeCodec.ts';
|
|
12
|
+
import { getSharedValueCodec } from '../lib/codecs/getSharedValueCodec.ts';
|
|
13
|
+
import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
|
|
14
|
+
import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
|
|
15
|
+
import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
16
|
+
import { createSharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
17
|
+
import { createFieldHint } from '../lib/reactivity/text/createFieldHint.ts';
|
|
18
|
+
import { createNodeLabel } from '../lib/reactivity/text/createNodeLabel.ts';
|
|
19
|
+
import type {
|
|
20
|
+
AnyRangeNodeDefinition,
|
|
21
|
+
RangeNodeDefinition,
|
|
22
|
+
RangeValueType,
|
|
23
|
+
} from '../parse/model/RangeNodeDefinition.ts';
|
|
24
|
+
import type { Root } from './Root.ts';
|
|
25
|
+
import { ValueNode, type ValueNodeStateSpec } from './abstract/ValueNode.ts';
|
|
26
|
+
import type { GeneralParentNode } from './hierarchy.ts';
|
|
27
|
+
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
28
|
+
import type { ValidationContext } from './internal-api/ValidationContext.ts';
|
|
29
|
+
import type { ClientReactiveSubmittableValueNode } from './internal-api/submission/ClientReactiveSubmittableValueNode.ts';
|
|
30
|
+
|
|
31
|
+
interface RangeControlStateSpec<V extends RangeValueType>
|
|
32
|
+
extends ValueNodeStateSpec<RangeValue<V>> {
|
|
33
|
+
readonly label: Accessor<TextRange<'label'> | null>;
|
|
34
|
+
readonly hint: Accessor<TextRange<'hint'> | null>;
|
|
35
|
+
readonly valueOptions: null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class RangeControl<V extends RangeValueType = RangeValueType>
|
|
39
|
+
extends ValueNode<V, RangeNodeDefinition<V>, RangeValue<V>, RangeInputValue<V>>
|
|
40
|
+
implements
|
|
41
|
+
RangeNode<V>,
|
|
42
|
+
XFormsXPathElement,
|
|
43
|
+
EvaluationContext,
|
|
44
|
+
ValidationContext,
|
|
45
|
+
ClientReactiveSubmittableValueNode
|
|
46
|
+
{
|
|
47
|
+
static from(parent: GeneralParentNode, definition: AnyRangeNodeDefinition): AnyRangeControl;
|
|
48
|
+
static from<V extends RangeValueType>(
|
|
49
|
+
parent: GeneralParentNode,
|
|
50
|
+
definition: RangeNodeDefinition<V>
|
|
51
|
+
): RangeControl<V> {
|
|
52
|
+
return new this<V>(parent, definition);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// XFormsXPathElement
|
|
56
|
+
override readonly [XPathNodeKindKey] = 'element';
|
|
57
|
+
|
|
58
|
+
// InstanceNode
|
|
59
|
+
protected readonly state: SharedNodeState<RangeControlStateSpec<V>>;
|
|
60
|
+
protected readonly engineState: EngineState<RangeControlStateSpec<V>>;
|
|
61
|
+
|
|
62
|
+
// RangeNode
|
|
63
|
+
readonly nodeType = 'range';
|
|
64
|
+
readonly appearances: RangeNodeAppearances;
|
|
65
|
+
readonly nodeOptions = null;
|
|
66
|
+
readonly currentState: CurrentState<RangeControlStateSpec<V>>;
|
|
67
|
+
|
|
68
|
+
constructor(parent: GeneralParentNode, definition: RangeNodeDefinition<V>) {
|
|
69
|
+
const baseCodec = getSharedValueCodec(definition.valueType);
|
|
70
|
+
const codec = new RangeCodec(baseCodec, definition);
|
|
71
|
+
|
|
72
|
+
super(parent, definition, codec);
|
|
73
|
+
|
|
74
|
+
this.appearances = definition.bodyElement.appearances;
|
|
75
|
+
|
|
76
|
+
const sharedStateOptions = {
|
|
77
|
+
clientStateFactory: this.engineConfig.stateFactory,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const state = createSharedNodeState(
|
|
81
|
+
this.scope,
|
|
82
|
+
{
|
|
83
|
+
reference: this.contextReference,
|
|
84
|
+
readonly: this.isReadonly,
|
|
85
|
+
relevant: this.isRelevant,
|
|
86
|
+
required: this.isRequired,
|
|
87
|
+
|
|
88
|
+
label: createNodeLabel(this, definition),
|
|
89
|
+
hint: createFieldHint(this, definition),
|
|
90
|
+
children: null,
|
|
91
|
+
valueOptions: null,
|
|
92
|
+
value: this.valueState,
|
|
93
|
+
instanceValue: this.getInstanceValue,
|
|
94
|
+
},
|
|
95
|
+
sharedStateOptions
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
this.state = state;
|
|
99
|
+
this.engineState = state.engineState;
|
|
100
|
+
this.currentState = state.currentState;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
setValue(value: RangeInputValue<V>): Root {
|
|
104
|
+
this.setValueState(value);
|
|
105
|
+
|
|
106
|
+
return this.root;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// prettier-ignore
|
|
111
|
+
export type AnyRangeControl =
|
|
112
|
+
| RangeControl<'decimal'>
|
|
113
|
+
| RangeControl<'int'>;
|