@getodk/xforms-engine 0.13.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.
Files changed (138) hide show
  1. package/dist/client/AttributeNode.d.ts +53 -0
  2. package/dist/client/BaseItem.d.ts +6 -0
  3. package/dist/client/GroupNode.d.ts +4 -4
  4. package/dist/client/MarkdownNode.d.ts +33 -0
  5. package/dist/client/RankNode.d.ts +2 -4
  6. package/dist/client/SelectNode.d.ts +2 -5
  7. package/dist/client/TextRange.d.ts +2 -2
  8. package/dist/client/hierarchy.d.ts +1 -2
  9. package/dist/client/index.d.ts +2 -1
  10. package/dist/client/node-types.d.ts +2 -2
  11. package/dist/client/validation.d.ts +7 -1
  12. package/dist/index.js +10758 -402
  13. package/dist/index.js.map +1 -1
  14. package/dist/instance/Attribute.d.ts +58 -0
  15. package/dist/instance/Group.d.ts +4 -0
  16. package/dist/instance/PrimaryInstance.d.ts +4 -0
  17. package/dist/instance/Root.d.ts +4 -0
  18. package/dist/instance/UploadControl.d.ts +4 -0
  19. package/dist/instance/abstract/InstanceNode.d.ts +7 -4
  20. package/dist/instance/abstract/ValueNode.d.ts +1 -0
  21. package/dist/instance/attachments/buildAttributes.d.ts +3 -0
  22. package/dist/instance/hierarchy.d.ts +6 -6
  23. package/dist/instance/internal-api/AttributeContext.d.ts +29 -0
  24. package/dist/instance/internal-api/serialization/ClientReactiveSerializableAttributeNode.d.ts +16 -0
  25. package/dist/instance/internal-api/serialization/ClientReactiveSerializableParentNode.d.ts +2 -0
  26. package/dist/instance/internal-api/serialization/ClientReactiveSerializableTemplatedNode.d.ts +2 -2
  27. package/dist/instance/markdown/MarkdownNode.d.ts +75 -0
  28. package/dist/instance/repeat/BaseRepeatRange.d.ts +5 -0
  29. package/dist/instance/repeat/RepeatInstance.d.ts +4 -2
  30. package/dist/instance/text/TextChunk.d.ts +0 -1
  31. package/dist/instance/text/TextRange.d.ts +2 -1
  32. package/dist/instance/text/markdownFormat.d.ts +3 -0
  33. package/dist/integration/xpath/adapter/XFormsXPathNode.d.ts +2 -2
  34. package/dist/lib/client-reactivity/instance-state/createAttributeNodeInstanceState.d.ts +3 -0
  35. package/dist/lib/client-reactivity/instance-state/createTemplatedNodeInstanceState.d.ts +0 -3
  36. package/dist/lib/names/NamespaceDeclarationMap.d.ts +1 -1
  37. package/dist/lib/reactivity/createAttributeState.d.ts +16 -0
  38. package/dist/lib/reactivity/createAttributeValueState.d.ts +15 -0
  39. package/dist/lib/reactivity/createItemCollection.d.ts +5 -7
  40. package/dist/lib/xml-serialization.d.ts +5 -9
  41. package/dist/parse/XFormDOM.d.ts +1 -1
  42. package/dist/parse/body/BodyDefinition.d.ts +2 -8
  43. package/dist/parse/body/GroupElementDefinition.d.ts +22 -0
  44. package/dist/parse/body/control/ItemsetDefinition.d.ts +3 -0
  45. package/dist/parse/expression/ItemPropertyExpression.d.ts +6 -0
  46. package/dist/parse/model/AttributeDefinition.d.ts +22 -0
  47. package/dist/parse/model/{RootAttributeMap.d.ts → AttributeDefinitionMap.d.ts} +4 -10
  48. package/dist/parse/model/{SubtreeDefinition.d.ts → GroupDefinition.d.ts} +8 -4
  49. package/dist/parse/model/LeafNodeDefinition.d.ts +1 -0
  50. package/dist/parse/model/NodeDefinition.d.ts +13 -9
  51. package/dist/parse/model/RepeatDefinition.d.ts +5 -2
  52. package/dist/parse/model/RootDefinition.d.ts +3 -3
  53. package/dist/parse/text/LabelDefinition.d.ts +4 -5
  54. package/dist/solid.js +10758 -402
  55. package/dist/solid.js.map +1 -1
  56. package/package.json +6 -5
  57. package/src/client/AttributeNode.ts +62 -0
  58. package/src/client/BaseItem.ts +7 -0
  59. package/src/client/GroupNode.ts +4 -10
  60. package/src/client/MarkdownNode.ts +53 -0
  61. package/src/client/RankNode.ts +2 -5
  62. package/src/client/SelectNode.ts +2 -6
  63. package/src/client/TextRange.ts +2 -2
  64. package/src/client/hierarchy.ts +0 -2
  65. package/src/client/index.ts +2 -1
  66. package/src/client/node-types.ts +1 -1
  67. package/src/client/validation.ts +9 -1
  68. package/src/instance/Attribute.ts +164 -0
  69. package/src/instance/Group.ts +17 -1
  70. package/src/instance/InputControl.ts +1 -0
  71. package/src/instance/ModelValue.ts +1 -0
  72. package/src/instance/Note.ts +1 -0
  73. package/src/instance/PrimaryInstance.ts +17 -0
  74. package/src/instance/RangeControl.ts +1 -0
  75. package/src/instance/RankControl.ts +1 -0
  76. package/src/instance/Root.ts +16 -0
  77. package/src/instance/SelectControl.ts +1 -0
  78. package/src/instance/TriggerControl.ts +1 -0
  79. package/src/instance/UploadControl.ts +14 -0
  80. package/src/instance/abstract/DescendantNode.ts +5 -1
  81. package/src/instance/abstract/InstanceNode.ts +6 -3
  82. package/src/instance/abstract/ValueNode.ts +1 -0
  83. package/src/instance/attachments/buildAttributes.ts +8 -0
  84. package/src/instance/children/buildChildren.ts +1 -17
  85. package/src/instance/children/normalizeChildInitOptions.ts +44 -59
  86. package/src/instance/hierarchy.ts +3 -7
  87. package/src/instance/internal-api/AttributeContext.ts +34 -0
  88. package/src/instance/internal-api/serialization/ClientReactiveSerializableAttributeNode.ts +19 -0
  89. package/src/instance/internal-api/serialization/ClientReactiveSerializableParentNode.ts +2 -0
  90. package/src/instance/internal-api/serialization/ClientReactiveSerializableTemplatedNode.ts +2 -3
  91. package/src/instance/markdown/MarkdownNode.ts +115 -0
  92. package/src/instance/repeat/BaseRepeatRange.ts +14 -0
  93. package/src/instance/repeat/RepeatInstance.ts +14 -5
  94. package/src/instance/text/TextChunk.ts +0 -5
  95. package/src/instance/text/TextRange.ts +5 -3
  96. package/src/instance/text/markdownFormat.ts +214 -0
  97. package/src/integration/xpath/adapter/XFormsXPathNode.ts +3 -1
  98. package/src/integration/xpath/adapter/names.ts +0 -1
  99. package/src/lib/client-reactivity/instance-state/createAttributeNodeInstanceState.ts +16 -0
  100. package/src/lib/client-reactivity/instance-state/createParentNodeInstanceState.ts +5 -5
  101. package/src/lib/client-reactivity/instance-state/createRootInstanceState.ts +6 -9
  102. package/src/lib/client-reactivity/instance-state/createTemplatedNodeInstanceState.ts +5 -15
  103. package/src/lib/names/NamespaceDeclarationMap.ts +1 -1
  104. package/src/lib/reactivity/createAttributeState.ts +51 -0
  105. package/src/lib/reactivity/createAttributeValueState.ts +189 -0
  106. package/src/lib/reactivity/createItemCollection.ts +25 -9
  107. package/src/lib/xml-serialization.ts +30 -34
  108. package/src/parse/body/BodyDefinition.ts +7 -34
  109. package/src/parse/body/GroupElementDefinition.ts +47 -0
  110. package/src/parse/body/control/ItemsetDefinition.ts +7 -0
  111. package/src/parse/expression/ItemPropertyExpression.ts +12 -0
  112. package/src/parse/model/AttributeDefinition.ts +58 -0
  113. package/src/parse/model/{RootAttributeMap.ts → AttributeDefinitionMap.ts} +7 -13
  114. package/src/parse/model/{SubtreeDefinition.ts → GroupDefinition.ts} +12 -8
  115. package/src/parse/model/LeafNodeDefinition.ts +1 -0
  116. package/src/parse/model/NodeDefinition.ts +19 -12
  117. package/src/parse/model/RepeatDefinition.ts +10 -3
  118. package/src/parse/model/RootDefinition.ts +6 -6
  119. package/src/parse/model/nodeDefinitionMap.ts +1 -1
  120. package/src/parse/text/LabelDefinition.ts +4 -9
  121. package/dist/client/SubtreeNode.d.ts +0 -56
  122. package/dist/error/TemplatedNodeAttributeSerializationError.d.ts +0 -22
  123. package/dist/instance/Subtree.d.ts +0 -38
  124. package/dist/instance/text/FormattedTextStub.d.ts +0 -1
  125. package/dist/parse/body/group/BaseGroupDefinition.d.ts +0 -40
  126. package/dist/parse/body/group/LogicalGroupDefinition.d.ts +0 -6
  127. package/dist/parse/body/group/PresentationGroupDefinition.d.ts +0 -11
  128. package/dist/parse/body/group/StructuralGroupDefinition.d.ts +0 -6
  129. package/dist/parse/model/RootAttributeDefinition.d.ts +0 -21
  130. package/src/client/SubtreeNode.ts +0 -61
  131. package/src/error/TemplatedNodeAttributeSerializationError.ts +0 -24
  132. package/src/instance/Subtree.ts +0 -102
  133. package/src/instance/text/FormattedTextStub.ts +0 -8
  134. package/src/parse/body/group/BaseGroupDefinition.ts +0 -89
  135. package/src/parse/body/group/LogicalGroupDefinition.ts +0 -11
  136. package/src/parse/body/group/PresentationGroupDefinition.ts +0 -28
  137. package/src/parse/body/group/StructuralGroupDefinition.ts +0 -11
  138. package/src/parse/model/RootAttributeDefinition.ts +0 -44
