@getodk/xforms-engine 0.1.0 → 0.2.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 (157) hide show
  1. package/dist/.vite/manifest.json +1 -0
  2. package/dist/XFormDOM.d.ts +1 -0
  3. package/dist/XFormDataType.d.ts +2 -1
  4. package/dist/XFormDefinition.d.ts +1 -0
  5. package/dist/body/BodyDefinition.d.ts +27 -9
  6. package/dist/body/BodyElementDefinition.d.ts +5 -4
  7. package/dist/body/RepeatElementDefinition.d.ts +19 -0
  8. package/dist/body/UnsupportedBodyElementDefinition.d.ts +3 -2
  9. package/dist/body/appearance/inputAppearanceParser.d.ts +4 -0
  10. package/dist/body/appearance/selectAppearanceParser.d.ts +4 -0
  11. package/dist/body/appearance/structureElementAppearanceParser.d.ts +4 -0
  12. package/dist/body/control/ControlDefinition.d.ts +5 -2
  13. package/dist/body/control/InputDefinition.d.ts +6 -0
  14. package/dist/body/control/select/ItemDefinition.d.ts +4 -3
  15. package/dist/body/control/select/ItemsetDefinition.d.ts +4 -3
  16. package/dist/body/control/select/ItemsetNodesetContext.d.ts +3 -2
  17. package/dist/body/control/select/ItemsetNodesetExpression.d.ts +2 -1
  18. package/dist/body/control/select/ItemsetValueExpression.d.ts +2 -1
  19. package/dist/body/control/select/SelectDefinition.d.ts +16 -5
  20. package/dist/body/group/BaseGroupDefinition.d.ts +6 -10
  21. package/dist/body/group/LogicalGroupDefinition.d.ts +1 -0
  22. package/dist/body/group/PresentationGroupDefinition.d.ts +3 -2
  23. package/dist/body/group/StructuralGroupDefinition.d.ts +1 -0
  24. package/dist/body/text/HintDefinition.d.ts +4 -4
  25. package/dist/body/text/LabelDefinition.d.ts +9 -7
  26. package/dist/body/text/TextElementDefinition.d.ts +9 -8
  27. package/dist/body/text/TextElementOutputPart.d.ts +2 -1
  28. package/dist/body/text/TextElementPart.d.ts +5 -4
  29. package/dist/body/text/TextElementReferencePart.d.ts +2 -1
  30. package/dist/body/text/TextElementStaticPart.d.ts +2 -1
  31. package/dist/client/BaseNode.d.ts +9 -3
  32. package/dist/client/EngineConfig.d.ts +2 -1
  33. package/dist/client/GroupNode.d.ts +10 -6
  34. package/dist/client/NodeAppearances.d.ts +15 -0
  35. package/dist/client/RepeatInstanceNode.d.ts +10 -6
  36. package/dist/client/RepeatRangeNode.d.ts +11 -7
  37. package/dist/client/RootNode.d.ts +24 -4
  38. package/dist/client/SelectNode.d.ts +10 -6
  39. package/dist/client/StringNode.d.ts +9 -5
  40. package/dist/client/SubtreeNode.d.ts +6 -4
  41. package/dist/client/TextRange.d.ts +2 -1
  42. package/dist/client/hierarchy.d.ts +9 -8
  43. package/dist/client/index.d.ts +3 -2
  44. package/dist/expression/DependencyContext.d.ts +2 -1
  45. package/dist/expression/DependentExpression.d.ts +3 -2
  46. package/dist/index.d.ts +2 -1
  47. package/dist/index.js +1882 -1757
  48. package/dist/index.js.map +1 -1
  49. package/dist/instance/Group.d.ts +15 -15
  50. package/dist/instance/RepeatInstance.d.ts +39 -15
  51. package/dist/instance/RepeatRange.d.ts +98 -20
  52. package/dist/instance/Root.d.ts +25 -39
  53. package/dist/instance/SelectField.d.ts +17 -17
  54. package/dist/instance/StringField.d.ts +17 -17
  55. package/dist/instance/Subtree.d.ts +13 -13
  56. package/dist/instance/abstract/DescendantNode.d.ts +26 -18
  57. package/dist/instance/abstract/InstanceNode.d.ts +44 -46
  58. package/dist/instance/children.d.ts +2 -1
  59. package/dist/instance/hierarchy.d.ts +8 -7
  60. package/dist/instance/index.d.ts +4 -3
  61. package/dist/instance/internal-api/EvaluationContext.d.ts +10 -8
  62. package/dist/instance/internal-api/InstanceConfig.d.ts +3 -2
  63. package/dist/instance/internal-api/SubscribableDependency.d.ts +2 -1
  64. package/dist/instance/internal-api/TranslationContext.d.ts +2 -1
  65. package/dist/instance/internal-api/ValueContext.d.ts +6 -5
  66. package/dist/instance/resource.d.ts +3 -2
  67. package/dist/instance/text/TextChunk.d.ts +4 -3
  68. package/dist/instance/text/TextRange.d.ts +2 -1
  69. package/dist/lib/TokenListParser.d.ts +84 -0
  70. package/dist/lib/dom/query.d.ts +8 -2
  71. package/dist/lib/reactivity/createChildrenState.d.ts +4 -3
  72. package/dist/lib/reactivity/createComputedExpression.d.ts +4 -3
  73. package/dist/lib/reactivity/createSelectItems.d.ts +4 -3
  74. package/dist/lib/reactivity/createValueState.d.ts +3 -2
  75. package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +6 -4
  76. package/dist/lib/reactivity/node-state/createClientState.d.ts +7 -6
  77. package/dist/lib/reactivity/node-state/createCurrentState.d.ts +5 -4
  78. package/dist/lib/reactivity/node-state/createEngineState.d.ts +4 -3
  79. package/dist/lib/reactivity/node-state/createSharedNodeState.d.ts +7 -6
  80. package/dist/lib/reactivity/node-state/createSpecifiedPropertyDescriptor.d.ts +2 -1
  81. package/dist/lib/reactivity/node-state/createSpecifiedState.d.ts +3 -2
  82. package/dist/lib/reactivity/node-state/representations.d.ts +2 -1
  83. package/dist/lib/reactivity/scope.d.ts +2 -1
  84. package/dist/lib/reactivity/text/createFieldHint.d.ts +4 -3
  85. package/dist/lib/reactivity/text/createNodeLabel.d.ts +4 -3
  86. package/dist/lib/reactivity/text/createTextRange.d.ts +6 -5
  87. package/dist/lib/reactivity/types.d.ts +2 -1
  88. package/dist/lib/xpath/analysis.d.ts +2 -1
  89. package/dist/model/BindComputation.d.ts +2 -1
  90. package/dist/model/BindDefinition.d.ts +6 -5
  91. package/dist/model/DescendentNodeDefinition.d.ts +6 -6
  92. package/dist/model/ModelBindMap.d.ts +4 -3
  93. package/dist/model/ModelDefinition.d.ts +2 -1
  94. package/dist/model/NodeDefinition.d.ts +20 -19
  95. package/dist/model/RepeatInstanceDefinition.d.ts +7 -7
  96. package/dist/model/{RepeatSequenceDefinition.d.ts → RepeatRangeDefinition.d.ts} +7 -6
  97. package/dist/model/RepeatTemplateDefinition.d.ts +8 -8
  98. package/dist/model/RootDefinition.d.ts +8 -5
  99. package/dist/model/SubtreeDefinition.d.ts +5 -4
  100. package/dist/model/ValueNodeDefinition.d.ts +5 -5
  101. package/dist/solid.js +1873 -1751
  102. package/dist/solid.js.map +1 -1
  103. package/package.json +14 -18
  104. package/src/XFormDOM.ts +81 -8
  105. package/src/body/BodyDefinition.ts +38 -23
  106. package/src/body/RepeatElementDefinition.ts +70 -0
  107. package/src/body/appearance/inputAppearanceParser.ts +39 -0
  108. package/src/body/appearance/selectAppearanceParser.ts +38 -0
  109. package/src/body/appearance/structureElementAppearanceParser.ts +7 -0
  110. package/src/body/control/ControlDefinition.ts +4 -0
  111. package/src/body/control/InputDefinition.ts +13 -0
  112. package/src/body/control/select/SelectDefinition.ts +14 -5
  113. package/src/body/group/BaseGroupDefinition.ts +11 -49
  114. package/src/body/text/LabelDefinition.ts +15 -1
  115. package/src/body/text/TextElementDefinition.ts +5 -5
  116. package/src/client/BaseNode.ts +9 -1
  117. package/src/client/GroupNode.ts +6 -2
  118. package/src/client/NodeAppearances.ts +22 -0
  119. package/src/client/RepeatInstanceNode.ts +4 -0
  120. package/src/client/RepeatRangeNode.ts +6 -2
  121. package/src/client/RootNode.ts +22 -0
  122. package/src/client/SelectNode.ts +4 -0
  123. package/src/client/StringNode.ts +4 -0
  124. package/src/client/SubtreeNode.ts +1 -0
  125. package/src/instance/Group.ts +14 -9
  126. package/src/instance/RepeatInstance.ts +59 -15
  127. package/src/instance/RepeatRange.ts +133 -15
  128. package/src/instance/Root.ts +20 -64
  129. package/src/instance/SelectField.ts +7 -7
  130. package/src/instance/StringField.ts +8 -7
  131. package/src/instance/Subtree.ts +10 -7
  132. package/src/instance/abstract/DescendantNode.ts +45 -43
  133. package/src/instance/abstract/InstanceNode.ts +69 -86
  134. package/src/instance/children.ts +17 -7
  135. package/src/instance/index.ts +1 -1
  136. package/src/instance/internal-api/EvaluationContext.ts +5 -6
  137. package/src/instance/internal-api/ValueContext.ts +2 -2
  138. package/src/lib/TokenListParser.ts +156 -0
  139. package/src/lib/dom/query.ts +13 -0
  140. package/src/lib/reactivity/createChildrenState.ts +51 -6
  141. package/src/lib/reactivity/createComputedExpression.ts +1 -1
  142. package/src/lib/reactivity/createSelectItems.ts +4 -6
  143. package/src/lib/reactivity/createValueState.ts +6 -6
  144. package/src/lib/reactivity/materializeCurrentStateChildren.ts +3 -1
  145. package/src/model/DescendentNodeDefinition.ts +1 -2
  146. package/src/model/ModelDefinition.ts +1 -1
  147. package/src/model/NodeDefinition.ts +12 -12
  148. package/src/model/RepeatInstanceDefinition.ts +8 -13
  149. package/src/model/{RepeatSequenceDefinition.ts → RepeatRangeDefinition.ts} +6 -6
  150. package/src/model/RepeatTemplateDefinition.ts +10 -15
  151. package/src/model/RootDefinition.ts +6 -12
  152. package/src/model/SubtreeDefinition.ts +3 -3
  153. package/src/model/ValueNodeDefinition.ts +2 -3
  154. package/dist/body/RepeatDefinition.d.ts +0 -15
  155. package/dist/body/group/RepeatGroupDefinition.d.ts +0 -12
  156. package/src/body/RepeatDefinition.ts +0 -54
  157. package/src/body/group/RepeatGroupDefinition.ts +0 -91
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "src/index.ts": {
3
3
  "file": "solid.js",
4
+ "name": "solid",
4
5
  "src": "src/index.ts",
5
6
  "isEntry": true
6
7
  }
