sadais-piui 1.2.4-beta2 → 1.2.4-beta5

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.
Files changed (140) hide show
  1. package/CHANGELOG.md +512 -512
  2. package/LICENSE +20 -20
  3. package/README.md +166 -166
  4. package/components/pi-action-sheet/index.vue +247 -247
  5. package/components/pi-badge/index.vue +136 -136
  6. package/components/pi-bottom-bar/index.vue +139 -139
  7. package/components/pi-button/index.vue +492 -492
  8. package/components/pi-calendar/index.vue +178 -178
  9. package/components/pi-calendar-panel/index.vue +436 -432
  10. package/components/pi-canvas/index.vue +400 -400
  11. package/components/pi-card/index.vue +127 -127
  12. package/components/pi-checkbox/index.vue +345 -345
  13. package/components/pi-checkbox-group/index.vue +215 -215
  14. package/components/pi-circle-progress/index.vue +224 -224
  15. package/components/pi-code-input/index.vue +262 -262
  16. package/components/pi-count-down/index.vue +245 -245
  17. package/components/pi-count-up/index.vue +209 -209
  18. package/components/pi-date-picker/index.vue +366 -366
  19. package/components/pi-divider/index.vue +109 -109
  20. package/components/pi-dropdown/components/dropdown-tab.vue +62 -62
  21. package/components/pi-dropdown/index.vue +316 -316
  22. package/components/pi-dropdown-item/index.vue +233 -233
  23. package/components/pi-form/index.vue +237 -237
  24. package/components/pi-form-item/index.vue +534 -534
  25. package/components/pi-gap/index.vue +72 -72
  26. package/components/pi-grid/index.vue +92 -92
  27. package/components/pi-grid-item/index.vue +220 -220
  28. package/components/pi-icon/index.vue +147 -147
  29. package/components/pi-img/index.vue +267 -267
  30. package/components/pi-img-cropper/canvas.js +112 -112
  31. package/components/pi-img-cropper/index.vue +357 -357
  32. package/components/pi-img-cropper/touch.js +163 -163
  33. package/components/pi-img-cropper/vector.js +34 -34
  34. package/components/pi-input/index.vue +299 -299
  35. package/components/pi-line/index.vue +78 -78
  36. package/components/pi-line-progress/index.vue +198 -198
  37. package/components/pi-list/index.vue +115 -115
  38. package/components/pi-list-item/index.vue +331 -331
  39. package/components/pi-loading/index.vue +188 -188
  40. package/components/pi-marquee/index.vue +281 -281
  41. package/components/pi-marquee-item/index.vue +47 -47
  42. package/components/pi-mask/index.vue +198 -198
  43. package/components/pi-modal/index.vue +303 -303
  44. package/components/pi-navbar/index.vue +421 -421
  45. package/components/pi-notify/index.vue +239 -239
  46. package/components/pi-number-keyboard/index.vue +189 -189
  47. package/components/pi-opentype-button/index.vue +501 -501
  48. package/components/pi-pagination/index.vue +277 -277
  49. package/components/pi-picker/index.vue +317 -317
  50. package/components/pi-popup/index.vue +353 -353
  51. package/components/pi-popup-select/index.vue +291 -291
  52. package/components/pi-radio/index.vue +387 -387
  53. package/components/pi-radio-group/index.vue +262 -262
  54. package/components/pi-rate/index.vue +212 -212
  55. package/components/pi-regions-select/index.vue +318 -318
  56. package/components/pi-search/index.vue +351 -351
  57. package/components/pi-section/index.vue +218 -218
  58. package/components/pi-select/index.vue +391 -391
  59. package/components/pi-skeleton/index.vue +280 -280
  60. package/components/pi-status-bar/index.vue +56 -56
  61. package/components/pi-stepper/index.vue +394 -394
  62. package/components/pi-steps/index.vue +299 -299
  63. package/components/pi-swiper/index.vue +344 -344
  64. package/components/pi-switch/index.vue +227 -227
  65. package/components/pi-tabs/index.vue +398 -398
  66. package/components/pi-upload-img/index.vue +508 -506
  67. package/components/pi-waterfall/index.vue +130 -130
  68. package/components/pi-webview/index.vue +82 -82
  69. package/config/actionSheet.js +25 -25
  70. package/config/badge.js +9 -9
  71. package/config/bottomBar.js +11 -11
  72. package/config/button.js +29 -29
  73. package/config/calendar.js +19 -19
  74. package/config/calendarPanel.js +24 -24
  75. package/config/card.js +8 -8
  76. package/config/checkbox.js +14 -14
  77. package/config/checkboxGroup.js +14 -14
  78. package/config/circleProgress.js +13 -13
  79. package/config/codeInput.js +12 -12
  80. package/config/countDown.js +12 -12
  81. package/config/countUp.js +13 -13
  82. package/config/datePicker.js +22 -22
  83. package/config/divider.js +10 -10
  84. package/config/dropdown.js +21 -21
  85. package/config/dropdownItem.js +26 -26
  86. package/config/form.js +27 -27
  87. package/config/formItem.js +25 -25
  88. package/config/gap.js +8 -8
  89. package/config/grid.js +9 -9
  90. package/config/gridItem.js +12 -12
  91. package/config/icon.js +11 -11
  92. package/config/img.js +21 -21
  93. package/config/imgCropper.js +26 -26
  94. package/config/index.js +28 -28
  95. package/config/input.js +25 -25
  96. package/config/line.js +8 -8
  97. package/config/lineProgress.js +14 -14
  98. package/config/list.js +12 -12
  99. package/config/listItem.js +25 -25
  100. package/config/loading.js +10 -10
  101. package/config/marquee.js +8 -8
  102. package/config/mask.js +12 -12
  103. package/config/modal.js +36 -36
  104. package/config/navbar.js +32 -32
  105. package/config/notify.js +13 -13
  106. package/config/numberKeyboard.js +21 -21
  107. package/config/pagination.js +10 -10
  108. package/config/picker.js +19 -19
  109. package/config/popup.js +23 -23
  110. package/config/popupSelect.js +35 -35
  111. package/config/radio.js +15 -15
  112. package/config/radioGroup.js +16 -16
  113. package/config/rate.js +15 -15
  114. package/config/regionsData.js +58 -58
  115. package/config/regionsSelect.js +18 -18
  116. package/config/search.js +27 -27
  117. package/config/section.js +23 -23
  118. package/config/select.js +28 -28
  119. package/config/skeleton.js +13 -13
  120. package/config/statusBar.js +5 -5
  121. package/config/stepper.js +19 -19
  122. package/config/steps.js +19 -19
  123. package/config/swiper.js +22 -22
  124. package/config/switch.js +13 -13
  125. package/config/tabs.js +23 -23
  126. package/config/uploadImg.js +63 -63
  127. package/config/waterfall.js +6 -6
  128. package/index.js +41 -41
  129. package/mixin/component-custom.js +24 -24
  130. package/mixin/emitter.js +45 -45
  131. package/mixin/props-sync.js +65 -65
  132. package/mixin/value-sync.js +32 -32
  133. package/mixin/wx-code.js +30 -30
  134. package/package.json +25 -25
  135. package/plugins/async-validator.js +1511 -1511
  136. package/scss/animation.scss +260 -260
  137. package/scss/icon/icon.scss +594 -594
  138. package/scss/index.scss +5 -5
  139. package/scss/mixin.scss +47 -47
  140. package/tools/index.js +11 -11