@@ -0,0 +1,53 @@
1
+ import { Root } from '../instance/Root.ts';
2
+ import { AttributeDefinition } from '../parse/model/AttributeDefinition.ts';
3
+ import { InstanceState } from './serialization/InstanceState.ts';
4
+ export interface AttributeNodeState {
5
+ get value(): string;
6
+ }
7
+ /**
8
+ * Base interface for common/shared aspects of attributes.
9
+ */
10
+ export interface AttributeNode {
11
+ /**
12
+ * Specifies the node's general type. This can be useful for narrowing types,
13
+ * e.g. those of children.
14
+ */
15
+ readonly nodeType: 'attribute';
16
+ /**
17
+ * Each node has a definition which specifies aspects of the node defined in
18
+ * the form. These aspects include (but are not limited to) the node's data
19
+ * type, its body presentation constraints (if any), its bound nodeset, and
20
+ * so on...
21
+ */
22
+ readonly definition: AttributeDefinition;
23
+ /**
24
+ * Each node links back to the node representing the root of the form.
25
+ */
26
+ readonly root: Root;
27
+ /**
28
+ * Each node links back to its parent, if any. All nodes have a parent except
29
+ * the form's {@link root}.
30
+ */
31
+ readonly parent: unknown;
32
+ /**
33
+ * Each node provides a discrete object representing the stateful aspects of
34
+ * that node which will change over time. This includes state which is either
35
+ * client-/user-mutable, or state which is computed based on the core XForms
36
+ * computation model. Each node also exposes {@link validationState}, which
37
+ * reflects the validity of the node, or its descendants.
38
+ *
39
+ * When a client provides a {@link OpaqueReactiveObjectFactory}, the engine
40
+ * will update the properties of this object as their respective states
41
+ * change, so a client can implement reactive updates that respond to changes
42
+ * as they occur.
43
+ */
44
+ readonly currentState: AttributeNodeState;
45
+ /**
46
+ * Represents the current instance state of the node.
47
+ *
48
+ * @see {@link InstanceState.instanceXML} for additional detail.
49
+ */
50
+ readonly instanceState: InstanceState;
51
+ readonly appearances: null;
52
+ readonly nodeOptions: null;
53
+ }
@@ -0,0 +1,6 @@
1
+ import { TextRange } from './TextRange.ts';
2
+ export interface BaseItem {
3
+ get label(): TextRange<'item-label'>;
4
+ get value(): string;
5
+ properties: Array<[string, string]>;
6
+ }
@@ -1,5 +1,5 @@
1
- import { AnyGroupElementDefinition } from '../parse/body/BodyDefinition.ts';
2
- import { SubtreeDefinition } from '../parse/model/SubtreeDefinition.ts';
1
+ import { GroupElementDefinition } from '../parse/body/GroupElementDefinition.ts';
2
+ import { GroupDefinition as GroupNodeDefinition } from '../parse/model/GroupDefinition.ts';
3
3
  import { BaseNode, BaseNodeState } from './BaseNode.ts';
