/**
30 | * Module containing classes and objects that define the form element type and
31 | * behavior.
32 | *
33 | * @module formElementDefinitions
34 | */
35 |
36 | /**
37 | * The available types of a form element.
38 | *
39 | * @enum {string}
40 | */
41 | const ElementType = {
42 | /** The form element representing the root JSON Schema. */
43 | ROOT: 'root',
44 |
45 | /** A required form element. */
46 | REQUIRED: 'required',
47 |
48 | /** An optional form element. */
49 | OPTIONAL: 'optional',
50 |
51 | /** A form element able to be removed. */
52 | REMOVABLE: 'removable',
53 | };
54 |
55 | /**
56 | * The possible types of a form element title.
57 | *
58 | * @enum {string}
59 | */
60 | const TitleType = {
61 | /** A regular, unmodifiable form element title. */
62 | STATIC: 'static',
63 |
64 | /** An editable form element title. */
65 | FIELD: 'field',
66 |
67 | /** A static element title for an added JSON Schema's `array` item. */
68 | ADDED_ITEM: 'addedItem',
69 | };
70 |
71 | /** The form element state descriptor. */
72 | class State {
73 | /**
74 | * Class constructor.
75 | *
76 | * @param {boolean} [active=true] Flag indicating whether the form element is
77 | * active (i.e. the form element can be interacted --at least its toggler).
78 | * @param {boolean?} [disabled=null] Flag indicating whether the form element
79 | * is disabled (i.e. the input fields or child elements cannot be interacted).
80 | */
81 | constructor(active = true, disabled = null) {
82 | /**
83 | * Indicates whether the form element is active.
84 | *
85 | * @type {boolean}
86 | */
87 | this.active = active;
88 |
89 | /**
90 | * Indicates whether the form element is disabled.
91 | *
92 | * @type {boolean?}
93 | */
94 | this.disabled = disabled;
95 | }
96 | }
97 |
98 | export { ElementType, State, TitleType };
99 |
A JavaScript tool that generates HTML forms from JSON Schemas.
48 |
This implementation accepts schemas following the JSON Schema Draft 2019-09 specification, with the goal of providing a straightforward mean to express potentially large and complex JSON Schemas in an intuitive fashion.
49 |
JsonSchemaForms comes with Bootstrap (4.5+) and Font Awesome (5.13+) support in order to organize and decorate the layout. While these libraries are not required, they are highly recommended to get the form properly rendered by the browser.
50 |
JsonSchemaForms makes use of the JSON Schema $Ref Parser to resolve and dereference the schemas to be processed.
51 |
Usage
52 |
The JsonSchemaForms module provides a build() function that performs the whole process of analyzing a JSON Schema and generating the DOM and internal representation of the form. Have a look at the JsonSchemaForms.build() API for usage details.
53 |
Through CDN
54 |
The quickly and easy way to make JsonSchemaForms available to your scripts, by adding a few CDN links to your HTML code.
55 |
JsonSchemaForms provides a script and style sheet that can be linked adding the following tags:
On top of that, as mentioned before, Bootstrap and Font Awesome allow for a nice-looking result, so their CDN links are recommended to be included, too.
61 |
Hence, the full picture of a barebone example.html using JsonSchemaForms CDN ends up looking like this:
500 |
501 |
504 |
505 |
506 |
507 |
510 |
511 |
512 |
513 |
514 |
--------------------------------------------------------------------------------
/docs/scripts/linenumber.js:
--------------------------------------------------------------------------------
1 | /*global document */
2 | (() => {
3 | const source = document.getElementsByClassName('prettyprint source linenums');
4 | let i = 0;
5 | let lineNumber = 0;
6 | let lineId;
7 | let lines;
8 | let totalLines;
9 | let anchorHash;
10 |
11 | if (source && source[0]) {
12 | anchorHash = document.location.hash.substring(1);
13 | lines = source[0].getElementsByTagName('li');
14 | totalLines = lines.length;
15 |
16 | for (; i < totalLines; i++) {
17 | lineNumber++;
18 | lineId = `line${lineNumber}`;
19 | lines[i].id = lineId;
20 | if (lineId === anchorHash) {
21 | lines[i].className += ' selected';
22 | }
23 | }
24 | }
25 | })();
26 |
--------------------------------------------------------------------------------
/docs/scripts/prettify/Apache-License-2.0.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/docs/scripts/prettify/lang-css.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n"]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com",
2 | /^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]);
3 |
--------------------------------------------------------------------------------
/docs/styles/jsdoc-default.css:
--------------------------------------------------------------------------------
1 | @font-face {
2 | font-family: 'Open Sans';
3 | font-weight: normal;
4 | font-style: normal;
5 | src: url('../fonts/OpenSans-Regular-webfont.eot');
6 | src:
7 | local('Open Sans'),
8 | local('OpenSans'),
9 | url('../fonts/OpenSans-Regular-webfont.eot?#iefix') format('embedded-opentype'),
10 | url('../fonts/OpenSans-Regular-webfont.woff') format('woff'),
11 | url('../fonts/OpenSans-Regular-webfont.svg#open_sansregular') format('svg');
12 | }
13 |
14 | @font-face {
15 | font-family: 'Open Sans Light';
16 | font-weight: normal;
17 | font-style: normal;
18 | src: url('../fonts/OpenSans-Light-webfont.eot');
19 | src:
20 | local('Open Sans Light'),
21 | local('OpenSans Light'),
22 | url('../fonts/OpenSans-Light-webfont.eot?#iefix') format('embedded-opentype'),
23 | url('../fonts/OpenSans-Light-webfont.woff') format('woff'),
24 | url('../fonts/OpenSans-Light-webfont.svg#open_sanslight') format('svg');
25 | }
26 |
27 | html
28 | {
29 | overflow: auto;
30 | background-color: #fff;
31 | font-size: 14px;
32 | }
33 |
34 | body
35 | {
36 | font-family: 'Open Sans', sans-serif;
37 | line-height: 1.5;
38 | color: #4d4e53;
39 | background-color: white;
40 | }
41 |
42 | a, a:visited, a:active {
43 | color: #0095dd;
44 | text-decoration: none;
45 | }
46 |
47 | a:hover {
48 | text-decoration: underline;
49 | }
50 |
51 | header
52 | {
53 | display: block;
54 | padding: 0px 4px;
55 | }
56 |
57 | tt, code, kbd, samp {
58 | font-family: Consolas, Monaco, 'Andale Mono', monospace;
59 | }
60 |
61 | .class-description {
62 | font-size: 130%;
63 | line-height: 140%;
64 | margin-bottom: 1em;
65 | margin-top: 1em;
66 | }
67 |
68 | .class-description:empty {
69 | margin: 0;
70 | }
71 |
72 | #main {
73 | float: left;
74 | width: 70%;
75 | }
76 |
77 | article dl {
78 | margin-bottom: 40px;
79 | }
80 |
81 | article img {
82 | max-width: 100%;
83 | }
84 |
85 | section
86 | {
87 | display: block;
88 | background-color: #fff;
89 | padding: 12px 24px;
90 | border-bottom: 1px solid #ccc;
91 | margin-right: 30px;
92 | }
93 |
94 | .variation {
95 | display: none;
96 | }
97 |
98 | .signature-attributes {
99 | font-size: 60%;
100 | color: #aaa;
101 | font-style: italic;
102 | font-weight: lighter;
103 | }
104 |
105 | nav
106 | {
107 | display: block;
108 | float: right;
109 | margin-top: 28px;
110 | width: 30%;
111 | box-sizing: border-box;
112 | border-left: 1px solid #ccc;
113 | padding-left: 16px;
114 | }
115 |
116 | nav ul {
117 | font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif;
118 | font-size: 100%;
119 | line-height: 17px;
120 | padding: 0;
121 | margin: 0;
122 | list-style-type: none;
123 | }
124 |
125 | nav ul a, nav ul a:visited, nav ul a:active {
126 | font-family: Consolas, Monaco, 'Andale Mono', monospace;
127 | line-height: 18px;
128 | color: #4D4E53;
129 | }
130 |
131 | nav h3 {
132 | margin-top: 12px;
133 | }
134 |
135 | nav li {
136 | margin-top: 6px;
137 | }
138 |
139 | footer {
140 | display: block;
141 | padding: 6px;
142 | margin-top: 12px;
143 | font-style: italic;
144 | font-size: 90%;
145 | }
146 |
147 | h1, h2, h3, h4 {
148 | font-weight: 200;
149 | margin: 0;
150 | }
151 |
152 | h1
153 | {
154 | font-family: 'Open Sans Light', sans-serif;
155 | font-size: 48px;
156 | letter-spacing: -2px;
157 | margin: 12px 24px 20px;
158 | }
159 |
160 | h2, h3.subsection-title
161 | {
162 | font-size: 30px;
163 | font-weight: 700;
164 | letter-spacing: -1px;
165 | margin-bottom: 12px;
166 | }
167 |
168 | h3
169 | {
170 | font-size: 24px;
171 | letter-spacing: -0.5px;
172 | margin-bottom: 12px;
173 | }
174 |
175 | h4
176 | {
177 | font-size: 18px;
178 | letter-spacing: -0.33px;
179 | margin-bottom: 12px;
180 | color: #4d4e53;
181 | }
182 |
183 | h5, .container-overview .subsection-title
184 | {
185 | font-size: 120%;
186 | font-weight: bold;
187 | letter-spacing: -0.01em;
188 | margin: 8px 0 3px 0;
189 | }
190 |
191 | h6
192 | {
193 | font-size: 100%;
194 | letter-spacing: -0.01em;
195 | margin: 6px 0 3px 0;
196 | font-style: italic;
197 | }
198 |
199 | table
200 | {
201 | border-spacing: 0;
202 | border: 0;
203 | border-collapse: collapse;
204 | }
205 |
206 | td, th
207 | {
208 | border: 1px solid #ddd;
209 | margin: 0px;
210 | text-align: left;
211 | vertical-align: top;
212 | padding: 4px 6px;
213 | display: table-cell;
214 | }
215 |
216 | thead tr
217 | {
218 | background-color: #ddd;
219 | font-weight: bold;
220 | }
221 |
222 | th { border-right: 1px solid #aaa; }
223 | tr > th:last-child { border-right: 1px solid #ddd; }
224 |
225 | .ancestors, .attribs { color: #999; }
226 | .ancestors a, .attribs a
227 | {
228 | color: #999 !important;
229 | text-decoration: none;
230 | }
231 |
232 | .clear
233 | {
234 | clear: both;
235 | }
236 |
237 | .important
238 | {
239 | font-weight: bold;
240 | color: #950B02;
241 | }
242 |
243 | .yes-def {
244 | text-indent: -1000px;
245 | }
246 |
247 | .type-signature {
248 | color: #aaa;
249 | }
250 |
251 | .name, .signature {
252 | font-family: Consolas, Monaco, 'Andale Mono', monospace;
253 | }
254 |
255 | .details { margin-top: 14px; border-left: 2px solid #DDD; }
256 | .details dt { width: 120px; float: left; padding-left: 10px; padding-top: 6px; }
257 | .details dd { margin-left: 70px; }
258 | .details ul { margin: 0; }
259 | .details ul { list-style-type: none; }
260 | .details li { margin-left: 30px; padding-top: 6px; }
261 | .details pre.prettyprint { margin: 0 }
262 | .details .object-value { padding-top: 0; }
263 |
264 | .description {
265 | margin-bottom: 1em;
266 | margin-top: 1em;
267 | }
268 |
269 | .code-caption
270 | {
271 | font-style: italic;
272 | font-size: 107%;
273 | margin: 0;
274 | }
275 |
276 | .source
277 | {
278 | border: 1px solid #ddd;
279 | width: 80%;
280 | overflow: auto;
281 | }
282 |
283 | .prettyprint.source {
284 | width: inherit;
285 | }
286 |
287 | .source code
288 | {
289 | font-size: 100%;
290 | line-height: 18px;
291 | display: block;
292 | padding: 4px 12px;
293 | margin: 0;
294 | background-color: #fff;
295 | color: #4D4E53;
296 | }
297 |
298 | .prettyprint code span.line
299 | {
300 | display: inline-block;
301 | }
302 |
303 | .prettyprint.linenums
304 | {
305 | padding-left: 70px;
306 | -webkit-user-select: none;
307 | -moz-user-select: none;
308 | -ms-user-select: none;
309 | user-select: none;
310 | }
311 |
312 | .prettyprint.linenums ol
313 | {
314 | padding-left: 0;
315 | }
316 |
317 | .prettyprint.linenums li
318 | {
319 | border-left: 3px #ddd solid;
320 | }
321 |
322 | .prettyprint.linenums li.selected,
323 | .prettyprint.linenums li.selected *
324 | {
325 | background-color: lightyellow;
326 | }
327 |
328 | .prettyprint.linenums li *
329 | {
330 | -webkit-user-select: text;
331 | -moz-user-select: text;
332 | -ms-user-select: text;
333 | user-select: text;
334 | }
335 |
336 | .params .name, .props .name, .name code {
337 | color: #4D4E53;
338 | font-family: Consolas, Monaco, 'Andale Mono', monospace;
339 | font-size: 100%;
340 | }
341 |
342 | .params td.description > p:first-child,
343 | .props td.description > p:first-child
344 | {
345 | margin-top: 0;
346 | padding-top: 0;
347 | }
348 |
349 | .params td.description > p:last-child,
350 | .props td.description > p:last-child
351 | {
352 | margin-bottom: 0;
353 | padding-bottom: 0;
354 | }
355 |
356 | .disabled {
357 | color: #454545;
358 | }
359 |
--------------------------------------------------------------------------------
/docs/styles/prettify-jsdoc.css:
--------------------------------------------------------------------------------
1 | /* JSDoc prettify.js theme */
2 |
3 | /* plain text */
4 | .pln {
5 | color: #000000;
6 | font-weight: normal;
7 | font-style: normal;
8 | }
9 |
10 | /* string content */
11 | .str {
12 | color: #006400;
13 | font-weight: normal;
14 | font-style: normal;
15 | }
16 |
17 | /* a keyword */
18 | .kwd {
19 | color: #000000;
20 | font-weight: bold;
21 | font-style: normal;
22 | }
23 |
24 | /* a comment */
25 | .com {
26 | font-weight: normal;
27 | font-style: italic;
28 | }
29 |
30 | /* a type name */
31 | .typ {
32 | color: #000000;
33 | font-weight: normal;
34 | font-style: normal;
35 | }
36 |
37 | /* a literal value */
38 | .lit {
39 | color: #006400;
40 | font-weight: normal;
41 | font-style: normal;
42 | }
43 |
44 | /* punctuation */
45 | .pun {
46 | color: #000000;
47 | font-weight: bold;
48 | font-style: normal;
49 | }
50 |
51 | /* lisp open bracket */
52 | .opn {
53 | color: #000000;
54 | font-weight: bold;
55 | font-style: normal;
56 | }
57 |
58 | /* lisp close bracket */
59 | .clo {
60 | color: #000000;
61 | font-weight: bold;
62 | font-style: normal;
63 | }
64 |
65 | /* a markup tag name */
66 | .tag {
67 | color: #006400;
68 | font-weight: normal;
69 | font-style: normal;
70 | }
71 |
72 | /* a markup attribute name */
73 | .atn {
74 | color: #006400;
75 | font-weight: normal;
76 | font-style: normal;
77 | }
78 |
79 | /* a markup attribute value */
80 | .atv {
81 | color: #006400;
82 | font-weight: normal;
83 | font-style: normal;
84 | }
85 |
86 | /* a declaration */
87 | .dec {
88 | color: #000000;
89 | font-weight: bold;
90 | font-style: normal;
91 | }
92 |
93 | /* a variable name */
94 | .var {
95 | color: #000000;
96 | font-weight: normal;
97 | font-style: normal;
98 | }
99 |
100 | /* a function name */
101 | .fun {
102 | color: #000000;
103 | font-weight: bold;
104 | font-style: normal;
105 | }
106 |
107 | /* Specify class=linenums on a pre to get line numbering */
108 | ol.linenums {
109 | margin-top: 0;
110 | margin-bottom: 0;
111 | }
112 |
--------------------------------------------------------------------------------
/docs/styles/prettify-tomorrow.css:
--------------------------------------------------------------------------------
1 | /* Tomorrow Theme */
2 | /* Original theme - https://github.com/chriskempson/tomorrow-theme */
3 | /* Pretty printing styles. Used with prettify.js. */
4 | /* SPAN elements with the classes below are added by prettyprint. */
5 | /* plain text */
6 | .pln {
7 | color: #4d4d4c; }
8 |
9 | @media screen {
10 | /* string content */
11 | .str {
12 | color: #718c00; }
13 |
14 | /* a keyword */
15 | .kwd {
16 | color: #8959a8; }
17 |
18 | /* a comment */
19 | .com {
20 | color: #8e908c; }
21 |
22 | /* a type name */
23 | .typ {
24 | color: #4271ae; }
25 |
26 | /* a literal value */
27 | .lit {
28 | color: #f5871f; }
29 |
30 | /* punctuation */
31 | .pun {
32 | color: #4d4d4c; }
33 |
34 | /* lisp open bracket */
35 | .opn {
36 | color: #4d4d4c; }
37 |
38 | /* lisp close bracket */
39 | .clo {
40 | color: #4d4d4c; }
41 |
42 | /* a markup tag name */
43 | .tag {
44 | color: #c82829; }
45 |
46 | /* a markup attribute name */
47 | .atn {
48 | color: #f5871f; }
49 |
50 | /* a markup attribute value */
51 | .atv {
52 | color: #3e999f; }
53 |
54 | /* a declaration */
55 | .dec {
56 | color: #f5871f; }
57 |
58 | /* a variable name */
59 | .var {
60 | color: #c82829; }
61 |
62 | /* a function name */
63 | .fun {
64 | color: #4271ae; } }
65 | /* Use higher contrast and text-weight for printable form. */
66 | @media print, projection {
67 | .str {
68 | color: #060; }
69 |
70 | .kwd {
71 | color: #006;
72 | font-weight: bold; }
73 |
74 | .com {
75 | color: #600;
76 | font-style: italic; }
77 |
78 | .typ {
79 | color: #404;
80 | font-weight: bold; }
81 |
82 | .lit {
83 | color: #044; }
84 |
85 | .pun, .opn, .clo {
86 | color: #440; }
87 |
88 | .tag {
89 | color: #006;
90 | font-weight: bold; }
91 |
92 | .atn {
93 | color: #404; }
94 |
95 | .atv {
96 | color: #060; } }
97 | /* Style */
98 | /*
99 | pre.prettyprint {
100 | background: white;
101 | font-family: Consolas, Monaco, 'Andale Mono', monospace;
102 | font-size: 12px;
103 | line-height: 1.5;
104 | border: 1px solid #ccc;
105 | padding: 10px; }
106 | */
107 |
108 | /* Specify class=linenums on a pre to get line numbering */
109 | ol.linenums {
110 | margin-top: 0;
111 | margin-bottom: 0; }
112 |
113 | /* IE indents via margin-left */
114 | li.L0,
115 | li.L1,
116 | li.L2,
117 | li.L3,
118 | li.L4,
119 | li.L5,
120 | li.L6,
121 | li.L7,
122 | li.L8,
123 | li.L9 {
124 | /* */ }
125 |
126 | /* Alternate shading for lines */
127 | li.L1,
128 | li.L3,
129 | li.L5,
130 | li.L7,
131 | li.L9 {
132 | /* */ }
133 |
--------------------------------------------------------------------------------
/docs/utils_formElementByDiv.js.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | JSDoc: Source: utils/formElementByDiv.js
6 |
7 |
8 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
Source: utils/formElementByDiv.js
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
/**
30 | * A global map holding weak references from the DOM elements to its represented
31 | * {@link module:formElement~FormElement} objects.
32 | *
33 | * @type {WeakMap.<HTMLDivElement, module:formElement~FormElement>}
34 | */
35 | const formElementByDiv = new WeakMap();
36 |
37 | export default formElementByDiv;
38 |
/**
30 | * Builds a string with a format suitable for its use as an HTML `id` tag
31 | * attribute.
32 | *
33 | * @param {string} pointer A JSON Pointer-like string that provides unique
34 | * identification of the JSON Schema being represented by the form element.
35 | *
36 | * @returns {string} The formatted string suitable for `id` tag attributes.
37 | */
38 | function pointerToId(pointer) {
39 | return `json-schema__${pointer.replace(/\//gi, '_')}`;
40 | }
41 |
42 | export default pointerToId;
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
55 |
56 |
57 |
58 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "json-schema-forms",
3 | "version": "0.2.0-alpha.2",
4 | "description": "A pure JavaScript tool that generates HTML forms from JSON Schemas.",
5 | "license": "GPL-3.0-or-later",
6 | "keywords": [
7 | "json",
8 | "schema",
9 | "form",
10 | "html-form",
11 | "jsonschema",
12 | "json-schema",
13 | "json-schema-form",
14 | "bootstrap"
15 | ],
16 | "author": {
17 | "name": "Hernán Blanco",
18 | "email": "hblanco@pm.me",
19 | "url": "https://github.com/hblanko"
20 | },
21 | "repository": {
22 | "type": "git",
23 | "url": "https://github.com/hblanko/json-schema-forms.git"
24 | },
25 | "main": "src/index.js",
26 | "files": [
27 | "dist/json-schema-forms.min.js",
28 | "css/json-schema-forms.css",
29 | "src/**/*"
30 | ],
31 | "scripts": {
32 | "build": "parcel build ./src/index.js --out-dir dist --no-source-maps -o json-schema-forms.min.js",
33 | "dev": "parcel ./tests/example-dev.html --out-dir serve",
34 | "doc": "jsdoc -c ./.jsdoc.json",
35 | "lint": "eslint ./src --ext .js",
36 | "prettify": "prettier-eslint --eslint-config-path ./.eslintrc.js --write \"$PWD/src/**/*.js\" \"$PWD/package.json\"",
37 | "prettify:tests": "prettier-eslint --eslint-config-path ./.eslintrc.js --write \"$PWD/tests/**/*{.js,.html}\"",
38 | "setup-bundler": "yarn add parcel-bundler --dev"
39 | },
40 | "husky": {
41 | "hooks": {
42 | "pre-commit": "lint-staged && yarn doc && git add docs"
43 | }
44 | },
45 | "lint-staged": {
46 | "src/**/*.js": "prettier-eslint --eslint-config-path ./.eslintrc.js --write",
47 | "package.json": "prettier-eslint --eslint-config-path ./.eslintrc.js --write"
48 | },
49 | "devDependencies": {
50 | "babel": "^6.23.0",
51 | "babel-eslint": "^10.1.0",
52 | "eslint": "^7.1.0",
53 | "eslint-plugin-jsdoc": "^25.4.2",
54 | "husky": "^4.2.5",
55 | "lint-staged": "^10.2.6",
56 | "parcel-bundler": "^1.12.4",
57 | "prettier": "^2.0.5",
58 | "prettier-eslint": "^10.1.1",
59 | "prettier-eslint-cli": "^5.0.0"
60 | },
61 | "dependencies": {
62 | "@apidevtools/json-schema-ref-parser": "^9.0.1",
63 | "es": "^0.7.3",
64 | "jquery": "^3.5.1"
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/JsonSchemaForms.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The main module implementing the form construction.
3 | *
4 | * @module JsonSchemaForms
5 | */
6 | 'use strict';
7 |
8 | import FormElement from './form/formElement.js';
9 | import defaultFormOptions from './form/defaultFormOptions.js';
10 |
11 | import $RefParser from '@apidevtools/json-schema-ref-parser';
12 | import jquery from 'jquery';
13 |
14 | /**
15 | * Builds an HTML form from a given JSON Schema. The main function to be
16 | * interacted by users.
17 | *
18 | * It allows to provide specific options for the form construction, and a custom
19 | * callback function triggered on submission.
20 | *
21 | * @param {object} schema The JSON Schema to represent as an HTML form.
22 | * @param {Function} [submitCallback=() => {}] Callback function to be called
23 | * when the form triggers the `submit` DOM event.
24 | * @param {object} customFormOptions Form options overriding the default. See
25 | * {@link defaultFormOptions} for details.
26 | *
27 | * @returns {HTMLDivElement} A `
` element containing the HTML form.
28 | */
29 | function build(schema, submitCallback = () => {}, customFormOptions = {}) {
30 | // Builds form options by merging the provided custom options with the
31 | // defaults.
32 | const formOptions = {
33 | ...defaultFormOptions,
34 | ...customFormOptions,
35 | };
36 |
37 | // Ensures jQuery is available if Bootstrap is required but failed loading.
38 | if (formOptions.bootstrap && !window.$) {
39 | console.warn('Bootstrap expected but JQuery was not loaded.');
40 | window.$ = jquery;
41 | }
42 |
43 | const containerDiv = document.createElement('div');
44 |
45 | $RefParser.dereference(schema, (err, s) => {
46 | if (err) console.error(err);
47 | else {
48 | // Generates the form recursively.
49 | const rootFormElement = new FormElement(s, {
50 | formOptions,
51 | });
52 |
53 | // Creates the HTML structure containing the form.
54 | const formDiv = document.createElement('div');
55 | const form = formDiv.appendChild(document.createElement('form'));
56 | form.id = formOptions.formId;
57 |
58 | form.addEventListener('submit', (event) => {
59 | const valid = submitCallback(rootFormElement);
60 |
61 | if (valid === false) event.preventDefault();
62 | });
63 |
64 | const submitButton = form.appendChild(document.createElement('button'));
65 | submitButton.type = 'submit';
66 | submitButton.innerText = formOptions.submitButtonText;
67 |
68 | containerDiv.appendChild(rootFormElement.layout.root);
69 | containerDiv.appendChild(formDiv);
70 |
71 | if (formOptions.bootstrap) {
72 | containerDiv.classList.add('container-fluid', 'bg-light');
73 | formDiv.classList.add('pt-4');
74 | submitButton.classList.add('btn', 'btn-primary');
75 | }
76 | }
77 | });
78 |
79 | return containerDiv;
80 | }
81 |
82 | export default { build };
83 |
--------------------------------------------------------------------------------
/src/form/defaultFormOptions.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The default options used to build the form.
3 | *
4 | * @enum
5 | */
6 | const defaultFormOptions = {
7 | formId: 'json-schema-form',
8 | bootstrap: '4.5',
9 | fontAwesome: '5.13.0',
10 | maxEnumTabs: 5,
11 | maxSelectSize: 6,
12 | booleanTranslateFunction: (b) => (b ? 'Yes' : 'No'),
13 | arraySubstitute: 'List',
14 | objectSubstitute: 'Group',
15 | submitButtonText: 'Submit',
16 | initTogglersOff: false,
17 | arrayItemTitle: 'Item',
18 | adHocOptions: {
19 | todo: 'To-do',
20 | },
21 | };
22 |
23 | export default defaultFormOptions;
24 |
--------------------------------------------------------------------------------
/src/form/formElementDefinitions.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Module containing classes and objects that define the form element type and
3 | * behavior.
4 | *
5 | * @module formElementDefinitions
6 | */
7 |
8 | /**
9 | * The available types of a form element.
10 | *
11 | * @enum {string}
12 | */
13 | const ElementType = {
14 | /** The form element representing the root JSON Schema. */
15 | ROOT: 'root',
16 |
17 | /** A required form element. */
18 | REQUIRED: 'required',
19 |
20 | /** An optional form element. */
21 | OPTIONAL: 'optional',
22 |
23 | /** A form element able to be removed. */
24 | REMOVABLE: 'removable',
25 | };
26 |
27 | /**
28 | * The possible types of a form element title.
29 | *
30 | * @enum {string}
31 | */
32 | const TitleType = {
33 | /** A regular, unmodifiable form element title. */
34 | STATIC: 'static',
35 |
36 | /** An editable form element title. */
37 | FIELD: 'field',
38 |
39 | /** A static element title for an added JSON Schema's `array` item. */
40 | ADDED_ITEM: 'addedItem',
41 | };
42 |
43 | /** The form element state descriptor. */
44 | class State {
45 | /**
46 | * Class constructor.
47 | *
48 | * @param {boolean} [active=true] Flag indicating whether the form element is
49 | * active (i.e. the form element can be interacted --at least its toggler).
50 | * @param {boolean?} [disabled=null] Flag indicating whether the form element
51 | * is disabled (i.e. the input fields or child elements cannot be interacted).
52 | */
53 | constructor(active = true, disabled = null) {
54 | /**
55 | * Indicates whether the form element is active.
56 | *
57 | * @type {boolean}
58 | */
59 | this.active = active;
60 |
61 | /**
62 | * Indicates whether the form element is disabled.
63 | *
64 | * @type {boolean?}
65 | */
66 | this.disabled = disabled;
67 | }
68 | }
69 |
70 | export { ElementType, State, TitleType };
71 |
--------------------------------------------------------------------------------
/src/form/json-schema/JsonSchemaKeywords.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Keywords and types specified by the [JSON Schema 2019-09 RFC Draft](https://json-schema.org/draft/2019-09/json-schema-core.html).
3 | *
4 | * @module JsonSchemaKeywords
5 | */
6 |
7 | /**
8 | * Object containing the JSON Schema keywords classified by its role in the
9 | * schema definition.
10 | *
11 | * @enum {object.}
12 | */
13 | const JsonSchemaKeywords = {
14 | /**
15 | * Keywords representing [JSON Schema annotations](https://json-schema.org/draft/2019-09/json-schema-core.html#annotations).
16 | *
17 | * @enum {string}
18 | */
19 | Annotation: {
20 | DEFAULT: 'default',
21 | DEPRECATED: 'deprecated',
22 | DESCRIPTION: 'description',
23 | EXAMPLES: 'examples',
24 | READ_ONLY: 'readOnly',
25 | TITLE: 'title',
26 | WRITE_ONLY: 'writeOnly',
27 | },
28 |
29 | /**
30 | * Keywords representing [JSON Schema applicators for `array` instances](https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.9.3.1).
31 | *
32 | * @enum {string}
33 | */
34 | ArrayApplicator: {
35 | ADDITIONAL_ITEMS: 'additionalItems',
36 | CONTAINS: 'contains',
37 | ITEMS: 'items',
38 | UNEVALUATED_ITEMS: 'unevaluatedItems',
39 | },
40 |
41 | /**
42 | * Keywords representing [JSON Schema validation conditions for `array`
43 | * instances](https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.4).
44 | *
45 | * @enum {string}
46 | */
47 | ArrayValidation: {
48 | MAX_CONTAINS: 'maxContains',
49 | MAX_ITEMS: 'maxItems',
50 | MIN_CONTAINS: 'minContains',
51 | MIN_ITEMS: 'minItems',
52 | UNIQUE_ITEMS: 'uniqueItems',
53 | },
54 |
55 | /**
56 | * Keywords representing [JSON Schema in-place applicators with boolean logic](https://json-schema.org/draft/2019-09/json-schema-core.html#logic).
57 | *
58 | * @enum {string}
59 | */
60 | BooleanLogicApplicator: {
61 | ALL_OF: 'allOf',
62 | ANY_OF: 'anyOf',
63 | NOT: 'not',
64 | ONE_OF: 'oneOf',
65 | },
66 |
67 | /**
68 | * Keywords representing [JSON Schema in-place applicators conditionally](https://json-schema.org/draft/2019-09/json-schema-core.html#conditional).
69 | *
70 | * @enum {string}
71 | */
72 | ConditionalApplicator: {
73 | IF: 'if',
74 | THEN: 'then',
75 | ELSE: 'else',
76 | },
77 |
78 | /**
79 | * Keywords representing [generic JSON Schema validation conditions](https://json-schema.org/draft/2019-09/json-schema-validation.html#general).
80 | *
81 | * @enum {string}
82 | */
83 | GenericValidation: {
84 | CONST: 'const',
85 | ENUM: 'enum',
86 | TYPE: 'type',
87 | },
88 |
89 | /**
90 | * Keywords representing [JSON Schema validation conditions for numeric
91 | * (`number` and `integer`) instances](https://json-schema.org/draft/2019-09/json-schema-validation.html#numeric).
92 | *
93 | * @enum {string}
94 | */
95 | NumberValidation: {
96 | EXCLUSIVE_MAXIMUM: 'exclusiveMaximum',
97 | EXCLUSIVE_MINIMUM: 'exclusiveMinimum',
98 | MAXIMUM: 'maximum',
99 | MINIMUM: 'minimum',
100 | MULTIPLE_OF: 'multipleOf',
101 | },
102 |
103 | /**
104 | * Keywords representing [JSON Schema applicators for `object` instances](https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.9.3.2).
105 | *
106 | * @enum {string}
107 | */
108 | ObjectApplicator: {
109 | ADDITIONAL_PROPERTIES: 'additionalProperties',
110 | PATTERN_PROPERTIES: 'patternProperties',
111 | PROPERTIES: 'properties',
112 | UNEVALUATED_PROPERTIES: 'unevaluatedProperties',
113 | },
114 |
115 | /**
116 | * Keywords representing [JSON Schema validation conditions for `object`
117 | * instances](https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.5).
118 | *
119 | * @enum {string}
120 | */
121 | ObjectValidation: {
122 | DEPENDENT_REQUIRED: 'dependentRequired',
123 | MAX_PROPERTIES: 'maxProperties',
124 | MIN_PROPERTIES: 'minProperties',
125 | PROPERTY_NAMES: 'propertyNames',
126 | REQUIRED: 'required',
127 | },
128 |
129 | /**
130 | * Keywords representing [JSON Schema validation conditions for `string`
131 | * instances](https://json-schema.org/draft/2019-09/json-schema-validation.html#string).
132 | *
133 | * @enum {string}
134 | */
135 | StringValidation: {
136 | MAX_LENGTH: 'maxLength',
137 | MIN_LENGTH: 'minLength',
138 | PATTERN: 'pattern',
139 | },
140 | };
141 |
142 | export default JsonSchemaKeywords;
143 |
--------------------------------------------------------------------------------
/src/form/json-schema/JsonSchemaType.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Module specifying the values that the `type` generic validation keyword can
3 | * take.
4 | *
5 | * @module JsonSchemaType
6 | *
7 | * @see {@link https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.1.1}
8 | */
9 |
10 | /**
11 | * List of JSON types defined by the JSON Schema specification.
12 | *
13 | * @enum {string}
14 | */
15 | const JsonSchemaType = {
16 | ARRAY: 'array',
17 | BOOLEAN: 'boolean',
18 | INTEGER: 'integer',
19 | NULL: 'null',
20 | NUMBER: 'number',
21 | OBJECT: 'object',
22 | STRING: 'string',
23 | };
24 |
25 | export default JsonSchemaType;
26 |
--------------------------------------------------------------------------------
/src/form/json-schema/inPlaceApplicators.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Module that analyzes and resolves [JSON Schema in-place applicators](https://json-schema.org/draft/2019-09/json-schema-core.html#in-place).
3 | *
4 | * In this approach, the in-place applicators present in a JSON Schema are
5 | * modeled as a directed tree (where nodes represented by {@link
6 | * module:inPlaceApplicators~IPASchema} objects). Each node stores the keywords
7 | * belonging to its corresponding subschema: hence, any possible materialization
8 | * of a JSON Schema can be reconstructed by aggregating the keywords of each
9 | * node traversed by any directed path from the root node to the leaf.
10 | *
11 | * The user is intended to select the desired path: {@link module:selectors}
12 | * provides a user interface for this purpose.
13 | *
14 | * @module inPlaceApplicators
15 | */
16 | import JsonSchemaKeywords from './JsonSchemaKeywords.js';
17 |
18 | /**
19 | * Processes a JSON Schema, generating an in-place application tree that
20 | * represents its possible materializations.
21 | *
22 | * @param {object} schema The JSON Schema to process.
23 | * @param {string} [pointer=''] A JSON Pointer that provides unique
24 | * identification to each in-place applicator in the JSON Schema.
25 | * @param {number} [selected=0] The index indicating the applicator subschema to
26 | * be selected at initialization.
27 | *
28 | * @returns {module:inPlaceApplicators~IPASchema} The root node to the in-place
29 | * application tree that represents the given JSON Schema.
30 | */
31 | function process(schema, pointer = '', selected = 0) {
32 | const { common, applicatorByPointer } = schema.allOf
33 | ? processAllOf(
34 | schema,
35 | `${pointer}/${JsonSchemaKeywords.BooleanLogicApplicator.ALL_OF}`
36 | )
37 | : {
38 | common: {
39 | ...schema,
40 | },
41 | applicatorByPointer: new Map(),
42 | };
43 |
44 | if (schema.anyOf) {
45 | delete common.anyOf;
46 | const aop = `${pointer}/${JsonSchemaKeywords.BooleanLogicApplicator.ANY_OF}`;
47 |
48 | applicatorByPointer.set(
49 | aop,
50 | new InPlaceApplicator(processAnyOf(schema.anyOf, aop), selected)
51 | );
52 | }
53 |
54 | if (schema.oneOf) {
55 | delete common.oneOf;
56 | const oop = `${pointer}/${JsonSchemaKeywords.BooleanLogicApplicator.ONE_OF}`;
57 |
58 | applicatorByPointer.set(
59 | oop,
60 | new InPlaceApplicator(processOneOf(schema.oneOf, oop), selected)
61 | );
62 | }
63 |
64 | return new IPASchema(common, applicatorByPointer);
65 | }
66 |
67 | /**
68 | * @typedef {object} ProcessAllOfResult
69 | *
70 | * @property {object} common The keywords that are common to all the `allOf`
71 | * subschemas.
72 | * @property {Map.} applicatorByPointer
73 | * A map including the child in-place applicators contained by the processed
74 | * `allOf` applicator.
75 | */
76 |
77 | /**
78 | * Processes an `allOf` in-place applicator.
79 | *
80 | * @param {object} schema The JSON Schema including an `allOf` property to
81 | * process.
82 | * @param {string} [pointer=''] A JSON Pointer that identifies the JSON Schema.
83 | *
84 | * @returns {module:inPlaceApplicators~ProcessAllOfResult} The result of
85 | * processing the `allOf` in-place applicator.
86 | */
87 | function processAllOf(schema, pointer) {
88 | const ipaSchemas = schema.allOf.map((s, i) => process(s, `${pointer}/${i}`));
89 |
90 | return {
91 | common: aggregate(schema, ...ipaSchemas),
92 | applicatorByPointer: new Map(
93 | ipaSchemas.flatMap((ipaSchema) => [...ipaSchema.applicatorByPointer])
94 | ),
95 | };
96 | }
97 |
98 | /**
99 | * Processes an `anyOf` in-place applicator.
100 | *
101 | * @param {Array.