Skip to content

Commit

Permalink
Bump version to 2.13.1 and update dist files
Browse files Browse the repository at this point in the history
  • Loading branch information
bhch committed Dec 2, 2023
1 parent 3446118 commit c3f0d7c
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 8 deletions.
16 changes: 14 additions & 2 deletions dist/react-json-form.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,12 @@ function getSyncedObject(data, schema, getRef) {
}

if (!data.hasOwnProperty(key)) {
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_ || '';
/* This key is declared in schema but it's not present in the data.
So we can use blank data here.
*/
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_ || '';
} else {
if (type === 'array') newData[key] = getSyncedArray(data[key], schemaValue, getRef);else if (type === 'object') newData[key] = getSyncedObject(data[key], schemaValue, getRef);else {
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 {
// if the current value is not in choices, we reset to blank
if (!valueInChoices(schemaValue, data[key])) data[key] = '';

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

if (schema.hasOwnProperty('oneOf')) newData = _extends({}, newData, getSyncedOneOf(data, schema, getRef));
if (schema.hasOwnProperty('anyOf')) newData = _extends({}, newData, getSyncedAnyOf(data, schema, getRef));
return newData;
}

Expand Down Expand Up @@ -539,6 +544,13 @@ function findMatchingSubschemaIndex(data, schema, getRef, schemaName) {
}
}

if (index === null) {
// still no match found
if (data === null) // for null data, return the first subschema and hope for the best
index = 1;else // for anything else, throw error
throw new Error("No matching subschema found in '" + schemaName + "' for data '" + data + "' (type: " + dataType + ")");
}

return index;
}
function dataObjectMatchesSchema(data, subschema) {
Expand Down
2 changes: 1 addition & 1 deletion dist/react-json-form.js

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions dist/react-json-form.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,12 @@ function getSyncedObject(data, schema, getRef) {
}

if (!data.hasOwnProperty(key)) {
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_ || '';
/* This key is declared in schema but it's not present in the data.
So we can use blank data here.
*/
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_ || '';
} else {
if (type === 'array') newData[key] = getSyncedArray(data[key], schemaValue, getRef);else if (type === 'object') newData[key] = getSyncedObject(data[key], schemaValue, getRef);else {
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 {
// if the current value is not in choices, we reset to blank
if (!valueInChoices(schemaValue, data[key])) data[key] = '';

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

if (schema.hasOwnProperty('oneOf')) newData = _extends({}, newData, getSyncedOneOf(data, schema, getRef));
if (schema.hasOwnProperty('anyOf')) newData = _extends({}, newData, getSyncedAnyOf(data, schema, getRef));
return newData;
}

Expand Down Expand Up @@ -533,6 +538,13 @@ function findMatchingSubschemaIndex(data, schema, getRef, schemaName) {
}
}

if (index === null) {
// still no match found
if (data === null) // for null data, return the first subschema and hope for the best
index = 1;else // for anything else, throw error
throw new Error("No matching subschema found in '" + schemaName + "' for data '" + data + "' (type: " + dataType + ")");
}

return index;
}
function dataObjectMatchesSchema(data, subschema) {
Expand Down
16 changes: 14 additions & 2 deletions dist/react-json-form.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,12 @@ function getSyncedObject(data, schema, getRef) {
}

if (!data.hasOwnProperty(key)) {
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_ || '';
/* This key is declared in schema but it's not present in the data.
So we can use blank data here.
*/
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_ || '';
} else {
if (type === 'array') newData[key] = getSyncedArray(data[key], schemaValue, getRef);else if (type === 'object') newData[key] = getSyncedObject(data[key], schemaValue, getRef);else {
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 {
// if the current value is not in choices, we reset to blank
if (!valueInChoices(schemaValue, data[key])) data[key] = '';

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

if (schema.hasOwnProperty('oneOf')) newData = _extends({}, newData, getSyncedOneOf(data, schema, getRef));
if (schema.hasOwnProperty('anyOf')) newData = _extends({}, newData, getSyncedAnyOf(data, schema, getRef));
return newData;
}

Expand Down Expand Up @@ -533,6 +538,13 @@ function findMatchingSubschemaIndex(data, schema, getRef, schemaName) {
}
}

if (index === null) {
// still no match found
if (data === null) // for null data, return the first subschema and hope for the best
index = 1;else // for anything else, throw error
throw new Error("No matching subschema found in '" + schemaName + "' for data '" + data + "' (type: " + dataType + ")");
}

return index;
}
function dataObjectMatchesSchema(data, subschema) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bhch/react-json-form",
"version": "2.13.0",
"version": "2.13.1",
"description": "Create forms using JSON Schema",
"publishConfig": {
"access": "public"
Expand Down

0 comments on commit c3f0d7c

Please sign in to comment.