@getodk/xforms-engine 0.6.0 → 0.8.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/dist/client/BaseNode.d.ts +4 -4
- package/dist/client/BaseValueNode.d.ts +7 -3
- package/dist/client/RootNode.d.ts +20 -16
- package/dist/client/UploadNode.d.ts +53 -0
- package/dist/client/attachments/InstanceAttachmentMeta.d.ts +8 -0
- package/dist/client/attachments/InstanceAttachmentsConfig.d.ts +8 -0
- 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 +19 -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 +4 -5
- package/dist/client/index.d.ts +40 -11
- package/dist/client/node-types.d.ts +2 -3
- 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 +14 -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 +24 -0
- package/dist/client/serialization/InstanceState.d.ts +12 -0
- package/dist/client/submission/{SubmissionDefinition.d.ts → SubmissionMeta.d.ts} +1 -1
- 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/TemplatedNodeAttributeSerializationError.d.ts +22 -0
- package/dist/error/UploadValueTypeError.d.ts +8 -0
- package/dist/index.d.ts +2 -33
- package/dist/index.js +8280 -6779
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +6 -5
- package/dist/instance/InputControl.d.ts +5 -4
- package/dist/instance/ModelValue.d.ts +5 -4
- package/dist/instance/Note.d.ts +4 -3
- package/dist/instance/PrimaryInstance.d.ts +34 -8
- package/dist/instance/RangeControl.d.ts +5 -4
- package/dist/instance/RankControl.d.ts +6 -5
- package/dist/instance/Root.d.ts +7 -9
- package/dist/instance/SelectControl.d.ts +4 -3
- package/dist/instance/Subtree.d.ts +6 -5
- package/dist/instance/TriggerControl.d.ts +4 -3
- package/dist/instance/UploadControl.d.ts +58 -0
- package/dist/instance/abstract/DescendantNode.d.ts +10 -1
- package/dist/instance/abstract/InstanceNode.d.ts +7 -4
- package/dist/instance/abstract/ValueNode.d.ts +7 -5
- package/dist/instance/attachments/InstanceAttachment.d.ts +42 -0
- package/dist/instance/attachments/InstanceAttachmentsState.d.ts +9 -0
- 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 +6 -7
- package/dist/instance/input/InitialInstanceState.d.ts +13 -0
- package/dist/instance/input/InstanceAttachmentMap.d.ts +19 -0
- package/dist/instance/internal-api/InstanceAttachmentContext.d.ts +19 -0
- package/dist/instance/internal-api/InstanceConfig.d.ts +4 -9
- package/dist/instance/internal-api/InstanceValueContext.d.ts +8 -1
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableInstance.d.ts +16 -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 +10 -8
- package/dist/instance/repeat/RepeatInstance.d.ts +10 -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/integration/xpath/EngineXPathEvaluator.d.ts +2 -2
- package/dist/integration/xpath/adapter/kind.d.ts +4 -10
- package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +4 -5
- package/dist/integration/xpath/static-dom/StaticDocument.d.ts +13 -10
- package/dist/integration/xpath/static-dom/StaticElement.d.ts +21 -22
- 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/names/UnprefixedXFormsName.d.ts +4 -0
- package/dist/lib/reactivity/createInstanceAttachment.d.ts +8 -0
- package/dist/lib/reactivity/createInstanceValueState.d.ts +2 -27
- package/dist/lib/resource-helpers.d.ts +2 -0
- package/dist/parse/XFormDOM.d.ts +1 -1
- package/dist/parse/body/BodyDefinition.d.ts +2 -1
- package/dist/parse/body/control/UploadControlDefinition.d.ts +2 -0
- package/dist/parse/model/BindDefinition.d.ts +1 -1
- package/dist/parse/model/BindTypeDefinition.d.ts +2 -7
- package/dist/parse/model/ItextTranslationsDefinition.d.ts +18 -0
- package/dist/parse/model/LeafNodeDefinition.d.ts +4 -5
- package/dist/parse/model/ModelBindMap.d.ts +1 -1
- package/dist/parse/model/ModelDefinition.d.ts +9 -2
- package/dist/parse/model/NodeDefinition.d.ts +18 -30
- package/dist/parse/model/NoteNodeDefinition.d.ts +3 -2
- package/dist/parse/model/RangeNodeDefinition.d.ts +2 -1
- package/dist/parse/model/RepeatDefinition.d.ts +62 -0
- package/dist/parse/model/RootAttributeDefinition.d.ts +1 -4
- package/dist/parse/model/RootAttributeMap.d.ts +2 -1
- package/dist/parse/model/RootDefinition.d.ts +7 -8
- 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 +4 -5
- 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 -21
- package/dist/solid.js +8251 -6751
- package/dist/solid.js.map +1 -1
- package/package.json +15 -14
- package/src/client/BaseNode.ts +4 -4
- package/src/client/BaseValueNode.ts +7 -3
- package/src/client/RootNode.ts +32 -19
- package/src/client/UploadNode.ts +78 -0
- package/src/client/attachments/InstanceAttachmentMeta.ts +10 -0
- package/src/client/attachments/InstanceAttachmentsConfig.ts +13 -0
- 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 +21 -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 +5 -8
- package/src/client/index.ts +49 -29
- package/src/client/node-types.ts +3 -8
- 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 +24 -0
- package/src/client/serialization/InstanceFile.ts +9 -0
- package/src/client/serialization/InstancePayload.ts +126 -0
- package/src/client/serialization/InstancePayloadOptions.ts +29 -0
- package/src/client/serialization/InstanceState.ts +14 -0
- package/src/client/submission/{SubmissionDefinition.ts → SubmissionMeta.ts} +1 -1
- package/src/entrypoints/FormInstance.ts +56 -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/TemplatedNodeAttributeSerializationError.ts +24 -0
- package/src/error/UploadValueTypeError.ts +13 -0
- package/src/index.ts +2 -46
- package/src/instance/Group.ts +16 -15
- package/src/instance/InputControl.ts +17 -11
- package/src/instance/ModelValue.ts +17 -11
- package/src/instance/Note.ts +10 -9
- package/src/instance/PrimaryInstance.ts +68 -31
- package/src/instance/RangeControl.ts +17 -11
- package/src/instance/RankControl.ts +28 -19
- package/src/instance/Root.ts +20 -31
- package/src/instance/SelectControl.ts +21 -12
- package/src/instance/Subtree.ts +16 -15
- package/src/instance/TriggerControl.ts +21 -12
- package/src/instance/UploadControl.ts +184 -0
- package/src/instance/abstract/DescendantNode.ts +12 -2
- package/src/instance/abstract/InstanceNode.ts +9 -5
- package/src/instance/abstract/ValueNode.ts +11 -13
- package/src/instance/attachments/InstanceAttachment.ts +69 -0
- package/src/instance/attachments/InstanceAttachmentsState.ts +18 -0
- package/src/instance/children/DescendantNodeInitOptions.ts +35 -0
- package/src/instance/{children.ts → children/buildChildren.ts} +57 -53
- package/src/instance/children/childrenInitOptions.ts +117 -0
- package/src/instance/children/normalizeChildInitOptions.ts +332 -0
- package/src/instance/hierarchy.ts +6 -9
- package/src/instance/input/InitialInstanceState.ts +108 -0
- package/src/instance/input/InstanceAttachmentMap.ts +154 -0
- package/src/instance/internal-api/InstanceAttachmentContext.ts +20 -0
- package/src/instance/internal-api/InstanceConfig.ts +6 -10
- package/src/instance/internal-api/InstanceValueContext.ts +9 -1
- package/src/instance/internal-api/serialization/ClientReactiveSerializableInstance.ts +22 -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 +19 -24
- package/src/instance/repeat/RepeatInstance.ts +26 -19
- package/src/instance/repeat/RepeatRangeControlled.ts +90 -17
- package/src/instance/repeat/RepeatRangeUncontrolled.ts +10 -9
- package/src/instance/resource.ts +14 -1
- package/src/integration/xpath/EngineXPathEvaluator.ts +2 -2
- package/src/integration/xpath/adapter/kind.ts +1 -28
- package/src/integration/xpath/adapter/traversal.ts +2 -2
- package/src/integration/xpath/static-dom/StaticAttribute.ts +6 -5
- package/src/integration/xpath/static-dom/StaticDocument.ts +17 -16
- package/src/integration/xpath/static-dom/StaticElement.ts +196 -50
- 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/{submission/createRootSubmissionState.ts → instance-state/createRootInstanceState.ts} +4 -4
- 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 +237 -0
- package/src/lib/names/UnprefixedXFormsName.ts +12 -0
- package/src/lib/reactivity/createInstanceAttachment.ts +212 -0
- package/src/lib/reactivity/createInstanceValueState.ts +27 -51
- package/src/lib/resource-helpers.ts +33 -0
- package/src/parse/XFormDOM.ts +1 -3
- package/src/parse/body/BodyDefinition.ts +4 -0
- package/src/parse/body/control/UploadControlDefinition.ts +42 -0
- package/src/parse/model/BindDefinition.ts +1 -1
- package/src/parse/model/BindTypeDefinition.ts +68 -26
- package/src/parse/model/ItextTranslationsDefinition.ts +79 -0
- package/src/parse/model/LeafNodeDefinition.ts +3 -5
- package/src/parse/model/ModelBindMap.ts +0 -5
- package/src/parse/model/ModelDefinition.ts +36 -3
- package/src/parse/model/NodeDefinition.ts +19 -45
- package/src/parse/model/NoteNodeDefinition.ts +4 -3
- package/src/parse/model/RangeNodeDefinition.ts +3 -2
- package/src/parse/model/RepeatDefinition.ts +382 -0
- package/src/parse/model/RootAttributeDefinition.ts +6 -7
- package/src/parse/model/RootAttributeMap.ts +15 -10
- package/src/parse/model/RootDefinition.ts +17 -19
- 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/ExternalSecondaryInstanceResource.ts +1 -30
- package/src/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.ts +64 -137
- 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 +4 -5
- package/src/parse/model/nodeDefinitionMap.ts +34 -0
- package/src/parse/shared/parseInstanceXML.ts +79 -0
- package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +45 -130
- 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/UnsupportedControlNode.d.ts +0 -30
- package/dist/client/unsupported/UploadNode.d.ts +0 -9
- package/dist/instance/abstract/UnsupportedControl.d.ts +0 -54
- 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 -32
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +0 -19
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +0 -18
- package/dist/instance/unsupported/UploadControl.d.ts +0 -6
- 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/createRootSubmissionState.d.ts +0 -3
- 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/createValueState.d.ts +0 -40
- package/dist/parse/model/ItextTranslation/ItextTranslationDefinition.d.ts +0 -4
- package/dist/parse/model/ItextTranslation/ItextTranslationRootDefinition.d.ts +0 -9
- package/dist/parse/model/ItextTranslation/ItextTranslationsDefinition.d.ts +0 -8
- package/dist/parse/model/RepeatInstanceDefinition.d.ts +0 -17
- package/dist/parse/model/RepeatRangeDefinition.d.ts +0 -32
- package/dist/parse/model/RepeatTemplateDefinition.d.ts +0 -31
- 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/UnsupportedControlNode.ts +0 -36
- package/src/client/unsupported/UploadNode.ts +0 -14
- package/src/instance/abstract/UnsupportedControl.ts +0 -175
- 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 -43
- package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +0 -26
- package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +0 -24
- package/src/instance/unsupported/UploadControl.ts +0 -9
- 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/model/ItextTranslation/ItextTranslationDefinition.ts +0 -4
- package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +0 -42
- package/src/parse/model/ItextTranslation/ItextTranslationsDefinition.ts +0 -31
- package/src/parse/model/RepeatInstanceDefinition.ts +0 -38
- package/src/parse/model/RepeatRangeDefinition.ts +0 -98
- package/src/parse/model/RepeatTemplateDefinition.ts +0 -149
- package/src/parse/model/SecondaryInstance/SecondaryInstanceDefinition.ts +0 -4
- package/src/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.ts +0 -12
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { UploadMediaOptions, UploadNodeOptions } from '../../../client/UploadNode.ts';
|
|
2
|
+
import { ErrorProductionDesignPendingError } from '../../../error/ErrorProductionDesignPendingError.ts';
|
|
1
3
|
import type { XFormDefinition } from '../../XFormDefinition.ts';
|
|
2
4
|
import {
|
|
3
5
|
unknownAppearanceParser,
|
|
@@ -6,6 +8,44 @@ import {
|
|
|
6
8
|
import type { BodyElementParentContext } from '../BodyDefinition.ts';
|
|
7
9
|
import { ControlDefinition } from './ControlDefinition.ts';
|
|
8
10
|
|
|
11
|
+
const MEDIATYPE_PATTERN = /^([^/]+)\/([^/]+)$/;
|
|
12
|
+
|
|
13
|
+
// prettier-ignore
|
|
14
|
+
type MediaTypeMatches =
|
|
15
|
+
| readonly [$0: string, $1: string, $2: string];
|
|
16
|
+
|
|
17
|
+
const parseUploadMediaOptions = (element: Element): UploadMediaOptions => {
|
|
18
|
+
const mediaType = element.getAttribute('mediatype')?.trim();
|
|
19
|
+
|
|
20
|
+
if (mediaType == null || mediaType === '') {
|
|
21
|
+
return {
|
|
22
|
+
accept: '*',
|
|
23
|
+
type: null,
|
|
24
|
+
subtype: null,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const matches = MEDIATYPE_PATTERN.exec(mediaType) as MediaTypeMatches | null;
|
|
29
|
+
|
|
30
|
+
if (matches == null) {
|
|
31
|
+
throw new ErrorProductionDesignPendingError(`Unsupported mediatype: ${mediaType}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const [accept, type, subtype] = matches;
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
accept,
|
|
38
|
+
type,
|
|
39
|
+
subtype,
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const parseUploadNodeOptions = (element: Element): UploadNodeOptions => {
|
|
44
|
+
const media = parseUploadMediaOptions(element);
|
|
45
|
+
|
|
46
|
+
return { media };
|
|
47
|
+
};
|
|
48
|
+
|
|
9
49
|
export class UploadControlDefinition extends ControlDefinition<'upload'> {
|
|
10
50
|
static override isCompatible(localName: string): boolean {
|
|
11
51
|
return localName === 'upload';
|
|
@@ -13,11 +53,13 @@ export class UploadControlDefinition extends ControlDefinition<'upload'> {
|
|
|
13
53
|
|
|
14
54
|
readonly type = 'upload';
|
|
15
55
|
readonly appearances: UnknownAppearanceDefinition;
|
|
56
|
+
readonly options: UploadNodeOptions;
|
|
16
57
|
|
|
17
58
|
constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element) {
|
|
18
59
|
super(form, parent, element);
|
|
19
60
|
|
|
20
61
|
this.appearances = unknownAppearanceParser.parseFrom(element, 'appearance');
|
|
62
|
+
this.options = parseUploadNodeOptions(element);
|
|
21
63
|
}
|
|
22
64
|
|
|
23
65
|
override toJSON(): object {
|
|
@@ -80,7 +80,7 @@ export class BindDefinition<T extends BindType = BindType> extends DependencyCon
|
|
|
80
80
|
) {
|
|
81
81
|
super();
|
|
82
82
|
|
|
83
|
-
this.type = BindTypeDefinition.from(bindElement);
|
|
83
|
+
this.type = BindTypeDefinition.from(form, nodeset, bindElement);
|
|
84
84
|
|
|
85
85
|
const parentNodeset = nodeset.replace(/\/[^/]+$/, '');
|
|
86
86
|
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import { XSD_NAMESPACE_URI, XSD_PREFIX } from '@getodk/common/constants/xmlns.ts';
|
|
2
|
+
import type { AnyBodyElementType } from '../body/BodyDefinition.ts';
|
|
3
|
+
import type { XFormDefinition } from '../XFormDefinition.ts';
|
|
2
4
|
import { parseQualifiedNameExpression } from '../xpath/semantic-analysis.ts';
|
|
3
5
|
import type { BindElement } from './BindElement.ts';
|
|
4
6
|
|
|
5
|
-
/**
|
|
6
|
-
* As specified by {@link https://getodk.github.io/xforms-spec/#bind-attributes}
|
|
7
|
-
*/
|
|
8
|
-
export const DEFAULT_BIND_TYPE = 'string';
|
|
9
|
-
|
|
10
|
-
export type DefaultBindType = typeof DEFAULT_BIND_TYPE;
|
|
11
|
-
|
|
12
7
|
/**
|
|
13
8
|
* As specified by {@link https://getodk.github.io/xforms-spec/#data-types}
|
|
14
9
|
*/
|
|
15
10
|
const BIND_TYPES = [
|
|
16
|
-
|
|
11
|
+
'string',
|
|
17
12
|
'int',
|
|
18
13
|
'boolean',
|
|
19
14
|
'decimal',
|
|
@@ -32,6 +27,47 @@ type BindTypes = typeof BIND_TYPES;
|
|
|
32
27
|
|
|
33
28
|
export type BindType = BindTypes[number];
|
|
34
29
|
|
|
30
|
+
type BindTypeDefaultOverridesByBodyType = Partial<Readonly<Record<AnyBodyElementType, BindType>>>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* As specified by {@link https://getodk.github.io/xforms-spec/#bind-attributes}
|
|
34
|
+
*/
|
|
35
|
+
const SPEC_BIND_TYPE_DEFAULT = 'string' satisfies BindType;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* If an `<upload>` is not explicitly associated with any `<bind type>`, we can do one of two things:
|
|
39
|
+
*
|
|
40
|
+
* - correct: default to {@link SPEC_BIND_TYPE_DEFAULT | the spec default regardless of control type}
|
|
41
|
+
* - more useful and robust: default to "binary", which is the only type the spec allows for an `<upload>` control
|
|
42
|
+
*
|
|
43
|
+
* Asked which would be preferable, @lognaturel responded:
|
|
44
|
+
*
|
|
45
|
+
* > I think we should assume in the spirit of doing the most useful thing!
|
|
46
|
+
*/
|
|
47
|
+
const UPLOAD_BIND_TYPE_DEFAULT = 'binary' satisfies BindType;
|
|
48
|
+
|
|
49
|
+
const BODY_BIND_TYPE_DEFAULT_OVERRIDES = {
|
|
50
|
+
upload: UPLOAD_BIND_TYPE_DEFAULT,
|
|
51
|
+
} as const satisfies BindTypeDefaultOverridesByBodyType;
|
|
52
|
+
|
|
53
|
+
type BodyBindTypeDefaultOverrides = typeof BODY_BIND_TYPE_DEFAULT_OVERRIDES;
|
|
54
|
+
|
|
55
|
+
type BodyBindTypeDefaultOverride = keyof BodyBindTypeDefaultOverrides;
|
|
56
|
+
|
|
57
|
+
const isBodyBindTypeDefaultOverride = (
|
|
58
|
+
bodyElementType: AnyBodyElementType | null
|
|
59
|
+
): bodyElementType is BodyBindTypeDefaultOverride => {
|
|
60
|
+
return bodyElementType != null && bodyElementType in BODY_BIND_TYPE_DEFAULT_OVERRIDES;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const resolveDefaultBindType = (bodyElementType: AnyBodyElementType | null): BindType => {
|
|
64
|
+
if (isBodyBindTypeDefaultOverride(bodyElementType)) {
|
|
65
|
+
return BODY_BIND_TYPE_DEFAULT_OVERRIDES[bodyElementType];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return SPEC_BIND_TYPE_DEFAULT;
|
|
69
|
+
};
|
|
70
|
+
|
|
35
71
|
const isBindType = (value: string): value is BindType => {
|
|
36
72
|
return BIND_TYPES.includes(value as BindType);
|
|
37
73
|
};
|
|
@@ -42,14 +78,10 @@ const resolveSupportedBindType = (sourceType: string): BindType | null => {
|
|
|
42
78
|
|
|
43
79
|
type BindTypeAliasMapping = Readonly<Record<string, BindType>>;
|
|
44
80
|
|
|
45
|
-
/**
|
|
46
|
-
* @todo should we make these aliases explicit (rather than relying on {@link resolveUnsupportedBindType})?
|
|
47
|
-
*
|
|
48
|
-
* - select1
|
|
49
|
-
* - rank
|
|
50
|
-
* - odk:rank
|
|
51
|
-
*/
|
|
52
81
|
const BIND_TYPE_ALIASES: BindTypeAliasMapping = {
|
|
82
|
+
select1: SPEC_BIND_TYPE_DEFAULT,
|
|
83
|
+
rank: SPEC_BIND_TYPE_DEFAULT,
|
|
84
|
+
'odk:rank': SPEC_BIND_TYPE_DEFAULT,
|
|
53
85
|
integer: 'int',
|
|
54
86
|
};
|
|
55
87
|
|
|
@@ -65,7 +97,7 @@ const resolveAliasedBindType = (sourceType: string): BindType | null => {
|
|
|
65
97
|
* @todo Should we warn on this fallback?
|
|
66
98
|
*/
|
|
67
99
|
const resolveUnsupportedBindType = (_unsupportedType: string): BindType => {
|
|
68
|
-
return
|
|
100
|
+
return SPEC_BIND_TYPE_DEFAULT;
|
|
69
101
|
};
|
|
70
102
|
|
|
71
103
|
interface BindDataTypeNamespaceResolver {
|
|
@@ -144,7 +176,15 @@ const resolveNamespacedBindType = (
|
|
|
144
176
|
return null;
|
|
145
177
|
};
|
|
146
178
|
|
|
147
|
-
const resolveBindType = (
|
|
179
|
+
const resolveBindType = (
|
|
180
|
+
bodyElementType: AnyBodyElementType | null,
|
|
181
|
+
bindElement: BindElement,
|
|
182
|
+
sourceType: string | null
|
|
183
|
+
): BindType => {
|
|
184
|
+
if (sourceType == null) {
|
|
185
|
+
return resolveDefaultBindType(bodyElementType);
|
|
186
|
+
}
|
|
187
|
+
|
|
148
188
|
return (
|
|
149
189
|
resolveSupportedBindType(sourceType) ??
|
|
150
190
|
resolveAliasedBindType(sourceType) ??
|
|
@@ -154,20 +194,22 @@ const resolveBindType = (bindElement: BindElement, sourceType: string): BindType
|
|
|
154
194
|
};
|
|
155
195
|
|
|
156
196
|
export class BindTypeDefinition<T extends BindType = BindType> {
|
|
157
|
-
static from<T extends BindType>(
|
|
197
|
+
static from<T extends BindType>(
|
|
198
|
+
form: XFormDefinition,
|
|
199
|
+
nodeset: string,
|
|
200
|
+
bindElement: BindElement
|
|
201
|
+
): BindTypeDefinition<T> {
|
|
202
|
+
const bodyElementType = form.body.getBodyElementType(nodeset);
|
|
158
203
|
const sourceType = bindElement.getAttribute('type');
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const resolved = resolveBindType(bindElement, sourceType);
|
|
204
|
+
const resolved = resolveBindType(
|
|
205
|
+
bodyElementType,
|
|
206
|
+
bindElement,
|
|
207
|
+
sourceType
|
|
208
|
+
) satisfies BindType as T;
|
|
165
209
|
|
|
166
210
|
return new this(sourceType, resolved);
|
|
167
211
|
}
|
|
168
212
|
|
|
169
|
-
private constructor(source: null, resolved: DefaultBindType);
|
|
170
|
-
private constructor(source: string, resolved: BindType);
|
|
171
213
|
private constructor(
|
|
172
214
|
readonly source: string | null,
|
|
173
215
|
readonly resolved: T
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
XFORMS_KNOWN_ATTRIBUTE,
|
|
3
|
+
XFORMS_LOCAL_NAME,
|
|
4
|
+
XFormsItextTranslationMap,
|
|
5
|
+
} from '@getodk/xpath';
|
|
6
|
+
import { StaticDocument } from '../../integration/xpath/static-dom/StaticDocument.ts';
|
|
7
|
+
import type { StaticElement } from '../../integration/xpath/static-dom/StaticElement.ts';
|
|
8
|
+
import type { XFormDOM } from '../XFormDOM.ts';
|
|
9
|
+
import { parseStaticDocumentFromDOMSubtree } from '../shared/parseStaticDocumentFromDOMSubtree.ts';
|
|
10
|
+
|
|
11
|
+
export interface ItextTranslationDefinition extends StaticDocument {
|
|
12
|
+
readonly rootDocument: ItextTranslationDefinition;
|
|
13
|
+
readonly root: ItextTranslationRootDefinition;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ItextTranslationRootDefinition extends StaticElement {
|
|
17
|
+
readonly [XFORMS_LOCAL_NAME]: 'translation';
|
|
18
|
+
readonly [XFORMS_KNOWN_ATTRIBUTE]: 'lang';
|
|
19
|
+
|
|
20
|
+
readonly root: ItextTranslationRootDefinition;
|
|
21
|
+
readonly rootDocument: ItextTranslationDefinition;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type ItextTranslationsDefinitionEntry = readonly [
|
|
25
|
+
key: string,
|
|
26
|
+
value: ItextTranslationRootDefinition,
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
type AssertItextTranslationsDefinitionEntry = (
|
|
30
|
+
entry: readonly [key: string | null, value: StaticElement]
|
|
31
|
+
) => asserts entry is ItextTranslationsDefinitionEntry;
|
|
32
|
+
|
|
33
|
+
const assertItextTranslationsDefinitionEntry: AssertItextTranslationsDefinitionEntry = ([
|
|
34
|
+
key,
|
|
35
|
+
root,
|
|
36
|
+
]) => {
|
|
37
|
+
if (key == null || root.qualifiedName.localName !== 'translation') {
|
|
38
|
+
throw new Error();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @todo At time of writing, this shouldn't have any observable
|
|
44
|
+
* consequence—apart from preventing the potential mistake of using an
|
|
45
|
+
* {@link ItextTranslationDefinition} where an
|
|
46
|
+
* **instance**-as-{@link StaticDocument} would be expected (i.e. anything
|
|
47
|
+
* expecting an instance's {@link StaticDocument.nodeset} to be '/', or an its
|
|
48
|
+
* descendant elements' {@link StaticElement.nodeset} to start with '/'). The
|
|
49
|
+
* main intent, however, is to leave a breadcrumb back to ideas discussed in
|
|
50
|
+
* {@link https://github.com/getodk/web-forms/issues/22#issuecomment-2669228571 | Allow output in translation text (#22)}.
|
|
51
|
+
*/
|
|
52
|
+
const itextTranslationNodesetPrefix = (lang: string) => {
|
|
53
|
+
return `wf:translation('${lang}')`;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export class ItextTranslationsDefinition
|
|
57
|
+
extends Map<string, ItextTranslationRootDefinition>
|
|
58
|
+
implements XFormsItextTranslationMap<ItextTranslationRootDefinition>
|
|
59
|
+
{
|
|
60
|
+
static from(xformDOM: XFormDOM): ItextTranslationsDefinition {
|
|
61
|
+
const entries = xformDOM.itextTranslationElements.map((element) => {
|
|
62
|
+
const lang = element.getAttribute('lang');
|
|
63
|
+
const { root } = parseStaticDocumentFromDOMSubtree(element, {
|
|
64
|
+
nodesetPrefix: itextTranslationNodesetPrefix(lang),
|
|
65
|
+
});
|
|
66
|
+
const entry = [lang, root] as const;
|
|
67
|
+
|
|
68
|
+
assertItextTranslationsDefinitionEntry(entry);
|
|
69
|
+
|
|
70
|
+
return entry;
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return new this(entries);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private constructor(entries: readonly ItextTranslationsDefinitionEntry[]) {
|
|
77
|
+
super(entries);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ValueType } from '../../client/ValueType.ts';
|
|
2
|
+
import type { StaticLeafElement } from '../../integration/xpath/static-dom/StaticElement.ts';
|
|
2
3
|
import {
|
|
3
4
|
NamespaceDeclarationMap,
|
|
4
5
|
type NamedSubtreeDefinition,
|
|
@@ -19,14 +20,12 @@ export class LeafNodeDefinition<V extends ValueType = ValueType>
|
|
|
19
20
|
readonly namespaceDeclarations: NamespaceDeclarationMap;
|
|
20
21
|
readonly qualifiedName: QualifiedName;
|
|
21
22
|
readonly children = null;
|
|
22
|
-
readonly instances = null;
|
|
23
|
-
readonly defaultValue: string;
|
|
24
23
|
|
|
25
24
|
constructor(
|
|
26
25
|
parent: ParentNodeDefinition,
|
|
27
26
|
bind: BindDefinition,
|
|
28
27
|
bodyElement: AnyBodyElementDefinition | null,
|
|
29
|
-
readonly
|
|
28
|
+
readonly template: StaticLeafElement
|
|
30
29
|
) {
|
|
31
30
|
if (bodyElement != null && bodyElement.category !== 'control') {
|
|
32
31
|
throw new Error(`Unexpected body element for nodeset ${bind.nodeset}`);
|
|
@@ -35,9 +34,8 @@ export class LeafNodeDefinition<V extends ValueType = ValueType>
|
|
|
35
34
|
super(parent, bind, bodyElement);
|
|
36
35
|
|
|
37
36
|
this.valueType = bind.type.resolved satisfies ValueType as V;
|
|
38
|
-
this.qualifiedName =
|
|
37
|
+
this.qualifiedName = template.qualifiedName;
|
|
39
38
|
this.namespaceDeclarations = new NamespaceDeclarationMap(this);
|
|
40
|
-
this.defaultValue = node.textContent ?? '';
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
toJSON() {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { XFormDefinition } from '../XFormDefinition.ts';
|
|
2
2
|
import { BindDefinition } from './BindDefinition.ts';
|
|
3
3
|
import type { BindElement, BindNodeset } from './BindElement.ts';
|
|
4
|
-
import { DEFAULT_BIND_TYPE } from './BindTypeDefinition.ts';
|
|
5
4
|
import type { ModelDefinition } from './ModelDefinition.ts';
|
|
6
5
|
|
|
7
6
|
class ArtificialBindElement implements BindElement {
|
|
@@ -16,10 +15,6 @@ class ArtificialBindElement implements BindElement {
|
|
|
16
15
|
return this.ancestorNodeset;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
if (name === 'type') {
|
|
20
|
-
return DEFAULT_BIND_TYPE;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
18
|
return null;
|
|
24
19
|
}
|
|
25
20
|
|
|
@@ -1,21 +1,54 @@
|
|
|
1
|
+
import { ErrorProductionDesignPendingError } from '../../error/ErrorProductionDesignPendingError.ts';
|
|
2
|
+
import type { StaticDocument } from '../../integration/xpath/static-dom/StaticDocument.ts';
|
|
3
|
+
import { parseStaticDocumentFromDOMSubtree } from '../shared/parseStaticDocumentFromDOMSubtree.ts';
|
|
1
4
|
import type { XFormDefinition } from '../XFormDefinition.ts';
|
|
2
|
-
import {
|
|
3
|
-
import { ItextTranslationsDefinition } from './ItextTranslation/ItextTranslationsDefinition.ts';
|
|
5
|
+
import { ItextTranslationsDefinition } from './ItextTranslationsDefinition.ts';
|
|
4
6
|
import { ModelBindMap } from './ModelBindMap.ts';
|
|
7
|
+
import type { AnyNodeDefinition } from './NodeDefinition.ts';
|
|
8
|
+
import type { NodeDefinitionMap } from './nodeDefinitionMap.ts';
|
|
9
|
+
import { nodeDefinitionMap } from './nodeDefinitionMap.ts';
|
|
5
10
|
import { RootDefinition } from './RootDefinition.ts';
|
|
11
|
+
import { SubmissionDefinition } from './SubmissionDefinition.ts';
|
|
6
12
|
|
|
7
13
|
export class ModelDefinition {
|
|
8
14
|
readonly binds: ModelBindMap;
|
|
9
15
|
readonly root: RootDefinition;
|
|
16
|
+
readonly nodes: NodeDefinitionMap;
|
|
17
|
+
readonly instance: StaticDocument;
|
|
10
18
|
readonly itextTranslations: ItextTranslationsDefinition;
|
|
11
19
|
|
|
12
20
|
constructor(readonly form: XFormDefinition) {
|
|
13
|
-
const submission = new
|
|
21
|
+
const submission = new SubmissionDefinition(form.xformDOM);
|
|
22
|
+
|
|
14
23
|
this.binds = ModelBindMap.fromModel(this);
|
|
24
|
+
this.instance = parseStaticDocumentFromDOMSubtree(form.xformDOM.primaryInstanceRoot, {
|
|
25
|
+
nodesetPrefix: '/',
|
|
26
|
+
});
|
|
15
27
|
this.root = new RootDefinition(form, this, submission, form.body.classes);
|
|
28
|
+
this.nodes = nodeDefinitionMap(this.root);
|
|
16
29
|
this.itextTranslations = ItextTranslationsDefinition.from(form.xformDOM);
|
|
17
30
|
}
|
|
18
31
|
|
|
32
|
+
getNodeDefinition(nodeset: string): AnyNodeDefinition {
|
|
33
|
+
const definition = this.nodes.get(nodeset);
|
|
34
|
+
|
|
35
|
+
if (definition == null) {
|
|
36
|
+
throw new ErrorProductionDesignPendingError(`No definition for nodeset: ${nodeset}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return definition;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
getRootDefinition(instance: StaticDocument): RootDefinition {
|
|
43
|
+
const definition = this.getNodeDefinition(instance.root.nodeset);
|
|
44
|
+
|
|
45
|
+
if (definition !== this.root) {
|
|
46
|
+
throw new ErrorProductionDesignPendingError();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return definition;
|
|
50
|
+
}
|
|
51
|
+
|
|
19
52
|
toJSON() {
|
|
20
53
|
const { form, ...rest } = this;
|
|
21
54
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StaticElement } from '../../integration/xpath/static-dom/StaticElement.ts';
|
|
1
2
|
import type {
|
|
2
3
|
NamedSubtreeDefinition,
|
|
3
4
|
NamespaceDeclarationMap,
|
|
@@ -7,14 +8,12 @@ import type { AnyBodyElementDefinition } from '../body/BodyDefinition.ts';
|
|
|
7
8
|
import type { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
|
|
8
9
|
import type { BindDefinition } from './BindDefinition.ts';
|
|
9
10
|
import type { LeafNodeDefinition } from './LeafNodeDefinition.ts';
|
|
10
|
-
import type {
|
|
11
|
-
import type { AnyRepeatRangeDefinition } from './RepeatRangeDefinition.ts';
|
|
12
|
-
import type { RepeatTemplateDefinition } from './RepeatTemplateDefinition.ts';
|
|
11
|
+
import type { AnyRepeatDefinition } from './RepeatDefinition.ts';
|
|
13
12
|
import type { RootDefinition } from './RootDefinition.ts';
|
|
14
13
|
import type { SubtreeDefinition } from './SubtreeDefinition.ts';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
|
-
* Corresponds to
|
|
16
|
+
* Corresponds to a model instance root node, i.e.:
|
|
18
17
|
*
|
|
19
18
|
* - the element matching `/*` in primary instance expressions, a.k.a.
|
|
20
19
|
* - `/h:html/h:head/xf:model/xf:instance[1]/*`
|
|
@@ -22,34 +21,25 @@ import type { SubtreeDefinition } from './SubtreeDefinition.ts';
|
|
|
22
21
|
export type RootNodeType = 'root';
|
|
23
22
|
|
|
24
23
|
/**
|
|
25
|
-
* Corresponds to
|
|
26
|
-
*
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
* an explicit `jr:template=""` attribute in the form definition or is inferred
|
|
33
|
-
* as a template from the form's first element matched by a <repeat nodeset>.
|
|
34
|
-
*/
|
|
35
|
-
export type RepeatTemplateType = 'repeat-template';
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Corresponds to a single instance of a model/entry DOM subtree which
|
|
39
|
-
* in turn corresponds to a <repeat> in the form body definition, and a
|
|
40
|
-
* 'repeat-range' definition.
|
|
24
|
+
* Corresponds to the combined concepts defining a "repeat".
|
|
25
|
+
*
|
|
26
|
+
* @see {@link RepeatDefinition} for details on these concepts and how they are used to produce a "repeat definition", as such.
|
|
27
|
+
*
|
|
28
|
+
* , including or
|
|
29
|
+
* referencing all of the following:
|
|
30
|
+
*
|
|
41
31
|
*/
|
|
42
|
-
export type
|
|
32
|
+
export type RepeatType = 'repeat';
|
|
43
33
|
|
|
44
34
|
/**
|
|
45
|
-
* Corresponds to a model
|
|
35
|
+
* Corresponds to a model instance subtree which **does not** correspond to a
|
|
46
36
|
* <repeat> in the form definition. This will typically correspond to a <group>,
|
|
47
37
|
* but this is not strictly necessary per spec (hence the distinct name).
|
|
48
38
|
*/
|
|
49
39
|
export type SubtreeNodeType = 'subtree';
|
|
50
40
|
|
|
51
41
|
/**
|
|
52
|
-
* Corresponds to a model
|
|
42
|
+
* Corresponds to a model instance leaf node, i.e. one of:
|
|
53
43
|
*
|
|
54
44
|
* - An element with no child elements
|
|
55
45
|
* - Any attribute corresponding to a bind's `nodeset` expression
|
|
@@ -60,9 +50,7 @@ export type LeafNodeType = 'leaf-node';
|
|
|
60
50
|
export type NodeDefinitionType =
|
|
61
51
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
62
52
|
| RootNodeType
|
|
63
|
-
|
|
|
64
|
-
| RepeatTemplateType
|
|
65
|
-
| RepeatInstanceType
|
|
53
|
+
| RepeatType
|
|
66
54
|
| SubtreeNodeType
|
|
67
55
|
| LeafNodeType;
|
|
68
56
|
|
|
@@ -70,24 +58,15 @@ export type NodeDefinitionType =
|
|
|
70
58
|
export type ParentNodeDefinition =
|
|
71
59
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
72
60
|
| RootDefinition
|
|
73
|
-
|
|
|
74
|
-
| RepeatInstanceDefinition
|
|
61
|
+
| AnyRepeatDefinition
|
|
75
62
|
| SubtreeDefinition;
|
|
76
63
|
|
|
77
64
|
// prettier-ignore
|
|
78
65
|
export type ChildNodeDefinition =
|
|
79
|
-
|
|
|
66
|
+
| AnyRepeatDefinition
|
|
80
67
|
| LeafNodeDefinition
|
|
81
68
|
| SubtreeDefinition;
|
|
82
69
|
|
|
83
|
-
// prettier-ignore
|
|
84
|
-
export type ChildNodeInstanceDefinition =
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
86
|
-
| RepeatTemplateDefinition
|
|
87
|
-
| RepeatInstanceDefinition
|
|
88
|
-
| SubtreeDefinition
|
|
89
|
-
| LeafNodeDefinition;
|
|
90
|
-
|
|
91
70
|
export abstract class NodeDefinition<Type extends NodeDefinitionType>
|
|
92
71
|
implements NamedSubtreeDefinition
|
|
93
72
|
{
|
|
@@ -98,12 +77,8 @@ export abstract class NodeDefinition<Type extends NodeDefinitionType>
|
|
|
98
77
|
abstract readonly isTranslated: boolean;
|
|
99
78
|
abstract readonly root: RootDefinition;
|
|
100
79
|
abstract readonly parent: ParentNodeDefinition | null;
|
|
80
|
+
abstract readonly template: StaticElement;
|
|
101
81
|
abstract readonly children: readonly ChildNodeDefinition[] | null;
|
|
102
|
-
abstract readonly instances: readonly RepeatInstanceDefinition[] | null;
|
|
103
|
-
abstract readonly defaultValue: string | null;
|
|
104
|
-
|
|
105
|
-
/** @todo leaf-node may be Attr */
|
|
106
|
-
abstract readonly node: Element | null;
|
|
107
82
|
|
|
108
83
|
readonly nodeset: string;
|
|
109
84
|
|
|
@@ -112,11 +87,10 @@ export abstract class NodeDefinition<Type extends NodeDefinitionType>
|
|
|
112
87
|
}
|
|
113
88
|
}
|
|
114
89
|
|
|
90
|
+
// prettier-ignore
|
|
115
91
|
export type AnyNodeDefinition =
|
|
116
92
|
// eslint-disable-next-line @typescript-eslint/sort-type-constituents
|
|
117
93
|
| RootDefinition
|
|
118
|
-
|
|
|
119
|
-
| RepeatTemplateDefinition
|
|
120
|
-
| RepeatInstanceDefinition
|
|
94
|
+
| AnyRepeatDefinition
|
|
121
95
|
| SubtreeDefinition
|
|
122
96
|
| LeafNodeDefinition;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { NoteNode } from '../../client/NoteNode.ts';
|
|
2
2
|
import type { ValueType } from '../../client/ValueType.ts';
|
|
3
|
+
import type { StaticLeafElement } from '../../integration/xpath/static-dom/StaticElement.ts';
|
|
3
4
|
import type { AnyBodyElementDefinition } from '../body/BodyDefinition.ts';
|
|
4
5
|
import type { InputControlDefinition } from '../body/control/InputControlDefinition.ts';
|
|
5
6
|
import { BindComputationExpression } from '../expression/BindComputationExpression.ts';
|
|
@@ -43,7 +44,7 @@ export class NoteNodeDefinition<V extends ValueType = ValueType> extends LeafNod
|
|
|
43
44
|
parent: ParentNodeDefinition,
|
|
44
45
|
bind: BindDefinition<V>,
|
|
45
46
|
bodyElement: AnyBodyElementDefinition | null,
|
|
46
|
-
node:
|
|
47
|
+
node: StaticLeafElement
|
|
47
48
|
): NoteNodeDefinition<V> | null {
|
|
48
49
|
if (!isNoteBindDefinition(bind) || bodyElement?.type !== 'input') {
|
|
49
50
|
return null;
|
|
@@ -64,8 +65,8 @@ export class NoteNodeDefinition<V extends ValueType = ValueType> extends LeafNod
|
|
|
64
65
|
override readonly bind: NoteBindDefinition<V>,
|
|
65
66
|
override readonly bodyElement: InputControlDefinition,
|
|
66
67
|
readonly noteTextDefinition: NoteTextDefinition,
|
|
67
|
-
|
|
68
|
+
template: StaticLeafElement
|
|
68
69
|
) {
|
|
69
|
-
super(parent, bind, bodyElement,
|
|
70
|
+
super(parent, bind, bodyElement, template);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ValueType } from '../../client/ValueType.ts';
|
|
2
2
|
import { ErrorProductionDesignPendingError } from '../../error/ErrorProductionDesignPendingError.ts';
|
|
3
|
+
import type { StaticLeafElement } from '../../integration/xpath/static-dom/StaticElement.ts';
|
|
3
4
|
import type { RuntimeValue, SharedValueCodec } from '../../lib/codecs/getSharedValueCodec.ts';
|
|
4
5
|
import { getSharedValueCodec } from '../../lib/codecs/getSharedValueCodec.ts';
|
|
5
6
|
import type {
|
|
@@ -91,7 +92,7 @@ export class RangeNodeDefinition<V extends RangeValueType = RangeValueType>
|
|
|
91
92
|
parent: ParentNodeDefinition,
|
|
92
93
|
bind: BindDefinition<V>,
|
|
93
94
|
bodyElement: RangeControlDefinition,
|
|
94
|
-
node:
|
|
95
|
+
node: StaticLeafElement
|
|
95
96
|
): RangeNodeDefinition<Extract<V, RangeValueType>> {
|
|
96
97
|
assertRangeBindDefinition(bind);
|
|
97
98
|
|
|
@@ -104,7 +105,7 @@ export class RangeNodeDefinition<V extends RangeValueType = RangeValueType>
|
|
|
104
105
|
parent: ParentNodeDefinition,
|
|
105
106
|
override readonly bind: BindDefinition<V>,
|
|
106
107
|
override readonly bodyElement: RangeControlDefinition,
|
|
107
|
-
node:
|
|
108
|
+
node: StaticLeafElement
|
|
108
109
|
) {
|
|
109
110
|
super(parent, bind, bodyElement, node);
|
|
110
111
|
|