sadais-piui 1.2.7-beta113 → 1.2.7-beta115
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/.prettierrc +7 -7
- package/CHANGELOG.md +545 -545
- package/LICENSE +20 -20
- package/README.md +166 -166
- package/components/pi-action-sheet/index.vue +247 -247
- package/components/pi-badge/index.vue +146 -146
- package/components/pi-bottom-bar/index.vue +139 -139
- package/components/pi-bubble/index.vue +174 -174
- package/components/pi-button/index.vue +492 -492
- package/components/pi-calendar-input/index.vue +230 -230
- package/components/pi-calendar-panel/components/calendar-days/index.vue +410 -410
- package/components/pi-calendar-panel/index.vue +473 -473
- package/components/pi-canvas/index.vue +407 -407
- package/components/pi-card/index.vue +127 -127
- package/components/pi-cascader/index.vue +601 -601
- package/components/pi-checkbox/index.vue +363 -363
- package/components/pi-checkbox-group/index.vue +222 -222
- package/components/pi-circle-progress/index.vue +311 -311
- package/components/pi-code-input/index.vue +270 -270
- package/components/pi-collapse/index.vue +124 -124
- package/components/pi-collapse-item/index.vue +352 -352
- package/components/pi-count-down/index.vue +245 -245
- package/components/pi-count-up/index.vue +209 -209
- package/components/pi-date-picker-input/index.vue +219 -219
- package/components/pi-divider/index.vue +112 -112
- package/components/pi-dropdown/components/dropdown-tab.vue +71 -71
- package/components/pi-dropdown/index.vue +356 -356
- package/components/pi-dropdown-item/index.vue +252 -252
- package/components/pi-form/index.vue +273 -273
- package/components/pi-form-item/index.vue +603 -590
- package/components/pi-gap/index.vue +72 -72
- package/components/pi-grid/index.vue +92 -92
- package/components/pi-grid-item/index.vue +220 -220
- package/components/pi-icon/index.vue +147 -147
- package/components/pi-img/index.vue +266 -266
- package/components/pi-img-cropper/canvas.js +106 -106
- package/components/pi-img-cropper/index.vue +357 -357
- package/components/pi-img-cropper/touch.js +163 -163
- package/components/pi-img-cropper/vector.js +34 -34
- package/components/pi-input/index.vue +409 -401
- package/components/pi-line/index.vue +78 -78
- package/components/pi-line-progress/index.vue +198 -198
- package/components/pi-list/index.vue +115 -115
- package/components/pi-list-item/index.vue +335 -335
- package/components/pi-loading/index.vue +188 -188
- package/components/pi-marquee/index.vue +310 -310
- package/components/pi-marquee-item/index.vue +47 -47
- package/components/pi-mask/index.vue +198 -198
- package/components/pi-modal/index.vue +303 -303
- package/components/pi-navbar/index.vue +421 -421
- package/components/pi-notify/index.vue +239 -239
- package/components/pi-number-keyboard/index.vue +189 -189
- package/components/pi-opentype-button/index.vue +501 -501
- package/components/pi-pagination/index.vue +290 -290
- package/components/pi-picker/index.vue +317 -317
- package/components/pi-popup/index.vue +356 -356
- package/components/pi-popup-select/index.vue +300 -300
- package/components/pi-radio/index.vue +403 -403
- package/components/pi-radio-group/index.vue +300 -300
- package/components/pi-rate/index.vue +212 -212
- package/components/pi-regions-select/index.vue +349 -349
- package/components/pi-regions-select-input/index.vue +230 -230
- package/components/pi-search/index.vue +386 -386
- package/components/pi-section/index.vue +218 -218
- package/components/pi-select/index.vue +678 -678
- package/components/pi-select-input/index.vue +273 -273
- package/components/pi-skeleton/index.vue +280 -280
- package/components/pi-status-bar/index.vue +56 -56
- package/components/pi-stepper/index.vue +408 -408
- package/components/pi-steps/index.vue +378 -378
- package/components/pi-subsection/index.vue +403 -403
- package/components/pi-swiper/index.vue +344 -344
- package/components/pi-switch/index.vue +231 -231
- package/components/pi-table/index.vue +351 -351
- package/components/pi-tabs/index.vue +435 -435
- package/components/pi-tag/index.vue +488 -488
- package/components/pi-upload-img/index.vue +980 -980
- package/components/pi-waterfall/index.vue +130 -130
- package/config/actionSheet.js +24 -24
- package/config/badge.js +9 -9
- package/config/bottomBar.js +11 -11
- package/config/bubble.js +6 -6
- package/config/button.js +29 -29
- package/config/calendar.js +19 -19
- package/config/calendarInput.js +19 -19
- package/config/calendarPanel.js +27 -27
- package/config/card.js +8 -8
- package/config/cascader.js +22 -22
- package/config/checkbox.js +15 -15
- package/config/checkboxGroup.js +15 -15
- package/config/circleProgress.js +20 -20
- package/config/codeInput.js +13 -13
- package/config/collapse.js +7 -7
- package/config/collapseItem.js +11 -11
- package/config/countDown.js +12 -12
- package/config/countUp.js +13 -13
- package/config/datePickerInput.js +18 -18
- package/config/divider.js +10 -10
- package/config/dropdown.js +25 -25
- package/config/dropdownItem.js +26 -26
- package/config/form.js +29 -29
- package/config/formItem.js +27 -27
- package/config/gap.js +8 -8
- package/config/grid.js +9 -9
- package/config/gridItem.js +12 -12
- package/config/icon.js +11 -11
- package/config/img.js +21 -21
- package/config/imgCropper.js +26 -26
- package/config/index.js +28 -28
- package/config/input.js +37 -36
- package/config/line.js +8 -8
- package/config/lineProgress.js +14 -14
- package/config/list.js +12 -12
- package/config/listItem.js +25 -25
- package/config/loading.js +10 -10
- package/config/marquee.js +10 -10
- package/config/mask.js +12 -12
- package/config/modal.js +36 -36
- package/config/navbar.js +32 -32
- package/config/notify.js +13 -13
- package/config/numberKeyboard.js +21 -21
- package/config/pagination.js +10 -10
- package/config/picker.js +19 -19
- package/config/popup.js +23 -23
- package/config/popupSelect.js +35 -35
- package/config/radio.js +16 -16
- package/config/radioGroup.js +17 -17
- package/config/rate.js +15 -15
- package/config/regionsData.js +58 -58
- package/config/regionsSelect.js +19 -19
- package/config/regionsSelectInput.js +29 -29
- package/config/search.js +27 -27
- package/config/section.js +23 -23
- package/config/select.js +41 -41
- package/config/selectInput.js +29 -29
- package/config/skeleton.js +13 -13
- package/config/statusBar.js +5 -5
- package/config/stepper.js +19 -19
- package/config/steps.js +19 -19
- package/config/subsection.js +14 -14
- package/config/swiper.js +22 -22
- package/config/switch.js +13 -13
- package/config/table.js +8 -8
- package/config/tabs.js +23 -23
- package/config/tag.js +21 -21
- package/config/uploadImg.js +81 -81
- package/config/waterfall.js +6 -6
- package/index.js +41 -41
- package/mixin/component-custom.js +24 -24
- package/mixin/emitter.js +45 -45
- package/mixin/props-sync.js +65 -65
- package/mixin/value-sync.js +32 -32
- package/mixin/wx-code.js +30 -30
- package/package.json +28 -28
- package/plugins/async-validator.js +1511 -1511
- package/scss/animation.scss +260 -260
- package/scss/icon/icon.scss +595 -595
- package/scss/index.scss +5 -5
- package/scss/mixin.scss +47 -47
- package/tools/index.js +19 -19
|
@@ -1,401 +1,409 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view
|
|
3
|
-
class="pi-input-wrap"
|
|
4
|
-
:style="[getInputWrapStyle]"
|
|
5
|
-
:class="[{ disabled: getDisabled }]"
|
|
6
|
-
>
|
|
7
|
-
<!-- 当disabled,增加一个abso的蒙层,为了触发click事件 -->
|
|
8
|
-
<view
|
|
9
|
-
v-if="getDisabled"
|
|
10
|
-
class="pi-input-mask"
|
|
11
|
-
:style="{ width: `calc(100% - ${closeIconWidth}px)` }"
|
|
12
|
-
@tap="handleItemClick"
|
|
13
|
-
/>
|
|
14
|
-
|
|
15
|
-
<textarea
|
|
16
|
-
v-if="type === 'textarea'"
|
|
17
|
-
class="pi-input-textarea"
|
|
18
|
-
:style="[customStyle]"
|
|
19
|
-
:class="[customClass]"
|
|
20
|
-
:value="val"
|
|
21
|
-
:password="password"
|
|
22
|
-
:placeholder="placeholder"
|
|
23
|
-
:placeholder-style="placeholderStyle"
|
|
24
|
-
:placeholder-class="placeholderClass"
|
|
25
|
-
:maxlength="parseInt(maxlength, 10)"
|
|
26
|
-
:cursor-spacing="cursorSpacing"
|
|
27
|
-
:focus="focus"
|
|
28
|
-
:disabled="getDisabled"
|
|
29
|
-
:confirm-hold="confirmHold"
|
|
30
|
-
:cursor="cursor"
|
|
31
|
-
:selection-start="selectionStart"
|
|
32
|
-
:selection-end="selectionEnd"
|
|
33
|
-
:adjust-position="adjustPosition"
|
|
34
|
-
:hold-keyboard="holdKeyboard"
|
|
35
|
-
:auto-blur="autoBlur"
|
|
36
|
-
:show-confirm-bar="showConfirmbar"
|
|
37
|
-
:auto-height="autoHeight"
|
|
38
|
-
:disable-default-padding="disableDefaultPadding"
|
|
39
|
-
@focus="handleFocus"
|
|
40
|
-
@input="handleInput"
|
|
41
|
-
@blur="handleBlur"
|
|
42
|
-
@confirm="handleConfirm"
|
|
43
|
-
@keyboardheightchange="$emit('keyboardheightchange', $event)"
|
|
44
|
-
@linechange="$emit('linechange', $event)"
|
|
45
|
-
@tap="handleItemClick"
|
|
46
|
-
/>
|
|
47
|
-
<input
|
|
48
|
-
v-else
|
|
49
|
-
class="pi-input"
|
|
50
|
-
:style="[customStyle]"
|
|
51
|
-
:class="[customClass]"
|
|
52
|
-
:type="type == 'password' ? 'text' : type"
|
|
53
|
-
:value="val"
|
|
54
|
-
:password="password"
|
|
55
|
-
:placeholder="placeholder"
|
|
56
|
-
:placeholder-style="placeholderStyle"
|
|
57
|
-
:placeholder-class="placeholderClass"
|
|
58
|
-
:maxlength="parseInt(maxlength, 10)"
|
|
59
|
-
:cursor-spacing="cursorSpacing"
|
|
60
|
-
:focus="focus"
|
|
61
|
-
:disabled="getDisabled"
|
|
62
|
-
:confirm-hold="confirmHold"
|
|
63
|
-
:cursor="cursor"
|
|
64
|
-
:selection-start="selectionStart"
|
|
65
|
-
:selection-end="selectionEnd"
|
|
66
|
-
:adjust-position="adjustPosition"
|
|
67
|
-
:hold-keyboard="holdKeyboard"
|
|
68
|
-
:auto-blur="autoBlur"
|
|
69
|
-
@focus="handleFocus"
|
|
70
|
-
@input="handleInput"
|
|
71
|
-
@blur="handleBlur"
|
|
72
|
-
@confirm="handleConfirm"
|
|
73
|
-
@keyboardheightchange="$emit('keyboardheightchange', $event)"
|
|
74
|
-
@tap="handleItemClick"
|
|
75
|
-
/>
|
|
76
|
-
<!-- 清空icon -->
|
|
77
|
-
<view class="pi-input-close-icon">
|
|
78
|
-
<pi-icon
|
|
79
|
-
v-if="showClearIcon"
|
|
80
|
-
:custom-style="clearIcon.customStyle"
|
|
81
|
-
:custom-class="`pi-pd-left-12 ${clearIcon.customClass}`"
|
|
82
|
-
:name="clearIcon.name"
|
|
83
|
-
:dot="clearIcon.dot"
|
|
84
|
-
:dot-radius="clearIcon.dotRadius"
|
|
85
|
-
:badge="clearIcon.badge"
|
|
86
|
-
:color="clearIcon.color"
|
|
87
|
-
:size="clearIcon.size"
|
|
88
|
-
:class-prefix="clearIcon.classPrefix"
|
|
89
|
-
@click="handleClearInput"
|
|
90
|
-
/>
|
|
91
|
-
</view>
|
|
92
|
-
</view>
|
|
93
|
-
</template>
|
|
94
|
-
|
|
95
|
-
<script>
|
|
96
|
-
/**
|
|
97
|
-
*
|
|
98
|
-
* @description 输入框
|
|
99
|
-
*/
|
|
100
|
-
import Emitter from '../../mixin/emitter'
|
|
101
|
-
import ValueSync from '../../mixin/value-sync'
|
|
102
|
-
import { getConfig } from '../../config'
|
|
103
|
-
import { debounce } from '@sadais/piui-tool/tools/common'
|
|
104
|
-
|
|
105
|
-
const { input } = getConfig()
|
|
106
|
-
|
|
107
|
-
const TAG = 'PiInput'
|
|
108
|
-
|
|
109
|
-
export default {
|
|
110
|
-
name: 'PiInput',
|
|
111
|
-
// 混入v-model
|
|
112
|
-
mixins: [ValueSync, Emitter],
|
|
113
|
-
props: {
|
|
114
|
-
// 初始值
|
|
115
|
-
value: {
|
|
116
|
-
required: false
|
|
117
|
-
},
|
|
118
|
-
// 自定义样式
|
|
119
|
-
customStyle: {
|
|
120
|
-
type: Object,
|
|
121
|
-
default() {
|
|
122
|
-
// {}
|
|
123
|
-
return input.customStyle
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
// 自定义样式类
|
|
127
|
-
customClass: {
|
|
128
|
-
type: String,
|
|
129
|
-
default() {
|
|
130
|
-
// ''
|
|
131
|
-
return input.customClass
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
// 输入框类型
|
|
135
|
-
type: {
|
|
136
|
-
required: false,
|
|
137
|
-
// `'textarea'` `'text'` `'number'` `'idcard'` `'digit'`
|
|
138
|
-
type: String,
|
|
139
|
-
// `'text'`
|
|
140
|
-
default() {
|
|
141
|
-
return input.type
|
|
142
|
-
},
|
|
143
|
-
validator: function(value) {
|
|
144
|
-
return ['textarea', 'text', 'number', 'idcard', 'digit'].includes(value)
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
// 是否是密码类型
|
|
148
|
-
password: {
|
|
149
|
-
type: Boolean,
|
|
150
|
-
// false
|
|
151
|
-
default: input.password
|
|
152
|
-
},
|
|
153
|
-
placeholder: {
|
|
154
|
-
type: String,
|
|
155
|
-
// ''
|
|
156
|
-
default: input.placeholder
|
|
157
|
-
},
|
|
158
|
-
placeholderStyle: {
|
|
159
|
-
type: String,
|
|
160
|
-
// color: #c0c4cc; font-weight: 400;
|
|
161
|
-
default: input.placeholderStyle
|
|
162
|
-
},
|
|
163
|
-
placeholderClass: {
|
|
164
|
-
type: String,
|
|
165
|
-
// input-placeholder
|
|
166
|
-
default: input.placeholderClass
|
|
167
|
-
},
|
|
168
|
-
// 是否禁用
|
|
169
|
-
disabled: {
|
|
170
|
-
type: Boolean,
|
|
171
|
-
// false
|
|
172
|
-
default: input.disabled
|
|
173
|
-
},
|
|
174
|
-
// 边框样式设置
|
|
175
|
-
border: {
|
|
176
|
-
type: [Boolean, String],
|
|
177
|
-
// false
|
|
178
|
-
default: input.border
|
|
179
|
-
},
|
|
180
|
-
// 最大输入长度,设置为 -1 的时候不限制最大长度
|
|
181
|
-
maxlength: {
|
|
182
|
-
type: [Number, String],
|
|
183
|
-
// 140
|
|
184
|
-
default: input.maxlength
|
|
185
|
-
},
|
|
186
|
-
// 指定光标与键盘的距离,单位 px
|
|
187
|
-
cursorSpacing: {
|
|
188
|
-
type: [Number, String],
|
|
189
|
-
// 0
|
|
190
|
-
default: input.cursorSpacing
|
|
191
|
-
},
|
|
192
|
-
// 是否自动获得焦点
|
|
193
|
-
focus: {
|
|
194
|
-
type: Boolean,
|
|
195
|
-
// false
|
|
196
|
-
default: input.focus
|
|
197
|
-
},
|
|
198
|
-
// 设置键盘右下角按钮的文字,仅在 type="text" 时生效。
|
|
199
|
-
confirmType: {
|
|
200
|
-
type: String,
|
|
201
|
-
// 'done'
|
|
202
|
-
default: input.confirmType
|
|
203
|
-
},
|
|
204
|
-
// 点击键盘右下角按钮时是否保持键盘不收起
|
|
205
|
-
confirmHold: {
|
|
206
|
-
type: Boolean,
|
|
207
|
-
// false
|
|
208
|
-
default: input.confirmHold
|
|
209
|
-
},
|
|
210
|
-
// 指定focus时的光标位置
|
|
211
|
-
cursor: {
|
|
212
|
-
type: [Object, Number],
|
|
213
|
-
// null
|
|
214
|
-
default: input.cursor
|
|
215
|
-
},
|
|
216
|
-
// 光标起始位置,自动聚焦时有效,需与selection-end搭配使用
|
|
217
|
-
selectionStart: {
|
|
218
|
-
type: [Number, String],
|
|
219
|
-
// -1
|
|
220
|
-
default: input.selectionStart
|
|
221
|
-
},
|
|
222
|
-
// 光标结束位置,自动聚焦时有效,需与selection-start搭配使用
|
|
223
|
-
selectionEnd: {
|
|
224
|
-
type: [Number, String],
|
|
225
|
-
// -1
|
|
226
|
-
default: input.selectionEnd
|
|
227
|
-
},
|
|
228
|
-
// 键盘弹起时,是否自动上推页面
|
|
229
|
-
adjustPosition: {
|
|
230
|
-
type: Boolean,
|
|
231
|
-
// true
|
|
232
|
-
default: input.adjustPosition
|
|
233
|
-
},
|
|
234
|
-
// focus时,点击页面的时候不收起键盘
|
|
235
|
-
holdKeyboard: {
|
|
236
|
-
type: Boolean,
|
|
237
|
-
// false
|
|
238
|
-
default: input.holdKeyboard
|
|
239
|
-
},
|
|
240
|
-
// 键盘收起时,是否自动失去焦点
|
|
241
|
-
autoBlur: {
|
|
242
|
-
type: Boolean,
|
|
243
|
-
// true
|
|
244
|
-
default: input.autoBlur
|
|
245
|
-
},
|
|
246
|
-
// 以下是textarea组件的属性
|
|
247
|
-
// 是否显示键盘上方带有”完成“按钮那一栏
|
|
248
|
-
showConfirmbar: {
|
|
249
|
-
type: Boolean,
|
|
250
|
-
// true
|
|
251
|
-
default: input.showConfirmbar
|
|
252
|
-
},
|
|
253
|
-
// 是否自动增高
|
|
254
|
-
autoHeight: {
|
|
255
|
-
type: Boolean,
|
|
256
|
-
// false
|
|
257
|
-
default: input.autoHeight
|
|
258
|
-
},
|
|
259
|
-
// 如果 textarea 是在一个 position:fixed 的区域,需要显示指定属性 fixed 为 true
|
|
260
|
-
fixed: {
|
|
261
|
-
type: Boolean,
|
|
262
|
-
// false
|
|
263
|
-
default: input.fixed
|
|
264
|
-
},
|
|
265
|
-
// 是否去掉 iOS 下的默认内边距
|
|
266
|
-
disableDefaultPadding: {
|
|
267
|
-
type: Boolean,
|
|
268
|
-
// false
|
|
269
|
-
default: input.disableDefaultPadding
|
|
270
|
-
},
|
|
271
|
-
// 是否可清空
|
|
272
|
-
clearable: {
|
|
273
|
-
type: Boolean,
|
|
274
|
-
// false
|
|
275
|
-
default: input.clearable
|
|
276
|
-
},
|
|
277
|
-
// 清空图标设置
|
|
278
|
-
clearIcon: {
|
|
279
|
-
type: Object,
|
|
280
|
-
default() {
|
|
281
|
-
return input.clearIcon
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
}
|
|
290
|
-
},
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
this.$emit('
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
this.$emit('
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
this.$emit('
|
|
370
|
-
},
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
.
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="pi-input-wrap"
|
|
4
|
+
:style="[getInputWrapStyle]"
|
|
5
|
+
:class="[{ disabled: getDisabled }]"
|
|
6
|
+
>
|
|
7
|
+
<!-- 当disabled,增加一个abso的蒙层,为了触发click事件 -->
|
|
8
|
+
<view
|
|
9
|
+
v-if="getDisabled"
|
|
10
|
+
class="pi-input-mask"
|
|
11
|
+
:style="{ width: `calc(100% - ${closeIconWidth}px)` }"
|
|
12
|
+
@tap="handleItemClick"
|
|
13
|
+
/>
|
|
14
|
+
|
|
15
|
+
<textarea
|
|
16
|
+
v-if="type === 'textarea'"
|
|
17
|
+
class="pi-input-textarea"
|
|
18
|
+
:style="[customStyle]"
|
|
19
|
+
:class="[customClass]"
|
|
20
|
+
:value="val"
|
|
21
|
+
:password="password"
|
|
22
|
+
:placeholder="placeholder"
|
|
23
|
+
:placeholder-style="placeholderStyle"
|
|
24
|
+
:placeholder-class="placeholderClass"
|
|
25
|
+
:maxlength="parseInt(maxlength, 10)"
|
|
26
|
+
:cursor-spacing="cursorSpacing"
|
|
27
|
+
:focus="focus"
|
|
28
|
+
:disabled="getDisabled"
|
|
29
|
+
:confirm-hold="confirmHold"
|
|
30
|
+
:cursor="cursor"
|
|
31
|
+
:selection-start="selectionStart"
|
|
32
|
+
:selection-end="selectionEnd"
|
|
33
|
+
:adjust-position="adjustPosition"
|
|
34
|
+
:hold-keyboard="holdKeyboard"
|
|
35
|
+
:auto-blur="autoBlur"
|
|
36
|
+
:show-confirm-bar="showConfirmbar"
|
|
37
|
+
:auto-height="autoHeight"
|
|
38
|
+
:disable-default-padding="disableDefaultPadding"
|
|
39
|
+
@focus="handleFocus"
|
|
40
|
+
@input="handleInput"
|
|
41
|
+
@blur="handleBlur"
|
|
42
|
+
@confirm="handleConfirm"
|
|
43
|
+
@keyboardheightchange="$emit('keyboardheightchange', $event)"
|
|
44
|
+
@linechange="$emit('linechange', $event)"
|
|
45
|
+
@tap="handleItemClick"
|
|
46
|
+
/>
|
|
47
|
+
<input
|
|
48
|
+
v-else
|
|
49
|
+
class="pi-input"
|
|
50
|
+
:style="[customStyle]"
|
|
51
|
+
:class="[customClass]"
|
|
52
|
+
:type="type == 'password' ? 'text' : type"
|
|
53
|
+
:value="val"
|
|
54
|
+
:password="password"
|
|
55
|
+
:placeholder="placeholder"
|
|
56
|
+
:placeholder-style="placeholderStyle"
|
|
57
|
+
:placeholder-class="placeholderClass"
|
|
58
|
+
:maxlength="parseInt(maxlength, 10)"
|
|
59
|
+
:cursor-spacing="cursorSpacing"
|
|
60
|
+
:focus="focus"
|
|
61
|
+
:disabled="getDisabled"
|
|
62
|
+
:confirm-hold="confirmHold"
|
|
63
|
+
:cursor="cursor"
|
|
64
|
+
:selection-start="selectionStart"
|
|
65
|
+
:selection-end="selectionEnd"
|
|
66
|
+
:adjust-position="adjustPosition"
|
|
67
|
+
:hold-keyboard="holdKeyboard"
|
|
68
|
+
:auto-blur="autoBlur"
|
|
69
|
+
@focus="handleFocus"
|
|
70
|
+
@input="handleInput"
|
|
71
|
+
@blur="handleBlur"
|
|
72
|
+
@confirm="handleConfirm"
|
|
73
|
+
@keyboardheightchange="$emit('keyboardheightchange', $event)"
|
|
74
|
+
@tap="handleItemClick"
|
|
75
|
+
/>
|
|
76
|
+
<!-- 清空icon -->
|
|
77
|
+
<view class="pi-input-close-icon">
|
|
78
|
+
<pi-icon
|
|
79
|
+
v-if="showClearIcon"
|
|
80
|
+
:custom-style="clearIcon.customStyle"
|
|
81
|
+
:custom-class="`pi-pd-left-12 ${clearIcon.customClass}`"
|
|
82
|
+
:name="clearIcon.name"
|
|
83
|
+
:dot="clearIcon.dot"
|
|
84
|
+
:dot-radius="clearIcon.dotRadius"
|
|
85
|
+
:badge="clearIcon.badge"
|
|
86
|
+
:color="clearIcon.color"
|
|
87
|
+
:size="clearIcon.size"
|
|
88
|
+
:class-prefix="clearIcon.classPrefix"
|
|
89
|
+
@click="handleClearInput"
|
|
90
|
+
/>
|
|
91
|
+
</view>
|
|
92
|
+
</view>
|
|
93
|
+
</template>
|
|
94
|
+
|
|
95
|
+
<script>
|
|
96
|
+
/**
|
|
97
|
+
*
|
|
98
|
+
* @description 输入框
|
|
99
|
+
*/
|
|
100
|
+
import Emitter from '../../mixin/emitter'
|
|
101
|
+
import ValueSync from '../../mixin/value-sync'
|
|
102
|
+
import { getConfig } from '../../config'
|
|
103
|
+
import { debounce } from '@sadais/piui-tool/tools/common'
|
|
104
|
+
|
|
105
|
+
const { input } = getConfig()
|
|
106
|
+
|
|
107
|
+
const TAG = 'PiInput'
|
|
108
|
+
|
|
109
|
+
export default {
|
|
110
|
+
name: 'PiInput',
|
|
111
|
+
// 混入v-model
|
|
112
|
+
mixins: [ValueSync, Emitter],
|
|
113
|
+
props: {
|
|
114
|
+
// 初始值
|
|
115
|
+
value: {
|
|
116
|
+
required: false
|
|
117
|
+
},
|
|
118
|
+
// 自定义样式
|
|
119
|
+
customStyle: {
|
|
120
|
+
type: Object,
|
|
121
|
+
default() {
|
|
122
|
+
// {}
|
|
123
|
+
return input.customStyle
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
// 自定义样式类
|
|
127
|
+
customClass: {
|
|
128
|
+
type: String,
|
|
129
|
+
default() {
|
|
130
|
+
// ''
|
|
131
|
+
return input.customClass
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
// 输入框类型
|
|
135
|
+
type: {
|
|
136
|
+
required: false,
|
|
137
|
+
// `'textarea'` `'text'` `'number'` `'idcard'` `'digit'`
|
|
138
|
+
type: String,
|
|
139
|
+
// `'text'`
|
|
140
|
+
default() {
|
|
141
|
+
return input.type
|
|
142
|
+
},
|
|
143
|
+
validator: function(value) {
|
|
144
|
+
return ['textarea', 'text', 'number', 'idcard', 'digit'].includes(value)
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
// 是否是密码类型
|
|
148
|
+
password: {
|
|
149
|
+
type: Boolean,
|
|
150
|
+
// false
|
|
151
|
+
default: input.password
|
|
152
|
+
},
|
|
153
|
+
placeholder: {
|
|
154
|
+
type: String,
|
|
155
|
+
// ''
|
|
156
|
+
default: input.placeholder
|
|
157
|
+
},
|
|
158
|
+
placeholderStyle: {
|
|
159
|
+
type: String,
|
|
160
|
+
// color: #c0c4cc; font-weight: 400;
|
|
161
|
+
default: input.placeholderStyle
|
|
162
|
+
},
|
|
163
|
+
placeholderClass: {
|
|
164
|
+
type: String,
|
|
165
|
+
// input-placeholder
|
|
166
|
+
default: input.placeholderClass
|
|
167
|
+
},
|
|
168
|
+
// 是否禁用
|
|
169
|
+
disabled: {
|
|
170
|
+
type: Boolean,
|
|
171
|
+
// false
|
|
172
|
+
default: input.disabled
|
|
173
|
+
},
|
|
174
|
+
// 边框样式设置
|
|
175
|
+
border: {
|
|
176
|
+
type: [Boolean, String],
|
|
177
|
+
// false
|
|
178
|
+
default: input.border
|
|
179
|
+
},
|
|
180
|
+
// 最大输入长度,设置为 -1 的时候不限制最大长度
|
|
181
|
+
maxlength: {
|
|
182
|
+
type: [Number, String],
|
|
183
|
+
// 140
|
|
184
|
+
default: input.maxlength
|
|
185
|
+
},
|
|
186
|
+
// 指定光标与键盘的距离,单位 px
|
|
187
|
+
cursorSpacing: {
|
|
188
|
+
type: [Number, String],
|
|
189
|
+
// 0
|
|
190
|
+
default: input.cursorSpacing
|
|
191
|
+
},
|
|
192
|
+
// 是否自动获得焦点
|
|
193
|
+
focus: {
|
|
194
|
+
type: Boolean,
|
|
195
|
+
// false
|
|
196
|
+
default: input.focus
|
|
197
|
+
},
|
|
198
|
+
// 设置键盘右下角按钮的文字,仅在 type="text" 时生效。
|
|
199
|
+
confirmType: {
|
|
200
|
+
type: String,
|
|
201
|
+
// 'done'
|
|
202
|
+
default: input.confirmType
|
|
203
|
+
},
|
|
204
|
+
// 点击键盘右下角按钮时是否保持键盘不收起
|
|
205
|
+
confirmHold: {
|
|
206
|
+
type: Boolean,
|
|
207
|
+
// false
|
|
208
|
+
default: input.confirmHold
|
|
209
|
+
},
|
|
210
|
+
// 指定focus时的光标位置
|
|
211
|
+
cursor: {
|
|
212
|
+
type: [Object, Number],
|
|
213
|
+
// null
|
|
214
|
+
default: input.cursor
|
|
215
|
+
},
|
|
216
|
+
// 光标起始位置,自动聚焦时有效,需与selection-end搭配使用
|
|
217
|
+
selectionStart: {
|
|
218
|
+
type: [Number, String],
|
|
219
|
+
// -1
|
|
220
|
+
default: input.selectionStart
|
|
221
|
+
},
|
|
222
|
+
// 光标结束位置,自动聚焦时有效,需与selection-start搭配使用
|
|
223
|
+
selectionEnd: {
|
|
224
|
+
type: [Number, String],
|
|
225
|
+
// -1
|
|
226
|
+
default: input.selectionEnd
|
|
227
|
+
},
|
|
228
|
+
// 键盘弹起时,是否自动上推页面
|
|
229
|
+
adjustPosition: {
|
|
230
|
+
type: Boolean,
|
|
231
|
+
// true
|
|
232
|
+
default: input.adjustPosition
|
|
233
|
+
},
|
|
234
|
+
// focus时,点击页面的时候不收起键盘
|
|
235
|
+
holdKeyboard: {
|
|
236
|
+
type: Boolean,
|
|
237
|
+
// false
|
|
238
|
+
default: input.holdKeyboard
|
|
239
|
+
},
|
|
240
|
+
// 键盘收起时,是否自动失去焦点
|
|
241
|
+
autoBlur: {
|
|
242
|
+
type: Boolean,
|
|
243
|
+
// true
|
|
244
|
+
default: input.autoBlur
|
|
245
|
+
},
|
|
246
|
+
// 以下是textarea组件的属性
|
|
247
|
+
// 是否显示键盘上方带有”完成“按钮那一栏
|
|
248
|
+
showConfirmbar: {
|
|
249
|
+
type: Boolean,
|
|
250
|
+
// true
|
|
251
|
+
default: input.showConfirmbar
|
|
252
|
+
},
|
|
253
|
+
// 是否自动增高
|
|
254
|
+
autoHeight: {
|
|
255
|
+
type: Boolean,
|
|
256
|
+
// false
|
|
257
|
+
default: input.autoHeight
|
|
258
|
+
},
|
|
259
|
+
// 如果 textarea 是在一个 position:fixed 的区域,需要显示指定属性 fixed 为 true
|
|
260
|
+
fixed: {
|
|
261
|
+
type: Boolean,
|
|
262
|
+
// false
|
|
263
|
+
default: input.fixed
|
|
264
|
+
},
|
|
265
|
+
// 是否去掉 iOS 下的默认内边距
|
|
266
|
+
disableDefaultPadding: {
|
|
267
|
+
type: Boolean,
|
|
268
|
+
// false
|
|
269
|
+
default: input.disableDefaultPadding
|
|
270
|
+
},
|
|
271
|
+
// 是否可清空
|
|
272
|
+
clearable: {
|
|
273
|
+
type: Boolean,
|
|
274
|
+
// false
|
|
275
|
+
default: input.clearable
|
|
276
|
+
},
|
|
277
|
+
// 清空图标设置
|
|
278
|
+
clearIcon: {
|
|
279
|
+
type: Object,
|
|
280
|
+
default() {
|
|
281
|
+
return input.clearIcon
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
// 是否失去焦点更新v-model
|
|
285
|
+
updateOnBlur: {
|
|
286
|
+
type: Boolean,
|
|
287
|
+
// true
|
|
288
|
+
default: input.updateOnBlur
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
data() {
|
|
292
|
+
return {
|
|
293
|
+
focused: this.focus,
|
|
294
|
+
closeIconWidth: 0
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
computed: {
|
|
298
|
+
getDisabled() {
|
|
299
|
+
const parentFormItem = this.$pi.parent(this, 'PiFormItem')
|
|
300
|
+
const disabled =
|
|
301
|
+
this.disabled || (parentFormItem && parentFormItem.getDisabled)
|
|
302
|
+
return disabled
|
|
303
|
+
},
|
|
304
|
+
getInputWrapStyle() {
|
|
305
|
+
const style = {}
|
|
306
|
+
if (this.border) {
|
|
307
|
+
style.padding = '8rpx 14rpx'
|
|
308
|
+
style.borderRadius = '4rpx'
|
|
309
|
+
if (this.$pi.lang.isString(this.border)) {
|
|
310
|
+
style.border = this.border
|
|
311
|
+
} else {
|
|
312
|
+
style.border = '1px solid #d9d9d9'
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return style
|
|
316
|
+
},
|
|
317
|
+
showClearIcon() {
|
|
318
|
+
return this.clearable && this.val
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
watch: {
|
|
322
|
+
showClearIcon() {
|
|
323
|
+
this.$nextTick(() => {
|
|
324
|
+
this.init()
|
|
325
|
+
})
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
mounted() {
|
|
329
|
+
this.init()
|
|
330
|
+
},
|
|
331
|
+
methods: {
|
|
332
|
+
async init() {
|
|
333
|
+
if (!this.closeIconWidth) {
|
|
334
|
+
const closeIconRect = await this.$pi.common.queryRect(
|
|
335
|
+
this,
|
|
336
|
+
'.pi-input-close-icon',
|
|
337
|
+
false
|
|
338
|
+
)
|
|
339
|
+
if (closeIconRect && closeIconRect.width) {
|
|
340
|
+
this.closeIconWidth = closeIconRect.width
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
handleItemClick(e) {
|
|
345
|
+
this.$emit('click', e)
|
|
346
|
+
},
|
|
347
|
+
handleInput(e) {
|
|
348
|
+
const value = e.detail.value
|
|
349
|
+
this.handleChange(value)
|
|
350
|
+
},
|
|
351
|
+
handleFocus() {
|
|
352
|
+
this.focused = true
|
|
353
|
+
// 获得焦点
|
|
354
|
+
this.$emit('focus')
|
|
355
|
+
},
|
|
356
|
+
handleBlur(e) {
|
|
357
|
+
const value = e.detail.value
|
|
358
|
+
if (this.updateOnBlur) {
|
|
359
|
+
this.handleChange(value)
|
|
360
|
+
}
|
|
361
|
+
this.$emit('blur', value)
|
|
362
|
+
setTimeout(() => {
|
|
363
|
+
this.focused = false
|
|
364
|
+
this.dispatch('PiFormItem', 'form-blur', value)
|
|
365
|
+
}, 100)
|
|
366
|
+
},
|
|
367
|
+
handleClearInput() {
|
|
368
|
+
this.handleChange('')
|
|
369
|
+
this.$emit('clear')
|
|
370
|
+
},
|
|
371
|
+
/**
|
|
372
|
+
* @vuese
|
|
373
|
+
* 确认选择
|
|
374
|
+
*/
|
|
375
|
+
handleConfirm(e) {
|
|
376
|
+
// 输入完成事件
|
|
377
|
+
this.$emit('confirm', e.detail.value)
|
|
378
|
+
},
|
|
379
|
+
handleChange(value) {
|
|
380
|
+
this.val = value
|
|
381
|
+
this.handleEmitChange()
|
|
382
|
+
this.dispatch('PiForm', 'form-change', this.val)
|
|
383
|
+
this.dispatch('PiFormItem', 'form-change', this.val)
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
</script>
|
|
388
|
+
|
|
389
|
+
<style lang="scss" scoped>
|
|
390
|
+
.pi-input-wrap {
|
|
391
|
+
position: relative;
|
|
392
|
+
width: 100%;
|
|
393
|
+
display: flex;
|
|
394
|
+
align-items: center;
|
|
395
|
+
.pi-input,
|
|
396
|
+
.pi-input-textarea {
|
|
397
|
+
width: 100%;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.pi-input-mask {
|
|
401
|
+
position: absolute;
|
|
402
|
+
left: 0;
|
|
403
|
+
top: 0;
|
|
404
|
+
bottom: 0;
|
|
405
|
+
background: transparent;
|
|
406
|
+
z-index: 101;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
</style>
|