Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const {uiSchema, errorSchema, idSchema, name, required, registry} = props;
const {definitions, fields, formContext, FieldTemplate = DefaultTemplate} = registry;
const schema = retrieveSchema(props.schema, definitions);
const FieldComponent = getFieldComponent(schema, uiSchema, fields);
const disabled = Boolean(props.disabled || uiSchema['ui:disabled']);
const readonly = Boolean(props.readonly || uiSchema['ui:readonly']);
const autofocus = Boolean(props.autofocus || uiSchema['ui:autofocus']);
if (Object.keys(schema).length === 0) {
// See #312: Ensure compatibility with old versions of React.
return <div>;
}
let displayLabel = true;
if (schema.type === 'array') {
displayLabel = isMultiSelect(schema) || isFilesArray(schema, uiSchema);
}
if (schema.type === 'object') {
displayLabel = false;
}
if (schema.type === 'boolean' && !uiSchema['ui:widget']) {
displayLabel = false;
}
if (uiSchema['ui:field']) {
displayLabel = false;
}
const field = (
</div>
render() {
const { schema, uiSchema, idSchema, registry } = this.props;
const { definitions } = registry;
// eslint-disable-next-line no-prototype-builtins
if (!schema.hasOwnProperty('items')) {
return (
);
}
if (isFixedItems(schema)) {
return this.renderFixedArray();
}
if (isFilesArray(schema, uiSchema, definitions)) {
return this.renderFiles();
}
if (isMultiSelect(schema, definitions)) {
return this.renderMultiSelect();
}
return this.renderNormalArray();
}
}
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;
const { DescriptionField = DefaultDescriptionField } = fields;
if (displayLabel || forceLabelDisplay) {
return [
<label id="{id}" required="{required}" label="{label}">,</label>
render() {
const {schema, uiSchema} = this.props;
const widget = uiSchema['ui:widget'];
if (widget === 'hidden') {
return null;
}
if (isFilesArray(schema, uiSchema)) {
return this.renderFiles();
}
if (isFixedItems(schema)) {
return this.renderFixedArray();
}
if (isMultiSelect(schema)) {
return this.renderMultiSelect();
}
if (schema.items.type === 'object') {
return this.renderObjectArray();
}
return this.renderNormalArray();
}