4
4
  import { NodeAppearances } from './NodeAppearances.ts';
5
5
  import { RootNode } from './RootNode.ts';
@@ -11,8 +11,8 @@ export interface GroupNodeState extends BaseNodeState {
11
11
  get valueOptions(): null;
12
12
  get value(): null;
13
13
  }
14
- export interface GroupDefinition extends SubtreeDefinition {
15
- readonly bodyElement: AnyGroupElementDefinition;
14
+ export interface GroupDefinition extends GroupNodeDefinition {
15
+ readonly bodyElement: GroupElementDefinition;
16
16
  }
17
17
  export type GroupNodeAppearances = NodeAppearances<GroupDefinition>;
18
18
  /**
@@ -0,0 +1,33 @@
1
+ export type Heading = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
2
+ export type ElementName = Heading | 'a' | 'div' | 'em' | 'li' | 'ol' | 'p' | 'span' | 'strong' | 'u' | 'ul';
3
+ export type MarkdownNode = ChildMarkdownNode | HtmlMarkdownNode | ParentMarkdownNode;
4
+ export interface ParentMarkdownNode {
5
+ readonly role: 'parent';
6
+ readonly elementName: string;
7
+ readonly children: MarkdownNode[];
8
+ }
9
+ export interface ChildMarkdownNode {
10
+ readonly role: 'child';
11
+ readonly value: string;
12
+ }
13
+ export interface HtmlMarkdownNode {
14
+ readonly role: 'html';
15
+ readonly unsafeHtml: string;
16
+ }
17
+ export interface AnchorMarkdownNode extends ParentMarkdownNode {
18
+ readonly elementName: 'a';
19
+ readonly url: string;
20
+ }
21
+ export interface StyledMarkdownNode extends ParentMarkdownNode {
22
+ readonly elementName: 'div' | 'p' | 'span';
23
+ readonly properties: MarkdownProperty | undefined;
24
+ }
25
+ export interface MarkdownProperty {
26
+ readonly style: StyleProperty;
27
+ }
28
+ export interface StyleProperty {
29
+ readonly color: string | undefined;
30
+ readonly 'font-family': string | undefined;
31
+ readonly 'text-align': 'center' | 'left' | 'right' | undefined;
32
+ readonly 'font-size': string | undefined;
33
+ }
@@ -1,16 +1,14 @@
1
1
  import { RankControlDefinition } from '../parse/body/control/RankControlDefinition.ts';
2
2
  import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
3
3
  import { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
4
+ import { BaseItem } from './BaseItem.ts';
4
5
  import { RootNode } from './RootNode.ts';
5
6
  import { TextRange } from './TextRange.ts';
6
7
  import { GeneralParentNode } from './hierarchy.ts';
7
8
  import { LeafNodeValidationState } from './validation.ts';
8
9
  import { UnknownAppearanceDefinition } from '../parse/body/appearance/unknownAppearanceParser.ts';
9
10
  import { ValueType } from './ValueType.ts';
10
- export interface RankItem {
11
- get label(): TextRange<'item-label'>;
12
- get value(): string;
13
- }
11
+ export type RankItem = BaseItem;
14
12
  export type RankValueOptions = readonly RankItem[];
15
13
  export interface RankNodeState extends BaseValueNodeState<readonly string[]> {
16
14
  get valueOptions(): RankValueOptions;
@@ -1,16 +1,13 @@
1
1
  import { AnySelectControlDefinition, SelectType } from '../parse/body/control/SelectControlDefinition.ts';
2
2
  import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
3
3
  import { BaseValueNode, BaseValueNodeState } from './BaseValueNode.ts';
4
+ import { BaseItem } from './BaseItem.ts';
4
5
  import { NodeAppearances } from './NodeAppearances.ts';
5
6
  import { RootNode } from './RootNode.ts';
6
- import { TextRange } from './TextRange.ts';
7
7
  import { ValueType } from './ValueType.ts';
8
8
  import { GeneralParentNode } from './hierarchy.ts';
9
9
  import { LeafNodeValidationState } from './validation.ts';
10
- export interface SelectItem {
11
- get label(): TextRange<'item-label'>;
12
- get value(): string;
13
- }
10
+ export type SelectItem = BaseItem;
14
11
  export type SelectValueOptions = readonly SelectItem[];
15
12
  export interface SelectNodeState extends BaseValueNodeState<readonly string[]> {
16
13
  get isSelectWithImages(): boolean;
@@ -1,5 +1,6 @@
1
1
  import { JRResourceURL } from '../../../common/src/jr-resources/JRResourceURL.ts';
2
2
  import { ActiveLanguage } from './FormLanguage.ts';
3
+ import { MarkdownNode } from './MarkdownNode.ts';
3
4
  /**
4
5
  * **COMMENTARY**
5
6
  *
@@ -64,7 +65,6 @@ export interface TextChunk {
64
65
  */
65
66
  get language(): ActiveLanguage;
66
67
  get asString(): string;
67
- get formatted(): unknown;
68
68
  }
