@getodk/xforms-engine 0.16.1 → 0.17.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/client/InputNode.d.ts +8 -4
- package/dist/client/MarkdownNode.d.ts +3 -0
- package/dist/client/NoteNode.d.ts +6 -2
- package/dist/client/form/FormInstanceConfig.d.ts +4 -0
- package/dist/client/form/LoadFormResult.d.ts +5 -14
- package/dist/client/form/ResetFormInstance.d.ts +13 -0
- package/dist/entrypoints/FormResult/BaseFormResult.d.ts +1 -0
- package/dist/entrypoints/FormResult/BaseInstantiableFormResult.d.ts +2 -0
- package/dist/entrypoints/FormResult/FormFailureResult.d.ts +2 -0
- package/dist/entrypoints/createPotentiallyClientOwnedReactiveScope.d.ts +19 -0
- package/dist/index.js +21681 -25500
- package/dist/index.js.map +1 -1
- package/dist/instance/PrimaryInstance.d.ts +4 -1
- package/dist/instance/internal-api/AttributeContext.d.ts +1 -0
- package/dist/instance/internal-api/InstanceConfig.d.ts +2 -1
- package/dist/instance/internal-api/InstanceValueContext.d.ts +1 -0
- package/dist/instance/markdown/MarkdownNode.d.ts +14 -9
- package/dist/integration/xpath/static-dom/StaticDocument.d.ts +2 -0
- package/dist/lib/codecs/{Geopoint/Geopoint.d.ts → geolocation/Geolocation.d.ts} +11 -15
- package/dist/lib/codecs/geolocation/Geopoint.d.ts +7 -0
- package/dist/lib/codecs/geolocation/Geoshape.d.ts +7 -0
- package/dist/lib/codecs/geolocation/Geotrace.d.ts +7 -0
- package/dist/lib/codecs/geolocation/createGeolocationValueCodec.d.ts +3 -0
- package/dist/lib/codecs/getSharedValueCodec.d.ts +7 -5
- package/dist/lib/reactivity/text/createTextRange.d.ts +0 -2
- package/dist/parse/XFormDOM.d.ts +7 -1
- package/dist/parse/body/appearance/inputAppearanceParser.d.ts +1 -1
- package/dist/parse/model/ActionDefinition.d.ts +1 -1
- package/dist/parse/model/BindPreloadDefinition.d.ts +2 -1
- package/dist/parse/model/ModelActionMap.d.ts +3 -2
- package/dist/parse/model/ModelDefinition.d.ts +3 -5
- package/dist/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.d.ts +0 -17
- package/dist/parse/model/SecondaryInstance/sources/external-instance-csv-parser.d.ts +8 -0
- package/dist/parse/model/TranslationDefinitionMap.d.ts +4 -0
- package/dist/solid.js +21407 -25226
- package/dist/solid.js.map +1 -1
- package/package.json +2 -2
- package/src/client/InputNode.ts +11 -3
- package/src/client/MarkdownNode.ts +3 -0
- package/src/client/NoteNode.ts +9 -1
- package/src/client/form/FormInstanceConfig.ts +6 -0
- package/src/client/form/LoadFormResult.ts +5 -17
- package/src/client/form/ResetFormInstance.ts +17 -0
- package/src/entrypoints/FormInstance.ts +2 -0
- package/src/entrypoints/FormResult/BaseFormResult.ts +1 -0
- package/src/entrypoints/FormResult/BaseInstantiableFormResult.ts +10 -1
- package/src/entrypoints/FormResult/FormFailureResult.ts +3 -0
- package/src/entrypoints/createPotentiallyClientOwnedReactiveScope.ts +30 -0
- package/src/entrypoints/loadForm.ts +1 -31
- package/src/instance/InputControl.ts +3 -5
- package/src/instance/PrimaryInstance.ts +17 -2
- package/src/instance/attachments/buildAttributes.ts +21 -1
- package/src/instance/internal-api/AttributeContext.ts +1 -0
- package/src/instance/internal-api/InstanceConfig.ts +3 -0
- package/src/instance/internal-api/InstanceValueContext.ts +1 -0
- package/src/instance/markdown/MarkdownNode.ts +19 -7
- package/src/instance/text/markdownFormat.ts +4 -3
- package/src/integration/xpath/static-dom/StaticDocument.ts +2 -0
- package/src/lib/codecs/{Geopoint/Geopoint.ts → geolocation/Geolocation.ts} +43 -24
- package/src/lib/codecs/geolocation/Geopoint.ts +15 -0
- package/src/lib/codecs/geolocation/Geoshape.ts +36 -0
- package/src/lib/codecs/geolocation/Geotrace.ts +36 -0
- package/src/lib/codecs/geolocation/createGeolocationValueCodec.ts +18 -0
- package/src/lib/codecs/getSharedValueCodec.ts +37 -11
- package/src/lib/reactivity/createInstanceValueState.ts +64 -34
- package/src/lib/reactivity/text/createTextRange.ts +71 -45
- package/src/parse/XFormDOM.ts +22 -2
- package/src/parse/model/ActionDefinition.ts +6 -6
- package/src/parse/model/BindDefinition.ts +1 -1
- package/src/parse/model/BindPreloadDefinition.ts +21 -14
- package/src/parse/model/ModelActionMap.ts +30 -13
- package/src/parse/model/ModelDefinition.ts +5 -10
- package/src/parse/model/RootDefinition.ts +2 -1
- package/src/parse/model/SecondaryInstance/sources/CSVExternalSecondaryInstance.ts +2 -184
- package/src/parse/model/SecondaryInstance/sources/external-instance-csv-parser.ts +185 -0
- package/src/parse/model/TranslationDefinitionMap.ts +23 -0
- package/dist/lib/codecs/Geopoint/GeopointValueCodec.d.ts +0 -5
- package/dist/parse/model/generateItextChunks.d.ts +0 -5
- package/src/lib/codecs/Geopoint/GeopointValueCodec.ts +0 -20
- package/src/parse/model/generateItextChunks.ts +0 -61
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { DOMItextTranslationElement } from '../XFormDOM.ts';
|
|
2
|
+
|
|
3
|
+
const generateChunksForLanguage = (
|
|
4
|
+
translationElement: DOMItextTranslationElement
|
|
5
|
+
): Map<string, Element> => {
|
|
6
|
+
return new Map(
|
|
7
|
+
Array.from(translationElement.children).map((textElement) => {
|
|
8
|
+
const itextId = textElement.getAttribute('id');
|
|
9
|
+
return [itextId!, textElement] as const;
|
|
10
|
+
})
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export class TranslationDefinitionMap extends Map<string, Map<string, Element>> {
|
|
15
|
+
constructor(translationElements: readonly DOMItextTranslationElement[]) {
|
|
16
|
+
super(
|
|
17
|
+
translationElements.map((translationElement) => {
|
|
18
|
+
const lang = translationElement.getAttribute('lang');
|
|
19
|
+
return [lang, generateChunksForLanguage(translationElement)] as const;
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { TextChunkExpression } from '../expression/TextChunkExpression.ts';
|
|
2
|
-
import { DOMItextTranslationElement } from '../XFormDOM.ts';
|
|
3
|
-
export interface ChunkExpressionsByItextId extends Map<string, ReadonlyArray<TextChunkExpression<'string'>>> {
|
|
4
|
-
}
|
|
5
|
-
export declare const generateItextChunks: (translationElements: readonly DOMItextTranslationElement[]) => Map<string, ChunkExpressionsByItextId>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type CodecDecoder, type CodecEncoder, ValueCodec } from '../ValueCodec.ts';
|
|
2
|
-
import { Geopoint, type GeopointInputValue, type GeopointRuntimeValue } from './Geopoint.ts';
|
|
3
|
-
|
|
4
|
-
export class GeopointValueCodec extends ValueCodec<
|
|
5
|
-
'geopoint',
|
|
6
|
-
GeopointRuntimeValue,
|
|
7
|
-
GeopointInputValue
|
|
8
|
-
> {
|
|
9
|
-
constructor() {
|
|
10
|
-
const encodeValue: CodecEncoder<GeopointInputValue> = (value) => {
|
|
11
|
-
return Geopoint.toCoordinatesString(value);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const decodeValue: CodecDecoder<GeopointRuntimeValue> = (value: string) => {
|
|
15
|
-
return Geopoint.parseString(value);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
super('geopoint', encodeValue, decodeValue);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isResourceType,
|
|
3
|
-
type JRResourceURLString,
|
|
4
|
-
type ResourceType,
|
|
5
|
-
} from '@getodk/common/jr-resources/JRResourceURL.ts';
|
|
6
|
-
import { isElementNode, isTextNode } from '@getodk/common/lib/dom/predicates.ts';
|
|
7
|
-
import { TextChunkExpression } from '../expression/TextChunkExpression.ts';
|
|
8
|
-
import type { DOMItextTranslationElement } from '../XFormDOM.ts';
|
|
9
|
-
|
|
10
|
-
const generateChunk = (node: Node): TextChunkExpression<'string'> | null => {
|
|
11
|
-
if (isElementNode(node)) {
|
|
12
|
-
return TextChunkExpression.fromOutput(node);
|
|
13
|
-
}
|
|
14
|
-
if (isTextNode(node)) {
|
|
15
|
-
const formAttribute = node.parentElement!.getAttribute('form') as ResourceType;
|
|
16
|
-
if (isResourceType(formAttribute)) {
|
|
17
|
-
return TextChunkExpression.fromResource(node.data as JRResourceURLString, formAttribute);
|
|
18
|
-
}
|
|
19
|
-
return TextChunkExpression.fromLiteral(node.data);
|
|
20
|
-
}
|
|
21
|
-
return null;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const generateChunksForValues = (valueElement: ChildNode): Array<TextChunkExpression<'string'>> => {
|
|
25
|
-
return Array.from(valueElement.childNodes)
|
|
26
|
-
.map((node) => generateChunk(node))
|
|
27
|
-
.filter((chunk) => chunk !== null);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const generateChunksForTranslation = (
|
|
31
|
-
textElement: Element
|
|
32
|
-
): Array<TextChunkExpression<'string'>> => {
|
|
33
|
-
return Array.from(textElement.childNodes).flatMap((valueElement) =>
|
|
34
|
-
generateChunksForValues(valueElement)
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const generateChunksForLanguage = (
|
|
39
|
-
translationElement: DOMItextTranslationElement
|
|
40
|
-
): Map<string, ReadonlyArray<TextChunkExpression<'string'>>> => {
|
|
41
|
-
return new Map(
|
|
42
|
-
Array.from(translationElement.children).map((textElement) => {
|
|
43
|
-
const itextId = textElement.getAttribute('id');
|
|
44
|
-
return [itextId!, generateChunksForTranslation(textElement)] as const;
|
|
45
|
-
})
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export interface ChunkExpressionsByItextId
|
|
50
|
-
extends Map<string, ReadonlyArray<TextChunkExpression<'string'>>> {}
|
|
51
|
-
|
|
52
|
-
export const generateItextChunks = (
|
|
53
|
-
translationElements: readonly DOMItextTranslationElement[]
|
|
54
|
-
): Map<string, ChunkExpressionsByItextId> => {
|
|
55
|
-
return new Map(
|
|
56
|
-
translationElements.map((translationElement) => {
|
|
57
|
-
const lang = translationElement.getAttribute('lang');
|
|
58
|
-
return [lang, generateChunksForLanguage(translationElement)] as const;
|
|
59
|
-
})
|
|
60
|
-
);
|
|
61
|
-
};
|