How to use the mson/lib/fields/component-field function in mson

To help you get started, we’ve selected a few mson 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 redgeoff / mson-react / src / field-editor-form.js View on Github external
if (field) {
        // Prevent listener leak
        field.destroy();
      }

      if (value.componentName) {
        component = compiler.newComponent({
          component: value.componentName
        });

        // Is the component a field?
        if (component.isField) {
          field = component;
        } else {
          // e.g. Text component is not a field
          field = new ComponentField({ content: component });
        }

        // Auto validate so that the user can preview how the validation will work
        const validate = () => {
          field.clearErr();
          field.validate();
        };
        field.on('value', validate);
        field.on('touched', validate);
      } else {
        field = null;
      }
    }

    if (field) {
      // Set field values using form values. The corresponding values may not exist if the field was