@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
package/src/instance/Subtree.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
2
|
import type { Accessor } from 'solid-js';
|
|
3
3
|
import type { FormNodeID } from '../client/identity.ts';
|
|
4
|
-
import type {
|
|
4
|
+
import type { InstanceState } from '../client/serialization/InstanceState.ts';
|
|
5
5
|
import type { SubtreeDefinition, SubtreeNode } from '../client/SubtreeNode.ts';
|
|
6
6
|
import type { AncestorNodeValidationState } from '../client/validation.ts';
|
|
7
7
|
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
8
|
-
import {
|
|
8
|
+
import type { StaticElement } from '../integration/xpath/static-dom/StaticElement.ts';
|
|
9
|
+
import { createParentNodeInstanceState } from '../lib/client-reactivity/instance-state/createParentNodeInstanceState.ts';
|
|
9
10
|
import type { ChildrenState } from '../lib/reactivity/createChildrenState.ts';
|
|
10
11
|
import { createChildrenState } from '../lib/reactivity/createChildrenState.ts';
|
|
11
12
|
import type { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
|
|
@@ -17,10 +18,10 @@ import { createSharedNodeState } from '../lib/reactivity/node-state/createShared
|
|
|
17
18
|
import { createAggregatedViolations } from '../lib/reactivity/validation/createAggregatedViolations.ts';
|
|
18
19
|
import type { DescendantNodeSharedStateSpec } from './abstract/DescendantNode.ts';
|
|
19
20
|
import { DescendantNode } from './abstract/DescendantNode.ts';
|
|
20
|
-
import { buildChildren } from './children.ts';
|
|
21
|
+
import { buildChildren } from './children/buildChildren.ts';
|
|
21
22
|
import type { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
|
|
22
23
|
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
23
|
-
import type {
|
|
24
|
+
import type { ClientReactiveSerializableParentNode } from './internal-api/serialization/ClientReactiveSerializableParentNode.ts';
|
|
24
25
|
|
|
25
26
|
interface SubtreeStateSpec extends DescendantNodeSharedStateSpec {
|
|
26
27
|
readonly label: null;
|
|
@@ -36,7 +37,7 @@ export class Subtree
|
|
|
36
37
|
SubtreeNode,
|
|
37
38
|
XFormsXPathElement,
|
|
38
39
|
EvaluationContext,
|
|
39
|
-
|
|
40
|
+
ClientReactiveSerializableParentNode<GeneralChildNode>
|
|
40
41
|
{
|
|
41
42
|
private readonly childrenState: ChildrenState<GeneralChildNode>;
|
|
42
43
|
|
|
@@ -49,21 +50,22 @@ export class Subtree
|
|
|
49
50
|
// SubtreeNode
|
|
50
51
|
readonly nodeType = 'subtree';
|
|
51
52
|
readonly appearances = null;
|
|
53
|
+
readonly nodeOptions = null;
|
|
52
54
|
readonly currentState: MaterializedChildren<CurrentState<SubtreeStateSpec>, GeneralChildNode>;
|
|
53
55
|
readonly validationState: AncestorNodeValidationState;
|
|
54
|
-
readonly
|
|
56
|
+
readonly instanceState: InstanceState;
|
|
55
57
|
|
|
56
|
-
constructor(
|
|
57
|
-
|
|
58
|
+
constructor(
|
|
59
|
+
parent: GeneralParentNode,
|
|
60
|
+
instanceNode: StaticElement | null,
|
|
61
|
+
definition: SubtreeDefinition
|
|
62
|
+
) {
|
|
63
|
+
super(parent, instanceNode, definition);
|
|
58
64
|
|
|
59
65
|
const childrenState = createChildrenState<Subtree, GeneralChildNode>(this);
|
|
60
66
|
|
|
61
67
|
this.childrenState = childrenState;
|
|
62
68
|
|
|
63
|
-
const sharedStateOptions = {
|
|
64
|
-
clientStateFactory: this.engineConfig.stateFactory,
|
|
65
|
-
};
|
|
66
|
-
|
|
67
69
|
const state = createSharedNodeState(
|
|
68
70
|
this.scope,
|
|
69
71
|
{
|
|
@@ -78,7 +80,7 @@ export class Subtree
|
|
|
78
80
|
valueOptions: null,
|
|
79
81
|
value: null,
|
|
80
82
|
},
|
|
81
|
-
|
|
83
|
+
this.instanceConfig
|
|
82
84
|
);
|
|
83
85
|
|
|
84
86
|
this.state = state;
|
|
@@ -90,8 +92,8 @@ export class Subtree
|
|
|
90
92
|
);
|
|
91
93
|
|
|
92
94
|
childrenState.setChildren(buildChildren(this));
|
|
93
|
-
this.validationState = createAggregatedViolations(this,
|
|
94
|
-
this.
|
|
95
|
+
this.validationState = createAggregatedViolations(this, this.instanceConfig);
|
|
96
|
+
this.instanceState = createParentNodeInstanceState(this);
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
getChildren(): readonly GeneralChildNode[] {
|
|
@@ -2,51 +2,70 @@ import { XPathNodeKindKey } from '@getodk/xpath';
|
|
|
2
2
|
import type { Accessor } from 'solid-js';
|
|
3
3
|
import type { TextRange } from '../client/TextRange.ts';
|
|
4
4
|
import type { TriggerNode, TriggerNodeDefinition } from '../client/TriggerNode.ts';
|
|
5
|
-
import type {
|
|
6
|
-
import
|
|
5
|
+
import type { ValueType } from '../client/ValueType.ts';
|
|
6
|
+
import { ErrorProductionDesignPendingError } from '../error/ErrorProductionDesignPendingError.ts';
|
|
7
7
|
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import type { StaticLeafElement } from '../integration/xpath/static-dom/StaticElement.ts';
|
|
9
|
+
import type { TriggerInputValue, TriggerRuntimeValue } from '../lib/codecs/TriggerCodec.ts';
|
|
10
|
+
import { TriggerCodec } from '../lib/codecs/TriggerCodec.ts';
|
|
10
11
|
import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
|
|
11
12
|
import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
|
|
12
13
|
import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
13
14
|
import { createSharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
14
15
|
import { createFieldHint } from '../lib/reactivity/text/createFieldHint.ts';
|
|
15
16
|
import { createNodeLabel } from '../lib/reactivity/text/createNodeLabel.ts';
|
|
16
|
-
import type { SimpleAtomicState } from '../lib/reactivity/types.ts';
|
|
17
|
-
import type { SharedValidationState } from '../lib/reactivity/validation/createValidation.ts';
|
|
18
|
-
import { createValidationState } from '../lib/reactivity/validation/createValidation.ts';
|
|
19
17
|
import type { UnknownAppearanceDefinition } from '../parse/body/appearance/unknownAppearanceParser.ts';
|
|
20
18
|
import type { Root } from './Root.ts';
|
|
21
|
-
import type
|
|
22
|
-
import { DescendantNode } from './abstract/DescendantNode.ts';
|
|
19
|
+
import { ValueNode, type ValueNodeStateSpec } from './abstract/ValueNode.ts';
|
|
23
20
|
import type { GeneralParentNode } from './hierarchy.ts';
|
|
24
21
|
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
25
22
|
import type { ValidationContext } from './internal-api/ValidationContext.ts';
|
|
26
|
-
import type {
|
|
27
|
-
import type { ClientReactiveSubmittableLeafNode } from './internal-api/submission/ClientReactiveSubmittableLeafNode.ts';
|
|
23
|
+
import type { ClientReactiveSerializableValueNode } from './internal-api/serialization/ClientReactiveSerializableValueNode.ts';
|
|
28
24
|
|
|
29
|
-
interface TriggerControlStateSpec extends
|
|
25
|
+
interface TriggerControlStateSpec extends ValueNodeStateSpec<TriggerRuntimeValue> {
|
|
30
26
|
readonly label: Accessor<TextRange<'label'> | null>;
|
|
31
27
|
readonly hint: Accessor<TextRange<'hint'> | null>;
|
|
32
|
-
readonly children: null;
|
|
33
|
-
readonly value: SimpleAtomicState<boolean>;
|
|
34
28
|
readonly valueOptions: null;
|
|
35
29
|
}
|
|
36
30
|
|
|
37
|
-
|
|
31
|
+
type AnyTriggerNodeDefinition = {
|
|
32
|
+
[V in ValueType]: TriggerNodeDefinition<V>;
|
|
33
|
+
}[ValueType];
|
|
34
|
+
|
|
35
|
+
const codec = new TriggerCodec();
|
|
38
36
|
|
|
39
37
|
export class TriggerControl
|
|
40
|
-
extends
|
|
38
|
+
extends ValueNode<
|
|
39
|
+
'string',
|
|
40
|
+
TriggerNodeDefinition<'string'>,
|
|
41
|
+
TriggerRuntimeValue,
|
|
42
|
+
TriggerInputValue
|
|
43
|
+
>
|
|
41
44
|
implements
|
|
42
45
|
TriggerNode,
|
|
43
46
|
XFormsXPathElement,
|
|
44
47
|
EvaluationContext,
|
|
45
48
|
ValidationContext,
|
|
46
|
-
|
|
47
|
-
ClientReactiveSubmittableLeafNode<boolean>
|
|
49
|
+
ClientReactiveSerializableValueNode
|
|
48
50
|
{
|
|
49
|
-
|
|
51
|
+
static from(
|
|
52
|
+
parent: GeneralParentNode,
|
|
53
|
+
instanceNode: StaticLeafElement | null,
|
|
54
|
+
definition: TriggerNodeDefinition
|
|
55
|
+
): TriggerControl;
|
|
56
|
+
static from(
|
|
57
|
+
parent: GeneralParentNode,
|
|
58
|
+
instanceNode: StaticLeafElement | null,
|
|
59
|
+
definition: AnyTriggerNodeDefinition
|
|
60
|
+
): TriggerControl {
|
|
61
|
+
if (definition.valueType !== 'string') {
|
|
62
|
+
throw new ErrorProductionDesignPendingError(
|
|
63
|
+
`Unsupported trigger value type: ${definition.valueType}`
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return new this(parent, instanceNode, definition);
|
|
68
|
+
}
|
|
50
69
|
|
|
51
70
|
// XFormsXPathElement
|
|
52
71
|
override readonly [XPathNodeKindKey] = 'element';
|
|
@@ -58,46 +77,17 @@ export class TriggerControl
|
|
|
58
77
|
// TriggerNode
|
|
59
78
|
readonly nodeType = 'trigger';
|
|
60
79
|
readonly appearances: UnknownAppearanceDefinition;
|
|
80
|
+
readonly nodeOptions = null;
|
|
61
81
|
readonly currentState: CurrentState<TriggerControlStateSpec>;
|
|
62
82
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// ValueContext
|
|
70
|
-
override readonly contextNode = this;
|
|
71
|
-
readonly encodeValue: (runtimeValue: boolean) => string;
|
|
72
|
-
readonly decodeValue: (instanceValue: string) => boolean;
|
|
73
|
-
|
|
74
|
-
constructor(parent: GeneralParentNode, definition: TriggerNodeDefinition) {
|
|
75
|
-
super(parent, definition);
|
|
83
|
+
private constructor(
|
|
84
|
+
parent: GeneralParentNode,
|
|
85
|
+
instanceNode: StaticLeafElement | null,
|
|
86
|
+
definition: TriggerNodeDefinition<'string'>
|
|
87
|
+
) {
|
|
88
|
+
super(parent, instanceNode, definition, codec);
|
|
76
89
|
|
|
77
90
|
this.appearances = definition.bodyElement.appearances;
|
|
78
|
-
this.encodeValue = (runtimeValue) => {
|
|
79
|
-
return runtimeValue ? TRIGGER_ASSIGNED_VALUE : '';
|
|
80
|
-
};
|
|
81
|
-
this.decodeValue = (instanceValue) => {
|
|
82
|
-
const value = instanceValue.trim();
|
|
83
|
-
|
|
84
|
-
switch (value) {
|
|
85
|
-
case TRIGGER_ASSIGNED_VALUE:
|
|
86
|
-
return true;
|
|
87
|
-
|
|
88
|
-
case '':
|
|
89
|
-
return false;
|
|
90
|
-
|
|
91
|
-
// TODO (robustness principle): Case insensitivity? Handle
|
|
92
|
-
// XPath-semantic booleans?? Other known/common equivalents?
|
|
93
|
-
default:
|
|
94
|
-
throw new Error(`Unexpected trigger value: ${value}`);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const sharedStateOptions = {
|
|
99
|
-
clientStateFactory: this.engineConfig.stateFactory,
|
|
100
|
-
};
|
|
101
91
|
|
|
102
92
|
const state = createSharedNodeState(
|
|
103
93
|
this.scope,
|
|
@@ -111,40 +101,20 @@ export class TriggerControl
|
|
|
111
101
|
hint: createFieldHint(this, definition),
|
|
112
102
|
children: null,
|
|
113
103
|
valueOptions: null,
|
|
114
|
-
value:
|
|
104
|
+
value: this.valueState,
|
|
105
|
+
instanceValue: this.getInstanceValue,
|
|
115
106
|
},
|
|
116
|
-
|
|
107
|
+
this.instanceConfig
|
|
117
108
|
);
|
|
118
109
|
|
|
119
110
|
this.state = state;
|
|
120
111
|
this.engineState = state.engineState;
|
|
121
112
|
this.currentState = state.currentState;
|
|
122
|
-
this.validation = createValidationState(this, sharedStateOptions);
|
|
123
|
-
this.submissionState = createLeafNodeSubmissionState(this);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// XFormsXPathElement
|
|
127
|
-
override getXPathValue(): string {
|
|
128
|
-
return this.encodeValue(this.engineState.value);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// ValidationContext
|
|
132
|
-
getViolation(): AnyViolation | null {
|
|
133
|
-
return this.validation.engineState.violation;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
isBlank(): boolean {
|
|
137
|
-
return this.engineState.value == null;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// InstanceNode
|
|
141
|
-
getChildren(): readonly [] {
|
|
142
|
-
return [];
|
|
143
113
|
}
|
|
144
114
|
|
|
145
115
|
// TriggerNode
|
|
146
|
-
setValue(value:
|
|
147
|
-
this.
|
|
116
|
+
setValue(value: TriggerInputValue): Root {
|
|
117
|
+
this.setValueState(value);
|
|
148
118
|
|
|
149
119
|
return this.root;
|
|
150
120
|
}
|
|
@@ -11,10 +11,11 @@ import type {
|
|
|
11
11
|
} from '../../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
12
12
|
import { XFORMS_XPATH_NODE_RANGE_KIND } from '../../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
13
13
|
import type { EngineXPathEvaluator } from '../../integration/xpath/EngineXPathEvaluator.ts';
|
|
14
|
+
import type { StaticElement } from '../../integration/xpath/static-dom/StaticElement.ts';
|
|
14
15
|
import { createComputedExpression } from '../../lib/reactivity/createComputedExpression.ts';
|
|
15
16
|
import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
16
|
-
import type { AnyDescendantNodeDefinition } from '../../parse/model/DescendentNodeDefinition.ts';
|
|
17
17
|
import type { AnyNodeDefinition } from '../../parse/model/NodeDefinition.ts';
|
|
18
|
+
import type { DescendantNodeInitOptions } from '../children/DescendantNodeInitOptions.ts';
|
|
18
19
|
import type { AnyChildNode, AnyParentNode, RepeatRange } from '../hierarchy.ts';
|
|
19
20
|
import type { EvaluationContext } from '../internal-api/EvaluationContext.ts';
|
|
20
21
|
import type { RepeatInstance } from '../repeat/RepeatInstance.ts';
|
|
@@ -35,11 +36,7 @@ export type DescendantNodeStateSpec<Value = never> =
|
|
|
35
36
|
& InstanceNodeStateSpec<Value>
|
|
36
37
|
& DescendantNodeSharedStateSpec;
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
export type DescendantNodeDefinition = Extract<
|
|
40
|
-
AnyNodeDefinition,
|
|
41
|
-
AnyDescendantNodeDefinition
|
|
42
|
-
>;
|
|
39
|
+
export type DescendantNodeDefinition = AnyNodeDefinition;
|
|
43
40
|
|
|
44
41
|
export type AnyDescendantNode = DescendantNode<
|
|
45
42
|
DescendantNodeDefinition,
|
|
@@ -55,6 +52,13 @@ interface DescendantNodeOptions {
|
|
|
55
52
|
readonly computeReference?: Accessor<string>;
|
|
56
53
|
}
|
|
57
54
|
|
|
55
|
+
/**
|
|
56
|
+
* @todo Unify constructor signatures of {@link DescendantNode} and its
|
|
57
|
+
* subclasses, which will simplify the branchy logic of child node construction
|
|
58
|
+
* and minimize internal churn as common themes evolve. A good starting point is
|
|
59
|
+
* beginning to form in {@link DescendantNodeInitOptions} (not to be confused
|
|
60
|
+
* with the current module-local {@link DescendantNodeOptions}).
|
|
61
|
+
*/
|
|
58
62
|
export abstract class DescendantNode<
|
|
59
63
|
Definition extends DescendantNodeDefinition,
|
|
60
64
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -133,10 +137,11 @@ export abstract class DescendantNode<
|
|
|
133
137
|
|
|
134
138
|
constructor(
|
|
135
139
|
override readonly parent: Parent,
|
|
140
|
+
override readonly instanceNode: StaticElement | null,
|
|
136
141
|
override readonly definition: Definition,
|
|
137
142
|
options?: DescendantNodeOptions
|
|
138
143
|
) {
|
|
139
|
-
super(parent.
|
|
144
|
+
super(parent.instanceConfig, parent, instanceNode, definition, options);
|
|
140
145
|
|
|
141
146
|
if (this.isRoot()) {
|
|
142
147
|
this.root = this;
|
|
@@ -147,7 +152,7 @@ export abstract class DescendantNode<
|
|
|
147
152
|
const { evaluator } = parent;
|
|
148
153
|
|
|
149
154
|
// See notes on property declaration
|
|
150
|
-
if (definition.type === 'repeat
|
|
155
|
+
if (definition.type === 'repeat') {
|
|
151
156
|
this[XPathNodeKindKey] = XFORMS_XPATH_NODE_RANGE_KIND;
|
|
152
157
|
} else {
|
|
153
158
|
this[XPathNodeKindKey] = 'element';
|
|
@@ -4,7 +4,7 @@ import type { BaseNode } from '../../client/BaseNode.ts';
|
|
|
4
4
|
import type { NodeAppearances } from '../../client/NodeAppearances.ts';
|
|
5
5
|
import type { FormNodeID } from '../../client/identity.ts';
|
|
6
6
|
import type { InstanceNodeType as ClientInstanceNodeType } from '../../client/node-types.ts';
|
|
7
|
-
import type {
|
|
7
|
+
import type { InstanceState } from '../../client/serialization/InstanceState.ts';
|
|
8
8
|
import type { NodeValidationState } from '../../client/validation.ts';
|
|
9
9
|
import type { ActiveLanguage, TextRange } from '../../index.ts';
|
|
10
10
|
import type { EngineXPathEvaluator } from '../../integration/xpath/EngineXPathEvaluator.ts';
|
|
@@ -13,6 +13,8 @@ import type {
|
|
|
13
13
|
XFormsXPathPrimaryInstanceNodeKind,
|
|
14
14
|
} from '../../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
15
15
|
import type { PrimaryInstanceXPathNode } from '../../integration/xpath/adapter/kind.ts';
|
|
16
|
+
import type { StaticDocument } from '../../integration/xpath/static-dom/StaticDocument.ts';
|
|
17
|
+
import type { StaticElement } from '../../integration/xpath/static-dom/StaticElement.ts';
|
|
16
18
|
import type { MaterializedChildren } from '../../lib/reactivity/materializeCurrentStateChildren.ts';
|
|
17
19
|
import type { CurrentState } from '../../lib/reactivity/node-state/createCurrentState.ts';
|
|
18
20
|
import type { EngineState } from '../../lib/reactivity/node-state/createEngineState.ts';
|
|
@@ -20,6 +22,7 @@ import type { SharedNodeState } from '../../lib/reactivity/node-state/createShar
|
|
|
20
22
|
import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
21
23
|
import { createReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
22
24
|
import type { SimpleAtomicState } from '../../lib/reactivity/types.ts';
|
|
25
|
+
import { createUniqueId } from '../../lib/unique-id.ts';
|
|
23
26
|
import type { AnyNodeDefinition } from '../../parse/model/NodeDefinition.ts';
|
|
24
27
|
import type { PrimaryInstance } from '../PrimaryInstance.ts';
|
|
25
28
|
import type { Root } from '../Root.ts';
|
|
@@ -34,6 +37,12 @@ export interface BaseEngineNode extends Omit<BaseNode, 'nodeType'> {
|
|
|
34
37
|
readonly nodeType: EngineInstanceNodeType;
|
|
35
38
|
}
|
|
36
39
|
|
|
40
|
+
// prettier-ignore
|
|
41
|
+
export type InstanceNodeValueOptionsStateSpec =
|
|
42
|
+
| Accessor<null>
|
|
43
|
+
| Accessor<readonly unknown[]>
|
|
44
|
+
| null
|
|
45
|
+
|
|
37
46
|
export interface InstanceNodeStateSpec<Value = never> {
|
|
38
47
|
readonly reference: Accessor<string> | string;
|
|
39
48
|
readonly readonly: Accessor<boolean> | boolean;
|
|
@@ -42,7 +51,7 @@ export interface InstanceNodeStateSpec<Value = never> {
|
|
|
42
51
|
readonly label: Accessor<TextRange<'label'> | null> | null;
|
|
43
52
|
readonly hint: Accessor<TextRange<'hint'> | null> | null;
|
|
44
53
|
readonly children: Accessor<readonly FormNodeID[]> | null;
|
|
45
|
-
readonly valueOptions:
|
|
54
|
+
readonly valueOptions: InstanceNodeValueOptionsStateSpec;
|
|
46
55
|
readonly value: Signal<Value> | SimpleAtomicState<Value> | null;
|
|
47
56
|
}
|
|
48
57
|
|
|
@@ -136,11 +145,13 @@ export abstract class InstanceNode<
|
|
|
136
145
|
|
|
137
146
|
abstract readonly appearances: NodeAppearances<Definition>;
|
|
138
147
|
|
|
148
|
+
abstract readonly nodeOptions: object | null;
|
|
149
|
+
|
|
139
150
|
abstract readonly currentState: InstanceNodeCurrentState<Spec, Child>;
|
|
140
151
|
|
|
141
152
|
abstract readonly validationState: NodeValidationState;
|
|
142
153
|
|
|
143
|
-
abstract readonly
|
|
154
|
+
abstract readonly instanceState: InstanceState;
|
|
144
155
|
|
|
145
156
|
// EvaluationContext: instance-global/shared
|
|
146
157
|
abstract readonly evaluator: EngineXPathEvaluator;
|
|
@@ -161,7 +172,7 @@ export abstract class InstanceNode<
|
|
|
161
172
|
);
|
|
162
173
|
}
|
|
163
174
|
|
|
164
|
-
return `${parent.contextReference()}/${definition.
|
|
175
|
+
return `${parent.contextReference()}/${definition.qualifiedName.getPrefixedName()}`;
|
|
165
176
|
};
|
|
166
177
|
|
|
167
178
|
// EvaluationContext: node-specific
|
|
@@ -178,8 +189,9 @@ export abstract class InstanceNode<
|
|
|
178
189
|
this as AnyInstanceNode as PrimaryInstanceXPathNode;
|
|
179
190
|
|
|
180
191
|
constructor(
|
|
181
|
-
readonly
|
|
192
|
+
readonly instanceConfig: InstanceConfig,
|
|
182
193
|
readonly parent: Parent,
|
|
194
|
+
readonly instanceNode: StaticDocument | StaticElement | null,
|
|
183
195
|
readonly definition: Definition,
|
|
184
196
|
options?: InstanceNodeOptions
|
|
185
197
|
) {
|
|
@@ -200,8 +212,8 @@ export abstract class InstanceNode<
|
|
|
200
212
|
this.computeReference = options?.computeReference ?? this.computeChildStepReference;
|
|
201
213
|
|
|
202
214
|
this.scope = options?.scope ?? createReactiveScope();
|
|
203
|
-
this.
|
|
204
|
-
this.nodeId = nodeID(
|
|
215
|
+
this.instanceConfig = instanceConfig;
|
|
216
|
+
this.nodeId = nodeID(createUniqueId());
|
|
205
217
|
this.definition = definition;
|
|
206
218
|
}
|
|
207
219
|
|
|
@@ -2,11 +2,12 @@ import { XPathNodeKindKey } from '@getodk/xpath';
|
|
|
2
2
|
import type { Accessor } from 'solid-js';
|
|
3
3
|
import type { BaseValueNode } from '../../client/BaseValueNode.ts';
|
|
4
4
|
import type { LeafNodeType as ValueNodeType } from '../../client/node-types.ts';
|
|
5
|
-
import type {
|
|
5
|
+
import type { InstanceState } from '../../client/serialization/InstanceState.ts';
|
|
6
6
|
import type { AnyViolation, LeafNodeValidationState } from '../../client/validation.ts';
|
|
7
7
|
import type { ValueType } from '../../client/ValueType.ts';
|
|
8
8
|
import type { XFormsXPathElement } from '../../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
9
|
-
import {
|
|
9
|
+
import type { StaticLeafElement } from '../../integration/xpath/static-dom/StaticElement.ts';
|
|
10
|
+
import { createValueNodeInstanceState } from '../../lib/client-reactivity/instance-state/createValueNodeInstanceState.ts';
|
|
10
11
|
import type {
|
|
11
12
|
RuntimeValueSetter,
|
|
12
13
|
RuntimeValueState,
|
|
@@ -26,7 +27,7 @@ import type {
|
|
|
26
27
|
DecodeInstanceValue,
|
|
27
28
|
InstanceValueContext,
|
|
28
29
|
} from '../internal-api/InstanceValueContext.ts';
|
|
29
|
-
import type {
|
|
30
|
+
import type { ClientReactiveSerializableValueNode } from '../internal-api/serialization/ClientReactiveSerializableValueNode.ts';
|
|
30
31
|
import type { ValidationContext } from '../internal-api/ValidationContext.ts';
|
|
31
32
|
import type { DescendantNodeStateSpec } from './DescendantNode.ts';
|
|
32
33
|
import { DescendantNode } from './DescendantNode.ts';
|
|
@@ -35,7 +36,6 @@ export type ValueNodeDefinition<V extends ValueType> = LeafNodeDefinition<V>;
|
|
|
35
36
|
|
|
36
37
|
export interface ValueNodeStateSpec<RuntimeValue> extends DescendantNodeStateSpec<RuntimeValue> {
|
|
37
38
|
readonly children: null;
|
|
38
|
-
readonly valueOptions: null;
|
|
39
39
|
readonly value: SimpleAtomicState<RuntimeValue>;
|
|
40
40
|
readonly instanceValue: Accessor<string>;
|
|
41
41
|
}
|
|
@@ -53,7 +53,7 @@ export abstract class ValueNode<
|
|
|
53
53
|
EvaluationContext,
|
|
54
54
|
InstanceValueContext,
|
|
55
55
|
ValidationContext,
|
|
56
|
-
|
|
56
|
+
ClientReactiveSerializableValueNode
|
|
57
57
|
{
|
|
58
58
|
protected readonly validation: SharedValidationState;
|
|
59
59
|
protected readonly getInstanceValue: Accessor<string>;
|
|
@@ -81,21 +81,20 @@ export abstract class ValueNode<
|
|
|
81
81
|
return this.validation.currentState;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
readonly
|
|
84
|
+
readonly instanceState: InstanceState;
|
|
85
85
|
|
|
86
86
|
constructor(
|
|
87
87
|
parent: GeneralParentNode,
|
|
88
|
+
override readonly instanceNode: StaticLeafElement | null,
|
|
88
89
|
definition: Definition,
|
|
89
90
|
codec: ValueCodec<V, RuntimeValue, RuntimeInputValue>
|
|
90
91
|
) {
|
|
91
|
-
super(parent, definition);
|
|
92
|
+
super(parent, instanceNode, definition);
|
|
92
93
|
|
|
93
94
|
this.valueType = definition.valueType;
|
|
94
95
|
this.decodeInstanceValue = codec.decodeInstanceValue;
|
|
95
96
|
|
|
96
|
-
const instanceValueState = createInstanceValueState(this
|
|
97
|
-
initialValueSource: 'FORM_DEFAULT',
|
|
98
|
-
});
|
|
97
|
+
const instanceValueState = createInstanceValueState(this);
|
|
99
98
|
const valueState = codec.createRuntimeValueState(instanceValueState);
|
|
100
99
|
|
|
101
100
|
const [getInstanceValue] = instanceValueState;
|
|
@@ -103,12 +102,12 @@ export abstract class ValueNode<
|
|
|
103
102
|
|
|
104
103
|
this.getInstanceValue = getInstanceValue;
|
|
105
104
|
this.setValueState = setValueState;
|
|
106
|
-
this.getXPathValue =
|
|
105
|
+
this.getXPathValue = () => {
|
|
106
|
+
return this.getInstanceValue();
|
|
107
|
+
};
|
|
107
108
|
this.valueState = valueState;
|
|
108
|
-
this.validation = createValidationState(this,
|
|
109
|
-
|
|
110
|
-
});
|
|
111
|
-
this.submissionState = createValueNodeSubmissionState(this);
|
|
109
|
+
this.validation = createValidationState(this, this.instanceConfig);
|
|
110
|
+
this.instanceState = createValueNodeInstanceState(this);
|
|
112
111
|
}
|
|
113
112
|
|
|
114
113
|
// ValidationContext
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { StaticElement } from '../../integration/xpath/static-dom/StaticElement.ts';
|
|
2
|
+
import type { ChildNodeDefinition } from '../../parse/model/NodeDefinition.ts';
|
|
3
|
+
import type { DescendantNode } from '../abstract/DescendantNode.ts';
|
|
4
|
+
import type { childrenInitOptions } from './childrenInitOptions.ts';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @todo We could pretty significantly simplify downstream child node
|
|
8
|
+
* construction logic, if we break this down into a tagged union (essentially
|
|
9
|
+
* moving the branchy type refinement aspects up the stack, probably trimming
|
|
10
|
+
* the construction logic itself down to a switch statement). At which point,
|
|
11
|
+
* it'd also probably be easier to reason about each of those constructors
|
|
12
|
+
* accepting input exactly as it's represented as a member of this hypothetical
|
|
13
|
+
* tagged union. Something like this:
|
|
14
|
+
*
|
|
15
|
+
* - Revise each concrete {@link DescendantNode} class to accept an options-like
|
|
16
|
+
* object suitable for its construction, each respectively defined by an
|
|
17
|
+
* interface whose name is consistent with that node
|
|
18
|
+
* - Update this type to be a union of those interfaces
|
|
19
|
+
* - Implement that in {@link childrenInitOptions}
|
|
20
|
+
* - Update downstream construction to switch over whatever narrows the union
|
|
21
|
+
* - Bonus points: revise each concrete {@link DescendantNode} to use a common
|
|
22
|
+
* constructor API (i.e. a static `from` method, since several such classes
|
|
23
|
+
* already have private constructors). Then downstream isn't even a switch
|
|
24
|
+
* statement, it's just a lookup table.
|
|
25
|
+
*
|
|
26
|
+
* @todo As of this commit, and as now mentioned on {@link DescendantNode}, and
|
|
27
|
+
* as discussed in
|
|
28
|
+
* {@link https://github.com/getodk/web-forms/pull/352#discussion_r2008237762}:
|
|
29
|
+
* this interface is intended as an intermediate step toward these goals.
|
|
30
|
+
*/
|
|
31
|
+
export interface DescendantNodeInitOptions {
|
|
32
|
+
readonly childNodeset: string;
|
|
33
|
+
readonly definition: ChildNodeDefinition;
|
|
34
|
+
readonly instanceNodes: readonly StaticElement[];
|
|
35
|
+
}
|