|  | @@ -1,14 +1,15 @@
 | 
	
		
			
				|  |  |  <template lang="pug">
 | 
	
		
			
				|  |  | -    .input-group
 | 
	
		
			
				|  |  | -        .input-group-button(v-if='withPrefix')
 | 
	
		
			
				|  |  | -            button(type='button') {{ prefix }}
 | 
	
		
			
				|  |  | -        input.form-input(type='text' v-model='formattedValue' :style="{'width': withPrefix || withSuffix ? '88%' : '100%'}")
 | 
	
		
			
				|  |  | -        .input-group-button(v-if='withSuffix')
 | 
	
		
			
				|  |  | -            button(type='button' @click='onShowSuffixOptions' ref='suffixButton') {{ suffix }}
 | 
	
		
			
				|  |  | -                span.caret(:style="{'display': withSuffixOptions() ? 'none' : 'inline-block'}")
 | 
	
		
			
				|  |  | -            ul.dropdown(:style="{'display': isShowSuffixOptions ? 'block' : 'none'}" ref='suffixDropdown')
 | 
	
		
			
				|  |  | -                li(v-for='option in suffixOptions' :key='option.id')
 | 
	
		
			
				|  |  | -                    a(@click='onClickSuffixOption(option)') {{ option.name }}
 | 
	
		
			
				|  |  | +    div
 | 
	
		
			
				|  |  | +        .input-group
 | 
	
		
			
				|  |  | +            .input-group-button(v-if='hasPrefix()')
 | 
	
		
			
				|  |  | +                button(type='button') {{ prefix }}
 | 
	
		
			
				|  |  | +            input.input-formatted(type='text' v-model='formattedValue' :disabled='!editable' :autofocus='focus')
 | 
	
		
			
				|  |  | +            .input-group-button(v-if='hasSuffix()')
 | 
	
		
			
				|  |  | +                button(type='button' @click='onShowOptions()' ref='suffixButton') {{ suffix }}
 | 
	
		
			
				|  |  | +                    span.caret(:style="{'display': hasOptions() ? 'inline-block' : 'none'}")
 | 
	
		
			
				|  |  | +                ul.dropdown(:style="{'display': isShowOptions ? 'block' : 'none'}" ref='suffixDropdown')
 | 
	
		
			
				|  |  | +                    li(v-for='(option, index) in options' :key='index')
 | 
	
		
			
				|  |  | +                        a(@click='onClickOption(option)') {{ option }}
 | 
	
		
			
				|  |  |  </template>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  <script>
 | 
	
	
		
			
				|  | @@ -22,7 +23,11 @@
 | 
	
		
			
				|  |  |                  type: String,
 | 
	
		
			
				|  |  |                  default: 'text'
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  | -            withPrefix: {
 | 
	
		
			
				|  |  | +            editable: {
 | 
	
		
			
				|  |  | +                type: Boolean,
 | 
	
		
			
				|  |  | +                default: true
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  | +            focus: {
 | 
	
		
			
				|  |  |                  type: Boolean,
 | 
	
		
			
				|  |  |                  default: false
 | 
	
		
			
				|  |  |              },
 | 
	
	
		
			
				|  | @@ -30,19 +35,11 @@
 | 
	
		
			
				|  |  |                  type: String,
 | 
	
		
			
				|  |  |                  default: ''
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  | -            prefixOptions: {
 | 
	
		
			
				|  |  | -                type: Array,
 | 
	
		
			
				|  |  | -                default: []
 | 
	
		
			
				|  |  | -            },
 | 
	
		
			
				|  |  | -            withSuffix: {
 | 
	
		
			
				|  |  | -                type: Boolean,
 | 
	
		
			
				|  |  | -                default: false
 | 
	
		
			
				|  |  | -            },
 | 
	
		
			
				|  |  |              suffix: {
 | 
	
		
			
				|  |  |                  type: String,
 | 
	
		
			
				|  |  |                  default: ''
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  | -            suffixOptions: {
 | 
	
		
			
				|  |  | +            options: {
 | 
	
		
			
				|  |  |                  type: Array,
 | 
	
		
			
				|  |  |                  default: []
 | 
	
		
			
				|  |  |              }
 | 
	
	
		
			
				|  | @@ -50,10 +47,10 @@
 | 
	
		
			
				|  |  |          computed: {
 | 
	
		
			
				|  |  |              formattedValue: {
 | 
	
		
			
				|  |  |                  get() {
 | 
	
		
			
				|  |  | -                    let value = ''
 | 
	
		
			
				|  |  | +                    let value = this.value
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      if (this.format === 'number') {
 | 
	
		
			
				|  |  | -                        value = this.formatValue(this.value)
 | 
	
		
			
				|  |  | +                        value = this.formatValue(value)
 | 
	
		
			
				|  |  |                          value = !!this.value ? value : value.replace(/\d/, '')
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -66,7 +63,7 @@
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      this.value = value
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                    this.onChange(value)
 | 
	
		
			
				|  |  | +                    this.onChangeValue(value)
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          },
 | 
	
	
		
			
				|  | @@ -111,24 +108,27 @@
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  return value
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  | -            onChange(data) {
 | 
	
		
			
				|  |  | -                this.$emit('onChange', data)
 | 
	
		
			
				|  |  | +            hideOptions() {
 | 
	
		
			
				|  |  | +                this.isShowOptions = false
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  | -            hideSuffixOptions() {
 | 
	
		
			
				|  |  | -                this.isShowSuffixOptions = false
 | 
	
		
			
				|  |  | +            onChangeValue(value) {
 | 
	
		
			
				|  |  | +                this.$emit('onChangeValue', value)
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  | -            withPrefixOptions() {
 | 
	
		
			
				|  |  | -                return this.prefixOptions.length == 0
 | 
	
		
			
				|  |  | +            hasPrefix() {
 | 
	
		
			
				|  |  | +                return this.prefix.length !== 0
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  | -            withSuffixOptions() {
 | 
	
		
			
				|  |  | -                return this.suffixOptions.length == 0
 | 
	
		
			
				|  |  | +            hasSuffix() {
 | 
	
		
			
				|  |  | +                return this.suffix.length !== 0
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  | -            onShowSuffixOptions() {
 | 
	
		
			
				|  |  | -                if (this.withSuffixOptions()) {
 | 
	
		
			
				|  |  | +            hasOptions() {
 | 
	
		
			
				|  |  | +                return this.options.length !== 0
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  | +            onShowOptions() {
 | 
	
		
			
				|  |  | +                if (!this.hasOptions()) {
 | 
	
		
			
				|  |  |                      return
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                this.isShowSuffixOptions = !this.isShowSuffixOptions
 | 
	
		
			
				|  |  | +                
 | 
	
		
			
				|  |  | +                this.isShowOptions = !this.isShowOptions
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  |              onClickOutside(e) {
 | 
	
		
			
				|  |  |                  let suffixButton = this.$refs.suffixButton
 | 
	
	
		
			
				|  | @@ -146,12 +146,12 @@
 | 
	
		
			
				|  |  |                  let el = this.$refs.suffixDropdown
 | 
	
		
			
				|  |  |                  
 | 
	
		
			
				|  |  |                  if (el !== target && !el.contains(target)) {
 | 
	
		
			
				|  |  | -                    this.hideSuffixOptions()
 | 
	
		
			
				|  |  | +                    this.hideOptions()
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  | -            onClickSuffixOption(suffixOption) {
 | 
	
		
			
				|  |  | -                this.hideSuffixOptions()
 | 
	
		
			
				|  |  | -                this.$emit('onSuffix', suffixOption)
 | 
	
		
			
				|  |  | +            onClickOption(selectedOption) {
 | 
	
		
			
				|  |  | +                this.hideOptions()
 | 
	
		
			
				|  |  | +                this.$emit('onClickOption', selectedOption)
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          },
 | 
	
		
			
				|  |  |          created() {
 | 
	
	
		
			
				|  | @@ -163,7 +163,7 @@
 | 
	
		
			
				|  |  |          data() {
 | 
	
		
			
				|  |  |              return {
 | 
	
		
			
				|  |  |                  value: '',
 | 
	
		
			
				|  |  | -                isShowSuffixOptions: false
 | 
	
		
			
				|  |  | +                isShowOptions: false
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -172,9 +172,10 @@
 | 
	
		
			
				|  |  |  <style lang="sass">
 | 
	
		
			
				|  |  |      .input-group
 | 
	
		
			
				|  |  |          position: relative
 | 
	
		
			
				|  |  | +        width: 100%
 | 
	
		
			
				|  |  |          display: table
 | 
	
		
			
				|  |  |          border-collapse: separate
 | 
	
		
			
				|  |  | -        .form-input
 | 
	
		
			
				|  |  | +        .input-formatted
 | 
	
		
			
				|  |  |              position: relative
 | 
	
		
			
				|  |  |              width: 100%
 | 
	
		
			
				|  |  |              height: 35px
 | 
	
	
		
			
				|  | @@ -184,7 +185,6 @@
 | 
	
		
			
				|  |  |              margin-bottom: 0
 | 
	
		
			
				|  |  |              border-radius: 0
 | 
	
		
			
				|  |  |              font-size: 12pt
 | 
	
		
			
				|  |  | -            line-height: 1.42857143
 | 
	
		
			
				|  |  |              padding: 6px 12px
 | 
	
		
			
				|  |  |              &:focus
 | 
	
		
			
				|  |  |                  z-index: 3
 | 
	
	
		
			
				|  | @@ -223,7 +223,7 @@
 | 
	
		
			
				|  |  |                      display: inline-block
 | 
	
		
			
				|  |  |                      width: 0
 | 
	
		
			
				|  |  |                      height: 0
 | 
	
		
			
				|  |  | -                    margin-left: 2px
 | 
	
		
			
				|  |  | +                    margin-left: 0
 | 
	
		
			
				|  |  |                      vertical-align: middle
 | 
	
		
			
				|  |  |                      border-top: 4px dashed
 | 
	
		
			
				|  |  |                      border-right: 4px solid transparent
 | 
	
	
		
			
				|  | @@ -243,6 +243,7 @@
 | 
	
		
			
				|  |  |                  padding: 5px 0
 | 
	
		
			
				|  |  |                  margin: 2px 0 0
 | 
	
		
			
				|  |  |                  z-index: 1000
 | 
	
		
			
				|  |  | +                font-size: 10pt
 | 
	
		
			
				|  |  |                  & > li > a
 | 
	
		
			
				|  |  |                      height: 35px
 | 
	
		
			
				|  |  |                      display: block
 |