@getodk/xforms-engine 0.12.0 → 0.14.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 (95) hide show
  1. package/dist/client/BaseItem.d.ts +6 -0
  2. package/dist/client/GroupNode.d.ts +4 -4
  3. package/dist/client/MarkdownNode.d.ts +33 -0
  4. package/dist/client/RankNode.d.ts +2 -4
  5. package/dist/client/SelectNode.d.ts +2 -5
  6. package/dist/client/TextRange.d.ts +2 -11
  7. package/dist/client/hierarchy.d.ts +1 -2
  8. package/dist/client/index.d.ts +1 -1
  9. package/dist/client/node-types.d.ts +1 -1
  10. package/dist/index.js +10543 -332
  11. package/dist/index.js.map +1 -1
  12. package/dist/instance/RankControl.d.ts +3 -2
  13. package/dist/instance/SelectControl.d.ts +3 -2
  14. package/dist/instance/hierarchy.d.ts +5 -6
  15. package/dist/instance/markdown/MarkdownNode.d.ts +75 -0
  16. package/dist/instance/text/TextChunk.d.ts +0 -1
  17. package/dist/instance/text/TextRange.d.ts +2 -1
  18. package/dist/instance/text/markdownFormat.d.ts +3 -0
  19. package/dist/lib/reactivity/createItemCollection.d.ts +5 -7
  20. package/dist/parse/body/BodyDefinition.d.ts +2 -8
  21. package/dist/parse/body/GroupElementDefinition.d.ts +22 -0
  22. package/dist/parse/body/control/ItemsetDefinition.d.ts +4 -1
  23. package/dist/parse/expression/BindComputationExpression.d.ts +1 -1
  24. package/dist/parse/expression/ItemPropertyExpression.d.ts +6 -0
  25. package/dist/parse/expression/ItemsetNodesetExpression.d.ts +1 -2
  26. package/dist/parse/expression/TextChunkExpression.d.ts +9 -7
  27. package/dist/parse/expression/abstract/DependentExpression.d.ts +1 -15
  28. package/dist/parse/model/{SubtreeDefinition.d.ts → GroupDefinition.d.ts} +4 -3
  29. package/dist/parse/model/ModelDefinition.d.ts +6 -1
  30. package/dist/parse/model/NodeDefinition.d.ts +7 -8
  31. package/dist/parse/model/RepeatDefinition.d.ts +1 -1
  32. package/dist/parse/model/RootDefinition.d.ts +1 -1
  33. package/dist/parse/model/generateItextChunks.d.ts +5 -0
  34. package/dist/parse/text/LabelDefinition.d.ts +4 -5
  35. package/dist/parse/xpath/semantic-analysis.d.ts +1 -0
  36. package/dist/solid.js +10543 -332
  37. package/dist/solid.js.map +1 -1
  38. package/package.json +3 -2
  39. package/src/client/BaseItem.ts +7 -0
  40. package/src/client/GroupNode.ts +4 -10
  41. package/src/client/MarkdownNode.ts +53 -0
  42. package/src/client/RankNode.ts +2 -5
  43. package/src/client/SelectNode.ts +2 -6
  44. package/src/client/TextRange.ts +2 -11
  45. package/src/client/hierarchy.ts +0 -2
  46. package/src/client/index.ts +1 -1
  47. package/src/client/node-types.ts +0 -1
  48. package/src/instance/Group.ts +1 -1
  49. package/src/instance/RankControl.ts +8 -2
  50. package/src/instance/SelectControl.ts +8 -2
  51. package/src/instance/children/buildChildren.ts +1 -17
  52. package/src/instance/children/normalizeChildInitOptions.ts +44 -59
  53. package/src/instance/hierarchy.ts +0 -6
  54. package/src/instance/markdown/MarkdownNode.ts +115 -0
  55. package/src/instance/text/TextChunk.ts +0 -5
  56. package/src/instance/text/TextRange.ts +5 -3
  57. package/src/instance/text/markdownFormat.ts +214 -0
  58. package/src/integration/xpath/adapter/names.ts +0 -1
  59. package/src/lib/reactivity/createItemCollection.ts +25 -9
  60. package/src/lib/reactivity/text/createTextRange.ts +30 -30
  61. package/src/parse/body/BodyDefinition.ts +7 -34
  62. package/src/parse/body/GroupElementDefinition.ts +47 -0
  63. package/src/parse/body/control/ItemsetDefinition.ts +9 -2
  64. package/src/parse/expression/BindComputationExpression.ts +2 -7
  65. package/src/parse/expression/ItemPropertyExpression.ts +12 -0
  66. package/src/parse/expression/ItemsetNodesetExpression.ts +2 -3
  67. package/src/parse/expression/ItemsetValueExpression.ts +1 -1
  68. package/src/parse/expression/RepeatCountControlExpression.ts +4 -4
  69. package/src/parse/expression/TextChunkExpression.ts +25 -35
  70. package/src/parse/expression/abstract/DependentExpression.ts +2 -38
  71. package/src/parse/model/{SubtreeDefinition.ts → GroupDefinition.ts} +6 -8
  72. package/src/parse/model/ModelDefinition.ts +13 -0
  73. package/src/parse/model/NodeDefinition.ts +8 -9
  74. package/src/parse/model/RepeatDefinition.ts +2 -2
  75. package/src/parse/model/RootDefinition.ts +2 -2
  76. package/src/parse/model/generateItextChunks.ts +61 -0
  77. package/src/parse/text/ItemsetLabelDefinition.ts +4 -4
  78. package/src/parse/text/LabelDefinition.ts +4 -9
  79. package/src/parse/text/MessageDefinition.ts +4 -4
  80. package/src/parse/text/abstract/TextElementDefinition.ts +6 -7
  81. package/src/parse/xpath/semantic-analysis.ts +37 -8
  82. package/dist/client/SubtreeNode.d.ts +0 -56
  83. package/dist/instance/Subtree.d.ts +0 -38
  84. package/dist/instance/text/FormattedTextStub.d.ts +0 -1
  85. package/dist/parse/body/group/BaseGroupDefinition.d.ts +0 -40
  86. package/dist/parse/body/group/LogicalGroupDefinition.d.ts +0 -6
  87. package/dist/parse/body/group/PresentationGroupDefinition.d.ts +0 -11
  88. package/dist/parse/body/group/StructuralGroupDefinition.d.ts +0 -6
  89. package/src/client/SubtreeNode.ts +0 -61
  90. package/src/instance/Subtree.ts +0 -102
  91. package/src/instance/text/FormattedTextStub.ts +0 -8
  92. package/src/parse/body/group/BaseGroupDefinition.ts +0 -89
  93. package/src/parse/body/group/LogicalGroupDefinition.ts +0 -11
  94. package/src/parse/body/group/PresentationGroupDefinition.ts +0 -28
  95. package/src/parse/body/group/StructuralGroupDefinition.ts +0 -11
