@getodk/xforms-engine 0.14.0 → 0.15.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 +53 -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 +436 -164
- package/dist/index.js.map +1 -1
- package/dist/instance/Attribute.d.ts +58 -0
- package/dist/instance/Group.d.ts +4 -0
- package/dist/instance/PrimaryInstance.d.ts +4 -0
- package/dist/instance/Root.d.ts +4 -0
- package/dist/instance/UploadControl.d.ts +4 -0
- package/dist/instance/abstract/InstanceNode.d.ts +7 -4
- package/dist/instance/abstract/ValueNode.d.ts +1 -0
- package/dist/instance/attachments/buildAttributes.d.ts +3 -0
- package/dist/instance/hierarchy.d.ts +2 -1
- package/dist/instance/internal-api/AttributeContext.d.ts +29 -0
- package/dist/instance/internal-api/serialization/ClientReactiveSerializableAttributeNode.d.ts +16 -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/repeat/BaseRepeatRange.d.ts +5 -0
- package/dist/instance/repeat/RepeatInstance.d.ts +4 -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/names/NamespaceDeclarationMap.d.ts +1 -1
- package/dist/lib/reactivity/createAttributeState.d.ts +16 -0
- package/dist/lib/reactivity/createAttributeValueState.d.ts +15 -0
- package/dist/lib/xml-serialization.d.ts +5 -9
- package/dist/parse/XFormDOM.d.ts +1 -1
- package/dist/parse/model/AttributeDefinition.d.ts +22 -0
- package/dist/parse/model/{RootAttributeMap.d.ts → AttributeDefinitionMap.d.ts} +4 -10
- package/dist/parse/model/GroupDefinition.d.ts +4 -1
- package/dist/parse/model/LeafNodeDefinition.d.ts +1 -0
- package/dist/parse/model/NodeDefinition.d.ts +8 -3
- package/dist/parse/model/RepeatDefinition.d.ts +4 -1
- package/dist/parse/model/RootDefinition.d.ts +2 -2
- package/dist/solid.js +436 -164
- package/dist/solid.js.map +1 -1
- package/package.json +5 -5
- package/src/client/AttributeNode.ts +62 -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/instance/Attribute.ts +164 -0
- package/src/instance/Group.ts +16 -0
- package/src/instance/InputControl.ts +1 -0
- package/src/instance/ModelValue.ts +1 -0
- package/src/instance/Note.ts +1 -0
- package/src/instance/PrimaryInstance.ts +17 -0
- package/src/instance/RangeControl.ts +1 -0
- package/src/instance/RankControl.ts +1 -0
- package/src/instance/Root.ts +16 -0
- package/src/instance/SelectControl.ts +1 -0
- package/src/instance/TriggerControl.ts +1 -0
- package/src/instance/UploadControl.ts +14 -0
- package/src/instance/abstract/DescendantNode.ts +5 -1
- package/src/instance/abstract/InstanceNode.ts +6 -3
- package/src/instance/abstract/ValueNode.ts +1 -0
- package/src/instance/attachments/buildAttributes.ts +8 -0
- package/src/instance/hierarchy.ts +3 -1
- package/src/instance/internal-api/AttributeContext.ts +34 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableAttributeNode.ts +19 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableParentNode.ts +2 -0
- package/src/instance/internal-api/serialization/ClientReactiveSerializableTemplatedNode.ts +2 -3
- package/src/instance/repeat/BaseRepeatRange.ts +14 -0
- package/src/instance/repeat/RepeatInstance.ts +14 -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/names/NamespaceDeclarationMap.ts +1 -1
- package/src/lib/reactivity/createAttributeState.ts +51 -0
- package/src/lib/reactivity/createAttributeValueState.ts +189 -0
- package/src/lib/xml-serialization.ts +30 -34
- package/src/parse/model/AttributeDefinition.ts +58 -0
- package/src/parse/model/{RootAttributeMap.ts → AttributeDefinitionMap.ts} +7 -13
- package/src/parse/model/GroupDefinition.ts +6 -0
- package/src/parse/model/LeafNodeDefinition.ts +1 -0
- package/src/parse/model/NodeDefinition.ts +11 -3
- package/src/parse/model/RepeatDefinition.ts +8 -1
- package/src/parse/model/RootDefinition.ts +5 -5
- 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
package/dist/solid.js
CHANGED
|
@@ -7556,7 +7556,7 @@ const sn$1 = /*@__PURE__*/new WeakMap(),
|
|
|
7556
7556
|
epochMilliseconds: I$1,
|
|
7557
7557
|
epochNanoseconds: v$1
|
|
7558
7558
|
},
|
|
7559
|
-
[wn$1, In$1
|
|
7559
|
+
[wn$1, In$1] = createSlotClass$1(N$1, j$1, {
|
|
7560
7560
|
...gn$1,
|
|
7561
7561
|
blank: y$1
|
|
7562
7562
|
}, {
|
|
@@ -7641,7 +7641,7 @@ const sn$1 = /*@__PURE__*/new WeakMap(),
|
|
|
7641
7641
|
from: (t, e) => En$1(toPlainDateTimeSlots$1(t, e)),
|
|
7642
7642
|
compare: (t, e) => Yt$1(toPlainDateTimeSlots$1(t), toPlainDateTimeSlots$1(e))
|
|
7643
7643
|
}),
|
|
7644
|
-
[Ln$1, Vn$1
|
|
7644
|
+
[Ln$1, Vn$1] = createSlotClass$1(qt$1, Pt$1(kt$1, Mt$1), {
|
|
7645
7645
|
...Pn$1,
|
|
7646
7646
|
...Dn$1
|
|
7647
7647
|
}, {
|
|
@@ -7660,7 +7660,7 @@ const sn$1 = /*@__PURE__*/new WeakMap(),
|
|
|
7660
7660
|
}, {
|
|
7661
7661
|
from: (t, e) => Vn$1(toPlainMonthDaySlots$1(t, e))
|
|
7662
7662
|
}),
|
|
7663
|
-
[kn$1, qn$1
|
|
7663
|
+
[kn$1, qn$1] = createSlotClass$1(Ut$1, Pt$1(Qt$1, Mt$1), {
|
|
7664
7664
|
...Pn$1,
|
|
7665
7665
|
...hn$1
|
|
7666
7666
|
}, {
|
|
@@ -7684,7 +7684,7 @@ const sn$1 = /*@__PURE__*/new WeakMap(),
|
|
|
7684
7684
|
from: (t, e) => qn$1(toPlainYearMonthSlots$1(t, e)),
|
|
7685
7685
|
compare: (t, e) => te$1(toPlainYearMonthSlots$1(t), toPlainYearMonthSlots$1(e))
|
|
7686
7686
|
}),
|
|
7687
|
-
[xn$1, Wn$1
|
|
7687
|
+
[xn$1, Wn$1] = createSlotClass$1(G$1, Pt$1(ue$1, Mt$1), {
|
|
7688
7688
|
...Pn$1,
|
|
7689
7689
|
...Tn$1
|
|
7690
7690
|
}, {
|
|
@@ -7767,7 +7767,7 @@ const sn$1 = /*@__PURE__*/new WeakMap(),
|
|
|
7767
7767
|
from: (t, e) => $n$1(toZonedDateTimeSlots$1(t, e)),
|
|
7768
7768
|
compare: (t, e) => Be$1(toZonedDateTimeSlots$1(t), toZonedDateTimeSlots$1(e))
|
|
7769
7769
|
}),
|
|
7770
|
-
[Hn$1, Kn$1
|
|
7770
|
+
[Hn$1, Kn$1] = createSlotClass$1(Re$1, qe$1, On$1, {
|
|
7771
7771
|
add: (t, e) => Kn$1(Ye$1(0, t, toDurationSlots$1(e))),
|
|
7772
7772
|
subtract: (t, e) => Kn$1(Ye$1(1, t, toDurationSlots$1(e))),
|
|
7773
7773
|
until: (t, e, n) => In$1(Ee$1(0, t, toInstantSlots$1(e), n)),
|
|
@@ -21557,7 +21557,7 @@ const collectDefinitions = (result, definition) => {
|
|
|
21557
21557
|
throw new ErrorProductionDesignPendingError();
|
|
21558
21558
|
}
|
|
21559
21559
|
result.set(nodeset, definition);
|
|
21560
|
-
if (definition.type === "leaf-node") {
|
|
21560
|
+
if (definition.type === "leaf-node" || definition.type === "attribute") {
|
|
21561
21561
|
return result;
|
|
21562
21562
|
}
|
|
21563
21563
|
for (const child of definition.children) {
|
|
@@ -21612,33 +21612,33 @@ const serializeElementNamespaceDeclarationXML = (namespaceDeclarations) => {
|
|
|
21612
21612
|
});
|
|
21613
21613
|
}).join("");
|
|
21614
21614
|
};
|
|
21615
|
-
const
|
|
21616
|
-
if (attributes == null) {
|
|
21617
|
-
return "";
|
|
21618
|
-
}
|
|
21619
|
-
return attributes.map((attribute) => {
|
|
21620
|
-
return attribute.serializeAttributeXML();
|
|
21621
|
-
}).join("");
|
|
21622
|
-
};
|
|
21623
|
-
const serializeElementXML = (qualifiedName, children, options = {}) => {
|
|
21615
|
+
const serializeElementXML = (qualifiedName, children, attributes, namespaceDeclarations) => {
|
|
21624
21616
|
const nodeName = qualifiedName.getPrefixedName(
|
|
21625
21617
|
// options.namespaceDeclarations
|
|
21626
21618
|
);
|
|
21627
|
-
const
|
|
21628
|
-
|
|
21629
|
-
);
|
|
21630
|
-
const attributes = serializeElementAttributeXML(options.attributes);
|
|
21631
|
-
const prefix = `<${nodeName}${namespaceDeclarations}${attributes}`;
|
|
21619
|
+
const serializedNamespaceDeclarations = serializeElementNamespaceDeclarationXML(namespaceDeclarations);
|
|
21620
|
+
const prefix = `<${nodeName}${serializedNamespaceDeclarations}${attributes}`;
|
|
21632
21621
|
if (children === "") {
|
|
21633
21622
|
return `${prefix}/>`;
|
|
21634
21623
|
}
|
|
21635
21624
|
return `${prefix}>${children}</${nodeName}>`;
|
|
21636
21625
|
};
|
|
21637
|
-
const
|
|
21638
|
-
|
|
21626
|
+
const serializeAttributeXML = (qualifiedName, xmlValue) => {
|
|
21627
|
+
const nodeName = qualifiedName.getPrefixedName();
|
|
21628
|
+
return ` ${nodeName}="${xmlValue.normalize()}"`;
|
|
21629
|
+
};
|
|
21630
|
+
const serializeParentElementXML = (qualifiedName, children, attributes, namespaceDeclarations) => {
|
|
21631
|
+
const serializedChildren = children.map((child) => child.instanceState.instanceXML).join("");
|
|
21632
|
+
const serializedAttributes = attributes.map((attribute) => attribute.instanceState.instanceXML).join("");
|
|
21633
|
+
return serializeElementXML(
|
|
21634
|
+
qualifiedName,
|
|
21635
|
+
serializedChildren,
|
|
21636
|
+
serializedAttributes,
|
|
21637
|
+
namespaceDeclarations
|
|
21638
|
+
);
|
|
21639
21639
|
};
|
|
21640
|
-
const serializeLeafElementXML = (qualifiedName, xmlValue,
|
|
21641
|
-
return serializeElementXML(qualifiedName, xmlValue.normalize(),
|
|
21640
|
+
const serializeLeafElementXML = (qualifiedName, xmlValue, namespaceDeclarations) => {
|
|
21641
|
+
return serializeElementXML(qualifiedName, xmlValue.normalize(), "", namespaceDeclarations);
|
|
21642
21642
|
};
|
|
21643
21643
|
|
|
21644
21644
|
class NamespaceDeclaration {
|
|
@@ -21867,6 +21867,59 @@ class NodeDefinition {
|
|
|
21867
21867
|
nodeset;
|
|
21868
21868
|
}
|
|
21869
21869
|
|
|
21870
|
+
class AttributeDefinition extends NodeDefinition {
|
|
21871
|
+
constructor(root, bind, template) {
|
|
21872
|
+
super(bind);
|
|
21873
|
+
this.template = template;
|
|
21874
|
+
const { value } = template;
|
|
21875
|
+
this.root = root;
|
|
21876
|
+
this.value = value;
|
|
21877
|
+
this.qualifiedName = template.qualifiedName;
|
|
21878
|
+
this.namespaceDeclarations = new NamespaceDeclarationMap(this);
|
|
21879
|
+
if (this.qualifiedName.namespaceURI?.href === XMLNS_NAMESPACE_URI$1) {
|
|
21880
|
+
this.serializedXML = "";
|
|
21881
|
+
} else {
|
|
21882
|
+
const xmlValue = escapeXMLText(this.value, true);
|
|
21883
|
+
this.serializedXML = serializeAttributeXML(this.qualifiedName, xmlValue);
|
|
21884
|
+
}
|
|
21885
|
+
}
|
|
21886
|
+
serializedXML;
|
|
21887
|
+
value;
|
|
21888
|
+
type = "attribute";
|
|
21889
|
+
namespaceDeclarations;
|
|
21890
|
+
bodyElement = null;
|
|
21891
|
+
root;
|
|
21892
|
+
isTranslated = false;
|
|
21893
|
+
parent = null;
|
|
21894
|
+
children = null;
|
|
21895
|
+
attributes = null;
|
|
21896
|
+
qualifiedName;
|
|
21897
|
+
serializeAttributeXML() {
|
|
21898
|
+
return this.serializedXML;
|
|
21899
|
+
}
|
|
21900
|
+
}
|
|
21901
|
+
|
|
21902
|
+
const isNonNamespaceAttribute = (attribute) => {
|
|
21903
|
+
return attribute.qualifiedName.namespaceURI?.href !== XMLNS_NAMESPACE_URI$1;
|
|
21904
|
+
};
|
|
21905
|
+
class AttributeDefinitionMap extends Map {
|
|
21906
|
+
static from(model, instanceNode) {
|
|
21907
|
+
const nonNamespaceAttributes = instanceNode.attributes.filter(isNonNamespaceAttribute);
|
|
21908
|
+
const definitions = nonNamespaceAttributes.map((attribute) => {
|
|
21909
|
+
const bind = model.binds.getOrCreateBindDefinition(attribute.nodeset);
|
|
21910
|
+
return new AttributeDefinition(model.root, bind, attribute);
|
|
21911
|
+
});
|
|
21912
|
+
return new this(definitions);
|
|
21913
|
+
}
|
|
21914
|
+
constructor(definitions) {
|
|
21915
|
+
super(
|
|
21916
|
+
definitions.map((attribute) => {
|
|
21917
|
+
return [attribute.qualifiedName, attribute];
|
|
21918
|
+
})
|
|
21919
|
+
);
|
|
21920
|
+
}
|
|
21921
|
+
}
|
|
21922
|
+
|
|
21870
21923
|
class DescendentNodeDefinition extends NodeDefinition {
|
|
21871
21924
|
constructor(parent, bind, bodyElement) {
|
|
21872
21925
|
super(bind);
|
|
@@ -21882,7 +21935,7 @@ class DescendentNodeDefinition extends NodeDefinition {
|
|
|
21882
21935
|
}
|
|
21883
21936
|
|
|
21884
21937
|
class GroupDefinition extends DescendentNodeDefinition {
|
|
21885
|
-
constructor(parent, bind, bodyElement, template) {
|
|
21938
|
+
constructor(model, parent, bind, bodyElement, template) {
|
|
21886
21939
|
if (bodyElement != null && (bodyElement.category !== "structure" || bodyElement.type === "repeat")) {
|
|
21887
21940
|
throw new Error(`Unexpected body element for nodeset ${bind.nodeset}`);
|
|
21888
21941
|
}
|
|
@@ -21892,11 +21945,13 @@ class GroupDefinition extends DescendentNodeDefinition {
|
|
|
21892
21945
|
this.qualifiedName = template.qualifiedName;
|
|
21893
21946
|
this.namespaceDeclarations = new NamespaceDeclarationMap(this);
|
|
21894
21947
|
this.children = root.buildSubtree(this, template);
|
|
21948
|
+
this.attributes = AttributeDefinitionMap.from(model, template);
|
|
21895
21949
|
}
|
|
21896
21950
|
type = "group";
|
|
21897
21951
|
namespaceDeclarations;
|
|
21898
21952
|
qualifiedName;
|
|
21899
21953
|
children;
|
|
21954
|
+
attributes;
|
|
21900
21955
|
toJSON() {
|
|
21901
21956
|
const { parent, bodyElement, bind, root, ...rest } = this;
|
|
21902
21957
|
return rest;
|
|
@@ -21919,6 +21974,7 @@ class LeafNodeDefinition extends DescendentNodeDefinition {
|
|
|
21919
21974
|
namespaceDeclarations;
|
|
21920
21975
|
qualifiedName;
|
|
21921
21976
|
children = null;
|
|
21977
|
+
attributes = null;
|
|
21922
21978
|
toJSON() {
|
|
21923
21979
|
const { bind, bodyElement, parent, root, ...rest } = this;
|
|
21924
21980
|
return rest;
|
|
@@ -25575,7 +25631,7 @@ const sn = /*@__PURE__*/ new WeakMap, cn = /*@__PURE__*/ sn.get.bind(sn), un = /
|
|
|
25575
25631
|
}, gn = /*@__PURE__*/ g((t => e => e[t]), p.concat("sign")), pn = /*@__PURE__*/ g(((t, e) => t => t[w[e]]), O), On = {
|
|
25576
25632
|
epochMilliseconds: I,
|
|
25577
25633
|
epochNanoseconds: v
|
|
25578
|
-
}, [wn, In
|
|
25634
|
+
}, [wn, In] = createSlotClass(N, j, {
|
|
25579
25635
|
...gn,
|
|
25580
25636
|
blank: y
|
|
25581
25637
|
}, {
|
|
@@ -25649,7 +25705,7 @@ const sn = /*@__PURE__*/ new WeakMap, cn = /*@__PURE__*/ sn.get.bind(sn), un = /
|
|
|
25649
25705
|
}, {
|
|
25650
25706
|
from: (t, e) => En(toPlainDateTimeSlots(t, e)),
|
|
25651
25707
|
compare: (t, e) => Yt(toPlainDateTimeSlots(t), toPlainDateTimeSlots(e))
|
|
25652
|
-
}), [Ln, Vn
|
|
25708
|
+
}), [Ln, Vn] = createSlotClass(qt, Pt(kt, Mt), {
|
|
25653
25709
|
...Pn,
|
|
25654
25710
|
...Dn
|
|
25655
25711
|
}, {
|
|
@@ -25667,7 +25723,7 @@ const sn = /*@__PURE__*/ new WeakMap, cn = /*@__PURE__*/ sn.get.bind(sn), un = /
|
|
|
25667
25723
|
valueOf: neverValueOf
|
|
25668
25724
|
}, {
|
|
25669
25725
|
from: (t, e) => Vn(toPlainMonthDaySlots(t, e))
|
|
25670
|
-
}), [kn, qn
|
|
25726
|
+
}), [kn, qn] = createSlotClass(Ut, Pt(Qt, Mt), {
|
|
25671
25727
|
...Pn,
|
|
25672
25728
|
...hn
|
|
25673
25729
|
}, {
|
|
@@ -25690,7 +25746,7 @@ const sn = /*@__PURE__*/ new WeakMap, cn = /*@__PURE__*/ sn.get.bind(sn), un = /
|
|
|
25690
25746
|
}, {
|
|
25691
25747
|
from: (t, e) => qn(toPlainYearMonthSlots(t, e)),
|
|
25692
25748
|
compare: (t, e) => te(toPlainYearMonthSlots(t), toPlainYearMonthSlots(e))
|
|
25693
|
-
}), [xn, Wn
|
|
25749
|
+
}), [xn, Wn] = createSlotClass(G, Pt(ue, Mt), {
|
|
25694
25750
|
...Pn,
|
|
25695
25751
|
...Tn
|
|
25696
25752
|
}, {
|
|
@@ -25766,7 +25822,7 @@ const sn = /*@__PURE__*/ new WeakMap, cn = /*@__PURE__*/ sn.get.bind(sn), un = /
|
|
|
25766
25822
|
}, {
|
|
25767
25823
|
from: (t, e) => $n(toZonedDateTimeSlots(t, e)),
|
|
25768
25824
|
compare: (t, e) => Be(toZonedDateTimeSlots(t), toZonedDateTimeSlots(e))
|
|
25769
|
-
}), [Hn, Kn
|
|
25825
|
+
}), [Hn, Kn] = createSlotClass(Re, qe, On, {
|
|
25770
25826
|
add: (t, e) => Kn(Ye(0, t, toDurationSlots(e))),
|
|
25771
25827
|
subtract: (t, e) => Kn(Ye(1, t, toDurationSlots(e))),
|
|
25772
25828
|
until: (t, e, n) => In(Ee(0, t, toInstantSlots(e), n)),
|
|
@@ -26228,8 +26284,8 @@ const parseRepeatTemplateElement = (firstRepeatInstanceNode) => {
|
|
|
26228
26284
|
return cloneStaticElementStructure(firstRepeatInstanceNode);
|
|
26229
26285
|
};
|
|
26230
26286
|
class RepeatDefinition extends DescendentNodeDefinition {
|
|
26231
|
-
static from(parent, bind, bodyElement, instanceNodes) {
|
|
26232
|
-
return new this(parent, bind, bodyElement, instanceNodes);
|
|
26287
|
+
static from(model, parent, bind, bodyElement, instanceNodes) {
|
|
26288
|
+
return new this(model, parent, bind, bodyElement, instanceNodes);
|
|
26233
26289
|
}
|
|
26234
26290
|
type = "repeat";
|
|
26235
26291
|
children;
|
|
@@ -26237,7 +26293,8 @@ class RepeatDefinition extends DescendentNodeDefinition {
|
|
|
26237
26293
|
template;
|
|
26238
26294
|
namespaceDeclarations;
|
|
26239
26295
|
qualifiedName;
|
|
26240
|
-
|
|
26296
|
+
attributes;
|
|
26297
|
+
constructor(model, parent, bind, bodyElement, instanceNodes) {
|
|
26241
26298
|
super(parent, bind, bodyElement);
|
|
26242
26299
|
const { root } = parent;
|
|
26243
26300
|
const [instanceNode] = instanceNodes;
|
|
@@ -26248,6 +26305,7 @@ class RepeatDefinition extends DescendentNodeDefinition {
|
|
|
26248
26305
|
this.namespaceDeclarations = new NamespaceDeclarationMap(this);
|
|
26249
26306
|
this.children = root.buildSubtree(self, template);
|
|
26250
26307
|
const initialCount = this.omitTemplate(instanceNodes).length;
|
|
26308
|
+
this.attributes = AttributeDefinitionMap.from(model, template);
|
|
26251
26309
|
this.count = RepeatCountControlExpression.from(bodyElement, initialCount);
|
|
26252
26310
|
}
|
|
26253
26311
|
isControlled() {
|
|
@@ -26266,48 +26324,6 @@ class RepeatDefinition extends DescendentNodeDefinition {
|
|
|
26266
26324
|
}
|
|
26267
26325
|
}
|
|
26268
26326
|
|
|
26269
|
-
class RootAttributeDefinition {
|
|
26270
|
-
serializedXML;
|
|
26271
|
-
parent;
|
|
26272
|
-
qualifiedName;
|
|
26273
|
-
value;
|
|
26274
|
-
constructor(root, source) {
|
|
26275
|
-
const { qualifiedName, value } = source;
|
|
26276
|
-
this.parent = root;
|
|
26277
|
-
this.qualifiedName = qualifiedName;
|
|
26278
|
-
this.value = value;
|
|
26279
|
-
if (qualifiedName.namespaceURI?.href === XMLNS_NAMESPACE_URI$1) {
|
|
26280
|
-
this.serializedXML = "";
|
|
26281
|
-
} else {
|
|
26282
|
-
const nodeName = qualifiedName.getPrefixedName();
|
|
26283
|
-
this.serializedXML = ` ${nodeName}="${escapeXMLText(value, true)}"`;
|
|
26284
|
-
}
|
|
26285
|
-
}
|
|
26286
|
-
serializeAttributeXML() {
|
|
26287
|
-
return this.serializedXML;
|
|
26288
|
-
}
|
|
26289
|
-
}
|
|
26290
|
-
|
|
26291
|
-
const isNonNamespaceAttribute = (attribute) => {
|
|
26292
|
-
return attribute.qualifiedName.namespaceURI?.href !== XMLNS_NAMESPACE_URI$1;
|
|
26293
|
-
};
|
|
26294
|
-
class RootAttributeMap extends Map {
|
|
26295
|
-
static from(root, instanceNode) {
|
|
26296
|
-
const nonNamespaceAttributes = instanceNode.attributes.filter(isNonNamespaceAttribute);
|
|
26297
|
-
const definitions = nonNamespaceAttributes.map((attribute) => {
|
|
26298
|
-
return new RootAttributeDefinition(root, attribute);
|
|
26299
|
-
});
|
|
26300
|
-
return new this(definitions);
|
|
26301
|
-
}
|
|
26302
|
-
constructor(definitions) {
|
|
26303
|
-
super(
|
|
26304
|
-
definitions.map((attribute) => {
|
|
26305
|
-
return [attribute.qualifiedName, attribute];
|
|
26306
|
-
})
|
|
26307
|
-
);
|
|
26308
|
-
}
|
|
26309
|
-
}
|
|
26310
|
-
|
|
26311
26327
|
class RootDefinition extends NodeDefinition {
|
|
26312
26328
|
constructor(form, model, submission, classes) {
|
|
26313
26329
|
const template = model.instance.root;
|
|
@@ -26325,7 +26341,7 @@ class RootDefinition extends NodeDefinition {
|
|
|
26325
26341
|
this.classes = classes;
|
|
26326
26342
|
this.qualifiedName = qualifiedName;
|
|
26327
26343
|
this.template = template;
|
|
26328
|
-
this.attributes =
|
|
26344
|
+
this.attributes = AttributeDefinitionMap.from(model, template);
|
|
26329
26345
|
this.namespaceDeclarations = new NamespaceDeclarationMap(this);
|
|
26330
26346
|
this.children = this.buildSubtree(this, template);
|
|
26331
26347
|
}
|
|
@@ -26362,7 +26378,7 @@ class RootDefinition extends NodeDefinition {
|
|
|
26362
26378
|
const bodyElement = body.getBodyElement(nodeset);
|
|
26363
26379
|
const [firstChild, ...restChildren] = children;
|
|
26364
26380
|
if (bodyElement?.type === "repeat") {
|
|
26365
|
-
return RepeatDefinition.from(parent, bind, bodyElement, children);
|
|
26381
|
+
return RepeatDefinition.from(model, parent, bind, bodyElement, children);
|
|
26366
26382
|
}
|
|
26367
26383
|
if (restChildren.length) {
|
|
26368
26384
|
throw new Error(`Unexpected: multiple elements for non-repeat nodeset: ${nodeset}`);
|
|
@@ -26374,7 +26390,7 @@ class RootDefinition extends NodeDefinition {
|
|
|
26374
26390
|
}
|
|
26375
26391
|
return NoteNodeDefinition.from(parent, bind, bodyElement, element) ?? new LeafNodeDefinition(parent, bind, bodyElement, element);
|
|
26376
26392
|
}
|
|
26377
|
-
return new GroupDefinition(parent, bind, bodyElement, element);
|
|
26393
|
+
return new GroupDefinition(model, parent, bind, bodyElement, element);
|
|
26378
26394
|
});
|
|
26379
26395
|
}
|
|
26380
26396
|
toJSON() {
|
|
@@ -28544,6 +28560,30 @@ const prepareInstancePayload = (instanceRoot, options) => {
|
|
|
28544
28560
|
}
|
|
28545
28561
|
};
|
|
28546
28562
|
|
|
28563
|
+
const createAttributeState = (scope) => {
|
|
28564
|
+
return scope.runTask(() => {
|
|
28565
|
+
const baseState = createSignal([]);
|
|
28566
|
+
const [getAttributes, baseSetAttributes] = baseState;
|
|
28567
|
+
const setAttributes = (valueOrSetterCallback) => {
|
|
28568
|
+
let setterCallback;
|
|
28569
|
+
if (typeof valueOrSetterCallback === "function") {
|
|
28570
|
+
setterCallback = valueOrSetterCallback;
|
|
28571
|
+
} else {
|
|
28572
|
+
setterCallback = (_) => valueOrSetterCallback;
|
|
28573
|
+
}
|
|
28574
|
+
return baseSetAttributes((prev) => {
|
|
28575
|
+
return setterCallback(prev);
|
|
28576
|
+
});
|
|
28577
|
+
};
|
|
28578
|
+
const attributes = [getAttributes, setAttributes];
|
|
28579
|
+
return {
|
|
28580
|
+
attributes,
|
|
28581
|
+
getAttributes,
|
|
28582
|
+
setAttributes
|
|
28583
|
+
};
|
|
28584
|
+
});
|
|
28585
|
+
};
|
|
28586
|
+
|
|
28547
28587
|
const createChildrenState = (parent) => {
|
|
28548
28588
|
return parent.scope.runTask(() => {
|
|
28549
28589
|
const baseState = createSignal([]);
|
|
@@ -28856,6 +28896,249 @@ class InstanceNode {
|
|
|
28856
28896
|
}
|
|
28857
28897
|
}
|
|
28858
28898
|
|
|
28899
|
+
const createAttributeNodeInstanceState = (node) => {
|
|
28900
|
+
const { qualifiedName } = node.definition;
|
|
28901
|
+
return {
|
|
28902
|
+
get instanceXML() {
|
|
28903
|
+
const xmlValue = escapeXMLText(node.currentState.instanceValue, true);
|
|
28904
|
+
return serializeAttributeXML(qualifiedName, xmlValue);
|
|
28905
|
+
}
|
|
28906
|
+
};
|
|
28907
|
+
};
|
|
28908
|
+
|
|
28909
|
+
const expressionEvaluator = (evaluator, type, expression, options) => {
|
|
28910
|
+
switch (type) {
|
|
28911
|
+
case "boolean":
|
|
28912
|
+
return () => {
|
|
28913
|
+
return evaluator.evaluateBoolean(expression, options);
|
|
28914
|
+
};
|
|
28915
|
+
case "nodes":
|
|
28916
|
+
return () => {
|
|
28917
|
+
return evaluator.evaluateNodes(expression, options);
|
|
28918
|
+
};
|
|
28919
|
+
case "number":
|
|
28920
|
+
return () => {
|
|
28921
|
+
return evaluator.evaluateNumber(expression, options);
|
|
28922
|
+
};
|
|
28923
|
+
case "string":
|
|
28924
|
+
return () => {
|
|
28925
|
+
return evaluator.evaluateString(expression, options);
|
|
28926
|
+
};
|
|
28927
|
+
default:
|
|
28928
|
+
throw new UnreachableError$1(type);
|
|
28929
|
+
}
|
|
28930
|
+
};
|
|
28931
|
+
const DEFAULT_BOOLEAN_EVALUATION = false;
|
|
28932
|
+
const DEFAULT_NODES_EVALUATION = [];
|
|
28933
|
+
const DEFAULT_NUMBER_EVALUATION = NaN;
|
|
28934
|
+
const DEFAULT_STRING_EVALUATION = "";
|
|
28935
|
+
const defaultEvaluationsByType = {
|
|
28936
|
+
boolean: DEFAULT_BOOLEAN_EVALUATION,
|
|
28937
|
+
nodes: DEFAULT_NODES_EVALUATION,
|
|
28938
|
+
number: DEFAULT_NUMBER_EVALUATION,
|
|
28939
|
+
string: DEFAULT_STRING_EVALUATION
|
|
28940
|
+
};
|
|
28941
|
+
const createComputedExpression = (context, dependentExpression, options = {}) => {
|
|
28942
|
+
return context.scope.runTask(() => {
|
|
28943
|
+
const { contextNode, evaluator } = context;
|
|
28944
|
+
const { expression, isTranslated, resultType } = dependentExpression;
|
|
28945
|
+
const evaluatePreInitializationDefaultValue = () => {
|
|
28946
|
+
return options?.defaultValue ?? defaultEvaluationsByType[resultType];
|
|
28947
|
+
};
|
|
28948
|
+
const evaluateExpression = expressionEvaluator(evaluator, resultType, expression, {
|
|
28949
|
+
contextNode
|
|
28950
|
+
});
|
|
28951
|
+
if (isConstantExpression(expression)) {
|
|
28952
|
+
return createMemo(evaluateExpression);
|
|
28953
|
+
}
|
|
28954
|
+
return createMemo(() => {
|
|
28955
|
+
if (!context.isAttached()) {
|
|
28956
|
+
return evaluatePreInitializationDefaultValue();
|
|
28957
|
+
}
|
|
28958
|
+
if (isTranslated) {
|
|
28959
|
+
context.getActiveLanguage();
|
|
28960
|
+
}
|
|
28961
|
+
return evaluateExpression();
|
|
28962
|
+
});
|
|
28963
|
+
});
|
|
28964
|
+
};
|
|
28965
|
+
|
|
28966
|
+
const isInstanceFirstLoad$1 = (context) => {
|
|
28967
|
+
return context.rootDocument.initializationMode === "create";
|
|
28968
|
+
};
|
|
28969
|
+
const isEditInitialLoad$1 = (context) => {
|
|
28970
|
+
return context.rootDocument.initializationMode === "edit";
|
|
28971
|
+
};
|
|
28972
|
+
const getInitialValue$1 = (context) => {
|
|
28973
|
+
const sourceNode = context.instanceNode ?? context.definition.template;
|
|
28974
|
+
return context.decodeInstanceValue(sourceNode.value);
|
|
28975
|
+
};
|
|
28976
|
+
const createRelevantValueState$1 = (context, baseValueState) => {
|
|
28977
|
+
return context.scope.runTask(() => {
|
|
28978
|
+
const [getRelevantValue, setValue] = baseValueState;
|
|
28979
|
+
const getValue = createMemo(() => {
|
|
28980
|
+
if (context.isRelevant()) {
|
|
28981
|
+
return getRelevantValue();
|
|
28982
|
+
}
|
|
28983
|
+
return "";
|
|
28984
|
+
});
|
|
28985
|
+
return [getValue, setValue];
|
|
28986
|
+
});
|
|
28987
|
+
};
|
|
28988
|
+
const guardDownstreamReadonlyWrites$1 = (context, baseState) => {
|
|
28989
|
+
const { readonly } = context.definition.bind;
|
|
28990
|
+
if (readonly.isDefaultExpression) {
|
|
28991
|
+
return baseState;
|
|
28992
|
+
}
|
|
28993
|
+
const [getValue, baseSetValue] = baseState;
|
|
28994
|
+
const setValue = (value) => {
|
|
28995
|
+
if (context.isReadonly()) {
|
|
28996
|
+
const reference = untrack(() => context.contextReference());
|
|
28997
|
+
throw new Error(`Cannot write to readonly field: ${reference}`);
|
|
28998
|
+
}
|
|
28999
|
+
return baseSetValue(value);
|
|
29000
|
+
};
|
|
29001
|
+
return [getValue, setValue];
|
|
29002
|
+
};
|
|
29003
|
+
const PRELOAD_UID_EXPRESSION$1 = 'concat("uuid:", uuid())';
|
|
29004
|
+
const shouldPreloadUID$1 = (context) => {
|
|
29005
|
+
return isInstanceFirstLoad$1(context) || isEditInitialLoad$1(context);
|
|
29006
|
+
};
|
|
29007
|
+
const setPreloadUIDValue$1 = (context, valueState) => {
|
|
29008
|
+
const { preload } = context.definition.bind;
|
|
29009
|
+
if (preload?.type !== "uid" || !shouldPreloadUID$1(context)) {
|
|
29010
|
+
return;
|
|
29011
|
+
}
|
|
29012
|
+
const preloadUIDValue = context.evaluator.evaluateString(PRELOAD_UID_EXPRESSION$1, {
|
|
29013
|
+
contextNode: context.contextNode
|
|
29014
|
+
});
|
|
29015
|
+
const [, setValue] = valueState;
|
|
29016
|
+
setValue(preloadUIDValue);
|
|
29017
|
+
};
|
|
29018
|
+
const createCalculation$1 = (context, setRelevantValue, calculateDefinition) => {
|
|
29019
|
+
context.scope.runTask(() => {
|
|
29020
|
+
const calculate = createComputedExpression(context, calculateDefinition, {
|
|
29021
|
+
defaultValue: ""
|
|
29022
|
+
});
|
|
29023
|
+
createComputed(() => {
|
|
29024
|
+
if (context.isAttached() && context.isRelevant()) {
|
|
29025
|
+
const calculated = calculate();
|
|
29026
|
+
const value = context.decodeInstanceValue(calculated);
|
|
29027
|
+
setRelevantValue(value);
|
|
29028
|
+
}
|
|
29029
|
+
});
|
|
29030
|
+
});
|
|
29031
|
+
};
|
|
29032
|
+
const createAttributeValueState = (context) => {
|
|
29033
|
+
return context.scope.runTask(() => {
|
|
29034
|
+
const initialValue = getInitialValue$1(context);
|
|
29035
|
+
const baseValueState = createSignal(initialValue);
|
|
29036
|
+
const relevantValueState = createRelevantValueState$1(context, baseValueState);
|
|
29037
|
+
setPreloadUIDValue$1(context, relevantValueState);
|
|
29038
|
+
const { calculate } = context.definition.bind;
|
|
29039
|
+
if (calculate != null) {
|
|
29040
|
+
const [, setValue] = relevantValueState;
|
|
29041
|
+
createCalculation$1(context, setValue, calculate);
|
|
29042
|
+
}
|
|
29043
|
+
return guardDownstreamReadonlyWrites$1(context, relevantValueState);
|
|
29044
|
+
});
|
|
29045
|
+
};
|
|
29046
|
+
|
|
29047
|
+
class Attribute extends InstanceNode {
|
|
29048
|
+
constructor(parent, definition, instanceNode) {
|
|
29049
|
+
const codec = getSharedValueCodec("string");
|
|
29050
|
+
super(parent.instanceConfig, parent, instanceNode, definition, {
|
|
29051
|
+
scope: parent.scope,
|
|
29052
|
+
computeReference: () => "@" + this.definition.qualifiedName.getPrefixedName()
|
|
29053
|
+
});
|
|
29054
|
+
this.instanceNode = instanceNode;
|
|
29055
|
+
this.root = parent.root;
|
|
29056
|
+
this.getActiveLanguage = parent.getActiveLanguage;
|
|
29057
|
+
this.validationState = { violations: [] };
|
|
29058
|
+
this.valueType = "string";
|
|
29059
|
+
this.evaluator = parent.evaluator;
|
|
29060
|
+
this.decodeInstanceValue = codec.decodeInstanceValue;
|
|
29061
|
+
const instanceValueState = createAttributeValueState(this);
|
|
29062
|
+
const valueState = codec.createRuntimeValueState(instanceValueState);
|
|
29063
|
+
const [getInstanceValue] = instanceValueState;
|
|
29064
|
+
const [, setValueState] = valueState;
|
|
29065
|
+
this.getInstanceValue = getInstanceValue;
|
|
29066
|
+
this.setValueState = setValueState;
|
|
29067
|
+
this.getXPathValue = () => {
|
|
29068
|
+
return this.getInstanceValue();
|
|
29069
|
+
};
|
|
29070
|
+
this.valueState = valueState;
|
|
29071
|
+
const state = createSharedNodeState(
|
|
29072
|
+
this.scope,
|
|
29073
|
+
{
|
|
29074
|
+
reference: this.contextReference,
|
|
29075
|
+
readonly: this.isReadonly,
|
|
29076
|
+
relevant: this.isRelevant,
|
|
29077
|
+
required: () => false,
|
|
29078
|
+
label: null,
|
|
29079
|
+
hint: null,
|
|
29080
|
+
children: null,
|
|
29081
|
+
valueOptions: null,
|
|
29082
|
+
value: this.valueState,
|
|
29083
|
+
instanceValue: this.getInstanceValue,
|
|
29084
|
+
attributes: null
|
|
29085
|
+
},
|
|
29086
|
+
this.instanceConfig
|
|
29087
|
+
);
|
|
29088
|
+
this.state = state;
|
|
29089
|
+
this.engineState = state.engineState;
|
|
29090
|
+
this.currentState = state.currentState;
|
|
29091
|
+
this.instanceState = createAttributeNodeInstanceState(this);
|
|
29092
|
+
}
|
|
29093
|
+
[XPathNodeKindKey] = "attribute";
|
|
29094
|
+
state;
|
|
29095
|
+
engineState;
|
|
29096
|
+
validationState;
|
|
29097
|
+
nodeType = "attribute";
|
|
29098
|
+
currentState;
|
|
29099
|
+
instanceState;
|
|
29100
|
+
appearances = null;
|
|
29101
|
+
nodeOptions = null;
|
|
29102
|
+
valueType;
|
|
29103
|
+
decodeInstanceValue;
|
|
29104
|
+
getInstanceValue;
|
|
29105
|
+
valueState;
|
|
29106
|
+
setValueState;
|
|
29107
|
+
evaluator;
|
|
29108
|
+
getActiveLanguage;
|
|
29109
|
+
root;
|
|
29110
|
+
isRelevant = () => {
|
|
29111
|
+
return this.parent.isRelevant();
|
|
29112
|
+
};
|
|
29113
|
+
isAttached = () => {
|
|
29114
|
+
return this.parent.isAttached();
|
|
29115
|
+
};
|
|
29116
|
+
isReadonly = () => {
|
|
29117
|
+
return true;
|
|
29118
|
+
};
|
|
29119
|
+
hasReadonlyAncestor = () => {
|
|
29120
|
+
const { parent } = this;
|
|
29121
|
+
return parent.hasReadonlyAncestor() || parent.isReadonly();
|
|
29122
|
+
};
|
|
29123
|
+
hasNonRelevantAncestor = () => {
|
|
29124
|
+
const { parent } = this;
|
|
29125
|
+
return parent.hasNonRelevantAncestor() || !parent.isRelevant();
|
|
29126
|
+
};
|
|
29127
|
+
setValue(value) {
|
|
29128
|
+
this.setValueState(value);
|
|
29129
|
+
return this.root;
|
|
29130
|
+
}
|
|
29131
|
+
getChildren() {
|
|
29132
|
+
return [];
|
|
29133
|
+
}
|
|
29134
|
+
}
|
|
29135
|
+
|
|
29136
|
+
function buildAttributes(parent) {
|
|
29137
|
+
return Array.from(parent.definition.attributes.values()).map((attributeDefinition) => {
|
|
29138
|
+
return new Attribute(parent, attributeDefinition, attributeDefinition.template);
|
|
29139
|
+
});
|
|
29140
|
+
}
|
|
29141
|
+
|
|
28859
29142
|
class InstanceAttachmentsState extends Map {
|
|
28860
29143
|
constructor(sourceAttachments = null) {
|
|
28861
29144
|
super();
|
|
@@ -28872,14 +29155,12 @@ class InstanceAttachmentsState extends Map {
|
|
|
28872
29155
|
const createRootInstanceState = (node) => {
|
|
28873
29156
|
return {
|
|
28874
29157
|
get instanceXML() {
|
|
28875
|
-
|
|
28876
|
-
|
|
28877
|
-
|
|
28878
|
-
|
|
28879
|
-
|
|
28880
|
-
|
|
28881
|
-
attributes: Array.from(attributes.values())
|
|
28882
|
-
});
|
|
29158
|
+
return serializeParentElementXML(
|
|
29159
|
+
node.definition.qualifiedName,
|
|
29160
|
+
node.currentState.children,
|
|
29161
|
+
node.currentState.attributes,
|
|
29162
|
+
node.definition.namespaceDeclarations
|
|
29163
|
+
);
|
|
28883
29164
|
}
|
|
28884
29165
|
};
|
|
28885
29166
|
};
|
|
@@ -28933,63 +29214,6 @@ const createAggregatedViolations = (context, options) => {
|
|
|
28933
29214
|
|
|
28934
29215
|
const XFORMS_XPATH_NODE_RANGE_KIND = "comment";
|
|
28935
29216
|
|
|
28936
|
-
const expressionEvaluator = (evaluator, type, expression, options) => {
|
|
28937
|
-
switch (type) {
|
|
28938
|
-
case "boolean":
|
|
28939
|
-
return () => {
|
|
28940
|
-
return evaluator.evaluateBoolean(expression, options);
|
|
28941
|
-
};
|
|
28942
|
-
case "nodes":
|
|
28943
|
-
return () => {
|
|
28944
|
-
return evaluator.evaluateNodes(expression, options);
|
|
28945
|
-
};
|
|
28946
|
-
case "number":
|
|
28947
|
-
return () => {
|
|
28948
|
-
return evaluator.evaluateNumber(expression, options);
|
|
28949
|
-
};
|
|
28950
|
-
case "string":
|
|
28951
|
-
return () => {
|
|
28952
|
-
return evaluator.evaluateString(expression, options);
|
|
28953
|
-
};
|
|
28954
|
-
default:
|
|
28955
|
-
throw new UnreachableError$1(type);
|
|
28956
|
-
}
|
|
28957
|
-
};
|
|
28958
|
-
const DEFAULT_BOOLEAN_EVALUATION = false;
|
|
28959
|
-
const DEFAULT_NODES_EVALUATION = [];
|
|
28960
|
-
const DEFAULT_NUMBER_EVALUATION = NaN;
|
|
28961
|
-
const DEFAULT_STRING_EVALUATION = "";
|
|
28962
|
-
const defaultEvaluationsByType = {
|
|
28963
|
-
boolean: DEFAULT_BOOLEAN_EVALUATION,
|
|
28964
|
-
nodes: DEFAULT_NODES_EVALUATION,
|
|
28965
|
-
number: DEFAULT_NUMBER_EVALUATION,
|
|
28966
|
-
string: DEFAULT_STRING_EVALUATION
|
|
28967
|
-
};
|
|
28968
|
-
const createComputedExpression = (context, dependentExpression, options = {}) => {
|
|
28969
|
-
return context.scope.runTask(() => {
|
|
28970
|
-
const { contextNode, evaluator } = context;
|
|
28971
|
-
const { expression, isTranslated, resultType } = dependentExpression;
|
|
28972
|
-
const evaluatePreInitializationDefaultValue = () => {
|
|
28973
|
-
return options?.defaultValue ?? defaultEvaluationsByType[resultType];
|
|
28974
|
-
};
|
|
28975
|
-
const evaluateExpression = expressionEvaluator(evaluator, resultType, expression, {
|
|
28976
|
-
contextNode
|
|
28977
|
-
});
|
|
28978
|
-
if (isConstantExpression(expression)) {
|
|
28979
|
-
return createMemo(evaluateExpression);
|
|
28980
|
-
}
|
|
28981
|
-
return createMemo(() => {
|
|
28982
|
-
if (!context.isAttached()) {
|
|
28983
|
-
return evaluatePreInitializationDefaultValue();
|
|
28984
|
-
}
|
|
28985
|
-
if (isTranslated) {
|
|
28986
|
-
context.getActiveLanguage();
|
|
28987
|
-
}
|
|
28988
|
-
return evaluateExpression();
|
|
28989
|
-
});
|
|
28990
|
-
});
|
|
28991
|
-
};
|
|
28992
|
-
|
|
28993
29217
|
class DescendantNode extends InstanceNode {
|
|
28994
29218
|
constructor(parent, instanceNode, definition, options) {
|
|
28995
29219
|
super(parent.instanceConfig, parent, instanceNode, definition, options);
|
|
@@ -29015,6 +29239,11 @@ class DescendantNode extends InstanceNode {
|
|
|
29015
29239
|
return true;
|
|
29016
29240
|
}
|
|
29017
29241
|
}
|
|
29242
|
+
for (const attr of parent.getAttributes()) {
|
|
29243
|
+
if (attr === self) {
|
|
29244
|
+
return true;
|
|
29245
|
+
}
|
|
29246
|
+
}
|
|
29018
29247
|
return false;
|
|
29019
29248
|
});
|
|
29020
29249
|
});
|
|
@@ -29126,10 +29355,11 @@ const createParentNodeInstanceState = (node) => {
|
|
|
29126
29355
|
if (!node.currentState.relevant) {
|
|
29127
29356
|
return "";
|
|
29128
29357
|
}
|
|
29129
|
-
|
|
29130
|
-
|
|
29131
|
-
|
|
29132
|
-
|
|
29358
|
+
return serializeParentElementXML(
|
|
29359
|
+
node.definition.qualifiedName,
|
|
29360
|
+
node.currentState.children,
|
|
29361
|
+
node.currentState.attributes
|
|
29362
|
+
);
|
|
29133
29363
|
}
|
|
29134
29364
|
};
|
|
29135
29365
|
};
|
|
@@ -39403,6 +39633,7 @@ const createNodeLabel = (context, definition) => {
|
|
|
39403
39633
|
|
|
39404
39634
|
class Group extends DescendantNode {
|
|
39405
39635
|
childrenState;
|
|
39636
|
+
attributeState;
|
|
39406
39637
|
[XPathNodeKindKey] = "element";
|
|
39407
39638
|
// InstanceNode
|
|
39408
39639
|
state;
|
|
@@ -39418,7 +39649,9 @@ class Group extends DescendantNode {
|
|
|
39418
39649
|
super(parent, instanceNode, definition);
|
|
39419
39650
|
this.appearances = definition.bodyElement?.appearances ?? null;
|
|
39420
39651
|
const childrenState = createChildrenState(this);
|
|
39652
|
+
const attributeState = createAttributeState(this.scope);
|
|
39421
39653
|
this.childrenState = childrenState;
|
|
39654
|
+
this.attributeState = attributeState;
|
|
39422
39655
|
const state = createSharedNodeState(
|
|
39423
39656
|
this.scope,
|
|
39424
39657
|
{
|
|
@@ -39429,6 +39662,7 @@ class Group extends DescendantNode {
|
|
|
39429
39662
|
label: createNodeLabel(this, definition),
|
|
39430
39663
|
hint: null,
|
|
39431
39664
|
children: childrenState.childIds,
|
|
39665
|
+
attributes: attributeState.getAttributes,
|
|
39432
39666
|
valueOptions: null,
|
|
39433
39667
|
value: null
|
|
39434
39668
|
},
|
|
@@ -39442,12 +39676,16 @@ class Group extends DescendantNode {
|
|
|
39442
39676
|
childrenState
|
|
39443
39677
|
);
|
|
39444
39678
|
childrenState.setChildren(buildChildren(this));
|
|
39679
|
+
attributeState.setAttributes(buildAttributes(this));
|
|
39445
39680
|
this.validationState = createAggregatedViolations(this, this.instanceConfig);
|
|
39446
39681
|
this.instanceState = createParentNodeInstanceState(this);
|
|
39447
39682
|
}
|
|
39448
39683
|
getChildren() {
|
|
39449
39684
|
return this.childrenState.getChildren();
|
|
39450
39685
|
}
|
|
39686
|
+
getAttributes() {
|
|
39687
|
+
return this.attributeState.getAttributes();
|
|
39688
|
+
}
|
|
39451
39689
|
}
|
|
39452
39690
|
|
|
39453
39691
|
const createFieldHint = (context, definition) => {
|
|
@@ -39751,6 +39989,7 @@ class InputControl extends ValueNode {
|
|
|
39751
39989
|
label: createNodeLabel(this, definition),
|
|
39752
39990
|
hint: createFieldHint(this, definition),
|
|
39753
39991
|
children: null,
|
|
39992
|
+
attributes: null,
|
|
39754
39993
|
valueOptions: null,
|
|
39755
39994
|
value: this.valueState,
|
|
39756
39995
|
instanceValue: this.getInstanceValue
|
|
@@ -39794,6 +40033,7 @@ class ModelValue extends ValueNode {
|
|
|
39794
40033
|
label: null,
|
|
39795
40034
|
hint: null,
|
|
39796
40035
|
children: null,
|
|
40036
|
+
attributes: null,
|
|
39797
40037
|
valueOptions: null,
|
|
39798
40038
|
value: this.valueState,
|
|
39799
40039
|
instanceValue: this.getInstanceValue
|
|
@@ -39921,6 +40161,7 @@ class Note extends ValueNode {
|
|
|
39921
40161
|
hint,
|
|
39922
40162
|
noteText,
|
|
39923
40163
|
children: null,
|
|
40164
|
+
attributes: null,
|
|
39924
40165
|
valueOptions: null,
|
|
39925
40166
|
value: this.valueState,
|
|
39926
40167
|
instanceValue: this.getInstanceValue
|
|
@@ -40000,6 +40241,7 @@ class RangeControl extends ValueNode {
|
|
|
40000
40241
|
label: createNodeLabel(this, definition),
|
|
40001
40242
|
hint: createFieldHint(this, definition),
|
|
40002
40243
|
children: null,
|
|
40244
|
+
attributes: null,
|
|
40003
40245
|
valueOptions: null,
|
|
40004
40246
|
value: this.valueState,
|
|
40005
40247
|
instanceValue: this.getInstanceValue
|
|
@@ -40257,6 +40499,7 @@ class RankControl extends ValueNode {
|
|
|
40257
40499
|
label: createNodeLabel(this, definition),
|
|
40258
40500
|
hint: createFieldHint(this, definition),
|
|
40259
40501
|
children: null,
|
|
40502
|
+
attributes: null,
|
|
40260
40503
|
valueOptions,
|
|
40261
40504
|
value: valueState,
|
|
40262
40505
|
instanceValue: this.getInstanceValue
|
|
@@ -40318,26 +40561,17 @@ const createNodeRangeInstanceState = (node) => {
|
|
|
40318
40561
|
};
|
|
40319
40562
|
};
|
|
40320
40563
|
|
|
40321
|
-
class TemplatedNodeAttributeSerializationError extends Error {
|
|
40322
|
-
constructor() {
|
|
40323
|
-
super("Template attribute omission not implemented");
|
|
40324
|
-
}
|
|
40325
|
-
}
|
|
40326
|
-
|
|
40327
40564
|
const createTemplatedNodeInstanceState = (node) => {
|
|
40328
40565
|
return {
|
|
40329
40566
|
get instanceXML() {
|
|
40330
40567
|
if (!node.currentState.relevant) {
|
|
40331
40568
|
return "";
|
|
40332
40569
|
}
|
|
40333
|
-
|
|
40334
|
-
|
|
40335
|
-
|
|
40336
|
-
|
|
40337
|
-
|
|
40338
|
-
throw new TemplatedNodeAttributeSerializationError();
|
|
40339
|
-
}
|
|
40340
|
-
return serializeParentElementXML(node.definition.qualifiedName, serializedChildren);
|
|
40570
|
+
return serializeParentElementXML(
|
|
40571
|
+
node.definition.qualifiedName,
|
|
40572
|
+
node.currentState.children,
|
|
40573
|
+
node.currentState.attributes
|
|
40574
|
+
);
|
|
40341
40575
|
}
|
|
40342
40576
|
};
|
|
40343
40577
|
};
|
|
@@ -40358,7 +40592,9 @@ class RepeatInstance extends DescendantNode {
|
|
|
40358
40592
|
this.parent = parent;
|
|
40359
40593
|
this.appearances = definition.bodyElement.appearances;
|
|
40360
40594
|
const childrenState = createChildrenState(this);
|
|
40595
|
+
const attributeState = createAttributeState(this.scope);
|
|
40361
40596
|
this.childrenState = childrenState;
|
|
40597
|
+
this.attributeState = attributeState;
|
|
40362
40598
|
this.currentIndex = currentIndex;
|
|
40363
40599
|
const state = createSharedNodeState(
|
|
40364
40600
|
this.scope,
|
|
@@ -40370,7 +40606,7 @@ class RepeatInstance extends DescendantNode {
|
|
|
40370
40606
|
// TODO: only-child <group><label>
|
|
40371
40607
|
label: createNodeLabel(this, definition),
|
|
40372
40608
|
hint: null,
|
|
40373
|
-
attributes:
|
|
40609
|
+
attributes: attributeState.getAttributes,
|
|
40374
40610
|
children: childrenState.childIds,
|
|
40375
40611
|
valueOptions: null,
|
|
40376
40612
|
value: null
|
|
@@ -40393,6 +40629,7 @@ class RepeatInstance extends DescendantNode {
|
|
|
40393
40629
|
this.instanceState = createTemplatedNodeInstanceState(this);
|
|
40394
40630
|
}
|
|
40395
40631
|
childrenState;
|
|
40632
|
+
attributeState;
|
|
40396
40633
|
currentIndex;
|
|
40397
40634
|
[XPathNodeKindKey] = "element";
|
|
40398
40635
|
// InstanceNode
|
|
@@ -40427,10 +40664,14 @@ class RepeatInstance extends DescendantNode {
|
|
|
40427
40664
|
getChildren() {
|
|
40428
40665
|
return this.childrenState.getChildren();
|
|
40429
40666
|
}
|
|
40667
|
+
getAttributes() {
|
|
40668
|
+
return this.attributeState.getAttributes();
|
|
40669
|
+
}
|
|
40430
40670
|
}
|
|
40431
40671
|
|
|
40432
40672
|
class BaseRepeatRange extends DescendantNode {
|
|
40433
40673
|
childrenState;
|
|
40674
|
+
attributeState;
|
|
40434
40675
|
/**
|
|
40435
40676
|
* A repeat range doesn't have a corresponding primary instance element of its
|
|
40436
40677
|
* own. It is represented in the following ways:
|
|
@@ -40470,7 +40711,9 @@ class BaseRepeatRange extends DescendantNode {
|
|
|
40470
40711
|
super(parent, definition.template, definition);
|
|
40471
40712
|
const repeatRange = this;
|
|
40472
40713
|
const childrenState = createChildrenState(repeatRange);
|
|
40714
|
+
const attributeState = createAttributeState(this.scope);
|
|
40473
40715
|
this.childrenState = childrenState;
|
|
40716
|
+
this.attributeState = attributeState;
|
|
40474
40717
|
const state = createSharedNodeState(
|
|
40475
40718
|
this.scope,
|
|
40476
40719
|
{
|
|
@@ -40481,6 +40724,7 @@ class BaseRepeatRange extends DescendantNode {
|
|
|
40481
40724
|
label: createNodeLabel(this, definition),
|
|
40482
40725
|
hint: null,
|
|
40483
40726
|
children: childrenState.childIds,
|
|
40727
|
+
attributes: attributeState.getAttributes,
|
|
40484
40728
|
valueOptions: null,
|
|
40485
40729
|
value: null
|
|
40486
40730
|
},
|
|
@@ -40548,6 +40792,9 @@ class BaseRepeatRange extends DescendantNode {
|
|
|
40548
40792
|
getChildren() {
|
|
40549
40793
|
return this.childrenState.getChildren();
|
|
40550
40794
|
}
|
|
40795
|
+
getAttributes() {
|
|
40796
|
+
return this.attributeState.getAttributes();
|
|
40797
|
+
}
|
|
40551
40798
|
}
|
|
40552
40799
|
|
|
40553
40800
|
class RepeatRangeControlled extends BaseRepeatRange {
|
|
@@ -40791,6 +41038,7 @@ class SelectControl extends ValueNode {
|
|
|
40791
41038
|
label: createNodeLabel(this, definition),
|
|
40792
41039
|
hint: createFieldHint(this, definition),
|
|
40793
41040
|
children: null,
|
|
41041
|
+
attributes: null,
|
|
40794
41042
|
valueOptions,
|
|
40795
41043
|
value: valueState,
|
|
40796
41044
|
instanceValue: this.getInstanceValue,
|
|
@@ -40926,6 +41174,7 @@ class TriggerControl extends ValueNode {
|
|
|
40926
41174
|
label: createNodeLabel(this, definition),
|
|
40927
41175
|
hint: createFieldHint(this, definition),
|
|
40928
41176
|
children: null,
|
|
41177
|
+
attributes: null,
|
|
40929
41178
|
valueOptions: null,
|
|
40930
41179
|
value: this.valueState,
|
|
40931
41180
|
instanceValue: this.getInstanceValue
|
|
@@ -41124,6 +41373,8 @@ class UploadControl extends DescendantNode {
|
|
|
41124
41373
|
this.nodeOptions = definition.bodyElement.options;
|
|
41125
41374
|
const instanceAttachment = createInstanceAttachment(this);
|
|
41126
41375
|
this.instanceAttachment = instanceAttachment;
|
|
41376
|
+
const attributeState = createAttributeState(this.scope);
|
|
41377
|
+
this.attributeState = attributeState;
|
|
41127
41378
|
this.decodeInstanceValue = instanceAttachment.decodeInstanceValue;
|
|
41128
41379
|
this.getXPathValue = instanceAttachment.getInstanceValue;
|
|
41129
41380
|
const state = createSharedNodeState(
|
|
@@ -41138,6 +41389,7 @@ class UploadControl extends DescendantNode {
|
|
|
41138
41389
|
children: null,
|
|
41139
41390
|
valueOptions: null,
|
|
41140
41391
|
value: instanceAttachment.valueState,
|
|
41392
|
+
attributes: attributeState.getAttributes,
|
|
41141
41393
|
instanceValue: instanceAttachment.getInstanceValue
|
|
41142
41394
|
},
|
|
41143
41395
|
this.instanceConfig
|
|
@@ -41154,6 +41406,7 @@ class UploadControl extends DescendantNode {
|
|
|
41154
41406
|
}
|
|
41155
41407
|
validation;
|
|
41156
41408
|
instanceAttachment;
|
|
41409
|
+
attributeState;
|
|
41157
41410
|
// XFormsXPathElement
|
|
41158
41411
|
[XPathNodeKindKey] = "element";
|
|
41159
41412
|
getXPathValue;
|
|
@@ -41188,6 +41441,9 @@ class UploadControl extends DescendantNode {
|
|
|
41188
41441
|
this.instanceAttachment.setValue(value);
|
|
41189
41442
|
return this.root;
|
|
41190
41443
|
}
|
|
41444
|
+
getAttributes() {
|
|
41445
|
+
return this.attributeState.getAttributes();
|
|
41446
|
+
}
|
|
41191
41447
|
}
|
|
41192
41448
|
|
|
41193
41449
|
const META_LOCAL_NAME = "meta";
|
|
@@ -41469,6 +41725,7 @@ const buildChildren = (parent) => {
|
|
|
41469
41725
|
|
|
41470
41726
|
class Root extends DescendantNode {
|
|
41471
41727
|
childrenState;
|
|
41728
|
+
attributeState;
|
|
41472
41729
|
// XFormsXPathElement
|
|
41473
41730
|
[XPathNodeKindKey] = "element";
|
|
41474
41731
|
// DescendantNode
|
|
@@ -41500,7 +41757,9 @@ class Root extends DescendantNode {
|
|
|
41500
41757
|
});
|
|
41501
41758
|
this.classes = parent.classes;
|
|
41502
41759
|
const childrenState = createChildrenState(this);
|
|
41760
|
+
const attributeState = createAttributeState(this.scope);
|
|
41503
41761
|
this.childrenState = childrenState;
|
|
41762
|
+
this.attributeState = attributeState;
|
|
41504
41763
|
this.languages = parent.languages;
|
|
41505
41764
|
const state = createSharedNodeState(
|
|
41506
41765
|
this.scope,
|
|
@@ -41514,7 +41773,8 @@ class Root extends DescendantNode {
|
|
|
41514
41773
|
required: () => false,
|
|
41515
41774
|
valueOptions: null,
|
|
41516
41775
|
value: null,
|
|
41517
|
-
children: childrenState.childIds
|
|
41776
|
+
children: childrenState.childIds,
|
|
41777
|
+
attributes: attributeState.getAttributes
|
|
41518
41778
|
},
|
|
41519
41779
|
this.instanceConfig
|
|
41520
41780
|
);
|
|
@@ -41526,12 +41786,16 @@ class Root extends DescendantNode {
|
|
|
41526
41786
|
childrenState
|
|
41527
41787
|
);
|
|
41528
41788
|
childrenState.setChildren(buildChildren(this));
|
|
41789
|
+
attributeState.setAttributes(buildAttributes(this));
|
|
41529
41790
|
this.validationState = createAggregatedViolations(this, this.instanceConfig);
|
|
41530
41791
|
this.instanceState = createRootInstanceState(this);
|
|
41531
41792
|
}
|
|
41532
41793
|
getChildren() {
|
|
41533
41794
|
return this.childrenState.getChildren();
|
|
41534
41795
|
}
|
|
41796
|
+
getAttributes() {
|
|
41797
|
+
return this.attributeState.getAttributes();
|
|
41798
|
+
}
|
|
41535
41799
|
// RootNode
|
|
41536
41800
|
setLanguage(language) {
|
|
41537
41801
|
this.rootDocument.setLanguage(language);
|
|
@@ -41576,6 +41840,7 @@ class PrimaryInstance extends InstanceNode {
|
|
|
41576
41840
|
isAttached;
|
|
41577
41841
|
evaluator;
|
|
41578
41842
|
contextNode = this;
|
|
41843
|
+
attributeState;
|
|
41579
41844
|
constructor(options) {
|
|
41580
41845
|
const { mode, initialState, scope, model, secondaryInstances, config } = options;
|
|
41581
41846
|
const { instance: modelInstance } = model;
|
|
@@ -41606,7 +41871,9 @@ class PrimaryInstance extends InstanceNode {
|
|
|
41606
41871
|
this.evaluator = evaluator;
|
|
41607
41872
|
this.classes = definition.classes;
|
|
41608
41873
|
const childrenState = createChildrenState(this);
|
|
41874
|
+
const attributeState = createAttributeState(this.scope);
|
|
41609
41875
|
this.getChildren = childrenState.getChildren;
|
|
41876
|
+
this.attributeState = attributeState;
|
|
41610
41877
|
const stateSpec = {
|
|
41611
41878
|
activeLanguage: getActiveLanguage,
|
|
41612
41879
|
reference: PRIMARY_INSTANCE_REFERENCE,
|
|
@@ -41617,7 +41884,8 @@ class PrimaryInstance extends InstanceNode {
|
|
|
41617
41884
|
required: false,
|
|
41618
41885
|
valueOptions: null,
|
|
41619
41886
|
value: null,
|
|
41620
|
-
children: childrenState.childIds
|
|
41887
|
+
children: childrenState.childIds,
|
|
41888
|
+
attributes: attributeState.getAttributes
|
|
41621
41889
|
};
|
|
41622
41890
|
const state = createSharedNodeState(scope, stateSpec, config);
|
|
41623
41891
|
this.state = state;
|
|
@@ -41632,6 +41900,7 @@ class PrimaryInstance extends InstanceNode {
|
|
|
41632
41900
|
};
|
|
41633
41901
|
this.instanceState = createPrimaryInstanceState(this);
|
|
41634
41902
|
childrenState.setChildren([root]);
|
|
41903
|
+
attributeState.setAttributes(buildAttributes(this));
|
|
41635
41904
|
setIsAttached(true);
|
|
41636
41905
|
}
|
|
41637
41906
|
// PrimaryInstanceDocument
|
|
@@ -41674,6 +41943,9 @@ class PrimaryInstance extends InstanceNode {
|
|
|
41674
41943
|
});
|
|
41675
41944
|
return Promise.resolve(result);
|
|
41676
41945
|
}
|
|
41946
|
+
getAttributes() {
|
|
41947
|
+
return this.attributeState.getAttributes();
|
|
41948
|
+
}
|
|
41677
41949
|
}
|
|
41678
41950
|
|
|
41679
41951
|
class FormInstance {
|