all files / addon/components/ el-input.js

0% Statements 0/11
0% Branches 0/18
0% Functions 0/7
0% Lines 0/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84                                                                                                                                                                       
import Component from '@ember/component';
import layout from '../templates/components/el-input';
import {computed, get, set} from "@ember/object";
 
export default Component.extend({
  layout,
  value: null,
  size: null,
  resize: null,
  disabled: false,
  readonly: false,
  type: 'text',
  autosize: false,
  autocomplete: 'off',
  validateEvent: true,
  suffixIcon: null,
  prefixIcon: null,
  label: null,
  clearable: false,
  tabindex: '',
  placeholder: '',
  prepend: null,
  append: null,
  customClass: '',
 
  _isGroup: computed('prepend', 'append', function () {
    return !!(get(this, 'prepend') || get(this, 'append'));
  }),
 
  _isPrefix: computed('prefix', 'prefixIcon', function () {
    return !!(get(this, 'prefix') || get(this, 'prefixIcon'));
  }),
 
  _isSuffix: computed('suffix', 'suffixIcon', function () {
    return !!(get(this, 'suffix') || get(this, 'suffixIcon'));
  }),
 
 
  showClear: computed('clearable', 'disabled', 'readonly', 'value', function () {
    return this.get('clearable') &&
      !this.get('disabled') &&
      !this.get('readonly') &&
      this.get('value') !== ''
  }),
 
 
  _isShowSuffixIcon: computed('suffixIcon', 'showClear', 'validateState', 'needStatusIcon', function () {
    return !!(get(this, 'suffixIcon') || get(this, 'showClear') || (get(this, 'validateState') && get(this, 'needStatusIcon')));
  }),
 
 
  classNameBindings: ['getClassName',
    'disabled:is-disabled',
    '_isGroup:el-input-group',
    '_isPrefix:el-input--prefix',
    '_isSuffix:el-input--suffix',
    'append:el-input-group--append',
    'prepend:el-input-group--prepend',
  ],
 
 
  getClassName: computed('type', 'size', function () {
 
    let classNames = '';
 
    classNames += get(this, 'type') === 'textarea' ? 'el-textarea' : 'el-input';
 
    if (get(this, 'size')) {
      classNames += ` el-input--${get(this, 'size')}`;
    }
 
    return classNames;
  }),
 
  actions: {
    clear() {
      set(this, 'value', '');
    }
  }
 
 
});