@json-layout/vocabulary 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.
Files changed (37) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +54 -0
  3. package/src/index.js +4 -0
  4. package/src/layout-keyword/index.js +62 -0
  5. package/src/layout-keyword/schema.js +367 -0
  6. package/src/layout-keyword/schema.json +209 -0
  7. package/src/layout-keyword/types.ts +109 -0
  8. package/src/layout-keyword/validate.js +2 -0
  9. package/src/normalize.js +313 -0
  10. package/src/normalized-layout/index.js +105 -0
  11. package/src/normalized-layout/schema.js +824 -0
  12. package/src/normalized-layout/schema.json +413 -0
  13. package/src/normalized-layout/types.ts +243 -0
  14. package/src/normalized-layout/validate.js +3 -0
  15. package/src/types.ts +19 -0
  16. package/types/index.d.ts +5 -0
  17. package/types/index.d.ts.map +1 -0
  18. package/types/layout-keyword/index.d.ts +42 -0
  19. package/types/layout-keyword/index.d.ts.map +1 -0
  20. package/types/layout-keyword/schema.d.ts +279 -0
  21. package/types/layout-keyword/schema.d.ts.map +1 -0
  22. package/types/layout-keyword/types.d.ts +90 -0
  23. package/types/layout-keyword/types.d.ts.map +1 -0
  24. package/types/layout-keyword/validate.d.ts +24 -0
  25. package/types/layout-keyword/validate.d.ts.map +1 -0
  26. package/types/normalize.d.ts +18 -0
  27. package/types/normalize.d.ts.map +1 -0
  28. package/types/normalized-layout/index.d.ts +96 -0
  29. package/types/normalized-layout/index.d.ts.map +1 -0
  30. package/types/normalized-layout/schema.d.ts +626 -0
  31. package/types/normalized-layout/schema.d.ts.map +1 -0
  32. package/types/normalized-layout/types.d.ts +221 -0
  33. package/types/normalized-layout/types.d.ts.map +1 -0
  34. package/types/normalized-layout/validate.d.ts +23 -0
  35. package/types/normalized-layout/validate.d.ts.map +1 -0
  36. package/types/types.d.ts +19 -0
  37. package/types/types.d.ts.map +1 -0