@@ -1,351 +1,351 @@
1
- <template>
2
- <view class="pi-align-center pi-w-100P" :style="[customStyle]" :class="[customClass]">
3
- <view v-if="searchLabel" class="pi-pd-right-18" :style="[searchLabelStyle]">
4
- {{ searchLabel }}
5
- </view>
6
- <!-- 中间灰色包裹块 -->
7
- <view
8
- class="pi-search-wrap pi-flex-sub pi-align-center pi-of-hidden"
9
- :class="[customClass]"
10
- :style="[
11
- customStyle,
12
- {
13
- background: background,
14
- borderRadius: shape == 'round' ? '2000px' : '8rpx',
15
- flexDirection: searchIconPosition === 'right' ? 'row-reverse' : 'row'
16
- }
17
- ]"
18
- >
19
- <!-- 搜索图标 -->
20
- <view
21
- v-if="showSearchIcon"
22
- :class="[
23
- {
24
- 'pi-pd-left-18 pi-pd-right-18': searchIconPosition === 'left',
25
- 'pi-pd-right-18': searchIconPosition === 'right'
26
- }
27
- ]"
28
- >
29
- <view :class="'pi-fz-32 pi-icon-' + searchIcon" :style="[IconStyle]" />
30
- </view>
31
- <!-- 输入框包裹 -->
32
- <view
33
- class="pi-align-center pi-flex-sub"
34
- :class="[{ 'pi-pd-left-18': searchIconPosition === 'right' }]"
35
- >
36
- <input
37
- class="pi-flex-sub pi-fz-28"
38
- confirm-type="search"
39
- :value="val"
40
- :disabled="disabled"
41
- :maxlength="parseInt(maxlength, 10)"
42
- :focus="focused"
43
- :placeholder="placeholder"
44
- :placeholder-style="placeholderStyle"
45
- type="text"
46
- :style="[mergeInputStyle]"
47
- @blur="handleInputBlur"
48
- @confirm="handleInputSearch"
49
- @input="handleInputChange"
50
- @focus="handleInputFocus"
51
- />
52
- <!-- clear action -->
53
- <view v-if="clearable && val" class="pi-pd-lr-18" @tap="handleClearInput">
54
- <view class="pi-icon-roundclosefill" :style="[clearIconStyle]" />
55
- </view>
56
- </view>
57
- </view>
58
- <!-- right action -->
59
- <view
60
- v-if="showAction"
61
- class="pi-pd-left-18 pi-primary pi-fz-28"
62
- :style="[actionStyle]"
63
- @tap.stop="handleActionClick"
64
- >
65
- {{ actionText }}
66
- </view>
67
- </view>
68
- </template>
69
-
70
- <script>
71
- /**
72
- *
73
- * search 确定搜索时触发 value: string (当前输入的值)
74
- * input 输入框内容变化时触发 value: string (当前输入的值)
75
- * focus 输入框获得焦点时触发 event: Event
76
- * blur 输入框失去焦点时触发 event: Event
77
- * clear 点击清除按钮后触发 event: Event
78
- * action 点击右侧action触发
79
- */
80
- import ValueSync from '../../mixin/value-sync'
81
- import { getConfig } from '../../config'
82
-
83
- const TAG = 'PiSearch'
84
- const { search } = getConfig()
85
-
86
- export default {
87
- name: 'PiSearch',
88
- // 混入自定义样式customStyle和customClass
89
- mixins: [ValueSync], // 注入value与val,进行双向绑定
90
- props: {
91
- // 初始值
92
- value: {
93
- required: false
94
- },
95
- // 自定义样式,对象形式
96
- customStyle: {
97
- type: Object,
98
- // `{}`
99
- default() {
100
- return search.customStyle
101
- }
102
- },
103
- // 自定义样式类,字符串形式
104
- customClass: {
105
- type: String,
106
- // `''`
107
- default() {
108
- return search.customClass
109
- }
110
- },
111
- // 搜索框形状,可选值为 `'square'` `'round'`
112
- shape: {
113
- type: String,
114
- // `'round'`
115
- default: search.shape,
116
- validator: function(value) {
117
- return ['square', 'round'].includes(value)
118
- }
119
- },
120
- // 背景颜色
121
- background: {
122
- type: String,
123
- // `'#f5f5f5'`
124
- default: search.background
125
- },
126
- // 是否启用清除控件
127
- clearable: {
128
- type: Boolean,
129
- // `true`
130
- default: search.clearable
131
- },
132
- // 清除图标自定义样式
133
- clearIconStyle: {
134
- type: Object,
135
- // `{}`
136
- default() {
137
- return search.searchIconStyle
138
- }
139
- },
140
- // 是否自动获得焦点
141
- focus: {
142
- type: Boolean,
143
- // `false`
144
- default: search.focus
145
- },
146
- // 占位提示文字
147
- placeholder: {
148
- type: String,
149
- // `'请输入搜索关键词'`
150
- default: search.placeholder
151
- },
152
- // 指定 placeholder 的样式
153
- placeholderStyle: {
154
- type: String,
155
- // `'color: #cccccc;'`
156
- default() {
157
- return search.placeholderStyle
158
- }
159
- },
160
- // 输入框最大能输入的长度,-1为不限制长度
161
- maxlength: {
162
- type: [Number, String],
163
- // `-1`
164
- default: search.maxlength
165
- },
166
- // 是否在搜索框右侧显示文字
167
- showAction: {
168
- type: Boolean,
169
- // `false`
170
- default: search.showAction
171
- },
172
- // 右侧显示文字
173
- actionText: {
174
- type: String,
175
- // `'取消'`
176
- default: search.actionText
177
- },
178
- // 指定右侧显示文字样式
179
- actionStyle: {
180
- type: Object,
181
- // `{}`
182
- default() {
183
- return search.actionStyle
184
- }
185
- },
186
- // 输入框内容对齐方式,可选值 `'left'` `'center'` `'right'`
187
- inputAlign: {
188
- type: String,
189
- // `'left'`
190
- default: search.inputAlign
191
- },
192
- // 搜索框左侧文本
193
- searchLabel: {
194
- type: String,
195
- // `''`
196
- default: search.searchLabel
197
- },
198
- // 搜索框左侧文本样式
199
- searchLabelStyle: {
200
- type: Object,
201
- // `{}`
202
- default() {
203
- return search.searchLabelStyle
204
- }
205
- },
206
- // 是否显示搜索icon
207
- showSearchIcon: {
208
- type: Boolean,
209
- // `true`
210
- default: search.showSearchIcon
211
- },
212
- // 输入框的图标,可以为icon名称或图片路径
213
- searchIcon: {
214
- type: String,
215
- // `'search'`
216
- default: search.searchIcon
217
- },
218
- // 输入框左边的图标颜色(当传入searchIcon为name的时候)
219
- searchIconColor: {
220
- type: String,
221
- // `'#333333'`
222
- default: search.searchIconColor
223
- },
224
- // 输入框左侧的图标自定义样式
225
- searchIconStyle: {
226
- type: Object,
227
- // `{}`
228
- default() {
229
- return search.searchIconStyle
230
- }
231
- },
232
- // 搜索icon的位置, 可选值为`'left'` `'right'`
233
- searchIconPosition: {
234
- type: String,
235
- // `'left'`
236
- default: search.searchIconPosition,
237
- validator: function(value) {
238
- return ['left', 'right'].includes(value)
239
- }
240
- },
241
- // 是否禁用输入框
242
- disabled: {
243
- type: Boolean,
244
- // `false`
245
- default: search.disabled
246
- },
247
- // 指定input样式
248
- inputStyle: {
249
- type: Object,
250
- // `{}`
251
- default() {
252
- return search.inputStyle
253
- }
254
- },
255
- // 导航栏高度,单位px
256
- height: {
257
- type: [String, Number],
258
- // `58`
259
- default: search.height
260
- },
261
- // 输入文本颜色
262
- color: {
263
- type: String,
264
- // `'#333333'`
265
- default: search.color
266
- }
267
- },
268
- data() {
269
- return {
270
- focused: this.focus // input 是否已获取焦点
271
- }
272
- },
273
- computed: {
274
- getHeight() {
275
- return this.$pi.common.addUnit(this.height)
276
- },
277
- mergeInputStyle() {
278
- return {
279
- textAlign: this.inputAlign,
280
- color: this.color,
281
- background: this.background,
282
- height: this.getHeight,
283
- ...this.inputStyle
284
- }
285
- },
286
- IconStyle() {
287
- return {
288
- color: this.searchIconColor,
289
- ...this.searchIconStyle
290
- }
291
- }
292
- },
293
- watch: {
294
- focus: {
295
- deep: true,
296
- immediate: true,
297
- handler(value) {
298
- this.focused = value
299
- }
300
- }
301
- },
302
- methods: {
303
- handleInputChange(e) {
304
- const value = e.detail.value
305
- // 输入框内容变化时触发
306
- this.val = value
307
- this.handleEmitChange()
308
- },
309
- handleInputBlur() {
310
- this.focused = false
311
- // 输入框失去焦点时触发
312
- // @arg `event: Event`
313
- this.$emit('blur', this.val)
314
- uni.hideKeyboard() // 收起键盘
315
- },
316
- handleInputSearch(e) {
317
- // 确定搜索时触发
318
- // @arg `value: string` (当前输入的值)
319
- this.$emit('search', e.detail.value)
320
- uni.hideKeyboard() // 收起键盘
321
- },
322
- handleInputFocus() {
323
- this.focused = true
324
- // 输入框获得焦点时触发
325
- // @arg `event: Event`
326
- this.$emit('focus', this.val)
327
- },
328
- handleClearInput() {
329
- this.val = ''
330
- this.handleEmitChange()
331
- uni.hideKeyboard() // 收起键盘
332
- this.$nextTick(() => {
333
- // 延后发出事件,避免在父组件监听clear事件时,value为更新前的值(不为空)
334
- // @arg `event: Event`
335
- this.$emit('clear', this.val)
336
- })
337
- },
338
- handleActionClick() {
339
- // 点击按钮时触发
340
- this.$emit('action')
341
- }
342
- }
343
- }
344
- </script>
345
-
346
- <style lang="scss" scoped>
347
- .pi-search-wrap {
348
- font-weight: initial;
349
- color: #cccccc;
350
- }
351
- </style>
1
+ <template>
2
+ <view class="pi-align-center pi-w-100P" :style="[customStyle]" :class="[customClass]">
3
+ <view v-if="searchLabel" class="pi-pd-right-18" :style="[searchLabelStyle]">
4
+ {{ searchLabel }}
5
+ </view>
6
+ <!-- 中间灰色包裹块 -->
7
+ <view
8
+ class="pi-search-wrap pi-flex-sub pi-align-center pi-of-hidden"
9
+ :class="[customClass]"
10
+ :style="[
11
+ customStyle,
12
+ {
13
+ background: background,
14
+ borderRadius: shape == 'round' ? '2000px' : '8rpx',
15
+ flexDirection: searchIconPosition === 'right' ? 'row-reverse' : 'row'
16
+ }
17
+ ]"
18
+ >
19
+ <!-- 搜索图标 -->
20
+ <view
21
+ v-if="showSearchIcon"
22
+ :class="[
23
+ {
24
+ 'pi-pd-left-18 pi-pd-right-18': searchIconPosition === 'left',
25
+ 'pi-pd-right-18': searchIconPosition === 'right'
26
+ }
27
+ ]"
28
+ >
29
+ <view :class="'pi-fz-32 pi-icon-' + searchIcon" :style="[IconStyle]" />
30
+ </view>
31
+ <!-- 输入框包裹 -->
32
+ <view
33
+ class="pi-align-center pi-flex-sub"
34
+ :class="[{ 'pi-pd-left-18': searchIconPosition === 'right' }]"
35
+ >
36
+ <input
37
+ class="pi-flex-sub pi-fz-28"
38
+ confirm-type="search"
39
+ :value="val"
40
+ :disabled="disabled"
41
+ :maxlength="parseInt(maxlength, 10)"
42
+ :focus="focused"
43
+ :placeholder="placeholder"
44
+ :placeholder-style="placeholderStyle"
45
+ type="text"
46
+ :style="[mergeInputStyle]"
47
+ @blur="handleInputBlur"
48
+ @confirm="handleInputSearch"
49
+ @input="handleInputChange"
50
+ @focus="handleInputFocus"
51
+ />
52
+ <!-- clear action -->
53
+ <view v-if="clearable && val" class="pi-pd-lr-18" @tap="handleClearInput">
54
+ <view class="pi-icon-roundclosefill" :style="[clearIconStyle]" />
55
+ </view>
56
+ </view>
57
+ </view>
58
+ <!-- right action -->
59
+ <view
60
+ v-if="showAction"
61
+ class="pi-pd-left-18 pi-primary pi-fz-28"
62
+ :style="[actionStyle]"
63
+ @tap.stop="handleActionClick"
64
+ >
65
+ {{ actionText }}
66
+ </view>
67
+ </view>
68
+ </template>
69
+
70
+ <script>
71
+ /**
72
+ *
73
+ * search 确定搜索时触发 value: string (当前输入的值)
74
+ * input 输入框内容变化时触发 value: string (当前输入的值)
75
+ * focus 输入框获得焦点时触发 event: Event
76
+ * blur 输入框失去焦点时触发 event: Event
77
+ * clear 点击清除按钮后触发 event: Event
78
+ * action 点击右侧action触发
79
+ */
80
+ import ValueSync from '../../mixin/value-sync'
81
+ import { getConfig } from '../../config'
82
+
83
+ const TAG = 'PiSearch'
84
+ const { search } = getConfig()
85
+
86
+ export default {
87
+ name: 'PiSearch',
88
+ // 混入自定义样式customStyle和customClass
89
+ mixins: [ValueSync], // 注入value与val,进行双向绑定
90
+ props: {
91
+ // 初始值
92
+ value: {
93
+ required: false
94
+ },
95
+ // 自定义样式,对象形式
96
+ customStyle: {
97
+ type: Object,
98
+ // `{}`
99
+ default() {
100
+ return search.customStyle
101
+ }
102
+ },
103
+ // 自定义样式类,字符串形式
104
+ customClass: {
105
+ type: String,
106
+ // `''`
107
+ default() {
108
+ return search.customClass
109
+ }
110
+ },
111
+ // 搜索框形状,可选值为 `'square'` `'round'`
112
+ shape: {
113
+ type: String,
114
+ // `'round'`
115
+ default: search.shape,
116
+ validator: function(value) {
117
+ return ['square', 'round'].includes(value)
118
+ }
119
+ },
120
+ // 背景颜色
121
+ background: {
122
+ type: String,
123
+ // `'#f5f5f5'`
124
+ default: search.background
125
+ },
126
+ // 是否启用清除控件
127
+ clearable: {
128
+ type: Boolean,
129
+ // `true`
130
+ default: search.clearable
131
+ },
132
+ // 清除图标自定义样式
133
+ clearIconStyle: {
134
+ type: Object,
135
+ // `{}`
136
+ default() {
137
+ return search.searchIconStyle
138
+ }
139
+ },
140
+ // 是否自动获得焦点
141
+ focus: {
142
+ type: Boolean,
143
+ // `false`
144
+ default: search.focus
145
+ },
146
+ // 占位提示文字
147
+ placeholder: {
148
+ type: String,
149
+ // `'请输入搜索关键词'`
150
+ default: search.placeholder
151
+ },
152
+ // 指定 placeholder 的样式
153
+ placeholderStyle: {
154
+ type: String,
155
+ // `'color: #cccccc;'`
156
+ default() {
157
+ return search.placeholderStyle
158
+ }
159
+ },
160
+ // 输入框最大能输入的长度,-1为不限制长度
161
+ maxlength: {
162
+ type: [Number, String],
163
+ // `-1`
164
+ default: search.maxlength
165
+ },
166
+ // 是否在搜索框右侧显示文字
167
+ showAction: {
168
+ type: Boolean,
169
+ // `false`
170
+ default: search.showAction
171
+ },
172
+ // 右侧显示文字
173
+ actionText: {
174
+ type: String,
175
+ // `'取消'`
176
+ default: search.actionText
177
+ },
178
+ // 指定右侧显示文字样式
179
+ actionStyle: {
180
+ type: Object,
181
+ // `{}`
182
+ default() {
183
+ return search.actionStyle
184
+ }
185
+ },
186
+ // 输入框内容对齐方式,可选值 `'left'` `'center'` `'right'`
187
+ inputAlign: {
188
+ type: String,
189
+ // `'left'`
190
+ default: search.inputAlign
191
+ },
192
+ // 搜索框左侧文本
193
+ searchLabel: {
194
+ type: String,
195
+ // `''`
196
+ default: search.searchLabel
197
+ },
198
+ // 搜索框左侧文本样式
199
+ searchLabelStyle: {
200
+ type: Object,
201
+ // `{}`
202
+ default() {
203
+ return search.searchLabelStyle
204
+ }
205
+ },
206
+ // 是否显示搜索icon
207
+ showSearchIcon: {
208
+ type: Boolean,
209
+ // `true`
210
+ default: search.showSearchIcon
211
+ },
212
+ // 输入框的图标,可以为icon名称或图片路径
213
+ searchIcon: {
214
+ type: String,
215
+ // `'search'`
216
+ default: search.searchIcon
217
+ },
218
+ // 输入框左边的图标颜色(当传入searchIcon为name的时候)
219
+ searchIconColor: {
220
+ type: String,
221
+ // `'#333333'`
222
+ default: search.searchIconColor
223
+ },
224
+ // 输入框左侧的图标自定义样式
225
+ searchIconStyle: {
226
+ type: Object,
227
+ // `{}`
228
+ default() {
229
+ return search.searchIconStyle
230
+ }
231
+ },
232
+ // 搜索icon的位置, 可选值为`'left'` `'right'`
233
+ searchIconPosition: {
234
+ type: String,
235
+ // `'left'`
236
+ default: search.searchIconPosition,
237
+ validator: function(value) {
238
+ return ['left', 'right'].includes(value)
239
+ }
240
+ },
241
+ // 是否禁用输入框
242
+ disabled: {
243
+ type: Boolean,
244
+ // `false`
245
+ default: search.disabled
246
+ },
247
+ // 指定input样式
248
+ inputStyle: {
249
+ type: Object,
250
+ // `{}`
251
+ default() {
252
+ return search.inputStyle
253
+ }
254
+ },
255
+ // 导航栏高度,单位px
256
+ height: {
257
+ type: [String, Number],
258
+ // `58`
259
+ default: search.height
260
+ },
261
+ // 输入文本颜色
262
+ color: {
263
+ type: String,
264
+ // `'#333333'`
265
+ default: search.color
266
+ }
267
+ },
268
+ data() {
269
+ return {
270
+ focused: this.focus // input 是否已获取焦点
271
+ }
272
+ },
273
+ computed: {
274
+ getHeight() {
275
+ return this.$pi.common.addUnit(this.height)
276
+ },
277
+ mergeInputStyle() {
278
+ return {
279
+ textAlign: this.inputAlign,
280
+ color: this.color,
281
+ background: this.background,
282
+ height: this.getHeight,
283
+ ...this.inputStyle
284
+ }
285
+ },
286
+ IconStyle() {
287
+ return {
288
+ color: this.searchIconColor,
289
+ ...this.searchIconStyle
290
+ }
291
+ }
292
+ },
293
+ watch: {
294
+ focus: {
295
+ deep: true,
296
+ immediate: true,
297
+ handler(value) {
298
+ this.focused = value
299
+ }
300
+ }
301
+ },
302
+ methods: {
303
+ handleInputChange(e) {
304
+ const value = e.detail.value
305
+ // 输入框内容变化时触发
306
+ this.val = value
307
+ this.handleEmitChange()
308
+ },
309
+ handleInputBlur() {
310
+ this.focused = false
311
+ // 输入框失去焦点时触发
312
+ // @arg `event: Event`
313
+ this.$emit('blur', this.val)
314
+ uni.hideKeyboard() // 收起键盘
315
+ },
316
+ handleInputSearch(e) {
317
+ // 确定搜索时触发
318
+ // @arg `value: string` (当前输入的值)
319
+ this.$emit('search', e.detail.value)
320
+ uni.hideKeyboard() // 收起键盘
321
+ },
322
+ handleInputFocus() {
323
+ this.focused = true
324
+ // 输入框获得焦点时触发
325
+ // @arg `event: Event`
326
+ this.$emit('focus', this.val)
327
+ },
328
+ handleClearInput() {
329
+ this.val = ''
330
+ this.handleEmitChange()
331
+ uni.hideKeyboard() // 收起键盘
332
+ this.$nextTick(() => {
333
+ // 延后发出事件,避免在父组件监听clear事件时,value为更新前的值(不为空)
334
+ // @arg `event: Event`
335
+ this.$emit('clear', this.val)
336
+ })
337
+ },
338
+ handleActionClick() {
339
+ // 点击按钮时触发
340
+ this.$emit('action')
341
+ }
342
+ }
343
+ }
344
+ </script>
345
+
346
+ <style lang="scss" scoped>
347
+ .pi-search-wrap {
348
+ font-weight: initial;
349
+ color: #cccccc;
350
+ }
351
+ </style>