@getodk/xforms-engine 0.16.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/client/AttributeNode.d.ts +4 -3
  2. package/dist/index.js +272 -211
  3. package/dist/index.js.map +1 -1
  4. package/dist/instance/Attribute.d.ts +11 -23
  5. package/dist/instance/Group.d.ts +3 -0
  6. package/dist/instance/InputControl.d.ts +3 -0
  7. package/dist/instance/ModelValue.d.ts +4 -0
  8. package/dist/instance/Note.d.ts +4 -0
  9. package/dist/instance/PrimaryInstance.d.ts +3 -0
  10. package/dist/instance/RangeControl.d.ts +4 -0
  11. package/dist/instance/RankControl.d.ts +5 -1
  12. package/dist/instance/Root.d.ts +3 -0
  13. package/dist/instance/SelectControl.d.ts +5 -1
  14. package/dist/instance/TriggerControl.d.ts +4 -0
  15. package/dist/instance/UploadControl.d.ts +3 -0
  16. package/dist/instance/abstract/DescendantNode.d.ts +5 -4
  17. package/dist/instance/abstract/InstanceNode.d.ts +4 -3
  18. package/dist/instance/hierarchy.d.ts +2 -1
  19. package/dist/instance/repeat/RepeatInstance.d.ts +2 -0
  20. package/dist/integration/xpath/adapter/XFormsXPathNode.d.ts +1 -1
  21. package/dist/integration/xpath/adapter/kind.d.ts +5 -3
  22. package/dist/integration/xpath/adapter/traversal.d.ts +3 -3
  23. package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +1 -0
  24. package/dist/parse/model/AttributeDefinition.d.ts +2 -0
  25. package/dist/solid.js +272 -211
  26. package/dist/solid.js.map +1 -1
  27. package/package.json +2 -2
  28. package/src/client/AttributeNode.ts +4 -3
  29. package/src/instance/Attribute.ts +38 -54
  30. package/src/instance/Group.ts +12 -4
  31. package/src/instance/InputControl.ts +12 -4
  32. package/src/instance/ModelValue.ts +13 -4
  33. package/src/instance/Note.ts +13 -4
  34. package/src/instance/PrimaryInstance.ts +12 -4
  35. package/src/instance/RangeControl.ts +13 -4
  36. package/src/instance/RankControl.ts +14 -5
  37. package/src/instance/Root.ts +12 -4
  38. package/src/instance/SelectControl.ts +14 -5
  39. package/src/instance/TriggerControl.ts +13 -4
  40. package/src/instance/UploadControl.ts +13 -3
  41. package/src/instance/abstract/DescendantNode.ts +4 -3
  42. package/src/instance/abstract/InstanceNode.ts +5 -3
  43. package/src/instance/attachments/buildAttributes.ts +5 -1
  44. package/src/instance/children/childrenInitOptions.ts +2 -1
  45. package/src/instance/hierarchy.ts +2 -0
  46. package/src/instance/repeat/RepeatInstance.ts +11 -3
  47. package/src/integration/xpath/adapter/XFormsXPathNode.ts +1 -0
  48. package/src/integration/xpath/adapter/engineDOMAdapter.ts +2 -2
  49. package/src/integration/xpath/adapter/kind.ts +6 -1
  50. package/src/integration/xpath/adapter/names.ts +1 -0
  51. package/src/integration/xpath/adapter/traversal.ts +5 -6
  52. package/src/integration/xpath/static-dom/StaticAttribute.ts +1 -0
  53. package/src/lib/reactivity/createInstanceValueState.ts +29 -3
  54. package/src/parse/model/AttributeDefinition.ts +7 -0
