@getodk/xforms-engine 0.14.0 → 0.16.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/client/AttributeNode.d.ts +50 -0
- package/dist/client/BaseNode.d.ts +5 -0
- package/dist/client/form/FormInstanceConfig.d.ts +15 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/node-types.d.ts +1 -1
- package/dist/client/validation.d.ts +7 -1
- package/dist/index.js +730 -294
- package/dist/index.js.map +1 -1
- package/dist/instance/Attribute.d.ts +64 -0
- package/dist/instance/Group.d.ts +2 -0
- package/dist/instance/InputControl.d.ts +2 -0
- package/dist/instance/PrimaryInstance.d.ts +2 -0
- package/dist/instance/Root.d.ts +2 -0
- package/dist/instance/UploadControl.d.ts +2 -0
- package/dist/instance/abstract/InstanceNode.d.ts +5 -2
- package/dist/instance/abstract/ValueNode.d.ts +2 -0
- package/dist/instance/attachments/buildAttributes.d.ts +7 -0
- package/dist/instance/internal-api/AttributeContext.d.ts +35 -0
- package/dist/instance/internal-api/InstanceConfig.d.ts +2 -0
- package/dist/instance/internal-api/InstanceValueContext.d.ts +6 -0
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableAttributeNode.d.ts +15 -0
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableParentNode.d.ts +2 -0
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableTemplatedNode.d.ts +2 -2
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableValueNode.d.ts +4 -0
- package/dist/instance/repeat/BaseRepeatRange.d.ts +5 -0
- package/dist/instance/repeat/RepeatInstance.d.ts +2 -2
- package/dist/integration/xpath/adapter/XFormsXPathNode.d.ts +2 -2
- package/dist/lib/client-reactivity/instance-state/createAttributeNodeInstanceState.d.ts +3 -0
- package/dist/lib/client-reactivity/instance-state/createTemplatedNodeInstanceState.d.ts +0 -3
- package/dist/lib/codecs/items/SingleValueItemCodec.d.ts +1 -1
- package/dist/lib/names/NamespaceDeclarationMap.d.ts +1 -1
- package/dist/lib/reactivity/createAttributeState.d.ts +16 -0
- package/dist/lib/reactivity/createInstanceValueState.d.ts +4 -1
- package/dist/lib/reactivity/node-state/createSharedNodeState.d.ts +2 -2
- package/dist/lib/xml-serialization.d.ts +5 -9
- package/dist/parse/XFormDOM.d.ts +4 -1
- package/dist/parse/expression/ActionComputationExpression.d.ts +4 -0
- package/dist/parse/model/ActionDefinition.d.ts +15 -0
- package/dist/parse/model/AttributeDefinition.d.ts +24 -0
- package/dist/parse/model/{RootAttributeMap.d.ts → AttributeDefinitionMap.d.ts} +4 -10
- package/dist/parse/model/BindPreloadDefinition.d.ts +6 -10
- package/dist/parse/model/Event.d.ts +8 -0
- package/dist/parse/model/GroupDefinition.d.ts +4 -1
- package/dist/parse/model/LeafNodeDefinition.d.ts +5 -1
- package/dist/parse/model/ModelActionMap.d.ts +9 -0
- package/dist/parse/model/ModelDefinition.d.ts +8 -1
- package/dist/parse/model/NodeDefinition.d.ts +8 -3
- package/dist/parse/model/NoteNodeDefinition.d.ts +3 -2
- package/dist/parse/model/RangeNodeDefinition.d.ts +2 -1
- package/dist/parse/model/RepeatDefinition.d.ts +4 -1
- package/dist/parse/model/RootDefinition.d.ts +3 -2
- package/dist/solid.js +730 -294
- package/dist/solid.js.map +1 -1
- package/package.json +21 -17
- package/src/client/AttributeNode.ts +59 -0
- package/src/client/BaseNode.ts +6 -0
- package/src/client/form/FormInstanceConfig.ts +17 -0
- package/src/client/index.ts +1 -0
- package/src/client/node-types.ts +1 -0
- package/src/client/validation.ts +9 -1
- package/src/entrypoints/FormInstance.ts +1 -0
- package/src/instance/Attribute.ts +164 -0
- package/src/instance/Group.ts +7 -0
- package/src/instance/InputControl.ts +8 -0
- package/src/instance/ModelValue.ts +7 -0
- package/src/instance/Note.ts +6 -0
- package/src/instance/PrimaryInstance.ts +7 -0
- package/src/instance/RangeControl.ts +6 -0
- package/src/instance/RankControl.ts +7 -0
- package/src/instance/Root.ts +7 -0
- package/src/instance/SelectControl.ts +6 -0
- package/src/instance/TriggerControl.ts +6 -0
- package/src/instance/UploadControl.ts +5 -0
- package/src/instance/abstract/DescendantNode.ts +0 -1
- package/src/instance/abstract/InstanceNode.ts +4 -1
- package/src/instance/abstract/ValueNode.ts +2 -0
- package/src/instance/attachments/buildAttributes.ts +15 -0
- package/src/instance/children/normalizeChildInitOptions.ts +1 -1
- package/src/instance/internal-api/AttributeContext.ts +40 -0
- package/src/instance/internal-api/InstanceConfig.ts +6 -1
- package/src/instance/internal-api/InstanceValueContext.ts +6 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableAttributeNode.ts +18 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableParentNode.ts +2 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableTemplatedNode.ts +2 -3
- package/src/instance/internal-api/serialization/ClientReactiveSerializableValueNode.ts +4 -0
- package/src/instance/repeat/BaseRepeatRange.ts +14 -0
- package/src/instance/repeat/RepeatInstance.ts +5 -5
- package/src/integration/xpath/adapter/XFormsXPathNode.ts +3 -1
- package/src/lib/client-reactivity/instance-state/createAttributeNodeInstanceState.ts +16 -0
- package/src/lib/client-reactivity/instance-state/createParentNodeInstanceState.ts +5 -5
- package/src/lib/client-reactivity/instance-state/createRootInstanceState.ts +6 -9
- package/src/lib/client-reactivity/instance-state/createTemplatedNodeInstanceState.ts +5 -15
- package/src/lib/client-reactivity/instance-state/createValueNodeInstanceState.ts +2 -1
- package/src/lib/client-reactivity/instance-state/prepareInstancePayload.ts +1 -0
- package/src/lib/codecs/NoteCodec.ts +1 -1
- package/src/lib/codecs/items/SingleValueItemCodec.ts +1 -3
- package/src/lib/names/NamespaceDeclarationMap.ts +1 -1
- package/src/lib/reactivity/createAttributeState.ts +51 -0
- package/src/lib/reactivity/createInstanceValueState.ts +152 -53
- package/src/lib/reactivity/node-state/createSharedNodeState.ts +2 -2
- package/src/lib/xml-serialization.ts +38 -34
- package/src/parse/XFormDOM.ts +9 -0
- package/src/parse/body/GroupElementDefinition.ts +1 -1
- package/src/parse/body/control/InputControlDefinition.ts +1 -1
- package/src/parse/expression/ActionComputationExpression.ts +12 -0
- package/src/parse/model/ActionDefinition.ts +70 -0
- package/src/parse/model/AttributeDefinition.ts +59 -0
- package/src/parse/model/{RootAttributeMap.ts → AttributeDefinitionMap.ts} +7 -13
- package/src/parse/model/BindDefinition.ts +1 -6
- package/src/parse/model/BindPreloadDefinition.ts +44 -12
- package/src/parse/model/Event.ts +9 -0
- package/src/parse/model/GroupDefinition.ts +6 -0
- package/src/parse/model/LeafNodeDefinition.ts +5 -0
- package/src/parse/model/ModelActionMap.ts +37 -0
- package/src/parse/model/ModelDefinition.ts +18 -3
- package/src/parse/model/NodeDefinition.ts +11 -3
- package/src/parse/model/NoteNodeDefinition.ts +5 -2
- package/src/parse/model/RangeNodeDefinition.ts +5 -2
- package/src/parse/model/RepeatDefinition.ts +8 -1
- package/src/parse/model/RootDefinition.ts +27 -9
- package/src/parse/model/nodeDefinitionMap.ts +1 -1
- package/dist/error/TemplatedNodeAttributeSerializationError.d.ts +0 -22
- package/dist/parse/model/RootAttributeDefinition.d.ts +0 -21
- package/src/error/TemplatedNodeAttributeSerializationError.ts +0 -24
- package/src/parse/model/RootAttributeDefinition.ts +0 -44
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { StaticElement } from '../../integration/xpath/static-dom/StaticElement.ts';
|
|
2
2
|
import { NamespaceDeclarationMap } from '../../lib/names/NamespaceDeclarationMap.ts';
|
|
3
3
|
import { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
4
|
-
import type { BodyClassList } from '../body/BodyDefinition.ts';
|
|
4
|
+
import type { AnyBodyElementDefinition, BodyClassList } from '../body/BodyDefinition.ts';
|
|
5
5
|
import type { XFormDefinition } from '../XFormDefinition.ts';
|
|
6
|
+
import { ActionDefinition } from './ActionDefinition.ts';
|
|
7
|
+
import { AttributeDefinitionMap } from './AttributeDefinitionMap.ts';
|
|
6
8
|
import { GroupDefinition } from './GroupDefinition.ts';
|
|
7
9
|
import { LeafNodeDefinition } from './LeafNodeDefinition.ts';
|
|
8
10
|
import type { ModelDefinition } from './ModelDefinition.ts';
|
|
@@ -11,7 +13,6 @@ import { NodeDefinition } from './NodeDefinition.ts';
|
|
|
11
13
|
import { NoteNodeDefinition } from './NoteNodeDefinition.ts';
|
|
12
14
|
import { RangeNodeDefinition } from './RangeNodeDefinition.ts';
|
|
13
15
|
import { RepeatDefinition } from './RepeatDefinition.ts';
|
|
14
|
-
import { RootAttributeMap } from './RootAttributeMap.ts';
|
|
15
16
|
import type { SubmissionDefinition } from './SubmissionDefinition.ts';
|
|
16
17
|
|
|
17
18
|
export class RootDefinition extends NodeDefinition<'root'> {
|
|
@@ -22,7 +23,7 @@ export class RootDefinition extends NodeDefinition<'root'> {
|
|
|
22
23
|
readonly parent = null;
|
|
23
24
|
readonly template: StaticElement;
|
|
24
25
|
readonly namespaceDeclarations: NamespaceDeclarationMap;
|
|
25
|
-
readonly attributes:
|
|
26
|
+
readonly attributes: AttributeDefinitionMap;
|
|
26
27
|
readonly children: readonly ChildNodeDefinition[];
|
|
27
28
|
|
|
28
29
|
readonly isTranslated = false;
|
|
@@ -51,11 +52,24 @@ export class RootDefinition extends NodeDefinition<'root'> {
|
|
|
51
52
|
|
|
52
53
|
this.qualifiedName = qualifiedName;
|
|
53
54
|
this.template = template;
|
|
54
|
-
this.attributes =
|
|
55
|
+
this.attributes = AttributeDefinitionMap.from(model, template);
|
|
55
56
|
this.namespaceDeclarations = new NamespaceDeclarationMap(this);
|
|
56
57
|
this.children = this.buildSubtree(this, template);
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
private mapActions(bodyElement: AnyBodyElementDefinition) {
|
|
61
|
+
const source = bodyElement.reference;
|
|
62
|
+
if (!source) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
for (const child of bodyElement.element.children) {
|
|
66
|
+
if (child.nodeName === 'setvalue') {
|
|
67
|
+
const action = new ActionDefinition(this.model, child, source);
|
|
68
|
+
this.model.actions.add(action);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
59
73
|
buildSubtree(parent: ParentNodeDefinition, node: StaticElement): readonly ChildNodeDefinition[] {
|
|
60
74
|
const { form, model } = this;
|
|
61
75
|
const { body } = form;
|
|
@@ -86,8 +100,12 @@ export class RootDefinition extends NodeDefinition<'root'> {
|
|
|
86
100
|
const bodyElement = body.getBodyElement(nodeset);
|
|
87
101
|
const [firstChild, ...restChildren] = children;
|
|
88
102
|
|
|
103
|
+
if (bodyElement) {
|
|
104
|
+
this.mapActions(bodyElement);
|
|
105
|
+
}
|
|
106
|
+
|
|
89
107
|
if (bodyElement?.type === 'repeat') {
|
|
90
|
-
return RepeatDefinition.from(parent, bind, bodyElement, children);
|
|
108
|
+
return RepeatDefinition.from(model, parent, bind, bodyElement, children);
|
|
91
109
|
}
|
|
92
110
|
|
|
93
111
|
if (restChildren.length) {
|
|
@@ -98,16 +116,16 @@ export class RootDefinition extends NodeDefinition<'root'> {
|
|
|
98
116
|
|
|
99
117
|
if (element.isLeafElement()) {
|
|
100
118
|
if (bodyElement?.type === 'range') {
|
|
101
|
-
return RangeNodeDefinition.from(parent, bind, bodyElement, element);
|
|
119
|
+
return RangeNodeDefinition.from(model, parent, bind, bodyElement, element);
|
|
102
120
|
}
|
|
103
121
|
|
|
104
122
|
return (
|
|
105
|
-
NoteNodeDefinition.from(parent, bind, bodyElement, element) ??
|
|
106
|
-
new LeafNodeDefinition(parent, bind, bodyElement, element)
|
|
123
|
+
NoteNodeDefinition.from(model, parent, bind, bodyElement, element) ??
|
|
124
|
+
new LeafNodeDefinition(model, parent, bind, bodyElement, element)
|
|
107
125
|
);
|
|
108
126
|
}
|
|
109
127
|
|
|
110
|
-
return new GroupDefinition(parent, bind, bodyElement, element);
|
|
128
|
+
return new GroupDefinition(model, parent, bind, bodyElement, element);
|
|
111
129
|
});
|
|
112
130
|
}
|
|
113
131
|
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This error class is intended as a common point of reference for all of the
|
|
3
|
-
* related interfaces and implementation where we've deferred two concerns:
|
|
4
|
-
*
|
|
5
|
-
* 1. Support for attributes on instance nodes (which may be bound in a form's
|
|
6
|
-
* model and/or may be expected to preserve model-defined defaults)
|
|
7
|
-
* 2. Present lack of logic to treat a `jr:template` attribute as a special
|
|
8
|
-
* case: whereas in the general case we would expect to pass through a
|
|
9
|
-
* form/model-defined attribute, we expect to specifically **omit**
|
|
10
|
-
* `jr:template` from repeat instances derived from any of form's
|
|
11
|
-
* explicitly-defined repeat templates
|
|
12
|
-
*
|
|
13
|
-
* Addressing #1 is (now) a prerequisite to addressing #2, and it is also a
|
|
14
|
-
* prerequisite for #2's unaddressed status to _become meaningfully observable
|
|
15
|
-
* and problematic_.
|
|
16
|
-
*
|
|
17
|
-
* By introducing this error at a point where a change in #1's status is likely
|
|
18
|
-
* to be implicated, we're also likely to be reminded to address #2 in tandem.
|
|
19
|
-
*/
|
|
20
|
-
export declare class TemplatedNodeAttributeSerializationError extends Error {
|
|
21
|
-
constructor();
|
|
22
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { NamedNodeDefinition } from '../../lib/names/NamespaceDeclarationMap.ts';
|
|
2
|
-
import { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
3
|
-
import { RootDefinition } from './RootDefinition.ts';
|
|
4
|
-
interface RootAttributeSource {
|
|
5
|
-
readonly qualifiedName: QualifiedName;
|
|
6
|
-
readonly value: string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* @todo This class is named and typed to emphasize its intentionally narrow
|
|
10
|
-
* usage and purpose. It **intentionally** avoids addressing the much broader
|
|
11
|
-
* set of concerns around modeling attributes in primary instance/submissions.
|
|
12
|
-
*/
|
|
13
|
-
export declare class RootAttributeDefinition implements NamedNodeDefinition {
|
|
14
|
-
private readonly serializedXML;
|
|
15
|
-
readonly parent: RootDefinition;
|
|
16
|
-
readonly qualifiedName: QualifiedName;
|
|
17
|
-
readonly value: string;
|
|
18
|
-
constructor(root: RootDefinition, source: RootAttributeSource);
|
|
19
|
-
serializeAttributeXML(): string;
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This error class is intended as a common point of reference for all of the
|
|
3
|
-
* related interfaces and implementation where we've deferred two concerns:
|
|
4
|
-
*
|
|
5
|
-
* 1. Support for attributes on instance nodes (which may be bound in a form's
|
|
6
|
-
* model and/or may be expected to preserve model-defined defaults)
|
|
7
|
-
* 2. Present lack of logic to treat a `jr:template` attribute as a special
|
|
8
|
-
* case: whereas in the general case we would expect to pass through a
|
|
9
|
-
* form/model-defined attribute, we expect to specifically **omit**
|
|
10
|
-
* `jr:template` from repeat instances derived from any of form's
|
|
11
|
-
* explicitly-defined repeat templates
|
|
12
|
-
*
|
|
13
|
-
* Addressing #1 is (now) a prerequisite to addressing #2, and it is also a
|
|
14
|
-
* prerequisite for #2's unaddressed status to _become meaningfully observable
|
|
15
|
-
* and problematic_.
|
|
16
|
-
*
|
|
17
|
-
* By introducing this error at a point where a change in #1's status is likely
|
|
18
|
-
* to be implicated, we're also likely to be reminded to address #2 in tandem.
|
|
19
|
-
*/
|
|
20
|
-
export class TemplatedNodeAttributeSerializationError extends Error {
|
|
21
|
-
constructor() {
|
|
22
|
-
super('Template attribute omission not implemented');
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { XMLNS_NAMESPACE_URI } from '@getodk/common/constants/xmlns.ts';
|
|
2
|
-
import type { NamedNodeDefinition } from '../../lib/names/NamespaceDeclarationMap.ts';
|
|
3
|
-
import { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
4
|
-
import { escapeXMLText } from '../../lib/xml-serialization.ts';
|
|
5
|
-
import type { RootDefinition } from './RootDefinition.ts';
|
|
6
|
-
|
|
7
|
-
interface RootAttributeSource {
|
|
8
|
-
readonly qualifiedName: QualifiedName;
|
|
9
|
-
readonly value: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @todo This class is named and typed to emphasize its intentionally narrow
|
|
14
|
-
* usage and purpose. It **intentionally** avoids addressing the much broader
|
|
15
|
-
* set of concerns around modeling attributes in primary instance/submissions.
|
|
16
|
-
*/
|
|
17
|
-
export class RootAttributeDefinition implements NamedNodeDefinition {
|
|
18
|
-
private readonly serializedXML: string;
|
|
19
|
-
|
|
20
|
-
readonly parent: RootDefinition;
|
|
21
|
-
readonly qualifiedName: QualifiedName;
|
|
22
|
-
readonly value: string;
|
|
23
|
-
|
|
24
|
-
constructor(root: RootDefinition, source: RootAttributeSource) {
|
|
25
|
-
const { qualifiedName, value } = source;
|
|
26
|
-
|
|
27
|
-
this.parent = root;
|
|
28
|
-
this.qualifiedName = qualifiedName;
|
|
29
|
-
this.value = value;
|
|
30
|
-
|
|
31
|
-
// We serialize namespace declarations separately
|
|
32
|
-
if (qualifiedName.namespaceURI?.href === XMLNS_NAMESPACE_URI) {
|
|
33
|
-
this.serializedXML = '';
|
|
34
|
-
} else {
|
|
35
|
-
const nodeName = qualifiedName.getPrefixedName();
|
|
36
|
-
|
|
37
|
-
this.serializedXML = ` ${nodeName}="${escapeXMLText(value, true)}"`;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
serializeAttributeXML(): string {
|
|
42
|
-
return this.serializedXML;
|
|
43
|
-
}
|
|
44
|
-
}
|