@kengic/uni 0.5.1 → 0.5.2-beta.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.
Files changed (146) hide show
  1. package/dist/uni/uni-ui/uni-badge/uni-badge.vue +222 -219
  2. package/dist/uni/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +29 -29
  3. package/dist/uni/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +88 -88
  4. package/dist/uni/uni-ui/uni-calendar/calendar.js +936 -532
  5. package/dist/uni/uni-ui/uni-calendar/i18n/en.json +10 -10
  6. package/dist/uni/uni-ui/uni-calendar/i18n/index.js +8 -7
  7. package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hans.json +10 -10
  8. package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hant.json +10 -10
  9. package/dist/uni/uni-ui/uni-calendar/uni-calendar-item.vue +190 -168
  10. package/dist/uni/uni-ui/uni-calendar/uni-calendar.vue +459 -459
  11. package/dist/uni/uni-ui/uni-calendar/util.js +324 -340
  12. package/dist/uni/uni-ui/uni-card/uni-card.vue +8 -1
  13. package/dist/uni/uni-ui/uni-col/uni-col.vue +294 -287
  14. package/dist/uni/uni-ui/uni-collapse/uni-collapse.vue +139 -140
  15. package/dist/uni/uni-ui/uni-collapse-item/uni-collapse-item.vue +381 -378
  16. package/dist/uni/uni-ui/uni-combox/uni-combox.vue +280 -272
  17. package/dist/uni/uni-ui/uni-countdown/i18n/en.json +4 -4
  18. package/dist/uni/uni-ui/uni-countdown/i18n/index.js +8 -7
  19. package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hans.json +4 -4
  20. package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hant.json +4 -4
  21. package/dist/uni/uni-ui/uni-countdown/uni-countdown.vue +249 -257
  22. package/dist/uni/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +832 -813
  23. package/dist/uni/uni-ui/uni-data-picker/keypress.js +42 -42
  24. package/dist/uni/uni-ui/uni-data-picker/uni-data-picker.vue +535 -516
  25. package/dist/uni/uni-ui/uni-data-pickerview/uni-data-picker.js +623 -618
  26. package/dist/uni/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +293 -288
  27. package/dist/uni/uni-ui/uni-data-select/uni-data-select.vue +495 -509
  28. package/dist/uni/uni-ui/uni-dateformat/date-format.js +181 -184
  29. package/dist/uni/uni-ui/uni-dateformat/uni-dateformat.vue +81 -82
  30. package/dist/uni/uni-ui/uni-datetime-picker/calendar-item.vue +176 -170
  31. package/dist/uni/uni-ui/uni-datetime-picker/calendar.vue +926 -920
  32. package/dist/uni/uni-ui/uni-datetime-picker/i18n/en.json +20 -20
  33. package/dist/uni/uni-ui/uni-datetime-picker/i18n/index.js +8 -7
  34. package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +21 -21
  35. package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +21 -21
  36. package/dist/uni/uni-ui/uni-datetime-picker/time-picker.vue +921 -926
  37. package/dist/uni/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1059 -1012
  38. package/dist/uni/uni-ui/uni-datetime-picker/util.js +366 -377
  39. package/dist/uni/uni-ui/uni-drawer/keypress.js +42 -42
  40. package/dist/uni/uni-ui/uni-drawer/uni-drawer.vue +176 -167
  41. package/dist/uni/uni-ui/uni-easyinput/common.js +40 -42
  42. package/dist/uni/uni-ui/uni-easyinput/uni-easyinput.vue +628 -547
  43. package/dist/uni/uni-ui/uni-fab/uni-fab.vue +507 -483
  44. package/dist/uni/uni-ui/uni-fav/i18n/en.json +2 -2
  45. package/dist/uni/uni-ui/uni-fav/i18n/index.js +8 -7
  46. package/dist/uni/uni-ui/uni-fav/i18n/zh-Hans.json +2 -2
  47. package/dist/uni/uni-ui/uni-fav/i18n/zh-Hant.json +2 -2
  48. package/dist/uni/uni-ui/uni-fav/uni-fav.vue +155 -147
  49. package/dist/uni/uni-ui/uni-file-picker/choose-and-upload-file.js +172 -198
  50. package/dist/uni/uni-ui/uni-file-picker/uni-file-picker.vue +636 -634
  51. package/dist/uni/uni-ui/uni-file-picker/upload-file.vue +294 -293
  52. package/dist/uni/uni-ui/uni-file-picker/upload-image.vue +267 -270
  53. package/dist/uni/uni-ui/uni-file-picker/utils.js +81 -82
  54. package/dist/uni/uni-ui/uni-forms/uni-forms.vue +360 -372
  55. package/dist/uni/uni-ui/uni-forms/utils.js +170 -174
  56. package/dist/uni/uni-ui/uni-forms/validate.js +447 -456
  57. package/dist/uni/uni-ui/uni-forms-item/uni-forms-item.vue +497 -497
  58. package/dist/uni/uni-ui/uni-goods-nav/i18n/en.json +4 -4
  59. package/dist/uni/uni-ui/uni-goods-nav/i18n/index.js +8 -7
  60. package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hans.json +4 -4
  61. package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hant.json +4 -4
  62. package/dist/uni/uni-ui/uni-goods-nav/uni-goods-nav.vue +238 -222
  63. package/dist/uni/uni-ui/uni-grid/uni-grid.vue +134 -134
  64. package/dist/uni/uni-ui/uni-grid-item/uni-grid-item.vue +121 -119
  65. package/dist/uni/uni-ui/uni-group/uni-group.vue +121 -121
  66. package/dist/uni/uni-ui/uni-icons/icons.js +1170 -1168
  67. package/dist/uni/uni-ui/uni-icons/uni-icons.vue +91 -86
  68. package/dist/uni/uni-ui/uni-icons/uniicons.css +166 -166
  69. package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +129 -129
  70. package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list.vue +352 -347
  71. package/dist/uni/uni-ui/uni-link/uni-link.vue +134 -119
  72. package/dist/uni/uni-ui/uni-list/uni-list.vue +119 -110
  73. package/dist/uni/uni-ui/uni-list/uni-refresh.vue +14 -14
  74. package/dist/uni/uni-ui/uni-list/uni-refresh.wxs +14 -14
  75. package/dist/uni/uni-ui/uni-list-ad/uni-list-ad.vue +101 -95
  76. package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.scss +18 -18
  77. package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.vue +602 -586
  78. package/dist/uni/uni-ui/uni-list-item/uni-list-item.vue +507 -503
  79. package/dist/uni/uni-ui/uni-load-more/i18n/en.json +3 -3
  80. package/dist/uni/uni-ui/uni-load-more/i18n/index.js +8 -7
  81. package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hans.json +3 -3
  82. package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hant.json +3 -3
  83. package/dist/uni/uni-ui/uni-load-more/uni-load-more.vue +402 -392
  84. package/dist/uni/uni-ui/uni-nav-bar/uni-nav-bar.vue +328 -330
  85. package/dist/uni/uni-ui/uni-nav-bar/uni-status-bar.vue +17 -17
  86. package/dist/uni/uni-ui/uni-notice-bar/uni-notice-bar.vue +422 -401
  87. package/dist/uni/uni-ui/uni-number-box/uni-number-box.vue +211 -205
  88. package/dist/uni/uni-ui/uni-pagination/i18n/en.json +3 -3
  89. package/dist/uni/uni-ui/uni-pagination/i18n/es.json +3 -3
  90. package/dist/uni/uni-ui/uni-pagination/i18n/fr.json +3 -3
  91. package/dist/uni/uni-ui/uni-pagination/i18n/index.js +12 -11
  92. package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hans.json +3 -3
  93. package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hant.json +3 -3
  94. package/dist/uni/uni-ui/uni-pagination/uni-pagination.vue +450 -433
  95. package/dist/uni/uni-ui/uni-popup/uni-popup.vue +404 -404
  96. package/dist/uni/uni-ui/uni-popup-dialog/keypress.js +42 -42
  97. package/dist/uni/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +1 -0
  98. package/dist/uni/uni-ui/uni-popup-message/uni-popup-message.vue +126 -125
  99. package/dist/uni/uni-ui/uni-popup-share/uni-popup-share.vue +172 -172
  100. package/dist/uni/uni-ui/uni-rate/uni-rate.vue +343 -347
  101. package/dist/uni/uni-ui/uni-row/uni-row.vue +180 -182
  102. package/dist/uni/uni-ui/uni-scss/changelog.md +11 -4
  103. package/dist/uni/uni-ui/uni-scss/package.json +73 -73
  104. package/dist/uni/uni-ui/uni-scss/readme.md +2 -1
  105. package/dist/uni/uni-ui/uni-scss/styles/setting/_border.scss +2 -2
  106. package/dist/uni/uni-ui/uni-scss/styles/setting/_color.scss +46 -47
  107. package/dist/uni/uni-ui/uni-scss/styles/setting/_radius.scss +49 -49
  108. package/dist/uni/uni-ui/uni-scss/styles/setting/_space.scss +52 -53
  109. package/dist/uni/uni-ui/uni-scss/styles/setting/_styles.scss +142 -147
  110. package/dist/uni/uni-ui/uni-scss/styles/setting/_text.scss +20 -20
  111. package/dist/uni/uni-ui/uni-scss/styles/setting/_variables.scss +111 -95
  112. package/dist/uni/uni-ui/uni-scss/styles/tools/functions.scss +28 -18
  113. package/dist/uni/uni-ui/uni-scss/theme.scss +10 -7
  114. package/dist/uni/uni-ui/uni-scss/variables.scss +42 -24
  115. package/dist/uni/uni-ui/uni-search-bar/i18n/en.json +3 -3
  116. package/dist/uni/uni-ui/uni-search-bar/i18n/index.js +8 -7
  117. package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hans.json +2 -2
  118. package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hant.json +2 -2
  119. package/dist/uni/uni-ui/uni-search-bar/uni-search-bar.vue +290 -281
  120. package/dist/uni/uni-ui/uni-section/uni-section.vue +149 -146
  121. package/dist/uni/uni-ui/uni-segmented-control/uni-segmented-control.vue +141 -131
  122. package/dist/uni/uni-ui/uni-steps/uni-steps.vue +255 -236
  123. package/dist/uni/uni-ui/uni-swipe-action/uni-swipe-action.vue +51 -51
  124. package/dist/uni/uni-ui/uni-swipe-action-item/bindingx.js +276 -282
  125. package/dist/uni/uni-ui/uni-swipe-action-item/isPC.js +10 -10
  126. package/dist/uni/uni-ui/uni-swipe-action-item/mpalipay.js +182 -187
  127. package/dist/uni/uni-ui/uni-swipe-action-item/mpother.js +235 -244
  128. package/dist/uni/uni-ui/uni-swipe-action-item/mpwxs.js +70 -75
  129. package/dist/uni/uni-ui/uni-swipe-action-item/render.js +238 -247
  130. package/dist/uni/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +387 -313
  131. package/dist/uni/uni-ui/uni-swipe-action-item/wx.wxs +206 -215
  132. package/dist/uni/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +241 -197
  133. package/dist/uni/uni-ui/uni-table/uni-table.vue +445 -447
  134. package/dist/uni/uni-ui/uni-tag/uni-tag.vue +234 -244
  135. package/dist/uni/uni-ui/uni-tbody/uni-tbody.vue +20 -23
  136. package/dist/uni/uni-ui/uni-td/uni-td.vue +79 -80
  137. package/dist/uni/uni-ui/uni-th/filter-dropdown.vue +510 -503
  138. package/dist/uni/uni-ui/uni-th/uni-th.vue +289 -273
  139. package/dist/uni/uni-ui/uni-thead/uni-thead.vue +115 -114
  140. package/dist/uni/uni-ui/uni-title/uni-title.vue +151 -154
  141. package/dist/uni/uni-ui/uni-tooltip/uni-tooltip.vue +55 -60
  142. package/dist/uni/uni-ui/uni-tr/table-checkbox.vue +162 -163
  143. package/dist/uni/uni-ui/uni-tr/uni-tr.vue +158 -157
  144. package/dist/uni/uni-ui/uni-transition/createAnimation.js +130 -113
  145. package/dist/uni/uni-ui/uni-transition/uni-transition.vue +274 -272
  146. package/package.json +1 -1
