jedison 0.1.1
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/CHANGELOG.md +0 -0
- package/LICENSE +21 -0
- package/README.md +1911 -0
- package/dist/cjs/jedison.cjs +2 -0
- package/dist/cjs/jedison.cjs.map +1 -0
- package/dist/esm/jedison.js +7567 -0
- package/dist/esm/jedison.js.map +1 -0
- package/dist/umd/jedison.umd.js +2 -0
- package/dist/umd/jedison.umd.js.map +1 -0
- package/package.json +85 -0
package/README.md
ADDED
|
@@ -0,0 +1,1911 @@
|
|
|
1
|
+
[](https://github.com/germanbisurgi/jedison/actions/workflows/main.yml)
|
|
2
|
+
|
|
3
|
+
# Jedison
|
|
4
|
+
|
|
5
|
+
Generates forms from JSON schemas. Can be used in backend to validate JSON data too.
|
|
6
|
+
|
|
7
|
+
Check Out the [PLAYGROUND](https://germanbisurgi.github.io/jedison/index.html?theme=bootstrap5)
|
|
8
|
+
|
|
9
|
+
# Table of Contents
|
|
10
|
+
|
|
11
|
+
- [Key Features](#key-features)
|
|
12
|
+
- [Getting Started](#getting-started)
|
|
13
|
+
- [As a Validator](#as-a-validator)
|
|
14
|
+
- [As an Editor](#as-an-editor)
|
|
15
|
+
- [Instance Methods](#instance-methods)
|
|
16
|
+
- [Instance event listeners](#instance-event-listeners)
|
|
17
|
+
- [RefParser](#refParser)
|
|
18
|
+
- [Instance Options](#instance-options)
|
|
19
|
+
- [Editors](#editors)
|
|
20
|
+
- [Array](#array-editors)
|
|
21
|
+
- [Array](#array-list)
|
|
22
|
+
- [Array checkboxes](#array-checkboxes)
|
|
23
|
+
- [Array choices](#array-choices)
|
|
24
|
+
- [Array nav](#array-nav)
|
|
25
|
+
- [Array table](#array-table)
|
|
26
|
+
- [Boolean](#boolean-editors)
|
|
27
|
+
- [Boolean checkbox](#boolean-checkbox)
|
|
28
|
+
- [Boolean radios](#boolean-radios)
|
|
29
|
+
- [Boolean select](#boolean-select)
|
|
30
|
+
- [Number](#number-editors)
|
|
31
|
+
- [Number input](#number-input)
|
|
32
|
+
- [Number radios](#number-radios)
|
|
33
|
+
- [Number select](#number-select)
|
|
34
|
+
- [Number select](#number-select)
|
|
35
|
+
- [Object](#object-editors)
|
|
36
|
+
- [Object select](#object)
|
|
37
|
+
- [Object grid](#object-grid)
|
|
38
|
+
- [Object nav](#object-nav)
|
|
39
|
+
- [String](#string-editors)
|
|
40
|
+
- [String input](#string-input)
|
|
41
|
+
- [String radios](#string-radios)
|
|
42
|
+
- [String select](#string-select)
|
|
43
|
+
- [String textarea](#string-textarea)
|
|
44
|
+
- [String IMask](#string-imask)
|
|
45
|
+
- [Null](#null-editors)
|
|
46
|
+
- [Null](#null)
|
|
47
|
+
- [Language and Translations](#language-and-translations)
|
|
48
|
+
- [Annotations](#annotations)
|
|
49
|
+
- [Markdown](#markdown)
|
|
50
|
+
- [Schema Options](#schema-options)
|
|
51
|
+
- [x-addPropertyContent](#x-addPropertyContent)
|
|
52
|
+
- [x-arrayAdd](#x-arrayAdd)
|
|
53
|
+
- [x-arrayAddContent](#x-arrayAddContent)
|
|
54
|
+
- [x-arrayDelete](#x-arrayDelete)
|
|
55
|
+
- [x-arrayDeleteContent](#x-arrayDeleteContent)
|
|
56
|
+
- [x-arrayDragContent](#x-arrayDragContent)
|
|
57
|
+
- [x-arrayMove](#x-arrayMove)
|
|
58
|
+
- [x-arrayMoveDownContent](#x-arrayMoveDownContent)
|
|
59
|
+
- [x-arrayMoveUpContent](#x-arrayMoveUpContent)
|
|
60
|
+
- [x-assertFormat](#x-assertformat)
|
|
61
|
+
- [x-collapseToggleContent](#x-collapseToggleContent)
|
|
62
|
+
- [x-containerAttributes](#x-containerAttributes)
|
|
63
|
+
- [x-deactivateNonRequired](#x-deactivateNonRequired)
|
|
64
|
+
- [x-enableCollapseToggle](#x-enableCollapseToggle)
|
|
65
|
+
- [x-enforceConst](#x-enforceconst)
|
|
66
|
+
- [x-enforceEnum](#x-enforceenum)
|
|
67
|
+
- [x-enumTitles](#x-enumtitles)
|
|
68
|
+
- [x-format](#x-format)
|
|
69
|
+
- [x-grid](#x-grid)
|
|
70
|
+
- [x-hidden](#x-hidden)
|
|
71
|
+
- [x-info](#x-info)
|
|
72
|
+
- [x-inputAttributes](#x-inputattributes)
|
|
73
|
+
- [x-messages](#x-messages)
|
|
74
|
+
- [x-propertiesToggleContent](#x-propertiesToggleContent)
|
|
75
|
+
- [x-showErrors](#x-showerrors)
|
|
76
|
+
- [x-sortable](#x-sortable)
|
|
77
|
+
- [x-startCollapsed](#x-startCollapsed)
|
|
78
|
+
- [x-switcherTitle](#x-switchertitle)
|
|
79
|
+
- [x-titleHidden](#x-titlehidden)
|
|
80
|
+
- [x-titleIconClass](#x-titleiconclass)
|
|
81
|
+
- [x-titleTemplate](#x-titleTemplate)
|
|
82
|
+
- [License](#license)
|
|
83
|
+
- [Resources](#resources)
|
|
84
|
+
|
|
85
|
+
## Key Features
|
|
86
|
+
|
|
87
|
+
- Dependency free
|
|
88
|
+
- JSON Schema Validation: Easily validate your JSON data using JSON schemas.
|
|
89
|
+
- JSON Editing: Generate user-friendly forms for smooth JSON editing in the browser.
|
|
90
|
+
- Dereferences JSON Schema <code>'$ref'</code> pointers.
|
|
91
|
+
- CSS libraries Integration:
|
|
92
|
+
- Bootstrap 3
|
|
93
|
+
- Bootstrap 4
|
|
94
|
+
- Bootstrap 5
|
|
95
|
+
- Icon libraries Integration:
|
|
96
|
+
- Glyphicons
|
|
97
|
+
- Bootstrap icons
|
|
98
|
+
- FontAwesome 3
|
|
99
|
+
- FontAwesome 4
|
|
100
|
+
- FontAwesome 5
|
|
101
|
+
- FontAwesome 6
|
|
102
|
+
- Plugin Editors:
|
|
103
|
+
- Quill - powerful rich text editor
|
|
104
|
+
- Flatpickr - lightweight and powerful datetime picker
|
|
105
|
+
- Awesomplete - Ultra lightweight, customizable, simple autocomplete widget with zero dependencies
|
|
106
|
+
- Jodit - WYSIWYG Editor
|
|
107
|
+
- Raty - star Rating Plugin
|
|
108
|
+
- IMask - vanilla javascript input mask
|
|
109
|
+
|
|
110
|
+
## Getting Started
|
|
111
|
+
|
|
112
|
+
### As a Validator
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
const schema = {
|
|
116
|
+
"type": "string"
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const refParser = new Jedison.RefParser()
|
|
120
|
+
|
|
121
|
+
const init = async () => {
|
|
122
|
+
await refParser.dereference(schema)
|
|
123
|
+
|
|
124
|
+
const jedison = new Jedison.Create({
|
|
125
|
+
refParser: refParser,
|
|
126
|
+
schema: schema
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
init()
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### As an Editor
|
|
134
|
+
|
|
135
|
+
```html
|
|
136
|
+
|
|
137
|
+
<div id="jedison-container"></div>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
```javascript
|
|
141
|
+
const schema = {
|
|
142
|
+
"type": "string"
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const refParser = new Jedison.RefParser()
|
|
146
|
+
|
|
147
|
+
const init = async () => {
|
|
148
|
+
await refParser.dereference(schema)
|
|
149
|
+
|
|
150
|
+
const jedison = new Jedison.Create({
|
|
151
|
+
container: document.querySelector('#jedison-container'),
|
|
152
|
+
theme: new Jedison.ThemeBootstrap3(),
|
|
153
|
+
refParser: refParser,
|
|
154
|
+
schema: schema
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
init()
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Instance Methods
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
jedison.getValue() // returns the value of the editor
|
|
165
|
+
jedison.setValue({name: "Marcus miller"}) // set the editor value
|
|
166
|
+
jedison.getInstance('#/name') // gets the instance by json path
|
|
167
|
+
jedison.showValidationErrors() // displays validation errors in the respective editors
|
|
168
|
+
jedison.getErrors() // returns an array of validation error messages
|
|
169
|
+
jedison.disable() // disables the editor
|
|
170
|
+
jedison.enable() // enables the editor
|
|
171
|
+
jedison.destroy() // destroys the editor
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Instance event listeners
|
|
175
|
+
|
|
176
|
+
```javascript
|
|
177
|
+
// emitted when the jedison instance changes (whole json value/instance/editor)
|
|
178
|
+
jedison.on('change', (initiator) => {
|
|
179
|
+
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
// emitted when an instance changes (parts of the value/instance/editor)
|
|
183
|
+
jedison.on('instance-change', (instance, initiator) => {
|
|
184
|
+
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
// emitted when a new item to an array instance
|
|
188
|
+
jedison.editor.on('item-add', (initiator, newInstance) => {
|
|
189
|
+
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
// emitted when an item is removed from an array instance
|
|
193
|
+
jedison.editor.on('item-delete', (initiator) => {
|
|
194
|
+
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
// emitted when a new item is move up or down in an array instance
|
|
198
|
+
jedison.editor.on('item-move', (initiator) => {
|
|
199
|
+
|
|
200
|
+
})
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The argument `ìnitiator`can have one of the two values:
|
|
204
|
+
- `"api"`: indicates that the change came from a call of a method like `setValue()` or from internal mechanism of this library.
|
|
205
|
+
- `"user"`: indicates that the change came from a user interaction.
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
## RefParser
|
|
209
|
+
|
|
210
|
+
A `RefParser` resolves `$ref` references in JSON Schemas by dereferencing then.
|
|
211
|
+
|
|
212
|
+
```json
|
|
213
|
+
{
|
|
214
|
+
"type": "object",
|
|
215
|
+
"properties": {
|
|
216
|
+
"user": {
|
|
217
|
+
"$ref": "#/$defs/user"
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
"$defs": {
|
|
221
|
+
"user": {
|
|
222
|
+
"type": "object",
|
|
223
|
+
"properties": {
|
|
224
|
+
"name": {
|
|
225
|
+
"type": "string"
|
|
226
|
+
},
|
|
227
|
+
"email": {
|
|
228
|
+
"type": "string",
|
|
229
|
+
"format": "email"
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
translates to:
|
|
238
|
+
|
|
239
|
+
```json
|
|
240
|
+
{
|
|
241
|
+
"type": "object",
|
|
242
|
+
"properties": {
|
|
243
|
+
"user": {
|
|
244
|
+
"type": "object",
|
|
245
|
+
"properties": {
|
|
246
|
+
"name": {
|
|
247
|
+
"type": "string"
|
|
248
|
+
},
|
|
249
|
+
"email": {
|
|
250
|
+
"type": "string",
|
|
251
|
+
"format": "email"
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## Instance Options
|
|
260
|
+
|
|
261
|
+
<table>
|
|
262
|
+
<thead>
|
|
263
|
+
<tr align="left">
|
|
264
|
+
<th>Option</th>
|
|
265
|
+
<th>Type</th>
|
|
266
|
+
<th>Default</th>
|
|
267
|
+
<th>Description</th>
|
|
268
|
+
<th>As schema "x-" option</th>
|
|
269
|
+
</tr>
|
|
270
|
+
</thead>
|
|
271
|
+
<tbody>
|
|
272
|
+
<tr align="left">
|
|
273
|
+
<td><code>container</code></td>
|
|
274
|
+
<td><code>HTMLElement</code></td>
|
|
275
|
+
<td><code>null</code></td>
|
|
276
|
+
<td>The HTML element that will contain the generated form.</td>
|
|
277
|
+
<td>no</td>
|
|
278
|
+
</tr>
|
|
279
|
+
<tr align="left">
|
|
280
|
+
<td><code>iconLib</code></td>
|
|
281
|
+
<td><code>string</code></td>
|
|
282
|
+
<td><code>null</code></td>
|
|
283
|
+
<td>
|
|
284
|
+
Specifies the icon library to use for UI components. Valid options include:
|
|
285
|
+
<ul>
|
|
286
|
+
<li><code>'glyphicons'</code></li>
|
|
287
|
+
<li><code>'bootstrap-icons'</code></li>
|
|
288
|
+
<li><code>'fontawesome3'</code></li>
|
|
289
|
+
<li><code>'fontawesome4'</code></li>
|
|
290
|
+
<li><code>'fontawesome5'</code></li>
|
|
291
|
+
<li><code>'fontawesome6'</code></li>
|
|
292
|
+
</ul>
|
|
293
|
+
</td>
|
|
294
|
+
<td>no</td>
|
|
295
|
+
</tr>
|
|
296
|
+
<tr align="left">
|
|
297
|
+
<td><code>theme</code></td>
|
|
298
|
+
<td><code>Theme</code></td>
|
|
299
|
+
<td><code>null</code></td>
|
|
300
|
+
<td>
|
|
301
|
+
An instance of <code>Theme</code> to apply to the UI. Valid options include:
|
|
302
|
+
<ul>
|
|
303
|
+
<li><code>new Jedison.Theme()</code></li>
|
|
304
|
+
<li><code>new Jedison.ThemeBootstrap3()</code></li>
|
|
305
|
+
<li><code>new Jedison.ThemeBootstrap4()</code></li>
|
|
306
|
+
<li><code>new Jedison.ThemeBootstrap5()</code></li>
|
|
307
|
+
</ul>
|
|
308
|
+
</td>
|
|
309
|
+
<td>no</td>
|
|
310
|
+
</tr>
|
|
311
|
+
<tr align="left">
|
|
312
|
+
<td><code>refParser</code></td>
|
|
313
|
+
<td><code>new Jedison.RefParser</code></td>
|
|
314
|
+
<td><code>null</code></td>
|
|
315
|
+
<td>An instance of <code>RefParser</code> to handle <code>'$ref'</code> keywords.</td>
|
|
316
|
+
<td>no</td>
|
|
317
|
+
</tr>
|
|
318
|
+
<tr align="left">
|
|
319
|
+
<td><code>translations</code></td>
|
|
320
|
+
<td><code>object</code></td>
|
|
321
|
+
<td><code>'{}'</code></td>
|
|
322
|
+
<td>Used to add new translations or override the default ones.
|
|
323
|
+
<pre>translations: {
|
|
324
|
+
en: {
|
|
325
|
+
errorEnum: 'LOL'
|
|
326
|
+
}
|
|
327
|
+
}</pre>
|
|
328
|
+
</td>
|
|
329
|
+
<td>no</td>
|
|
330
|
+
</tr>
|
|
331
|
+
<tr align="left">
|
|
332
|
+
<td><code>parseMarkdown</code></td>
|
|
333
|
+
<td><code>boolean</code></td>
|
|
334
|
+
<td><code>false</code></td>
|
|
335
|
+
<td>
|
|
336
|
+
Transform <code>markdown</code> to <code>html</code> in annotations like <code>title</code> and <code>description</code> if marked.js is available as <code>window.marked</code>.
|
|
337
|
+
</td>
|
|
338
|
+
<td>no</td>
|
|
339
|
+
</tr>
|
|
340
|
+
<tr align="left">
|
|
341
|
+
<td><code>purifyHtml</code></td>
|
|
342
|
+
<td><code>boolean</code></td>
|
|
343
|
+
<td><code>true</code></td>
|
|
344
|
+
<td>
|
|
345
|
+
Sanitizes <code>html</code> tags from annotations like if DOMPurify.js is available as <code>window.DOMPurify</code>.
|
|
346
|
+
</td>
|
|
347
|
+
<td>no</td>
|
|
348
|
+
</tr>
|
|
349
|
+
<tr align="left">
|
|
350
|
+
<td><code>domPurifyOptions</code></td>
|
|
351
|
+
<td><code>object</code></td>
|
|
352
|
+
<td><code>{}</code></td>
|
|
353
|
+
<td>
|
|
354
|
+
DOMPurify options.
|
|
355
|
+
</td>
|
|
356
|
+
<td>no</td>
|
|
357
|
+
</tr>
|
|
358
|
+
<tr align="left">
|
|
359
|
+
<td><code>schema</code></td>
|
|
360
|
+
<td><code>object</code></td>
|
|
361
|
+
<td><code>{}</code></td>
|
|
362
|
+
<td>A JSON schema for the form.</td>
|
|
363
|
+
<td>no</td>
|
|
364
|
+
</tr>
|
|
365
|
+
<tr align="left">
|
|
366
|
+
<td><code>id</code></td>
|
|
367
|
+
<td><code>string</code></td>
|
|
368
|
+
<td><code>''</code></td>
|
|
369
|
+
<td>Used to prefix <code>id</code> and <code>for</code> attributes</td>
|
|
370
|
+
<td>no</td>
|
|
371
|
+
</tr>
|
|
372
|
+
<tr align="left">
|
|
373
|
+
<td><code>language</code></td>
|
|
374
|
+
<td><code>string</code></td>
|
|
375
|
+
<td><code>'en'</code></td>
|
|
376
|
+
<td>Set default language for error messages and UI texts</td>
|
|
377
|
+
<td>no</td>
|
|
378
|
+
</tr>
|
|
379
|
+
<tr align="left">
|
|
380
|
+
<td><code>data</code></td>
|
|
381
|
+
<td><code>object</code></td>
|
|
382
|
+
<td><code>undefined</code></td>
|
|
383
|
+
<td>Initial data to populate the form.</td>
|
|
384
|
+
<td>no</td>
|
|
385
|
+
</tr>
|
|
386
|
+
<tr align="left">
|
|
387
|
+
<td><code>customEditors</code></td>
|
|
388
|
+
<td><code>array</code></td>
|
|
389
|
+
<td><code>[]</code></td>
|
|
390
|
+
<td>An array of custom editor classes.</td>
|
|
391
|
+
<td>no</td>
|
|
392
|
+
</tr>
|
|
393
|
+
<tr align="left">
|
|
394
|
+
<td><code>hiddenInputAttributes</code></td>
|
|
395
|
+
<td><code>object</code></td>
|
|
396
|
+
<td><code>{}</code></td>
|
|
397
|
+
<td>Attributes for hidden inputs in the form.</td>
|
|
398
|
+
<td>no</td>
|
|
399
|
+
</tr>
|
|
400
|
+
<tr align="left">
|
|
401
|
+
<td><code>settings</code></td>
|
|
402
|
+
<td><code>object</code></td>
|
|
403
|
+
<td><code>{}</code></td>
|
|
404
|
+
<td>An object to store user data and functions. Useful for when there is the need to provide options to configure a plugin but the options can not be used in schemas because of JSON data limitations. Can be used in annotations when using templates</td>
|
|
405
|
+
<td>no</td>
|
|
406
|
+
</tr>
|
|
407
|
+
<tr align="left">
|
|
408
|
+
<td><code>btnContents</code></td>
|
|
409
|
+
<td><code>boolean</code></td>
|
|
410
|
+
<td><code>true</code></td>
|
|
411
|
+
<td>If buttons texts should be displayed</td>
|
|
412
|
+
<td>no</td>
|
|
413
|
+
</tr>
|
|
414
|
+
<tr align="left">
|
|
415
|
+
<td><code>btnIcons</code></td>
|
|
416
|
+
<td><code>boolean</code></td>
|
|
417
|
+
<td><code>true</code></td>
|
|
418
|
+
<td>If buttons icons should be displayed</td>
|
|
419
|
+
<td>no</td>
|
|
420
|
+
</tr>
|
|
421
|
+
<tr align="left">
|
|
422
|
+
<td><code>enforceEnum</code></td>
|
|
423
|
+
<td><code>boolean</code></td>
|
|
424
|
+
<td><code>true</code></td>
|
|
425
|
+
<td>When <code>true</code> uses the first item in the enum as the default value</td>
|
|
426
|
+
<td>yes</td>
|
|
427
|
+
</tr>
|
|
428
|
+
<tr align="left">
|
|
429
|
+
<td><code>enforceRequired</code></td>
|
|
430
|
+
<td><code>boolean</code></td>
|
|
431
|
+
<td><code>true</code></td>
|
|
432
|
+
<td>When <code>true</code> required properties are always displayed</td>
|
|
433
|
+
<td>yes</td>
|
|
434
|
+
</tr>
|
|
435
|
+
<tr align="left">
|
|
436
|
+
<td><code>enforceAdditionalProperties</code></td>
|
|
437
|
+
<td><code>boolean</code></td>
|
|
438
|
+
<td><code>true</code></td>
|
|
439
|
+
<td>When <code>true</code> the editor removes all properties that are not listed in properties</td>
|
|
440
|
+
<td>yes</td>
|
|
441
|
+
</tr>
|
|
442
|
+
<tr align="left">
|
|
443
|
+
<td><code>switcherInput</code></td>
|
|
444
|
+
<td><code>string</code></td>
|
|
445
|
+
<td><code>'select'</code></td>
|
|
446
|
+
<td>
|
|
447
|
+
Sets the input type that will be used to witch between multiple editors
|
|
448
|
+
<ul>
|
|
449
|
+
<li><code>select</code></li>
|
|
450
|
+
<li><code>radios</code></li>
|
|
451
|
+
<li><code>radios-inline</code></li>
|
|
452
|
+
</ul>
|
|
453
|
+
</td>
|
|
454
|
+
<td>yes</td>
|
|
455
|
+
</tr>
|
|
456
|
+
<tr align="left">
|
|
457
|
+
<td><code>mergeAllOf</code></td>
|
|
458
|
+
<td><code>boolean</code></td>
|
|
459
|
+
<td><code>false</code></td>
|
|
460
|
+
<td>
|
|
461
|
+
Merge <code>allOf</code> subschemas into it's owner schema. <b>WARNING</b>, merging schemas can lead to unwanted overrides. Use at your own risk.
|
|
462
|
+
</td>
|
|
463
|
+
<td>yes</td>
|
|
464
|
+
</tr>
|
|
465
|
+
<tr align="left">
|
|
466
|
+
<td><code>enablePropertiesToggle</code></td>
|
|
467
|
+
<td><code>boolean</code></td>
|
|
468
|
+
<td><code>false</code></td>
|
|
469
|
+
<td>Enables a toggle to show/hide properties in the UI.</td>
|
|
470
|
+
<td>yes</td>
|
|
471
|
+
</tr>
|
|
472
|
+
<tr align="left">
|
|
473
|
+
<td><code>enableCollapseToggle</code></td>
|
|
474
|
+
<td><code>boolean</code></td>
|
|
475
|
+
<td><code>false</code></td>
|
|
476
|
+
<td>Allows sections to be collapsible in the UI.</td>
|
|
477
|
+
<td>yes</td>
|
|
478
|
+
</tr>
|
|
479
|
+
<tr align="left">
|
|
480
|
+
<td><code>deactivateNonRequired</code></td>
|
|
481
|
+
<td><code>boolean</code></td>
|
|
482
|
+
<td><code>false</code></td>
|
|
483
|
+
<td>Deactivates non-required properties.</td>
|
|
484
|
+
<td>yes</td>
|
|
485
|
+
</tr>
|
|
486
|
+
<tr align="left">
|
|
487
|
+
<td><code>showErrors</code></td>
|
|
488
|
+
<td><code>string</code></td>
|
|
489
|
+
<td><code>'change'</code></td>
|
|
490
|
+
<td>
|
|
491
|
+
Determines when to display validation errors. Options include:
|
|
492
|
+
<ul>
|
|
493
|
+
<li><code>'never'</code></li>
|
|
494
|
+
<li><code>'change'</code></li>
|
|
495
|
+
<li><code>'always'</code></li>
|
|
496
|
+
</ul>
|
|
497
|
+
</td>
|
|
498
|
+
<td>yes</td>
|
|
499
|
+
</tr>
|
|
500
|
+
<tr align="left">
|
|
501
|
+
<td><code>assertFormat</code></td>
|
|
502
|
+
<td><code>boolean</code></td>
|
|
503
|
+
<td><code>false</code></td>
|
|
504
|
+
<td>Treats <code>'format'</code> as a validator rather than just an annotation.</td>
|
|
505
|
+
<td>yes</td>
|
|
506
|
+
</tr>
|
|
507
|
+
<tr align="left">
|
|
508
|
+
<td><code>enforceConst</code></td>
|
|
509
|
+
<td><code>boolean</code></td>
|
|
510
|
+
<td><code>false</code></td>
|
|
511
|
+
<td>Enforces the <code>const</code> keyword value in editors.</td>
|
|
512
|
+
<td>yes</td>
|
|
513
|
+
</tr>
|
|
514
|
+
<tr align="left">
|
|
515
|
+
<td><code>arrayDelete</code></td>
|
|
516
|
+
<td><code>boolean</code></td>
|
|
517
|
+
<td><code>true</code></td>
|
|
518
|
+
<td>If array delete buttons should be displayed</td>
|
|
519
|
+
<td>yes</td>
|
|
520
|
+
</tr>
|
|
521
|
+
<tr align="left">
|
|
522
|
+
<td><code>arrayMove</code></td>
|
|
523
|
+
<td><code>boolean</code></td>
|
|
524
|
+
<td><code>true</code></td>
|
|
525
|
+
<td>If array move up and move down buttons should be displayed</td>
|
|
526
|
+
<td>yes</td>
|
|
527
|
+
</tr>
|
|
528
|
+
<tr align="left">
|
|
529
|
+
<td><code>arrayAdd</code></td>
|
|
530
|
+
<td><code>boolean</code></td>
|
|
531
|
+
<td><code>true</code></td>
|
|
532
|
+
<td>If array add buttons should be displayed</td>
|
|
533
|
+
<td>yes</td>
|
|
534
|
+
</tr>
|
|
535
|
+
</tbody>
|
|
536
|
+
</table>
|
|
537
|
+
|
|
538
|
+
## Editors
|
|
539
|
+
|
|
540
|
+
An editor is a UI that allows users to input data and finally edit the relative json instance.
|
|
541
|
+
Editors can be as simple as a checkbox input filed for a boolean, or as complex as a wysiwyg rich text editor
|
|
542
|
+
for a string representing html.
|
|
543
|
+
The type of editor greatly depends on the type of json data that it's connected to and the keywords
|
|
544
|
+
present in it's json schema.
|
|
545
|
+
|
|
546
|
+
Virtually all editors can have the following features:
|
|
547
|
+
|
|
548
|
+
- [x-assertFormat](#x-assertFormat)
|
|
549
|
+
- [x-containerAttributes](#x-containerAttributes)
|
|
550
|
+
- [x-enforceConst](#x-enforceconst)
|
|
551
|
+
- [x-enforceEnum](#x-enforceEnum)
|
|
552
|
+
- [x-hidden](#x-hidden)
|
|
553
|
+
- [x-info](#x-info)
|
|
554
|
+
- [x-inputAttributes](#x-inputattributes) (if any)
|
|
555
|
+
- [x-messages](#x-messages)
|
|
556
|
+
- [x-showErrors](#x-showerrors)
|
|
557
|
+
- [x-titleHidden](#x-titlehidden)
|
|
558
|
+
- [x-titleIconClass](#x-titleiconclass)
|
|
559
|
+
|
|
560
|
+
```json
|
|
561
|
+
{
|
|
562
|
+
"type": "string",
|
|
563
|
+
"title": "label text for this editor",
|
|
564
|
+
"description": "description text for this editor",
|
|
565
|
+
"x-info": {
|
|
566
|
+
"variant": "modal",
|
|
567
|
+
"title": "<h4>Info Button title</h4>",
|
|
568
|
+
"content": "<p>Info button content</p>"
|
|
569
|
+
},
|
|
570
|
+
"x-inputAttributes": {
|
|
571
|
+
"placeholder": "placeholder text"
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
### Array editors
|
|
577
|
+
|
|
578
|
+
Options:
|
|
579
|
+
|
|
580
|
+
- [x-arrayAdd](#x-arrayAdd)
|
|
581
|
+
- [x-arrayAddContent](#x-arrayAddContent)
|
|
582
|
+
- [x-arrayDelete](#x-arrayDelete)
|
|
583
|
+
- [x-arrayDeleteContent](#x-arrayDeleteContent)
|
|
584
|
+
- [x-arrayDragContent](#x-arrayDragContent)
|
|
585
|
+
- [x-arrayMove](#x-arrayMove)
|
|
586
|
+
- [x-arrayMoveDownContent](#x-arrayMoveDownContent)
|
|
587
|
+
- [x-arrayMoveUpContent](#x-arrayMoveUpContent)
|
|
588
|
+
- [x-collapseToggleContent](#x-collapseToggleContent)
|
|
589
|
+
- [x-enableCollapseToggle](#x-enableCollapseToggle)
|
|
590
|
+
- [x-sortable](#x-sortable)
|
|
591
|
+
- [x-startCollapsed](#x-startCollapsed)
|
|
592
|
+
- [x-titleTemplate](#x-titleTemplate)
|
|
593
|
+
|
|
594
|
+
#### Array list
|
|
595
|
+
|
|
596
|
+
A fieldset that can contain list of editors. Each child editor correspond to an items in the array.
|
|
597
|
+
Child editors are placed from top to bottom.
|
|
598
|
+
|
|
599
|
+
```json
|
|
600
|
+
{
|
|
601
|
+
"type": "array",
|
|
602
|
+
"title": "Array",
|
|
603
|
+
"description": "Arrays are used for ordered elements. In JSON, each element in an array may be of a different type.",
|
|
604
|
+
"items": {
|
|
605
|
+
"title": "I am an array item editor",
|
|
606
|
+
"type": "string"
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
#### Array checkboxes
|
|
612
|
+
|
|
613
|
+
A fieldset containing a list of enumerated editors. Each editor is represented by a checkboxes.
|
|
614
|
+
Works only if the items are of type `string`, `number` or `integer`.
|
|
615
|
+
|
|
616
|
+
```json
|
|
617
|
+
{
|
|
618
|
+
"title": "Array",
|
|
619
|
+
"description": "Array of unique values wich item types can be string, number or integer",
|
|
620
|
+
"type": "array",
|
|
621
|
+
"uniqueItems": true,
|
|
622
|
+
"items": {
|
|
623
|
+
"enum": [
|
|
624
|
+
"value1",
|
|
625
|
+
"value2"
|
|
626
|
+
]
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
checkbox inline variant
|
|
632
|
+
|
|
633
|
+
```json
|
|
634
|
+
{
|
|
635
|
+
"x-format": "checkboxes-inline",
|
|
636
|
+
"title": "Array",
|
|
637
|
+
"description": "Array of unique values wich item types can be string, number or integer",
|
|
638
|
+
"type": "array",
|
|
639
|
+
"uniqueItems": true,
|
|
640
|
+
"items": {
|
|
641
|
+
"type": "string",
|
|
642
|
+
"enum": [
|
|
643
|
+
"value1",
|
|
644
|
+
"value2"
|
|
645
|
+
]
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
#### Array choices
|
|
651
|
+
|
|
652
|
+
A fieldset containing a list of enumerated editors. Each editor is represented by an item in the choices input.
|
|
653
|
+
Works only if the items are of type `string`, `number` or `integer`.
|
|
654
|
+
Choices.js musst be installed and available as `window.Choices` for this to work.
|
|
655
|
+
|
|
656
|
+
```json
|
|
657
|
+
{
|
|
658
|
+
"x-format": "choices",
|
|
659
|
+
"title": "Choices",
|
|
660
|
+
"description": "A vanilla JS customisable select box/text input plugin.",
|
|
661
|
+
"type": "array",
|
|
662
|
+
"uniqueItems": true,
|
|
663
|
+
"items": {
|
|
664
|
+
"type": "string",
|
|
665
|
+
"enum": [
|
|
666
|
+
"US",
|
|
667
|
+
"CA",
|
|
668
|
+
"GB",
|
|
669
|
+
"FR",
|
|
670
|
+
"DE",
|
|
671
|
+
"IT",
|
|
672
|
+
"IN",
|
|
673
|
+
"JP",
|
|
674
|
+
"BR",
|
|
675
|
+
"AU"
|
|
676
|
+
],
|
|
677
|
+
"x-enumTitles": [
|
|
678
|
+
"United States (US)",
|
|
679
|
+
"Canada (CA)",
|
|
680
|
+
"United Kingdom (GB)",
|
|
681
|
+
"France (FR)",
|
|
682
|
+
"Germany (DE)",
|
|
683
|
+
"Italy (IT)",
|
|
684
|
+
"India (IN)",
|
|
685
|
+
"Japan (JP)",
|
|
686
|
+
"Brazil (BR)",
|
|
687
|
+
"Australia (AU)"
|
|
688
|
+
]
|
|
689
|
+
},
|
|
690
|
+
"default": [
|
|
691
|
+
"US"
|
|
692
|
+
],
|
|
693
|
+
"minItems": 1
|
|
694
|
+
}
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
#### Array nav
|
|
698
|
+
|
|
699
|
+
A fieldset containing a list of enumerated editors. Each editor is represented by a checkboxes.
|
|
700
|
+
Works only if the items are of type `string`, `number` or `integer`.
|
|
701
|
+
|
|
702
|
+
options:
|
|
703
|
+
|
|
704
|
+
- `titleTemplate` is used to dynamically generate the nav items text. The parameters available are:
|
|
705
|
+
- `{{ i0 }}` is the index of the item starting by 0.
|
|
706
|
+
- `{{ i1 }}` is the index of the item starting by 1. More useful for end users.
|
|
707
|
+
- `{{ value }}` The value of the items.
|
|
708
|
+
|
|
709
|
+
With vertical nav
|
|
710
|
+
|
|
711
|
+
```json
|
|
712
|
+
{
|
|
713
|
+
"x-format": "nav-vertical",
|
|
714
|
+
"x-titleTemplate": "{{ i1 }} {{ value.name }}",
|
|
715
|
+
"type": "array",
|
|
716
|
+
"title": "People",
|
|
717
|
+
"items": {
|
|
718
|
+
"type": "object",
|
|
719
|
+
"title": "Person",
|
|
720
|
+
"properties": {
|
|
721
|
+
"name": {
|
|
722
|
+
"title": "Name",
|
|
723
|
+
"type": "string"
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
},
|
|
727
|
+
"default": [
|
|
728
|
+
{
|
|
729
|
+
"name": "Albert"
|
|
730
|
+
}
|
|
731
|
+
]
|
|
732
|
+
}
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
With horizontal nav
|
|
736
|
+
|
|
737
|
+
```json
|
|
738
|
+
{
|
|
739
|
+
"x-format": "nav-horizontal",
|
|
740
|
+
"x-titleTemplate": "{{ i1 }} {{ value.name }}",
|
|
741
|
+
"type": "array",
|
|
742
|
+
"title": "People",
|
|
743
|
+
"items": {
|
|
744
|
+
"type": "object",
|
|
745
|
+
"title": "Person",
|
|
746
|
+
"properties": {
|
|
747
|
+
"name": {
|
|
748
|
+
"title": "Name",
|
|
749
|
+
"type": "string"
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
},
|
|
753
|
+
"default": [
|
|
754
|
+
{
|
|
755
|
+
"name": "Albert"
|
|
756
|
+
}
|
|
757
|
+
]
|
|
758
|
+
}
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
#### Array table
|
|
762
|
+
|
|
763
|
+
A table where each item editor is rendered in a new table row.
|
|
764
|
+
|
|
765
|
+
```json
|
|
766
|
+
{
|
|
767
|
+
"x-format": "table",
|
|
768
|
+
"title": "users",
|
|
769
|
+
"type": "array",
|
|
770
|
+
"items": {
|
|
771
|
+
"type": "object",
|
|
772
|
+
"title": "Person",
|
|
773
|
+
"description": "User",
|
|
774
|
+
"properties": {
|
|
775
|
+
"name": {
|
|
776
|
+
"type": "string",
|
|
777
|
+
"title": "Name"
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
},
|
|
781
|
+
"default": [
|
|
782
|
+
{
|
|
783
|
+
"name": "Albert"
|
|
784
|
+
},
|
|
785
|
+
{
|
|
786
|
+
"name": "Betti"
|
|
787
|
+
}
|
|
788
|
+
]
|
|
789
|
+
}
|
|
790
|
+
```
|
|
791
|
+
|
|
792
|
+
### Boolean editors
|
|
793
|
+
|
|
794
|
+
#### Boolean checkbox
|
|
795
|
+
|
|
796
|
+
Renders a type checkbox input
|
|
797
|
+
|
|
798
|
+
```json
|
|
799
|
+
{
|
|
800
|
+
"x-format": "checkbox",
|
|
801
|
+
"type": "boolean",
|
|
802
|
+
"title": "Boolean"
|
|
803
|
+
}
|
|
804
|
+
```
|
|
805
|
+
|
|
806
|
+
#### Boolean radios
|
|
807
|
+
|
|
808
|
+
Renders two type radio inputs. The radio labels can be customized with the
|
|
809
|
+
`enumTitles` option.
|
|
810
|
+
|
|
811
|
+
```json
|
|
812
|
+
{
|
|
813
|
+
"x-format": "radios",
|
|
814
|
+
"type": "boolean",
|
|
815
|
+
"title": "Boolean",
|
|
816
|
+
"x-enumTitles": [
|
|
817
|
+
"Yes",
|
|
818
|
+
"No"
|
|
819
|
+
]
|
|
820
|
+
}
|
|
821
|
+
```
|
|
822
|
+
|
|
823
|
+
Inline variant
|
|
824
|
+
|
|
825
|
+
```json
|
|
826
|
+
{
|
|
827
|
+
"x-format": "radios-inline",
|
|
828
|
+
"type": "boolean",
|
|
829
|
+
"title": "Boolean",
|
|
830
|
+
"x-enumTitles": [
|
|
831
|
+
"Yes",
|
|
832
|
+
"No"
|
|
833
|
+
]
|
|
834
|
+
}
|
|
835
|
+
```
|
|
836
|
+
|
|
837
|
+
#### Boolean select
|
|
838
|
+
|
|
839
|
+
Renders type select input with 2 options. The options labels can be customized with the
|
|
840
|
+
`enumTitles` option.
|
|
841
|
+
|
|
842
|
+
```json
|
|
843
|
+
{
|
|
844
|
+
"x-format": "select",
|
|
845
|
+
"type": "boolean",
|
|
846
|
+
"title": "Boolean",
|
|
847
|
+
"x-enumTitles": [
|
|
848
|
+
"Yes",
|
|
849
|
+
"No"
|
|
850
|
+
]
|
|
851
|
+
}
|
|
852
|
+
```
|
|
853
|
+
|
|
854
|
+
### Number editors
|
|
855
|
+
|
|
856
|
+
#### Number input
|
|
857
|
+
|
|
858
|
+
Renders type number input. Handles `number`and `integer` types.
|
|
859
|
+
|
|
860
|
+
```json
|
|
861
|
+
{
|
|
862
|
+
"type": "number",
|
|
863
|
+
"title": "Number"
|
|
864
|
+
}
|
|
865
|
+
```
|
|
866
|
+
|
|
867
|
+
#### Number radios
|
|
868
|
+
|
|
869
|
+
Renders as many radio type inputs as values in the `enum` constraint. The radio labels can be customized with the
|
|
870
|
+
`enumTitles` option. Handles `number`and `integer` types.
|
|
871
|
+
|
|
872
|
+
```json
|
|
873
|
+
{
|
|
874
|
+
"x-format": "radios",
|
|
875
|
+
"type": "number",
|
|
876
|
+
"title": "Quantity",
|
|
877
|
+
"enum": [
|
|
878
|
+
0,
|
|
879
|
+
1,
|
|
880
|
+
2
|
|
881
|
+
],
|
|
882
|
+
"x-enumTitles": [
|
|
883
|
+
"None",
|
|
884
|
+
"One",
|
|
885
|
+
"A pair"
|
|
886
|
+
]
|
|
887
|
+
}
|
|
888
|
+
```
|
|
889
|
+
|
|
890
|
+
Inline variant
|
|
891
|
+
|
|
892
|
+
```json
|
|
893
|
+
{
|
|
894
|
+
"x-format": "radios-inline",
|
|
895
|
+
"type": "number",
|
|
896
|
+
"title": "Quantity",
|
|
897
|
+
"enum": [
|
|
898
|
+
0,
|
|
899
|
+
1,
|
|
900
|
+
2
|
|
901
|
+
],
|
|
902
|
+
"x-enumTitles": [
|
|
903
|
+
"None",
|
|
904
|
+
"One",
|
|
905
|
+
"A pair"
|
|
906
|
+
]
|
|
907
|
+
}
|
|
908
|
+
```
|
|
909
|
+
|
|
910
|
+
#### Number select
|
|
911
|
+
|
|
912
|
+
Renders as many radio type inputs as values in the `enum` constraint. The options labels can be customized with the
|
|
913
|
+
`enumTitles` option. Handles `number`and `integer` types.
|
|
914
|
+
|
|
915
|
+
```json
|
|
916
|
+
{
|
|
917
|
+
"type": "number",
|
|
918
|
+
"title": "Quantity",
|
|
919
|
+
"enum": [
|
|
920
|
+
0,
|
|
921
|
+
1,
|
|
922
|
+
2
|
|
923
|
+
],
|
|
924
|
+
"x-enumTitles": [
|
|
925
|
+
"None",
|
|
926
|
+
"One",
|
|
927
|
+
"A pair"
|
|
928
|
+
]
|
|
929
|
+
}
|
|
930
|
+
```
|
|
931
|
+
|
|
932
|
+
#### Number Raty
|
|
933
|
+
|
|
934
|
+
Renders a star rating input using Raty.js if installed and available as `window.Raty`.
|
|
935
|
+
|
|
936
|
+
```json
|
|
937
|
+
{
|
|
938
|
+
"title": "Raty",
|
|
939
|
+
"type": "number",
|
|
940
|
+
"description": "Raty - A Star Rating Plugin",
|
|
941
|
+
"default": 3,
|
|
942
|
+
"minimum": 0.5,
|
|
943
|
+
"x-raty": {
|
|
944
|
+
"half": true,
|
|
945
|
+
"starType": "i"
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
```
|
|
949
|
+
|
|
950
|
+
### Object editors
|
|
951
|
+
|
|
952
|
+
options:
|
|
953
|
+
|
|
954
|
+
- [x-addPropertyContent](#x-addPropertyContent)
|
|
955
|
+
- [x-collapseToggleContent](#x-collapseToggleContent)
|
|
956
|
+
- [x-deactivateNonRequired](#x-deactivateNonRequired)
|
|
957
|
+
- [x-enableCollapseToggle](#x-enableCollapseToggle)
|
|
958
|
+
- [x-propertiesToggleContent](#x-propertiesToggleContent)
|
|
959
|
+
- [x-startCollapsed](#x-startCollapsed)
|
|
960
|
+
- [x-titleTemplate](#x-titleTemplate)
|
|
961
|
+
|
|
962
|
+
#### Object
|
|
963
|
+
|
|
964
|
+
Renders a fieldset that will contain it properties editors.
|
|
965
|
+
The fieldset can be collapsed or expanded.
|
|
966
|
+
|
|
967
|
+
```json
|
|
968
|
+
{
|
|
969
|
+
"type": "object",
|
|
970
|
+
"title": "Login",
|
|
971
|
+
"properties": {
|
|
972
|
+
"email": {
|
|
973
|
+
"title": "E-Mail",
|
|
974
|
+
"type": "string",
|
|
975
|
+
"format": "email"
|
|
976
|
+
},
|
|
977
|
+
"password": {
|
|
978
|
+
"title": "Password",
|
|
979
|
+
"type": "string",
|
|
980
|
+
"minLength": 8
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
```
|
|
985
|
+
|
|
986
|
+
#### Object grid
|
|
987
|
+
|
|
988
|
+
Renders a fieldset that will contain it properties editors and use a grid system to position
|
|
989
|
+
its property editors. The fieldset can be collapsed or expanded.
|
|
990
|
+
Property editors can have more options:
|
|
991
|
+
|
|
992
|
+
- `columns`: How many columns should the editor occupy.
|
|
993
|
+
- `offset`: How many columns should the editor be offset.
|
|
994
|
+
- `newRow`: Whether the editor should be put in a new row.
|
|
995
|
+
|
|
996
|
+
```json
|
|
997
|
+
{
|
|
998
|
+
"x-format": "grid",
|
|
999
|
+
"type": "object",
|
|
1000
|
+
"title": "Login",
|
|
1001
|
+
"properties": {
|
|
1002
|
+
"email": {
|
|
1003
|
+
"title": "E-Mail",
|
|
1004
|
+
"type": "string",
|
|
1005
|
+
"format": "email",
|
|
1006
|
+
"x-grid": {
|
|
1007
|
+
"columns": 6
|
|
1008
|
+
}
|
|
1009
|
+
},
|
|
1010
|
+
"password": {
|
|
1011
|
+
"title": "Password",
|
|
1012
|
+
"type": "string",
|
|
1013
|
+
"minLength": 8,
|
|
1014
|
+
"x-grid": {
|
|
1015
|
+
"columns": 6
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
```
|
|
1021
|
+
|
|
1022
|
+
#### Object nav
|
|
1023
|
+
|
|
1024
|
+
Renders a fieldset that will contain it properties editors.
|
|
1025
|
+
The fieldset can be collapsed or expanded.
|
|
1026
|
+
|
|
1027
|
+
With vertical nav
|
|
1028
|
+
|
|
1029
|
+
```json
|
|
1030
|
+
{
|
|
1031
|
+
"x-format": "nav-vertical",
|
|
1032
|
+
"type": "object",
|
|
1033
|
+
"title": "All Editors",
|
|
1034
|
+
"properties": {
|
|
1035
|
+
"personA": {
|
|
1036
|
+
"title": "Person A",
|
|
1037
|
+
"type": "object",
|
|
1038
|
+
"properties": {
|
|
1039
|
+
"name": {
|
|
1040
|
+
"type": "string"
|
|
1041
|
+
},
|
|
1042
|
+
"age": {
|
|
1043
|
+
"type": "integer",
|
|
1044
|
+
"minimum": 0
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
},
|
|
1048
|
+
"personB": {
|
|
1049
|
+
"title": "Person B",
|
|
1050
|
+
"type": "object",
|
|
1051
|
+
"properties": {
|
|
1052
|
+
"name": {
|
|
1053
|
+
"type": "string"
|
|
1054
|
+
},
|
|
1055
|
+
"age": {
|
|
1056
|
+
"type": "integer",
|
|
1057
|
+
"minimum": 0
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
```
|
|
1064
|
+
|
|
1065
|
+
With horizontal nav
|
|
1066
|
+
|
|
1067
|
+
```json
|
|
1068
|
+
{
|
|
1069
|
+
"x-format": "nav-horizontal",
|
|
1070
|
+
"type": "object",
|
|
1071
|
+
"title": "All Editors",
|
|
1072
|
+
"properties": {
|
|
1073
|
+
"personA": {
|
|
1074
|
+
"title": "Person A",
|
|
1075
|
+
"type": "object",
|
|
1076
|
+
"properties": {
|
|
1077
|
+
"name": {
|
|
1078
|
+
"type": "string"
|
|
1079
|
+
},
|
|
1080
|
+
"age": {
|
|
1081
|
+
"type": "integer",
|
|
1082
|
+
"minimum": 0
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
},
|
|
1086
|
+
"personB": {
|
|
1087
|
+
"title": "Person B",
|
|
1088
|
+
"type": "object",
|
|
1089
|
+
"properties": {
|
|
1090
|
+
"name": {
|
|
1091
|
+
"type": "string"
|
|
1092
|
+
},
|
|
1093
|
+
"age": {
|
|
1094
|
+
"type": "integer",
|
|
1095
|
+
"minimum": 0
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
```
|
|
1102
|
+
|
|
1103
|
+
### String editors
|
|
1104
|
+
|
|
1105
|
+
#### String input
|
|
1106
|
+
|
|
1107
|
+
Renders type text input.
|
|
1108
|
+
|
|
1109
|
+
```json
|
|
1110
|
+
{
|
|
1111
|
+
"type": "string",
|
|
1112
|
+
"title": "String"
|
|
1113
|
+
}
|
|
1114
|
+
```
|
|
1115
|
+
|
|
1116
|
+
#### String radios
|
|
1117
|
+
|
|
1118
|
+
Renders as many radio type inputs as values in the `enum` constraint. The radio labels can be customized with the
|
|
1119
|
+
`enumTitles` option.
|
|
1120
|
+
|
|
1121
|
+
```json
|
|
1122
|
+
{
|
|
1123
|
+
"x-format": "radios",
|
|
1124
|
+
"type": "string",
|
|
1125
|
+
"title": "String radios",
|
|
1126
|
+
"enum": [
|
|
1127
|
+
"albert",
|
|
1128
|
+
"betti",
|
|
1129
|
+
"carl"
|
|
1130
|
+
],
|
|
1131
|
+
"x-enumTitles": [
|
|
1132
|
+
"Albert",
|
|
1133
|
+
"Betti",
|
|
1134
|
+
"Carl"
|
|
1135
|
+
]
|
|
1136
|
+
}
|
|
1137
|
+
```
|
|
1138
|
+
|
|
1139
|
+
Inline variant
|
|
1140
|
+
|
|
1141
|
+
```json
|
|
1142
|
+
{
|
|
1143
|
+
"x-format": "radios-inline",
|
|
1144
|
+
"type": "string",
|
|
1145
|
+
"title": "String radios",
|
|
1146
|
+
"enum": [
|
|
1147
|
+
"albert",
|
|
1148
|
+
"betti",
|
|
1149
|
+
"carl"
|
|
1150
|
+
],
|
|
1151
|
+
"x-enumTitles": [
|
|
1152
|
+
"Albert",
|
|
1153
|
+
"Betti",
|
|
1154
|
+
"Carl"
|
|
1155
|
+
]
|
|
1156
|
+
}
|
|
1157
|
+
```
|
|
1158
|
+
|
|
1159
|
+
#### String select
|
|
1160
|
+
|
|
1161
|
+
Renders as many radio type inputs as values in the `enum` constraint. The options labels can be customized with the
|
|
1162
|
+
`enumTitles` option.
|
|
1163
|
+
|
|
1164
|
+
```json
|
|
1165
|
+
{
|
|
1166
|
+
"type": "string",
|
|
1167
|
+
"title": "String select",
|
|
1168
|
+
"enum": [
|
|
1169
|
+
"albert",
|
|
1170
|
+
"betti",
|
|
1171
|
+
"carl"
|
|
1172
|
+
],
|
|
1173
|
+
"x-enumTitles": [
|
|
1174
|
+
"Albert",
|
|
1175
|
+
"Betti",
|
|
1176
|
+
"Carl"
|
|
1177
|
+
]
|
|
1178
|
+
}
|
|
1179
|
+
```
|
|
1180
|
+
|
|
1181
|
+
#### String textarea
|
|
1182
|
+
|
|
1183
|
+
Renders textarea input.
|
|
1184
|
+
|
|
1185
|
+
```json
|
|
1186
|
+
{
|
|
1187
|
+
"x-format": "textarea",
|
|
1188
|
+
"type": "string",
|
|
1189
|
+
"title": "String"
|
|
1190
|
+
}
|
|
1191
|
+
```
|
|
1192
|
+
|
|
1193
|
+
#### String awesomplete
|
|
1194
|
+
|
|
1195
|
+
Renders a autocomplete featured text input using Awesomplete.js if installed and available as `window.Awesomplete`.
|
|
1196
|
+
|
|
1197
|
+
```json
|
|
1198
|
+
{
|
|
1199
|
+
"title": "Awesomplete",
|
|
1200
|
+
"type": "string",
|
|
1201
|
+
"description": "Awesomplete is an ultra lightweight, customizable, simple autocomplete widget with zero dependencies, built with modern standards for modern browsers.",
|
|
1202
|
+
"default": "Awesomplete default",
|
|
1203
|
+
"minLength": 1,
|
|
1204
|
+
"x-awesomplete": {
|
|
1205
|
+
"list": [
|
|
1206
|
+
"JavaScript",
|
|
1207
|
+
"Java",
|
|
1208
|
+
"Python",
|
|
1209
|
+
"Ruby",
|
|
1210
|
+
"C++",
|
|
1211
|
+
"C#",
|
|
1212
|
+
"PHP",
|
|
1213
|
+
"Swift",
|
|
1214
|
+
"Go",
|
|
1215
|
+
"Kotlin"
|
|
1216
|
+
],
|
|
1217
|
+
"minChars": 1,
|
|
1218
|
+
"maxItems": 5,
|
|
1219
|
+
"autoFirst": true
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
```
|
|
1223
|
+
|
|
1224
|
+
#### String flatpickr
|
|
1225
|
+
|
|
1226
|
+
Renders a datetime picker using flatpickr.js if installed and available as `window.flatpickr`.
|
|
1227
|
+
|
|
1228
|
+
```json
|
|
1229
|
+
{
|
|
1230
|
+
"title": "Flatpickr",
|
|
1231
|
+
"type": "string",
|
|
1232
|
+
"description": "Flatpickr is a lightweight and powerful datetime picker.",
|
|
1233
|
+
"default": "2024-08-27",
|
|
1234
|
+
"minLength": 3,
|
|
1235
|
+
"x-flatpickr": {}
|
|
1236
|
+
}
|
|
1237
|
+
```
|
|
1238
|
+
|
|
1239
|
+
#### String imask
|
|
1240
|
+
|
|
1241
|
+
Renders a masked text input using IMask.js if installed and available as `window.IMask`.
|
|
1242
|
+
|
|
1243
|
+
```json
|
|
1244
|
+
{
|
|
1245
|
+
"title": "IBAN",
|
|
1246
|
+
"type": "string",
|
|
1247
|
+
"x-imask": {
|
|
1248
|
+
"mask": "DE00 0000 0000 0000 0000 00",
|
|
1249
|
+
"lazy": false
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
```
|
|
1253
|
+
|
|
1254
|
+
This example feature configuration through the Jedison instance `settings` option due to the impossibility
|
|
1255
|
+
of configuring the plugin with just JSON data. note that for custom options the prefix `x-` is still being used.
|
|
1256
|
+
|
|
1257
|
+
```json
|
|
1258
|
+
{
|
|
1259
|
+
"title": "Date",
|
|
1260
|
+
"type": "string",
|
|
1261
|
+
"x-imask": {
|
|
1262
|
+
"x-settings": "imaskDate"
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
```
|
|
1266
|
+
|
|
1267
|
+
```javascript
|
|
1268
|
+
const options = {
|
|
1269
|
+
settings: {
|
|
1270
|
+
imaskDate: {
|
|
1271
|
+
mask: Date,
|
|
1272
|
+
min: new Date(1990, 0, 1),
|
|
1273
|
+
max: new Date(2020, 0, 1),
|
|
1274
|
+
lazy: false
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
```
|
|
1279
|
+
|
|
1280
|
+
#### String Jodit
|
|
1281
|
+
|
|
1282
|
+
Renders a WYSIWYG editor using Jodit.js if installed and available as `window.Jodit`.
|
|
1283
|
+
|
|
1284
|
+
```json
|
|
1285
|
+
{
|
|
1286
|
+
"title": "Jodit",
|
|
1287
|
+
"type": "string",
|
|
1288
|
+
"description": "Jodit - Best WYSIWYG Editor for You.",
|
|
1289
|
+
"default": "Jodit default",
|
|
1290
|
+
"minLength": 20,
|
|
1291
|
+
"x-jodit": {}
|
|
1292
|
+
}
|
|
1293
|
+
```
|
|
1294
|
+
|
|
1295
|
+
#### String Quill
|
|
1296
|
+
|
|
1297
|
+
Renders a WYSIWYG editor using Quill.js if installed and available as `window.Quill`.
|
|
1298
|
+
|
|
1299
|
+
```json
|
|
1300
|
+
{
|
|
1301
|
+
"title": "Quill",
|
|
1302
|
+
"type": "string",
|
|
1303
|
+
"description": "Quill is a modern WYSIWYG editor built for compatibility and extensibility.",
|
|
1304
|
+
"default": "Quill default",
|
|
1305
|
+
"minLength": 3,
|
|
1306
|
+
"x-quill": {
|
|
1307
|
+
"theme": "snow"
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
```
|
|
1311
|
+
|
|
1312
|
+
### Null editors
|
|
1313
|
+
|
|
1314
|
+
#### Null
|
|
1315
|
+
|
|
1316
|
+
No input is rendered.
|
|
1317
|
+
|
|
1318
|
+
```json
|
|
1319
|
+
{
|
|
1320
|
+
"type": "null",
|
|
1321
|
+
"title": "Null"
|
|
1322
|
+
}
|
|
1323
|
+
```
|
|
1324
|
+
|
|
1325
|
+
## Language and Translations
|
|
1326
|
+
|
|
1327
|
+
The default language for UI and error messages is `en` (english). The language can be set to any of
|
|
1328
|
+
the supported languages in the instance options.
|
|
1329
|
+
|
|
1330
|
+
This will set german as the default language:
|
|
1331
|
+
|
|
1332
|
+
```javascript
|
|
1333
|
+
const jedison = new Jedison.Create({
|
|
1334
|
+
language: 'de'
|
|
1335
|
+
})
|
|
1336
|
+
```
|
|
1337
|
+
|
|
1338
|
+
Currently, the supported languages are `en` (english), `de` (german), `it` (italian) and `es` (spanish).
|
|
1339
|
+
New languages can be added to the `translations` option. To use them the `language` options
|
|
1340
|
+
should be set to the language specified.
|
|
1341
|
+
|
|
1342
|
+
The default translation can be overridden in the instance options as well.
|
|
1343
|
+
|
|
1344
|
+
```javascript
|
|
1345
|
+
const jedison = new Jedison.Create({
|
|
1346
|
+
language: 'de',
|
|
1347
|
+
translations: {
|
|
1348
|
+
de: {
|
|
1349
|
+
errorAdditionalProperties: 'Hat die zusätzliche Eigenschaft "{{ property }}", aber keine zusätzlichen Eigenschaften sind erlaubt.',
|
|
1350
|
+
errorAnyOf: 'Muss mindestens einem der bereitgestellten Schemata entsprechen.',
|
|
1351
|
+
errorConst: 'Muss den Wert {{ const }} haben.',
|
|
1352
|
+
errorContains: 'Muss mindestens ein Element enthalten, das dem bereitgestellten Schema entspricht.',
|
|
1353
|
+
errorDependentRequired: 'Muss die erforderlichen Eigenschaften haben: {{ dependentRequired }}.',
|
|
1354
|
+
errorEnum: 'Muss einer der aufgeführten Werte sein: {{ enum }}.',
|
|
1355
|
+
errorExclusiveMaximum: 'Muss kleiner als {{ exclusiveMaximum }} sein.',
|
|
1356
|
+
errorExclusiveMinimum: 'Muss größer als {{ exclusiveMinimum }} sein.',
|
|
1357
|
+
errorFormat: 'Muss ein gültiges {{ format }} sein.',
|
|
1358
|
+
errorItems: 'Muss Elemente enthalten, die dem bereitgestellten Schema entsprechen.',
|
|
1359
|
+
errorMaximum: 'Muss höchstens {{ maximum }} sein.',
|
|
1360
|
+
errorMaxItems: 'Darf höchstens {{ maxItems }} Elemente enthalten.',
|
|
1361
|
+
errorMaxLength: 'Darf höchstens {{ maxLength }} Zeichen lang sein.',
|
|
1362
|
+
errorMaxProperties: 'Darf höchstens {{ maxProperties }} Eigenschaften haben.',
|
|
1363
|
+
errorMaxContains: 'Darf höchstens {{ maxContains }} Elemente enthalten, die dem bereitgestellten Schema entsprechen. Aktuell enthält es {{ counter }}.',
|
|
1364
|
+
errorMinContains: 'Muss mindestens {{ minContains }} Elemente enthalten, die dem bereitgestellten Schema entsprechen. Aktuell enthält es {{ counter }}.',
|
|
1365
|
+
errorMinimum: 'Muss mindestens {{ minimum }} sein.',
|
|
1366
|
+
errorMinItems: 'Muss mindestens {{ minItems }} Elemente enthalten.',
|
|
1367
|
+
errorMinLength: 'Muss mindestens {{ minLength }} Zeichen lang sein.',
|
|
1368
|
+
errorMinProperties: 'Muss mindestens {{ minProperties }} Eigenschaften haben.',
|
|
1369
|
+
errorMultipleOf: 'Muss ein Vielfaches von {{ multipleOf }} sein.',
|
|
1370
|
+
errorNot: 'Darf nicht dem bereitgestellten Schema entsprechen.',
|
|
1371
|
+
errorOneOf: 'Muss genau einem der bereitgestellten Schemata entsprechen. Derzeit entspricht es {{ counter }} der Schemata.',
|
|
1372
|
+
errorPattern: 'Muss dem Muster "{{ pattern }}" entsprechen.',
|
|
1373
|
+
errorPrefixItems: 'Element {{ index }} entspricht nicht der Validierung.',
|
|
1374
|
+
errorPropertyNames: 'Der Eigenschaftsname "{{ propertyName }}" entspricht nicht der Validierung.',
|
|
1375
|
+
errorProperties: 'Die folgenden Eigenschaften entsprechen nicht ihren Schemata: {{ properties }}',
|
|
1376
|
+
errorRequired: 'Muss die erforderlichen Eigenschaften haben: {{ required }}.',
|
|
1377
|
+
errorType: 'Muss vom Typ {{ type }} sein.',
|
|
1378
|
+
errorUnevaluatedProperties: 'Hat eine ungültige nicht bewertete Eigenschaft "{{ property }}"',
|
|
1379
|
+
errorUniqueItems: 'Muss eindeutige Elemente haben.',
|
|
1380
|
+
arrayDelete: 'Element löschen',
|
|
1381
|
+
arrayMoveUp: 'Nach oben verschieben',
|
|
1382
|
+
arrayMoveDown: 'Nach unten verschieben',
|
|
1383
|
+
arrayDrag: 'Ziehen',
|
|
1384
|
+
arrayAdd: 'Element hinzufügen',
|
|
1385
|
+
arrayConfirmDelete: 'Möchten Sie dieses Element wirklich löschen?',
|
|
1386
|
+
objectAddProperty: 'Eigenschaft hinzufügen',
|
|
1387
|
+
objectPropertyAdded: 'Feld wurde dem Formular hinzugefügt',
|
|
1388
|
+
objectPropertyRemoved: 'Feld wurde aus dem Formular entfernt',
|
|
1389
|
+
propertiesToggle: 'Eigenschaften',
|
|
1390
|
+
collapseToggle: 'Einklappen'
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
})
|
|
1394
|
+
```
|
|
1395
|
+
|
|
1396
|
+
The text between brackets like `{{ minimum }}` or `{{ minLength }}` are templates.
|
|
1397
|
+
This templates will be replaced dynamically with values specified in constraints.
|
|
1398
|
+
|
|
1399
|
+
The error message for the following schema will be "Muss mindestens `3` Zeichen lang sein."
|
|
1400
|
+
because of the `minLength: 3`.
|
|
1401
|
+
|
|
1402
|
+
```json
|
|
1403
|
+
{
|
|
1404
|
+
"title": "Email",
|
|
1405
|
+
"format": "email",
|
|
1406
|
+
"type": "string",
|
|
1407
|
+
"minLength": 3
|
|
1408
|
+
}
|
|
1409
|
+
```
|
|
1410
|
+
|
|
1411
|
+
## Annotations
|
|
1412
|
+
|
|
1413
|
+
### markdown
|
|
1414
|
+
In schemas, `markdown` can be used in annotation to generate `html` content. This works only if
|
|
1415
|
+
marked.js is installed and available as `window.marked`.
|
|
1416
|
+
|
|
1417
|
+
```json
|
|
1418
|
+
{
|
|
1419
|
+
"type": "object",
|
|
1420
|
+
"title": "markdown annotations",
|
|
1421
|
+
"properties": {
|
|
1422
|
+
"name": {
|
|
1423
|
+
"title": "**markdown to html title**",
|
|
1424
|
+
"type": "string"
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
```
|
|
1429
|
+
|
|
1430
|
+
## Schema options
|
|
1431
|
+
|
|
1432
|
+
The `x-` or `x-options` [custom annotation](https://json-schema.org/blog/posts/custom-annotations-will-continue#what's-the-solution)
|
|
1433
|
+
can be used in JSON Schemas to changes how instances and editors behave.
|
|
1434
|
+
Schema `x-` options override global options.
|
|
1435
|
+
|
|
1436
|
+
```json
|
|
1437
|
+
{
|
|
1438
|
+
"title": "Message",
|
|
1439
|
+
"type": "string",
|
|
1440
|
+
"x-showErrors": "always"
|
|
1441
|
+
}
|
|
1442
|
+
```
|
|
1443
|
+
|
|
1444
|
+
Some options depend on other options to be set. In the example the option `"enumTitles"`
|
|
1445
|
+
depends on the option `"enum"`.
|
|
1446
|
+
|
|
1447
|
+
```json
|
|
1448
|
+
{
|
|
1449
|
+
"title": "Type",
|
|
1450
|
+
"type": "string",
|
|
1451
|
+
"enum": [
|
|
1452
|
+
"#000000",
|
|
1453
|
+
"#ffffff"
|
|
1454
|
+
],
|
|
1455
|
+
"x-enumTitles": [
|
|
1456
|
+
"Black",
|
|
1457
|
+
"White"
|
|
1458
|
+
]
|
|
1459
|
+
}
|
|
1460
|
+
```
|
|
1461
|
+
|
|
1462
|
+
### `x-addPropertyContent`
|
|
1463
|
+
|
|
1464
|
+
- Type: `boolean`
|
|
1465
|
+
- Default: -
|
|
1466
|
+
- Description: Text content for "add property" buttons.
|
|
1467
|
+
|
|
1468
|
+
### `x-arrayAdd`
|
|
1469
|
+
|
|
1470
|
+
- Type: `boolean`
|
|
1471
|
+
- Default: `true`
|
|
1472
|
+
- Description: If array add buttons should be displayed.
|
|
1473
|
+
|
|
1474
|
+
### `x-arrayAddContent`
|
|
1475
|
+
|
|
1476
|
+
- Type: `boolean`
|
|
1477
|
+
- Default: -
|
|
1478
|
+
- Description: Text content for array "add" buttons.
|
|
1479
|
+
|
|
1480
|
+
### `x-arrayDelete`
|
|
1481
|
+
|
|
1482
|
+
- Type: `boolean`
|
|
1483
|
+
- Default: `true`
|
|
1484
|
+
- Description: If array delete buttons should be displayed.
|
|
1485
|
+
|
|
1486
|
+
### `x-arrayDeleteContent`
|
|
1487
|
+
|
|
1488
|
+
- Type: `boolean`
|
|
1489
|
+
- Default: -
|
|
1490
|
+
- Description: Text content for array "delete" buttons.
|
|
1491
|
+
|
|
1492
|
+
### `x-arrayDragContent`,
|
|
1493
|
+
|
|
1494
|
+
- Type: `boolean`
|
|
1495
|
+
- Default: -
|
|
1496
|
+
- Description: Text content for array "drag" buttons.
|
|
1497
|
+
|
|
1498
|
+
### `x-arrayMove`
|
|
1499
|
+
|
|
1500
|
+
- Type: `boolean`
|
|
1501
|
+
- Default: `true`
|
|
1502
|
+
- Description: If array move up and move down buttons should be displayed.
|
|
1503
|
+
|
|
1504
|
+
### `x-arrayMoveDownContent`
|
|
1505
|
+
|
|
1506
|
+
- Type: `boolean`
|
|
1507
|
+
- Default: -
|
|
1508
|
+
- Description: Text content for array "move down" buttons.
|
|
1509
|
+
|
|
1510
|
+
### `x-arrayMoveUpContent`
|
|
1511
|
+
|
|
1512
|
+
- Type: `boolean`
|
|
1513
|
+
- Default: -
|
|
1514
|
+
- Description: Text content for array "move up" buttons.
|
|
1515
|
+
|
|
1516
|
+
### `x-assertFormat`
|
|
1517
|
+
|
|
1518
|
+
- Type: `boolean`
|
|
1519
|
+
- Default: `"false"`
|
|
1520
|
+
- Options: `"never"`, `"change"`, `"always"`
|
|
1521
|
+
- Description: Treats `"format"` as a validator rather than just an annotation.
|
|
1522
|
+
|
|
1523
|
+
Treat `"format": "email"` as a constraint keyword instead of an annotation.
|
|
1524
|
+
|
|
1525
|
+
```json
|
|
1526
|
+
{
|
|
1527
|
+
"title": "Message",
|
|
1528
|
+
"type": "string",
|
|
1529
|
+
"format": "email",
|
|
1530
|
+
"x-assertFormat": true
|
|
1531
|
+
}
|
|
1532
|
+
```
|
|
1533
|
+
|
|
1534
|
+
### `x-collapseToggleContent`
|
|
1535
|
+
|
|
1536
|
+
- Type: `boolean`
|
|
1537
|
+
- Default: -
|
|
1538
|
+
- Description: Text content for "collapse" buttons.
|
|
1539
|
+
|
|
1540
|
+
### `x-containerAttributes`
|
|
1541
|
+
|
|
1542
|
+
- Type: `object`
|
|
1543
|
+
- Description: Editors container HTML attributes can be set using the `x-containerAttributes` option. Attributes such as `class` or `data-*` will be applied to the container element.
|
|
1544
|
+
|
|
1545
|
+
```json
|
|
1546
|
+
{
|
|
1547
|
+
"title": "`x-containerAttributes`",
|
|
1548
|
+
"type": "object",
|
|
1549
|
+
"description": "Editors container HTML attributes can be set using the `x-containerAttributes` option. Attributes such as `class` or `data-*` will be applied to the container element.",
|
|
1550
|
+
"x-containerAttributes": {
|
|
1551
|
+
"class": "a-class another-class",
|
|
1552
|
+
"data-custom": "custom-data"
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
```
|
|
1556
|
+
|
|
1557
|
+
### `x-deactivateNonRequired`
|
|
1558
|
+
|
|
1559
|
+
- Type: `boolean`
|
|
1560
|
+
- Description: Whether the editor should deactivate (hide) or activate (show) non required properties. Works on only with `object` type editors.
|
|
1561
|
+
|
|
1562
|
+
Only the property `name` is active
|
|
1563
|
+
|
|
1564
|
+
```json
|
|
1565
|
+
{
|
|
1566
|
+
"title": "Person",
|
|
1567
|
+
"type": "object",
|
|
1568
|
+
"x-deactivateNonRequired": true,
|
|
1569
|
+
"required": [
|
|
1570
|
+
"name"
|
|
1571
|
+
],
|
|
1572
|
+
"properties": {
|
|
1573
|
+
"name": {
|
|
1574
|
+
"type": "string",
|
|
1575
|
+
"title": "Name"
|
|
1576
|
+
},
|
|
1577
|
+
"age": {
|
|
1578
|
+
"type": "integer",
|
|
1579
|
+
"title": "Age"
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
```
|
|
1584
|
+
|
|
1585
|
+
### `x-enableCollapseToggle`
|
|
1586
|
+
|
|
1587
|
+
- Type: `boolean`
|
|
1588
|
+
- Description: Display a collapse button used to collapse or expand editors that support collapse like `object` and `arrays`
|
|
1589
|
+
|
|
1590
|
+
### `x-enforceConst`
|
|
1591
|
+
|
|
1592
|
+
- Type: `boolean`
|
|
1593
|
+
- Default: `true`
|
|
1594
|
+
- Description: Value will remain whatever is defined in schema `"const"`.
|
|
1595
|
+
|
|
1596
|
+
Default value for this editor will be `"ff0000"`.
|
|
1597
|
+
|
|
1598
|
+
```json
|
|
1599
|
+
{
|
|
1600
|
+
"title": "Color",
|
|
1601
|
+
"type": "string",
|
|
1602
|
+
"const": "ff0000",
|
|
1603
|
+
"x-enforceConst": true
|
|
1604
|
+
}
|
|
1605
|
+
```
|
|
1606
|
+
|
|
1607
|
+
### `x-enforceEnum`
|
|
1608
|
+
|
|
1609
|
+
- Type: `boolean`
|
|
1610
|
+
- Default: `true`
|
|
1611
|
+
- Description: Whether the editor initial value will be the first item in the `"enum"`.
|
|
1612
|
+
|
|
1613
|
+
Default value for this editor will be `""`.
|
|
1614
|
+
|
|
1615
|
+
```json
|
|
1616
|
+
{
|
|
1617
|
+
"title": "Color",
|
|
1618
|
+
"type": "string",
|
|
1619
|
+
"enum": [
|
|
1620
|
+
"ff0000",
|
|
1621
|
+
"00ff00",
|
|
1622
|
+
"0000ff"
|
|
1623
|
+
],
|
|
1624
|
+
"x-enforceEnum": false
|
|
1625
|
+
}
|
|
1626
|
+
```
|
|
1627
|
+
|
|
1628
|
+
Default value for this editor will be `"ff0000"`.
|
|
1629
|
+
|
|
1630
|
+
```json
|
|
1631
|
+
{
|
|
1632
|
+
"title": "Color",
|
|
1633
|
+
"type": "string",
|
|
1634
|
+
"enum": [
|
|
1635
|
+
"ff0000",
|
|
1636
|
+
"00ff00",
|
|
1637
|
+
"0000ff"
|
|
1638
|
+
],
|
|
1639
|
+
"x-enforceEnum": true
|
|
1640
|
+
}
|
|
1641
|
+
```
|
|
1642
|
+
|
|
1643
|
+
### `x-enumTitles`
|
|
1644
|
+
|
|
1645
|
+
- Type: `string[]`
|
|
1646
|
+
- Description: Used to display user-friendly labels in the editor instead of those listen in `"enum"`.
|
|
1647
|
+
|
|
1648
|
+
Display color names instead of hex codes.
|
|
1649
|
+
|
|
1650
|
+
```json
|
|
1651
|
+
{
|
|
1652
|
+
"title": "Color",
|
|
1653
|
+
"type": "string",
|
|
1654
|
+
"enum": [
|
|
1655
|
+
"ff0000",
|
|
1656
|
+
"00ff00",
|
|
1657
|
+
"0000ff"
|
|
1658
|
+
],
|
|
1659
|
+
"x-enumTitles": [
|
|
1660
|
+
"Red",
|
|
1661
|
+
"Green",
|
|
1662
|
+
"Blue"
|
|
1663
|
+
]
|
|
1664
|
+
}
|
|
1665
|
+
```
|
|
1666
|
+
|
|
1667
|
+
### `x-format`
|
|
1668
|
+
|
|
1669
|
+
- Type: `string`
|
|
1670
|
+
- Description: Determines which editor UI will be used to edit the json einstance.
|
|
1671
|
+
|
|
1672
|
+
Use radios editor to display color names instead of hex codes.
|
|
1673
|
+
|
|
1674
|
+
```json
|
|
1675
|
+
{
|
|
1676
|
+
"title": "Color",
|
|
1677
|
+
"type": "string",
|
|
1678
|
+
"enum": [
|
|
1679
|
+
"Red",
|
|
1680
|
+
"Green",
|
|
1681
|
+
"Blue"
|
|
1682
|
+
],
|
|
1683
|
+
"x-format": "radios"
|
|
1684
|
+
}
|
|
1685
|
+
```
|
|
1686
|
+
|
|
1687
|
+
### `x-grid`
|
|
1688
|
+
|
|
1689
|
+
- Type: `object`
|
|
1690
|
+
- Description: A configuration object to determine the position of the property editor in the parent's grid.
|
|
1691
|
+
- Options:
|
|
1692
|
+
- `columns`: How many columns should the editor occupy.
|
|
1693
|
+
- `offset`: How many columns should the editor be offsetted.
|
|
1694
|
+
- `newRow`: Whether the editor should be put in a new row.
|
|
1695
|
+
|
|
1696
|
+
### `x-hidden`
|
|
1697
|
+
|
|
1698
|
+
- Type: `boolean`
|
|
1699
|
+
- Description: Editors can be hidden using the `x-hidden` option. When set to `true`, the editor is hidden.
|
|
1700
|
+
|
|
1701
|
+
### `x-info`
|
|
1702
|
+
|
|
1703
|
+
- Type: `object`
|
|
1704
|
+
- Description: Used to display extra information. If `markdown` is used to generate `html` content, it can be sanitized by DOMPurify is available, otherwise only the textContent will be displayed without any HTML tags.
|
|
1705
|
+
- Options:
|
|
1706
|
+
- `variant`: `"modal"`
|
|
1707
|
+
- `title`: Plain text or `markdown`.
|
|
1708
|
+
- `content`: Plain text or `markdown`.
|
|
1709
|
+
|
|
1710
|
+
Displays an info button right after the title, that opens a modal with title and content.
|
|
1711
|
+
|
|
1712
|
+
```json
|
|
1713
|
+
{
|
|
1714
|
+
"title": "Message",
|
|
1715
|
+
"type": "string",
|
|
1716
|
+
"x-info": {
|
|
1717
|
+
"variant": "modal",
|
|
1718
|
+
"title": "### Info Button title",
|
|
1719
|
+
"content": "Info button content"
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
```
|
|
1723
|
+
|
|
1724
|
+
### `x-inputAttributes`
|
|
1725
|
+
|
|
1726
|
+
- Type: `object`
|
|
1727
|
+
- Description: Used to set attributes for the editor input.
|
|
1728
|
+
|
|
1729
|
+
Add `placeholder` attribute to textarea.
|
|
1730
|
+
|
|
1731
|
+
```json
|
|
1732
|
+
{
|
|
1733
|
+
"title": "Message",
|
|
1734
|
+
"type": "string",
|
|
1735
|
+
"x-format": "textarea",
|
|
1736
|
+
"x-inputAttributes": {
|
|
1737
|
+
"placeholder": "Your message here..."
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
```
|
|
1741
|
+
|
|
1742
|
+
### `x-messages`
|
|
1743
|
+
|
|
1744
|
+
- Type: `object` | `string[]`
|
|
1745
|
+
- Description: Validation error messages can be customized using the `x-messages` option in the schema.
|
|
1746
|
+
|
|
1747
|
+
Validation error messages can be customized using the `x-messages` option in the schema. When defined as an object, messages can be applied by constraint (e.g., `minLength`, `const`).
|
|
1748
|
+
|
|
1749
|
+
```json
|
|
1750
|
+
{
|
|
1751
|
+
"title": "`x-messages`",
|
|
1752
|
+
"description": "Validation error messages can be customized using the `x-messages` option in the schema. When defined as an object, messages can be applied by constraint (e.g., `minLength`, `const`).",
|
|
1753
|
+
"type": "object",
|
|
1754
|
+
"properties": {
|
|
1755
|
+
"string": {
|
|
1756
|
+
"type": "string",
|
|
1757
|
+
"minLength": 5,
|
|
1758
|
+
"const": "locoloco",
|
|
1759
|
+
"x-messages": {
|
|
1760
|
+
"minLength": "Need at least 5 sparks of brilliance.",
|
|
1761
|
+
"const": "Only 'locoloco' unlocks the magic here."
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
```
|
|
1767
|
+
|
|
1768
|
+
Validation error messages can be customized using the `x-messages` option in the schema. When defined as an object, messages can be applied per language (e.g., `en`, `fr`) and constraint (e.g., `minLength`, `const`).
|
|
1769
|
+
|
|
1770
|
+
```json
|
|
1771
|
+
{
|
|
1772
|
+
"title": "`x-messages`",
|
|
1773
|
+
"description": "Validation error messages can be customized using the `x-messages` option in the schema. When defined as an array, messages are defined per validation rule (e.g., `minLength`, `const`) and per language (e.g., `en`, `fr`).",
|
|
1774
|
+
"type": "object",
|
|
1775
|
+
"properties": {
|
|
1776
|
+
"string": {
|
|
1777
|
+
"type": "string",
|
|
1778
|
+
"minLength": 5,
|
|
1779
|
+
"const": "locoloco",
|
|
1780
|
+
"x-messages": {
|
|
1781
|
+
"en": {
|
|
1782
|
+
"minLength": "Need at least 5 sparks of brilliance.",
|
|
1783
|
+
"const": "Only 'locoloco' unlocks the magic here."
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
```
|
|
1790
|
+
|
|
1791
|
+
When defined as an array, the messages apply to all validation rules for the property.
|
|
1792
|
+
|
|
1793
|
+
```json
|
|
1794
|
+
{
|
|
1795
|
+
"title": "`x-messages`",
|
|
1796
|
+
"description": "Validation error messages can be customized using the `x-messages` option in the schema. When defined as an array, the messages apply to all validation rules for the property.",
|
|
1797
|
+
"type": "object",
|
|
1798
|
+
"properties": {
|
|
1799
|
+
"string": {
|
|
1800
|
+
"type": "string",
|
|
1801
|
+
"minLength": 5,
|
|
1802
|
+
"x-messages": [
|
|
1803
|
+
"5 chars please."
|
|
1804
|
+
]
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
```
|
|
1809
|
+
|
|
1810
|
+
### `x-propertiesToggleContent`
|
|
1811
|
+
|
|
1812
|
+
- Type: `boolean`
|
|
1813
|
+
- Default: -
|
|
1814
|
+
- Description: Text content for "properties" buttons.
|
|
1815
|
+
|
|
1816
|
+
### `x-showErrors`
|
|
1817
|
+
|
|
1818
|
+
- Type: `string`
|
|
1819
|
+
- Default: `"change"`
|
|
1820
|
+
- Options: `"never"`, `"change"`, `"always"`
|
|
1821
|
+
- Description: Determines when to display validation errors.
|
|
1822
|
+
|
|
1823
|
+
Always show errors for this editor even if the value didn't change.
|
|
1824
|
+
|
|
1825
|
+
```json
|
|
1826
|
+
{
|
|
1827
|
+
"title": "Message",
|
|
1828
|
+
"type": "string",
|
|
1829
|
+
"x-showErrors": "always"
|
|
1830
|
+
}
|
|
1831
|
+
```
|
|
1832
|
+
|
|
1833
|
+
### `x-sortable`
|
|
1834
|
+
|
|
1835
|
+
- Type: `boolean`
|
|
1836
|
+
- Default: `false`
|
|
1837
|
+
- Description: Items can be sort via drag and drop if Sortable.js.
|
|
1838
|
+
|
|
1839
|
+
### `x-startCollapsed`
|
|
1840
|
+
|
|
1841
|
+
- Type: `boolean`
|
|
1842
|
+
- Description: Whether the editor should start expanded or collapsed. Works on editors that support collapse like `object` and `arrays`
|
|
1843
|
+
|
|
1844
|
+
### `x-switcherTitle`
|
|
1845
|
+
|
|
1846
|
+
- Type: `string`
|
|
1847
|
+
- Default: property name or `"title"`.
|
|
1848
|
+
- Description: The text displayed in the multiple editor switcher to select this sub-schema editor.
|
|
1849
|
+
|
|
1850
|
+
Switcher options displayed are:
|
|
1851
|
+
|
|
1852
|
+
- "I want to pay with Credit Card"
|
|
1853
|
+
- "I want to pay with PayPal"
|
|
1854
|
+
|
|
1855
|
+
But in the sub-editors the titles remain:
|
|
1856
|
+
|
|
1857
|
+
- "Card Number"
|
|
1858
|
+
- "Email"
|
|
1859
|
+
|
|
1860
|
+
```json
|
|
1861
|
+
{
|
|
1862
|
+
"anyOf": [
|
|
1863
|
+
{
|
|
1864
|
+
"title": "Card Number",
|
|
1865
|
+
"type": "string",
|
|
1866
|
+
"x-switcherTitle": "I want to pay with Credit Card"
|
|
1867
|
+
},
|
|
1868
|
+
{
|
|
1869
|
+
"title": "Email",
|
|
1870
|
+
"type": "string",
|
|
1871
|
+
"x-switcherTitle": "I want to pay with PayPal"
|
|
1872
|
+
}
|
|
1873
|
+
]
|
|
1874
|
+
}
|
|
1875
|
+
```
|
|
1876
|
+
|
|
1877
|
+
### `x-titleHidden`
|
|
1878
|
+
|
|
1879
|
+
- Type: `boolean`
|
|
1880
|
+
- Default: `false`
|
|
1881
|
+
- Description: Hides the editor title.
|
|
1882
|
+
|
|
1883
|
+
### `x-titleIconClass`
|
|
1884
|
+
|
|
1885
|
+
- Type: `string`
|
|
1886
|
+
- Description: Icon class to use in titles if using any.
|
|
1887
|
+
|
|
1888
|
+
Show a fontawesome envelope icon in the title.
|
|
1889
|
+
|
|
1890
|
+
```json
|
|
1891
|
+
{
|
|
1892
|
+
"title": "Message",
|
|
1893
|
+
"type": "string",
|
|
1894
|
+
"x-titleIconClass": "fas fa-envelope"
|
|
1895
|
+
}
|
|
1896
|
+
```
|
|
1897
|
+
|
|
1898
|
+
### `x-titleTemplate`
|
|
1899
|
+
|
|
1900
|
+
- Type: `string`
|
|
1901
|
+
- Description: A template to form titles dynamically.
|
|
1902
|
+
|
|
1903
|
+
|
|
1904
|
+
## License
|
|
1905
|
+
|
|
1906
|
+
Jedison is released under the MIT License, making it free for commercial and non-commercial use.
|
|
1907
|
+
|
|
1908
|
+
## Resources
|
|
1909
|
+
|
|
1910
|
+
* [Understanding JSON Schema](https://json-schema.org/understanding-json-schema)
|
|
1911
|
+
* [JSON-Schema-Test-Suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite)
|