@getodk/xforms-engine 0.4.0 → 0.5.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 +14 -3
- package/dist/client/BaseValueNode.d.ts +32 -0
- package/dist/client/EngineConfig.d.ts +49 -48
- package/dist/client/InputNode.d.ts +53 -0
- package/dist/client/ModelValueNode.d.ts +12 -7
- package/dist/client/NoteNode.d.ts +2 -2
- package/dist/client/RootNode.d.ts +34 -7
- package/dist/client/SelectNode.d.ts +2 -2
- package/dist/client/ValueType.d.ts +3 -0
- package/dist/client/constants.d.ts +50 -0
- package/dist/client/hierarchy.d.ts +4 -4
- package/dist/client/identity.d.ts +14 -0
- package/dist/client/node-types.d.ts +2 -1
- package/dist/client/resources.d.ts +93 -0
- package/dist/client/submission/SubmissionData.d.ts +7 -0
- package/dist/client/submission/SubmissionDefinition.d.ts +14 -0
- package/dist/client/submission/SubmissionInstanceFile.d.ts +6 -0
- package/dist/client/submission/SubmissionOptions.d.ts +23 -0
- package/dist/client/submission/SubmissionResult.d.ts +91 -0
- package/dist/client/submission/SubmissionState.d.ts +12 -0
- package/dist/client/validation.d.ts +2 -2
- package/dist/error/ErrorProductionDesignPendingError.d.ts +7 -0
- package/dist/error/ValueTypeInvariantError.d.ts +17 -0
- package/dist/error/XPathFunctionalityError.d.ts +14 -0
- package/dist/error/XPathFunctionalityNotSupportedError.d.ts +7 -0
- package/dist/error/XPathFunctionalityPendingError.d.ts +7 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +10856 -8585
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +9 -4
- package/dist/instance/InputControl.d.ts +36 -0
- package/dist/instance/ModelValue.d.ts +16 -26
- package/dist/instance/Note.d.ts +10 -3
- package/dist/instance/PrimaryInstance.d.ts +84 -0
- package/dist/instance/Root.d.ts +29 -25
- package/dist/instance/SelectField.d.ts +10 -2
- package/dist/instance/Subtree.d.ts +10 -5
- package/dist/instance/TriggerControl.d.ts +10 -3
- package/dist/instance/abstract/DescendantNode.d.ts +31 -23
- package/dist/instance/abstract/InstanceNode.d.ts +49 -29
- package/dist/instance/abstract/UnsupportedControl.d.ts +10 -3
- package/dist/instance/abstract/ValueNode.d.ts +48 -0
- package/dist/instance/hierarchy.d.ts +9 -8
- package/dist/instance/identity.d.ts +2 -7
- package/dist/instance/internal-api/EvaluationContext.d.ts +53 -12
- package/dist/instance/internal-api/InstanceConfig.d.ts +8 -2
- package/dist/instance/internal-api/InstanceValueContext.d.ts +20 -0
- package/dist/instance/internal-api/PrimaryInstanceDocument.d.ts +36 -0
- package/dist/instance/internal-api/TranslationContext.d.ts +3 -2
- package/dist/instance/internal-api/ValidationContext.d.ts +3 -4
- package/dist/instance/internal-api/ValueContext.d.ts +2 -1
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableInstance.d.ts +14 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +31 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +18 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +17 -0
- package/dist/instance/repeat/BaseRepeatRange.d.ts +39 -83
- package/dist/instance/repeat/RepeatInstance.d.ts +11 -29
- package/dist/instance/repeat/RepeatRangeControlled.d.ts +2 -2
- package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +2 -2
- package/dist/instance/resource.d.ts +1 -1
- package/dist/instance/text/TextRange.d.ts +1 -1
- package/dist/instance/unsupported/RangeControl.d.ts +3 -1
- package/dist/instance/unsupported/RankControl.d.ts +3 -1
- package/dist/instance/unsupported/UploadControl.d.ts +3 -1
- package/dist/integration/xpath/EngineXPathEvaluator.d.ts +14 -0
- package/dist/integration/xpath/adapter/XFormsXPathNode.d.ts +71 -0
- package/dist/integration/xpath/adapter/engineDOMAdapter.d.ts +5 -0
- package/dist/integration/xpath/adapter/kind.d.ts +32 -0
- package/dist/integration/xpath/adapter/names.d.ts +16 -0
- package/dist/integration/xpath/adapter/traversal.d.ts +25 -0
- package/dist/integration/xpath/adapter/values.d.ts +2 -0
- package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +19 -0
- package/dist/integration/xpath/static-dom/StaticDocument.d.ts +16 -0
- package/dist/integration/xpath/static-dom/StaticElement.d.ts +40 -0
- package/dist/integration/xpath/static-dom/StaticNamedNode.d.ts +17 -0
- package/dist/integration/xpath/static-dom/StaticNode.d.ts +33 -0
- package/dist/integration/xpath/static-dom/StaticText.d.ts +16 -0
- package/dist/lib/client-reactivity/submission/createInstanceSubmissionState.d.ts +3 -0
- package/dist/lib/client-reactivity/submission/createLeafNodeSubmissionState.d.ts +3 -0
- package/dist/lib/client-reactivity/submission/createNodeRangeSubmissionState.d.ts +4 -0
- package/dist/lib/client-reactivity/submission/createParentNodeSubmissionState.d.ts +4 -0
- package/dist/lib/client-reactivity/submission/createValueNodeSubmissionState.d.ts +3 -0
- package/dist/lib/client-reactivity/submission/prepareSubmission.d.ts +8 -0
- package/dist/lib/codecs/DecimalValueCodec.d.ts +6 -0
- package/dist/lib/codecs/IntValueCodec.d.ts +6 -0
- package/dist/lib/codecs/StringValueCodec.d.ts +4 -0
- package/dist/lib/codecs/ValueCodec.d.ts +30 -0
- package/dist/lib/codecs/ValueTypePlaceholderCodec.d.ts +12 -0
- package/dist/lib/codecs/getSharedValueCodec.d.ts +47 -0
- package/dist/lib/dom/query.d.ts +3 -0
- package/dist/lib/reactivity/createChildrenState.d.ts +7 -5
- package/dist/lib/reactivity/createComputedExpression.d.ts +18 -5
- package/dist/lib/reactivity/createInstanceValueState.d.ts +40 -0
- package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +2 -2
- package/dist/lib/reactivity/createTranslationState.d.ts +19 -0
- package/dist/lib/reactivity/createValueState.d.ts +6 -10
- package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +4 -4
- package/dist/lib/xml-serialization.d.ts +41 -0
- package/dist/parse/XFormDOM.d.ts +18 -7
- package/dist/parse/XFormDefinition.d.ts +1 -2
- package/dist/parse/attachments/FormAttachmentResource.d.ts +27 -0
- package/dist/parse/body/BodyDefinition.d.ts +3 -3
- package/dist/parse/body/RepeatElementDefinition.d.ts +1 -1
- package/dist/parse/body/appearance/inputAppearanceParser.d.ts +1 -1
- package/dist/parse/body/control/{InputDefinition.d.ts → InputControlDefinition.d.ts} +1 -1
- package/dist/parse/body/control/select/ItemsetNodesetContext.d.ts +0 -2
- package/dist/parse/expression/abstract/DependencyContext.d.ts +0 -5
- package/dist/parse/expression/abstract/DependentExpression.d.ts +2 -3
- package/dist/parse/model/BindDefinition.d.ts +4 -5
- package/dist/parse/model/BindTypeDefinition.d.ts +20 -0
- package/dist/parse/model/DescendentNodeDefinition.d.ts +0 -1
- package/dist/parse/model/FormSubmissionDefinition.d.ts +8 -0
- package/dist/parse/model/ItextTranslation/ItextTranslationDefinition.d.ts +4 -0
- package/dist/parse/model/ItextTranslation/ItextTranslationRootDefinition.d.ts +8 -0
- package/dist/parse/model/ItextTranslation/ItextTranslationsDefinition.d.ts +8 -0
- package/dist/parse/model/LeafNodeDefinition.d.ts +3 -1
- package/dist/parse/model/ModelBindMap.d.ts +1 -1
- package/dist/parse/model/ModelDefinition.d.ts +2 -0
- package/dist/parse/model/NodeDefinition.d.ts +0 -1
- package/dist/parse/model/NoteNodeDefinition.d.ts +4 -4
- package/dist/parse/model/RootDefinition.d.ts +3 -2
- package/dist/parse/model/SecondaryInstance/SecondaryInstanceDefinition.d.ts +4 -0
- package/dist/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.d.ts +7 -0
- package/dist/parse/model/SecondaryInstance/SecondaryInstancesDefinition.d.ts +13 -0
- package/dist/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.d.ts +14 -0
- package/dist/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.d.ts +22 -0
- package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.d.ts +23 -0
- package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.d.ts +9 -0
- package/dist/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.d.ts +5 -0
- package/dist/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.d.ts +7 -0
- package/dist/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.d.ts +13 -0
- package/dist/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.d.ts +12 -0
- package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +24 -0
- package/dist/parse/text/abstract/TextRangeDefinition.d.ts +0 -2
- package/dist/parse/xpath/semantic-analysis.d.ts +5 -0
- package/dist/solid.js +8174 -5921
- package/dist/solid.js.map +1 -1
- package/package.json +13 -11
- package/src/client/BaseNode.ts +16 -6
- package/src/client/BaseValueNode.ts +35 -0
- package/src/client/EngineConfig.ts +52 -51
- package/src/client/InputNode.ts +77 -0
- package/src/client/ModelValueNode.ts +30 -7
- package/src/client/NoteNode.ts +2 -2
- package/src/client/RootNode.ts +37 -7
- package/src/client/SelectNode.ts +3 -3
- package/src/client/ValueType.ts +4 -0
- package/src/client/constants.ts +67 -0
- package/src/client/hierarchy.ts +5 -5
- package/src/client/identity.ts +16 -0
- package/src/client/node-types.ts +12 -6
- package/src/client/resources.ts +118 -0
- package/src/client/submission/SubmissionData.ts +12 -0
- package/src/client/submission/SubmissionDefinition.ts +16 -0
- package/src/client/submission/SubmissionInstanceFile.ts +9 -0
- package/src/client/submission/SubmissionOptions.ts +28 -0
- package/src/client/submission/SubmissionResult.ts +124 -0
- package/src/client/submission/SubmissionState.ts +14 -0
- package/src/client/validation.ts +2 -2
- package/src/error/ErrorProductionDesignPendingError.ts +6 -0
- package/src/error/ValueTypeInvariantError.ts +22 -0
- package/src/error/XPathFunctionalityError.ts +26 -0
- package/src/error/XPathFunctionalityNotSupportedError.ts +18 -0
- package/src/error/XPathFunctionalityPendingError.ts +18 -0
- package/src/index.ts +10 -1
- package/src/instance/Group.ts +17 -5
- package/src/instance/InputControl.ts +119 -0
- package/src/instance/ModelValue.ts +47 -54
- package/src/instance/Note.ts +24 -8
- package/src/instance/PrimaryInstance.ts +244 -0
- package/src/instance/Root.ts +62 -134
- package/src/instance/SelectField.ts +56 -19
- package/src/instance/Subtree.ts +19 -7
- package/src/instance/TriggerControl.ts +23 -6
- package/src/instance/abstract/DescendantNode.ts +90 -45
- package/src/instance/abstract/InstanceNode.ts +103 -105
- package/src/instance/abstract/UnsupportedControl.ts +28 -5
- package/src/instance/abstract/ValueNode.ts +127 -0
- package/src/instance/children.ts +9 -10
- package/src/instance/hierarchy.ts +19 -15
- package/src/instance/identity.ts +3 -9
- package/src/instance/index.ts +25 -7
- package/src/instance/internal-api/EvaluationContext.ts +60 -13
- package/src/instance/internal-api/InstanceConfig.ts +9 -2
- package/src/instance/internal-api/InstanceValueContext.ts +24 -0
- package/src/instance/internal-api/PrimaryInstanceDocument.ts +53 -0
- package/src/instance/internal-api/TranslationContext.ts +3 -2
- package/src/instance/internal-api/ValidationContext.ts +3 -4
- package/src/instance/internal-api/ValueContext.ts +2 -1
- package/src/instance/internal-api/submission/ClientReactiveSubmittableInstance.ts +20 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +42 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +25 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +23 -0
- package/src/instance/repeat/BaseRepeatRange.ts +50 -131
- package/src/instance/repeat/RepeatInstance.ts +20 -46
- package/src/instance/repeat/RepeatRangeControlled.ts +5 -5
- package/src/instance/repeat/RepeatRangeUncontrolled.ts +2 -4
- package/src/instance/resource.ts +1 -1
- package/src/instance/text/TextChunk.ts +1 -1
- package/src/instance/unsupported/RangeControl.ts +5 -1
- package/src/instance/unsupported/RankControl.ts +5 -1
- package/src/instance/unsupported/UploadControl.ts +5 -1
- package/src/integration/xpath/EngineXPathEvaluator.ts +22 -0
- package/src/integration/xpath/adapter/XFormsXPathNode.ts +126 -0
- package/src/integration/xpath/adapter/engineDOMAdapter.ts +57 -0
- package/src/integration/xpath/adapter/kind.ts +114 -0
- package/src/integration/xpath/adapter/names.ts +99 -0
- package/src/integration/xpath/adapter/traversal.ts +228 -0
- package/src/integration/xpath/adapter/values.ts +5 -0
- package/src/integration/xpath/static-dom/StaticAttribute.ts +33 -0
- package/src/integration/xpath/static-dom/StaticDocument.ts +38 -0
- package/src/integration/xpath/static-dom/StaticElement.ts +106 -0
- package/src/integration/xpath/static-dom/StaticNamedNode.ts +45 -0
- package/src/integration/xpath/static-dom/StaticNode.ts +68 -0
- package/src/integration/xpath/static-dom/StaticText.ts +28 -0
- package/src/lib/client-reactivity/README.md +0 -0
- package/src/lib/client-reactivity/submission/createInstanceSubmissionState.ts +12 -0
- package/src/lib/client-reactivity/submission/createLeafNodeSubmissionState.ts +20 -0
- package/src/lib/client-reactivity/submission/createNodeRangeSubmissionState.ts +17 -0
- package/src/lib/client-reactivity/submission/createParentNodeSubmissionState.ts +22 -0
- package/src/lib/client-reactivity/submission/createValueNodeSubmissionState.ts +21 -0
- package/src/lib/client-reactivity/submission/prepareSubmission.ts +172 -0
- package/src/lib/codecs/DecimalValueCodec.ts +46 -0
- package/src/lib/codecs/IntValueCodec.ts +100 -0
- package/src/lib/codecs/StringValueCodec.ts +11 -0
- package/src/lib/codecs/ValueCodec.ts +106 -0
- package/src/lib/codecs/ValueTypePlaceholderCodec.ts +19 -0
- package/src/lib/codecs/getSharedValueCodec.ts +77 -0
- package/src/lib/dom/query.ts +7 -0
- package/src/lib/reactivity/createChildrenState.ts +8 -6
- package/src/lib/reactivity/createComputedExpression.ts +57 -34
- package/src/lib/reactivity/createInstanceValueState.ts +166 -0
- package/src/lib/reactivity/createNoteReadonlyThunk.ts +12 -7
- package/src/lib/reactivity/createSelectItems.ts +21 -21
- package/src/lib/reactivity/createTranslationState.ts +61 -0
- package/src/lib/reactivity/createValueState.ts +62 -120
- package/src/lib/reactivity/materializeCurrentStateChildren.ts +7 -7
- package/src/lib/reactivity/text/createTextRange.ts +4 -3
- package/src/lib/reactivity/validation/createAggregatedViolations.ts +1 -1
- package/src/lib/reactivity/validation/createValidation.ts +2 -3
- package/src/lib/xml-serialization.ts +96 -0
- package/src/parse/XFormDOM.ts +110 -75
- package/src/parse/XFormDefinition.ts +1 -6
- package/src/parse/attachments/FormAttachmentResource.ts +40 -0
- package/src/parse/body/BodyDefinition.ts +3 -3
- package/src/parse/body/appearance/inputAppearanceParser.ts +1 -1
- package/src/parse/body/control/{InputDefinition.ts → InputControlDefinition.ts} +3 -5
- package/src/parse/body/control/select/ItemsetNodesetContext.ts +0 -5
- package/src/parse/expression/abstract/DependencyContext.ts +0 -26
- package/src/parse/expression/abstract/DependentExpression.ts +2 -13
- package/src/parse/model/BindDefinition.ts +5 -8
- package/src/parse/model/BindTypeDefinition.ts +175 -0
- package/src/parse/model/DescendentNodeDefinition.ts +0 -6
- package/src/parse/model/FormSubmissionDefinition.ts +44 -0
- package/src/parse/model/ItextTranslation/ItextTranslationDefinition.ts +4 -0
- package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +41 -0
- package/src/parse/model/ItextTranslation/ItextTranslationsDefinition.ts +31 -0
- package/src/parse/model/LeafNodeDefinition.ts +4 -1
- package/src/parse/model/ModelBindMap.ts +6 -8
- package/src/parse/model/ModelDefinition.ts +6 -1
- package/src/parse/model/NodeDefinition.ts +0 -3
- package/src/parse/model/NoteNodeDefinition.ts +3 -3
- package/src/parse/model/RootDefinition.ts +2 -1
- package/src/parse/model/SecondaryInstance/SecondaryInstanceDefinition.ts +4 -0
- package/src/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.ts +12 -0
- package/src/parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts +102 -0
- package/src/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.ts +40 -0
- package/src/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.ts +288 -0
- package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.ts +222 -0
- package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.ts +22 -0
- package/src/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.ts +414 -0
- package/src/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.ts +19 -0
- package/src/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.ts +29 -0
- package/src/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.ts +32 -0
- package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +149 -0
- package/src/parse/text/abstract/TextRangeDefinition.ts +0 -6
- package/src/parse/xpath/semantic-analysis.ts +29 -0
- package/dist/client/StringNode.d.ts +0 -46
- package/dist/instance/StringField.d.ts +0 -44
- package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -59
- package/dist/parse/XFormDataType.d.ts +0 -25
- package/src/client/StringNode.ts +0 -52
- package/src/instance/StringField.ts +0 -120
- package/src/instance/internal-api/SubscribableDependency.ts +0 -61
- package/src/parse/XFormDataType.ts +0 -62
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { InputDefinition } from '../parse/body/control/InputDefinition.ts';
|
|
2
|
-
import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
3
|
-
import { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
4
|
-
import { NodeAppearances } from './NodeAppearances.ts';
|
|
5
|
-
import { RootNode } from './RootNode.ts';
|
|
6
|
-
import { GeneralParentNode } from './hierarchy.ts';
|
|
7
|
-
import { LeafNodeValidationState } from './validation.ts';
|
|
8
|
-
export interface StringNodeState extends BaseNodeState {
|
|
9
|
-
get children(): null;
|
|
10
|
-
get valueOptions(): null;
|
|
11
|
-
/**
|
|
12
|
-
* Reflects the current value of a {@link StringNode}. This value may be
|
|
13
|
-
* populated when a form is loaded, and it may be updated by certain
|
|
14
|
-
* computations defined by the form. It may also be updated by a client, using
|
|
15
|
-
* the {@link StringNode.setValue} method.
|
|
16
|
-
*/
|
|
17
|
-
get value(): string;
|
|
18
|
-
}
|
|
19
|
-
export interface StringDefinition extends LeafNodeDefinition {
|
|
20
|
-
readonly bodyElement: InputDefinition;
|
|
21
|
-
}
|
|
22
|
-
export type StringNodeAppearances = NodeAppearances<StringDefinition>;
|
|
23
|
-
/**
|
|
24
|
-
* A node which can be assigned a string/text value. A string node **MAY**
|
|
25
|
-
* correspond to form field defined as an XForms `<input>`, which a user-facing
|
|
26
|
-
* client would likely present for a user to fill. It may not correspond to an
|
|
27
|
-
* `<input>`, or necessarily have any presentational implications for a client
|
|
28
|
-
* (for instance if the node is bound to an XForms `calculate` expression).
|
|
29
|
-
*/
|
|
30
|
-
export interface StringNode extends BaseNode {
|
|
31
|
-
readonly nodeType: 'string';
|
|
32
|
-
readonly appearances: StringNodeAppearances;
|
|
33
|
-
readonly definition: StringDefinition;
|
|
34
|
-
readonly root: RootNode;
|
|
35
|
-
readonly parent: GeneralParentNode;
|
|
36
|
-
readonly currentState: StringNodeState;
|
|
37
|
-
readonly validationState: LeafNodeValidationState;
|
|
38
|
-
/**
|
|
39
|
-
* For use by a client to update the value of a string node.
|
|
40
|
-
*
|
|
41
|
-
* @todo [how] should we express write restrictions to a client? E.g. what
|
|
42
|
-
* happens when a string node is readonly, and a client attempts to call this
|
|
43
|
-
* method?
|
|
44
|
-
*/
|
|
45
|
-
setValue(value: string): RootNode;
|
|
46
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Accessor } from 'solid-js';
|
|
2
|
-
import { StringNode, StringNodeAppearances } from '../client/StringNode.ts';
|
|
3
|
-
import { TextRange } from '../client/TextRange.ts';
|
|
4
|
-
import { AnyViolation, LeafNodeValidationState } from '../client/validation.ts';
|
|
5
|
-
import { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
|
|
6
|
-
import { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
|
|
7
|
-
import { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
8
|
-
import { SimpleAtomicState } from '../lib/reactivity/types.ts';
|
|
9
|
-
import { InputDefinition } from '../parse/body/control/InputDefinition.ts';
|
|
10
|
-
import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
11
|
-
import { Root } from './Root.ts';
|
|
12
|
-
import { DescendantNodeStateSpec, DescendantNode } from './abstract/DescendantNode.ts';
|
|
13
|
-
import { GeneralParentNode } from './hierarchy.ts';
|
|
14
|
-
import { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
15
|
-
import { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
|
|
16
|
-
import { ValidationContext } from './internal-api/ValidationContext.ts';
|
|
17
|
-
import { ValueContext } from './internal-api/ValueContext.ts';
|
|
18
|
-
export interface StringFieldDefinition extends LeafNodeDefinition {
|
|
19
|
-
readonly bodyElement: InputDefinition;
|
|
20
|
-
}
|
|
21
|
-
interface StringFieldStateSpec extends DescendantNodeStateSpec<string> {
|
|
22
|
-
readonly label: Accessor<TextRange<'label'> | null>;
|
|
23
|
-
readonly hint: Accessor<TextRange<'hint'> | null>;
|
|
24
|
-
readonly children: null;
|
|
25
|
-
readonly value: SimpleAtomicState<string>;
|
|
26
|
-
readonly valueOptions: null;
|
|
27
|
-
}
|
|
28
|
-
export declare class StringField extends DescendantNode<StringFieldDefinition, StringFieldStateSpec, null> implements StringNode, EvaluationContext, SubscribableDependency, ValidationContext, ValueContext<string> {
|
|
29
|
-
private readonly validation;
|
|
30
|
-
protected readonly state: SharedNodeState<StringFieldStateSpec>;
|
|
31
|
-
protected engineState: EngineState<StringFieldStateSpec>;
|
|
32
|
-
readonly nodeType = "string";
|
|
33
|
-
readonly appearances: StringNodeAppearances;
|
|
34
|
-
readonly currentState: CurrentState<StringFieldStateSpec>;
|
|
35
|
-
get validationState(): LeafNodeValidationState;
|
|
36
|
-
readonly encodeValue: (value: string) => string;
|
|
37
|
-
readonly decodeValue: (value: string) => string;
|
|
38
|
-
constructor(parent: GeneralParentNode, definition: StringFieldDefinition);
|
|
39
|
-
getViolation(): AnyViolation | null;
|
|
40
|
-
isBlank(): boolean;
|
|
41
|
-
getChildren(): readonly [];
|
|
42
|
-
setValue(value: string): Root;
|
|
43
|
-
}
|
|
44
|
-
export {};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
2
|
-
/**
|
|
3
|
-
* Provides a common interface to explicitly establish a reactive subscription
|
|
4
|
-
* to a form node, regardless of which node-specific details might trigger
|
|
5
|
-
* reactive updates. This is primarily intended for use in coordination with a
|
|
6
|
-
* node's {@link EvaluationContext} interface, so that computed expression
|
|
7
|
-
* evaluations can be re-executed when their dependencies update, without
|
|
8
|
-
* requiring a given evaluation to handle node-specific logic to determine
|
|
9
|
-
* when/whether updates have occurred.
|
|
10
|
-
*
|
|
11
|
-
* @example Given a form with these bindings:
|
|
12
|
-
*
|
|
13
|
-
* ```xml
|
|
14
|
-
* <bind nodeset="/data/field-1" />
|
|
15
|
-
* <bind nodeset="/data/field-2" type="int" />
|
|
16
|
-
* <bind nodeset="/data/group-a" relevant="/data/field-1 != ''" />
|
|
17
|
-
* <bind nodeset="/data/group-a/field-a-1" calculate="/data/field-2 * 2" />
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* The field `/data/group-a/field-a-1`'s calculate has two dependencies:
|
|
21
|
-
*
|
|
22
|
-
* - `/data-field-2` (explicit)
|
|
23
|
-
* - `/data/group-a` (implicit: non-relevance is inherited)
|
|
24
|
-
*
|
|
25
|
-
* (This is an oversimplification, but it helps to illustrate the concept.)
|
|
26
|
-
*
|
|
27
|
-
* The first dependency's subscription is clearly concerned with that leaf
|
|
28
|
-
* node's value. In which case, that node's `subscribe` method should react to
|
|
29
|
-
* updates to its value (e.g. its `currentState.value` or the internal reactive
|
|
30
|
-
* representation thereof).
|
|
31
|
-
*
|
|
32
|
-
* Whereas the second dependency has no value (no parent nodes do); instead, the
|
|
33
|
-
* subscription would be concerned with that node's relevance. In which case,
|
|
34
|
-
* that node's `subscribe` method should react to updates to its relevance state
|
|
35
|
-
* (e.g. its `currentState.relevant` or the internal reactive represeentation
|
|
36
|
-
* thereof).
|
|
37
|
-
*
|
|
38
|
-
* @example Given a form with:
|
|
39
|
-
*
|
|
40
|
-
* ```xml
|
|
41
|
-
* <!-- model -->
|
|
42
|
-
* <bind nodeset="/data/repeat-a/field-a-1" calculate="position(..)" />
|
|
43
|
-
* <!-- body -->
|
|
44
|
-
* <repeat nodeset="/data/repeat-a" />
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* The field `/data/repeat-a/field-a-1` has a dependency on its containing
|
|
48
|
-
* repeat instance. That node also doesn't have a value, and here the dynamic
|
|
49
|
-
* aspect of the dependency is the node's current position. Here the node's
|
|
50
|
-
* `subscribe` method should react to changes in its position (likely indirectly
|
|
51
|
-
* by reading its `contextReference`).
|
|
52
|
-
*
|
|
53
|
-
* @see {@link EvaluationContext}
|
|
54
|
-
* @see {@link EvaluationContext.contextReference}
|
|
55
|
-
*/
|
|
56
|
-
export interface SubscribableDependency {
|
|
57
|
-
readonly scope: ReactiveScope;
|
|
58
|
-
readonly subscribe: VoidFunction;
|
|
59
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { CollectionValues } from '../../../common/types/collections/CollectionValues.ts';
|
|
2
|
-
/**
|
|
3
|
-
* Like JavaRosa. Presumably for explicit types which aren't impelemnted?
|
|
4
|
-
*/
|
|
5
|
-
declare const UNSUPPORTED_DATA_TYPE = "UNSUPPORTED";
|
|
6
|
-
export type UnsupportedDataType = typeof UNSUPPORTED_DATA_TYPE;
|
|
7
|
-
/**
|
|
8
|
-
* Like JavaRosa. Presumably for e.g. groups with explicit binds (`relevant` etc)?
|
|
9
|
-
*/
|
|
10
|
-
export type NullDataType = 'NULL';
|
|
11
|
-
/**
|
|
12
|
-
* As in ODK XForms Spec.
|
|
13
|
-
*
|
|
14
|
-
* TODO: it's unclear why JavaRosa's `DataType` hews closely to the spec, but
|
|
15
|
-
* has certain differences (e.g. string -> TEXT, int -> INTEGER). It's also
|
|
16
|
-
* not immediately clear how additive types like CHOICE and MULTIPLE_ITEMS
|
|
17
|
-
* square with the underlying spec types.
|
|
18
|
-
*/
|
|
19
|
-
export declare const XFORM_SPEC_DATA_TYPES: readonly ["string", "int", "boolean", "decimal", "date", "time", "dateTime", "geopoint", "geotrace", "geoshape", "binary", "barcode", "intent"];
|
|
20
|
-
export type XFormSpecDataType = CollectionValues<typeof XFORM_SPEC_DATA_TYPES>;
|
|
21
|
-
export type XFormDataType = NullDataType | UnsupportedDataType | XFormSpecDataType;
|
|
22
|
-
declare const DEFAULT_XFORM_DATA_TYPE = "string";
|
|
23
|
-
export type DefaultXFormDataType = typeof DEFAULT_XFORM_DATA_TYPE;
|
|
24
|
-
export declare const bindDataType: (bindType: string | null) => XFormDataType;
|
|
25
|
-
export {};
|
package/src/client/StringNode.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { InputDefinition } from '../parse/body/control/InputDefinition.ts';
|
|
2
|
-
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
3
|
-
import type { BaseNode, BaseNodeState } from './BaseNode.ts';
|
|
4
|
-
import type { NodeAppearances } from './NodeAppearances.ts';
|
|
5
|
-
import type { RootNode } from './RootNode.ts';
|
|
6
|
-
import type { GeneralParentNode } from './hierarchy.ts';
|
|
7
|
-
import type { LeafNodeValidationState } from './validation.ts';
|
|
8
|
-
|
|
9
|
-
export interface StringNodeState extends BaseNodeState {
|
|
10
|
-
get children(): null;
|
|
11
|
-
get valueOptions(): null;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Reflects the current value of a {@link StringNode}. This value may be
|
|
15
|
-
* populated when a form is loaded, and it may be updated by certain
|
|
16
|
-
* computations defined by the form. It may also be updated by a client, using
|
|
17
|
-
* the {@link StringNode.setValue} method.
|
|
18
|
-
*/
|
|
19
|
-
get value(): string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface StringDefinition extends LeafNodeDefinition {
|
|
23
|
-
readonly bodyElement: InputDefinition;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export type StringNodeAppearances = NodeAppearances<StringDefinition>;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* A node which can be assigned a string/text value. A string node **MAY**
|
|
30
|
-
* correspond to form field defined as an XForms `<input>`, which a user-facing
|
|
31
|
-
* client would likely present for a user to fill. It may not correspond to an
|
|
32
|
-
* `<input>`, or necessarily have any presentational implications for a client
|
|
33
|
-
* (for instance if the node is bound to an XForms `calculate` expression).
|
|
34
|
-
*/
|
|
35
|
-
export interface StringNode extends BaseNode {
|
|
36
|
-
readonly nodeType: 'string';
|
|
37
|
-
readonly appearances: StringNodeAppearances;
|
|
38
|
-
readonly definition: StringDefinition;
|
|
39
|
-
readonly root: RootNode;
|
|
40
|
-
readonly parent: GeneralParentNode;
|
|
41
|
-
readonly currentState: StringNodeState;
|
|
42
|
-
readonly validationState: LeafNodeValidationState;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* For use by a client to update the value of a string node.
|
|
46
|
-
*
|
|
47
|
-
* @todo [how] should we express write restrictions to a client? E.g. what
|
|
48
|
-
* happens when a string node is readonly, and a client attempts to call this
|
|
49
|
-
* method?
|
|
50
|
-
*/
|
|
51
|
-
setValue(value: string): RootNode;
|
|
52
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { identity } from '@getodk/common/lib/identity.ts';
|
|
2
|
-
import type { Accessor } from 'solid-js';
|
|
3
|
-
import type { StringNode, StringNodeAppearances } from '../client/StringNode.ts';
|
|
4
|
-
import type { TextRange } from '../client/TextRange.ts';
|
|
5
|
-
import type { AnyViolation, LeafNodeValidationState } from '../client/validation.ts';
|
|
6
|
-
import { createValueState } from '../lib/reactivity/createValueState.ts';
|
|
7
|
-
import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
|
|
8
|
-
import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
|
|
9
|
-
import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
10
|
-
import { createSharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
11
|
-
import { createFieldHint } from '../lib/reactivity/text/createFieldHint.ts';
|
|
12
|
-
import { createNodeLabel } from '../lib/reactivity/text/createNodeLabel.ts';
|
|
13
|
-
import type { SimpleAtomicState } from '../lib/reactivity/types.ts';
|
|
14
|
-
import type { SharedValidationState } from '../lib/reactivity/validation/createValidation.ts';
|
|
15
|
-
import { createValidationState } from '../lib/reactivity/validation/createValidation.ts';
|
|
16
|
-
import type { InputDefinition } from '../parse/body/control/InputDefinition.ts';
|
|
17
|
-
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
18
|
-
import type { Root } from './Root.ts';
|
|
19
|
-
import type { DescendantNodeStateSpec } from './abstract/DescendantNode.ts';
|
|
20
|
-
import { DescendantNode } from './abstract/DescendantNode.ts';
|
|
21
|
-
import type { GeneralParentNode } from './hierarchy.ts';
|
|
22
|
-
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
23
|
-
import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
|
|
24
|
-
import type { ValidationContext } from './internal-api/ValidationContext.ts';
|
|
25
|
-
import type { ValueContext } from './internal-api/ValueContext.ts';
|
|
26
|
-
|
|
27
|
-
export interface StringFieldDefinition extends LeafNodeDefinition {
|
|
28
|
-
readonly bodyElement: InputDefinition;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface StringFieldStateSpec extends DescendantNodeStateSpec<string> {
|
|
32
|
-
readonly label: Accessor<TextRange<'label'> | null>;
|
|
33
|
-
readonly hint: Accessor<TextRange<'hint'> | null>;
|
|
34
|
-
readonly children: null;
|
|
35
|
-
readonly value: SimpleAtomicState<string>;
|
|
36
|
-
readonly valueOptions: null;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export class StringField
|
|
40
|
-
extends DescendantNode<StringFieldDefinition, StringFieldStateSpec, null>
|
|
41
|
-
implements
|
|
42
|
-
StringNode,
|
|
43
|
-
EvaluationContext,
|
|
44
|
-
SubscribableDependency,
|
|
45
|
-
ValidationContext,
|
|
46
|
-
ValueContext<string>
|
|
47
|
-
{
|
|
48
|
-
private readonly validation: SharedValidationState;
|
|
49
|
-
protected readonly state: SharedNodeState<StringFieldStateSpec>;
|
|
50
|
-
|
|
51
|
-
// InstanceNode
|
|
52
|
-
protected engineState: EngineState<StringFieldStateSpec>;
|
|
53
|
-
|
|
54
|
-
// StringNode
|
|
55
|
-
readonly nodeType = 'string';
|
|
56
|
-
readonly appearances: StringNodeAppearances;
|
|
57
|
-
readonly currentState: CurrentState<StringFieldStateSpec>;
|
|
58
|
-
|
|
59
|
-
get validationState(): LeafNodeValidationState {
|
|
60
|
-
return this.validation.currentState;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// ValueContext
|
|
64
|
-
readonly encodeValue = identity<string>;
|
|
65
|
-
|
|
66
|
-
readonly decodeValue = identity<string>;
|
|
67
|
-
|
|
68
|
-
constructor(parent: GeneralParentNode, definition: StringFieldDefinition) {
|
|
69
|
-
super(parent, definition);
|
|
70
|
-
|
|
71
|
-
this.appearances = definition.bodyElement.appearances;
|
|
72
|
-
|
|
73
|
-
const sharedStateOptions = {
|
|
74
|
-
clientStateFactory: this.engineConfig.stateFactory,
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const state = createSharedNodeState(
|
|
78
|
-
this.scope,
|
|
79
|
-
{
|
|
80
|
-
reference: this.contextReference,
|
|
81
|
-
readonly: this.isReadonly,
|
|
82
|
-
relevant: this.isRelevant,
|
|
83
|
-
required: this.isRequired,
|
|
84
|
-
|
|
85
|
-
label: createNodeLabel(this, definition),
|
|
86
|
-
hint: createFieldHint(this, definition),
|
|
87
|
-
children: null,
|
|
88
|
-
valueOptions: null,
|
|
89
|
-
value: createValueState(this),
|
|
90
|
-
},
|
|
91
|
-
sharedStateOptions
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
this.state = state;
|
|
95
|
-
this.engineState = state.engineState;
|
|
96
|
-
this.currentState = state.currentState;
|
|
97
|
-
this.validation = createValidationState(this, sharedStateOptions);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// ValidationContext
|
|
101
|
-
getViolation(): AnyViolation | null {
|
|
102
|
-
return this.validation.engineState.violation;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
isBlank(): boolean {
|
|
106
|
-
return this.engineState.value === '';
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// InstanceNode
|
|
110
|
-
getChildren(): readonly [] {
|
|
111
|
-
return [];
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// StringNode
|
|
115
|
-
setValue(value: string): Root {
|
|
116
|
-
this.state.setProperty('value', value);
|
|
117
|
-
|
|
118
|
-
return this.root;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
2
|
-
import type { EvaluationContext } from './EvaluationContext.ts';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Provides a common interface to explicitly establish a reactive subscription
|
|
6
|
-
* to a form node, regardless of which node-specific details might trigger
|
|
7
|
-
* reactive updates. This is primarily intended for use in coordination with a
|
|
8
|
-
* node's {@link EvaluationContext} interface, so that computed expression
|
|
9
|
-
* evaluations can be re-executed when their dependencies update, without
|
|
10
|
-
* requiring a given evaluation to handle node-specific logic to determine
|
|
11
|
-
* when/whether updates have occurred.
|
|
12
|
-
*
|
|
13
|
-
* @example Given a form with these bindings:
|
|
14
|
-
*
|
|
15
|
-
* ```xml
|
|
16
|
-
* <bind nodeset="/data/field-1" />
|
|
17
|
-
* <bind nodeset="/data/field-2" type="int" />
|
|
18
|
-
* <bind nodeset="/data/group-a" relevant="/data/field-1 != ''" />
|
|
19
|
-
* <bind nodeset="/data/group-a/field-a-1" calculate="/data/field-2 * 2" />
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* The field `/data/group-a/field-a-1`'s calculate has two dependencies:
|
|
23
|
-
*
|
|
24
|
-
* - `/data-field-2` (explicit)
|
|
25
|
-
* - `/data/group-a` (implicit: non-relevance is inherited)
|
|
26
|
-
*
|
|
27
|
-
* (This is an oversimplification, but it helps to illustrate the concept.)
|
|
28
|
-
*
|
|
29
|
-
* The first dependency's subscription is clearly concerned with that leaf
|
|
30
|
-
* node's value. In which case, that node's `subscribe` method should react to
|
|
31
|
-
* updates to its value (e.g. its `currentState.value` or the internal reactive
|
|
32
|
-
* representation thereof).
|
|
33
|
-
*
|
|
34
|
-
* Whereas the second dependency has no value (no parent nodes do); instead, the
|
|
35
|
-
* subscription would be concerned with that node's relevance. In which case,
|
|
36
|
-
* that node's `subscribe` method should react to updates to its relevance state
|
|
37
|
-
* (e.g. its `currentState.relevant` or the internal reactive represeentation
|
|
38
|
-
* thereof).
|
|
39
|
-
*
|
|
40
|
-
* @example Given a form with:
|
|
41
|
-
*
|
|
42
|
-
* ```xml
|
|
43
|
-
* <!-- model -->
|
|
44
|
-
* <bind nodeset="/data/repeat-a/field-a-1" calculate="position(..)" />
|
|
45
|
-
* <!-- body -->
|
|
46
|
-
* <repeat nodeset="/data/repeat-a" />
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* The field `/data/repeat-a/field-a-1` has a dependency on its containing
|
|
50
|
-
* repeat instance. That node also doesn't have a value, and here the dynamic
|
|
51
|
-
* aspect of the dependency is the node's current position. Here the node's
|
|
52
|
-
* `subscribe` method should react to changes in its position (likely indirectly
|
|
53
|
-
* by reading its `contextReference`).
|
|
54
|
-
*
|
|
55
|
-
* @see {@link EvaluationContext}
|
|
56
|
-
* @see {@link EvaluationContext.contextReference}
|
|
57
|
-
*/
|
|
58
|
-
export interface SubscribableDependency {
|
|
59
|
-
readonly scope: ReactiveScope;
|
|
60
|
-
readonly subscribe: VoidFunction;
|
|
61
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { CollectionValues } from '@getodk/common/types/collections/CollectionValues.ts';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Like JavaRosa. Presumably for explicit types which aren't impelemnted?
|
|
5
|
-
*/
|
|
6
|
-
const UNSUPPORTED_DATA_TYPE = 'UNSUPPORTED';
|
|
7
|
-
|
|
8
|
-
export type UnsupportedDataType = typeof UNSUPPORTED_DATA_TYPE;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Like JavaRosa. Presumably for e.g. groups with explicit binds (`relevant` etc)?
|
|
12
|
-
*/
|
|
13
|
-
export type NullDataType = 'NULL';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* As in ODK XForms Spec.
|
|
17
|
-
*
|
|
18
|
-
* TODO: it's unclear why JavaRosa's `DataType` hews closely to the spec, but
|
|
19
|
-
* has certain differences (e.g. string -> TEXT, int -> INTEGER). It's also
|
|
20
|
-
* not immediately clear how additive types like CHOICE and MULTIPLE_ITEMS
|
|
21
|
-
* square with the underlying spec types.
|
|
22
|
-
*/
|
|
23
|
-
export const XFORM_SPEC_DATA_TYPES = [
|
|
24
|
-
'string',
|
|
25
|
-
'int',
|
|
26
|
-
'boolean',
|
|
27
|
-
'decimal',
|
|
28
|
-
'date',
|
|
29
|
-
'time',
|
|
30
|
-
'dateTime',
|
|
31
|
-
'geopoint',
|
|
32
|
-
'geotrace',
|
|
33
|
-
'geoshape',
|
|
34
|
-
'binary',
|
|
35
|
-
'barcode',
|
|
36
|
-
'intent',
|
|
37
|
-
] as const;
|
|
38
|
-
|
|
39
|
-
const isSupportedDataType = (bindType: string): bindType is XFormSpecDataType =>
|
|
40
|
-
XFORM_SPEC_DATA_TYPES.includes(bindType as XFormSpecDataType);
|
|
41
|
-
|
|
42
|
-
export type XFormSpecDataType = CollectionValues<typeof XFORM_SPEC_DATA_TYPES>;
|
|
43
|
-
|
|
44
|
-
export type XFormDataType = NullDataType | UnsupportedDataType | XFormSpecDataType;
|
|
45
|
-
|
|
46
|
-
const DEFAULT_XFORM_DATA_TYPE = 'string';
|
|
47
|
-
|
|
48
|
-
export type DefaultXFormDataType = typeof DEFAULT_XFORM_DATA_TYPE;
|
|
49
|
-
|
|
50
|
-
// TODO: groups -> NULL?
|
|
51
|
-
// TODO: XSD namespace
|
|
52
|
-
export const bindDataType = (bindType: string | null): XFormDataType => {
|
|
53
|
-
if (bindType == null) {
|
|
54
|
-
return DEFAULT_XFORM_DATA_TYPE;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (isSupportedDataType(bindType)) {
|
|
58
|
-
return bindType;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return UNSUPPORTED_DATA_TYPE;
|
|
62
|
-
};
|