@getodk/xforms-engine 0.2.0 → 0.4.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 (292) hide show
  1. package/dist/client/BaseNode.d.ts +69 -4
  2. package/dist/client/EngineConfig.d.ts +0 -1
  3. package/dist/client/GroupNode.d.ts +4 -3
  4. package/dist/client/ModelValueNode.d.ts +36 -0
  5. package/dist/client/NodeAppearances.d.ts +1 -2
  6. package/dist/client/NoteNode.d.ts +52 -0
  7. package/dist/client/RootNode.d.ts +4 -3
  8. package/dist/client/SelectNode.d.ts +6 -5
  9. package/dist/client/StringNode.d.ts +6 -5
  10. package/dist/client/SubtreeNode.d.ts +3 -2
  11. package/dist/client/TextRange.d.ts +85 -3
  12. package/dist/client/TriggerNode.d.ts +25 -0
  13. package/dist/client/constants.d.ts +8 -0
  14. package/dist/client/hierarchy.d.ts +19 -10
  15. package/dist/client/index.d.ts +0 -1
  16. package/dist/client/node-types.d.ts +3 -1
  17. package/dist/client/{RepeatRangeNode.d.ts → repeat/BaseRepeatRangeNode.d.ts} +18 -18
  18. package/dist/client/{RepeatInstanceNode.d.ts → repeat/RepeatInstanceNode.d.ts} +9 -9
  19. package/dist/client/repeat/RepeatRangeControlledNode.d.ts +18 -0
  20. package/dist/client/repeat/RepeatRangeUncontrolledNode.d.ts +19 -0
  21. package/dist/client/unsupported/RangeNode.d.ts +9 -0
  22. package/dist/client/unsupported/RankNode.d.ts +9 -0
  23. package/dist/client/unsupported/UnsupportedControlNode.d.ts +32 -0
  24. package/dist/client/unsupported/UploadNode.d.ts +9 -0
  25. package/dist/client/validation.d.ts +162 -0
  26. package/dist/index.d.ts +14 -6
  27. package/dist/index.js +39696 -36151
  28. package/dist/index.js.map +1 -1
  29. package/dist/instance/Group.d.ts +3 -2
  30. package/dist/instance/ModelValue.d.ts +39 -0
  31. package/dist/instance/Note.d.ts +41 -0
  32. package/dist/instance/Root.d.ts +5 -4
  33. package/dist/instance/SelectField.d.ts +11 -6
  34. package/dist/instance/StringField.d.ts +12 -7
  35. package/dist/instance/Subtree.d.ts +2 -1
  36. package/dist/instance/TriggerControl.d.ts +40 -0
  37. package/dist/instance/abstract/DescendantNode.d.ts +8 -10
  38. package/dist/instance/abstract/InstanceNode.d.ts +3 -2
  39. package/dist/instance/abstract/UnsupportedControl.d.ts +46 -0
  40. package/dist/instance/children.d.ts +0 -1
  41. package/dist/instance/hierarchy.d.ts +15 -6
  42. package/dist/instance/index.d.ts +0 -1
  43. package/dist/instance/internal-api/EvaluationContext.d.ts +0 -1
  44. package/dist/instance/internal-api/InstanceConfig.d.ts +0 -1
  45. package/dist/instance/internal-api/SubscribableDependency.d.ts +0 -1
  46. package/dist/instance/internal-api/TranslationContext.d.ts +0 -1
  47. package/dist/instance/internal-api/ValidationContext.d.ts +28 -0
  48. package/dist/instance/internal-api/ValueContext.d.ts +3 -4
  49. package/dist/instance/{RepeatRange.d.ts → repeat/BaseRepeatRange.d.ts} +46 -46
  50. package/dist/instance/{RepeatInstance.d.ts → repeat/RepeatInstance.d.ts} +13 -13
  51. package/dist/instance/repeat/RepeatRangeControlled.d.ts +15 -0
  52. package/dist/instance/repeat/RepeatRangeUncontrolled.d.ts +34 -0
  53. package/dist/instance/resource.d.ts +0 -1
  54. package/dist/instance/text/TextChunk.d.ts +0 -1
  55. package/dist/instance/text/TextRange.d.ts +4 -5
  56. package/dist/instance/unsupported/RangeControl.d.ts +4 -0
  57. package/dist/instance/unsupported/RankControl.d.ts +4 -0
  58. package/dist/instance/unsupported/UploadControl.d.ts +4 -0
  59. package/dist/lib/TokenListParser.d.ts +3 -3
  60. package/dist/lib/dom/query.d.ts +1 -2
  61. package/dist/lib/reactivity/createChildrenState.d.ts +0 -1
  62. package/dist/lib/reactivity/createComputedExpression.d.ts +7 -3
  63. package/dist/lib/reactivity/createNoteReadonlyThunk.d.ts +4 -0
  64. package/dist/lib/reactivity/createSelectItems.d.ts +0 -1
  65. package/dist/lib/reactivity/createValueState.d.ts +0 -1
  66. package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +0 -1
  67. package/dist/lib/reactivity/node-state/createClientState.d.ts +0 -1
  68. package/dist/lib/reactivity/node-state/createCurrentState.d.ts +0 -1
  69. package/dist/lib/reactivity/node-state/createEngineState.d.ts +0 -1
  70. package/dist/lib/reactivity/node-state/createSharedNodeState.d.ts +1 -2
  71. package/dist/lib/reactivity/node-state/createSpecifiedPropertyDescriptor.d.ts +0 -1
  72. package/dist/lib/reactivity/node-state/createSpecifiedState.d.ts +1 -2
  73. package/dist/lib/reactivity/node-state/representations.d.ts +0 -1
  74. package/dist/lib/reactivity/scope.d.ts +0 -1
  75. package/dist/lib/reactivity/text/createFieldHint.d.ts +3 -4
  76. package/dist/lib/reactivity/text/createNodeLabel.d.ts +3 -4
  77. package/dist/lib/reactivity/text/createNoteText.d.ts +24 -0
  78. package/dist/lib/reactivity/text/createTextRange.d.ts +5 -8
  79. package/dist/lib/reactivity/types.d.ts +0 -1
  80. package/dist/lib/reactivity/validation/createAggregatedViolations.d.ts +8 -0
  81. package/dist/lib/reactivity/validation/createValidation.d.ts +17 -0
  82. package/dist/{XFormDOM.d.ts → parse/XFormDOM.d.ts} +1 -2
  83. package/dist/{XFormDataType.d.ts → parse/XFormDataType.d.ts} +2 -4
  84. package/dist/{XFormDefinition.d.ts → parse/XFormDefinition.d.ts} +2 -3
  85. package/dist/{body → parse/body}/BodyDefinition.d.ts +15 -10
  86. package/dist/{body → parse/body}/BodyElementDefinition.d.ts +8 -7
  87. package/dist/{body → parse/body}/RepeatElementDefinition.d.ts +4 -5
  88. package/dist/{body → parse/body}/UnsupportedBodyElementDefinition.d.ts +0 -1
  89. package/dist/{body → parse/body}/appearance/inputAppearanceParser.d.ts +1 -2
  90. package/dist/{body → parse/body}/appearance/selectAppearanceParser.d.ts +1 -2
  91. package/dist/{body → parse/body}/appearance/structureElementAppearanceParser.d.ts +1 -2
  92. package/dist/parse/body/appearance/unknownAppearanceParser.d.ts +3 -0
  93. package/dist/{body → parse/body}/control/ControlDefinition.d.ts +3 -4
  94. package/dist/{body → parse/body}/control/InputDefinition.d.ts +1 -2
  95. package/dist/parse/body/control/RangeControlDefinition.d.ts +11 -0
  96. package/dist/parse/body/control/RankControlDefinition.d.ts +11 -0
  97. package/dist/parse/body/control/TriggerControlDefinition.d.ts +11 -0
  98. package/dist/parse/body/control/UploadControlDefinition.d.ts +11 -0
  99. package/dist/{body → parse/body}/control/select/ItemDefinition.d.ts +3 -4
  100. package/dist/{body → parse/body}/control/select/ItemsetDefinition.d.ts +7 -7
  101. package/dist/{body → parse/body}/control/select/ItemsetNodesetContext.d.ts +2 -3
  102. package/dist/{body → parse/body}/control/select/SelectDefinition.d.ts +3 -12
  103. package/dist/{body → parse/body}/group/BaseGroupDefinition.d.ts +3 -5
  104. package/dist/{body → parse/body}/group/LogicalGroupDefinition.d.ts +0 -1
  105. package/dist/{body → parse/body}/group/PresentationGroupDefinition.d.ts +1 -2
  106. package/dist/{body → parse/body}/group/StructuralGroupDefinition.d.ts +0 -1
  107. package/dist/{model/BindComputation.d.ts → parse/expression/BindComputationExpression.d.ts} +5 -6
  108. package/dist/{body/control/select → parse/expression}/ItemsetNodesetExpression.d.ts +2 -3
  109. package/dist/{body/control/select → parse/expression}/ItemsetValueExpression.d.ts +2 -3
  110. package/dist/parse/expression/RepeatCountControlExpression.d.ts +18 -0
  111. package/dist/parse/expression/TextLiteralExpression.d.ts +9 -0
  112. package/dist/parse/expression/TextOutputExpression.d.ts +7 -0
  113. package/dist/parse/expression/TextReferenceExpression.d.ts +7 -0
  114. package/dist/parse/expression/TextTranslationExpression.d.ts +8 -0
  115. package/dist/{expression → parse/expression/abstract}/DependencyContext.d.ts +0 -1
  116. package/dist/{expression → parse/expression/abstract}/DependentExpression.d.ts +13 -10
  117. package/dist/parse/expression/abstract/TextChunkExpression.d.ts +17 -0
  118. package/dist/parse/model/BindDefinition.d.ts +39 -0
  119. package/dist/{model → parse/model}/BindElement.d.ts +1 -0
  120. package/dist/{model → parse/model}/DescendentNodeDefinition.d.ts +0 -1
  121. package/dist/{model/ValueNodeDefinition.d.ts → parse/model/LeafNodeDefinition.d.ts} +3 -4
  122. package/dist/{model → parse/model}/ModelBindMap.d.ts +0 -1
  123. package/dist/{model → parse/model}/ModelDefinition.d.ts +1 -2
  124. package/dist/{model → parse/model}/NodeDefinition.d.ts +8 -9
  125. package/dist/parse/model/NoteNodeDefinition.d.ts +30 -0
  126. package/dist/{model → parse/model}/RepeatInstanceDefinition.d.ts +3 -4
  127. package/dist/{model → parse/model}/RepeatRangeDefinition.d.ts +14 -5
  128. package/dist/{model → parse/model}/RepeatTemplateDefinition.d.ts +2 -3
  129. package/dist/{model → parse/model}/RootDefinition.d.ts +2 -3
  130. package/dist/{model → parse/model}/SubtreeDefinition.d.ts +1 -2
  131. package/dist/parse/text/HintDefinition.d.ts +8 -0
  132. package/dist/parse/text/ItemLabelDefinition.d.ts +8 -0
  133. package/dist/parse/text/ItemsetLabelDefinition.d.ts +12 -0
  134. package/dist/parse/text/LabelDefinition.d.ts +14 -0
  135. package/dist/parse/text/MessageDefinition.d.ts +14 -0
  136. package/dist/parse/text/abstract/TextElementDefinition.d.ts +22 -0
  137. package/dist/parse/text/abstract/TextRangeDefinition.d.ts +34 -0
  138. package/dist/parse/xpath/dependency-analysis.d.ts +40 -0
  139. package/dist/parse/xpath/path-resolution.d.ts +69 -0
  140. package/dist/parse/xpath/predicate-analysis.d.ts +29 -0
  141. package/dist/parse/xpath/reference-parsing.d.ts +17 -0
  142. package/dist/parse/xpath/semantic-analysis.d.ts +97 -0
  143. package/dist/parse/xpath/syntax-traversal.d.ts +68 -0
  144. package/dist/solid.js +8745 -5186
  145. package/dist/solid.js.map +1 -1
  146. package/package.json +15 -16
  147. package/src/client/BaseNode.ts +74 -8
  148. package/src/client/GroupNode.ts +4 -2
  149. package/src/client/ModelValueNode.ts +40 -0
  150. package/src/client/NodeAppearances.ts +1 -1
  151. package/src/client/NoteNode.ts +74 -0
  152. package/src/client/README.md +1 -0
  153. package/src/client/RootNode.ts +4 -2
  154. package/src/client/SelectNode.ts +6 -4
  155. package/src/client/StringNode.ts +6 -4
  156. package/src/client/SubtreeNode.ts +3 -1
  157. package/src/client/TextRange.ts +98 -2
  158. package/src/client/TriggerNode.ts +29 -0
  159. package/src/client/constants.ts +10 -0
  160. package/src/client/hierarchy.ts +43 -15
  161. package/src/client/node-types.ts +17 -2
  162. package/src/client/{RepeatRangeNode.ts → repeat/BaseRepeatRangeNode.ts} +18 -19
  163. package/src/client/{RepeatInstanceNode.ts → repeat/RepeatInstanceNode.ts} +10 -8
  164. package/src/client/repeat/RepeatRangeControlledNode.ts +20 -0
  165. package/src/client/repeat/RepeatRangeUncontrolledNode.ts +21 -0
  166. package/src/client/unsupported/RangeNode.ts +14 -0
  167. package/src/client/unsupported/RankNode.ts +14 -0
  168. package/src/client/unsupported/UnsupportedControlNode.ts +40 -0
  169. package/src/client/unsupported/UploadNode.ts +14 -0
  170. package/src/client/validation.ts +199 -0
  171. package/src/index.ts +21 -9
  172. package/src/instance/Group.ts +10 -4
  173. package/src/instance/ModelValue.ts +104 -0
  174. package/src/instance/Note.ts +142 -0
  175. package/src/instance/Root.ts +16 -6
  176. package/src/instance/SelectField.ts +29 -7
  177. package/src/instance/StringField.ts +36 -10
  178. package/src/instance/Subtree.ts +9 -3
  179. package/src/instance/TriggerControl.ts +134 -0
  180. package/src/instance/abstract/DescendantNode.ts +9 -10
  181. package/src/instance/abstract/InstanceNode.ts +29 -7
  182. package/src/instance/abstract/UnsupportedControl.ts +151 -0
  183. package/src/instance/children.ts +113 -16
  184. package/src/instance/hierarchy.ts +42 -5
  185. package/src/instance/index.ts +1 -1
  186. package/src/instance/internal-api/EvaluationContext.ts +1 -1
  187. package/src/instance/internal-api/ValidationContext.ts +32 -0
  188. package/src/instance/internal-api/ValueContext.ts +3 -3
  189. package/src/instance/{RepeatRange.ts → repeat/BaseRepeatRange.ts} +114 -99
  190. package/src/instance/{RepeatInstance.ts → repeat/RepeatInstance.ts} +27 -22
  191. package/src/instance/repeat/RepeatRangeControlled.ts +82 -0
  192. package/src/instance/repeat/RepeatRangeUncontrolled.ts +67 -0
  193. package/src/instance/text/TextRange.ts +10 -4
  194. package/src/instance/unsupported/RangeControl.ts +5 -0
  195. package/src/instance/unsupported/RankControl.ts +5 -0
  196. package/src/instance/unsupported/UploadControl.ts +5 -0
  197. package/src/lib/TokenListParser.ts +11 -7
  198. package/src/lib/dom/query.ts +1 -1
  199. package/src/lib/reactivity/createComputedExpression.ts +25 -27
  200. package/src/lib/reactivity/createNoteReadonlyThunk.ts +33 -0
  201. package/src/lib/reactivity/createSelectItems.ts +23 -16
  202. package/src/lib/reactivity/createValueState.ts +3 -3
  203. package/src/lib/reactivity/node-state/createSharedNodeState.ts +1 -1
  204. package/src/lib/reactivity/node-state/createSpecifiedState.ts +1 -1
  205. package/src/lib/reactivity/text/createFieldHint.ts +9 -7
  206. package/src/lib/reactivity/text/createNodeLabel.ts +8 -6
  207. package/src/lib/reactivity/text/createNoteText.ts +72 -0
  208. package/src/lib/reactivity/text/createTextRange.ts +17 -90
  209. package/src/lib/reactivity/validation/createAggregatedViolations.ts +75 -0
  210. package/src/lib/reactivity/validation/createValidation.ts +196 -0
  211. package/src/{XFormDataType.ts → parse/XFormDataType.ts} +1 -3
  212. package/src/{XFormDefinition.ts → parse/XFormDefinition.ts} +2 -2
  213. package/src/{body → parse/body}/BodyDefinition.ts +44 -27
  214. package/src/{body → parse/body}/BodyElementDefinition.ts +13 -6
  215. package/src/{body → parse/body}/RepeatElementDefinition.ts +10 -20
  216. package/src/{body → parse/body}/appearance/inputAppearanceParser.ts +1 -1
  217. package/src/{body → parse/body}/appearance/selectAppearanceParser.ts +1 -1
  218. package/src/{body → parse/body}/appearance/structureElementAppearanceParser.ts +1 -1
  219. package/src/parse/body/appearance/unknownAppearanceParser.ts +5 -0
  220. package/src/{body → parse/body}/control/ControlDefinition.ts +5 -4
  221. package/src/parse/body/control/RangeControlDefinition.ts +26 -0
  222. package/src/parse/body/control/RankControlDefinition.ts +27 -0
  223. package/src/parse/body/control/TriggerControlDefinition.ts +26 -0
  224. package/src/parse/body/control/UploadControlDefinition.ts +26 -0
  225. package/src/{body → parse/body}/control/select/ItemDefinition.ts +4 -4
  226. package/src/parse/body/control/select/ItemsetDefinition.ts +53 -0
  227. package/src/{body → parse/body}/control/select/ItemsetNodesetContext.ts +2 -2
  228. package/src/{body → parse/body}/control/select/SelectDefinition.ts +3 -11
  229. package/src/{body → parse/body}/group/BaseGroupDefinition.ts +11 -21
  230. package/src/{body → parse/body}/group/PresentationGroupDefinition.ts +1 -1
  231. package/src/{model/BindComputation.ts → parse/expression/BindComputationExpression.ts} +8 -12
  232. package/src/parse/expression/ItemsetNodesetExpression.ts +8 -0
  233. package/src/{body/control/select → parse/expression}/ItemsetValueExpression.ts +2 -2
  234. package/src/parse/expression/RepeatCountControlExpression.ts +44 -0
  235. package/src/parse/expression/TextLiteralExpression.ts +19 -0
  236. package/src/parse/expression/TextOutputExpression.ts +25 -0
  237. package/src/parse/expression/TextReferenceExpression.ts +14 -0
  238. package/src/parse/expression/TextTranslationExpression.ts +38 -0
  239. package/src/{expression → parse/expression/abstract}/DependentExpression.ts +46 -28
  240. package/src/parse/expression/abstract/TextChunkExpression.ts +38 -0
  241. package/src/{model → parse/model}/BindDefinition.ts +30 -27
  242. package/src/{model → parse/model}/BindElement.ts +1 -0
  243. package/src/{model/ValueNodeDefinition.ts → parse/model/LeafNodeDefinition.ts} +4 -4
  244. package/src/{model → parse/model}/ModelBindMap.ts +4 -0
  245. package/src/{model → parse/model}/NodeDefinition.ts +12 -12
  246. package/src/parse/model/NoteNodeDefinition.ts +70 -0
  247. package/src/{model → parse/model}/RepeatInstanceDefinition.ts +2 -2
  248. package/src/parse/model/RepeatRangeDefinition.ts +94 -0
  249. package/src/{model → parse/model}/RootDefinition.ts +8 -4
  250. package/src/parse/text/HintDefinition.ts +25 -0
  251. package/src/parse/text/ItemLabelDefinition.ts +25 -0
  252. package/src/parse/text/ItemsetLabelDefinition.ts +44 -0
  253. package/src/parse/text/LabelDefinition.ts +61 -0
  254. package/src/parse/text/MessageDefinition.ts +49 -0
  255. package/src/parse/text/abstract/TextElementDefinition.ts +71 -0
  256. package/src/parse/text/abstract/TextRangeDefinition.ts +70 -0
  257. package/src/parse/xpath/dependency-analysis.ts +105 -0
  258. package/src/parse/xpath/path-resolution.ts +475 -0
  259. package/src/parse/xpath/predicate-analysis.ts +61 -0
  260. package/src/parse/xpath/reference-parsing.ts +90 -0
  261. package/src/parse/xpath/semantic-analysis.ts +466 -0
  262. package/src/parse/xpath/syntax-traversal.ts +129 -0
  263. package/dist/body/text/HintDefinition.d.ts +0 -11
  264. package/dist/body/text/LabelDefinition.d.ts +0 -22
  265. package/dist/body/text/TextElementDefinition.d.ts +0 -33
  266. package/dist/body/text/TextElementOutputPart.d.ts +0 -13
  267. package/dist/body/text/TextElementPart.d.ts +0 -13
  268. package/dist/body/text/TextElementReferencePart.d.ts +0 -7
  269. package/dist/body/text/TextElementStaticPart.d.ts +0 -7
  270. package/dist/lib/xpath/analysis.d.ts +0 -23
  271. package/dist/model/BindDefinition.d.ts +0 -32
  272. package/src/body/control/select/ItemsetDefinition.ts +0 -36
  273. package/src/body/control/select/ItemsetNodesetExpression.ts +0 -8
  274. package/src/body/text/HintDefinition.ts +0 -26
  275. package/src/body/text/LabelDefinition.ts +0 -68
  276. package/src/body/text/TextElementDefinition.ts +0 -97
  277. package/src/body/text/TextElementOutputPart.ts +0 -27
  278. package/src/body/text/TextElementPart.ts +0 -31
  279. package/src/body/text/TextElementReferencePart.ts +0 -21
  280. package/src/body/text/TextElementStaticPart.ts +0 -26
  281. package/src/lib/xpath/analysis.ts +0 -241
  282. package/src/model/RepeatRangeDefinition.ts +0 -53
  283. package/src/{XFormDOM.ts → parse/XFormDOM.ts} +0 -0
  284. package/src/{body → parse/body}/UnsupportedBodyElementDefinition.ts +0 -0
  285. package/src/{body → parse/body}/control/InputDefinition.ts +1 -1
  286. /package/src/{body → parse/body}/group/LogicalGroupDefinition.ts +0 -0
  287. /package/src/{body → parse/body}/group/StructuralGroupDefinition.ts +0 -0
  288. /package/src/{expression → parse/expression/abstract}/DependencyContext.ts +0 -0
  289. /package/src/{model → parse/model}/DescendentNodeDefinition.ts +0 -0
  290. /package/src/{model → parse/model}/ModelDefinition.ts +0 -0
  291. /package/src/{model → parse/model}/RepeatTemplateDefinition.ts +0 -0
  292. /package/src/{model → parse/model}/SubtreeDefinition.ts +0 -0
