@chobantonov/jsonforms-extended-spec 0.2.0 → 0.3.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.
Files changed (31) hide show
  1. package/conformance/authoring.json +511 -0
  2. package/conformance/behavior.json +875 -4
  3. package/conformance/config-consumption.json +13 -2
  4. package/docs/conditional-fields.md +44 -2
  5. package/docs/implementation-guide.md +56 -3
  6. package/docs/implementation-pitfalls.md +167 -1
  7. package/docs/spec.md +156 -7
  8. package/docs/todo.md +17 -0
  9. package/examples/README.md +8 -2
  10. package/examples/additional-errors/README.md +7 -0
  11. package/examples/additional-properties/README.md +15 -0
  12. package/examples/color-control/README.md +4 -1
  13. package/examples/conditional-fields/README.md +11 -3
  14. package/examples/conditional-fields/translations.json +4 -2
  15. package/examples/conditional-fields/uischema.json +67 -7
  16. package/examples/index.js +2 -2
  17. package/examples/label-interpolation/README.md +41 -0
  18. package/examples/label-interpolation/config.json +8 -2
  19. package/examples/label-interpolation/uischema.json +6 -2
  20. package/package.json +1 -1
  21. package/schemas/README.md +8 -3
  22. package/schemas/jsonforms-config.schema.json +1 -1
  23. package/schemas/jsonforms-extended-config.schema.json +5 -0
  24. package/schemas/jsonforms-extended-uischema.schema.json +10 -1
  25. package/schemas/jsonforms-uischema.schema.json +14 -1
  26. package/typescript/README.md +8 -2
  27. package/typescript/lib/authoring/forSchema.d.ts +10 -1
  28. package/typescript/src/authoring/forSchema.ts +10 -1
  29. package/typescript/test/schemaContract.test.ts +12 -0
  30. package/typescript/test/typedAuthoring.test.ts +12 -1
  31. package/typescript/test/typedAuthoringCoverage.test.ts +33 -0
@@ -198,3 +198,44 @@ no gate.
198
198
  Load the JSON assets listed in [the catalog](../catalog.json) into a host
199
199
  with the relevant renderer capabilities. No framework registration module is
200
200
  required by this package.
201
+
202
+
203
+ ## Optional host CSS hooks
204
+
205
+ The supplied config enables `jsonformsExtended.markup.textParamSpans`. On an
206
+ HTML renderer implementing [§9.4a](../../docs/spec.md#94a-styling-named-substitutions),
207
+ the “Both together” summary explicitly opts in with `options.textParamSpans: true`
208
+ and marks the `account`, `plan` and `amount` substitutions even when the host
209
+ default is false. Other interpolated Labels inherit the host default. The
210
+ account-holder Label opts out with `options.textParamSpans: false`, so its
211
+ substitutions remain unmarked even under the supplied true default.
212
+ The summary's `options.part: "membership-summary prominent"` marks the containing layout
213
+ slot under [§5.7](../../docs/spec.md#57-host-styling-markers). The account-holder
214
+ Label supplies a separate `account-holder` part. A host can apply, for example:
215
+
216
+ ```css
217
+ [data-part~="membership-summary"] [data-text-param="plan"] { font-weight: 600; }
218
+ [data-part~="account-holder"] { font-style: italic; }
219
+ ```
220
+
221
+ Install these rules in the form's styling scope; document-level CSS does not
222
+ cross a Shadow Root automatically. The example assets supply names, not styles.
223
+ Native or canvas hosts may map names to native styling or document a no-op;
224
+ either fallback retains all membership text, fields and actions.
225
+
226
+ Proposed adapter acceptance cases (not executed renderer tests in this package):
227
+
228
+ - Toggle the host default: Labels without a local override follow it; the
229
+ summary stays enabled and the account-holder stays disabled. Remove each
230
+ override to restore inheritance. Text, formatting, links and accessible reading
231
+ order remain unchanged; effective false creates no spans or tracking parse.
232
+ - In English and Bulgarian, inspect the named substitutions after translation.
233
+ Repeated or reordered parameters keep their original names. The literal
234
+ `displayName` Markdown characters remain literal text. Temporarily enable
235
+ the holder's local option and verify they remain text within the holder span.
236
+ - Remove `options.part` while keeping `i18n`: no element marker is inferred.
237
+ Inspect a root and a Group region without a layout slot: neither grows a
238
+ wrapper just to expose a part. A nested layout uses its own parent slot.
239
+ - Run `styling-*` behavior vectors for parsing boundaries, URL security,
240
+ normalization and the documented native no-op. Record actual results per
241
+ renderer family; schema validation does not establish support.
@@ -1,8 +1,14 @@
1
1
  {
2
2
  "jsonformsExtended": {
3
- "dynamicValues": { "enabled": true },
3
+ "dynamicValues": {
4
+ "enabled": true
5
+ },
4
6
  "markup": {
5
- "markdown": { "enabled": true, "profile": "basic" }
7
+ "markdown": {
8
+ "enabled": true,
9
+ "profile": "basic"
10
+ },
11
+ "textParamSpans": true
6
12
  }
7
13
  }
8
14
  }
@@ -93,7 +93,9 @@
93
93
  "account": "{data.customerName}",
94
94
  "plan": "{translate(\"plan.\" + data.plan)}",
95
95
  "amount": "{currency(data.amountDue, \"EUR\")}"
96
- }
96
+ },
97
+ "part": "membership-summary prominent",
98
+ "textParamSpans": true
97
99
  }
