import "./item.css";
/* script */
import { createComponentName, componentMixin } from '../../utils/base';
import gdButton from '../button';
const __vue_script__ = {
  name: createComponentName('filter-list'),
  components: {
    gdButton
  },
  mixins: [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: () => ({
        name: 'test',
        list: []
      })
    }
  },
  methods: {
    isSelected(id) {
      return this.selectId === id ? 'primary' : null;
    },

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

  },

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

};
/* template */

/* style */

const __vue_inject_styles__ = undefined;
/* scoped */

const __vue_scope_id__ = undefined;
/* module identifier */

const __vue_module_identifier__ = undefined;
/* functional template */

const __vue_is_functional_template__ = undefined;
/* component normalizer */

import __vue_normalize__ from '../../utils/vue-normalize-component.js';
/* style inject */

/* style inject SSR */

export default __vue_normalize__({}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, undefined, undefined);