How to use the react-jsonschema-form/lib/utils.getUiOptions 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 chili-epfl / collab-react-components / src / client / CollabForm.js View on Github external
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
github Talend / ui / packages / forms / src / deprecated / fields / ArrayField.js View on Github external
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 (
github RxNT / react-jsonschema-form-extras / src / Label.js View on Github external
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;
github Talend / ui / packages / forms / src / deprecated / fields / BooleanField.js View on Github external
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,
github Talend / ui / packages / forms / src / deprecated / fields / ArrayField.js View on Github external
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 (
github chili-epfl / collab-react-components / src / client / fields / CollabStringField.js View on Github external
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 (
github cloudwan / gohan_webui / src / Form / formComponents / fields / ArrayField / ArrayField.js View on Github external
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 (
      
    );
  }
github Talend / ui / packages / forms / src / deprecated / fields / ArrayField.js View on Github external
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 (