@vtj/materials 0.10.1-alpha.6 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/antdv/index.umd.js +2 -2
- package/dist/assets/charts/index.umd.js +2 -2
- package/dist/assets/element/index.umd.js +2 -2
- package/dist/assets/ui/index.umd.js +2 -2
- package/dist/assets/uni-h5/index.umd.js +2 -2
- package/dist/assets/uni-ui/index.umd.js +3 -3
- package/dist/assets/vant/index.umd.js +5 -5
- package/dist/deps/@vtj/charts/index.umd.js +2 -2
- package/dist/deps/@vtj/icons/index.umd.js +2 -2
- package/dist/deps/@vtj/ui/index.umd.js +2 -2
- package/dist/deps/@vtj/utils/index.umd.js +2 -2
- package/dist/deps/uni-ui/index.umd.js +1 -1
- package/dist/deps/uni-ui/style.css +1 -1
- package/package.json +6 -6
- package/src/uni-ui/components/badge.ts +5 -1
- package/src/uni-ui/components/breadcrumb.ts +76 -0
- package/src/uni-ui/components/calendar.ts +63 -0
- package/src/uni-ui/components/card.ts +113 -0
- package/src/uni-ui/components/collapse.ts +118 -0
- package/src/uni-ui/components/combox.ts +51 -0
- package/src/uni-ui/components/countdown.ts +92 -0
- package/src/uni-ui/components/dataCheckbox.ts +104 -0
- package/src/uni-ui/components/dataPicker.ts +146 -0
- package/src/uni-ui/components/dataSelect.ts +68 -0
- package/src/uni-ui/components/dateformat.ts +42 -0
- package/src/uni-ui/components/datetimePicker.ts +103 -0
- package/src/uni-ui/components/drawer.ts +38 -0
- package/src/uni-ui/components/easyinput.ts +159 -0
- package/src/uni-ui/components/fab.ts +89 -0
- package/src/uni-ui/components/fav.ts +65 -0
- package/src/uni-ui/components/filePicker.ts +127 -0
- package/src/uni-ui/components/forms.ts +209 -0
- package/src/uni-ui/components/goodsNav.ts +31 -0
- package/src/uni-ui/components/grid.ts +104 -0
- package/src/uni-ui/components/group.ts +50 -0
- package/src/uni-ui/components/icons.ts +47 -0
- package/src/uni-ui/components/index.ts +89 -1
- package/src/uni-ui/components/indexedList.ts +51 -0
- package/src/uni-ui/components/link.ts +60 -0
- package/src/uni-ui/components/list.ts +259 -0
- package/src/uni-ui/components/loadMore.ts +61 -0
- package/src/uni-ui/components/navbar.ts +121 -0
- package/src/uni-ui/components/noticeBar.ts +83 -0
- package/src/uni-ui/components/numberbox.ts +49 -0
- package/src/uni-ui/components/pagination.ts +59 -0
- package/src/uni-ui/components/popup.ts +206 -0
- package/src/uni-ui/components/rate.ts +89 -0
- package/src/uni-ui/components/row.ts +126 -0
- package/src/uni-ui/components/searchBar.ts +84 -0
- package/src/uni-ui/components/section.ts +68 -0
- package/src/uni-ui/components/segmentedControl.ts +48 -0
- package/src/uni-ui/components/steps.ts +55 -0
- package/src/uni-ui/components/swipeAction.ts +133 -0
- package/src/uni-ui/components/swiperDot.ts +114 -0
- package/src/uni-ui/components/table.ts +132 -0
- package/src/uni-ui/components/tag.ts +56 -0
- package/src/uni-ui/components/title.ts +49 -0
- package/src/uni-ui/components/tooltip.ts +32 -0
- package/src/uni-ui/components/transition.ts +49 -0
- package/src/uni-ui/index.ts +30 -13
- package/src/uni-ui/lib/uni-col/uni-col.vue +324 -0
- package/src/uni-ui/lib/uni-data-select/uni-data-select.vue +590 -0
- package/src/uni-ui/lib/uni-datetime-picker/calendar-item.vue +177 -177
- package/src/uni-ui/lib/uni-datetime-picker/calendar.vue +947 -947
- package/src/uni-ui/lib/uni-datetime-picker/i18n/en.json +22 -22
- package/src/uni-ui/lib/uni-datetime-picker/i18n/index.js +7 -7
- package/src/uni-ui/lib/uni-datetime-picker/time-picker.vue +939 -939
- package/src/uni-ui/lib/uni-datetime-picker/util.js +419 -419
- package/src/uni-ui/lib/uni-easyinput/common.js +54 -0
- package/src/uni-ui/lib/uni-easyinput/uni-easyinput.vue +790 -0
- package/src/uni-ui/lib/uni-forms/uni-forms.vue +416 -416
- package/src/uni-ui/lib/uni-forms/utils.js +281 -281
- package/src/uni-ui/lib/uni-forms/validate.js +485 -485
- package/src/uni-ui/lib/uni-forms-item/uni-forms-item.vue +630 -0
- package/src/uni-ui/lib/uni-goods-nav/i18n/en.json +6 -0
- package/src/uni-ui/lib/uni-goods-nav/i18n/index.js +8 -0
- package/src/uni-ui/lib/uni-goods-nav/i18n/zh-Hans.json +6 -0
- package/src/uni-ui/lib/uni-goods-nav/i18n/zh-Hant.json +6 -0
- package/src/uni-ui/lib/uni-goods-nav/uni-goods-nav.vue +231 -0
- package/src/uni-ui/lib/uni-icons/uni-icons.uvue +91 -0
- package/src/uni-ui/lib/uni-icons/uni-icons.vue +114 -0
- package/src/uni-ui/lib/uni-icons/uniicons.css +664 -0
- package/src/uni-ui/lib/uni-icons/uniicons.ttf +0 -0
- package/src/uni-ui/lib/uni-icons/uniicons_file.ts +664 -0
- package/src/uni-ui/lib/uni-icons/uniicons_file_vue.js +649 -0
- package/src/uni-ui/lib/uni-indexed-list/uni-indexed-list-item.vue +144 -0
- package/src/uni-ui/lib/uni-indexed-list/uni-indexed-list.vue +404 -0
- package/src/uni-ui/lib/uni-list/uni-list.vue +123 -0
- package/src/uni-ui/lib/uni-list/uni-refresh.vue +65 -0
- package/src/uni-ui/lib/uni-list/uni-refresh.wxs +87 -0
- package/src/uni-ui/lib/uni-popup-dialog/keypress.js +45 -0
- package/src/uni-ui/lib/uni-popup-dialog/uni-popup-dialog.vue +324 -0
- package/src/uni-ui/lib/uni-rate/uni-rate.vue +361 -0
- package/src/uni-ui/lib/uni-table/uni-table.vue +496 -0
- package/src/uni-ui/lib/uni-td/uni-td.vue +99 -0
- package/src/uni-ui/lib/uni-th/uni-th.vue +310 -283
- package/src/uni-ui/lib/uni-tr/uni-tr.vue +194 -170
- package/src/version.ts +2 -2
@@ -0,0 +1,790 @@
|
|
1
|
+
<template>
|
2
|
+
<view
|
3
|
+
class="uni-easyinput"
|
4
|
+
:class="{ 'uni-easyinput-error': msg }"
|
5
|
+
:style="boxStyle">
|
6
|
+
<view
|
7
|
+
class="uni-easyinput__content"
|
8
|
+
:class="inputContentClass"
|
9
|
+
:style="inputContentStyle">
|
10
|
+
<uni-icons
|
11
|
+
v-if="prefixIcon"
|
12
|
+
class="content-clear-icon"
|
13
|
+
:type="prefixIcon"
|
14
|
+
color="#c0c4cc"
|
15
|
+
@click="onClickIcon('prefix')"
|
16
|
+
size="22"></uni-icons>
|
17
|
+
<slot name="left"> </slot>
|
18
|
+
<!-- #ifdef MP-ALIPAY -->
|
19
|
+
<!-- <textarea
|
20
|
+
:enableNative="enableNative"
|
21
|
+
v-if="type === 'textarea'"
|
22
|
+
class="uni-easyinput__content-textarea"
|
23
|
+
:class="{ 'input-padding': inputBorder }"
|
24
|
+
:name="name"
|
25
|
+
:value="val"
|
26
|
+
:placeholder="placeholder"
|
27
|
+
:placeholderStyle="placeholderStyle"
|
28
|
+
:disabled="disabled"
|
29
|
+
placeholder-class="uni-easyinput__placeholder-class"
|
30
|
+
:maxlength="inputMaxlength"
|
31
|
+
:focus="focused"
|
32
|
+
:autoHeight="autoHeight"
|
33
|
+
:cursor-spacing="cursorSpacing"
|
34
|
+
:adjust-position="adjustPosition"
|
35
|
+
@input="onInput"
|
36
|
+
@blur="_Blur"
|
37
|
+
@focus="_Focus"
|
38
|
+
@confirm="onConfirm"
|
39
|
+
@keyboardheightchange="onkeyboardheightchange"></textarea>
|
40
|
+
<input
|
41
|
+
:enableNative="enableNative"
|
42
|
+
v-else
|
43
|
+
:type="type === 'password' ? 'text' : type"
|
44
|
+
class="uni-easyinput__content-input"
|
45
|
+
:style="inputStyle"
|
46
|
+
:name="name"
|
47
|
+
:value="val"
|
48
|
+
:password="!showPassword && type === 'password'"
|
49
|
+
:placeholder="placeholder"
|
50
|
+
:placeholderStyle="placeholderStyle"
|
51
|
+
placeholder-class="uni-easyinput__placeholder-class"
|
52
|
+
:disabled="disabled"
|
53
|
+
:maxlength="inputMaxlength"
|
54
|
+
:focus="focused"
|
55
|
+
:confirmType="confirmType"
|
56
|
+
:cursor-spacing="cursorSpacing"
|
57
|
+
:adjust-position="adjustPosition"
|
58
|
+
@focus="_Focus"
|
59
|
+
@blur="_Blur"
|
60
|
+
@input="onInput"
|
61
|
+
@confirm="onConfirm"
|
62
|
+
@keyboardheightchange="onkeyboardheightchange" /> -->
|
63
|
+
<!-- #endif -->
|
64
|
+
<!-- #ifndef MP-ALIPAY -->
|
65
|
+
<textarea
|
66
|
+
v-if="type === 'textarea'"
|
67
|
+
class="uni-easyinput__content-textarea"
|
68
|
+
:class="{ 'input-padding': inputBorder }"
|
69
|
+
:name="name"
|
70
|
+
:value="val"
|
71
|
+
:placeholder="placeholder"
|
72
|
+
:placeholderStyle="placeholderStyle"
|
73
|
+
:disabled="disabled"
|
74
|
+
placeholder-class="uni-easyinput__placeholder-class"
|
75
|
+
:maxlength="inputMaxlength"
|
76
|
+
:focus="focused"
|
77
|
+
:autoHeight="autoHeight"
|
78
|
+
:cursor-spacing="cursorSpacing"
|
79
|
+
:adjust-position="adjustPosition"
|
80
|
+
@input="onInput"
|
81
|
+
@blur="_Blur"
|
82
|
+
@focus="_Focus"
|
83
|
+
@confirm="onConfirm"
|
84
|
+
@keyboardheightchange="onkeyboardheightchange"></textarea>
|
85
|
+
<input
|
86
|
+
v-else
|
87
|
+
:type="type === 'password' ? 'text' : type"
|
88
|
+
class="uni-easyinput__content-input"
|
89
|
+
:style="inputStyle"
|
90
|
+
:name="name"
|
91
|
+
:value="val"
|
92
|
+
:password="!showPassword && type === 'password'"
|
93
|
+
:placeholder="placeholder"
|
94
|
+
:placeholderStyle="placeholderStyle"
|
95
|
+
placeholder-class="uni-easyinput__placeholder-class"
|
96
|
+
:disabled="disabled"
|
97
|
+
:maxlength="inputMaxlength"
|
98
|
+
:focus="focused"
|
99
|
+
:confirmType="confirmType"
|
100
|
+
:cursor-spacing="cursorSpacing"
|
101
|
+
:adjust-position="adjustPosition"
|
102
|
+
@focus="_Focus"
|
103
|
+
@blur="_Blur"
|
104
|
+
@input="onInput"
|
105
|
+
@confirm="onConfirm"
|
106
|
+
@keyboardheightchange="onkeyboardheightchange" />
|
107
|
+
<!-- #endif -->
|
108
|
+
|
109
|
+
<template v-if="type === 'password' && passwordIcon">
|
110
|
+
<!-- 开启密码时显示小眼睛 -->
|
111
|
+
<uni-icons
|
112
|
+
v-if="isVal"
|
113
|
+
class="content-clear-icon"
|
114
|
+
:class="{ 'is-textarea-icon': type === 'textarea' }"
|
115
|
+
:type="showPassword ? 'eye-slash-filled' : 'eye-filled'"
|
116
|
+
:size="22"
|
117
|
+
:color="focusShow ? primaryColor : '#c0c4cc'"
|
118
|
+
@click="onEyes"></uni-icons>
|
119
|
+
</template>
|
120
|
+
<template v-if="suffixIcon">
|
121
|
+
<uni-icons
|
122
|
+
v-if="suffixIcon"
|
123
|
+
class="content-clear-icon"
|
124
|
+
:type="suffixIcon"
|
125
|
+
color="#c0c4cc"
|
126
|
+
@click="onClickIcon('suffix')"
|
127
|
+
size="22"></uni-icons>
|
128
|
+
</template>
|
129
|
+
<template v-else>
|
130
|
+
<uni-icons
|
131
|
+
v-if="clearable && isVal && !disabled && type !== 'textarea'"
|
132
|
+
class="content-clear-icon"
|
133
|
+
:class="{ 'is-textarea-icon': type === 'textarea' }"
|
134
|
+
type="clear"
|
135
|
+
:size="clearSize"
|
136
|
+
:color="msg ? '#dd524d' : focusShow ? primaryColor : '#c0c4cc'"
|
137
|
+
@click="onClear"></uni-icons>
|
138
|
+
</template>
|
139
|
+
<slot name="right"></slot>
|
140
|
+
</view>
|
141
|
+
</view>
|
142
|
+
</template>
|
143
|
+
|
144
|
+
<script>
|
145
|
+
/**
|
146
|
+
* Easyinput 输入框
|
147
|
+
* @description 此组件可以实现表单的输入与校验,包括 "text" 和 "textarea" 类型。
|
148
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=3455
|
149
|
+
* @property {String} value 输入内容
|
150
|
+
* @property {String } type 输入框的类型(默认text) password/text/textarea/..
|
151
|
+
* @value text 文本输入键盘
|
152
|
+
* @value textarea 多行文本输入键盘
|
153
|
+
* @value password 密码输入键盘
|
154
|
+
* @value number 数字输入键盘,注意iOS上app-vue弹出的数字键盘并非9宫格方式
|
155
|
+
* @value idcard 身份证输入键盘,信、支付宝、百度、QQ小程序
|
156
|
+
* @value digit 带小数点的数字键盘 ,App的nvue页面、微信、支付宝、百度、头条、QQ小程序支持
|
157
|
+
* @property {Boolean} clearable 是否显示右侧清空内容的图标控件,点击可清空输入框内容(默认true)
|
158
|
+
* @property {Boolean} autoHeight 是否自动增高输入区域,type为textarea时有效(默认true)
|
159
|
+
* @property {String } placeholder 输入框的提示文字
|
160
|
+
* @property {String } placeholderStyle placeholder的样式(内联样式,字符串),如"color: #ddd"
|
161
|
+
* @property {Boolean} focus 是否自动获得焦点(默认false)
|
162
|
+
* @property {Boolean} disabled 是否禁用(默认false)
|
163
|
+
* @property {Number } maxlength 最大输入长度,设置为 -1 的时候不限制最大长度(默认140)
|
164
|
+
* @property {String } confirmType 设置键盘右下角按钮的文字,仅在type="text"时生效(默认done)
|
165
|
+
* @property {Number } clearSize 清除图标的大小,单位px(默认15)
|
166
|
+
* @property {String} prefixIcon 输入框头部图标
|
167
|
+
* @property {String} suffixIcon 输入框尾部图标
|
168
|
+
* @property {String} primaryColor 设置主题色(默认#2979ff)
|
169
|
+
* @property {Boolean} trim 是否自动去除两端的空格
|
170
|
+
* @property {Boolean} cursorSpacing 指定光标与键盘的距离,单位 px
|
171
|
+
* @property {Boolean} ajust-position 当键盘弹起时,是否上推内容,默认值:true
|
172
|
+
* @value both 去除两端空格
|
173
|
+
* @value left 去除左侧空格
|
174
|
+
* @value right 去除右侧空格
|
175
|
+
* @value start 去除左侧空格
|
176
|
+
* @value end 去除右侧空格
|
177
|
+
* @value all 去除全部空格
|
178
|
+
* @value none 不去除空格
|
179
|
+
* @property {Boolean} inputBorder 是否显示input输入框的边框(默认true)
|
180
|
+
* @property {Boolean} passwordIcon type=password时是否显示小眼睛图标
|
181
|
+
* @property {Object} styles 自定义颜色
|
182
|
+
* @event {Function} input 输入框内容发生变化时触发
|
183
|
+
* @event {Function} focus 输入框获得焦点时触发
|
184
|
+
* @event {Function} blur 输入框失去焦点时触发
|
185
|
+
* @event {Function} confirm 点击完成按钮时触发
|
186
|
+
* @event {Function} iconClick 点击图标时触发
|
187
|
+
* @example <uni-easyinput v-model="mobile"></uni-easyinput>
|
188
|
+
*/
|
189
|
+
function obj2strClass(obj) {
|
190
|
+
let classess = '';
|
191
|
+
for (let key in obj) {
|
192
|
+
const val = obj[key];
|
193
|
+
if (val) {
|
194
|
+
classess += `${key} `;
|
195
|
+
}
|
196
|
+
}
|
197
|
+
return classess;
|
198
|
+
}
|
199
|
+
|
200
|
+
function obj2strStyle(obj) {
|
201
|
+
let style = '';
|
202
|
+
for (let key in obj) {
|
203
|
+
const val = obj[key];
|
204
|
+
style += `${key}:${val};`;
|
205
|
+
}
|
206
|
+
return style;
|
207
|
+
}
|
208
|
+
export default {
|
209
|
+
name: 'uni-easyinput',
|
210
|
+
emits: [
|
211
|
+
'click',
|
212
|
+
'iconClick',
|
213
|
+
'update:modelValue',
|
214
|
+
'input',
|
215
|
+
'focus',
|
216
|
+
'blur',
|
217
|
+
'confirm',
|
218
|
+
'clear',
|
219
|
+
'eyes',
|
220
|
+
'change',
|
221
|
+
'keyboardheightchange'
|
222
|
+
],
|
223
|
+
model: {
|
224
|
+
prop: 'modelValue',
|
225
|
+
event: 'update:modelValue'
|
226
|
+
},
|
227
|
+
options: {
|
228
|
+
// #ifdef MP-TOUTIAO
|
229
|
+
virtualHost: false,
|
230
|
+
// #endif
|
231
|
+
// #ifndef MP-TOUTIAO
|
232
|
+
virtualHost: true
|
233
|
+
// #endif
|
234
|
+
},
|
235
|
+
inject: {
|
236
|
+
form: {
|
237
|
+
from: 'uniForm',
|
238
|
+
default: null
|
239
|
+
},
|
240
|
+
formItem: {
|
241
|
+
from: 'uniFormItem',
|
242
|
+
default: null
|
243
|
+
}
|
244
|
+
},
|
245
|
+
props: {
|
246
|
+
name: String,
|
247
|
+
value: [Number, String],
|
248
|
+
modelValue: [Number, String],
|
249
|
+
type: {
|
250
|
+
type: String,
|
251
|
+
default: 'text'
|
252
|
+
},
|
253
|
+
clearable: {
|
254
|
+
type: Boolean,
|
255
|
+
default: true
|
256
|
+
},
|
257
|
+
autoHeight: {
|
258
|
+
type: Boolean,
|
259
|
+
default: false
|
260
|
+
},
|
261
|
+
placeholder: {
|
262
|
+
type: String,
|
263
|
+
default: ' '
|
264
|
+
},
|
265
|
+
placeholderStyle: String,
|
266
|
+
focus: {
|
267
|
+
type: Boolean,
|
268
|
+
default: false
|
269
|
+
},
|
270
|
+
disabled: {
|
271
|
+
type: Boolean,
|
272
|
+
default: false
|
273
|
+
},
|
274
|
+
maxlength: {
|
275
|
+
type: [Number, String],
|
276
|
+
default: 140
|
277
|
+
},
|
278
|
+
confirmType: {
|
279
|
+
type: String,
|
280
|
+
default: 'done'
|
281
|
+
},
|
282
|
+
clearSize: {
|
283
|
+
type: [Number, String],
|
284
|
+
default: 24
|
285
|
+
},
|
286
|
+
inputBorder: {
|
287
|
+
type: Boolean,
|
288
|
+
default: true
|
289
|
+
},
|
290
|
+
prefixIcon: {
|
291
|
+
type: String,
|
292
|
+
default: ''
|
293
|
+
},
|
294
|
+
suffixIcon: {
|
295
|
+
type: String,
|
296
|
+
default: ''
|
297
|
+
},
|
298
|
+
trim: {
|
299
|
+
type: [Boolean, String],
|
300
|
+
default: false
|
301
|
+
},
|
302
|
+
cursorSpacing: {
|
303
|
+
type: Number,
|
304
|
+
default: 0
|
305
|
+
},
|
306
|
+
passwordIcon: {
|
307
|
+
type: Boolean,
|
308
|
+
default: true
|
309
|
+
},
|
310
|
+
adjustPosition: {
|
311
|
+
type: Boolean,
|
312
|
+
default: true
|
313
|
+
},
|
314
|
+
primaryColor: {
|
315
|
+
type: String,
|
316
|
+
default: '#2979ff'
|
317
|
+
},
|
318
|
+
styles: {
|
319
|
+
type: Object,
|
320
|
+
default() {
|
321
|
+
return {
|
322
|
+
color: '#333',
|
323
|
+
backgroundColor: '#fff',
|
324
|
+
disableColor: '#F7F6F6',
|
325
|
+
borderColor: '#e5e5e5'
|
326
|
+
};
|
327
|
+
}
|
328
|
+
},
|
329
|
+
errorMessage: {
|
330
|
+
type: [String, Boolean],
|
331
|
+
default: ''
|
332
|
+
},
|
333
|
+
// #ifdef MP-ALIPAY
|
334
|
+
enableNative: {
|
335
|
+
type: Boolean,
|
336
|
+
default: false
|
337
|
+
}
|
338
|
+
// #endif
|
339
|
+
},
|
340
|
+
data() {
|
341
|
+
return {
|
342
|
+
focused: false,
|
343
|
+
val: '',
|
344
|
+
showMsg: '',
|
345
|
+
border: false,
|
346
|
+
isFirstBorder: false,
|
347
|
+
showClearIcon: false,
|
348
|
+
showPassword: false,
|
349
|
+
focusShow: false,
|
350
|
+
localMsg: '',
|
351
|
+
isEnter: false // 用于判断当前是否是使用回车操作
|
352
|
+
};
|
353
|
+
},
|
354
|
+
computed: {
|
355
|
+
// 输入框内是否有值
|
356
|
+
isVal() {
|
357
|
+
const val = this.val;
|
358
|
+
// fixed by mehaotian 处理值为0的情况,字符串0不在处理范围
|
359
|
+
if (val || val === 0) {
|
360
|
+
return true;
|
361
|
+
}
|
362
|
+
return false;
|
363
|
+
},
|
364
|
+
|
365
|
+
msg() {
|
366
|
+
// console.log('computed', this.form, this.formItem);
|
367
|
+
// if (this.form) {
|
368
|
+
// return this.errorMessage || this.formItem.errMsg;
|
369
|
+
// }
|
370
|
+
// TODO 处理头条 formItem 中 errMsg 不更新的问题
|
371
|
+
return this.localMsg || this.errorMessage;
|
372
|
+
},
|
373
|
+
// 因为uniapp的input组件的maxlength组件必须要数值,这里转为数值,用户可以传入字符串数值
|
374
|
+
inputMaxlength() {
|
375
|
+
return Number(this.maxlength);
|
376
|
+
},
|
377
|
+
|
378
|
+
// 处理外层样式的style
|
379
|
+
boxStyle() {
|
380
|
+
return `color:${
|
381
|
+
this.inputBorder && this.msg ? '#e43d33' : this.styles.color
|
382
|
+
};`;
|
383
|
+
},
|
384
|
+
// input 内容的类和样式处理
|
385
|
+
inputContentClass() {
|
386
|
+
return obj2strClass({
|
387
|
+
'is-input-border': this.inputBorder,
|
388
|
+
'is-input-error-border': this.inputBorder && this.msg,
|
389
|
+
'is-textarea': this.type === 'textarea',
|
390
|
+
'is-disabled': this.disabled,
|
391
|
+
'is-focused': this.focusShow
|
392
|
+
});
|
393
|
+
},
|
394
|
+
inputContentStyle() {
|
395
|
+
const focusColor = this.focusShow
|
396
|
+
? this.primaryColor
|
397
|
+
: this.styles.borderColor;
|
398
|
+
const borderColor =
|
399
|
+
this.inputBorder && this.msg ? '#dd524d' : focusColor;
|
400
|
+
return obj2strStyle({
|
401
|
+
'border-color': borderColor || '#e5e5e5',
|
402
|
+
'background-color': this.disabled
|
403
|
+
? this.styles.disableColor
|
404
|
+
: this.styles.backgroundColor
|
405
|
+
});
|
406
|
+
},
|
407
|
+
// input右侧样式
|
408
|
+
inputStyle() {
|
409
|
+
const paddingRight =
|
410
|
+
this.type === 'password' || this.clearable || this.prefixIcon
|
411
|
+
? ''
|
412
|
+
: '10px';
|
413
|
+
return obj2strStyle({
|
414
|
+
'padding-right': paddingRight,
|
415
|
+
'padding-left': this.prefixIcon ? '' : '10px'
|
416
|
+
});
|
417
|
+
}
|
418
|
+
},
|
419
|
+
watch: {
|
420
|
+
value(newVal) {
|
421
|
+
// fix by mehaotian 解决 值为null的情况下,input报错的bug
|
422
|
+
if (newVal === null) {
|
423
|
+
this.val = '';
|
424
|
+
return;
|
425
|
+
}
|
426
|
+
this.val = newVal;
|
427
|
+
},
|
428
|
+
modelValue(newVal) {
|
429
|
+
if (newVal === null) {
|
430
|
+
this.val = '';
|
431
|
+
return;
|
432
|
+
}
|
433
|
+
this.val = newVal;
|
434
|
+
},
|
435
|
+
focus(newVal) {
|
436
|
+
this.$nextTick(() => {
|
437
|
+
this.focused = this.focus;
|
438
|
+
this.focusShow = this.focus;
|
439
|
+
});
|
440
|
+
}
|
441
|
+
},
|
442
|
+
created() {
|
443
|
+
this.init();
|
444
|
+
// TODO 处理头条vue3 computed 不监听 inject 更改的问题(formItem.errMsg)
|
445
|
+
if (this.form && this.formItem) {
|
446
|
+
this.$watch('formItem.errMsg', (newVal) => {
|
447
|
+
this.localMsg = newVal;
|
448
|
+
});
|
449
|
+
}
|
450
|
+
},
|
451
|
+
mounted() {
|
452
|
+
this.$nextTick(() => {
|
453
|
+
this.focused = this.focus;
|
454
|
+
this.focusShow = this.focus;
|
455
|
+
});
|
456
|
+
},
|
457
|
+
methods: {
|
458
|
+
/**
|
459
|
+
* 初始化变量值
|
460
|
+
*/
|
461
|
+
init() {
|
462
|
+
if (this.value || this.value === 0) {
|
463
|
+
this.val = this.value;
|
464
|
+
} else if (
|
465
|
+
this.modelValue ||
|
466
|
+
this.modelValue === 0 ||
|
467
|
+
this.modelValue === ''
|
468
|
+
) {
|
469
|
+
this.val = this.modelValue;
|
470
|
+
} else {
|
471
|
+
// fix by ht 如果初始值为null,则input报错,待框架修复
|
472
|
+
this.val = '';
|
473
|
+
}
|
474
|
+
},
|
475
|
+
|
476
|
+
/**
|
477
|
+
* 点击图标时触发
|
478
|
+
* @param {Object} type
|
479
|
+
*/
|
480
|
+
onClickIcon(type) {
|
481
|
+
this.$emit('iconClick', type);
|
482
|
+
},
|
483
|
+
|
484
|
+
/**
|
485
|
+
* 显示隐藏内容,密码框时生效
|
486
|
+
*/
|
487
|
+
onEyes() {
|
488
|
+
this.showPassword = !this.showPassword;
|
489
|
+
this.$emit('eyes', this.showPassword);
|
490
|
+
},
|
491
|
+
|
492
|
+
/**
|
493
|
+
* 输入时触发
|
494
|
+
* @param {Object} event
|
495
|
+
*/
|
496
|
+
onInput(event) {
|
497
|
+
let value = event.detail.value;
|
498
|
+
// 判断是否去除空格
|
499
|
+
if (this.trim) {
|
500
|
+
if (typeof this.trim === 'boolean' && this.trim) {
|
501
|
+
value = this.trimStr(value);
|
502
|
+
}
|
503
|
+
if (typeof this.trim === 'string') {
|
504
|
+
value = this.trimStr(value, this.trim);
|
505
|
+
}
|
506
|
+
}
|
507
|
+
if (this.errMsg) this.errMsg = '';
|
508
|
+
this.val = value;
|
509
|
+
// TODO 兼容 vue2
|
510
|
+
this.$emit('input', value);
|
511
|
+
// TODO 兼容 vue3
|
512
|
+
this.$emit('update:modelValue', value);
|
513
|
+
},
|
514
|
+
|
515
|
+
/**
|
516
|
+
* 外部调用方法
|
517
|
+
* 获取焦点时触发
|
518
|
+
* @param {Object} event
|
519
|
+
*/
|
520
|
+
onFocus() {
|
521
|
+
this.$nextTick(() => {
|
522
|
+
this.focused = true;
|
523
|
+
});
|
524
|
+
this.$emit('focus', null);
|
525
|
+
},
|
526
|
+
|
527
|
+
_Focus(event) {
|
528
|
+
this.focusShow = true;
|
529
|
+
this.$emit('focus', event);
|
530
|
+
},
|
531
|
+
|
532
|
+
/**
|
533
|
+
* 外部调用方法
|
534
|
+
* 失去焦点时触发
|
535
|
+
* @param {Object} event
|
536
|
+
*/
|
537
|
+
onBlur() {
|
538
|
+
this.focused = false;
|
539
|
+
this.$emit('blur', null);
|
540
|
+
},
|
541
|
+
_Blur(event) {
|
542
|
+
let value = event.detail.value;
|
543
|
+
this.focusShow = false;
|
544
|
+
this.$emit('blur', event);
|
545
|
+
// 根据类型返回值,在event中获取的值理论上讲都是string
|
546
|
+
if (this.isEnter === false) {
|
547
|
+
this.$emit('change', this.val);
|
548
|
+
}
|
549
|
+
// 失去焦点时参与表单校验
|
550
|
+
if (this.form && this.formItem) {
|
551
|
+
const { validateTrigger } = this.form;
|
552
|
+
if (validateTrigger === 'blur') {
|
553
|
+
this.formItem.onFieldChange();
|
554
|
+
}
|
555
|
+
}
|
556
|
+
},
|
557
|
+
|
558
|
+
/**
|
559
|
+
* 按下键盘的发送键
|
560
|
+
* @param {Object} e
|
561
|
+
*/
|
562
|
+
onConfirm(e) {
|
563
|
+
this.$emit('confirm', this.val);
|
564
|
+
this.isEnter = true;
|
565
|
+
this.$emit('change', this.val);
|
566
|
+
this.$nextTick(() => {
|
567
|
+
this.isEnter = false;
|
568
|
+
});
|
569
|
+
},
|
570
|
+
|
571
|
+
/**
|
572
|
+
* 清理内容
|
573
|
+
* @param {Object} event
|
574
|
+
*/
|
575
|
+
onClear(event) {
|
576
|
+
this.val = '';
|
577
|
+
// TODO 兼容 vue2
|
578
|
+
this.$emit('input', '');
|
579
|
+
// TODO 兼容 vue2
|
580
|
+
// TODO 兼容 vue3
|
581
|
+
this.$emit('update:modelValue', '');
|
582
|
+
// 点击叉号触发
|
583
|
+
this.$emit('clear');
|
584
|
+
},
|
585
|
+
|
586
|
+
/**
|
587
|
+
* 键盘高度发生变化的时候触发此事件
|
588
|
+
* 兼容性:微信小程序2.7.0+、App 3.1.0+
|
589
|
+
* @param {Object} event
|
590
|
+
*/
|
591
|
+
onkeyboardheightchange(event) {
|
592
|
+
this.$emit('keyboardheightchange', event);
|
593
|
+
},
|
594
|
+
|
595
|
+
/**
|
596
|
+
* 去除空格
|
597
|
+
*/
|
598
|
+
trimStr(str, pos = 'both') {
|
599
|
+
if (pos === 'both') {
|
600
|
+
return str.trim();
|
601
|
+
} else if (pos === 'left') {
|
602
|
+
return str.trimLeft();
|
603
|
+
} else if (pos === 'right') {
|
604
|
+
return str.trimRight();
|
605
|
+
} else if (pos === 'start') {
|
606
|
+
return str.trimStart();
|
607
|
+
} else if (pos === 'end') {
|
608
|
+
return str.trimEnd();
|
609
|
+
} else if (pos === 'all') {
|
610
|
+
return str.replace(/\s+/g, '');
|
611
|
+
} else if (pos === 'none') {
|
612
|
+
return str;
|
613
|
+
}
|
614
|
+
return str;
|
615
|
+
}
|
616
|
+
}
|
617
|
+
};
|
618
|
+
</script>
|
619
|
+
|
620
|
+
<style lang="scss">
|
621
|
+
$uni-error: #e43d33;
|
622
|
+
$uni-border-1: #dcdfe6 !default;
|
623
|
+
|
624
|
+
.uni-easyinput {
|
625
|
+
/* #ifndef APP-NVUE */
|
626
|
+
width: 100%;
|
627
|
+
/* #endif */
|
628
|
+
flex: 1;
|
629
|
+
position: relative;
|
630
|
+
text-align: left;
|
631
|
+
color: #333;
|
632
|
+
font-size: 14px;
|
633
|
+
}
|
634
|
+
|
635
|
+
.uni-easyinput__content {
|
636
|
+
flex: 1;
|
637
|
+
/* #ifndef APP-NVUE */
|
638
|
+
width: 100%;
|
639
|
+
display: flex;
|
640
|
+
box-sizing: border-box;
|
641
|
+
// min-height: 36px;
|
642
|
+
/* #endif */
|
643
|
+
flex-direction: row;
|
644
|
+
align-items: center;
|
645
|
+
// 处理border动画刚开始显示黑色的问题
|
646
|
+
border-color: #fff;
|
647
|
+
transition-property: border-color;
|
648
|
+
transition-duration: 0.3s;
|
649
|
+
}
|
650
|
+
|
651
|
+
.uni-easyinput__content-input {
|
652
|
+
/* #ifndef APP-NVUE */
|
653
|
+
width: auto;
|
654
|
+
/* #endif */
|
655
|
+
position: relative;
|
656
|
+
overflow: hidden;
|
657
|
+
flex: 1;
|
658
|
+
line-height: 1;
|
659
|
+
font-size: 14px;
|
660
|
+
height: 35px;
|
661
|
+
// min-height: 36px;
|
662
|
+
|
663
|
+
/*ifdef H5*/
|
664
|
+
& ::-ms-reveal {
|
665
|
+
display: none;
|
666
|
+
}
|
667
|
+
|
668
|
+
& ::-ms-clear {
|
669
|
+
display: none;
|
670
|
+
}
|
671
|
+
|
672
|
+
& ::-o-clear {
|
673
|
+
display: none;
|
674
|
+
}
|
675
|
+
|
676
|
+
/*endif*/
|
677
|
+
}
|
678
|
+
|
679
|
+
.uni-easyinput__placeholder-class {
|
680
|
+
color: #999;
|
681
|
+
font-size: 12px;
|
682
|
+
// font-weight: 200;
|
683
|
+
}
|
684
|
+
|
685
|
+
.is-textarea {
|
686
|
+
align-items: flex-start;
|
687
|
+
}
|
688
|
+
|
689
|
+
.is-textarea-icon {
|
690
|
+
margin-top: 5px;
|
691
|
+
}
|
692
|
+
|
693
|
+
.uni-easyinput__content-textarea {
|
694
|
+
position: relative;
|
695
|
+
overflow: hidden;
|
696
|
+
flex: 1;
|
697
|
+
line-height: 1.5;
|
698
|
+
font-size: 14px;
|
699
|
+
margin: 6px;
|
700
|
+
margin-left: 0;
|
701
|
+
height: 80px;
|
702
|
+
min-height: 80px;
|
703
|
+
/* #ifndef APP-NVUE */
|
704
|
+
min-height: 80px;
|
705
|
+
width: auto;
|
706
|
+
/* #endif */
|
707
|
+
}
|
708
|
+
|
709
|
+
.input-padding {
|
710
|
+
padding-left: 10px;
|
711
|
+
}
|
712
|
+
|
713
|
+
.content-clear-icon {
|
714
|
+
padding: 0 5px;
|
715
|
+
}
|
716
|
+
|
717
|
+
.label-icon {
|
718
|
+
margin-right: 5px;
|
719
|
+
margin-top: -1px;
|
720
|
+
}
|
721
|
+
|
722
|
+
// 显示边框
|
723
|
+
.is-input-border {
|
724
|
+
/* #ifndef APP-NVUE */
|
725
|
+
display: flex;
|
726
|
+
box-sizing: border-box;
|
727
|
+
/* #endif */
|
728
|
+
flex-direction: row;
|
729
|
+
align-items: center;
|
730
|
+
border: 1px solid $uni-border-1;
|
731
|
+
border-radius: 4px;
|
732
|
+
/* #ifdef MP-ALIPAY */
|
733
|
+
overflow: hidden;
|
734
|
+
/* #endif */
|
735
|
+
}
|
736
|
+
|
737
|
+
.uni-error-message {
|
738
|
+
position: absolute;
|
739
|
+
bottom: -17px;
|
740
|
+
left: 0;
|
741
|
+
line-height: 12px;
|
742
|
+
color: $uni-error;
|
743
|
+
font-size: 12px;
|
744
|
+
text-align: left;
|
745
|
+
}
|
746
|
+
|
747
|
+
.uni-error-msg--boeder {
|
748
|
+
position: relative;
|
749
|
+
bottom: 0;
|
750
|
+
line-height: 22px;
|
751
|
+
}
|
752
|
+
|
753
|
+
.is-input-error-border {
|
754
|
+
border-color: $uni-error;
|
755
|
+
|
756
|
+
.uni-easyinput__placeholder-class {
|
757
|
+
color: mix(#fff, $uni-error, 50%);
|
758
|
+
}
|
759
|
+
}
|
760
|
+
|
761
|
+
.uni-easyinput--border {
|
762
|
+
margin-bottom: 0;
|
763
|
+
padding: 10px 15px;
|
764
|
+
// padding-bottom: 0;
|
765
|
+
border-top: 1px #eee solid;
|
766
|
+
}
|
767
|
+
|
768
|
+
.uni-easyinput-error {
|
769
|
+
padding-bottom: 0;
|
770
|
+
}
|
771
|
+
|
772
|
+
.is-first-border {
|
773
|
+
/* #ifndef APP-NVUE */
|
774
|
+
border: none;
|
775
|
+
/* #endif */
|
776
|
+
/* #ifdef APP-NVUE */
|
777
|
+
border-width: 0;
|
778
|
+
/* #endif */
|
779
|
+
}
|
780
|
+
|
781
|
+
.is-disabled {
|
782
|
+
background-color: #f7f6f6;
|
783
|
+
color: #d5d5d5;
|
784
|
+
|
785
|
+
.uni-easyinput__placeholder-class {
|
786
|
+
color: #d5d5d5;
|
787
|
+
font-size: 12px;
|
788
|
+
}
|
789
|
+
}
|
790
|
+
</style>
|