Skip to content

Commit 18a1393

Browse files
committed
Bump version to 2.13.0 and update dist files
1 parent c67164e commit 18a1393

File tree

5 files changed

+242
-41
lines changed

5 files changed

+242
-41
lines changed

dist/react-json-form.cjs

Lines changed: 80 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,12 @@ function getBlankObject(schema, getRef) {
218218
let value = schema_keys[key];
219219
let isRef = value.hasOwnProperty('$ref');
220220
let isConst = value.hasOwnProperty('const');
221-
if (isRef) value = getRef(value['$ref']);
221+
222+
if (isRef) {
223+
value = _extends({}, getRef(value['$ref']), value);
224+
delete value['$ref'];
225+
}
226+
222227
let type = normalizeKeyword(value.type);
223228

224229
if (!type) {
@@ -258,7 +263,8 @@ function getBlankArray(schema, getRef) {
258263
if (schema.items.hasOwnProperty('$ref')) {
259264
// :TODO: this mutates the original schema
260265
// but i'll fix it later
261-
schema.items = getRef(schema.items['$ref']);
266+
schema.items = _extends({}, getRef(schema.items['$ref']), schema.items);
267+
delete schema.items['$ref'];
262268
}
263269

264270
let type = normalizeKeyword(schema.items.type);
@@ -317,7 +323,11 @@ function getBlankAnyOf(schema, getRef) {
317323
return getBlankData(nextSchema, getRef);
318324
}
319325
function getBlankData(schema, getRef) {
320-
if (schema.hasOwnProperty('$ref')) schema = getRef(schema['$ref']);
326+
if (schema.hasOwnProperty('$ref')) {
327+
schema = _extends({}, getRef(schema['$ref']), schema);
328+
delete schema['$ref'];
329+
}
330+
321331
let type = getSchemaType(schema);
322332
let default_ = schema.default;
323333

@@ -338,7 +348,8 @@ function getSyncedArray(data, schema, getRef) {
338348
if (schema.items.hasOwnProperty('$ref')) {
339349
// :TODO: this will most probably mutate the original schema
340350
// but i'll fix it later
341-
schema.items = getRef(schema.items['$ref']);
351+
schema.items = _extends({}, getRef(schema.items['$ref']), schema.items);
352+
delete schema.items['$ref'];
342353
}
343354

344355
let type;
@@ -400,7 +411,12 @@ function getSyncedObject(data, schema, getRef) {
400411
let key = keys[i];
401412
let schemaValue = schema_keys[key];
402413
let isRef = schemaValue.hasOwnProperty('$ref');
403-
if (isRef) schemaValue = getRef(schemaValue['$ref']);
414+
415+
if (isRef) {
416+
schemaValue = _extends({}, getRef(schemaValue['$ref']), schemaValue);
417+
delete schemaValue['$ref'];
418+
}
419+
404420
let type;
405421
let default_;
406422

@@ -454,7 +470,11 @@ function getSyncedAnyOf(data, schema, getRef) {
454470
}
455471
function getSyncedData(data, schema, getRef) {
456472
// adds those keys to data which are in schema but not in data
457-
if (schema.hasOwnProperty('$ref')) schema = getRef(schema['$ref']);
473+
if (schema.hasOwnProperty('$ref')) {
474+
schema = _extends({}, getRef(schema['$ref']), schema);
475+
delete schema['$ref'];
476+
}
477+
458478
let type = getSchemaType(schema);
459479
let syncFunc = getSyncFunc(type);
460480
if (syncFunc) return syncFunc(data, schema, getRef);
@@ -473,7 +493,12 @@ function findMatchingSubschemaIndex(data, schema, getRef, schemaName) {
473493

474494
for (let i = 0; i < subschemas.length; i++) {
475495
let subschema = subschemas[i];
476-
if (subschema.hasOwnProperty('$ref')) subschema = getRef(subschema['$ref']);
496+
497+
if (subschema.hasOwnProperty('$ref')) {
498+
subschema = _extends({}, getRef(subschema['$ref']), subschema);
499+
delete subschema['$ref'];
500+
}
501+
477502
let subType = getSchemaType(subschema);
478503

479504
if (dataType === 'object') {
@@ -499,7 +524,12 @@ function findMatchingSubschemaIndex(data, schema, getRef, schemaName) {
499524
// so we'll just return the first schema that matches the data type
500525
for (let i = 0; i < subschemas.length; i++) {
501526
let subschema = subschemas[i];
502-
if (subschema.hasOwnProperty('$ref')) subschema = getRef(subschema['$ref']);
527+
528+
if (subschema.hasOwnProperty('$ref')) {
529+
subschema = _extends({}, getRef(subschema['$ref']), subschema);
530+
delete subschema['$ref'];
531+
}
532+
503533
let subType = getSchemaType(subschema);
504534

505535
if (dataType === subType) {
@@ -2730,7 +2760,12 @@ function getArrayFormRow(args) {
27302760
let max_items = getKeyword(schema, 'max_items', 'maxItems') || 100;
27312761
if (data.length >= max_items || isReadonly) addable = false;
27322762
let isRef = schema.items.hasOwnProperty('$ref');
2733-
if (isRef) schema.items = args.getRef(schema.items['$ref']);
2763+
2764+
if (isRef) {
2765+
schema.items = _extends({}, args.getRef(schema.items['$ref']), schema.items);
2766+
delete schema.items['$ref'];
2767+
}
2768+
27342769
let type = normalizeKeyword(schema.items.type);
27352770
let nextArgs = {
27362771
schema: schema.items,
@@ -2895,7 +2930,12 @@ function getObjectFormRow(args) {
28952930
}
28962931

28972932
let isRef = schemaValue.hasOwnProperty('$ref');
2898-
if (isRef) schemaValue = args.getRef(schemaValue['$ref']);
2933+
2934+
if (isRef) {
2935+
schemaValue = _extends({}, args.getRef(schemaValue['$ref']), schemaValue);
2936+
delete schemaValue['$ref'];
2937+
}
2938+
28992939
if (isReadonly) schemaValue.readOnly = true;
29002940
let type = normalizeKeyword(schemaValue.type);
29012941

@@ -3049,7 +3089,14 @@ class OneOfTopLevel extends React__default["default"].Component {
30493089
if (index === undefined) index = this.state.option;
30503090
let schema = this.props.args.schema[this.schemaName][index];
30513091
let isRef = schema.hasOwnProperty('$ref');
3052-
if (isRef) schema = this.props.args.getRef(schema['$ref']);
3092+
3093+
if (isRef) {
3094+
schema = _extends({}, this.props.args.getRef(schema['$ref']), {
3095+
schema
3096+
});
3097+
delete schema['$ref'];
3098+
}
3099+
30533100
return schema;
30543101
};
30553102

@@ -3136,7 +3183,12 @@ class OneOf extends React__default["default"].Component {
31363183
for (let i = 0; i < subschemas.length; i++) {
31373184
let subschema = subschemas[i];
31383185
let isRef = subschema.hasOwnProperty('$ref');
3139-
if (isRef) subschema = this.props.parentArgs.getRef(subschema['$ref']);
3186+
3187+
if (isRef) {
3188+
subschema = _extends({}, this.props.parentArgs.getRef(subschema['$ref']), subschema);
3189+
delete subschema['$ref'];
3190+
}
3191+
31403192
let subType = getSchemaType(subschema);
31413193

31423194
if (subschema.hasOwnProperty('const')) {
@@ -3256,7 +3308,12 @@ class OneOf extends React__default["default"].Component {
32563308
}
32573309

32583310
let isRef = schema.hasOwnProperty('$ref');
3259-
if (isRef) schema = this.props.parentArgs.getRef(schema['$ref']);
3311+
3312+
if (isRef) {
3313+
schema = _extends({}, this.props.parentArgs.getRef(schema['$ref']), schema);
3314+
delete schema['$ref'];
3315+
}
3316+
32603317
return schema;
32613318
};
32623319

@@ -3431,6 +3488,10 @@ function validateSchema(schema) {
34313488
validation = validateOneOf(schema);
34323489
} else if (schema.hasOwnProperty('anyOf')) {
34333490
validation = validateAnyOf(schema);
3491+
} else if (schema.hasOwnProperty('$ref')) {
3492+
validation = {
3493+
isValid: true
3494+
};
34343495
} else {
34353496
validation = {
34363497
isValid: false,
@@ -3797,6 +3858,12 @@ class ReactJSONForm extends React__default["default"].Component {
37973858
let data = this.props.editorState.getData();
37983859
let schema = this.props.editorState.getSchema();
37993860
let formGroups = [];
3861+
3862+
if (schema.hasOwnProperty('$ref')) {
3863+
schema = _extends({}, this.getRef(schema['$ref']), schema);
3864+
delete schema['$ref'];
3865+
}
3866+
38003867
let type = getSchemaType(schema);
38013868
let args = {
38023869
data: data,

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: 80 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,12 @@ function getBlankObject(schema, getRef) {
212212
let value = schema_keys[key];
213213
let isRef = value.hasOwnProperty('$ref');
214214
let isConst = value.hasOwnProperty('const');
215-
if (isRef) value = getRef(value['$ref']);
215+
216+
if (isRef) {
217+
value = _extends({}, getRef(value['$ref']), value);
218+
delete value['$ref'];
219+
}
220+
216221
let type = normalizeKeyword(value.type);
217222

218223
if (!type) {
@@ -252,7 +257,8 @@ function getBlankArray(schema, getRef) {
252257
if (schema.items.hasOwnProperty('$ref')) {
253258
// :TODO: this mutates the original schema
254259
// but i'll fix it later
255-
schema.items = getRef(schema.items['$ref']);
260+
schema.items = _extends({}, getRef(schema.items['$ref']), schema.items);
261+
delete schema.items['$ref'];
256262
}
257263

258264
let type = normalizeKeyword(schema.items.type);
@@ -311,7 +317,11 @@ function getBlankAnyOf(schema, getRef) {
311317
return getBlankData(nextSchema, getRef);
312318
}
313319
function getBlankData(schema, getRef) {
314-
if (schema.hasOwnProperty('$ref')) schema = getRef(schema['$ref']);
320+
if (schema.hasOwnProperty('$ref')) {
321+
schema = _extends({}, getRef(schema['$ref']), schema);
322+
delete schema['$ref'];
323+
}
324+
315325
let type = getSchemaType(schema);
316326
let default_ = schema.default;
317327

@@ -332,7 +342,8 @@ function getSyncedArray(data, schema, getRef) {
332342
if (schema.items.hasOwnProperty('$ref')) {
333343
// :TODO: this will most probably mutate the original schema
334344
// but i'll fix it later
335-
schema.items = getRef(schema.items['$ref']);
345+
schema.items = _extends({}, getRef(schema.items['$ref']), schema.items);
346+
delete schema.items['$ref'];
336347
}
337348

338349
let type;
@@ -394,7 +405,12 @@ function getSyncedObject(data, schema, getRef) {
394405
let key = keys[i];
395406
let schemaValue = schema_keys[key];
396407
let isRef = schemaValue.hasOwnProperty('$ref');
397-
if (isRef) schemaValue = getRef(schemaValue['$ref']);
408+
409+
if (isRef) {
410+
schemaValue = _extends({}, getRef(schemaValue['$ref']), schemaValue);
411+
delete schemaValue['$ref'];
412+
}
413+
398414
let type;
399415
let default_;
400416

@@ -448,7 +464,11 @@ function getSyncedAnyOf(data, schema, getRef) {
448464
}
449465
function getSyncedData(data, schema, getRef) {
450466
// adds those keys to data which are in schema but not in data
451-
if (schema.hasOwnProperty('$ref')) schema = getRef(schema['$ref']);
467+
if (schema.hasOwnProperty('$ref')) {
468+
schema = _extends({}, getRef(schema['$ref']), schema);
469+
delete schema['$ref'];
470+
}
471+
452472
let type = getSchemaType(schema);
453473
let syncFunc = getSyncFunc(type);
454474
if (syncFunc) return syncFunc(data, schema, getRef);
@@ -467,7 +487,12 @@ function findMatchingSubschemaIndex(data, schema, getRef, schemaName) {
467487

468488
for (let i = 0; i < subschemas.length; i++) {
469489
let subschema = subschemas[i];
470-
if (subschema.hasOwnProperty('$ref')) subschema = getRef(subschema['$ref']);
490+
491+
if (subschema.hasOwnProperty('$ref')) {
492+
subschema = _extends({}, getRef(subschema['$ref']), subschema);
493+
delete subschema['$ref'];
494+
}
495+
471496
let subType = getSchemaType(subschema);
472497

473498
if (dataType === 'object') {
@@ -493,7 +518,12 @@ function findMatchingSubschemaIndex(data, schema, getRef, schemaName) {
493518
// so we'll just return the first schema that matches the data type
494519
for (let i = 0; i < subschemas.length; i++) {
495520
let subschema = subschemas[i];
496-
if (subschema.hasOwnProperty('$ref')) subschema = getRef(subschema['$ref']);
521+
522+
if (subschema.hasOwnProperty('$ref')) {
523+
subschema = _extends({}, getRef(subschema['$ref']), subschema);
524+
delete subschema['$ref'];
525+
}
526+
497527
let subType = getSchemaType(subschema);
498528

499529
if (dataType === subType) {
@@ -2724,7 +2754,12 @@ function getArrayFormRow(args) {
27242754
let max_items = getKeyword(schema, 'max_items', 'maxItems') || 100;
27252755
if (data.length >= max_items || isReadonly) addable = false;
27262756
let isRef = schema.items.hasOwnProperty('$ref');
2727-
if (isRef) schema.items = args.getRef(schema.items['$ref']);
2757+
2758+
if (isRef) {
2759+
schema.items = _extends({}, args.getRef(schema.items['$ref']), schema.items);
2760+
delete schema.items['$ref'];
2761+
}
2762+
27282763
let type = normalizeKeyword(schema.items.type);
27292764
let nextArgs = {
27302765
schema: schema.items,
@@ -2889,7 +2924,12 @@ function getObjectFormRow(args) {
28892924
}
28902925

28912926
let isRef = schemaValue.hasOwnProperty('$ref');
2892-
if (isRef) schemaValue = args.getRef(schemaValue['$ref']);
2927+
2928+
if (isRef) {
2929+
schemaValue = _extends({}, args.getRef(schemaValue['$ref']), schemaValue);
2930+
delete schemaValue['$ref'];
2931+
}
2932+
28932933
if (isReadonly) schemaValue.readOnly = true;
28942934
let type = normalizeKeyword(schemaValue.type);
28952935

@@ -3043,7 +3083,14 @@ class OneOfTopLevel extends React$1.Component {
30433083
if (index === undefined) index = this.state.option;
30443084
let schema = this.props.args.schema[this.schemaName][index];
30453085
let isRef = schema.hasOwnProperty('$ref');
3046-
if (isRef) schema = this.props.args.getRef(schema['$ref']);
3086+
3087+
if (isRef) {
3088+
schema = _extends({}, this.props.args.getRef(schema['$ref']), {
3089+
schema
3090+
});
3091+
delete schema['$ref'];
3092+
}
3093+
30473094
return schema;
30483095
};
30493096

@@ -3130,7 +3177,12 @@ class OneOf extends React$1.Component {
31303177
for (let i = 0; i < subschemas.length; i++) {
31313178
let subschema = subschemas[i];
31323179
let isRef = subschema.hasOwnProperty('$ref');
3133-
if (isRef) subschema = this.props.parentArgs.getRef(subschema['$ref']);
3180+
3181+
if (isRef) {
3182+
subschema = _extends({}, this.props.parentArgs.getRef(subschema['$ref']), subschema);
3183+
delete subschema['$ref'];
3184+
}
3185+
31343186
let subType = getSchemaType(subschema);
31353187

31363188
if (subschema.hasOwnProperty('const')) {
@@ -3250,7 +3302,12 @@ class OneOf extends React$1.Component {
32503302
}
32513303

32523304
let isRef = schema.hasOwnProperty('$ref');
3253-
if (isRef) schema = this.props.parentArgs.getRef(schema['$ref']);
3305+
3306+
if (isRef) {
3307+
schema = _extends({}, this.props.parentArgs.getRef(schema['$ref']), schema);
3308+
delete schema['$ref'];
3309+
}
3310+
32543311
return schema;
32553312
};
32563313

@@ -3425,6 +3482,10 @@ function validateSchema(schema) {
34253482
validation = validateOneOf(schema);
34263483
} else if (schema.hasOwnProperty('anyOf')) {
34273484
validation = validateAnyOf(schema);
3485+
} else if (schema.hasOwnProperty('$ref')) {
3486+
validation = {
3487+
isValid: true
3488+
};
34283489
} else {
34293490
validation = {
34303491
isValid: false,
@@ -3791,6 +3852,12 @@ class ReactJSONForm extends React$1.Component {
37913852
let data = this.props.editorState.getData();
37923853
let schema = this.props.editorState.getSchema();
37933854
let formGroups = [];
3855+
3856+
if (schema.hasOwnProperty('$ref')) {
3857+
schema = _extends({}, this.getRef(schema['$ref']), schema);
3858+
delete schema['$ref'];
3859+
}
3860+
37943861
let type = getSchemaType(schema);
37953862
let args = {
37963863
data: data,

0 commit comments

Comments
 (0)