index.js
3.2 KB
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
var e = require("../common/component"), t = require("./props");
(0, e.VantComponent)({
field: !0,
classes: [ "input-class", "right-icon-class" ],
props: Object.assign(Object.assign(Object.assign(Object.assign({}, t.commonProps), t.inputProps), t.textareaProps), {
size: String,
icon: String,
label: String,
error: Boolean,
center: Boolean,
isLink: Boolean,
leftIcon: String,
rightIcon: String,
autosize: [ Boolean, Object ],
readonly: {
type: Boolean,
observer: "setShowClear"
},
required: Boolean,
iconClass: String,
clearable: {
type: Boolean,
observer: "setShowClear"
},
clickable: Boolean,
inputAlign: String,
customStyle: String,
errorMessage: String,
arrowDirection: String,
showWordLimit: Boolean,
errorMessageAlign: String,
border: {
type: Boolean,
value: !0
},
titleWidth: {
type: String,
value: "90px"
}
}),
data: {
focused: !1,
innerValue: "",
showClear: !1
},
created: function() {
this.value = this.data.value, this.setData({
innerValue: this.value
});
},
methods: {
onInput: function(e) {
var t = (e.detail || {}).value, i = void 0 === t ? "" : t;
this.value = i, this.setShowClear(), this.emitChange();
},
onFocus: function(e) {
this.focused = !0, this.setShowClear(), this.$emit("focus", e.detail);
},
onBlur: function(e) {
this.focused = !1, this.setShowClear(), this.$emit("blur", e.detail);
},
onClickIcon: function() {
this.$emit("click-icon");
},
onClear: function() {
var e = this;
this.setData({
innerValue: ""
}), this.value = "", this.setShowClear(), wx.nextTick(function() {
e.emitChange(), e.$emit("clear", "");
});
},
onConfirm: function(e) {
var t = (e.detail || {}).value, i = void 0 === t ? "" : t;
this.value = i, this.setShowClear(), this.$emit("confirm", i);
},
setValue: function(e) {
this.value = e, this.setShowClear(), "" === e && this.setData({
innerValue: ""
}), this.emitChange();
},
onLineChange: function(e) {
this.$emit("linechange", e.detail);
},
onKeyboardHeightChange: function(e) {
this.$emit("keyboardheightchange", e.detail);
},
emitChange: function() {
var e = this;
this.setData({
value: this.value
}), wx.nextTick(function() {
e.$emit("input", e.value), e.$emit("change", e.value);
});
},
setShowClear: function() {
var e = this.data, t = e.clearable, i = e.readonly, n = this.focused, a = this.value;
this.setData({
showClear: !(!t || !n || !a || i)
});
},
noop: function() {}
}
});