@@ -1,298 +1,307 @@
1
1
  <template>
2
- <view class="uni-searchbar">
3
- <view :style="{borderRadius:radius+'px',backgroundColor: bgColor}" class="uni-searchbar__box"
4
- @click="searchClick">
5
- <view class="uni-searchbar__box-icon-search">
6
- <slot name="searchIcon">
7
- <uni-icons color="#c0c4cc" size="18" type="search" />
8
- </slot>
9
- </view>
10
- <input v-if="show || searchVal" :focus="showSync" :disabled="readonly" :placeholder="placeholderText" :maxlength="maxlength"
11
- class="uni-searchbar__box-search-input" confirm-type="search" type="text" v-model="searchVal"
12
- @confirm="confirm" @blur="blur" @focus="emitFocus" />
13
- <text v-else class="uni-searchbar__text-placeholder">{{ placeholder }}</text>
14
- <view v-if="show && (clearButton==='always'||clearButton==='auto'&&searchVal!=='') &&!readonly"
15
- class="uni-searchbar__box-icon-clear" @click="clear">
16
- <slot name="clearIcon">
17
- <uni-icons color="#c0c4cc" size="20" type="clear" />
18
- </slot>
19
- </view>
20
- </view>
21
- <text @click="cancel" class="uni-searchbar__cancel"
22
- v-if="cancelButton ==='always' || show && cancelButton ==='auto'">{{cancelTextI18n}}</text>
23
- </view>
2
+ <view class="uni-searchbar">
3
+ <view :style="{ borderRadius: radius + 'px', backgroundColor: bgColor }" class="uni-searchbar__box" @click="searchClick">
4
+ <view class="uni-searchbar__box-icon-search">
5
+ <slot name="searchIcon">
6
+ <uni-icons color="#c0c4cc" size="18" type="search" />
7
+ </slot>
8
+ </view>
9
+ <input
10
+ v-if="show || searchVal"
11
+ :focus="showSync"
12
+ :disabled="readonly"
13
+ :placeholder="placeholderText"
14
+ :maxlength="maxlength"
15
+ class="uni-searchbar__box-search-input"
16
+ confirm-type="search"
17
+ type="text"
18
+ v-model="searchVal"
19
+ @confirm="confirm"
20
+ @blur="blur"
21
+ @focus="emitFocus"
22
+ />
23
+ <text v-else class="uni-searchbar__text-placeholder">{{ placeholder }}</text>
24
+ <view
25
+ v-if="show && (clearButton === 'always' || (clearButton === 'auto' && searchVal !== '')) && !readonly"
26
+ class="uni-searchbar__box-icon-clear"
27
+ @click="clear"
28
+ >
29
+ <slot name="clearIcon">
30
+ <uni-icons color="#c0c4cc" size="20" type="clear" />
31
+ </slot>
32
+ </view>
33
+ </view>
34
+ <text @click="cancel" class="uni-searchbar__cancel" v-if="cancelButton === 'always' || (show && cancelButton === 'auto')">{{ cancelTextI18n }}</text>
35
+ </view>
24
36
  </template>
