simpler-forms 0.1.0-alpha.0 → 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/README.md +221 -76
- package/dist/src/casing.d.ts +43 -0
- package/dist/src/casing.js +146 -0
- package/dist/src/casing.js.map +1 -0
- package/dist/src/decorators/index.d.ts +1 -0
- package/dist/src/decorators/index.js +1 -0
- package/dist/src/decorators/index.js.map +1 -1
- package/dist/src/decorators/mapping.d.ts +11 -0
- package/dist/src/decorators/mapping.js +22 -0
- package/dist/src/decorators/mapping.js.map +1 -0
- package/dist/src/decorators/meta.d.ts +13 -3
- package/dist/src/decorators/meta.js +31 -4
- package/dist/src/decorators/meta.js.map +1 -1
- package/dist/src/decorators/shared.d.ts +10 -0
- package/dist/src/decorators/shared.js +8 -0
- package/dist/src/decorators/shared.js.map +1 -1
- package/dist/src/decorators/ui.d.ts +33 -12
- package/dist/src/decorators/ui.js +39 -43
- package/dist/src/decorators/ui.js.map +1 -1
- package/dist/src/emitter.d.ts +8 -0
- package/dist/src/emitter.js +48 -13
- package/dist/src/emitter.js.map +1 -1
- package/dist/src/emitters/block-ui.d.ts +17 -3
- package/dist/src/emitters/block-ui.js +144 -124
- package/dist/src/emitters/block-ui.js.map +1 -1
- package/dist/src/emitters/layout-ui.d.ts +12 -0
- package/dist/src/emitters/layout-ui.js +225 -0
- package/dist/src/emitters/layout-ui.js.map +1 -0
- package/dist/src/emitters/overlay.d.ts +3 -6
- package/dist/src/emitters/overlay.js +3 -86
- package/dist/src/emitters/overlay.js.map +1 -1
- package/dist/src/forms.d.ts +23 -0
- package/dist/src/forms.js +54 -0
- package/dist/src/forms.js.map +1 -0
- package/dist/src/index.d.ts +17 -6
- package/dist/src/index.js +14 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/layout.d.ts +50 -0
- package/dist/src/layout.js +397 -0
- package/dist/src/layout.js.map +1 -0
- package/dist/src/lib.d.ts +485 -39
- package/dist/src/lib.js +216 -16
- package/dist/src/lib.js.map +1 -1
- package/dist/src/linter.js +2 -41
- package/dist/src/linter.js.map +1 -1
- package/dist/src/mapping-from.d.ts +20 -0
- package/dist/src/mapping-from.js +149 -0
- package/dist/src/mapping-from.js.map +1 -0
- package/dist/src/mapping.d.ts +58 -0
- package/dist/src/mapping.js +209 -0
- package/dist/src/mapping.js.map +1 -0
- package/dist/src/model.d.ts +87 -9
- package/dist/src/model.js +65 -10
- package/dist/src/model.js.map +1 -1
- package/dist/src/public.d.ts +19 -3
- package/dist/src/public.js +27 -3
- package/dist/src/public.js.map +1 -1
- package/dist/src/validate.d.ts +2 -1
- package/dist/src/validate.js +181 -59
- package/dist/src/validate.js.map +1 -1
- package/lib/main.tsp +1 -0
- package/lib/mapping.tsp +71 -0
- package/lib/meta.tsp +23 -4
- package/lib/types.tsp +13 -65
- package/lib/ui.tsp +60 -17
- package/package.json +7 -1
- package/src/casing.ts +172 -0
- package/src/decorators/index.ts +1 -0
- package/src/decorators/mapping.ts +57 -0
- package/src/decorators/meta.ts +50 -11
- package/src/decorators/shared.ts +13 -0
- package/src/decorators/ui.ts +81 -59
- package/src/emitter.ts +59 -13
- package/src/emitters/block-ui.ts +156 -140
- package/src/emitters/layout-ui.ts +280 -0
- package/src/emitters/overlay.ts +3 -103
- package/src/forms.ts +82 -0
- package/src/index.ts +14 -3
- package/src/layout.ts +592 -0
- package/src/lib.ts +222 -16
- package/src/linter.ts +1 -42
- package/src/mapping-from.ts +193 -0
- package/src/mapping.ts +351 -0
- package/src/model.ts +192 -24
- package/src/public.ts +50 -5
- package/src/validate.ts +189 -60
- package/dist/src/emitters/override-condition.d.ts +0 -12
- package/dist/src/emitters/override-condition.js +0 -25
- package/dist/src/emitters/override-condition.js.map +0 -1
- package/src/emitters/override-condition.ts +0 -37
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { getDoc } from "@typespec/compiler";
|
|
2
|
-
import { childBlock,
|
|
3
|
-
|
|
2
|
+
import { childBlock, modelLabel, modelOrder, modelProperties, propEnabledWhen, propLabel, propOmit, propReadOnly, propReadOnlyWhen, propVisibleWhen, propWidget, readBlock, } from "../model.js";
|
|
3
|
+
/** An answered value: not null, not blank, not an empty list. */
|
|
4
|
+
const answeredSchema = {
|
|
5
|
+
not: {
|
|
6
|
+
anyOf: [{ type: "null" }, { const: "" }, { type: "array", maxItems: 0 }],
|
|
7
|
+
},
|
|
8
|
+
};
|
|
4
9
|
const conditionSchema = (condition) => condition.operator === "in"
|
|
5
10
|
? { enum: condition.values }
|
|
6
11
|
: condition.operator === "countAtLeast"
|
|
7
12
|
? { type: "array", minItems: condition.minimum }
|
|
8
13
|
: condition.operator === "present"
|
|
9
|
-
?
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
],
|
|
16
|
-
},
|
|
17
|
-
}
|
|
18
|
-
: { const: condition.value };
|
|
14
|
+
? answeredSchema
|
|
15
|
+
: condition.operator === "notEquals"
|
|
16
|
+
? condition.requiresAnswer
|
|
17
|
+
? { allOf: [answeredSchema, { not: { const: condition.value } }] }
|
|
18
|
+
: { not: { const: condition.value } }
|
|
19
|
+
: { const: condition.value };
|
|
19
20
|
/** A condition over the block root, used only for the bounded cross-field disjunction. */
|
|
20
21
|
const rootConditionSchema = (condition) => {
|
|
21
22
|
let schema = conditionSchema(condition);
|
|
@@ -24,7 +25,7 @@ const rootConditionSchema = (condition) => {
|
|
|
24
25
|
}
|
|
25
26
|
return schema;
|
|
26
27
|
};
|
|
27
|
-
const jsonFormsCondition = (condition) => condition.operator === "any"
|
|
28
|
+
export const jsonFormsCondition = (condition) => condition.operator === "any"
|
|
28
29
|
? {
|
|
29
30
|
scope: "#",
|
|
30
31
|
schema: { anyOf: condition.predicates.map(rootConditionSchema) },
|
|
@@ -32,50 +33,11 @@ const jsonFormsCondition = (condition) => condition.operator === "any"
|
|
|
32
33
|
: {
|
|
33
34
|
scope: `#/${condition.sourcePath.map((step) => `properties/${step}`).join("/")}`,
|
|
34
35
|
schema: conditionSchema(condition),
|
|
36
|
+
// JSON Forms passes a condition whose source is absent unless told otherwise.
|
|
37
|
+
...(condition.operator === "notEquals" && condition.requiresAnswer
|
|
38
|
+
? { failWhenUndefined: true }
|
|
39
|
+
: {}),
|
|
35
40
|
};
|
|
36
|
-
/** Convert a canonical JSON Forms scope into the dotted path addressed by @UI.overrides. */
|
|
37
|
-
const dataPathFromScope = (scope) => {
|
|
38
|
-
if (!scope.startsWith("#/properties/"))
|
|
39
|
-
return undefined;
|
|
40
|
-
const tokens = scope.slice(2).split("/");
|
|
41
|
-
const path = [];
|
|
42
|
-
for (let index = 0; index < tokens.length;) {
|
|
43
|
-
if (tokens[index] !== "properties" || !tokens[index + 1])
|
|
44
|
-
return undefined;
|
|
45
|
-
path.push(tokens[index + 1]);
|
|
46
|
-
index += 2;
|
|
47
|
-
if (tokens[index] === "items")
|
|
48
|
-
index += 1;
|
|
49
|
-
}
|
|
50
|
-
return path.join(".");
|
|
51
|
-
};
|
|
52
|
-
/** Emit the portable JSON Forms equivalent of a form-scoped enabledWhen override. */
|
|
53
|
-
const overrideEnabledRule = (override) => {
|
|
54
|
-
const condition = normalizedOverrideEnabledWhen(override);
|
|
55
|
-
if (!condition)
|
|
56
|
-
return undefined;
|
|
57
|
-
const scope = `#/${condition.sourcePath.map((step) => `properties/${step}`).join("/")}`;
|
|
58
|
-
const schema = condition.operator === "in"
|
|
59
|
-
? { enum: condition.values }
|
|
60
|
-
: { const: condition.value };
|
|
61
|
-
return { effect: "ENABLE", condition: { scope, schema } };
|
|
62
|
-
};
|
|
63
|
-
/** Apply occurrence-specific behavior after recursively composing canonical child UI trees. */
|
|
64
|
-
const applyOverrides = (node, overrides) => {
|
|
65
|
-
const out = { ...node };
|
|
66
|
-
if (typeof node.scope === "string") {
|
|
67
|
-
const path = dataPathFromScope(node.scope);
|
|
68
|
-
const rule = path ? overrideEnabledRule(overrides[path] ?? {}) : undefined;
|
|
69
|
-
if (rule && node.rule) {
|
|
70
|
-
throw new Error(`@UI.overrides enabledWhen collides with intrinsic UI behavior at ${path}`);
|
|
71
|
-
}
|
|
72
|
-
if (rule)
|
|
73
|
-
out.rule = rule;
|
|
74
|
-
}
|
|
75
|
-
if (node.elements)
|
|
76
|
-
out.elements = node.elements.map((child) => applyOverrides(child, overrides));
|
|
77
|
-
return out;
|
|
78
|
-
};
|
|
79
41
|
/** Re-prefix every Control scope so a child's tree sits under `propName`. */
|
|
80
42
|
export function rescopeUi(node, propName) {
|
|
81
43
|
const out = { ...node };
|
|
@@ -110,94 +72,152 @@ export function rescopeUi(node, propName) {
|
|
|
110
72
|
return out;
|
|
111
73
|
}
|
|
112
74
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
75
|
+
* Every property a model's answers carry, inherited ones included, in `@UI.order`.
|
|
76
|
+
*
|
|
77
|
+
* Not `orderedProps`, which keeps a question to its own properties because its JSON Schema
|
|
78
|
+
* composes the base through `allOf`. A layout has no `allOf` to fall back on: a question
|
|
79
|
+
* whose fields are all inherited -- `primary-org/address` extends `generics/address` and adds
|
|
80
|
+
* none -- would lay out as an empty group, and a form-local extension could not interleave
|
|
81
|
+
* its fields with the ones it inherits.
|
|
115
82
|
*/
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
83
|
+
function layoutProps(program, model) {
|
|
84
|
+
const props = modelProperties(model).filter((p) => !propOmit(program, p));
|
|
85
|
+
const order = modelOrder(program, model);
|
|
86
|
+
if (!order)
|
|
87
|
+
return props;
|
|
88
|
+
const byName = new Map(props.map((p) => [p.name, p]));
|
|
89
|
+
const out = order
|
|
90
|
+
.map((n) => byName.get(n))
|
|
91
|
+
.filter(Boolean);
|
|
92
|
+
for (const p of props)
|
|
93
|
+
if (!out.includes(p))
|
|
94
|
+
out.push(p);
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
/** A model laid out as a block would be, whether or not it is one. */
|
|
98
|
+
export const layoutSource = (program, model) => readBlock(program, model) ?? {
|
|
99
|
+
model,
|
|
100
|
+
scalar: false,
|
|
101
|
+
label: modelLabel(program, model),
|
|
102
|
+
doc: getDoc(program, model),
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* The layout of one entry of a repeated property, which JSON Forms reads from a list
|
|
106
|
+
* control's `options.detail`. Its scopes are relative to the entry rather than the form, so
|
|
107
|
+
* it is not re-scoped when the list is composed into a larger block.
|
|
108
|
+
*
|
|
109
|
+
* Without it a renderer has nothing to order the entry's fields by but the item schema, and
|
|
110
|
+
* a composed item spreads its fields across `allOf` branches.
|
|
111
|
+
*/
|
|
112
|
+
function itemDetail(program, prop) {
|
|
113
|
+
const type = prop.type;
|
|
114
|
+
if (type.kind !== "Model" || !type.indexer)
|
|
115
|
+
return undefined;
|
|
116
|
+
const item = type.indexer.value;
|
|
117
|
+
// A list of scalars has no fields of its own to lay out.
|
|
118
|
+
if (item.kind !== "Model")
|
|
119
|
+
return undefined;
|
|
120
|
+
return emitBlockUi(program, layoutSource(program, item));
|
|
121
|
+
}
|
|
122
|
+
/** The model a property's fields lay out from: a composed question, or a model of the form's own. */
|
|
123
|
+
function fieldSource(program, prop) {
|
|
124
|
+
const child = childBlock(program, prop);
|
|
125
|
+
if (child)
|
|
126
|
+
return child.scalar ? undefined : child;
|
|
127
|
+
const type = prop.type;
|
|
128
|
+
if (type.kind !== "Model" || type.indexer)
|
|
129
|
+
return undefined;
|
|
130
|
+
return layoutSource(program, type);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* One property as its model lays it out, scoped to that model: a Group of a composed
|
|
134
|
+
* question's fields, or of a model the form declares itself, or a Control.
|
|
135
|
+
*
|
|
136
|
+
* A Group takes the property's label before the question's, and the property's doc comment
|
|
137
|
+
* as its description, so a question asked in several roles is told apart by role.
|
|
138
|
+
*/
|
|
139
|
+
export function propertyUi(program, prop) {
|
|
140
|
+
const child = fieldSource(program, prop);
|
|
141
|
+
if (child) {
|
|
142
|
+
const group = rescopeUi(emitBlockUi(program, child), prop.name);
|
|
133
143
|
const label = propLabel(program, prop);
|
|
134
144
|
if (label)
|
|
135
|
-
|
|
145
|
+
group.label = label;
|
|
146
|
+
const description = getDoc(program, prop);
|
|
136
147
|
const widget = propWidget(program, prop);
|
|
137
|
-
if (widget)
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
148
|
+
if (description || widget)
|
|
149
|
+
group.options = {
|
|
150
|
+
...(group.options ?? {}),
|
|
151
|
+
...(description ? { description } : {}),
|
|
152
|
+
...(widget ? { widget } : {}),
|
|
153
|
+
};
|
|
154
|
+
return group;
|
|
155
|
+
}
|
|
156
|
+
const node = {
|
|
157
|
+
type: "Control",
|
|
158
|
+
scope: `#/properties/${prop.name}`,
|
|
159
|
+
};
|
|
160
|
+
const label = propLabel(program, prop);
|
|
161
|
+
if (label)
|
|
162
|
+
node.label = label;
|
|
163
|
+
const detail = itemDetail(program, prop);
|
|
164
|
+
if (detail)
|
|
165
|
+
node.options = { ...(node.options ?? {}), detail };
|
|
166
|
+
const widget = propWidget(program, prop);
|
|
167
|
+
if (widget)
|
|
168
|
+
node.options = { ...(node.options ?? {}), widget };
|
|
169
|
+
if (propReadOnly(program, prop))
|
|
170
|
+
node.options = { ...(node.options ?? {}), readonly: true };
|
|
171
|
+
const conds = propVisibleWhen(program, prop);
|
|
172
|
+
if (conds.length === 1) {
|
|
173
|
+
const c = conds[0];
|
|
174
|
+
node.rule = {
|
|
175
|
+
effect: "SHOW",
|
|
176
|
+
condition: jsonFormsCondition(c),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
const enabled = propEnabledWhen(program, prop);
|
|
181
|
+
if (enabled.length === 1) {
|
|
182
|
+
const c = enabled[0];
|
|
144
183
|
node.rule = {
|
|
145
|
-
effect: "
|
|
184
|
+
effect: "ENABLE",
|
|
146
185
|
condition: jsonFormsCondition(c),
|
|
147
186
|
};
|
|
148
187
|
}
|
|
149
188
|
else {
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
152
|
-
const c =
|
|
189
|
+
const readOnly = propReadOnlyWhen(program, prop);
|
|
190
|
+
if (readOnly.length === 1) {
|
|
191
|
+
const c = readOnly[0];
|
|
153
192
|
node.rule = {
|
|
154
|
-
effect: "
|
|
193
|
+
effect: "DISABLE",
|
|
155
194
|
condition: jsonFormsCondition(c),
|
|
156
195
|
};
|
|
157
196
|
}
|
|
158
|
-
else {
|
|
159
|
-
const readOnly = propReadOnlyWhen(program, prop);
|
|
160
|
-
if (readOnly.length === 1) {
|
|
161
|
-
const c = readOnly[0];
|
|
162
|
-
node.rule = {
|
|
163
|
-
effect: "DISABLE",
|
|
164
|
-
condition: jsonFormsCondition(c),
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return node;
|
|
170
|
-
};
|
|
171
|
-
const props = orderedProps(program, block);
|
|
172
|
-
const elements = [];
|
|
173
|
-
const documentedStaticSections = block.sections
|
|
174
|
-
? [...block.sections.members.values()].filter((member) => getDoc(program, member) &&
|
|
175
|
-
!props.some((prop) => propSection(program, prop)?.name === member.name))
|
|
176
|
-
: [];
|
|
177
|
-
if (documentedStaticSections.length && block.sections) {
|
|
178
|
-
const emitted = new Set();
|
|
179
|
-
for (const member of block.sections.members.values()) {
|
|
180
|
-
const description = getDoc(program, member);
|
|
181
|
-
const members = props.filter((prop) => propSection(program, prop)?.name === member.name);
|
|
182
|
-
if (!members.length && description)
|
|
183
|
-
elements.push({ type: "Label", text: description });
|
|
184
|
-
for (const prop of members) {
|
|
185
|
-
elements.push(nodeForProperty(prop));
|
|
186
|
-
emitted.add(prop.name);
|
|
187
|
-
}
|
|
188
197
|
}
|
|
189
|
-
for (const prop of props)
|
|
190
|
-
if (!emitted.has(prop.name))
|
|
191
|
-
elements.push(nodeForProperty(prop));
|
|
192
198
|
}
|
|
193
|
-
|
|
194
|
-
|
|
199
|
+
return node;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* The canonical UI artifact for one block. Scopes are relative to this block's own
|
|
203
|
+
* root, so it renders standalone; children are incorporated and re-scoped.
|
|
204
|
+
*/
|
|
205
|
+
export function emitBlockUi(program, block) {
|
|
206
|
+
// A single-value question renders as one Control at its own root.
|
|
207
|
+
if (block.scalar) {
|
|
208
|
+
const node = { type: "Control", scope: "#" };
|
|
209
|
+
if (block.label)
|
|
210
|
+
node.label = block.label;
|
|
211
|
+
return node;
|
|
195
212
|
}
|
|
213
|
+
const nodeForProperty = (prop) => propertyUi(program, prop);
|
|
214
|
+
const props = block.model.kind === "Model" ? layoutProps(program, block.model) : [];
|
|
215
|
+
const elements = props.map(nodeForProperty);
|
|
196
216
|
const group = { type: "Group", elements };
|
|
197
217
|
if (block.label)
|
|
198
218
|
group.label = block.label;
|
|
199
219
|
else if (block.doc)
|
|
200
220
|
group.label = block.doc;
|
|
201
|
-
return
|
|
221
|
+
return group;
|
|
202
222
|
}
|
|
203
223
|
//# sourceMappingURL=block-ui.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block-ui.js","sourceRoot":"","sources":["../../../src/emitters/block-ui.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAIL,UAAU,EACV,
|
|
1
|
+
{"version":3,"file":"block-ui.js","sourceRoot":"","sources":["../../../src/emitters/block-ui.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAIL,UAAU,EACV,UAAU,EACV,UAAU,EACV,eAAe,EACf,eAAe,EACf,SAAS,EACT,QAAQ,EACR,YAAY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,GAAG,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAE5C,MAAM,KAAK,GAAW,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;IAClD,IAAI,KAAK,CAAC,KAAK;QAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;SACtC,IAAI,KAAK,CAAC,GAAG;QAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;IAC5C,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Diagnostic, Program } from "@typespec/compiler";
|
|
2
|
+
import { type ResolvedLayout } from "../layout.js";
|
|
3
|
+
import { type UiNode } from "./block-ui.js";
|
|
4
|
+
/**
|
|
5
|
+
* The JSON Forms UI for a layout. Each section is a top-level labelled Group. A field is laid
|
|
6
|
+
* out as its model lays it out, less whatever the layout places elsewhere or omits, with the
|
|
7
|
+
* entry's label, help text, widget and condition on top.
|
|
8
|
+
*/
|
|
9
|
+
export declare function emitLayoutUi(program: Program, layout: ResolvedLayout): {
|
|
10
|
+
ui: UiNode;
|
|
11
|
+
diagnostics: Diagnostic[];
|
|
12
|
+
};
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { getDoc } from "@typespec/compiler";
|
|
2
|
+
import { createDiagnostic } from "../lib.js";
|
|
3
|
+
import { behind, isList, } from "../layout.js";
|
|
4
|
+
import { modelLabel, propHelpText, propLabel, propWidget, readBlock, } from "../model.js";
|
|
5
|
+
import { emitBlockUi, jsonFormsCondition, layoutSource, propertyUi, rescopeUi, } from "./block-ui.js";
|
|
6
|
+
const key = (path) => path.join(".");
|
|
7
|
+
const emitted = new WeakMap();
|
|
8
|
+
/**
|
|
9
|
+
* The JSON Forms UI for a layout. Each section is a top-level labelled Group. A field is laid
|
|
10
|
+
* out as its model lays it out, less whatever the layout places elsewhere or omits, with the
|
|
11
|
+
* entry's label, help text, widget and condition on top.
|
|
12
|
+
*/
|
|
13
|
+
export function emitLayoutUi(program, layout) {
|
|
14
|
+
let result = emitted.get(layout);
|
|
15
|
+
if (!result)
|
|
16
|
+
emitted.set(layout, (result = build(program, layout)));
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
function build(program, layout) {
|
|
20
|
+
const excluded = [...layout.placed, ...layout.omitted];
|
|
21
|
+
/** What is placed elsewhere or omitted from inside the field at `path`. */
|
|
22
|
+
const excludedUnder = (path) => excluded.filter((k) => k.startsWith(`${key(path)}.`));
|
|
23
|
+
const help = (entry) => propHelpText(program, entry) ?? getDoc(program, entry);
|
|
24
|
+
/** Apply what an entry says about how its field is presented. */
|
|
25
|
+
const present = (ui, node, fallbackLabel) => {
|
|
26
|
+
const out = { ...ui };
|
|
27
|
+
const label = propLabel(program, node.entry) ?? fallbackLabel;
|
|
28
|
+
if (label)
|
|
29
|
+
out.label = label;
|
|
30
|
+
const description = help(node.entry);
|
|
31
|
+
const widget = propWidget(program, node.entry);
|
|
32
|
+
if (description || widget)
|
|
33
|
+
out.options = {
|
|
34
|
+
...(out.options ?? {}),
|
|
35
|
+
...(description ? { description } : {}),
|
|
36
|
+
...(widget ? { widget } : {}),
|
|
37
|
+
};
|
|
38
|
+
// A layout's condition replaces the field's own for this occurrence.
|
|
39
|
+
if (node.condition)
|
|
40
|
+
out.rule = {
|
|
41
|
+
effect: node.condition.effect,
|
|
42
|
+
condition: jsonFormsCondition(node.condition.condition),
|
|
43
|
+
};
|
|
44
|
+
return out;
|
|
45
|
+
};
|
|
46
|
+
/** The fields of `node`'s type that no entry lists, in their model's order. */
|
|
47
|
+
const remaining = (node) => {
|
|
48
|
+
const inner = behind(node.prop.type);
|
|
49
|
+
if (!inner)
|
|
50
|
+
return [];
|
|
51
|
+
const list = isList(node.prop.type);
|
|
52
|
+
const base = list ? node.path : node.scopeBase;
|
|
53
|
+
const steps = list ? [] : node.path.slice(node.scopeBase.length);
|
|
54
|
+
const own = emitBlockUi(program, layoutSource(program, inner));
|
|
55
|
+
// A single-value question has no fields to lay out.
|
|
56
|
+
if (!own.elements)
|
|
57
|
+
return [];
|
|
58
|
+
return own.elements
|
|
59
|
+
.map((child) => rescopeAll(child, steps))
|
|
60
|
+
.map((child) => prune(child, base, excludedUnder(node.path)))
|
|
61
|
+
.filter((child) => !!child);
|
|
62
|
+
};
|
|
63
|
+
const fieldUi = (node) => {
|
|
64
|
+
const own = rescopeAll(propertyUi(program, node.prop), node.path.slice(node.scopeBase.length, -1));
|
|
65
|
+
let ui;
|
|
66
|
+
if (node.listed) {
|
|
67
|
+
const elements = [...node.listed.flatMap(nodeUi), ...remaining(node)];
|
|
68
|
+
if (isList(node.prop.type)) {
|
|
69
|
+
ui = {
|
|
70
|
+
...own,
|
|
71
|
+
options: {
|
|
72
|
+
...(own.options ?? {}),
|
|
73
|
+
detail: { type: "Group", elements },
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
else if (own.type === "Group") {
|
|
78
|
+
ui = { ...own, elements };
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
// A field that lays out as one Control becomes a Group once a layout lists entries in it.
|
|
82
|
+
const inner = behind(node.prop.type);
|
|
83
|
+
const label = propLabel(program, node.prop) ??
|
|
84
|
+
(inner ? modelLabel(program, inner) : undefined);
|
|
85
|
+
const description = getDoc(program, node.prop);
|
|
86
|
+
ui = {
|
|
87
|
+
type: "Group",
|
|
88
|
+
...(label ? { label } : {}),
|
|
89
|
+
elements,
|
|
90
|
+
...(description ? { options: { description } } : {}),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
ui = prune(own, node.scopeBase, excludedUnder(node.path));
|
|
96
|
+
}
|
|
97
|
+
if (!ui)
|
|
98
|
+
return [];
|
|
99
|
+
ui = present(ui, node);
|
|
100
|
+
if (node.flatten && ui.type === "Group" && !isList(node.prop.type)) {
|
|
101
|
+
const rule = ui.rule;
|
|
102
|
+
return (ui.elements ?? []).map((child) => rule && !child.rule ? { ...child, rule } : child);
|
|
103
|
+
}
|
|
104
|
+
return [ui];
|
|
105
|
+
};
|
|
106
|
+
const nodeUi = (node) => node.kind === "field"
|
|
107
|
+
? fieldUi(node)
|
|
108
|
+
: [
|
|
109
|
+
present({ type: "Group", elements: node.children.flatMap(nodeUi) }, node, node.entry.name),
|
|
110
|
+
];
|
|
111
|
+
/** A section is always a labelled Group, so a renderer shows it as one. */
|
|
112
|
+
const sectionUi = (node) => {
|
|
113
|
+
const flat = node.kind === "field" ? { ...node, flatten: false } : node;
|
|
114
|
+
return nodeUi(flat).map((ui) => {
|
|
115
|
+
if (ui.type === "Group" && ui.label)
|
|
116
|
+
return ui;
|
|
117
|
+
if (ui.type === "Group")
|
|
118
|
+
return { ...ui, label: node.entry.name };
|
|
119
|
+
// The section carries the control's rule and description: they are about the section.
|
|
120
|
+
const { rule, ...control } = ui;
|
|
121
|
+
const { description, ...options } = control.options ?? {};
|
|
122
|
+
if (control.options)
|
|
123
|
+
if (Object.keys(options).length)
|
|
124
|
+
control.options = options;
|
|
125
|
+
else
|
|
126
|
+
delete control.options;
|
|
127
|
+
const label = propLabel(program, node.entry) ??
|
|
128
|
+
(node.kind === "field"
|
|
129
|
+
? (propLabel(program, node.prop) ?? node.prop.name)
|
|
130
|
+
: node.entry.name);
|
|
131
|
+
return {
|
|
132
|
+
type: "Group",
|
|
133
|
+
label,
|
|
134
|
+
elements: [control],
|
|
135
|
+
...(rule ? { rule } : {}),
|
|
136
|
+
...(description ? { options: { description } } : {}),
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
const block = readBlock(program, layout.presented);
|
|
141
|
+
const label = modelLabel(program, layout.layout) ?? block?.label ?? block?.doc;
|
|
142
|
+
const ui = {
|
|
143
|
+
type: "Group",
|
|
144
|
+
elements: layout.sections.flatMap(sectionUi),
|
|
145
|
+
...(label ? { label } : {}),
|
|
146
|
+
};
|
|
147
|
+
return { ui, diagnostics: duplicateLabels(layout, ui) };
|
|
148
|
+
}
|
|
149
|
+
/** Re-prefix a node's scopes with each of `steps`, outermost first. */
|
|
150
|
+
function rescopeAll(node, steps) {
|
|
151
|
+
return [...steps].reverse().reduce(rescopeUi, node);
|
|
152
|
+
}
|
|
153
|
+
/** The data path a Control's scope addresses, relative to its root. */
|
|
154
|
+
function dataPath(scope) {
|
|
155
|
+
const tokens = scope.replace(/^#\/?/, "").split("/").filter(Boolean);
|
|
156
|
+
const path = [];
|
|
157
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
158
|
+
if (tokens[i] === "properties" && tokens[i + 1])
|
|
159
|
+
path.push(tokens[++i]);
|
|
160
|
+
}
|
|
161
|
+
return path;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Drop every Control whose path is excluded, and any Group left empty by that. `base` is the
|
|
165
|
+
* path the node's scopes are relative to.
|
|
166
|
+
*/
|
|
167
|
+
function prune(node, base, excluded) {
|
|
168
|
+
if (!excluded.length)
|
|
169
|
+
return node;
|
|
170
|
+
const out = { ...node };
|
|
171
|
+
if (node.scope) {
|
|
172
|
+
const path = key([...base, ...dataPath(node.scope)]);
|
|
173
|
+
if (excluded.some((e) => path === e || path.startsWith(`${e}.`)))
|
|
174
|
+
return undefined;
|
|
175
|
+
const detail = node.options?.detail;
|
|
176
|
+
if (detail) {
|
|
177
|
+
const pruned = prune(detail, path ? path.split(".") : base, excluded);
|
|
178
|
+
out.options = {
|
|
179
|
+
...node.options,
|
|
180
|
+
detail: pruned ?? { ...detail, elements: [] },
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (node.elements) {
|
|
185
|
+
out.elements = node.elements
|
|
186
|
+
.map((child) => prune(child, base, excluded))
|
|
187
|
+
.filter((child) => !!child);
|
|
188
|
+
if (node.elements.length && !out.elements.length)
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
return out;
|
|
192
|
+
}
|
|
193
|
+
/** Sibling entries that render under one label, which an applicant cannot tell apart. */
|
|
194
|
+
function duplicateLabels(layout, ui) {
|
|
195
|
+
const out = [];
|
|
196
|
+
const name = (node) => node.label ?? (node.scope ? dataPath(node.scope).slice(-1)[0] : undefined);
|
|
197
|
+
const visit = (node, where) => {
|
|
198
|
+
const seen = new Map();
|
|
199
|
+
for (const child of node.elements ?? []) {
|
|
200
|
+
const label = name(child);
|
|
201
|
+
const first = label === undefined ? undefined : seen.get(label);
|
|
202
|
+
if (label !== undefined && first)
|
|
203
|
+
out.push(createDiagnostic({
|
|
204
|
+
code: "layout-duplicate-label",
|
|
205
|
+
target: layout.layout,
|
|
206
|
+
format: {
|
|
207
|
+
where,
|
|
208
|
+
label,
|
|
209
|
+
first: describe(first),
|
|
210
|
+
second: describe(child),
|
|
211
|
+
},
|
|
212
|
+
}));
|
|
213
|
+
else if (label !== undefined)
|
|
214
|
+
seen.set(label, child);
|
|
215
|
+
visit(child, child.label ?? where);
|
|
216
|
+
const detail = child.options?.detail;
|
|
217
|
+
if (detail)
|
|
218
|
+
visit(detail, label ?? where);
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
visit(ui, layout.layout.name);
|
|
222
|
+
return out;
|
|
223
|
+
}
|
|
224
|
+
const describe = (node) => node.scope ?? (node.label ? `the group "${node.label}"` : "a group");
|
|
225
|
+
//# sourceMappingURL=layout-ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout-ui.js","sourceRoot":"","sources":["../../../src/emitters/layout-ui.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAIL,MAAM,EACN,MAAM,GACP,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,UAAU,EACV,YAAY,EACZ,SAAS,EACT,UAAU,EACV,SAAS,GACV,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,WAA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