@@ -1,22 +0,0 @@
1
- import { XFormDefinition } from '../../XFormDefinition.ts';
2
- import { AnyControlDefinition } from '../control/ControlDefinition.ts';
3
- import { ItemDefinition } from '../control/select/ItemDefinition.ts';
4
- import { ItemsetDefinition } from '../control/select/ItemsetDefinition.ts';
5
- import { BaseGroupDefinition } from '../group/BaseGroupDefinition.ts';
6
- import { RepeatElementDefinition } from '../RepeatElementDefinition.ts';
7
- import { TextElement, TextElementOwner, TextElementDefinition } from './TextElementDefinition.ts';
8
-
9
- export interface LabelElement extends TextElement {
10
- readonly localName: 'label';
11
- }
12
- type StaticLabelContext = Exclude<TextElementOwner, ItemsetDefinition>;
13
- export declare class LabelDefinition extends TextElementDefinition<'label'> {
14
- protected static staticDefinition(form: XFormDefinition, definition: StaticLabelContext): LabelDefinition | null;
15
- static forControl(form: XFormDefinition, control: AnyControlDefinition): LabelDefinition | null;
16
- static forRepeatGroup(form: XFormDefinition, repeat: RepeatElementDefinition): LabelDefinition | null;
17
- static forGroup(form: XFormDefinition, group: BaseGroupDefinition<any>): LabelDefinition | null;
18
- static forItem(form: XFormDefinition, item: ItemDefinition): LabelDefinition | null;
19
- static forItemset(form: XFormDefinition, itemset: ItemsetDefinition): LabelDefinition | null;
20
- readonly type = "label";
21
- }
22
- export {};
@@ -1,33 +0,0 @@
1
- import { XFormDefinition } from '../../XFormDefinition.ts';
2
- import { AnyDependentExpression } from '../../expression/DependentExpression.ts';
3
- import { AnyGroupElementDefinition } from '../BodyDefinition.ts';
4
- import { BodyElementDefinition } from '../BodyElementDefinition.ts';
5
- import { RepeatElementDefinition } from '../RepeatElementDefinition.ts';
6
- import { AnyControlDefinition } from '../control/ControlDefinition.ts';
7
- import { ItemDefinition } from '../control/select/ItemDefinition.ts';
8
- import { ItemsetDefinition } from '../control/select/ItemsetDefinition.ts';
9
- import { TextElementOutputPart } from './TextElementOutputPart.ts';
10
- import { TextElementReferencePart } from './TextElementReferencePart.ts';
11
- import { TextElementStaticPart } from './TextElementStaticPart.ts';
12
-
13
- export type TextElementType = 'hint' | 'label';
14
- export interface TextElement extends Element {
15
- readonly localName: TextElementType;
16
- }
17
- export type TextElementOwner = AnyControlDefinition | AnyGroupElementDefinition | ItemDefinition | ItemsetDefinition | RepeatElementDefinition;
18
- export type TextElementChild = TextElementOutputPart | TextElementStaticPart;
19
- export declare abstract class TextElementDefinition<Type extends TextElementType> extends BodyElementDefinition<Type> {
20
- readonly owner: TextElementOwner;
21
- readonly category = "support";
22
- abstract readonly type: Type;
23
- readonly reference: string | null;
24
- readonly parentReference: string | null;
25
- readonly referenceExpression: TextElementReferencePart | null;
26
- readonly children: readonly TextElementChild[];
27
- get isTranslated(): boolean;
28
- set isTranslated(value: true);
29
- protected constructor(form: XFormDefinition, owner: TextElementOwner, element: TextElement);
30
- registerDependentExpression(expression: AnyDependentExpression): void;
31
- toJSON(): object;
32
- }
33
- export type AnyTextElementDefinition = TextElementDefinition<TextElementType>;
@@ -1,13 +0,0 @@
1
- import { AnyTextElementDefinition } from './TextElementDefinition.ts';
2
- import { TextElementPart } from './TextElementPart.ts';
3
-
4
- interface OutputElement extends Element {
5
- readonly localName: 'output';
6
- getAttribute(name: 'value'): string;
7
- getAttribute(name: string): string | null;
8
- }
9
- export declare class TextElementOutputPart extends TextElementPart<'output'> {
10
- static from(context: AnyTextElementDefinition, element: Element): TextElementOutputPart | null;
11
- protected constructor(context: AnyTextElementDefinition, element: OutputElement);
12
- }
13
- export {};
@@ -1,13 +0,0 @@
1
- import { DependentExpression } from '../../expression/DependentExpression.ts';
2
- import { AnyTextElementDefinition } from './TextElementDefinition.ts';
3
- import { TextElementOutputPart } from './TextElementOutputPart.ts';
4
- import { TextElementReferencePart } from './TextElementReferencePart.ts';
5
- import { TextElementStaticPart } from './TextElementStaticPart.ts';
6
-
7
- export type TextElementPartType = 'output' | 'reference' | 'static';
8
- export declare abstract class TextElementPart<Type extends TextElementPartType> extends DependentExpression<'string'> {
9
- readonly type: Type;
10
- readonly stringValue?: string;
11
- constructor(type: Type, context: AnyTextElementDefinition, expression: string);
12
- }
13
- export type AnyTextElementPart = TextElementOutputPart | TextElementReferencePart | TextElementStaticPart;
@@ -1,7 +0,0 @@
1
- import { AnyTextElementDefinition, TextElement } from './TextElementDefinition.ts';
2
- import { TextElementPart } from './TextElementPart.ts';
3
-
4
- export declare class TextElementReferencePart extends TextElementPart<'reference'> {
5
- static from(context: AnyTextElementDefinition, element: TextElement): TextElementReferencePart | null;
6
- protected constructor(context: AnyTextElementDefinition, expression: string);
7
- }
@@ -1,7 +0,0 @@
1
- import { AnyTextElementDefinition } from './TextElementDefinition.ts';
2
- import { TextElementPart } from './TextElementPart.ts';
3
-
4
- export declare class TextElementStaticPart extends TextElementPart<'static'> {
5
- readonly stringValue: string;
6
- constructor(context: AnyTextElementDefinition, node: Text);
7
- }
@@ -1,23 +0,0 @@
1
- import { AnySyntaxNode } from '@getodk/xpath/static/grammar/SyntaxNode.js';
2
-
3
- export type SingleChildNode = Extract<AnySyntaxNode, {
4
- readonly children: readonly [AnySyntaxNode];
5
- }>;
6
- export declare const isItextFunctionCalled: (expression: string) => boolean;
7
- interface GetNodesetDependenciesOptions {
8
- readonly contextReference?: string | null;
9
- /**
10
- * @default false
11
- */
12
- readonly ignoreContextReference?: boolean;
13
- /**
14
- * Ignores location path sub-expressions whose full text is `null`. While this
15
- * is technically a valid relative name test step, it seems that real forms in
16
- * the wild use it as if XPath had an actual `null` token/value.
17
- *
18
- * @default true
19
- */
20
- readonly ignoreNullExpressions?: boolean;
21
- }
22
- export declare const getNodesetDependencies: (expression: string, options?: GetNodesetDependenciesOptions) => Set<string>;
23
- export {};
@@ -1,32 +0,0 @@
1
- import { XFormDataType } from '../XFormDataType.ts';
2
- import { XFormDefinition } from '../XFormDefinition.ts';
3
- import { DependencyContext } from '../expression/DependencyContext.ts';
4
- import { DependentExpression } from '../expression/DependentExpression.ts';
5
- import { BindComputation } from './BindComputation.ts';
6
- import { BindElement } from './BindElement.ts';
7
- import { ModelDefinition } from './ModelDefinition.ts';
8
-
9
- export declare class BindDefinition extends DependencyContext {
10
- readonly form: XFormDefinition;
11
- protected readonly model: ModelDefinition;
12
- readonly nodeset: string;
13
- readonly bindElement: BindElement;
14
- readonly bindType: string | null;
15
- readonly dataType: XFormDataType;
16
- readonly parentNodeset: string | null;
17
- readonly calculate: BindComputation<'calculate'> | null;
18
- readonly readonly: BindComputation<'readonly'>;
19
- readonly relevant: BindComputation<'relevant'>;
20
- readonly required: BindComputation<'required'>;
21
- /**
22
- * Diverges from {@link https://github.com/getodk/javarosa/blob/059321160e6f8dbb3e81d9add61d68dd35b13cc8/dag.md | JavaRosa's}, which excludes `constraint` expressions. We compute `constraint` dependencies like the other <bind> computation expressions, but explicitly ignore self-references (this is currently handled by {@link BindComputation}, via its {@link DependentExpression} parent class).
23
- */
24
- readonly constraint: BindComputation<'constraint'> & DependentExpression<'boolean'>;
25
- readonly saveIncomplete: BindComputation<'saveIncomplete'>;
26
- protected _parentBind: BindDefinition | null | undefined;
27
- get parentBind(): BindDefinition | null;
28
- get reference(): string;
29
- get parentReference(): string | null;
30
- constructor(form: XFormDefinition, model: ModelDefinition, nodeset: string, bindElement: BindElement);
31
- toJSON(): Omit<this, "model" | "toJSON" | "form" | "reference" | "parentReference" | "isTranslated" | "registerDependentExpression" | "dependencyExpressions" | "bindElement" | "parentBind">;
32
- }
@@ -1,36 +0,0 @@
1
- import { getValueElement, type ItemsetElement } from '../../../lib/dom/query.ts';
2
- import type { XFormDefinition } from '../../../XFormDefinition.ts';
3
- import { BodyElementDefinition } from '../../BodyElementDefinition.ts';
4
- import { LabelDefinition } from '../../text/LabelDefinition.ts';
5
- import { ItemsetNodesetExpression } from './ItemsetNodesetExpression.ts';
6
- import { ItemsetValueExpression } from './ItemsetValueExpression.ts';
7
- import type { AnySelectDefinition } from './SelectDefinition.ts';
8
-
9
- export class ItemsetDefinition extends BodyElementDefinition<'itemset'> {
10
- override readonly category = 'support';
11
- readonly type = 'itemset';
12
-
13
- override readonly reference: string;
14
- override readonly label: LabelDefinition | null;
15
-
16
- readonly nodes: ItemsetNodesetExpression;
17
- readonly value: ItemsetValueExpression;
18
-
19
- constructor(form: XFormDefinition, select: AnySelectDefinition, element: ItemsetElement) {
20
- const valueElement = getValueElement(element);
21
- const valueExpression = valueElement?.getAttribute('ref');
22
-
23
- if (valueExpression == null) {
24
- throw new Error(`<itemset> has no <value>`);
25
- }
26
-
27
- super(form, select, element);
28
-
29
- const nodesetExpression = element.getAttribute('nodeset');
30
-
31
- this.reference = nodesetExpression;
32
- this.nodes = new ItemsetNodesetExpression(this, nodesetExpression);
33
- this.value = new ItemsetValueExpression(this, valueExpression);
34
- this.label = LabelDefinition.forItemset(form, this);
35
- }
36
- }
@@ -1,8 +0,0 @@
1
- import { DependentExpression } from '../../../expression/DependentExpression.ts';
2
- import type { ItemsetDefinition } from './ItemsetDefinition.ts';
3
-
4
- export class ItemsetNodesetExpression extends DependentExpression<'nodes'> {
5
- constructor(itemset: ItemsetDefinition, nodesetExpression: string) {
6
- super(itemset, 'nodes', nodesetExpression);
7
- }
8
- }
@@ -1,26 +0,0 @@
1
- import { getHintElement } from '../../lib/dom/query.ts';
2
- import type { XFormDefinition } from '../../XFormDefinition.ts';
3
- import type { AnyControlDefinition } from '../control/ControlDefinition.ts';
4
- import type { TextElement } from './TextElementDefinition.ts';
5
- import { TextElementDefinition } from './TextElementDefinition.ts';
6
-
7
- export interface HintElement extends TextElement {
8
- readonly localName: 'hint';
9
- }
10
-
11
- export class HintDefinition extends TextElementDefinition<'hint'> {
12
- static forElement(
13
- form: XFormDefinition,
14
- definition: AnyControlDefinition
15
- ): HintDefinition | null {
16
- const hintElement = getHintElement(definition.element);
17
-
18
- if (hintElement == null) {
19
- return null;
20
- }
21
-
22
- return new this(form, definition, hintElement);
23
- }
24
-
25
- readonly type = 'hint';
26
- }
@@ -1,68 +0,0 @@
1
- import { getLabelElement, getRepeatGroupLabelElement } from '../../lib/dom/query.ts';
2
- import type { XFormDefinition } from '../../XFormDefinition.ts';
3
- import type { AnyControlDefinition } from '../control/ControlDefinition.ts';
4
- import type { ItemDefinition } from '../control/select/ItemDefinition.ts';
5
- import type { ItemsetDefinition } from '../control/select/ItemsetDefinition.ts';
6
- import type { BaseGroupDefinition } from '../group/BaseGroupDefinition.ts';
7
- import type { RepeatElementDefinition } from '../RepeatElementDefinition.ts';
8
- import type { TextElement, TextElementOwner } from './TextElementDefinition.ts';
9
- import { TextElementDefinition } from './TextElementDefinition.ts';
10
-
11
- export interface LabelElement extends TextElement {
12
- readonly localName: 'label';
13
- }
14
-
15
- type StaticLabelContext = Exclude<TextElementOwner, ItemsetDefinition>;
16
-
17
- export class LabelDefinition extends TextElementDefinition<'label'> {
18
- protected static staticDefinition(
19
- form: XFormDefinition,
20
- definition: StaticLabelContext
21
- ): LabelDefinition | null {
22
- const labelElement = getLabelElement(definition.element);
23
-
24
- if (labelElement == null) {
25
- return null;
26
- }
27
-
28
- return new this(form, definition, labelElement);
29
- }
30
-
31
- static forControl(form: XFormDefinition, control: AnyControlDefinition): LabelDefinition | null {
32
- return this.staticDefinition(form, control);
33
- }
34
-
35
- static forRepeatGroup(
36
- form: XFormDefinition,
37
- repeat: RepeatElementDefinition
38
- ): LabelDefinition | null {
39
- const repeatGroupLabel = getRepeatGroupLabelElement(repeat.element);
40
-
41
- if (repeatGroupLabel == null) {
42
- return null;
43
- }
44
-
45
- return new this(form, repeat, repeatGroupLabel);
46
- }
47
-
48
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
- static forGroup(form: XFormDefinition, group: BaseGroupDefinition<any>): LabelDefinition | null {
50
- return this.staticDefinition(form, group);
51
- }
52
-
53
- static forItem(form: XFormDefinition, item: ItemDefinition): LabelDefinition | null {
54
- return this.staticDefinition(form, item);
55
- }
56
-
57
- static forItemset(form: XFormDefinition, itemset: ItemsetDefinition): LabelDefinition | null {
58
- const labelElement = getLabelElement(itemset.element);
59
-
60
- if (labelElement == null) {
61
- return null;
62
- }
63
-
64
- return new this(form, itemset, labelElement);
65
- }
66
-
67
- readonly type = 'label';
68
- }
@@ -1,97 +0,0 @@
1
- import { isCommentNode, isElementNode, isTextNode } from '@getodk/common/lib/dom/predicates.ts';
2
- import type { XFormDefinition } from '../../XFormDefinition.ts';
3
- import { type AnyDependentExpression } from '../../expression/DependentExpression.ts';
4
- import type { AnyGroupElementDefinition } from '../BodyDefinition.ts';
5
- import { BodyElementDefinition } from '../BodyElementDefinition.ts';
6
- import type { RepeatElementDefinition } from '../RepeatElementDefinition.ts';
7
- import type { AnyControlDefinition } from '../control/ControlDefinition.ts';
8
- import type { ItemDefinition } from '../control/select/ItemDefinition.ts';
9
- import type { ItemsetDefinition } from '../control/select/ItemsetDefinition.ts';
10
- import { TextElementOutputPart } from './TextElementOutputPart.ts';
11
- import { TextElementReferencePart } from './TextElementReferencePart.ts';
12
- import { TextElementStaticPart } from './TextElementStaticPart.ts';
13
-
14
- export type TextElementType = 'hint' | 'label';
15
-
16
- export interface TextElement extends Element {
17
- readonly localName: TextElementType;
18
- }
19
-
20
- export type TextElementOwner =
21
- | AnyControlDefinition
22
- | AnyGroupElementDefinition
23
- | ItemDefinition
24
- | ItemsetDefinition
25
- | RepeatElementDefinition;
26
-
27
- export type TextElementChild = TextElementOutputPart | TextElementStaticPart;
28
-
29
- export abstract class TextElementDefinition<
30
- Type extends TextElementType,
31
- > extends BodyElementDefinition<Type> {
32
- readonly category = 'support';
33
- abstract override readonly type: Type;
34
-
35
- override readonly reference: string | null;
36
- override readonly parentReference: string | null;
37
-
38
- readonly referenceExpression: TextElementReferencePart | null;
39
- readonly children: readonly TextElementChild[];
40
-
41
- override get isTranslated(): boolean {
42
- return this.owner.isTranslated;
43
- }
44
-
45
- override set isTranslated(value: true) {
46
- this.owner.isTranslated = value;
47
- }
48
-
49
- protected constructor(
50
- form: XFormDefinition,
51
- readonly owner: TextElementOwner,
52
- element: TextElement
53
- ) {
54
- super(form, owner, element);
55
-
56
- this.reference = owner.reference;
57
- this.parentReference = owner.parentReference;
58
- this.referenceExpression = TextElementReferencePart.from(this, element);
59
-
60
- const children = Array.from(element.childNodes).flatMap((node) => {
61
- if (isTextNode(node)) {
62
- return new TextElementStaticPart(this, node);
63
- }
64
-
65
- if (isElementNode(node)) {
66
- const output = TextElementOutputPart.from(this, node);
67
-
68
- if (output != null) {
69
- return output;
70
- }
71
- }
72
-
73
- if (isCommentNode(node)) {
74
- return [];
75
- }
76
-
77
- // eslint-disable-next-line no-console
78
- console.error('Unexpected text element child', node);
79
-
80
- throw new Error(`Unexpected <${element.nodeName}> child element`);
81
- });
82
-
83
- this.children = children;
84
- }
85
-
86
- override registerDependentExpression(expression: AnyDependentExpression): void {
87
- this.owner.registerDependentExpression(expression);
88
- }
89
-
90
- override toJSON(): object {
91
- const { form, owner, parent, ...rest } = this;
92
-
93
- return rest;
94
- }
95
- }
96
-
97
- export type AnyTextElementDefinition = TextElementDefinition<TextElementType>;
@@ -1,27 +0,0 @@
1
- import type { AnyTextElementDefinition } from './TextElementDefinition.ts';
2
- import { TextElementPart } from './TextElementPart.ts';
3
-
4
- interface OutputElement extends Element {
5
- readonly localName: 'output';
6
-
7
- getAttribute(name: 'value'): string;
8
- getAttribute(name: string): string | null;
9
- }
10
-
11
- const isOutputElement = (element: Element): element is OutputElement => {
12
- return element.localName === 'output' && element.hasAttribute('value');
13
- };
14
-
15
- export class TextElementOutputPart extends TextElementPart<'output'> {
16
- static from(context: AnyTextElementDefinition, element: Element): TextElementOutputPart | null {
17
- if (isOutputElement(element)) {
18
- return new this(context, element);
19
- }
20
-
21
- return null;
22
- }
23
-
24
- protected constructor(context: AnyTextElementDefinition, element: OutputElement) {
25
- super('output', context, element.getAttribute('value'));
26
- }
27
- }
@@ -1,31 +0,0 @@
1
- import { DependentExpression } from '../../expression/DependentExpression.ts';
2
- import type { AnyTextElementDefinition } from './TextElementDefinition.ts';
3
- import type { TextElementOutputPart } from './TextElementOutputPart.ts';
4
- import type { TextElementReferencePart } from './TextElementReferencePart.ts';
5
- import type { TextElementStaticPart } from './TextElementStaticPart.ts';
6
-
7
- export type TextElementPartType = 'output' | 'reference' | 'static';
8
-
9
- export abstract class TextElementPart<
10
- Type extends TextElementPartType,
11
- > extends DependentExpression<'string'> {
12
- readonly stringValue?: string;
13
-
14
- constructor(
15
- readonly type: Type,
16
- context: AnyTextElementDefinition,
17
- expression: string
18
- ) {
19
- super(context, 'string', expression, {
20
- semanticDependencies: {
21
- translations: type !== 'static',
22
- },
23
- ignoreContextReference: true,
24
- });
25
- }
26
- }
27
-
28
- export type AnyTextElementPart =
29
- | TextElementOutputPart
30
- | TextElementReferencePart
31
- | TextElementStaticPart;
@@ -1,21 +0,0 @@
1
- import type { AnyTextElementDefinition, TextElement } from './TextElementDefinition.ts';
2
- import { TextElementPart } from './TextElementPart.ts';
3
-
4
- export class TextElementReferencePart extends TextElementPart<'reference'> {
5
- static from(
6
- context: AnyTextElementDefinition,
7
- element: TextElement
8
- ): TextElementReferencePart | null {
9
- const expression = element.getAttribute('ref');
10
-
11
- if (expression == null) {
12
- return null;
13
- }
14
-
15
- return new this(context, expression);
16
- }
17
-
18
- protected constructor(context: AnyTextElementDefinition, expression: string) {
19
- super('reference', context, expression);
20
- }
21
- }
@@ -1,26 +0,0 @@
1
- import type { AnyTextElementDefinition } from './TextElementDefinition.ts';
2
- import { TextElementPart } from './TextElementPart.ts';
3
-
4
- const toStaticXPathExpression = (staticTextValue: string): string => {
5
- const quote = staticTextValue.includes('"') ? "'" : '"';
6
-
7
- if (staticTextValue.includes(quote)) {
8
- // throw new Error('todo concat()');
9
- return 'todo(concat())';
10
- }
11
-
12
- return `${quote}${staticTextValue}${quote}`;
13
- };
14
-
15
- export class TextElementStaticPart extends TextElementPart<'static'> {
16
- override readonly stringValue: string;
17
-
18
- constructor(context: AnyTextElementDefinition, node: Text) {
19
- const stringValue = node.data;
20
- const expression = toStaticXPathExpression(stringValue);
21
-
22
- super('static', context, expression);
23
-
24
- this.stringValue = stringValue;
25
- }
26
- }