@getodk/xforms-engine 0.1.1 → 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.
- package/dist/body/BodyDefinition.d.ts +24 -7
- package/dist/body/RepeatElementDefinition.d.ts +19 -0
- package/dist/body/appearance/inputAppearanceParser.d.ts +4 -0
- package/dist/body/appearance/selectAppearanceParser.d.ts +4 -0
- package/dist/body/appearance/structureElementAppearanceParser.d.ts +4 -0
- package/dist/body/control/ControlDefinition.d.ts +2 -0
- package/dist/body/control/InputDefinition.d.ts +5 -0
- package/dist/body/control/select/SelectDefinition.d.ts +11 -1
- package/dist/body/group/BaseGroupDefinition.d.ts +3 -8
- package/dist/body/text/LabelDefinition.d.ts +2 -0
- package/dist/body/text/TextElementDefinition.d.ts +3 -3
- package/dist/client/BaseNode.d.ts +6 -1
- package/dist/client/GroupNode.d.ts +5 -2
- package/dist/client/NodeAppearances.d.ts +15 -0
- package/dist/client/RepeatInstanceNode.d.ts +3 -0
- package/dist/client/RepeatRangeNode.d.ts +5 -2
- package/dist/client/RootNode.d.ts +19 -0
- package/dist/client/SelectNode.d.ts +3 -0
- package/dist/client/StringNode.d.ts +3 -0
- package/dist/client/SubtreeNode.d.ts +1 -0
- package/dist/index.js +624 -368
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +3 -3
- package/dist/instance/RepeatInstance.d.ts +26 -2
- package/dist/instance/RepeatRange.d.ts +84 -5
- package/dist/instance/Root.d.ts +8 -23
- package/dist/instance/SelectField.d.ts +2 -2
- package/dist/instance/StringField.d.ts +2 -2
- package/dist/instance/Subtree.d.ts +1 -1
- package/dist/instance/abstract/DescendantNode.d.ts +12 -4
- package/dist/instance/abstract/InstanceNode.d.ts +26 -29
- package/dist/instance/internal-api/EvaluationContext.d.ts +5 -4
- package/dist/instance/internal-api/ValueContext.d.ts +2 -2
- package/dist/lib/TokenListParser.d.ts +84 -0
- package/dist/lib/dom/query.d.ts +5 -0
- package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +2 -1
- package/dist/model/DescendentNodeDefinition.d.ts +1 -2
- package/dist/model/NodeDefinition.d.ts +12 -12
- package/dist/model/RepeatInstanceDefinition.d.ts +5 -6
- package/dist/model/{RepeatSequenceDefinition.d.ts → RepeatRangeDefinition.d.ts} +4 -4
- package/dist/model/RepeatTemplateDefinition.d.ts +6 -7
- package/dist/model/RootDefinition.d.ts +3 -1
- package/dist/model/SubtreeDefinition.d.ts +2 -2
- package/dist/model/ValueNodeDefinition.d.ts +2 -3
- package/dist/solid.js +625 -369
- package/dist/solid.js.map +1 -1
- package/package.json +2 -2
- package/src/XFormDOM.ts +81 -8
- package/src/body/BodyDefinition.ts +38 -23
- package/src/body/RepeatElementDefinition.ts +70 -0
- package/src/body/appearance/inputAppearanceParser.ts +39 -0
- package/src/body/appearance/selectAppearanceParser.ts +38 -0
- package/src/body/appearance/structureElementAppearanceParser.ts +7 -0
- package/src/body/control/ControlDefinition.ts +4 -0
- package/src/body/control/InputDefinition.ts +13 -0
- package/src/body/control/select/SelectDefinition.ts +14 -5
- package/src/body/group/BaseGroupDefinition.ts +11 -49
- package/src/body/text/LabelDefinition.ts +15 -1
- package/src/body/text/TextElementDefinition.ts +5 -5
- package/src/client/BaseNode.ts +9 -1
- package/src/client/GroupNode.ts +6 -2
- package/src/client/NodeAppearances.ts +22 -0
- package/src/client/RepeatInstanceNode.ts +4 -0
- package/src/client/RepeatRangeNode.ts +6 -2
- package/src/client/RootNode.ts +22 -0
- package/src/client/SelectNode.ts +4 -0
- package/src/client/StringNode.ts +4 -0
- package/src/client/SubtreeNode.ts +1 -0
- package/src/instance/Group.ts +14 -9
- package/src/instance/RepeatInstance.ts +59 -15
- package/src/instance/RepeatRange.ts +133 -15
- package/src/instance/Root.ts +20 -64
- package/src/instance/SelectField.ts +7 -7
- package/src/instance/StringField.ts +8 -7
- package/src/instance/Subtree.ts +10 -7
- package/src/instance/abstract/DescendantNode.ts +45 -43
- package/src/instance/abstract/InstanceNode.ts +69 -86
- package/src/instance/children.ts +17 -7
- package/src/instance/index.ts +1 -1
- package/src/instance/internal-api/EvaluationContext.ts +5 -6
- package/src/instance/internal-api/ValueContext.ts +2 -2
- package/src/lib/TokenListParser.ts +156 -0
- package/src/lib/dom/query.ts +13 -0
- package/src/lib/reactivity/createChildrenState.ts +51 -6
- package/src/lib/reactivity/createComputedExpression.ts +1 -1
- package/src/lib/reactivity/createSelectItems.ts +4 -6
- package/src/lib/reactivity/createValueState.ts +6 -6
- package/src/lib/reactivity/materializeCurrentStateChildren.ts +3 -1
- package/src/model/DescendentNodeDefinition.ts +1 -2
- package/src/model/ModelDefinition.ts +1 -1
- package/src/model/NodeDefinition.ts +12 -12
- package/src/model/RepeatInstanceDefinition.ts +8 -13
- package/src/model/{RepeatSequenceDefinition.ts → RepeatRangeDefinition.ts} +6 -6
- package/src/model/RepeatTemplateDefinition.ts +10 -15
- package/src/model/RootDefinition.ts +6 -12
- package/src/model/SubtreeDefinition.ts +3 -3
- package/src/model/ValueNodeDefinition.ts +2 -3
- package/dist/body/RepeatDefinition.d.ts +0 -16
- package/dist/body/group/RepeatGroupDefinition.d.ts +0 -13
- package/src/body/RepeatDefinition.ts +0 -54
- package/src/body/group/RepeatGroupDefinition.ts +0 -91
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { JAVAROSA_NAMESPACE_URI } from '@getodk/common/constants/xmlns.ts';
|
|
2
|
-
import type {
|
|
2
|
+
import type { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
|
|
3
3
|
import { BindDefinition } from './BindDefinition.ts';
|
|
4
4
|
import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
|
|
5
5
|
import type { ChildNodeDefinition, NodeDefinition } from './NodeDefinition.ts';
|
|
6
|
-
import type {
|
|
6
|
+
import type { RepeatRangeDefinition } from './RepeatRangeDefinition.ts';
|
|
7
7
|
|
|
8
8
|
const repeatTemplates = new WeakMap<BindDefinition, RepeatTemplateDefinition>();
|
|
9
9
|
|
|
@@ -73,14 +73,14 @@ interface ParsedRepeatNodes {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
export class RepeatTemplateDefinition
|
|
76
|
-
extends DescendentNodeDefinition<'repeat-template',
|
|
76
|
+
extends DescendentNodeDefinition<'repeat-template', RepeatElementDefinition>
|
|
77
77
|
implements NodeDefinition<'repeat-template'>
|
|
78
78
|
{
|
|
79
79
|
static parseModelNodes(
|
|
80
|
-
|
|
80
|
+
range: RepeatRangeDefinition,
|
|
81
81
|
modelNodes: readonly [Element, ...Element[]]
|
|
82
82
|
): ParsedRepeatNodes {
|
|
83
|
-
const { bind } =
|
|
83
|
+
const { bind } = range;
|
|
84
84
|
|
|
85
85
|
let template = repeatTemplates.get(bind);
|
|
86
86
|
let instanceNodes: readonly Element[];
|
|
@@ -89,7 +89,7 @@ export class RepeatTemplateDefinition
|
|
|
89
89
|
const [templateNode, ...rest] = splitInstanceNodes(modelNodes);
|
|
90
90
|
|
|
91
91
|
instanceNodes = rest;
|
|
92
|
-
template = new this(
|
|
92
|
+
template = new this(range, templateNode);
|
|
93
93
|
} else {
|
|
94
94
|
// TODO: this is under the assumption that for any depth > 1, if a
|
|
95
95
|
// template has already been defined for the given form definition, any
|
|
@@ -121,17 +121,12 @@ export class RepeatTemplateDefinition
|
|
|
121
121
|
readonly defaultValue = null;
|
|
122
122
|
|
|
123
123
|
protected constructor(
|
|
124
|
-
|
|
124
|
+
range: RepeatRangeDefinition,
|
|
125
125
|
protected readonly templateNode: ExplicitRepeatTemplateElement
|
|
126
126
|
) {
|
|
127
|
-
const {
|
|
128
|
-
bind,
|
|
129
|
-
bodyElement: repeatGroupBodyElement,
|
|
130
|
-
parent: repeatSequenceParent,
|
|
131
|
-
root,
|
|
132
|
-
} = sequence;
|
|
127
|
+
const { bind, bodyElement, parent, root } = range;
|
|
133
128
|
|
|
134
|
-
super(
|
|
129
|
+
super(parent, bind, bodyElement);
|
|
135
130
|
|
|
136
131
|
const node = templateNode.cloneNode(true) as Element;
|
|
137
132
|
|
|
@@ -143,7 +138,7 @@ export class RepeatTemplateDefinition
|
|
|
143
138
|
}
|
|
144
139
|
|
|
145
140
|
toJSON() {
|
|
146
|
-
const { bind, bodyElement, parent, root,
|
|
141
|
+
const { bind, bodyElement, parent, root, ...rest } = this;
|
|
147
142
|
|
|
148
143
|
return rest;
|
|
149
144
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { XFormDefinition } from '../XFormDefinition.ts';
|
|
2
|
-
import type {
|
|
2
|
+
import type { BodyClassList } from '../body/BodyDefinition.ts';
|
|
3
3
|
import type { BindDefinition } from './BindDefinition.ts';
|
|
4
4
|
import type { ModelDefinition } from './ModelDefinition.ts';
|
|
5
5
|
import type {
|
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
NodeDefinition,
|
|
8
8
|
ParentNodeDefinition,
|
|
9
9
|
} from './NodeDefinition.ts';
|
|
10
|
-
import {
|
|
10
|
+
import { RepeatRangeDefinition } from './RepeatRangeDefinition.ts';
|
|
11
11
|
import { SubtreeDefinition } from './SubtreeDefinition.ts';
|
|
12
12
|
import { ValueNodeDefinition } from './ValueNodeDefinition.ts';
|
|
13
13
|
|
|
@@ -29,7 +29,8 @@ export class RootDefinition implements NodeDefinition<'root'> {
|
|
|
29
29
|
|
|
30
30
|
constructor(
|
|
31
31
|
protected readonly form: XFormDefinition,
|
|
32
|
-
protected readonly model: ModelDefinition
|
|
32
|
+
protected readonly model: ModelDefinition,
|
|
33
|
+
readonly classes: BodyClassList
|
|
33
34
|
) {
|
|
34
35
|
// TODO: theoretically the pertinent step in the bind's `nodeset` *could* be
|
|
35
36
|
// namespaced. It also may make more sense to determine the root nodeset
|
|
@@ -86,16 +87,9 @@ export class RootDefinition implements NodeDefinition<'root'> {
|
|
|
86
87
|
const bind = binds.getOrCreateBindDefinition(nodeset);
|
|
87
88
|
const bodyElement = body.getBodyElement(nodeset);
|
|
88
89
|
const [firstChild, ...restChildren] = children;
|
|
89
|
-
const repeatGroup = body.getRepeatGroup(nodeset);
|
|
90
90
|
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (repeatDefinition == null) {
|
|
95
|
-
throw 'TODO: this is why I have hesitated to pick an "is repeat" predicate direction';
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return new RepeatSequenceDefinition(parent, bind, repeatGroup, children);
|
|
91
|
+
if (bodyElement?.type === 'repeat') {
|
|
92
|
+
return new RepeatRangeDefinition(parent, bind, bodyElement, children);
|
|
99
93
|
}
|
|
100
94
|
|
|
101
95
|
if (restChildren.length) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AnyBodyElementDefinition,
|
|
3
|
-
|
|
3
|
+
AnyGroupElementDefinition,
|
|
4
4
|
} from '../body/BodyDefinition.ts';
|
|
5
5
|
import type { BindDefinition } from './BindDefinition.ts';
|
|
6
6
|
import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
|
|
@@ -11,7 +11,7 @@ import type {
|
|
|
11
11
|
} from './NodeDefinition.ts';
|
|
12
12
|
|
|
13
13
|
export class SubtreeDefinition
|
|
14
|
-
extends DescendentNodeDefinition<'subtree',
|
|
14
|
+
extends DescendentNodeDefinition<'subtree', AnyGroupElementDefinition | null>
|
|
15
15
|
implements NodeDefinition<'subtree'>
|
|
16
16
|
{
|
|
17
17
|
readonly type = 'subtree';
|
|
@@ -29,7 +29,7 @@ export class SubtreeDefinition
|
|
|
29
29
|
) {
|
|
30
30
|
if (
|
|
31
31
|
bodyElement != null &&
|
|
32
|
-
(bodyElement.category !== 'structure' || bodyElement.type === 'repeat
|
|
32
|
+
(bodyElement.category !== 'structure' || bodyElement.type === 'repeat')
|
|
33
33
|
) {
|
|
34
34
|
throw new Error(`Unexpected body element for nodeset ${bind.nodeset}`);
|
|
35
35
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { AnyBodyElementDefinition } from '../body/BodyDefinition.ts';
|
|
2
|
-
import type { AnyControlDefinition } from '../body/control/ControlDefinition.ts';
|
|
1
|
+
import type { AnyBodyElementDefinition, ControlElementDefinition } from '../body/BodyDefinition.ts';
|
|
3
2
|
import type { BindDefinition } from './BindDefinition.ts';
|
|
4
3
|
import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
|
|
5
4
|
import type { NodeDefinition, ParentNodeDefinition } from './NodeDefinition.ts';
|
|
6
5
|
|
|
7
6
|
export class ValueNodeDefinition
|
|
8
|
-
extends DescendentNodeDefinition<'value-node',
|
|
7
|
+
extends DescendentNodeDefinition<'value-node', ControlElementDefinition | null>
|
|
9
8
|
implements NodeDefinition<'value-node'>
|
|
10
9
|
{
|
|
11
10
|
readonly type = 'value-node';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { XFormDefinition } from '../XFormDefinition.ts';
|
|
2
|
-
import { BodyElementDefinitionArray } from './BodyDefinition.ts';
|
|
3
|
-
import { BodyElementDefinition } from './BodyElementDefinition.ts';
|
|
4
|
-
import { RepeatGroupDefinition } from './group/RepeatGroupDefinition.ts';
|
|
5
|
-
|
|
6
|
-
export declare class RepeatDefinition extends BodyElementDefinition<'repeat'> {
|
|
7
|
-
readonly groupDefinition: RepeatGroupDefinition;
|
|
8
|
-
readonly category = "structure";
|
|
9
|
-
readonly type = "repeat";
|
|
10
|
-
readonly reference: string;
|
|
11
|
-
readonly countExpression: string | null;
|
|
12
|
-
readonly isFixedCount: boolean;
|
|
13
|
-
readonly children: BodyElementDefinitionArray;
|
|
14
|
-
constructor(form: XFormDefinition, groupDefinition: RepeatGroupDefinition, element: Element);
|
|
15
|
-
toJSON(): Omit<this, "toJSON" | "form" | "parent" | "isTranslated" | "registerDependentExpression" | "dependencyExpressions" | "groupDefinition">;
|
|
16
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { XFormDefinition } from '../../XFormDefinition.ts';
|
|
2
|
-
import { BodyElementDefinitionArray, BodyElementParentContext } from '../BodyDefinition.ts';
|
|
3
|
-
import { RepeatDefinition } from '../RepeatDefinition.ts';
|
|
4
|
-
import { BaseGroupDefinition } from './BaseGroupDefinition.ts';
|
|
5
|
-
|
|
6
|
-
export declare class RepeatGroupDefinition extends BaseGroupDefinition<'repeat-group'> {
|
|
7
|
-
static isCompatible(localName: string, element: Element): boolean;
|
|
8
|
-
readonly type = "repeat-group";
|
|
9
|
-
readonly repeat: RepeatDefinition;
|
|
10
|
-
get repeatChildren(): BodyElementDefinitionArray;
|
|
11
|
-
constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element);
|
|
12
|
-
}
|
|
13
|
-
export type RepeatGroupDefinitionClass = typeof RepeatGroupDefinition;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { JAVAROSA_NAMESPACE_URI } from '@getodk/common/constants/xmlns.ts';
|
|
2
|
-
import type { XFormDefinition } from '../XFormDefinition.ts';
|
|
3
|
-
import type { BodyElementDefinitionArray } from './BodyDefinition.ts';
|
|
4
|
-
import { BodyElementDefinition } from './BodyElementDefinition.ts';
|
|
5
|
-
import type { RepeatGroupDefinition } from './group/RepeatGroupDefinition.ts';
|
|
6
|
-
|
|
7
|
-
export class RepeatDefinition extends BodyElementDefinition<'repeat'> {
|
|
8
|
-
override readonly category = 'structure';
|
|
9
|
-
readonly type = 'repeat';
|
|
10
|
-
override readonly reference: string;
|
|
11
|
-
|
|
12
|
-
// TODO: this will fall into the growing category of non-`BindExpression`
|
|
13
|
-
// cases which have roughly the same design story.
|
|
14
|
-
readonly countExpression: string | null;
|
|
15
|
-
|
|
16
|
-
readonly isFixedCount: boolean;
|
|
17
|
-
|
|
18
|
-
readonly children: BodyElementDefinitionArray;
|
|
19
|
-
|
|
20
|
-
constructor(
|
|
21
|
-
form: XFormDefinition,
|
|
22
|
-
readonly groupDefinition: RepeatGroupDefinition,
|
|
23
|
-
element: Element
|
|
24
|
-
) {
|
|
25
|
-
super(form, groupDefinition, element);
|
|
26
|
-
|
|
27
|
-
const reference = element.getAttribute('nodeset');
|
|
28
|
-
|
|
29
|
-
if (reference == null) {
|
|
30
|
-
throw new Error('Invalid repeat: missing `nodeset` reference');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
this.reference = reference;
|
|
34
|
-
this.countExpression = element.getAttributeNS(JAVAROSA_NAMESPACE_URI, 'count');
|
|
35
|
-
this.children = groupDefinition.getChildren(element);
|
|
36
|
-
|
|
37
|
-
// Spec says this can be either `true()` or `false()`. That said, it
|
|
38
|
-
// could also presumably be `true ( )` or whatever.
|
|
39
|
-
const noAddRemove =
|
|
40
|
-
element
|
|
41
|
-
.getAttributeNS(JAVAROSA_NAMESPACE_URI, 'noAddRemove')
|
|
42
|
-
?.trim()
|
|
43
|
-
.replaceAll(/\s+/g, '') ?? 'false()';
|
|
44
|
-
|
|
45
|
-
// TODO: **probably** safe to disregard anything else?
|
|
46
|
-
this.isFixedCount = noAddRemove === 'true()';
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
override toJSON() {
|
|
50
|
-
const { form, groupDefinition, parent, ...rest } = this;
|
|
51
|
-
|
|
52
|
-
return rest;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { getRepeatElement } from '../../lib/dom/query.ts';
|
|
2
|
-
import type { XFormDefinition } from '../../XFormDefinition.ts';
|
|
3
|
-
import type { BodyElementDefinitionArray, BodyElementParentContext } from '../BodyDefinition.ts';
|
|
4
|
-
import { RepeatDefinition } from '../RepeatDefinition.ts';
|
|
5
|
-
import { BaseGroupDefinition } from './BaseGroupDefinition.ts';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* TODO: The `RepeatGroupDefinition`/`RepeatDefinition` types are currently
|
|
9
|
-
* expected to always pair, mirroring the corresponding XForm structure, e.g.
|
|
10
|
-
*
|
|
11
|
-
* ```xml
|
|
12
|
-
* <group ref="/root/rep"> <!-- RepeatGroupDefinition -->
|
|
13
|
-
* <repeat nodeset="/root/rep" /> <!-- RepeatDefinition -->
|
|
14
|
-
* </group>
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* This structure has already been a source of one bug (where a recursive walk
|
|
18
|
-
* through a `BodyDefinition`'s descendants failed to reach the children of
|
|
19
|
-
* `RepeatDefinition`s). It seems likely this will continue to be a footgun.
|
|
20
|
-
* After some discussion with @lognaturel, I concluded that the pairing isn't
|
|
21
|
-
* strictly necessary, as this should be considered invalid:
|
|
22
|
-
*
|
|
23
|
-
* ```xml
|
|
24
|
-
* <group ref="/root/rep">
|
|
25
|
-
* <repeat nodeset="/root/rep" />
|
|
26
|
-
* <input ref="/root/rep/not-a-repeat-child" />
|
|
27
|
-
* </group>
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* It **may** make sense to collapse these types in the future, but I've held
|
|
31
|
-
* off, following another discussion with @lognaturel. There's some potential
|
|
32
|
-
* for group/repeat labeling ambiguity.
|
|
33
|
-
*
|
|
34
|
-
* - The current design accommodates sharing a repeat-containing group's label
|
|
35
|
-
* across multiple repeat instances, but
|
|
36
|
-
* - The
|
|
37
|
-
* {@link https://github.com/getodk/xforms-spec/blob/791753a09fabd3d64d8cb95776dc0cef71fa4446/_sections/60-repeats.md?plain=1#L46 | ODK XForms spec suggests}
|
|
38
|
-
* a repeat's first group might be a better candidate
|
|
39
|
-
*
|
|
40
|
-
* Example of such a structure:
|
|
41
|
-
*
|
|
42
|
-
* ```xml
|
|
43
|
-
* <group ref="/root/foo">
|
|
44
|
-
* <label>Foo (outer label)</label>
|
|
45
|
-
* <repeat nodeset="/root/foo">
|
|
46
|
-
* <group>
|
|
47
|
-
* <label>Foo (inner label)</label>
|
|
48
|
-
* <!-- ... -->
|
|
49
|
-
* </group>
|
|
50
|
-
* </repeat>
|
|
51
|
-
* </group>
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
55
|
-
// @ts-ignore - All this so I could attach a JSDoc comment to something other
|
|
56
|
-
// than the actual class...
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-unused-vars
|
|
58
|
-
interface IgnoreMeIAmJustHereForTheJSDoc {}
|
|
59
|
-
|
|
60
|
-
export class RepeatGroupDefinition extends BaseGroupDefinition<'repeat-group'> {
|
|
61
|
-
static override isCompatible(localName: string, element: Element): boolean {
|
|
62
|
-
return this.getGroupType(localName, element) === 'repeat-group';
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
readonly type = 'repeat-group';
|
|
66
|
-
|
|
67
|
-
readonly repeat: RepeatDefinition;
|
|
68
|
-
|
|
69
|
-
get repeatChildren(): BodyElementDefinitionArray {
|
|
70
|
-
return this.repeat.children;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
constructor(form: XFormDefinition, parent: BodyElementParentContext, element: Element) {
|
|
74
|
-
// TODO: this has already been queried at least twice before reaching this
|
|
75
|
-
// point!
|
|
76
|
-
const repeat = getRepeatElement(element);
|
|
77
|
-
|
|
78
|
-
// TODO: and as such, this should not happen
|
|
79
|
-
if (repeat == null) {
|
|
80
|
-
throw new Error('Invalid repeat-group');
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
super(form, parent, element);
|
|
84
|
-
|
|
85
|
-
const repeatDefinition = new RepeatDefinition(form, this, repeat);
|
|
86
|
-
|
|
87
|
-
this.repeat = repeatDefinition;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export type RepeatGroupDefinitionClass = typeof RepeatGroupDefinition;
|