25
37
 
26
38
  <script>
27
- import {
28
- initVueI18n
29
- } from '@dcloudio/uni-i18n'
30
- import messages from './i18n'
31
- const {
32
- t
33
- } = initVueI18n(messages)
39
+ import { initVueI18n } from '@dcloudio/uni-i18n';
40
+ import messages from './i18n';
34
41
 
35
- /**
36
- * SearchBar 搜索栏
37
- * @description 搜索栏组件,通常用于搜索商品、文章等
38
- * @tutorial https://ext.dcloud.net.cn/plugin?id=866
39
- * @property {Number} radius 搜索栏圆角
40
- * @property {Number} maxlength 输入最大长度
41
- * @property {String} placeholder 搜索栏Placeholder
42
- * @property {String} clearButton = [always|auto|none] 是否显示清除按钮
43
- * @value always 一直显示
44
- * @value auto 输入框不为空时显示
45
- * @value none 一直不显示
46
- * @property {String} cancelButton = [always|auto|none] 是否显示取消按钮
47
- * @value always 一直显示
48
- * @value auto 输入框不为空时显示
49
- * @value none 一直不显示
50
- * @property {String} cancelText 取消按钮的文字
51
- * @property {String} bgColor 输入框背景颜色
52
- * @property {Boolean} focus 是否自动聚焦
53
- * @property {Boolean} readonly 组件只读,不能有任何操作,只做展示
54
- * @event {Function} confirm uniSearchBar 的输入框 confirm 事件,返回参数为uniSearchBar的value,e={value:Number}
55
- * @event {Function} input uniSearchBar 的 value 改变时触发事件,返回参数为uniSearchBar的value,e=value
56
- * @event {Function} cancel 点击取消按钮时触发事件,返回参数为uniSearchBar的value,e={value:Number}
57
- * @event {Function} clear 点击清除按钮时触发事件,返回参数为uniSearchBar的value,e={value:Number}
58
- * @event {Function} blur input失去焦点时触发事件,返回参数为uniSearchBar的value,e={value:Number}
59
- */
42
+ const { t } = initVueI18n(messages);
60
43
 
