@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.
- package/dist/.vite/manifest.json +1 -0
- package/dist/XFormDOM.d.ts +1 -0
- package/dist/XFormDataType.d.ts +2 -1
- package/dist/XFormDefinition.d.ts +1 -0
- package/dist/body/BodyDefinition.d.ts +27 -9
- package/dist/body/BodyElementDefinition.d.ts +5 -4
- package/dist/body/RepeatElementDefinition.d.ts +19 -0
- package/dist/body/UnsupportedBodyElementDefinition.d.ts +3 -2
- package/dist/body/appearance/inputAppearanceParser.d.ts +4 -0
- package/dist/body/appearance/selectAppearanceParser.d.ts +4 -0
- package/dist/body/appearance/structureElementAppearanceParser.d.ts +4 -0
- package/dist/body/control/ControlDefinition.d.ts +5 -2
- package/dist/body/control/InputDefinition.d.ts +6 -0
- package/dist/body/control/select/ItemDefinition.d.ts +4 -3
- package/dist/body/control/select/ItemsetDefinition.d.ts +4 -3
- package/dist/body/control/select/ItemsetNodesetContext.d.ts +3 -2
- package/dist/body/control/select/ItemsetNodesetExpression.d.ts +2 -1
- package/dist/body/control/select/ItemsetValueExpression.d.ts +2 -1
- package/dist/body/control/select/SelectDefinition.d.ts +16 -5
- package/dist/body/group/BaseGroupDefinition.d.ts +6 -10
- package/dist/body/group/LogicalGroupDefinition.d.ts +1 -0
- package/dist/body/group/PresentationGroupDefinition.d.ts +3 -2
- package/dist/body/group/StructuralGroupDefinition.d.ts +1 -0
- package/dist/body/text/HintDefinition.d.ts +4 -4
- package/dist/body/text/LabelDefinition.d.ts +9 -7
- package/dist/body/text/TextElementDefinition.d.ts +9 -8
- package/dist/body/text/TextElementOutputPart.d.ts +2 -1
- package/dist/body/text/TextElementPart.d.ts +5 -4
- package/dist/body/text/TextElementReferencePart.d.ts +2 -1
- package/dist/body/text/TextElementStaticPart.d.ts +2 -1
- package/dist/client/BaseNode.d.ts +9 -3
- package/dist/client/EngineConfig.d.ts +2 -1
- package/dist/client/GroupNode.d.ts +10 -6
- package/dist/client/NodeAppearances.d.ts +15 -0
- package/dist/client/RepeatInstanceNode.d.ts +10 -6
- package/dist/client/RepeatRangeNode.d.ts +11 -7
- package/dist/client/RootNode.d.ts +24 -4
- package/dist/client/SelectNode.d.ts +10 -6
- package/dist/client/StringNode.d.ts +9 -5
- package/dist/client/SubtreeNode.d.ts +6 -4
- package/dist/client/TextRange.d.ts +2 -1
- package/dist/client/hierarchy.d.ts +9 -8
- package/dist/client/index.d.ts +3 -2
- package/dist/expression/DependencyContext.d.ts +2 -1
- package/dist/expression/DependentExpression.d.ts +3 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1882 -1757
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +15 -15
- package/dist/instance/RepeatInstance.d.ts +39 -15
- package/dist/instance/RepeatRange.d.ts +98 -20
- package/dist/instance/Root.d.ts +25 -39
- package/dist/instance/SelectField.d.ts +17 -17
- package/dist/instance/StringField.d.ts +17 -17
- package/dist/instance/Subtree.d.ts +13 -13
- package/dist/instance/abstract/DescendantNode.d.ts +26 -18
- package/dist/instance/abstract/InstanceNode.d.ts +44 -46
- package/dist/instance/children.d.ts +2 -1
- package/dist/instance/hierarchy.d.ts +8 -7
- package/dist/instance/index.d.ts +4 -3
- package/dist/instance/internal-api/EvaluationContext.d.ts +10 -8
- package/dist/instance/internal-api/InstanceConfig.d.ts +3 -2
- package/dist/instance/internal-api/SubscribableDependency.d.ts +2 -1
- package/dist/instance/internal-api/TranslationContext.d.ts +2 -1
- package/dist/instance/internal-api/ValueContext.d.ts +6 -5
- package/dist/instance/resource.d.ts +3 -2
- package/dist/instance/text/TextChunk.d.ts +4 -3
- package/dist/instance/text/TextRange.d.ts +2 -1
- package/dist/lib/TokenListParser.d.ts +84 -0
- package/dist/lib/dom/query.d.ts +8 -2
- package/dist/lib/reactivity/createChildrenState.d.ts +4 -3
- package/dist/lib/reactivity/createComputedExpression.d.ts +4 -3
- package/dist/lib/reactivity/createSelectItems.d.ts +4 -3
- package/dist/lib/reactivity/createValueState.d.ts +3 -2
- package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +6 -4
- package/dist/lib/reactivity/node-state/createClientState.d.ts +7 -6
- package/dist/lib/reactivity/node-state/createCurrentState.d.ts +5 -4
- package/dist/lib/reactivity/node-state/createEngineState.d.ts +4 -3
- package/dist/lib/reactivity/node-state/createSharedNodeState.d.ts +7 -6
- package/dist/lib/reactivity/node-state/createSpecifiedPropertyDescriptor.d.ts +2 -1
- package/dist/lib/reactivity/node-state/createSpecifiedState.d.ts +3 -2
- package/dist/lib/reactivity/node-state/representations.d.ts +2 -1
- package/dist/lib/reactivity/scope.d.ts +2 -1
- package/dist/lib/reactivity/text/createFieldHint.d.ts +4 -3
- package/dist/lib/reactivity/text/createNodeLabel.d.ts +4 -3
- package/dist/lib/reactivity/text/createTextRange.d.ts +6 -5
- package/dist/lib/reactivity/types.d.ts +2 -1
- package/dist/lib/xpath/analysis.d.ts +2 -1
- package/dist/model/BindComputation.d.ts +2 -1
- package/dist/model/BindDefinition.d.ts +6 -5
- package/dist/model/DescendentNodeDefinition.d.ts +6 -6
- package/dist/model/ModelBindMap.d.ts +4 -3
- package/dist/model/ModelDefinition.d.ts +2 -1
- package/dist/model/NodeDefinition.d.ts +20 -19
- package/dist/model/RepeatInstanceDefinition.d.ts +7 -7
- package/dist/model/{RepeatSequenceDefinition.d.ts → RepeatRangeDefinition.d.ts} +7 -6
- package/dist/model/RepeatTemplateDefinition.d.ts +8 -8
- package/dist/model/RootDefinition.d.ts +8 -5
- package/dist/model/SubtreeDefinition.d.ts +5 -4
- package/dist/model/ValueNodeDefinition.d.ts +5 -5
- package/dist/solid.js +1873 -1751
- package/dist/solid.js.map +1 -1
- package/package.json +14 -18
- package/src/XFormDOM.ts +81 -8
- package/src/body/BodyDefinition.ts +38 -23
- package/src/body/RepeatElementDefinition.ts +70 -0
- package/src/body/appearance/inputAppearanceParser.ts +39 -0
- package/src/body/appearance/selectAppearanceParser.ts +38 -0
- package/src/body/appearance/structureElementAppearanceParser.ts +7 -0
- package/src/body/control/ControlDefinition.ts +4 -0
- package/src/body/control/InputDefinition.ts +13 -0
- package/src/body/control/select/SelectDefinition.ts +14 -5
- package/src/body/group/BaseGroupDefinition.ts +11 -49
- package/src/body/text/LabelDefinition.ts +15 -1
- package/src/body/text/TextElementDefinition.ts +5 -5
- package/src/client/BaseNode.ts +9 -1
- package/src/client/GroupNode.ts +6 -2
- package/src/client/NodeAppearances.ts +22 -0
- package/src/client/RepeatInstanceNode.ts +4 -0
- package/src/client/RepeatRangeNode.ts +6 -2
- package/src/client/RootNode.ts +22 -0
- package/src/client/SelectNode.ts +4 -0
- package/src/client/StringNode.ts +4 -0
- package/src/client/SubtreeNode.ts +1 -0
- package/src/instance/Group.ts +14 -9
- package/src/instance/RepeatInstance.ts +59 -15
- package/src/instance/RepeatRange.ts +133 -15
- package/src/instance/Root.ts +20 -64
- package/src/instance/SelectField.ts +7 -7
- package/src/instance/StringField.ts +8 -7
- package/src/instance/Subtree.ts +10 -7
- package/src/instance/abstract/DescendantNode.ts +45 -43
- package/src/instance/abstract/InstanceNode.ts +69 -86
- package/src/instance/children.ts +17 -7
- package/src/instance/index.ts +1 -1
- package/src/instance/internal-api/EvaluationContext.ts +5 -6
- package/src/instance/internal-api/ValueContext.ts +2 -2
- package/src/lib/TokenListParser.ts +156 -0
- package/src/lib/dom/query.ts +13 -0
- package/src/lib/reactivity/createChildrenState.ts +51 -6
- package/src/lib/reactivity/createComputedExpression.ts +1 -1
- package/src/lib/reactivity/createSelectItems.ts +4 -6
- package/src/lib/reactivity/createValueState.ts +6 -6
- package/src/lib/reactivity/materializeCurrentStateChildren.ts +3 -1
- package/src/model/DescendentNodeDefinition.ts +1 -2
- package/src/model/ModelDefinition.ts +1 -1
- package/src/model/NodeDefinition.ts +12 -12
- package/src/model/RepeatInstanceDefinition.ts +8 -13
- package/src/model/{RepeatSequenceDefinition.ts → RepeatRangeDefinition.ts} +6 -6
- package/src/model/RepeatTemplateDefinition.ts +10 -15
- package/src/model/RootDefinition.ts +6 -12
- package/src/model/SubtreeDefinition.ts +3 -3
- package/src/model/ValueNodeDefinition.ts +2 -3
- package/dist/body/RepeatDefinition.d.ts +0 -15
- package/dist/body/group/RepeatGroupDefinition.d.ts +0 -12
- package/src/body/RepeatDefinition.ts +0 -54
- package/src/body/group/RepeatGroupDefinition.ts +0 -91
package/dist/instance/Group.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
|
|
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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
|
|
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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
|
|
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<
|
|
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:
|
|
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
|
/**
|
package/dist/instance/Root.d.ts
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
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
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
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
|
-
|
|
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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
|
|
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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
|
|
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 {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
|
|
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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
|
|
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 {};
|