69
69
  export type ElementTextRole = 'hint' | 'label' | 'item-label';
70
70
  export type ValidationTextRole = 'constraintMsg' | 'requiredMsg';
@@ -126,7 +126,7 @@ export interface TextRange<Role extends TextRole, Origin extends TextOrigin = Te
126
126
  readonly role: Role;
127
127
  [Symbol.iterator](): Iterable<TextChunk>;
128
128
  get asString(): string;
129
- get formatted(): unknown;
129
+ get formatted(): MarkdownNode[];
130
130
  get imageSource(): JRResourceURL | undefined;
131
131
  get audioSource(): JRResourceURL | undefined;
132
132
  get videoSource(): JRResourceURL | undefined;
@@ -10,7 +10,6 @@ import { RepeatRangeControlledNode } from './repeat/RepeatRangeControlledNode.ts
10
10
  import { RepeatRangeUncontrolledNode } from './repeat/RepeatRangeUncontrolledNode.ts';
11
11
  import { RootNode } from './RootNode.ts';
12
12
  import { SelectNode } from './SelectNode.ts';
13
- import { SubtreeNode } from './SubtreeNode.ts';
14
13
  import { TriggerNode } from './TriggerNode.ts';
15
14
  import { UploadNode } from './UploadNode.ts';
16
15
  export type AnyControlNode = AnyInputNode | AnyNoteNode | AnyRangeNode | RankNode | SelectNode | TriggerNode | UploadNode;
