@getodk/xforms-engine 0.4.0 → 0.6.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 (392) hide show
  1. package/README.md +1 -1
  2. package/dist/client/BaseNode.d.ts +18 -3
  3. package/dist/client/BaseValueNode.d.ts +32 -0
  4. package/dist/client/EngineConfig.d.ts +49 -48
  5. package/dist/client/GroupNode.d.ts +1 -0
  6. package/dist/client/InputNode.d.ts +82 -0
  7. package/dist/client/ModelValueNode.d.ts +13 -7
  8. package/dist/client/NoteNode.d.ts +26 -9
  9. package/dist/client/RangeNode.d.ts +36 -0
  10. package/dist/client/RankNode.d.ts +46 -0
  11. package/dist/client/RootNode.d.ts +37 -7
  12. package/dist/client/SelectNode.d.ts +47 -25
  13. package/dist/client/SubtreeNode.d.ts +1 -0
  14. package/dist/client/TriggerNode.d.ts +10 -6
  15. package/dist/client/ValueType.d.ts +3 -0
  16. package/dist/client/constants.d.ts +50 -0
  17. package/dist/client/hierarchy.d.ts +8 -8
  18. package/dist/client/identity.d.ts +14 -0
  19. package/dist/client/node-types.d.ts +3 -2
  20. package/dist/client/resources.d.ts +93 -0
  21. package/dist/client/submission/SubmissionData.d.ts +7 -0
  22. package/dist/client/submission/SubmissionDefinition.d.ts +14 -0
  23. package/dist/client/submission/SubmissionInstanceFile.d.ts +6 -0
  24. package/dist/client/submission/SubmissionOptions.d.ts +23 -0
  25. package/dist/client/submission/SubmissionResult.d.ts +91 -0
  26. package/dist/client/submission/SubmissionState.d.ts +12 -0
  27. package/dist/client/unsupported/UnsupportedControlNode.d.ts +1 -3
  28. package/dist/client/validation.d.ts +2 -2
  29. package/dist/error/ErrorProductionDesignPendingError.d.ts +7 -0
  30. package/dist/error/RankMissingValueError.d.ts +3 -0
  31. package/dist/error/RankValueTypeError.d.ts +6 -0
  32. package/dist/error/SelectValueTypeError.d.ts +15 -0
  33. package/dist/error/ValueTypeInvariantError.d.ts +17 -0
  34. package/dist/error/XFormsSpecViolationError.d.ts +2 -0
  35. package/dist/error/XPathFunctionalityError.d.ts +14 -0
  36. package/dist/error/XPathFunctionalityNotSupportedError.d.ts +7 -0
  37. package/dist/error/XPathFunctionalityPendingError.d.ts +7 -0
  38. package/dist/index.d.ts +12 -4
  39. package/dist/index.js +17864 -14655
  40. package/dist/index.js.map +1 -1
  41. package/dist/instance/Group.d.ts +10 -4
  42. package/dist/instance/InputControl.d.ts +38 -0
  43. package/dist/instance/ModelValue.d.ts +17 -25
  44. package/dist/instance/Note.d.ts +16 -21
  45. package/dist/instance/PrimaryInstance.d.ts +85 -0
  46. package/dist/instance/RangeControl.d.ts +34 -0
  47. package/dist/instance/RankControl.d.ts +40 -0
  48. package/dist/instance/Root.d.ts +30 -25
  49. package/dist/instance/SelectControl.d.ts +66 -0
  50. package/dist/instance/Subtree.d.ts +11 -5
  51. package/dist/instance/TriggerControl.d.ts +13 -19
  52. package/dist/instance/abstract/DescendantNode.d.ts +32 -25
  53. package/dist/instance/abstract/InstanceNode.d.ts +52 -30
  54. package/dist/instance/abstract/UnsupportedControl.d.ts +11 -3
  55. package/dist/instance/abstract/ValueNode.d.ts +47 -0
  56. package/dist/instance/hierarchy.d.ts +13 -12
  57. package/dist/instance/identity.d.ts +2 -7
  58. package/dist/instance/internal-api/EvaluationContext.d.ts +53 -12
  59. package/dist/instance/internal-api/InstanceConfig.d.ts +8 -2
  60. package/dist/instance/internal-api/InstanceValueContext.d.ts +22 -0
  61. package/dist/instance/internal-api/PrimaryInstanceDocument.d.ts +36 -0
  62. package/dist/instance/internal-api/TranslationContext.d.ts +3 -2
  63. package/dist/instance/internal-api/ValidationContext.d.ts +3 -4
  64. package/dist/instance/internal-api/ValueContext.d.ts +2 -1
  65. package/dist/instance/internal-api/submission/ClientReactiveSubmittableInstance.d.ts +14 -0
  66. package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +32 -0
  67. package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +19 -0
  68. package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +18 -0
  69. package/dist/instance/repeat/BaseRepeatRange.d.ts +40 -83
  70. package/dist/instance/repeat/RepeatInstance.d.ts +12 -29
  71. package/dist/instance/repeat/RepeatRangeControlled.d.ts +2 -2
  72. package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +2 -2
  73. package/dist/instance/resource.d.ts +1 -1
  74. package/dist/instance/text/TextRange.d.ts +1 -1
  75. package/dist/instance/unsupported/UploadControl.d.ts +3 -1
  76. package/dist/integration/xpath/EngineXPathEvaluator.d.ts +14 -0
  77. package/dist/integration/xpath/adapter/XFormsXPathNode.d.ts +71 -0
  78. package/dist/integration/xpath/adapter/engineDOMAdapter.d.ts +5 -0
  79. package/dist/integration/xpath/adapter/kind.d.ts +32 -0
  80. package/dist/integration/xpath/adapter/names.d.ts +6 -0
  81. package/dist/integration/xpath/adapter/traversal.d.ts +26 -0
  82. package/dist/integration/xpath/adapter/values.d.ts +2 -0
  83. package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +26 -0
  84. package/dist/integration/xpath/static-dom/StaticDocument.d.ts +15 -0
  85. package/dist/integration/xpath/static-dom/StaticElement.d.ts +48 -0
  86. package/dist/integration/xpath/static-dom/StaticNode.d.ts +33 -0
  87. package/dist/integration/xpath/static-dom/StaticText.d.ts +16 -0
  88. package/dist/lib/client-reactivity/submission/createInstanceSubmissionState.d.ts +3 -0
  89. package/dist/lib/client-reactivity/submission/createLeafNodeSubmissionState.d.ts +3 -0
  90. package/dist/lib/client-reactivity/submission/createNodeRangeSubmissionState.d.ts +4 -0
  91. package/dist/lib/client-reactivity/submission/createParentNodeSubmissionState.d.ts +4 -0
  92. package/dist/lib/client-reactivity/submission/createRootSubmissionState.d.ts +3 -0
  93. package/dist/lib/client-reactivity/submission/createValueNodeSubmissionState.d.ts +3 -0
  94. package/dist/lib/client-reactivity/submission/prepareSubmission.d.ts +8 -0
  95. package/dist/lib/codecs/DecimalValueCodec.d.ts +6 -0
  96. package/dist/lib/codecs/Geopoint/Geopoint.d.ts +48 -0
  97. package/dist/lib/codecs/Geopoint/GeopointValueCodec.d.ts +5 -0
  98. package/dist/lib/codecs/IntValueCodec.d.ts +6 -0
  99. package/dist/lib/codecs/NoteCodec.d.ts +8 -0
  100. package/dist/lib/codecs/RangeCodec.d.ts +8 -0
  101. package/dist/lib/codecs/StringValueCodec.d.ts +4 -0
  102. package/dist/lib/codecs/TriggerCodec.d.ts +7 -0
  103. package/dist/lib/codecs/ValueArrayCodec.d.ts +11 -0
  104. package/dist/lib/codecs/ValueCodec.d.ts +30 -0
  105. package/dist/lib/codecs/ValueTypePlaceholderCodec.d.ts +12 -0
  106. package/dist/lib/codecs/getNoteCodec.d.ts +3 -0
  107. package/dist/lib/codecs/getSelectCodec.d.ts +5 -0
  108. package/dist/lib/codecs/getSharedValueCodec.d.ts +48 -0
  109. package/dist/lib/codecs/items/BaseItemCodec.d.ts +9 -0
  110. package/dist/lib/codecs/items/MultipleValueItemCodec.d.ts +14 -0
  111. package/dist/lib/codecs/items/SingleValueItemCodec.d.ts +24 -0
  112. package/dist/lib/dom/query.d.ts +4 -2
  113. package/dist/lib/names/NamespaceDeclaration.d.ts +45 -0
  114. package/dist/lib/names/NamespaceDeclarationMap.d.ts +137 -0
  115. package/dist/lib/names/NamespaceURL.d.ts +30 -0
  116. package/dist/lib/names/QualifiedName.d.ts +113 -0
  117. package/dist/lib/number-parsers.d.ts +2 -0
  118. package/dist/lib/reactivity/createChildrenState.d.ts +7 -5
  119. package/dist/lib/reactivity/createComputedExpression.d.ts +18 -5
  120. package/dist/lib/reactivity/createInstanceValueState.d.ts +40 -0
  121. package/dist/lib/reactivity/createItemCollection.d.ts +21 -0
  122. package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +2 -2
  123. package/dist/lib/reactivity/createTranslationState.d.ts +19 -0
  124. package/dist/lib/reactivity/createValueState.d.ts +6 -10
  125. package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +4 -4
  126. package/dist/lib/xml-serialization.d.ts +50 -0
  127. package/dist/parse/XFormDOM.d.ts +18 -7
  128. package/dist/parse/XFormDefinition.d.ts +1 -2
  129. package/dist/parse/attachments/FormAttachmentResource.d.ts +27 -0
  130. package/dist/parse/body/BodyDefinition.d.ts +4 -4
  131. package/dist/parse/body/RepeatElementDefinition.d.ts +1 -1
  132. package/dist/parse/body/appearance/inputAppearanceParser.d.ts +1 -1
  133. package/dist/parse/body/appearance/rangeAppearanceParser.d.ts +3 -0
  134. package/dist/parse/body/control/{InputDefinition.d.ts → InputControlDefinition.d.ts} +4 -1
  135. package/dist/parse/body/control/ItemDefinition.d.ts +14 -0
  136. package/dist/parse/body/control/ItemsetDefinition.d.ts +18 -0
  137. package/dist/parse/body/control/RangeControlDefinition.d.ts +31 -2
  138. package/dist/parse/body/control/RankControlDefinition.d.ts +7 -3
  139. package/dist/parse/body/control/{select/SelectDefinition.d.ts → SelectControlDefinition.d.ts} +9 -9
  140. package/dist/parse/expression/ItemsetNodesetExpression.d.ts +1 -1
  141. package/dist/parse/expression/ItemsetValueExpression.d.ts +1 -1
  142. package/dist/parse/expression/abstract/DependencyContext.d.ts +0 -5
  143. package/dist/parse/expression/abstract/DependentExpression.d.ts +2 -3
  144. package/dist/parse/model/BindDefinition.d.ts +6 -5
  145. package/dist/parse/model/BindPreloadDefinition.d.ts +42 -0
  146. package/dist/parse/model/BindTypeDefinition.d.ts +20 -0
  147. package/dist/parse/model/DescendentNodeDefinition.d.ts +4 -14
  148. package/dist/parse/model/FormSubmissionDefinition.d.ts +8 -0
  149. package/dist/parse/model/ItextTranslation/ItextTranslationDefinition.d.ts +4 -0
  150. package/dist/parse/model/ItextTranslation/ItextTranslationRootDefinition.d.ts +9 -0
  151. package/dist/parse/model/ItextTranslation/ItextTranslationsDefinition.d.ts +8 -0
  152. package/dist/parse/model/LeafNodeDefinition.d.ts +9 -4
  153. package/dist/parse/model/ModelBindMap.d.ts +1 -1
  154. package/dist/parse/model/ModelDefinition.d.ts +2 -0
  155. package/dist/parse/model/NodeDefinition.d.ts +16 -20
  156. package/dist/parse/model/NoteNodeDefinition.d.ts +9 -8
  157. package/dist/parse/model/RangeNodeDefinition.d.ts +41 -0
  158. package/dist/parse/model/RepeatInstanceDefinition.d.ts +7 -4
  159. package/dist/parse/model/RepeatRangeDefinition.d.ts +7 -4
  160. package/dist/parse/model/RepeatTemplateDefinition.d.ts +7 -4
  161. package/dist/parse/model/RootAttributeDefinition.d.ts +24 -0
  162. package/dist/parse/model/RootAttributeMap.d.ts +23 -0
  163. package/dist/parse/model/RootDefinition.d.ts +12 -9
  164. package/dist/parse/model/SecondaryInstance/SecondaryInstanceDefinition.d.ts +4 -0
  165. package/dist/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.d.ts +7 -0
  166. package/dist/parse/model/SecondaryInstance/SecondaryInstancesDefinition.d.ts +13 -0
  167. package/dist/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.d.ts +14 -0
  168. package/dist/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.d.ts +22 -0
  169. package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.d.ts +23 -0
  170. package/dist/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.d.ts +9 -0
  171. package/dist/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.d.ts +5 -0
  172. package/dist/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.d.ts +7 -0
  173. package/dist/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.d.ts +13 -0
  174. package/dist/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.d.ts +12 -0
  175. package/dist/parse/model/SubtreeDefinition.d.ts +7 -4
  176. package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +23 -0
  177. package/dist/parse/text/ItemLabelDefinition.d.ts +1 -1
  178. package/dist/parse/text/ItemsetLabelDefinition.d.ts +2 -2
  179. package/dist/parse/text/abstract/TextElementDefinition.d.ts +1 -1
  180. package/dist/parse/text/abstract/TextRangeDefinition.d.ts +0 -2
  181. package/dist/parse/xpath/semantic-analysis.d.ts +6 -3
  182. package/dist/solid.js +15437 -12246
  183. package/dist/solid.js.map +1 -1
  184. package/package.json +18 -13
  185. package/src/client/BaseNode.ts +21 -6
  186. package/src/client/BaseValueNode.ts +35 -0
  187. package/src/client/EngineConfig.ts +52 -51
  188. package/src/client/GroupNode.ts +1 -0
  189. package/src/client/InputNode.ts +113 -0
  190. package/src/client/ModelValueNode.ts +31 -7
  191. package/src/client/NoteNode.ts +45 -9
  192. package/src/client/RangeNode.ts +51 -0
  193. package/src/client/RankNode.ts +54 -0
  194. package/src/client/RootNode.ts +43 -7
  195. package/src/client/SelectNode.ts +53 -26
  196. package/src/client/SubtreeNode.ts +1 -0
  197. package/src/client/TriggerNode.ts +12 -6
  198. package/src/client/ValueType.ts +4 -0
  199. package/src/client/constants.ts +67 -0
  200. package/src/client/hierarchy.ts +12 -13
  201. package/src/client/identity.ts +16 -0
  202. package/src/client/node-types.ts +13 -7
  203. package/src/client/resources.ts +118 -0
  204. package/src/client/submission/SubmissionData.ts +12 -0
  205. package/src/client/submission/SubmissionDefinition.ts +16 -0
  206. package/src/client/submission/SubmissionInstanceFile.ts +9 -0
  207. package/src/client/submission/SubmissionOptions.ts +28 -0
  208. package/src/client/submission/SubmissionResult.ts +124 -0
  209. package/src/client/submission/SubmissionState.ts +14 -0
  210. package/src/client/unsupported/UnsupportedControlNode.ts +2 -6
  211. package/src/client/validation.ts +2 -2
  212. package/src/error/ErrorProductionDesignPendingError.ts +6 -0
  213. package/src/error/RankMissingValueError.ts +5 -0
  214. package/src/error/RankValueTypeError.ts +13 -0
  215. package/src/error/SelectValueTypeError.ts +22 -0
  216. package/src/error/ValueTypeInvariantError.ts +22 -0
  217. package/src/error/XFormsSpecViolationError.ts +1 -0
  218. package/src/error/XPathFunctionalityError.ts +26 -0
  219. package/src/error/XPathFunctionalityNotSupportedError.ts +18 -0
  220. package/src/error/XPathFunctionalityPendingError.ts +18 -0
  221. package/src/index.ts +12 -13
  222. package/src/instance/Group.ts +18 -5
  223. package/src/instance/InputControl.ts +159 -0
  224. package/src/instance/ModelValue.ts +48 -53
  225. package/src/instance/Note.ts +40 -49
  226. package/src/instance/PrimaryInstance.ts +245 -0
  227. package/src/instance/RangeControl.ts +113 -0
  228. package/src/instance/RankControl.ts +199 -0
  229. package/src/instance/Root.ts +63 -134
  230. package/src/instance/SelectControl.ts +219 -0
  231. package/src/instance/Subtree.ts +20 -7
  232. package/src/instance/TriggerControl.ts +44 -66
  233. package/src/instance/abstract/DescendantNode.ts +91 -51
  234. package/src/instance/abstract/InstanceNode.ts +113 -107
  235. package/src/instance/abstract/UnsupportedControl.ts +29 -5
  236. package/src/instance/abstract/ValueNode.ts +128 -0
  237. package/src/instance/children.ts +80 -40
  238. package/src/instance/hierarchy.ts +39 -30
  239. package/src/instance/identity.ts +3 -9
  240. package/src/instance/index.ts +25 -7
  241. package/src/instance/internal-api/EvaluationContext.ts +60 -13
  242. package/src/instance/internal-api/InstanceConfig.ts +9 -2
  243. package/src/instance/internal-api/InstanceValueContext.ts +26 -0
  244. package/src/instance/internal-api/PrimaryInstanceDocument.ts +53 -0
  245. package/src/instance/internal-api/TranslationContext.ts +3 -2
  246. package/src/instance/internal-api/ValidationContext.ts +3 -4
  247. package/src/instance/internal-api/ValueContext.ts +2 -1
  248. package/src/instance/internal-api/submission/ClientReactiveSubmittableInstance.ts +20 -0
  249. package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +43 -0
  250. package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +26 -0
  251. package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +24 -0
  252. package/src/instance/repeat/BaseRepeatRange.ts +52 -131
  253. package/src/instance/repeat/RepeatInstance.ts +21 -46
  254. package/src/instance/repeat/RepeatRangeControlled.ts +5 -5
  255. package/src/instance/repeat/RepeatRangeUncontrolled.ts +2 -4
  256. package/src/instance/resource.ts +5 -2
  257. package/src/instance/text/TextChunk.ts +1 -1
  258. package/src/instance/unsupported/UploadControl.ts +5 -1
  259. package/src/integration/xpath/EngineXPathEvaluator.ts +22 -0
  260. package/src/integration/xpath/adapter/XFormsXPathNode.ts +126 -0
  261. package/src/integration/xpath/adapter/engineDOMAdapter.ts +57 -0
  262. package/src/integration/xpath/adapter/kind.ts +114 -0
  263. package/src/integration/xpath/adapter/names.ts +148 -0
  264. package/src/integration/xpath/adapter/traversal.ts +229 -0
  265. package/src/integration/xpath/adapter/values.ts +5 -0
  266. package/src/integration/xpath/static-dom/StaticAttribute.ts +41 -0
  267. package/src/integration/xpath/static-dom/StaticDocument.ts +36 -0
  268. package/src/integration/xpath/static-dom/StaticElement.ts +119 -0
  269. package/src/integration/xpath/static-dom/StaticNode.ts +68 -0
  270. package/src/integration/xpath/static-dom/StaticText.ts +28 -0
  271. package/src/lib/client-reactivity/README.md +0 -0
  272. package/src/lib/client-reactivity/submission/createInstanceSubmissionState.ts +12 -0
  273. package/src/lib/client-reactivity/submission/createLeafNodeSubmissionState.ts +20 -0
  274. package/src/lib/client-reactivity/submission/createNodeRangeSubmissionState.ts +17 -0
  275. package/src/lib/client-reactivity/submission/createParentNodeSubmissionState.ts +22 -0
  276. package/src/lib/client-reactivity/submission/createRootSubmissionState.ts +19 -0
  277. package/src/lib/client-reactivity/submission/createValueNodeSubmissionState.ts +21 -0
  278. package/src/lib/client-reactivity/submission/prepareSubmission.ts +172 -0
  279. package/src/lib/codecs/DecimalValueCodec.ts +46 -0
  280. package/src/lib/codecs/Geopoint/Geopoint.ts +150 -0
  281. package/src/lib/codecs/Geopoint/GeopointValueCodec.ts +20 -0
  282. package/src/lib/codecs/IntValueCodec.ts +100 -0
  283. package/src/lib/codecs/NoteCodec.ts +32 -0
  284. package/src/lib/codecs/RangeCodec.ts +65 -0
  285. package/src/lib/codecs/StringValueCodec.ts +11 -0
  286. package/src/lib/codecs/TriggerCodec.ts +64 -0
  287. package/src/lib/codecs/ValueArrayCodec.ts +42 -0
  288. package/src/lib/codecs/ValueCodec.ts +106 -0
  289. package/src/lib/codecs/ValueTypePlaceholderCodec.ts +19 -0
  290. package/src/lib/codecs/getNoteCodec.ts +27 -0
  291. package/src/lib/codecs/getSelectCodec.ts +27 -0
  292. package/src/lib/codecs/getSharedValueCodec.ts +79 -0
  293. package/src/lib/codecs/items/BaseItemCodec.ts +20 -0
  294. package/src/lib/codecs/items/MultipleValueItemCodec.ts +28 -0
  295. package/src/lib/codecs/items/SingleValueItemCodec.ts +67 -0
  296. package/src/lib/dom/query.ts +8 -2
  297. package/src/lib/names/NamespaceDeclaration.ts +106 -0
  298. package/src/lib/names/NamespaceDeclarationMap.ts +228 -0
  299. package/src/lib/names/NamespaceURL.ts +44 -0
  300. package/src/lib/names/QualifiedName.ts +170 -0
  301. package/src/lib/number-parsers.ts +25 -0
  302. package/src/lib/reactivity/createChildrenState.ts +8 -6
  303. package/src/lib/reactivity/createComputedExpression.ts +57 -34
  304. package/src/lib/reactivity/createInstanceValueState.ts +216 -0
  305. package/src/lib/reactivity/createItemCollection.ts +173 -0
  306. package/src/lib/reactivity/createNoteReadonlyThunk.ts +12 -7
  307. package/src/lib/reactivity/createTranslationState.ts +61 -0
  308. package/src/lib/reactivity/createValueState.ts +62 -120
  309. package/src/lib/reactivity/materializeCurrentStateChildren.ts +7 -7
  310. package/src/lib/reactivity/text/createTextRange.ts +4 -3
  311. package/src/lib/reactivity/validation/createAggregatedViolations.ts +1 -1
  312. package/src/lib/reactivity/validation/createValidation.ts +2 -3
  313. package/src/lib/xml-serialization.ts +163 -0
  314. package/src/parse/XFormDOM.ts +231 -76
  315. package/src/parse/XFormDefinition.ts +2 -10
  316. package/src/parse/attachments/FormAttachmentResource.ts +40 -0
  317. package/src/parse/body/BodyDefinition.ts +7 -7
  318. package/src/parse/body/appearance/inputAppearanceParser.ts +1 -1
  319. package/src/parse/body/appearance/rangeAppearanceParser.ts +11 -0
  320. package/src/parse/body/control/InputControlDefinition.ts +29 -0
  321. package/src/parse/body/control/{select/ItemDefinition.ts → ItemDefinition.ts} +8 -6
  322. package/src/parse/body/control/{select/ItemsetDefinition.ts → ItemsetDefinition.ts} +11 -9
  323. package/src/parse/body/control/RangeControlDefinition.ts +91 -6
  324. package/src/parse/body/control/RankControlDefinition.ts +25 -7
  325. package/src/parse/body/control/{select/SelectDefinition.ts → SelectControlDefinition.ts} +9 -9
  326. package/src/parse/expression/ItemsetNodesetExpression.ts +1 -1
  327. package/src/parse/expression/ItemsetValueExpression.ts +1 -1
  328. package/src/parse/expression/abstract/DependencyContext.ts +0 -26
  329. package/src/parse/expression/abstract/DependentExpression.ts +2 -13
  330. package/src/parse/model/BindDefinition.ts +9 -8
  331. package/src/parse/model/BindPreloadDefinition.ts +100 -0
  332. package/src/parse/model/BindTypeDefinition.ts +175 -0
  333. package/src/parse/model/DescendentNodeDefinition.ts +7 -31
  334. package/src/parse/model/FormSubmissionDefinition.ts +44 -0
  335. package/src/parse/model/ItextTranslation/ItextTranslationDefinition.ts +4 -0
  336. package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +42 -0
  337. package/src/parse/model/ItextTranslation/ItextTranslationsDefinition.ts +31 -0
  338. package/src/parse/model/LeafNodeDefinition.ts +15 -5
  339. package/src/parse/model/ModelBindMap.ts +6 -8
  340. package/src/parse/model/ModelDefinition.ts +6 -1
  341. package/src/parse/model/NodeDefinition.ts +24 -48
  342. package/src/parse/model/NoteNodeDefinition.ts +11 -10
  343. package/src/parse/model/RangeNodeDefinition.ts +118 -0
  344. package/src/parse/model/RepeatInstanceDefinition.ts +11 -7
  345. package/src/parse/model/RepeatRangeDefinition.ts +11 -7
  346. package/src/parse/model/RepeatTemplateDefinition.ts +11 -7
  347. package/src/parse/model/RootAttributeDefinition.ts +45 -0
  348. package/src/parse/model/RootAttributeMap.ts +44 -0
  349. package/src/parse/model/RootDefinition.ts +31 -29
  350. package/src/parse/model/SecondaryInstance/SecondaryInstanceDefinition.ts +4 -0
  351. package/src/parse/model/SecondaryInstance/SecondaryInstanceRootDefinition.ts +12 -0
  352. package/src/parse/model/SecondaryInstance/SecondaryInstancesDefinition.ts +102 -0
  353. package/src/parse/model/SecondaryInstance/sources/BlankSecondaryInstanceSource.ts +40 -0
  354. package/src/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.ts +288 -0
  355. package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceResource.ts +222 -0
  356. package/src/parse/model/SecondaryInstance/sources/ExternalSecondaryInstanceSource.ts +22 -0
  357. package/src/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.ts +415 -0
  358. package/src/parse/model/SecondaryInstance/sources/InternalSecondaryInstanceSource.ts +19 -0
  359. package/src/parse/model/SecondaryInstance/sources/SecondaryInstanceSource.ts +29 -0
  360. package/src/parse/model/SecondaryInstance/sources/XMLExternalSecondaryInstanceSource.ts +32 -0
  361. package/src/parse/model/SubtreeDefinition.ts +12 -12
  362. package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +149 -0
  363. package/src/parse/text/ItemLabelDefinition.ts +1 -1
  364. package/src/parse/text/ItemsetLabelDefinition.ts +2 -2
  365. package/src/parse/text/abstract/TextElementDefinition.ts +1 -1
  366. package/src/parse/text/abstract/TextRangeDefinition.ts +0 -6
  367. package/src/parse/xpath/semantic-analysis.ts +33 -3
  368. package/dist/client/StringNode.d.ts +0 -46
  369. package/dist/client/unsupported/RangeNode.d.ts +0 -9
  370. package/dist/client/unsupported/RankNode.d.ts +0 -9
  371. package/dist/instance/SelectField.d.ts +0 -50
  372. package/dist/instance/StringField.d.ts +0 -44
  373. package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -59
  374. package/dist/instance/unsupported/RangeControl.d.ts +0 -4
  375. package/dist/instance/unsupported/RankControl.d.ts +0 -4
  376. package/dist/lib/reactivity/createSelectItems.d.ts +0 -16
  377. package/dist/parse/XFormDataType.d.ts +0 -25
  378. package/dist/parse/body/control/select/ItemDefinition.d.ts +0 -13
  379. package/dist/parse/body/control/select/ItemsetDefinition.d.ts +0 -17
  380. package/dist/parse/body/control/select/ItemsetNodesetContext.d.ts +0 -11
  381. package/src/client/StringNode.ts +0 -52
  382. package/src/client/unsupported/RangeNode.ts +0 -14
  383. package/src/client/unsupported/RankNode.ts +0 -14
  384. package/src/instance/SelectField.ts +0 -226
  385. package/src/instance/StringField.ts +0 -120
  386. package/src/instance/internal-api/SubscribableDependency.ts +0 -61
  387. package/src/instance/unsupported/RangeControl.ts +0 -5
  388. package/src/instance/unsupported/RankControl.ts +0 -5
  389. package/src/lib/reactivity/createSelectItems.ts +0 -168
  390. package/src/parse/XFormDataType.ts +0 -62
  391. package/src/parse/body/control/InputDefinition.ts +0 -22
  392. package/src/parse/body/control/select/ItemsetNodesetContext.ts +0 -26