@@ -1,4 +1,5 @@
1
1
  import { XFormsXPathEvaluator } from '@getodk/xpath';
2
+
2
3
  interface XFormDOMNormalizationOptions {
3
4
  readonly isNormalized: boolean;
4
5
  }
@@ -1,4 +1,5 @@
1
- import type { CollectionValues } from '../../common/types/collections/CollectionValues.ts';
1
+ import { CollectionValues } from '../../common/types/collections/CollectionValues.ts';
2
+
2
3
  /**
3
4
  * Like JavaRosa. Presumably for explicit types which aren't impelemnted?
4
5
  */
@@ -1,6 +1,7 @@
1
1
  import { XFormDOM } from './XFormDOM.ts';
2
2
  import { BodyDefinition } from './body/BodyDefinition.ts';
3
3
  import { ModelDefinition } from './model/ModelDefinition.ts';
4
+
4
5
  export declare class XFormDefinition {
5
6
  readonly sourceXML: string;
6
7
  readonly xformDOM: XFormDOM;
@@ -1,26 +1,26 @@
1
- import type { XFormDefinition } from '../XFormDefinition.ts';
1
+ import { XFormDefinition } from '../XFormDefinition.ts';
2
2
  import { DependencyContext } from '../expression/DependencyContext.ts';
3
+ import { ParsedTokenList, TokenListParser } from '../lib/TokenListParser.ts';
4
+ import { RepeatElementDefinition } from './RepeatElementDefinition.ts';
3
5
  import { UnsupportedBodyElementDefinition } from './UnsupportedBodyElementDefinition.ts';
4
6
  import { InputDefinition } from './control/InputDefinition.ts';
5
- import type { AnySelectDefinition } from './control/select/SelectDefinition.ts';
7
+ import { AnySelectDefinition } from './control/select/SelectDefinition.ts';
6
8
  import { LogicalGroupDefinition } from './group/LogicalGroupDefinition.ts';
7
9
  import { PresentationGroupDefinition } from './group/PresentationGroupDefinition.ts';
8
- import { RepeatGroupDefinition } from './group/RepeatGroupDefinition.ts';
9
10
  import { StructuralGroupDefinition } from './group/StructuralGroupDefinition.ts';
11
+
10
12
  export interface BodyElementParentContext {
11
13
  readonly reference: string | null;
12
14
  readonly element: Element;
13
15
  }
14
- type SupportedBodyElementDefinition = RepeatGroupDefinition | LogicalGroupDefinition | PresentationGroupDefinition | StructuralGroupDefinition | InputDefinition | AnySelectDefinition;
16
+ export type ControlElementDefinition = AnySelectDefinition | InputDefinition;
17
+ type SupportedBodyElementDefinition = RepeatElementDefinition | LogicalGroupDefinition | PresentationGroupDefinition | StructuralGroupDefinition | ControlElementDefinition;
15
18
  export type AnyBodyElementDefinition = SupportedBodyElementDefinition | UnsupportedBodyElementDefinition;
16
19
  export type BodyElementDefinitionArray = readonly AnyBodyElementDefinition[];
17
20
  export type AnyBodyElementType = AnyBodyElementDefinition['type'];
18
21
  export type AnyGroupElementDefinition = Extract<AnyBodyElementDefinition, {
19
22
  readonly type: `${string}-group`;
20
23
  }>;
21
- export type NonRepeatGroupElementDefinition = Exclude<AnyGroupElementDefinition, {
22
- readonly type: 'repeat-group';
23
- }>;
24
24
  export declare const groupElementDefinition: (element: AnyBodyElementDefinition) => AnyGroupElementDefinition | null;
25
25
  export type AnyControlElementDefinition = Extract<AnyBodyElementDefinition, {
26
26
  readonly category: 'control';
@@ -36,17 +36,35 @@ declare class BodyElementMap extends Map<BodyElementReference, AnyBodyElementDef
36
36
  [k: string]: AnyBodyElementDefinition;
37
37
  };
38
38
  }
