@getodk/xforms-engine 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/client/InputNode.d.ts +4 -2
  2. package/dist/client/NoteNode.d.ts +4 -2
  3. package/dist/client/SelectNode.d.ts +1 -0
  4. package/dist/client/TextRange.d.ts +4 -0
  5. package/dist/index.js +14474 -28463
  6. package/dist/index.js.map +1 -1
  7. package/dist/instance/SelectControl.d.ts +1 -0
  8. package/dist/instance/text/TextRange.d.ts +11 -1
  9. package/dist/integration/xpath/adapter/traversal.d.ts +2 -2
  10. package/dist/lib/codecs/DateValueCodec.d.ts +7 -0
  11. package/dist/lib/codecs/getSharedValueCodec.d.ts +3 -2
  12. package/dist/lib/reactivity/text/createTextRange.d.ts +1 -2
  13. package/dist/parse/expression/TextChunkExpression.d.ts +16 -0
  14. package/dist/parse/text/ItemsetLabelDefinition.d.ts +2 -4
  15. package/dist/parse/text/MessageDefinition.d.ts +3 -7
  16. package/dist/parse/text/abstract/TextElementDefinition.d.ts +2 -8
  17. package/dist/parse/text/abstract/TextRangeDefinition.d.ts +2 -2
  18. package/dist/solid.js +14474 -28463
  19. package/dist/solid.js.map +1 -1
  20. package/package.json +4 -3
  21. package/src/client/InputNode.ts +4 -0
  22. package/src/client/NoteNode.ts +4 -0
  23. package/src/client/SelectNode.ts +2 -0
  24. package/src/client/TextRange.ts +5 -1
  25. package/src/instance/SelectControl.ts +6 -0
  26. package/src/instance/text/TextRange.ts +21 -1
  27. package/src/integration/xpath/adapter/traversal.ts +4 -2
  28. package/src/lib/codecs/DateValueCodec.ts +94 -0
  29. package/src/lib/codecs/getSharedValueCodec.ts +5 -3
  30. package/src/lib/reactivity/text/createTextRange.ts +56 -43
  31. package/src/lib/reactivity/validation/createValidation.ts +1 -3
  32. package/src/parse/expression/TextChunkExpression.ts +78 -0
  33. package/src/parse/text/ItemsetLabelDefinition.ts +8 -12
  34. package/src/parse/text/MessageDefinition.ts +9 -16
  35. package/src/parse/text/abstract/TextElementDefinition.ts +10 -26
  36. package/src/parse/text/abstract/TextRangeDefinition.ts +2 -2
  37. package/src/parse/xpath/semantic-analysis.ts +7 -2
  38. package/dist/parse/expression/TextLiteralExpression.d.ts +0 -9
  39. package/dist/parse/expression/TextOutputExpression.d.ts +0 -7
  40. package/dist/parse/expression/TextReferenceExpression.d.ts +0 -7
  41. package/dist/parse/expression/TextTranslationExpression.d.ts +0 -8
  42. package/dist/parse/expression/abstract/TextChunkExpression.d.ts +0 -17
  43. package/src/parse/expression/TextLiteralExpression.ts +0 -19
  44. package/src/parse/expression/TextOutputExpression.ts +0 -25
  45. package/src/parse/expression/TextReferenceExpression.ts +0 -14
  46. package/src/parse/expression/TextTranslationExpression.ts +0 -38
  47. package/src/parse/expression/abstract/TextChunkExpression.ts +0 -38
@@ -22,6 +22,7 @@ interface SelectControlStateSpec extends ValueNodeStateSpec<readonly string[]> {
22
22
  readonly label: Accessor<TextRange<'label'> | null>;
23
23
  readonly hint: Accessor<TextRange<'hint'> | null>;
24
24
  readonly valueOptions: Accessor<SelectValueOptions>;
25
+ readonly isSelectWithImages: Accessor<boolean>;
25
26
  }