61
- export default {
62
- name: "UniSearchBar",
63
- emits: ['input', 'update:modelValue', 'clear', 'cancel', 'confirm', 'blur', 'focus'],
64
- props: {
65
- placeholder: {
66
- type: String,
67
- default: ""
68
- },
69
- radius: {
70
- type: [Number, String],
71
- default: 5
72
- },
73
- clearButton: {
74
- type: String,
75
- default: "auto"
76
- },
77
- cancelButton: {
78
- type: String,
79
- default: "auto"
80
- },
81
- cancelText: {
82
- type: String,
83
- default: '取消'
84
- },
85
- bgColor: {
86
- type: String,
87
- default: "#F8F8F8"
88
- },
89
- maxlength: {
90
- type: [Number, String],
91
- default: 100
92
- },
93
- value: {
94
- type: [Number, String],
95
- default: ""
96
- },
97
- modelValue: {
98
- type: [Number, String],
99
- default: ""
100
- },
101
- focus: {
102
- type: Boolean,
103
- default: false
104
- },
105
- readonly: {
106
- type: Boolean,
107
- default: false
108
- }
109
- },
110
- data() {
111
- return {
112
- show: false,
113
- showSync: false,
114
- searchVal: ''
115
- }
116
- },
117
- computed: {
118
- cancelTextI18n() {
119
- return this.cancelText || t("uni-search-bar.cancel")
120
- },
121
- placeholderText() {
122
- return this.placeholder || t("uni-search-bar.placeholder")
123
- }
124
- },
125
- watch: {
126
- // #ifndef VUE3
127
- value: {
128
- immediate: true,
129
- handler(newVal) {
130
- this.searchVal = newVal
131
- if (newVal) {
132
- this.show = true
133
- }
134
- }
135
- },
136
- // #endif
137
- // #ifdef VUE3
138
- modelValue: {
139
- immediate: true,
140
- handler(newVal) {
141
- this.searchVal = newVal
142
- if (newVal) {
143
- this.show = true
144
- }
145
- }
146
- },
147
- // #endif
148
- focus: {
149
- immediate: true,
150
- handler(newVal) {
151
- if (newVal) {
152
- if(this.readonly) return
153
- this.show = true;
154
- this.$nextTick(() => {
155
- this.showSync = true
156
- })
157
- }
158
- }
159
- },
160
- searchVal(newVal, oldVal) {
161
- this.$emit("input", newVal)
162
- // #ifdef VUE3
163
- this.$emit("update:modelValue", newVal)
164
- // #endif
165
- }
166
- },
167
- methods: {
168
- searchClick() {
169
- if(this.readonly) return
170
- if (this.show) {
171
- return
172
- }
173
- this.show = true;
174
- this.$nextTick(() => {
175
- this.showSync = true
176
- })
177
- },
178
- clear() {
179
- this.$emit("clear", {
180
- value: this.searchVal
181
- })
182
- this.searchVal = ""
183
- },
184
- cancel() {
185
- if(this.readonly) return
186
- this.$emit("cancel", {
187
- value: this.searchVal
188
- });
189
- this.searchVal = ""
190
- this.show = false
191
- this.showSync = false
192
- // #ifndef APP-PLUS
193
- uni.hideKeyboard()
194
- // #endif
195
- // #ifdef APP-PLUS
196
- plus.key.hideSoftKeybord()
197
- // #endif
198
- },
199
- confirm() {
200
- // #ifndef APP-PLUS
201
- uni.hideKeyboard();
202
- // #endif
203
- // #ifdef APP-PLUS
204
- plus.key.hideSoftKeybord()
205
- // #endif
206
- this.$emit("confirm", {
207
- value: this.searchVal
208
- })
209
- },
210
- blur() {
211
- // #ifndef APP-PLUS
212
- uni.hideKeyboard();
213
- // #endif
214
- // #ifdef APP-PLUS
215
- plus.key.hideSoftKeybord()
216
- // #endif
217
- this.$emit("blur", {
218
- value: this.searchVal
219
- })
220
- },
221
- emitFocus(e) {
222
- this.$emit("focus", e.detail)
223
- }
224
- }
225
- };
44
+ /**
45
+ * SearchBar 搜索栏
46
+ * @description 搜索栏组件,通常用于搜索商品、文章等
47
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=866
48
+ * @property {Number} radius 搜索栏圆角
49
+ * @property {Number} maxlength 输入最大长度
50
+ * @property {String} placeholder 搜索栏Placeholder
51
+ * @property {String} clearButton = [always|auto|none] 是否显示清除按钮
52
+ * @value always 一直显示
53
+ * @value auto 输入框不为空时显示
54
+ * @value none 一直不显示
55
+ * @property {String} cancelButton = [always|auto|none] 是否显示取消按钮
56
+ * @value always 一直显示
57
+ * @value auto 输入框不为空时显示
58
+ * @value none 一直不显示
59
+ * @property {String} cancelText 取消按钮的文字
60
+ * @property {String} bgColor 输入框背景颜色
61
+ * @property {Boolean} focus 是否自动聚焦
62
+ * @property {Boolean} readonly 组件只读,不能有任何操作,只做展示
63
+ * @event {Function} confirm uniSearchBar 的输入框 confirm 事件,返回参数为uniSearchBar的value,e={value:Number}
64
+ * @event {Function} input uniSearchBar 的 value 改变时触发事件,返回参数为uniSearchBar的value,e=value
65
+ * @event {Function} cancel 点击取消按钮时触发事件,返回参数为uniSearchBar的value,e={value:Number}
66
+ * @event {Function} clear 点击清除按钮时触发事件,返回参数为uniSearchBar的value,e={value:Number}
67
+ * @event {Function} blur input失去焦点时触发事件,返回参数为uniSearchBar的value,e={value:Number}
68
+ */
69
+
70
+ export default {
71
+ name: 'UniSearchBar',
72
+ emits: ['input', 'update:modelValue', 'clear', 'cancel', 'confirm', 'blur', 'focus'],
73
+ props: {
74
+ placeholder: {
75
+ type: String,
76
+ default: '',
77
+ },
78
+ radius: {
79
+ type: [Number, String],
80
+ default: 5,
81
+ },
82
+ clearButton: {
83
+ type: String,
84
+ default: 'auto',
85
+ },
86
+ cancelButton: {
87
+ type: String,
88
+ default: 'auto',
89
+ },
90
+ cancelText: {
91
+ type: String,
92
+ default: '取消',
93
+ },
94
+ bgColor: {
95
+ type: String,
96
+ default: '#F8F8F8',
97
+ },
98
+ maxlength: {
99
+ type: [Number, String],
100
+ default: 100,
101
+ },
102
+ value: {
103
+ type: [Number, String],
104
+ default: '',
105
+ },
106
+ modelValue: {
107
+ type: [Number, String],
108
+ default: '',
109
+ },
110
+ focus: {
111
+ type: Boolean,
112
+ default: false,
113
+ },
114
+ readonly: {
115
+ type: Boolean,
116
+ default: false,
117
+ },
118
+ },
119
+ data() {
120
+ return {
121
+ show: false,
122
+ showSync: false,
123
+ searchVal: '',
124
+ };
125
+ },
126
+ computed: {
127
+ cancelTextI18n() {
128
+ return this.cancelText || t('uni-search-bar.cancel');
129
+ },
130
+ placeholderText() {
131
+ return this.placeholder || t('uni-search-bar.placeholder');
132
+ },
133
+ },
134
+ watch: {
135
+ // #ifndef VUE3
136
+ value: {
137
+ immediate: true,
138
+ handler(newVal) {
139
+ this.searchVal = newVal;
140
+ if (newVal) {
141
+ this.show = true;
142
+ }
143
+ },
144
+ },
145
+ // #endif
146
+ // #ifdef VUE3
147
+ modelValue: {
148
+ immediate: true,
149
+ handler(newVal) {
150
+ this.searchVal = newVal;
151
+ if (newVal) {
152
+ this.show = true;
153
+ }
154
+ },
155
+ },
156
+ // #endif
157
+ focus: {
158
+ immediate: true,
159
+ handler(newVal) {
160
+ if (newVal) {
161
+ if (this.readonly) return;
162
+ this.show = true;
163
+ this.$nextTick(() => {
164
+ this.showSync = true;
165
+ });
166
+ }
167
+ },
168
+ },
169
+ searchVal(newVal, oldVal) {
170
+ this.$emit('input', newVal);
171
+ // #ifdef VUE3
172
+ this.$emit('update:modelValue', newVal);
173
+ // #endif
174
+ },
175
+ },
176
+ methods: {
177
+ searchClick() {
178
+ if (this.readonly) return;
179
+ if (this.show) {
180
+ return;
181
+ }
182
+ this.show = true;
183
+ this.$nextTick(() => {
184
+ this.showSync = true;
185
+ });
186
+ },
187
+ clear() {
188
+ this.$emit('clear', {
189
+ value: this.searchVal,
190
+ });
191
+ this.searchVal = '';
192
+ },
193
+ cancel() {
194
+ if (this.readonly) return;
195
+ this.$emit('cancel', {
196
+ value: this.searchVal,
197
+ });
198
+ this.searchVal = '';
199
+ this.show = false;
200
+ this.showSync = false;
201
+ // #ifndef APP-PLUS
202
+ uni.hideKeyboard();
203
+ // #endif
204
+ // #ifdef APP-PLUS
205
+ plus.key.hideSoftKeybord();
206
+ // #endif
207
+ },
208
+ confirm() {
209
+ // #ifndef APP-PLUS
210
+ uni.hideKeyboard();
211
+ // #endif
212
+ // #ifdef APP-PLUS
213
+ plus.key.hideSoftKeybord();
214
+ // #endif
215
+ this.$emit('confirm', {
216
+ value: this.searchVal,
217
+ });
218
+ },
219
+ blur() {
220
+ // #ifndef APP-PLUS
221
+ uni.hideKeyboard();
222
+ // #endif
223
+ // #ifdef APP-PLUS
224
+ plus.key.hideSoftKeybord();
225
+ // #endif
226
+ this.$emit('blur', {
227
+ value: this.searchVal,
228
+ });
229
+ },
230
+ emitFocus(e) {
231
+ this.$emit('focus', e.detail);
232
+ },
233
+ },
234
+ };
226
235
  </script>
