@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
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { UnsupportedControl } from '../abstract/UnsupportedControl.ts';
|
|
2
|
-
import { ValueContext } from '../internal-api/ValueContext.ts';
|
|
3
|
-
export declare class RangeControl extends UnsupportedControl<'range'> implements ValueContext<unknown> {
|
|
4
|
-
readonly nodeType = "range";
|
|
5
|
-
readonly contextNode: this;
|
|
6
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { UnsupportedControl } from '../abstract/UnsupportedControl.ts';
|
|
2
|
-
import { ValueContext } from '../internal-api/ValueContext.ts';
|
|
3
|
-
export declare class RankControl extends UnsupportedControl<'rank'> implements ValueContext<unknown> {
|
|
4
|
-
readonly nodeType = "rank";
|
|
5
|
-
readonly contextNode: this;
|
|
6
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { XFormsXPathNamedNode, XPathNamedNodeKind } from '../adapter/XFormsXPathNode.ts';
|
|
2
|
-
import { StaticDocument } from './StaticDocument.ts';
|
|
3
|
-
import { StaticParentNode, StaticNode } from './StaticNode.ts';
|
|
4
|
-
export interface StaticNamedNodeOptions {
|
|
5
|
-
readonly namespaceURI: string | null;
|
|
6
|
-
readonly localName: string;
|
|
7
|
-
readonly value?: string;
|
|
8
|
-
}
|
|
9
|
-
export declare abstract class StaticNamedNode<Kind extends XPathNamedNodeKind> extends StaticNode<Kind> implements XFormsXPathNamedNode {
|
|
10
|
-
readonly parent: StaticParentNode;
|
|
11
|
-
readonly rootDocument: StaticDocument;
|
|
12
|
-
readonly isXFormsNamespace: boolean;
|
|
13
|
-
readonly namespaceURI: string | null;
|
|
14
|
-
readonly localName: string;
|
|
15
|
-
readonly value: string | null;
|
|
16
|
-
protected constructor(parent: StaticParentNode, options: StaticNamedNodeOptions);
|
|
17
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Accessor } from 'solid-js';
|
|
2
|
-
import { SelectItem } from '../../index.ts';
|
|
3
|
-
import { SelectField } from '../../instance/SelectField.ts';
|
|
4
|
-
/**
|
|
5
|
-
* Creates a reactive computation of a {@link SelectField}'s
|
|
6
|
-
* {@link SelectItem}s, in support of the field's `valueOptions`.
|
|
7
|
-
*
|
|
8
|
-
* - Selects defined with static `<item>`s will compute to an corresponding
|
|
9
|
-
* static list of items.
|
|
10
|
-
* - Selects defined with a computed `<itemset>` will compute to a reactive list
|
|
11
|
-
* of items.
|
|
12
|
-
* - Items of both will produce {@link SelectItem.label | labels} reactive to
|
|
13
|
-
* their appropriate dependencies (whether relative to the itemset item node,
|
|
14
|
-
* referencing a form's `itext` translations, etc).
|
|
15
|
-
*/
|
|
16
|
-
export declare const createSelectItems: (selectField: SelectField) => Accessor<readonly SelectItem[]>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ItemElement } from '../../../../lib/dom/query.ts';
|
|
2
|
-
import { ItemLabelDefinition } from '../../../text/ItemLabelDefinition.ts';
|
|
3
|
-
import { XFormDefinition } from '../../../XFormDefinition.ts';
|
|
4
|
-
import { BodyElementDefinition } from '../../BodyElementDefinition.ts';
|
|
5
|
-
import { AnySelectDefinition } from './SelectDefinition.ts';
|
|
6
|
-
export declare class ItemDefinition extends BodyElementDefinition<'item'> {
|
|
7
|
-
readonly parent: AnySelectDefinition;
|
|
8
|
-
readonly category = "support";
|
|
9
|
-
readonly type = "item";
|
|
10
|
-
readonly label: ItemLabelDefinition | null;
|
|
11
|
-
readonly value: string;
|
|
12
|
-
constructor(form: XFormDefinition, parent: AnySelectDefinition, element: ItemElement);
|
|
13
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ItemsetElement } from '../../../../lib/dom/query.ts';
|
|
2
|
-
import { ItemsetNodesetExpression } from '../../../expression/ItemsetNodesetExpression.ts';
|
|
3
|
-
import { ItemsetValueExpression } from '../../../expression/ItemsetValueExpression.ts';
|
|
4
|
-
import { ItemsetLabelDefinition } from '../../../text/ItemsetLabelDefinition.ts';
|
|
5
|
-
import { XFormDefinition } from '../../../XFormDefinition.ts';
|
|
6
|
-
import { BodyElementDefinition } from '../../BodyElementDefinition.ts';
|
|
7
|
-
import { AnySelectDefinition } from './SelectDefinition.ts';
|
|
8
|
-
export declare class ItemsetDefinition extends BodyElementDefinition<'itemset'> {
|
|
9
|
-
readonly parent: AnySelectDefinition;
|
|
10
|
-
readonly category = "support";
|
|
11
|
-
readonly type = "itemset";
|
|
12
|
-
readonly reference: string;
|
|
13
|
-
readonly label: ItemsetLabelDefinition | null;
|
|
14
|
-
readonly nodes: ItemsetNodesetExpression;
|
|
15
|
-
readonly value: ItemsetValueExpression;
|
|
16
|
-
constructor(form: XFormDefinition, parent: AnySelectDefinition, element: ItemsetElement);
|
|
17
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DependencyContext } from '../../../expression/abstract/DependencyContext.ts';
|
|
2
|
-
import { ItemsetDefinition } from './ItemsetDefinition.ts';
|
|
3
|
-
export declare class ItemsetNodesetContext extends DependencyContext {
|
|
4
|
-
protected readonly itemset: ItemsetDefinition;
|
|
5
|
-
readonly parentReference: null;
|
|
6
|
-
readonly reference: string;
|
|
7
|
-
constructor(itemset: ItemsetDefinition, nodesetExpression: string);
|
|
8
|
-
set isTranslated(value: true);
|
|
9
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { RangeControlDefinition } from '../../parse/body/control/RangeControlDefinition.ts';
|
|
2
|
-
import type {
|
|
3
|
-
UnsupportedControlDefinition,
|
|
4
|
-
UnsupportedControlNode,
|
|
5
|
-
} from './UnsupportedControlNode.ts';
|
|
6
|
-
|
|
7
|
-
export interface RangeNodeDefinition extends UnsupportedControlDefinition {
|
|
8
|
-
readonly bodyElement: RangeControlDefinition;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface RangeNode extends UnsupportedControlNode {
|
|
12
|
-
readonly nodeType: 'range';
|
|
13
|
-
readonly definition: RangeNodeDefinition;
|
|
14
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { RankControlDefinition } from '../../parse/body/control/RankControlDefinition.ts';
|
|
2
|
-
import type {
|
|
3
|
-
UnsupportedControlDefinition,
|
|
4
|
-
UnsupportedControlNode,
|
|
5
|
-
} from './UnsupportedControlNode.ts';
|
|
6
|
-
|
|
7
|
-
export interface RankNodeDefinition extends UnsupportedControlDefinition {
|
|
8
|
-
readonly bodyElement: RankControlDefinition;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface RankNode extends UnsupportedControlNode {
|
|
12
|
-
readonly nodeType: 'rank';
|
|
13
|
-
readonly definition: RankNodeDefinition;
|
|
14
|
-
}
|
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import { xmlXPathWhitespaceSeparatedList } from '@getodk/common/lib/string/whitespace.ts';
|
|
2
|
-
import { XPathNodeKindKey } from '@getodk/xpath';
|
|
3
|
-
import type { Accessor } from 'solid-js';
|
|
4
|
-
import { createMemo, untrack } from 'solid-js';
|
|
5
|
-
import type { SelectItem, SelectNode, SelectNodeAppearances } from '../client/SelectNode.ts';
|
|
6
|
-
import type { TextRange } from '../client/TextRange.ts';
|
|
7
|
-
import type { SubmissionState } from '../client/submission/SubmissionState.ts';
|
|
8
|
-
import type { AnyViolation, LeafNodeValidationState } from '../client/validation.ts';
|
|
9
|
-
import type { XFormsXPathElement } from '../integration/xpath/adapter/XFormsXPathNode.ts';
|
|
10
|
-
import { createLeafNodeSubmissionState } from '../lib/client-reactivity/submission/createLeafNodeSubmissionState.ts';
|
|
11
|
-
import { createSelectItems } from '../lib/reactivity/createSelectItems.ts';
|
|
12
|
-
import { createValueState } from '../lib/reactivity/createValueState.ts';
|
|
13
|
-
import type { CurrentState } from '../lib/reactivity/node-state/createCurrentState.ts';
|
|
14
|
-
import type { EngineState } from '../lib/reactivity/node-state/createEngineState.ts';
|
|
15
|
-
import type { SharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
16
|
-
import { createSharedNodeState } from '../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
17
|
-
import { createFieldHint } from '../lib/reactivity/text/createFieldHint.ts';
|
|
18
|
-
import { createNodeLabel } from '../lib/reactivity/text/createNodeLabel.ts';
|
|
19
|
-
import type { SimpleAtomicState } from '../lib/reactivity/types.ts';
|
|
20
|
-
import type { SharedValidationState } from '../lib/reactivity/validation/createValidation.ts';
|
|
21
|
-
import { createValidationState } from '../lib/reactivity/validation/createValidation.ts';
|
|
22
|
-
import type { AnySelectDefinition } from '../parse/body/control/select/SelectDefinition.ts';
|
|
23
|
-
import type { LeafNodeDefinition } from '../parse/model/LeafNodeDefinition.ts';
|
|
24
|
-
import type { Root } from './Root.ts';
|
|
25
|
-
import type { DescendantNodeStateSpec } from './abstract/DescendantNode.ts';
|
|
26
|
-
import { DescendantNode } from './abstract/DescendantNode.ts';
|
|
27
|
-
import type { GeneralParentNode } from './hierarchy.ts';
|
|
28
|
-
import type { EvaluationContext } from './internal-api/EvaluationContext.ts';
|
|
29
|
-
import type { ValidationContext } from './internal-api/ValidationContext.ts';
|
|
30
|
-
import type { ValueContext } from './internal-api/ValueContext.ts';
|
|
31
|
-
import type { ClientReactiveSubmittableLeafNode } from './internal-api/submission/ClientReactiveSubmittableLeafNode.ts';
|
|
32
|
-
|
|
33
|
-
export interface SelectFieldDefinition extends LeafNodeDefinition {
|
|
34
|
-
readonly bodyElement: AnySelectDefinition;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
interface SelectFieldStateSpec extends DescendantNodeStateSpec<readonly SelectItem[]> {
|
|
38
|
-
readonly label: Accessor<TextRange<'label'> | null>;
|
|
39
|
-
readonly hint: Accessor<TextRange<'hint'> | null>;
|
|
40
|
-
readonly children: null;
|
|
41
|
-
readonly value: SimpleAtomicState<readonly SelectItem[]>;
|
|
42
|
-
readonly valueOptions: Accessor<readonly SelectItem[]>;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export class SelectField
|
|
46
|
-
extends DescendantNode<SelectFieldDefinition, SelectFieldStateSpec, GeneralParentNode, null>
|
|
47
|
-
implements
|
|
48
|
-
SelectNode,
|
|
49
|
-
XFormsXPathElement,
|
|
50
|
-
EvaluationContext,
|
|
51
|
-
ValidationContext,
|
|
52
|
-
ValueContext<readonly SelectItem[]>,
|
|
53
|
-
ClientReactiveSubmittableLeafNode<readonly SelectItem[]>
|
|
54
|
-
{
|
|
55
|
-
private readonly selectExclusive: boolean;
|
|
56
|
-
private readonly validation: SharedValidationState;
|
|
57
|
-
|
|
58
|
-
// XFormsXPathElement
|
|
59
|
-
override readonly [XPathNodeKindKey] = 'element';
|
|
60
|
-
|
|
61
|
-
// InstanceNode
|
|
62
|
-
protected readonly state: SharedNodeState<SelectFieldStateSpec>;
|
|
63
|
-
protected override engineState: EngineState<SelectFieldStateSpec>;
|
|
64
|
-
|
|
65
|
-
// SelectNode
|
|
66
|
-
readonly nodeType = 'select';
|
|
67
|
-
readonly appearances: SelectNodeAppearances;
|
|
68
|
-
readonly currentState: CurrentState<SelectFieldStateSpec>;
|
|
69
|
-
|
|
70
|
-
get validationState(): LeafNodeValidationState {
|
|
71
|
-
return this.validation.currentState;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
readonly submissionState: SubmissionState;
|
|
75
|
-
|
|
76
|
-
// ValueContext
|
|
77
|
-
override readonly contextNode = this;
|
|
78
|
-
|
|
79
|
-
readonly encodeValue = (runtimeValue: readonly SelectItem[]): string => {
|
|
80
|
-
const itemValues = new Set(runtimeValue.map(({ value }) => value));
|
|
81
|
-
const selectedItems = this.getValueOptions().filter(({ value }) => {
|
|
82
|
-
return itemValues.has(value);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
return selectedItems.map(({ value }) => value).join(' ');
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
readonly decodeValue = (instanceValue: string): readonly SelectItem[] => {
|
|
89
|
-
const itemValues = new Set(
|
|
90
|
-
xmlXPathWhitespaceSeparatedList(instanceValue, {
|
|
91
|
-
ignoreEmpty: true,
|
|
92
|
-
})
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
// TODO: also want set-like behavior, probably?
|
|
96
|
-
return this.getValueOptions().filter((option) => {
|
|
97
|
-
return itemValues.has(option.value);
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
protected readonly getValueOptions: Accessor<readonly SelectItem[]>;
|
|
102
|
-
protected readonly getValue: Accessor<readonly SelectItem[]>;
|
|
103
|
-
|
|
104
|
-
constructor(parent: GeneralParentNode, definition: SelectFieldDefinition) {
|
|
105
|
-
super(parent, definition);
|
|
106
|
-
|
|
107
|
-
this.appearances = definition.bodyElement.appearances;
|
|
108
|
-
this.selectExclusive = definition.bodyElement.type === 'select1';
|
|
109
|
-
|
|
110
|
-
const valueOptions = createSelectItems(this);
|
|
111
|
-
|
|
112
|
-
this.getValueOptions = valueOptions;
|
|
113
|
-
|
|
114
|
-
const [baseGetValue, setValue] = createValueState(this);
|
|
115
|
-
|
|
116
|
-
const getValue = this.scope.runTask(() => {
|
|
117
|
-
const selectItemsByValue = createMemo((): ReadonlyMap<string, SelectItem> => {
|
|
118
|
-
return new Map(valueOptions().map((item) => [item.value, item]));
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
return createMemo(() => {
|
|
122
|
-
const items = selectItemsByValue();
|
|
123
|
-
|
|
124
|
-
return baseGetValue().filter((item) => {
|
|
125
|
-
return items.has(item.value);
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
this.getValue = getValue;
|
|
131
|
-
|
|
132
|
-
const valueState: SimpleAtomicState<readonly SelectItem[]> = [getValue, setValue];
|
|
133
|
-
|
|
134
|
-
const sharedStateOptions = {
|
|
135
|
-
clientStateFactory: this.engineConfig.stateFactory,
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const state = createSharedNodeState(
|
|
139
|
-
this.scope,
|
|
140
|
-
{
|
|
141
|
-
reference: this.contextReference,
|
|
142
|
-
readonly: this.isReadonly,
|
|
143
|
-
relevant: this.isRelevant,
|
|
144
|
-
required: this.isRequired,
|
|
145
|
-
|
|
146
|
-
label: createNodeLabel(this, definition),
|
|
147
|
-
hint: createFieldHint(this, definition),
|
|
148
|
-
children: null,
|
|
149
|
-
value: valueState,
|
|
150
|
-
valueOptions,
|
|
151
|
-
},
|
|
152
|
-
sharedStateOptions
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
this.state = state;
|
|
156
|
-
this.engineState = state.engineState;
|
|
157
|
-
this.currentState = state.currentState;
|
|
158
|
-
this.validation = createValidationState(this, sharedStateOptions);
|
|
159
|
-
this.submissionState = createLeafNodeSubmissionState(this);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
protected getSelectItemsByValue(
|
|
163
|
-
valueOptions: readonly SelectItem[] = this.getValueOptions()
|
|
164
|
-
): ReadonlyMap<string, SelectItem> {
|
|
165
|
-
return new Map(
|
|
166
|
-
valueOptions.map((item) => {
|
|
167
|
-
return [item.value, item];
|
|
168
|
-
})
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
protected updateSelectedItemValues(values: readonly string[]) {
|
|
173
|
-
const itemsByValue = untrack(() => this.getSelectItemsByValue());
|
|
174
|
-
|
|
175
|
-
const items = values.flatMap((value) => {
|
|
176
|
-
const item = itemsByValue.get(value);
|
|
177
|
-
|
|
178
|
-
if (item == null) {
|
|
179
|
-
return [];
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return item ?? [];
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
this.state.setProperty('value', items);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
protected setSelectedItemValue(value: string | null) {
|
|
189
|
-
if (value == null) {
|
|
190
|
-
this.state.setProperty('value', []);
|
|
191
|
-
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
this.updateSelectedItemValues([value]);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// XFormsXPathElement
|
|
199
|
-
override getXPathValue(): string {
|
|
200
|
-
return this.encodeValue(this.engineState.value);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// SelectNode
|
|
204
|
-
select(selectedItem: SelectItem): Root {
|
|
205
|
-
const { engineState, root } = this;
|
|
206
|
-
|
|
207
|
-
if (this.selectExclusive) {
|
|
208
|
-
this.setSelectedItemValue(selectedItem.value);
|
|
209
|
-
|
|
210
|
-
return root;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const currentValues = engineState.value.map(({ value }) => {
|
|
214
|
-
return value;
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
const selectedValue = selectedItem.value;
|
|
218
|
-
|
|
219
|
-
if (currentValues.includes(selectedValue)) {
|
|
220
|
-
return root;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
this.updateSelectedItemValues(currentValues.concat(selectedValue));
|
|
224
|
-
|
|
225
|
-
return root;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
deselect(deselectedItem: SelectItem): Root {
|
|
229
|
-
const { engineState, root } = this;
|
|
230
|
-
|
|
231
|
-
const currentValues = engineState.value.map(({ value }) => {
|
|
232
|
-
return value;
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
const selectedValue = deselectedItem.value;
|
|
236
|
-
|
|
237
|
-
if (!currentValues.includes(selectedValue)) {
|
|
238
|
-
return root;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
const updatedValues = currentValues.filter((value) => {
|
|
242
|
-
return value !== selectedValue;
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
this.updateSelectedItemValues(updatedValues);
|
|
246
|
-
|
|
247
|
-
return root;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// InstanceNode
|
|
251
|
-
getChildren(): readonly [] {
|
|
252
|
-
return [];
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// ValidationContext
|
|
256
|
-
getViolation(): AnyViolation | null {
|
|
257
|
-
return this.validation.engineState.violation;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
isBlank(): boolean {
|
|
261
|
-
return this.engineState.value.length === 0;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { UnsupportedControl } from '../abstract/UnsupportedControl.ts';
|
|
2
|
-
import type { ValueContext } from '../internal-api/ValueContext.ts';
|
|
3
|
-
|
|
4
|
-
export class RangeControl extends UnsupportedControl<'range'> implements ValueContext<unknown> {
|
|
5
|
-
readonly nodeType = 'range';
|
|
6
|
-
|
|
7
|
-
// ValueContext
|
|
8
|
-
readonly contextNode = this;
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { UnsupportedControl } from '../abstract/UnsupportedControl.ts';
|
|
2
|
-
import type { ValueContext } from '../internal-api/ValueContext.ts';
|
|
3
|
-
|
|
4
|
-
export class RankControl extends UnsupportedControl<'rank'> implements ValueContext<unknown> {
|
|
5
|
-
readonly nodeType = 'rank';
|
|
6
|
-
|
|
7
|
-
// ValueContext
|
|
8
|
-
readonly contextNode = this;
|
|
9
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { XFORMS_NAMESPACE_URI } from '@getodk/common/constants/xmlns.ts';
|
|
2
|
-
import type { XFormsXPathNamedNode, XPathNamedNodeKind } from '../adapter/XFormsXPathNode.ts';
|
|
3
|
-
import type { StaticDocument } from './StaticDocument.ts';
|
|
4
|
-
import type { StaticParentNode } from './StaticNode.ts';
|
|
5
|
-
import { StaticNode } from './StaticNode.ts';
|
|
6
|
-
|
|
7
|
-
export interface StaticNamedNodeOptions {
|
|
8
|
-
readonly namespaceURI: string | null;
|
|
9
|
-
readonly localName: string;
|
|
10
|
-
readonly value?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export abstract class StaticNamedNode<Kind extends XPathNamedNodeKind>
|
|
14
|
-
extends StaticNode<Kind>
|
|
15
|
-
implements XFormsXPathNamedNode
|
|
16
|
-
{
|
|
17
|
-
readonly rootDocument: StaticDocument;
|
|
18
|
-
readonly isXFormsNamespace: boolean;
|
|
19
|
-
readonly namespaceURI: string | null;
|
|
20
|
-
readonly localName: string;
|
|
21
|
-
readonly value: string | null;
|
|
22
|
-
|
|
23
|
-
protected constructor(
|
|
24
|
-
readonly parent: StaticParentNode,
|
|
25
|
-
options: StaticNamedNodeOptions
|
|
26
|
-
) {
|
|
27
|
-
super();
|
|
28
|
-
|
|
29
|
-
this.rootDocument = parent.rootDocument;
|
|
30
|
-
|
|
31
|
-
const { namespaceURI, localName, value = null } = options;
|
|
32
|
-
|
|
33
|
-
this.namespaceURI = namespaceURI;
|
|
34
|
-
this.localName = localName;
|
|
35
|
-
this.value = value;
|
|
36
|
-
|
|
37
|
-
if (namespaceURI === XFORMS_NAMESPACE_URI) {
|
|
38
|
-
this.isXFormsNamespace = true;
|
|
39
|
-
} else if (parent == null || parent.isXFormsNamespace) {
|
|
40
|
-
this.isXFormsNamespace = namespaceURI == null;
|
|
41
|
-
} else {
|
|
42
|
-
this.isXFormsNamespace = false;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { DependencyContext } from '../../../expression/abstract/DependencyContext.ts';
|
|
2
|
-
import type { ItemsetDefinition } from './ItemsetDefinition.ts';
|
|
3
|
-
|
|
4
|
-
export class ItemsetNodesetContext extends DependencyContext {
|
|
5
|
-
override readonly parentReference = null;
|
|
6
|
-
override readonly reference: string;
|
|
7
|
-
|
|
8
|
-
constructor(
|
|
9
|
-
protected readonly itemset: ItemsetDefinition,
|
|
10
|
-
nodesetExpression: string
|
|
11
|
-
) {
|
|
12
|
-
super();
|
|
13
|
-
|
|
14
|
-
this.reference = nodesetExpression;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
override set isTranslated(value: true) {
|
|
18
|
-
super.isTranslated = value;
|
|
19
|
-
this.itemset.isTranslated = value;
|
|
20
|
-
}
|
|
21
|
-
}
|