98
100
  },
99
101
  {
@@ -105,7 +107,9 @@
105
107
  "markup": "markdown",
106
108
  "textParams": {
107
109
  "holder": "{data.displayName}"
108
- }
110
+ },
111
+ "part": "account-holder",
112
+ "textParamSpans": false
109
113
  }
110
114
  },
111
115
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chobantonov/jsonforms-extended-spec",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Portable JSON Forms extended UI model specification, JSON schemas and examples",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/schemas/README.md CHANGED
@@ -3,6 +3,9 @@
3
3
  These schemas describe the published authoring subset of [spec.md](../docs/spec.md).
4
4
  The explicitly provisional input-adornment authoring contract is also validated
5
5
  here. Schema validation does not establish renderer support or visual behavior.
6
+ The accepted optional host styling contracts (`options.part` and
7
+ `jsonformsExtended.markup.textParamSpans`) are validated as well; their
8
+ platform-specific implementation and verification status is tracked separately.
6
9
  Other provisional and unimplemented features
7
10
  belong in [TODO.md](../docs/todo.md), not schema definitions.
8
11
  They use draft-07 and preserve unknown options and namespaces. Core configuration
@@ -12,7 +15,7 @@ presentation behavior; their descriptions state that boundary.
12
15
  | File | Input |
13
16
  | --- | --- |
14
17
  | [jsonforms-uischema.schema.json](jsonforms-uischema.schema.json) | Common UI vocabulary |
15
- | [jsonforms-extended-uischema.schema.json](jsonforms-extended-uischema.schema.json) | Implemented extended UI vocabulary |
18
+ | [jsonforms-extended-uischema.schema.json](jsonforms-extended-uischema.schema.json) | Published extended UI vocabulary |
16
19
  | [jsonforms-config.schema.json](jsonforms-config.schema.json) | Common configuration |
17
20
  | [jsonforms-extended-config.schema.json](jsonforms-extended-config.schema.json) | Extended configuration |
18
21
  | [jsonforms-rule.schema.json](jsonforms-rule.schema.json) | Standalone serialized rule, also referenced by both UI profiles |
@@ -71,7 +74,9 @@ specified host adapter; the old function-source regex is not such an adapter.
71
74
 