39
+ declare const bodyClassParser: TokenListParser<"pages", "pages">;
40
+ export type BodyClassList = ParsedTokenList<typeof bodyClassParser>;
39
41
  export declare class BodyDefinition extends DependencyContext {
40
42
  protected readonly form: XFormDefinition;
41
43
  static getChildElementDefinitions(form: XFormDefinition, parent: BodyElementParentContext, parentElement: Element, children?: readonly Element[]): readonly AnyBodyElementDefinition[];
42
44
  readonly element: Element;
45
+ /**
46
+ * @todo this class is already an oddity in that it's **like** an element
47
+ * definition, but it isn't one itself. Adding this property here emphasizes
48
+ * that awkwardness. It also extends the applicable scope where instances of
49
+ * this class are accessed. While it's still ephemeral, it's anticipated that
50
+ * this extension might cause some disomfort. If so, the most plausible
51
+ * alternative is an additional refactor to:
52
+ *
53
+ * 1. Introduce a `BodyElementDefinition` sublass for `<h:body>`.
54
+ * 2. Disambiguate the respective names of those, in some reasonable way.
55
+ * 3. Add a layer of indirection between this class and that new body element
56
+ * definition's class.
57
+ * 4. At that point, we may as well prioritize the little bit of grunt work to
58
+ * pass the `BodyDefinition` instance by reference rather than assigning it
59
+ * to anything.
60
+ */
61
+ readonly classes: BodyClassList;
43
62
  readonly elements: readonly AnyBodyElementDefinition[];
44
63
  protected readonly elementsByReference: BodyElementMap;
45
64
  readonly parentReference: null;
46
65
  readonly reference: string;
47
66
  constructor(form: XFormDefinition);
48
67
  getBodyElement(reference: string): AnyBodyElementDefinition | null;
49
- getRepeatGroup(reference: string): RepeatGroupDefinition | null;
50
- toJSON(): Omit<this, "toJSON" | "form" | "isTranslated" | "registerDependentExpression" | "dependencyExpressions" | "getBodyElement" | "getRepeatGroup">;
68
+ toJSON(): Omit<this, "toJSON" | "form" | "isTranslated" | "registerDependentExpression" | "dependencyExpressions" | "getBodyElement">;
51
69
  }
52
70
  export {};
@@ -1,8 +1,9 @@
1
- import type { XFormDefinition } from '../XFormDefinition.ts';
1
+ import { XFormDefinition } from '../XFormDefinition.ts';
2
2
  import { DependencyContext } from '../expression/DependencyContext.ts';
