<commit_before>// Styles
import '../../stylus/components/_overflow-buttons.styl'

// Extensions
import VSelect from '../VSelect/VSelect'
import VAutocomplete from '../VAutocomplete'
import VTextField from '../VTextField/VTextField'

import VBtn from '../VBtn'

import { consoleWarn } from '../../util/console'

export default {
  name: 'v-overflow-btn',

  extends: VAutocomplete,

  props: {
    segmented: Boolean,
    editable: Boolean,
    transition: VSelect.props.transition
  },

  computed: {
    classes () {
      return Object.assign(VAutocomplete.computed.classes.call(this), {
        'v-overflow-btn': true,
        'v-overflow-btn--segmented': this.segmented,
        'v-overflow-btn--editable': this.editable
      })
    },
    isAnyValueAllowed () {
      return this.editable ||
        VAutocomplete.computed.isAnyValueAllowed.call(this)
    },
    isSingle () {
      return true
    }
  },

  methods: {
    genSelections () {
      return this.segmented
        ? VSelect.methods.genSelections.call(this) // Override v-autocomplete's override
        : VAutocomplete.methods.genSelections.call(this)
    },
    genCommaSelection (item) {
      return this.segmented
        ? this.genSegmentedBtn(item)
        : VSelect.methods.genCommaSelection.call(this, item)
    },
    genInput () {
      const input = VTextField.methods.genInput.call(this)

      input.data.domProps.value = this.internalSearch
      input.data.attrs.readonly = !this.isAnyValueAllowed

      return input
    },
    genLabel () {
      const label = VTextField.methods.genLabel.call(this)

      if (!label) return label

      // Force 16px always
      label.data.style.left = '16px'
      delete label.data.style.position

      return label
    },
    genSegmentedBtn (item) {
      const itemObj = this.computedItems.find(i => i.value === item)

      if (!itemObj ||
        !itemObj.text ||
        !itemObj.callback
      ) {
        consoleWarn('When using \'segmented\' prop without a selection slot, items must contain both a text and callback property', this)
        return null
      }

      return this.$createElement(VBtn, {
        props: { flat: true },
        on: {
          click (e) {
            e.stopPropagation()
            itemObj.callback(e)<commit_msg>fix(VOverflowBtn): get correct item value and ignore search unless editable<commit_after>// Styles
import '../../stylus/components/_overflow-buttons.styl'

// Extensions
import VSelect from '../VSelect/VSelect'
import VAutocomplete from '../VAutocomplete'
import VTextField from '../VTextField/VTextField'

import VBtn from '../VBtn'

import { consoleWarn } from '../../util/console'

export default {
  name: 'v-overflow-btn',

  extends: VAutocomplete,

  props: {
    segmented: Boolean,
    editable: Boolean,
    transition: VSelect.props.transition
  },

  computed: {
    classes () {
      return Object.assign(VAutocomplete.computed.classes.call(this), {
        'v-overflow-btn': true,
        'v-overflow-btn--segmented': this.segmented,
        'v-overflow-btn--editable': this.editable
      })
    },
    isAnyValueAllowed () {
      return this.editable ||
        VAutocomplete.computed.isAnyValueAllowed.call(this)
    },
    isSingle () {
      return true
    },
    internalSearch: {
      get () {
        return this.editable
          ? VAutocomplete.computed.internalSearch.get.call(this)
          : ''
      },
      set (val) {
        VAutocomplete.computed.internalSearch.set.call(this, val)
      }
    }
  },

  methods: {
    genSelections () {
      return this.segmented
        ? VSelect.methods.genSelections.call(this) // Override v-autocomplete's override
        : VAutocomplete.methods.genSelections.call(this)
    },
    genCommaSelection (item) {
      return this.segmented
        ? this.genSegmentedBtn(item)
        : VSelect.methods.genCommaSelection.call(this, item)
    },
    genInput () {
      const input = VTextField.methods.genInput.call(this)

      input.data.domProps.value = this.internalSearch
      input.data.attrs.readonly = !this.isAnyValueAllowed

      return input
    },
    genLabel () {
      const label = VTextField.methods.genLabel.call(this)

      if (!label) return label

      // Force 16px always
      label.data.style.left = '16px'
      delete label.data.style.position

      return label
    },
    genSegmentedBtn (item) {
      const itemValue = this.getValue(item)
      const itemObj = this.computedItems.find(i => this.getValue(i) === itemValue) || item

      if (!itemObj.text || !itemObj.callback) {
        consoleWarn('When using \'segmented\' prop without a selection slot, items must contain both a text and callback property', this)
        return null
      }

      return this.$createElement(VBtn, {
        props: { flat: true },
        on: {
          click (e) {
            e.stopPropagation()
            itemObj.callback(e)
{'fraction_non_alphanumeric': 0.12110726643598616, 'fraction_numerical': 0.001628332994097293, 'mean_word_length': 2.407766990291262, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3006986', 'n_tokens_mistral': 1495, 'n_tokens_neox': 1457, 'n_words': 298}