Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function load() {
switch (form.data.schema.type) {
case 'string':
// If the widget is not collaborative, we also have to update it !
const { widget = 'text' } = getUiOptions(props.uiSchema);
const isSupported = isAvailableWidget(widget);
if (!isSupported) {
this.setState({ form, isObject: false });
} else {
this.setState({ form, isObject: false, isCollab: true });
}
break;
case 'object':
// We save all non-collaborative keys
const nonCollabKeys = [];
const properties = form.data.schema.properties;
Object.keys(properties).forEach(key => {
if (properties[key].type !== 'string') {
nonCollabKeys.push(key);
} else if (props.uiSchema[key]) {
// If the widget is not collaborative, we also have to update it ! Also if it is an enum
name,
required,
disabled,
readonly,
autofocus,
registry,
formContext,
onBlur,
onChange,
onFocus,
} = this.props;
const title = schema.title === undefined ? name : schema.title;
const { ArrayFieldTemplate, definitions, fields, widgets } = registry;
const { TitleField, DescriptionField } = fields;
const itemsSchema = retrieveSchema(schema.items, definitions);
const { widget, addable = true, type = 'element', ...options } = getUiOptions(uiSchema);
if (typeof widget === 'string') {
if (widget === 'hidden') {
return null;
}
const Widget = getWidget(schema, widget, widgets);
const onChangeHandler = value => {
onChange(value, options);
};
return (
export function DefaultLabel({
schema,
uiSchema,
definitions,
required,
id,
name,
fields = {},
formContext,
}) {
const uiOptions = getUiOptions(uiSchema);
let { label: displayLabel = true, forceLabelDisplay } = uiOptions;
if (schema.type === "array") {
displayLabel =
isMultiSelect(schema, definitions) ||
isFilesArray(schema, uiSchema, definitions);
}
if (schema.type === "object") {
displayLabel = false;
}
if (schema.type === "boolean" && !uiSchema["ui:widget"]) {
displayLabel = false;
}
const label = uiSchema["ui:title"] || schema.title || name;
const description = uiSchema["ui:description"] || schema.description;
name,
uiSchema,
idSchema,
formData,
registry,
required,
disabled,
readonly,
autofocus,
onChange,
onBlur,
} = props;
const { title } = schema;
const { widgets, formContext } = registry;
const widget = uiSchema['ui:widget'];
const uiOptions = getUiOptions(uiSchema);
const onChangeHandler = () => {
onChange(!formData, uiOptions);
};
const onBlurHandler = () => {
if (onBlur) {
onBlur(idSchema && idSchema.$id, formData);
}
};
const commonProps = {
schema,
id: idSchema && idSchema.$id,
onChange: onChangeHandler,
onBlur: onBlurHandler,
label: title === undefined ? name : title,
value: formData,
const {
schema,
uiSchema,
idSchema,
name,
disabled,
readonly,
autofocus,
onBlur,
onFocus,
registry,
} = this.props;
const title = schema.title || name;
const items = this.props.formData;
const { widgets, formContext } = registry;
const { widget = 'files', ...options } = getUiOptions(uiSchema);
const Widget = getWidget(schema, widget, widgets);
return (
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);
if (options.emptyValue === undefined) options.emptyValue = '';
return (
disabled,
readonly,
autofocus
} = this.props;
const {items} = this.state;
const {widgets, definitions} = this.props.registry;
const itemsSchema = retrieveSchema(schema.items, definitions);
const enumOptions = (itemsSchema && itemsSchema.options) ?
optionsListObject(itemsSchema) :
optionsList(itemsSchema);
const {
widget = 'select',
...options
} = {
...getUiOptions(uiSchema),
enumOptions,
};
const Widget = getWidget(schema, widget, widgets);
return (
);
}
schema,
idSchema,
uiSchema,
disabled,
readonly,
autofocus,
onBlur,
onFocus,
registry,
} = this.props;
const items = this.props.formData;
const { widgets, definitions, formContext } = registry;
const itemsSchema = retrieveSchema(schema.items, definitions);
const enumOptions = optionsList(itemsSchema);
const { widget = 'select', ...options } = {
...getUiOptions(uiSchema),
enumOptions,
};
const Widget = getWidget(schema, widget, widgets);
return (