3
- import type { BodyElementParentContext } from './BodyDefinition.ts';
4
- import type { HintDefinition } from './text/HintDefinition.ts';
5
- import type { LabelDefinition } from './text/LabelDefinition.ts';
3
+ import { BodyElementParentContext } from './BodyDefinition.ts';
4
+ import { HintDefinition } from './text/HintDefinition.ts';
5
+ import { LabelDefinition } from './text/LabelDefinition.ts';
6
+
6
7
  /**
7
8
  * These category names roughly correspond to each of the ODK XForms spec's
8
9
  * {@link https://getodk.github.io/xforms-spec/#body-elements | Body Elements}
@@ -0,0 +1,19 @@
1
+ import { XFormDefinition } from '../XFormDefinition.ts';
2
+ import { BodyElementDefinitionArray, BodyElementParentContext } from './BodyDefinition.ts';
3
+ import { BodyElementDefinition } from './BodyElementDefinition.ts';
4
+ import { StructureElementAppearanceDefinition } from './appearance/structureElementAppearanceParser.ts';
5
+ import { LabelDefinition } from './text/LabelDefinition.ts';
6
+
7
+ export declare class RepeatElementDefinition extends BodyElementDefinition<'repeat'> {
8
+ static isCompatible(localName: string): boolean;
9
+ readonly category = "structure";
10
+ readonly type = "repeat";
11
+ readonly reference: string;
12
+ readonly appearances: StructureElementAppearanceDefinition;
13
+ readonly label: LabelDefinition | null;
14
+ readonly countExpression: string | null;
15
+ readonly isFixedCount: boolean;
16
+ readonly children: BodyElementDefinitionArray;
17
+ constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element);
18
+ toJSON(): Omit<this, "toJSON" | "form" | "parent" | "isTranslated" | "registerDependentExpression" | "dependencyExpressions">;
19
+ }
@@ -1,6 +1,7 @@
1
- import type { XFormDefinition } from '../XFormDefinition.ts';
2
- import type { BodyElementParentContext } from './BodyDefinition.ts';
1
+ import { XFormDefinition } from '../XFormDefinition.ts';
2
+ import { BodyElementParentContext } from './BodyDefinition.ts';
3
3
  import { BodyElementDefinition } from './BodyElementDefinition.ts';
4
+
4
5
  export declare class UnsupportedBodyElementDefinition extends BodyElementDefinition<'UNSUPPORTED'> {
5
6
  static isCompatible(): boolean;
6
7
  readonly category = "UNSUPPORTED";
@@ -0,0 +1,4 @@
1
+ import { TokenListParser, ParsedTokenList } from '../../lib/TokenListParser.ts';
2
+
3
+ export declare const inputAppearanceParser: TokenListParser<"multiline" | "numbers" | "url" | "thousand-sep" | "no-calendar" | "month-year" | "year" | "ethiopian" | "coptic" | "islamic" | "bikram-sambat" | "myanmar" | "persian" | "placement-map" | "maps" | "hidden-answer" | "annotate" | "draw" | "signature" | "new-front" | "new" | "front" | "printer" | "masked", "multiline" | "numbers" | "url" | "thousand-sep" | "no-calendar" | "month-year" | "year" | "ethiopian" | "coptic" | "islamic" | "bikram-sambat" | "myanmar" | "persian" | "placement-map" | "maps" | "hidden-answer" | "annotate" | "draw" | "signature" | "new-front" | "new" | "front" | "printer" | "masked">;
4
+ export type InputAppearanceDefinition = ParsedTokenList<typeof inputAppearanceParser>;
@@ -0,0 +1,4 @@
1
+ import { TokenListParser, ParsedTokenList } from '../../lib/TokenListParser.ts';
2
+
3
+ export declare const selectAppearanceParser: TokenListParser<"map" | "label" | "compact" | "horizontal" | "horizontal-compact" | "list-nolabel" | "minimal" | "columns" | "columns-1" | "columns-2" | "columns-3" | "columns-4" | "columns-5" | "columns-pack" | "autocomplete" | "likert" | "quick" | "quickcompact", "autocomplete">;
4
+ export type SelectAppearanceDefinition = ParsedTokenList<typeof selectAppearanceParser>;
@@ -0,0 +1,4 @@
1
+ import { TokenListParser, ParsedTokenList } from '../../lib/TokenListParser.ts';
2
+
3
+ export declare const structureElementAppearanceParser: TokenListParser<"field-list" | "table-list", "field-list" | "table-list">;
4
+ export type StructureElementAppearanceDefinition = ParsedTokenList<typeof structureElementAppearanceParser>;
@@ -1,8 +1,10 @@
1
- import type { XFormDefinition } from '../../XFormDefinition.ts';
2
- import type { BodyElementParentContext } from '../BodyDefinition.ts';
1
+ import { XFormDefinition } from '../../XFormDefinition.ts';
2
+ import { ParsedTokenList } from '../../lib/TokenListParser.ts';
3
+ import { BodyElementParentContext } from '../BodyDefinition.ts';
3
4
  import { BodyElementDefinition } from '../BodyElementDefinition.ts';
4
5
  import { HintDefinition } from '../text/HintDefinition.ts';
5
6
  import { LabelDefinition } from '../text/LabelDefinition.ts';
7
+
6
8
  type ControlType = 'input' | 'range' | 'rank' | 'select' | 'select1' | 'trigger' | 'upload';
7
9
  export declare abstract class ControlDefinition<Type extends ControlType> extends BodyElementDefinition<Type> {
8
10
  readonly category = "control";
@@ -10,6 +12,7 @@ export declare abstract class ControlDefinition<Type extends ControlType> extend
10
12
  readonly reference: string;
11
13
  readonly label: LabelDefinition | null;
12
14
  readonly hint: HintDefinition | null;
15
+ abstract readonly appearances: ParsedTokenList<any>;
13
16
  constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element);
14
17
  }
15
18
  export type AnyControlDefinition = ControlDefinition<any>;
@@ -1,5 +1,11 @@
1
+ import { XFormDefinition } from '../../XFormDefinition.ts';
2
+ import { BodyElementParentContext } from '../BodyDefinition.ts';
3
+ import { InputAppearanceDefinition } from '../appearance/inputAppearanceParser.ts';
1
4
  import { ControlDefinition } from './ControlDefinition.ts';
5
+
2
6
  export declare class InputDefinition extends ControlDefinition<'input'> {
3
7
  static isCompatible(localName: string): boolean;
4
8
  readonly type = "input";
9
+ readonly appearances: InputAppearanceDefinition;
10
+ constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element);
5
11
  }
@@ -1,8 +1,9 @@
1
- import { type ItemElement } from '../../../lib/dom/query.ts';
2
- import type { XFormDefinition } from '../../../XFormDefinition.ts';
1
+ import { ItemElement } from '../../../lib/dom/query.ts';
2
+ import { XFormDefinition } from '../../../XFormDefinition.ts';
3
3
  import { BodyElementDefinition } from '../../BodyElementDefinition.ts';
4
4
  import { LabelDefinition } from '../../text/LabelDefinition.ts';
5
- import type { AnySelectDefinition } from './SelectDefinition.ts';
5
+ import { AnySelectDefinition } from './SelectDefinition.ts';
6
+
6
7
  export declare class ItemDefinition extends BodyElementDefinition<'item'> {
7
8
  readonly parent: AnySelectDefinition;
8
9
  readonly category = "support";
@@ -1,10 +1,11 @@
1
- import { type ItemsetElement } from '../../../lib/dom/query.ts';
2
- import type { XFormDefinition } from '../../../XFormDefinition.ts';
1
+ import { ItemsetElement } from '../../../lib/dom/query.ts';
2
+ import { XFormDefinition } from '../../../XFormDefinition.ts';
3
3
  import { BodyElementDefinition } from '../../BodyElementDefinition.ts';
4
4
  import { LabelDefinition } from '../../text/LabelDefinition.ts';
5
5
  import { ItemsetNodesetExpression } from './ItemsetNodesetExpression.ts';
6
6
  import { ItemsetValueExpression } from './ItemsetValueExpression.ts';
7
- import type { AnySelectDefinition } from './SelectDefinition.ts';
7
+ import { AnySelectDefinition } from './SelectDefinition.ts';
8
+
8
9
  export declare class ItemsetDefinition extends BodyElementDefinition<'itemset'> {
9
10
  readonly category = "support";
10
11
  readonly type = "itemset";
@@ -1,6 +1,7 @@
1
1
  import { DependencyContext } from '../../../expression/DependencyContext.ts';
2
- import type { AnyDependentExpression } from '../../../expression/DependentExpression.ts';
3
- import type { ItemsetDefinition } from './ItemsetDefinition.ts';
2
+ import { AnyDependentExpression } from '../../../expression/DependentExpression.ts';
3
+ import { ItemsetDefinition } from './ItemsetDefinition.ts';
4
+
4
5
  export declare class ItemsetNodesetContext extends DependencyContext {
5
6
  protected readonly itemset: ItemsetDefinition;
6
7
  readonly parentReference: null;
@@ -1,5 +1,6 @@
1
1
  import { DependentExpression } from '../../../expression/DependentExpression.ts';
2
- import type { ItemsetDefinition } from './ItemsetDefinition.ts';
2
+ import { ItemsetDefinition } from './ItemsetDefinition.ts';
3
+
3
4
  export declare class ItemsetNodesetExpression extends DependentExpression<'nodes'> {
4
5
  constructor(itemset: ItemsetDefinition, nodesetExpression: string);
5
6
  }
@@ -1,5 +1,6 @@
1
1
  import { DependentExpression } from '../../../expression/DependentExpression.ts';
2
- import type { ItemsetDefinition } from './ItemsetDefinition.ts';
2
+ import { ItemsetDefinition } from './ItemsetDefinition.ts';
3
+
3
4
  export declare class ItemsetValueExpression extends DependentExpression<'string'> {
4
5
  readonly itemset: ItemsetDefinition;
5
6
  constructor(itemset: ItemsetDefinition, expression: string);
@@ -1,11 +1,21 @@
1
- import type { CollectionValues } from '../../../../../common/types/collections/CollectionValues.ts';
2
- import type { LocalNamedElement } from '../../../../../common/types/dom.ts';
3
- import type { XFormDefinition } from '../../../XFormDefinition.ts';
4
- import type { AnyBodyElementDefinition, BodyElementParentContext } from '../../BodyDefinition.ts';
1
+ import { CollectionValues } from '../../../../../common/types/collections/CollectionValues.ts';
2
+ import { LocalNamedElement } from '../../../../../common/types/dom.ts';
3
+ import { XFormDefinition } from '../../../XFormDefinition.ts';
4
+ import { AnyBodyElementDefinition, BodyElementParentContext } from '../../BodyDefinition.ts';
5
+ import { SelectAppearanceDefinition } from '../../appearance/selectAppearanceParser.ts';
5
6
  import { ControlDefinition } from '../ControlDefinition.ts';
6
7
  import { ItemDefinition } from './ItemDefinition.ts';
7
8
  import { ItemsetDefinition } from './ItemsetDefinition.ts';
8
- declare const selectLocalNames: Set<"select" | "rank" | "select1">;
9
+
10
+ /**
11
+ * @todo We were previously a bit overzealous about introducing `<rank>` support
12
+ * here. It'll likely still fit, but we should approach it with more intention.
13
+ *
14
+ * @todo `<trigger>` is *almost* reasonable to support here too. The main
15
+ * hesitation is that its single, implicit "item" does not have a distinct
16
+ * <label>, and presumably has different UX **and translation** considerations.
17
+ */
18
+ declare const selectLocalNames: Set<"select" | "select1">;
9
19
  export type SelectType = CollectionValues<typeof selectLocalNames>;
