'use strict';

const index = require('./index-1141a245.js');
const FieldGenerator = require('./FieldGenerator-279a646b.js');
const BaseField = require('./BaseField-381327a9.js');

class SubFormField extends BaseField.BaseField {
  constructor(id, title, fields, description, 
  // TODO
  layout, showFieldOrder, language) {
    super(id, 'subForm');
    this.id = id;
    this.title = title;
    this.description = description;
    this.fields = fields;
    this.language = language;
    this.layout = layout;
    this.showFieldOrder = showFieldOrder;
    this.maxCount = 1;
    this.minCount = 1;
    this.separated = true;
    this.value = undefined;
  }
  setMaxCount(maxCount) {
    this.maxCount = maxCount;
    return this;
  }
  setMinCount(minCount) {
    this.minCount = minCount;
    return this;
  }
  setSeparated(separated) {
    this.separated = separated;
    return this;
  }
}
SubFormField.type = 'subForm';

const render = (field, value, errors, disabled, onFieldChange, onFieldBlur) => index.h("dvn-field-input-sub-form", { disabled: disabled, errors: errors, field: field, onChange: (e) => {
    e.stopImmediatePropagation();
    onFieldChange(field, e.detail);
  }, onBlur: () => onFieldBlur(field), value: value });
// register 'subForm' key for json form generations
FieldGenerator.registerField('subForm', render);

exports.SubFormField = SubFormField;