26
27
  export declare class SelectControl extends ValueNode<'string', SelectDefinition<'string'>, readonly string[], readonly string[]> implements SelectNode, XFormsXPathElement, EvaluationContext, ValidationContext, ClientReactiveSerializableValueNode {
27
28
  static from(parent: GeneralParentNode, instanceNode: StaticLeafElement | null, definition: SelectDefinition): SelectControl;
@@ -1,10 +1,20 @@
1
+ import { JRResourceURL } from '../../../../common/src/jr-resources/JRResourceURL.ts';
1
2
  import { TextRange as ClientTextRange, TextChunk, TextOrigin, TextRole } from '../../client/TextRange.ts';
3
+ export interface MediaSources {
4
+ image?: JRResourceURL;
5
+ video?: JRResourceURL;
6
+ audio?: JRResourceURL;
7
+ }
2
8
  export declare class TextRange<Role extends TextRole, Origin extends TextOrigin> implements ClientTextRange<Role, Origin> {
3
9
  readonly origin: Origin;
4
10
  readonly role: Role;
5
11
  protected readonly chunks: readonly TextChunk[];
12
+ protected readonly mediaSources?: MediaSources | undefined;
6
13
  [Symbol.iterator](): Generator<TextChunk, void, unknown>;
7
14
  get formatted(): Record<PropertyKey, unknown>;
8
15
  get asString(): string;
9
- constructor(origin: Origin, role: Role, chunks: readonly TextChunk[]);
16
+ get imageSource(): JRResourceURL | undefined;
17
+ get audioSource(): JRResourceURL | undefined;
18
+ get videoSource(): JRResourceURL | undefined;
19
+ constructor(origin: Origin, role: Role, chunks: readonly TextChunk[], mediaSources?: MediaSources | undefined);
10
20
  }
@@ -1,6 +1,6 @@
1
1
  import { EngineXPathAttribute, EngineXPathDocument, EngineXPathElement, EngineXPathNode, EngineXPathParentNode, XFormsXPathChildNode } from './kind.ts';
2
2
  export declare const getContainingEngineXPathDocument: (node: EngineXPathNode) => EngineXPathDocument;
3
- export declare const getEngineXPathAttributes: (node: EngineXPathNode) => Iterable<EngineXPathAttribute>;
3
+ export declare const getEngineXPathAttributes: (node: EngineXPathNode) => readonly EngineXPathAttribute[];
4
4
  /**
5
5
  * @todo We've now laid most of the groundwork necessary to implement this
6
6
  * properly. At time of writing it has still been deferred because:
@@ -14,7 +14,7 @@ export declare const getEngineXPathAttributes: (node: EngineXPathNode) => Iterab
14
14
  * it throw? It might be nice to be alerted if the assumptions in point 2 above
15
15
  * are somehow wrong (or become wrong).
16
16
  */
17
- export declare const getNamespaceDeclarations: () => Iterable<never>;
17
+ export declare const getNamespaceDeclarations: () => readonly [];
18
18
  export declare const getParentNode: (node: EngineXPathNode) => EngineXPathParentNode | null;
19
19
  export declare const getChildNodes: (node: EngineXPathNode) => readonly XFormsXPathChildNode[];
20
20
  export declare const getChildElements: (node: EngineXPathNode) => readonly EngineXPathElement[];
@@ -0,0 +1,7 @@
1
+ import { Temporal } from 'temporal-polyfill';
2
+ import { ValueCodec } from './ValueCodec.ts';
3
+ export type DatetimeRuntimeValue = Temporal.PlainDate | null;
4
+ export type DatetimeInputValue = Date | Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime | string | null;
5
+ export declare class DateValueCodec extends ValueCodec<'date', DatetimeRuntimeValue, DatetimeInputValue> {
6
+ constructor();
7
+ }
@@ -1,4 +1,5 @@
1
1
  import { ValueType } from '../../client/ValueType.ts';
2
+ import { DatetimeInputValue, DatetimeRuntimeValue } from './DateValueCodec.ts';
2
3
  import { DecimalInputValue, DecimalRuntimeValue } from './DecimalValueCodec.ts';
3
4
  import { GeopointInputValue, GeopointRuntimeValue } from './Geopoint/Geopoint.ts';
4
5
  import { IntInputValue, IntRuntimeValue } from './IntValueCodec.ts';
@@ -8,7 +9,7 @@ interface RuntimeValuesByType {
8
9
  readonly int: IntRuntimeValue;
9
10
  readonly decimal: DecimalRuntimeValue;
10
11
  readonly boolean: string;
11
- readonly date: string;
12
+ readonly date: DatetimeRuntimeValue;
12
13
  readonly time: string;
13
14
  readonly dateTime: string;
14
15
  readonly geopoint: GeopointRuntimeValue;
@@ -24,7 +25,7 @@ interface RuntimeInputValuesByType {
24
25
  readonly int: IntInputValue;
25
26
  readonly decimal: DecimalInputValue;
26
27
  readonly boolean: string;
27
- readonly date: string;
28
+ readonly date: DatetimeInputValue;
28
29
  readonly time: string;
29
30
  readonly dateTime: string;
30
31
  readonly geopoint: GeopointInputValue;
@@ -5,8 +5,7 @@ import { TextRange } from '../../../instance/text/TextRange.ts';
5
5
  import { TextRangeDefinition } from '../../../parse/text/abstract/TextRangeDefinition.ts';
6
6
  type ComputedFormTextRange<Role extends TextRole> = Accessor<TextRange<Role, 'form'>>;
7
7
  /**
8
- * Creates a text range (e.g. label or hint) from the provided definition,
9
- * reactive to:
8
+ * Creates a text range (e.g. label or hint) from the provided definition, reactive to:
10
9
  *
11
10
  * - The form's current language (e.g. `<label ref="jr:itext('text-id')" />`)
12
11
  * - Direct `<output>` references within the label's children
@@ -0,0 +1,16 @@
1
+ import { TextChunkSource } from '../../client/TextRange.ts';
2
+ import { AnyTextRangeDefinition } from '../text/abstract/TextRangeDefinition.ts';
3
+ import { DependentExpression } from './abstract/DependentExpression.ts';
4
+ interface TextChunkExpressionOptions {
5
+ readonly isTranslated?: true;
6
+ }
7
+ export declare class TextChunkExpression<T extends 'nodes' | 'string'> extends DependentExpression<T> {
8
+ readonly source: TextChunkSource;
9
+ readonly stringValue: string;
10
+ constructor(context: AnyTextRangeDefinition, resultType: T, expression: string, source: TextChunkSource, options?: TextChunkExpressionOptions, literalValue?: string);
11
+ static fromLiteral(context: AnyTextRangeDefinition, stringValue: string): TextChunkExpression<'string'>;
12
+ static fromReference(context: AnyTextRangeDefinition, ref: string): TextChunkExpression<'string'>;
13
+ static fromOutput(context: AnyTextRangeDefinition, element: Element): TextChunkExpression<'string'> | null;
14
+ static fromTranslation(context: AnyTextRangeDefinition, maybeExpression: string): TextChunkExpression<'nodes'> | null;
15
+ }
16
+ export {};
@@ -1,12 +1,10 @@
1
1
  import { XFormDefinition } from '../../parse/XFormDefinition.ts';
2
- import { ItemDefinition } from '../body/control/ItemDefinition.ts';
3
2
  import { ItemsetDefinition } from '../body/control/ItemsetDefinition.ts';
4
- import { RefAttributeChunk } from './abstract/TextElementDefinition.ts';
3
+ import { TextChunkExpression } from '../expression/TextChunkExpression.ts';
5
4
  import { TextRangeDefinition } from './abstract/TextRangeDefinition.ts';
6
- export type ItemLabelOwner = ItemDefinition | ItemsetDefinition;
7
5
  export declare class ItemsetLabelDefinition extends TextRangeDefinition<'item-label'> {
8
6
  static from(form: XFormDefinition, owner: ItemsetDefinition): ItemsetLabelDefinition | null;
9
7
  readonly role = "item-label";
10
- readonly chunks: readonly [RefAttributeChunk];
8
+ readonly chunks: ReadonlyArray<TextChunkExpression<'nodes' | 'string'>>;
11
9
  private constructor();
12
10
  }
@@ -1,14 +1,10 @@
1
- import { TextLiteralExpression } from '../expression/TextLiteralExpression.ts';
2
- import { TextTranslationExpression } from '../expression/TextTranslationExpression.ts';
1
+ import { TextChunkExpression } from '../expression/TextChunkExpression.ts';
3
2
  import { BindDefinition } from '../model/BindDefinition.ts';
4
- import { TextBindAttributeLocalName, TextSourceNode, TextRangeDefinition } from './abstract/TextRangeDefinition.ts';
5
- export type MessageSourceNode = TextSourceNode<TextBindAttributeLocalName>;
6
- type MessageChunk = TextLiteralExpression | TextTranslationExpression;
3
+ import { TextBindAttributeLocalName, TextRangeDefinition } from './abstract/TextRangeDefinition.ts';
7
4
  export declare class MessageDefinition<Type extends TextBindAttributeLocalName> extends TextRangeDefinition<Type> {
8
5
  readonly role: Type;
9
6
  static from<Type extends TextBindAttributeLocalName>(bind: BindDefinition, type: Type): MessageDefinition<Type> | null;
10
- readonly chunks: readonly [MessageChunk];
7
+ readonly chunks: ReadonlyArray<TextChunkExpression<'nodes' | 'string'>>;
11
8
  private constructor();
12
9
  }
13
10
  export type AnyMessageDefinition = MessageDefinition<TextBindAttributeLocalName>;
14
- export {};
@@ -1,21 +1,15 @@
1
1
  import { ElementTextRole } from '../../../client/TextRange.ts';
2
2
  import { XFormDefinition } from '../../../parse/XFormDefinition.ts';
3
3
  import { ItemDefinition } from '../../body/control/ItemDefinition.ts';
4
- import { TextLiteralExpression } from '../../expression/TextLiteralExpression.ts';
5
- import { TextOutputExpression } from '../../expression/TextOutputExpression.ts';
6
- import { TextReferenceExpression } from '../../expression/TextReferenceExpression.ts';
7
- import { TextTranslationExpression } from '../../expression/TextTranslationExpression.ts';
4
+ import { TextChunkExpression } from '../../expression/TextChunkExpression.ts';
8
5
  import { HintDefinition } from '../HintDefinition.ts';
9
6
  import { ItemLabelDefinition } from '../ItemLabelDefinition.ts';
10
7
  import { ItemsetLabelDefinition } from '../ItemsetLabelDefinition.ts';
11
8
  import { LabelDefinition, LabelOwner } from '../LabelDefinition.ts';
12
9
  import { TextSourceNode, TextRangeDefinition } from './TextRangeDefinition.ts';
13
- export type RefAttributeChunk = TextReferenceExpression | TextTranslationExpression;
14
- type TextElementChildChunk = TextOutputExpression | TextLiteralExpression;
15
- type TextElementChunks = readonly [RefAttributeChunk] | readonly TextElementChildChunk[];
16
10
  type TextElementOwner = ItemDefinition | LabelOwner;
17
11
  export declare abstract class TextElementDefinition<Role extends ElementTextRole> extends TextRangeDefinition<Role> {
18
- readonly chunks: TextElementChunks;
12
+ readonly chunks: ReadonlyArray<TextChunkExpression<'nodes' | 'string'>>;
19
13
  constructor(form: XFormDefinition, owner: TextElementOwner, sourceNode: TextSourceNode<Role>);
20
14
  }
21
15
  export type AnyTextElementDefinition = HintDefinition | ItemLabelDefinition | ItemsetLabelDefinition | LabelDefinition;
@@ -2,7 +2,7 @@ import { LocalNamedElement } from '../../../../../common/types/dom.ts';
2
2
  import { TextRole } from '../../../client/TextRange.ts';
3
3
  import { XFormDefinition } from '../../../parse/XFormDefinition.ts';
4
4
  import { DependencyContext } from '../../expression/abstract/DependencyContext.ts';
5
- import { AnyTextChunkExpression } from '../../expression/abstract/TextChunkExpression.ts';
5
+ import { TextChunkExpression } from '../../expression/TextChunkExpression.ts';
6
6
  import { AnyMessageDefinition } from '../MessageDefinition.ts';
7
7
  import { AnyTextElementDefinition } from './TextElementDefinition.ts';
8
8
  export type TextBindAttributeLocalName = 'constraintMsg' | 'requiredMsg';
@@ -22,7 +22,7 @@ export declare abstract class TextRangeDefinition<Role extends TextRole> extends
22
22
  abstract readonly role: Role;
23
23
  readonly parentReference: string | null;
24
24
  readonly reference: string | null;
25
- abstract readonly chunks: readonly AnyTextChunkExpression[];
25
+ abstract readonly chunks: ReadonlyArray<TextChunkExpression<'nodes' | 'string'>>;
26
26
  get isTranslated(): boolean;
27
27
  set isTranslated(value: true);
28
28
  protected constructor(form: XFormDefinition, ownerContext: DependencyContext, sourceNode: TextSourceNode<Role>);