"use strict";

var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");

exports.__esModule = true;
exports.default = void 0;

require("./Item.css");

var _component = require("../_utils/component");

var _Button = _interopRequireDefault(require("../Button"));

var _vueNormalizeComponent = _interopRequireDefault(require("../_utils/vue-normalize-component.js"));

/* script */
var __vue_script__ = {
  name: (0, _component.createComponentName)('filter-list'),
  components: {
    gdButton: _Button.default
  },
  mixins: [_component.componentMixin],
  props: {
    visiableAllBtn: {
      type: Boolean,
      default: true
    },
    parentIndex: {
      type: Number,
      default: 0
    },
    selectId: {
      type: [String, Number, null],
      default: null
    },
    selected: {
      type: Function,

      default() {}

    },
    info: {
      type: Object,
      default: function _default() {
        return {
          name: 'test',
          list: []
        };
      }
    }
  },
  methods: {
    isSelected(id) {
      return this.selectId === id ? 'primary' : null;
    },

    renderAllBtn() {
      var _this = this;

      var h = this.$createElement;
      if (!this.visiableAllBtn) return null;
      return h("li", [h("gd-button", {
        attrs: {
          type: this.isSelected(null),
          rect: true
        },
        on: {
          "click": function click() {
            _this.selected(_this.info.name, null, 0);
          }
        }
      }, ["\u5168\u90E8"])]);
    }

  },

  render() {
    var _this2 = this;

    var h = arguments[0];
    return h("div", {
      "class": this.bem()
    }, [h("div", [this.info.name]), h("ul", [this.renderAllBtn(), this.info.lists.map(function (item, index) {
      return h("li", {
        key: index
      }, [h("gd-button", {
        attrs: {
          type: _this2.isSelected(item.id),
          rect: true
        },
        on: {
          "click": function click() {
            _this2.selected(_this2.info.name, item.id, index, _this2.parentIndex);
          }
        }
      }, [item.name])]);
    })])]);
  }

};
/* template */

/* style */

var __vue_inject_styles__ = undefined;
/* scoped */

var __vue_scope_id__ = undefined;
/* module identifier */

var __vue_module_identifier__ = undefined;
/* functional template */

var __vue_is_functional_template__ = undefined;
/* component normalizer */

/* style inject */

/* style inject SSR */
var _default2 = (0, _vueNormalizeComponent.default)({}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, undefined, undefined);

exports.default = _default2;