@@ -0,0 +1,413 @@
1
+ {
2
+ "$id": "https://json-layout.github.io/normalized-layout-keyword",
3
+ "title": "normalized layout",
4
+ "oneOf": [
5
+ {"$ref": "#/$defs/switch-struct"},
6
+ {"$ref": "#/$defs/comp-object"}
7
+ ],
8
+ "$defs": {
9
+ "switch-struct": {
10
+ "type": "object",
11
+ "required": ["switch"],
12
+ "additionalProperties": false,
13
+ "properties": {
14
+ "switch": {
15
+ "type": "array",
16
+ "items": {"$ref": "#/$defs/comp-object"}
17
+ }
18
+ }
19
+ },
20
+ "comp-object": {
21
+ "type": "object",
22
+ "required": ["comp"],
23
+ "unevaluatedProperties": false,
24
+ "allOf": [
25
+ {
26
+ "properties": {
27
+ "if": {"$ref": "#/$defs/expression"},
28
+ "help": {"type": "string"},
29
+ "cols": {"$ref": "#/$defs/cols-obj"},
30
+ "props": {"$ref": "#/$defs/state-node-props-lib"},
31
+ "slots": {
32
+ "type": "object",
33
+ "allOf": [
34
+ {"$ref": "#/$defs/state-node-slots-lib"},
35
+ {
36
+ "properties": {
37
+ "before": {"$ref": "#/$defs/slot"},
38
+ "after": {"$ref": "#/$defs/slot"},
39
+ "component": {"$ref": "#/$defs/slot"}
40
+ }
41
+ }
42
+ ]
43
+ },
44
+ "options": {"$ref": "#/$defs/state-node-options"}
45
+ }
46
+ },
47
+ {
48
+ "discriminator": {"propertyName": "comp"},
49
+ "oneOf": [
50
+ {"$ref": "#/$defs/none"},
51
+ {"$ref": "#/$defs/list"},
52
+ {"$ref": "#/$defs/text-field"},
53
+ {"$ref": "#/$defs/number-field"},
54
+ {"$ref": "#/$defs/textarea"},
55
+ {"$ref": "#/$defs/checkbox"},
56
+ {"$ref": "#/$defs/switch"},
57
+ {"$ref": "#/$defs/slider"},
58
+ {"$ref": "#/$defs/date-picker"},
59
+ {"$ref": "#/$defs/date-time-picker"},
60
+ {"$ref": "#/$defs/time-picker"},
61
+ {"$ref": "#/$defs/color-picker"},
62
+ {"$ref": "#/$defs/select"},
63
+ {"$ref": "#/$defs/one-of-select"},
64
+ {"$ref": "#/$defs/section"},
65
+ {"$ref": "#/$defs/tabs"},
66
+ {"$ref": "#/$defs/vertical-tabs"},
67
+ {"$ref": "#/$defs/expansion-panels"}
68
+ ]
69
+ }
70
+ ]
71
+ },
72
+ "composite-comp-object": {
73
+ "type": "object",
74
+ "discriminator": {"propertyName": "comp"},
75
+ "oneOf": [
76
+ {"$ref": "#/$defs/section"},
77
+ {"$ref": "#/$defs/tabs"},
78
+ {"$ref": "#/$defs/vertical-tabs"},
79
+ {"$ref": "#/$defs/expansion-panels"}
80
+ ]
81
+ },
82
+ "none": {
83
+ "type": "object",
84
+ "required": ["comp"],
85
+ "properties": {
86
+ "comp": {"const": "none"}
87
+
88
+ }
89
+ },
90
+ "section": {
91
+ "type": "object",
92
+ "required": ["comp", "children"],
93
+ "properties": {
94
+ "comp": {"const": "section"},
95
+ "title": {"type": ["string", "null"]},
96
+ "subtitle": {"type": ["string", "null"]},
97
+ "children": {"$ref": "#/$defs/children"}
98
+ }
99
+ },
100
+ "tabs": {
101
+ "type": "object",
102
+ "required": ["comp", "children"],
103
+ "properties": {
104
+ "comp": {"const": "tabs"},
105
+ "title": {"type": ["string", "null"]},
106
+ "subtitle": {"type": ["string", "null"]},
107
+ "children": {"$ref": "#/$defs/children"}
108
+ }
109
+ },
110
+ "vertical-tabs": {
111
+ "type": "object",
112
+ "required": ["comp", "children"],
113
+ "properties": {
114
+ "comp": {"const": "vertical-tabs"},
115
+ "title": {"type": ["string", "null"]},
116
+ "subtitle": {"type": ["string", "null"]},
117
+ "children": {"$ref": "#/$defs/children"}
118
+ }
119
+ },
120
+ "expansion-panels": {
121
+ "type": "object",
122
+ "required": ["comp", "children"],
123
+ "properties": {
124
+ "comp": {"const": "expansion-panels"},
125
+ "title": {"type": ["string", "null"]},
126
+ "subtitle": {"type": ["string", "null"]},
127
+ "children": {"$ref": "#/$defs/children"}
128
+ }
129
+ },
130
+ "child": {
131
+ "type": "object",
132
+ "unevaluatedProperties": false,
133
+ "required": ["key"],
134
+ "properties": {
135
+ "key": {"type": ["string", "integer"]},
136
+ "cols": {"$ref": "#/$defs/cols-obj"}
137
+ },
138
+ "anyOf": [
139
+ {},
140
+ {"$ref": "#/$defs/composite-comp-object"}
141
+ ]
142
+ },
143
+ "children": {
144
+ "type": "array",
145
+ "items": {"$ref": "#/$defs/child"}
146
+ },
147
+ "list": {
148
+ "type": "object",
149
+ "required": ["comp", "listEditMode", "listActions"],
150
+ "properties": {
151
+ "comp": {"const": "list"},
152
+ "title": {"type": "string"},
153
+ "listEditMode": {"type": "string", "enum": ["inline", "inline-single", "menu", "dialog"]},
154
+ "listActions": {"type": "array", "items": {"type": "string", "enum": ["add", "edit", "delete", "sort", "duplicate"]}},
155
+ "itemTitle": {"$ref": "#/$defs/expression"},
156
+ "itemSubtitle": {"$ref": "#/$defs/expression"},
157
+ "messages": {
158
+ "type": "object",
159
+ "additionalProperties": false,
160
+ "properties": {
161
+ "addItem": {"type": "string"},
162
+ "delete": {"type": "string"},
163
+ "edit": {"type": "string"},
164
+ "duplicate": {"type": "string"},
165
+ "sort": {"type": "string"}
166
+ }
167
+ }
168
+ }
169
+ },
170
+ "text-field": {
171
+ "type": "object",
172
+ "required": ["comp", "label"],
173
+ "properties": {
174
+ "comp": {"const": "text-field"},
175
+ "label": {"type": "string"}
176
+ }
177
+ },
178
+ "number-field": {
179
+ "type": "object",
180
+ "required": ["comp", "label"],
181
+ "properties": {
182
+ "comp": {"const": "number-field"},
183
+ "label": {"type": "string"},
184
+ "step": {"type": "number"},
185
+ "min": {"type": "number"},
186
+ "max": {"type": "number"}
187
+ }
188
+ },
189
+ "textarea": {
190
+ "type": "object",
191
+ "required": ["comp", "label"],
192
+ "properties": {
193
+ "comp": {"const": "textarea"},
194
+ "label": {"type": "string"}
195
+ }
196
+ },
197
+ "checkbox": {
198
+ "type": "object",
199
+ "required": ["comp", "label"],
200
+ "properties": {
201
+ "comp": {"const": "checkbox"},
202
+ "label": {"type": "string"}
203
+ }
204
+ },
205
+ "switch": {
206
+ "type": "object",
207
+ "required": ["comp", "label"],
208
+ "properties": {
209
+ "comp": {"const": "switch"},
210
+ "label": {"type": "string"}
211
+ }
212
+ },
213
+ "slider": {
214
+ "type": "object",
215
+ "required": ["comp", "label", "min", "max"],
216
+ "properties": {
217
+ "comp": {"const": "slider"},
218
+ "label": {"type": "string"},
219
+ "step": {"type": "number"},
220
+ "min": {"type": "number"},
221
+ "max": {"type": "number"}
222
+ }
223
+ },
224
+ "date-picker": {
225
+ "type": "object",
226
+ "required": ["comp", "label"],
227
+ "properties": {
228
+ "comp": {"const": "date-picker"},
229
+ "label": {"type": "string"},
230
+ "min": {"type": "string", "format": "date"},
231
+ "max": {"type": "string", "format": "date"},
232
+ "format": {"type": "string", "enum": ["date", "date-time"], "default": "date"}
233
+ }
234
+ },
235
+ "date-time-picker": {
236
+ "type": "object",
237
+ "required": ["comp", "label"],
238
+ "properties": {
239
+ "comp": {"const": "date-time-picker"},
240
+ "label": {"type": "string"},
241
+ "min": {"type": "string", "format": "date-time"},
242
+ "max": {"type": "string", "format": "date-time"}
243
+ }
244
+ },
245
+ "time-picker": {
246
+ "type": "object",
247
+ "required": ["comp", "label"],
248
+ "properties": {
249
+ "comp": {"const": "time-picker"},
250
+ "label": {"type": "string"},
251
+ "min": {"type": "string", "format": "time"},
252
+ "max": {"type": "string", "format": "time"}
253
+ }
254
+ },
255
+ "color-picker": {
256
+ "type": "object",
257
+ "required": ["comp", "label"],
258
+ "properties": {
259
+ "comp": {"const": "color-picker"},
260
+ "label": {"type": "string"}
261
+ }
262
+ },
263
+ "select": {
264
+ "type": "object",
265
+ "required": ["comp", "label"],
266
+ "properties": {
267
+ "comp": {"const": "select"},
268
+ "label": {"type": "string"},
269
+ "items": {"$ref": "#/$defs/select-items"},
270
+ "getItems": {"$ref": "#/$defs/get-items"}
271
+ }
272
+ },
273
+ "select-items": {
274
+ "type": "array",
275
+ "items": {"$ref": "#/$defs/select-item"}
276
+ },
277
+ "select-item": {
278
+ "type": "object",
279
+ "required": ["title", "key", "value"],
280
+ "properties": {
281
+ "title": {"type": "string"},
282
+ "key": {"type": "string"},
283
+ "value": {}
284
+ }
285
+ },
286
+ "get-items": {
287
+ "type": "object",
288
+ "properties": {
289
+ "returnObjects": {"type": "boolean", "readOnly": true},
290
+ "itemsResults": {"$ref": "#/$defs/expression"},
291
+ "itemTitle": {"$ref": "#/$defs/expression"},
292
+ "itemKey": {"$ref": "#/$defs/expression"},
293
+ "itemValue": {"$ref": "#/$defs/expression"}
294
+ },
295
+ "oneOf": [
296
+ {"$ref": "#/$defs/expression"},
297
+ {"$ref": "#/$defs/get-items-fetch"}
298
+ ]
299
+ },
300
+ "get-items-fetch": {
301
+ "type": "object",
302
+ "required": ["url"],
303
+ "properties": {
304
+ "url": {"$ref": "#/$defs/expression"}
305
+ }
306
+ },
307
+ "one-of-select": {
308
+ "type": "object",
309
+ "required": ["comp"],
310
+ "properties": {
311
+ "comp": {"const": "one-of-select"},
312
+ "if": {"$ref": "#/$defs/expression"},
313
+ "label": {"type": "string"},
314
+ "help": {"type": "string"}
315
+ }
316
+ },
317
+ "expression": {
318
+ "type": "object",
319
+ "required": ["type", "expr"],
320
+ "properties": {
321
+ "type": {
322
+ "type": "string",
323
+ "enum": ["js-fn", "js-eval", "js-tpl"]
324
+ },
325
+ "expr": {
326
+ "type": "string"
327
+ },
328
+ "ref": {
329
+ "type": "integer",
330
+ "readOnly": true
331
+ }
332
+ }
333
+ },
334
+ "cols-obj": {
335
+ "type": "object",
336
+ "additionalProperties": false,
337
+ "required": ["xs"],
338
+ "properties": {
339
+ "xs": {"$ref": "#/$defs/cols", "default": 12},
340
+ "sm": {"$ref": "#/$defs/cols"},
341
+ "md": {"$ref": "#/$defs/cols"},
342
+ "lg": {"$ref": "#/$defs/cols"},
343
+ "xl": {"$ref": "#/$defs/cols"},
344
+ "xxl": {"$ref": "#/$defs/cols"}
345
+ }
346
+ },
347
+ "cols": {
348
+ "type": "integer",
349
+ "minimum": 0,
350
+ "maximum": 12
351
+ },
352
+ "slot": {
353
+ "oneOf": [
354
+ {
355
+ "type": "object",
356
+ "additionalProperties": false,
357
+ "required": ["text"],
358
+ "properties": {
359
+ "text": {"type": "string"}
360
+ }
361
+ },
362
+ {
363
+ "type": "object",
364
+ "additionalProperties": false,
365
+ "required": ["markdown"],
366
+ "properties": {
367
+ "markdown": {"type": "string"}
368
+ }
369
+ },
370
+ {
371
+ "type": "object",
372
+ "additionalProperties": false,
373
+ "required": ["name"],
374
+ "properties": {
375
+ "name": {"type": "string"}
376
+ }
377
+ }
378
+ ]
379
+ },
380
+ "state-node-options": {
381
+ "type": "object",
382
+ "allOf": [
383
+ {"$ref": "#/$defs/state-node-options-lib"},
384
+ {
385
+ "properties": {
386
+ "readOnly": {"type": "boolean", "default": false},
387
+ "summary": {"type": "boolean", "default": false},
388
+ "titleDepth": {"type": "integer", "minimum": 1, "maximum": 6, "default": 2}
389
+ }
390
+ }
391
+ ]
392
+ },
393
+ "state-node-options-lib": {
394
+ "type": "object",
395
+ "patternProperties": {
396
+ ".*": {}
397
+ }
398
+ },
399
+ "state-node-props-lib": {
400
+ "type": "object",
401
+ "patternProperties": {
402
+ ".*": {}
403
+ }
404
+ },
405
+ "state-node-slots-lib": {
406
+ "type": "object",
407
+ "patternProperties": {
408
+ ".*": {"$ref": "#/$defs/slot"}
409
+ }
410
+ }
411
+ }
412
+ }
413
+
@@ -0,0 +1,243 @@
1
+ export type NormalizedLayout = SwitchStruct | CompObject;
2
+ export type CompObject = {
3
+ if?: Expression;
4
+ help?: string;
5
+ cols?: ColsObj;
6
+ props?: StateNodePropsLib;
7
+ slots?: StateNodeSlotsLib & {
8
+ before?: Slot;
9
+ after?: Slot;
10
+ component?: Slot;
11
+ [k: string]: unknown;
12
+ };
13
+ options?: StateNodeOptions;
14
+ [k: string]: unknown;
15
+ } & (
16
+ | None
17
+ | List
18
+ | TextField
19
+ | NumberField
20
+ | Textarea
21
+ | Checkbox
22
+ | Switch
23
+ | Slider
24
+ | DatePicker
25
+ | DateTimePicker
26
+ | TimePicker
27
+ | ColorPicker
28
+ | Select
29
+ | OneOfSelect
30
+ | Section
31
+ | Tabs
32
+ | VerticalTabs
33
+ | ExpansionPanels
34
+ );
35
+ export type Cols = number;
36
+ /**
37
+ * This interface was referenced by `StateNodeSlotsLib`'s JSON-Schema definition
38
+ * via the `patternProperty` ".*".
39
+ */
40
+ export type Slot =
41
+ | {
42
+ text: string;
43
+ }
44
+ | {
45
+ markdown: string;
46
+ }
47
+ | {
48
+ name: string;
49
+ };
50
+ export type StateNodeOptions = StateNodeOptionsLib & {
51
+ readOnly?: boolean;
52
+ summary?: boolean;
53
+ titleDepth?: number;
54
+ [k: string]: unknown;
55
+ };
56
+ export type SelectItems = SelectItem[];
57
+ export type GetItems = {
58
+ returnObjects?: boolean;
59
+ itemsResults?: Expression;
60
+ itemTitle?: Expression;
61
+ itemKey?: Expression;
62
+ itemValue?: Expression;
63
+ [k: string]: unknown;
64
+ } & GetItems1;
65
+ export type GetItems1 = Expression | GetItemsFetch;
66
+ export type Child = Child1 & {
67
+ key: string | number;
68
+ cols?: ColsObj;
69
+ [k: string]: unknown;
70
+ };
71
+ export type Child1 = unknown | CompositeCompObject;
72
+ export type CompositeCompObject = Section | Tabs | VerticalTabs | ExpansionPanels;
73
+ export type Children = Child[];
74
+
75
+ export interface SwitchStruct {
76
+ switch: CompObject[];
77
+ }
78
+ export interface Expression {
79
+ type: "js-fn" | "js-eval" | "js-tpl";
80
+ expr: string;
81
+ ref?: number;
82
+ [k: string]: unknown;
83
+ }
84
+ export interface ColsObj {
85
+ xs: number;
86
+ sm?: Cols;
87
+ md?: Cols;
88
+ lg?: Cols;
89
+ xl?: Cols;
90
+ xxl?: Cols;
91
+ }
92
+ export interface StateNodePropsLib {
93
+ /**
94
+ * This interface was referenced by `StateNodePropsLib`'s JSON-Schema definition
95
+ * via the `patternProperty` ".*".
96
+ */
97
+ [k: string]: unknown;
98
+ }
99
+ export interface StateNodeSlotsLib {
100
+ [k: string]: Slot;
101
+ }
102
+ export interface StateNodeOptionsLib {
103
+ /**
104
+ * This interface was referenced by `StateNodeOptionsLib`'s JSON-Schema definition
105
+ * via the `patternProperty` ".*".
106
+ */
107
+ [k: string]: unknown;
108
+ }
109
+ export interface None {
110
+ comp: "none";
111
+ [k: string]: unknown;
112
+ }
113
+ export interface List {
114
+ comp: "list";
115
+ title?: string;
116
+ listEditMode: "inline" | "inline-single" | "menu" | "dialog";
117
+ listActions: ("add" | "edit" | "delete" | "sort" | "duplicate")[];
118
+ itemTitle?: Expression;
119
+ itemSubtitle?: Expression;
120
+ messages?: {
121
+ addItem?: string;
122
+ delete?: string;
123
+ edit?: string;
124
+ duplicate?: string;
125
+ sort?: string;
126
+ };
127
+ [k: string]: unknown;
128
+ }
129
+ export interface TextField {
130
+ comp: "text-field";
131
+ label: string;
132
+ [k: string]: unknown;
133
+ }
134
+ export interface NumberField {
135
+ comp: "number-field";
136
+ label: string;
137
+ step?: number;
138
+ min?: number;
139
+ max?: number;
140
+ [k: string]: unknown;
141
+ }
142
+ export interface Textarea {
143
+ comp: "textarea";
144
+ label: string;
145
+ [k: string]: unknown;
146
+ }
147
+ export interface Checkbox {
148
+ comp: "checkbox";
149
+ label: string;
150
+ [k: string]: unknown;
151
+ }
152
+ export interface Switch {
153
+ comp: "switch";
154
+ label: string;
155
+ [k: string]: unknown;
156
+ }
157
+ export interface Slider {
158
+ comp: "slider";
159
+ label: string;
160
+ step?: number;
161
+ min: number;
162
+ max: number;
163
+ [k: string]: unknown;
164
+ }
165
+ export interface DatePicker {
166
+ comp: "date-picker";
167
+ label: string;
168
+ min?: string;
169
+ max?: string;
170
+ format?: "date" | "date-time";
171
+ [k: string]: unknown;
172
+ }
173
+ export interface DateTimePicker {
174
+ comp: "date-time-picker";
175
+ label: string;
176
+ min?: string;
177
+ max?: string;
178
+ [k: string]: unknown;
179
+ }
180
+ export interface TimePicker {
181
+ comp: "time-picker";
182
+ label: string;
183
+ min?: string;
184
+ max?: string;
185
+ [k: string]: unknown;
186
+ }
187
+ export interface ColorPicker {
188
+ comp: "color-picker";
189
+ label: string;
190
+ [k: string]: unknown;
191
+ }
192
+ export interface Select {
193
+ comp: "select";
194
+ label: string;
195
+ items?: SelectItems;
196
+ getItems?: GetItems;
197
+ [k: string]: unknown;
198
+ }
199
+ export interface SelectItem {
200
+ title: string;
201
+ key: string;
202
+ value: unknown;
203
+ [k: string]: unknown;
204
+ }
205
+ export interface GetItemsFetch {
206
+ url: Expression;
207
+ [k: string]: unknown;
208
+ }
209
+ export interface OneOfSelect {
210
+ comp: "one-of-select";
211
+ if?: Expression;
212
+ label?: string;
213
+ help?: string;
214
+ [k: string]: unknown;
215
+ }
216
+ export interface Section {
217
+ comp: "section";
218
+ title?: string | null;
219
+ subtitle?: string | null;
220
+ children: Children;
221
+ [k: string]: unknown;
222
+ }
223
+ export interface Tabs {
224
+ comp: "tabs";
225
+ title?: string | null;
226
+ subtitle?: string | null;
227
+ children: Children;
228
+ [k: string]: unknown;
229
+ }
230
+ export interface VerticalTabs {
231
+ comp: "vertical-tabs";
232
+ title?: string | null;
233
+ subtitle?: string | null;
234
+ children: Children;
235
+ [k: string]: unknown;
236
+ }
237
+ export interface ExpansionPanels {
238
+ comp: "expansion-panels";
239
+ title?: string | null;
240
+ subtitle?: string | null;
241
+ children: Children;
242
+ [k: string]: unknown;
243
+ }