How to use the mson/lib/compiler.newComponent 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
handleValueChange = value => {
    const form = this.props.component;
    let { field } = this.state;
    let component = null;

    // Is the field changing?
    if (!field || value.componentName !== field.getClassName()) {
      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();
        };
github redgeoff / mson-react / src / demo / app.js View on Github external
// Register optional core components
compiler.registerComponent('FieldEditorForm', FieldEditorForm);
uiComponents.FieldEditorForm = FieldEditorFormUI;
compiler.registerComponent('FormEditor', FormEditor);
uiComponents.FormEditor = FormEditorUI;
compiler.registerComponent('FormBuilder', FormBuilder);

// Register all the components
for (let name in components) {
  let component = components[name];
  compiler.registerComponent(component.name, component);
}

// Instantiate the app
const app = compiler.newComponent({
  component: 'app.App'
});

export default app;
github redgeoff / mson-react / src / component.js View on Github external
createComponent() {
    const { definition } = this.props;
    this.setState({ component: compiler.newComponent(definition) });
  }