@@ -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
  *
@@ -47,15 +48,6 @@ import { ActiveLanguage } from './FormLanguage.ts';
47
48
  * - `h:body//hint/@ref[not(is-translation-expr())]`
48
49
  *
49
50
  * (See notes above for clarification of `is-translation-expr()`.)
50
- *
51
- * @todo It's unclear whether this will all become simpler or more compelex when
52
- * we add support for outputs in translations. In theory, the actual translation
53
- * `<text>` nodes map quite well to the `TextRange` concept (i.e. they are a
54
- * range of static and output chunks, just like labels and hints). The potential
55
- * for complications arise from XPath implementation details being largely
56
- * opaque (as in, the `jr:itext` implementation is encapsulated in the `xpath`
57
- * package, and the engine doesn't really deal with itext translations at the
58
- * node level at all).
59
51
  */
60
52
  export type TextChunkSource = 'literal' | 'output' | 'reference' | 'translation';
61
53
  /**
@@ -73,7 +65,6 @@ export interface TextChunk {
73
65
  */
74
66
  get language(): ActiveLanguage;
75
67
  get asString(): string;
76
- get formatted(): unknown;
77
68
  }
78
69
  export type ElementTextRole = 'hint' | 'label' | 'item-label';
79
70
  export type ValidationTextRole = 'constraintMsg' | 'requiredMsg';
@@ -135,7 +126,7 @@ export interface TextRange<Role extends TextRole, Origin extends TextOrigin = Te
135
126
  readonly role: Role;
136
127
  [Symbol.iterator](): Iterable<TextChunk>;
137
128
  get asString(): string;
138
- get formatted(): unknown;
129
+ get formatted(): MarkdownNode[];
139
130
  get imageSource(): JRResourceURL | undefined;
140
131
  get audioSource(): JRResourceURL | undefined;
141
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
  *
@@ -15,6 +15,7 @@ export type * from './GroupNode.ts';
15
15
  export type { AnyChildNode, AnyControlNode, AnyLeafNode, AnyNode, AnyParentNode, GeneralChildNode, GeneralParentNode, RepeatRangeNode, } from './hierarchy.ts';
16
16
  export type * from './identity.ts';
17
17
  export type * from './InputNode.ts';
18
+ export type * from './MarkdownNode.ts';
18
19
  export type * from './ModelValueNode.ts';
19
20
  export type * from './NoteNode.ts';
20
21
  export type * from './OpaqueReactiveObjectFactory.ts';
@@ -32,7 +33,6 @@ export type * from './serialization/InstancePayload.ts';
32
33
  export type * from './serialization/InstancePayloadOptions.ts';
33
34
  export type * from './serialization/InstanceState.ts';
34
35
  export type * from './submission/SubmissionMeta.ts';
35
- export type * from './SubtreeNode.ts';
36
36
  export type * from './TextRange.ts';
37
37
  export type * from './TriggerNode.ts';
38
38
  export type * from './UploadNode.ts';
@@ -1,3 +1,3 @@
1
1
  export type RepeatRangeNodeType = 'repeat-range:controlled' | 'repeat-range:uncontrolled';
2
2
  export type LeafNodeType = 'model-value' | 'note' | 'select' | 'input' | 'trigger' | 'range' | 'rank' | 'upload';
3
- export type InstanceNodeType = 'root' | RepeatRangeNodeType | 'repeat-instance' | 'group' | 'subtree' | LeafNodeType;
3
+ export type InstanceNodeType = 'root' | RepeatRangeNodeType | 'repeat-instance' | 'group' | LeafNodeType;