@getodk/xforms-engine 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.vite/manifest.json +1 -0
- package/dist/XFormDOM.d.ts +1 -0
- package/dist/XFormDataType.d.ts +2 -1
- package/dist/XFormDefinition.d.ts +1 -0
- package/dist/body/BodyDefinition.d.ts +27 -9
- package/dist/body/BodyElementDefinition.d.ts +5 -4
- package/dist/body/RepeatElementDefinition.d.ts +19 -0
- package/dist/body/UnsupportedBodyElementDefinition.d.ts +3 -2
- 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 +5 -2
- package/dist/body/control/InputDefinition.d.ts +6 -0
- package/dist/body/control/select/ItemDefinition.d.ts +4 -3
- package/dist/body/control/select/ItemsetDefinition.d.ts +4 -3
- package/dist/body/control/select/ItemsetNodesetContext.d.ts +3 -2
- package/dist/body/control/select/ItemsetNodesetExpression.d.ts +2 -1
- package/dist/body/control/select/ItemsetValueExpression.d.ts +2 -1
- package/dist/body/control/select/SelectDefinition.d.ts +16 -5
- package/dist/body/group/BaseGroupDefinition.d.ts +6 -10
- package/dist/body/group/LogicalGroupDefinition.d.ts +1 -0
- package/dist/body/group/PresentationGroupDefinition.d.ts +3 -2
- package/dist/body/group/StructuralGroupDefinition.d.ts +1 -0
- package/dist/body/text/HintDefinition.d.ts +4 -4
- package/dist/body/text/LabelDefinition.d.ts +9 -7
- package/dist/body/text/TextElementDefinition.d.ts +9 -8
- package/dist/body/text/TextElementOutputPart.d.ts +2 -1
- package/dist/body/text/TextElementPart.d.ts +5 -4
- package/dist/body/text/TextElementReferencePart.d.ts +2 -1
- package/dist/body/text/TextElementStaticPart.d.ts +2 -1
- package/dist/client/BaseNode.d.ts +9 -3
- package/dist/client/EngineConfig.d.ts +2 -1
- package/dist/client/GroupNode.d.ts +10 -6
- package/dist/client/NodeAppearances.d.ts +15 -0
- package/dist/client/RepeatInstanceNode.d.ts +10 -6
- package/dist/client/RepeatRangeNode.d.ts +11 -7
- package/dist/client/RootNode.d.ts +24 -4
- package/dist/client/SelectNode.d.ts +10 -6
- package/dist/client/StringNode.d.ts +9 -5
- package/dist/client/SubtreeNode.d.ts +6 -4
- package/dist/client/TextRange.d.ts +2 -1
- package/dist/client/hierarchy.d.ts +9 -8
- package/dist/client/index.d.ts +3 -2
- package/dist/expression/DependencyContext.d.ts +2 -1
- package/dist/expression/DependentExpression.d.ts +3 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1882 -1757
- package/dist/index.js.map +1 -1
- package/dist/instance/Group.d.ts +15 -15
- package/dist/instance/RepeatInstance.d.ts +39 -15
- package/dist/instance/RepeatRange.d.ts +98 -20
- package/dist/instance/Root.d.ts +25 -39
- package/dist/instance/SelectField.d.ts +17 -17
- package/dist/instance/StringField.d.ts +17 -17
- package/dist/instance/Subtree.d.ts +13 -13
- package/dist/instance/abstract/DescendantNode.d.ts +26 -18
- package/dist/instance/abstract/InstanceNode.d.ts +44 -46
- package/dist/instance/children.d.ts +2 -1
- package/dist/instance/hierarchy.d.ts +8 -7
- package/dist/instance/index.d.ts +4 -3
- package/dist/instance/internal-api/EvaluationContext.d.ts +10 -8
- package/dist/instance/internal-api/InstanceConfig.d.ts +3 -2
- package/dist/instance/internal-api/SubscribableDependency.d.ts +2 -1
- package/dist/instance/internal-api/TranslationContext.d.ts +2 -1
- package/dist/instance/internal-api/ValueContext.d.ts +6 -5
- package/dist/instance/resource.d.ts +3 -2
- package/dist/instance/text/TextChunk.d.ts +4 -3
- package/dist/instance/text/TextRange.d.ts +2 -1
- package/dist/lib/TokenListParser.d.ts +84 -0
- package/dist/lib/dom/query.d.ts +8 -2
- package/dist/lib/reactivity/createChildrenState.d.ts +4 -3
- package/dist/lib/reactivity/createComputedExpression.d.ts +4 -3
- package/dist/lib/reactivity/createSelectItems.d.ts +4 -3
- package/dist/lib/reactivity/createValueState.d.ts +3 -2
- package/dist/lib/reactivity/materializeCurrentStateChildren.d.ts +6 -4
- package/dist/lib/reactivity/node-state/createClientState.d.ts +7 -6
- package/dist/lib/reactivity/node-state/createCurrentState.d.ts +5 -4
- package/dist/lib/reactivity/node-state/createEngineState.d.ts +4 -3
- package/dist/lib/reactivity/node-state/createSharedNodeState.d.ts +7 -6
- package/dist/lib/reactivity/node-state/createSpecifiedPropertyDescriptor.d.ts +2 -1
- package/dist/lib/reactivity/node-state/createSpecifiedState.d.ts +3 -2
- package/dist/lib/reactivity/node-state/representations.d.ts +2 -1
- package/dist/lib/reactivity/scope.d.ts +2 -1
- package/dist/lib/reactivity/text/createFieldHint.d.ts +4 -3
- package/dist/lib/reactivity/text/createNodeLabel.d.ts +4 -3
- package/dist/lib/reactivity/text/createTextRange.d.ts +6 -5
- package/dist/lib/reactivity/types.d.ts +2 -1
- package/dist/lib/xpath/analysis.d.ts +2 -1
- package/dist/model/BindComputation.d.ts +2 -1
- package/dist/model/BindDefinition.d.ts +6 -5
- package/dist/model/DescendentNodeDefinition.d.ts +6 -6
- package/dist/model/ModelBindMap.d.ts +4 -3
- package/dist/model/ModelDefinition.d.ts +2 -1
- package/dist/model/NodeDefinition.d.ts +20 -19
- package/dist/model/RepeatInstanceDefinition.d.ts +7 -7
- package/dist/model/{RepeatSequenceDefinition.d.ts → RepeatRangeDefinition.d.ts} +7 -6
- package/dist/model/RepeatTemplateDefinition.d.ts +8 -8
- package/dist/model/RootDefinition.d.ts +8 -5
- package/dist/model/SubtreeDefinition.d.ts +5 -4
- package/dist/model/ValueNodeDefinition.d.ts +5 -5
- package/dist/solid.js +1873 -1751
- package/dist/solid.js.map +1 -1
- package/package.json +14 -18
- 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 -15
- package/dist/body/group/RepeatGroupDefinition.d.ts +0 -12
- package/src/body/RepeatDefinition.ts +0 -54
- package/src/body/group/RepeatGroupDefinition.ts +0 -91
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
1
|
+
import { XFormsXPathEvaluator } from '@getodk/xpath';
|
|
2
|
+
import { Accessor, Signal } from 'solid-js';
|
|
3
|
+
import { BaseNode } from '../../client/BaseNode.ts';
|
|
4
|
+
import { NodeAppearances } from '../../client/NodeAppearances.ts';
|
|
5
|
+
import { InstanceNodeType } from '../../client/node-types.ts';
|
|
6
|
+
import { TextRange } from '../../index.ts';
|
|
7
|
+
import { CurrentState } from '../../lib/reactivity/node-state/createCurrentState.ts';
|
|
8
|
+
import { EngineState } from '../../lib/reactivity/node-state/createEngineState.ts';
|
|
9
|
+
import { SharedNodeState } from '../../lib/reactivity/node-state/createSharedNodeState.ts';
|
|
10
|
+
import { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
11
|
+
import { SimpleAtomicState } from '../../lib/reactivity/types.ts';
|
|
12
|
+
import { AnyNodeDefinition } from '../../model/NodeDefinition.ts';
|
|
13
|
+
import { Root } from '../Root.ts';
|
|
14
|
+
import { AnyChildNode, AnyNode, AnyParentNode } from '../hierarchy.ts';
|
|
15
|
+
import { NodeID } from '../identity.ts';
|
|
16
|
+
import { EvaluationContext } from '../internal-api/EvaluationContext.ts';
|
|
17
|
+
import { InstanceConfig } from '../internal-api/InstanceConfig.ts';
|
|
18
|
+
import { SubscribableDependency } from '../internal-api/SubscribableDependency.ts';
|
|
19
|
+
|
|
18
20
|
export interface InstanceNodeStateSpec<Value = never> {
|
|
19
21
|
readonly reference: Accessor<string> | string;
|
|
20
22
|
readonly readonly: Accessor<boolean> | boolean;
|
|
@@ -27,9 +29,6 @@ export interface InstanceNodeStateSpec<Value = never> {
|
|
|
27
29
|
readonly value: Signal<Value> | SimpleAtomicState<Value> | null;
|
|
28
30
|
}
|
|
29
31
|
type AnyInstanceNode = InstanceNode<AnyNodeDefinition, InstanceNodeStateSpec<any>, any>;
|
|
30
|
-
interface InitializedStateOptions<T, K extends keyof T> {
|
|
31
|
-
readonly uninitializedFallback: T[K];
|
|
32
|
-
}
|
|
33
32
|
/**
|
|
34
33
|
* This type has the same effect as {@link MaterializedChildren}, but abstractly
|
|
35
34
|
* handles leaf node types as well.
|
|
@@ -37,52 +36,52 @@ interface InitializedStateOptions<T, K extends keyof T> {
|
|
|
37
36
|
export type InstanceNodeCurrentState<Spec extends InstanceNodeStateSpec<any>, Child> = CurrentState<Omit<Spec, 'children'>> & {
|
|
38
37
|
readonly children: [Child] extends [AnyChildNode] ? readonly Child[] : null;
|
|
39
38
|
};
|
|
39
|
+
interface ComputableReferenceNode {
|
|
40
|
+
readonly parent: AnyParentNode | null;
|
|
41
|
+
readonly definition: AnyNodeDefinition;
|
|
42
|
+
}
|
|
43
|
+
type ComputeInstanceNodeReference = <This extends ComputableReferenceNode>(this: This, parent: This['parent'], definition: This['definition']) => string;
|
|
44
|
+
export interface InstanceNodeOptions {
|
|
45
|
+
readonly computeReference?: () => string;
|
|
46
|
+
}
|
|
40
47
|
export declare abstract class InstanceNode<Definition extends AnyNodeDefinition, Spec extends InstanceNodeStateSpec<any>, Child extends AnyChildNode | null = null> implements BaseNode, EvaluationContext, SubscribableDependency {
|
|
41
48
|
readonly engineConfig: InstanceConfig;
|
|
42
49
|
readonly parent: AnyParentNode | null;
|
|
43
50
|
readonly definition: Definition;
|
|
44
|
-
protected readonly isStateInitialized: Accessor<boolean>;
|
|
45
51
|
protected abstract readonly state: SharedNodeState<Spec>;
|
|
46
52
|
protected abstract readonly engineState: EngineState<Spec>;
|
|
47
53
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* - a value of the expected type will be available
|
|
56
|
-
* - any read access will become reactive to the actual state, once it has
|
|
57
|
-
* been initialized and {@link engineState} is assigned
|
|
58
|
-
*
|
|
59
|
-
* @todo This is one among several chicken/egg problems encountered trying to
|
|
60
|
-
* support state initialization in which some aspects of the state derive from
|
|
61
|
-
* other aspects of it. It would be nice to dispense with this entirely. But
|
|
62
|
-
* if it must persist, we should also consider replacing the method with a
|
|
63
|
-
* direct accessor once state initialization completes, so the initialized
|
|
64
|
-
* check is only called until it becomes impertinent.
|
|
54
|
+
* @package Exposed on every node type to facilitate inheritance, as well as
|
|
55
|
+
* conditional behavior for value nodes.
|
|
56
|
+
*/
|
|
57
|
+
abstract readonly hasReadonlyAncestor: Accessor<boolean>;
|
|
58
|
+
/**
|
|
59
|
+
* @package Exposed on every node type to facilitate inheritance, as well as
|
|
60
|
+
* conditional behavior for value nodes.
|
|
65
61
|
*/
|
|
66
|
-
|
|
62
|
+
abstract readonly isReadonly: Accessor<boolean>;
|
|
67
63
|
/**
|
|
68
64
|
* @package Exposed on every node type to facilitate inheritance, as well as
|
|
69
65
|
* conditional behavior for value nodes.
|
|
70
66
|
*/
|
|
71
|
-
|
|
67
|
+
abstract readonly hasNonRelevantAncestor: Accessor<boolean>;
|
|
72
68
|
/**
|
|
73
69
|
* @package Exposed on every node type to facilitate inheritance, as well as
|
|
74
70
|
* conditional behavior for value nodes.
|
|
75
71
|
*/
|
|
76
|
-
|
|
72
|
+
abstract readonly isRelevant: Accessor<boolean>;
|
|
77
73
|
readonly nodeId: NodeID;
|
|
78
74
|
abstract readonly nodeType: InstanceNodeType;
|
|
75
|
+
abstract readonly appearances: NodeAppearances<Definition>;
|
|
79
76
|
abstract readonly currentState: InstanceNodeCurrentState<Spec, Child>;
|
|
80
77
|
abstract readonly root: Root;
|
|
81
78
|
abstract readonly evaluator: XFormsXPathEvaluator;
|
|
82
79
|
readonly scope: ReactiveScope;
|
|
83
|
-
|
|
80
|
+
readonly computeReference: ComputeInstanceNodeReference;
|
|
81
|
+
protected readonly computeChildStepReference: ComputeInstanceNodeReference;
|
|
82
|
+
readonly contextReference: () => string;
|
|
84
83
|
abstract readonly contextNode: Element;
|
|
85
|
-
constructor(engineConfig: InstanceConfig, parent: AnyParentNode | null, definition: Definition);
|
|
84
|
+
constructor(engineConfig: InstanceConfig, parent: AnyParentNode | null, definition: Definition, options?: InstanceNodeOptions);
|
|
86
85
|
/**
|
|
87
86
|
* @package This presently serves a few internal use cases, where certain
|
|
88
87
|
* behaviors depend on arbitrary traversal from any point in the instance
|
|
@@ -94,9 +93,8 @@ export declare abstract class InstanceNode<Definition extends AnyNodeDefinition,
|
|
|
94
93
|
* interface for those internal uses.
|
|
95
94
|
*/
|
|
96
95
|
abstract getChildren(this: AnyInstanceNode): readonly AnyChildNode[];
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
getSubscribableDependencyByReference(this: AnyNode, reference: string): SubscribableDependency | null;
|
|
96
|
+
getNodesByReference(this: AnyNode, visited: WeakSet<AnyNode>, dependencyReference: string): readonly SubscribableDependency[];
|
|
97
|
+
getSubscribableDependenciesByReference(this: AnyNode, reference: string): readonly SubscribableDependency[];
|
|
100
98
|
/**
|
|
101
99
|
* This is a default implementation suitable for most node types. The rest
|
|
102
100
|
* (currently: `Root`, `RepeatRange`, `RepeatInstance`) should likely extend
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
1
|
+
import { Group } from './Group.ts';
|
|
2
|
+
import { RepeatInstance } from './RepeatInstance.ts';
|
|
3
|
+
import { RepeatRange } from './RepeatRange.ts';
|
|
4
|
+
import { Root } from './Root.ts';
|
|
5
|
+
import { SelectField } from './SelectField.ts';
|
|
6
|
+
import { StringField } from './StringField.ts';
|
|
7
|
+
import { Subtree } from './Subtree.ts';
|
|
8
|
+
|
|
8
9
|
export type AnyNode = Root | Group | Subtree | RepeatRange | RepeatInstance | StringField | SelectField;
|
|
9
10
|
export type AnyParentNode = Root | Group | Subtree | RepeatRange | RepeatInstance;
|
|
10
11
|
export type GeneralParentNode = Root | Group | Subtree | RepeatInstance;
|
package/dist/instance/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { RootNode } from '../client/RootNode.ts';
|
|
2
|
+
import { InitializeFormOptions as BaseInitializeFormOptions, FormResource } from '../client/index.ts';
|
|
3
|
+
import { InstanceConfig } from './internal-api/InstanceConfig.ts';
|
|
4
|
+
|
|
4
5
|
interface InitializeFormOptions extends BaseInitializeFormOptions {
|
|
5
6
|
readonly config: Partial<InstanceConfig>;
|
|
6
7
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { XFormsXPathEvaluator } from '@getodk/xpath';
|
|
2
|
+
import { Accessor } from 'solid-js';
|
|
3
|
+
import { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
4
|
+
import { SubscribableDependency } from './SubscribableDependency.ts';
|
|
5
|
+
import { TranslationContext } from './TranslationContext.ts';
|
|
6
|
+
|
|
5
7
|
export interface EvaluationContextRoot extends SubscribableDependency, TranslationContext {
|
|
6
8
|
}
|
|
7
9
|
/**
|
|
@@ -24,11 +26,11 @@ export interface EvaluationContext {
|
|
|
24
26
|
* Produces the current absolute reference to the {@link contextNode}, where
|
|
25
27
|
* the absolute `/` resolves to the active form state's primary instance root.
|
|
26
28
|
*/
|
|
27
|
-
|
|
29
|
+
readonly contextReference: Accessor<string>;
|
|
28
30
|
readonly contextNode: Node;
|
|
29
31
|
/**
|
|
30
|
-
* Resolves
|
|
31
|
-
* {@link EvaluationContext.contextNode}.
|
|
32
|
+
* Resolves nodes corresponding to the provided node-set reference, possibly
|
|
33
|
+
* relative to the {@link EvaluationContext.contextNode}.
|
|
32
34
|
*/
|
|
33
|
-
|
|
35
|
+
getSubscribableDependenciesByReference(reference: string): readonly SubscribableDependency[];
|
|
34
36
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { EngineConfig } from '../../client/EngineConfig.ts';
|
|
2
|
+
import { CreateUniqueId } from '../../lib/unique-id.ts';
|
|
3
|
+
|
|
3
4
|
export interface InstanceConfig extends Required<EngineConfig> {
|
|
4
5
|
/**
|
|
5
6
|
* Uniqueness per form instance session (so e.g. persistence isn't necessary).
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Provides a common interface to explicitly establish a reactive subscription
|
|
4
5
|
* to a form node, regardless of which node-specific details might trigger
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { ReactiveScope } from '../../lib/reactivity/scope.ts';
|
|
2
|
+
import { BindComputation } from '../../model/BindComputation.ts';
|
|
3
|
+
import { EvaluationContext } from './EvaluationContext.ts';
|
|
4
|
+
|
|
4
5
|
export type InstanceValue = string;
|
|
5
6
|
interface ValueContextDefinitionBind {
|
|
6
7
|
readonly calculate: BindComputation<'calculate'> | null;
|
|
@@ -14,8 +15,8 @@ export interface ValueContext<RuntimeValue> extends EvaluationContext {
|
|
|
14
15
|
readonly scope: ReactiveScope;
|
|
15
16
|
readonly definition: ValueContextDefinition;
|
|
16
17
|
readonly contextNode: Element;
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
isReadonly(): boolean;
|
|
19
|
+
isRelevant(): boolean;
|
|
19
20
|
readonly encodeValue: (this: unknown, runtimeValue: RuntimeValue) => InstanceValue;
|
|
20
21
|
readonly decodeValue: (this: unknown, instanceValue: InstanceValue) => RuntimeValue;
|
|
21
22
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { FetchResource, FetchResourceResponse } from '../client/EngineConfig.ts';
|
|
2
|
+
import { FormResource } from '../client/index.ts';
|
|
3
|
+
|
|
3
4
|
export type { FetchResource, FetchResourceResponse, FormResource };
|
|
4
5
|
export interface ResourceOptions {
|
|
5
6
|
readonly fetchResource: FetchResource;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { ActiveLanguage } from '../../client/FormLanguage.ts';
|
|
2
|
+
import { TextChunk as ClientTextChunk, TextChunkSource } from '../../client/TextRange.ts';
|
|
3
|
+
import { TranslationContext } from '../internal-api/TranslationContext.ts';
|
|
4
|
+
|
|
4
5
|
export declare class TextChunk implements ClientTextChunk {
|
|
5
6
|
readonly context: TranslationContext;
|
|
6
7
|
readonly source: TextChunkSource;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { TextRange as ClientTextRange, TextChunk } from '../../client/TextRange.ts';
|
|
2
|
+
|
|
2
3
|
export type TextRole = 'hint' | 'label';
|
|
3
4
|
export declare class TextRange<Role extends TextRole> implements ClientTextRange<Role> {
|
|
4
5
|
readonly role: Role;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { PartiallyKnownString } from '../../../common/types/string/PartiallyKnownString.ts';
|
|
2
|
+
|
|
3
|
+
type SymbolIterator = typeof Symbol.iterator;
|
|
4
|
+
type TokenListKey<CanonicalToken extends string> = PartiallyKnownString<CanonicalToken> | SymbolIterator;
|
|
5
|
+
type TokenListIterator<CanonicalToken extends string> = IterableIterator<PartiallyKnownString<CanonicalToken>>;
|
|
6
|
+
/**
|
|
7
|
+
* @see {@link TokenListParser}
|
|
8
|
+
*/
|
|
9
|
+
export type TokenList<CanonicalToken extends string = string> = {
|
|
10
|
+
readonly [Key in TokenListKey<CanonicalToken>]: Key extends SymbolIterator ? () => TokenListIterator<CanonicalToken> : boolean;
|
|
11
|
+
};
|
|
12
|
+
interface TokenListAlias<CanonicalToken extends string> {
|
|
13
|
+
readonly fromAlias: string;
|
|
14
|
+
readonly toCanonical: CanonicalToken;
|
|
15
|
+
}
|
|
16
|
+
type TokenAliases<CanonicalToken extends string> = ReadonlyArray<TokenListAlias<CanonicalToken>>;
|
|
17
|
+
interface TokenListParserOptions<CanonicalToken extends string> {
|
|
18
|
+
readonly aliases?: TokenAliases<CanonicalToken>;
|
|
19
|
+
}
|
|
20
|
+
type TokenListAttributeName = PartiallyKnownString<'appearance' | 'class'>;
|
|
21
|
+
/**
|
|
22
|
+
* Intended primarily for use in parsing these features:
|
|
23
|
+
*
|
|
24
|
+
* - {@link https://getodk.github.io/xforms-spec/#appearances | appearances} ({@link https://xlsform.org/en/#appearance | additional documentation})
|
|
25
|
+
*
|
|
26
|
+
* - {@link https://getodk.github.io/xforms-spec/#body-attributes | body `class` attribute}
|
|
27
|
+
*
|
|
28
|
+
* This class is named as a reference to {@link DOMTokenList}
|
|
29
|
+
* ({@link https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList | MDN}),
|
|
30
|
+
* with these similarities:
|
|
31
|
+
*
|
|
32
|
+
* - Represents a value whose serialization is a space-separated list.
|
|
33
|
+
* - Each member ("token") is a string (without whitespace).
|
|
34
|
+
* - Provides set-like semantics to determine presence of members.
|
|
35
|
+
* - Provides ordering semantics as determined by the serialization.
|
|
36
|
+
*
|
|
37
|
+
* This class differs from that prior art in that:
|
|
38
|
+
*
|
|
39
|
+
* - It provides a notion of "canonical" members. This is _mostly_ (but not
|
|
40
|
+
* entirely) intended as a convenience to client developers, automatically
|
|
41
|
+
* populating canonical/known tokens for a given parser type in
|
|
42
|
+
* editor-provided autocomplete, etc. **Importantly**, non-canonical tokens
|
|
43
|
+
* _are not ignored_ in either the {@link TokenList}'s types or runtime
|
|
44
|
+
* values.
|
|
45
|
+
*
|
|
46
|
+
* - Provided "canonical" members may also be used to specify
|
|
47
|
+
* {@link TokenListParserOptions.aliases | optional aliases}. (Example: when
|
|
48
|
+
* parsing "appearances", an alias might map an older deprecated appearance to
|
|
49
|
+
* a newer canonical equivalent.) **Importantly**, when a token matches an
|
|
50
|
+
* alias, both that alias _and the token as-specified_ will be present in the
|
|
51
|
+
* produced {@link TokenList}.
|
|
52
|
+
*
|
|
53
|
+
* - As a parser, it is intended to be read-only. The serialized format which it
|
|
54
|
+
* parses is _generally_ the source of truth (excepting e.g. aliases).
|
|
55
|
+
* Notably, and as mentioned above, ordering is determined by:
|
|
56
|
+
*
|
|
57
|
+
* - Iterating each member, as provided by the serialized representation
|
|
58
|
+
*
|
|
59
|
+
* - If that member corresponds to an alias, that alias is yielded first
|
|
60
|
+
*
|
|
61
|
+
* - Regardless of whether the member corresponds to an alias, the member is
|
|
62
|
+
* yielded as-specified
|
|
63
|
+
*
|
|
64
|
+
* - A parsed {@link TokenList} is intended to maximize convenience of read-only
|
|
65
|
+
* access. Despite many _conceptual similarities_, most of the
|
|
66
|
+
* {@link DOMTokenList} **interface** is eschewed in favor of two (mutually
|
|
67
|
+
* equivalent) access mechanisms:
|
|
68
|
+
*
|
|
69
|
+
* - `Iterable<Token>`, with the ordering semantics described above
|
|
70
|
+
* - `Record<Token, boolean>`
|
|
71
|
+
*
|
|
72
|
+
* \* This may change, as we refine requirements. In the future, we may
|
|
73
|
+
* introduce a notion of mutually exclusive tokens (e.g. "appearances" which
|
|
74
|
+
* cannot be used together), which may in turn utilize instance-defined ordering
|
|
75
|
+
* as part of that mechanism.
|
|
76
|
+
*/
|
|
77
|
+
export declare class TokenListParser<CanonicalToken extends string, TokenAlias extends CanonicalToken = CanonicalToken> {
|
|
78
|
+
readonly canonicalTokens: readonly CanonicalToken[];
|
|
79
|
+
private readonly aliases;
|
|
80
|
+
constructor(canonicalTokens: readonly CanonicalToken[], options?: TokenListParserOptions<TokenAlias>);
|
|
81
|
+
parseFrom(element: Element, attributeName: TokenListAttributeName): TokenList<CanonicalToken>;
|
|
82
|
+
}
|
|
83
|
+
export type ParsedTokenList<Parser extends TokenListParser<any>> = Parser extends TokenListParser<infer CanonicalToken> ? TokenList<CanonicalToken> : never;
|
|
84
|
+
export {};
|
package/dist/lib/dom/query.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { KnownAttributeLocalNamedElement, LocalNamedElement } from '../../../../common/types/dom.ts';
|
|
2
|
+
import { SelectElement } from '../../body/control/select/SelectDefinition';
|
|
3
|
+
|
|
3
4
|
export interface HintElement extends LocalNamedElement<'hint'> {
|
|
4
5
|
}
|
|
5
6
|
export interface ItemElement extends LocalNamedElement<'item'> {
|
|
@@ -8,6 +9,10 @@ export interface ItemsetElement extends KnownAttributeLocalNamedElement<'itemset
|
|
|
8
9
|
}
|
|
9
10
|
export interface LabelElement extends LocalNamedElement<'label'> {
|
|
10
11
|
}
|
|
12
|
+
export interface RepeatGroupLabelElement extends LabelElement {
|
|
13
|
+
getAttribute(name: 'form-definition-source'): 'repeat-group';
|
|
14
|
+
getAttribute(name: string): string;
|
|
15
|
+
}
|
|
11
16
|
export interface RepeatElement extends KnownAttributeLocalNamedElement<'repeat', 'nodeset'> {
|
|
12
17
|
}
|
|
13
18
|
export interface ValueElement extends LocalNamedElement<'value'> {
|
|
@@ -16,5 +21,6 @@ export declare const getHintElement: (parent: Element) => HintElement | null;
|
|
|
16
21
|
export declare const getItemElements: (parent: SelectElement) => readonly ItemElement[];
|
|
17
22
|
export declare const getItemsetElement: (parent: Element) => ItemsetElement | null;
|
|
18
23
|
export declare const getLabelElement: (parent: Element) => LabelElement | null;
|
|
24
|
+
export declare const getRepeatGroupLabelElement: (parent: Element) => RepeatGroupLabelElement | null;
|
|
19
25
|
export declare const getRepeatElement: (parent: Element) => RepeatElement | null;
|
|
20
26
|
export declare const getValueElement: (parent: ItemElement | ItemsetElement) => ValueElement | null;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { Accessor, Setter, Signal } from 'solid-js';
|
|
2
|
+
import { AnyChildNode, AnyParentNode } from '../../instance/hierarchy.ts';
|
|
3
|
+
import { NodeID } from '../../instance/identity.ts';
|
|
4
|
+
|
|
4
5
|
export interface ChildrenState<Child extends AnyChildNode> {
|
|
5
6
|
readonly children: Signal<readonly Child[]>;
|
|
6
7
|
readonly getChildren: Accessor<readonly Child[]>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { Accessor } from 'solid-js';
|
|
2
|
+
import { DependentExpression, DependentExpressionResultType } from '../../expression/DependentExpression.ts';
|
|
3
|
+
import { EvaluationContext } from '../../instance/internal-api/EvaluationContext.ts';
|
|
4
|
+
|
|
4
5
|
interface ComputedExpressionResults {
|
|
5
6
|
readonly boolean: boolean;
|
|
6
7
|
readonly nodes: Node[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { Accessor } from 'solid-js';
|
|
2
|
+
import { SelectItem } from '../../index.ts';
|
|
3
|
+
import { SelectField } from '../../instance/SelectField.ts';
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* Creates a reactive computation of a {@link SelectField}'s
|
|
6
7
|
* {@link SelectItem}s, in support of the field's `valueOptions`.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { ValueContext } from '../../instance/internal-api/ValueContext.ts';
|
|
2
|
+
import { SimpleAtomicState } from './types.ts';
|
|
3
|
+
|
|
3
4
|
type InitialValueSource = 'FORM_DEFAULT' | 'PRIMARY_INSTANCE';
|
|
4
5
|
export interface ValueStateOptions {
|
|
5
6
|
/**
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { AnyChildNode } from '../../instance/hierarchy.ts';
|
|
2
|
+
import { NodeID } from '../../instance/identity.ts';
|
|
3
|
+
import { ChildrenState } from './createChildrenState.ts';
|
|
4
|
+
import { ReactiveScope } from './scope.ts';
|
|
5
|
+
|
|
4
6
|
export interface EncodedParentState {
|
|
5
7
|
readonly children: readonly NodeID[];
|
|
6
8
|
}
|
|
@@ -15,4 +17,4 @@ export type MaterializedChildren<BaseState extends EncodedParentState, Child ext
|
|
|
15
17
|
*
|
|
16
18
|
* @see {@link createChildrenState} for further detail.
|
|
17
19
|
*/
|
|
18
|
-
export declare const materializeCurrentStateChildren: <Child extends AnyChildNode, ParentState extends EncodedParentState>(currentState: ParentState, childrenState: ChildrenState<Child>) => MaterializedChildren<ParentState, Child>;
|
|
20
|
+
export declare const materializeCurrentStateChildren: <Child extends AnyChildNode, ParentState extends EncodedParentState>(scope: ReactiveScope, currentState: ParentState, childrenState: ChildrenState<Child>) => MaterializedChildren<ParentState, Child>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import { ShallowMutable } from '../../../../../common/types/helpers.js';
|
|
2
|
+
import { OpaqueReactiveObjectFactory } from '../../../index.ts';
|
|
3
|
+
import { ReactiveScope } from '../scope.ts';
|
|
4
|
+
import { EngineState } from './createEngineState.ts';
|
|
5
|
+
import { SpecifiedState, StateSpec } from './createSpecifiedState.ts';
|
|
6
|
+
import { InternalClientRepresentation } from './representations.ts';
|
|
7
|
+
|
|
7
8
|
export type SpecifiedClientStateFactory<Factory extends OpaqueReactiveObjectFactory, Spec extends StateSpec> = ShallowMutable<SpecifiedState<Spec>> extends Parameters<Factory>[0] ? Factory : never;
|
|
8
9
|
export type ClientState<Spec extends StateSpec> = InternalClientRepresentation<SpecifiedState<Spec>>;
|
|
9
10
|
export declare const createClientState: <Factory extends OpaqueReactiveObjectFactory, Spec extends StateSpec>(scope: ReactiveScope, engineState: EngineState<Spec>, clientStateFactory: SpecifiedClientStateFactory<Factory, Spec>) => ClientState<Spec>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { ReactiveScope } from '../scope.ts';
|
|
2
|
+
import { ClientState } from './createClientState.ts';
|
|
3
|
+
import { SpecifiedState, StateSpec } from './createSpecifiedState.ts';
|
|
4
|
+
import { ReadonlyClientRepresentation } from './representations.ts';
|
|
5
|
+
|
|
5
6
|
export type CurrentState<Spec extends StateSpec> = ReadonlyClientRepresentation<SpecifiedState<Spec>>;
|
|
6
7
|
export declare const createCurrentState: <Spec extends StateSpec>(scope: ReactiveScope, clientState: ClientState<Spec>) => CurrentState<Spec>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { ReactiveScope } from '../scope.ts';
|
|
2
|
+
import { SpecifiedState, StateSpec } from './createSpecifiedState.ts';
|
|
3
|
+
import { EngineRepresentation } from './representations.ts';
|
|
4
|
+
|
|
4
5
|
export type EngineState<Spec extends StateSpec> = EngineRepresentation<SpecifiedState<Spec>>;
|
|
5
6
|
export declare const createEngineState: <Spec extends StateSpec>(scope: ReactiveScope, spec: Spec) => EngineState<Spec>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import { OpaqueReactiveObjectFactory } from '../../../index.ts';
|
|
2
|
+
import { ReactiveScope } from '../scope.ts';
|
|
3
|
+
import { ClientState, SpecifiedClientStateFactory } from './createClientState.ts';
|
|
4
|
+
import { CurrentState } from './createCurrentState.ts';
|
|
5
|
+
import { EngineState } from './createEngineState.ts';
|
|
6
|
+
import { MutablePropertySpec, SpecifiedState, StateSpec } from './createSpecifiedState.ts';
|
|
7
|
+
|
|
7
8
|
type MutableKeyOf<Spec extends StateSpec> = {
|
|
8
9
|
[K in string & keyof Spec]: Spec[K] extends MutablePropertySpec<any> ? K : never;
|
|
9
10
|
}[string & keyof Spec];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { StatePropertySpec } from './createSpecifiedState.ts';
|
|
2
|
+
|
|
2
3
|
export interface SpecifiedPropertyDescriptor<T = any> extends TypedPropertyDescriptor<T> {
|
|
3
4
|
readonly configurable: true;
|
|
4
5
|
readonly enumerable: true;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { Accessor, Signal } from 'solid-js';
|
|
2
|
+
import { SimpleAtomicState } from '../types.ts';
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* Specifies a state object's property as mutable. Basic usage:
|
|
5
6
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ShallowMutable } from '../../../../../common/types/helpers.js';
|
|
2
|
+
|
|
2
3
|
declare const ENGINE_REPRESENTATION: unique symbol;
|
|
3
4
|
type ENGINE_REPRESENTATION = typeof ENGINE_REPRESENTATION;
|
|
4
5
|
declare const INTERNAL_CLIENT_REPRESENTATION: unique symbol;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Accessor } from 'solid-js';
|
|
2
|
+
import { EvaluationContext } from '../../../instance/internal-api/EvaluationContext.ts';
|
|
3
3
|
import { TextRange } from '../../../instance/text/TextRange.ts';
|
|
4
|
-
import
|
|
4
|
+
import { ValueNodeDefinition } from '../../../model/ValueNodeDefinition.ts';
|
|
5
|
+
|
|
5
6
|
export declare const createFieldHint: (context: EvaluationContext, definition: ValueNodeDefinition) => Accessor<TextRange<'hint'> | null>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Accessor } from 'solid-js';
|
|
2
|
+
import { EvaluationContext } from '../../../instance/internal-api/EvaluationContext.ts';
|
|
3
3
|
import { TextRange } from '../../../instance/text/TextRange.ts';
|
|
4
|
-
import
|
|
4
|
+
import { AnyNodeDefinition } from '../../../model/NodeDefinition.ts';
|
|
5
|
+
|
|
5
6
|
export declare const createNodeLabel: (context: EvaluationContext, definition: AnyNodeDefinition) => Accessor<TextRange<'label'> | null>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { TextRange,
|
|
1
|
+
import { Accessor } from 'solid-js';
|
|
2
|
+
import { TextElementDefinition } from '../../../body/text/TextElementDefinition.ts';
|
|
3
|
+
import { EvaluationContext } from '../../../instance/internal-api/EvaluationContext.ts';
|
|
4
|
+
import { TextRange, TextRole } from '../../../instance/text/TextRange.ts';
|
|
5
|
+
|
|
5
6
|
interface CreateTextRangeOptions<FallbackValue extends string | null> {
|
|
6
7
|
readonly fallbackValue?: FallbackValue;
|
|
7
8
|
}
|
|
@@ -15,5 +16,5 @@ type ComputedTextRange<Role extends TextRole, Definition extends TextElementDefi
|
|
|
15
16
|
*
|
|
16
17
|
* @todo This does not yet handle itext translations **with** outputs!
|
|
17
18
|
*/
|
|
18
|
-
export declare const createTextRange: <Role extends TextRole, Definition extends TextElementDefinition<Role> | null, FallbackValue extends string | null = null>(context: EvaluationContext, role: Role, definition: Definition, options?: CreateTextRangeOptions<FallbackValue>
|
|
19
|
+
export declare const createTextRange: <Role extends TextRole, Definition extends TextElementDefinition<Role> | null, FallbackValue extends string | null = null>(context: EvaluationContext, role: Role, definition: Definition, options?: CreateTextRangeOptions<FallbackValue>) => ComputedTextRange<Role, Definition, FallbackValue>;
|
|
19
20
|
export {};
|