227
236
 
228
237
  <style lang="scss">
229
- $uni-searchbar-height: 36px;
238
+ $uni-searchbar-height: 36px;
230
239
 
231
- .uni-searchbar {
232
- /* #ifndef APP-NVUE */
233
- display: flex;
234
- /* #endif */
235
- flex-direction: row;
236
- position: relative;
237
- padding: 10px;
238
- // background-color: #fff;
239
- }
240
+ .uni-searchbar {
241
+ /* #ifndef APP-NVUE */
242
+ display: flex;
243
+ /* #endif */
244
+ flex-direction: row;
245
+ position: relative;
246
+ padding: 10px;
247
+ // background-color: #fff;
248
+ }
240
249
 
241
- .uni-searchbar__box {
242
- /* #ifndef APP-NVUE */
243
- display: flex;
244
- box-sizing: border-box;
245
- /* #endif */
246
- overflow: hidden;
247
- position: relative;
248
- flex: 1;
249
- justify-content: center;
250
- flex-direction: row;
251
- align-items: center;
252
- height: $uni-searchbar-height;
253
- padding: 5px 8px 5px 0px;
254
- }
250
+ .uni-searchbar__box {
251
+ /* #ifndef APP-NVUE */
252
+ display: flex;
253
+ box-sizing: border-box;
254
+ /* #endif */
255
+ overflow: hidden;
256
+ position: relative;
257
+ flex: 1;
258
+ justify-content: center;
259
+ flex-direction: row;
260
+ align-items: center;
261
+ height: $uni-searchbar-height;
262
+ padding: 5px 8px 5px 0px;
263
+ }
255
264
 
