@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.
Files changed (285) hide show
  1. package/dist/client/BaseNode.d.ts +14 -3
  2. package/dist/client/BaseValueNode.d.ts +32 -0
  3. package/dist/client/EngineConfig.d.ts +49 -48
  4. package/dist/client/InputNode.d.ts +53 -0
  5. package/dist/client/ModelValueNode.d.ts +12 -7
  6. package/dist/client/NoteNode.d.ts +2 -2
  7. package/dist/client/RootNode.d.ts +34 -7
  8. package/dist/client/SelectNode.d.ts +2 -2
  9. package/dist/client/ValueType.d.ts +3 -0
  10. package/dist/client/constants.d.ts +50 -0
  11. package/dist/client/hierarchy.d.ts +4 -4
  12. package/dist/client/identity.d.ts +14 -0
  13. package/dist/client/node-types.d.ts +2 -1
  14. package/dist/client/resources.d.ts +93 -0
  15. package/dist/client/submission/SubmissionData.d.ts +7 -0
  16. package/dist/client/submission/SubmissionDefinition.d.ts +14 -0
  17. package/dist/client/submission/SubmissionInstanceFile.d.ts +6 -0
  18. package/dist/client/submission/SubmissionOptions.d.ts +23 -0
  19. package/dist/client/submission/SubmissionResult.d.ts +91 -0
  20. package/dist/client/submission/SubmissionState.d.ts +12 -0
  21. package/dist/client/validation.d.ts +2 -2
  22. package/dist/error/ErrorProductionDesignPendingError.d.ts +7 -0
  23. package/dist/error/ValueTypeInvariantError.d.ts +17 -0
  24. package/dist/error/XPathFunctionalityError.d.ts +14 -0
  25. package/dist/error/XPathFunctionalityNotSupportedError.d.ts +7 -0
  26. package/dist/error/XPathFunctionalityPendingError.d.ts +7 -0
  27. package/dist/index.d.ts +10 -1
  28. package/dist/index.js +10856 -8585
  29. package/dist/index.js.map +1 -1
  30. package/dist/instance/Group.d.ts +9 -4
  31. package/dist/instance/InputControl.d.ts +36 -0
  32. package/dist/instance/ModelValue.d.ts +16 -26
  33. package/dist/instance/Note.d.ts +10 -3
  34. package/dist/instance/PrimaryInstance.d.ts +84 -0
  35. package/dist/instance/Root.d.ts +29 -25
  36. package/dist/instance/SelectField.d.ts +10 -2
  37. package/dist/instance/Subtree.d.ts +10 -5
  38. package/dist/instance/TriggerControl.d.ts +10 -3
  39. package/dist/instance/abstract/DescendantNode.d.ts +31 -23
  40. package/dist/instance/abstract/InstanceNode.d.ts +49 -29
  41. package/dist/instance/abstract/UnsupportedControl.d.ts +10 -3
  42. package/dist/instance/abstract/ValueNode.d.ts +48 -0
  43. package/dist/instance/hierarchy.d.ts +9 -8
  44. package/dist/instance/identity.d.ts +2 -7
  45. package/dist/instance/internal-api/EvaluationContext.d.ts +53 -12
  46. package/dist/instance/internal-api/InstanceConfig.d.ts +8 -2
  47. package/dist/instance/internal-api/InstanceValueContext.d.ts +20 -0
  48. package/dist/instance/internal-api/PrimaryInstanceDocument.d.ts +36 -0
  49. package/dist/instance/internal-api/TranslationContext.d.ts +3 -2
  50. package/dist/instance/internal-api/ValidationContext.d.ts +3 -4
  51. package/dist/instance/internal-api/ValueContext.d.ts +2 -1
  52. package/dist/instance/internal-api/submission/ClientReactiveSubmittableInstance.d.ts +14 -0
  53. package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +31 -0
  54. package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +18 -0
  55. package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +17 -0
  56. package/dist/instance/repeat/BaseRepeatRange.d.ts +39 -83
  57. package/dist/instance/repeat/RepeatInstance.d.ts +11 -29
  58. package/dist/instance/repeat/RepeatRangeControlled.d.ts +2 -2
  59. package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +2 -2
  60. package/dist/instance/resource.d.ts +1 -1
  61. package/dist/instance/text/TextRange.d.ts +1 -1
  62. package/dist/instance/unsupported/RangeControl.d.ts +3 -1
  63. package/dist/instance/unsupported/RankControl.d.ts +3 -1
  64. package/dist/instance/unsupported/UploadControl.d.ts +3 -1
  65. package/dist/integration/xpath/EngineXPathEvaluator.d.ts +14 -0
  66. package/dist/integration/xpath/adapter/XFormsXPathNode.d.ts +71 -0
  67. package/dist/integration/xpath/adapter/engineDOMAdapter.d.ts +5 -0
  68. package/dist/integration/xpath/adapter/kind.d.ts +32 -0
  69. package/dist/integration/xpath/adapter/names.d.ts +16 -0
  70. package/dist/integration/xpath/adapter/traversal.d.ts +25 -0
  71. package/dist/integration/xpath/adapter/values.d.ts +2 -0
  72. package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +19 -0
  73. package/dist/integration/xpath/static-dom/StaticDocument.d.ts +16 -0
  74. package/dist/integration/xpath/static-dom/StaticElement.d.ts +40 -0
  75. package/dist/integration/xpath/static-dom/StaticNamedNode.d.ts +17 -0
  76. package/dist/integration/xpath/static-dom/StaticNode.d.ts +33 -0
  77. package/dist/integration/xpath/static-dom/StaticText.d.ts +16 -0
  78. package/dist/lib/client-reactivity/submission/createInstanceSubmissionState.d.ts +3 -0
  79. package/dist/lib/client-reactivity/submission/createLeafNodeSubmissionState.d.ts +3 -0
  80. package/dist/lib/client-reactivity/submission/createNodeRangeSubmissionState.d.ts +4 -0
  81. package/dist/lib/client-reactivity/submission/createParentNodeSubmissionState.d.ts +4 -0
  82. package/dist/lib/client-reactivity/submission/createValueNodeSubmissionState.d.ts +3 -0
  83. package/dist/lib/client-reactivity/submission/prepareSubmission.d.ts +8 -0
  84. package/dist/lib/codecs/DecimalValueCodec.d.ts +6 -0
  85. package/dist/lib/codecs/IntValueCodec.d.ts +6 -0
  86. package/dist/lib/codecs/StringValueCodec.d.ts +4 -0
  87. package/dist/lib/codecs/ValueCodec.d.ts +30 -0
  88. package/dist/lib/codecs/ValueTypePlaceholderCodec.d.ts +12 -0
  89. package/dist/lib/codecs/getSharedValueCodec.d.ts +47 -0
  90. package/dist/lib/dom/query.d.ts +3 -0
  91. package/dist/lib/reactivity/createChildrenState.d.ts +7 -5
  92. package/dist/lib/reactivity/createComputedExpression.d.ts +18 -5
  93. package/dist/lib/reactivity/createInstanceValueState.d.ts +40 -0
  94. package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +2 -2
  95. package/dist/lib/reactivity/createTranslationState.d.ts +19 -0
  96. package/dist/lib/reactivity/createValueState.d.ts +6 -10
  97. package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +4 -4
  98. package/dist/lib/xml-serialization.d.ts +41 -0
  99. package/dist/parse/XFormDOM.d.ts +18 -7
  100. package/dist/parse/XFormDefinition.d.ts +1 -2
  101. package/dist/parse/attachments/FormAttachmentResource.d.ts +27 -0
  102. package/dist/parse/body/BodyDefinition.d.ts +3 -3
  103. package/dist/parse/body/RepeatElementDefinition.d.ts +1 -1
  104. package/dist/parse/body/appearance/inputAppearanceParser.d.ts +1 -1
  105. package/dist/parse/body/control/{InputDefinition.d.ts → InputControlDefinition.d.ts} +1 -1
  106. package/dist/parse/body/control/select/ItemsetNodesetContext.d.ts +0 -2
  107. package/dist/parse/expression/abstract/DependencyContext.d.ts +0 -5
  108. package/dist/parse/expression/abstract/DependentExpression.d.ts +2 -3
  109. package/dist/parse/model/BindDefinition.d.ts +4 -5
  110. package/dist/parse/model/BindTypeDefinition.d.ts +20 -0
  111. package/dist/parse/model/DescendentNodeDefinition.d.ts +0 -1
  112. package/dist/parse/model/FormSubmissionDefinition.d.ts +8 -0
  113. package/dist/parse/model/ItextTranslation/ItextTranslationDefinition.d.ts +4 -0
  114. package/dist/parse/model/ItextTranslation/ItextTranslationRootDefinition.d.ts +8 -0
  115. package/dist/parse/model/ItextTranslation/ItextTranslationsDefinition.d.ts +8 -0
  116. package/dist/parse/model/LeafNodeDefinition.d.ts +3 -1
  117. package/dist/parse/model/ModelBindMap.d.ts +1 -1
  118. package/dist/parse/model/ModelDefinition.d.ts +2 -0
  119. package/dist/parse/model/NodeDefinition.d.ts +0 -1
  120. package/dist/parse/model/NoteNodeDefinition.d.ts +4 -4
  121. package/dist/parse/model/RootDefinition.d.ts +3 -2
  122. package/dist/parse/model/SecondaryInstance/SecondaryInstanceDefinition.d.ts +4 -0
  123. package/dist/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.d.ts +7 -0
  124. package/dist/parse/model/SecondaryInstance/SecondaryInstancesDefinition.d.ts +13 -0
  125. package/dist/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.d.ts +14 -0
  126. package/dist/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.d.ts +22 -0
  127. package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.d.ts +23 -0
  128. package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.d.ts +9 -0
  129. package/dist/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.d.ts +5 -0
  130. package/dist/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.d.ts +7 -0
  131. package/dist/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.d.ts +13 -0
  132. package/dist/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.d.ts +12 -0
  133. package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +24 -0
  134. package/dist/parse/text/abstract/TextRangeDefinition.d.ts +0 -2
  135. package/dist/parse/xpath/semantic-analysis.d.ts +5 -0
  136. package/dist/solid.js +8174 -5921
  137. package/dist/solid.js.map +1 -1
  138. package/package.json +13 -11
  139. package/src/client/BaseNode.ts +16 -6
  140. package/src/client/BaseValueNode.ts +35 -0
  141. package/src/client/EngineConfig.ts +52 -51
  142. package/src/client/InputNode.ts +77 -0
  143. package/src/client/ModelValueNode.ts +30 -7
  144. package/src/client/NoteNode.ts +2 -2
  145. package/src/client/RootNode.ts +37 -7
  146. package/src/client/SelectNode.ts +3 -3
  147. package/src/client/ValueType.ts +4 -0
  148. package/src/client/constants.ts +67 -0
  149. package/src/client/hierarchy.ts +5 -5
  150. package/src/client/identity.ts +16 -0
  151. package/src/client/node-types.ts +12 -6
  152. package/src/client/resources.ts +118 -0
  153. package/src/client/submission/SubmissionData.ts +12 -0
  154. package/src/client/submission/SubmissionDefinition.ts +16 -0
  155. package/src/client/submission/SubmissionInstanceFile.ts +9 -0
  156. package/src/client/submission/SubmissionOptions.ts +28 -0
  157. package/src/client/submission/SubmissionResult.ts +124 -0
  158. package/src/client/submission/SubmissionState.ts +14 -0
  159. package/src/client/validation.ts +2 -2
  160. package/src/error/ErrorProductionDesignPendingError.ts +6 -0
  161. package/src/error/ValueTypeInvariantError.ts +22 -0
  162. package/src/error/XPathFunctionalityError.ts +26 -0
  163. package/src/error/XPathFunctionalityNotSupportedError.ts +18 -0
  164. package/src/error/XPathFunctionalityPendingError.ts +18 -0
  165. package/src/index.ts +10 -1
  166. package/src/instance/Group.ts +17 -5
  167. package/src/instance/InputControl.ts +119 -0
  168. package/src/instance/ModelValue.ts +47 -54
  169. package/src/instance/Note.ts +24 -8
  170. package/src/instance/PrimaryInstance.ts +244 -0
  171. package/src/instance/Root.ts +62 -134
  172. package/src/instance/SelectField.ts +56 -19
  173. package/src/instance/Subtree.ts +19 -7
  174. package/src/instance/TriggerControl.ts +23 -6
  175. package/src/instance/abstract/DescendantNode.ts +90 -45
  176. package/src/instance/abstract/InstanceNode.ts +103 -105
  177. package/src/instance/abstract/UnsupportedControl.ts +28 -5
  178. package/src/instance/abstract/ValueNode.ts +127 -0
  179. package/src/instance/children.ts +9 -10
  180. package/src/instance/hierarchy.ts +19 -15
  181. package/src/instance/identity.ts +3 -9
  182. package/src/instance/index.ts +25 -7
  183. package/src/instance/internal-api/EvaluationContext.ts +60 -13
  184. package/src/instance/internal-api/InstanceConfig.ts +9 -2
  185. package/src/instance/internal-api/InstanceValueContext.ts +24 -0
  186. package/src/instance/internal-api/PrimaryInstanceDocument.ts +53 -0
  187. package/src/instance/internal-api/TranslationContext.ts +3 -2
  188. package/src/instance/internal-api/ValidationContext.ts +3 -4
  189. package/src/instance/internal-api/ValueContext.ts +2 -1
  190. package/src/instance/internal-api/submission/ClientReactiveSubmittableInstance.ts +20 -0
  191. package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +42 -0
  192. package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +25 -0
  193. package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +23 -0
  194. package/src/instance/repeat/BaseRepeatRange.ts +50 -131
  195. package/src/instance/repeat/RepeatInstance.ts +20 -46
  196. package/src/instance/repeat/RepeatRangeControlled.ts +5 -5
  197. package/src/instance/repeat/RepeatRangeUncontrolled.ts +2 -4
  198. package/src/instance/resource.ts +1 -1
  199. package/src/instance/text/TextChunk.ts +1 -1
  200. package/src/instance/unsupported/RangeControl.ts +5 -1
  201. package/src/instance/unsupported/RankControl.ts +5 -1
  202. package/src/instance/unsupported/UploadControl.ts +5 -1
  203. package/src/integration/xpath/EngineXPathEvaluator.ts +22 -0
  204. package/src/integration/xpath/adapter/XFormsXPathNode.ts +126 -0
  205. package/src/integration/xpath/adapter/engineDOMAdapter.ts +57 -0
  206. package/src/integration/xpath/adapter/kind.ts +114 -0
  207. package/src/integration/xpath/adapter/names.ts +99 -0
  208. package/src/integration/xpath/adapter/traversal.ts +228 -0
  209. package/src/integration/xpath/adapter/values.ts +5 -0
  210. package/src/integration/xpath/static-dom/StaticAttribute.ts +33 -0
  211. package/src/integration/xpath/static-dom/StaticDocument.ts +38 -0
  212. package/src/integration/xpath/static-dom/StaticElement.ts +106 -0
  213. package/src/integration/xpath/static-dom/StaticNamedNode.ts +45 -0
  214. package/src/integration/xpath/static-dom/StaticNode.ts +68 -0
  215. package/src/integration/xpath/static-dom/StaticText.ts +28 -0
  216. package/src/lib/client-reactivity/README.md +0 -0
  217. package/src/lib/client-reactivity/submission/createInstanceSubmissionState.ts +12 -0
  218. package/src/lib/client-reactivity/submission/createLeafNodeSubmissionState.ts +20 -0
  219. package/src/lib/client-reactivity/submission/createNodeRangeSubmissionState.ts +17 -0
  220. package/src/lib/client-reactivity/submission/createParentNodeSubmissionState.ts +22 -0
  221. package/src/lib/client-reactivity/submission/createValueNodeSubmissionState.ts +21 -0
  222. package/src/lib/client-reactivity/submission/prepareSubmission.ts +172 -0
  223. package/src/lib/codecs/DecimalValueCodec.ts +46 -0
  224. package/src/lib/codecs/IntValueCodec.ts +100 -0
  225. package/src/lib/codecs/StringValueCodec.ts +11 -0
  226. package/src/lib/codecs/ValueCodec.ts +106 -0
  227. package/src/lib/codecs/ValueTypePlaceholderCodec.ts +19 -0
  228. package/src/lib/codecs/getSharedValueCodec.ts +77 -0
  229. package/src/lib/dom/query.ts +7 -0
  230. package/src/lib/reactivity/createChildrenState.ts +8 -6
  231. package/src/lib/reactivity/createComputedExpression.ts +57 -34
  232. package/src/lib/reactivity/createInstanceValueState.ts +166 -0
  233. package/src/lib/reactivity/createNoteReadonlyThunk.ts +12 -7
  234. package/src/lib/reactivity/createSelectItems.ts +21 -21
  235. package/src/lib/reactivity/createTranslationState.ts +61 -0
  236. package/src/lib/reactivity/createValueState.ts +62 -120
  237. package/src/lib/reactivity/materializeCurrentStateChildren.ts +7 -7
  238. package/src/lib/reactivity/text/createTextRange.ts +4 -3
  239. package/src/lib/reactivity/validation/createAggregatedViolations.ts +1 -1
  240. package/src/lib/reactivity/validation/createValidation.ts +2 -3
  241. package/src/lib/xml-serialization.ts +96 -0
  242. package/src/parse/XFormDOM.ts +110 -75
  243. package/src/parse/XFormDefinition.ts +1 -6
  244. package/src/parse/attachments/FormAttachmentResource.ts +40 -0
  245. package/src/parse/body/BodyDefinition.ts +3 -3
  246. package/src/parse/body/appearance/inputAppearanceParser.ts +1 -1
  247. package/src/parse/body/control/{InputDefinition.ts → InputControlDefinition.ts} +3 -5
  248. package/src/parse/body/control/select/ItemsetNodesetContext.ts +0 -5
  249. package/src/parse/expression/abstract/DependencyContext.ts +0 -26
  250. package/src/parse/expression/abstract/DependentExpression.ts +2 -13
  251. package/src/parse/model/BindDefinition.ts +5 -8
  252. package/src/parse/model/BindTypeDefinition.ts +175 -0
  253. package/src/parse/model/DescendentNodeDefinition.ts +0 -6
  254. package/src/parse/model/FormSubmissionDefinition.ts +44 -0
  255. package/src/parse/model/ItextTranslation/ItextTranslationDefinition.ts +4 -0
  256. package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +41 -0
  257. package/src/parse/model/ItextTranslation/ItextTranslationsDefinition.ts +31 -0
  258. package/src/parse/model/LeafNodeDefinition.ts +4 -1
  259. package/src/parse/model/ModelBindMap.ts +6 -8
  260. package/src/parse/model/ModelDefinition.ts +6 -1
  261. package/src/parse/model/NodeDefinition.ts +0 -3
  262. package/src/parse/model/NoteNodeDefinition.ts +3 -3
  263. package/src/parse/model/RootDefinition.ts +2 -1
  264. package/src/parse/model/SecondaryInstance/SecondaryInstanceDefinition.ts +4 -0
  265. package/src/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.ts +12 -0
  266. package/src/parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts +102 -0
  267. package/src/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.ts +40 -0
  268. package/src/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.ts +288 -0
  269. package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.ts +222 -0
  270. package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.ts +22 -0
  271. package/src/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.ts +414 -0
  272. package/src/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.ts +19 -0
  273. package/src/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.ts +29 -0
  274. package/src/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.ts +32 -0
  275. package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +149 -0
  276. package/src/parse/text/abstract/TextRangeDefinition.ts +0 -6
  277. package/src/parse/xpath/semantic-analysis.ts +29 -0
  278. package/dist/client/StringNode.d.ts +0 -46
  279. package/dist/instance/StringField.d.ts +0 -44
  280. package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -59
  281. package/dist/parse/XFormDataType.d.ts +0 -25
  282. package/src/client/StringNode.ts +0 -52
  283. package/src/instance/StringField.ts +0 -120
  284. package/src/instance/internal-api/SubscribableDependency.ts +0 -61
  285. 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 {};
@@ -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
- };