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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
  | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 
 |      var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 
 |      if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 
 |      else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 
 |      return c > 3 && r && Object.defineProperty(target, key, r), r; 
 |  }; 
 |  import { SuperComponent, wxComponent } from '../common/src/index'; 
 |  import config from '../common/config'; 
 |  import props from './props'; 
 |  import { getCharacterLength, calcIcon, isDef } from '../common/utils'; 
 |  const { prefix } = config; 
 |  const name = `${prefix}-input`; 
 |  let Input = class Input extends SuperComponent { 
 |      constructor() { 
 |          super(...arguments); 
 |          this.options = { 
 |              multipleSlots: true, 
 |          }; 
 |          this.externalClasses = [ 
 |              `${prefix}-class`, 
 |              `${prefix}-class-prefix-icon`, 
 |              `${prefix}-class-label`, 
 |              `${prefix}-class-input`, 
 |              `${prefix}-class-clearable`, 
 |              `${prefix}-class-suffix`, 
 |              `${prefix}-class-suffix-icon`, 
 |              `${prefix}-class-tips`, 
 |          ]; 
 |          this.behaviors = ['wx://form-field']; 
 |          this.properties = props; 
 |          this.data = { 
 |              prefix, 
 |              classPrefix: name, 
 |              classBasePrefix: prefix, 
 |              showClearIcon: true, 
 |          }; 
 |          this.lifetimes = { 
 |              ready() { 
 |                  const { value } = this.properties; 
 |                  this.updateValue(value !== null && value !== void 0 ? value : ''); 
 |              }, 
 |          }; 
 |          this.observers = { 
 |              prefixIcon(v) { 
 |                  this.setData({ 
 |                      _prefixIcon: calcIcon(v), 
 |                  }); 
 |              }, 
 |              suffixIcon(v) { 
 |                  this.setData({ 
 |                      _suffixIcon: calcIcon(v), 
 |                  }); 
 |              }, 
 |              clearable(v) { 
 |                  this.setData({ 
 |                      _clearIcon: calcIcon(v, 'close-circle-filled'), 
 |                  }); 
 |              }, 
 |              clearTrigger() { 
 |                  this.updateClearIconVisible(); 
 |              }, 
 |          }; 
 |          this.methods = { 
 |              updateValue(value) { 
 |                  const { maxcharacter, maxlength } = this.properties; 
 |                  if (maxcharacter && maxcharacter > 0 && !Number.isNaN(maxcharacter)) { 
 |                      const { length, characters } = getCharacterLength('maxcharacter', value, maxcharacter); 
 |                      this.setData({ 
 |                          value: characters, 
 |                          count: length, 
 |                      }); 
 |                  } 
 |                  else if (maxlength && maxlength > 0 && !Number.isNaN(maxlength)) { 
 |                      const { length, characters } = getCharacterLength('maxlength', value, maxlength); 
 |                      this.setData({ 
 |                          value: characters, 
 |                          count: length, 
 |                      }); 
 |                  } 
 |                  else { 
 |                      this.setData({ 
 |                          value, 
 |                          count: isDef(value) ? String(value).length : 0, 
 |                      }); 
 |                  } 
 |              }, 
 |              updateClearIconVisible(value = false) { 
 |                  const { clearTrigger } = this.properties; 
 |                  this.setData({ showClearIcon: value || clearTrigger === 'always' }); 
 |              }, 
 |              onInput(e) { 
 |                  const { value, cursor, keyCode } = e.detail; 
 |                  this.updateValue(value); 
 |                  this.triggerEvent('change', { value: this.data.value, cursor, keyCode }); 
 |              }, 
 |              onFocus(e) { 
 |                  this.updateClearIconVisible(true); 
 |                  this.triggerEvent('focus', e.detail); 
 |              }, 
 |              onBlur(e) { 
 |                  this.updateClearIconVisible(); 
 |                  this.triggerEvent('blur', e.detail); 
 |              }, 
 |              onConfirm(e) { 
 |                  this.triggerEvent('enter', e.detail); 
 |              }, 
 |              onSuffixClick() { 
 |                  this.triggerEvent('click', { trigger: 'suffix' }); 
 |              }, 
 |              onSuffixIconClick() { 
 |                  this.triggerEvent('click', { trigger: 'suffix-icon' }); 
 |              }, 
 |              clearInput(e) { 
 |                  this.triggerEvent('clear', e.detail); 
 |                  this.setData({ value: '' }); 
 |              }, 
 |              onKeyboardHeightChange(e) { 
 |                  this.triggerEvent('keyboardheightchange', e.detail); 
 |              }, 
 |              onNickNameReview(e) { 
 |                  this.triggerEvent('nicknamereview', e.detail); 
 |              }, 
 |          }; 
 |      } 
 |  }; 
 |  Input = __decorate([ 
 |      wxComponent() 
 |  ], Input); 
 |  export default Input; 
 |  
  |