@fieldia/core 0.9.2 → 0.11.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 +199 -0
- package/package.json +1 -1
- package/schema/page.schema.json +1837 -94
- package/src/index.d.mts +1 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +4 -1
- package/src/index.js.map +1 -1
- package/src/index.mjs +1 -0
- package/src/index.mjs.map +1 -1
- package/src/lib/expression/evaluator.d.mts +6 -5
- package/src/lib/expression/evaluator.d.ts +6 -5
- package/src/lib/expression/evaluator.js +37 -22
- package/src/lib/expression/evaluator.js.map +1 -1
- package/src/lib/expression/evaluator.mjs +32 -18
- package/src/lib/expression/evaluator.mjs.map +1 -1
- package/src/lib/expression/expression.d.mts +21 -0
- package/src/lib/expression/expression.d.ts +21 -0
- package/src/lib/expression/expression.js +29 -0
- package/src/lib/expression/expression.js.map +1 -0
- package/src/lib/expression/expression.mjs +26 -0
- package/src/lib/expression/expression.mjs.map +1 -0
- package/src/lib/expression/extractFieldNames.js +6 -1
- package/src/lib/expression/extractFieldNames.js.map +1 -1
- package/src/lib/expression/extractFieldNames.mjs +6 -1
- package/src/lib/expression/extractFieldNames.mjs.map +1 -1
- package/src/lib/expression/functions.d.mts +35 -0
- package/src/lib/expression/functions.d.ts +35 -0
- package/src/lib/expression/functions.js +129 -0
- package/src/lib/expression/functions.js.map +1 -0
- package/src/lib/expression/functions.mjs +124 -0
- package/src/lib/expression/functions.mjs.map +1 -0
- package/src/lib/expression/modifier.d.mts +3 -1
- package/src/lib/expression/modifier.d.ts +3 -1
- package/src/lib/expression/modifier.js +4 -27
- package/src/lib/expression/modifier.js.map +1 -1
- package/src/lib/expression/modifier.mjs +3 -26
- package/src/lib/expression/modifier.mjs.map +1 -1
- package/src/lib/expression/operations.d.mts +25 -0
- package/src/lib/expression/operations.d.ts +25 -0
- package/src/lib/expression/operations.js +81 -0
- package/src/lib/expression/operations.js.map +1 -0
- package/src/lib/expression/operations.mjs +72 -0
- package/src/lib/expression/operations.mjs.map +1 -0
- package/src/lib/expression/order.d.mts +11 -0
- package/src/lib/expression/order.d.ts +11 -0
- package/src/lib/expression/order.js +36 -0
- package/src/lib/expression/order.js.map +1 -0
- package/src/lib/expression/order.mjs +33 -0
- package/src/lib/expression/order.mjs.map +1 -0
- package/src/lib/expression/parser.d.mts +34 -4
- package/src/lib/expression/parser.d.ts +34 -4
- package/src/lib/expression/parser.js +72 -6
- package/src/lib/expression/parser.js.map +1 -1
- package/src/lib/expression/parser.mjs +72 -6
- package/src/lib/expression/parser.mjs.map +1 -1
- package/src/lib/expression/reads.d.mts +8 -0
- package/src/lib/expression/reads.d.ts +8 -0
- package/src/lib/expression/reads.js +48 -0
- package/src/lib/expression/reads.js.map +1 -0
- package/src/lib/expression/reads.mjs +44 -0
- package/src/lib/expression/reads.mjs.map +1 -0
- package/src/lib/expression/tokenizer.d.mts +7 -6
- package/src/lib/expression/tokenizer.d.ts +7 -6
- package/src/lib/expression/tokenizer.js +28 -18
- package/src/lib/expression/tokenizer.js.map +1 -1
- package/src/lib/expression/tokenizer.mjs +28 -18
- package/src/lib/expression/tokenizer.mjs.map +1 -1
- package/src/lib/format/actions.d.mts +692 -0
- package/src/lib/format/actions.d.ts +692 -0
- package/src/lib/format/actions.js +53 -0
- package/src/lib/format/actions.js.map +1 -0
- package/src/lib/format/actions.mjs +50 -0
- package/src/lib/format/actions.mjs.map +1 -0
- package/src/lib/format/field.d.mts +686 -5
- package/src/lib/format/field.d.ts +686 -5
- package/src/lib/format/field.js +117 -13
- package/src/lib/format/field.js.map +1 -1
- package/src/lib/format/field.mjs +116 -12
- package/src/lib/format/field.mjs.map +1 -1
- package/src/lib/format/layout.d.mts +1130 -22
- package/src/lib/format/layout.d.ts +1130 -22
- package/src/lib/format/layout.js +67 -5
- package/src/lib/format/layout.js.map +1 -1
- package/src/lib/format/layout.mjs +66 -4
- package/src/lib/format/layout.mjs.map +1 -1
- package/src/lib/format/layout.types.d.mts +2 -1
- package/src/lib/format/layout.types.d.ts +2 -1
- package/src/lib/format/names.d.mts +1 -1
- package/src/lib/format/names.d.ts +1 -1
- package/src/lib/format/names.js +1 -0
- package/src/lib/format/names.js.map +1 -1
- package/src/lib/format/names.mjs +1 -0
- package/src/lib/format/names.mjs.map +1 -1
- package/src/lib/format/page.d.mts +1007 -7
- package/src/lib/format/page.d.ts +1007 -7
- package/src/lib/format/page.js +28 -0
- package/src/lib/format/page.js.map +1 -1
- package/src/lib/format/page.mjs +28 -0
- package/src/lib/format/page.mjs.map +1 -1
- package/src/lib/format/part-look.d.mts +36 -0
- package/src/lib/format/part-look.d.ts +36 -0
- package/src/lib/format/part-look.js +23 -0
- package/src/lib/format/part-look.js.map +1 -0
- package/src/lib/format/part-look.mjs +20 -0
- package/src/lib/format/part-look.mjs.map +1 -0
- package/src/lib/format/references.d.mts +33 -1
- package/src/lib/format/references.d.ts +33 -1
- package/src/lib/format/references.js +227 -10
- package/src/lib/format/references.js.map +1 -1
- package/src/lib/format/references.mjs +227 -10
- package/src/lib/format/references.mjs.map +1 -1
- package/src/lib/format/translate.d.mts +20 -0
- package/src/lib/format/translate.d.ts +20 -0
- package/src/lib/format/translate.js +79 -21
- package/src/lib/format/translate.js.map +1 -1
- package/src/lib/format/translate.mjs +76 -21
- package/src/lib/format/translate.mjs.map +1 -1
- package/src/lib/record/check.d.mts +19 -1
- package/src/lib/record/check.d.ts +19 -1
- package/src/lib/record/check.js +84 -21
- package/src/lib/record/check.js.map +1 -1
- package/src/lib/record/check.mjs +82 -21
- package/src/lib/record/check.mjs.map +1 -1
- package/src/lib/record/compute.d.mts +24 -0
- package/src/lib/record/compute.d.ts +24 -0
- package/src/lib/record/compute.js +107 -0
- package/src/lib/record/compute.js.map +1 -0
- package/src/lib/record/compute.mjs +103 -0
- package/src/lib/record/compute.mjs.map +1 -0
- package/src/lib/record/data-source.d.mts +14 -2
- package/src/lib/record/data-source.d.ts +14 -2
- package/src/lib/record/data-source.js.map +1 -1
- package/src/lib/record/data-source.mjs.map +1 -1
- package/src/lib/record/env.d.mts +9 -0
- package/src/lib/record/env.d.ts +9 -0
- package/src/lib/record/env.js +28 -0
- package/src/lib/record/env.js.map +1 -0
- package/src/lib/record/env.mjs +25 -0
- package/src/lib/record/env.mjs.map +1 -0
- package/src/lib/record/form.d.mts +110 -18
- package/src/lib/record/form.d.ts +110 -18
- package/src/lib/record/form.js +497 -72
- package/src/lib/record/form.js.map +1 -1
- package/src/lib/record/form.mjs +497 -72
- package/src/lib/record/form.mjs.map +1 -1
- package/src/lib/record/inputs.d.mts +5 -0
- package/src/lib/record/inputs.d.ts +5 -0
- package/src/lib/record/inputs.js +47 -0
- package/src/lib/record/inputs.js.map +1 -0
- package/src/lib/record/inputs.mjs +44 -0
- package/src/lib/record/inputs.mjs.map +1 -0
- package/src/lib/record/limits.d.mts +13 -0
- package/src/lib/record/limits.d.ts +13 -0
- package/src/lib/record/limits.js +45 -0
- package/src/lib/record/limits.js.map +1 -0
- package/src/lib/record/limits.mjs +41 -0
- package/src/lib/record/limits.mjs.map +1 -0
- package/src/lib/record/locales/all.d.mts +7 -0
- package/src/lib/record/locales/all.d.ts +7 -0
- package/src/lib/record/locales/all.js +13 -0
- package/src/lib/record/locales/all.js.map +1 -0
- package/src/lib/record/locales/all.mjs +10 -0
- package/src/lib/record/locales/all.mjs.map +1 -0
- package/src/lib/record/locales/ar.d.mts +3 -0
- package/src/lib/record/locales/ar.d.ts +3 -0
- package/src/lib/record/locales/ar.js +55 -0
- package/src/lib/record/locales/ar.js.map +1 -0
- package/src/lib/record/locales/ar.mjs +52 -0
- package/src/lib/record/locales/ar.mjs.map +1 -0
- package/src/lib/record/locales/de.d.mts +3 -0
- package/src/lib/record/locales/de.d.ts +3 -0
- package/src/lib/record/locales/de.js +55 -0
- package/src/lib/record/locales/de.js.map +1 -0
- package/src/lib/record/locales/de.mjs +52 -0
- package/src/lib/record/locales/de.mjs.map +1 -0
- package/src/lib/record/locales/fr.d.mts +3 -0
- package/src/lib/record/locales/fr.d.ts +3 -0
- package/src/lib/record/locales/fr.js +55 -0
- package/src/lib/record/locales/fr.js.map +1 -0
- package/src/lib/record/locales/fr.mjs +52 -0
- package/src/lib/record/locales/fr.mjs.map +1 -0
- package/src/lib/record/memory-data-source.d.mts +3 -0
- package/src/lib/record/memory-data-source.d.ts +3 -0
- package/src/lib/record/memory-data-source.js +8 -0
- package/src/lib/record/memory-data-source.js.map +1 -1
- package/src/lib/record/memory-data-source.mjs +8 -0
- package/src/lib/record/memory-data-source.mjs.map +1 -1
- package/src/lib/record/messages.d.mts +46 -0
- package/src/lib/record/messages.d.ts +46 -0
- package/src/lib/record/messages.js +58 -101
- package/src/lib/record/messages.js.map +1 -1
- package/src/lib/record/messages.mjs +58 -101
- package/src/lib/record/messages.mjs.map +1 -1
- package/src/lib/record/rules.d.mts +33 -0
- package/src/lib/record/rules.d.ts +33 -0
- package/src/lib/record/rules.js +83 -0
- package/src/lib/record/rules.js.map +1 -0
- package/src/lib/record/rules.mjs +79 -0
- package/src/lib/record/rules.mjs.map +1 -0
- package/src/lib/record/run.d.mts +169 -0
- package/src/lib/record/run.d.ts +169 -0
- package/src/lib/record/run.js +350 -0
- package/src/lib/record/run.js.map +1 -0
- package/src/lib/record/run.mjs +345 -0
- package/src/lib/record/run.mjs.map +1 -0
- package/src/lib/record/score.d.mts +16 -0
- package/src/lib/record/score.d.ts +16 -0
- package/src/lib/record/score.js +35 -0
- package/src/lib/record/score.js.map +1 -0
- package/src/lib/record/score.mjs +32 -0
- package/src/lib/record/score.mjs.map +1 -0
- package/src/lib/record/set-when.d.mts +24 -0
- package/src/lib/record/set-when.d.ts +24 -0
- package/src/lib/record/set-when.js +68 -0
- package/src/lib/record/set-when.js.map +1 -0
- package/src/lib/record/set-when.mjs +65 -0
- package/src/lib/record/set-when.mjs.map +1 -0
- package/src/lib/record/structures.d.mts +14 -0
- package/src/lib/record/structures.d.ts +14 -0
- package/src/lib/record/structures.js +32 -0
- package/src/lib/record/structures.js.map +1 -0
- package/src/lib/record/structures.mjs +28 -0
- package/src/lib/record/structures.mjs.map +1 -0
- package/src/lib/record/values.d.mts +10 -5
- package/src/lib/record/values.d.ts +10 -5
- package/src/lib/record/values.js +20 -6
- package/src/lib/record/values.js.map +1 -1
- package/src/lib/record/values.mjs +19 -6
- package/src/lib/record/values.mjs.map +1 -1
- package/src/runtime.d.mts +13 -7
- package/src/runtime.d.ts +13 -7
- package/src/runtime.js +14 -1
- package/src/runtime.js.map +1 -1
- package/src/runtime.mjs +6 -2
- package/src/runtime.mjs.map +1 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { compileExpression } from '../expression/expression.mjs';
|
|
2
|
+
import { compileModifier } from '../expression/modifier.mjs';
|
|
3
|
+
import { fitTo } from './compute.mjs';
|
|
4
|
+
import { expressionEnv } from './env.mjs';
|
|
5
|
+
import { expressionContext, lineKind, sameValue } from './values.mjs';
|
|
6
|
+
function rules(fields) {
|
|
7
|
+
return Object.entries(fields).flatMap(([name, def]) => (def.setWhen ?? []).map((rule, i) => ({ key: `${name}#${i}`, name, def, when: compileModifier(rule.when), value: compileExpression(rule.value) })));
|
|
8
|
+
}
|
|
9
|
+
/** Before anything was known: every condition counts as holding, so none starts. */
|
|
10
|
+
const EVERYTHING = { has: () => true };
|
|
11
|
+
/** Read every `setWhen` of a page once. `today` is the day `today()` gives. */
|
|
12
|
+
export function compileSetWhen(page, today) {
|
|
13
|
+
const own = rules(page.fields);
|
|
14
|
+
const lineRules = new Map();
|
|
15
|
+
for (const [name, def] of Object.entries(page.fields)) {
|
|
16
|
+
if (def.type !== 'one2many')
|
|
17
|
+
continue;
|
|
18
|
+
const found = rules(def.fields);
|
|
19
|
+
if (found.length)
|
|
20
|
+
lineRules.set(name, { def, rules: found });
|
|
21
|
+
}
|
|
22
|
+
const lineEnv = { today };
|
|
23
|
+
/** One set of values (the record's, or a line's): every rule read against them as they are, before any is set. */
|
|
24
|
+
function run(values, list, fields, env, prefix, before, now) {
|
|
25
|
+
let next = values;
|
|
26
|
+
const context = expressionContext(values, fields);
|
|
27
|
+
for (const rule of list) {
|
|
28
|
+
if (!rule.when.evaluate(context, env))
|
|
29
|
+
continue;
|
|
30
|
+
const key = prefix + rule.key;
|
|
31
|
+
now.add(key);
|
|
32
|
+
if (before.has(key))
|
|
33
|
+
continue;
|
|
34
|
+
const value = fitTo(rule.def, rule.value.evaluate(context, env));
|
|
35
|
+
if (!sameValue(value, next[rule.name]))
|
|
36
|
+
next = { ...next, [rule.name]: value };
|
|
37
|
+
}
|
|
38
|
+
return next;
|
|
39
|
+
}
|
|
40
|
+
function apply(values, before) {
|
|
41
|
+
const now = new Set();
|
|
42
|
+
let next = own.length ? run(values, own, page.fields, expressionEnv(values, page.fields, today), '', before, now) : values;
|
|
43
|
+
for (const [field, { def, rules: list }] of lineRules) {
|
|
44
|
+
const current = values[field];
|
|
45
|
+
if (!Array.isArray(current))
|
|
46
|
+
continue;
|
|
47
|
+
let changed = false;
|
|
48
|
+
const updated = current.map((line) => {
|
|
49
|
+
// A section or a note has nothing to set.
|
|
50
|
+
if (lineKind(def, line.values) !== null)
|
|
51
|
+
return line;
|
|
52
|
+
const set = run(line.values, list, def.fields, lineEnv, `${field}.${line.key}.`, before, now);
|
|
53
|
+
if (set === line.values)
|
|
54
|
+
return line;
|
|
55
|
+
changed = true;
|
|
56
|
+
return { ...line, values: set };
|
|
57
|
+
});
|
|
58
|
+
if (changed)
|
|
59
|
+
next = { ...next, [field]: updated };
|
|
60
|
+
}
|
|
61
|
+
return { values: next, holding: now };
|
|
62
|
+
}
|
|
63
|
+
return { apply, holding: (values) => apply(values, EVERYTHING).holding };
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=set-when.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-when.mjs","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/set-when.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAA+C,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,CAAC;IACxC,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Field } from '../format/field.mjs';
|
|
2
|
+
import type { FieldNode } from '../format/layout.mjs';
|
|
3
|
+
import { type Messages } from './messages.mjs';
|
|
4
|
+
import type { Value } from './values.mjs';
|
|
5
|
+
/**
|
|
6
|
+
* What a structure's widget asks of its answer beyond Required: an address
|
|
7
|
+
* (`json.address`) its parts in `options.requiredParts` filled — the first
|
|
8
|
+
* missing one named — and a table of lines or a repeating group as few lines
|
|
9
|
+
* as `options.min` and as many as `options.max`, once it has any. Undefined
|
|
10
|
+
* when it keeps them, or when there is nothing to check.
|
|
11
|
+
*/
|
|
12
|
+
/** An address's parts, in the order its boxes and its messages name them. */
|
|
13
|
+
export declare const ADDRESS_PARTS: readonly ["street", "line2", "city", "region", "postcode", "country"];
|
|
14
|
+
export declare function checkStructure(field: Field, node: FieldNode, value: Value | undefined, messages: Messages): string | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Field } from '../format/field';
|
|
2
|
+
import type { FieldNode } from '../format/layout';
|
|
3
|
+
import { type Messages } from './messages';
|
|
4
|
+
import type { Value } from './values';
|
|
5
|
+
/**
|
|
6
|
+
* What a structure's widget asks of its answer beyond Required: an address
|
|
7
|
+
* (`json.address`) its parts in `options.requiredParts` filled — the first
|
|
8
|
+
* missing one named — and a table of lines or a repeating group as few lines
|
|
9
|
+
* as `options.min` and as many as `options.max`, once it has any. Undefined
|
|
10
|
+
* when it keeps them, or when there is nothing to check.
|
|
11
|
+
*/
|
|
12
|
+
/** An address's parts, in the order its boxes and its messages name them. */
|
|
13
|
+
export declare const ADDRESS_PARTS: readonly ["street", "line2", "city", "region", "postcode", "country"];
|
|
14
|
+
export declare function checkStructure(field: Field, node: FieldNode, value: Value | undefined, messages: Messages): string | undefined;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ADDRESS_PARTS = void 0;
|
|
4
|
+
exports.checkStructure = checkStructure;
|
|
5
|
+
const messages_1 = require("./messages");
|
|
6
|
+
/**
|
|
7
|
+
* What a structure's widget asks of its answer beyond Required: an address
|
|
8
|
+
* (`json.address`) its parts in `options.requiredParts` filled — the first
|
|
9
|
+
* missing one named — and a table of lines or a repeating group as few lines
|
|
10
|
+
* as `options.min` and as many as `options.max`, once it has any. Undefined
|
|
11
|
+
* when it keeps them, or when there is nothing to check.
|
|
12
|
+
*/
|
|
13
|
+
/** An address's parts, in the order its boxes and its messages name them. */
|
|
14
|
+
exports.ADDRESS_PARTS = ['street', 'line2', 'city', 'region', 'postcode', 'country'];
|
|
15
|
+
function checkStructure(field, node, value, messages) {
|
|
16
|
+
const options = node.options ?? {};
|
|
17
|
+
const label = node.label ?? field.label;
|
|
18
|
+
if (field.type === 'one2many' && Array.isArray(value) && value.length) {
|
|
19
|
+
if (typeof options['min'] === 'number' && value.length < options['min'])
|
|
20
|
+
return (0, messages_1.fill)(messages.minLines, { label, min: options['min'] });
|
|
21
|
+
if (typeof options['max'] === 'number' && value.length > options['max'])
|
|
22
|
+
return (0, messages_1.fill)(messages.maxLines, { label, max: options['max'] });
|
|
23
|
+
}
|
|
24
|
+
const needed = options['requiredParts'];
|
|
25
|
+
if (node.widget !== 'address' || !Array.isArray(needed) || !value || typeof value !== 'object' || Array.isArray(value))
|
|
26
|
+
return undefined;
|
|
27
|
+
const asked = Array.isArray(options['parts']) ? options['parts'] : exports.ADDRESS_PARTS;
|
|
28
|
+
const parts = value;
|
|
29
|
+
const missing = exports.ADDRESS_PARTS.findIndex((part) => needed.includes(part) && asked.includes(part) && !String(parts[part] ?? '').trim());
|
|
30
|
+
return missing < 0 ? undefined : (0, messages_1.fill)(messages.required, { label: messages.addressParts.split('|')[missing] });
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=structures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structures.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/structures.ts"],"names":[],"mappings":";;;AAgBA,wCAaC;AA3BD,yCAAiD;AAGjD;;;;;;GAMG;AAEH,6EAA6E;AAChE,QAAA,aAAa,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAU,CAAC;AAEnG,SAAgB,cAAc,CAAC,KAAY,EAAE,IAAe,EAAE,KAAwB,EAAE,QAAkB;IACxG,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;IACnC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC;IACxC,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QACtE,IAAI,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;YAAE,OAAO,IAAA,eAAI,EAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACxI,IAAI,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;YAAE,OAAO,IAAA,eAAI,EAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC1I,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IACxC,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACzI,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,qBAAa,CAAC;IACjF,MAAM,KAAK,GAAG,KAAgC,CAAC;IAC/C,MAAM,OAAO,GAAG,qBAAa,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACtI,OAAO,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,eAAI,EAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AACjH,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { fill } from './messages.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* What a structure's widget asks of its answer beyond Required: an address
|
|
4
|
+
* (`json.address`) its parts in `options.requiredParts` filled — the first
|
|
5
|
+
* missing one named — and a table of lines or a repeating group as few lines
|
|
6
|
+
* as `options.min` and as many as `options.max`, once it has any. Undefined
|
|
7
|
+
* when it keeps them, or when there is nothing to check.
|
|
8
|
+
*/
|
|
9
|
+
/** An address's parts, in the order its boxes and its messages name them. */
|
|
10
|
+
export const ADDRESS_PARTS = ['street', 'line2', 'city', 'region', 'postcode', 'country'];
|
|
11
|
+
export function checkStructure(field, node, value, messages) {
|
|
12
|
+
const options = node.options ?? {};
|
|
13
|
+
const label = node.label ?? field.label;
|
|
14
|
+
if (field.type === 'one2many' && Array.isArray(value) && value.length) {
|
|
15
|
+
if (typeof options['min'] === 'number' && value.length < options['min'])
|
|
16
|
+
return fill(messages.minLines, { label, min: options['min'] });
|
|
17
|
+
if (typeof options['max'] === 'number' && value.length > options['max'])
|
|
18
|
+
return fill(messages.maxLines, { label, max: options['max'] });
|
|
19
|
+
}
|
|
20
|
+
const needed = options['requiredParts'];
|
|
21
|
+
if (node.widget !== 'address' || !Array.isArray(needed) || !value || typeof value !== 'object' || Array.isArray(value))
|
|
22
|
+
return undefined;
|
|
23
|
+
const asked = Array.isArray(options['parts']) ? options['parts'] : ADDRESS_PARTS;
|
|
24
|
+
const parts = value;
|
|
25
|
+
const missing = ADDRESS_PARTS.findIndex((part) => needed.includes(part) && asked.includes(part) && !String(parts[part] ?? '').trim());
|
|
26
|
+
return missing < 0 ? undefined : fill(messages.required, { label: messages.addressParts.split('|')[missing] });
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=structures.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structures.mjs","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/structures.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAiB,MAAM,YAAY,CAAC;AAGjD;;;;;;GAMG;AAEH,6EAA6E;AAC7E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAU,CAAC;AAEnG,MAAM,UAAU,cAAc,CAAC,KAAY,EAAE,IAAe,EAAE,KAAwB,EAAE,QAAkB;IACxG,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,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,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACtI,OAAO,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AACjH,CAAC"}
|
|
@@ -23,6 +23,8 @@ export interface FileValue {
|
|
|
23
23
|
size: number;
|
|
24
24
|
data?: string;
|
|
25
25
|
url?: string;
|
|
26
|
+
/** A signature typed rather than drawn: the name typed, kept beside its picture. */
|
|
27
|
+
text?: string;
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* One line of a one2many. `key` is stable for the life of the form, so a line
|
|
@@ -34,19 +36,20 @@ export interface Line {
|
|
|
34
36
|
id?: RecordId;
|
|
35
37
|
values: Values;
|
|
36
38
|
}
|
|
37
|
-
export type Value = JsonValue | RelatedRecord | RelatedRecord[] | ReferenceValue | FileValue | Line[];
|
|
39
|
+
export type Value = JsonValue | RelatedRecord | RelatedRecord[] | ReferenceValue | FileValue | FileValue[] | Line[];
|
|
38
40
|
export type Values = Record<string, Value>;
|
|
39
41
|
type AnyField = Field | LineField;
|
|
40
42
|
/** What a field holds before anyone types in it. */
|
|
41
43
|
export declare function emptyValue(field: AnyField): Value;
|
|
42
|
-
/** A fresh record: each field's default, or its empty value. */
|
|
43
|
-
export declare function initialValues(fields: Record<string, AnyField
|
|
44
|
+
/** A fresh record: each field's default, or its empty value. A date's default may be a day counted from `today` ("today", "today+1"). */
|
|
45
|
+
export declare function initialValues(fields: Record<string, AnyField>, today?: string): Values;
|
|
44
46
|
/** Nothing worth keeping: no value, blank text, or an empty list. Numbers and booleans never are. */
|
|
45
|
-
export declare function isEmpty(
|
|
47
|
+
export declare function isEmpty(field: AnyField, value: Value | undefined): boolean;
|
|
46
48
|
/**
|
|
47
49
|
* The values as modifiers read them, matching what backends write in their
|
|
48
50
|
* expressions: a many2one is its id, a many2many its ids, a reference
|
|
49
|
-
* "model,id", a file its name
|
|
51
|
+
* "model,id", a file its name — several files their names — and lines a list
|
|
52
|
+
* (so `not child_ids` works).
|
|
50
53
|
*/
|
|
51
54
|
export declare function expressionContext(values: Values, fields: Record<string, AnyField>): Record<string, unknown>;
|
|
52
55
|
/**
|
|
@@ -56,6 +59,8 @@ export declare function expressionContext(values: Values, fields: Record<string,
|
|
|
56
59
|
export declare function lineKind(field: Extract<Field, {
|
|
57
60
|
type: 'one2many';
|
|
58
61
|
}>, values: Values): 'section' | 'note' | null;
|
|
62
|
+
/** Whether two values are the same, as they would be saved: a missing value is an empty one. */
|
|
63
|
+
export declare function sameValue(a: Value | undefined, b: Value | undefined): boolean;
|
|
59
64
|
/** A deep copy of plain JSON. */
|
|
60
65
|
export declare function structuredCopy<T>(value: T): T;
|
|
61
66
|
export {};
|
|
@@ -23,6 +23,8 @@ export interface FileValue {
|
|
|
23
23
|
size: number;
|
|
24
24
|
data?: string;
|
|
25
25
|
url?: string;
|
|
26
|
+
/** A signature typed rather than drawn: the name typed, kept beside its picture. */
|
|
27
|
+
text?: string;
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* One line of a one2many. `key` is stable for the life of the form, so a line
|
|
@@ -34,19 +36,20 @@ export interface Line {
|
|
|
34
36
|
id?: RecordId;
|
|
35
37
|
values: Values;
|
|
36
38
|
}
|
|
37
|
-
export type Value = JsonValue | RelatedRecord | RelatedRecord[] | ReferenceValue | FileValue | Line[];
|
|
39
|
+
export type Value = JsonValue | RelatedRecord | RelatedRecord[] | ReferenceValue | FileValue | FileValue[] | Line[];
|
|
38
40
|
export type Values = Record<string, Value>;
|
|
39
41
|
type AnyField = Field | LineField;
|
|
40
42
|
/** What a field holds before anyone types in it. */
|
|
41
43
|
export declare function emptyValue(field: AnyField): Value;
|
|
42
|
-
/** A fresh record: each field's default, or its empty value. */
|
|
43
|
-
export declare function initialValues(fields: Record<string, AnyField
|
|
44
|
+
/** A fresh record: each field's default, or its empty value. A date's default may be a day counted from `today` ("today", "today+1"). */
|
|
45
|
+
export declare function initialValues(fields: Record<string, AnyField>, today?: string): Values;
|
|
44
46
|
/** Nothing worth keeping: no value, blank text, or an empty list. Numbers and booleans never are. */
|
|
45
|
-
export declare function isEmpty(
|
|
47
|
+
export declare function isEmpty(field: AnyField, value: Value | undefined): boolean;
|
|
46
48
|
/**
|
|
47
49
|
* The values as modifiers read them, matching what backends write in their
|
|
48
50
|
* expressions: a many2one is its id, a many2many its ids, a reference
|
|
49
|
-
* "model,id", a file its name
|
|
51
|
+
* "model,id", a file its name — several files their names — and lines a list
|
|
52
|
+
* (so `not child_ids` works).
|
|
50
53
|
*/
|
|
51
54
|
export declare function expressionContext(values: Values, fields: Record<string, AnyField>): Record<string, unknown>;
|
|
52
55
|
/**
|
|
@@ -56,6 +59,8 @@ export declare function expressionContext(values: Values, fields: Record<string,
|
|
|
56
59
|
export declare function lineKind(field: Extract<Field, {
|
|
57
60
|
type: 'one2many';
|
|
58
61
|
}>, values: Values): 'section' | 'note' | null;
|
|
62
|
+
/** Whether two values are the same, as they would be saved: a missing value is an empty one. */
|
|
63
|
+
export declare function sameValue(a: Value | undefined, b: Value | undefined): boolean;
|
|
59
64
|
/** A deep copy of plain JSON. */
|
|
60
65
|
export declare function structuredCopy<T>(value: T): T;
|
|
61
66
|
export {};
|
package/src/lib/record/values.js
CHANGED
|
@@ -5,7 +5,9 @@ exports.initialValues = initialValues;
|
|
|
5
5
|
exports.isEmpty = isEmpty;
|
|
6
6
|
exports.expressionContext = expressionContext;
|
|
7
7
|
exports.lineKind = lineKind;
|
|
8
|
+
exports.sameValue = sameValue;
|
|
8
9
|
exports.structuredCopy = structuredCopy;
|
|
10
|
+
const limits_1 = require("./limits");
|
|
9
11
|
/** What a field holds before anyone types in it. */
|
|
10
12
|
function emptyValue(field) {
|
|
11
13
|
switch (field.type) {
|
|
@@ -15,33 +17,41 @@ function emptyValue(field) {
|
|
|
15
17
|
case 'one2many':
|
|
16
18
|
return [];
|
|
17
19
|
case 'selection':
|
|
20
|
+
case 'binary':
|
|
21
|
+
case 'image':
|
|
18
22
|
return field.multiple ? [] : null;
|
|
19
23
|
default:
|
|
20
24
|
return null;
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
|
-
/** A fresh record: each field's default, or its empty value. */
|
|
24
|
-
function initialValues(fields) {
|
|
27
|
+
/** A fresh record: each field's default, or its empty value. A date's default may be a day counted from `today` ("today", "today+1"). */
|
|
28
|
+
function initialValues(fields, today) {
|
|
25
29
|
const values = {};
|
|
26
30
|
for (const [name, field] of Object.entries(fields)) {
|
|
27
|
-
|
|
31
|
+
const start = field.default;
|
|
32
|
+
values[name] = start === undefined ? emptyValue(field) : field.type === 'date' && typeof start === 'string' && start.startsWith('today') ? (0, limits_1.dayOf)(start, today) : structuredCopy(start);
|
|
28
33
|
}
|
|
29
34
|
return values;
|
|
30
35
|
}
|
|
31
36
|
/** Nothing worth keeping: no value, blank text, or an empty list. Numbers and booleans never are. */
|
|
32
|
-
function isEmpty(
|
|
37
|
+
function isEmpty(field, value) {
|
|
33
38
|
if (value === null || value === undefined)
|
|
34
39
|
return true;
|
|
35
40
|
if (typeof value === 'string')
|
|
36
41
|
return value.trim() === '';
|
|
37
42
|
if (Array.isArray(value))
|
|
38
43
|
return value.length === 0;
|
|
44
|
+
// A matrix with no row answered is not answered at all.
|
|
45
|
+
if (field.type === 'matrix' && typeof value === 'object') {
|
|
46
|
+
return Object.values(value).every((a) => a === null || a === undefined || (Array.isArray(a) && !a.length));
|
|
47
|
+
}
|
|
39
48
|
return false;
|
|
40
49
|
}
|
|
41
50
|
/**
|
|
42
51
|
* The values as modifiers read them, matching what backends write in their
|
|
43
52
|
* expressions: a many2one is its id, a many2many its ids, a reference
|
|
44
|
-
* "model,id", a file its name
|
|
53
|
+
* "model,id", a file its name — several files their names — and lines a list
|
|
54
|
+
* (so `not child_ids` works).
|
|
45
55
|
*/
|
|
46
56
|
function expressionContext(values, fields) {
|
|
47
57
|
const context = {};
|
|
@@ -67,7 +77,7 @@ function forExpressions(field, value) {
|
|
|
67
77
|
}
|
|
68
78
|
case 'binary':
|
|
69
79
|
case 'image':
|
|
70
|
-
return value.name;
|
|
80
|
+
return Array.isArray(value) ? value.map((file) => file.name) : value.name;
|
|
71
81
|
default:
|
|
72
82
|
return value;
|
|
73
83
|
}
|
|
@@ -87,6 +97,10 @@ function lineKind(field, values) {
|
|
|
87
97
|
return 'note';
|
|
88
98
|
return null;
|
|
89
99
|
}
|
|
100
|
+
/** Whether two values are the same, as they would be saved: a missing value is an empty one. */
|
|
101
|
+
function sameValue(a, b) {
|
|
102
|
+
return JSON.stringify(a ?? null) === JSON.stringify(b ?? null);
|
|
103
|
+
}
|
|
90
104
|
/** A deep copy of plain JSON. */
|
|
91
105
|
function structuredCopy(value) {
|
|
92
106
|
return value === undefined ? value : JSON.parse(JSON.stringify(value));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"values.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/values.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"values.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/values.ts"],"names":[],"mappings":";;AA4DA,gCAcC;AAGD,sCAOC;AAGD,0BASC;AAQD,8CAOC;AA2BD,4BAOC;AAGD,8BAEC;AAGD,wCAEC;AAzJD,qCAAiC;AAyDjC,oDAAoD;AACpD,SAAgB,UAAU,CAAC,KAAe;IACxC,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,SAAS;YACZ,OAAO,KAAK,CAAC;QACf,KAAK,WAAW,CAAC;QACjB,KAAK,UAAU;YACb,OAAO,EAAE,CAAC;QACZ,KAAK,WAAW,CAAC;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|
+
import { dayOf } from './limits.mjs';
|
|
1
2
|
/** What a field holds before anyone types in it. */
|
|
2
3
|
export function emptyValue(field) {
|
|
3
4
|
switch (field.type) {
|
|
@@ -7,33 +8,41 @@ export function emptyValue(field) {
|
|
|
7
8
|
case 'one2many':
|
|
8
9
|
return [];
|
|
9
10
|
case 'selection':
|
|
11
|
+
case 'binary':
|
|
12
|
+
case 'image':
|
|
10
13
|
return field.multiple ? [] : null;
|
|
11
14
|
default:
|
|
12
15
|
return null;
|
|
13
16
|
}
|
|
14
17
|
}
|
|
15
|
-
/** A fresh record: each field's default, or its empty value. */
|
|
16
|
-
export function initialValues(fields) {
|
|
18
|
+
/** A fresh record: each field's default, or its empty value. A date's default may be a day counted from `today` ("today", "today+1"). */
|
|
19
|
+
export function initialValues(fields, today) {
|
|
17
20
|
const values = {};
|
|
18
21
|
for (const [name, field] of Object.entries(fields)) {
|
|
19
|
-
|
|
22
|
+
const start = field.default;
|
|
23
|
+
values[name] = start === undefined ? emptyValue(field) : field.type === 'date' && typeof start === 'string' && start.startsWith('today') ? dayOf(start, today) : structuredCopy(start);
|
|
20
24
|
}
|
|
21
25
|
return values;
|
|
22
26
|
}
|
|
23
27
|
/** Nothing worth keeping: no value, blank text, or an empty list. Numbers and booleans never are. */
|
|
24
|
-
export function isEmpty(
|
|
28
|
+
export function isEmpty(field, value) {
|
|
25
29
|
if (value === null || value === undefined)
|
|
26
30
|
return true;
|
|
27
31
|
if (typeof value === 'string')
|
|
28
32
|
return value.trim() === '';
|
|
29
33
|
if (Array.isArray(value))
|
|
30
34
|
return value.length === 0;
|
|
35
|
+
// A matrix with no row answered is not answered at all.
|
|
36
|
+
if (field.type === 'matrix' && typeof value === 'object') {
|
|
37
|
+
return Object.values(value).every((a) => a === null || a === undefined || (Array.isArray(a) && !a.length));
|
|
38
|
+
}
|
|
31
39
|
return false;
|
|
32
40
|
}
|
|
33
41
|
/**
|
|
34
42
|
* The values as modifiers read them, matching what backends write in their
|
|
35
43
|
* expressions: a many2one is its id, a many2many its ids, a reference
|
|
36
|
-
* "model,id", a file its name
|
|
44
|
+
* "model,id", a file its name — several files their names — and lines a list
|
|
45
|
+
* (so `not child_ids` works).
|
|
37
46
|
*/
|
|
38
47
|
export function expressionContext(values, fields) {
|
|
39
48
|
const context = {};
|
|
@@ -59,7 +68,7 @@ function forExpressions(field, value) {
|
|
|
59
68
|
}
|
|
60
69
|
case 'binary':
|
|
61
70
|
case 'image':
|
|
62
|
-
return value.name;
|
|
71
|
+
return Array.isArray(value) ? value.map((file) => file.name) : value.name;
|
|
63
72
|
default:
|
|
64
73
|
return value;
|
|
65
74
|
}
|
|
@@ -79,6 +88,10 @@ export function lineKind(field, values) {
|
|
|
79
88
|
return 'note';
|
|
80
89
|
return null;
|
|
81
90
|
}
|
|
91
|
+
/** Whether two values are the same, as they would be saved: a missing value is an empty one. */
|
|
92
|
+
export function sameValue(a, b) {
|
|
93
|
+
return JSON.stringify(a ?? null) === JSON.stringify(b ?? null);
|
|
94
|
+
}
|
|
82
95
|
/** A deep copy of plain JSON. */
|
|
83
96
|
export function structuredCopy(value) {
|
|
84
97
|
return value === undefined ? value : JSON.parse(JSON.stringify(value));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"values.mjs","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/values.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"values.mjs","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/values.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAyDjC,oDAAoD;AACpD,MAAM,UAAU,UAAU,CAAC,KAAe;IACxC,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,SAAS;YACZ,OAAO,KAAK,CAAC;QACf,KAAK,WAAW,CAAC;QACjB,KAAK,UAAU;YACb,OAAO,EAAE,CAAC;QACZ,KAAK,WAAW,CAAC;QACjB,KAAK,QAAQ,CAAC;QACd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,29 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export type { JsonValue } from './lib/format/json.mjs';
|
|
7
7
|
export { FIELD_NAME, FIELD_TYPES, type FieldType } from './lib/format/names.mjs';
|
|
8
|
-
export type { Field, Fields, LineField, LineKinds, Option, PropertyDefinition, FilterCondition, FilterItem } from './lib/format/field.mjs';
|
|
9
|
-
export type { Modifier, Tone, FieldNode, ButtonNode, TextNode, SlotNode, SectionNode, TabNode, TabsNode, StepNode, WizardNode, SectionsNode, SheetNode, SheetTitle, Statusbar, StatButton, Ribbon, Alert, Badge, ColumnCount, ColumnsByWidth, LayoutNode, RootLayout, ListNode, ListFilter, } from './lib/format/layout.mjs';
|
|
8
|
+
export type { Field, Fields, LineField, LineKinds, Option, OptionsFrom, PropertyDefinition, FilterCondition, FilterItem, SetWhen } from './lib/format/field.mjs';
|
|
9
|
+
export type { Modifier, Tone, FieldNode, ButtonNode, TextNode, SlotNode, SectionNode, TabNode, TabsNode, StepNode, WizardNode, SectionsNode, SheetNode, SheetTitle, Statusbar, StatButton, Ribbon, Alert, Badge, ColumnCount, ColumnsByWidth, LayoutNode, RootLayout, ListNode, ListFilter, LabelPlace, AnswerRule, DividerNode, SpacerNode, ImageNode, FormNode, } from './lib/format/layout.mjs';
|
|
10
10
|
export { wideColumns } from './lib/format/columns.mjs';
|
|
11
|
+
export type { ActionStep, PageEvents, ValueMap, OpenStep, PanelSide, SetStep, ClearStep, AddLineStep, CheckStep, SaveStep, ResetStep, GoToStep, SayStep, AskStep, CallStep, CloseStep, } from './lib/format/actions.mjs';
|
|
11
12
|
export { FORMAT_VERSION } from './lib/format/version.mjs';
|
|
12
|
-
export type { Page, PageData } from './lib/format/page.mjs';
|
|
13
|
+
export type { Page, PageData, PageLook } from './lib/format/page.mjs';
|
|
14
|
+
export { PART_LOOKS, type PartLook, type PartLookKind, type PartsLook } from './lib/format/part-look.mjs';
|
|
13
15
|
export { checkPage } from './lib/format/check-page.mjs';
|
|
14
16
|
export type { PageIssue, PageValidation } from './lib/format/references.mjs';
|
|
15
|
-
export { translatePage } from './lib/format/translate.mjs';
|
|
17
|
+
export { translatePage, localizePage, pageWords, isRightToLeft } from './lib/format/translate.mjs';
|
|
16
18
|
export { compileModifier, type CompiledModifier } from './lib/expression/modifier.mjs';
|
|
17
19
|
export { evaluateModifier, isModifierValid } from './lib/expression/evaluateModifier.mjs';
|
|
18
20
|
export { emptyValue, initialValues, isEmpty, expressionContext, lineKind, type RecordId, type RelatedRecord, type ReferenceValue, type FileValue, type Line, type Value, type Values, } from './lib/record/values.mjs';
|
|
19
|
-
export { checkValue, formatBytes } from './lib/record/check.mjs';
|
|
20
|
-
export
|
|
21
|
+
export { checkValue, formatBytes, fileProblem, describeTypes } from './lib/record/check.mjs';
|
|
22
|
+
export { scoreOf, type Score } from './lib/record/score.mjs';
|
|
23
|
+
export type { DataSource, LoadRequest, SaveRequest, SaveResult, OnchangeRequest, OnchangeResult, SearchRequest, CreateRequest, SubmitRequest, SubmitResult, ResolvedFilterCondition, ResolvedFilter, RecordChanges, LineOp, LinkOp, SaveProblem, SortOrder, ListRequest, ListResult, GroupRequest, Group, OptionsRequest, } from './lib/record/data-source.mjs';
|
|
21
24
|
export { saveRefused, saveProblemOf } from './lib/record/data-source.mjs';
|
|
22
25
|
export { matchesFilter } from './lib/record/filter.mjs';
|
|
23
26
|
export { suggestions, facetsToFilter, groupByFields, type Facet, type Suggestion } from './lib/record/search.mjs';
|
|
24
27
|
export { createMemoryDataSource, type MemoryDataSource, type MemoryDataSourceOptions } from './lib/record/memory-data-source.mjs';
|
|
25
28
|
export { hostScheduler, wait, type Scheduler } from './lib/record/scheduler.mjs';
|
|
26
|
-
export { createForm, type Form, type FormOptions, type FormState, type FormStatus, type NodeState, type DraftStore, type ActionRequest, } from './lib/record/form.mjs';
|
|
29
|
+
export { createForm, type Form, type FormOptions, type FormState, type FormStatus, type NodeState, type Choices, type DraftStore, type ActionRequest, type ChangeBy, type FormEvents, } from './lib/record/form.mjs';
|
|
30
|
+
export type { ActionHost, ActionResult, OnAction, OpenRequest, OpenResult, RunContext, RunResult, RunStop } from './lib/record/run.mjs';
|
|
27
31
|
export { MESSAGES, fill, type Messages, type Locale } from './lib/record/messages.mjs';
|
|
32
|
+
export { dayOf } from './lib/record/limits.mjs';
|
|
33
|
+
export { ADDRESS_PARTS } from './lib/record/structures.mjs';
|
package/src/runtime.d.ts
CHANGED
|
@@ -5,23 +5,29 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export type { JsonValue } from './lib/format/json';
|
|
7
7
|
export { FIELD_NAME, FIELD_TYPES, type FieldType } from './lib/format/names';
|
|
8
|
-
export type { Field, Fields, LineField, LineKinds, Option, PropertyDefinition, FilterCondition, FilterItem } from './lib/format/field';
|
|
9
|
-
export type { Modifier, Tone, FieldNode, ButtonNode, TextNode, SlotNode, SectionNode, TabNode, TabsNode, StepNode, WizardNode, SectionsNode, SheetNode, SheetTitle, Statusbar, StatButton, Ribbon, Alert, Badge, ColumnCount, ColumnsByWidth, LayoutNode, RootLayout, ListNode, ListFilter, } from './lib/format/layout';
|
|
8
|
+
export type { Field, Fields, LineField, LineKinds, Option, OptionsFrom, PropertyDefinition, FilterCondition, FilterItem, SetWhen } from './lib/format/field';
|
|
9
|
+
export type { Modifier, Tone, FieldNode, ButtonNode, TextNode, SlotNode, SectionNode, TabNode, TabsNode, StepNode, WizardNode, SectionsNode, SheetNode, SheetTitle, Statusbar, StatButton, Ribbon, Alert, Badge, ColumnCount, ColumnsByWidth, LayoutNode, RootLayout, ListNode, ListFilter, LabelPlace, AnswerRule, DividerNode, SpacerNode, ImageNode, FormNode, } from './lib/format/layout';
|
|
10
10
|
export { wideColumns } from './lib/format/columns';
|
|
11
|
+
export type { ActionStep, PageEvents, ValueMap, OpenStep, PanelSide, SetStep, ClearStep, AddLineStep, CheckStep, SaveStep, ResetStep, GoToStep, SayStep, AskStep, CallStep, CloseStep, } from './lib/format/actions';
|
|
11
12
|
export { FORMAT_VERSION } from './lib/format/version';
|
|
12
|
-
export type { Page, PageData } from './lib/format/page';
|
|
13
|
+
export type { Page, PageData, PageLook } from './lib/format/page';
|
|
14
|
+
export { PART_LOOKS, type PartLook, type PartLookKind, type PartsLook } from './lib/format/part-look';
|
|
13
15
|
export { checkPage } from './lib/format/check-page';
|
|
14
16
|
export type { PageIssue, PageValidation } from './lib/format/references';
|
|
15
|
-
export { translatePage } from './lib/format/translate';
|
|
17
|
+
export { translatePage, localizePage, pageWords, isRightToLeft } from './lib/format/translate';
|
|
16
18
|
export { compileModifier, type CompiledModifier } from './lib/expression/modifier';
|
|
17
19
|
export { evaluateModifier, isModifierValid } from './lib/expression/evaluateModifier';
|
|
18
20
|
export { emptyValue, initialValues, isEmpty, expressionContext, lineKind, type RecordId, type RelatedRecord, type ReferenceValue, type FileValue, type Line, type Value, type Values, } from './lib/record/values';
|
|
19
|
-
export { checkValue, formatBytes } from './lib/record/check';
|
|
20
|
-
export
|
|
21
|
+
export { checkValue, formatBytes, fileProblem, describeTypes } from './lib/record/check';
|
|
22
|
+
export { scoreOf, type Score } from './lib/record/score';
|
|
23
|
+
export type { DataSource, LoadRequest, SaveRequest, SaveResult, OnchangeRequest, OnchangeResult, SearchRequest, CreateRequest, SubmitRequest, SubmitResult, ResolvedFilterCondition, ResolvedFilter, RecordChanges, LineOp, LinkOp, SaveProblem, SortOrder, ListRequest, ListResult, GroupRequest, Group, OptionsRequest, } from './lib/record/data-source';
|
|
21
24
|
export { saveRefused, saveProblemOf } from './lib/record/data-source';
|
|
22
25
|
export { matchesFilter } from './lib/record/filter';
|
|
23
26
|
export { suggestions, facetsToFilter, groupByFields, type Facet, type Suggestion } from './lib/record/search';
|
|
24
27
|
export { createMemoryDataSource, type MemoryDataSource, type MemoryDataSourceOptions } from './lib/record/memory-data-source';
|
|
25
28
|
export { hostScheduler, wait, type Scheduler } from './lib/record/scheduler';
|
|
26
|
-
export { createForm, type Form, type FormOptions, type FormState, type FormStatus, type NodeState, type DraftStore, type ActionRequest, } from './lib/record/form';
|
|
29
|
+
export { createForm, type Form, type FormOptions, type FormState, type FormStatus, type NodeState, type Choices, type DraftStore, type ActionRequest, type ChangeBy, type FormEvents, } from './lib/record/form';
|
|
30
|
+
export type { ActionHost, ActionResult, OnAction, OpenRequest, OpenResult, RunContext, RunResult, RunStop } from './lib/record/run';
|
|
27
31
|
export { MESSAGES, fill, type Messages, type Locale } from './lib/record/messages';
|
|
32
|
+
export { dayOf } from './lib/record/limits';
|
|
33
|
+
export { ADDRESS_PARTS } from './lib/record/structures';
|
package/src/runtime.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fill = exports.MESSAGES = exports.createForm = exports.wait = exports.hostScheduler = exports.createMemoryDataSource = exports.groupByFields = exports.facetsToFilter = exports.suggestions = exports.matchesFilter = exports.saveProblemOf = exports.saveRefused = exports.formatBytes = exports.checkValue = exports.lineKind = exports.expressionContext = exports.isEmpty = exports.initialValues = exports.emptyValue = exports.isModifierValid = exports.evaluateModifier = exports.compileModifier = exports.translatePage = exports.checkPage = exports.FORMAT_VERSION = exports.wideColumns = exports.FIELD_TYPES = exports.FIELD_NAME = void 0;
|
|
3
|
+
exports.ADDRESS_PARTS = exports.dayOf = exports.fill = exports.MESSAGES = exports.createForm = exports.wait = exports.hostScheduler = exports.createMemoryDataSource = exports.groupByFields = exports.facetsToFilter = exports.suggestions = exports.matchesFilter = exports.saveProblemOf = exports.saveRefused = exports.scoreOf = exports.describeTypes = exports.fileProblem = exports.formatBytes = exports.checkValue = exports.lineKind = exports.expressionContext = exports.isEmpty = exports.initialValues = exports.emptyValue = exports.isModifierValid = exports.evaluateModifier = exports.compileModifier = exports.isRightToLeft = exports.pageWords = exports.localizePage = exports.translatePage = exports.checkPage = exports.PART_LOOKS = exports.FORMAT_VERSION = exports.wideColumns = exports.FIELD_TYPES = exports.FIELD_NAME = void 0;
|
|
4
4
|
var names_1 = require("./lib/format/names");
|
|
5
5
|
Object.defineProperty(exports, "FIELD_NAME", { enumerable: true, get: function () { return names_1.FIELD_NAME; } });
|
|
6
6
|
Object.defineProperty(exports, "FIELD_TYPES", { enumerable: true, get: function () { return names_1.FIELD_TYPES; } });
|
|
@@ -8,10 +8,15 @@ var columns_1 = require("./lib/format/columns");
|
|
|
8
8
|
Object.defineProperty(exports, "wideColumns", { enumerable: true, get: function () { return columns_1.wideColumns; } });
|
|
9
9
|
var version_1 = require("./lib/format/version");
|
|
10
10
|
Object.defineProperty(exports, "FORMAT_VERSION", { enumerable: true, get: function () { return version_1.FORMAT_VERSION; } });
|
|
11
|
+
var part_look_1 = require("./lib/format/part-look");
|
|
12
|
+
Object.defineProperty(exports, "PART_LOOKS", { enumerable: true, get: function () { return part_look_1.PART_LOOKS; } });
|
|
11
13
|
var check_page_1 = require("./lib/format/check-page");
|
|
12
14
|
Object.defineProperty(exports, "checkPage", { enumerable: true, get: function () { return check_page_1.checkPage; } });
|
|
13
15
|
var translate_1 = require("./lib/format/translate");
|
|
14
16
|
Object.defineProperty(exports, "translatePage", { enumerable: true, get: function () { return translate_1.translatePage; } });
|
|
17
|
+
Object.defineProperty(exports, "localizePage", { enumerable: true, get: function () { return translate_1.localizePage; } });
|
|
18
|
+
Object.defineProperty(exports, "pageWords", { enumerable: true, get: function () { return translate_1.pageWords; } });
|
|
19
|
+
Object.defineProperty(exports, "isRightToLeft", { enumerable: true, get: function () { return translate_1.isRightToLeft; } });
|
|
15
20
|
var modifier_1 = require("./lib/expression/modifier");
|
|
16
21
|
Object.defineProperty(exports, "compileModifier", { enumerable: true, get: function () { return modifier_1.compileModifier; } });
|
|
17
22
|
var evaluateModifier_1 = require("./lib/expression/evaluateModifier");
|
|
@@ -26,6 +31,10 @@ Object.defineProperty(exports, "lineKind", { enumerable: true, get: function ()
|
|
|
26
31
|
var check_1 = require("./lib/record/check");
|
|
27
32
|
Object.defineProperty(exports, "checkValue", { enumerable: true, get: function () { return check_1.checkValue; } });
|
|
28
33
|
Object.defineProperty(exports, "formatBytes", { enumerable: true, get: function () { return check_1.formatBytes; } });
|
|
34
|
+
Object.defineProperty(exports, "fileProblem", { enumerable: true, get: function () { return check_1.fileProblem; } });
|
|
35
|
+
Object.defineProperty(exports, "describeTypes", { enumerable: true, get: function () { return check_1.describeTypes; } });
|
|
36
|
+
var score_1 = require("./lib/record/score");
|
|
37
|
+
Object.defineProperty(exports, "scoreOf", { enumerable: true, get: function () { return score_1.scoreOf; } });
|
|
29
38
|
var data_source_1 = require("./lib/record/data-source");
|
|
30
39
|
Object.defineProperty(exports, "saveRefused", { enumerable: true, get: function () { return data_source_1.saveRefused; } });
|
|
31
40
|
Object.defineProperty(exports, "saveProblemOf", { enumerable: true, get: function () { return data_source_1.saveProblemOf; } });
|
|
@@ -45,4 +54,8 @@ Object.defineProperty(exports, "createForm", { enumerable: true, get: function (
|
|
|
45
54
|
var messages_1 = require("./lib/record/messages");
|
|
46
55
|
Object.defineProperty(exports, "MESSAGES", { enumerable: true, get: function () { return messages_1.MESSAGES; } });
|
|
47
56
|
Object.defineProperty(exports, "fill", { enumerable: true, get: function () { return messages_1.fill; } });
|
|
57
|
+
var limits_1 = require("./lib/record/limits");
|
|
58
|
+
Object.defineProperty(exports, "dayOf", { enumerable: true, get: function () { return limits_1.dayOf; } });
|
|
59
|
+
var structures_1 = require("./lib/record/structures");
|
|
60
|
+
Object.defineProperty(exports, "ADDRESS_PARTS", { enumerable: true, get: function () { return structures_1.ADDRESS_PARTS; } });
|
|
48
61
|
//# sourceMappingURL=runtime.js.map
|
package/src/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../../libs/core/src/runtime.ts"],"names":[],"mappings":";;;AAMA,4CAA6E;AAApE,mGAAA,UAAU,OAAA;AAAE,oGAAA,WAAW,OAAA;
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../../libs/core/src/runtime.ts"],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