Skip to content

Commit 414c46c

Browse files
committed
Bump version to 2.14.4 and update dist files
1 parent 0d31622 commit 414c46c

File tree

5 files changed

+35
-20
lines changed

5 files changed

+35
-20
lines changed

dist/react-json-form.cjs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2654,13 +2654,14 @@ function FormField(props) {
26542654
if (typeof inputProps.error === 'string') inputProps.error = [inputProps.error];
26552655
if (props.schema.placeholder) inputProps.placeholder = props.schema.placeholder;
26562656
if (props.schema.handler) inputProps.handler = props.schema.handler;
2657+
let schemaType = normalizeKeyword(props.schema.type);
26572658
let type;
26582659

26592660
if (props.schema.hasOwnProperty('const')) {
26602661
type = actualType(props.schema.const);
26612662
inputProps.readOnly = true;
26622663
} else {
2663-
type = normalizeKeyword(props.schema.type);
2664+
type = schemaType;
26642665
}
26652666

26662667
let choices = getKeyword(props.schema, 'choices', 'enum');
@@ -2715,12 +2716,9 @@ function FormField(props) {
27152716

27162717
case 'range':
27172718
case 'integer':
2718-
inputProps.step = '1';
2719-
// fall through
2720-
27212719
case 'number':
27222720
if (type === 'range') inputProps.type = 'range';else inputProps.type = 'number';
2723-
inputProps.step = 'any';
2721+
if (schemaType === 'integer') inputProps.step = '1';else inputProps.step = 'any';
27242722
InputField = FormInput;
27252723
if (props.schema.minimum || props.schema.minimum === 0) inputProps.min = props.schema.minimum;
27262724
if (props.schema.maximum || props.schema.maximum === 0) inputProps.max = props.schema.maximum;
@@ -3363,18 +3361,22 @@ class OneOf extends React__default["default"].Component {
33633361
this.getSchema = index => {
33643362
if (index === undefined) index = this.state.option;
33653363
let parentType = this.getParentType();
3364+
let isReadonly = false;
33663365
let schema;
33673366

33683367
if (parentType === 'object') {
33693368
if (this.props.nextArgs) {
33703369
// this is an object key which has oneOf keyword
33713370
schema = _extends({}, this.props.nextArgs.schema[this.schemaName][index]);
33723371
if (!schema.title) schema.title = this.props.nextArgs.schema.title;
3372+
isReadonly = getKeyword(this.props.nextArgs.schema, 'readOnly', 'readonly', isReadonly);
33733373
} else {
33743374
schema = this.props.parentArgs.schema[this.schemaName][index];
3375+
isReadonly = getKeyword(this.props.parentArgs.schema, 'readOnly', 'readonly', isReadonly);
33753376
}
33763377
} else if (parentType === 'array') {
33773378
schema = this.props.parentArgs.schema.items[this.schemaName][index];
3379+
isReadonly = getKeyword(this.props.parentArgs.schema, 'readOnly', 'readonly', isReadonly);
33783380
} else {
33793381
schema = {
33803382
'type': 'string'
@@ -3388,6 +3390,7 @@ class OneOf extends React__default["default"].Component {
33883390
delete schema['$ref'];
33893391
}
33903392

3393+
if (isReadonly) schema.readOnly = true;
33913394
return schema;
33923395
};
33933396

@@ -3475,6 +3478,7 @@ class OneOf extends React__default["default"].Component {
34753478
*/
34763479
let selectedOption = this.findSelectedOption();
34773480
let schema = this.getSchema(selectedOption);
3481+
let isReadonly = getKeyword(schema, 'readOnly', 'readonly');
34783482
let type = getSchemaType(schema);
34793483
let args = this.props.nextArgs ? this.props.nextArgs : this.props.parentArgs;
34803484
let rowFunc;
@@ -3507,7 +3511,8 @@ class OneOf extends React__default["default"].Component {
35073511
options: this.getOptions(),
35083512
onChange: e => this.handleOptionChange(e, selectedOption),
35093513
className: "rjf-oneof-selector-input",
3510-
label: selectorLabel
3514+
label: selectorLabel,
3515+
readOnly: isReadonly
35113516
})), rows);
35123517
}
35133518

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: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2648,13 +2648,14 @@ function FormField(props) {
26482648
if (typeof inputProps.error === 'string') inputProps.error = [inputProps.error];
26492649
if (props.schema.placeholder) inputProps.placeholder = props.schema.placeholder;
26502650
if (props.schema.handler) inputProps.handler = props.schema.handler;
2651+
let schemaType = normalizeKeyword(props.schema.type);
26512652
let type;
26522653

26532654
if (props.schema.hasOwnProperty('const')) {
26542655
type = actualType(props.schema.const);
26552656
inputProps.readOnly = true;
26562657
} else {
2657-
type = normalizeKeyword(props.schema.type);
2658+
type = schemaType;
26582659
}
26592660

26602661
let choices = getKeyword(props.schema, 'choices', 'enum');
@@ -2709,12 +2710,9 @@ function FormField(props) {
27092710

27102711
case 'range':
27112712
case 'integer':
2712-
inputProps.step = '1';
2713-
// fall through
2714-
27152713
case 'number':
27162714
if (type === 'range') inputProps.type = 'range';else inputProps.type = 'number';
2717-
inputProps.step = 'any';
2715+
if (schemaType === 'integer') inputProps.step = '1';else inputProps.step = 'any';
27182716
InputField = FormInput;
27192717
if (props.schema.minimum || props.schema.minimum === 0) inputProps.min = props.schema.minimum;
27202718
if (props.schema.maximum || props.schema.maximum === 0) inputProps.max = props.schema.maximum;
@@ -3357,18 +3355,22 @@ class OneOf extends React$1.Component {
33573355
this.getSchema = index => {
33583356
if (index === undefined) index = this.state.option;
33593357
let parentType = this.getParentType();
3358+
let isReadonly = false;
33603359
let schema;
33613360

33623361
if (parentType === 'object') {
33633362
if (this.props.nextArgs) {
33643363
// this is an object key which has oneOf keyword
33653364
schema = _extends({}, this.props.nextArgs.schema[this.schemaName][index]);
33663365
if (!schema.title) schema.title = this.props.nextArgs.schema.title;
3366+
isReadonly = getKeyword(this.props.nextArgs.schema, 'readOnly', 'readonly', isReadonly);
33673367
} else {
33683368
schema = this.props.parentArgs.schema[this.schemaName][index];
3369+
isReadonly = getKeyword(this.props.parentArgs.schema, 'readOnly', 'readonly', isReadonly);
33693370
}
33703371
} else if (parentType === 'array') {
33713372
schema = this.props.parentArgs.schema.items[this.schemaName][index];
3373+
isReadonly = getKeyword(this.props.parentArgs.schema, 'readOnly', 'readonly', isReadonly);
33723374
} else {
33733375
schema = {
33743376
'type': 'string'
@@ -3382,6 +3384,7 @@ class OneOf extends React$1.Component {
33823384
delete schema['$ref'];
33833385
}
33843386

3387+
if (isReadonly) schema.readOnly = true;
33853388
return schema;
33863389
};
33873390

@@ -3469,6 +3472,7 @@ class OneOf extends React$1.Component {
34693472
*/
34703473
let selectedOption = this.findSelectedOption();
34713474
let schema = this.getSchema(selectedOption);
3475+
let isReadonly = getKeyword(schema, 'readOnly', 'readonly');
34723476
let type = getSchemaType(schema);
34733477
let args = this.props.nextArgs ? this.props.nextArgs : this.props.parentArgs;
34743478
let rowFunc;
@@ -3501,7 +3505,8 @@ class OneOf extends React$1.Component {
35013505
options: this.getOptions(),
35023506
onChange: e => this.handleOptionChange(e, selectedOption),
35033507
className: "rjf-oneof-selector-input",
3504-
label: selectorLabel
3508+
label: selectorLabel,
3509+
readOnly: isReadonly
35053510
})), rows);
35063511
}
35073512

dist/react-json-form.module.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2648,13 +2648,14 @@ function FormField(props) {
26482648
if (typeof inputProps.error === 'string') inputProps.error = [inputProps.error];
26492649
if (props.schema.placeholder) inputProps.placeholder = props.schema.placeholder;
26502650
if (props.schema.handler) inputProps.handler = props.schema.handler;
2651+
let schemaType = normalizeKeyword(props.schema.type);
26512652
let type;
26522653

26532654
if (props.schema.hasOwnProperty('const')) {
26542655
type = actualType(props.schema.const);
26552656
inputProps.readOnly = true;
26562657
} else {
2657-
type = normalizeKeyword(props.schema.type);
2658+
type = schemaType;
26582659
}
26592660

26602661
let choices = getKeyword(props.schema, 'choices', 'enum');
@@ -2709,12 +2710,9 @@ function FormField(props) {
27092710

27102711
case 'range':
27112712
case 'integer':
2712-
inputProps.step = '1';
2713-
// fall through
2714-
27152713
case 'number':
27162714
if (type === 'range') inputProps.type = 'range';else inputProps.type = 'number';
2717-
inputProps.step = 'any';
2715+
if (schemaType === 'integer') inputProps.step = '1';else inputProps.step = 'any';
27182716
InputField = FormInput;
27192717
if (props.schema.minimum || props.schema.minimum === 0) inputProps.min = props.schema.minimum;
27202718
if (props.schema.maximum || props.schema.maximum === 0) inputProps.max = props.schema.maximum;
@@ -3357,18 +3355,22 @@ class OneOf extends React$1.Component {
33573355
this.getSchema = index => {
33583356
if (index === undefined) index = this.state.option;
33593357
let parentType = this.getParentType();
3358+
let isReadonly = false;
33603359
let schema;
33613360

33623361
if (parentType === 'object') {
33633362
if (this.props.nextArgs) {
33643363
// this is an object key which has oneOf keyword
33653364
schema = _extends({}, this.props.nextArgs.schema[this.schemaName][index]);
33663365
if (!schema.title) schema.title = this.props.nextArgs.schema.title;
3366+
isReadonly = getKeyword(this.props.nextArgs.schema, 'readOnly', 'readonly', isReadonly);
33673367
} else {
33683368
schema = this.props.parentArgs.schema[this.schemaName][index];
3369+
isReadonly = getKeyword(this.props.parentArgs.schema, 'readOnly', 'readonly', isReadonly);
33693370
}
33703371
} else if (parentType === 'array') {
33713372
schema = this.props.parentArgs.schema.items[this.schemaName][index];
3373+
isReadonly = getKeyword(this.props.parentArgs.schema, 'readOnly', 'readonly', isReadonly);
33723374
} else {
33733375
schema = {
33743376
'type': 'string'
@@ -3382,6 +3384,7 @@ class OneOf extends React$1.Component {
33823384
delete schema['$ref'];
33833385
}
33843386

3387+
if (isReadonly) schema.readOnly = true;
33853388
return schema;
33863389
};
33873390

@@ -3469,6 +3472,7 @@ class OneOf extends React$1.Component {
34693472
*/
34703473
let selectedOption = this.findSelectedOption();
34713474
let schema = this.getSchema(selectedOption);
3475+
let isReadonly = getKeyword(schema, 'readOnly', 'readonly');
34723476
let type = getSchemaType(schema);
34733477
let args = this.props.nextArgs ? this.props.nextArgs : this.props.parentArgs;
34743478
let rowFunc;
@@ -3501,7 +3505,8 @@ class OneOf extends React$1.Component {
35013505
options: this.getOptions(),
35023506
onChange: e => this.handleOptionChange(e, selectedOption),
35033507
className: "rjf-oneof-selector-input",
3504-
label: selectorLabel
3508+
label: selectorLabel,
3509+
readOnly: isReadonly
35053510
})), rows);
35063511
}
35073512

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.14.3",
3+
"version": "2.14.4",
44
"description": "Create forms using JSON Schema",
55
"publishConfig": {
66
"access": "public"

0 commit comments

Comments
 (0)