@@ -0,0 +1,219 @@
1
+ import { XPathNodeKindKey } from '@getodk/xpath';
2
+ import type { Accessor } from 'solid-js';
3
+ import { createMemo } from 'solid-js';
4
+ import type {
5
+ SelectDefinition,
6
+ SelectItem,
7
+ SelectNode,
8
+ SelectNodeAppearances,
9
+ SelectValueOptions,
10
+ } from '../client/SelectNode.ts';
11
+ import type { TextRange } from '../client/TextRange.ts';
12
+ import type { ValueType } from '../client/ValueType.ts';
13
+ import { SelectValueTypeError } from '../error/SelectValueTypeError.ts';
14
+ import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
15
+ import { getSelectCodec } from '../lib/codecs/getSelectCodec.ts';
16
+ import { createItemCollection } from '../lib/reactivity/createItemCollection.ts';
17
+ import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
18
+ import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
19
+ import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
20
+ import { createSharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
21
+ import { createFieldHint } from '../lib/reactivity/text/createFieldHint.ts';
22
+ import { createNodeLabel } from '../lib/reactivity/text/createNodeLabel.ts';
23
+ import type { SimpleAtomicState } from '../lib/reactivity/types.ts';
24
+ import type { SelectType } from '../parse/body/control/SelectControlDefinition.ts';
25
+ import type { Root } from './Root.ts';
26
+ import type { ValueNodeStateSpec } from './abstract/ValueNode.ts';
27
+ import { ValueNode } from './abstract/ValueNode.ts';
28
+ import type { GeneralParentNode } from './hierarchy.ts';
29
+ import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
30
+ import type { ValidationContext } from './internal-api/ValidationContext.ts';
31
+ import type { ClientReactiveSubmittableValueNode } from './internal-api/submission/ClientReactiveSubmittableValueNode.ts';
32
+
33
+ export type AnySelectDefinition = {
34
+ [V in ValueType]: SelectDefinition<V>;
35
+ }[ValueType];
36
+
37
+ type AssertSupportedSelectValueType = (
38
+ definition: AnySelectDefinition
39
+ ) => asserts definition is SelectDefinition<'string'>;
40
+
41
+ const assertSupportedSelectValueType: AssertSupportedSelectValueType = (definition) => {
42
+ if (definition.valueType !== 'string') {
43
+ throw new SelectValueTypeError(definition);
44
+ }
45
+ };
46
+
47
+ type SelectItemMap = ReadonlyMap<string, SelectItem>;
48
+
49
+ interface SelectControlStateSpec extends ValueNodeStateSpec<readonly string[]> {
50
+ readonly label: Accessor<TextRange<'label'> | null>;
51
+ readonly hint: Accessor<TextRange<'hint'> | null>;
52
+ readonly valueOptions: Accessor<SelectValueOptions>;
53
+ }
54
+
55
+ export class SelectControl
56
+ extends ValueNode<'string', SelectDefinition<'string'>, readonly string[], readonly string[]>
57
+ implements
58
+ SelectNode,
59
+ XFormsXPathElement,
60
+ EvaluationContext,
61
+ ValidationContext,
62
+ ClientReactiveSubmittableValueNode
63
+ {
64
+ static from(parent: GeneralParentNode, definition: SelectDefinition): SelectControl;
65
+ static from(parent: GeneralParentNode, definition: AnySelectDefinition): SelectControl {
66
+ assertSupportedSelectValueType(definition);
67
+
68
+ return new this(parent, definition);
69
+ }
70
+
71
+ private readonly mapOptionsByValue: Accessor<SelectItemMap>;
72
+
73
+ protected override readonly getInstanceValue: Accessor<string>;
74
+
75
+ // XFormsXPathElement
76
+ override readonly [XPathNodeKindKey] = 'element';
77
+
78
+ // InstanceNode
79
+ protected readonly state: SharedNodeState<SelectControlStateSpec>;
80
+ protected readonly engineState: EngineState<SelectControlStateSpec>;
81
+
82
+ // SelectNode
83
+ readonly nodeType = 'select';
84
+ readonly selectType: SelectType;
85
+ readonly appearances: SelectNodeAppearances;
86
+ readonly nodeOptions = null;
87
+ readonly currentState: CurrentState<SelectControlStateSpec>;
88
+
89
+ private constructor(parent: GeneralParentNode, definition: SelectDefinition<'string'>) {
90
+ const codec = getSelectCodec(definition);
91
+
92
+ super(parent, definition, codec);
93
+
94
+ this.appearances = definition.bodyElement.appearances;
95
+ this.selectType = definition.bodyElement.type;
96
+
97
+ const valueOptions = createItemCollection(this);
98
+
99
+ const mapOptionsByValue: Accessor<SelectItemMap> = this.scope.runTask(() => {
100
+ return createMemo(() => {
101
+ return new Map(valueOptions().map((item) => [item.value, item]));
102
+ });
103
+ });
104
+
105
+ this.mapOptionsByValue = mapOptionsByValue;
106
+
107
+ const baseValueState = this.valueState;
108
+ const [baseGetValue, setValue] = baseValueState;
109
+ const getValue = this.scope.runTask(() => {
110
+ return createMemo(() => {
111
+ const optionsByValue = mapOptionsByValue();
112
+
113
+ return baseGetValue().filter((value) => {
114
+ return optionsByValue.has(value);
115
+ });
116
+ });
117
+ });
118
+ const valueState: SimpleAtomicState<readonly string[]> = [getValue, setValue];
119
+
120
+ this.getInstanceValue = this.scope.runTask(() => {
121
+ return createMemo(() => {
122
+ return codec.encodeValue(getValue());
123
+ });
124
+ });
125
+
126
+ const sharedStateOptions = {
127
+ clientStateFactory: this.engineConfig.stateFactory,
128
+ };
129
+
130
+ const state = createSharedNodeState(
131
+ this.scope,
132
+ {
133
+ reference: this.contextReference,
134
+ readonly: this.isReadonly,
135
+ relevant: this.isRelevant,
136
+ required: this.isRequired,
137
+
138
+ label: createNodeLabel(this, definition),
139
+ hint: createFieldHint(this, definition),
140
+ children: null,
141
+ valueOptions,
142
+ value: valueState,
143
+ instanceValue: this.getInstanceValue,
144
+ },
145
+ sharedStateOptions
146
+ );
147
+
148
+ this.state = state;
149
+ this.engineState = state.engineState;
150
+ this.currentState = state.currentState;
151
+ }
152
+
153
+ /**
154
+ * Filters {@link values} to include only those values which are currently
155
+ * available in the mapping produced by {@link mapOptionsByValue}, i.e. within
156
+ * a potentially filtered itemset.
157
+ *
158
+ * Note: this method effectively produces an intersection of
159
+ * {@link sourceValues} and {@link values}. **Importantly**, ordering of the
160
+ * results is deterministic, preserving the order of values as yielded _by
161
+ * {@link sourceValues}_.
162
+ *
163
+ * At time of writing, there are several tests (in `@getodk/scenario`, ported
164
+ * from JavaRosa) which expect the values of a `<select>` to match the order
165
+ * they appear in the control's (potentially filtered) `<itemset>` (or list of
166
+ * `<item>`s, for forms defining those inline).
167
+ *
168
+ * @todo The `<odk:rank>` control, having semantics very similar to
169
+ * `<select>`, will likely perform similar filtering logic. However, one of
170
+ * the important distinctions between these controls is that `<odk:rank>`
171
+ * exists explicitly to control the order of values. It's quite likely that
172
+ * would be achieved by invoking the same logic with the parameter order
173
+ * reversed.
174
+ */
175
+ private filterValues(
176
+ sourceValues: Iterable<string>,
177
+ values: Iterable<string>
178
+ ): readonly string[] {
179
+ const selectedValues = new Set(values);
180
+
181
+ return Array.from(sourceValues).filter((sourceValue) => {
182
+ return selectedValues.has(sourceValue);
183
+ });
184
+ }
185
+
186
+ // SelectNode
187
+ getValueOption(value: string): SelectItem | null {
188
+ // Note: this method is a client-facing convenience API for reading state,
189
+ // so it **MUST** read from client-reactive state!
190
+ const valueOption = this.currentState.valueOptions.find((item) => {
191
+ return item.value === value;
192
+ });
193
+
194
+ return valueOption ?? null;
195
+ }
196
+
197
+ isSelected(value: string): boolean {
198
+ // Note: this method is a client-facing convenience API for reading state,
199
+ // so it **MUST** read from client-reactive state!
200
+ return this.currentState.value.includes(value);
201
+ }
202
+
203
+ selectValue(value: string | null): Root {
204
+ if (value == null) {
205
+ return this.selectValues([]);
206
+ }
207
+
208
+ return this.selectValues([value]);
209
+ }
210
+
211
+ selectValues(values: readonly string[]): Root {
212
+ const sourceValues = this.mapOptionsByValue().keys();
213
+ const effectiveValues = this.filterValues(sourceValues, values);
214
+
215
+ this.setValueState(effectiveValues);
216
+
217
+ return this.root;
218
+ }
219
+ }
@@ -1,6 +1,11 @@
1
- import { type Accessor } from 'solid-js';
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,40 @@ 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 { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
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 NodeID[]>;
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 SubtreeNode, EvaluationContext, SubscribableDependency
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;
52
+ readonly nodeOptions = null;
42
53
  readonly currentState: MaterializedChildren<CurrentState<SubtreeStateSpec>, GeneralChildNode>;
43
54
  readonly validationState: AncestorNodeValidationState;
55
+ readonly submissionState: SubmissionState;
44
56
 
45
57
  constructor(parent: GeneralParentNode, definition: SubtreeDefinition) {
46
58
  super(parent, definition);
@@ -80,6 +92,7 @@ export class Subtree
80
92
 
81
93
  childrenState.setChildren(buildChildren(this));
82
94
  this.validationState = createAggregatedViolations(this, sharedStateOptions);
95
+ this.submissionState = createParentNodeSubmissionState(this);
83
96
  }
84
97
 
85
98
  getChildren(): readonly GeneralChildNode[] {
@@ -1,88 +1,80 @@
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';
4
- import type { AnyViolation, LeafNodeValidationState } from '../client/validation.ts';
5
- import { createValueState } from '../lib/reactivity/createValueState.ts';
5
+ import type { ValueType } from '../client/ValueType.ts';
6
+ import { ErrorProductionDesignPendingError } from '../error/ErrorProductionDesignPendingError.ts';
7
+ import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
8
+ import type { TriggerInputValue, TriggerRuntimeValue } from '../lib/codecs/TriggerCodec.ts';
9
+ import { TriggerCodec } from '../lib/codecs/TriggerCodec.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';
8
12
  import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
9
13
  import { createSharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
10
14
  import { createFieldHint } from '../lib/reactivity/text/createFieldHint.ts';
11
15
  import { createNodeLabel } from '../lib/reactivity/text/createNodeLabel.ts';
12
- import type { SimpleAtomicState } from '../lib/reactivity/types.ts';
13
- import type { SharedValidationState } from '../lib/reactivity/validation/createValidation.ts';
14
- import { createValidationState } from '../lib/reactivity/validation/createValidation.ts';
15
16
  import type { UnknownAppearanceDefinition } from '../parse/body/appearance/unknownAppearanceParser.ts';
16
17
  import type { Root } from './Root.ts';
17
- import type { DescendantNodeStateSpec } from './abstract/DescendantNode.ts';
18
- import { DescendantNode } from './abstract/DescendantNode.ts';
18
+ import { ValueNode, type ValueNodeStateSpec } from './abstract/ValueNode.ts';
19
19
  import type { GeneralParentNode } from './hierarchy.ts';
20
20
  import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
21
- import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
22
21
  import type { ValidationContext } from './internal-api/ValidationContext.ts';
23
- import type { ValueContext } from './internal-api/ValueContext.ts';
22
+ import type { ClientReactiveSubmittableValueNode } from './internal-api/submission/ClientReactiveSubmittableValueNode.ts';
24
23
 
25
- interface TriggerControlStateSpec extends DescendantNodeStateSpec<boolean> {
24
+ interface TriggerControlStateSpec extends ValueNodeStateSpec<TriggerRuntimeValue> {
26
25
  readonly label: Accessor<TextRange<'label'> | null>;
27
26
  readonly hint: Accessor<TextRange<'hint'> | null>;
28
- readonly children: null;
29
- readonly value: SimpleAtomicState<boolean>;
30
27
  readonly valueOptions: null;
31
28
  }
32
29
 
33
- const TRIGGER_ASSIGNED_VALUE = 'OK';
30
+ type AnyTriggerNodeDefinition = {
31
+ [V in ValueType]: TriggerNodeDefinition<V>;
32
+ }[ValueType];
33
+
34
+ const codec = new TriggerCodec();
34
35
 
35
36
  export class TriggerControl
36
- extends DescendantNode<TriggerNodeDefinition, TriggerControlStateSpec, null>
37
+ extends ValueNode<
38
+ 'string',
39
+ TriggerNodeDefinition<'string'>,
40
+ TriggerRuntimeValue,
41
+ TriggerInputValue
42
+ >
37
43
  implements
38
44
  TriggerNode,
45
+ XFormsXPathElement,
39
46
  EvaluationContext,
40
- SubscribableDependency,
41
47
  ValidationContext,
42
- ValueContext<boolean>
48
+ ClientReactiveSubmittableValueNode
43
49
  {
44
- private readonly validation: SharedValidationState;
45
- protected readonly state: SharedNodeState<TriggerControlStateSpec>;
50
+ static from(parent: GeneralParentNode, definition: TriggerNodeDefinition): TriggerControl;
51
+ static from(parent: GeneralParentNode, definition: AnyTriggerNodeDefinition): TriggerControl {
52
+ if (definition.valueType !== 'string') {
53
+ throw new ErrorProductionDesignPendingError(
54
+ `Unsupported trigger value type: ${definition.valueType}`
55
+ );
56
+ }
57
+
58
+ return new this(parent, definition);
59
+ }
60
+
61
+ // XFormsXPathElement
62
+ override readonly [XPathNodeKindKey] = 'element';
46
63
 
47
64
  // InstanceNode
48
- protected engineState: EngineState<TriggerControlStateSpec>;
65
+ protected readonly state: SharedNodeState<TriggerControlStateSpec>;
66
+ protected readonly engineState: EngineState<TriggerControlStateSpec>;
49
67
 
50
68
  // TriggerNode
51
69
  readonly nodeType = 'trigger';
52
70
  readonly appearances: UnknownAppearanceDefinition;
71
+ readonly nodeOptions = null;
53
72
  readonly currentState: CurrentState<TriggerControlStateSpec>;
54
73
 
55
- get validationState(): LeafNodeValidationState {
56
- return this.validation.currentState;
57
- }
58
-
59
- // ValueContext
60
- readonly encodeValue: (runtimeValue: boolean) => string;
61
- readonly decodeValue: (instanceValue: string) => boolean;
62
-
63
- constructor(parent: GeneralParentNode, definition: TriggerNodeDefinition) {
64
- super(parent, definition);
74
+ private constructor(parent: GeneralParentNode, definition: TriggerNodeDefinition<'string'>) {
75
+ super(parent, definition, codec);
65
76
 
66
77
  this.appearances = definition.bodyElement.appearances;
67
- this.encodeValue = (runtimeValue) => {
68
- return runtimeValue ? TRIGGER_ASSIGNED_VALUE : '';
69
- };
70
- this.decodeValue = (instanceValue) => {
71
- const value = instanceValue.trim();
72
-
73
- switch (value) {
74
- case TRIGGER_ASSIGNED_VALUE:
75
- return true;
76
-
77
- case '':
78
- return false;
79
-
80
- // TODO (robustness principle): Case insensitivity? Handle
81
- // XPath-semantic booleans?? Other known/common equivalents?
82
- default:
83
- throw new Error(`Unexpected trigger value: ${value}`);
84
- }
85
- };
86
78
 
87
79
  const sharedStateOptions = {
88
80
  clientStateFactory: this.engineConfig.stateFactory,
@@ -100,7 +92,8 @@ export class TriggerControl
100
92
  hint: createFieldHint(this, definition),
101
93
  children: null,
102
94
  valueOptions: null,
103
- value: createValueState(this),
95
+ value: this.valueState,
96
+ instanceValue: this.getInstanceValue,
104
97
  },
105
98
  sharedStateOptions
106
99
  );
@@ -108,26 +101,11 @@ export class TriggerControl
108
101
  this.state = state;
109
102
  this.engineState = state.engineState;
110
103
  this.currentState = state.currentState;
111
- this.validation = createValidationState(this, sharedStateOptions);
112
- }
113
-
114
- // ValidationContext
115
- getViolation(): AnyViolation | null {
116
- return this.validation.engineState.violation;
117
- }
118
-
119
- isBlank(): boolean {
120
- return this.engineState.value == null;
121
- }
122
-
123
- // InstanceNode
124
- getChildren(): readonly [] {
125
- return [];
126
104
  }
127
105
 
128
106
  // TriggerNode
129
- setValue(value: boolean): Root {
130
- this.state.setProperty('value', value);
107
+ setValue(value: TriggerInputValue): Root {
108
+ this.setValueState(value);
131
109
 
132
110
  return this.root;
133
111
  }
@@ -1,15 +1,21 @@
1
- import type { XFormsXPathEvaluator } from '@getodk/xpath';
1
+ import { XPathNodeKindKey } from '@getodk/xpath';
2
2
  import type { Accessor } from 'solid-js';
3
+ import { createMemo } from 'solid-js';
3
4
  import type { BaseNode } from '../../client/BaseNode.ts';
5
+ import type { ActiveLanguage } from '../../client/FormLanguage.ts';
6
+ import type { InstanceNodeType } from '../../client/node-types.ts';
7
+ import type { PrimaryInstanceXPathChildNode } from '../../integration/xpath/adapter/kind.ts';
8
+ import type {
9
+ XFormsXPathPrimaryInstanceDescendantNode,
10
+ XFormsXPathPrimaryInstanceDescendantNodeKind,
11
+ } from '../../integration/xpath/adapter/XFormsXPathNode.ts';
12
+ import { XFORMS_XPATH_NODE_RANGE_KIND } from '../../integration/xpath/adapter/XFormsXPathNode.ts';
13
+ import type { EngineXPathEvaluator } from '../../integration/xpath/EngineXPathEvaluator.ts';
4
14
  import { createComputedExpression } from '../../lib/reactivity/createComputedExpression.ts';
5
15
  import type { ReactiveScope } from '../../lib/reactivity/scope.ts';
6
- import type { AnyDescendantNodeDefinition } from '../../parse/model/DescendentNodeDefinition.ts';
7
- import type { LeafNodeDefinition } from '../../parse/model/LeafNodeDefinition.ts';
8
16
  import type { AnyNodeDefinition } from '../../parse/model/NodeDefinition.ts';
9
- import type { RepeatInstanceDefinition } from '../../parse/model/RepeatInstanceDefinition.ts';
10
- import type { AnyChildNode, GeneralParentNode, RepeatRange } from '../hierarchy.ts';
17
+ import type { AnyChildNode, AnyParentNode, RepeatRange } from '../hierarchy.ts';
11
18
  import type { EvaluationContext } from '../internal-api/EvaluationContext.ts';
12
- import type { SubscribableDependency } from '../internal-api/SubscribableDependency.ts';
13
19
  import type { RepeatInstance } from '../repeat/RepeatInstance.ts';
14
20
  import type { Root } from '../Root.ts';
15
21
  import type { InstanceNodeStateSpec } from './InstanceNode.ts';
@@ -28,25 +34,15 @@ export type DescendantNodeStateSpec<Value = never> =
28
34
  & InstanceNodeStateSpec<Value>
29
35
  & DescendantNodeSharedStateSpec;
30
36
 
31
- // prettier-ignore
32
- export type DescendantNodeDefinition = Extract<
33
- AnyNodeDefinition,
34
- AnyDescendantNodeDefinition
35
- >;
36
-
37
- // prettier-ignore
38
- export type DescendantNodeParent<Definition extends DescendantNodeDefinition> =
39
- Definition extends LeafNodeDefinition
40
- ? GeneralParentNode
41
- : Definition extends RepeatInstanceDefinition
42
- ? RepeatRange
43
- : GeneralParentNode;
37
+ export type DescendantNodeDefinition = AnyNodeDefinition;
44
38
 
45
39
  export type AnyDescendantNode = DescendantNode<
46
40
  DescendantNodeDefinition,
47
41
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
42
  DescendantNodeStateSpec<any>,
49
43
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
+ any,
45
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
46
  any
51
47
  >;
52
48
 
@@ -58,11 +54,18 @@ export abstract class DescendantNode<
58
54
  Definition extends DescendantNodeDefinition,
59
55
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
56
  Spec extends DescendantNodeStateSpec<any>,
57
+ Parent extends AnyParentNode,
61
58
  Child extends AnyChildNode | null = null,
62
59
  >
63
- extends InstanceNode<Definition, Spec, Child>
64
- implements BaseNode, EvaluationContext, SubscribableDependency
60
+ extends InstanceNode<Definition, Spec, Parent, Child>
61
+ implements BaseNode, XFormsXPathPrimaryInstanceDescendantNode, EvaluationContext
65
62
  {
63
+ /**
64
+ * Partial implementation of {@link isAttached}, used to check whether `this`
65
+ * is present in {@link parent}'s children state.
66
+ */
67
+ protected readonly isAttachedDescendant: Accessor<boolean>;
68
+
66
69
  readonly hasReadonlyAncestor: Accessor<boolean> = () => {
67
70
  const { parent } = this;
68
71
 
@@ -97,51 +100,88 @@ export abstract class DescendantNode<
97
100
 
98
101
  readonly isRequired: Accessor<boolean>;
99
102
 
103
+ // XFormsXPathPrimaryInstanceDescendantNode
104
+
105
+ /**
106
+ * WARNING! Ideally, this would be an abstract property, defined by each
107
+ * concrete subclass (or other intermediate abstract classes, where
108
+ * appropriate). Unfortunately it must be assigned here, so it will be present
109
+ * for certain XPath DOM adapter functionality **during** each concrete node's
110
+ * construction.
111
+ *
112
+ * Those subclasses nevertheless override this same property, assigning the
113
+ * same value, for the purposes of narrowing the XPath node kind semantics
114
+ * appropriate for each node type.
115
+ */
116
+ override readonly [XPathNodeKindKey]: XFormsXPathPrimaryInstanceDescendantNodeKind;
100
117
  readonly root: Root;
101
- readonly evaluator: XFormsXPathEvaluator;
102
- readonly contextNode: Element;
118
+
119
+ // BaseNode
120
+ abstract override readonly nodeType: InstanceNodeType;
121
+
122
+ // EvaluationContext
123
+ readonly isAttached: Accessor<boolean>;
124
+ readonly evaluator: EngineXPathEvaluator;
125
+ override readonly contextNode: PrimaryInstanceXPathChildNode =
126
+ this as AnyDescendantNode as PrimaryInstanceXPathChildNode;
127
+ readonly getActiveLanguage: Accessor<ActiveLanguage>;
103
128
 
104
129
  constructor(
105
- override readonly parent: DescendantNodeParent<Definition>,
130
+ override readonly parent: Parent,
106
131
  override readonly definition: Definition,
107
132
  options?: DescendantNodeOptions
108
133
  ) {
109
134
  super(parent.engineConfig, parent, definition, options);
110
135
 
111
- const { evaluator, root } = parent;
136
+ if (this.isRoot()) {
137
+ this.root = this;
138
+ } else {
139
+ this.root = parent.root;
140
+ }
112
141
 
113
- this.root = root;
114
- this.evaluator = evaluator;
115
- this.contextNode = this.initializeContextNode(parent.contextNode, definition.nodeName);
142
+ const { evaluator } = parent;
116
143
 
117
- const { readonly, relevant, required } = definition.bind;
144
+ // See notes on property declaration
145
+ if (definition.type === 'repeat-range') {
146
+ this[XPathNodeKindKey] = XFORMS_XPATH_NODE_RANGE_KIND;
147
+ } else {
148
+ this[XPathNodeKindKey] = 'element';
149
+ }
118
150
 
119
- this.isSelfReadonly = createComputedExpression(this, readonly);
120
- this.isSelfRelevant = createComputedExpression(this, relevant);
121
- this.isRequired = createComputedExpression(this, required);
122
- }
151
+ const self = this as AnyDescendantNode as AnyChildNode;
123
152
 
124
- protected createContextNode(parentContextNode: Element, nodeName: string): Element {
125
- return parentContextNode.ownerDocument.createElement(nodeName);
126
- }
153
+ this.isAttachedDescendant = this.scope.runTask(() => {
154
+ return createMemo(() => {
155
+ for (const child of parent.getChildren()) {
156
+ if (child === self) {
157
+ return true;
158
+ }
159
+ }
127
160
 
128
- /**
129
- * Currently expected to be overridden by...
130
- *
131
- * - Repeat range: returns its parent's context node, because it doesn't have
132
- * a node in the primary instance tree.
133
- *
134
- * - Repeat instance: returns its created context node, but overrides handles
135
- * appending behavior separately (for inserting at the end of its parent
136
- * range, or even at an arbitrary index within the range, after instance
137
- * creation is has completed).
138
- */
139
- protected initializeContextNode(parentContextNode: Element, nodeName: string): Element {
140
- const element = this.createContextNode(parentContextNode, nodeName);
161
+ return false;
162
+ });
163
+ });
141
164
 
142
- parentContextNode.append(element);
165
+ this.isAttached = this.scope.runTask(() => {
166
+ return createMemo(() => {
167
+ return this.parent.isAttached() && this.isAttachedDescendant();
168
+ });
169
+ });
170
+
171
+ this.evaluator = evaluator;
172
+ this.getActiveLanguage = parent.getActiveLanguage;
173
+
174
+ const { readonly, relevant, required } = definition.bind;
143
175
 
144
- return element;
176
+ this.isSelfReadonly = createComputedExpression(this, readonly, {
177
+ defaultValue: true,
178
+ });
179
+ this.isSelfRelevant = createComputedExpression(this, relevant, {
180
+ defaultValue: false,
181
+ });
182
+ this.isRequired = createComputedExpression(this, required, {
183
+ defaultValue: false,
184
+ });
145
185
  }
146
186
 
147
187
  /**