72
75
  Known options inside cell overrides are checked as control options. This checks
73
76
  their shape, not whether every renderer is available as a cell. Monaco and grid
74
- vendor option bags remain open. Global declarations are limited
75
- to traced config paths. Keep field-dependent `elementLabelProp`,
77
+ vendor option bags remain open. Global declarations use traced config paths
78
+ or an explicitly accepted optional platform contract. The config-consumption
79
+ inventory marks the styling switch as pending verification rather than
80
+ claiming a traced renderer implementation. Keep field-dependent `elementLabelProp`,
76
81
  `detail`, `summary` and `cells` on their controls; isolated merged-config readers
77
82
  do not establish a common global default.
@@ -354,7 +354,7 @@
354
354
  "conditionalFields": {
355
355
  "type": "boolean",
356
356
  "default": false,
357
- "description": "Default opt-in for conditional field presentation in object controls. Local options.conditionalFields overrides."
357
+ "description": "Default opt-in for conditional object presentation on object Controls and object-context layout entries. Entry-local options.conditionalFields overrides; descendant layouts inherit the entry decision."
358
358
  }
359
359
  }
360
360
  },
@@ -291,6 +291,11 @@
291
291
  "type": "boolean",
292
292
  "default": true,
293
293
  "description": "Uses themed typography for rendered text. An element's typography option can override this default."
294
+ },
295
+ "textParamSpans": {
296
+ "type": "boolean",
297
+ "default": false,
298
+ "description": "Default for data-text-param spans for named substitutions in interpolated Label text on HTML renderers. A Label's options.textParamSpans overrides this value, including explicit false. Preserve text, Markdown structure and URL policy; non-HTML renderers may use a documented no-op."
294
299
  }
295
300
  }
296
301
  },
@@ -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 object-context layout entry. Local false overrides config. The entry owns descendant layouts and Categories; nested object/item boundaries are independent. Explicit layouts filter inactive branch-only bindings and update required markers without adding controls or deleting data."
54
63
  }
55
64
  }
56
65
  },
@@ -995,7 +1004,7 @@
995
1004
  },
996
1005
  "conditionalFields": {
997
1006
  "type": "boolean",
998
- "description": "Opt in to active conditional object field discovery (if/then/else and Draft-07 dependencies). Local false overrides config. Explicit detail layouts retain placement; inactive branch-only controls are omitted without deleting data."
1007
+ "description": "Opt in to conditional object presentation on an object Control or object-context layout entry. Local false overrides config. The entry owns descendant layouts and Categories; nested object/item boundaries are independent. Explicit layouts filter inactive branch-only bindings and update required markers without adding controls or deleting data."
999
1008
  },
1000
1009
  "choices": {
1001
1010
  "type": "array",
@@ -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 object-context layout entry. Local false overrides config. The entry owns descendant layouts and Categories; nested object/item boundaries are independent. Explicit layouts filter inactive branch-only bindings and update required markers without adding controls or deleting data."
77
86
  }
78
87
  }
79
88
  },
@@ -1004,7 +1013,7 @@
1004
1013
  },
1005
1014
  "conditionalFields": {
1006
1015
  "type": "boolean",
1007
- "description": "Opt in to active conditional object field discovery (if/then/else and Draft-07 dependencies). Local false overrides config. Explicit detail layouts retain placement; inactive branch-only controls are omitted without deleting data."
1016
+ "description": "Opt in to conditional object presentation on an object Control or object-context layout entry. Local false overrides config. The entry owns descendant layouts and Categories; nested object/item boundaries are independent. Explicit layouts filter inactive branch-only bindings and update required markers without adding controls or deleting data."
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. Optional HTML styling markers; documented native or canvas no-op is permitted."
1137
1150
  }
1138
1151
  }
1139
1152
  }
@@ -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 the default
540
- `config.jsonformsExtended.conditionalFields`. Local false opts out.
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',