@chobantonov/jsonforms-extended-spec 0.2.0 → 0.4.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/conformance/authoring.json +511 -0
- package/conformance/behavior.json +2373 -4
- package/conformance/config-consumption.json +13 -2
- package/docs/audit.md +17 -2
- package/docs/conditional-fields.md +133 -6
- package/docs/external-resources-proposal.md +8 -2
- package/docs/implementation-guide.md +129 -90
- package/docs/implementation-pitfalls.md +393 -1
- package/docs/implementation-web-typescript.md +2 -5
- package/docs/renderer-and-demo.md +47 -34
- package/docs/spec.md +235 -14
- package/docs/todo.md +72 -18
- package/examples/README.md +8 -2
- package/examples/additional-errors/README.md +7 -0
- package/examples/additional-properties/README.md +15 -0
- package/examples/catalog.json +16 -1
- package/examples/color-control/README.md +4 -1
- package/examples/conditional-fields/README.md +21 -3
- package/examples/conditional-fields/translations.json +4 -2
- package/examples/conditional-fields/uischema.json +67 -7
- package/examples/conditional-template-slots/README.md +14 -0
- package/examples/conditional-template-slots/config.json +7 -0
- package/examples/conditional-template-slots/data.json +5 -0
- package/examples/conditional-template-slots/schema.json +37 -0
- package/examples/conditional-template-slots/translations.json +16 -0
- package/examples/conditional-template-slots/uischema.json +22 -0
- package/examples/index.js +4 -3
- package/examples/kitchen-sink/README.md +93 -4
- package/examples/kitchen-sink/config.json +7 -0
- package/examples/kitchen-sink/data.json +14 -2
- package/examples/kitchen-sink/invalid-data.json +13 -1
- package/examples/kitchen-sink/schema.json +100 -1
- package/examples/kitchen-sink/translations.json +80 -2
- package/examples/kitchen-sink/uischema.json +239 -4
- package/examples/label-interpolation/README.md +58 -1
- package/examples/label-interpolation/config.json +8 -2
- package/examples/label-interpolation/translations.json +8 -4
- package/examples/label-interpolation/uischema.json +31 -8
- package/package.json +1 -1
- package/schemas/README.md +8 -3
- package/schemas/jsonforms-config.schema.json +1 -1
- package/schemas/jsonforms-extended-config.schema.json +5 -0
- package/schemas/jsonforms-extended-uischema.schema.json +11 -2
- package/schemas/jsonforms-uischema.schema.json +14 -1
- package/typescript/README.md +8 -2
- package/typescript/lib/authoring/forSchema.d.ts +10 -1
- package/typescript/src/authoring/forSchema.ts +10 -1
- package/typescript/test/schemaContract.test.ts +12 -0
- package/typescript/test/typedAuthoring.test.ts +12 -1
- package/typescript/test/typedAuthoringCoverage.test.ts +33 -0
|
@@ -51,6 +51,15 @@
|
|
|
51
51
|
},
|
|
52
52
|
"readonly": {
|
|
53
53
|
"type": "boolean"
|
|
54
|
+
},
|
|
55
|
+
"part": {
|
|
56
|
+
"type": "string",
|
|
57
|
+
"pattern": "^\\s*([A-Za-z][A-Za-z0-9_-]*(\\s+|$))*$",
|
|
58
|
+
"description": "Optional host styling names separated by whitespace. HTML implementations expose normalized names as data-part on the layout slot; non-HTML renderers may use a documented no-op. No built-in styling or behavior."
|
|
59
|
+
},
|
|
60
|
+
"conditionalFields": {
|
|
61
|
+
"type": "boolean",
|
|
62
|
+
"description": "Opt in to conditional object presentation on an object Control or owning VerticalLayout, HorizontalLayout, Group, Categorization, TemplateLayout, Template or Slot entry. Entry-local false overrides config. Descendant layout and Category options are ignored in both directions; this option is also ignored on other element kinds. Nested object/item and independent host form boundaries resolve independently. Filter inactive branch-only field bindings in bodies and Group regions without adding controls, pruning empty containers or deleting data. Whole-value editors retain the authored schema. Template child addresses remain reserved when inactive; known inactive slots render nothing without fallback or unknown-slot warnings."
|
|
54
63
|
}
|
|
55
64
|
}
|
|
56
65
|
},
|
|
@@ -995,7 +1004,7 @@
|
|
|
995
1004
|
},
|
|
996
1005
|
"conditionalFields": {
|
|
997
1006
|
"type": "boolean",
|
|
998
|
-
"description": "Opt in to
|
|
1007
|
+
"description": "Opt in to conditional object presentation on an object Control or owning VerticalLayout, HorizontalLayout, Group, Categorization, TemplateLayout, Template or Slot entry. Entry-local false overrides config. Descendant layout and Category options are ignored in both directions; this option is also ignored on other element kinds. Nested object/item and independent host form boundaries resolve independently. Filter inactive branch-only field bindings in bodies and Group regions without adding controls, pruning empty containers or deleting data. Whole-value editors retain the authored schema. Template child addresses remain reserved when inactive; known inactive slots render nothing without fallback or unknown-slot warnings."
|
|
999
1008
|
},
|
|
1000
1009
|
"choices": {
|
|
1001
1010
|
"type": "array",
|
|
@@ -1650,7 +1659,7 @@
|
|
|
1650
1659
|
"textParams": {
|
|
1651
1660
|
"type": "object",
|
|
1652
1661
|
"additionalProperties": true,
|
|
1653
|
-
"description": "
|
|
1662
|
+
"description": "Declared values exposed to text expressions as bare identifiers. Text has no implicit locale variable: declare a parameter such as language with value {locale} to expose the host locale. A parameter named locale is allowed. Parameter expressions may read host locale without the data-access gate; data/item/config/context require jsonformsExtended.dynamicValues.enabled."
|
|
1654
1663
|
}
|
|
1655
1664
|
}
|
|
1656
1665
|
}
|
|
@@ -74,6 +74,15 @@
|
|
|
74
74
|
},
|
|
75
75
|
"readonly": {
|
|
76
76
|
"type": "boolean"
|
|
77
|
+
},
|
|
78
|
+
"part": {
|
|
79
|
+
"type": "string",
|
|
80
|
+
"pattern": "^\\s*([A-Za-z][A-Za-z0-9_-]*(\\s+|$))*$",
|
|
81
|
+
"description": "Optional host styling names separated by whitespace. HTML implementations expose normalized names as data-part on the layout slot; non-HTML renderers may use a documented no-op. No built-in styling or behavior."
|
|
82
|
+
},
|
|
83
|
+
"conditionalFields": {
|
|
84
|
+
"type": "boolean",
|
|
85
|
+
"description": "Opt in to conditional object presentation on an object Control or owning VerticalLayout, HorizontalLayout, Group, Categorization, TemplateLayout, Template or Slot entry. Entry-local false overrides config. Descendant layout and Category options are ignored in both directions; this option is also ignored on other element kinds. Nested object/item and independent host form boundaries resolve independently. Filter inactive branch-only field bindings in bodies and Group regions without adding controls, pruning empty containers or deleting data. Whole-value editors retain the authored schema. Template child addresses remain reserved when inactive; known inactive slots render nothing without fallback or unknown-slot warnings."
|
|
77
86
|
}
|
|
78
87
|
}
|
|
79
88
|
},
|
|
@@ -1004,7 +1013,7 @@
|
|
|
1004
1013
|
},
|
|
1005
1014
|
"conditionalFields": {
|
|
1006
1015
|
"type": "boolean",
|
|
1007
|
-
"description": "Opt in to
|
|
1016
|
+
"description": "Opt in to conditional object presentation on an object Control or owning VerticalLayout, HorizontalLayout, Group, Categorization, TemplateLayout, Template or Slot entry. Entry-local false overrides config. Descendant layout and Category options are ignored in both directions; this option is also ignored on other element kinds. Nested object/item and independent host form boundaries resolve independently. Filter inactive branch-only field bindings in bodies and Group regions without adding controls, pruning empty containers or deleting data. Whole-value editors retain the authored schema. Template child addresses remain reserved when inactive; known inactive slots render nothing without fallback or unknown-slot warnings."
|
|
1008
1017
|
},
|
|
1009
1018
|
"pagination": {
|
|
1010
1019
|
"$ref": "#/$defs/pagination"
|
|
@@ -1134,6 +1143,10 @@
|
|
|
1134
1143
|
"properties": {
|
|
1135
1144
|
"format": {
|
|
1136
1145
|
"type": "string"
|
|
1146
|
+
},
|
|
1147
|
+
"textParamSpans": {
|
|
1148
|
+
"type": "boolean",
|
|
1149
|
+
"description": "Overrides jsonformsExtended.markup.textParamSpans for this Label, including explicit false. Omit to inherit; otherwise defaults to false. Unchecked non-boolean local values are ignored as omitted. Optional HTML styling markers for declared parameters only; documented native or canvas no-op is permitted."
|
|
1137
1150
|
}
|
|
1138
1151
|
}
|
|
1139
1152
|
}
|
package/typescript/README.md
CHANGED
|
@@ -536,5 +536,11 @@ validate authored models against the extended UI-schema JSON Schema. See the
|
|
|
536
536
|
## Conditional fields
|
|
537
537
|
|
|
538
538
|
See [conditional field presentation and graphical authoring](../docs/conditional-fields.md).
|
|
539
|
-
Use `options.conditionalFields: true` on an object Control or
|
|
540
|
-
|
|
539
|
+
Use `options.conditionalFields: true` on an object Control or an object-context
|
|
540
|
+
layout entry (VerticalLayout, HorizontalLayout, Group or Categorization), or use
|
|
541
|
+
`config.jsonformsExtended.conditionalFields` as the default. Local false opts out.
|
|
542
|
+
The entry owns the projection for descendant layouts and Categories at that
|
|
543
|
+
object boundary. Nested object and array-item boundaries resolve independently.
|
|
544
|
+
Explicit layouts preserve placement and update conditional required indicators
|
|
545
|
+
without generating extra controls. See the conditional-fields contract for
|
|
546
|
+
ownership, validation, examples and platform support limits.
|
|
@@ -60,6 +60,8 @@ export type InputAdornment = {
|
|
|
60
60
|
};
|
|
61
61
|
export type InputAdornmentValue = string | InputAdornment | InputAdornment[];
|
|
62
62
|
export interface CommonControlOptions {
|
|
63
|
+
/** Host styling names; HTML layout-slot marker, optional on non-HTML platforms. */
|
|
64
|
+
part?: string;
|
|
63
65
|
/** Provisional portable input-edge content; support depends on the renderer variant. */
|
|
64
66
|
startAdornment?: InputAdornmentValue;
|
|
65
67
|
endAdornment?: InputAdornmentValue;
|
|
@@ -248,7 +250,10 @@ export interface TypedLabelElement<S> {
|
|
|
248
250
|
type: 'Label';
|
|
249
251
|
text?: string;
|
|
250
252
|
i18n?: string;
|
|
251
|
-
options?: Record<string, unknown
|
|
253
|
+
options?: Record<string, unknown> & {
|
|
254
|
+
/** Override the host default for named substitution markers; omit to inherit. */
|
|
255
|
+
textParamSpans?: boolean;
|
|
256
|
+
};
|
|
252
257
|
rule?: TypedRule<S>;
|
|
253
258
|
$dynamic?: DynamicSpec<DynamicTarget<TypedLabelElement<S>>>;
|
|
254
259
|
}
|
|
@@ -274,6 +279,10 @@ export interface TypedLayout<S> {
|
|
|
274
279
|
footer?: TypedElement<S>[];
|
|
275
280
|
elements: (TypedElement<S> | TypedCategory<S>)[];
|
|
276
281
|
options?: {
|
|
282
|
+
/** Own conditional object presentation for this layout subtree. */
|
|
283
|
+
conditionalFields?: boolean;
|
|
284
|
+
/** Host styling names on this element's slot in its parent layout. */
|
|
285
|
+
part?: string;
|
|
277
286
|
gap?: CssLength;
|
|
278
287
|
wrap?: boolean;
|
|
279
288
|
minItemWidth?: CssLength;
|
|
@@ -41,6 +41,8 @@ export type InputAdornment =
|
|
|
41
41
|
export type InputAdornmentValue = string | InputAdornment | InputAdornment[];
|
|
42
42
|
|
|
43
43
|
export interface CommonControlOptions {
|
|
44
|
+
/** Host styling names; HTML layout-slot marker, optional on non-HTML platforms. */
|
|
45
|
+
part?: string;
|
|
44
46
|
/** Provisional portable input-edge content; support depends on the renderer variant. */
|
|
45
47
|
startAdornment?: InputAdornmentValue;
|
|
46
48
|
endAdornment?: InputAdornmentValue;
|
|
@@ -209,7 +211,10 @@ export interface TypedLabelElement<S> {
|
|
|
209
211
|
type: 'Label';
|
|
210
212
|
text?: string;
|
|
211
213
|
i18n?: string;
|
|
212
|
-
options?: Record<string, unknown
|
|
214
|
+
options?: Record<string, unknown> & {
|
|
215
|
+
/** Override the host default for named substitution markers; omit to inherit. */
|
|
216
|
+
textParamSpans?: boolean;
|
|
217
|
+
};
|
|
213
218
|
rule?: TypedRule<S>;
|
|
214
219
|
$dynamic?: DynamicSpec<DynamicTarget<TypedLabelElement<S>>>;
|
|
215
220
|
}
|
|
@@ -237,6 +242,10 @@ export interface TypedLayout<S> {
|
|
|
237
242
|
footer?: TypedElement<S>[];
|
|
238
243
|
elements: (TypedElement<S> | TypedCategory<S>)[];
|
|
239
244
|
options?: {
|
|
245
|
+
/** Own conditional object presentation for this layout subtree. */
|
|
246
|
+
conditionalFields?: boolean;
|
|
247
|
+
/** Host styling names on this element's slot in its parent layout. */
|
|
248
|
+
part?: string;
|
|
240
249
|
gap?: CssLength;
|
|
241
250
|
wrap?: boolean;
|
|
242
251
|
minItemWidth?: CssLength;
|
|
@@ -624,3 +624,15 @@ it.each([true, false, undefined])('accepts Button fullWidth %s', (fullWidth) =>
|
|
|
624
624
|
it.each(['true', 1, null])('rejects nonboolean Button fullWidth %s', (fullWidth) => {
|
|
625
625
|
expect(compile(EXTENDED_UISCHEMA)({ type: 'Button', options: { fullWidth } })).toBe(false);
|
|
626
626
|
});
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
it.each([BASE_UISCHEMA, EXTENDED_UISCHEMA])('validates conditional layout entry options in %s', name => {
|
|
630
|
+
const validate = compile(name);
|
|
631
|
+
for (const type of ['VerticalLayout', 'HorizontalLayout', 'Group', 'Categorization']) {
|
|
632
|
+
const elements = type === 'Categorization' ? [{type:'Category',label:'Fields',elements:[]}] : [];
|
|
633
|
+
for (const conditionalFields of [true, false]) {
|
|
634
|
+
expect(validate({type, elements, options:{conditionalFields}})).toBe(true);
|
|
635
|
+
}
|
|
636
|
+
expect(validate({type, elements, options:{conditionalFields:'auto'}})).toBe(false);
|
|
637
|
+
}
|
|
638
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
2
|
import { createAjv } from '@jsonforms/core';
|
|
3
|
-
import { forSchema } from '../src/authoring/forSchema';
|
|
3
|
+
import { forSchema, type TypedLayout } from '../src/authoring/forSchema';
|
|
4
4
|
import type { DataOf } from '../src/authoring/schemaTypes';
|
|
5
5
|
|
|
6
6
|
/*
|
|
@@ -138,3 +138,14 @@ it('authors conditional fields with an explicit opt-out', () => {
|
|
|
138
138
|
// @ts-expect-error The opt-in is a boolean, not a presentation mode.
|
|
139
139
|
f.control('address', {options: {conditionalFields: 'auto'}});
|
|
140
140
|
});
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
it('types conditional object presentation on layout entries', () => {
|
|
144
|
+
const layout: TypedLayout<typeof schema> = {type:'VerticalLayout',elements:[],options:{conditionalFields:true}};
|
|
145
|
+
expect(layout.options?.conditionalFields).toBe(true);
|
|
146
|
+
const invalid: TypedLayout<typeof schema> = {type:'Group',elements:[],options:{
|
|
147
|
+
// @ts-expect-error Layout conditionalFields must be a boolean.
|
|
148
|
+
conditionalFields:'auto'
|
|
149
|
+
}};
|
|
150
|
+
expect(invalid.type).toBe('Group');
|
|
151
|
+
});
|
|
@@ -37,6 +37,39 @@ const schema = {
|
|
|
37
37
|
const f = forSchema(schema);
|
|
38
38
|
|
|
39
39
|
describe('every element kind is expressible', () => {
|
|
40
|
+
it('authors Label substitution marker overrides without adding an inherited default', () => {
|
|
41
|
+
const inherited = f.label({ text: 'Membership details' });
|
|
42
|
+
expect(inherited.options?.textParamSpans).toBeUndefined();
|
|
43
|
+
for (const textParamSpans of [true, false]) {
|
|
44
|
+
const label = f.label({ text: 'Membership details', options: { textParamSpans } });
|
|
45
|
+
expect(label.options?.textParamSpans).toBe(textParamSpans);
|
|
46
|
+
}
|
|
47
|
+
// @ts-expect-error A local override must be boolean.
|
|
48
|
+
f.label({ text: 'Membership details', options: { textParamSpans: 'true' } });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('preserves host styling parts on controls and layout slots', () => {
|
|
52
|
+
const control = f.control('email', { options: { part: 'primary contact' } });
|
|
53
|
+
const ui = f.layout({
|
|
54
|
+
type: 'VerticalLayout',
|
|
55
|
+
options: { part: 'contact-section' },
|
|
56
|
+
elements: [
|
|
57
|
+
control,
|
|
58
|
+
f.label({ text: 'Contact details', options: { part: 'heading' } }),
|
|
59
|
+
],
|
|
60
|
+
});
|
|
61
|
+
expect(ui.options?.part).toBe('contact-section');
|
|
62
|
+
expect(control.options?.part).toBe('primary contact');
|
|
63
|
+
// @ts-expect-error Parts use the serialized string shape, not an array.
|
|
64
|
+
f.control('email', { options: { part: ['primary'] } });
|
|
65
|
+
f.layout({
|
|
66
|
+
type: 'VerticalLayout',
|
|
67
|
+
// @ts-expect-error Layout markers use the same string shape.
|
|
68
|
+
options: { part: ['contact-section'] },
|
|
69
|
+
elements: [],
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
40
73
|
it('authors Group regions in the current schema context', () => {
|
|
41
74
|
const ui = f.layout({
|
|
42
75
|
type: 'Group',
|