package/dist/index.js CHANGED
@@ -21252,6 +21252,7 @@ class StaticAttribute extends StaticNode {
21252
21252
  nodeset;
21253
21253
  attributes = [];
21254
21254
  children = null;
21255
+ childElements = [];
21255
21256
  value;
21256
21257
  // XFormsXPathAttribute
21257
21258
  getXPathValue() {
@@ -22370,6 +22371,7 @@ class AttributeDefinition extends NodeDefinition {
22370
22371
  serializedXML;
22371
22372
  value;
22372
22373
  type = "attribute";
22374
+ valueType = "string";
22373
22375
  namespaceDeclarations;
22374
22376
  bodyElement = null;
22375
22377
  root;
@@ -22381,6 +22383,10 @@ class AttributeDefinition extends NodeDefinition {
22381
22383
  serializeAttributeXML() {
22382
22384
  return this.serializedXML;
22383
22385
  }
22386
+ toJSON() {
22387
+ const { bind, bodyElement, parent, root, ...rest } = this;
22388
+ return rest;
22389
+ }
22384
22390
  }
22385
22391
 
22386
22392
  const isNonNamespaceAttribute = (attribute) => {
@@ -27953,6 +27959,7 @@ const resolveEngineXPathNodeNamespaceURI = (node, prefix) => {
27953
27959
  case "static-element":
27954
27960
  case "static-text":
27955
27961
  return resolveNamespaceURIFromStaticNodeContext(node, prefix);
27962
+ case "attribute":
27956
27963
  case "group":
27957
27964
  case "input":
27958
27965
  case "model-value":
@@ -27985,10 +27992,13 @@ class XPathFunctionalityPendingError extends XPathFunctionalityError {
27985
27992
  const getContainingEngineXPathDocument = (node) => {
27986
27993
  return node.rootDocument;
27987
27994
  };
27988
- const getEngineXPathAttributes = (node) => {
27995
+ const getAttributes = (node) => {
27989
27996
  if (node.nodeType === "static-element") {
27990
27997
  return node.attributes;
27991
27998
  }
27999
+ if (isEngineXPathElement(node)) {
28000
+ return node.getAttributes();
28001
+ }
27992
28002
  return [];
27993
28003
  };
27994
28004
  const getNamespaceDeclarations = () => [];
@@ -28145,7 +28155,7 @@ const engineDOMAdapter = {
28145
28155
  getNodeValue: getEngineXPathNodeValue,
28146
28156
  // XPathTraversalAdapter
28147
28157
  compareDocumentOrder,
28148
- getAttributes: getEngineXPathAttributes,
28158
+ getAttributes,
28149
28159
  getChildElements,
28150
28160
  getChildNodes,
28151
28161
  getContainingDocument: getContainingEngineXPathDocument,
@@ -29581,6 +29591,21 @@ const createCalculation = (context, setRelevantValue, computation) => {
29581
29591
  }
29582
29592
  });
29583
29593
  };
29594
+ const createActionCalculation = (context, setRelevantValue, computation) => {
29595
+ createComputed(() => {
29596
+ if (context.isAttached()) {
29597
+ const relevant = untrack(() => context.isRelevant());
29598
+ if (!relevant) {
29599
+ return;
29600
+ }
29601
+ const calculated = untrack(() => {
29602
+ return context.evaluator.evaluateString(computation.expression, context);
29603
+ });
29604
+ const value = context.decodeInstanceValue(calculated);
29605
+ setRelevantValue(value);
29606
+ }
29607
+ });
29608
+ };
29584
29609
  const createValueChangedCalculation = (context, setRelevantValue, action) => {
29585
29610
  const { source, ref } = bindToRepeatInstance(context, action);
29586
29611
  if (!source) {
@@ -29606,17 +29631,17 @@ const createValueChangedCalculation = (context, setRelevantValue, action) => {
29606
29631
  const registerAction = (context, setValue, action) => {
29607
29632
  if (action.events.includes(XFORM_EVENT.odkInstanceFirstLoad)) {
29608
29633
  if (isInstanceFirstLoad(context)) {
29609
- createCalculation(context, setValue, action.computation);
29634
+ createActionCalculation(context, setValue, action.computation);
29610
29635
  }
29611
29636
  }
29612
29637
  if (action.events.includes(XFORM_EVENT.odkInstanceLoad)) {
29613
29638
  if (!isAddingRepeatChild(context)) {
29614
- createCalculation(context, setValue, action.computation);
29639
+ createActionCalculation(context, setValue, action.computation);
29615
29640
  }
29616
29641
  }
29617
29642
  if (action.events.includes(XFORM_EVENT.odkNewRepeat)) {
29618
29643
  if (isAddingRepeatChild(context)) {
29619
- createCalculation(context, setValue, action.computation);
29644
+ createActionCalculation(context, setValue, action.computation);
29620
29645
  }
29621
29646
  }
29622
29647
  if (action.events.includes(XFORM_EVENT.xformsValueChanged)) {
@@ -29642,178 +29667,6 @@ const createInstanceValueState = (context) => {
29642
29667
  });
29643
29668
  };
29644
29669
 
29645
- class Attribute {
29646
- constructor(owner, definition, instanceNode) {
29647
- this.owner = owner;
29648
- this.definition = definition;
29649
- this.instanceNode = instanceNode;
29650
- const codec = getSharedValueCodec("string");
29651
- this.contextNode = owner;
29652
- this.scope = owner.scope;
29653
- this.rootDocument = owner.rootDocument;
29654
- this.root = owner.root;
29655
- this.instanceConfig = owner.instanceConfig;
29656
- this.getActiveLanguage = owner.getActiveLanguage;
29657
- this.validationState = { violations: [] };
29658
- this.valueType = "string";
29659
- this.evaluator = owner.evaluator;
29660
- this.decodeInstanceValue = codec.decodeInstanceValue;
29661
- const instanceValueState = createInstanceValueState(this);
29662
- const valueState = codec.createRuntimeValueState(instanceValueState);
29663
- const [getInstanceValue] = instanceValueState;
29664
- const [, setValueState] = valueState;
29665
- this.getInstanceValue = getInstanceValue;
29666
- this.setValueState = setValueState;
29667
- this.valueState = valueState;
29668
- const state = createSharedNodeState(
29669
- owner.scope,
29670
- {
29671
- value: this.valueState,
29672
- instanceValue: this.getInstanceValue,
29673
- relevant: this.owner.isRelevant
29674
- },
29675
- this.instanceConfig
29676
- );
29677
- this.state = state;
29678
- this.engineState = state.engineState;
29679
- this.currentState = state.currentState;
29680
- this.instanceState = createAttributeNodeInstanceState(this);
29681
- }
29682
- [XPathNodeKindKey] = "attribute";
29683
- state;
29684
- engineState;
29685
- validationState;
29686
- nodeType = "attribute";
29687
- currentState;
29688
- instanceState;
29689
- appearances = null;
29690
- nodeOptions = null;
29691
- valueType;
29692
- decodeInstanceValue;
29693
- getInstanceValue;
29694
- valueState;
29695
- setValueState;
29696
- evaluator;
29697
- getActiveLanguage;
29698
- contextNode;
29699
- scope;
29700
- rootDocument;
29701
- instanceConfig;
29702
- root;
29703
- isRelevant = () => {
29704
- return this.owner.isRelevant();
29705
- };
29706
- isAttached = () => {
29707
- return this.owner.isAttached();
29708
- };
29709
- isReadonly = () => {
29710
- return true;
29711
- };
29712
- hasReadonlyAncestor = () => {
29713
- const { owner } = this;
29714
- return owner.hasReadonlyAncestor() || owner.isReadonly();
29715
- };
29716
- hasNonRelevantAncestor = () => {
29717
- const { owner } = this;
29718
- return owner.hasNonRelevantAncestor() || !owner.isRelevant();
29719
- };
29720
- contextReference = () => {
29721
- return this.owner.contextReference() + "/@" + this.definition.qualifiedName.getPrefixedName();
29722
- };
29723
- setValue(value) {
29724
- this.setValueState(value);
29725
- return this.root;
29726
- }
29727
- getChildren() {
29728
- return [];
29729
- }
29730
- getXPathChildNodes() {
29731
- return [];
29732
- }
29733
- getXPathValue() {
29734
- return "";
29735
- }
29736
- }
29737
-
29738
- function buildAttributes(owner) {
29739
- return Array.from(owner.definition.attributes.values()).map((attributeDefinition) => {
29740
- return new Attribute(owner, attributeDefinition, attributeDefinition.template);
29741
- });
29742
- }
29743
-
29744
- class InstanceAttachmentsState extends Map {
29745
- constructor(sourceAttachments = null) {
29746
- super();
29747
- this.sourceAttachments = sourceAttachments;
29748
- }
29749
- getInitialFileValue(instanceNode) {
29750
- if (instanceNode == null) {
29751
- return null;
29752
- }
29753
- return this.sourceAttachments?.get(instanceNode.value) ?? null;
29754
- }
29755
- }
29756
-
29757
- const createRootInstanceState = (node) => {
29758
- return {
29759
- get instanceXML() {
29760
- return serializeParentElementXML(
29761
- node.definition.qualifiedName,
29762
- node.currentState.children,
29763
- node.currentState.attributes,
29764
- node.definition.namespaceDeclarations
29765
- );
29766
- }
29767
- };
29768
- };
29769
-
29770
- const violationReference = (node) => {
29771
- const violation = node.getViolation();
29772
- if (violation == null) {
29773
- return null;
29774
- }
29775
- const { nodeId } = node;
29776
- return {
29777
- nodeId,
29778
- get reference() {
29779
- return node.currentState.reference;
29780
- },
29781
- violation
29782
- };
29783
- };
29784
- const collectViolationReferences = (context) => {
29785
- return context.getChildren().flatMap((child) => {
29786
- switch (child.nodeType) {
29787
- case "model-value":
29788
- case "input":
29789
- case "note":
29790
- case "select":
29791
- case "range":
29792
- case "rank":
29793
- case "trigger":
29794
- case "upload": {
29795
- const reference = violationReference(child);
29796
- if (reference == null) {
29797
- return [];
29798
- }
29799
- return [reference];
29800
- }
29801
- default:
29802
- return collectViolationReferences(child);
29803
- }
29804
- });
29805
- };
29806
- const createAggregatedViolations = (context, options) => {
29807
- const { scope } = context;
29808
- return scope.runTask(() => {
29809
- const violations = createMemo(() => {
29810
- return collectViolationReferences(context);
29811
- });
29812
- const spec = { violations };
29813
- return createSharedNodeState(scope, spec, options).currentState;
29814
- });
29815
- };
29816
-
29817
29670
  const XFORMS_XPATH_NODE_RANGE_KIND = "comment";
29818
29671
 
29819
29672
  class DescendantNode extends InstanceNode {
@@ -29946,6 +29799,165 @@ class DescendantNode extends InstanceNode {
29946
29799
  }
29947
29800
  }
29948
29801
 
29802
+ class Attribute extends DescendantNode {
29803
+ constructor(owner, definition, instanceNode) {
29804
+ const computeReference = () => {
29805
+ return `${this.owner.contextReference()}/@${this.definition.qualifiedName.getPrefixedName()}`;
29806
+ };
29807
+ super(owner, instanceNode, definition, { computeReference });
29808
+ this.owner = owner;
29809
+ this.instanceNode = instanceNode;
29810
+ const codec = getSharedValueCodec("string");
29811
+ this.validationState = { violations: [] };
29812
+ this.valueType = "string";
29813
+ this.decodeInstanceValue = codec.decodeInstanceValue;
29814
+ const instanceValueState = createInstanceValueState(this);
29815
+ const valueState = codec.createRuntimeValueState(instanceValueState);
29816
+ const [getInstanceValue] = instanceValueState;
29817
+ const [, setValueState] = valueState;
29818
+ this.getInstanceValue = getInstanceValue;
29819
+ this.setValueState = setValueState;
29820
+ this.valueState = valueState;
29821
+ const state = createSharedNodeState(
29822
+ owner.scope,
29823
+ {
29824
+ value: this.valueState,
29825
+ instanceValue: this.getInstanceValue,
29826
+ relevant: this.owner.isRelevant,
29827
+ readonly: () => true,
29828
+ reference: this.contextReference,
29829
+ required: () => false,
29830
+ children: null,
29831
+ label: () => null,
29832
+ hint: () => null,
29833
+ attributes: () => [],
29834
+ valueOptions: () => []
29835
+ },
29836
+ this.instanceConfig
29837
+ );
29838
+ this.state = state;
29839
+ this.engineState = state.engineState;
29840
+ this.currentState = state.currentState;
29841
+ this.instanceState = createAttributeNodeInstanceState(this);
29842
+ this.attributeState = createAttributeState(this.scope);
29843
+ this.getXPathValue = () => {
29844
+ return this.getInstanceValue();
29845
+ };
29846
+ }
29847
+ [XPathNodeKindKey] = "attribute";
29848
+ state;
29849
+ engineState;
29850
+ validationState;
29851
+ nodeType = "attribute";
29852
+ currentState;
29853
+ instanceState;
29854
+ appearances = null;
29855
+ nodeOptions = null;
29856
+ valueType;
29857
+ decodeInstanceValue;
29858
+ getInstanceValue;
29859
+ valueState;
29860
+ setValueState;
29861
+ attributeState;
29862
+ isAttached = () => {
29863
+ return this.owner.isAttached();
29864
+ };
29865
+ getXPathValue;
29866
+ setValue(value) {
29867
+ this.setValueState(value);
29868
+ return this.root;
29869
+ }
29870
+ getAttributes() {
29871
+ return [];
29872
+ }
29873
+ getChildren() {
29874
+ return [];
29875
+ }
29876
+ }
29877
+
29878
+ function buildAttributes(owner) {
29879
+ const attributes = owner.definition.attributes;
29880
+ if (!attributes) {
29881
+ return [];
29882
+ }
29883
+ return Array.from(attributes.values()).map((attributeDefinition) => {
29884
+ return new Attribute(owner, attributeDefinition, attributeDefinition.template);
29885
+ });
29886
+ }
29887
+
29888
+ class InstanceAttachmentsState extends Map {
29889
+ constructor(sourceAttachments = null) {
29890
+ super();
29891
+ this.sourceAttachments = sourceAttachments;
29892
+ }
29893
+ getInitialFileValue(instanceNode) {
29894
+ if (instanceNode == null) {
29895
+ return null;
29896
+ }
29897
+ return this.sourceAttachments?.get(instanceNode.value) ?? null;
29898
+ }
29899
+ }
29900
+
29901
+ const createRootInstanceState = (node) => {
29902
+ return {
29903
+ get instanceXML() {
29904
+ return serializeParentElementXML(
29905
+ node.definition.qualifiedName,
29906
+ node.currentState.children,
29907
+ node.currentState.attributes,
29908
+ node.definition.namespaceDeclarations
29909
+ );
29910
+ }
29911
+ };
29912
+ };
29913
+
29914
+ const violationReference = (node) => {
29915
+ const violation = node.getViolation();
29916
+ if (violation == null) {
29917
+ return null;
29918
+ }
29919
+ const { nodeId } = node;
29920
+ return {
29921
+ nodeId,
29922
+ get reference() {
29923
+ return node.currentState.reference;
29924
+ },
29925
+ violation
29926
+ };
29927
+ };
29928
+ const collectViolationReferences = (context) => {
29929
+ return context.getChildren().flatMap((child) => {
29930
+ switch (child.nodeType) {
29931
+ case "model-value":
29932
+ case "input":
29933
+ case "note":
29934
+ case "select":
29935
+ case "range":
29936
+ case "rank":
29937
+ case "trigger":
29938
+ case "upload": {
29939
+ const reference = violationReference(child);
29940
+ if (reference == null) {
29941
+ return [];
29942
+ }
29943
+ return [reference];
29944
+ }
29945
+ default:
29946
+ return collectViolationReferences(child);
29947
+ }
29948
+ });
29949
+ };
29950
+ const createAggregatedViolations = (context, options) => {
29951
+ const { scope } = context;
29952
+ return scope.runTask(() => {
29953
+ const violations = createMemo(() => {
29954
+ return collectViolationReferences(context);
29955
+ });
29956
+ const spec = { violations };
29957
+ return createSharedNodeState(scope, spec, options).currentState;
29958
+ });
29959
+ };
29960
+
29949
29961
  const createParentNodeInstanceState = (node) => {
29950
29962
  return {
29951
29963
  get instanceXML() {
@@ -40234,6 +40246,7 @@ class Group extends DescendantNode {
40234
40246
  // InstanceNode
40235
40247
  state;
40236
40248
  engineState;
40249
+ attributeState;
40237
40250
  // GroupNode
40238
40251
  nodeType = "group";
40239
40252
  appearances;
@@ -40245,7 +40258,7 @@ class Group extends DescendantNode {
40245
40258
  super(parent, instanceNode, definition);
40246
40259
  this.appearances = definition.bodyElement?.appearances ?? null;
40247
40260
  const childrenState = createChildrenState(this);
40248
- const attributeState = createAttributeState(this.scope);
40261
+ this.attributeState = createAttributeState(this.scope);
40249
40262
  this.childrenState = childrenState;
40250
40263
  const state = createSharedNodeState(
40251
40264
  this.scope,
@@ -40257,7 +40270,7 @@ class Group extends DescendantNode {
40257
40270
  label: createNodeLabel(this, definition),
40258
40271
  hint: null,
40259
40272
  children: childrenState.childIds,
40260
- attributes: attributeState.getAttributes,
40273
+ attributes: this.attributeState.getAttributes,
40261
40274
  valueOptions: null,
40262
40275
  value: null
40263
40276
  },
@@ -40271,13 +40284,16 @@ class Group extends DescendantNode {
40271
40284
  childrenState
40272
40285
  );
40273
40286
  childrenState.setChildren(buildChildren(this));
40274
- attributeState.setAttributes(buildAttributes(this));
40287
+ this.attributeState.setAttributes(buildAttributes(this));
40275
40288
  this.validationState = createAggregatedViolations(this, this.instanceConfig);
40276
40289
  this.instanceState = createParentNodeInstanceState(this);
40277
40290
  }
40278
40291
  getChildren() {
40279
40292
  return this.childrenState.getChildren();
40280
40293
  }
40294
+ getAttributes() {
40295
+ return this.attributeState.getAttributes();
40296
+ }
40281
40297
  }
40282
40298
 
40283
40299
  const createFieldHint = (context, definition) => {
@@ -40481,6 +40497,7 @@ class InputControl extends ValueNode {
40481
40497
  // InstanceNode
40482
40498
  state;
40483
40499
  engineState;
40500
+ attributeState;
40484
40501
  // InputNode
40485
40502
  nodeType = "input";
40486
40503
  appearances;
@@ -40491,7 +40508,7 @@ class InputControl extends ValueNode {
40491
40508
  super(parent, instanceNode, definition, codec);
40492
40509
  this.appearances = definition.bodyElement.appearances;
40493
40510
  this.nodeOptions = nodeOptionsFactoryByType[definition.valueType](definition.bodyElement);
40494
- const attributeState = createAttributeState(this.scope);
40511
+ this.attributeState = createAttributeState(this.scope);
40495
40512
  const state = createSharedNodeState(
40496
40513
  this.scope,
40497
40514
  {
@@ -40502,14 +40519,14 @@ class InputControl extends ValueNode {
40502
40519
  label: createNodeLabel(this, definition),
40503
40520
  hint: createFieldHint(this, definition),
40504
40521
  children: null,
40505
- attributes: attributeState.getAttributes,
40522
+ attributes: this.attributeState.getAttributes,
40506
40523
  valueOptions: null,
40507
40524
  value: this.valueState,
40508
40525
  instanceValue: this.getInstanceValue
40509
40526
  },
40510
40527
  this.instanceConfig
40511
40528
  );
40512
- attributeState.setAttributes(buildAttributes(this));
40529
+ this.attributeState.setAttributes(buildAttributes(this));
40513
40530
  this.state = state;
40514
40531
  this.engineState = state.engineState;
40515
40532
  this.currentState = state.currentState;
@@ -40518,6 +40535,9 @@ class InputControl extends ValueNode {
40518
40535
  this.setValueState(value);
40519
40536
  return this.root;
40520
40537
  }
40538
+ getAttributes() {
40539
+ return this.attributeState.getAttributes();
40540
+ }
40521
40541
  }
40522
40542
 
40523
40543
  class ModelValue extends ValueNode {
@@ -40529,6 +40549,7 @@ class ModelValue extends ValueNode {
40529
40549
  // InstanceNode
40530
40550
  state;
40531
40551
  engineState;
40552
+ attributeState;
40532
40553
  // ModelValueNode
40533
40554
  nodeType = "model-value";
40534
40555
  appearances = null;
@@ -40537,7 +40558,7 @@ class ModelValue extends ValueNode {
40537
40558
  constructor(parent, instanceNode, definition) {
40538
40559
  const codec = getSharedValueCodec(definition.valueType);
40539
40560
  super(parent, instanceNode, definition, codec);
40540
- const attributeState = createAttributeState(this.scope);
40561
+ this.attributeState = createAttributeState(this.scope);
40541
40562
  const state = createSharedNodeState(
40542
40563
  this.scope,
40543
40564
  {
@@ -40548,18 +40569,21 @@ class ModelValue extends ValueNode {
40548
40569
  label: null,
40549
40570
  hint: null,
40550
40571
  children: null,
40551
- attributes: attributeState.getAttributes,
40572
+ attributes: this.attributeState.getAttributes,
40552
40573
  valueOptions: null,
40553
40574
  value: this.valueState,
40554
40575
  instanceValue: this.getInstanceValue
40555
40576
  },
40556
40577
  this.instanceConfig
40557
40578
  );
40558
- attributeState.setAttributes(buildAttributes(this));
40579
+ this.attributeState.setAttributes(buildAttributes(this));
40559
40580
  this.state = state;
40560
40581
  this.engineState = state.engineState;
40561
40582
  this.currentState = state.currentState;
40562
40583
  }
40584
+ getAttributes() {
40585
+ return this.attributeState.getAttributes();
40586
+ }
40563
40587
  }
40564
40588
 
40565
40589
  class NoteCodec extends ValueCodec {
@@ -40636,6 +40660,7 @@ class Note extends ValueNode {
40636
40660
  // InstanceNode
40637
40661
  state;
40638
40662
  engineState;
40663
+ attributeState;
40639
40664
  // NoteNode
40640
40665
  nodeType = "note";
40641
40666
  appearances;
@@ -40647,7 +40672,7 @@ class Note extends ValueNode {
40647
40672
  this.appearances = definition.bodyElement.appearances;
40648
40673
  const isReadonly = createNoteReadonlyThunk(this, definition);
40649
40674
  const noteTextComputation = createNoteText(this, definition.noteTextDefinition);
40650
- const attributeState = createAttributeState(this.scope);
40675
+ this.attributeState = createAttributeState(this.scope);
40651
40676
  let noteText;
40652
40677
  let label;
40653
40678
  let hint;
@@ -40678,18 +40703,21 @@ class Note extends ValueNode {
40678
40703
  hint,
40679
40704
  noteText,
40680
40705
  children: null,
40681
- attributes: attributeState.getAttributes,
40706
+ attributes: this.attributeState.getAttributes,
40682
40707
  valueOptions: null,
40683
40708
  value: this.valueState,
40684
40709
  instanceValue: this.getInstanceValue
40685
40710
  },
40686
40711
  this.instanceConfig
40687
40712
  );
40688
- attributeState.setAttributes(buildAttributes(this));
40713
+ this.attributeState.setAttributes(buildAttributes(this));
40689
40714
  this.state = state;
40690
40715
  this.engineState = state.engineState;
40691
40716
  this.currentState = state.currentState;
40692
40717
  }
40718
+ getAttributes() {
40719
+ return this.attributeState.getAttributes();
40720
+ }
40693
40721
  }
40694
40722
 
40695
40723
  class RangeCodec extends ValueCodec {
@@ -40739,6 +40767,7 @@ class RangeControl extends ValueNode {
40739
40767
  // InstanceNode
40740
40768
  state;
40741
40769
  engineState;
40770
+ attributeState;
40742
40771
  // RangeNode
40743
40772
  nodeType = "range";
40744
40773
  appearances;
@@ -40749,7 +40778,7 @@ class RangeControl extends ValueNode {
40749
40778
  const codec = new RangeCodec(baseCodec, definition);
40750
40779
  super(parent, instanceNode, definition, codec);
40751
40780
  this.appearances = definition.bodyElement.appearances;
40752
- const attributeState = createAttributeState(this.scope);
40781
+ this.attributeState = createAttributeState(this.scope);
40753
40782
  const state = createSharedNodeState(
40754
40783
  this.scope,
40755
40784
  {
@@ -40760,14 +40789,14 @@ class RangeControl extends ValueNode {
40760
40789
  label: createNodeLabel(this, definition),
40761
40790
  hint: createFieldHint(this, definition),
40762
40791
  children: null,
40763
- attributes: attributeState.getAttributes,
40792
+ attributes: this.attributeState.getAttributes,
40764
40793
  valueOptions: null,
40765
40794
  value: this.valueState,
40766
40795
  instanceValue: this.getInstanceValue
40767
40796
  },
40768
40797
  this.instanceConfig
40769
40798
  );
40770
- attributeState.setAttributes(buildAttributes(this));
40799
+ this.attributeState.setAttributes(buildAttributes(this));
40771
40800
  this.state = state;
40772
40801
  this.engineState = state.engineState;
40773
40802
  this.currentState = state.currentState;
@@ -40776,6 +40805,9 @@ class RangeControl extends ValueNode {
40776
40805
  this.setValueState(value);
40777
40806
  return this.root;
40778
40807
  }
40808
+ getAttributes() {
40809
+ return this.attributeState.getAttributes();
40810
+ }
40779
40811
  }
40780
40812
 
40781
40813
  class RankMissingValueError extends Error {
@@ -40967,6 +40999,7 @@ class RankControl extends ValueNode {
40967
40999
  // InstanceNode
40968
41000
  state;
40969
41001
  engineState;
41002
+ attributeState;
40970
41003
  // RankNode
40971
41004
  nodeType = "rank";
40972
41005
  appearances;
@@ -40985,7 +41018,7 @@ class RankControl extends ValueNode {
40985
41018
  this.mapOptionsByValue = mapOptionsByValue;
40986
41019
  const baseValueState = this.valueState;
40987
41020
  const [baseGetValue, setValue] = baseValueState;
40988
- const attributeState = createAttributeState(this.scope);
41021
+ this.attributeState = createAttributeState(this.scope);
40989
41022
  const getValue = this.scope.runTask(() => {
40990
41023
  return createMemo(() => {
40991
41024
  const options = valueOptions();
@@ -41020,18 +41053,21 @@ class RankControl extends ValueNode {
41020
41053
  label: createNodeLabel(this, definition),
41021
41054
  hint: createFieldHint(this, definition),
41022
41055
  children: null,
41023
- attributes: attributeState.getAttributes,
41056
+ attributes: this.attributeState.getAttributes,
41024
41057
  valueOptions,
41025
41058
  value: valueState,
41026
41059
  instanceValue: this.getInstanceValue
41027
41060
  },
41028
41061
  this.instanceConfig
41029
41062
  );
41030
- attributeState.setAttributes(buildAttributes(this));
41063
+ this.attributeState.setAttributes(buildAttributes(this));
41031
41064
  this.state = state;
41032
41065
  this.engineState = state.engineState;
41033
41066
  this.currentState = state.currentState;
41034
41067
  }
41068
+ getAttributes() {
41069
+ return this.attributeState.getAttributes();
41070
+ }
41035
41071
  getValueLabel(value) {
41036
41072
  const valueOption = this.currentState.valueOptions.find((item) => item.value === value);
41037
41073
  return valueOption?.label ?? null;
@@ -41114,7 +41150,7 @@ class RepeatInstance extends DescendantNode {
41114
41150
  this.parent = parent;
41115
41151
  this.appearances = definition.bodyElement.appearances;
41116
41152
  const childrenState = createChildrenState(this);
41117
- const attributeState = createAttributeState(this.scope);
41153
+ this.attributeState = createAttributeState(this.scope);
41118
41154
  this.childrenState = childrenState;
41119
41155
  this.currentIndex = currentIndex;
41120
41156
  const state = createSharedNodeState(
@@ -41127,7 +41163,7 @@ class RepeatInstance extends DescendantNode {
41127
41163
  // TODO: only-child <group><label>
41128
41164
  label: createNodeLabel(this, definition),
41129
41165
  hint: null,
41130
- attributes: attributeState.getAttributes,
41166
+ attributes: this.attributeState.getAttributes,
41131
41167
  children: childrenState.childIds,
41132
41168
  valueOptions: null,
41133
41169
  value: null
@@ -41150,6 +41186,7 @@ class RepeatInstance extends DescendantNode {
41150
41186
  this.instanceState = createTemplatedNodeInstanceState(this);
41151
41187
  }
41152
41188
  childrenState;
41189
+ attributeState;
41153
41190
  currentIndex;
41154
41191
  [XPathNodeKindKey] = "element";
41155
41192
  // InstanceNode
@@ -41184,6 +41221,9 @@ class RepeatInstance extends DescendantNode {
41184
41221
  getChildren() {
41185
41222
  return this.childrenState.getChildren();
41186
41223
  }
41224
+ getAttributes() {
41225
+ return this.attributeState.getAttributes();
41226
+ }
41187
41227
  }
41188
41228
 
41189
41229
  class BaseRepeatRange extends DescendantNode {
@@ -41508,6 +41548,7 @@ class SelectControl extends ValueNode {
41508
41548
  // InstanceNode
41509
41549
  state;
41510
41550
  engineState;
41551
+ attributeState;
41511
41552
  // SelectNode
41512
41553
  nodeType = "select";
41513
41554
  selectType;
@@ -41519,7 +41560,7 @@ class SelectControl extends ValueNode {
41519
41560
  super(parent, instanceNode, definition, codec);
41520
41561
  this.appearances = definition.bodyElement.appearances;
41521
41562
  this.selectType = definition.bodyElement.type;
41522
- const attributeState = createAttributeState(this.scope);
41563
+ this.attributeState = createAttributeState(this.scope);
41523
41564
  const valueOptions = createItemCollection(this);
41524
41565
  const isSelectWithImages = this.scope.runTask(() => {
41525
41566
  return createMemo(() => valueOptions().some((item) => !!item.label.imageSource));
@@ -41556,7 +41597,7 @@ class SelectControl extends ValueNode {
41556
41597
  label: createNodeLabel(this, definition),
41557
41598
  hint: createFieldHint(this, definition),
41558
41599
  children: null,
41559
- attributes: attributeState.getAttributes,
41600
+ attributes: this.attributeState.getAttributes,
41560
41601
  valueOptions,
41561
41602
  value: valueState,
41562
41603
  instanceValue: this.getInstanceValue,
@@ -41564,7 +41605,7 @@ class SelectControl extends ValueNode {
41564
41605
  },
41565
41606
  this.instanceConfig
41566
41607
  );
41567
- attributeState.setAttributes(buildAttributes(this));
41608
+ this.attributeState.setAttributes(buildAttributes(this));
41568
41609
  this.state = state;
41569
41610
  this.engineState = state.engineState;
41570
41611
  this.currentState = state.currentState;
@@ -41623,6 +41664,9 @@ class SelectControl extends ValueNode {
41623
41664
  const option = this.mapOptionsByValue().get(value);
41624
41665
  return option?.label?.asString ?? null;
41625
41666
  }
41667
+ getAttributes() {
41668
+ return this.attributeState.getAttributes();
41669
+ }
41626
41670
  }
41627
41671
 
41628
41672
  const TRIGGER_INSTANCE_VALUES = {
@@ -41675,6 +41719,7 @@ class TriggerControl extends ValueNode {
41675
41719
  // InstanceNode
41676
41720
  state;
41677
41721
  engineState;
41722
+ attributeState;
41678
41723
  // TriggerNode
41679
41724
  nodeType = "trigger";
41680
41725
  appearances;
@@ -41683,7 +41728,7 @@ class TriggerControl extends ValueNode {
41683
41728
  constructor(parent, instanceNode, definition) {
41684
41729
  super(parent, instanceNode, definition, codec);
41685
41730
  this.appearances = definition.bodyElement.appearances;
41686
- const attributeState = createAttributeState(this.scope);
41731
+ this.attributeState = createAttributeState(this.scope);
41687
41732
  const state = createSharedNodeState(
41688
41733
  this.scope,
41689
41734
  {
@@ -41694,18 +41739,21 @@ class TriggerControl extends ValueNode {
41694
41739
  label: createNodeLabel(this, definition),
41695
41740
  hint: createFieldHint(this, definition),
41696
41741
  children: null,
41697
- attributes: attributeState.getAttributes,
41742
+ attributes: this.attributeState.getAttributes,
41698
41743
  valueOptions: null,
41699
41744
  value: this.valueState,
41700
41745
  instanceValue: this.getInstanceValue
41701
41746
  },
41702
41747
  this.instanceConfig
41703
41748
  );
41704
- attributeState.setAttributes(buildAttributes(this));
41749
+ this.attributeState.setAttributes(buildAttributes(this));
41705
41750
  this.state = state;
41706
41751
  this.engineState = state.engineState;
41707
41752
  this.currentState = state.currentState;
41708
41753
  }
41754
+ getAttributes() {
41755
+ return this.attributeState.getAttributes();
41756
+ }
41709
41757
  // TriggerNode
41710
41758
  setValue(value) {
41711
41759
  this.setValueState(value);
@@ -41894,7 +41942,7 @@ class UploadControl extends DescendantNode {
41894
41942
  this.nodeOptions = definition.bodyElement.options;
41895
41943
  const instanceAttachment = createInstanceAttachment(this);
41896
41944
  this.instanceAttachment = instanceAttachment;
41897
- const attributeState = createAttributeState(this.scope);
41945
+ this.attributeState = createAttributeState(this.scope);
41898
41946
  this.decodeInstanceValue = instanceAttachment.decodeInstanceValue;
41899
41947
  this.getXPathValue = instanceAttachment.getInstanceValue;
41900
41948
  const state = createSharedNodeState(
@@ -41909,7 +41957,7 @@ class UploadControl extends DescendantNode {
41909
41957
  children: null,
41910
41958
  valueOptions: null,
41911
41959
  value: instanceAttachment.valueState,
41912
- attributes: attributeState.getAttributes,
41960
+ attributes: this.attributeState.getAttributes,
41913
41961
  instanceValue: instanceAttachment.getInstanceValue
41914
41962
  },
41915
41963
  this.instanceConfig
@@ -41918,6 +41966,7 @@ class UploadControl extends DescendantNode {
41918
41966
  this.engineState = state.engineState;
41919
41967
  this.currentState = state.currentState;
41920
41968
  this.validation = createValidationState(this, this.instanceConfig);
41969
+ this.attributeState.setAttributes(buildAttributes(this));
41921
41970
  this.instanceState = createValueNodeInstanceState(this);
41922
41971
  }
41923
41972
  static from(parent, instanceNode, definition) {
@@ -41932,6 +41981,7 @@ class UploadControl extends DescendantNode {
41932
41981
  // InstanceNode
41933
41982
  state;
41934
41983
  engineState;
41984
+ attributeState;
41935
41985
  // InstanceValueContext
41936
41986
  decodeInstanceValue;
41937
41987
  // UploadNode
@@ -41955,6 +42005,9 @@ class UploadControl extends DescendantNode {
41955
42005
  getChildren() {
41956
42006
  return [];
41957
42007
  }
42008
+ getAttributes() {
42009
+ return this.attributeState.getAttributes();
42010
+ }
41958
42011
  // UploadNode
41959
42012
  setValue(value) {
41960
42013
  this.instanceAttachment.setValue(value);
@@ -42246,6 +42299,7 @@ class Root extends DescendantNode {
42246
42299
  // DescendantNode
42247
42300
  state;
42248
42301
  engineState;
42302
+ attributeState;
42249
42303
  hasReadonlyAncestor = () => false;
42250
42304
  isSelfReadonly = () => false;
42251
42305
  isReadonly = () => false;
@@ -42272,7 +42326,7 @@ class Root extends DescendantNode {
42272
42326
  });
42273
42327
  this.classes = parent.classes;
42274
42328
  const childrenState = createChildrenState(this);
42275
- const attributeState = createAttributeState(this.scope);
42329
+ this.attributeState = createAttributeState(this.scope);
42276
42330
  this.childrenState = childrenState;
42277
42331
  this.languages = parent.languages;
42278
42332
  const state = createSharedNodeState(
@@ -42288,7 +42342,7 @@ class Root extends DescendantNode {
42288
42342
  valueOptions: null,
42289
42343
  value: null,
42290
42344
  children: childrenState.childIds,
42291
- attributes: attributeState.getAttributes
42345
+ attributes: this.attributeState.getAttributes
42292
42346
  },
42293
42347
  this.instanceConfig
42294
42348
  );
@@ -42300,13 +42354,16 @@ class Root extends DescendantNode {
42300
42354
  childrenState
42301
42355
  );
42302
42356
  childrenState.setChildren(buildChildren(this));
42303
- attributeState.setAttributes(buildAttributes(this));
42357
+ this.attributeState.setAttributes(buildAttributes(this));
42304
42358
  this.validationState = createAggregatedViolations(this, this.instanceConfig);
42305
42359
  this.instanceState = createRootInstanceState(this);
42306
42360
  }
42307
42361
  getChildren() {
42308
42362
  return this.childrenState.getChildren();
42309
42363
  }
42364
+ getAttributes() {
42365
+ return this.attributeState.getAttributes();
42366
+ }
42310
42367
  // RootNode
42311
42368
  setLanguage(language) {
42312
42369
  this.rootDocument.setLanguage(language);
@@ -42325,6 +42382,7 @@ class PrimaryInstance extends InstanceNode {
42325
42382
  // InstanceNode
42326
42383
  state;
42327
42384
  engineState;
42385
+ attributeState;
42328
42386
  instanceNode;
42329
42387
  getChildren;
42330
42388
  hasReadonlyAncestor = () => false;
@@ -42381,7 +42439,7 @@ class PrimaryInstance extends InstanceNode {
42381
42439
  this.evaluator = evaluator;
42382
42440
  this.classes = definition.classes;
42383
42441
  const childrenState = createChildrenState(this);
42384
- const attributeState = createAttributeState(this.scope);
42442
+ this.attributeState = createAttributeState(this.scope);
42385
42443
  this.getChildren = childrenState.getChildren;
42386
42444
  const stateSpec = {
42387
42445
  activeLanguage: getActiveLanguage,
@@ -42394,7 +42452,7 @@ class PrimaryInstance extends InstanceNode {
42394
42452
  valueOptions: null,
42395
42453
  value: null,
42396
42454
  children: childrenState.childIds,
42397
- attributes: attributeState.getAttributes
42455
+ attributes: this.attributeState.getAttributes
42398
42456
  };
42399
42457
  const state = createSharedNodeState(scope, stateSpec, config);
42400
42458
  this.state = state;
@@ -42409,9 +42467,12 @@ class PrimaryInstance extends InstanceNode {
42409
42467
  };
42410
42468
  this.instanceState = createPrimaryInstanceState(this);
42411
42469
  childrenState.setChildren([root]);
42412
- attributeState.setAttributes(buildAttributes(this));
42470
+ this.attributeState.setAttributes(buildAttributes(this));
42413
42471
  setIsAttached(true);
42414
42472
  }
42473
+ getAttributes() {
42474
+ return this.attributeState.getAttributes();
42475
+ }
42415
42476
  // PrimaryInstanceDocument
42416
42477
  /**
42417
42478
  * @todo Note that this method's signature is intentionally derived from