@getodk/xforms-engine 0.1.0 → 0.2.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 (157) hide show
  1. package/dist/.vite/manifest.json +1 -0
  2. package/dist/XFormDOM.d.ts +1 -0
  3. package/dist/XFormDataType.d.ts +2 -1
  4. package/dist/XFormDefinition.d.ts +1 -0
  5. package/dist/body/BodyDefinition.d.ts +27 -9
  6. package/dist/body/BodyElementDefinition.d.ts +5 -4
  7. package/dist/body/RepeatElementDefinition.d.ts +19 -0
  8. package/dist/body/UnsupportedBodyElementDefinition.d.ts +3 -2
  9. package/dist/body/appearance/inputAppearanceParser.d.ts +4 -0
  10. package/dist/body/appearance/selectAppearanceParser.d.ts +4 -0
  11. package/dist/body/appearance/structureElementAppearanceParser.d.ts +4 -0
  12. package/dist/body/control/ControlDefinition.d.ts +5 -2
  13. package/dist/body/control/InputDefinition.d.ts +6 -0
  14. package/dist/body/control/select/ItemDefinition.d.ts +4 -3
  15. package/dist/body/control/select/ItemsetDefinition.d.ts +4 -3
  16. package/dist/body/control/select/ItemsetNodesetContext.d.ts +3 -2
  17. package/dist/body/control/select/ItemsetNodesetExpression.d.ts +2 -1
  18. package/dist/body/control/select/ItemsetValueExpression.d.ts +2 -1
  19. package/dist/body/control/select/SelectDefinition.d.ts +16 -5
  20. package/dist/body/group/BaseGroupDefinition.d.ts +6 -10
  21. package/dist/body/group/LogicalGroupDefinition.d.ts +1 -0
  22. package/dist/body/group/PresentationGroupDefinition.d.ts +3 -2
  23. package/dist/body/group/StructuralGroupDefinition.d.ts +1 -0
  24. package/dist/body/text/HintDefinition.d.ts +4 -4
  25. package/dist/body/text/LabelDefinition.d.ts +9 -7
  26. package/dist/body/text/TextElementDefinition.d.ts +9 -8
  27. package/dist/body/text/TextElementOutputPart.d.ts +2 -1
  28. package/dist/body/text/TextElementPart.d.ts +5 -4
  29. package/dist/body/text/TextElementReferencePart.d.ts +2 -1
  30. package/dist/body/text/TextElementStaticPart.d.ts +2 -1
  31. package/dist/client/BaseNode.d.ts +9 -3
  32. package/dist/client/EngineConfig.d.ts +2 -1
  33. package/dist/client/GroupNode.d.ts +10 -6
  34. package/dist/client/NodeAppearances.d.ts +15 -0
  35. package/dist/client/RepeatInstanceNode.d.ts +10 -6
  36. package/dist/client/RepeatRangeNode.d.ts +11 -7
  37. package/dist/client/RootNode.d.ts +24 -4
  38. package/dist/client/SelectNode.d.ts +10 -6
  39. package/dist/client/StringNode.d.ts +9 -5
  40. package/dist/client/SubtreeNode.d.ts +6 -4
  41. package/dist/client/TextRange.d.ts +2 -1
  42. package/dist/client/hierarchy.d.ts +9 -8
  43. package/dist/client/index.d.ts +3 -2
  44. package/dist/expression/DependencyContext.d.ts +2 -1
  45. package/dist/expression/DependentExpression.d.ts +3 -2
  46. package/dist/index.d.ts +2 -1
  47. package/dist/index.js +1882 -1757
  48. package/dist/index.js.map +1 -1
  49. package/dist/instance/Group.d.ts +15 -15
  50. package/dist/instance/RepeatInstance.d.ts +39 -15
  51. package/dist/instance/RepeatRange.d.ts +98 -20
  52. package/dist/instance/Root.d.ts +25 -39
  53. package/dist/instance/SelectField.d.ts +17 -17
  54. package/dist/instance/StringField.d.ts +17 -17
  55. package/dist/instance/Subtree.d.ts +13 -13
  56. package/dist/instance/abstract/DescendantNode.d.ts +26 -18
  57. package/dist/instance/abstract/InstanceNode.d.ts +44 -46
  58. package/dist/instance/children.d.ts +2 -1
  59. package/dist/instance/hierarchy.d.ts +8 -7
  60. package/dist/instance/index.d.ts +4 -3
  61. package/dist/instance/internal-api/EvaluationContext.d.ts +10 -8
  62. package/dist/instance/internal-api/InstanceConfig.d.ts +3 -2
  63. package/dist/instance/internal-api/SubscribableDependency.d.ts +2 -1
  64. package/dist/instance/internal-api/TranslationContext.d.ts +2 -1
  65. package/dist/instance/internal-api/ValueContext.d.ts +6 -5
  66. package/dist/instance/resource.d.ts +3 -2
  67. package/dist/instance/text/TextChunk.d.ts +4 -3
  68. package/dist/instance/text/TextRange.d.ts +2 -1
  69. package/dist/lib/TokenListParser.d.ts +84 -0
  70. package/dist/lib/dom/query.d.ts +8 -2
  71. package/dist/lib/reactivity/createChildrenState.d.ts +4 -3
  72. package/dist/lib/reactivity/createComputedExpression.d.ts +4 -3
  73. package/dist/lib/reactivity/createSelectItems.d.ts +4 -3
  74. package/dist/lib/reactivity/createValueState.d.ts +3 -2
  75. package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +6 -4
  76. package/dist/lib/reactivity/node-state/createClientState.d.ts +7 -6
  77. package/dist/lib/reactivity/node-state/createCurrentState.d.ts +5 -4
  78. package/dist/lib/reactivity/node-state/createEngineState.d.ts +4 -3
  79. package/dist/lib/reactivity/node-state/createSharedNodeState.d.ts +7 -6
  80. package/dist/lib/reactivity/node-state/createSpecifiedPropertyDescriptor.d.ts +2 -1
  81. package/dist/lib/reactivity/node-state/createSpecifiedState.d.ts +3 -2
  82. package/dist/lib/reactivity/node-state/representations.d.ts +2 -1
  83. package/dist/lib/reactivity/scope.d.ts +2 -1
  84. package/dist/lib/reactivity/text/createFieldHint.d.ts +4 -3
  85. package/dist/lib/reactivity/text/createNodeLabel.d.ts +4 -3
  86. package/dist/lib/reactivity/text/createTextRange.d.ts +6 -5
  87. package/dist/lib/reactivity/types.d.ts +2 -1
  88. package/dist/lib/xpath/analysis.d.ts +2 -1
  89. package/dist/model/BindComputation.d.ts +2 -1
  90. package/dist/model/BindDefinition.d.ts +6 -5
  91. package/dist/model/DescendentNodeDefinition.d.ts +6 -6
  92. package/dist/model/ModelBindMap.d.ts +4 -3
  93. package/dist/model/ModelDefinition.d.ts +2 -1
  94. package/dist/model/NodeDefinition.d.ts +20 -19
  95. package/dist/model/RepeatInstanceDefinition.d.ts +7 -7
  96. package/dist/model/{RepeatSequenceDefinition.d.ts → RepeatRangeDefinition.d.ts} +7 -6
  97. package/dist/model/RepeatTemplateDefinition.d.ts +8 -8
  98. package/dist/model/RootDefinition.d.ts +8 -5
  99. package/dist/model/SubtreeDefinition.d.ts +5 -4
  100. package/dist/model/ValueNodeDefinition.d.ts +5 -5
  101. package/dist/solid.js +1873 -1751
  102. package/dist/solid.js.map +1 -1
  103. package/package.json +14 -18
  104. package/src/XFormDOM.ts +81 -8
  105. package/src/body/BodyDefinition.ts +38 -23
  106. package/src/body/RepeatElementDefinition.ts +70 -0
  107. package/src/body/appearance/inputAppearanceParser.ts +39 -0
  108. package/src/body/appearance/selectAppearanceParser.ts +38 -0
  109. package/src/body/appearance/structureElementAppearanceParser.ts +7 -0
  110. package/src/body/control/ControlDefinition.ts +4 -0
  111. package/src/body/control/InputDefinition.ts +13 -0
  112. package/src/body/control/select/SelectDefinition.ts +14 -5
  113. package/src/body/group/BaseGroupDefinition.ts +11 -49
  114. package/src/body/text/LabelDefinition.ts +15 -1
  115. package/src/body/text/TextElementDefinition.ts +5 -5
  116. package/src/client/BaseNode.ts +9 -1
  117. package/src/client/GroupNode.ts +6 -2
  118. package/src/client/NodeAppearances.ts +22 -0
  119. package/src/client/RepeatInstanceNode.ts +4 -0
  120. package/src/client/RepeatRangeNode.ts +6 -2
  121. package/src/client/RootNode.ts +22 -0
  122. package/src/client/SelectNode.ts +4 -0
  123. package/src/client/StringNode.ts +4 -0
  124. package/src/client/SubtreeNode.ts +1 -0
  125. package/src/instance/Group.ts +14 -9
  126. package/src/instance/RepeatInstance.ts +59 -15
  127. package/src/instance/RepeatRange.ts +133 -15
  128. package/src/instance/Root.ts +20 -64
  129. package/src/instance/SelectField.ts +7 -7
  130. package/src/instance/StringField.ts +8 -7
  131. package/src/instance/Subtree.ts +10 -7
  132. package/src/instance/abstract/DescendantNode.ts +45 -43
  133. package/src/instance/abstract/InstanceNode.ts +69 -86
  134. package/src/instance/children.ts +17 -7
  135. package/src/instance/index.ts +1 -1
  136. package/src/instance/internal-api/EvaluationContext.ts +5 -6
  137. package/src/instance/internal-api/ValueContext.ts +2 -2
  138. package/src/lib/TokenListParser.ts +156 -0
  139. package/src/lib/dom/query.ts +13 -0
  140. package/src/lib/reactivity/createChildrenState.ts +51 -6
  141. package/src/lib/reactivity/createComputedExpression.ts +1 -1
  142. package/src/lib/reactivity/createSelectItems.ts +4 -6
  143. package/src/lib/reactivity/createValueState.ts +6 -6
  144. package/src/lib/reactivity/materializeCurrentStateChildren.ts +3 -1
  145. package/src/model/DescendentNodeDefinition.ts +1 -2
  146. package/src/model/ModelDefinition.ts +1 -1
  147. package/src/model/NodeDefinition.ts +12 -12
  148. package/src/model/RepeatInstanceDefinition.ts +8 -13
  149. package/src/model/{RepeatSequenceDefinition.ts → RepeatRangeDefinition.ts} +6 -6
  150. package/src/model/RepeatTemplateDefinition.ts +10 -15
  151. package/src/model/RootDefinition.ts +6 -12
  152. package/src/model/SubtreeDefinition.ts +3 -3
  153. package/src/model/ValueNodeDefinition.ts +2 -3
  154. package/dist/body/RepeatDefinition.d.ts +0 -15
  155. package/dist/body/group/RepeatGroupDefinition.d.ts +0 -12
  156. package/src/body/RepeatDefinition.ts +0 -54
  157. package/src/body/group/RepeatGroupDefinition.ts +0 -91
