Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// deep check on sorted keys
if (!deepEquals(newKeys.sort(), oldKeys.sort())) {
return true;
}
return false;
}
class ObjectField extends Component {
nullValue = false;
static defaultProps = {
uiSchema: {},
errorSchema: {},
idSchema: {},
registry: getDefaultRegistry(),
required: false,
disabled: false,
readonly: false,
};
constructor(props) {
super(props);
this.state = {...this.getStateFromProps(props)};
this.nullValue = props.formData === null || (this.isFieldEmpty() && !props.required);
}
componentWillReceiveProps(nextProps) {
const state = this.getStateFromProps(nextProps);
const {formData} = nextProps;
if (formData && objectKeysHaveChanged(formData, this.state)) {
disabled: PropTypes.bool,
readonly: PropTypes.bool,
autofocus: PropTypes.bool,
registry: PropTypes.shape({
widgets: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object]))
.isRequired,
fields: PropTypes.objectOf(PropTypes.func).isRequired,
definitions: PropTypes.object.isRequired,
formContext: PropTypes.object.isRequired,
}),
};
}
BooleanField.defaultProps = {
uiSchema: {},
registry: getDefaultRegistry(),
disabled: false,
readonly: false,
autofocus: false,
};
export default BooleanField;
shouldRender,
getDefaultRegistry,
setState
} from 'react-jsonschema-form/lib/utils';
import jsyaml from 'js-yaml';
import {omitByRecursively, removeEmptyObjects} from '../utils';
class YamlField extends Component {
nullValue = false;
static defaultProps = {
uiSchema: {},
errorSchema: {},
idSchema: {},
registry: getDefaultRegistry(),
required: false,
disabled: false,
readonly: false,
};
constructor(props) {
super(props);
this.state = {
errors: [],
value: {...this.getStateFromProps(props)}
};
}
componentWillReceiveProps(nextProps) {
const value = this.getStateFromProps(nextProps);
toIdSchema,
shouldRender,
getDefaultRegistry,
setState
} from 'react-jsonschema-form/lib/utils';
import FileWidget from '../../widgets/FileWidget';
import ArrayFieldTitle from './ArrayFieldTitle';
import ArrayFieldDescription from './ArrayFieldDescription';
import AddButton from './AddButton';
import {ArraySortableList} from './ArraySortableList';
export default class ArrayField extends Component {
static defaultProps = {
uiSchema: {},
idSchema: {},
registry: getDefaultRegistry(),
required: false,
disabled: false,
readonly: false,
autofocus: false,
};
static reorderList(items, oldIndex, newIndex) {
const array = [...items];
if (newIndex === oldIndex) {
return array;
}
const target = array[oldIndex];
const step = newIndex < oldIndex ? -1 : 1;
for (let k = oldIndex; k !== newIndex; k += step) {
render() {
const {
schema,
name,
uiSchema,
idSchema,
formData,
required,
disabled,
readonly,
autofocus,
onChange,
onBlur,
registry = getDefaultRegistry(),
} = this.props;
const { title, format } = schema;
const { widgets, formContext } = registry;
const enumOptions = Array.isArray(schema.enum) && optionsList(schema);
const defaultWidget = format || (enumOptions ? 'select' : 'text');
const {
widget = defaultWidget,
placeholder = '',
...options
} = getUiOptions(uiSchema);
const Widget = CollabStringField.getWidget(schema, widget, widgets);
const ref = {};
if (this.isCollab) ref.widgetRef = w => (this._widget = w);
render() {
const {
uiSchema,
formData,
errorSchema,
idSchema,
name,
required,
disabled,
readonly,
idPrefix,
onBlur,
onFocus,
registry = getDefaultRegistry(),
} = this.props;
const { definitions, fields, formContext } = registry;
const { SchemaField, TitleField, DescriptionField } = fields;
const schema = retrieveSchema(this.props.schema, definitions, formData);
const title = schema.title === undefined ? name : schema.title;
const description = uiSchema['ui:description'] || schema.description;
let orderedProperties: string[];
try {
const properties = Object.keys(schema.properties || {});
orderedProperties = orderProperties(properties, uiSchema['ui:order']);
} catch (err) {
return (
<div>
<p style="{{">
Invalid {name || 'root'} object field configuration:</p></div>
])).isRequired,
fields: PropTypes.objectOf(PropTypes.func).isRequired,
definitions: PropTypes.object.isRequired,
formContext: PropTypes.object.isRequired,
}),
formContext: PropTypes.object.isRequired,
required: PropTypes.bool,
disabled: PropTypes.bool,
readonly: PropTypes.bool,
autofocus: PropTypes.bool,
};
}
StringField.defaultProps = {
uiSchema: {},
registry: getDefaultRegistry(),
disabled: false,
readonly: false,
autofocus: false,
};
export default StringField;
).isRequired,
fields: PropTypes.objectOf(PropTypes.func).isRequired,
definitions: PropTypes.object.isRequired,
formContext: PropTypes.object.isRequired,
}),
formContext: PropTypes.object.isRequired,
required: PropTypes.bool,
disabled: PropTypes.bool,
readonly: PropTypes.bool,
autofocus: PropTypes.bool,
};
}
CollabStringField.defaultProps = {
uiSchema: {},
registry: getDefaultRegistry(),
disabled: false,
readonly: false,
autofocus: false,
};
export default CollabStringField;
const ArrayFieldTemplate = (props: ArrayFieldTemplateProps) => {
const { schema, registry = getDefaultRegistry() } = props;
if (isMultiSelect(schema, registry.definitions)) {
return ;
} else {
return ;
}
};
);
containers.forEach(block => {
const fields = Array.from(block.querySelectorAll('.form-checkbox,.schemaform-field-template'));
if (fields.length) {
fields[0].classList.add('schemaform-first-field');
}
});
}
}
class ObjectField extends React.Component {
static defaultProps = {
uiSchema: {},
errorSchema: {},
idSchema: {},
registry: getDefaultRegistry(),
required: false,
disabled: false,
readonly: false,
}
constructor(props) {
super(props);
this.state = this.getStateFromProps(props);
this.onPropertyChange = this.onPropertyChange.bind(this);
this.onPropertyBlur = this.onPropertyBlur.bind(this);
this.isRequired = this.isRequired.bind(this);
this.SchemaField = pureWithDeepEquals(this.props.registry.fields.SchemaField);
this.orderedProperties = this.orderAndFilterProperties(props.schema, props.uiSchema);
}
componentDidMount() {