@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
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { SubmissionState } from '../../../client/submission/SubmissionState.ts';
|
|
2
|
+
import type { QualifiedName } from '../../../lib/names/QualifiedName.ts';
|
|
3
|
+
import type { EscapedXMLText } from '../../../lib/xml-serialization.ts';
|
|
4
|
+
import type {
|
|
5
|
+
ClientReactiveSubmittableChildNode,
|
|
6
|
+
ClientReactiveSubmittableParentNode,
|
|
7
|
+
} from './ClientReactiveSubmittableParentNode.ts';
|
|
8
|
+
|
|
9
|
+
interface ClientReactiveSubmittableLeafNodeCurrentState<RuntimeValue> {
|
|
10
|
+
get relevant(): boolean;
|
|
11
|
+
get value(): RuntimeValue;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type SerializedSubmissionValue = string;
|
|
15
|
+
|
|
16
|
+
interface ClientReactiveSubmittableLeafNodeDefinition {
|
|
17
|
+
readonly qualifiedName: QualifiedName;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ClientReactiveSubmittableLeafNode<RuntimeValue> {
|
|
21
|
+
readonly definition: ClientReactiveSubmittableLeafNodeDefinition;
|
|
22
|
+
readonly parent: ClientReactiveSubmittableParentNode<ClientReactiveSubmittableChildNode>;
|
|
23
|
+
readonly currentState: ClientReactiveSubmittableLeafNodeCurrentState<RuntimeValue>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A client-reactive submittable leaf node is responsible for producing a
|
|
27
|
+
* string representation of its value state, suitable for serialization for
|
|
28
|
+
* submission. It **MUST NOT** perform any further submission-specific
|
|
29
|
+
* serialization duties: in particular, the value **MUST NOT** be escaped for
|
|
30
|
+
* XML. This responsibility is delegated up the stack, to avoid repeat
|
|
31
|
+
* escaping.
|
|
32
|
+
*
|
|
33
|
+
* Note: excluding {@link EscapedXMLText} here does not have an effect on the
|
|
34
|
+
* type system, it is a documentation-only hint, to help guard against future
|
|
35
|
+
* double-escaping mistakes.
|
|
36
|
+
*/
|
|
37
|
+
readonly encodeValue: (
|
|
38
|
+
this: unknown,
|
|
39
|
+
runtimeValue: RuntimeValue
|
|
40
|
+
) => Exclude<string, EscapedXMLText>;
|
|
41
|
+
|
|
42
|
+
readonly submissionState: SubmissionState;
|
|
43
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { SubmissionState } from '../../../client/submission/SubmissionState.ts';
|
|
2
|
+
import type { QualifiedName } from '../../../lib/names/QualifiedName.ts';
|
|
3
|
+
|
|
4
|
+
export interface ClientReactiveSubmittableChildNode {
|
|
5
|
+
readonly submissionState: SubmissionState;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface ClientReactiveSubmittableParentNodeCurrentState<
|
|
9
|
+
Child extends ClientReactiveSubmittableChildNode,
|
|
10
|
+
> {
|
|
11
|
+
get relevant(): boolean;
|
|
12
|
+
get children(): readonly Child[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ClientReactiveSubmittableParentNodeDefinition {
|
|
16
|
+
readonly qualifiedName: QualifiedName;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ClientReactiveSubmittableParentNode<
|
|
20
|
+
Child extends ClientReactiveSubmittableChildNode,
|
|
21
|
+
> {
|
|
22
|
+
readonly definition: ClientReactiveSubmittableParentNodeDefinition;
|
|
23
|
+
readonly parent: ClientReactiveSubmittableParentNode<ClientReactiveSubmittableChildNode> | null;
|
|
24
|
+
readonly currentState: ClientReactiveSubmittableParentNodeCurrentState<Child>;
|
|
25
|
+
readonly submissionState: SubmissionState;
|
|
26
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { SubmissionState } from '../../../client/submission/SubmissionState.ts';
|
|
2
|
+
import type { QualifiedName } from '../../../lib/names/QualifiedName.ts';
|
|
3
|
+
import type {
|
|
4
|
+
ClientReactiveSubmittableChildNode,
|
|
5
|
+
ClientReactiveSubmittableParentNode,
|
|
6
|
+
} from './ClientReactiveSubmittableParentNode.ts';
|
|
7
|
+
|
|
8
|
+
interface ClientReactiveSubmittableValueNodeCurrentState {
|
|
9
|
+
get relevant(): boolean;
|
|
10
|
+
get instanceValue(): string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type SerializedSubmissionValue = string;
|
|
14
|
+
|
|
15
|
+
interface ClientReactiveSubmittableValueNodeDefinition {
|
|
16
|
+
readonly qualifiedName: QualifiedName;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ClientReactiveSubmittableValueNode {
|
|
20
|
+
readonly definition: ClientReactiveSubmittableValueNodeDefinition;
|
|
21
|
+
readonly parent: ClientReactiveSubmittableParentNode<ClientReactiveSubmittableChildNode>;
|
|
22
|
+
readonly currentState: ClientReactiveSubmittableValueNodeCurrentState;
|
|
23
|
+
readonly submissionState: SubmissionState;
|
|
24
|
+
}
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { insertAtIndex } from '@getodk/common/lib/array/insert.ts';
|
|
2
|
-
import {
|
|
2
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
3
|
+
import type { Accessor } from 'solid-js';
|
|
4
|
+
import { untrack } from 'solid-js';
|
|
5
|
+
import type { RepeatRangeNode } from '../../client/hierarchy.ts';
|
|
6
|
+
import type { FormNodeID } from '../../client/identity.ts';
|
|
3
7
|
import type { NodeAppearances } from '../../client/NodeAppearances.ts';
|
|
4
8
|
import type { BaseRepeatRangeNode } from '../../client/repeat/BaseRepeatRangeNode.ts';
|
|
9
|
+
import type { SubmissionState } from '../../client/submission/SubmissionState.ts';
|
|
5
10
|
import type { TextRange } from '../../client/TextRange.ts';
|
|
6
11
|
import type { AncestorNodeValidationState } from '../../client/validation.ts';
|
|
12
|
+
import type {
|
|
13
|
+
XFormsXPathNodeRange,
|
|
14
|
+
XFormsXPathNodeRangeKind,
|
|
15
|
+
} from '../../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
16
|
+
import { XFORMS_XPATH_NODE_RANGE_KIND } from '../../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
17
|
+
import { createNodeRangeSubmissionState } from '../../lib/client-reactivity/submission/createNodeRangeSubmissionState.ts';
|
|
7
18
|
import type { ChildrenState } from '../../lib/reactivity/createChildrenState.ts';
|
|
8
19
|
import { createChildrenState } from '../../lib/reactivity/createChildrenState.ts';
|
|
9
|
-
import { createComputedExpression } from '../../lib/reactivity/createComputedExpression.ts';
|
|
10
20
|
import type { MaterializedChildren } from '../../lib/reactivity/materializeCurrentStateChildren.ts';
|
|
11
21
|
import { materializeCurrentStateChildren } from '../../lib/reactivity/materializeCurrentStateChildren.ts';
|
|
12
22
|
import type { CurrentState } from '../../lib/reactivity/node-state/createCurrentState.ts';
|
|
@@ -20,20 +30,18 @@ import type {
|
|
|
20
30
|
} from '../../parse/model/RepeatRangeDefinition.ts';
|
|
21
31
|
import type {
|
|
22
32
|
AnyDescendantNode,
|
|
23
|
-
DescendantNodeParent,
|
|
24
33
|
DescendantNodeSharedStateSpec,
|
|
25
34
|
} from '../abstract/DescendantNode.ts';
|
|
26
35
|
import { DescendantNode } from '../abstract/DescendantNode.ts';
|
|
27
|
-
import type { RepeatRange } from '../hierarchy.ts';
|
|
28
|
-
import type { NodeID } from '../identity.ts';
|
|
36
|
+
import type { GeneralParentNode, RepeatRange } from '../hierarchy.ts';
|
|
29
37
|
import type { EvaluationContext } from '../internal-api/EvaluationContext.ts';
|
|
30
|
-
import type {
|
|
38
|
+
import type { ClientReactiveSubmittableParentNode } from '../internal-api/submission/ClientReactiveSubmittableParentNode.ts';
|
|
31
39
|
import { RepeatInstance, type RepeatDefinition } from './RepeatInstance.ts';
|
|
32
40
|
|
|
33
41
|
interface RepeatRangeStateSpec extends DescendantNodeSharedStateSpec {
|
|
34
42
|
readonly hint: null;
|
|
35
43
|
readonly label: Accessor<TextRange<'label'> | null>;
|
|
36
|
-
readonly children: Accessor<readonly
|
|
44
|
+
readonly children: Accessor<readonly FormNodeID[]>;
|
|
37
45
|
readonly valueOptions: null;
|
|
38
46
|
readonly value: null;
|
|
39
47
|
}
|
|
@@ -45,59 +53,48 @@ type BaseRepeatRangeNodeType<Definition extends AnyRepeatRangeDefinition> =
|
|
|
45
53
|
: 'repeat-range:uncontrolled';
|
|
46
54
|
|
|
47
55
|
export abstract class BaseRepeatRange<Definition extends AnyRepeatRangeDefinition>
|
|
48
|
-
extends DescendantNode<Definition, RepeatRangeStateSpec, RepeatInstance>
|
|
49
|
-
implements
|
|
56
|
+
extends DescendantNode<Definition, RepeatRangeStateSpec, GeneralParentNode, RepeatInstance>
|
|
57
|
+
implements
|
|
58
|
+
BaseRepeatRangeNode,
|
|
59
|
+
XFormsXPathNodeRange,
|
|
60
|
+
EvaluationContext,
|
|
61
|
+
ClientReactiveSubmittableParentNode<RepeatInstance>
|
|
50
62
|
{
|
|
63
|
+
protected readonly childrenState: ChildrenState<RepeatInstance>;
|
|
64
|
+
|
|
51
65
|
/**
|
|
52
66
|
* A repeat range doesn't have a corresponding primary instance element of its
|
|
53
|
-
* own
|
|
54
|
-
* creation of the initial primary instance state and DOM trees, we _could_
|
|
55
|
-
* reliably append all of the range's instances in order as the definition
|
|
56
|
-
* tree is recursed. But that would fail to handle some instance addition
|
|
57
|
-
* cases afterwards.
|
|
67
|
+
* own. It is represented in the following ways:
|
|
58
68
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* and appended during range initialization) in lieu of a nonexistent
|
|
66
|
-
* preceding instance's {@link contextNode}.
|
|
69
|
+
* - As a comment node (in terms of XPath semantics), immediately preceding
|
|
70
|
+
* the repeat range's {@link RepeatInstance | repeat instances} (if it
|
|
71
|
+
* presently has any; as a placeholder where they may be appended
|
|
72
|
+
* otherwise). This is necessary to support certain ODK XForms functionality
|
|
73
|
+
* where an expression is expected to be evaluated against "repeats" as a
|
|
74
|
+
* conceptual unit. Most typically, this includes:
|
|
67
75
|
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Range | DOM Range}
|
|
71
|
-
* instead?
|
|
72
|
-
*/
|
|
73
|
-
protected readonly anchorNode: Comment;
|
|
74
|
-
|
|
75
|
-
protected readonly childrenState: ChildrenState<RepeatInstance>;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Provides an {@link EvaluationContext} from which to evaluate expressions
|
|
79
|
-
* where some LocationPath sub-expressions may be **relative to the repeat
|
|
80
|
-
* range itself**. This is useful for evaluation of expressions where:
|
|
76
|
+
* - `jr:count` expressions associated with the repeat's body element
|
|
77
|
+
* - `relevant` bind computations associated with the repeat's nodeset
|
|
81
78
|
*
|
|
82
|
-
* -
|
|
83
|
-
* {@link
|
|
84
|
-
*
|
|
79
|
+
* - As a subtree with {@link RepeatInstance | repeat instance} **children**,
|
|
80
|
+
* in service of the client-facing {@link RepeatRangeNode} API (and with the
|
|
81
|
+
* same structural semantics internally)
|
|
85
82
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
*
|
|
83
|
+
* Ultimately, this means there is a fundamental impedance mismatch between
|
|
84
|
+
* two representations which are either necessary (XPath) or high value
|
|
85
|
+
* (providing a coherent mental model for clients and the engine
|
|
86
|
+
* implementation servicing that client-facing model).
|
|
87
|
+
*
|
|
88
|
+
* In recognition that this is a truly odd mix of inherent and incidental
|
|
89
|
+
* complexity, here we use the special {@link XFormsXPathNodeRangeKind}
|
|
90
|
+
* branded type as a dedicated point of (internal) documentation where the two
|
|
91
|
+
* models diverge.
|
|
95
92
|
*/
|
|
96
|
-
|
|
93
|
+
override readonly [XPathNodeKindKey]: XFormsXPathNodeRangeKind = XFORMS_XPATH_NODE_RANGE_KIND;
|
|
97
94
|
|
|
98
95
|
// InstanceNode
|
|
99
96
|
protected readonly state: SharedNodeState<RepeatRangeStateSpec>;
|
|
100
|
-
protected
|
|
97
|
+
protected readonly engineState: EngineState<RepeatRangeStateSpec>;
|
|
101
98
|
|
|
102
99
|
// DescendantNode
|
|
103
100
|
/**
|
|
@@ -108,49 +105,6 @@ export abstract class BaseRepeatRange<Definition extends AnyRepeatRangeDefinitio
|
|
|
108
105
|
*/
|
|
109
106
|
declare isSelfReadonly: Accessor<boolean>;
|
|
110
107
|
|
|
111
|
-
/**
|
|
112
|
-
* A repeat range does not exist in the primary instance tree. A `relevant`
|
|
113
|
-
* expression applies to each {@link RepeatInstance} child of the repeat
|
|
114
|
-
* range. Determining whether a repeat range itself "is relevant" isn't a
|
|
115
|
-
* concept the spec addresses, but it may be used by clients to determine
|
|
116
|
-
* whether to allow interaction with the range (e.g. by adding a repeat
|
|
117
|
-
* instance, or presenting the range's label when empty).
|
|
118
|
-
*
|
|
119
|
-
* As a naive first pass, it seems like the heuristic for this should be:
|
|
120
|
-
*
|
|
121
|
-
* 1. Does the repeat range have any repeat instance children?
|
|
122
|
-
*
|
|
123
|
-
* - If yes, go to 2.
|
|
124
|
-
* - If no, go to 3.
|
|
125
|
-
*
|
|
126
|
-
* 2. Does one or more of those children return `true` for the node's
|
|
127
|
-
* `relevant` expression (i.e. is the repeat instance "self relevant")?
|
|
128
|
-
*
|
|
129
|
-
* 3. Does the relevant expression return `true` for the repeat range itself
|
|
130
|
-
* (where, at least for now, the context of that evaluation would be the
|
|
131
|
-
* repeat range's {@link anchorNode} to ensure correct relative expressions
|
|
132
|
-
* resolve correctly)?
|
|
133
|
-
*
|
|
134
|
-
* @todo While (3) is proactively implemented, there isn't presently a test
|
|
135
|
-
* exercising it. It felt best for now to surface this for discussion in
|
|
136
|
-
* review to validate that it's going in the right direction.
|
|
137
|
-
*
|
|
138
|
-
* @todo While (2) **is actually tested**, the tests currently in place behave
|
|
139
|
-
* the same way with only the logic for (3), regardless of whether the repeat
|
|
140
|
-
* range actually has any repeat instance children. It's unclear (a) if that's
|
|
141
|
-
* a preferable simplification and (b) how that might affect performance (in
|
|
142
|
-
* theory it could vary depending on form structure and runtime state).
|
|
143
|
-
*/
|
|
144
|
-
override readonly isSelfRelevant: Accessor<boolean> = () => {
|
|
145
|
-
const instances = this.childrenState.getChildren();
|
|
146
|
-
|
|
147
|
-
if (instances.length > 0) {
|
|
148
|
-
return instances.some((instance) => instance.isSelfRelevant());
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return this.isEmptyRangeSelfRelevant();
|
|
152
|
-
};
|
|
153
|
-
|
|
154
108
|
// BaseRepeatRangeNode
|
|
155
109
|
abstract override readonly nodeType: BaseRepeatRangeNodeType<Definition>;
|
|
156
110
|
|
|
@@ -189,11 +143,15 @@ export abstract class BaseRepeatRange<Definition extends AnyRepeatRangeDefinitio
|
|
|
189
143
|
*/
|
|
190
144
|
abstract override readonly appearances: NodeAppearances<Definition>;
|
|
191
145
|
|
|
146
|
+
readonly nodeOptions = null;
|
|
147
|
+
|
|
192
148
|
readonly currentState: MaterializedChildren<CurrentState<RepeatRangeStateSpec>, RepeatInstance>;
|
|
193
149
|
|
|
194
150
|
abstract override readonly validationState: AncestorNodeValidationState;
|
|
195
151
|
|
|
196
|
-
|
|
152
|
+
readonly submissionState: SubmissionState;
|
|
153
|
+
|
|
154
|
+
constructor(parent: GeneralParentNode, definition: Definition) {
|
|
197
155
|
super(parent, definition);
|
|
198
156
|
|
|
199
157
|
const repeatRange = this as AnyDescendantNode as RepeatRange;
|
|
@@ -202,28 +160,6 @@ export abstract class BaseRepeatRange<Definition extends AnyRepeatRangeDefinitio
|
|
|
202
160
|
|
|
203
161
|
this.childrenState = childrenState;
|
|
204
162
|
|
|
205
|
-
this.anchorNode = this.contextNode.ownerDocument.createComment(
|
|
206
|
-
`Begin repeat range: ${definition.nodeset}`
|
|
207
|
-
);
|
|
208
|
-
this.contextNode.append(this.anchorNode);
|
|
209
|
-
|
|
210
|
-
this.selfEvaluationContext = {
|
|
211
|
-
scope: this.scope,
|
|
212
|
-
evaluator: this.evaluator,
|
|
213
|
-
root: this.root,
|
|
214
|
-
contextReference: this.contextReference,
|
|
215
|
-
contextNode: this.anchorNode,
|
|
216
|
-
|
|
217
|
-
getSubscribableDependenciesByReference: (reference) => {
|
|
218
|
-
return repeatRange.getSubscribableDependenciesByReference(reference);
|
|
219
|
-
},
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
this.isEmptyRangeSelfRelevant = createComputedExpression(
|
|
223
|
-
this.selfEvaluationContext,
|
|
224
|
-
definition.bind.relevant
|
|
225
|
-
);
|
|
226
|
-
|
|
227
163
|
const sharedStateOptions = {
|
|
228
164
|
clientStateFactory: this.engineConfig.stateFactory,
|
|
229
165
|
};
|
|
@@ -252,16 +188,13 @@ export abstract class BaseRepeatRange<Definition extends AnyRepeatRangeDefinitio
|
|
|
252
188
|
state.currentState,
|
|
253
189
|
childrenState
|
|
254
190
|
);
|
|
191
|
+
this.submissionState = createNodeRangeSubmissionState(this);
|
|
255
192
|
}
|
|
256
193
|
|
|
257
194
|
protected getLastIndex(): number {
|
|
258
195
|
return this.engineState.children.length - 1;
|
|
259
196
|
}
|
|
260
197
|
|
|
261
|
-
protected override initializeContextNode(parentContextNode: Element): Element {
|
|
262
|
-
return parentContextNode;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
198
|
getInstanceIndex(instance: RepeatInstance): number {
|
|
266
199
|
return this.engineState.children.indexOf(instance.nodeId);
|
|
267
200
|
}
|
|
@@ -289,9 +222,7 @@ export abstract class BaseRepeatRange<Definition extends AnyRepeatRangeDefinitio
|
|
|
289
222
|
|
|
290
223
|
return definitions.reduce<RepeatInstance[]>((acc, definition) => {
|
|
291
224
|
const precedingInstance = acc[acc.length - 1] ?? initialPrecedingInstance;
|
|
292
|
-
const precedingPrimaryInstanceNode = precedingInstance?.contextNode ?? this.anchorNode;
|
|
293
225
|
const newInstance = new RepeatInstance(repeatRange, definition, {
|
|
294
|
-
precedingPrimaryInstanceNode,
|
|
295
226
|
precedingInstance,
|
|
296
227
|
});
|
|
297
228
|
|
|
@@ -331,16 +262,6 @@ export abstract class BaseRepeatRange<Definition extends AnyRepeatRangeDefinitio
|
|
|
331
262
|
});
|
|
332
263
|
}
|
|
333
264
|
|
|
334
|
-
override subscribe(): void {
|
|
335
|
-
super.subscribe();
|
|
336
|
-
|
|
337
|
-
// Subscribing to children can support reactive expressions dependent on the
|
|
338
|
-
// repeat range itself (e.g. `count()`).
|
|
339
|
-
this.childrenState.getChildren().forEach((child) => {
|
|
340
|
-
child.subscribe();
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
|
|
344
265
|
getChildren(): readonly RepeatInstance[] {
|
|
345
266
|
return this.childrenState.getChildren();
|
|
346
267
|
}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
1
2
|
import type { Accessor } from 'solid-js';
|
|
2
3
|
import { createComputed, createSignal, on } from 'solid-js';
|
|
4
|
+
import type { FormNodeID } from '../../client/identity.ts';
|
|
3
5
|
import type {
|
|
4
6
|
RepeatDefinition,
|
|
5
7
|
RepeatInstanceNode,
|
|
6
8
|
RepeatInstanceNodeAppearances,
|
|
7
9
|
} from '../../client/repeat/RepeatInstanceNode.ts';
|
|
10
|
+
import type { SubmissionState } from '../../client/submission/SubmissionState.ts';
|
|
8
11
|
import type { TextRange } from '../../client/TextRange.ts';
|
|
9
12
|
import type { AncestorNodeValidationState } from '../../client/validation.ts';
|
|
13
|
+
import type { XFormsXPathElement } from '../../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
14
|
+
import { createParentNodeSubmissionState } from '../../lib/client-reactivity/submission/createParentNodeSubmissionState.ts';
|
|
10
15
|
import type { ChildrenState } from '../../lib/reactivity/createChildrenState.ts';
|
|
11
16
|
import { createChildrenState } from '../../lib/reactivity/createChildrenState.ts';
|
|
12
17
|
import type { MaterializedChildren } from '../../lib/reactivity/materializeCurrentStateChildren.ts';
|
|
@@ -20,36 +25,40 @@ import { createAggregatedViolations } from '../../lib/reactivity/validation/crea
|
|
|
20
25
|
import type { DescendantNodeSharedStateSpec } from '../abstract/DescendantNode.ts';
|
|
21
26
|
import { DescendantNode } from '../abstract/DescendantNode.ts';
|
|
22
27
|
import { buildChildren } from '../children.ts';
|
|
23
|
-
import type {
|
|
24
|
-
import type { NodeID } from '../identity.ts';
|
|
28
|
+
import type { GeneralChildNode, RepeatRange } from '../hierarchy.ts';
|
|
25
29
|
import type { EvaluationContext } from '../internal-api/EvaluationContext.ts';
|
|
26
|
-
import type {
|
|
30
|
+
import type { ClientReactiveSubmittableParentNode } from '../internal-api/submission/ClientReactiveSubmittableParentNode.ts';
|
|
27
31
|
|
|
28
32
|
export type { RepeatDefinition };
|
|
29
33
|
|
|
30
34
|
interface RepeatInstanceStateSpec extends DescendantNodeSharedStateSpec {
|
|
31
35
|
readonly label: Accessor<TextRange<'label'> | null>;
|
|
32
36
|
readonly hint: null;
|
|
33
|
-
readonly children: Accessor<readonly
|
|
37
|
+
readonly children: Accessor<readonly FormNodeID[]>;
|
|
34
38
|
readonly valueOptions: null;
|
|
35
39
|
readonly value: null;
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
interface RepeatInstanceOptions {
|
|
39
|
-
readonly precedingPrimaryInstanceNode: Comment | Element;
|
|
40
43
|
readonly precedingInstance: RepeatInstance | null;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
export class RepeatInstance
|
|
44
|
-
extends DescendantNode<RepeatDefinition, RepeatInstanceStateSpec, GeneralChildNode>
|
|
45
|
-
implements
|
|
47
|
+
extends DescendantNode<RepeatDefinition, RepeatInstanceStateSpec, RepeatRange, GeneralChildNode>
|
|
48
|
+
implements
|
|
49
|
+
RepeatInstanceNode,
|
|
50
|
+
XFormsXPathElement,
|
|
51
|
+
EvaluationContext,
|
|
52
|
+
ClientReactiveSubmittableParentNode<GeneralChildNode>
|
|
46
53
|
{
|
|
47
54
|
private readonly childrenState: ChildrenState<GeneralChildNode>;
|
|
48
55
|
private readonly currentIndex: Accessor<number>;
|
|
49
56
|
|
|
57
|
+
override readonly [XPathNodeKindKey] = 'element';
|
|
58
|
+
|
|
50
59
|
// InstanceNode
|
|
51
60
|
protected readonly state: SharedNodeState<RepeatInstanceStateSpec>;
|
|
52
|
-
protected
|
|
61
|
+
protected readonly engineState: EngineState<RepeatInstanceStateSpec>;
|
|
53
62
|
|
|
54
63
|
/**
|
|
55
64
|
* @todo Should we special case repeat `readonly` inheritance the same way
|
|
@@ -83,12 +92,14 @@ export class RepeatInstance
|
|
|
83
92
|
* @see {@link RepeatRange.appearances}
|
|
84
93
|
*/
|
|
85
94
|
readonly appearances: RepeatInstanceNodeAppearances;
|
|
95
|
+
readonly nodeOptions = null;
|
|
86
96
|
|
|
87
97
|
readonly currentState: MaterializedChildren<
|
|
88
98
|
CurrentState<RepeatInstanceStateSpec>,
|
|
89
99
|
GeneralChildNode
|
|
90
100
|
>;
|
|
91
101
|
readonly validationState: AncestorNodeValidationState;
|
|
102
|
+
readonly submissionState: SubmissionState;
|
|
92
103
|
|
|
93
104
|
constructor(
|
|
94
105
|
override readonly parent: RepeatRange,
|
|
@@ -113,9 +124,6 @@ export class RepeatInstance
|
|
|
113
124
|
const childrenState = createChildrenState<RepeatInstance, GeneralChildNode>(this);
|
|
114
125
|
|
|
115
126
|
this.childrenState = childrenState;
|
|
116
|
-
|
|
117
|
-
options.precedingPrimaryInstanceNode.after(this.contextNode);
|
|
118
|
-
|
|
119
127
|
this.currentIndex = currentIndex;
|
|
120
128
|
|
|
121
129
|
const sharedStateOptions = {
|
|
@@ -166,48 +174,15 @@ export class RepeatInstance
|
|
|
166
174
|
// other reactive implementations of specific XForms semantics)?
|
|
167
175
|
const computeCurrentIndex = parent.getInstanceIndex.bind(parent, this);
|
|
168
176
|
|
|
169
|
-
createComputed(on(computeCurrentIndex, setCurrentIndex, { defer: true }));
|
|
177
|
+
createComputed(on<number, number>(computeCurrentIndex, setCurrentIndex, { defer: true }));
|
|
170
178
|
});
|
|
171
179
|
|
|
172
180
|
childrenState.setChildren(buildChildren(this));
|
|
173
181
|
this.validationState = createAggregatedViolations(this, sharedStateOptions);
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
protected override initializeContextNode(parentContextNode: Element, nodeName: string): Element {
|
|
177
|
-
return this.createContextNode(parentContextNode, nodeName);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
override subscribe(): void {
|
|
181
|
-
super.subscribe();
|
|
182
|
-
this.currentIndex();
|
|
182
|
+
this.submissionState = createParentNodeSubmissionState(this);
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
getChildren(): readonly GeneralChildNode[] {
|
|
186
186
|
return this.childrenState.getChildren();
|
|
187
187
|
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Performs repeat instance node-specific removal logic, then general node
|
|
191
|
-
* removal logic, in that order:
|
|
192
|
-
*
|
|
193
|
-
* 1. At present, before any reactive state change is performed, the repeat
|
|
194
|
-
* instance's {@link contextNode} is removed from the primary instance's
|
|
195
|
-
* XML DOM backing store (which also removes any descendant nodes from that
|
|
196
|
-
* store, as a side effect). This behavior may become unnecessary if/when
|
|
197
|
-
* we phase out use of this XML DOM backing store. This should be peformed
|
|
198
|
-
* first, so that any following reactive logic which evaluates affected
|
|
199
|
-
* XPath expressions will be performed against a state consistent with the
|
|
200
|
-
* repeat instance's removal (and that of its XML DOM descendants).
|
|
201
|
-
*
|
|
202
|
-
* 2. Performs any remaining removal logic as defined in
|
|
203
|
-
* {@link DescendantNode.remove}.
|
|
204
|
-
*
|
|
205
|
-
* These removal steps **must also** occur before any update to the parent
|
|
206
|
-
* {@link RepeatRange}'s reactive children state.
|
|
207
|
-
*/
|
|
208
|
-
override remove(this: AnyChildNode): void {
|
|
209
|
-
this.contextNode.remove();
|
|
210
|
-
|
|
211
|
-
super.remove();
|
|
212
|
-
}
|
|
213
188
|
}
|
|
@@ -2,24 +2,22 @@ import { createComputed } from 'solid-js';
|
|
|
2
2
|
import type { RepeatRangeNodeAppearances } from '../../client/repeat/BaseRepeatRangeNode.ts';
|
|
3
3
|
import type { RepeatRangeControlledNode } from '../../client/repeat/RepeatRangeControlledNode.ts';
|
|
4
4
|
import type { AncestorNodeValidationState } from '../../client/validation.ts';
|
|
5
|
+
import type { XFormsXPathNodeRange } from '../../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
5
6
|
import { createComputedExpression } from '../../lib/reactivity/createComputedExpression.ts';
|
|
6
7
|
import { createAggregatedViolations } from '../../lib/reactivity/validation/createAggregatedViolations.ts';
|
|
7
8
|
import type { ControlledRepeatRangeDefinition } from '../../parse/model/RepeatRangeDefinition.ts';
|
|
8
9
|
import type { GeneralParentNode } from '../hierarchy.ts';
|
|
9
10
|
import type { EvaluationContext } from '../internal-api/EvaluationContext.ts';
|
|
10
|
-
import type { SubscribableDependency } from '../internal-api/SubscribableDependency.ts';
|
|
11
11
|
import { BaseRepeatRange } from './BaseRepeatRange.ts';
|
|
12
12
|
import type { RepeatDefinition } from './RepeatInstance.ts';
|
|
13
13
|
|
|
14
14
|
export class RepeatRangeControlled
|
|
15
15
|
extends BaseRepeatRange<ControlledRepeatRangeDefinition>
|
|
16
|
-
implements RepeatRangeControlledNode,
|
|
16
|
+
implements RepeatRangeControlledNode, XFormsXPathNodeRange, EvaluationContext
|
|
17
17
|
{
|
|
18
18
|
// RepeatRangeControlledNode
|
|
19
19
|
readonly nodeType = 'repeat-range:controlled';
|
|
20
|
-
|
|
21
20
|
readonly appearances: RepeatRangeNodeAppearances;
|
|
22
|
-
|
|
23
21
|
readonly validationState: AncestorNodeValidationState;
|
|
24
22
|
|
|
25
23
|
constructor(parent: GeneralParentNode, definition: ControlledRepeatRangeDefinition) {
|
|
@@ -37,7 +35,9 @@ export class RepeatRangeControlled
|
|
|
37
35
|
private initializeControlledChildrenState(definition: ControlledRepeatRangeDefinition): void {
|
|
38
36
|
this.scope.runTask(() => {
|
|
39
37
|
const { count, instances, template } = definition;
|
|
40
|
-
const computeCount = createComputedExpression(this
|
|
38
|
+
const computeCount = createComputedExpression(this, count, {
|
|
39
|
+
defaultValue: 0,
|
|
40
|
+
});
|
|
41
41
|
|
|
42
42
|
createComputed<number>((previousCount) => {
|
|
43
43
|
let currentCount = computeCount();
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import type { RepeatRangeNodeAppearances } from '../../client/repeat/BaseRepeatRangeNode.ts';
|
|
2
2
|
import type { RepeatRangeUncontrolledNode } from '../../client/repeat/RepeatRangeUncontrolledNode.ts';
|
|
3
3
|
import type { AncestorNodeValidationState } from '../../client/validation.ts';
|
|
4
|
+
import type { XFormsXPathNodeRange } from '../../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
4
5
|
import { createAggregatedViolations } from '../../lib/reactivity/validation/createAggregatedViolations.ts';
|
|
5
6
|
import type { UncontrolledRepeatRangeDefinition } from '../../parse/model/RepeatRangeDefinition.ts';
|
|
6
7
|
import type { GeneralParentNode } from '../hierarchy.ts';
|
|
7
8
|
import type { EvaluationContext } from '../internal-api/EvaluationContext.ts';
|
|
8
|
-
import type { SubscribableDependency } from '../internal-api/SubscribableDependency.ts';
|
|
9
9
|
import type { Root } from '../Root.ts';
|
|
10
10
|
import { BaseRepeatRange } from './BaseRepeatRange.ts';
|
|
11
11
|
import { RepeatInstance } from './RepeatInstance.ts';
|
|
12
12
|
|
|
13
13
|
export class RepeatRangeUncontrolled
|
|
14
14
|
extends BaseRepeatRange<UncontrolledRepeatRangeDefinition>
|
|
15
|
-
implements RepeatRangeUncontrolledNode,
|
|
15
|
+
implements RepeatRangeUncontrolledNode, XFormsXPathNodeRange, EvaluationContext
|
|
16
16
|
{
|
|
17
17
|
// RepeatRangeUncontrolledNode
|
|
18
18
|
readonly nodeType = 'repeat-range:uncontrolled';
|
|
19
|
-
|
|
20
19
|
readonly appearances: RepeatRangeNodeAppearances;
|
|
21
|
-
|
|
22
20
|
readonly validationState: AncestorNodeValidationState;
|
|
23
21
|
|
|
24
22
|
constructor(parent: GeneralParentNode, definition: UncontrolledRepeatRangeDefinition) {
|
package/src/instance/resource.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UnreachableError } from '@getodk/common/lib/error/UnreachableError.ts';
|
|
2
2
|
import { getBlobText } from '@getodk/common/lib/web-compat/blob.ts';
|
|
3
|
-
import type { FetchResource, FetchResourceResponse } from '../client/EngineConfig.ts';
|
|
4
3
|
import type { FormResource } from '../client/index.ts';
|
|
4
|
+
import type { FetchResource, FetchResourceResponse } from '../client/resources.ts';
|
|
5
5
|
|
|
6
6
|
export type { FetchResource, FetchResourceResponse, FormResource };
|
|
7
7
|
|
|
@@ -10,7 +10,10 @@ export interface ResourceOptions {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const fetchTextFromURL = async (resource: URL, options: ResourceOptions): Promise<string> => {
|
|
13
|
-
|
|
13
|
+
// destructuring prevents "Failed to execute 'fetch' on 'Window': Illegal invocation"
|
|
14
|
+
const { fetchResource } = options;
|
|
15
|
+
|
|
16
|
+
const response = await fetchResource(resource);
|
|
14
17
|
|
|
15
18
|
return response.text();
|
|
16
19
|
};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { UnsupportedControl } from '../abstract/UnsupportedControl.ts';
|
|
2
|
+
import type { ValueContext } from '../internal-api/ValueContext.ts';
|
|
2
3
|
|
|
3
|
-
export class UploadControl extends UnsupportedControl<'upload'> {
|
|
4
|
+
export class UploadControl extends UnsupportedControl<'upload'> implements ValueContext<unknown> {
|
|
4
5
|
readonly nodeType = 'upload';
|
|
6
|
+
|
|
7
|
+
// ValueContext
|
|
8
|
+
readonly contextNode = this;
|
|
5
9
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { XFormsItextTranslationMap, XFormsSecondaryInstanceMap } from '@getodk/xpath';
|
|
2
|
+
import { XFormsXPathEvaluator } from '@getodk/xpath';
|
|
3
|
+
import type { PrimaryInstance } from '../../instance/PrimaryInstance.ts';
|
|
4
|
+
import type { ItextTranslationRootDefinition } from '../../parse/model/ItextTranslation/ItextTranslationRootDefinition.ts';
|
|
5
|
+
import type { SecondaryInstanceRootDefinition } from '../../parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.ts';
|
|
6
|
+
import { engineDOMAdapter } from './adapter/engineDOMAdapter.ts';
|
|
7
|
+
import type { EngineXPathNode } from './adapter/kind.ts';
|
|
8
|
+
|
|
9
|
+
interface EngineXPathEvaluatorOptions {
|
|
10
|
+
readonly rootNode: PrimaryInstance;
|
|
11
|
+
readonly itextTranslationsByLanguage: XFormsItextTranslationMap<ItextTranslationRootDefinition>;
|
|
12
|
+
readonly secondaryInstancesById: XFormsSecondaryInstanceMap<SecondaryInstanceRootDefinition>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class EngineXPathEvaluator extends XFormsXPathEvaluator<EngineXPathNode> {
|
|
16
|
+
constructor(options: EngineXPathEvaluatorOptions) {
|
|
17
|
+
super({
|
|
18
|
+
domAdapter: engineDOMAdapter,
|
|
19
|
+
...options,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|