@getodk/xforms-engine 0.5.0 → 0.7.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 +8 -4
- package/dist/client/BaseValueNode.d.ts +8 -4
- package/dist/client/GroupNode.d.ts +1 -0
- package/dist/client/InputNode.d.ts +32 -3
- package/dist/client/ModelValueNode.d.ts +1 -0
- package/dist/client/NoteNode.d.ts +24 -7
- package/dist/client/RangeNode.d.ts +36 -0
- package/dist/client/RankNode.d.ts +46 -0
- package/dist/client/RootNode.d.ts +21 -14
- 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/constants.d.ts +11 -12
- package/dist/client/form/CreateFormInstance.d.ts +14 -0
- package/dist/client/form/EditFormInstance.d.ts +62 -0
- package/dist/client/form/FormInstance.d.ts +104 -0
- package/dist/client/form/FormInstanceConfig.d.ts +17 -0
- package/dist/client/form/FormResource.d.ts +1 -0
- package/dist/client/form/LoadForm.d.ts +79 -0
- package/dist/client/form/LoadFormResult.d.ts +67 -0
- package/dist/client/form/RestoreFormInstance.d.ts +8 -0
- package/dist/client/hierarchy.d.ts +5 -5
- package/dist/client/index.d.ts +37 -11
- package/dist/client/node-types.d.ts +2 -2
- package/dist/client/repeat/BaseRepeatRangeNode.d.ts +3 -4
- package/dist/client/repeat/RepeatInstanceNode.d.ts +4 -5
- package/dist/client/repeat/RepeatRangeControlledNode.d.ts +2 -2
- package/dist/client/repeat/RepeatRangeUncontrolledNode.d.ts +2 -2
- package/dist/client/resources.d.ts +1 -1
- package/dist/client/serialization/InstanceData.d.ts +12 -0
- package/dist/client/serialization/InstanceFile.d.ts +6 -0
- package/dist/client/serialization/InstancePayload.d.ts +93 -0
- package/dist/client/serialization/InstancePayloadOptions.d.ts +23 -0
- package/dist/client/serialization/InstanceState.d.ts +12 -0
- package/dist/client/submission/{SubmissionDefinition.d.ts → SubmissionMeta.d.ts} +1 -1
- package/dist/client/unsupported/UnsupportedControlNode.d.ts +1 -3
- package/dist/entrypoints/FormInstance.d.ts +20 -0
- package/dist/entrypoints/FormResult/BaseFormResult.d.ts +22 -0
- package/dist/entrypoints/FormResult/BaseInstantiableFormResult.d.ts +25 -0
- package/dist/entrypoints/FormResult/FormFailureResult.d.ts +17 -0
- package/dist/entrypoints/FormResult/FormSuccessResult.d.ts +15 -0
- package/dist/entrypoints/FormResult/FormWarningResult.d.ts +15 -0
- package/dist/entrypoints/createInstance.d.ts +9 -0
- package/dist/entrypoints/editInstance.d.ts +9 -0
- package/dist/entrypoints/index.d.ts +4 -0
- package/dist/entrypoints/loadForm.d.ts +4 -0
- package/dist/entrypoints/restoreInstance.d.ts +9 -0
- package/dist/error/LoadFormFailureError.d.ts +9 -0
- package/dist/error/MalformedInstanceDataError.d.ts +3 -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/TemplatedNodeAttributeSerializationError.d.ts +22 -0
- package/dist/error/XFormsSpecViolationError.d.ts +2 -0
- package/dist/index.d.ts +2 -34
- package/dist/index.js +7274 -5840
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +7 -5
- package/dist/instance/InputControl.d.ts +9 -6
- package/dist/instance/ModelValue.d.ts +7 -4
- package/dist/instance/Note.d.ts +14 -25
- package/dist/instance/PrimaryInstance.d.ts +36 -8
- package/dist/instance/RangeControl.d.ts +35 -0
- package/dist/instance/RankControl.d.ts +41 -0
- package/dist/instance/Root.d.ts +8 -9
- package/dist/instance/SelectControl.d.ts +67 -0
- package/dist/instance/Subtree.d.ts +7 -5
- package/dist/instance/TriggerControl.d.ts +10 -22
- package/dist/instance/abstract/DescendantNode.d.ts +11 -3
- package/dist/instance/abstract/InstanceNode.d.ts +10 -5
- package/dist/instance/abstract/ValueNode.d.ts +7 -6
- package/dist/instance/children/DescendantNodeInitOptions.d.ts +32 -0
- package/dist/instance/{children.d.ts → children/buildChildren.d.ts} +1 -1
- package/dist/instance/children/childrenInitOptions.d.ts +9 -0
- package/dist/instance/children/normalizeChildInitOptions.d.ts +2 -0
- package/dist/instance/hierarchy.d.ts +9 -9
- package/dist/instance/input/InitialInstanceState.d.ts +13 -0
- package/dist/instance/input/InstanceAttachmentMap.d.ts +19 -0
- package/dist/instance/internal-api/InstanceConfig.d.ts +2 -9
- package/dist/instance/internal-api/InstanceValueContext.d.ts +10 -1
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableInstance.d.ts +14 -0
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableLeafNode.d.ts +32 -0
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableParentNode.d.ts +18 -0
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableTemplatedNode.d.ts +13 -0
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableValueNode.d.ts +21 -0
- package/dist/instance/repeat/BaseRepeatRange.d.ts +11 -8
- package/dist/instance/repeat/RepeatInstance.d.ts +11 -7
- package/dist/instance/repeat/RepeatRangeControlled.d.ts +27 -3
- package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +4 -3
- package/dist/instance/resource.d.ts +5 -1
- package/dist/instance/unsupported/UploadControl.d.ts +32 -4
- package/dist/integration/xpath/EngineXPathEvaluator.d.ts +2 -2
- package/dist/integration/xpath/adapter/kind.d.ts +4 -10
- package/dist/integration/xpath/adapter/names.d.ts +1 -11
- package/dist/integration/xpath/adapter/traversal.d.ts +10 -9
- package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +10 -4
- package/dist/integration/xpath/static-dom/StaticDocument.d.ts +13 -11
- package/dist/integration/xpath/static-dom/StaticElement.d.ts +25 -18
- package/dist/integration/xpath/static-dom/StaticNode.d.ts +1 -1
- package/dist/integration/xpath/static-dom/StaticParentNode.d.ts +13 -0
- package/dist/integration/xpath/static-dom/staticNodeName.d.ts +3 -0
- package/dist/lib/client-reactivity/instance-state/createNodeRangeInstanceState.d.ts +4 -0
- package/dist/lib/client-reactivity/instance-state/createParentNodeInstanceState.d.ts +4 -0
- package/dist/lib/client-reactivity/instance-state/createPrimaryInstanceState.d.ts +3 -0
- package/dist/lib/client-reactivity/instance-state/createRootInstanceState.d.ts +3 -0
- package/dist/lib/client-reactivity/instance-state/createTemplatedNodeInstanceState.d.ts +6 -0
- package/dist/lib/client-reactivity/instance-state/createValueNodeInstanceState.d.ts +3 -0
- package/dist/lib/client-reactivity/instance-state/prepareInstancePayload.d.ts +8 -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/NoteCodec.d.ts +8 -0
- package/dist/lib/codecs/RangeCodec.d.ts +8 -0
- package/dist/lib/codecs/TempUnsupportedControlCodec.d.ts +7 -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 +2 -2
- 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 +3 -2
- 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 +1 -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/names/UnprefixedXFormsName.d.ts +4 -0
- package/dist/lib/number-parsers.d.ts +2 -0
- package/dist/lib/reactivity/createInstanceValueState.d.ts +2 -27
- package/dist/lib/reactivity/createItemCollection.d.ts +21 -0
- package/dist/lib/xml-serialization.d.ts +11 -2
- package/dist/parse/XFormDOM.d.ts +1 -1
- package/dist/parse/body/BodyDefinition.d.ts +2 -2
- package/dist/parse/body/appearance/rangeAppearanceParser.d.ts +3 -0
- package/dist/parse/body/control/InputControlDefinition.d.ts +3 -0
- 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/model/BindDefinition.d.ts +3 -1
- package/dist/parse/model/BindPreloadDefinition.d.ts +42 -0
- package/dist/parse/model/DescendentNodeDefinition.d.ts +4 -13
- package/dist/parse/model/ItextTranslationsDefinition.d.ts +18 -0
- package/dist/parse/model/LeafNodeDefinition.d.ts +9 -7
- package/dist/parse/model/ModelDefinition.d.ts +9 -2
- package/dist/parse/model/NodeDefinition.d.ts +30 -45
- package/dist/parse/model/NoteNodeDefinition.d.ts +7 -5
- package/dist/parse/model/RangeNodeDefinition.d.ts +42 -0
- package/dist/parse/model/RepeatDefinition.d.ts +62 -0
- package/dist/parse/model/RootAttributeDefinition.d.ts +21 -0
- package/dist/parse/model/RootAttributeMap.d.ts +24 -0
- package/dist/parse/model/RootDefinition.d.ts +15 -14
- package/dist/parse/model/SecondaryInstance/SecondaryInstancesDefinition.d.ts +15 -2
- package/dist/parse/model/SecondaryInstance/assertSecondaryInstanceDefinition.d.ts +5 -0
- package/dist/parse/model/SecondaryInstance/defineSecondaryInstance.d.ts +5 -0
- package/dist/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.d.ts +1 -7
- package/dist/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.d.ts +1 -1
- package/dist/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.d.ts +1 -1
- package/dist/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.d.ts +1 -1
- package/dist/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.d.ts +1 -1
- package/dist/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.d.ts +1 -1
- package/dist/parse/model/{FormSubmissionDefinition.d.ts → SubmissionDefinition.d.ts} +2 -2
- package/dist/parse/model/SubtreeDefinition.d.ts +9 -7
- package/dist/parse/model/nodeDefinitionMap.d.ts +5 -0
- package/dist/parse/shared/parseInstanceXML.d.ts +21 -0
- package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +4 -22
- 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/xpath/semantic-analysis.d.ts +1 -3
- package/dist/solid.js +7247 -5813
- package/dist/solid.js.map +1 -1
- package/package.json +15 -12
- package/src/client/BaseNode.ts +9 -4
- package/src/client/BaseValueNode.ts +8 -4
- package/src/client/GroupNode.ts +1 -0
- package/src/client/InputNode.ts +38 -2
- package/src/client/ModelValueNode.ts +1 -0
- package/src/client/NoteNode.ts +43 -7
- package/src/client/RangeNode.ts +51 -0
- package/src/client/RankNode.ts +54 -0
- package/src/client/RootNode.ts +30 -16
- package/src/client/SelectNode.ts +53 -26
- package/src/client/SubtreeNode.ts +1 -0
- package/src/client/TriggerNode.ts +12 -6
- package/src/client/constants.ts +12 -14
- package/src/client/form/CreateFormInstance.ts +19 -0
- package/src/client/form/EditFormInstance.ts +93 -0
- package/src/client/form/FormInstance.ts +114 -0
- package/src/client/form/FormInstanceConfig.ts +18 -0
- package/src/client/form/FormResource.ts +1 -0
- package/src/client/form/LoadForm.ts +92 -0
- package/src/client/form/LoadFormResult.ts +103 -0
- package/src/client/form/RestoreFormInstance.ts +14 -0
- package/src/client/hierarchy.ts +7 -8
- package/src/client/index.ts +47 -29
- package/src/client/node-types.ts +3 -5
- package/src/client/repeat/BaseRepeatRangeNode.ts +3 -4
- package/src/client/repeat/RepeatInstanceNode.ts +4 -8
- package/src/client/repeat/RepeatRangeControlledNode.ts +2 -2
- package/src/client/repeat/RepeatRangeUncontrolledNode.ts +2 -2
- package/src/client/resources.ts +2 -2
- package/src/client/serialization/InstanceData.ts +16 -0
- package/src/client/serialization/InstanceFile.ts +9 -0
- package/src/client/serialization/InstancePayload.ts +126 -0
- package/src/client/serialization/InstancePayloadOptions.ts +28 -0
- package/src/client/serialization/InstanceState.ts +14 -0
- package/src/client/submission/{SubmissionDefinition.ts → SubmissionMeta.ts} +1 -1
- package/src/client/unsupported/UnsupportedControlNode.ts +2 -6
- package/src/entrypoints/FormInstance.ts +55 -0
- package/src/entrypoints/FormResult/BaseFormResult.ts +40 -0
- package/src/entrypoints/FormResult/BaseInstantiableFormResult.ts +109 -0
- package/src/entrypoints/FormResult/FormFailureResult.ts +44 -0
- package/src/entrypoints/FormResult/FormSuccessResult.ts +25 -0
- package/src/entrypoints/FormResult/FormWarningResult.ts +25 -0
- package/src/entrypoints/createInstance.ts +23 -0
- package/src/entrypoints/editInstance.ts +24 -0
- package/src/entrypoints/index.ts +4 -0
- package/src/entrypoints/loadForm.ts +154 -0
- package/src/entrypoints/restoreInstance.ts +27 -0
- package/src/error/LoadFormFailureError.ts +114 -0
- package/src/error/MalformedInstanceDataError.ts +3 -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/TemplatedNodeAttributeSerializationError.ts +24 -0
- package/src/error/XFormsSpecViolationError.ts +1 -0
- package/src/index.ts +2 -56
- package/src/instance/Group.ts +17 -15
- package/src/instance/InputControl.ts +58 -12
- package/src/instance/ModelValue.ts +19 -11
- package/src/instance/Note.ts +40 -64
- package/src/instance/PrimaryInstance.ts +70 -31
- package/src/instance/RangeControl.ts +119 -0
- package/src/instance/RankControl.ts +208 -0
- package/src/instance/Root.ts +21 -31
- package/src/instance/SelectControl.ts +228 -0
- package/src/instance/Subtree.ts +17 -15
- package/src/instance/TriggerControl.ts +50 -80
- package/src/instance/abstract/DescendantNode.ts +13 -8
- package/src/instance/abstract/InstanceNode.ts +19 -7
- package/src/instance/abstract/ValueNode.ts +14 -15
- package/src/instance/children/DescendantNodeInitOptions.ts +35 -0
- package/src/instance/children/buildChildren.ts +206 -0
- package/src/instance/children/childrenInitOptions.ts +117 -0
- package/src/instance/children/normalizeChildInitOptions.ts +332 -0
- package/src/instance/hierarchy.ts +21 -16
- package/src/instance/input/InitialInstanceState.ts +108 -0
- package/src/instance/input/InstanceAttachmentMap.ts +142 -0
- package/src/instance/internal-api/InstanceConfig.ts +3 -10
- package/src/instance/internal-api/InstanceValueContext.ts +11 -1
- package/src/instance/internal-api/serialization/ClientReactiveSerializableInstance.ts +20 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableLeafNode.ts +43 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableParentNode.ts +26 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableTemplatedNode.ts +24 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableValueNode.ts +28 -0
- package/src/instance/repeat/BaseRepeatRange.ts +21 -24
- package/src/instance/repeat/RepeatInstance.ts +27 -19
- package/src/instance/repeat/RepeatRangeControlled.ts +90 -17
- package/src/instance/repeat/RepeatRangeUncontrolled.ts +10 -9
- package/src/instance/resource.ts +18 -2
- package/src/instance/unsupported/UploadControl.ts +116 -5
- package/src/integration/xpath/EngineXPathEvaluator.ts +2 -2
- package/src/integration/xpath/adapter/kind.ts +1 -28
- package/src/integration/xpath/adapter/names.ts +66 -17
- package/src/integration/xpath/adapter/traversal.ts +12 -11
- package/src/integration/xpath/static-dom/StaticAttribute.ts +16 -7
- package/src/integration/xpath/static-dom/StaticDocument.ts +17 -18
- package/src/integration/xpath/static-dom/StaticElement.ts +211 -52
- package/src/integration/xpath/static-dom/StaticNode.ts +1 -1
- package/src/integration/xpath/static-dom/StaticParentNode.ts +22 -0
- package/src/integration/xpath/static-dom/staticNodeName.ts +20 -0
- package/src/lib/client-reactivity/instance-state/createNodeRangeInstanceState.ts +17 -0
- package/src/lib/client-reactivity/instance-state/createParentNodeInstanceState.ts +22 -0
- package/src/lib/client-reactivity/instance-state/createPrimaryInstanceState.ts +12 -0
- package/src/lib/client-reactivity/instance-state/createRootInstanceState.ts +19 -0
- package/src/lib/client-reactivity/instance-state/createTemplatedNodeInstanceState.ts +31 -0
- package/src/lib/client-reactivity/instance-state/createValueNodeInstanceState.ts +21 -0
- package/src/lib/client-reactivity/instance-state/prepareInstancePayload.ts +173 -0
- package/src/lib/codecs/Geopoint/Geopoint.ts +150 -0
- package/src/lib/codecs/Geopoint/GeopointValueCodec.ts +20 -0
- package/src/lib/codecs/NoteCodec.ts +32 -0
- package/src/lib/codecs/RangeCodec.ts +65 -0
- package/src/lib/codecs/TempUnsupportedControlCodec.ts +32 -0
- package/src/lib/codecs/TriggerCodec.ts +64 -0
- package/src/lib/codecs/ValueArrayCodec.ts +42 -0
- package/src/lib/codecs/ValueCodec.ts +2 -2
- package/src/lib/codecs/getNoteCodec.ts +27 -0
- package/src/lib/codecs/getSelectCodec.ts +27 -0
- package/src/lib/codecs/getSharedValueCodec.ts +5 -3
- 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 +1 -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/names/UnprefixedXFormsName.ts +12 -0
- package/src/lib/number-parsers.ts +25 -0
- package/src/lib/reactivity/createInstanceValueState.ts +69 -43
- package/src/lib/reactivity/{createSelectItems.ts → createItemCollection.ts} +41 -36
- package/src/lib/xml-serialization.ts +76 -9
- package/src/parse/XFormDOM.ts +141 -21
- package/src/parse/XFormDefinition.ts +1 -4
- package/src/parse/body/BodyDefinition.ts +4 -4
- package/src/parse/body/appearance/rangeAppearanceParser.ts +11 -0
- package/src/parse/body/control/InputControlDefinition.ts +9 -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/model/BindDefinition.ts +4 -0
- package/src/parse/model/BindPreloadDefinition.ts +100 -0
- package/src/parse/model/DescendentNodeDefinition.ts +7 -25
- package/src/parse/model/ItextTranslationsDefinition.ts +79 -0
- package/src/parse/model/LeafNodeDefinition.ts +13 -8
- package/src/parse/model/ModelDefinition.ts +36 -3
- package/src/parse/model/NodeDefinition.ts +38 -85
- package/src/parse/model/NoteNodeDefinition.ts +12 -10
- package/src/parse/model/RangeNodeDefinition.ts +119 -0
- package/src/parse/model/RepeatDefinition.ts +382 -0
- package/src/parse/model/RootAttributeDefinition.ts +44 -0
- package/src/parse/model/RootAttributeMap.ts +49 -0
- package/src/parse/model/RootDefinition.ts +42 -43
- package/src/parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts +23 -2
- package/src/parse/model/SecondaryInstance/assertSecondaryInstanceDefinition.ts +14 -0
- package/src/parse/model/SecondaryInstance/defineSecondaryInstance.ts +32 -0
- package/src/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.ts +3 -24
- package/src/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.ts +33 -86
- package/src/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.ts +64 -136
- package/src/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.ts +9 -7
- package/src/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.ts +1 -1
- package/src/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.ts +7 -7
- package/src/parse/model/{FormSubmissionDefinition.ts → SubmissionDefinition.ts} +2 -2
- package/src/parse/model/SubtreeDefinition.ts +15 -16
- package/src/parse/model/nodeDefinitionMap.ts +34 -0
- package/src/parse/shared/parseInstanceXML.ts +79 -0
- package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +46 -131
- 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/xpath/semantic-analysis.ts +4 -3
- package/dist/client/EngineConfig.d.ts +0 -79
- package/dist/client/submission/SubmissionData.d.ts +0 -7
- package/dist/client/submission/SubmissionInstanceFile.d.ts +0 -6
- package/dist/client/submission/SubmissionOptions.d.ts +0 -23
- package/dist/client/submission/SubmissionResult.d.ts +0 -91
- package/dist/client/submission/SubmissionState.d.ts +0 -12
- 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 -58
- package/dist/instance/abstract/UnsupportedControl.d.ts +0 -53
- package/dist/instance/index.d.ts +0 -8
- package/dist/instance/internal-api/ValueContext.d.ts +0 -23
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableInstance.d.ts +0 -14
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +0 -31
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +0 -18
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +0 -17
- package/dist/instance/unsupported/RangeControl.d.ts +0 -6
- package/dist/instance/unsupported/RankControl.d.ts +0 -6
- package/dist/integration/xpath/static-dom/StaticNamedNode.d.ts +0 -17
- package/dist/lib/client-reactivity/submission/createInstanceSubmissionState.d.ts +0 -3
- package/dist/lib/client-reactivity/submission/createLeafNodeSubmissionState.d.ts +0 -3
- package/dist/lib/client-reactivity/submission/createNodeRangeSubmissionState.d.ts +0 -4
- package/dist/lib/client-reactivity/submission/createParentNodeSubmissionState.d.ts +0 -4
- package/dist/lib/client-reactivity/submission/createValueNodeSubmissionState.d.ts +0 -3
- package/dist/lib/client-reactivity/submission/prepareSubmission.d.ts +0 -8
- package/dist/lib/reactivity/createSelectItems.d.ts +0 -16
- package/dist/lib/reactivity/createValueState.d.ts +0 -40
- 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 -9
- package/dist/parse/model/ItextTranslation/ItextTranslationDefinition.d.ts +0 -4
- package/dist/parse/model/ItextTranslation/ItextTranslationRootDefinition.d.ts +0 -8
- package/dist/parse/model/ItextTranslation/ItextTranslationsDefinition.d.ts +0 -8
- package/dist/parse/model/RepeatInstanceDefinition.d.ts +0 -14
- package/dist/parse/model/RepeatRangeDefinition.d.ts +0 -29
- package/dist/parse/model/RepeatTemplateDefinition.d.ts +0 -28
- package/dist/parse/model/SecondaryInstance/SecondaryInstanceDefinition.d.ts +0 -4
- package/dist/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.d.ts +0 -7
- package/src/client/EngineConfig.ts +0 -84
- package/src/client/submission/SubmissionData.ts +0 -12
- package/src/client/submission/SubmissionInstanceFile.ts +0 -9
- package/src/client/submission/SubmissionOptions.ts +0 -28
- package/src/client/submission/SubmissionResult.ts +0 -124
- package/src/client/submission/SubmissionState.ts +0 -14
- package/src/client/unsupported/RangeNode.ts +0 -14
- package/src/client/unsupported/RankNode.ts +0 -14
- package/src/instance/SelectField.ts +0 -263
- package/src/instance/abstract/UnsupportedControl.ts +0 -174
- package/src/instance/children.ts +0 -158
- package/src/instance/index.ts +0 -55
- package/src/instance/internal-api/ValueContext.ts +0 -28
- package/src/instance/internal-api/submission/ClientReactiveSubmittableInstance.ts +0 -20
- package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +0 -42
- package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +0 -25
- package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +0 -23
- package/src/instance/unsupported/RangeControl.ts +0 -9
- package/src/instance/unsupported/RankControl.ts +0 -9
- package/src/integration/xpath/static-dom/StaticNamedNode.ts +0 -45
- package/src/lib/client-reactivity/submission/createInstanceSubmissionState.ts +0 -12
- package/src/lib/client-reactivity/submission/createLeafNodeSubmissionState.ts +0 -20
- package/src/lib/client-reactivity/submission/createNodeRangeSubmissionState.ts +0 -17
- package/src/lib/client-reactivity/submission/createParentNodeSubmissionState.ts +0 -22
- package/src/lib/client-reactivity/submission/createValueNodeSubmissionState.ts +0 -21
- package/src/lib/client-reactivity/submission/prepareSubmission.ts +0 -172
- package/src/lib/reactivity/createValueState.ts +0 -200
- package/src/parse/body/control/select/ItemsetNodesetContext.ts +0 -21
- package/src/parse/model/ItextTranslation/ItextTranslationDefinition.ts +0 -4
- package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +0 -41
- package/src/parse/model/ItextTranslation/ItextTranslationsDefinition.ts +0 -31
- package/src/parse/model/RepeatInstanceDefinition.ts +0 -34
- package/src/parse/model/RepeatRangeDefinition.ts +0 -94
- package/src/parse/model/RepeatTemplateDefinition.ts +0 -145
- package/src/parse/model/SecondaryInstance/SecondaryInstanceDefinition.ts +0 -4
- package/src/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.ts +0 -12
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
|
+
import type { Accessor } from 'solid-js';
|
|
3
|
+
import type {
|
|
4
|
+
RangeInputValue,
|
|
5
|
+
RangeNode,
|
|
6
|
+
RangeNodeAppearances,
|
|
7
|
+
RangeValue,
|
|
8
|
+
} from '../client/RangeNode.ts';
|
|
9
|
+
import type { TextRange } from '../client/TextRange.ts';
|
|
10
|
+
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
11
|
+
import type { StaticLeafElement } from '../integration/xpath/static-dom/StaticElement.ts';
|
|
12
|
+
import { RangeCodec } from '../lib/codecs/RangeCodec.ts';
|
|
13
|
+
import { getSharedValueCodec } from '../lib/codecs/getSharedValueCodec.ts';
|
|
14
|
+
import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
|
|
15
|
+
import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
|
|
16
|
+
import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
17
|
+
import { createSharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
18
|
+
import { createFieldHint } from '../lib/reactivity/text/createFieldHint.ts';
|
|
19
|
+
import { createNodeLabel } from '../lib/reactivity/text/createNodeLabel.ts';
|
|
20
|
+
import type {
|
|
21
|
+
AnyRangeNodeDefinition,
|
|
22
|
+
RangeNodeDefinition,
|
|
23
|
+
RangeValueType,
|
|
24
|
+
} from '../parse/model/RangeNodeDefinition.ts';
|
|
25
|
+
import type { Root } from './Root.ts';
|
|
26
|
+
import { ValueNode, type ValueNodeStateSpec } from './abstract/ValueNode.ts';
|
|
27
|
+
import type { GeneralParentNode } from './hierarchy.ts';
|
|
28
|
+
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
29
|
+
import type { ValidationContext } from './internal-api/ValidationContext.ts';
|
|
30
|
+
import type { ClientReactiveSerializableValueNode } from './internal-api/serialization/ClientReactiveSerializableValueNode.ts';
|
|
31
|
+
|
|
32
|
+
interface RangeControlStateSpec<V extends RangeValueType>
|
|
33
|
+
extends ValueNodeStateSpec<RangeValue<V>> {
|
|
34
|
+
readonly label: Accessor<TextRange<'label'> | null>;
|
|
35
|
+
readonly hint: Accessor<TextRange<'hint'> | null>;
|
|
36
|
+
readonly valueOptions: null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export class RangeControl<V extends RangeValueType = RangeValueType>
|
|
40
|
+
extends ValueNode<V, RangeNodeDefinition<V>, RangeValue<V>, RangeInputValue<V>>
|
|
41
|
+
implements
|
|
42
|
+
RangeNode<V>,
|
|
43
|
+
XFormsXPathElement,
|
|
44
|
+
EvaluationContext,
|
|
45
|
+
ValidationContext,
|
|
46
|
+
ClientReactiveSerializableValueNode
|
|
47
|
+
{
|
|
48
|
+
static from(
|
|
49
|
+
parent: GeneralParentNode,
|
|
50
|
+
instanceNode: StaticLeafElement | null,
|
|
51
|
+
definition: AnyRangeNodeDefinition
|
|
52
|
+
): AnyRangeControl;
|
|
53
|
+
static from<V extends RangeValueType>(
|
|
54
|
+
parent: GeneralParentNode,
|
|
55
|
+
instanceNode: StaticLeafElement | null,
|
|
56
|
+
definition: RangeNodeDefinition<V>
|
|
57
|
+
): RangeControl<V> {
|
|
58
|
+
return new this<V>(parent, instanceNode, definition);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// XFormsXPathElement
|
|
62
|
+
override readonly [XPathNodeKindKey] = 'element';
|
|
63
|
+
|
|
64
|
+
// InstanceNode
|
|
65
|
+
protected readonly state: SharedNodeState<RangeControlStateSpec<V>>;
|
|
66
|
+
protected readonly engineState: EngineState<RangeControlStateSpec<V>>;
|
|
67
|
+
|
|
68
|
+
// RangeNode
|
|
69
|
+
readonly nodeType = 'range';
|
|
70
|
+
readonly appearances: RangeNodeAppearances;
|
|
71
|
+
readonly nodeOptions = null;
|
|
72
|
+
readonly currentState: CurrentState<RangeControlStateSpec<V>>;
|
|
73
|
+
|
|
74
|
+
constructor(
|
|
75
|
+
parent: GeneralParentNode,
|
|
76
|
+
instanceNode: StaticLeafElement | null,
|
|
77
|
+
definition: RangeNodeDefinition<V>
|
|
78
|
+
) {
|
|
79
|
+
const baseCodec = getSharedValueCodec(definition.valueType);
|
|
80
|
+
const codec = new RangeCodec(baseCodec, definition);
|
|
81
|
+
|
|
82
|
+
super(parent, instanceNode, definition, codec);
|
|
83
|
+
|
|
84
|
+
this.appearances = definition.bodyElement.appearances;
|
|
85
|
+
|
|
86
|
+
const state = createSharedNodeState(
|
|
87
|
+
this.scope,
|
|
88
|
+
{
|
|
89
|
+
reference: this.contextReference,
|
|
90
|
+
readonly: this.isReadonly,
|
|
91
|
+
relevant: this.isRelevant,
|
|
92
|
+
required: this.isRequired,
|
|
93
|
+
|
|
94
|
+
label: createNodeLabel(this, definition),
|
|
95
|
+
hint: createFieldHint(this, definition),
|
|
96
|
+
children: null,
|
|
97
|
+
valueOptions: null,
|
|
98
|
+
value: this.valueState,
|
|
99
|
+
instanceValue: this.getInstanceValue,
|
|
100
|
+
},
|
|
101
|
+
this.instanceConfig
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
this.state = state;
|
|
105
|
+
this.engineState = state.engineState;
|
|
106
|
+
this.currentState = state.currentState;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
setValue(value: RangeInputValue<V>): Root {
|
|
110
|
+
this.setValueState(value);
|
|
111
|
+
|
|
112
|
+
return this.root;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// prettier-ignore
|
|
117
|
+
export type AnyRangeControl =
|
|
118
|
+
| RangeControl<'decimal'>
|
|
119
|
+
| RangeControl<'int'>;
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
|
+
import type { Accessor } from 'solid-js';
|
|
3
|
+
import { createMemo } from 'solid-js';
|
|
4
|
+
import type { RankDefinition, RankItem, RankNode, RankValueOptions } from '../client/RankNode.ts';
|
|
5
|
+
import type { TextRange } from '../client/TextRange.ts';
|
|
6
|
+
import type { ValueType } from '../client/ValueType.ts';
|
|
7
|
+
import { RankMissingValueError } from '../error/RankMissingValueError.ts';
|
|
8
|
+
import { RankValueTypeError } from '../error/RankValueTypeError.ts';
|
|
9
|
+
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
10
|
+
import type { StaticLeafElement } from '../integration/xpath/static-dom/StaticElement.ts';
|
|
11
|
+
import { sharedValueCodecs } from '../lib/codecs/getSharedValueCodec.ts';
|
|
12
|
+
import { MultipleValueItemCodec } from '../lib/codecs/items/MultipleValueItemCodec.ts';
|
|
13
|
+
import { createItemCollection } from '../lib/reactivity/createItemCollection.ts';
|
|
14
|
+
import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
|
|
15
|
+
import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
|
|
16
|
+
import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
17
|
+
import { createSharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
18
|
+
import { createFieldHint } from '../lib/reactivity/text/createFieldHint.ts';
|
|
19
|
+
import { createNodeLabel } from '../lib/reactivity/text/createNodeLabel.ts';
|
|
20
|
+
import type { SimpleAtomicState } from '../lib/reactivity/types.ts';
|
|
21
|
+
import type { UnknownAppearanceDefinition } from '../parse/body/appearance/unknownAppearanceParser.ts';
|
|
22
|
+
import type { Root } from './Root.ts';
|
|
23
|
+
import type { ValueNodeStateSpec } from './abstract/ValueNode.ts';
|
|
24
|
+
import { ValueNode } from './abstract/ValueNode.ts';
|
|
25
|
+
import type { GeneralParentNode } from './hierarchy.ts';
|
|
26
|
+
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
27
|
+
import type { ValidationContext } from './internal-api/ValidationContext.ts';
|
|
28
|
+
import type { ClientReactiveSerializableValueNode } from './internal-api/serialization/ClientReactiveSerializableValueNode.ts';
|
|
29
|
+
|
|
30
|
+
export type AnyRankDefinition = {
|
|
31
|
+
[V in ValueType]: RankDefinition<V>;
|
|
32
|
+
}[ValueType];
|
|
33
|
+
|
|
34
|
+
type AssertRankNodeDefinition = (
|
|
35
|
+
definition: AnyRankDefinition
|
|
36
|
+
) => asserts definition is RankDefinition<'string'>;
|
|
37
|
+
|
|
38
|
+
const assertRankNodeDefinition: AssertRankNodeDefinition = (definition) => {
|
|
39
|
+
if (definition.valueType !== 'string') {
|
|
40
|
+
throw new RankValueTypeError(definition);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
type RankItemMap = ReadonlyMap<string, RankItem>;
|
|
45
|
+
|
|
46
|
+
interface RankControlStateSpec extends ValueNodeStateSpec<readonly string[]> {
|
|
47
|
+
readonly label: Accessor<TextRange<'label'> | null>;
|
|
48
|
+
readonly hint: Accessor<TextRange<'hint'> | null>;
|
|
49
|
+
readonly valueOptions: Accessor<RankValueOptions>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @ToDo We currently represent a blank value for `<odk:rank>` as an empty array.
|
|
54
|
+
* This is ambiguous, and likely to change.
|
|
55
|
+
*
|
|
56
|
+
* @see {@link https://github.com/getodk/web-forms/issues/295}
|
|
57
|
+
*/
|
|
58
|
+
type TempBlankValueState = readonly [];
|
|
59
|
+
const isBlankValueState = (values: readonly string[]): values is TempBlankValueState => {
|
|
60
|
+
return values.length === 0;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export class RankControl
|
|
64
|
+
extends ValueNode<'string', RankDefinition<'string'>, readonly string[], readonly string[]>
|
|
65
|
+
implements
|
|
66
|
+
RankNode,
|
|
67
|
+
XFormsXPathElement,
|
|
68
|
+
EvaluationContext,
|
|
69
|
+
ValidationContext,
|
|
70
|
+
ClientReactiveSerializableValueNode
|
|
71
|
+
{
|
|
72
|
+
static from(
|
|
73
|
+
parent: GeneralParentNode,
|
|
74
|
+
instanceNode: StaticLeafElement | null,
|
|
75
|
+
definition: RankDefinition
|
|
76
|
+
): RankControl;
|
|
77
|
+
static from(
|
|
78
|
+
parent: GeneralParentNode,
|
|
79
|
+
instanceNode: StaticLeafElement | null,
|
|
80
|
+
definition: AnyRankDefinition
|
|
81
|
+
): RankControl {
|
|
82
|
+
assertRankNodeDefinition(definition);
|
|
83
|
+
return new this(parent, instanceNode, definition);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private readonly mapOptionsByValue: Accessor<RankItemMap>;
|
|
87
|
+
|
|
88
|
+
protected override readonly getInstanceValue: Accessor<string>;
|
|
89
|
+
|
|
90
|
+
// XFormsXPathElement
|
|
91
|
+
override readonly [XPathNodeKindKey] = 'element';
|
|
92
|
+
|
|
93
|
+
// InstanceNode
|
|
94
|
+
protected readonly state: SharedNodeState<RankControlStateSpec>;
|
|
95
|
+
protected readonly engineState: EngineState<RankControlStateSpec>;
|
|
96
|
+
|
|
97
|
+
// RankNode
|
|
98
|
+
readonly nodeType = 'rank';
|
|
99
|
+
readonly appearances: UnknownAppearanceDefinition;
|
|
100
|
+
readonly nodeOptions = null;
|
|
101
|
+
readonly currentState: CurrentState<RankControlStateSpec>;
|
|
102
|
+
|
|
103
|
+
private constructor(
|
|
104
|
+
parent: GeneralParentNode,
|
|
105
|
+
instanceNode: StaticLeafElement | null,
|
|
106
|
+
definition: RankDefinition<'string'>
|
|
107
|
+
) {
|
|
108
|
+
const codec = new MultipleValueItemCodec(sharedValueCodecs.string);
|
|
109
|
+
super(parent, instanceNode, definition, codec);
|
|
110
|
+
|
|
111
|
+
this.appearances = definition.bodyElement.appearances;
|
|
112
|
+
|
|
113
|
+
const valueOptions = createItemCollection(this);
|
|
114
|
+
const mapOptionsByValue: Accessor<RankItemMap> = this.scope.runTask(() => {
|
|
115
|
+
return createMemo(() => {
|
|
116
|
+
return new Map(valueOptions().map((item) => [item.value, item]));
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
this.mapOptionsByValue = mapOptionsByValue;
|
|
121
|
+
|
|
122
|
+
const baseValueState = this.valueState;
|
|
123
|
+
const [baseGetValue, setValue] = baseValueState;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @ToDo As new value options become available, they're not yet in the
|
|
127
|
+
* `currentValues` state. This appends them. We intend to change this
|
|
128
|
+
* behavior, likely clearing the previous state instead.
|
|
129
|
+
*
|
|
130
|
+
* However, there's an open question about what we should do when a filter
|
|
131
|
+
* change **only removes values**.
|
|
132
|
+
*/
|
|
133
|
+
const getValue = this.scope.runTask(() => {
|
|
134
|
+
return createMemo(() => {
|
|
135
|
+
const options = valueOptions();
|
|
136
|
+
const values = baseGetValue();
|
|
137
|
+
|
|
138
|
+
if (isBlankValueState(values)) {
|
|
139
|
+
return values;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const optionValues = new Set(options.map((option) => option.value));
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @see {@link getValue} ToDo paragraph 2.
|
|
146
|
+
*/
|
|
147
|
+
const currentValues = values.filter((value) => optionValues.has(value));
|
|
148
|
+
|
|
149
|
+
return Array.from(
|
|
150
|
+
new Set([
|
|
151
|
+
...currentValues,
|
|
152
|
+
/**
|
|
153
|
+
* @see {@link getValue} ToDo paragraph 1.
|
|
154
|
+
*/
|
|
155
|
+
...optionValues,
|
|
156
|
+
])
|
|
157
|
+
);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
const valueState: SimpleAtomicState<readonly string[]> = [getValue, setValue];
|
|
161
|
+
|
|
162
|
+
this.getInstanceValue = this.scope.runTask(() => {
|
|
163
|
+
return createMemo(() => codec.encodeValue(getValue()));
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const state = createSharedNodeState(
|
|
167
|
+
this.scope,
|
|
168
|
+
{
|
|
169
|
+
reference: this.contextReference,
|
|
170
|
+
readonly: this.isReadonly,
|
|
171
|
+
relevant: this.isRelevant,
|
|
172
|
+
required: this.isRequired,
|
|
173
|
+
label: createNodeLabel(this, definition),
|
|
174
|
+
hint: createFieldHint(this, definition),
|
|
175
|
+
children: null,
|
|
176
|
+
valueOptions,
|
|
177
|
+
value: valueState,
|
|
178
|
+
instanceValue: this.getInstanceValue,
|
|
179
|
+
},
|
|
180
|
+
this.instanceConfig
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
this.state = state;
|
|
184
|
+
this.engineState = state.engineState;
|
|
185
|
+
this.currentState = state.currentState;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
getValueLabel(value: string): TextRange<'item-label'> | null {
|
|
189
|
+
const valueOption = this.currentState.valueOptions.find((item) => item.value === value);
|
|
190
|
+
return valueOption?.label ?? null;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
setValues(valuesInOrder: readonly string[]): Root {
|
|
194
|
+
if (isBlankValueState(valuesInOrder)) {
|
|
195
|
+
this.setValueState(valuesInOrder);
|
|
196
|
+
return this.root;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const sourceValues: string[] = Array.from(this.mapOptionsByValue().keys());
|
|
200
|
+
const hasAllValues = sourceValues.every((sourceValue) => valuesInOrder.includes(sourceValue));
|
|
201
|
+
if (!hasAllValues) {
|
|
202
|
+
throw new RankMissingValueError('There are missing options. Rank should have all options.');
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
this.setValueState(valuesInOrder);
|
|
206
|
+
return this.root;
|
|
207
|
+
}
|
|
208
|
+
}
|
package/src/instance/Root.ts
CHANGED
|
@@ -3,16 +3,15 @@ import type { Accessor } from 'solid-js';
|
|
|
3
3
|
import type { ActiveLanguage, FormLanguage, FormLanguages } from '../client/FormLanguage.ts';
|
|
4
4
|
import type { FormNodeID } from '../client/identity.ts';
|
|
5
5
|
import type { RootNode } from '../client/RootNode.ts';
|
|
6
|
-
import type {
|
|
6
|
+
import type { InstancePayload } from '../client/serialization/InstancePayload.ts';
|
|
7
7
|
import type {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from '../client/
|
|
11
|
-
import type {
|
|
12
|
-
import type { SubmissionState } from '../client/submission/SubmissionState.ts';
|
|
8
|
+
InstancePayloadOptions,
|
|
9
|
+
InstancePayloadType,
|
|
10
|
+
} from '../client/serialization/InstancePayloadOptions.ts';
|
|
11
|
+
import type { InstanceState } from '../client/serialization/InstanceState.ts';
|
|
13
12
|
import type { AncestorNodeValidationState } from '../client/validation.ts';
|
|
14
13
|
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
15
|
-
import {
|
|
14
|
+
import { createRootInstanceState } from '../lib/client-reactivity/instance-state/createRootInstanceState.ts';
|
|
16
15
|
import type { ChildrenState } from '../lib/reactivity/createChildrenState.ts';
|
|
17
16
|
import { createChildrenState } from '../lib/reactivity/createChildrenState.ts';
|
|
18
17
|
import type { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
|
|
@@ -25,10 +24,10 @@ import { createAggregatedViolations } from '../lib/reactivity/validation/createA
|
|
|
25
24
|
import type { BodyClassList } from '../parse/body/BodyDefinition.ts';
|
|
26
25
|
import type { RootDefinition } from '../parse/model/RootDefinition.ts';
|
|
27
26
|
import { DescendantNode } from './abstract/DescendantNode.ts';
|
|
28
|
-
import { buildChildren } from './children.ts';
|
|
27
|
+
import { buildChildren } from './children/buildChildren.ts';
|
|
29
28
|
import type { GeneralChildNode } from './hierarchy.ts';
|
|
30
29
|
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
31
|
-
import type {
|
|
30
|
+
import type { ClientReactiveSerializableParentNode } from './internal-api/serialization/ClientReactiveSerializableParentNode.ts';
|
|
32
31
|
import type { TranslationContext } from './internal-api/TranslationContext.ts';
|
|
33
32
|
import type { PrimaryInstance } from './PrimaryInstance.ts';
|
|
34
33
|
|
|
@@ -54,7 +53,7 @@ export class Root
|
|
|
54
53
|
XFormsXPathElement,
|
|
55
54
|
EvaluationContext,
|
|
56
55
|
TranslationContext,
|
|
57
|
-
|
|
56
|
+
ClientReactiveSerializableParentNode<GeneralChildNode>
|
|
58
57
|
{
|
|
59
58
|
private readonly childrenState: ChildrenState<GeneralChildNode>;
|
|
60
59
|
|
|
@@ -76,25 +75,20 @@ export class Root
|
|
|
76
75
|
// RootNode
|
|
77
76
|
readonly nodeType = 'root';
|
|
78
77
|
readonly appearances = null;
|
|
78
|
+
readonly nodeOptions = null;
|
|
79
79
|
readonly classes: BodyClassList;
|
|
80
80
|
readonly currentState: MaterializedChildren<CurrentState<RootStateSpec>, GeneralChildNode>;
|
|
81
81
|
readonly validationState: AncestorNodeValidationState;
|
|
82
|
-
readonly
|
|
83
|
-
|
|
84
|
-
// ClientReactiveSubmittableInstance
|
|
85
|
-
get submissionDefinition(): SubmissionDefinition {
|
|
86
|
-
return this.definition.submission;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// RootNode
|
|
82
|
+
readonly instanceState: InstanceState;
|
|
90
83
|
readonly languages: FormLanguages;
|
|
91
84
|
|
|
92
85
|
constructor(parent: PrimaryInstance) {
|
|
93
|
-
const { definition } = parent;
|
|
86
|
+
const { definition, instanceNode: instance } = parent;
|
|
87
|
+
const instanceNode = instance.root;
|
|
94
88
|
const { nodeset: reference } = definition;
|
|
95
89
|
const computeReference: Accessor<string> = () => reference;
|
|
96
90
|
|
|
97
|
-
super(parent, definition, {
|
|
91
|
+
super(parent, instanceNode, definition, {
|
|
98
92
|
computeReference,
|
|
99
93
|
});
|
|
100
94
|
|
|
@@ -105,10 +99,6 @@ export class Root
|
|
|
105
99
|
this.childrenState = childrenState;
|
|
106
100
|
this.languages = parent.languages;
|
|
107
101
|
|
|
108
|
-
const sharedStateOptions = {
|
|
109
|
-
clientStateFactory: this.engineConfig.stateFactory,
|
|
110
|
-
};
|
|
111
|
-
|
|
112
102
|
const state = createSharedNodeState(
|
|
113
103
|
this.scope,
|
|
114
104
|
{
|
|
@@ -123,7 +113,7 @@ export class Root
|
|
|
123
113
|
value: null,
|
|
124
114
|
children: childrenState.childIds,
|
|
125
115
|
},
|
|
126
|
-
|
|
116
|
+
this.instanceConfig
|
|
127
117
|
);
|
|
128
118
|
|
|
129
119
|
this.state = state;
|
|
@@ -135,8 +125,8 @@ export class Root
|
|
|
135
125
|
);
|
|
136
126
|
|
|
137
127
|
childrenState.setChildren(buildChildren(this));
|
|
138
|
-
this.validationState = createAggregatedViolations(this,
|
|
139
|
-
this.
|
|
128
|
+
this.validationState = createAggregatedViolations(this, this.instanceConfig);
|
|
129
|
+
this.instanceState = createRootInstanceState(this);
|
|
140
130
|
}
|
|
141
131
|
|
|
142
132
|
getChildren(): readonly GeneralChildNode[] {
|
|
@@ -150,9 +140,9 @@ export class Root
|
|
|
150
140
|
return this;
|
|
151
141
|
}
|
|
152
142
|
|
|
153
|
-
|
|
154
|
-
options?:
|
|
155
|
-
): Promise<
|
|
156
|
-
return this.rootDocument.
|
|
143
|
+
prepareInstancePayload<PayloadType extends InstancePayloadType = 'monolithic'>(
|
|
144
|
+
options?: InstancePayloadOptions<PayloadType>
|
|
145
|
+
): Promise<InstancePayload<PayloadType>> {
|
|
146
|
+
return this.rootDocument.prepareInstancePayload(options);
|
|
157
147
|
}
|
|
158
148
|
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
|
+
import type { Accessor } from 'solid-js';
|
|
3
|
+
import { createMemo } from 'solid-js';
|
|
4
|
+
import type {
|
|
5
|
+
SelectDefinition,
|
|
6
|
+
SelectItem,
|
|
7
|
+
SelectNode,
|
|
8
|
+
SelectNodeAppearances,
|
|
9
|
+
SelectValueOptions,
|
|
10
|
+
} from '../client/SelectNode.ts';
|
|
11
|
+
import type { TextRange } from '../client/TextRange.ts';
|
|
12
|
+
import type { ValueType } from '../client/ValueType.ts';
|
|
13
|
+
import { SelectValueTypeError } from '../error/SelectValueTypeError.ts';
|
|
14
|
+
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
15
|
+
import type { StaticLeafElement } from '../integration/xpath/static-dom/StaticElement.ts';
|
|
16
|
+
import { getSelectCodec } from '../lib/codecs/getSelectCodec.ts';
|
|
17
|
+
import { createItemCollection } from '../lib/reactivity/createItemCollection.ts';
|
|
18
|
+
import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
|
|
19
|
+
import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
|
|
20
|
+
import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
21
|
+
import { createSharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
22
|
+
import { createFieldHint } from '../lib/reactivity/text/createFieldHint.ts';
|
|
23
|
+
import { createNodeLabel } from '../lib/reactivity/text/createNodeLabel.ts';
|
|
24
|
+
import type { SimpleAtomicState } from '../lib/reactivity/types.ts';
|
|
25
|
+
import type { SelectType } from '../parse/body/control/SelectControlDefinition.ts';
|
|
26
|
+
import type { Root } from './Root.ts';
|
|
27
|
+
import type { ValueNodeStateSpec } from './abstract/ValueNode.ts';
|
|
28
|
+
import { ValueNode } from './abstract/ValueNode.ts';
|
|
29
|
+
import type { GeneralParentNode } from './hierarchy.ts';
|
|
30
|
+
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
31
|
+
import type { ValidationContext } from './internal-api/ValidationContext.ts';
|
|
32
|
+
import type { ClientReactiveSerializableValueNode } from './internal-api/serialization/ClientReactiveSerializableValueNode.ts';
|
|
33
|
+
|
|
34
|
+
export type AnySelectDefinition = {
|
|
35
|
+
[V in ValueType]: SelectDefinition<V>;
|
|
36
|
+
}[ValueType];
|
|
37
|
+
|
|
38
|
+
type AssertSupportedSelectValueType = (
|
|
39
|
+
definition: AnySelectDefinition
|
|
40
|
+
) => asserts definition is SelectDefinition<'string'>;
|
|
41
|
+
|
|
42
|
+
const assertSupportedSelectValueType: AssertSupportedSelectValueType = (definition) => {
|
|
43
|
+
if (definition.valueType !== 'string') {
|
|
44
|
+
throw new SelectValueTypeError(definition);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
type SelectItemMap = ReadonlyMap<string, SelectItem>;
|
|
49
|
+
|
|
50
|
+
interface SelectControlStateSpec extends ValueNodeStateSpec<readonly string[]> {
|
|
51
|
+
readonly label: Accessor<TextRange<'label'> | null>;
|
|
52
|
+
readonly hint: Accessor<TextRange<'hint'> | null>;
|
|
53
|
+
readonly valueOptions: Accessor<SelectValueOptions>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export class SelectControl
|
|
57
|
+
extends ValueNode<'string', SelectDefinition<'string'>, readonly string[], readonly string[]>
|
|
58
|
+
implements
|
|
59
|
+
SelectNode,
|
|
60
|
+
XFormsXPathElement,
|
|
61
|
+
EvaluationContext,
|
|
62
|
+
ValidationContext,
|
|
63
|
+
ClientReactiveSerializableValueNode
|
|
64
|
+
{
|
|
65
|
+
static from(
|
|
66
|
+
parent: GeneralParentNode,
|
|
67
|
+
instanceNode: StaticLeafElement | null,
|
|
68
|
+
definition: SelectDefinition
|
|
69
|
+
): SelectControl;
|
|
70
|
+
static from(
|
|
71
|
+
parent: GeneralParentNode,
|
|
72
|
+
instanceNode: StaticLeafElement | null,
|
|
73
|
+
definition: AnySelectDefinition
|
|
74
|
+
): SelectControl {
|
|
75
|
+
assertSupportedSelectValueType(definition);
|
|
76
|
+
|
|
77
|
+
return new this(parent, instanceNode, definition);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private readonly mapOptionsByValue: Accessor<SelectItemMap>;
|
|
81
|
+
|
|
82
|
+
protected override readonly getInstanceValue: Accessor<string>;
|
|
83
|
+
|
|
84
|
+
// XFormsXPathElement
|
|
85
|
+
override readonly [XPathNodeKindKey] = 'element';
|
|
86
|
+
|
|
87
|
+
// InstanceNode
|
|
88
|
+
protected readonly state: SharedNodeState<SelectControlStateSpec>;
|
|
89
|
+
protected readonly engineState: EngineState<SelectControlStateSpec>;
|
|
90
|
+
|
|
91
|
+
// SelectNode
|
|
92
|
+
readonly nodeType = 'select';
|
|
93
|
+
readonly selectType: SelectType;
|
|
94
|
+
readonly appearances: SelectNodeAppearances;
|
|
95
|
+
readonly nodeOptions = null;
|
|
96
|
+
readonly currentState: CurrentState<SelectControlStateSpec>;
|
|
97
|
+
|
|
98
|
+
private constructor(
|
|
99
|
+
parent: GeneralParentNode,
|
|
100
|
+
instanceNode: StaticLeafElement | null,
|
|
101
|
+
definition: SelectDefinition<'string'>
|
|
102
|
+
) {
|
|
103
|
+
const codec = getSelectCodec(definition);
|
|
104
|
+
|
|
105
|
+
super(parent, instanceNode, definition, codec);
|
|
106
|
+
|
|
107
|
+
this.appearances = definition.bodyElement.appearances;
|
|
108
|
+
this.selectType = definition.bodyElement.type;
|
|
109
|
+
|
|
110
|
+
const valueOptions = createItemCollection(this);
|
|
111
|
+
|
|
112
|
+
const mapOptionsByValue: Accessor<SelectItemMap> = this.scope.runTask(() => {
|
|
113
|
+
return createMemo(() => {
|
|
114
|
+
return new Map(valueOptions().map((item) => [item.value, item]));
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
this.mapOptionsByValue = mapOptionsByValue;
|
|
119
|
+
|
|
120
|
+
const baseValueState = this.valueState;
|
|
121
|
+
const [baseGetValue, setValue] = baseValueState;
|
|
122
|
+
const getValue = this.scope.runTask(() => {
|
|
123
|
+
return createMemo(() => {
|
|
124
|
+
const optionsByValue = mapOptionsByValue();
|
|
125
|
+
|
|
126
|
+
return baseGetValue().filter((value) => {
|
|
127
|
+
return optionsByValue.has(value);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
const valueState: SimpleAtomicState<readonly string[]> = [getValue, setValue];
|
|
132
|
+
|
|
133
|
+
this.getInstanceValue = this.scope.runTask(() => {
|
|
134
|
+
return createMemo(() => {
|
|
135
|
+
return codec.encodeValue(getValue());
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const state = createSharedNodeState(
|
|
140
|
+
this.scope,
|
|
141
|
+
{
|
|
142
|
+
reference: this.contextReference,
|
|
143
|
+
readonly: this.isReadonly,
|
|
144
|
+
relevant: this.isRelevant,
|
|
145
|
+
required: this.isRequired,
|
|
146
|
+
|
|
147
|
+
label: createNodeLabel(this, definition),
|
|
148
|
+
hint: createFieldHint(this, definition),
|
|
149
|
+
children: null,
|
|
150
|
+
valueOptions,
|
|
151
|
+
value: valueState,
|
|
152
|
+
instanceValue: this.getInstanceValue,
|
|
153
|
+
},
|
|
154
|
+
this.instanceConfig
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
this.state = state;
|
|
158
|
+
this.engineState = state.engineState;
|
|
159
|
+
this.currentState = state.currentState;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Filters {@link values} to include only those values which are currently
|
|
164
|
+
* available in the mapping produced by {@link mapOptionsByValue}, i.e. within
|
|
165
|
+
* a potentially filtered itemset.
|
|
166
|
+
*
|
|
167
|
+
* Note: this method effectively produces an intersection of
|
|
168
|
+
* {@link sourceValues} and {@link values}. **Importantly**, ordering of the
|
|
169
|
+
* results is deterministic, preserving the order of values as yielded _by
|
|
170
|
+
* {@link sourceValues}_.
|
|
171
|
+
*
|
|
172
|
+
* At time of writing, there are several tests (in `@getodk/scenario`, ported
|
|
173
|
+
* from JavaRosa) which expect the values of a `<select>` to match the order
|
|
174
|
+
* they appear in the control's (potentially filtered) `<itemset>` (or list of
|
|
175
|
+
* `<item>`s, for forms defining those inline).
|
|
176
|
+
*
|
|
177
|
+
* @todo The `<odk:rank>` control, having semantics very similar to
|
|
178
|
+
* `<select>`, will likely perform similar filtering logic. However, one of
|
|
179
|
+
* the important distinctions between these controls is that `<odk:rank>`
|
|
180
|
+
* exists explicitly to control the order of values. It's quite likely that
|
|
181
|
+
* would be achieved by invoking the same logic with the parameter order
|
|
182
|
+
* reversed.
|
|
183
|
+
*/
|
|
184
|
+
private filterValues(
|
|
185
|
+
sourceValues: Iterable<string>,
|
|
186
|
+
values: Iterable<string>
|
|
187
|
+
): readonly string[] {
|
|
188
|
+
const selectedValues = new Set(values);
|
|
189
|
+
|
|
190
|
+
return Array.from(sourceValues).filter((sourceValue) => {
|
|
191
|
+
return selectedValues.has(sourceValue);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// SelectNode
|
|
196
|
+
getValueOption(value: string): SelectItem | null {
|
|
197
|
+
// Note: this method is a client-facing convenience API for reading state,
|
|
198
|
+
// so it **MUST** read from client-reactive state!
|
|
199
|
+
const valueOption = this.currentState.valueOptions.find((item) => {
|
|
200
|
+
return item.value === value;
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
return valueOption ?? null;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
isSelected(value: string): boolean {
|
|
207
|
+
// Note: this method is a client-facing convenience API for reading state,
|
|
208
|
+
// so it **MUST** read from client-reactive state!
|
|
209
|
+
return this.currentState.value.includes(value);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
selectValue(value: string | null): Root {
|
|
213
|
+
if (value == null) {
|
|
214
|
+
return this.selectValues([]);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return this.selectValues([value]);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
selectValues(values: readonly string[]): Root {
|
|
221
|
+
const sourceValues = this.mapOptionsByValue().keys();
|
|
222
|
+
const effectiveValues = this.filterValues(sourceValues, values);
|
|
223
|
+
|
|
224
|
+
this.setValueState(effectiveValues);
|
|
225
|
+
|
|
226
|
+
return this.root;
|
|
227
|
+
}
|
|
228
|
+
}
|