256
- .uni-searchbar__box-icon-search {
257
- /* #ifndef APP-NVUE */
258
- display: flex;
259
- /* #endif */
260
- flex-direction: row;
261
- // width: 32px;
262
- padding: 0 8px;
263
- justify-content: center;
264
- align-items: center;
265
- color: #B3B3B3;
266
- }
265
+ .uni-searchbar__box-icon-search {
266
+ /* #ifndef APP-NVUE */
267
+ display: flex;
268
+ /* #endif */
269
+ flex-direction: row;
270
+ // width: 32px;
271
+ padding: 0 8px;
272
+ justify-content: center;
273
+ align-items: center;
274
+ color: #b3b3b3;
275
+ }
267
276
 
268
- .uni-searchbar__box-search-input {
269
- flex: 1;
270
- font-size: 14px;
271
- color: #333;
272
- }
277
+ .uni-searchbar__box-search-input {
278
+ flex: 1;
279
+ font-size: 14px;
280
+ color: #333;
281
+ }
273
282
 
274
- .uni-searchbar__box-icon-clear {
275
- align-items: center;
276
- line-height: 24px;
277
- padding-left: 8px;
278
- /* #ifdef H5 */
279
- cursor: pointer;
280
- /* #endif */
281
- }
283
+ .uni-searchbar__box-icon-clear {
284
+ align-items: center;
285
+ line-height: 24px;
286
+ padding-left: 8px;
287
+ /* #ifdef H5 */
288
+ cursor: pointer;
289
+ /* #endif */
290
+ }
282
291
 
283
- .uni-searchbar__text-placeholder {
284
- font-size: 14px;
285
- color: #B3B3B3;
286
- margin-left: 5px;
287
- }
292
+ .uni-searchbar__text-placeholder {
293
+ font-size: 14px;
294
+ color: #b3b3b3;
295
+ margin-left: 5px;
296
+ }
288
297
 
289
- .uni-searchbar__cancel {
290
- padding-left: 10px;
291
- line-height: $uni-searchbar-height;
292
- font-size: 14px;
293
- color: #333333;
294
- /* #ifdef H5 */
295
- cursor: pointer;
296
- /* #endif */
297
- }
298
+ .uni-searchbar__cancel {
299
+ padding-left: 10px;
300
+ line-height: $uni-searchbar-height;
301
+ font-size: 14px;
302
+ color: #333333;
303
+ /* #ifdef H5 */
304
+ cursor: pointer;
305
+ /* #endif */
306
+ }
298
307
  </style>