@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getodk/xforms-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "XForms engine for ODK Web Forms",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"README.md"
|
|
30
30
|
],
|
|
31
31
|
"engines": {
|
|
32
|
-
"node": "^18.20.
|
|
32
|
+
"node": "^18.20.5 || ^20.18.1 || ^22.12.0",
|
|
33
33
|
"yarn": "1.22.22"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
@@ -54,29 +54,34 @@
|
|
|
54
54
|
"test:types": "tsc --project ./tsconfig.json --emitDeclarationOnly false --noEmit"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"
|
|
57
|
+
"papaparse": "^5.4.1",
|
|
58
|
+
"solid-js": "^1.9.3"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
|
-
"@babel/core": "^7.
|
|
61
|
+
"@babel/core": "^7.26.0",
|
|
61
62
|
"@getodk/tree-sitter-xpath": "0.1.2",
|
|
62
|
-
"@getodk/xpath": "0.
|
|
63
|
-
"@playwright/test": "^1.
|
|
64
|
-
"@
|
|
63
|
+
"@getodk/xpath": "0.4.0",
|
|
64
|
+
"@playwright/test": "^1.49.1",
|
|
65
|
+
"@types/papaparse": "^5.3.15",
|
|
66
|
+
"@vitest/browser": "^2.1.8",
|
|
65
67
|
"babel-plugin-transform-jsbi-to-bigint": "^1.4.0",
|
|
66
68
|
"http-server": "^14.1.1",
|
|
67
|
-
"jsdom": "^25.0.
|
|
68
|
-
"typedoc": "^0.
|
|
69
|
-
"vite": "^5.4.
|
|
70
|
-
"vite-plugin-dts": "^4.
|
|
69
|
+
"jsdom": "^25.0.1",
|
|
70
|
+
"typedoc": "^0.27.5",
|
|
71
|
+
"vite": "^5.4.11",
|
|
72
|
+
"vite-plugin-dts": "^4.3.0",
|
|
71
73
|
"vite-plugin-no-bundle": "^4.0.0",
|
|
72
|
-
"vitest": "^2.
|
|
74
|
+
"vitest": "^2.1.8"
|
|
73
75
|
},
|
|
74
76
|
"peerDependencies": {
|
|
75
|
-
"solid-js": "^1.
|
|
77
|
+
"solid-js": "^1.9.3"
|
|
76
78
|
},
|
|
77
79
|
"peerDependenciesMeta": {
|
|
78
80
|
"solid-js": {
|
|
79
81
|
"optional": true
|
|
80
82
|
}
|
|
83
|
+
},
|
|
84
|
+
"publishConfig": {
|
|
85
|
+
"access": "public"
|
|
81
86
|
}
|
|
82
87
|
}
|
package/src/client/BaseNode.ts
CHANGED
|
@@ -3,7 +3,9 @@ import type { AnyNodeDefinition } from '../parse/model/NodeDefinition.ts';
|
|
|
3
3
|
import type { NodeAppearances } from './NodeAppearances.ts';
|
|
4
4
|
import type { OpaqueReactiveObjectFactory } from './OpaqueReactiveObjectFactory.ts';
|
|
5
5
|
import type { TextRange } from './TextRange.ts';
|
|
6
|
+
import type { FormNodeID } from './identity.ts';
|
|
6
7
|
import type { InstanceNodeType } from './node-types.ts';
|
|
8
|
+
import type { SubmissionState } from './submission/SubmissionState.ts';
|
|
7
9
|
import type {
|
|
8
10
|
AncestorNodeValidationState,
|
|
9
11
|
LeafNodeValidationState,
|
|
@@ -129,8 +131,6 @@ export interface BaseNodeState {
|
|
|
129
131
|
get value(): unknown;
|
|
130
132
|
}
|
|
131
133
|
|
|
132
|
-
type FormNodeID = string;
|
|
133
|
-
|
|
134
134
|
/**
|
|
135
135
|
* Base interface for common/shared aspects of any node type.
|
|
136
136
|
*/
|
|
@@ -153,6 +153,11 @@ export interface BaseNode {
|
|
|
153
153
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
154
154
|
readonly appearances: NodeAppearances<any> | null;
|
|
155
155
|
|
|
156
|
+
/**
|
|
157
|
+
* A node can have options that determine its behavior.
|
|
158
|
+
*/
|
|
159
|
+
readonly nodeOptions: object | null;
|
|
160
|
+
|
|
156
161
|
/**
|
|
157
162
|
* Each node has a definition which specifies aspects of the node defined in
|
|
158
163
|
* the form. These aspects include (but are not limited to) the node's data
|
|
@@ -189,15 +194,13 @@ export interface BaseNode {
|
|
|
189
194
|
// 2. If `parent` does become nullable state, how best to convey the same
|
|
190
195
|
// information for removed descendants. Some ideas:
|
|
191
196
|
//
|
|
192
|
-
// - Apply null-as-removed recursively.
|
|
193
|
-
// for the engine's current use of a DOM backing store (but that's an
|
|
194
|
-
// implementation detail clients don't/shouldn't care about).
|
|
197
|
+
// - Apply null-as-removed recursively.
|
|
195
198
|
//
|
|
196
199
|
// - Borrow the browser DOM's notion of node "connected"-ness. When a node
|
|
197
200
|
// is removed, its `isConnected` property is `false`. The same is true
|
|
198
201
|
// for any of its descendants, even though they retain their own direct
|
|
199
202
|
// parent reference.
|
|
200
|
-
readonly parent:
|
|
203
|
+
readonly parent: unknown;
|
|
201
204
|
|
|
202
205
|
/**
|
|
203
206
|
* Each node provides a discrete object representing the stateful aspects\* of
|
|
@@ -251,4 +254,16 @@ export interface BaseNode {
|
|
|
251
254
|
* clients to explicitly pause and resume recomputation.
|
|
252
255
|
*/
|
|
253
256
|
readonly validationState: NodeValidationState;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Represents the current submission state of the node.
|
|
260
|
+
*
|
|
261
|
+
* @see {@link SubmissionState.submissionXML} for additional detail.
|
|
262
|
+
*
|
|
263
|
+
* @todo Consider whether this can (should) be merged with
|
|
264
|
+
* {@link currentState}, while providing the same client-reactivity
|
|
265
|
+
* guarantees. (The challenge there is in defining client-reactive state which
|
|
266
|
+
* self-referentially derives state from its own definition.)
|
|
267
|
+
*/
|
|
268
|
+
readonly submissionState: SubmissionState;
|
|
254
269
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
2
|
+
import type { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
3
|
+
import type { GeneralParentNode } from './hierarchy.ts';
|
|
4
|
+
import type { LeafNodeType } from './node-types.ts';
|
|
5
|
+
import type { LeafNodeValidationState } from './validation.ts';
|
|
6
|
+
import type { ValueType } from './ValueType.ts';
|
|
7
|
+
|
|
8
|
+
export interface BaseValueNodeState<Value> extends BaseNodeState {
|
|
9
|
+
get children(): null;
|
|
10
|
+
get valueOptions(): unknown;
|
|
11
|
+
get value(): Value;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Reflects the serialized string representation of a {@link BaseValueNode}'s
|
|
15
|
+
* {@link value} state. This representation allows access to the node's value
|
|
16
|
+
* _as primary instance state_. In other words, this is the value which:
|
|
17
|
+
*
|
|
18
|
+
* - would be serialized as a text node in
|
|
19
|
+
* {@link SubmissionState.submissionXML} (note: this value is **NOT**
|
|
20
|
+
* escaped for XML serialization, as it is there)
|
|
21
|
+
*
|
|
22
|
+
* - is used when the node's value is referenced in any of a form's XPath
|
|
23
|
+
* expressions
|
|
24
|
+
*/
|
|
25
|
+
get instanceValue(): string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface BaseValueNode<V extends ValueType = ValueType, Value = string> extends BaseNode {
|
|
29
|
+
readonly nodeType: LeafNodeType;
|
|
30
|
+
readonly valueType: V;
|
|
31
|
+
readonly definition: LeafNodeDefinition;
|
|
32
|
+
readonly parent: GeneralParentNode;
|
|
33
|
+
readonly currentState: BaseValueNodeState<Value>;
|
|
34
|
+
readonly validationState: LeafNodeValidationState;
|
|
35
|
+
}
|
|
@@ -1,35 +1,7 @@
|
|
|
1
|
+
import type { initializeForm } from '../instance/index.ts';
|
|
2
|
+
import type { MissingResourceBehavior, MissingResourceBehaviorDefault } from './constants.ts';
|
|
1
3
|
import type { OpaqueReactiveObjectFactory } from './OpaqueReactiveObjectFactory.ts';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @todo this is currently a strict subset of the web standard `Response`. Is it
|
|
5
|
-
* sufficient? Ways it might not be:
|
|
6
|
-
*
|
|
7
|
-
* - No way to convey metadata about the resource
|
|
8
|
-
* - Ambiguous if a client supplies an alternative implementation which doesn't
|
|
9
|
-
* exhaust the body on access
|
|
10
|
-
*/
|
|
11
|
-
export interface FetchResourceResponse {
|
|
12
|
-
readonly ok?: boolean;
|
|
13
|
-
readonly body?: ReadableStream<Uint8Array> | null;
|
|
14
|
-
readonly bodyUsed?: boolean;
|
|
15
|
-
|
|
16
|
-
readonly blob: () => Promise<Blob>;
|
|
17
|
-
readonly text: () => Promise<string>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @todo this is a strict subset of the web standard `fetch` interface. It
|
|
22
|
-
* implicitly assumes that the engine itself will only ever issue `GET`-like
|
|
23
|
-
* requests. It also provides no further request-like semantics to the engine.
|
|
24
|
-
* This is presumed sufficient for now, but notably doesn't expose any notion of
|
|
25
|
-
* content negotiation (e.g. the ability to supply `Accept` headers).
|
|
26
|
-
*
|
|
27
|
-
* This also completely ignores any notion of mapping
|
|
28
|
-
* {@link https://getodk.github.io/xforms-spec/#uris | `jr:` URLs} to their
|
|
29
|
-
* actual resources (likely, but not necessarily, accessed at a corresponding
|
|
30
|
-
* HTTP URL).
|
|
31
|
-
*/
|
|
32
|
-
export type FetchResource = (resource: URL) => Promise<FetchResourceResponse>;
|
|
4
|
+
import type { FetchFormAttachment, FetchResource } from './resources.ts';
|
|
33
5
|
|
|
34
6
|
/**
|
|
35
7
|
* Options provided by a client to specify certain aspects of engine runtime
|
|
@@ -55,29 +27,58 @@ export interface EngineConfig {
|
|
|
55
27
|
readonly stateFactory?: OpaqueReactiveObjectFactory;
|
|
56
28
|
|
|
57
29
|
/**
|
|
58
|
-
* A client may specify a generic function for retrieving resources referenced
|
|
59
|
-
* by a form, such as:
|
|
60
30
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
31
|
+
* A client may specify an arbitrary {@link fetch}-like function for retrieving an XML XForm form
|
|
32
|
+
* definition.
|
|
33
|
+
*
|
|
34
|
+
* Notes:
|
|
35
|
+
*
|
|
36
|
+
* - This configuration will only be consuled for calls to
|
|
37
|
+
* {@link initializeForm} with a URL referencing an XML XForm definition. It
|
|
38
|
+
* will be ignored for calls passing an XML XForm form definition directly.
|
|
39
|
+
*
|
|
40
|
+
* - For calls to {@link initializeForm} with a URL, if this configuration is
|
|
41
|
+
* not specified it will default to the global {@link fetch} function (if
|
|
42
|
+
* one is defined).
|
|
43
|
+
*/
|
|
44
|
+
readonly fetchFormDefinition?: FetchResource;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A client may specify an arbitrary {@link fetch}-like function to retrieve a
|
|
48
|
+
* form's attachments, i.e. any `jr:` URL referenced by the form (as specified
|
|
49
|
+
* by {@link https://getodk.github.io/xforms-spec/ | ODK XForms}).
|
|
50
|
+
*
|
|
51
|
+
* Notes:
|
|
65
52
|
*
|
|
66
|
-
*
|
|
67
|
-
* {@link
|
|
68
|
-
* performing `GET` requests for:
|
|
53
|
+
* - This configuration will be consulted for all supported form attachments,
|
|
54
|
+
* as a part of {@link initializeForm | form initialization}.
|
|
69
55
|
*
|
|
70
|
-
* -
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
56
|
+
* - If this configuration is not specified it will default to the global
|
|
57
|
+
* {@link fetch} function (if one is defined).
|
|
58
|
+
*
|
|
59
|
+
* This default behavior will typically result in failure to load form
|
|
60
|
+
* attachments—and in most cases this will also cause
|
|
61
|
+
* {@link initializeForm | form initialization} to fail overall—with the
|
|
62
|
+
* following exceptions:
|
|
63
|
+
*
|
|
64
|
+
* - **CLIENT-SPECIFIC:** Usage in coordination with a client-implemented
|
|
65
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API | Serivce Worker},
|
|
66
|
+
* which can intercept network requests **generally**. Clients already using
|
|
67
|
+
* a Service Worker may opt for the convenience of handling network requests
|
|
68
|
+
* for `jr:` URLs along with any other network interception logic. Client
|
|
69
|
+
* implementors should be warned, however, that such `jr:` URLs are not
|
|
70
|
+
* namespaced or otherwise scoped to a particular form; such a client would
|
|
71
|
+
* therefore inherently need to coordinate state between the Service Worker
|
|
72
|
+
* and the main thread (or whatever other realm calls
|
|
73
|
+
* {@link initializeForm}).
|
|
74
|
+
*/
|
|
75
|
+
readonly fetchFormAttachment?: FetchFormAttachment;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @see {@link MissingResourceBehavior}
|
|
79
|
+
* @see {@link MissingResourceBehaviorDefault}
|
|
74
80
|
*
|
|
75
|
-
*
|
|
76
|
-
* retrieve any such resource, as required for engine functionality. If
|
|
77
|
-
* absent, the engine will use the native `fetch` function (if available, a
|
|
78
|
-
* polyfill otherwise). Clients may use this function to provide resources
|
|
79
|
-
* from sources other than the network, (or even in a test client to provide
|
|
80
|
-
* e.g. resources from test fixtures).
|
|
81
|
+
* @default MissingResourceBehaviorDefault
|
|
81
82
|
*/
|
|
82
|
-
readonly
|
|
83
|
+
readonly missingResourceBehavior?: MissingResourceBehavior;
|
|
83
84
|
}
|
package/src/client/GroupNode.ts
CHANGED
|
@@ -31,6 +31,7 @@ export type GroupNodeAppearances = NodeAppearances<GroupDefinition>;
|
|
|
31
31
|
export interface GroupNode extends BaseNode {
|
|
32
32
|
readonly nodeType: 'group';
|
|
33
33
|
readonly appearances: GroupNodeAppearances;
|
|
34
|
+
readonly nodeOptions: null;
|
|
34
35
|
readonly definition: GroupDefinition;
|
|
35
36
|
readonly root: RootNode;
|
|
36
37
|
readonly parent: GeneralParentNode;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { RuntimeInputValue, RuntimeValue } from '../lib/codecs/getSharedValueCodec.ts';
|
|
2
|
+
import type { InputControlDefinition } from '../parse/body/control/InputControlDefinition.ts';
|
|
3
|
+
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
4
|
+
import type { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
|
|
5
|
+
import type { NodeAppearances } from './NodeAppearances.ts';
|
|
6
|
+
import type { RootNode } from './RootNode.ts';
|
|
7
|
+
import type { ValueType } from './ValueType.ts';
|
|
8
|
+
import type { GeneralParentNode } from './hierarchy.ts';
|
|
9
|
+
import type { LeafNodeValidationState } from './validation.ts';
|
|
10
|
+
|
|
11
|
+
export type InputValue<V extends ValueType> = RuntimeValue<V>;
|
|
12
|
+
|
|
13
|
+
export type InputNodeInputValue<V extends ValueType> = RuntimeInputValue<V>;
|
|
14
|
+
|
|
15
|
+
export interface InputNodeState<V extends ValueType> extends BaseValueNodeState<InputValue<V>> {
|
|
16
|
+
get children(): null;
|
|
17
|
+
get valueOptions(): null;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Reflects the current value of a {@link InputNode}. This value may be
|
|
21
|
+
* populated when a form is loaded, and it may be updated by certain
|
|
22
|
+
* computations defined by the form. It may also be updated by a client, using
|
|
23
|
+
* the {@link InputNode.setValue} method.
|
|
24
|
+
*/
|
|
25
|
+
get value(): InputValue<V>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface InputDefinition<V extends ValueType = ValueType> extends LeafNodeDefinition<V> {
|
|
29
|
+
readonly bodyElement: InputControlDefinition;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type InputNodeAppearances = NodeAppearances<InputDefinition>;
|
|
33
|
+
|
|
34
|
+
interface StringInputNodeOptions {
|
|
35
|
+
readonly rows: number | null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface GeoInputNodeOptions {
|
|
39
|
+
readonly accuracyThreshold: number | null;
|
|
40
|
+
readonly unacceptableAccuracyThreshold: number | null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface InputNodeOptionsByValueType {
|
|
44
|
+
readonly string: StringInputNodeOptions;
|
|
45
|
+
readonly int: null;
|
|
46
|
+
readonly boolean: null;
|
|
47
|
+
readonly decimal: null;
|
|
48
|
+
readonly date: null;
|
|
49
|
+
readonly time: null;
|
|
50
|
+
readonly dateTime: null;
|
|
51
|
+
readonly geopoint: GeoInputNodeOptions;
|
|
52
|
+
readonly geotrace: GeoInputNodeOptions;
|
|
53
|
+
readonly geoshape: GeoInputNodeOptions;
|
|
54
|
+
readonly binary: null;
|
|
55
|
+
readonly barcode: null;
|
|
56
|
+
readonly intent: null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type InputNodeOptions<V extends ValueType> = InputNodeOptionsByValueType[V];
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* A node corresponding to form field defined as an
|
|
63
|
+
* {@link https://getodk.github.io/xforms-spec/#body-elements | XForms `<input>`},
|
|
64
|
+
* which a user-facing client would likely present for a user to fill.
|
|
65
|
+
*/
|
|
66
|
+
export interface InputNode<V extends ValueType = ValueType>
|
|
67
|
+
extends BaseValueNode<V, InputValue<V>> {
|
|
68
|
+
readonly nodeType: 'input';
|
|
69
|
+
readonly valueType: V;
|
|
70
|
+
readonly appearances: InputNodeAppearances;
|
|
71
|
+
readonly nodeOptions: InputNodeOptions<V>;
|
|
72
|
+
readonly definition: InputDefinition<V>;
|
|
73
|
+
readonly root: RootNode;
|
|
74
|
+
readonly parent: GeneralParentNode;
|
|
75
|
+
readonly currentState: InputNodeState<V>;
|
|
76
|
+
readonly validationState: LeafNodeValidationState;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* For use by a client to update the value of an {@link InputNode}.
|
|
80
|
+
*/
|
|
81
|
+
setValue(value: InputNodeInputValue<V>): RootNode;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export type StringInputValue = InputValue<'string'>;
|
|
85
|
+
export type IntInputValue = InputValue<'int'>;
|
|
86
|
+
export type DecimalInputValue = InputValue<'decimal'>;
|
|
87
|
+
export type GeopointInputValue = InputValue<'geopoint'>;
|
|
88
|
+
|
|
89
|
+
export type StringInputNode = InputNode<'string'>;
|
|
90
|
+
export type IntInputNode = InputNode<'int'>;
|
|
91
|
+
export type DecimalInputNode = InputNode<'decimal'>;
|
|
92
|
+
export type GeopointInputNode = InputNode<'geopoint'>;
|
|
93
|
+
|
|
94
|
+
// prettier-ignore
|
|
95
|
+
type SupportedInputValueType =
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
97
|
+
| 'string'
|
|
98
|
+
| 'int'
|
|
99
|
+
| 'decimal'
|
|
100
|
+
| 'geopoint';
|
|
101
|
+
|
|
102
|
+
type TemporaryStringValueType = Exclude<ValueType, SupportedInputValueType>;
|
|
103
|
+
|
|
104
|
+
export type TemporaryStringValueInputNode = InputNode<TemporaryStringValueType>;
|
|
105
|
+
|
|
106
|
+
// prettier-ignore
|
|
107
|
+
export type AnyInputNode =
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
109
|
+
| StringInputNode
|
|
110
|
+
| IntInputNode
|
|
111
|
+
| DecimalInputNode
|
|
112
|
+
| GeopointInputNode
|
|
113
|
+
| TemporaryStringValueInputNode;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import type { RuntimeValue } from '../lib/codecs/getSharedValueCodec.ts';
|
|
1
2
|
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
2
|
-
import type {
|
|
3
|
+
import type { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
|
|
3
4
|
import type { GeneralParentNode } from './hierarchy.ts';
|
|
4
5
|
import type { RootNode } from './RootNode.ts';
|
|
5
6
|
import type { LeafNodeValidationState } from './validation.ts';
|
|
7
|
+
import type { ValueType } from './ValueType.ts';
|
|
6
8
|
|
|
7
|
-
export
|
|
9
|
+
export type ModelValue<V extends ValueType> = RuntimeValue<V>;
|
|
10
|
+
|
|
11
|
+
export interface ModelValueNodeState<V extends ValueType>
|
|
12
|
+
extends BaseValueNodeState<ModelValue<V>> {
|
|
8
13
|
get label(): null;
|
|
9
14
|
get hint(): null;
|
|
10
15
|
get children(): null;
|
|
@@ -15,10 +20,11 @@ export interface ModelValueNodeState extends BaseNodeState {
|
|
|
15
20
|
* populated when a form is loaded, and it may be updated by certain
|
|
16
21
|
* computations defined by the form.
|
|
17
22
|
*/
|
|
18
|
-
get value():
|
|
23
|
+
get value(): ModelValue<V>;
|
|
19
24
|
}
|
|
20
25
|
|
|
21
|
-
export interface ModelValueDefinition extends
|
|
26
|
+
export interface ModelValueDefinition<V extends ValueType = ValueType>
|
|
27
|
+
extends LeafNodeDefinition<V> {
|
|
22
28
|
readonly bodyElement: null;
|
|
23
29
|
}
|
|
24
30
|
|
|
@@ -29,12 +35,30 @@ export interface ModelValueDefinition extends LeafNodeDefinition {
|
|
|
29
35
|
* - a leaf/value node (i.e. it has no element children; it may be defined in
|
|
30
36
|
* the form's `<model>` as either an {@link Element} or {@link Attr})
|
|
31
37
|
*/
|
|
32
|
-
export interface ModelValueNode extends
|
|
38
|
+
export interface ModelValueNode<V extends ValueType = ValueType>
|
|
39
|
+
extends BaseValueNode<V, ModelValue<V>> {
|
|
33
40
|
readonly nodeType: 'model-value';
|
|
41
|
+
readonly valueType: V;
|
|
34
42
|
readonly appearances: null;
|
|
35
|
-
readonly
|
|
43
|
+
readonly nodeOptions: null;
|
|
44
|
+
readonly definition: ModelValueDefinition<V>;
|
|
36
45
|
readonly root: RootNode;
|
|
37
46
|
readonly parent: GeneralParentNode;
|
|
38
|
-
readonly currentState: ModelValueNodeState
|
|
47
|
+
readonly currentState: ModelValueNodeState<V>;
|
|
39
48
|
readonly validationState: LeafNodeValidationState;
|
|
40
49
|
}
|
|
50
|
+
|
|
51
|
+
export type AnyModelValueNode =
|
|
52
|
+
| ModelValueNode<'barcode'>
|
|
53
|
+
| ModelValueNode<'binary'>
|
|
54
|
+
| ModelValueNode<'boolean'>
|
|
55
|
+
| ModelValueNode<'date'>
|
|
56
|
+
| ModelValueNode<'dateTime'>
|
|
57
|
+
| ModelValueNode<'decimal'>
|
|
58
|
+
| ModelValueNode<'geopoint'>
|
|
59
|
+
| ModelValueNode<'geoshape'>
|
|
60
|
+
| ModelValueNode<'geotrace'>
|
|
61
|
+
| ModelValueNode<'int'>
|
|
62
|
+
| ModelValueNode<'intent'>
|
|
63
|
+
| ModelValueNode<'string'>
|
|
64
|
+
| ModelValueNode<'time'>;
|
package/src/client/NoteNode.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NoteRuntimeValue } from '../lib/codecs/NoteCodec.ts';
|
|
2
|
+
import type { InputControlDefinition } from '../parse/body/control/InputControlDefinition.ts';
|
|
2
3
|
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
3
|
-
import type {
|
|
4
|
+
import type { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
|
|
4
5
|
import type { GeneralParentNode } from './hierarchy.ts';
|
|
5
6
|
import type { NodeAppearances } from './NodeAppearances.ts';
|
|
6
7
|
import type { RootNode } from './RootNode.ts';
|
|
7
8
|
import type { TextRange } from './TextRange.ts';
|
|
8
9
|
import type { LeafNodeValidationState } from './validation.ts';
|
|
10
|
+
import type { ValueType } from './ValueType.ts';
|
|
9
11
|
|
|
10
|
-
export
|
|
12
|
+
export type NoteValue<V extends ValueType> = NoteRuntimeValue<V>;
|
|
13
|
+
|
|
14
|
+
export interface NoteNodeState<V extends ValueType> extends BaseValueNodeState<NoteValue<V>> {
|
|
11
15
|
/**
|
|
12
16
|
* Note-specific specialization: a note will always have a non-null value in
|
|
13
17
|
* at least one of:
|
|
@@ -48,11 +52,11 @@ export interface NoteNodeState extends BaseNodeState {
|
|
|
48
52
|
// node types, specifically to make a clear distinction between blank and
|
|
49
53
|
// non-blank values (as that has been a primary driver for prioritizing note
|
|
50
54
|
// functionality).
|
|
51
|
-
get value():
|
|
55
|
+
get value(): NoteValue<V>;
|
|
52
56
|
}
|
|
53
57
|
|
|
54
|
-
export interface NoteDefinition extends LeafNodeDefinition {
|
|
55
|
-
readonly bodyElement:
|
|
58
|
+
export interface NoteDefinition<V extends ValueType = ValueType> extends LeafNodeDefinition<V> {
|
|
59
|
+
readonly bodyElement: InputControlDefinition;
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
export type NoteNodeAppearances = NodeAppearances<NoteDefinition>;
|
|
@@ -63,12 +67,44 @@ export type NoteNodeAppearances = NodeAppearances<NoteDefinition>;
|
|
|
63
67
|
* - associated with an input, with at least one text element (label or hint)
|
|
64
68
|
* - guaranteed to be {@link NoteNodeState.readonly | readonly}
|
|
65
69
|
*/
|
|
66
|
-
export interface NoteNode extends
|
|
70
|
+
export interface NoteNode<V extends ValueType = ValueType> extends BaseValueNode<V, NoteValue<V>> {
|
|
67
71
|
readonly nodeType: 'note';
|
|
68
72
|
readonly appearances: NoteNodeAppearances;
|
|
69
|
-
readonly
|
|
73
|
+
readonly nodeOptions: null;
|
|
74
|
+
readonly definition: NoteDefinition<V>;
|
|
70
75
|
readonly root: RootNode;
|
|
71
76
|
readonly parent: GeneralParentNode;
|
|
72
|
-
readonly currentState: NoteNodeState
|
|
77
|
+
readonly currentState: NoteNodeState<V>;
|
|
73
78
|
readonly validationState: LeafNodeValidationState;
|
|
74
79
|
}
|
|
80
|
+
|
|
81
|
+
export type StringNoteValue = NoteValue<'string'>;
|
|
82
|
+
export type IntNoteValue = NoteValue<'int'>;
|
|
83
|
+
export type DecimalNoteValue = NoteValue<'decimal'>;
|
|
84
|
+
export type GeopointNoteValue = NoteValue<'geopoint'>;
|
|
85
|
+
|
|
86
|
+
export type StringNoteNode = NoteNode<'string'>;
|
|
87
|
+
export type IntNoteNode = NoteNode<'int'>;
|
|
88
|
+
export type DecimalNoteNode = NoteNode<'decimal'>;
|
|
89
|
+
export type GeopointNoteNode = NoteNode<'geopoint'>;
|
|
90
|
+
|
|
91
|
+
// prettier-ignore
|
|
92
|
+
type SupportedNoteValueType =
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
94
|
+
| 'string'
|
|
95
|
+
| 'int'
|
|
96
|
+
| 'decimal'
|
|
97
|
+
| 'geopoint';
|
|
98
|
+
|
|
99
|
+
type TemporaryStringValueType = Exclude<ValueType, SupportedNoteValueType>;
|
|
100
|
+
|
|
101
|
+
export type TemporaryStringValueNoteNode = NoteNode<TemporaryStringValueType>;
|
|
102
|
+
|
|
103
|
+
// prettier-ignore
|
|
104
|
+
export type AnyNoteNode =
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
106
|
+
| StringNoteNode
|
|
107
|
+
| IntNoteNode
|
|
108
|
+
| DecimalNoteNode
|
|
109
|
+
| GeopointNoteNode
|
|
110
|
+
| TemporaryStringValueNoteNode;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { RuntimeInputValue, RuntimeValue } from '../lib/codecs/getSharedValueCodec.ts';
|
|
2
|
+
import type { RangeNodeDefinition, RangeValueType } from '../parse/model/RangeNodeDefinition.ts';
|
|
3
|
+
import type { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
|
|
4
|
+
import type { NodeAppearances } from './NodeAppearances.ts';
|
|
5
|
+
import type { RootNode } from './RootNode.ts';
|
|
6
|
+
import type { GeneralParentNode } from './hierarchy.ts';
|
|
7
|
+
import type { LeafNodeValidationState } from './validation.ts';
|
|
8
|
+
|
|
9
|
+
export type { RangeValueType };
|
|
10
|
+
|
|
11
|
+
export type RangeValue<V extends RangeValueType> = RuntimeValue<V>;
|
|
12
|
+
|
|
13
|
+
export type RangeInputValue<V extends RangeValueType> = RuntimeInputValue<V>;
|
|
14
|
+
|
|
15
|
+
export interface RangeNodeState<V extends RangeValueType>
|
|
16
|
+
extends BaseValueNodeState<RangeValue<V>> {
|
|
17
|
+
get valueOptions(): null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type RangeNodeAppearances = NodeAppearances<RangeNodeDefinition>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A node corresponding to form field defined as an
|
|
24
|
+
* {@link https://getodk.github.io/xforms-spec/#body-elements | XForms `<range>`}.
|
|
25
|
+
*/
|
|
26
|
+
export interface RangeNode<V extends RangeValueType = RangeValueType>
|
|
27
|
+
extends BaseValueNode<V, RangeValue<V>> {
|
|
28
|
+
readonly nodeType: 'range';
|
|
29
|
+
readonly valueType: V;
|
|
30
|
+
readonly appearances: RangeNodeAppearances;
|
|
31
|
+
readonly nodeOptions: null;
|
|
32
|
+
readonly definition: RangeNodeDefinition<V>;
|
|
33
|
+
readonly root: RootNode;
|
|
34
|
+
readonly parent: GeneralParentNode;
|
|
35
|
+
readonly currentState: RangeNodeState<V>;
|
|
36
|
+
readonly validationState: LeafNodeValidationState;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* For use by a client to update the value of an {@link RangeNode}.
|
|
40
|
+
*/
|
|
41
|
+
setValue(value: RangeInputValue<V>): RootNode;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type IntRangeNode = RangeNode<'int'>;
|
|
45
|
+
export type DecimalRangeNode = RangeNode<'decimal'>;
|
|
46
|
+
|
|
47
|
+
// prettier-ignore
|
|
48
|
+
export type AnyRangeNode =
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
50
|
+
| IntRangeNode
|
|
51
|
+
| DecimalRangeNode;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { RankControlDefinition } from '../parse/body/control/RankControlDefinition.ts';
|
|
2
|
+
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
3
|
+
import type { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
|
|
4
|
+
import type { RootNode } from './RootNode.ts';
|
|
5
|
+
import type { TextRange } from './TextRange.ts';
|
|
6
|
+
import type { GeneralParentNode } from './hierarchy.ts';
|
|
7
|
+
import type { LeafNodeValidationState } from './validation.ts';
|
|
8
|
+
import type { UnknownAppearanceDefinition } from '../parse/body/appearance/unknownAppearanceParser.ts';
|
|
9
|
+
import type { ValueType } from './ValueType.ts';
|
|
10
|
+
|
|
11
|
+
export interface RankItem {
|
|
12
|
+
get label(): TextRange<'item-label'>;
|
|
13
|
+
get value(): string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type RankValueOptions = readonly RankItem[];
|
|
17
|
+
|
|
18
|
+
export interface RankNodeState extends BaseValueNodeState<readonly string[]> {
|
|
19
|
+
get valueOptions(): RankValueOptions;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* An ordered collection of values from {@link RankItem}.
|
|
23
|
+
* The order of the items is important and must be preserved during processing.
|
|
24
|
+
*/
|
|
25
|
+
get value(): readonly string[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface RankDefinition<V extends ValueType = ValueType> extends LeafNodeDefinition<V> {
|
|
29
|
+
readonly bodyElement: RankControlDefinition;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface RankNode extends BaseValueNode<'string', readonly string[]> {
|
|
33
|
+
readonly nodeType: 'rank';
|
|
34
|
+
readonly appearances: UnknownAppearanceDefinition;
|
|
35
|
+
readonly nodeOptions: null;
|
|
36
|
+
readonly valueType: 'string';
|
|
37
|
+
readonly definition: RankDefinition<'string'>;
|
|
38
|
+
readonly root: RootNode;
|
|
39
|
+
readonly parent: GeneralParentNode;
|
|
40
|
+
readonly currentState: RankNodeState;
|
|
41
|
+
readonly validationState: LeafNodeValidationState;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Convenience API to get the {@link RankItem}'s label.
|
|
45
|
+
*/
|
|
46
|
+
getValueLabel(value: string): TextRange<'item-label'> | null;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Set the value which is an ordered collection of values from {@link RankItem}.
|
|
50
|
+
* Calling this setter replaces the currently value.
|
|
51
|
+
* If called with an empty array, the current is cleared.
|
|
52
|
+
*/
|
|
53
|
+
setValues(values: readonly string[]): RootNode;
|
|
54
|
+
}
|