text: import _ from 'lodash';
  import NestedComponent from '../_classes/nested/NestedComponent';
  import Component from '../_classes/component/Component';
  
  export default class ContainerComponent extends NestedComponent {
    static schema(...extend) {
      return NestedComponent.schema({
        label: 'Container',
        type: 'container',
        key: 'container',
        clearOnHide: true,
        input: true,
        tree: true,
        hideLabel: true,
        components: []
      }, ...extend);
    }
  
    static get builderInfo() {
      return {
        title: 'Container',
        icon: 'folder-open',
        group: 'data',
        documentation: 'http://help.form.io/userguide/#container',
        weight: 10,
        schema: ContainerComponent.schema()
      };
    }
  
    constructor(...args) {
      super(...args);
      this.type = 'container';
    }
  
    addComponents(data, options) {
      return super.addComponents(this.dataValue, options);
    }
  
    get defaultSchema() {
      return ContainerComponent.schema();
    }
  
    get emptyValue() {
      return {};
    }
  
    get templateName() {
      return 'container';
    }
  
    get allowData() {
      return true;
    }
  
    get data() {
      return this._data;
    }
  
    set data(value) {
      this._data = value;
      this.eachComponent(component => {
        component.data = this.dataValue;
      });
    }
  
    hasChanged(newValue, oldValue) {
      return !_.isEqual(newValue, oldValue);
    }
  
    getValue() {
      return this.dataValue;
    }
  
    updateValue(value, flags) {
      // Intentionally skip over nested component updateValue method to keep recursive update from occurring with sub components.
      return Component.prototype.updateValue.call(this, value, flags);
    }
  
    setValue(value, flags) {
      flags = flags || {};
      if (!value || !_.isObject(value)) {
        return false;
      }
      const hasValue = this.hasValue();
      if (hasValue && _.isEmpty(this.dataValue)) {
        flags.noValidate = true;
      }
      if (!hasValue) {
        // Set the data value and then reset each component to use the new data object.
        this.dataValue = {};
      }
      return super.setValue(value, flags);
    }
  }
  