@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/solid.js CHANGED
@@ -20909,6 +20909,7 @@ class StaticAttribute extends StaticNode {
20909
20909
  nodeset;
20910
20910
  attributes = [];
20911
20911
  children = null;
20912
+ childElements = [];
20912
20913
  value;
20913
20914
  // XFormsXPathAttribute
20914
20915
  getXPathValue() {
@@ -22027,6 +22028,7 @@ class AttributeDefinition extends NodeDefinition {
22027
22028
  serializedXML;
22028
22029
  value;
22029
22030
  type = "attribute";
22031
+ valueType = "string";
22030
22032
  namespaceDeclarations;
22031
22033
  bodyElement = null;
22032
22034
  root;
@@ -22038,6 +22040,10 @@ class AttributeDefinition extends NodeDefinition {
22038
22040
  serializeAttributeXML() {
22039
22041
  return this.serializedXML;
22040
22042
  }
22043
+ toJSON() {
22044
+ const { bind, bodyElement, parent, root, ...rest } = this;
22045
+ return rest;
22046
+ }
22041
22047
  }
22042
22048
 
22043
22049
  const isNonNamespaceAttribute = (attribute) => {
@@ -27610,6 +27616,7 @@ const resolveEngineXPathNodeNamespaceURI = (node, prefix) => {
27610
27616
  case "static-element":
27611
27617
  case "static-text":
27612
27618
  return resolveNamespaceURIFromStaticNodeContext(node, prefix);
27619
+ case "attribute":
27613
27620
  case "group":
27614
27621
  case "input":
27615
27622
  case "model-value":
@@ -27642,10 +27649,13 @@ class XPathFunctionalityPendingError extends XPathFunctionalityError {
27642
27649
  const getContainingEngineXPathDocument = (node) => {
27643
27650
  return node.rootDocument;
27644
27651
  };
27645
- const getEngineXPathAttributes = (node) => {
27652
+ const getAttributes = (node) => {
27646
27653
  if (node.nodeType === "static-element") {
27647
27654
  return node.attributes;
27648
27655
  }
27656
+ if (isEngineXPathElement(node)) {
27657
+ return node.getAttributes();
27658
+ }
27649
27659
  return [];
27650
27660
  };
27651
27661
  const getNamespaceDeclarations = () => [];
@@ -27802,7 +27812,7 @@ const engineDOMAdapter = {
27802
27812
  getNodeValue: getEngineXPathNodeValue,
27803
27813
  // XPathTraversalAdapter
27804
27814
  compareDocumentOrder,
27805
- getAttributes: getEngineXPathAttributes,
27815
+ getAttributes,
27806
27816
  getChildElements,
27807
27817
  getChildNodes,
27808
27818
  getContainingDocument: getContainingEngineXPathDocument,
@@ -29238,6 +29248,21 @@ const createCalculation = (context, setRelevantValue, computation) => {
29238
29248
  }
29239
29249
  });
29240
29250
  };
29251
+ const createActionCalculation = (context, setRelevantValue, computation) => {
29252
+ createComputed(() => {
29253
+ if (context.isAttached()) {
29254
+ const relevant = untrack(() => context.isRelevant());
29255
+ if (!relevant) {
29256
+ return;
29257
+ }
29258
+ const calculated = untrack(() => {
29259
+ return context.evaluator.evaluateString(computation.expression, context);
29260
+ });
29261
+ const value = context.decodeInstanceValue(calculated);
29262
+ setRelevantValue(value);
29263
+ }
29264
+ });
29265
+ };
29241
29266
  const createValueChangedCalculation = (context, setRelevantValue, action) => {
29242
29267
  const { source, ref } = bindToRepeatInstance(context, action);
29243
29268
  if (!source) {
@@ -29263,17 +29288,17 @@ const createValueChangedCalculation = (context, setRelevantValue, action) => {
29263
29288
  const registerAction = (context, setValue, action) => {
29264
29289
  if (action.events.includes(XFORM_EVENT.odkInstanceFirstLoad)) {
29265
29290
  if (isInstanceFirstLoad(context)) {
29266
- createCalculation(context, setValue, action.computation);
29291
+ createActionCalculation(context, setValue, action.computation);
29267
29292
  }
29268
29293
  }
29269
29294
  if (action.events.includes(XFORM_EVENT.odkInstanceLoad)) {
29270
29295
  if (!isAddingRepeatChild(context)) {
29271
- createCalculation(context, setValue, action.computation);
29296
+ createActionCalculation(context, setValue, action.computation);
29272
29297
  }
29273
29298
  }
29274
29299
  if (action.events.includes(XFORM_EVENT.odkNewRepeat)) {
29275
29300
  if (isAddingRepeatChild(context)) {
29276
- createCalculation(context, setValue, action.computation);
29301
+ createActionCalculation(context, setValue, action.computation);
29277
29302
  }
29278
29303
  }
29279
29304
  if (action.events.includes(XFORM_EVENT.xformsValueChanged)) {
@@ -29299,178 +29324,6 @@ const createInstanceValueState = (context) => {
29299
29324
  });
29300
29325
  };
29301
29326
 
29302
- class Attribute {
29303
- constructor(owner, definition, instanceNode) {
29304
- this.owner = owner;
29305
- this.definition = definition;
29306
- this.instanceNode = instanceNode;
29307
- const codec = getSharedValueCodec("string");
29308
- this.contextNode = owner;
29309
- this.scope = owner.scope;
29310
- this.rootDocument = owner.rootDocument;
29311
- this.root = owner.root;
29312
- this.instanceConfig = owner.instanceConfig;
29313
- this.getActiveLanguage = owner.getActiveLanguage;
29314
- this.validationState = { violations: [] };
29315
- this.valueType = "string";
29316
- this.evaluator = owner.evaluator;
29317
- this.decodeInstanceValue = codec.decodeInstanceValue;
29318
- const instanceValueState = createInstanceValueState(this);
29319
- const valueState = codec.createRuntimeValueState(instanceValueState);
29320
- const [getInstanceValue] = instanceValueState;
29321
- const [, setValueState] = valueState;
29322
- this.getInstanceValue = getInstanceValue;
29323
- this.setValueState = setValueState;
29324
- this.valueState = valueState;
29325
- const state = createSharedNodeState(
29326
- owner.scope,
29327
- {
29328
- value: this.valueState,
29329
- instanceValue: this.getInstanceValue,
29330
- relevant: this.owner.isRelevant
29331
- },
29332
- this.instanceConfig
29333
- );
29334
- this.state = state;
29335
- this.engineState = state.engineState;
29336
- this.currentState = state.currentState;
29337
- this.instanceState = createAttributeNodeInstanceState(this);
29338
- }
29339
- [XPathNodeKindKey] = "attribute";
29340
- state;
29341
- engineState;
29342
- validationState;
29343
- nodeType = "attribute";
29344
- currentState;
29345
- instanceState;
29346
- appearances = null;
29347
- nodeOptions = null;
29348
- valueType;
29349
- decodeInstanceValue;
29350
- getInstanceValue;
29351
- valueState;
29352
- setValueState;
29353
- evaluator;
29354
- getActiveLanguage;
29355
- contextNode;
29356
- scope;
29357
- rootDocument;
29358
- instanceConfig;
29359
- root;
29360
- isRelevant = () => {
29361
- return this.owner.isRelevant();
29362
- };
29363
- isAttached = () => {
29364
- return this.owner.isAttached();
29365
- };
29366
- isReadonly = () => {
29367
- return true;
29368
- };
29369
- hasReadonlyAncestor = () => {
29370
- const { owner } = this;
29371
- return owner.hasReadonlyAncestor() || owner.isReadonly();
29372
- };
29373
- hasNonRelevantAncestor = () => {
29374
- const { owner } = this;
29375
- return owner.hasNonRelevantAncestor() || !owner.isRelevant();
29376
- };
29377
- contextReference = () => {
29378
- return this.owner.contextReference() + "/@" + this.definition.qualifiedName.getPrefixedName();
29379
- };
29380
- setValue(value) {
29381
- this.setValueState(value);
29382
- return this.root;
29383
- }
29384
- getChildren() {
29385
- return [];
29386
- }
29387
- getXPathChildNodes() {
29388
- return [];
29389
- }
29390
- getXPathValue() {
29391
- return "";
29392
- }
29393
- }
29394
-
29395
- function buildAttributes(owner) {
29396
- return Array.from(owner.definition.attributes.values()).map((attributeDefinition) => {
29397
- return new Attribute(owner, attributeDefinition, attributeDefinition.template);
29398
- });
29399
- }
29400
-
29401
- class InstanceAttachmentsState extends Map {
29402
- constructor(sourceAttachments = null) {
29403
- super();
29404
- this.sourceAttachments = sourceAttachments;
29405
- }
29406
- getInitialFileValue(instanceNode) {
29407
- if (instanceNode == null) {
29408
- return null;
29409
- }
29410
- return this.sourceAttachments?.get(instanceNode.value) ?? null;
29411
- }
29412
- }
29413
-
29414
- const createRootInstanceState = (node) => {
29415
- return {
29416
- get instanceXML() {
29417
- return serializeParentElementXML(
29418
- node.definition.qualifiedName,
29419
- node.currentState.children,
29420
- node.currentState.attributes,
29421
- node.definition.namespaceDeclarations
29422
- );
29423
- }
29424
- };
29425
- };
29426
-
29427
- const violationReference = (node) => {
29428
- const violation = node.getViolation();
29429
- if (violation == null) {
29430
- return null;
29431
- }
29432
- const { nodeId } = node;
29433
- return {
29434
- nodeId,
29435
- get reference() {
29436
- return node.currentState.reference;
29437
- },
29438
- violation
29439
- };
29440
- };
29441
- const collectViolationReferences = (context) => {
29442
- return context.getChildren().flatMap((child) => {
29443
- switch (child.nodeType) {
29444
- case "model-value":
29445
- case "input":
29446
- case "note":
29447
- case "select":
29448
- case "range":
29449
- case "rank":
29450
- case "trigger":
29451
- case "upload": {
29452
- const reference = violationReference(child);
29453
- if (reference == null) {
29454
- return [];
29455
- }
29456
- return [reference];
29457
- }
29458
- default:
29459
- return collectViolationReferences(child);
29460
- }
29461
- });
29462
- };
29463
- const createAggregatedViolations = (context, options) => {
29464
- const { scope } = context;
29465
- return scope.runTask(() => {
29466
- const violations = createMemo(() => {
29467
- return collectViolationReferences(context);
29468
- });
29469
- const spec = { violations };
29470
- return createSharedNodeState(scope, spec, options).currentState;
29471
- });
29472
- };
29473
-
29474
29327
  const XFORMS_XPATH_NODE_RANGE_KIND = "comment";
29475
29328
 
29476
29329
  class DescendantNode extends InstanceNode {
@@ -29603,6 +29456,165 @@ class DescendantNode extends InstanceNode {
29603
29456
  }
29604
29457
  }
29605
29458
 
29459
+ class Attribute extends DescendantNode {
29460
+ constructor(owner, definition, instanceNode) {
29461
+ const computeReference = () => {
29462
+ return `${this.owner.contextReference()}/@${this.definition.qualifiedName.getPrefixedName()}`;
29463
+ };
29464
+ super(owner, instanceNode, definition, { computeReference });
29465
+ this.owner = owner;
29466
+ this.instanceNode = instanceNode;
29467
+ const codec = getSharedValueCodec("string");
29468
+ this.validationState = { violations: [] };
29469
+ this.valueType = "string";
29470
+ this.decodeInstanceValue = codec.decodeInstanceValue;
29471
+ const instanceValueState = createInstanceValueState(this);
29472
+ const valueState = codec.createRuntimeValueState(instanceValueState);
29473
+ const [getInstanceValue] = instanceValueState;
29474
+ const [, setValueState] = valueState;
29475
+ this.getInstanceValue = getInstanceValue;
29476
+ this.setValueState = setValueState;
29477
+ this.valueState = valueState;
29478
+ const state = createSharedNodeState(
29479
+ owner.scope,
29480
+ {
29481
+ value: this.valueState,
29482
+ instanceValue: this.getInstanceValue,
29483
+ relevant: this.owner.isRelevant,
29484
+ readonly: () => true,
29485
+ reference: this.contextReference,
29486
+ required: () => false,
29487
+ children: null,
29488
+ label: () => null,
29489
+ hint: () => null,
29490
+ attributes: () => [],
29491
+ valueOptions: () => []
29492
+ },
29493
+ this.instanceConfig
29494
+ );
29495
+ this.state = state;
29496
+ this.engineState = state.engineState;
29497
+ this.currentState = state.currentState;
29498
+ this.instanceState = createAttributeNodeInstanceState(this);
29499
+ this.attributeState = createAttributeState(this.scope);
29500
+ this.getXPathValue = () => {
29501
+ return this.getInstanceValue();
29502
+ };
29503
+ }
29504
+ [XPathNodeKindKey] = "attribute";
29505
+ state;
29506
+ engineState;
29507
+ validationState;
29508
+ nodeType = "attribute";
29509
+ currentState;
29510
+ instanceState;
29511
+ appearances = null;
29512
+ nodeOptions = null;
29513
+ valueType;
29514
+ decodeInstanceValue;
29515
+ getInstanceValue;
29516
+ valueState;
29517
+ setValueState;
29518
+ attributeState;
29519
+ isAttached = () => {
29520
+ return this.owner.isAttached();
29521
+ };
29522
+ getXPathValue;
29523
+ setValue(value) {
29524
+ this.setValueState(value);
29525
+ return this.root;
29526
+ }
29527
+ getAttributes() {
29528
+ return [];
29529
+ }
29530
+ getChildren() {
29531
+ return [];
29532
+ }
29533
+ }
29534
+
29535
+ function buildAttributes(owner) {
29536
+ const attributes = owner.definition.attributes;
29537
+ if (!attributes) {
29538
+ return [];
29539
+ }
29540
+ return Array.from(attributes.values()).map((attributeDefinition) => {
29541
+ return new Attribute(owner, attributeDefinition, attributeDefinition.template);
29542
+ });
29543
+ }
29544
+
29545
+ class InstanceAttachmentsState extends Map {
29546
+ constructor(sourceAttachments = null) {
29547
+ super();
29548
+ this.sourceAttachments = sourceAttachments;
29549
+ }
29550
+ getInitialFileValue(instanceNode) {
29551
+ if (instanceNode == null) {
29552
+ return null;
29553
+ }
29554
+ return this.sourceAttachments?.get(instanceNode.value) ?? null;
29555
+ }
29556
+ }
29557
+
29558
+ const createRootInstanceState = (node) => {
29559
+ return {
29560
+ get instanceXML() {
29561
+ return serializeParentElementXML(
29562
+ node.definition.qualifiedName,
29563
+ node.currentState.children,
29564
+ node.currentState.attributes,
29565
+ node.definition.namespaceDeclarations
29566
+ );
29567
+ }
29568
+ };
29569
+ };
29570
+
29571
+ const violationReference = (node) => {
29572
+ const violation = node.getViolation();
29573
+ if (violation == null) {
29574
+ return null;
29575
+ }
29576
+ const { nodeId } = node;
29577
+ return {
29578
+ nodeId,
29579
+ get reference() {
29580
+ return node.currentState.reference;
29581
+ },
29582
+ violation
29583
+ };
29584
+ };
29585
+ const collectViolationReferences = (context) => {
29586
+ return context.getChildren().flatMap((child) => {
29587
+ switch (child.nodeType) {
29588
+ case "model-value":
29589
+ case "input":
29590
+ case "note":
29591
+ case "select":
29592
+ case "range":
29593
+ case "rank":
29594
+ case "trigger":
29595
+ case "upload": {
29596
+ const reference = violationReference(child);
29597
+ if (reference == null) {
29598
+ return [];
29599
+ }
29600
+ return [reference];
29601
+ }
29602
+ default:
29603
+ return collectViolationReferences(child);
29604
+ }
29605
+ });
29606
+ };
29607
+ const createAggregatedViolations = (context, options) => {
29608
+ const { scope } = context;
29609
+ return scope.runTask(() => {
29610
+ const violations = createMemo(() => {
29611
+ return collectViolationReferences(context);
29612
+ });
29613
+ const spec = { violations };
29614
+ return createSharedNodeState(scope, spec, options).currentState;
29615
+ });
29616
+ };
29617
+
29606
29618
  const createParentNodeInstanceState = (node) => {
29607
29619
  return {
29608
29620
  get instanceXML() {
@@ -39891,6 +39903,7 @@ class Group extends DescendantNode {
39891
39903
  // InstanceNode
39892
39904
  state;
39893
39905
  engineState;
39906
+ attributeState;
39894
39907
  // GroupNode
39895
39908
  nodeType = "group";
39896
39909
  appearances;
@@ -39902,7 +39915,7 @@ class Group extends DescendantNode {
39902
39915
  super(parent, instanceNode, definition);
39903
39916
  this.appearances = definition.bodyElement?.appearances ?? null;
39904
39917
  const childrenState = createChildrenState(this);
39905
- const attributeState = createAttributeState(this.scope);
39918
+ this.attributeState = createAttributeState(this.scope);
39906
39919
  this.childrenState = childrenState;
39907
39920
  const state = createSharedNodeState(
39908
39921
  this.scope,
@@ -39914,7 +39927,7 @@ class Group extends DescendantNode {
39914
39927
  label: createNodeLabel(this, definition),
39915
39928
  hint: null,
39916
39929
  children: childrenState.childIds,
39917
- attributes: attributeState.getAttributes,
39930
+ attributes: this.attributeState.getAttributes,
39918
39931
  valueOptions: null,
39919
39932
  value: null
39920
39933
  },
@@ -39928,13 +39941,16 @@ class Group extends DescendantNode {
39928
39941
  childrenState
39929
39942
  );
39930
39943
  childrenState.setChildren(buildChildren(this));
39931
- attributeState.setAttributes(buildAttributes(this));
39944
+ this.attributeState.setAttributes(buildAttributes(this));
39932
39945
  this.validationState = createAggregatedViolations(this, this.instanceConfig);
39933
39946
  this.instanceState = createParentNodeInstanceState(this);
39934
39947
  }
39935
39948
  getChildren() {
39936
39949
  return this.childrenState.getChildren();
39937
39950
  }
39951
+ getAttributes() {
39952
+ return this.attributeState.getAttributes();
39953
+ }
39938
39954
  }
39939
39955
 
39940
39956
  const createFieldHint = (context, definition) => {
@@ -40138,6 +40154,7 @@ class InputControl extends ValueNode {
40138
40154
  // InstanceNode
40139
40155
  state;
40140
40156
  engineState;
40157
+ attributeState;
40141
40158
  // InputNode
40142
40159
  nodeType = "input";
40143
40160
  appearances;
@@ -40148,7 +40165,7 @@ class InputControl extends ValueNode {
40148
40165
  super(parent, instanceNode, definition, codec);
40149
40166
  this.appearances = definition.bodyElement.appearances;
40150
40167
  this.nodeOptions = nodeOptionsFactoryByType[definition.valueType](definition.bodyElement);
40151
- const attributeState = createAttributeState(this.scope);
40168
+ this.attributeState = createAttributeState(this.scope);
40152
40169
  const state = createSharedNodeState(
40153
40170
  this.scope,
40154
40171
  {
@@ -40159,14 +40176,14 @@ class InputControl extends ValueNode {
40159
40176
  label: createNodeLabel(this, definition),
40160
40177
  hint: createFieldHint(this, definition),
40161
40178
  children: null,
40162
- attributes: attributeState.getAttributes,
40179
+ attributes: this.attributeState.getAttributes,
40163
40180
  valueOptions: null,
40164
40181
  value: this.valueState,
40165
40182
  instanceValue: this.getInstanceValue
40166
40183
  },
40167
40184
  this.instanceConfig
40168
40185
  );
40169
- attributeState.setAttributes(buildAttributes(this));
40186
+ this.attributeState.setAttributes(buildAttributes(this));
40170
40187
  this.state = state;
40171
40188
  this.engineState = state.engineState;
40172
40189
  this.currentState = state.currentState;
@@ -40175,6 +40192,9 @@ class InputControl extends ValueNode {
40175
40192
  this.setValueState(value);
40176
40193
  return this.root;
40177
40194
  }
40195
+ getAttributes() {
40196
+ return this.attributeState.getAttributes();
40197
+ }
40178
40198
  }
40179
40199
 
40180
40200
  class ModelValue extends ValueNode {
@@ -40186,6 +40206,7 @@ class ModelValue extends ValueNode {
40186
40206
  // InstanceNode
40187
40207
  state;
40188
40208
  engineState;
40209
+ attributeState;
40189
40210
  // ModelValueNode
40190
40211
  nodeType = "model-value";
40191
40212
  appearances = null;
@@ -40194,7 +40215,7 @@ class ModelValue extends ValueNode {
40194
40215
  constructor(parent, instanceNode, definition) {
40195
40216
  const codec = getSharedValueCodec(definition.valueType);
40196
40217
  super(parent, instanceNode, definition, codec);
40197
- const attributeState = createAttributeState(this.scope);
40218
+ this.attributeState = createAttributeState(this.scope);
40198
40219
  const state = createSharedNodeState(
40199
40220
  this.scope,
40200
40221
  {
@@ -40205,18 +40226,21 @@ class ModelValue extends ValueNode {
40205
40226
  label: null,
40206
40227
  hint: null,
40207
40228
  children: null,
40208
- attributes: attributeState.getAttributes,
40229
+ attributes: this.attributeState.getAttributes,
40209
40230
  valueOptions: null,
40210
40231
  value: this.valueState,
40211
40232
  instanceValue: this.getInstanceValue
40212
40233
  },
40213
40234
  this.instanceConfig
40214
40235
  );
40215
- attributeState.setAttributes(buildAttributes(this));
40236
+ this.attributeState.setAttributes(buildAttributes(this));
40216
40237
  this.state = state;
40217
40238
  this.engineState = state.engineState;
40218
40239
  this.currentState = state.currentState;
40219
40240
  }
40241
+ getAttributes() {
40242
+ return this.attributeState.getAttributes();
40243
+ }
40220
40244
  }
40221
40245
 
40222
40246
  class NoteCodec extends ValueCodec {
@@ -40293,6 +40317,7 @@ class Note extends ValueNode {
40293
40317
  // InstanceNode
40294
40318
  state;
40295
40319
  engineState;
40320
+ attributeState;
40296
40321
  // NoteNode
40297
40322
  nodeType = "note";
40298
40323
  appearances;
@@ -40304,7 +40329,7 @@ class Note extends ValueNode {
40304
40329
  this.appearances = definition.bodyElement.appearances;
40305
40330
  const isReadonly = createNoteReadonlyThunk(this, definition);
40306
40331
  const noteTextComputation = createNoteText(this, definition.noteTextDefinition);
40307
- const attributeState = createAttributeState(this.scope);
40332
+ this.attributeState = createAttributeState(this.scope);
40308
40333
  let noteText;
40309
40334
  let label;
40310
40335
  let hint;
@@ -40335,18 +40360,21 @@ class Note extends ValueNode {
40335
40360
  hint,
40336
40361
  noteText,
40337
40362
  children: null,
40338
- attributes: attributeState.getAttributes,
40363
+ attributes: this.attributeState.getAttributes,
40339
40364
  valueOptions: null,
40340
40365
  value: this.valueState,
40341
40366
  instanceValue: this.getInstanceValue
40342
40367
  },
40343
40368
  this.instanceConfig
40344
40369
  );
40345
- attributeState.setAttributes(buildAttributes(this));
40370
+ this.attributeState.setAttributes(buildAttributes(this));
40346
40371
  this.state = state;
40347
40372
  this.engineState = state.engineState;
40348
40373
  this.currentState = state.currentState;
40349
40374
  }
40375
+ getAttributes() {
40376
+ return this.attributeState.getAttributes();
40377
+ }
40350
40378
  }
40351
40379
 
40352
40380
  class RangeCodec extends ValueCodec {
@@ -40396,6 +40424,7 @@ class RangeControl extends ValueNode {
40396
40424
  // InstanceNode
40397
40425
  state;
40398
40426
  engineState;
40427
+ attributeState;
40399
40428
  // RangeNode
40400
40429
  nodeType = "range";
40401
40430
  appearances;
@@ -40406,7 +40435,7 @@ class RangeControl extends ValueNode {
40406
40435
  const codec = new RangeCodec(baseCodec, definition);
40407
40436
  super(parent, instanceNode, definition, codec);
40408
40437
  this.appearances = definition.bodyElement.appearances;
40409
- const attributeState = createAttributeState(this.scope);
40438
+ this.attributeState = createAttributeState(this.scope);
40410
40439
  const state = createSharedNodeState(
40411
40440
  this.scope,
40412
40441
  {
@@ -40417,14 +40446,14 @@ class RangeControl extends ValueNode {
40417
40446
  label: createNodeLabel(this, definition),
40418
40447
  hint: createFieldHint(this, definition),
40419
40448
  children: null,
40420
- attributes: attributeState.getAttributes,
40449
+ attributes: this.attributeState.getAttributes,
40421
40450
  valueOptions: null,
40422
40451
  value: this.valueState,
40423
40452
  instanceValue: this.getInstanceValue
40424
40453
  },
40425
40454
  this.instanceConfig
40426
40455
  );
40427
- attributeState.setAttributes(buildAttributes(this));
40456
+ this.attributeState.setAttributes(buildAttributes(this));
40428
40457
  this.state = state;
40429
40458
  this.engineState = state.engineState;
40430
40459
  this.currentState = state.currentState;
@@ -40433,6 +40462,9 @@ class RangeControl extends ValueNode {
40433
40462
  this.setValueState(value);
40434
40463
  return this.root;
40435
40464
  }
40465
+ getAttributes() {
40466
+ return this.attributeState.getAttributes();
40467
+ }
40436
40468
  }
40437
40469
 
40438
40470
  class RankMissingValueError extends Error {
@@ -40624,6 +40656,7 @@ class RankControl extends ValueNode {
40624
40656
  // InstanceNode
40625
40657
  state;
40626
40658
  engineState;
40659
+ attributeState;
40627
40660
  // RankNode
40628
40661
  nodeType = "rank";
40629
40662
  appearances;
@@ -40642,7 +40675,7 @@ class RankControl extends ValueNode {
40642
40675
  this.mapOptionsByValue = mapOptionsByValue;
40643
40676
  const baseValueState = this.valueState;
40644
40677
  const [baseGetValue, setValue] = baseValueState;
40645
- const attributeState = createAttributeState(this.scope);
40678
+ this.attributeState = createAttributeState(this.scope);
40646
40679
  const getValue = this.scope.runTask(() => {
40647
40680
  return createMemo(() => {
40648
40681
  const options = valueOptions();
@@ -40677,18 +40710,21 @@ class RankControl extends ValueNode {
40677
40710
  label: createNodeLabel(this, definition),
40678
40711
  hint: createFieldHint(this, definition),
40679
40712
  children: null,
40680
- attributes: attributeState.getAttributes,
40713
+ attributes: this.attributeState.getAttributes,
40681
40714
  valueOptions,
40682
40715
  value: valueState,
40683
40716
  instanceValue: this.getInstanceValue
40684
40717
  },
40685
40718
  this.instanceConfig
40686
40719
  );
40687
- attributeState.setAttributes(buildAttributes(this));
40720
+ this.attributeState.setAttributes(buildAttributes(this));
40688
40721
  this.state = state;
40689
40722
  this.engineState = state.engineState;
40690
40723
  this.currentState = state.currentState;
40691
40724
  }
40725
+ getAttributes() {
40726
+ return this.attributeState.getAttributes();
40727
+ }
40692
40728
  getValueLabel(value) {
40693
40729
  const valueOption = this.currentState.valueOptions.find((item) => item.value === value);
40694
40730
  return valueOption?.label ?? null;
@@ -40771,7 +40807,7 @@ class RepeatInstance extends DescendantNode {
40771
40807
  this.parent = parent;
40772
40808
  this.appearances = definition.bodyElement.appearances;
40773
40809
  const childrenState = createChildrenState(this);
40774
- const attributeState = createAttributeState(this.scope);
40810
+ this.attributeState = createAttributeState(this.scope);
40775
40811
  this.childrenState = childrenState;
40776
40812
  this.currentIndex = currentIndex;
40777
40813
  const state = createSharedNodeState(
@@ -40784,7 +40820,7 @@ class RepeatInstance extends DescendantNode {
40784
40820
  // TODO: only-child <group><label>
40785
40821
  label: createNodeLabel(this, definition),
40786
40822
  hint: null,
40787
- attributes: attributeState.getAttributes,
40823
+ attributes: this.attributeState.getAttributes,
40788
40824
  children: childrenState.childIds,
40789
40825
  valueOptions: null,
40790
40826
  value: null
@@ -40807,6 +40843,7 @@ class RepeatInstance extends DescendantNode {
40807
40843
  this.instanceState = createTemplatedNodeInstanceState(this);
40808
40844
  }
40809
40845
  childrenState;
40846
+ attributeState;
40810
40847
  currentIndex;
40811
40848
  [XPathNodeKindKey] = "element";
40812
40849
  // InstanceNode
@@ -40841,6 +40878,9 @@ class RepeatInstance extends DescendantNode {
40841
40878
  getChildren() {
40842
40879
  return this.childrenState.getChildren();
40843
40880
  }
40881
+ getAttributes() {
40882
+ return this.attributeState.getAttributes();
40883
+ }
40844
40884
  }
40845
40885
 
40846
40886
  class BaseRepeatRange extends DescendantNode {
@@ -41165,6 +41205,7 @@ class SelectControl extends ValueNode {
41165
41205
  // InstanceNode
41166
41206
  state;
41167
41207
  engineState;
41208
+ attributeState;
41168
41209
  // SelectNode
41169
41210
  nodeType = "select";
41170
41211
  selectType;
@@ -41176,7 +41217,7 @@ class SelectControl extends ValueNode {
41176
41217
  super(parent, instanceNode, definition, codec);
41177
41218
  this.appearances = definition.bodyElement.appearances;
41178
41219
  this.selectType = definition.bodyElement.type;
41179
- const attributeState = createAttributeState(this.scope);
41220
+ this.attributeState = createAttributeState(this.scope);
41180
41221
  const valueOptions = createItemCollection(this);
41181
41222
  const isSelectWithImages = this.scope.runTask(() => {
41182
41223
  return createMemo(() => valueOptions().some((item) => !!item.label.imageSource));
@@ -41213,7 +41254,7 @@ class SelectControl extends ValueNode {
41213
41254
  label: createNodeLabel(this, definition),
41214
41255
  hint: createFieldHint(this, definition),
41215
41256
  children: null,
41216
- attributes: attributeState.getAttributes,
41257
+ attributes: this.attributeState.getAttributes,
41217
41258
  valueOptions,
41218
41259
  value: valueState,
41219
41260
  instanceValue: this.getInstanceValue,
@@ -41221,7 +41262,7 @@ class SelectControl extends ValueNode {
41221
41262
  },
41222
41263
  this.instanceConfig
41223
41264
  );
41224
- attributeState.setAttributes(buildAttributes(this));
41265
+ this.attributeState.setAttributes(buildAttributes(this));
41225
41266
  this.state = state;
41226
41267
  this.engineState = state.engineState;
41227
41268
  this.currentState = state.currentState;
@@ -41280,6 +41321,9 @@ class SelectControl extends ValueNode {
41280
41321
  const option = this.mapOptionsByValue().get(value);
41281
41322
  return option?.label?.asString ?? null;
41282
41323
  }
41324
+ getAttributes() {
41325
+ return this.attributeState.getAttributes();
41326
+ }
41283
41327
  }
41284
41328
 
41285
41329
  const TRIGGER_INSTANCE_VALUES = {
@@ -41332,6 +41376,7 @@ class TriggerControl extends ValueNode {
41332
41376
  // InstanceNode
41333
41377
  state;
41334
41378
  engineState;
41379
+ attributeState;
41335
41380
  // TriggerNode
41336
41381
  nodeType = "trigger";
41337
41382
  appearances;
@@ -41340,7 +41385,7 @@ class TriggerControl extends ValueNode {
41340
41385
  constructor(parent, instanceNode, definition) {
41341
41386
  super(parent, instanceNode, definition, codec);
41342
41387
  this.appearances = definition.bodyElement.appearances;
41343
- const attributeState = createAttributeState(this.scope);
41388
+ this.attributeState = createAttributeState(this.scope);
41344
41389
  const state = createSharedNodeState(
41345
41390
  this.scope,
41346
41391
  {
@@ -41351,18 +41396,21 @@ class TriggerControl extends ValueNode {
41351
41396
  label: createNodeLabel(this, definition),
41352
41397
  hint: createFieldHint(this, definition),
41353
41398
  children: null,
41354
- attributes: attributeState.getAttributes,
41399
+ attributes: this.attributeState.getAttributes,
41355
41400
  valueOptions: null,
41356
41401
  value: this.valueState,
41357
41402
  instanceValue: this.getInstanceValue
41358
41403
  },
41359
41404
  this.instanceConfig
41360
41405
  );
41361
- attributeState.setAttributes(buildAttributes(this));
41406
+ this.attributeState.setAttributes(buildAttributes(this));
41362
41407
  this.state = state;
41363
41408
  this.engineState = state.engineState;
41364
41409
  this.currentState = state.currentState;
41365
41410
  }
41411
+ getAttributes() {
41412
+ return this.attributeState.getAttributes();
41413
+ }
41366
41414
  // TriggerNode
41367
41415
  setValue(value) {
41368
41416
  this.setValueState(value);
@@ -41551,7 +41599,7 @@ class UploadControl extends DescendantNode {
41551
41599
  this.nodeOptions = definition.bodyElement.options;
41552
41600
  const instanceAttachment = createInstanceAttachment(this);
41553
41601
  this.instanceAttachment = instanceAttachment;
41554
- const attributeState = createAttributeState(this.scope);
41602
+ this.attributeState = createAttributeState(this.scope);
41555
41603
  this.decodeInstanceValue = instanceAttachment.decodeInstanceValue;
41556
41604
  this.getXPathValue = instanceAttachment.getInstanceValue;
41557
41605
  const state = createSharedNodeState(
@@ -41566,7 +41614,7 @@ class UploadControl extends DescendantNode {
41566
41614
  children: null,
41567
41615
  valueOptions: null,
41568
41616
  value: instanceAttachment.valueState,
41569
- attributes: attributeState.getAttributes,
41617
+ attributes: this.attributeState.getAttributes,
41570
41618
  instanceValue: instanceAttachment.getInstanceValue
41571
41619
  },
41572
41620
  this.instanceConfig
@@ -41575,6 +41623,7 @@ class UploadControl extends DescendantNode {
41575
41623
  this.engineState = state.engineState;
41576
41624
  this.currentState = state.currentState;
41577
41625
  this.validation = createValidationState(this, this.instanceConfig);
41626
+ this.attributeState.setAttributes(buildAttributes(this));
41578
41627
  this.instanceState = createValueNodeInstanceState(this);
41579
41628
  }
41580
41629
  static from(parent, instanceNode, definition) {
@@ -41589,6 +41638,7 @@ class UploadControl extends DescendantNode {
41589
41638
  // InstanceNode
41590
41639
  state;
41591
41640
  engineState;
41641
+ attributeState;
41592
41642
  // InstanceValueContext
41593
41643
  decodeInstanceValue;
41594
41644
  // UploadNode
@@ -41612,6 +41662,9 @@ class UploadControl extends DescendantNode {
41612
41662
  getChildren() {
41613
41663
  return [];
41614
41664
  }
41665
+ getAttributes() {
41666
+ return this.attributeState.getAttributes();
41667
+ }
41615
41668
  // UploadNode
41616
41669
  setValue(value) {
41617
41670
  this.instanceAttachment.setValue(value);
@@ -41903,6 +41956,7 @@ class Root extends DescendantNode {
41903
41956
  // DescendantNode
41904
41957
  state;
41905
41958
  engineState;
41959
+ attributeState;
41906
41960
  hasReadonlyAncestor = () => false;
41907
41961
  isSelfReadonly = () => false;
41908
41962
  isReadonly = () => false;
@@ -41929,7 +41983,7 @@ class Root extends DescendantNode {
41929
41983
  });
41930
41984
  this.classes = parent.classes;
41931
41985
  const childrenState = createChildrenState(this);
41932
- const attributeState = createAttributeState(this.scope);
41986
+ this.attributeState = createAttributeState(this.scope);
41933
41987
  this.childrenState = childrenState;
41934
41988
  this.languages = parent.languages;
41935
41989
  const state = createSharedNodeState(
@@ -41945,7 +41999,7 @@ class Root extends DescendantNode {
41945
41999
  valueOptions: null,
41946
42000
  value: null,
41947
42001
  children: childrenState.childIds,
41948
- attributes: attributeState.getAttributes
42002
+ attributes: this.attributeState.getAttributes
41949
42003
  },
41950
42004
  this.instanceConfig
41951
42005
  );
@@ -41957,13 +42011,16 @@ class Root extends DescendantNode {
41957
42011
  childrenState
41958
42012
  );
41959
42013
  childrenState.setChildren(buildChildren(this));
41960
- attributeState.setAttributes(buildAttributes(this));
42014
+ this.attributeState.setAttributes(buildAttributes(this));
41961
42015
  this.validationState = createAggregatedViolations(this, this.instanceConfig);
41962
42016
  this.instanceState = createRootInstanceState(this);
41963
42017
  }
41964
42018
  getChildren() {
41965
42019
  return this.childrenState.getChildren();
41966
42020
  }
42021
+ getAttributes() {
42022
+ return this.attributeState.getAttributes();
42023
+ }
41967
42024
  // RootNode
41968
42025
  setLanguage(language) {
41969
42026
  this.rootDocument.setLanguage(language);
@@ -41982,6 +42039,7 @@ class PrimaryInstance extends InstanceNode {
41982
42039
  // InstanceNode
41983
42040
  state;
41984
42041
  engineState;
42042
+ attributeState;
41985
42043
  instanceNode;
41986
42044
  getChildren;
41987
42045
  hasReadonlyAncestor = () => false;
@@ -42038,7 +42096,7 @@ class PrimaryInstance extends InstanceNode {
42038
42096
  this.evaluator = evaluator;
42039
42097
  this.classes = definition.classes;
42040
42098
  const childrenState = createChildrenState(this);
42041
- const attributeState = createAttributeState(this.scope);
42099
+ this.attributeState = createAttributeState(this.scope);
42042
42100
  this.getChildren = childrenState.getChildren;
42043
42101
  const stateSpec = {
42044
42102
  activeLanguage: getActiveLanguage,
@@ -42051,7 +42109,7 @@ class PrimaryInstance extends InstanceNode {
42051
42109
  valueOptions: null,
42052
42110
  value: null,
42053
42111
  children: childrenState.childIds,
42054
- attributes: attributeState.getAttributes
42112
+ attributes: this.attributeState.getAttributes
42055
42113
  };
42056
42114
  const state = createSharedNodeState(scope, stateSpec, config);
42057
42115
  this.state = state;
@@ -42066,9 +42124,12 @@ class PrimaryInstance extends InstanceNode {
42066
42124
  };
42067
42125
  this.instanceState = createPrimaryInstanceState(this);
42068
42126
  childrenState.setChildren([root]);
42069
- attributeState.setAttributes(buildAttributes(this));
42127
+ this.attributeState.setAttributes(buildAttributes(this));
42070
42128
  setIsAttached(true);
42071
42129
  }
42130
+ getAttributes() {
42131
+ return this.attributeState.getAttributes();
42132
+ }
42072
42133
  // PrimaryInstanceDocument
42073
42134
  /**
42074
42135
  * @todo Note that this method's signature is intentionally derived from