@@ -20,7 +19,7 @@ export type RepeatRangeNode = RepeatRangeControlledNode | RepeatRangeUncontrolle
20
19
  * Any of the concrete node types which may be a parent of non-repeat instance
21
20
  * child nodes.
22
21
  */
23
- export type GeneralParentNode = RootNode | SubtreeNode | GroupNode | RepeatInstanceNode;
22
+ export type GeneralParentNode = RootNode | GroupNode | RepeatInstanceNode;
24
23
  /**
25
24
  * Any of the concrete node types which may be a parent of any other node.
26
25
  *
@@ -1,5 +1,6 @@
1
1
  export type * from './attachments/InstanceAttachmentMeta.ts';
2
2
  export type * from './attachments/InstanceAttachmentsConfig.ts';
3
+ export type * from './AttributeNode.ts';
3
4
  export type * from './constants.ts';
4
5
  export * as constants from './constants.ts';
5
6
  export type * from './form/CreateFormInstance.ts';
@@ -15,6 +16,7 @@ export type * from './GroupNode.ts';
15
16
  export type { AnyChildNode, AnyControlNode, AnyLeafNode, AnyNode, AnyParentNode, GeneralChildNode, GeneralParentNode, RepeatRangeNode, } from './hierarchy.ts';
16
17
  export type * from './identity.ts';
17
18
  export type * from './InputNode.ts';
19
+ export type * from './MarkdownNode.ts';
18
20
  export type * from './ModelValueNode.ts';
19
21
  export type * from './NoteNode.ts';
20
22
  export type * from './OpaqueReactiveObjectFactory.ts';
@@ -32,7 +34,6 @@ export type * from './serialization/InstancePayload.ts';
32
34
  export type * from './serialization/InstancePayloadOptions.ts';
33
35
  export type * from './serialization/InstanceState.ts';
34
36
  export type * from './submission/SubmissionMeta.ts';
35
- export type * from './SubtreeNode.ts';
36
37
  export type * from './TextRange.ts';
37
38
  export type * from './TriggerNode.ts';
38
39
  export type * from './UploadNode.ts';
@@ -1,3 +1,3 @@
1
1
  export type RepeatRangeNodeType = 'repeat-range:controlled' | 'repeat-range:uncontrolled';
2
- export type LeafNodeType = 'model-value' | 'note' | 'select' | 'input' | 'trigger' | 'range' | 'rank' | 'upload';
3
- export type InstanceNodeType = 'root' | RepeatRangeNodeType | 'repeat-instance' | 'group' | 'subtree' | LeafNodeType;
2
+ export type LeafNodeType = 'model-value' | 'note' | 'select' | 'input' | 'trigger' | 'range' | 'rank' | 'attribute' | 'upload';
3
+ export type InstanceNodeType = 'root' | RepeatRangeNodeType | 'repeat-instance' | 'group' | LeafNodeType;
@@ -158,5 +158,11 @@ export interface DescendantNodeViolationReference {
158
158
  export interface AncestorNodeValidationState {
159
159
  get violations(): readonly DescendantNodeViolationReference[];
160
160
  }
161
- export type NodeValidationState = AncestorNodeValidationState | LeafNodeValidationState;
161
+ /**
162
+ * Convenience interface for nodes that cannot be invalid.
163
+ */
164
+ export interface NullValidationState {
165
+ get violations(): readonly [];
166
+ }
167
+ export type NodeValidationState = AncestorNodeValidationState | LeafNodeValidationState | NullValidationState;
162
168
  export {};