@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
package/src/instance/Root.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { Accessor
|
|
3
|
-
import { createSignal } from 'solid-js';
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
|
+
import type { Accessor } from 'solid-js';
|
|
4
3
|
import type { ActiveLanguage, FormLanguage, FormLanguages } from '../client/FormLanguage.ts';
|
|
4
|
+
import type { FormNodeID } from '../client/identity.ts';
|
|
5
5
|
import type { RootNode } from '../client/RootNode.ts';
|
|
6
|
+
import type { SubmissionDefinition } from '../client/submission/SubmissionDefinition.ts';
|
|
7
|
+
import type {
|
|
8
|
+
SubmissionChunkedType,
|
|
9
|
+
SubmissionOptions,
|
|
10
|
+
} from '../client/submission/SubmissionOptions.ts';
|
|
11
|
+
import type { SubmissionResult } from '../client/submission/SubmissionResult.ts';
|
|
12
|
+
import type { SubmissionState } from '../client/submission/SubmissionState.ts';
|
|
6
13
|
import type { AncestorNodeValidationState } from '../client/validation.ts';
|
|
14
|
+
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
15
|
+
import { createParentNodeSubmissionState } from '../lib/client-reactivity/submission/createParentNodeSubmissionState.ts';
|
|
7
16
|
import type { ChildrenState } from '../lib/reactivity/createChildrenState.ts';
|
|
8
17
|
import { createChildrenState } from '../lib/reactivity/createChildrenState.ts';
|
|
9
18
|
import type { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
|
|
@@ -15,146 +24,87 @@ import { createSharedNodeState } from '../lib/reactivity/node-state/createShared
|
|
|
15
24
|
import { createAggregatedViolations } from '../lib/reactivity/validation/createAggregatedViolations.ts';
|
|
16
25
|
import type { BodyClassList } from '../parse/body/BodyDefinition.ts';
|
|
17
26
|
import type { RootDefinition } from '../parse/model/RootDefinition.ts';
|
|
18
|
-
import
|
|
19
|
-
import { InstanceNode } from './abstract/InstanceNode.ts';
|
|
27
|
+
import { DescendantNode } from './abstract/DescendantNode.ts';
|
|
20
28
|
import { buildChildren } from './children.ts';
|
|
21
29
|
import type { GeneralChildNode } from './hierarchy.ts';
|
|
22
|
-
import type {
|
|
23
|
-
import type {
|
|
24
|
-
import type { InstanceConfig } from './internal-api/InstanceConfig.ts';
|
|
25
|
-
import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
|
|
30
|
+
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
31
|
+
import type { ClientReactiveSubmittableParentNode } from './internal-api/submission/ClientReactiveSubmittableParentNode.ts';
|
|
26
32
|
import type { TranslationContext } from './internal-api/TranslationContext.ts';
|
|
33
|
+
import type { PrimaryInstance } from './PrimaryInstance.ts';
|
|
27
34
|
|
|
28
35
|
interface RootStateSpec {
|
|
29
|
-
readonly reference: string
|
|
30
|
-
readonly readonly: boolean
|
|
31
|
-
readonly relevant: boolean
|
|
32
|
-
readonly required: boolean
|
|
36
|
+
readonly reference: Accessor<string>;
|
|
37
|
+
readonly readonly: Accessor<boolean>;
|
|
38
|
+
readonly relevant: Accessor<boolean>;
|
|
39
|
+
readonly required: Accessor<boolean>;
|
|
33
40
|
readonly label: null;
|
|
34
41
|
readonly hint: null;
|
|
35
|
-
readonly children: Accessor<readonly
|
|
42
|
+
readonly children: Accessor<readonly FormNodeID[]>;
|
|
36
43
|
readonly valueOptions: null;
|
|
37
44
|
readonly value: null;
|
|
38
45
|
|
|
39
46
|
// Root-specific
|
|
40
|
-
readonly activeLanguage:
|
|
47
|
+
readonly activeLanguage: Accessor<ActiveLanguage>;
|
|
41
48
|
}
|
|
42
49
|
|
|
43
|
-
// Subset of types expected from evaluator
|
|
44
|
-
interface ItextTranslations {
|
|
45
|
-
getActiveLanguage(): string | null;
|
|
46
|
-
getLanguages(): readonly string[];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
interface InitialLanguageState {
|
|
50
|
-
readonly defaultLanguage: ActiveLanguage;
|
|
51
|
-
readonly languages: FormLanguages;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// TODO: it's really very silly that the XPath evaluator is the current
|
|
55
|
-
// definitional source of truth for translation stuff... even though it currently makes sense that that's where it's first derived.
|
|
56
|
-
const getInitialLanguageState = (translations: ItextTranslations): InitialLanguageState => {
|
|
57
|
-
const activeLanguageName = translations.getActiveLanguage();
|
|
58
|
-
|
|
59
|
-
if (activeLanguageName == null) {
|
|
60
|
-
const defaultLanguage: ActiveLanguage = {
|
|
61
|
-
isSyntheticDefault: true,
|
|
62
|
-
language: '',
|
|
63
|
-
};
|
|
64
|
-
const languages = [defaultLanguage] satisfies FormLanguages;
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
defaultLanguage,
|
|
68
|
-
languages,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const languageNames = translations.getLanguages();
|
|
73
|
-
|
|
74
|
-
const inactiveLanguages = languageNames
|
|
75
|
-
.filter((languageName) => {
|
|
76
|
-
return languageName !== activeLanguageName;
|
|
77
|
-
})
|
|
78
|
-
.map((language): FormLanguage => {
|
|
79
|
-
return { language };
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
const languages = [
|
|
83
|
-
{ language: activeLanguageName } satisfies FormLanguage,
|
|
84
|
-
|
|
85
|
-
...inactiveLanguages,
|
|
86
|
-
] satisfies FormLanguages;
|
|
87
|
-
const [defaultLanguage] = languages;
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
defaultLanguage,
|
|
91
|
-
languages,
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
|
|
95
50
|
export class Root
|
|
96
|
-
extends
|
|
51
|
+
extends DescendantNode<RootDefinition, RootStateSpec, PrimaryInstance, GeneralChildNode>
|
|
97
52
|
implements
|
|
98
53
|
RootNode,
|
|
54
|
+
XFormsXPathElement,
|
|
99
55
|
EvaluationContext,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
TranslationContext
|
|
56
|
+
TranslationContext,
|
|
57
|
+
ClientReactiveSubmittableParentNode<GeneralChildNode>
|
|
103
58
|
{
|
|
104
59
|
private readonly childrenState: ChildrenState<GeneralChildNode>;
|
|
105
60
|
|
|
106
|
-
//
|
|
107
|
-
readonly
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
readonly isRelevant = () => true;
|
|
61
|
+
// XFormsXPathElement
|
|
62
|
+
override readonly [XPathNodeKindKey] = 'element';
|
|
63
|
+
|
|
64
|
+
// DescendantNode
|
|
111
65
|
protected readonly state: SharedNodeState<RootStateSpec>;
|
|
112
66
|
protected readonly engineState: EngineState<RootStateSpec>;
|
|
113
67
|
|
|
68
|
+
override readonly hasReadonlyAncestor = () => false;
|
|
69
|
+
override readonly isSelfReadonly = () => false;
|
|
70
|
+
override readonly isReadonly = () => false;
|
|
71
|
+
override readonly hasNonRelevantAncestor = () => false;
|
|
72
|
+
override readonly isSelfRelevant = () => true;
|
|
73
|
+
override readonly isRelevant = () => true;
|
|
74
|
+
override readonly isRequired = () => false;
|
|
75
|
+
|
|
114
76
|
// RootNode
|
|
115
77
|
readonly nodeType = 'root';
|
|
116
78
|
readonly appearances = null;
|
|
117
79
|
readonly classes: BodyClassList;
|
|
118
80
|
readonly currentState: MaterializedChildren<CurrentState<RootStateSpec>, GeneralChildNode>;
|
|
119
81
|
readonly validationState: AncestorNodeValidationState;
|
|
82
|
+
readonly submissionState: SubmissionState;
|
|
120
83
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
// EvaluationContext
|
|
127
|
-
readonly evaluator: XFormsXPathEvaluator;
|
|
128
|
-
|
|
129
|
-
readonly contextNode: Element;
|
|
84
|
+
// ClientReactiveSubmittableInstance
|
|
85
|
+
get submissionDefinition(): SubmissionDefinition {
|
|
86
|
+
return this.definition.submission;
|
|
87
|
+
}
|
|
130
88
|
|
|
131
89
|
// RootNode
|
|
132
|
-
override readonly parent = null;
|
|
133
|
-
|
|
134
90
|
readonly languages: FormLanguages;
|
|
135
91
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
constructor(xformDOM: XFormDOM, definition: RootDefinition, engineConfig: InstanceConfig) {
|
|
142
|
-
const reference = definition.nodeset;
|
|
92
|
+
constructor(parent: PrimaryInstance) {
|
|
93
|
+
const { definition } = parent;
|
|
94
|
+
const { nodeset: reference } = definition;
|
|
95
|
+
const computeReference: Accessor<string> = () => reference;
|
|
143
96
|
|
|
144
|
-
super(
|
|
145
|
-
computeReference
|
|
97
|
+
super(parent, definition, {
|
|
98
|
+
computeReference,
|
|
146
99
|
});
|
|
147
100
|
|
|
148
|
-
this.classes =
|
|
101
|
+
this.classes = parent.classes;
|
|
149
102
|
|
|
150
103
|
const childrenState = createChildrenState<Root, GeneralChildNode>(this);
|
|
151
104
|
|
|
152
105
|
this.childrenState = childrenState;
|
|
106
|
+
this.languages = parent.languages;
|
|
153
107
|
|
|
154
|
-
const instanceDOM = xformDOM.createInstance();
|
|
155
|
-
const evaluator = instanceDOM.primaryInstanceEvaluator;
|
|
156
|
-
const { translations } = evaluator;
|
|
157
|
-
const { defaultLanguage, languages } = getInitialLanguageState(translations);
|
|
158
108
|
const sharedStateOptions = {
|
|
159
109
|
clientStateFactory: this.engineConfig.stateFactory,
|
|
160
110
|
};
|
|
@@ -162,13 +112,13 @@ export class Root
|
|
|
162
112
|
const state = createSharedNodeState(
|
|
163
113
|
this.scope,
|
|
164
114
|
{
|
|
165
|
-
activeLanguage:
|
|
166
|
-
reference,
|
|
115
|
+
activeLanguage: parent.getActiveLanguage,
|
|
116
|
+
reference: computeReference,
|
|
167
117
|
label: null,
|
|
168
118
|
hint: null,
|
|
169
|
-
readonly: false,
|
|
170
|
-
relevant: true,
|
|
171
|
-
required: false,
|
|
119
|
+
readonly: () => false,
|
|
120
|
+
relevant: () => true,
|
|
121
|
+
required: () => false,
|
|
172
122
|
valueOptions: null,
|
|
173
123
|
value: null,
|
|
174
124
|
children: childrenState.childIds,
|
|
@@ -184,17 +134,9 @@ export class Root
|
|
|
184
134
|
childrenState
|
|
185
135
|
);
|
|
186
136
|
|
|
187
|
-
const contextNode = instanceDOM.xformDocument.createElement(definition.nodeName);
|
|
188
|
-
|
|
189
|
-
instanceDOM.primaryInstanceRoot.replaceWith(contextNode);
|
|
190
|
-
|
|
191
|
-
this.evaluator = evaluator;
|
|
192
|
-
this.contextNode = contextNode;
|
|
193
|
-
this.instanceDOM = instanceDOM;
|
|
194
|
-
this.languages = languages;
|
|
195
|
-
|
|
196
137
|
childrenState.setChildren(buildChildren(this));
|
|
197
138
|
this.validationState = createAggregatedViolations(this, sharedStateOptions);
|
|
139
|
+
this.submissionState = createParentNodeSubmissionState(this);
|
|
198
140
|
}
|
|
199
141
|
|
|
200
142
|
getChildren(): readonly GeneralChildNode[] {
|
|
@@ -203,28 +145,14 @@ export class Root
|
|
|
203
145
|
|
|
204
146
|
// RootNode
|
|
205
147
|
setLanguage(language: FormLanguage): Root {
|
|
206
|
-
|
|
207
|
-
return formLanguage.language === language.language;
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
if (activeLanguage == null) {
|
|
211
|
-
throw new Error(`Language "${language.language}" not available`);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
this.evaluator.translations.setActiveLanguage(activeLanguage.language);
|
|
215
|
-
this.state.setProperty('activeLanguage', activeLanguage);
|
|
148
|
+
this.rootDocument.setLanguage(language);
|
|
216
149
|
|
|
217
150
|
return this;
|
|
218
151
|
}
|
|
219
152
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
// TODO: typescript-eslint is right to object to this! We should _at least_
|
|
225
|
-
// make internal reactive reads obvious, i.e. function calls.
|
|
226
|
-
//
|
|
227
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- read == subscribe
|
|
228
|
-
this.engineState.activeLanguage;
|
|
153
|
+
prepareSubmission<ChunkedType extends SubmissionChunkedType = 'monolithic'>(
|
|
154
|
+
options?: SubmissionOptions<ChunkedType>
|
|
155
|
+
): Promise<SubmissionResult<ChunkedType>> {
|
|
156
|
+
return this.rootDocument.prepareSubmission(options);
|
|
229
157
|
}
|
|
230
158
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { xmlXPathWhitespaceSeparatedList } from '@getodk/common/lib/string/whitespace.ts';
|
|
2
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
3
|
import type { Accessor } from 'solid-js';
|
|
3
|
-
import { untrack } from 'solid-js';
|
|
4
|
+
import { createMemo, untrack } from 'solid-js';
|
|
4
5
|
import type { SelectItem, SelectNode, SelectNodeAppearances } from '../client/SelectNode.ts';
|
|
5
6
|
import type { TextRange } from '../client/TextRange.ts';
|
|
7
|
+
import type { SubmissionState } from '../client/submission/SubmissionState.ts';
|
|
6
8
|
import type { AnyViolation, LeafNodeValidationState } from '../client/validation.ts';
|
|
9
|
+
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
10
|
+
import { createLeafNodeSubmissionState } from '../lib/client-reactivity/submission/createLeafNodeSubmissionState.ts';
|
|
7
11
|
import { createSelectItems } from '../lib/reactivity/createSelectItems.ts';
|
|
8
12
|
import { createValueState } from '../lib/reactivity/createValueState.ts';
|
|
9
13
|
import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
|
|
@@ -22,9 +26,9 @@ import type { DescendantNodeStateSpec } from './abstract/DescendantNode.ts';
|
|
|
22
26
|
import { DescendantNode } from './abstract/DescendantNode.ts';
|
|
23
27
|
import type { GeneralParentNode } from './hierarchy.ts';
|
|
24
28
|
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
25
|
-
import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
|
|
26
29
|
import type { ValidationContext } from './internal-api/ValidationContext.ts';
|
|
27
30
|
import type { ValueContext } from './internal-api/ValueContext.ts';
|
|
31
|
+
import type { ClientReactiveSubmittableLeafNode } from './internal-api/submission/ClientReactiveSubmittableLeafNode.ts';
|
|
28
32
|
|
|
29
33
|
export interface SelectFieldDefinition extends LeafNodeDefinition {
|
|
30
34
|
readonly bodyElement: AnySelectDefinition;
|
|
@@ -39,17 +43,21 @@ interface SelectFieldStateSpec extends DescendantNodeStateSpec<readonly SelectIt
|
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
export class SelectField
|
|
42
|
-
extends DescendantNode<SelectFieldDefinition, SelectFieldStateSpec, null>
|
|
46
|
+
extends DescendantNode<SelectFieldDefinition, SelectFieldStateSpec, GeneralParentNode, null>
|
|
43
47
|
implements
|
|
44
48
|
SelectNode,
|
|
49
|
+
XFormsXPathElement,
|
|
45
50
|
EvaluationContext,
|
|
46
|
-
SubscribableDependency,
|
|
47
51
|
ValidationContext,
|
|
48
|
-
ValueContext<readonly SelectItem[]
|
|
52
|
+
ValueContext<readonly SelectItem[]>,
|
|
53
|
+
ClientReactiveSubmittableLeafNode<readonly SelectItem[]>
|
|
49
54
|
{
|
|
50
55
|
private readonly selectExclusive: boolean;
|
|
51
56
|
private readonly validation: SharedValidationState;
|
|
52
57
|
|
|
58
|
+
// XFormsXPathElement
|
|
59
|
+
override readonly [XPathNodeKindKey] = 'element';
|
|
60
|
+
|
|
53
61
|
// InstanceNode
|
|
54
62
|
protected readonly state: SharedNodeState<SelectFieldStateSpec>;
|
|
55
63
|
protected override engineState: EngineState<SelectFieldStateSpec>;
|
|
@@ -63,32 +71,35 @@ export class SelectField
|
|
|
63
71
|
return this.validation.currentState;
|
|
64
72
|
}
|
|
65
73
|
|
|
74
|
+
readonly submissionState: SubmissionState;
|
|
75
|
+
|
|
66
76
|
// ValueContext
|
|
77
|
+
override readonly contextNode = this;
|
|
78
|
+
|
|
67
79
|
readonly encodeValue = (runtimeValue: readonly SelectItem[]): string => {
|
|
68
80
|
const itemValues = new Set(runtimeValue.map(({ value }) => value));
|
|
81
|
+
const selectedItems = this.getValueOptions().filter(({ value }) => {
|
|
82
|
+
return itemValues.has(value);
|
|
83
|
+
});
|
|
69
84
|
|
|
70
|
-
return
|
|
85
|
+
return selectedItems.map(({ value }) => value).join(' ');
|
|
71
86
|
};
|
|
72
87
|
|
|
73
88
|
readonly decodeValue = (instanceValue: string): readonly SelectItem[] => {
|
|
74
|
-
|
|
75
|
-
|
|
89
|
+
const itemValues = new Set(
|
|
90
|
+
xmlXPathWhitespaceSeparatedList(instanceValue, {
|
|
76
91
|
ignoreEmpty: true,
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
const items = this.getSelectItemsByValue();
|
|
92
|
+
})
|
|
93
|
+
);
|
|
80
94
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
})
|
|
85
|
-
.filter((item): item is SelectItem => {
|
|
86
|
-
return item != null;
|
|
87
|
-
});
|
|
95
|
+
// TODO: also want set-like behavior, probably?
|
|
96
|
+
return this.getValueOptions().filter((option) => {
|
|
97
|
+
return itemValues.has(option.value);
|
|
88
98
|
});
|
|
89
99
|
};
|
|
90
100
|
|
|
91
101
|
protected readonly getValueOptions: Accessor<readonly SelectItem[]>;
|
|
102
|
+
protected readonly getValue: Accessor<readonly SelectItem[]>;
|
|
92
103
|
|
|
93
104
|
constructor(parent: GeneralParentNode, definition: SelectFieldDefinition) {
|
|
94
105
|
super(parent, definition);
|
|
@@ -100,6 +111,26 @@ export class SelectField
|
|
|
100
111
|
|
|
101
112
|
this.getValueOptions = valueOptions;
|
|
102
113
|
|
|
114
|
+
const [baseGetValue, setValue] = createValueState(this);
|
|
115
|
+
|
|
116
|
+
const getValue = this.scope.runTask(() => {
|
|
117
|
+
const selectItemsByValue = createMemo((): ReadonlyMap<string, SelectItem> => {
|
|
118
|
+
return new Map(valueOptions().map((item) => [item.value, item]));
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
return createMemo(() => {
|
|
122
|
+
const items = selectItemsByValue();
|
|
123
|
+
|
|
124
|
+
return baseGetValue().filter((item) => {
|
|
125
|
+
return items.has(item.value);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
this.getValue = getValue;
|
|
131
|
+
|
|
132
|
+
const valueState: SimpleAtomicState<readonly SelectItem[]> = [getValue, setValue];
|
|
133
|
+
|
|
103
134
|
const sharedStateOptions = {
|
|
104
135
|
clientStateFactory: this.engineConfig.stateFactory,
|
|
105
136
|
};
|
|
@@ -115,7 +146,7 @@ export class SelectField
|
|
|
115
146
|
label: createNodeLabel(this, definition),
|
|
116
147
|
hint: createFieldHint(this, definition),
|
|
117
148
|
children: null,
|
|
118
|
-
value:
|
|
149
|
+
value: valueState,
|
|
119
150
|
valueOptions,
|
|
120
151
|
},
|
|
121
152
|
sharedStateOptions
|
|
@@ -125,6 +156,7 @@ export class SelectField
|
|
|
125
156
|
this.engineState = state.engineState;
|
|
126
157
|
this.currentState = state.currentState;
|
|
127
158
|
this.validation = createValidationState(this, sharedStateOptions);
|
|
159
|
+
this.submissionState = createLeafNodeSubmissionState(this);
|
|
128
160
|
}
|
|
129
161
|
|
|
130
162
|
protected getSelectItemsByValue(
|
|
@@ -163,6 +195,11 @@ export class SelectField
|
|
|
163
195
|
this.updateSelectedItemValues([value]);
|
|
164
196
|
}
|
|
165
197
|
|
|
198
|
+
// XFormsXPathElement
|
|
199
|
+
override getXPathValue(): string {
|
|
200
|
+
return this.encodeValue(this.engineState.value);
|
|
201
|
+
}
|
|
202
|
+
|
|
166
203
|
// SelectNode
|
|
167
204
|
select(selectedItem: SelectItem): Root {
|
|
168
205
|
const { engineState, root } = this;
|
package/src/instance/Subtree.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
|
+
import type { Accessor } from 'solid-js';
|
|
3
|
+
import type { FormNodeID } from '../client/identity.ts';
|
|
4
|
+
import type { SubmissionState } from '../client/submission/SubmissionState.ts';
|
|
2
5
|
import type { SubtreeDefinition, SubtreeNode } from '../client/SubtreeNode.ts';
|
|
3
6
|
import type { AncestorNodeValidationState } from '../client/validation.ts';
|
|
7
|
+
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
8
|
+
import { createParentNodeSubmissionState } from '../lib/client-reactivity/submission/createParentNodeSubmissionState.ts';
|
|
4
9
|
import type { ChildrenState } from '../lib/reactivity/createChildrenState.ts';
|
|
5
10
|
import { createChildrenState } from '../lib/reactivity/createChildrenState.ts';
|
|
6
11
|
import type { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
|
|
@@ -14,33 +19,39 @@ import type { DescendantNodeSharedStateSpec } from './abstract/DescendantNode.ts
|
|
|
14
19
|
import { DescendantNode } from './abstract/DescendantNode.ts';
|
|
15
20
|
import { buildChildren } from './children.ts';
|
|
16
21
|
import type { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
|
|
17
|
-
import type { NodeID } from './identity.ts';
|
|
18
22
|
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
19
|
-
import type {
|
|
23
|
+
import type { ClientReactiveSubmittableParentNode } from './internal-api/submission/ClientReactiveSubmittableParentNode.ts';
|
|
20
24
|
|
|
21
25
|
interface SubtreeStateSpec extends DescendantNodeSharedStateSpec {
|
|
22
26
|
readonly label: null;
|
|
23
27
|
readonly hint: null;
|
|
24
|
-
readonly children: Accessor<readonly
|
|
28
|
+
readonly children: Accessor<readonly FormNodeID[]>;
|
|
25
29
|
readonly valueOptions: null;
|
|
26
30
|
readonly value: null;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
export class Subtree
|
|
30
|
-
extends DescendantNode<SubtreeDefinition, SubtreeStateSpec, GeneralChildNode>
|
|
31
|
-
implements
|
|
34
|
+
extends DescendantNode<SubtreeDefinition, SubtreeStateSpec, GeneralParentNode, GeneralChildNode>
|
|
35
|
+
implements
|
|
36
|
+
SubtreeNode,
|
|
37
|
+
XFormsXPathElement,
|
|
38
|
+
EvaluationContext,
|
|
39
|
+
ClientReactiveSubmittableParentNode<GeneralChildNode>
|
|
32
40
|
{
|
|
33
41
|
private readonly childrenState: ChildrenState<GeneralChildNode>;
|
|
34
42
|
|
|
43
|
+
override readonly [XPathNodeKindKey] = 'element';
|
|
44
|
+
|
|
35
45
|
// InstanceNode
|
|
36
46
|
protected readonly state: SharedNodeState<SubtreeStateSpec>;
|
|
37
|
-
protected engineState: EngineState<SubtreeStateSpec>;
|
|
47
|
+
protected readonly engineState: EngineState<SubtreeStateSpec>;
|
|
38
48
|
|
|
39
49
|
// SubtreeNode
|
|
40
50
|
readonly nodeType = 'subtree';
|
|
41
51
|
readonly appearances = null;
|
|
42
52
|
readonly currentState: MaterializedChildren<CurrentState<SubtreeStateSpec>, GeneralChildNode>;
|
|
43
53
|
readonly validationState: AncestorNodeValidationState;
|
|
54
|
+
readonly submissionState: SubmissionState;
|
|
44
55
|
|
|
45
56
|
constructor(parent: GeneralParentNode, definition: SubtreeDefinition) {
|
|
46
57
|
super(parent, definition);
|
|
@@ -80,6 +91,7 @@ export class Subtree
|
|
|
80
91
|
|
|
81
92
|
childrenState.setChildren(buildChildren(this));
|
|
82
93
|
this.validationState = createAggregatedViolations(this, sharedStateOptions);
|
|
94
|
+
this.submissionState = createParentNodeSubmissionState(this);
|
|
83
95
|
}
|
|
84
96
|
|
|
85
97
|
getChildren(): readonly GeneralChildNode[] {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
1
2
|
import type { Accessor } from 'solid-js';
|
|
2
3
|
import type { TextRange } from '../client/TextRange.ts';
|
|
3
4
|
import type { TriggerNode, TriggerNodeDefinition } from '../client/TriggerNode.ts';
|
|
5
|
+
import type { SubmissionState } from '../client/submission/SubmissionState.ts';
|
|
4
6
|
import type { AnyViolation, LeafNodeValidationState } from '../client/validation.ts';
|
|
7
|
+
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
8
|
+
import { createLeafNodeSubmissionState } from '../lib/client-reactivity/submission/createLeafNodeSubmissionState.ts';
|
|
5
9
|
import { createValueState } from '../lib/reactivity/createValueState.ts';
|
|
6
10
|
import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
|
|
7
11
|
import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
|
|
@@ -18,9 +22,9 @@ import type { DescendantNodeStateSpec } from './abstract/DescendantNode.ts';
|
|
|
18
22
|
import { DescendantNode } from './abstract/DescendantNode.ts';
|
|
19
23
|
import type { GeneralParentNode } from './hierarchy.ts';
|
|
20
24
|
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
21
|
-
import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
|
|
22
25
|
import type { ValidationContext } from './internal-api/ValidationContext.ts';
|
|
23
26
|
import type { ValueContext } from './internal-api/ValueContext.ts';
|
|
27
|
+
import type { ClientReactiveSubmittableLeafNode } from './internal-api/submission/ClientReactiveSubmittableLeafNode.ts';
|
|
24
28
|
|
|
25
29
|
interface TriggerControlStateSpec extends DescendantNodeStateSpec<boolean> {
|
|
26
30
|
readonly label: Accessor<TextRange<'label'> | null>;
|
|
@@ -33,19 +37,23 @@ interface TriggerControlStateSpec extends DescendantNodeStateSpec<boolean> {
|
|
|
33
37
|
const TRIGGER_ASSIGNED_VALUE = 'OK';
|
|
34
38
|
|
|
35
39
|
export class TriggerControl
|
|
36
|
-
extends DescendantNode<TriggerNodeDefinition, TriggerControlStateSpec, null>
|
|
40
|
+
extends DescendantNode<TriggerNodeDefinition, TriggerControlStateSpec, GeneralParentNode, null>
|
|
37
41
|
implements
|
|
38
42
|
TriggerNode,
|
|
43
|
+
XFormsXPathElement,
|
|
39
44
|
EvaluationContext,
|
|
40
|
-
SubscribableDependency,
|
|
41
45
|
ValidationContext,
|
|
42
|
-
ValueContext<boolean
|
|
46
|
+
ValueContext<boolean>,
|
|
47
|
+
ClientReactiveSubmittableLeafNode<boolean>
|
|
43
48
|
{
|
|
44
49
|
private readonly validation: SharedValidationState;
|
|
45
|
-
|
|
50
|
+
|
|
51
|
+
// XFormsXPathElement
|
|
52
|
+
override readonly [XPathNodeKindKey] = 'element';
|
|
46
53
|
|
|
47
54
|
// InstanceNode
|
|
48
|
-
protected
|
|
55
|
+
protected readonly state: SharedNodeState<TriggerControlStateSpec>;
|
|
56
|
+
protected readonly engineState: EngineState<TriggerControlStateSpec>;
|
|
49
57
|
|
|
50
58
|
// TriggerNode
|
|
51
59
|
readonly nodeType = 'trigger';
|
|
@@ -56,7 +64,10 @@ export class TriggerControl
|
|
|
56
64
|
return this.validation.currentState;
|
|
57
65
|
}
|
|
58
66
|
|
|
67
|
+
readonly submissionState: SubmissionState;
|
|
68
|
+
|
|
59
69
|
// ValueContext
|
|
70
|
+
override readonly contextNode = this;
|
|
60
71
|
readonly encodeValue: (runtimeValue: boolean) => string;
|
|
61
72
|
readonly decodeValue: (instanceValue: string) => boolean;
|
|
62
73
|
|
|
@@ -109,6 +120,12 @@ export class TriggerControl
|
|
|
109
120
|
this.engineState = state.engineState;
|
|
110
121
|
this.currentState = state.currentState;
|
|
111
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);
|
|
112
129
|
}
|
|
113
130
|
|
|
114
131
|
// ValidationContext
|