@getodk/xforms-engine 0.5.0 → 0.6.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/README.md +1 -1
- package/dist/client/BaseNode.d.ts +4 -0
- package/dist/client/BaseValueNode.d.ts +1 -1
- package/dist/client/GroupNode.d.ts +1 -0
- package/dist/client/InputNode.d.ts +32 -3
- package/dist/client/ModelValueNode.d.ts +1 -0
- package/dist/client/NoteNode.d.ts +24 -7
- package/dist/client/RangeNode.d.ts +36 -0
- package/dist/client/RankNode.d.ts +46 -0
- package/dist/client/RootNode.d.ts +6 -3
- package/dist/client/SelectNode.d.ts +47 -25
- package/dist/client/SubtreeNode.d.ts +1 -0
- package/dist/client/TriggerNode.d.ts +10 -6
- package/dist/client/hierarchy.d.ts +5 -5
- package/dist/client/node-types.d.ts +2 -2
- package/dist/client/unsupported/UnsupportedControlNode.d.ts +1 -3
- package/dist/error/RankMissingValueError.d.ts +3 -0
- package/dist/error/RankValueTypeError.d.ts +6 -0
- package/dist/error/SelectValueTypeError.d.ts +15 -0
- package/dist/error/XFormsSpecViolationError.d.ts +2 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +5604 -4666
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +1 -0
- package/dist/instance/InputControl.d.ts +5 -3
- package/dist/instance/ModelValue.d.ts +2 -0
- package/dist/instance/Note.d.ts +13 -25
- package/dist/instance/PrimaryInstance.d.ts +1 -0
- package/dist/instance/RangeControl.d.ts +34 -0
- package/dist/instance/RankControl.d.ts +40 -0
- package/dist/instance/Root.d.ts +1 -0
- package/dist/instance/SelectControl.d.ts +66 -0
- package/dist/instance/Subtree.d.ts +1 -0
- package/dist/instance/TriggerControl.d.ts +9 -22
- package/dist/instance/abstract/DescendantNode.d.ts +1 -2
- package/dist/instance/abstract/InstanceNode.d.ts +3 -1
- package/dist/instance/abstract/UnsupportedControl.d.ts +1 -0
- package/dist/instance/abstract/ValueNode.d.ts +0 -1
- package/dist/instance/hierarchy.d.ts +9 -9
- package/dist/instance/internal-api/InstanceValueContext.d.ts +2 -0
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.d.ts +2 -1
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableParentNode.d.ts +2 -1
- package/dist/instance/internal-api/submission/ClientReactiveSubmittableValueNode.d.ts +2 -1
- package/dist/instance/repeat/BaseRepeatRange.d.ts +1 -0
- package/dist/instance/repeat/RepeatInstance.d.ts +1 -0
- package/dist/integration/xpath/adapter/names.d.ts +1 -11
- package/dist/integration/xpath/adapter/traversal.d.ts +10 -9
- package/dist/integration/xpath/static-dom/StaticAttribute.d.ts +10 -3
- package/dist/integration/xpath/static-dom/StaticDocument.d.ts +0 -1
- package/dist/integration/xpath/static-dom/StaticElement.d.ts +12 -4
- package/dist/lib/client-reactivity/submission/createRootSubmissionState.d.ts +3 -0
- package/dist/lib/codecs/Geopoint/Geopoint.d.ts +48 -0
- package/dist/lib/codecs/Geopoint/GeopointValueCodec.d.ts +5 -0
- package/dist/lib/codecs/NoteCodec.d.ts +8 -0
- package/dist/lib/codecs/RangeCodec.d.ts +8 -0
- package/dist/lib/codecs/TriggerCodec.d.ts +7 -0
- package/dist/lib/codecs/ValueArrayCodec.d.ts +11 -0
- package/dist/lib/codecs/ValueCodec.d.ts +2 -2
- package/dist/lib/codecs/getNoteCodec.d.ts +3 -0
- package/dist/lib/codecs/getSelectCodec.d.ts +5 -0
- package/dist/lib/codecs/getSharedValueCodec.d.ts +3 -2
- package/dist/lib/codecs/items/BaseItemCodec.d.ts +9 -0
- package/dist/lib/codecs/items/MultipleValueItemCodec.d.ts +14 -0
- package/dist/lib/codecs/items/SingleValueItemCodec.d.ts +24 -0
- package/dist/lib/dom/query.d.ts +1 -2
- package/dist/lib/names/NamespaceDeclaration.d.ts +45 -0
- package/dist/lib/names/NamespaceDeclarationMap.d.ts +137 -0
- package/dist/lib/names/NamespaceURL.d.ts +30 -0
- package/dist/lib/names/QualifiedName.d.ts +113 -0
- package/dist/lib/number-parsers.d.ts +2 -0
- package/dist/lib/reactivity/createItemCollection.d.ts +21 -0
- package/dist/lib/xml-serialization.d.ts +11 -2
- package/dist/parse/XFormDOM.d.ts +1 -1
- package/dist/parse/body/BodyDefinition.d.ts +2 -2
- package/dist/parse/body/appearance/rangeAppearanceParser.d.ts +3 -0
- package/dist/parse/body/control/InputControlDefinition.d.ts +3 -0
- package/dist/parse/body/control/ItemDefinition.d.ts +14 -0
- package/dist/parse/body/control/ItemsetDefinition.d.ts +18 -0
- package/dist/parse/body/control/RangeControlDefinition.d.ts +31 -2
- package/dist/parse/body/control/RankControlDefinition.d.ts +7 -3
- package/dist/parse/body/control/{select/SelectDefinition.d.ts → SelectControlDefinition.d.ts} +9 -9
- package/dist/parse/expression/ItemsetNodesetExpression.d.ts +1 -1
- package/dist/parse/expression/ItemsetValueExpression.d.ts +1 -1
- package/dist/parse/model/BindDefinition.d.ts +3 -1
- package/dist/parse/model/BindPreloadDefinition.d.ts +42 -0
- package/dist/parse/model/DescendentNodeDefinition.d.ts +4 -13
- package/dist/parse/model/ItextTranslation/ItextTranslationRootDefinition.d.ts +2 -1
- package/dist/parse/model/LeafNodeDefinition.d.ts +7 -4
- package/dist/parse/model/ModelBindMap.d.ts +1 -1
- package/dist/parse/model/NodeDefinition.d.ts +16 -19
- package/dist/parse/model/NoteNodeDefinition.d.ts +6 -5
- package/dist/parse/model/RangeNodeDefinition.d.ts +41 -0
- package/dist/parse/model/RepeatInstanceDefinition.d.ts +7 -4
- package/dist/parse/model/RepeatRangeDefinition.d.ts +7 -4
- package/dist/parse/model/RepeatTemplateDefinition.d.ts +7 -4
- package/dist/parse/model/RootAttributeDefinition.d.ts +24 -0
- package/dist/parse/model/RootAttributeMap.d.ts +23 -0
- package/dist/parse/model/RootDefinition.d.ts +9 -7
- package/dist/parse/model/SubtreeDefinition.d.ts +7 -4
- package/dist/parse/shared/parseStaticDocumentFromDOMSubtree.d.ts +2 -3
- package/dist/parse/text/ItemLabelDefinition.d.ts +1 -1
- package/dist/parse/text/ItemsetLabelDefinition.d.ts +2 -2
- package/dist/parse/text/abstract/TextElementDefinition.d.ts +1 -1
- package/dist/parse/xpath/semantic-analysis.d.ts +1 -3
- package/dist/solid.js +5603 -4665
- package/dist/solid.js.map +1 -1
- package/package.json +15 -12
- package/src/client/BaseNode.ts +5 -0
- package/src/client/BaseValueNode.ts +1 -1
- package/src/client/GroupNode.ts +1 -0
- package/src/client/InputNode.ts +38 -2
- package/src/client/ModelValueNode.ts +1 -0
- package/src/client/NoteNode.ts +43 -7
- package/src/client/RangeNode.ts +51 -0
- package/src/client/RankNode.ts +54 -0
- package/src/client/RootNode.ts +11 -5
- package/src/client/SelectNode.ts +53 -26
- package/src/client/SubtreeNode.ts +1 -0
- package/src/client/TriggerNode.ts +12 -6
- package/src/client/hierarchy.ts +7 -8
- package/src/client/node-types.ts +1 -1
- package/src/client/unsupported/UnsupportedControlNode.ts +2 -6
- package/src/error/RankMissingValueError.ts +5 -0
- package/src/error/RankValueTypeError.ts +13 -0
- package/src/error/SelectValueTypeError.ts +22 -0
- package/src/error/XFormsSpecViolationError.ts +1 -0
- package/src/index.ts +2 -12
- package/src/instance/Group.ts +1 -0
- package/src/instance/InputControl.ts +42 -2
- package/src/instance/ModelValue.ts +2 -0
- package/src/instance/Note.ts +34 -59
- package/src/instance/PrimaryInstance.ts +1 -0
- package/src/instance/RangeControl.ts +113 -0
- package/src/instance/RankControl.ts +199 -0
- package/src/instance/Root.ts +3 -2
- package/src/instance/SelectControl.ts +219 -0
- package/src/instance/Subtree.ts +1 -0
- package/src/instance/TriggerControl.ts +36 -75
- package/src/instance/abstract/DescendantNode.ts +1 -6
- package/src/instance/abstract/InstanceNode.ts +10 -2
- package/src/instance/abstract/UnsupportedControl.ts +1 -0
- package/src/instance/abstract/ValueNode.ts +3 -2
- package/src/instance/children.ts +71 -30
- package/src/instance/hierarchy.ts +21 -16
- package/src/instance/internal-api/InstanceValueContext.ts +2 -0
- package/src/instance/internal-api/submission/ClientReactiveSubmittableLeafNode.ts +2 -1
- package/src/instance/internal-api/submission/ClientReactiveSubmittableParentNode.ts +2 -1
- package/src/instance/internal-api/submission/ClientReactiveSubmittableValueNode.ts +2 -1
- package/src/instance/repeat/BaseRepeatRange.ts +2 -0
- package/src/instance/repeat/RepeatInstance.ts +1 -0
- package/src/instance/resource.ts +4 -1
- package/src/integration/xpath/adapter/names.ts +66 -17
- package/src/integration/xpath/adapter/traversal.ts +10 -9
- package/src/integration/xpath/static-dom/StaticAttribute.ts +15 -7
- package/src/integration/xpath/static-dom/StaticDocument.ts +0 -2
- package/src/integration/xpath/static-dom/StaticElement.ts +21 -8
- package/src/lib/client-reactivity/submission/createLeafNodeSubmissionState.ts +1 -1
- package/src/lib/client-reactivity/submission/createParentNodeSubmissionState.ts +1 -1
- package/src/lib/client-reactivity/submission/createRootSubmissionState.ts +19 -0
- package/src/lib/client-reactivity/submission/createValueNodeSubmissionState.ts +2 -2
- package/src/lib/codecs/Geopoint/Geopoint.ts +150 -0
- package/src/lib/codecs/Geopoint/GeopointValueCodec.ts +20 -0
- package/src/lib/codecs/NoteCodec.ts +32 -0
- package/src/lib/codecs/RangeCodec.ts +65 -0
- package/src/lib/codecs/TriggerCodec.ts +64 -0
- package/src/lib/codecs/ValueArrayCodec.ts +42 -0
- package/src/lib/codecs/ValueCodec.ts +2 -2
- package/src/lib/codecs/getNoteCodec.ts +27 -0
- package/src/lib/codecs/getSelectCodec.ts +27 -0
- package/src/lib/codecs/getSharedValueCodec.ts +5 -3
- package/src/lib/codecs/items/BaseItemCodec.ts +20 -0
- package/src/lib/codecs/items/MultipleValueItemCodec.ts +28 -0
- package/src/lib/codecs/items/SingleValueItemCodec.ts +67 -0
- package/src/lib/dom/query.ts +1 -2
- package/src/lib/names/NamespaceDeclaration.ts +106 -0
- package/src/lib/names/NamespaceDeclarationMap.ts +228 -0
- package/src/lib/names/NamespaceURL.ts +44 -0
- package/src/lib/names/QualifiedName.ts +170 -0
- package/src/lib/number-parsers.ts +25 -0
- package/src/lib/reactivity/createInstanceValueState.ts +50 -0
- package/src/lib/reactivity/{createSelectItems.ts → createItemCollection.ts} +41 -36
- package/src/lib/xml-serialization.ts +76 -9
- package/src/parse/XFormDOM.ts +141 -21
- package/src/parse/XFormDefinition.ts +1 -4
- package/src/parse/body/BodyDefinition.ts +4 -4
- package/src/parse/body/appearance/rangeAppearanceParser.ts +11 -0
- package/src/parse/body/control/InputControlDefinition.ts +9 -0
- package/src/parse/body/control/{select/ItemDefinition.ts → ItemDefinition.ts} +8 -6
- package/src/parse/body/control/{select/ItemsetDefinition.ts → ItemsetDefinition.ts} +11 -9
- package/src/parse/body/control/RangeControlDefinition.ts +91 -6
- package/src/parse/body/control/RankControlDefinition.ts +25 -7
- package/src/parse/body/control/{select/SelectDefinition.ts → SelectControlDefinition.ts} +9 -9
- package/src/parse/expression/ItemsetNodesetExpression.ts +1 -1
- package/src/parse/expression/ItemsetValueExpression.ts +1 -1
- package/src/parse/model/BindDefinition.ts +4 -0
- package/src/parse/model/BindPreloadDefinition.ts +100 -0
- package/src/parse/model/DescendentNodeDefinition.ts +7 -25
- package/src/parse/model/ItextTranslation/ItextTranslationRootDefinition.ts +2 -1
- package/src/parse/model/LeafNodeDefinition.ts +11 -4
- package/src/parse/model/NodeDefinition.ts +24 -45
- package/src/parse/model/NoteNodeDefinition.ts +8 -7
- package/src/parse/model/RangeNodeDefinition.ts +118 -0
- package/src/parse/model/RepeatInstanceDefinition.ts +11 -7
- package/src/parse/model/RepeatRangeDefinition.ts +11 -7
- package/src/parse/model/RepeatTemplateDefinition.ts +11 -7
- package/src/parse/model/RootAttributeDefinition.ts +45 -0
- package/src/parse/model/RootAttributeMap.ts +44 -0
- package/src/parse/model/RootDefinition.ts +29 -28
- package/src/parse/model/SecondaryInstance/sources/GeoJSONExternalSecondaryInstance.ts +1 -0
- package/src/parse/model/SubtreeDefinition.ts +12 -12
- package/src/parse/shared/parseStaticDocumentFromDOMSubtree.ts +3 -3
- package/src/parse/text/ItemLabelDefinition.ts +1 -1
- package/src/parse/text/ItemsetLabelDefinition.ts +2 -2
- package/src/parse/text/abstract/TextElementDefinition.ts +1 -1
- package/src/parse/xpath/semantic-analysis.ts +4 -3
- package/dist/client/unsupported/RangeNode.d.ts +0 -9
- package/dist/client/unsupported/RankNode.d.ts +0 -9
- package/dist/instance/SelectField.d.ts +0 -58
- package/dist/instance/unsupported/RangeControl.d.ts +0 -6
- package/dist/instance/unsupported/RankControl.d.ts +0 -6
- package/dist/integration/xpath/static-dom/StaticNamedNode.d.ts +0 -17
- package/dist/lib/reactivity/createSelectItems.d.ts +0 -16
- package/dist/parse/body/control/select/ItemDefinition.d.ts +0 -13
- package/dist/parse/body/control/select/ItemsetDefinition.d.ts +0 -17
- package/dist/parse/body/control/select/ItemsetNodesetContext.d.ts +0 -9
- package/src/client/unsupported/RangeNode.ts +0 -14
- package/src/client/unsupported/RankNode.ts +0 -14
- package/src/instance/SelectField.ts +0 -263
- package/src/instance/unsupported/RangeControl.ts +0 -9
- package/src/instance/unsupported/RankControl.ts +0 -9
- package/src/integration/xpath/static-dom/StaticNamedNode.ts +0 -45
- package/src/parse/body/control/select/ItemsetNodesetContext.ts +0 -21
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { ValueType } from '../../client/ValueType.ts';
|
|
2
|
+
import { ErrorProductionDesignPendingError } from '../../error/ErrorProductionDesignPendingError.ts';
|
|
3
|
+
import type { RuntimeValue, SharedValueCodec } from '../../lib/codecs/getSharedValueCodec.ts';
|
|
4
|
+
import { getSharedValueCodec } from '../../lib/codecs/getSharedValueCodec.ts';
|
|
5
|
+
import type {
|
|
6
|
+
RangeControlBoundsDefinition,
|
|
7
|
+
RangeControlDefinition,
|
|
8
|
+
} from '../body/control/RangeControlDefinition.ts';
|
|
9
|
+
import type { BindDefinition } from './BindDefinition.ts';
|
|
10
|
+
import { LeafNodeDefinition } from './LeafNodeDefinition.ts';
|
|
11
|
+
import type { ParentNodeDefinition } from './NodeDefinition.ts';
|
|
12
|
+
|
|
13
|
+
const RANGE_VALUE_TYPES = ['decimal', 'int'] as const;
|
|
14
|
+
|
|
15
|
+
export type RangeValueType = (typeof RANGE_VALUE_TYPES)[number];
|
|
16
|
+
|
|
17
|
+
type AssertedRangeValueType<V extends ValueType> = Extract<V, RangeValueType>;
|
|
18
|
+
|
|
19
|
+
type AssertRangeBindDefinition = <V extends ValueType>(
|
|
20
|
+
bind: BindDefinition<V>
|
|
21
|
+
) => asserts bind is BindDefinition<AssertedRangeValueType<V>>;
|
|
22
|
+
|
|
23
|
+
const assertRangeBindDefinition: AssertRangeBindDefinition = (bind) => {
|
|
24
|
+
if (!RANGE_VALUE_TYPES.includes(bind.type.resolved as RangeValueType)) {
|
|
25
|
+
throw new ErrorProductionDesignPendingError(
|
|
26
|
+
`Expected range to have bind type "decimal" or "int", got: ${bind.type.resolved}`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export interface RangeLeafNodeDefinition<V extends ValueType = ValueType>
|
|
32
|
+
extends LeafNodeDefinition<V> {
|
|
33
|
+
readonly bodyElement: RangeControlDefinition;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const decodeBoundsValue = <V extends ValueType>(
|
|
37
|
+
codec: SharedValueCodec<V>,
|
|
38
|
+
value: string
|
|
39
|
+
): NonNullable<RuntimeValue<V>> => {
|
|
40
|
+
const decoded = codec.decodeValue(value);
|
|
41
|
+
|
|
42
|
+
if (decoded == null) {
|
|
43
|
+
throw new ErrorProductionDesignPendingError(
|
|
44
|
+
`Failed to decode bounds value (encoded as ${JSON.stringify(value)})`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return decoded;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
class RangeNodeBoundsDefinition<V extends RangeValueType = RangeValueType> {
|
|
52
|
+
static from<V extends RangeValueType>(
|
|
53
|
+
bounds: RangeControlBoundsDefinition,
|
|
54
|
+
bind: BindDefinition<V>
|
|
55
|
+
): RangeNodeBoundsDefinition<V> {
|
|
56
|
+
const type = bind.type.resolved;
|
|
57
|
+
const codec = getSharedValueCodec(type);
|
|
58
|
+
const min = decodeBoundsValue(codec, bounds.start);
|
|
59
|
+
const max = decodeBoundsValue(codec, bounds.end);
|
|
60
|
+
const step = decodeBoundsValue(codec, bounds.step);
|
|
61
|
+
|
|
62
|
+
return new this(min, max, step);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
constructor(
|
|
66
|
+
readonly min: NonNullable<RuntimeValue<V>>,
|
|
67
|
+
readonly max: NonNullable<RuntimeValue<V>>,
|
|
68
|
+
readonly step: NonNullable<RuntimeValue<V>>
|
|
69
|
+
) {}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @todo We should really consider making `LeafNodeDefinition` an abstract base
|
|
74
|
+
* class, and each node's definition an explicit concrete subclass of that. It
|
|
75
|
+
* would simplify a lot of things, reduce redundancy (and drift!) between
|
|
76
|
+
* various like `*Definition` types, and allow us to reason more clearly about
|
|
77
|
+
* what parse-product-input is used to construct each primary instance node.
|
|
78
|
+
* Furthermore, it would give us a great deal more flexibility to revisit some
|
|
79
|
+
* of the weaker parts of our current data model (e.g. splitting up selects).
|
|
80
|
+
*
|
|
81
|
+
* I explored this refactor as part of the prerequisite work to support range
|
|
82
|
+
* controls. I eventually backed out because it involved more churn than I felt
|
|
83
|
+
* comfortable with, but I do think we should keep an eye out for other
|
|
84
|
+
* opportunities to take on the churn.
|
|
85
|
+
*/
|
|
86
|
+
export class RangeNodeDefinition<V extends RangeValueType = RangeValueType>
|
|
87
|
+
extends LeafNodeDefinition<V>
|
|
88
|
+
implements RangeLeafNodeDefinition<V>
|
|
89
|
+
{
|
|
90
|
+
static from<V extends ValueType>(
|
|
91
|
+
parent: ParentNodeDefinition,
|
|
92
|
+
bind: BindDefinition<V>,
|
|
93
|
+
bodyElement: RangeControlDefinition,
|
|
94
|
+
node: Element
|
|
95
|
+
): RangeNodeDefinition<Extract<V, RangeValueType>> {
|
|
96
|
+
assertRangeBindDefinition(bind);
|
|
97
|
+
|
|
98
|
+
return new this(parent, bind, bodyElement, node);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
readonly bounds: RangeNodeBoundsDefinition<V>;
|
|
102
|
+
|
|
103
|
+
private constructor(
|
|
104
|
+
parent: ParentNodeDefinition,
|
|
105
|
+
override readonly bind: BindDefinition<V>,
|
|
106
|
+
override readonly bodyElement: RangeControlDefinition,
|
|
107
|
+
node: Element
|
|
108
|
+
) {
|
|
109
|
+
super(parent, bind, bodyElement, node);
|
|
110
|
+
|
|
111
|
+
this.bounds = RangeNodeBoundsDefinition.from(bodyElement.bounds, bind);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// prettier-ignore
|
|
116
|
+
export type AnyRangeNodeDefinition =
|
|
117
|
+
| RangeNodeDefinition<'decimal'>
|
|
118
|
+
| RangeNodeDefinition<'int'>;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import { NamespaceDeclarationMap } from '../../lib/names/NamespaceDeclarationMap.ts';
|
|
2
|
+
import { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
1
3
|
import { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
|
|
2
4
|
import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
|
|
3
|
-
import type { ChildNodeDefinition
|
|
5
|
+
import type { ChildNodeDefinition } from './NodeDefinition.ts';
|
|
4
6
|
import type { AnyRepeatRangeDefinition } from './RepeatRangeDefinition.ts';
|
|
5
7
|
|
|
6
|
-
export class RepeatInstanceDefinition
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
{
|
|
8
|
+
export class RepeatInstanceDefinition extends DescendentNodeDefinition<
|
|
9
|
+
'repeat-instance',
|
|
10
|
+
RepeatElementDefinition
|
|
11
|
+
> {
|
|
10
12
|
readonly type = 'repeat-instance';
|
|
11
13
|
|
|
12
|
-
readonly
|
|
14
|
+
readonly namespaceDeclarations: NamespaceDeclarationMap;
|
|
15
|
+
readonly qualifiedName: QualifiedName;
|
|
13
16
|
readonly children: readonly ChildNodeDefinition[];
|
|
14
17
|
readonly instances = null;
|
|
15
18
|
readonly defaultValue = null;
|
|
@@ -22,7 +25,8 @@ export class RepeatInstanceDefinition
|
|
|
22
25
|
|
|
23
26
|
super(parent, bind, bodyElement);
|
|
24
27
|
|
|
25
|
-
this.
|
|
28
|
+
this.qualifiedName = new QualifiedName(node);
|
|
29
|
+
this.namespaceDeclarations = new NamespaceDeclarationMap(this);
|
|
26
30
|
this.children = root.buildSubtree(this);
|
|
27
31
|
}
|
|
28
32
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { NamespaceDeclarationMap } from '../../lib/names/NamespaceDeclarationMap.ts';
|
|
2
|
+
import { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
1
3
|
import type { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
|
|
2
4
|
import { RepeatCountControlExpression } from '../expression/RepeatCountControlExpression.ts';
|
|
3
5
|
import type { BindDefinition } from './BindDefinition.ts';
|
|
4
6
|
import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
|
|
5
|
-
import type {
|
|
7
|
+
import type { ParentNodeDefinition } from './NodeDefinition.ts';
|
|
6
8
|
import { RepeatInstanceDefinition } from './RepeatInstanceDefinition.ts';
|
|
7
9
|
import { RepeatTemplateDefinition } from './RepeatTemplateDefinition.ts';
|
|
8
10
|
|
|
@@ -29,10 +31,10 @@ const assertRepeatRangeDefinitionUnion: AssertRepeatRangeDefinitionUnion = (_def
|
|
|
29
31
|
// tautologically true!
|
|
30
32
|
};
|
|
31
33
|
|
|
32
|
-
export class RepeatRangeDefinition
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
{
|
|
34
|
+
export class RepeatRangeDefinition extends DescendentNodeDefinition<
|
|
35
|
+
'repeat-range',
|
|
36
|
+
RepeatElementDefinition
|
|
37
|
+
> {
|
|
36
38
|
static from(
|
|
37
39
|
parent: ParentNodeDefinition,
|
|
38
40
|
bind: BindDefinition,
|
|
@@ -54,7 +56,8 @@ export class RepeatRangeDefinition
|
|
|
54
56
|
readonly count: RepeatCountControlExpression | null;
|
|
55
57
|
|
|
56
58
|
readonly node = null;
|
|
57
|
-
readonly
|
|
59
|
+
readonly namespaceDeclarations: NamespaceDeclarationMap;
|
|
60
|
+
readonly qualifiedName: QualifiedName;
|
|
58
61
|
readonly defaultValue = null;
|
|
59
62
|
|
|
60
63
|
private constructor(
|
|
@@ -68,7 +71,8 @@ export class RepeatRangeDefinition
|
|
|
68
71
|
const { template, instanceNodes } = RepeatTemplateDefinition.parseModelNodes(this, modelNodes);
|
|
69
72
|
|
|
70
73
|
this.template = template;
|
|
71
|
-
this.
|
|
74
|
+
this.qualifiedName = template.qualifiedName;
|
|
75
|
+
this.namespaceDeclarations = new NamespaceDeclarationMap(this);
|
|
72
76
|
this.count = RepeatCountControlExpression.from(bodyElement, instanceNodes.length);
|
|
73
77
|
|
|
74
78
|
assertRepeatRangeDefinitionUnion(this);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { JAVAROSA_NAMESPACE_URI } from '@getodk/common/constants/xmlns.ts';
|
|
2
|
+
import { NamespaceDeclarationMap } from '../../lib/names/NamespaceDeclarationMap.ts';
|
|
3
|
+
import { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
2
4
|
import type { RepeatElementDefinition } from '../body/RepeatElementDefinition.ts';
|
|
3
5
|
import { BindDefinition } from './BindDefinition.ts';
|
|
4
6
|
import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
|
|
5
|
-
import type { ChildNodeDefinition
|
|
7
|
+
import type { ChildNodeDefinition } from './NodeDefinition.ts';
|
|
6
8
|
import type { RepeatRangeDefinition } from './RepeatRangeDefinition.ts';
|
|
7
9
|
|
|
8
10
|
const repeatTemplates = new WeakMap<BindDefinition, RepeatTemplateDefinition>();
|
|
@@ -72,10 +74,10 @@ interface ParsedRepeatNodes {
|
|
|
72
74
|
readonly instanceNodes: readonly Element[];
|
|
73
75
|
}
|
|
74
76
|
|
|
75
|
-
export class RepeatTemplateDefinition
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
{
|
|
77
|
+
export class RepeatTemplateDefinition extends DescendentNodeDefinition<
|
|
78
|
+
'repeat-template',
|
|
79
|
+
RepeatElementDefinition
|
|
80
|
+
> {
|
|
79
81
|
static parseModelNodes(
|
|
80
82
|
range: RepeatRangeDefinition,
|
|
81
83
|
modelNodes: readonly [Element, ...Element[]]
|
|
@@ -115,7 +117,8 @@ export class RepeatTemplateDefinition
|
|
|
115
117
|
readonly type = 'repeat-template';
|
|
116
118
|
|
|
117
119
|
readonly node: Element;
|
|
118
|
-
readonly
|
|
120
|
+
readonly namespaceDeclarations: NamespaceDeclarationMap;
|
|
121
|
+
readonly qualifiedName: QualifiedName;
|
|
119
122
|
readonly children: readonly ChildNodeDefinition[];
|
|
120
123
|
readonly instances = null;
|
|
121
124
|
readonly defaultValue = null;
|
|
@@ -133,7 +136,8 @@ export class RepeatTemplateDefinition
|
|
|
133
136
|
node.removeAttributeNS(JAVAROSA_NAMESPACE_URI, 'template');
|
|
134
137
|
|
|
135
138
|
this.node = node;
|
|
136
|
-
this.
|
|
139
|
+
this.qualifiedName = new QualifiedName(node);
|
|
140
|
+
this.namespaceDeclarations = new NamespaceDeclarationMap(this);
|
|
137
141
|
this.children = root.buildSubtree(this);
|
|
138
142
|
}
|
|
139
143
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { XMLNS_NAMESPACE_URI } from '@getodk/common/constants/xmlns.ts';
|
|
2
|
+
import type { NamedNodeDefinition } from '../../lib/names/NamespaceDeclarationMap.ts';
|
|
3
|
+
import { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
4
|
+
import { escapeXMLText } from '../../lib/xml-serialization.ts';
|
|
5
|
+
import type { RootDefinition } from './RootDefinition.ts';
|
|
6
|
+
|
|
7
|
+
interface RootAttributeSource {
|
|
8
|
+
readonly namespaceURI: string | null;
|
|
9
|
+
readonly nodeName: string;
|
|
10
|
+
readonly prefix: string | null;
|
|
11
|
+
readonly localName: string;
|
|
12
|
+
readonly value: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @todo This class is named and typed to emphasize its intentionally narrow
|
|
17
|
+
* usage and purpose. It **intentionally** avoids addressing the much broader
|
|
18
|
+
* set of concerns around modeling attributes in primary instance/submissions.
|
|
19
|
+
*/
|
|
20
|
+
export class RootAttributeDefinition implements NamedNodeDefinition {
|
|
21
|
+
private readonly serializedXML: string;
|
|
22
|
+
|
|
23
|
+
readonly parent: RootDefinition;
|
|
24
|
+
readonly qualifiedName: QualifiedName;
|
|
25
|
+
readonly value: string;
|
|
26
|
+
|
|
27
|
+
constructor(root: RootDefinition, source: RootAttributeSource) {
|
|
28
|
+
const { namespaceURI, nodeName, value } = source;
|
|
29
|
+
|
|
30
|
+
this.parent = root;
|
|
31
|
+
this.qualifiedName = new QualifiedName(source);
|
|
32
|
+
this.value = value;
|
|
33
|
+
|
|
34
|
+
// We serialize namespace declarations separately
|
|
35
|
+
if (namespaceURI === XMLNS_NAMESPACE_URI) {
|
|
36
|
+
this.serializedXML = '';
|
|
37
|
+
} else {
|
|
38
|
+
this.serializedXML = ` ${nodeName}="${escapeXMLText(value, true)}"`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
serializeAttributeXML(): string {
|
|
43
|
+
return this.serializedXML;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { XMLNS_NAMESPACE_URI } from '@getodk/common/constants/xmlns.ts';
|
|
2
|
+
import type { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
3
|
+
import { RootAttributeDefinition } from './RootAttributeDefinition.ts';
|
|
4
|
+
import type { RootDefinition } from './RootDefinition.ts';
|
|
5
|
+
|
|
6
|
+
const isNonNamespaceDeclarationDOMAttr = (domAttr: Attr) => {
|
|
7
|
+
return domAttr.namespaceURI !== XMLNS_NAMESPACE_URI;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @todo This can be trivially expanded to a narrowly general case when we
|
|
12
|
+
* prioritize work to
|
|
13
|
+
* {@link https://github.com/getodk/web-forms/issues/285 | support attributes}
|
|
14
|
+
* (as modeled form nodes on par with elements). It's been deferred here to
|
|
15
|
+
* avoid expanding scope of an already fairly large yak shave.
|
|
16
|
+
*
|
|
17
|
+
* @todo There's a **much more expansive** general case just waiting for a good
|
|
18
|
+
* opportuntity to prioritize it. E.g. a `NamedNodeMap<T>`, where T is any
|
|
19
|
+
* generalized concept of a named node. This expansive generalization would have
|
|
20
|
+
* a ton of value in a variety of known performance optimization
|
|
21
|
+
* targets/solutions (i.e. optimizing the most redundant, suboptimal, frequently
|
|
22
|
+
* performed aspects of any typical XPath expression in a typical XForm).
|
|
23
|
+
*
|
|
24
|
+
* @see {@link QualifiedName} for more detail.
|
|
25
|
+
*/
|
|
26
|
+
export class RootAttributeMap extends Map<QualifiedName, RootAttributeDefinition> {
|
|
27
|
+
static from(root: RootDefinition, domRootSourceElement: Element) {
|
|
28
|
+
const domAttrs = Array.from(domRootSourceElement.attributes);
|
|
29
|
+
const nonNamespaceDeclarationDOMAttrs = domAttrs.filter(isNonNamespaceDeclarationDOMAttr);
|
|
30
|
+
const attributes = nonNamespaceDeclarationDOMAttrs.map((source) => {
|
|
31
|
+
return new RootAttributeDefinition(root, source);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return new this(attributes);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private constructor(attributes: readonly RootAttributeDefinition[]) {
|
|
38
|
+
super(
|
|
39
|
+
attributes.map((attribute) => {
|
|
40
|
+
return [attribute.qualifiedName, attribute];
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
+
import { NamespaceDeclarationMap } from '../../lib/names/NamespaceDeclarationMap.ts';
|
|
2
|
+
import { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
1
3
|
import type { BodyClassList } from '../body/BodyDefinition.ts';
|
|
2
4
|
import type { XFormDefinition } from '../XFormDefinition.ts';
|
|
3
|
-
import type { BindDefinition } from './BindDefinition.ts';
|
|
4
5
|
import type { FormSubmissionDefinition } from './FormSubmissionDefinition.ts';
|
|
5
6
|
import { LeafNodeDefinition } from './LeafNodeDefinition.ts';
|
|
6
7
|
import type { ModelDefinition } from './ModelDefinition.ts';
|
|
7
|
-
import type {
|
|
8
|
-
|
|
9
|
-
NodeDefinition,
|
|
10
|
-
ParentNodeDefinition,
|
|
11
|
-
} from './NodeDefinition.ts';
|
|
8
|
+
import type { ChildNodeDefinition, ParentNodeDefinition } from './NodeDefinition.ts';
|
|
9
|
+
import { NodeDefinition } from './NodeDefinition.ts';
|
|
12
10
|
import { NoteNodeDefinition } from './NoteNodeDefinition.ts';
|
|
11
|
+
import { RangeNodeDefinition } from './RangeNodeDefinition.ts';
|
|
13
12
|
import { RepeatRangeDefinition } from './RepeatRangeDefinition.ts';
|
|
13
|
+
import { RootAttributeMap } from './RootAttributeMap.ts';
|
|
14
14
|
import { SubtreeDefinition } from './SubtreeDefinition.ts';
|
|
15
15
|
|
|
16
|
-
export class RootDefinition
|
|
16
|
+
export class RootDefinition extends NodeDefinition<'root'> {
|
|
17
17
|
readonly type = 'root';
|
|
18
|
-
readonly
|
|
19
|
-
readonly nodeset: string;
|
|
20
|
-
readonly nodeName: string;
|
|
18
|
+
readonly qualifiedName: QualifiedName;
|
|
21
19
|
readonly bodyElement = null;
|
|
22
20
|
readonly root = this;
|
|
23
21
|
readonly parent = null;
|
|
22
|
+
readonly namespaceDeclarations: NamespaceDeclarationMap;
|
|
23
|
+
readonly attributes: RootAttributeMap;
|
|
24
24
|
readonly children: readonly ChildNodeDefinition[];
|
|
25
25
|
readonly instances = null;
|
|
26
26
|
readonly node: Element;
|
|
@@ -34,29 +34,26 @@ export class RootDefinition implements NodeDefinition<'root'> {
|
|
|
34
34
|
readonly submission: FormSubmissionDefinition,
|
|
35
35
|
readonly classes: BodyClassList
|
|
36
36
|
) {
|
|
37
|
+
const { primaryInstanceRoot } = form.xformDOM;
|
|
38
|
+
const qualifiedName = new QualifiedName(primaryInstanceRoot);
|
|
39
|
+
const nodeName = qualifiedName.getPrefixedName();
|
|
40
|
+
|
|
37
41
|
// TODO: theoretically the pertinent step in the bind's `nodeset` *could* be
|
|
38
42
|
// namespaced. It also may make more sense to determine the root nodeset
|
|
39
43
|
// earlier (i.e. in the appropriate definition class).
|
|
40
|
-
|
|
41
|
-
// TODO: while it's unlikely a form actually defines a <bind> for the root,
|
|
42
|
-
// if it did, bind nodesets are not yet normalized, so `/root` may currently
|
|
43
|
-
// be defined as `/ root` (or even `/ *` or any other valid expression
|
|
44
|
-
// resolving to the root).
|
|
45
|
-
const { primaryInstanceRoot } = form.xformDOM;
|
|
46
|
-
const { localName: rootNodeName } = primaryInstanceRoot;
|
|
47
|
-
|
|
48
|
-
this.nodeName = rootNodeName;
|
|
49
|
-
|
|
50
|
-
const nodeset = `/${rootNodeName}`;
|
|
44
|
+
const nodeset = `/${nodeName}`;
|
|
51
45
|
const bind = model.binds.get(nodeset);
|
|
52
46
|
|
|
53
47
|
if (bind == null) {
|
|
54
48
|
throw new Error('Missing root node bind definition');
|
|
55
49
|
}
|
|
56
50
|
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
super(bind);
|
|
52
|
+
|
|
53
|
+
this.qualifiedName = qualifiedName;
|
|
59
54
|
this.node = primaryInstanceRoot;
|
|
55
|
+
this.attributes = RootAttributeMap.from(this, primaryInstanceRoot);
|
|
56
|
+
this.namespaceDeclarations = new NamespaceDeclarationMap(this);
|
|
60
57
|
this.children = this.buildSubtree(this);
|
|
61
58
|
}
|
|
62
59
|
|
|
@@ -70,13 +67,13 @@ export class RootDefinition implements NodeDefinition<'root'> {
|
|
|
70
67
|
const childrenByName = new Map<string, [Element, ...Element[]]>();
|
|
71
68
|
|
|
72
69
|
for (const child of node.children) {
|
|
73
|
-
const {
|
|
70
|
+
const { nodeName } = child;
|
|
74
71
|
|
|
75
|
-
let elements = childrenByName.get(
|
|
72
|
+
let elements = childrenByName.get(nodeName);
|
|
76
73
|
|
|
77
74
|
if (elements == null) {
|
|
78
75
|
elements = [child];
|
|
79
|
-
childrenByName.set(
|
|
76
|
+
childrenByName.set(nodeName, elements);
|
|
80
77
|
} else {
|
|
81
78
|
// TODO: check if previous element exists, was it previous element
|
|
82
79
|
// sibling. Highly likely this should otherwise fail!
|
|
@@ -84,8 +81,8 @@ export class RootDefinition implements NodeDefinition<'root'> {
|
|
|
84
81
|
}
|
|
85
82
|
}
|
|
86
83
|
|
|
87
|
-
return Array.from(childrenByName).map(([
|
|
88
|
-
const nodeset = `${parentNodeset}/${
|
|
84
|
+
return Array.from(childrenByName).map(([nodeName, children]) => {
|
|
85
|
+
const nodeset = `${parentNodeset}/${nodeName}`;
|
|
89
86
|
const bind = binds.getOrCreateBindDefinition(nodeset);
|
|
90
87
|
const bodyElement = body.getBodyElement(nodeset);
|
|
91
88
|
const [firstChild, ...restChildren] = children;
|
|
@@ -102,6 +99,10 @@ export class RootDefinition implements NodeDefinition<'root'> {
|
|
|
102
99
|
const isLeafNode = element.childElementCount === 0;
|
|
103
100
|
|
|
104
101
|
if (isLeafNode) {
|
|
102
|
+
if (bodyElement?.type === 'range') {
|
|
103
|
+
return RangeNodeDefinition.from(parent, bind, bodyElement, element);
|
|
104
|
+
}
|
|
105
|
+
|
|
105
106
|
return (
|
|
106
107
|
NoteNodeDefinition.from(parent, bind, bodyElement, element) ??
|
|
107
108
|
new LeafNodeDefinition(parent, bind, bodyElement, element)
|
|
@@ -305,6 +305,7 @@ class GeoJSONSecondaryInstanceFeaturePropertyElement extends StaticElement {
|
|
|
305
305
|
const { id = propertiesId } = feature;
|
|
306
306
|
|
|
307
307
|
if (id !== undefined) {
|
|
308
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string -- Intentional fallback, we don't know what this is and it could be any permutation of JSON
|
|
308
309
|
yield new this(parent, 'id', String(id));
|
|
309
310
|
}
|
|
310
311
|
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
+
import { NamespaceDeclarationMap } from '../../lib/names/NamespaceDeclarationMap.ts';
|
|
2
|
+
import { QualifiedName } from '../../lib/names/QualifiedName.ts';
|
|
1
3
|
import type {
|
|
2
4
|
AnyBodyElementDefinition,
|
|
3
5
|
AnyGroupElementDefinition,
|
|
4
6
|
} from '../body/BodyDefinition.ts';
|
|
5
7
|
import type { BindDefinition } from './BindDefinition.ts';
|
|
6
8
|
import { DescendentNodeDefinition } from './DescendentNodeDefinition.ts';
|
|
7
|
-
import type {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export class SubtreeDefinition
|
|
14
|
-
extends DescendentNodeDefinition<'subtree', AnyGroupElementDefinition | null>
|
|
15
|
-
implements NodeDefinition<'subtree'>
|
|
16
|
-
{
|
|
9
|
+
import type { ChildNodeDefinition, ParentNodeDefinition } from './NodeDefinition.ts';
|
|
10
|
+
|
|
11
|
+
export class SubtreeDefinition extends DescendentNodeDefinition<
|
|
12
|
+
'subtree',
|
|
13
|
+
AnyGroupElementDefinition | null
|
|
14
|
+
> {
|
|
17
15
|
readonly type = 'subtree';
|
|
18
16
|
|
|
19
|
-
readonly
|
|
17
|
+
readonly namespaceDeclarations: NamespaceDeclarationMap;
|
|
18
|
+
readonly qualifiedName: QualifiedName;
|
|
20
19
|
readonly children: readonly ChildNodeDefinition[];
|
|
21
20
|
readonly instances = null;
|
|
22
21
|
readonly defaultValue = null;
|
|
@@ -38,7 +37,8 @@ export class SubtreeDefinition
|
|
|
38
37
|
|
|
39
38
|
const { root } = parent;
|
|
40
39
|
|
|
41
|
-
this.
|
|
40
|
+
this.qualifiedName = new QualifiedName(node);
|
|
41
|
+
this.namespaceDeclarations = new NamespaceDeclarationMap(this);
|
|
42
42
|
this.children = root.buildSubtree(this);
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -8,9 +8,9 @@ import type {
|
|
|
8
8
|
import type {
|
|
9
9
|
StaticElementAttributesFactory,
|
|
10
10
|
StaticElementChildNodesFactory,
|
|
11
|
+
StaticElementOptions,
|
|
11
12
|
} from '../../integration/xpath/static-dom/StaticElement.ts';
|
|
12
13
|
import { StaticElement } from '../../integration/xpath/static-dom/StaticElement.ts';
|
|
13
|
-
import type { StaticNamedNodeOptions } from '../../integration/xpath/static-dom/StaticNamedNode.ts';
|
|
14
14
|
import type { StaticParentNode } from '../../integration/xpath/static-dom/StaticNode.ts';
|
|
15
15
|
import { StaticText } from '../../integration/xpath/static-dom/StaticText.ts';
|
|
16
16
|
|
|
@@ -115,12 +115,12 @@ export type StaticElementConstructor<
|
|
|
115
115
|
parent: Parent,
|
|
116
116
|
attributesFactory: StaticElementAttributesFactory,
|
|
117
117
|
childNodesFactory: StaticElementChildNodesFactory,
|
|
118
|
-
options:
|
|
118
|
+
options: StaticElementOptions
|
|
119
119
|
): T;
|
|
120
120
|
};
|
|
121
121
|
|
|
122
122
|
const parseStaticElementFromDOMElement = <
|
|
123
|
-
T extends StaticElement
|
|
123
|
+
T extends StaticElement<Parent>,
|
|
124
124
|
Parent extends StaticParentNode = StaticParentNode,
|
|
125
125
|
>(
|
|
126
126
|
parent: Parent,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { LocalNamedElement } from '@getodk/common/types/dom.ts';
|
|
2
2
|
import { getLabelElement } from '../../lib/dom/query.ts';
|
|
3
3
|
import type { XFormDefinition } from '../../parse/XFormDefinition.ts';
|
|
4
|
-
import type { ItemDefinition } from '../body/control/
|
|
4
|
+
import type { ItemDefinition } from '../body/control/ItemDefinition.ts';
|
|
5
5
|
import { TextElementDefinition } from './abstract/TextElementDefinition.ts';
|
|
6
6
|
|
|
7
7
|
interface LabelElement extends LocalNamedElement<'label'> {}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { LocalNamedElement } from '@getodk/common/types/dom.ts';
|
|
2
2
|
import { getLabelElement } from '../../lib/dom/query.ts';
|
|
3
3
|
import type { XFormDefinition } from '../../parse/XFormDefinition.ts';
|
|
4
|
-
import type { ItemDefinition } from '../body/control/
|
|
5
|
-
import type { ItemsetDefinition } from '../body/control/
|
|
4
|
+
import type { ItemDefinition } from '../body/control/ItemDefinition.ts';
|
|
5
|
+
import type { ItemsetDefinition } from '../body/control/ItemsetDefinition.ts';
|
|
6
6
|
import { TextReferenceExpression } from '../expression/TextReferenceExpression.ts';
|
|
7
7
|
import { TextTranslationExpression } from '../expression/TextTranslationExpression.ts';
|
|
8
8
|
import type { RefAttributeChunk } from './abstract/TextElementDefinition.ts';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isElementNode, isTextNode } from '@getodk/common/lib/dom/predicates.ts';
|
|
2
2
|
import type { ElementTextRole } from '../../../client/TextRange.ts';
|
|
3
3
|
import type { XFormDefinition } from '../../../parse/XFormDefinition.ts';
|
|
4
|
-
import type { ItemDefinition } from '../../body/control/
|
|
4
|
+
import type { ItemDefinition } from '../../body/control/ItemDefinition.ts';
|
|
5
5
|
import { TextLiteralExpression } from '../../expression/TextLiteralExpression.ts';
|
|
6
6
|
import { TextOutputExpression } from '../../expression/TextOutputExpression.ts';
|
|
7
7
|
import { TextReferenceExpression } from '../../expression/TextReferenceExpression.ts';
|
|
@@ -396,9 +396,10 @@ const findConstantExpressionNode = (expression: string): ConstantExpressionSynta
|
|
|
396
396
|
}
|
|
397
397
|
};
|
|
398
398
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
399
|
+
// prettier-ignore
|
|
400
|
+
type BrandedExpression<Expression extends string, Brand extends symbol> =
|
|
401
|
+
& Expression
|
|
402
|
+
& Readonly<Record<Brand, true>>;
|
|
402
403
|
|
|
403
404
|
const CONSTANT_EXPRESSION = Symbol('CONSTANT_EXPRESSION');
|
|
404
405
|
type CONSTANT_EXPRESSION = typeof CONSTANT_EXPRESSION;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { RangeControlDefinition } from '../../parse/body/control/RangeControlDefinition.ts';
|
|
2
|
-
import { UnsupportedControlDefinition, UnsupportedControlNode } from './UnsupportedControlNode.ts';
|
|
3
|
-
export interface RangeNodeDefinition extends UnsupportedControlDefinition {
|
|
4
|
-
readonly bodyElement: RangeControlDefinition;
|
|
5
|
-
}
|
|
6
|
-
export interface RangeNode extends UnsupportedControlNode {
|
|
7
|
-
readonly nodeType: 'range';
|
|
8
|
-
readonly definition: RangeNodeDefinition;
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { RankControlDefinition } from '../../parse/body/control/RankControlDefinition.ts';
|
|
2
|
-
import { UnsupportedControlDefinition, UnsupportedControlNode } from './UnsupportedControlNode.ts';
|
|
3
|
-
export interface RankNodeDefinition extends UnsupportedControlDefinition {
|
|
4
|
-
readonly bodyElement: RankControlDefinition;
|
|
5
|
-
}
|
|
6
|
-
export interface RankNode extends UnsupportedControlNode {
|
|
7
|
-
readonly nodeType: 'rank';
|
|
8
|
-
readonly definition: RankNodeDefinition;
|
|
9
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
2
|
-
import { Accessor } from 'solid-js';
|
|
3
|
-
import { SelectItem, SelectNode, SelectNodeAppearances } from '../client/SelectNode.ts';
|
|
4
|
-
import { TextRange } from '../client/TextRange.ts';
|
|
5
|
-
import { SubmissionState } from '../client/submission/SubmissionState.ts';
|
|
6
|
-
import { AnyViolation, LeafNodeValidationState } from '../client/validation.ts';
|
|
7
|
-
import { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
8
|
-
import { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
|
|
9
|
-
import { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
|
|
10
|
-
import { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
11
|
-
import { SimpleAtomicState } from '../lib/reactivity/types.ts';
|
|
12
|
-
import { AnySelectDefinition } from '../parse/body/control/select/SelectDefinition.ts';
|
|
13
|
-
import { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
14
|
-
import { Root } from './Root.ts';
|
|
15
|
-
import { DescendantNodeStateSpec, DescendantNode } from './abstract/DescendantNode.ts';
|
|
16
|
-
import { GeneralParentNode } from './hierarchy.ts';
|
|
17
|
-
import { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
18
|
-
import { ValidationContext } from './internal-api/ValidationContext.ts';
|
|
19
|
-
import { ValueContext } from './internal-api/ValueContext.ts';
|
|
20
|
-
import { ClientReactiveSubmittableLeafNode } from './internal-api/submission/ClientReactiveSubmittableLeafNode.ts';
|
|
21
|
-
export interface SelectFieldDefinition extends LeafNodeDefinition {
|
|
22
|
-
readonly bodyElement: AnySelectDefinition;
|
|
23
|
-
}
|
|
24
|
-
interface SelectFieldStateSpec extends DescendantNodeStateSpec<readonly SelectItem[]> {
|
|
25
|
-
readonly label: Accessor<TextRange<'label'> | null>;
|
|
26
|
-
readonly hint: Accessor<TextRange<'hint'> | null>;
|
|
27
|
-
readonly children: null;
|
|
28
|
-
readonly value: SimpleAtomicState<readonly SelectItem[]>;
|
|
29
|
-
readonly valueOptions: Accessor<readonly SelectItem[]>;
|
|
30
|
-
}
|
|
31
|
-
export declare class SelectField extends DescendantNode<SelectFieldDefinition, SelectFieldStateSpec, GeneralParentNode, null> implements SelectNode, XFormsXPathElement, EvaluationContext, ValidationContext, ValueContext<readonly SelectItem[]>, ClientReactiveSubmittableLeafNode<readonly SelectItem[]> {
|
|
32
|
-
private readonly selectExclusive;
|
|
33
|
-
private readonly validation;
|
|
34
|
-
readonly [XPathNodeKindKey] = "element";
|
|
35
|
-
protected readonly state: SharedNodeState<SelectFieldStateSpec>;
|
|
36
|
-
protected engineState: EngineState<SelectFieldStateSpec>;
|
|
37
|
-
readonly nodeType = "select";
|
|
38
|
-
readonly appearances: SelectNodeAppearances;
|
|
39
|
-
readonly currentState: CurrentState<SelectFieldStateSpec>;
|
|
40
|
-
get validationState(): LeafNodeValidationState;
|
|
41
|
-
readonly submissionState: SubmissionState;
|
|
42
|
-
readonly contextNode: this;
|
|
43
|
-
readonly encodeValue: (runtimeValue: readonly SelectItem[]) => string;
|
|
44
|
-
readonly decodeValue: (instanceValue: string) => readonly SelectItem[];
|
|
45
|
-
protected readonly getValueOptions: Accessor<readonly SelectItem[]>;
|
|
46
|
-
protected readonly getValue: Accessor<readonly SelectItem[]>;
|
|
47
|
-
constructor(parent: GeneralParentNode, definition: SelectFieldDefinition);
|
|
48
|
-
protected getSelectItemsByValue(valueOptions?: readonly SelectItem[]): ReadonlyMap<string, SelectItem>;
|
|
49
|
-
protected updateSelectedItemValues(values: readonly string[]): void;
|
|
50
|
-
protected setSelectedItemValue(value: string | null): void;
|
|
51
|
-
getXPathValue(): string;
|
|
52
|
-
select(selectedItem: SelectItem): Root;
|
|
53
|
-
deselect(deselectedItem: SelectItem): Root;
|
|
54
|
-
getChildren(): readonly [];
|
|
55
|
-
getViolation(): AnyViolation | null;
|
|
56
|
-
isBlank(): boolean;
|
|
57
|
-
}
|
|
58
|
-
export {};
|