@@ -1,16 +1,16 @@
1
- import type { Accessor } from 'solid-js';
2
- import type { GroupDefinition, GroupNode } from '../client/GroupNode.ts';
3
- import type { TextRange } from '../index.ts';
4
- import type { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
5
- import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
6
- import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
7
- import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
8
- import type { DescendantNodeSharedStateSpec } from './abstract/DescendantNode.ts';
9
- import { DescendantNode } from './abstract/DescendantNode.ts';
10
- import type { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
11
- import type { NodeID } from './identity.ts';
12
- import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
13
- import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
1
+ import { Accessor } from 'solid-js';
2
+ import { GroupDefinition, GroupNode, GroupNodeAppearances } from '../client/GroupNode.ts';
3
+ import { TextRange } from '../index.ts';
4
+ import { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
5
+ import { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
6
+ import { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
7
+ import { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
8
+ import { DescendantNodeSharedStateSpec, DescendantNode } from './abstract/DescendantNode.ts';
9
+ import { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
10
+ import { NodeID } from './identity.ts';
11
+ import { EvaluationContext } from './internal-api/EvaluationContext.ts';
12
+ import { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
13
+
14
14
  interface GroupStateSpec extends DescendantNodeSharedStateSpec {
15
15
  readonly label: Accessor<TextRange<'label'> | null>;
16
16
  readonly hint: null;
@@ -22,10 +22,10 @@ export declare class Group extends DescendantNode<GroupDefinition, GroupStateSpe
22
22
  private readonly childrenState;
23
23
  protected readonly state: SharedNodeState<GroupStateSpec>;
24
24
  protected engineState: EngineState<GroupStateSpec>;
25
- readonly currentState: MaterializedChildren<CurrentState<GroupStateSpec>, GeneralChildNode>;
26
25
  readonly nodeType = "group";
26
+ readonly appearances: GroupNodeAppearances;
27
+ readonly currentState: MaterializedChildren<CurrentState<GroupStateSpec>, GeneralChildNode>;
27
28
  constructor(parent: GeneralParentNode, definition: GroupDefinition);
28
- protected computeReference(parent: GeneralParentNode): string;
29
29
  getChildren(): readonly GeneralChildNode[];
30
30
  }
31
31
  export {};
@@ -1,17 +1,17 @@
1
- import type { Accessor } from 'solid-js';
2
- import type { RepeatDefinition, RepeatInstanceNode } from '../client/RepeatInstanceNode.ts';
3
- import type { TextRange } from '../index.ts';
4
- import type { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
5
- import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
6
- import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
7
- import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
8
- import type { RepeatRange } from './RepeatRange.ts';
9
- import type { DescendantNodeSharedStateSpec } from './abstract/DescendantNode.ts';
10
- import { DescendantNode } from './abstract/DescendantNode.ts';
11
- import type { AnyChildNode, GeneralChildNode } from './hierarchy.ts';
12
- import type { NodeID } from './identity.ts';
13
- import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
14
- import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
1
+ import { Accessor } from 'solid-js';
2
+ import { RepeatDefinition, RepeatInstanceNode, RepeatInstanceNodeAppearances } from '../client/RepeatInstanceNode.ts';
3
+ import { TextRange } from '../index.ts';
4
+ import { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
5
+ import { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
6
+ import { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
7
+ import { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
8
+ import { RepeatRange } from './RepeatRange.ts';
9
+ import { DescendantNodeSharedStateSpec, DescendantNode } from './abstract/DescendantNode.ts';
10
+ import { AnyChildNode, GeneralChildNode } from './hierarchy.ts';
11
+ import { NodeID } from './identity.ts';
12
+ import { EvaluationContext } from './internal-api/EvaluationContext.ts';
13
+ import { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
14
+
15
15
  export type { RepeatDefinition };
16
16
  interface RepeatInstanceStateSpec extends DescendantNodeSharedStateSpec {
17
17
  readonly label: Accessor<TextRange<'label'> | null>;
@@ -30,10 +30,34 @@ export declare class RepeatInstance extends DescendantNode<RepeatDefinition, Rep
30
30
  private readonly currentIndex;
31
31
  protected readonly state: SharedNodeState<RepeatInstanceStateSpec>;
32
32
  protected engineState: EngineState<RepeatInstanceStateSpec>;
33
+ /**
34
+ * @todo Should we special case repeat `readonly` inheritance the same way
35
+ * we do for `relevant`?
36
+ *
37
+ * @see {@link hasNonRelevantAncestor}
38
+ */
39
+ readonly hasReadonlyAncestor: Accessor<boolean>;
40
+ /**
41
+ * A repeat instance can inherit non-relevance, just like any other node. That
42
+ * inheritance is derived from the repeat instance's parent node in the
43
+ * primary instance XML/DOM tree (and would be semantically expected to do so
44
+ * even if we move away from that implementation detail).
45
+ *
46
+ * Since {@link RepeatInstance.parent} is a {@link RepeatRange}, which is a
47
+ * runtime data model fiction that does not exist in that hierarchy, we pass
48
+ * this call through, allowing the {@link RepeatRange} to check the actual
49
+ * primary instance parent node's relevance state.
50
+ *
51
+ * @todo Should we apply similar reasoning in {@link hasReadonlyAncestor}?
52
+ */
53
+ readonly hasNonRelevantAncestor: Accessor<boolean>;
33
54
  readonly nodeType = "repeat-instance";
55
+ /**
56
+ * @see {@link RepeatRange.appearances}
57
+ */
58
+ readonly appearances: RepeatInstanceNodeAppearances;
34
59
  readonly currentState: MaterializedChildren<CurrentState<RepeatInstanceStateSpec>, GeneralChildNode>;
35
60
  constructor(parent: RepeatRange, definition: RepeatDefinition, options: RepeatInstanceOptions);
36
- protected computeReference(parent: RepeatRange): string;
37
61
  protected initializeContextNode(parentContextNode: Element, nodeName: string): Element;
38
62
  subscribe(): void;
39
63
  getChildren(): readonly GeneralChildNode[];
@@ -1,20 +1,19 @@
1
- import type { Accessor } from 'solid-js';
2
- import type { RepeatRangeNode } from '../client/RepeatRangeNode.ts';
3
- import type { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
4
- import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
5
- import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
6
- import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
7
- import type { RepeatSequenceDefinition } from '../model/RepeatSequenceDefinition.ts';
8
- import type { RepeatDefinition } from './RepeatInstance.ts';
9
- import { RepeatInstance } from './RepeatInstance.ts';
10
- import type { Root } from './Root.ts';
11
- import type { DescendantNodeSharedStateSpec } from './abstract/DescendantNode.ts';
12
- import { DescendantNode } from './abstract/DescendantNode.ts';
13
- import type { GeneralParentNode } from './hierarchy.ts';
14
- import type { NodeID } from './identity.ts';
15
- import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
16
- import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
17
- import type { TextRange } from './text/TextRange.ts';
1
+ import { Accessor } from 'solid-js';
2
+ import { RepeatRangeNode, RepeatRangeNodeAppearances } from '../client/RepeatRangeNode.ts';
3
+ import { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
4
+ import { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
5
+ import { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
6
+ import { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
7
+ import { RepeatRangeDefinition } from '../model/RepeatRangeDefinition.ts';
8
+ import { RepeatDefinition, RepeatInstance } from './RepeatInstance.ts';
9
+ import { Root } from './Root.ts';
10
+ import { DescendantNodeSharedStateSpec, DescendantNode } from './abstract/DescendantNode.ts';
11
+ import { GeneralParentNode } from './hierarchy.ts';
12
+ import { NodeID } from './identity.ts';
13
+ import { EvaluationContext } from './internal-api/EvaluationContext.ts';
14
+ import { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
15
+ import { TextRange } from './text/TextRange.ts';
16
+
18
17
  interface RepeatRangeStateSpec extends DescendantNodeSharedStateSpec {
19
18
  readonly hint: null;
20
19
  readonly label: Accessor<TextRange<'label'> | null>;
@@ -22,7 +21,7 @@ interface RepeatRangeStateSpec extends DescendantNodeSharedStateSpec {
22
21
  readonly valueOptions: null;
23
22
  readonly value: null;
24
23
  }
25
- export declare class RepeatRange extends DescendantNode<RepeatSequenceDefinition, RepeatRangeStateSpec, RepeatInstance> implements RepeatRangeNode, EvaluationContext, SubscribableDependency {
24
+ export declare class RepeatRange extends DescendantNode<RepeatRangeDefinition, RepeatRangeStateSpec, RepeatInstance> implements RepeatRangeNode, EvaluationContext, SubscribableDependency {
26
25
  /**
27
26
  * A repeat range doesn't have a corresponding primary instance element of its
28
27
  * own, and its instances are appended to the range's parent element. During
@@ -49,12 +48,91 @@ export declare class RepeatRange extends DescendantNode<RepeatSequenceDefinition
49
48
  private readonly childrenState;
50
49
  protected readonly state: SharedNodeState<RepeatRangeStateSpec>;
51
50
  protected engineState: EngineState<RepeatRangeStateSpec>;
51
+ /**
52
+ * @todo Should we special case repeat `readonly` state the same way
53
+ * we do for `relevant`?
54
+ *
55
+ * @see {@link isSelfRelevant}
56
+ */
57
+ isSelfReadonly: Accessor<boolean>;
58
+ private readonly emptyRangeEvaluationContext;
59
+ /**
60
+ * @see {@link isSelfRelevant}
61
+ */
62
+ private readonly isEmptyRangeSelfRelevant;
63
+ /**
64
+ * A repeat range does not exist in the primary instance tree. A `relevant`
65
+ * expression applies to each {@link RepeatInstance} child of the repeat
66
+ * range. Determining whether a repeat range itself "is relevant" isn't a
67
+ * concept the spec addresses, but it may be used by clients to determine
68
+ * whether to allow interaction with the range (e.g. by adding a repeat
69
+ * instance, or presenting the range's label when empty).
70
+ *
71
+ * As a naive first pass, it seems like the heuristic for this should be:
72
+ *
73
+ * 1. Does the repeat range have any repeat instance children?
74
+ *
75
+ * - If yes, go to 2.
76
+ * - If no, go to 3.
77
+ *
78
+ * 2. Does one or more of those children return `true` for the node's
79
+ * `relevant` expression (i.e. is the repeat instance "self relevant")?
80
+ *
81
+ * 3. Does the relevant expression return `true` for the repeat range itself
82
+ * (where, at least for now, the context of that evaluation would be the
83
+ * repeat range's {@link anchorNode} to ensure correct relative expressions
84
+ * resolve correctly)?
85
+ *
86
+ * @todo While (3) is proactively implemented, there isn't presently a test
87
+ * exercising it. It felt best for now to surface this for discussion in
88
+ * review to validate that it's going in the right direction.
89
+ *
90
+ * @todo While (2) **is actually tested**, the tests currently in place behave
91
+ * the same way with only the logic for (3), regardless of whether the repeat
92
+ * range actually has any repeat instance children. It's unclear (a) if that's
93
+ * a preferable simplification and (b) how that might affect performance (in
94
+ * theory it could vary depending on form structure and runtime state).
95
+ */
96
+ readonly isSelfRelevant: Accessor<boolean>;
52
97
  readonly nodeType = "repeat-range";
98
+ /**
99
+ * @todo RepeatRange*, RepeatInstance* (and RepeatTemplate*) all share the
100
+ * same body element, and thus all share the same definition `bodyElement`. As
101
+ * such, they also all share the same `appearances`. At time of writing,
102
+ * `web-forms` (Vue UI package) treats a `RepeatRangeNode`...
103
+ *
104
+ * - ... as a group, if the node has a label (i.e.
105
+ * `<group><label/><repeat/></group>`)
106
+ * - ... effectively as a fragment containing only its instances, otherwise
107
+ *
108
+ * We now collapse `<group><repeat>` into `<repeat>`, and no longer treat
109
+ * "repeat group" as a concept (after parsing). According to the spec, these
110
+ * appearances **are supposed to** come from that "repeat group" in the form
111
+ * definition. In practice, many forms do define appearances directly on a
112
+ * repeat element. The engine currently produces an error if both are defined
113
+ * simultaneously, but otherwise makes no distinction between appearances in
114
+ * these form definition shapes:
115
+ *
116
+ * ```xml
117
+ * <group ref="/data/rep1" appearance="...">
118
+ * <repeat nodeset="/data/rep1"/>
119
+ * </group>
120
+ *
121
+ * <group ref="/data/rep1">
122
+ * <repeat nodeset="/data/rep1"/ appearance="...">
123
+ * </group>
124
+ *
125
+ * <repeat nodeset="/data/rep1"/ appearance="...">
126
+ * ```
127
+ *
128
+ * All of the above creates considerable ambiguity about where "repeat
129
+ * appearances" should apply, under which circumstances.
130
+ */
131
+ readonly appearances: RepeatRangeNodeAppearances;
53
132
  readonly currentState: MaterializedChildren<CurrentState<RepeatRangeStateSpec>, RepeatInstance>;
54
- constructor(parent: GeneralParentNode, definition: RepeatSequenceDefinition);
133
+ constructor(parent: GeneralParentNode, definition: RepeatRangeDefinition);
55
134
  private getLastIndex;
56
135
  protected initializeContextNode(parentContextNode: Element): Element;
57
- protected computeReference(parent: GeneralParentNode): string;
58
136
  getInstanceIndex(instance: RepeatInstance): number;
59
137
  addInstances(afterIndex?: number, count?: number, definition?: RepeatDefinition): Root;
60
138
  /**
@@ -1,20 +1,22 @@
1
- import type { XFormsXPathEvaluator } from '@getodk/xpath';
2
- import type { Accessor, Signal } from 'solid-js';
3
- import type { XFormDOM } from '../XFormDOM.ts';
4
- import type { ActiveLanguage, FormLanguage, FormLanguages } from '../client/FormLanguage.ts';
5
- import type { RootNode } from '../client/RootNode.ts';
6
- import type { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
7
- import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
8
- import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
9
- import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
10
- import type { RootDefinition } from '../model/RootDefinition.ts';
1
+ import { XFormsXPathEvaluator } from '@getodk/xpath';
2
+ import { Accessor, Signal } from 'solid-js';
3
+ import { XFormDOM } from '../XFormDOM.ts';
4
+ import { BodyClassList } from '../body/BodyDefinition.ts';
5
+ import { ActiveLanguage, FormLanguage, FormLanguages } from '../client/FormLanguage.ts';
6
+ import { RootNode } from '../client/RootNode.ts';
7
+ import { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
8
+ import { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
9
+ import { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
10
+ import { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
11
+ import { RootDefinition } from '../model/RootDefinition.ts';
11
12
  import { InstanceNode } from './abstract/InstanceNode.ts';
12
- import type { GeneralChildNode } from './hierarchy.ts';
13
- import type { NodeID } from './identity.ts';
14
- import type { EvaluationContext, EvaluationContextRoot } from './internal-api/EvaluationContext.ts';
15
- import type { InstanceConfig } from './internal-api/InstanceConfig.ts';
16
- import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
17
- import type { TranslationContext } from './internal-api/TranslationContext.ts';
13
+ import { GeneralChildNode } from './hierarchy.ts';
14
+ import { NodeID } from './identity.ts';
15
+ import { EvaluationContext, EvaluationContextRoot } from './internal-api/EvaluationContext.ts';
16
+ import { InstanceConfig } from './internal-api/InstanceConfig.ts';
17
+ import { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
18
+ import { TranslationContext } from './internal-api/TranslationContext.ts';
19
+
18
20
  interface RootStateSpec {
19
21
  readonly reference: string;
20
22
  readonly readonly: boolean;
@@ -28,41 +30,25 @@ interface RootStateSpec {
28
30
  readonly activeLanguage: Signal<ActiveLanguage>;
29
31
  }
30
32
  export declare class Root extends InstanceNode<RootDefinition, RootStateSpec, GeneralChildNode> implements RootNode, EvaluationContext, EvaluationContextRoot, SubscribableDependency, TranslationContext {
31
- static initialize(xformDOM: XFormDOM, definition: RootDefinition, engineConfig: InstanceConfig): Promise<Root>;
32
33
  private readonly childrenState;
34
+ readonly hasReadonlyAncestor: () => boolean;
35
+ readonly isReadonly: () => boolean;
36
+ readonly hasNonRelevantAncestor: () => boolean;
37
+ readonly isRelevant: () => boolean;
33
38
  protected readonly state: SharedNodeState<RootStateSpec>;
34
39
  protected readonly engineState: EngineState<RootStateSpec>;
35
40
  readonly nodeType = "root";
41
+ readonly appearances: null;
42
+ readonly classes: BodyClassList;
36
43
  readonly currentState: MaterializedChildren<CurrentState<RootStateSpec>, GeneralChildNode>;
37
44
  protected readonly instanceDOM: XFormDOM;
38
45
  readonly root: this;
39
46
  readonly evaluator: XFormsXPathEvaluator;
40
- private readonly rootReference;
41
- get contextReference(): string;
42
47
  readonly contextNode: Element;
43
48
  readonly parent: null;
44
49
  readonly languages: FormLanguages;
45
50
  get activeLanguage(): ActiveLanguage;
46
- protected constructor(xformDOM: XFormDOM, definition: RootDefinition, engineConfig: InstanceConfig);
47
- /**
48
- * Waits until form state is fully initialized.
49
- *
50
- * As much as possible, all instance state computations are implemented so
51
- * that they complete synchronously.
52
- *
53
- * There is currently one exception: because instance nodes may form
54
- * computation dependencies into their descendants as well as their ancestors,
55
- * there is an allowance **during form initialization only** to account for
56
- * this chicken/egg scenario. Note that this allowance is intentionally,
57
- * strictly limited: if form state initialization is not resolved within a
58
- * single microtask tick we throw/reject.
59
- *
60
- * All subsequent computations are always performed synchronously (and we will
61
- * use tests to validate this, by utilizing the synchronously returned `Root`
62
- * state from client-facing write interfaces).
63
- */
64
- formStateInitialized(): Promise<void>;
65
- protected computeReference(_parent: null, definition: RootDefinition): string;
51
+ constructor(xformDOM: XFormDOM, definition: RootDefinition, engineConfig: InstanceConfig);
66
52
  getChildren(): readonly GeneralChildNode[];
67
53
  setLanguage(language: FormLanguage): Root;
68
54
  subscribe(): void;
@@ -1,19 +1,19 @@
1
- import type { Accessor } from 'solid-js';
2
- import type { AnySelectDefinition } from '../body/control/select/SelectDefinition.ts';
3
- import type { SelectItem, SelectNode } from '../client/SelectNode.ts';
4
- import type { TextRange } from '../index.ts';
5
- import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
6
- import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
7
- import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
8
- import type { SimpleAtomicState } from '../lib/reactivity/types.ts';
9
- import type { ValueNodeDefinition } from '../model/ValueNodeDefinition.ts';
10
- import type { Root } from './Root.ts';
11
- import type { DescendantNodeStateSpec } from './abstract/DescendantNode.ts';
12
- import { DescendantNode } from './abstract/DescendantNode.ts';
13
- import type { GeneralParentNode } from './hierarchy.ts';
14
- import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
15
- import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
16
- import type { ValueContext } from './internal-api/ValueContext.ts';
1
+ import { Accessor } from 'solid-js';
2
+ import { AnySelectDefinition } from '../body/control/select/SelectDefinition.ts';
3
+ import { SelectItem, SelectNode, SelectNodeAppearances } from '../client/SelectNode.ts';
4
+ import { TextRange } from '../index.ts';
5
+ import { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
6
+ import { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
7
+ import { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
8
+ import { SimpleAtomicState } from '../lib/reactivity/types.ts';
9
+ import { ValueNodeDefinition } from '../model/ValueNodeDefinition.ts';
10
+ import { Root } from './Root.ts';
11
+ import { DescendantNodeStateSpec, DescendantNode } from './abstract/DescendantNode.ts';
12
+ import { GeneralParentNode } from './hierarchy.ts';
13
+ import { EvaluationContext } from './internal-api/EvaluationContext.ts';
14
+ import { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
15
+ import { ValueContext } from './internal-api/ValueContext.ts';
16
+
17
17
  export interface SelectFieldDefinition extends ValueNodeDefinition {
18
18
  readonly bodyElement: AnySelectDefinition;
19
19
  }
@@ -29,13 +29,13 @@ export declare class SelectField extends DescendantNode<SelectFieldDefinition, S
29
29
  protected readonly state: SharedNodeState<SelectFieldStateSpec>;
30
30
  protected engineState: EngineState<SelectFieldStateSpec>;
31
31
  readonly nodeType = "select";
32
+ readonly appearances: SelectNodeAppearances;
32
33
  readonly currentState: CurrentState<SelectFieldStateSpec>;
33
34
  readonly encodeValue: (runtimeValue: readonly SelectItem[]) => string;
34
35
  readonly decodeValue: (instanceValue: string) => readonly SelectItem[];
35
36
  protected readonly getValueOptions: Accessor<readonly SelectItem[]>;
36
37
  constructor(parent: GeneralParentNode, definition: SelectFieldDefinition);
37
38
  protected getSelectItemsByValue(valueOptions?: readonly SelectItem[]): ReadonlyMap<string, SelectItem>;
38
- protected computeReference(parent: GeneralParentNode): string;
39
39
  protected updateSelectedItemValues(values: readonly string[]): void;
40
40
  protected setSelectedItemValue(value: string | null): void;
41
41
  select(selectedItem: SelectItem): Root;
@@ -1,19 +1,19 @@
1
- import type { Accessor } from 'solid-js';
2
- import type { InputDefinition } from '../body/control/InputDefinition.ts';
3
- import type { StringNode } from '../client/StringNode.ts';
4
- import type { TextRange } from '../index.ts';
5
- import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
6
- import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
7
- import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
8
- import type { SimpleAtomicState } from '../lib/reactivity/types.ts';
9
- import type { ValueNodeDefinition } from '../model/ValueNodeDefinition.ts';
10
- import type { Root } from './Root.ts';
11
- import type { DescendantNodeStateSpec } from './abstract/DescendantNode.ts';
12
- import { DescendantNode } from './abstract/DescendantNode.ts';
13
- import type { GeneralParentNode } from './hierarchy.ts';
14
- import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
15
- import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
16
- import type { ValueContext } from './internal-api/ValueContext.ts';
1
+ import { Accessor } from 'solid-js';
2
+ import { InputDefinition } from '../body/control/InputDefinition.ts';
3
+ import { StringNode, StringNodeAppearances } from '../client/StringNode.ts';
4
+ import { TextRange } from '../index.ts';
5
+ import { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
6
+ import { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
7
+ import { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
8
+ import { SimpleAtomicState } from '../lib/reactivity/types.ts';
9
+ import { ValueNodeDefinition } from '../model/ValueNodeDefinition.ts';
10
+ import { Root } from './Root.ts';
11
+ import { DescendantNodeStateSpec, DescendantNode } from './abstract/DescendantNode.ts';
12
+ import { GeneralParentNode } from './hierarchy.ts';
13
+ import { EvaluationContext } from './internal-api/EvaluationContext.ts';
14
+ import { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
15
+ import { ValueContext } from './internal-api/ValueContext.ts';
16
+
17
17
  export interface StringFieldDefinition extends ValueNodeDefinition {
18
18
  readonly bodyElement: InputDefinition | null;
19
19
  }
@@ -28,11 +28,11 @@ export declare class StringField extends DescendantNode<StringFieldDefinition, S
28
28
  protected readonly state: SharedNodeState<StringFieldStateSpec>;
29
29
  protected engineState: EngineState<StringFieldStateSpec>;
30
30
  readonly nodeType = "string";
31
+ readonly appearances: StringNodeAppearances;
31
32
  readonly currentState: CurrentState<StringFieldStateSpec>;
32
33
  readonly encodeValue: (value: string) => string;
33
34
  readonly decodeValue: (value: string) => string;
34
35
  constructor(parent: GeneralParentNode, definition: StringFieldDefinition);
35
- protected computeReference(parent: GeneralParentNode): string;
36
36
  getChildren(): readonly [];
37
37
  setValue(value: string): Root;
38
38
  }
@@ -1,15 +1,15 @@
1
- import { type Accessor } from 'solid-js';
2
- import type { SubtreeDefinition, SubtreeNode } from '../client/SubtreeNode.ts';
3
- import type { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
4
- import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
5
- import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
6
- import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
7
- import type { DescendantNodeSharedStateSpec } from './abstract/DescendantNode.ts';
8
- import { DescendantNode } from './abstract/DescendantNode.ts';
9
- import type { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
10
- import type { NodeID } from './identity.ts';
11
- import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
12
- import type { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
1
+ import { Accessor } from 'solid-js';
2
+ import { SubtreeDefinition, SubtreeNode } from '../client/SubtreeNode.ts';
3
+ import { MaterializedChildren } from '../lib/reactivity/materializeCurrentStateChildren.ts';
4
+ import { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
5
+ import { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
6
+ import { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
7
+ import { DescendantNodeSharedStateSpec, DescendantNode } from './abstract/DescendantNode.ts';
8
+ import { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
9
+ import { NodeID } from './identity.ts';
10
+ import { EvaluationContext } from './internal-api/EvaluationContext.ts';
11
+ import { SubscribableDependency } from './internal-api/SubscribableDependency.ts';
12
+
13
13
  interface SubtreeStateSpec extends DescendantNodeSharedStateSpec {
14
14
  readonly label: null;
15
15
  readonly hint: null;
@@ -22,9 +22,9 @@ export declare class Subtree extends DescendantNode<SubtreeDefinition, SubtreeSt
22
22
  protected readonly state: SharedNodeState<SubtreeStateSpec>;
23
23
  protected engineState: EngineState<SubtreeStateSpec>;
24
24
  readonly nodeType = "subtree";
25
+ readonly appearances: null;
25
26
  readonly currentState: MaterializedChildren<CurrentState<SubtreeStateSpec>, GeneralChildNode>;
26
27
  constructor(parent: GeneralParentNode, definition: SubtreeDefinition);
27
- protected computeReference(parent: GeneralParentNode): string;
28
28
  getChildren(): readonly GeneralChildNode[];
29
29
  }
30
30
  export {};
@@ -1,17 +1,17 @@
1
- import type { XFormsXPathEvaluator } from '@getodk/xpath';
2
- import type { Accessor } from 'solid-js';
3
- import type { BaseNode } from '../../client/BaseNode.ts';
4
- import type { AnyDescendantNodeDefinition } from '../../model/DescendentNodeDefinition.ts';
5
- import type { AnyNodeDefinition } from '../../model/NodeDefinition.ts';
6
- import type { RepeatInstanceDefinition } from '../../model/RepeatInstanceDefinition.ts';
7
- import type { ValueNodeDefinition } from '../../model/ValueNodeDefinition.ts';
8
- import type { RepeatRange } from '../RepeatRange.ts';
9
- import type { Root } from '../Root.ts';
10
- import type { AnyChildNode, GeneralParentNode } from '../hierarchy.ts';
11
- import type { EvaluationContext } from '../internal-api/EvaluationContext.ts';
12
- import type { SubscribableDependency } from '../internal-api/SubscribableDependency.ts';
13
- import type { InstanceNodeStateSpec } from './InstanceNode.ts';
14
- import { InstanceNode } from './InstanceNode.ts';
1
+ import { XFormsXPathEvaluator } from '@getodk/xpath';
2
+ import { Accessor } from 'solid-js';
3
+ import { BaseNode } from '../../client/BaseNode.ts';
4
+ import { AnyDescendantNodeDefinition } from '../../model/DescendentNodeDefinition.ts';
5
+ import { AnyNodeDefinition } from '../../model/NodeDefinition.ts';
6
+ import { RepeatInstanceDefinition } from '../../model/RepeatInstanceDefinition.ts';
7
+ import { ValueNodeDefinition } from '../../model/ValueNodeDefinition.ts';
8
+ import { RepeatRange } from '../RepeatRange.ts';
9
+ import { Root } from '../Root.ts';
10
+ import { AnyChildNode, GeneralParentNode } from '../hierarchy.ts';
11
+ import { EvaluationContext } from '../internal-api/EvaluationContext.ts';
12
+ import { SubscribableDependency } from '../internal-api/SubscribableDependency.ts';
13
+ import { InstanceNodeStateSpec, InstanceNode } from './InstanceNode.ts';
14
+
15
15
  export interface DescendantNodeSharedStateSpec {
16
16
  readonly reference: Accessor<string>;
17
17
  readonly readonly: Accessor<boolean>;
@@ -22,16 +22,23 @@ export type DescendantNodeStateSpec<Value = never> = InstanceNodeStateSpec<Value
22
22
  export type DescendantNodeDefinition = Extract<AnyNodeDefinition, AnyDescendantNodeDefinition>;
23
23
  export type DescendantNodeParent<Definition extends DescendantNodeDefinition> = Definition extends ValueNodeDefinition ? GeneralParentNode : Definition extends RepeatInstanceDefinition ? RepeatRange : GeneralParentNode;
24
24
  export type AnyDescendantNode = DescendantNode<DescendantNodeDefinition, DescendantNodeStateSpec<any>, any>;
25
+ interface DescendantNodeOptions {
26
+ readonly computeReference?: Accessor<string>;
27
+ }
25
28
  export declare abstract class DescendantNode<Definition extends DescendantNodeDefinition, Spec extends DescendantNodeStateSpec<any>, Child extends AnyChildNode | null = null> extends InstanceNode<Definition, Spec, Child> implements BaseNode, EvaluationContext, SubscribableDependency {
26
29
  readonly parent: DescendantNodeParent<Definition>;
27
30
  readonly definition: Definition;
31
+ readonly hasReadonlyAncestor: Accessor<boolean>;
32
+ readonly isSelfReadonly: Accessor<boolean>;
33
+ readonly isReadonly: Accessor<boolean>;
34
+ readonly hasNonRelevantAncestor: Accessor<boolean>;
35
+ readonly isSelfRelevant: Accessor<boolean>;
36
+ readonly isRelevant: Accessor<boolean>;
37
+ protected readonly isRequired: Accessor<boolean>;
28
38
  readonly root: Root;
29
39
  readonly evaluator: XFormsXPathEvaluator;
30
40
  readonly contextNode: Element;
31
- constructor(parent: DescendantNodeParent<Definition>, definition: Definition);
32
- protected computeChildStepReference(parent: DescendantNodeParent<Definition>): string;
33
- protected abstract computeReference(parent: DescendantNodeParent<Definition>, definition: Definition): string;
34
- protected buildSharedStateSpec(parent: DescendantNodeParent<Definition>, definition: Definition): DescendantNodeSharedStateSpec;
41
+ constructor(parent: DescendantNodeParent<Definition>, definition: Definition, options?: DescendantNodeOptions);
35
42
  protected createContextNode(parentContextNode: Element, nodeName: string): Element;
36
43
  /**
37
44
  * Currently expected to be overridden by...
@@ -74,3 +81,4 @@ export declare abstract class DescendantNode<Definition extends DescendantNodeDe
74
81
  */
75
82
  remove(this: AnyChildNode): void;
76
83
  }
84
+ export {};