10
20
  export interface SelectElement extends LocalNamedElement<SelectType> {
11
21
  }
@@ -14,6 +24,7 @@ export declare class SelectDefinition<Type extends SelectType> extends ControlDe
14
24
  static isSelect(element: AnyBodyElementDefinition): element is AnySelectDefinition;
15
25
  readonly type: Type;
16
26
  readonly element: SelectElement;
27
+ readonly appearances: SelectAppearanceDefinition;
17
28
  readonly itemset: ItemsetDefinition | null;
18
29
  readonly items: readonly ItemDefinition[];
19
30
  constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element);
@@ -1,7 +1,9 @@
1
- import type { XFormDefinition } from '../../XFormDefinition.ts';
2
- import { type BodyElementDefinitionArray, type BodyElementParentContext } from '../BodyDefinition.ts';
1
+ import { XFormDefinition } from '../../XFormDefinition.ts';
2
+ import { BodyElementDefinitionArray, BodyElementParentContext } from '../BodyDefinition.ts';
3
3
  import { BodyElementDefinition } from '../BodyElementDefinition.ts';
4
+ import { StructureElementAppearanceDefinition } from '../appearance/structureElementAppearanceParser.ts';
4
5
  import { LabelDefinition } from '../text/LabelDefinition.ts';
6
+
5
7
  /**
6
8
  * These type names are derived from **and expand upon** the language used in
7
9
  * the ODK XForms spec to describe various group usage. Whereas the spec
@@ -15,10 +17,6 @@ import { LabelDefinition } from '../text/LabelDefinition.ts';
15
17
  * - `presentation-group` is a group with a `<label>` child; its usage here
16
18
  * differs from the spec language in that `presentation-group` does **not**
17
19
  * have a `ref`
18
- * - `repeat-group` is not mentioned by the spec; it is an extension of
19
- * `logical-group`, wherein its `ref` is the same as its immediate `<repeat>`
20
- * child's `nodeset` (usage of each attribute is normalized during
21
- * initialization, in {@link XFormDOM})
22
20
  * - `structural-group` is any `<group>` element which does not satisfy any of
23
21
  * the other usage scenarios; this isn't exactly the terminology used, but is
24
22
  * the most closely fitting name for the concept where the other sceanarios
@@ -26,21 +24,19 @@ import { LabelDefinition } from '../text/LabelDefinition.ts';
26
24
  *
27
25
  * A more succinct decision tree:
28
26
  *
29
- * - `<group ref="$ref"><repeat nodeset="$ref">` -> `repeat-group`, else
30
27
  * - `<group ref="$ref">` -> `logical-group`, else
31
28
  * - `<group><label>` -> `presentation-group`, else
32
29
  * - `<group>` -> `structural-group`
33
30
  */
