trama-forms 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +83 -2
- package/dist/core/acceptance.d.ts +15 -0
- package/dist/core/acceptance.js +37 -0
- package/dist/core/address.d.ts +45 -0
- package/dist/core/address.js +68 -0
- package/dist/core/authoring-checks.d.ts +39 -0
- package/dist/core/authoring-checks.js +1 -0
- package/dist/core/authoring-form.d.ts +23 -0
- package/dist/core/authoring-form.js +1 -0
- package/dist/core/authoring-params.d.ts +37 -0
- package/dist/core/authoring-params.js +1 -0
- package/dist/core/authoring-relations.d.ts +46 -0
- package/dist/core/authoring-relations.js +1 -0
- package/dist/core/authoring-rows.d.ts +109 -0
- package/dist/core/authoring-rows.js +1 -0
- package/dist/core/authoring-values.d.ts +36 -0
- package/dist/core/authoring-values.js +1 -0
- package/dist/core/authoring.d.ts +117 -0
- package/dist/core/authoring.js +1 -0
- package/dist/core/baseline.d.ts +12 -0
- package/dist/core/baseline.js +66 -0
- package/dist/core/candidates.d.ts +26 -0
- package/dist/core/candidates.js +155 -0
- package/dist/core/collections.d.ts +59 -0
- package/dist/core/collections.js +138 -0
- package/dist/core/commands.d.ts +15 -0
- package/dist/core/commands.js +64 -0
- package/dist/core/compile.d.ts +18 -0
- package/dist/core/compile.js +60 -0
- package/dist/core/compiled.d.ts +34 -0
- package/dist/core/compiled.js +12 -0
- package/dist/core/config.d.ts +103 -0
- package/dist/core/config.js +1 -0
- package/dist/core/cycles.d.ts +14 -0
- package/dist/core/cycles.js +39 -0
- package/dist/core/data.d.ts +40 -0
- package/dist/core/data.js +236 -0
- package/dist/core/declarations.d.ts +61 -0
- package/dist/core/declarations.js +202 -0
- package/dist/core/definition.d.ts +54 -0
- package/dist/core/definition.js +3 -0
- package/dist/core/derived-fields.d.ts +37 -0
- package/dist/core/derived-fields.js +121 -0
- package/dist/core/derived-scope.d.ts +55 -0
- package/dist/core/derived-scope.js +105 -0
- package/dist/core/derived.d.ts +76 -0
- package/dist/core/derived.js +180 -0
- package/dist/core/endpoints.d.ts +94 -0
- package/dist/core/endpoints.js +95 -0
- package/dist/core/engine-types.d.ts +43 -0
- package/dist/core/engine-types.js +1 -0
- package/dist/core/engine.d.ts +9 -0
- package/dist/core/engine.js +140 -0
- package/dist/core/evaluation.d.ts +20 -0
- package/dist/core/evaluation.js +62 -0
- package/dist/core/external.d.ts +13 -0
- package/dist/core/external.js +49 -0
- package/dist/core/field-definitions.d.ts +103 -0
- package/dist/core/field-definitions.js +20 -0
- package/dist/core/field-traits.d.ts +29 -0
- package/dist/core/field-traits.js +149 -0
- package/dist/core/fields.d.ts +26 -0
- package/dist/core/fields.js +89 -0
- package/dist/core/forms.d.ts +23 -0
- package/dist/core/forms.js +46 -0
- package/dist/core/handles.d.ts +56 -0
- package/dist/core/handles.js +128 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/index.js +7 -0
- package/dist/core/invalidation.d.ts +30 -0
- package/dist/core/invalidation.js +161 -0
- package/dist/core/issues.d.ts +22 -0
- package/dist/core/issues.js +60 -0
- package/dist/core/known-keys.d.ts +4 -0
- package/dist/core/known-keys.js +22 -0
- package/dist/core/lists.d.ts +27 -0
- package/dist/core/lists.js +174 -0
- package/dist/core/lock.d.ts +4 -0
- package/dist/core/lock.js +70 -0
- package/dist/core/marking.d.ts +16 -0
- package/dist/core/marking.js +28 -0
- package/dist/core/marks.d.ts +32 -0
- package/dist/core/marks.js +203 -0
- package/dist/core/memory.d.ts +79 -0
- package/dist/core/memory.js +127 -0
- package/dist/core/messages.d.ts +20 -0
- package/dist/core/messages.js +46 -0
- package/dist/core/multiple.d.ts +12 -0
- package/dist/core/multiple.js +123 -0
- package/dist/core/notify.d.ts +32 -0
- package/dist/core/notify.js +160 -0
- package/dist/core/observation.d.ts +7 -0
- package/dist/core/observation.js +80 -0
- package/dist/core/observe.d.ts +19 -0
- package/dist/core/observe.js +59 -0
- package/dist/core/operation.d.ts +8 -0
- package/dist/core/operation.js +48 -0
- package/dist/core/options.d.ts +40 -0
- package/dist/core/options.js +32 -0
- package/dist/core/outputs.d.ts +58 -0
- package/dist/core/outputs.js +149 -0
- package/dist/core/param-memory.d.ts +13 -0
- package/dist/core/param-memory.js +17 -0
- package/dist/core/params.d.ts +37 -0
- package/dist/core/params.js +70 -0
- package/dist/core/pass.d.ts +6 -0
- package/dist/core/pass.js +141 -0
- package/dist/core/patches.d.ts +15 -0
- package/dist/core/patches.js +106 -0
- package/dist/core/prepare.d.ts +19 -0
- package/dist/core/prepare.js +105 -0
- package/dist/core/prepared.d.ts +10 -0
- package/dist/core/prepared.js +14 -0
- package/dist/core/program.d.ts +43 -0
- package/dist/core/program.js +100 -0
- package/dist/core/publication.d.ts +20 -0
- package/dist/core/publication.js +56 -0
- package/dist/core/published.d.ts +18 -0
- package/dist/core/published.js +83 -0
- package/dist/core/queries.d.ts +10 -0
- package/dist/core/queries.js +148 -0
- package/dist/core/query-batch.d.ts +2 -0
- package/dist/core/query-batch.js +67 -0
- package/dist/core/query-entries.d.ts +78 -0
- package/dist/core/query-entries.js +139 -0
- package/dist/core/query-response.d.ts +2 -0
- package/dist/core/query-response.js +110 -0
- package/dist/core/reads.d.ts +30 -0
- package/dist/core/reads.js +88 -0
- package/dist/core/rebase.d.ts +16 -0
- package/dist/core/rebase.js +40 -0
- package/dist/core/relations.d.ts +10 -0
- package/dist/core/relations.js +84 -0
- package/dist/core/remote-fields.d.ts +6 -0
- package/dist/core/remote-fields.js +29 -0
- package/dist/core/resolution.d.ts +12 -0
- package/dist/core/resolution.js +157 -0
- package/dist/core/restarts.d.ts +17 -0
- package/dist/core/restarts.js +42 -0
- package/dist/core/revisions.d.ts +11 -0
- package/dist/core/revisions.js +57 -0
- package/dist/core/row-arrays.d.ts +12 -0
- package/dist/core/row-arrays.js +47 -0
- package/dist/core/row-maps.d.ts +16 -0
- package/dist/core/row-maps.js +52 -0
- package/dist/core/row-states.d.ts +68 -0
- package/dist/core/row-states.js +75 -0
- package/dist/core/row-types.d.ts +76 -0
- package/dist/core/row-types.js +1 -0
- package/dist/core/rule-set-config.d.ts +56 -0
- package/dist/core/rule-set-config.js +1 -0
- package/dist/core/rule-set-types.d.ts +91 -0
- package/dist/core/rule-set-types.js +1 -0
- package/dist/core/rule-sets.d.ts +15 -0
- package/dist/core/rule-sets.js +107 -0
- package/dist/core/rules.d.ts +67 -0
- package/dist/core/rules.js +144 -0
- package/dist/core/saving.d.ts +55 -0
- package/dist/core/saving.js +132 -0
- package/dist/core/scope-declarations.d.ts +13 -0
- package/dist/core/scope-declarations.js +18 -0
- package/dist/core/scope-messages.d.ts +9 -0
- package/dist/core/scope-messages.js +46 -0
- package/dist/core/scope-states.d.ts +50 -0
- package/dist/core/scope-states.js +222 -0
- package/dist/core/session-external.d.ts +24 -0
- package/dist/core/session-external.js +138 -0
- package/dist/core/session-lists.d.ts +12 -0
- package/dist/core/session-lists.js +60 -0
- package/dist/core/session-marks.d.ts +22 -0
- package/dist/core/session-marks.js +113 -0
- package/dist/core/session-parts.d.ts +26 -0
- package/dist/core/session-parts.js +91 -0
- package/dist/core/session-rows.d.ts +15 -0
- package/dist/core/session-rows.js +62 -0
- package/dist/core/session-types.d.ts +112 -0
- package/dist/core/session-types.js +1 -0
- package/dist/core/session.d.ts +5 -0
- package/dist/core/session.js +51 -0
- package/dist/core/state-evaluation.d.ts +10 -0
- package/dist/core/state-evaluation.js +69 -0
- package/dist/core/state-properties.d.ts +30 -0
- package/dist/core/state-properties.js +101 -0
- package/dist/core/states.d.ts +73 -0
- package/dist/core/states.js +180 -0
- package/dist/core/steps.d.ts +37 -0
- package/dist/core/steps.js +183 -0
- package/dist/core/subtype-types.d.ts +67 -0
- package/dist/core/subtype-types.js +1 -0
- package/dist/core/subtypes.d.ts +19 -0
- package/dist/core/subtypes.js +69 -0
- package/dist/core/tree.d.ts +44 -0
- package/dist/core/tree.js +119 -0
- package/dist/core/validation.d.ts +11 -0
- package/dist/core/validation.js +42 -0
- package/dist/core/views.d.ts +24 -0
- package/dist/core/views.js +161 -0
- package/dist/react/async.d.ts +7 -0
- package/dist/react/async.js +67 -0
- package/dist/react/binding.d.ts +15 -0
- package/dist/react/binding.js +51 -0
- package/dist/react/coverage.d.ts +21 -0
- package/dist/react/coverage.js +91 -0
- package/dist/react/field.d.ts +60 -0
- package/dist/react/field.js +194 -0
- package/dist/react/form-state.d.ts +14 -0
- package/dist/react/form-state.js +70 -0
- package/dist/react/index.d.ts +152 -0
- package/dist/react/index.js +6 -0
- package/dist/react/opening.d.ts +38 -0
- package/dist/react/opening.js +206 -0
- package/dist/react/outputs.d.ts +11 -0
- package/dist/react/outputs.js +137 -0
- package/dist/react/props.d.ts +48 -0
- package/dist/react/props.js +1 -0
- package/dist/react/query.d.ts +11 -0
- package/dist/react/query.js +21 -0
- package/dist/react/render.d.ts +49 -0
- package/dist/react/render.js +119 -0
- package/dist/react/rows.d.ts +2 -0
- package/dist/react/rows.js +25 -0
- package/dist/react/visible-messages.d.ts +8 -0
- package/dist/react/visible-messages.js +16 -0
- package/package.json +77 -4
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
// The declarations of a section of rules: each property of each entry, checked
|
|
2
|
+
// once and kept in the order written. defineForm checks its own rules here,
|
|
3
|
+
// and defineRules those of a rule set, which every form that includes it
|
|
4
|
+
// places in its sequence.
|
|
5
|
+
import { fieldAt, isPlainRecord, remote } from "./fields.js";
|
|
6
|
+
import { hasState, isLimit, isStateProperty, stateKinds } from "./state-properties.js";
|
|
7
|
+
import { fieldLabel, templateLabel } from "./address.js";
|
|
8
|
+
import { checkQuery } from "./params.js";
|
|
9
|
+
import { relationOf } from "./relations.js";
|
|
10
|
+
// What a form takes of each property of a field: one declaration in the whole
|
|
11
|
+
// form, or contributions from every place, which combine in the order of the
|
|
12
|
+
// sequence. Every state property accumulates.
|
|
13
|
+
const accumulated = Object.fromEntries(Object.keys(stateKinds).map((property) => [property, "accumulate"]));
|
|
14
|
+
export const policies = {
|
|
15
|
+
value: "single",
|
|
16
|
+
relation: "single",
|
|
17
|
+
onChange: "single",
|
|
18
|
+
onEdit: "single",
|
|
19
|
+
params: "single",
|
|
20
|
+
query: "single",
|
|
21
|
+
...accumulated,
|
|
22
|
+
states: "accumulate",
|
|
23
|
+
};
|
|
24
|
+
export const eventConflict = (label, first, second) => new Error(`${label}: ${first} and ${second}; a field declares onChange or onEdit, not both`);
|
|
25
|
+
// Each entry names a field or a collection, whose each names its fields. The
|
|
26
|
+
// rules of a form may be undefined; those of a rule set may not.
|
|
27
|
+
export const declarationsOf = (owner, fields, collections, rules, table) => {
|
|
28
|
+
if (!isPlainRecord(rules) && (owner !== "Form" || rules !== undefined))
|
|
29
|
+
throw new Error(`${owner} rules must be an object keyed by field`);
|
|
30
|
+
const prefix = owner === "Form" ? "Rules" : "Rule set rules";
|
|
31
|
+
const declared = [];
|
|
32
|
+
for (const [name, entry] of Object.entries(rules ?? {})) {
|
|
33
|
+
const collection = collections.get(name);
|
|
34
|
+
if (collection !== undefined) {
|
|
35
|
+
declared.push(...eachOf(owner, `${prefix} of collection "${name}"`, collection, entry, table));
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const item = fieldAt(fields, name);
|
|
39
|
+
if (item === undefined)
|
|
40
|
+
throw new Error(`${prefix}: unknown field "${name}"`);
|
|
41
|
+
declared.push(...entryOf(owner, undefined, name, fieldLabel(name), fields, item, entry, table));
|
|
42
|
+
}
|
|
43
|
+
return Object.freeze(declared);
|
|
44
|
+
};
|
|
45
|
+
const eachOf = (owner, prefix, collection, entry, table) => {
|
|
46
|
+
if (entry === undefined)
|
|
47
|
+
return [];
|
|
48
|
+
if (!isPlainRecord(entry))
|
|
49
|
+
throw new Error(`${prefix}: expected an object with each, row or collection`);
|
|
50
|
+
for (const key of Object.keys(entry))
|
|
51
|
+
if (key !== "each" && key !== "row" && key !== "collection")
|
|
52
|
+
throw new Error(`${prefix}: unknown property "${key}"`);
|
|
53
|
+
const { name: of } = collection;
|
|
54
|
+
const own = [
|
|
55
|
+
...messagesOf(`Row of "${of}"`, `Row rules of "${of}"`, { kind: "row", collection: of }, entry.row),
|
|
56
|
+
...messagesOf(`Collection "${of}"`, `Collection rules of "${of}"`, { kind: "collection", collection: of }, entry.collection),
|
|
57
|
+
];
|
|
58
|
+
const each = entry.each;
|
|
59
|
+
if (each === undefined)
|
|
60
|
+
return own;
|
|
61
|
+
if (!isPlainRecord(each))
|
|
62
|
+
throw new Error(`${prefix} each: expected an object keyed by field`);
|
|
63
|
+
return [
|
|
64
|
+
...own,
|
|
65
|
+
...Object.entries(each).flatMap(([name, rules]) => {
|
|
66
|
+
const item = fieldAt(collection.fields, name);
|
|
67
|
+
if (item === undefined)
|
|
68
|
+
throw new Error(`${prefix} each: unknown field "${name}"`);
|
|
69
|
+
const label = templateLabel(name, collection.name);
|
|
70
|
+
return entryOf(owner, collection.name, name, label, collection.fields, item, rules, table);
|
|
71
|
+
}),
|
|
72
|
+
];
|
|
73
|
+
};
|
|
74
|
+
// The messages of the rows of a collection, or of the collection: an object
|
|
75
|
+
// with error and warning, each a formula or an array of them. A message of rows
|
|
76
|
+
// compiles where the fields of the rows do; one of the collection, in the
|
|
77
|
+
// header.
|
|
78
|
+
export const messagesOf = (label, rules, own, declared) => {
|
|
79
|
+
if (declared === undefined)
|
|
80
|
+
return [];
|
|
81
|
+
if (!isPlainRecord(declared))
|
|
82
|
+
throw new Error(`${rules}: expected an object with error or warning`);
|
|
83
|
+
for (const key of Object.keys(declared))
|
|
84
|
+
if (key !== "error" && key !== "warning")
|
|
85
|
+
throw new Error(`${rules}: unknown property "${key}"`);
|
|
86
|
+
return Object.entries(declared)
|
|
87
|
+
.filter(([, formulas]) => formulas !== undefined)
|
|
88
|
+
.map(([property, formulas]) => Object.freeze({
|
|
89
|
+
collection: own.kind === "row" ? own.collection : undefined,
|
|
90
|
+
name: "",
|
|
91
|
+
label,
|
|
92
|
+
own,
|
|
93
|
+
property: property,
|
|
94
|
+
formulas: functionsOf(`${label} ${property}`, property, formulas),
|
|
95
|
+
}));
|
|
96
|
+
};
|
|
97
|
+
// The properties an entry declares, without those left undefined: every name
|
|
98
|
+
// is checked first, then each property in the order written.
|
|
99
|
+
const entryOf = (owner, collection, name, label, fields, item, entry, table) => {
|
|
100
|
+
if (entry === undefined)
|
|
101
|
+
return [];
|
|
102
|
+
if (!isPlainRecord(entry))
|
|
103
|
+
throw new Error(`${label} rules: expected an object of properties`);
|
|
104
|
+
for (const property of Object.keys(entry))
|
|
105
|
+
checkProperty(label, item, property);
|
|
106
|
+
const entries = Object.entries(entry).filter(([, value]) => value !== undefined);
|
|
107
|
+
// A rule set rejects its own conflict of events; a form, when it compiles.
|
|
108
|
+
if (owner === "Rule set") {
|
|
109
|
+
const events = entries.filter(([property]) => property === "onChange" || property === "onEdit");
|
|
110
|
+
if (events.length > 1)
|
|
111
|
+
throw eventConflict(label, `${events[0]?.[0]} in rules`, `${events[1]?.[0]} in rules`);
|
|
112
|
+
}
|
|
113
|
+
return entries.flatMap(([property, declared]) => property === "relation"
|
|
114
|
+
? relationOf({ collection, name, label }, item, declared, fields)
|
|
115
|
+
: [
|
|
116
|
+
Object.freeze(property === "query"
|
|
117
|
+
? {
|
|
118
|
+
collection,
|
|
119
|
+
name,
|
|
120
|
+
label,
|
|
121
|
+
property,
|
|
122
|
+
query: checkQuery(label, declared, table, owner),
|
|
123
|
+
}
|
|
124
|
+
: {
|
|
125
|
+
collection,
|
|
126
|
+
name,
|
|
127
|
+
label,
|
|
128
|
+
property: property,
|
|
129
|
+
formulas: functionsOf(`${label} ${property}`, property, declared),
|
|
130
|
+
}),
|
|
131
|
+
]);
|
|
132
|
+
};
|
|
133
|
+
// The placeholder, the limits and params exist only in the field types that
|
|
134
|
+
// declare them.
|
|
135
|
+
const checkProperty = (label, item, property) => {
|
|
136
|
+
if (!Object.hasOwn(policies, property))
|
|
137
|
+
throw new Error(`${label} rules: unknown property "${property}"`);
|
|
138
|
+
if (isStateProperty(property) && !hasState(item.type, property))
|
|
139
|
+
throw new Error(`${label} ${property}: ${item.type} fields have no ${property}`);
|
|
140
|
+
if (property === "params" && !remote(item))
|
|
141
|
+
throw new Error(`${label} params: ${item.type} fields have no params`);
|
|
142
|
+
};
|
|
143
|
+
// A flag takes a formula or an array of formulas, each named by its position;
|
|
144
|
+
// every other property, as a text or a limit, takes one function.
|
|
145
|
+
const functionsOf = (prefix, property, declared) => {
|
|
146
|
+
if (typeof declared === "function")
|
|
147
|
+
return [["", declared]];
|
|
148
|
+
const kind = property === "onChange" || property === "onEdit" ? "event" : "formula";
|
|
149
|
+
if (!isStateProperty(property) || stateKinds[property] === "text" || isLimit(property))
|
|
150
|
+
throw new Error(`${prefix}: ${kind} must be a function`);
|
|
151
|
+
if (!Array.isArray(declared))
|
|
152
|
+
throw new Error(`${prefix}: expected a formula or an array of formulas`);
|
|
153
|
+
return Array.from(declared, (item, index) => {
|
|
154
|
+
if (typeof item !== "function")
|
|
155
|
+
throw new Error(`${prefix}[${index}]: formula must be a function`);
|
|
156
|
+
return [`[${index}]`, item];
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
// A value, relation, params or query claims its property; onEdit and onChange
|
|
160
|
+
// share the key of the field's event. Generated writers carry their driver
|
|
161
|
+
// so a conflict names the declaration that reserved the property.
|
|
162
|
+
export const claim = (claimed, { name, label, property, drivenBy }, place) => {
|
|
163
|
+
if (policies[property] !== "single")
|
|
164
|
+
return;
|
|
165
|
+
const key = `${property === "onEdit" ? "onChange" : property}:${name}`;
|
|
166
|
+
const next = { property, place, drivenBy };
|
|
167
|
+
const first = claimed.get(key);
|
|
168
|
+
if (first !== undefined)
|
|
169
|
+
throw conflict(label, first, next);
|
|
170
|
+
claimed.set(key, next);
|
|
171
|
+
};
|
|
172
|
+
const conflict = (label, first, next) => {
|
|
173
|
+
if (first.drivenBy !== undefined || next.drivenBy !== undefined)
|
|
174
|
+
return relationConflict(label, first, next);
|
|
175
|
+
if (first.property !== next.property)
|
|
176
|
+
return eventConflict(label, `${first.property} in ${first.place}`, `${next.property} in ${next.place}`);
|
|
177
|
+
return new Error(`${label} ${next.property}: declared by ${first.place} and ${next.place}`);
|
|
178
|
+
};
|
|
179
|
+
const relationAt = ({ drivenBy, place }) => `the relation of "${drivenBy}" in ${place}`;
|
|
180
|
+
const relationConflict = (label, first, next) => {
|
|
181
|
+
if (first.drivenBy !== undefined && next.drivenBy !== undefined)
|
|
182
|
+
return new Error(`${label}: member of ${relationAt(first)} and of ${relationAt(next)}; a field is a member of one relation`);
|
|
183
|
+
const [member, relation] = first.drivenBy === undefined ? [first, next] : [next, first];
|
|
184
|
+
return new Error(`${label} ${member.property} in ${member.place}: ${relationAt(relation)} takes the value and the events of its members`);
|
|
185
|
+
};
|
|
186
|
+
// A rule set with a relation rejects the conflicts between its entries when
|
|
187
|
+
// it is defined; a form, those between its sources when it compiles. Without
|
|
188
|
+
// a relation, an entry cannot conflict with another.
|
|
189
|
+
export const checkSetClaims = (declarations) => {
|
|
190
|
+
if (!declarations.some(({ property }) => property === "relation"))
|
|
191
|
+
return;
|
|
192
|
+
const scopes = new Map();
|
|
193
|
+
for (const declaration of declarations) {
|
|
194
|
+
const { collection } = declaration;
|
|
195
|
+
let claimed = scopes.get(collection);
|
|
196
|
+
if (claimed === undefined) {
|
|
197
|
+
claimed = new Map();
|
|
198
|
+
scopes.set(collection, claimed);
|
|
199
|
+
}
|
|
200
|
+
claim(claimed, declaration, "rules");
|
|
201
|
+
}
|
|
202
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { FieldDefinition, FieldValue } from "./fields.js";
|
|
2
|
+
import type { DeepReadonly, PlainRecord } from "./data.js";
|
|
3
|
+
import type { QueryState } from "./queries.js";
|
|
4
|
+
import type { RowValues } from "./row-types.js";
|
|
5
|
+
export { field, type TextDefinition, type NumberDefinition, type CheckboxDefinition, type SelectOption, type SelectDefinition, type AsyncDefinition, type DateDefinition, type MultiSelectDefinition, type MultiAsyncDefinition, type FieldDefinition, type FieldValue, } from "./fields.js";
|
|
6
|
+
export type FormDefinition<F extends Record<string, FieldDefinition> = Record<string, FieldDefinition>, O extends Record<string, unknown> = Record<string, unknown>, C = unknown, Q extends Record<string, QueryState> = Record<string, QueryState>, K extends Collections = {}, W extends CollectionQueries = CollectionQueries> = {
|
|
7
|
+
readonly fields: F;
|
|
8
|
+
readonly collections: K;
|
|
9
|
+
readonly [outputValues]?: O;
|
|
10
|
+
readonly [contextValue]?: C;
|
|
11
|
+
readonly [queryStates]?: Q;
|
|
12
|
+
readonly [rowQueryStates]?: W;
|
|
13
|
+
readonly [definitionBrand]: true;
|
|
14
|
+
};
|
|
15
|
+
declare const outputValues: unique symbol;
|
|
16
|
+
declare const contextValue: unique symbol;
|
|
17
|
+
declare const queryStates: unique symbol;
|
|
18
|
+
declare const rowQueryStates: unique symbol;
|
|
19
|
+
type CollectionQueries = Record<string, Readonly<Record<string, QueryState>>>;
|
|
20
|
+
export type FormQueries<D extends FormDefinition> = D extends {
|
|
21
|
+
readonly [queryStates]?: infer Q;
|
|
22
|
+
} ? Readonly<Q> : never;
|
|
23
|
+
export type RowQueries<D extends FormDefinition, N extends keyof D["collections"] & string> = NonNullable<D[typeof rowQueryStates]>[N];
|
|
24
|
+
declare const definitionBrand: unique symbol;
|
|
25
|
+
export type FormContext<D extends FormDefinition> = D extends {
|
|
26
|
+
readonly [contextValue]?: infer C;
|
|
27
|
+
} ? C : never;
|
|
28
|
+
declare const contextData: unique symbol;
|
|
29
|
+
export type ContextDeclaration<T> = {
|
|
30
|
+
readonly [contextData]: T;
|
|
31
|
+
};
|
|
32
|
+
type ContextData<T> = [T] extends [PlainRecord] ? [keyof T] extends [never] ? "context data needs a property" : PlainRecord : "context data must be plain";
|
|
33
|
+
type Declared<T> = [T] extends [never] ? "declareContext requires a type argument" : [T] extends [PlainRecord] ? ContextDeclaration<T> : "declareContext requires a type argument";
|
|
34
|
+
export declare const declaration: Readonly<{}>;
|
|
35
|
+
export declare const declareContext: <T extends ContextData<T>>() => Declared<T>;
|
|
36
|
+
export type ContextTools<C> = undefined extends C ? {} : {
|
|
37
|
+
readonly context: DeepReadonly<C>;
|
|
38
|
+
};
|
|
39
|
+
export type FormOutputs<D extends FormDefinition> = DeepReadonly<NonNullable<D[typeof outputValues]>>;
|
|
40
|
+
export type FormValues<D extends FormDefinition> = Flat<{
|
|
41
|
+
-readonly [K in keyof D["fields"]]: FieldValue<D["fields"][K]>;
|
|
42
|
+
} & {
|
|
43
|
+
-readonly [N in keyof D["collections"]]: RowValues<FieldsIn<D["collections"][N]>>[];
|
|
44
|
+
}>;
|
|
45
|
+
type Flat<T> = {
|
|
46
|
+
-readonly [K in keyof T]: T[K];
|
|
47
|
+
};
|
|
48
|
+
export type FieldsIn<E> = E extends {
|
|
49
|
+
readonly fields: infer R extends Fields;
|
|
50
|
+
} ? R : never;
|
|
51
|
+
export type Fields = Record<string, FieldDefinition>;
|
|
52
|
+
export type Collections = Record<string, {
|
|
53
|
+
readonly fields: Fields;
|
|
54
|
+
}>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { FieldDefinition } from "./field-definitions.js";
|
|
2
|
+
import { type External, type Mark } from "./marks.js";
|
|
3
|
+
import type { Messages } from "./messages.js";
|
|
4
|
+
import type { States } from "./states.js";
|
|
5
|
+
type State = States[string];
|
|
6
|
+
type Origin = {
|
|
7
|
+
readonly raw: State;
|
|
8
|
+
readonly result: number;
|
|
9
|
+
readonly message: string | undefined;
|
|
10
|
+
readonly inputs: readonly string[];
|
|
11
|
+
readonly external: External | undefined;
|
|
12
|
+
};
|
|
13
|
+
export type Deriver = {
|
|
14
|
+
readonly state: (raw: State, type: FieldDefinition["type"], result: number, dirty: boolean, before: Origin | undefined, held: State | undefined, mark: Mark | undefined) => State;
|
|
15
|
+
readonly origin: (published: State) => Origin | undefined;
|
|
16
|
+
readonly scope: (raw: States, next: States, names: readonly string[], external: boolean) => States;
|
|
17
|
+
};
|
|
18
|
+
export declare const createDeriver: (messages: Messages) => Deriver;
|
|
19
|
+
export declare const deriveField: (deriver: Deriver, type: FieldDefinition["type"], value: unknown, base: unknown, raw: State, held: State | undefined, changed: boolean, mark: Mark | undefined) => {
|
|
20
|
+
readonly disabled: boolean;
|
|
21
|
+
readonly readOnly: boolean;
|
|
22
|
+
readonly hidden: boolean;
|
|
23
|
+
readonly required: boolean;
|
|
24
|
+
readonly label: string | undefined;
|
|
25
|
+
readonly reasons: readonly string[];
|
|
26
|
+
readonly errors: readonly string[];
|
|
27
|
+
readonly externalErrors: readonly string[];
|
|
28
|
+
readonly warnings: readonly string[];
|
|
29
|
+
readonly dirty: boolean;
|
|
30
|
+
readonly touched: boolean;
|
|
31
|
+
} & {
|
|
32
|
+
readonly placeholder?: string | undefined;
|
|
33
|
+
readonly decimals?: number;
|
|
34
|
+
readonly min?: number | string;
|
|
35
|
+
readonly max?: number | string;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// The state a field publishes: the one its contributions combine, with the
|
|
2
|
+
// result of its validation, whether it is dirty and its mark. A state is
|
|
3
|
+
// interned per session by its combined state, its result, dirty and touched,
|
|
4
|
+
// so the rows that share them share one object, and a message of the
|
|
5
|
+
// application runs once for each. A state with inputs or with externals,
|
|
6
|
+
// which are rare, is its own.
|
|
7
|
+
import { sameItems } from "./data.js";
|
|
8
|
+
import { equalIn } from "./field-traits.js";
|
|
9
|
+
import { inputsOf, keptItems, merged, noInputs } from "./marks.js";
|
|
10
|
+
import { sameChecks, valid, validationMessage, validationOf } from "./validation.js";
|
|
11
|
+
export const createDeriver = (messages) => {
|
|
12
|
+
const interned = new WeakMap();
|
|
13
|
+
const origins = new WeakMap();
|
|
14
|
+
const scopes = new WeakMap();
|
|
15
|
+
return {
|
|
16
|
+
scope: (raw, next, names, external) => {
|
|
17
|
+
if (external)
|
|
18
|
+
return Object.freeze(next);
|
|
19
|
+
const last = scopes.get(raw);
|
|
20
|
+
if (last !== undefined && names.every((name) => last[name] === next[name]))
|
|
21
|
+
return last;
|
|
22
|
+
const frozen = Object.freeze(next);
|
|
23
|
+
scopes.set(raw, frozen);
|
|
24
|
+
return frozen;
|
|
25
|
+
},
|
|
26
|
+
state: (raw, type, result, dirty, before, held, mark) => {
|
|
27
|
+
// A valid, clean and unmarked state publishes as it combined.
|
|
28
|
+
if (result === valid && !dirty && mark === undefined)
|
|
29
|
+
return raw;
|
|
30
|
+
const create = () => {
|
|
31
|
+
const message = result === valid
|
|
32
|
+
? undefined
|
|
33
|
+
: before !== undefined && alike(before, raw, result)
|
|
34
|
+
? before.message
|
|
35
|
+
: validationMessage(messages, type, result, raw);
|
|
36
|
+
const state = published(raw, message, dirty, held, mark);
|
|
37
|
+
const external = mark?.external;
|
|
38
|
+
origins.set(state, { raw, result, message, inputs: inputsOf(mark), external });
|
|
39
|
+
return state;
|
|
40
|
+
};
|
|
41
|
+
if (inputsOf(mark) !== noInputs || mark?.external !== undefined)
|
|
42
|
+
return create();
|
|
43
|
+
let cache = interned.get(raw);
|
|
44
|
+
if (cache === undefined) {
|
|
45
|
+
cache = new Map();
|
|
46
|
+
interned.set(raw, cache);
|
|
47
|
+
}
|
|
48
|
+
const key = result * 4 + Number(dirty) * 2 + Number(mark?.touched === true);
|
|
49
|
+
let found = cache.get(key);
|
|
50
|
+
if (found === undefined)
|
|
51
|
+
cache.set(key, (found = create()));
|
|
52
|
+
return found;
|
|
53
|
+
},
|
|
54
|
+
origin: (state) => origins.get(state),
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
// Whether a state before validated as raw does, with the same result and label.
|
|
58
|
+
const alike = (before, raw, result) => before.result === result && before.raw.label === raw.label && sameChecks(before.raw, raw);
|
|
59
|
+
// The combined state with the inputs of its views first, the message of
|
|
60
|
+
// validation before those of the rules, once, dirty and touched; and, with
|
|
61
|
+
// externals, their errors apart and their warnings after its own. Its lists
|
|
62
|
+
// keep those the field published while their items are the same.
|
|
63
|
+
const published = (raw, message, dirty, held, mark) => {
|
|
64
|
+
const own = message === undefined || raw.errors[0] === message
|
|
65
|
+
? raw.errors
|
|
66
|
+
: [message, ...raw.errors.filter((error) => error !== message)];
|
|
67
|
+
const inputs = inputsOf(mark);
|
|
68
|
+
const errors = inputs === noInputs ? own : [...inputs, ...own];
|
|
69
|
+
const state = {
|
|
70
|
+
...raw,
|
|
71
|
+
errors: keptItems(errors, held?.errors),
|
|
72
|
+
dirty,
|
|
73
|
+
touched: mark?.touched ?? false,
|
|
74
|
+
};
|
|
75
|
+
const external = mark?.external;
|
|
76
|
+
if (external !== undefined) {
|
|
77
|
+
state.externalErrors = external.errors;
|
|
78
|
+
state.warnings = keptItems(merged(raw.warnings, external.warnings), held?.warnings);
|
|
79
|
+
}
|
|
80
|
+
return Object.freeze(state);
|
|
81
|
+
};
|
|
82
|
+
// Whether two published states have the same content.
|
|
83
|
+
const samePublished = (a, b) => {
|
|
84
|
+
if (a.dirty !== b.dirty || a.touched !== b.touched)
|
|
85
|
+
return false;
|
|
86
|
+
const keys = Object.keys(b);
|
|
87
|
+
if (keys.length !== Object.keys(a).length)
|
|
88
|
+
return false;
|
|
89
|
+
return keys.every((key) => {
|
|
90
|
+
const x = a[key];
|
|
91
|
+
const y = b[key];
|
|
92
|
+
return x === y || (Array.isArray(x) && Array.isArray(y) && sameItems(x, y));
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
// Whether a state was derived with a mark: touched, and the same inputs and
|
|
96
|
+
// external.
|
|
97
|
+
const sameMark = (state, origin, mark) => state.touched === (mark?.touched === true) &&
|
|
98
|
+
(origin?.inputs ?? noInputs) === inputsOf(mark) &&
|
|
99
|
+
origin?.external === mark?.external;
|
|
100
|
+
// One field: its type, its value and that of the baseline, absent in a row
|
|
101
|
+
// the baseline lacks, its combined state, the state it published, whether its
|
|
102
|
+
// value or its mark changed, and its mark. A field validates again only when
|
|
103
|
+
// its value changed or when its state changed what validation reads; dirty is
|
|
104
|
+
// compared again only when its value changed.
|
|
105
|
+
export const deriveField = (deriver, type, value, base, raw, held, changed, mark) => {
|
|
106
|
+
const origin = held === undefined ? undefined : deriver.origin(held);
|
|
107
|
+
const heldRaw = origin?.raw ?? held;
|
|
108
|
+
// The state held stays while what it derives from does: its value, its
|
|
109
|
+
// combined state and its mark, which a reset clears.
|
|
110
|
+
if (!changed && heldRaw === raw && sameMark(held, origin, mark))
|
|
111
|
+
return held;
|
|
112
|
+
const dirty = changed || held === undefined ? !equalIn(type, value, base) : held.dirty;
|
|
113
|
+
const result = !changed && heldRaw !== undefined && sameChecks(heldRaw, raw)
|
|
114
|
+
? (origin?.result ?? valid)
|
|
115
|
+
: validationOf(type, value, raw);
|
|
116
|
+
const next = deriver.state(raw, type, result, dirty, origin, held, mark);
|
|
117
|
+
// A state with the content the field published keeps its object: what
|
|
118
|
+
// changed is only what validation reads and does not publish, as the
|
|
119
|
+
// message of required.
|
|
120
|
+
return held !== undefined && next !== held && samePublished(held, next) ? held : next;
|
|
121
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type Deriver } from "./derived-fields.js";
|
|
2
|
+
import type { ScopeMarks } from "./marks.js";
|
|
3
|
+
import type { Fields } from "./definition.js";
|
|
4
|
+
import type { States } from "./states.js";
|
|
5
|
+
export declare const all = true;
|
|
6
|
+
export type Written = true | ReadonlySet<string> | Readonly<Record<string, unknown>> | undefined;
|
|
7
|
+
export declare const fieldNames: (fields: Fields) => readonly string[];
|
|
8
|
+
type Scope = {
|
|
9
|
+
readonly before: States | undefined;
|
|
10
|
+
readonly rawBefore: States | undefined;
|
|
11
|
+
readonly values: Readonly<Record<string, unknown>>;
|
|
12
|
+
readonly base: Readonly<Record<string, unknown>> | undefined;
|
|
13
|
+
readonly written: Written;
|
|
14
|
+
readonly marks: ScopeMarks | undefined;
|
|
15
|
+
readonly external: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare const deriveScope: (deriver: Deriver, fields: Fields, raw: States, scope: Scope, states?: States[string][]) => Readonly<Record<string, {
|
|
18
|
+
readonly disabled: boolean;
|
|
19
|
+
readonly readOnly: boolean;
|
|
20
|
+
readonly hidden: boolean;
|
|
21
|
+
readonly required: boolean;
|
|
22
|
+
readonly label: string | undefined;
|
|
23
|
+
readonly reasons: readonly string[];
|
|
24
|
+
readonly errors: readonly string[];
|
|
25
|
+
readonly externalErrors: readonly string[];
|
|
26
|
+
readonly warnings: readonly string[];
|
|
27
|
+
readonly dirty: boolean;
|
|
28
|
+
readonly touched: boolean;
|
|
29
|
+
} & {
|
|
30
|
+
readonly placeholder?: string | undefined;
|
|
31
|
+
readonly decimals?: number;
|
|
32
|
+
readonly min?: number | string;
|
|
33
|
+
readonly max?: number | string;
|
|
34
|
+
}>>;
|
|
35
|
+
export declare const deriveNames: (deriver: Deriver, fields: Fields, written: Iterable<string>, values: Readonly<Record<string, unknown>>, base: Readonly<Record<string, unknown>> | undefined, raw: States, before: States, marks: ScopeMarks | undefined, external: boolean) => Readonly<Record<string, {
|
|
36
|
+
readonly disabled: boolean;
|
|
37
|
+
readonly readOnly: boolean;
|
|
38
|
+
readonly hidden: boolean;
|
|
39
|
+
readonly required: boolean;
|
|
40
|
+
readonly label: string | undefined;
|
|
41
|
+
readonly reasons: readonly string[];
|
|
42
|
+
readonly errors: readonly string[];
|
|
43
|
+
readonly externalErrors: readonly string[];
|
|
44
|
+
readonly warnings: readonly string[];
|
|
45
|
+
readonly dirty: boolean;
|
|
46
|
+
readonly touched: boolean;
|
|
47
|
+
} & {
|
|
48
|
+
readonly placeholder?: string | undefined;
|
|
49
|
+
readonly decimals?: number;
|
|
50
|
+
readonly min?: number | string;
|
|
51
|
+
readonly max?: number | string;
|
|
52
|
+
}>>;
|
|
53
|
+
export declare const validatesNothing: (states: States) => boolean;
|
|
54
|
+
export declare const validatesAlike: (fields: Fields, before: States, after: States) => boolean;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// The states a scope publishes: those of each of its fields, derived from
|
|
2
|
+
// those they combine, in one object that the rows alike share.
|
|
3
|
+
import { defineOwn } from "./data.js";
|
|
4
|
+
import { deriveField } from "./derived-fields.js";
|
|
5
|
+
import { sameChecks } from "./validation.js";
|
|
6
|
+
// What changed of a scope: every field, the names written, none, or, at
|
|
7
|
+
// restore, the values published before, which each field compares with.
|
|
8
|
+
export const all = true;
|
|
9
|
+
const isWritten = (written, name, value) => written === true ||
|
|
10
|
+
(written instanceof Set
|
|
11
|
+
? written.has(name)
|
|
12
|
+
: written !== undefined && !Object.is(value, written[name]));
|
|
13
|
+
// The names of the fields of a scope, once per object of fields.
|
|
14
|
+
const namesOf = new WeakMap();
|
|
15
|
+
export const fieldNames = (fields) => {
|
|
16
|
+
let found = namesOf.get(fields);
|
|
17
|
+
if (found === undefined)
|
|
18
|
+
namesOf.set(fields, (found = Object.keys(fields)));
|
|
19
|
+
return found;
|
|
20
|
+
};
|
|
21
|
+
// Every field of a scope, keeping the object when no state changed. A field
|
|
22
|
+
// that published its combined state, whose value did not change and whose new
|
|
23
|
+
// combined state validates alike, publishes the new one as it is.
|
|
24
|
+
export const deriveScope = (deriver, fields, raw, scope, states = []) => {
|
|
25
|
+
const { before, rawBefore, values, base, written, marks, external } = scope;
|
|
26
|
+
const names = fieldNames(fields);
|
|
27
|
+
states.length = 0;
|
|
28
|
+
let kept = before !== undefined;
|
|
29
|
+
let combined = true;
|
|
30
|
+
for (const name of names) {
|
|
31
|
+
const held = before?.[name];
|
|
32
|
+
const state = raw[name];
|
|
33
|
+
const value = values[name];
|
|
34
|
+
const changed = isWritten(written, name, value);
|
|
35
|
+
const mark = marks?.get(name);
|
|
36
|
+
// A field that published its combined state, unmarked, keeps publishing it.
|
|
37
|
+
const next = !changed &&
|
|
38
|
+
held !== undefined &&
|
|
39
|
+
held === rawBefore?.[name] &&
|
|
40
|
+
mark === undefined &&
|
|
41
|
+
sameChecks(held, state)
|
|
42
|
+
? state
|
|
43
|
+
: deriveField(deriver, fields[name].type, value, base?.[name], state, held, changed, mark);
|
|
44
|
+
kept &&= next === held;
|
|
45
|
+
combined &&= next === state;
|
|
46
|
+
states.push(next);
|
|
47
|
+
}
|
|
48
|
+
if (kept)
|
|
49
|
+
return before;
|
|
50
|
+
// Fields that all publish as they combined share the combined states.
|
|
51
|
+
if (combined)
|
|
52
|
+
return raw;
|
|
53
|
+
const next = {};
|
|
54
|
+
for (const [index, name] of names.entries())
|
|
55
|
+
if (name === "__proto__")
|
|
56
|
+
defineOwn(next, name, states[index]);
|
|
57
|
+
else
|
|
58
|
+
next[name] = states[index];
|
|
59
|
+
return deriver.scope(raw, next, names, external);
|
|
60
|
+
};
|
|
61
|
+
// The written fields of a scope whose combined states did not change: only
|
|
62
|
+
// they derive again, on a copy of the states published.
|
|
63
|
+
export const deriveNames = (deriver, fields, written, values, base, raw, before, marks, external) => {
|
|
64
|
+
let next;
|
|
65
|
+
for (const name of written) {
|
|
66
|
+
const state = deriveField(deriver, fields[name].type, values[name], base?.[name], raw[name], before[name], true, marks?.get(name));
|
|
67
|
+
if (state === before[name])
|
|
68
|
+
continue;
|
|
69
|
+
next ??= { ...before };
|
|
70
|
+
if (name === "__proto__")
|
|
71
|
+
defineOwn(next, name, state);
|
|
72
|
+
else
|
|
73
|
+
next[name] = state;
|
|
74
|
+
}
|
|
75
|
+
if (next === undefined)
|
|
76
|
+
return before;
|
|
77
|
+
const names = fieldNames(fields);
|
|
78
|
+
// Fields that all publish as they combined share the combined states.
|
|
79
|
+
const derived = next;
|
|
80
|
+
return names.every((name) => derived[name] === raw[name])
|
|
81
|
+
? raw
|
|
82
|
+
: deriver.scope(raw, derived, names, external);
|
|
83
|
+
};
|
|
84
|
+
// Whether no field of a scope validates, once per object of states, which rows
|
|
85
|
+
// alike share.
|
|
86
|
+
const unvalidated = new WeakMap();
|
|
87
|
+
export const validatesNothing = (states) => {
|
|
88
|
+
let found = unvalidated.get(states);
|
|
89
|
+
if (found === undefined) {
|
|
90
|
+
found = true;
|
|
91
|
+
for (const name in states) {
|
|
92
|
+
const state = states[name];
|
|
93
|
+
if (state.required || state.min !== undefined || state.max !== undefined)
|
|
94
|
+
found = false;
|
|
95
|
+
}
|
|
96
|
+
unvalidated.set(states, found);
|
|
97
|
+
}
|
|
98
|
+
return found;
|
|
99
|
+
};
|
|
100
|
+
// Whether the new combined states of a scope validate as those before.
|
|
101
|
+
export const validatesAlike = (fields, before, after) => fieldNames(fields).every((name) => {
|
|
102
|
+
const was = before[name];
|
|
103
|
+
const is = after[name];
|
|
104
|
+
return was === is || sameChecks(was, is);
|
|
105
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Address, Field, Row } from "./address.js";
|
|
2
|
+
import { type Marks } from "./marks.js";
|
|
3
|
+
import type { Compiled } from "./compiled.js";
|
|
4
|
+
import type { Deriver } from "./derived-fields.js";
|
|
5
|
+
import type { Published } from "./publication.js";
|
|
6
|
+
import { type RowMap } from "./row-maps.js";
|
|
7
|
+
import type { States } from "./states.js";
|
|
8
|
+
import { type Store } from "./tree.js";
|
|
9
|
+
export type Derived = {
|
|
10
|
+
readonly fieldStates: Readonly<Record<string, unknown>>;
|
|
11
|
+
readonly derivedHeader: States;
|
|
12
|
+
readonly derivedRows: RowMap<States>;
|
|
13
|
+
readonly baseline: Store;
|
|
14
|
+
readonly marks: Marks;
|
|
15
|
+
};
|
|
16
|
+
export type Marking = {
|
|
17
|
+
readonly marks: Marks;
|
|
18
|
+
readonly addresses: ReadonlySet<Field>;
|
|
19
|
+
};
|
|
20
|
+
export type Derivation = {
|
|
21
|
+
readonly store: Store;
|
|
22
|
+
readonly baseline: Store;
|
|
23
|
+
readonly raw: Published;
|
|
24
|
+
readonly previous: (Published & Derived & {
|
|
25
|
+
readonly store: Store;
|
|
26
|
+
}) | undefined;
|
|
27
|
+
readonly changed: ReadonlySet<Address> | undefined;
|
|
28
|
+
readonly rows: Recombined | undefined;
|
|
29
|
+
readonly unchecked: boolean;
|
|
30
|
+
readonly marks: Marks;
|
|
31
|
+
};
|
|
32
|
+
export type Recombined = {
|
|
33
|
+
readonly recombined: ReadonlySet<Row> | undefined;
|
|
34
|
+
readonly removed: readonly Row[];
|
|
35
|
+
};
|
|
36
|
+
export declare const deriveStates: (compiled: Compiled, deriver: Deriver, derivation: Derivation) => {
|
|
37
|
+
fieldStates: Readonly<{}>;
|
|
38
|
+
derivedHeader: Readonly<Record<string, {
|
|
39
|
+
readonly disabled: boolean;
|
|
40
|
+
readonly readOnly: boolean;
|
|
41
|
+
readonly hidden: boolean;
|
|
42
|
+
readonly required: boolean;
|
|
43
|
+
readonly label: string | undefined;
|
|
44
|
+
readonly reasons: readonly string[];
|
|
45
|
+
readonly errors: readonly string[];
|
|
46
|
+
readonly externalErrors: readonly string[];
|
|
47
|
+
readonly warnings: readonly string[];
|
|
48
|
+
readonly dirty: boolean;
|
|
49
|
+
readonly touched: boolean;
|
|
50
|
+
} & {
|
|
51
|
+
readonly placeholder?: string | undefined;
|
|
52
|
+
readonly decimals?: number;
|
|
53
|
+
readonly min?: number | string;
|
|
54
|
+
readonly max?: number | string;
|
|
55
|
+
}>>;
|
|
56
|
+
derivedRows: RowMap<Readonly<Record<string, {
|
|
57
|
+
readonly disabled: boolean;
|
|
58
|
+
readonly readOnly: boolean;
|
|
59
|
+
readonly hidden: boolean;
|
|
60
|
+
readonly required: boolean;
|
|
61
|
+
readonly label: string | undefined;
|
|
62
|
+
readonly reasons: readonly string[];
|
|
63
|
+
readonly errors: readonly string[];
|
|
64
|
+
readonly externalErrors: readonly string[];
|
|
65
|
+
readonly warnings: readonly string[];
|
|
66
|
+
readonly dirty: boolean;
|
|
67
|
+
readonly touched: boolean;
|
|
68
|
+
} & {
|
|
69
|
+
readonly placeholder?: string | undefined;
|
|
70
|
+
readonly decimals?: number;
|
|
71
|
+
readonly min?: number | string;
|
|
72
|
+
readonly max?: number | string;
|
|
73
|
+
}>>>;
|
|
74
|
+
counted: Set<Row>;
|
|
75
|
+
};
|
|
76
|
+
export declare const marksOf: (previous: Marks | undefined, marking: Marking | undefined, changed: ReadonlySet<Address> | undefined, removed: readonly Row[]) => Marks;
|