How to use the react-jsonschema-form/lib/utils.getDefaultRegistry function in react-jsonschema-form

To help you get started, we’ve selected a few react-jsonschema-form examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cloudwan / gohan_webui / src / Form / formComponents / fields / ObjectField.js View on Github external
}
  // 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)) {
github Talend / ui / packages / forms / src / deprecated / fields / BooleanField.js View on Github external
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;
github cloudwan / gohan_webui / src / Form / formComponents / fields / YamlField.js View on Github external
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);
github cloudwan / gohan_webui / src / Form / formComponents / fields / ArrayField / ArrayField.js View on Github external
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) {
github chili-epfl / collab-react-components / src / client / fields / CollabStringField.js View on Github external
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);
github balena-io-modules / rendition / src / unstable / components / Form / fields / ObjectField.tsx View on Github external
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>
github cloudwan / gohan_webui / src / Form / formComponents / fields / StringField.js View on Github external
])).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;
github chili-epfl / collab-react-components / src / client / fields / CollabStringField.js View on Github external
).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;
github cybertec-postgresql / rjsf-material-ui / src / ArrayFieldTemplate / ArrayFieldTemplate.tsx View on Github external
const ArrayFieldTemplate = (props: ArrayFieldTemplateProps) =&gt; {
  const { schema, registry = getDefaultRegistry() } = props;

  if (isMultiSelect(schema, registry.definitions)) {
    return ;
  } else {
    return ;
  }
};
github department-of-veterans-affairs / vets-website / src / js / common / schemaform / fields / ObjectField.jsx View on Github external
);
    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() {