34
- export type GroupType = 'logical-group' | 'presentation-group' | 'repeat-group' | 'structural-group';
31
+ export type GroupType = 'logical-group' | 'presentation-group' | 'structural-group';
35
32
  export declare abstract class BaseGroupDefinition<Type extends GroupType> extends BodyElementDefinition<Type> {
36
33
  private static groupTypes;
37
34
  protected static getGroupType(localName: string, element: Element): GroupType | null;
38
35
  readonly category = "structure";
39
36
  readonly children: BodyElementDefinitionArray;
40
37
  readonly reference: string | null;
38
+ readonly appearances: StructureElementAppearanceDefinition;
41
39
  readonly label: LabelDefinition | null;
42
40
  constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element, children?: BodyElementDefinitionArray);
43
41
  getChildren(element: Element): BodyElementDefinitionArray;
44
42
  }
45
- export declare const repeatGroup: <T extends BaseGroupDefinition<any>>(groupDefinition: T) => Extract<T, BaseGroupDefinition<"repeat-group">> | null;
46
- export declare const nonRepeatGroup: <T extends BaseGroupDefinition<any>>(groupDefinition: T) => Exclude<T, BaseGroupDefinition<"repeat-group">> | null;
@@ -1,4 +1,5 @@
1
1
  import { BaseGroupDefinition } from './BaseGroupDefinition.ts';
