Skip to content

Commit c3f0d7c

Browse files
committed
Bump version to 2.13.1 and update dist files
1 parent 3446118 commit c3f0d7c

File tree

5 files changed

+44
-8
lines changed

5 files changed

+44
-8
lines changed

dist/react-json-form.cjs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,12 @@ function getSyncedObject(data, schema, getRef) {
429429
}
430430

431431
if (!data.hasOwnProperty(key)) {
432-
if (type === 'array') newData[key] = getSyncedArray([], schemaValue, getRef);else if (type === 'object') newData[key] = getSyncedObject({}, schemaValue, getRef);else if (type === 'boolean') newData[key] = default_ === false ? false : default_ || null;else if (type === 'integer' || type === 'number') newData[key] = default_ === 0 ? 0 : default_ || null;else newData[key] = default_ || '';
432+
/* This key is declared in schema but it's not present in the data.
433+
So we can use blank data here.
434+
*/
435+
if (type === 'array') newData[key] = getSyncedArray([], schemaValue, getRef);else if (type === 'object') newData[key] = getSyncedObject({}, schemaValue, getRef);else if (type === 'oneOf') newData[key] = getBlankOneOf(schemaValue, getRef);else if (type === 'anyOf') newData[key] = getBlankAntOf(schemaValue, getRef);else if (type === 'boolean') newData[key] = default_ === false ? false : default_ || null;else if (type === 'integer' || type === 'number') newData[key] = default_ === 0 ? 0 : default_ || null;else newData[key] = default_ || '';
433436
} else {
434-
if (type === 'array') newData[key] = getSyncedArray(data[key], schemaValue, getRef);else if (type === 'object') newData[key] = getSyncedObject(data[key], schemaValue, getRef);else {
437+
if (type === 'array') newData[key] = getSyncedArray(data[key], schemaValue, getRef);else if (type === 'object') newData[key] = getSyncedObject(data[key], schemaValue, getRef);else if (type === 'oneOf') newData[key] = getSyncedOneOf(data[key], schemaValue, getRef);else if (type === 'anyOf') newData[key] = getSyncedAnyOf(data[key], schemaValue, getRef);else {
435438
// if the current value is not in choices, we reset to blank
436439
if (!valueInChoices(schemaValue, data[key])) data[key] = '';
437440

@@ -446,6 +449,8 @@ function getSyncedObject(data, schema, getRef) {
446449
if (schemaValue.hasOwnProperty('const')) newData[key] = schemaValue.const;
447450
}
448451

452+
if (schema.hasOwnProperty('oneOf')) newData = _extends({}, newData, getSyncedOneOf(data, schema, getRef));
453+
if (schema.hasOwnProperty('anyOf')) newData = _extends({}, newData, getSyncedAnyOf(data, schema, getRef));
449454
return newData;
450455
}
451456

@@ -539,6 +544,13 @@ function findMatchingSubschemaIndex(data, schema, getRef, schemaName) {
539544
}
540545
}
541546

547+
if (index === null) {
548+
// still no match found
549+
if (data === null) // for null data, return the first subschema and hope for the best
550+
index = 1;else // for anything else, throw error
551+
throw new Error("No matching subschema found in '" + schemaName + "' for data '" + data + "' (type: " + dataType + ")");
552+
}
553+
542554
return index;
543555
}
544556
function dataObjectMatchesSchema(data, subschema) {

dist/react-json-form.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-json-form.modern.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,12 @@ function getSyncedObject(data, schema, getRef) {
423423
}
424424

425425
if (!data.hasOwnProperty(key)) {
426-
if (type === 'array') newData[key] = getSyncedArray([], schemaValue, getRef);else if (type === 'object') newData[key] = getSyncedObject({}, schemaValue, getRef);else if (type === 'boolean') newData[key] = default_ === false ? false : default_ || null;else if (type === 'integer' || type === 'number') newData[key] = default_ === 0 ? 0 : default_ || null;else newData[key] = default_ || '';
426+
/* This key is declared in schema but it's not present in the data.
427+
So we can use blank data here.
428+
*/
429+
if (type === 'array') newData[key] = getSyncedArray([], schemaValue, getRef);else if (type === 'object') newData[key] = getSyncedObject({}, schemaValue, getRef);else if (type === 'oneOf') newData[key] = getBlankOneOf(schemaValue, getRef);else if (type === 'anyOf') newData[key] = getBlankAntOf(schemaValue, getRef);else if (type === 'boolean') newData[key] = default_ === false ? false : default_ || null;else if (type === 'integer' || type === 'number') newData[key] = default_ === 0 ? 0 : default_ || null;else newData[key] = default_ || '';
427430
} else {
428-
if (type === 'array') newData[key] = getSyncedArray(data[key], schemaValue, getRef);else if (type === 'object') newData[key] = getSyncedObject(data[key], schemaValue, getRef);else {
431+
if (type === 'array') newData[key] = getSyncedArray(data[key], schemaValue, getRef);else if (type === 'object') newData[key] = getSyncedObject(data[key], schemaValue, getRef);else if (type === 'oneOf') newData[key] = getSyncedOneOf(data[key], schemaValue, getRef);else if (type === 'anyOf') newData[key] = getSyncedAnyOf(data[key], schemaValue, getRef);else {
429432
// if the current value is not in choices, we reset to blank
430433
if (!valueInChoices(schemaValue, data[key])) data[key] = '';
431434

@@ -440,6 +443,8 @@ function getSyncedObject(data, schema, getRef) {
440443
if (schemaValue.hasOwnProperty('const')) newData[key] = schemaValue.const;
441444
}
442445

446+
if (schema.hasOwnProperty('oneOf')) newData = _extends({}, newData, getSyncedOneOf(data, schema, getRef));
447+
if (schema.hasOwnProperty('anyOf')) newData = _extends({}, newData, getSyncedAnyOf(data, schema, getRef));
443448
return newData;
444449
}
445450

@@ -533,6 +538,13 @@ function findMatchingSubschemaIndex(data, schema, getRef, schemaName) {
533538
}
534539
}
535540

541+
if (index === null) {
542+
// still no match found
543+
if (data === null) // for null data, return the first subschema and hope for the best
544+
index = 1;else // for anything else, throw error
545+
throw new Error("No matching subschema found in '" + schemaName + "' for data '" + data + "' (type: " + dataType + ")");
546+
}
547+
536548
return index;
537549
}
538550
function dataObjectMatchesSchema(data, subschema) {

dist/react-json-form.module.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,12 @@ function getSyncedObject(data, schema, getRef) {
423423
}
424424

425425
if (!data.hasOwnProperty(key)) {
426-
if (type === 'array') newData[key] = getSyncedArray([], schemaValue, getRef);else if (type === 'object') newData[key] = getSyncedObject({}, schemaValue, getRef);else if (type === 'boolean') newData[key] = default_ === false ? false : default_ || null;else if (type === 'integer' || type === 'number') newData[key] = default_ === 0 ? 0 : default_ || null;else newData[key] = default_ || '';
426+
/* This key is declared in schema but it's not present in the data.
427+
So we can use blank data here.
428+
*/
429+
if (type === 'array') newData[key] = getSyncedArray([], schemaValue, getRef);else if (type === 'object') newData[key] = getSyncedObject({}, schemaValue, getRef);else if (type === 'oneOf') newData[key] = getBlankOneOf(schemaValue, getRef);else if (type === 'anyOf') newData[key] = getBlankAntOf(schemaValue, getRef);else if (type === 'boolean') newData[key] = default_ === false ? false : default_ || null;else if (type === 'integer' || type === 'number') newData[key] = default_ === 0 ? 0 : default_ || null;else newData[key] = default_ || '';
427430
} else {
428-
if (type === 'array') newData[key] = getSyncedArray(data[key], schemaValue, getRef);else if (type === 'object') newData[key] = getSyncedObject(data[key], schemaValue, getRef);else {
431+
if (type === 'array') newData[key] = getSyncedArray(data[key], schemaValue, getRef);else if (type === 'object') newData[key] = getSyncedObject(data[key], schemaValue, getRef);else if (type === 'oneOf') newData[key] = getSyncedOneOf(data[key], schemaValue, getRef);else if (type === 'anyOf') newData[key] = getSyncedAnyOf(data[key], schemaValue, getRef);else {
429432
// if the current value is not in choices, we reset to blank
430433
if (!valueInChoices(schemaValue, data[key])) data[key] = '';
431434

@@ -440,6 +443,8 @@ function getSyncedObject(data, schema, getRef) {
440443
if (schemaValue.hasOwnProperty('const')) newData[key] = schemaValue.const;
441444
}
442445

446+
if (schema.hasOwnProperty('oneOf')) newData = _extends({}, newData, getSyncedOneOf(data, schema, getRef));
447+
if (schema.hasOwnProperty('anyOf')) newData = _extends({}, newData, getSyncedAnyOf(data, schema, getRef));
443448
return newData;
444449
}
445450

@@ -533,6 +538,13 @@ function findMatchingSubschemaIndex(data, schema, getRef, schemaName) {
533538
}
534539
}
535540

541+
if (index === null) {
542+
// still no match found
543+
if (data === null) // for null data, return the first subschema and hope for the best
544+
index = 1;else // for anything else, throw error
545+
throw new Error("No matching subschema found in '" + schemaName + "' for data '" + data + "' (type: " + dataType + ")");
546+
}
547+
536548
return index;
537549
}
538550
function dataObjectMatchesSchema(data, subschema) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bhch/react-json-form",
3-
"version": "2.13.0",
3+
"version": "2.13.1",
44
"description": "Create forms using JSON Schema",
55
"publishConfig": {
66
"access": "public"

0 commit comments

Comments
 (0)