text: var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  
  function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  
  import { getObjectValueByPath } from '../../../util/helpers';
  
  /**
   * Select generators
   *
   * @mixin
   *
   * Used for creating the DOM elements for VSelect
   */
  export default {
    methods: {
      genMenu: function genMenu() {
        var _this = this;
  
        var data = {
          ref: 'menu',
          props: {
            activator: this.$el,
            auto: this.auto,
            closeOnClick: false,
            closeOnContentClick: !this.isMultiple,
            contentClass: this.computedContentClass,
            disabled: this.disabled,
            maxHeight: this.maxHeight,
            nudgeTop: this.nudgeTop,
            offsetY: this.shouldOffset,
            offsetOverflow: this.isAutocomplete,
            openOnClick: false,
            value: this.menuIsVisible,
            zIndex: this.menuZIndex
          },
          on: {
            input: function input(val) {
              if (!val) {
                _this.menuIsActive = false;
              }
            }
          }
        };
  
        if (this.isAutocomplete) data.props.transition = '';
  
        this.minWidth && (data.props.minWidth = this.minWidth);
  
        return this.$createElement('v-menu', data, [this.genList()]);
      },
      getMenuIndex: function getMenuIndex() {
        return this.$refs.menu ? this.$refs.menu.listIndex : -1;
      },
      setMenuIndex: function setMenuIndex(index) {
        this.$refs.menu && (this.$refs.menu.listIndex = index);
      },
      resetMenuIndex: function resetMenuIndex() {
        this.setMenuIndex(-1);
      },
      isMenuItemSelected: function isMenuItemSelected() {
        return this.menuIsActive && this.menuItems.length && this.getMenuIndex() > -1;
      },
      genSelectionsAndSearch: function genSelectionsAndSearch() {
        return this.$createElement('div', {
          'class': 'vf-input-group__selections',
          style: { 'overflow': 'hidden' },
          ref: 'activator'
        }, [].concat(_toConsumableArray(this.genSelections()), [this.genSearch()]));
      },
      genSelections: function genSelections() {
        var _this2 = this;
  
        if (this.hideSelections) return [];
  
        var children = [];
        var chips = this.chips;
        var slots = this.$scopedSlots.selection;
        var length = this.selectedItems.length;
        this.selectedItems.forEach(function (item, i) {
          if (slots) {
            children.push(_this2.genSlotSelection(item, i));
          } else if (chips) {
            children.push(_this2.genChipSelection(item, i));
          } else if (_this2.segmented) {
            children.push(_this2.genSegmentedBtn(item, i));
          } else {
            children.push(_this2.genCommaSelection(item, i < length - 1, i));
          }
        });
  
        return children;
      },
      genSearch: function genSearch() {
        var _this3 = this;
  
        var data = {
          staticClass: 'vf-input-group--select__autocomplete',
          'class': {
            'vf-input-group--select__autocomplete--index': this.selectedIndex > -1
          },
          style: {
            flex: this.shouldBreak ? '1 0 100%' : null
          },
          attrs: _extends({}, this.$attrs, {
            disabled: this.disabled || !this.isAutocomplete,
            readonly: this.readonly,
            tabindex: this.disabled || !this.isAutocomplete ? -1 : this.tabindex
          }),
          domProps: {
            value: this.maskText(this.lazySearch || '')
          },
          directives: [{
            name: 'show',
            value: this.isAutocomplete || this.placeholder && !this.selectedItems.length
          }],
          ref: 'input',
          key: 'input'
        };
  
        if (this.isAutocomplete) {
          data.attrs.role = 'combobox';
          data.domProps.autocomplete = this.browserAutocomplete;
  
          data.on = _extends({}, this.genListeners(), {
            input: function input(e) {
              _this3.searchValue = _this3.unmaskText(e.target.value);
            }
          });
  
          if (this.combobox) {
            // When using the combobox
            // update inputValue and
            // set the menu status
            data.on.blur = function (e) {
              // If user clears input
              // value will be falsey
              // but not null
              if (_this3.lazySearch == null ||
              // If blur was caused by clicking
              // a menu list tile, do nothing
              _this3.content && _this3.content.contains(e.relatedTarget) || _this3.$el && _this3.$el.contains(e.relatedTarget)) return;
  
              _this3.inputValue = _this3.lazySearch;
            };
          }
  
          data.directives = data.directives.concat(this.genDirectives());
        }
  
        if (this.placeholder) data.domProps.placeholder = this.placeholder;
  
        return this.$createElement('input', data);
      },
      genSegmentedBtn: function genSegmentedBtn(item) {
        if (!item.text || !item.callback) {
          console.warn('[Vuetify] Warn: When using the v-select component with \'segmented\' prop without a selection slot, items must contain both a text and callback property');
          return null;
        }
  
        return this.$createElement('v-btn', {
          props: {
            flat: true
          },
          on: {
            click: function click(e) {
              e.stopPropagation();
              item.callback(e);
            }
          }
        }, [item.text]);
      },
      genSlotSelection: function genSlotSelection(item, index) {
        return this.$scopedSlots.selection({
          parent: this,
          item: item,
          index: index,
          selected: index === this.selectedIndex,
          disabled: this.disabled || this.readonly
        });
      },
      genChipSelection: function genChipSelection(item, index) {
        var _this4 = this;
  
        var isDisabled = this.disabled || this.readonly;
        var click = function click(e) {
          if (isDisabled) return;
  
          e.stopPropagation();
          _this4.focusInput();
          _this4.selectedIndex = index;
        };
  
        return this.$createElement('v-chip', {
          staticClass: 'vf-chip--select-multi',
          attrs: { tabindex: '-1' },
          props: {
            close: this.deletableChips && !isDisabled,
            dark: this.dark,
            disabled: isDisabled,
            selected: index === this.selectedIndex
          },
          on: {
            click: click,
            focus: click,
            input: function input() {
              if (_this4.isMultiple) _this4.selectItem(item);else _this4.inputValue = null;
            }
          },
          key: this.getValue(item)
        }, this.getText(item));
      },
      genCommaSelection: function genCommaSelection(item, comma, index) {
        return this.$createElement('div', {
          staticClass: 'vf-input-group__selections__comma',
          'class': {
            'vf-input-group__selections__comma--active': index === this.selectedIndex
          },
          key: JSON.stringify(this.getValue(item)) // Item may be an object
        }, '' + this.getText(item) + (comma ? ', ' : ''));
      },
      genList: function genList() {
        var _this5 = this;
  
        var children = this.menuItems.map(function (o) {
          if (o.header) return _this5.genHeader(o);
          if (o.divider) return _this5.genDivider(o);else return _this5.genTile(o);
        });
  
        if (!children.length) {
          var noData = this.$slots['no-data'];
          if (noData) {
            children.push(noData);
          } else {
            children.push(this.genTile(this.noDataText, true));
          }
        }
  
        return this.$createElement('v-card', [this.$createElement('v-list', {
          props: {
            dense: this.dense
          },
          ref: 'list'
        }, children)]);
      },
      genHeader: function genHeader(item) {
        return this.$createElement('v-subheader', {
          props: item
        }, item.header);
      },
      genDivider: function genDivider(item) {
        return this.$createElement('v-divider', {
          props: item
        });
      },
      genLabel: function genLabel() {
        var singleLine = this.singleLine || this.isDropdown;
  
        if (singleLine && this.isDirty || singleLine && this.isFocused && this.searchValue) return null;
  
        var data = {};
  
        if (this.id) data.attrs = { for: this.id };
  
        return this.$createElement('label', data, this.$slots.label || this.label);
      },
      genTile: function genTile(item, disabled) {
        var _this6 = this;
  
        var active = this.selectedItems.indexOf(item) !== -1;
  
        if (typeof disabled === 'undefined') {
          disabled = getObjectValueByPath(item, this.itemDisabled);
        }
  
        var data = {
          on: {
            click: function click(e) {
              if (disabled) return;
  
              _this6.selectItem(item);
            }
          },
          props: {
            avatar: item === Object(item) && this.itemAvatar in item,
            ripple: true,
            value: active
          }
        };
  
        if (disabled) {
          data.props.disabled = disabled;
        }
  
        data.props.activeClass = Object.keys(this.addTextColorClassChecks()).join(' ');
  
        if (this.$scopedSlots.item) {
          return this.$createElement('v-list-tile', data, [this.$scopedSlots.item({ parent: this, item: item })]);
        }
  
        return this.$createElement('v-list-tile', data, [this.genAction(item, active), this.genContent(item)]);
      },
      genAction: function genAction(item, active) {
        var _this7 = this;
  
        if (!this.isMultiple || this.isHidingSelected) return null;
  
        var data = {
          staticClass: 'vf-list__tile__action--select-multi',
          on: {
            click: function click(e) {
              e.stopPropagation();
              _this7.selectItem(item);
            }
          }
        };
  
        return this.$createElement('v-list-tile-action', data, [this.$createElement('v-checkbox', {
          props: {
            color: this.computedColor,
            inputValue: active
          }
        })]);
      },
      genContent: function genContent(item) {
        var text = this.getText(item);
  
        return this.$createElement('v-list-tile-content', [this.$createElement('v-list-tile-title', {
          domProps: {
            innerHTML: this.genFiltered(text)
          }
        })]);
      }
    }
  };