2
+
2
3
  export declare class LogicalGroupDefinition extends BaseGroupDefinition<'logical-group'> {
3
4
  static isCompatible(localName: string, element: Element): boolean;
4
5
  readonly type = "logical-group";
@@ -1,7 +1,8 @@
1
- import type { XFormDefinition } from '../../XFormDefinition.ts';
2
- import type { BodyElementParentContext } from '../BodyDefinition.ts';
1
+ import { XFormDefinition } from '../../XFormDefinition.ts';
2
+ import { BodyElementParentContext } from '../BodyDefinition.ts';
3
3
  import { LabelDefinition } from '../text/LabelDefinition.ts';
4
4
  import { BaseGroupDefinition } from './BaseGroupDefinition.ts';
5
+
5
6
  export declare class PresentationGroupDefinition extends BaseGroupDefinition<'presentation-group'> {
6
7
  static isCompatible(localName: string, element: Element): boolean;
7
8
  readonly type = "presentation-group";
@@ -1,4 +1,5 @@
1
1
  import { BaseGroupDefinition } from './BaseGroupDefinition.ts';
2
+
2
3
  export declare class StructuralGroupDefinition extends BaseGroupDefinition<'structural-group'> {
3
4
  static isCompatible(localName: string, element: Element): boolean;
4
5
  readonly type = "structural-group";
@@ -1,7 +1,7 @@
1
- import type { XFormDefinition } from '../../XFormDefinition.ts';
2
- import type { AnyControlDefinition } from '../control/ControlDefinition.ts';
3
- import type { TextElement } from './TextElementDefinition.ts';
4
- import { TextElementDefinition } from './TextElementDefinition.ts';
1
+ import { XFormDefinition } from '../../XFormDefinition.ts';
2
+ import { AnyControlDefinition } from '../control/ControlDefinition.ts';
3
+ import { TextElement, TextElementDefinition } from './TextElementDefinition.ts';
4
+
5
5
  export interface HintElement extends TextElement {
6
6
  readonly localName: 'hint';
7
7
  }
@@ -1,10 +1,11 @@
1
- import type { XFormDefinition } from '../../XFormDefinition.ts';
2
- import type { AnyControlDefinition } from '../control/ControlDefinition.ts';
3
- import type { ItemDefinition } from '../control/select/ItemDefinition.ts';
4
- import type { ItemsetDefinition } from '../control/select/ItemsetDefinition.ts';
5
- import type { BaseGroupDefinition } from '../group/BaseGroupDefinition.ts';
6
- import type { TextElement, TextElementOwner } from './TextElementDefinition.ts';
7
- import { TextElementDefinition } from './TextElementDefinition.ts';
1
+ import { XFormDefinition } from '../../XFormDefinition.ts';
2
+ import { AnyControlDefinition } from '../control/ControlDefinition.ts';
3
+ import { ItemDefinition } from '../control/select/ItemDefinition.ts';
4
+ import { ItemsetDefinition } from '../control/select/ItemsetDefinition.ts';
5
+ import { BaseGroupDefinition } from '../group/BaseGroupDefinition.ts';
6
+ import { RepeatElementDefinition } from '../RepeatElementDefinition.ts';
7
+ import { TextElement, TextElementOwner, TextElementDefinition } from './TextElementDefinition.ts';
8
+
8
9
  export interface LabelElement extends TextElement {
9
10
  readonly localName: 'label';
10
11
  }
@@ -12,6 +13,7 @@ type StaticLabelContext = Exclude<TextElementOwner, ItemsetDefinition>;
12
13
  export declare class LabelDefinition extends TextElementDefinition<'label'> {
13
14
  protected static staticDefinition(form: XFormDefinition, definition: StaticLabelContext): LabelDefinition | null;
14
15
  static forControl(form: XFormDefinition, control: AnyControlDefinition): LabelDefinition | null;
16
+ static forRepeatGroup(form: XFormDefinition, repeat: RepeatElementDefinition): LabelDefinition | null;
15
17
  static forGroup(form: XFormDefinition, group: BaseGroupDefinition<any>): LabelDefinition | null;
16
18
  static forItem(form: XFormDefinition, item: ItemDefinition): LabelDefinition | null;
17
19
  static forItemset(form: XFormDefinition, itemset: ItemsetDefinition): LabelDefinition | null;
@@ -1,19 +1,20 @@
1
- import type { XFormDefinition } from '../../XFormDefinition.ts';
2
- import { type AnyDependentExpression } from '../../expression/DependentExpression.ts';
3
- import type { AnyGroupElementDefinition } from '../BodyDefinition.ts';
1
+ import { XFormDefinition } from '../../XFormDefinition.ts';
2
+ import { AnyDependentExpression } from '../../expression/DependentExpression.ts';
3
+ import { AnyGroupElementDefinition } from '../BodyDefinition.ts';
4
4
  import { BodyElementDefinition } from '../BodyElementDefinition.ts';
5
- import type { InputDefinition } from '../control/InputDefinition.ts';
6
- import type { ItemDefinition } from '../control/select/ItemDefinition.ts';
7
- import type { ItemsetDefinition } from '../control/select/ItemsetDefinition.ts';
8
- import type { AnySelectDefinition } from '../control/select/SelectDefinition.ts';
5
+ import { RepeatElementDefinition } from '../RepeatElementDefinition.ts';
6
+ import { AnyControlDefinition } from '../control/ControlDefinition.ts';
7
+ import { ItemDefinition } from '../control/select/ItemDefinition.ts';
8
+ import { ItemsetDefinition } from '../control/select/ItemsetDefinition.ts';
9
9
  import { TextElementOutputPart } from './TextElementOutputPart.ts';
10
10
  import { TextElementReferencePart } from './TextElementReferencePart.ts';
11
11
  import { TextElementStaticPart } from './TextElementStaticPart.ts';
12
+
12
13
  export type TextElementType = 'hint' | 'label';
13
14
  export interface TextElement extends Element {
14
15
  readonly localName: TextElementType;
15
16
  }
16
- export type TextElementOwner = AnyGroupElementDefinition | AnySelectDefinition | InputDefinition | ItemDefinition | ItemsetDefinition;
17
+ export type TextElementOwner = AnyControlDefinition | AnyGroupElementDefinition | ItemDefinition | ItemsetDefinition | RepeatElementDefinition;
17
18
  export type TextElementChild = TextElementOutputPart | TextElementStaticPart;
18
19
  export declare abstract class TextElementDefinition<Type extends TextElementType> extends BodyElementDefinition<Type> {
19
20
  readonly owner: TextElementOwner;
@@ -1,5 +1,6 @@
1
- import type { AnyTextElementDefinition } from './TextElementDefinition.ts';
1
+ import { AnyTextElementDefinition } from './TextElementDefinition.ts';
2
2
  import { TextElementPart } from './TextElementPart.ts';
3
+
3
4
  interface OutputElement extends Element {
4
5
  readonly localName: 'output';
5
6
  getAttribute(name: 'value'): string;
@@ -1,8 +1,9 @@
1
1
  import { DependentExpression } from '../../expression/DependentExpression.ts';
2
- import type { AnyTextElementDefinition } from './TextElementDefinition.ts';
3
- import type { TextElementOutputPart } from './TextElementOutputPart.ts';
4
- import type { TextElementReferencePart } from './TextElementReferencePart.ts';
5
- import type { TextElementStaticPart } from './TextElementStaticPart.ts';
2
+ import { AnyTextElementDefinition } from './TextElementDefinition.ts';
3
+ import { TextElementOutputPart } from './TextElementOutputPart.ts';
4
+ import { TextElementReferencePart } from './TextElementReferencePart.ts';
5
+ import { TextElementStaticPart } from './TextElementStaticPart.ts';
6
+
6
7
  export type TextElementPartType = 'output' | 'reference' | 'static';
7
8
  export declare abstract class TextElementPart<Type extends TextElementPartType> extends DependentExpression<'string'> {
8
9
  readonly type: Type;
@@ -1,5 +1,6 @@
1
- import type { AnyTextElementDefinition, TextElement } from './TextElementDefinition.ts';
1
+ import { AnyTextElementDefinition, TextElement } from './TextElementDefinition.ts';
2
2
  import { TextElementPart } from './TextElementPart.ts';
3
+
3
4
  export declare class TextElementReferencePart extends TextElementPart<'reference'> {
4
5
  static from(context: AnyTextElementDefinition, element: TextElement): TextElementReferencePart | null;
5
6
  protected constructor(context: AnyTextElementDefinition, expression: string);
@@ -1,5 +1,6 @@
1
- import type { AnyTextElementDefinition } from './TextElementDefinition.ts';
1
+ import { AnyTextElementDefinition } from './TextElementDefinition.ts';
2
2
  import { TextElementPart } from './TextElementPart.ts';
3
+
3
4
  export declare class TextElementStaticPart extends TextElementPart<'static'> {
4
5
  readonly stringValue: string;
5
6
  constructor(context: AnyTextElementDefinition, node: Text);
@@ -1,6 +1,8 @@
1
- import type { AnyNodeDefinition } from '../model/NodeDefinition.ts';
2
- import type { InstanceNodeType } from './node-types.js';
3
- import type { TextRange } from './TextRange.ts';
1
+ import { AnyNodeDefinition } from '../model/NodeDefinition.ts';
2
+ import { NodeAppearances } from './NodeAppearances.ts';
3
+ import { TextRange } from './TextRange.ts';
4
+ import { InstanceNodeType } from './node-types.ts';
5
+
4
6
  export interface BaseNodeState {
5
7
  /**
6
8
  * Location path reference to the node's primary instance state. This property
@@ -107,6 +109,10 @@ export interface BaseNode {
107
109
  * the lifetime of an active session filling a form.
108
110
  */
109
111
  readonly nodeId: FormNodeID;
112
+ /**
113
+ * @see {@link TokenListParser} for details.
114
+ */
115
+ readonly appearances: NodeAppearances<any> | null;
110
116
  /**
111
117
  * Each node has a definition which specifies aspects of the node defined in
112
118
  * the form. These aspects include (but are not limited to) the node's data
@@ -1,4 +1,5 @@
1
- import type { OpaqueReactiveObjectFactory } from './OpaqueReactiveObjectFactory.ts';
1
+ import { OpaqueReactiveObjectFactory } from './OpaqueReactiveObjectFactory.ts';
2
+
2
3
  /**
3
4
  * @todo this is currently a strict subset of the web standard `Response`. Is it
4
5
  * sufficient? Ways it might not be:
@@ -1,8 +1,10 @@
1
- import type { NonRepeatGroupElementDefinition } from '../body/BodyDefinition.ts';
2
- import type { SubtreeDefinition } from '../model/SubtreeDefinition.ts';
3
- import type { BaseNode, BaseNodeState } from './BaseNode.ts';
4
- import type { RootNode } from './RootNode.ts';
5
- import type { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
1
+ import { AnyGroupElementDefinition } from '../body/BodyDefinition.ts';
2
+ import { SubtreeDefinition } from '../model/SubtreeDefinition.ts';
3
+ import { BaseNode, BaseNodeState } from './BaseNode.ts';
4
+ import { NodeAppearances } from './NodeAppearances.ts';
5
+ import { RootNode } from './RootNode.ts';
6
+ import { GeneralChildNode, GeneralParentNode } from './hierarchy.ts';
7
+
6
8
  export interface GroupNodeState extends BaseNodeState {
7
9
  get hint(): null;
8
10
  get children(): readonly GeneralChildNode[];
@@ -10,13 +12,15 @@ export interface GroupNodeState extends BaseNodeState {
10
12
  get value(): null;
11
13
  }
12
14
  export interface GroupDefinition extends SubtreeDefinition {
13
- readonly bodyElement: NonRepeatGroupElementDefinition;
15
+ readonly bodyElement: AnyGroupElementDefinition;
14
16
  }
17
+ export type GroupNodeAppearances = NodeAppearances<GroupDefinition>;
15
18
  /**
16
19
  * A node corresponding to an XForms `<group>`.
17
20
  */
18
21
  export interface GroupNode extends BaseNode {
19
22
  readonly nodeType: 'group';
23
+ readonly appearances: GroupNodeAppearances;
20
24
  readonly definition: GroupDefinition;
21
25
  readonly root: RootNode;
22
26
  readonly parent: GeneralParentNode;
@@ -0,0 +1,15 @@
1
+ import { ParsedTokenList } from '../lib/TokenListParser.ts';
2
+ import { NodeDefinition } from '../model/NodeDefinition.ts';
3
+
4
+ /**
5
+ * - Provides a means to distinguish between internal and client-facing names
6
+ * for the same {@link ParsedTokenList} types.
7
+ *
8
+ * - Anticipates some iteration on both parsed ("definition") types and
9
+ * client-facing node types, which may not happen in tandem.
10
+ */
11
+ export type NodeAppearances<Definition extends NodeDefinition<any>> = Definition extends {
12
+ readonly bodyElement: {
13
+ readonly appearances: infer Appearances extends ParsedTokenList<any>;
14
+ };
15
+ } ? Appearances : null;
@@ -1,9 +1,11 @@
1
- import type { RepeatInstanceDefinition } from '../model/RepeatInstanceDefinition.ts';
2
- import type { RepeatTemplateDefinition } from '../model/RepeatTemplateDefinition.ts';
3
- import type { BaseNode, BaseNodeState } from './BaseNode.ts';
4
- import type { RepeatRangeNode } from './RepeatRangeNode.ts';
5
- import type { RootNode } from './RootNode.ts';
6
- import type { GeneralChildNode } from './hierarchy.ts';
1
+ import { RepeatInstanceDefinition } from '../model/RepeatInstanceDefinition.ts';
2
+ import { RepeatTemplateDefinition } from '../model/RepeatTemplateDefinition.ts';
3
+ import { BaseNode, BaseNodeState } from './BaseNode.ts';
4
+ import { NodeAppearances } from './NodeAppearances.ts';
5
+ import { RepeatRangeNode } from './RepeatRangeNode.ts';
6
+ import { RootNode } from './RootNode.ts';
7
+ import { GeneralChildNode } from './hierarchy.ts';
8
+
7
9
  export interface RepeatInstanceNodeState extends BaseNodeState {
8
10
  get hint(): null;
9
11
  get children(): readonly GeneralChildNode[];
@@ -11,8 +13,10 @@ export interface RepeatInstanceNodeState extends BaseNodeState {
11
13
  get value(): null;
12
14
  }
13
15
  export type RepeatDefinition = RepeatInstanceDefinition | RepeatTemplateDefinition;
16
+ export type RepeatInstanceNodeAppearances = NodeAppearances<RepeatDefinition>;
14
17
  export interface RepeatInstanceNode extends BaseNode {
15
18
  readonly nodeType: 'repeat-instance';
19
+ readonly appearances: RepeatInstanceNodeAppearances;
16
20
  readonly definition: RepeatDefinition;
17
21
  readonly root: RootNode;
18
22
  /**