hy-app 0.3.0 → 0.3.2
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/README.md +6 -3
- package/common/shakeService.ts +31 -29
- package/components/avatar.zip +0 -0
- package/components/hy-action-sheet/hy-action-sheet.vue +71 -46
- package/components/hy-address-picker/hy-address-picker.vue +94 -83
- package/components/hy-avatar/hy-avatar.vue +84 -85
- package/components/hy-back-top/hy-back-top.vue +8 -6
- package/components/hy-badge/hy-badge.vue +47 -46
- package/components/hy-button/hy-button.vue +117 -93
- package/components/hy-calendar/hy-calendar.vue +168 -160
- package/components/hy-card/hy-card.vue +50 -43
- package/components/hy-card/typing.d.ts +33 -32
- package/components/hy-cell/hy-cell.vue +73 -51
- package/components/hy-check-button/hy-check-button.vue +54 -47
- package/components/hy-checkbox/hy-checkbox.vue +97 -105
- package/components/hy-code-input/hy-code-input.vue +80 -89
- package/components/hy-config-provider/hy-config-provider.vue +20 -21
- package/components/hy-count-down/hy-count-down.vue +66 -67
- package/components/hy-count-to/hy-count-to.vue +105 -99
- package/components/hy-count-to/typing.d.ts +13 -12
- package/components/hy-datetime-picker/hy-datetime-picker.vue +261 -253
- package/components/hy-datetime-picker/typing.d.ts +42 -40
- package/components/hy-divider/hy-divider.vue +68 -73
- package/components/hy-dropdown/hy-dropdown.vue +20 -19
- package/components/hy-dropdown-item/hy-dropdown-item.vue +66 -61
- package/components/hy-dropdown-item/typing.d.ts +9 -9
- package/components/hy-empty/hy-empty.vue +42 -42
- package/components/hy-flex/hy-flex.vue +99 -0
- package/components/hy-flex/index.scss +8 -0
- package/components/hy-flex/typing.d.ts +23 -0
- package/components/hy-float-button/hy-float-button.vue +218 -210
- package/components/hy-folding-panel/hy-folding-panel.vue +32 -33
- package/components/hy-form/hy-form.vue +264 -252
- package/components/hy-form/typing.d.ts +4 -0
- package/components/hy-form-group/hy-form-group.vue +114 -183
- package/components/hy-form-item/hy-form-item.vue +12 -10
- package/components/hy-form-item/index.scss +2 -2
- package/components/hy-form-item/typing.d.ts +3 -6
- package/components/hy-grid/hy-grid.vue +44 -43
- package/components/hy-icon/hy-icon.vue +61 -67
- package/components/hy-image/hy-image.vue +112 -88
- package/components/hy-image/typing.d.ts +27 -23
- package/components/hy-input/hy-input.vue +157 -127
- package/components/hy-input/typing.d.ts +53 -47
- package/components/hy-line/hy-line.vue +26 -26
- package/components/hy-line-progress/hy-line-progress.vue +42 -35
- package/components/hy-list/hy-list.vue +76 -85
- package/components/hy-loading/hy-loading.vue +26 -23
- package/components/hy-login/TheUserLogin.vue +1 -1
- package/components/hy-menu/hy-menu.vue +48 -43
- package/components/hy-menu/typing.d.ts +18 -17
- package/components/hy-modal/hy-modal.vue +39 -35
- package/components/hy-navbar/hy-navbar.vue +25 -25
- package/components/hy-navbar/typing.d.ts +24 -22
- package/components/hy-notice-bar/hy-notice-bar.vue +26 -27
- package/components/hy-notify/hy-notify.vue +53 -53
- package/components/hy-number-step/hy-number-step.vue +134 -146
- package/components/hy-number-step/typing.d.ts +35 -35
- package/components/hy-overlay/hy-overlay.vue +23 -21
- package/components/hy-pagination/hy-pagination.vue +41 -36
- package/components/hy-picker/hy-picker.vue +184 -154
- package/components/hy-picker/typing.d.ts +39 -39
- package/components/hy-popover/hy-popover.vue +97 -77
- package/components/hy-popup/hy-popup.vue +107 -98
- package/components/hy-price/hy-price.vue +38 -34
- package/components/hy-qrcode/hy-qrcode.vue +50 -51
- package/components/hy-radio/hy-radio.vue +101 -113
- package/components/hy-rate/hy-rate.vue +107 -88
- package/components/hy-read-more/hy-read-more.vue +64 -49
- package/components/hy-scroll-list/hy-scroll-list.vue +45 -48
- package/components/hy-search/hy-search.vue +73 -66
- package/components/hy-search/typing.d.ts +36 -35
- package/components/hy-signature/hy-signature.vue +282 -240
- package/components/hy-slider/hy-slider.vue +195 -153
- package/components/hy-slider/typing.d.ts +21 -21
- package/components/hy-steps/hy-steps.vue +118 -90
- package/components/hy-steps/index.scss +31 -21
- package/components/hy-submit-bar/hy-submit-bar.vue +61 -70
- package/components/hy-subsection/hy-subsection.vue +99 -102
- package/components/hy-subsection/typing.d.ts +19 -19
- package/components/hy-swipe-action/hy-swipe-action.vue +131 -118
- package/components/hy-swiper/hy-swiper.vue +85 -71
- package/components/hy-switch/hy-switch.vue +67 -72
- package/components/hy-switch/typing.d.ts +21 -19
- package/components/hy-tabs/hy-tabs.vue +168 -113
- package/components/hy-tag/hy-tag.vue +90 -86
- package/components/hy-tag/typing.d.ts +26 -21
- package/components/hy-text/hy-text.vue +119 -111
- package/components/hy-textarea/hy-textarea.vue +100 -93
- package/components/hy-textarea/typing.d.ts +36 -31
- package/components/hy-toast/hy-toast.vue +77 -67
- package/components/hy-tooltip/hy-tooltip.vue +109 -91
- package/components/hy-transition/hy-transition.vue +62 -66
- package/components/hy-upload/hy-upload.vue +294 -152
- package/components/hy-upload/typing.d.ts +41 -36
- package/components/hy-warn/hy-warn.vue +34 -27
- package/components/hy-waterfall/hy-waterfall.vue +83 -74
- package/components/hy-watermark/hy-watermark.vue +134 -115
- package/components/index.ts +1 -1
- package/composables/usePopover.ts +236 -221
- package/composables/useQueue.ts +53 -52
- package/global.d.ts +1 -0
- package/package.json +2 -2
- package/store/index.ts +9 -1
- package/theme.scss +5 -5
- package/typing/index.ts +0 -1
- package/typing/modules/common.d.ts +0 -2
- package/web-types.json +1 -1
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view
|
|
2
|
+
<view
|
|
3
|
+
:class="['hy-input', inputClass]"
|
|
4
|
+
:style="[wrapperStyle, borderStyle(focused)]"
|
|
5
|
+
>
|
|
3
6
|
<view class="hy-input__content">
|
|
4
7
|
<view
|
|
5
8
|
class="hy-input__content__prefix-icon"
|
|
@@ -34,7 +37,7 @@
|
|
|
34
37
|
:type="type"
|
|
35
38
|
:focus="focus"
|
|
36
39
|
:cursor="cursor"
|
|
37
|
-
:value="innerValue"
|
|
40
|
+
:value="String(innerValue)"
|
|
38
41
|
:auto-blur="autoBlur"
|
|
39
42
|
:disabled="disabled || readonly"
|
|
40
43
|
:maxlength="maxlength"
|
|
@@ -48,7 +51,7 @@
|
|
|
48
51
|
:adjust-position="adjustPosition"
|
|
49
52
|
:selection-end="selectionEnd"
|
|
50
53
|
:selection-start="selectionStart"
|
|
51
|
-
:password="password || type === 'password' || false"
|
|
54
|
+
:password="password || type === 'safe-password' || false"
|
|
52
55
|
:ignoreCompositionEvent="ignoreCompositionEvent"
|
|
53
56
|
@input="onInput"
|
|
54
57
|
@blur="onBlur"
|
|
@@ -57,7 +60,11 @@
|
|
|
57
60
|
@keyboardheightchange="onkeyboardheightchange"
|
|
58
61
|
/>
|
|
59
62
|
</view>
|
|
60
|
-
<view
|
|
63
|
+
<view
|
|
64
|
+
class="hy-input__content__clear"
|
|
65
|
+
v-if="isShowClear"
|
|
66
|
+
@click="onClear"
|
|
67
|
+
>
|
|
61
68
|
<HyIcon
|
|
62
69
|
:name="IconConfig.CLOSE"
|
|
63
70
|
size="11"
|
|
@@ -93,31 +100,46 @@
|
|
|
93
100
|
|
|
94
101
|
<script lang="ts">
|
|
95
102
|
export default {
|
|
96
|
-
name:
|
|
103
|
+
name: "hy-input",
|
|
97
104
|
options: {
|
|
98
105
|
addGlobalClass: true,
|
|
99
106
|
virtualHost: true,
|
|
100
|
-
styleIsolation:
|
|
107
|
+
styleIsolation: "shared",
|
|
101
108
|
},
|
|
102
|
-
}
|
|
109
|
+
};
|
|
103
110
|
</script>
|
|
104
111
|
|
|
105
112
|
<script setup lang="ts">
|
|
106
|
-
import {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
import {
|
|
114
|
+
computed,
|
|
115
|
+
nextTick,
|
|
116
|
+
ref,
|
|
117
|
+
toRefs,
|
|
118
|
+
watch,
|
|
119
|
+
getCurrentInstance,
|
|
120
|
+
inject,
|
|
121
|
+
} from "vue";
|
|
122
|
+
import type { CSSProperties, PropType } from "vue";
|
|
123
|
+
import HyIcon from "../hy-icon/hy-icon.vue";
|
|
124
|
+
import { addUnit, formatObject } from "../../utils";
|
|
125
|
+
import { IconConfig } from "../../config";
|
|
126
|
+
import type { IInputEmits } from "./typing";
|
|
127
|
+
import type HyIconProps from "../hy-icon/typing";
|
|
128
|
+
import type { FormItemContext } from "../hy-form-item/typing";
|
|
129
|
+
import type {
|
|
130
|
+
InputConfirmType,
|
|
131
|
+
InputOnBlurEvent,
|
|
132
|
+
InputOnConfirmEvent,
|
|
133
|
+
InputOnFocusEvent,
|
|
134
|
+
InputOnKeyboardheightchange,
|
|
135
|
+
InputType,
|
|
136
|
+
} from "@uni-helper/uni-types";
|
|
115
137
|
|
|
116
138
|
/**
|
|
117
139
|
* 为一个输入框,利用它可以快速实现表单验证,输入内容,下拉选择等功能。
|
|
118
140
|
* @displayName hy-input
|
|
119
141
|
*/
|
|
120
|
-
defineOptions({})
|
|
142
|
+
defineOptions({});
|
|
121
143
|
|
|
122
144
|
// const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
123
145
|
const props = defineProps({
|
|
@@ -128,11 +150,11 @@ const props = defineProps({
|
|
|
128
150
|
},
|
|
129
151
|
/**
|
|
130
152
|
* 输入框类型,见上方说明
|
|
131
|
-
* @values text,idcard,number,digit,password
|
|
153
|
+
* @values text,idcard,number,digit,safe-password,tel,nickname
|
|
132
154
|
* */
|
|
133
155
|
type: {
|
|
134
|
-
type: String
|
|
135
|
-
default:
|
|
156
|
+
type: String as PropType<InputType>,
|
|
157
|
+
default: "text",
|
|
136
158
|
},
|
|
137
159
|
/** 如果 textarea 是在一个 position:fixed 的区域,需要显示指定属性 fixed 为 true,兼容性:微信小程序、百度小程序、字节跳动小程序、QQ小程序 */
|
|
138
160
|
fixed: {
|
|
@@ -145,7 +167,10 @@ const props = defineProps({
|
|
|
145
167
|
default: false,
|
|
146
168
|
},
|
|
147
169
|
/** 禁用状态时的背景色 */
|
|
148
|
-
disabledColor:
|
|
170
|
+
disabledColor: {
|
|
171
|
+
type: String,
|
|
172
|
+
default: "",
|
|
173
|
+
},
|
|
149
174
|
/** 是否显示清除控件 */
|
|
150
175
|
clearable: {
|
|
151
176
|
type: Boolean,
|
|
@@ -166,12 +191,12 @@ const props = defineProps({
|
|
|
166
191
|
/** 指定placeholder的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/ */
|
|
167
192
|
placeholderClass: {
|
|
168
193
|
type: String,
|
|
169
|
-
default:
|
|
194
|
+
default: "input-placeholder",
|
|
170
195
|
},
|
|
171
196
|
/** 指定placeholder的样式,字符串/对象形式,如"color: red;" */
|
|
172
197
|
placeholderStyle: {
|
|
173
198
|
type: Object as PropType<CSSProperties>,
|
|
174
|
-
default: {},
|
|
199
|
+
default: () => ({}),
|
|
175
200
|
},
|
|
176
201
|
/** 是否显示输入字数统计,只在 type ="text"或type ="textarea"时有效 */
|
|
177
202
|
showWordLimit: {
|
|
@@ -180,8 +205,8 @@ const props = defineProps({
|
|
|
180
205
|
},
|
|
181
206
|
/** 设置右下角按钮的文字,兼容性详见uni-app文档 */
|
|
182
207
|
confirmType: {
|
|
183
|
-
type: String
|
|
184
|
-
default:
|
|
208
|
+
type: String as PropType<InputConfirmType>,
|
|
209
|
+
default: "done",
|
|
185
210
|
},
|
|
186
211
|
/** 点击键盘右下角按钮时是否保持键盘不收起,H5无效 */
|
|
187
212
|
confirmHold: {
|
|
@@ -238,25 +263,28 @@ const props = defineProps({
|
|
|
238
263
|
* @values left,center,right
|
|
239
264
|
* */
|
|
240
265
|
inputAlign: {
|
|
241
|
-
type: String as PropType<
|
|
242
|
-
default:
|
|
266
|
+
type: String as PropType<HyApp.RowCenterType>,
|
|
267
|
+
default: "left",
|
|
243
268
|
},
|
|
244
269
|
/** 输入框字体的大小 */
|
|
245
270
|
fontSize: {
|
|
246
271
|
type: [String, Number],
|
|
247
|
-
default:
|
|
272
|
+
default: "15px",
|
|
248
273
|
},
|
|
249
274
|
/** 输入框字体颜色 */
|
|
250
|
-
color:
|
|
275
|
+
color: {
|
|
276
|
+
type: String,
|
|
277
|
+
default: "",
|
|
278
|
+
},
|
|
251
279
|
/** 输入框前置图标 */
|
|
252
280
|
prefixIcon: {
|
|
253
281
|
type: Object as PropType<HyIconProps>,
|
|
254
|
-
default: {},
|
|
282
|
+
default: () => {},
|
|
255
283
|
},
|
|
256
284
|
/** 输入框后置图标 */
|
|
257
285
|
suffixIcon: {
|
|
258
286
|
type: Object as PropType<HyIconProps>,
|
|
259
|
-
default: {},
|
|
287
|
+
default: () => {},
|
|
260
288
|
},
|
|
261
289
|
/**
|
|
262
290
|
* 边框类型
|
|
@@ -264,7 +292,7 @@ const props = defineProps({
|
|
|
264
292
|
* */
|
|
265
293
|
border: {
|
|
266
294
|
type: String,
|
|
267
|
-
default:
|
|
295
|
+
default: "surround",
|
|
268
296
|
},
|
|
269
297
|
/** 是否只读,与disabled不同之处在于disabled会置灰组件,而readonly则不会 */
|
|
270
298
|
readonly: {
|
|
@@ -277,7 +305,7 @@ const props = defineProps({
|
|
|
277
305
|
* */
|
|
278
306
|
shape: {
|
|
279
307
|
type: String,
|
|
280
|
-
default:
|
|
308
|
+
default: "square",
|
|
281
309
|
},
|
|
282
310
|
/** 是否忽略组件内对文本合成系统事件的处理 */
|
|
283
311
|
ignoreCompositionEvent: {
|
|
@@ -289,94 +317,96 @@ const props = defineProps({
|
|
|
289
317
|
/** 定义需要用到的外部样式 */
|
|
290
318
|
customStyle: {
|
|
291
319
|
type: Object as PropType<CSSProperties>,
|
|
320
|
+
default: () => {},
|
|
292
321
|
},
|
|
293
322
|
/** 自定义外部类名 */
|
|
294
323
|
customClass: String,
|
|
295
|
-
})
|
|
324
|
+
});
|
|
296
325
|
const {
|
|
297
326
|
disabled,
|
|
298
327
|
disabledColor,
|
|
299
328
|
border,
|
|
300
329
|
color,
|
|
301
330
|
inputAlign,
|
|
302
|
-
customStyle,
|
|
303
331
|
fontSize,
|
|
304
332
|
readonly,
|
|
305
333
|
placeholderStyle,
|
|
306
|
-
} = toRefs(props)
|
|
307
|
-
const emit = defineEmits<IInputEmits>()
|
|
308
|
-
const formItem = inject<FormItemContext>(
|
|
334
|
+
} = toRefs(props);
|
|
335
|
+
const emit = defineEmits<IInputEmits>();
|
|
336
|
+
const formItem = inject<FormItemContext | null>("formItem", null);
|
|
309
337
|
|
|
310
|
-
const instance = getCurrentInstance()
|
|
338
|
+
const instance = getCurrentInstance();
|
|
311
339
|
// 清除操作
|
|
312
|
-
const clearInput = ref<boolean>(false)
|
|
340
|
+
const clearInput = ref<boolean>(false);
|
|
313
341
|
// 输入框的值
|
|
314
|
-
const innerValue = ref<string | number>(
|
|
342
|
+
const innerValue = ref<string | number>("");
|
|
315
343
|
// 是否处于获得焦点状态
|
|
316
|
-
const focused = ref<boolean>(false)
|
|
344
|
+
const focused = ref<boolean>(false);
|
|
317
345
|
// value是否第一次变化,在watch中,由于加入immediate属性,会在第一次触发,此时不应该认为value发生了变化
|
|
318
|
-
const firstChange = ref<boolean>(true)
|
|
346
|
+
const firstChange = ref<boolean>(true);
|
|
319
347
|
// value绑定值的变化是由内部还是外部引起的
|
|
320
|
-
const changeFromInner = ref<boolean>(false)
|
|
321
|
-
const innerFormatter = (value: string) => value
|
|
348
|
+
const changeFromInner = ref<boolean>(false);
|
|
349
|
+
const innerFormatter = (value: string) => value;
|
|
322
350
|
|
|
323
351
|
watch(
|
|
324
352
|
() => props.modelValue,
|
|
325
353
|
(newVal) => {
|
|
326
354
|
if (changeFromInner.value || innerValue.value === newVal) {
|
|
327
|
-
changeFromInner.value = false // 重要否则会出现双向绑定失效问题https://github.com/ijry/uview-plus/issues/419
|
|
328
|
-
return
|
|
355
|
+
changeFromInner.value = false; // 重要否则会出现双向绑定失效问题https://github.com/ijry/uview-plus/issues/419
|
|
356
|
+
return;
|
|
329
357
|
}
|
|
330
|
-
innerValue.value = newVal
|
|
358
|
+
innerValue.value = newVal;
|
|
331
359
|
// 在H5中,外部value变化后,修改input中的值,不会触发@input事件,此时手动调用值变化方法
|
|
332
360
|
if (firstChange.value === false && changeFromInner.value === false) {
|
|
333
|
-
valueChange(innerValue.value, true)
|
|
361
|
+
valueChange(innerValue.value, true);
|
|
334
362
|
} else {
|
|
335
363
|
// 尝试调用up-form的验证方法
|
|
336
364
|
// if (!firstChange.value) formValidate(this, "change");
|
|
337
365
|
}
|
|
338
|
-
firstChange.value = false
|
|
366
|
+
firstChange.value = false;
|
|
339
367
|
// 重置changeFromInner的值为false,标识下一次引起默认为外部引起的
|
|
340
|
-
changeFromInner.value = false
|
|
368
|
+
changeFromInner.value = false;
|
|
341
369
|
},
|
|
342
370
|
{ immediate: true },
|
|
343
|
-
)
|
|
371
|
+
);
|
|
344
372
|
|
|
345
373
|
/**
|
|
346
374
|
* @description 是否显示清除控件
|
|
347
375
|
* */
|
|
348
376
|
const isShowClear = computed(() => {
|
|
349
|
-
const { clearable, readonly } = props
|
|
350
|
-
return clearable && !readonly && !!focused.value && innerValue.value !==
|
|
351
|
-
})
|
|
377
|
+
const { clearable, readonly } = props;
|
|
378
|
+
return clearable && !readonly && !!focused.value && innerValue.value !== "";
|
|
379
|
+
});
|
|
352
380
|
/**
|
|
353
381
|
* @description 组件的类名
|
|
354
382
|
* */
|
|
355
383
|
const inputClass = computed((): string => {
|
|
356
384
|
let classes: string[] = [],
|
|
357
|
-
{ border, shape } = props
|
|
358
|
-
border ===
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
385
|
+
{ border, shape } = props;
|
|
386
|
+
border === "surround" &&
|
|
387
|
+
(classes = classes.concat(["hy-border", "hy-input--radius"]));
|
|
388
|
+
classes.push(`hy-input--${shape}`);
|
|
389
|
+
border === "bottom" &&
|
|
390
|
+
(classes = classes.concat(["hy-border__bottom", "hy-input--no-radius"]));
|
|
391
|
+
disabled.value && classes.push("hy-input--disabled");
|
|
392
|
+
return classes.join(" ");
|
|
393
|
+
});
|
|
364
394
|
|
|
365
395
|
/**
|
|
366
396
|
* @description 组件的样式
|
|
367
397
|
* */
|
|
368
398
|
const wrapperStyle = computed((): CSSProperties => {
|
|
369
|
-
const style: CSSProperties = {}
|
|
370
|
-
style.paddingTop =
|
|
371
|
-
style.paddingBottom =
|
|
372
|
-
style.paddingLeft =
|
|
373
|
-
style.paddingRight =
|
|
399
|
+
const style: CSSProperties = {};
|
|
400
|
+
style.paddingTop = "6px";
|
|
401
|
+
style.paddingBottom = "6px";
|
|
402
|
+
style.paddingLeft = "9px";
|
|
403
|
+
style.paddingRight = "9px";
|
|
374
404
|
// 禁用状态下,被背景色加上对应的样式
|
|
375
405
|
if (disabled.value) {
|
|
376
|
-
style.backgroundColor = disabledColor.value
|
|
406
|
+
style.backgroundColor = disabledColor.value;
|
|
377
407
|
}
|
|
378
|
-
return Object.assign(style, customStyle
|
|
379
|
-
})
|
|
408
|
+
return Object.assign(style, props.customStyle);
|
|
409
|
+
});
|
|
380
410
|
/**
|
|
381
411
|
* @description 输入框的样式
|
|
382
412
|
* */
|
|
@@ -385,108 +415,108 @@ const inputStyle = computed((): CSSProperties => {
|
|
|
385
415
|
color: color.value,
|
|
386
416
|
fontSize: addUnit(fontSize.value),
|
|
387
417
|
textAlign: inputAlign.value,
|
|
388
|
-
}
|
|
389
|
-
})
|
|
418
|
+
};
|
|
419
|
+
});
|
|
390
420
|
|
|
391
421
|
/**
|
|
392
422
|
* @description 边框颜色
|
|
393
423
|
* */
|
|
394
424
|
const borderStyle = computed(() => {
|
|
395
425
|
return (isFocus: boolean) => {
|
|
396
|
-
let style: CSSProperties = {}
|
|
426
|
+
let style: CSSProperties = {};
|
|
397
427
|
if (isFocus) {
|
|
398
428
|
switch (border.value) {
|
|
399
|
-
case
|
|
400
|
-
style = { border: `1px solid var(--hy-theme-color, #3c9cff)` }
|
|
401
|
-
break
|
|
402
|
-
case
|
|
403
|
-
style = { borderBottom: `1px solid var(--hy-theme-color, #3c9cff)` }
|
|
404
|
-
break
|
|
429
|
+
case "surround":
|
|
430
|
+
style = { border: `1px solid var(--hy-theme-color, #3c9cff)` };
|
|
431
|
+
break;
|
|
432
|
+
case "bottom":
|
|
433
|
+
style = { borderBottom: `1px solid var(--hy-theme-color, #3c9cff)` };
|
|
434
|
+
break;
|
|
405
435
|
default:
|
|
406
|
-
break
|
|
436
|
+
break;
|
|
407
437
|
}
|
|
408
438
|
}
|
|
409
|
-
return style
|
|
410
|
-
}
|
|
411
|
-
})
|
|
439
|
+
return style;
|
|
440
|
+
};
|
|
441
|
+
});
|
|
412
442
|
|
|
413
443
|
/**
|
|
414
444
|
* @description 当键盘输入时,触发input事件
|
|
415
445
|
*/
|
|
416
446
|
const onInput = (e: any) => {
|
|
417
|
-
let { value =
|
|
447
|
+
let { value = "" } = e.detail || {};
|
|
418
448
|
// 为了避免props的单向数据流特性,需要先将innerValue值设置为当前值,再在$nextTick中重新赋予设置后的值才有效
|
|
419
449
|
// console.log('onInput', value, this.innerValue)
|
|
420
|
-
innerValue.value = value
|
|
450
|
+
innerValue.value = value;
|
|
421
451
|
nextTick(() => {
|
|
422
|
-
let formatValue = innerFormatter(value)
|
|
423
|
-
innerValue.value = formatValue
|
|
424
|
-
valueChange(formatValue)
|
|
425
|
-
})
|
|
426
|
-
}
|
|
452
|
+
let formatValue = innerFormatter(value);
|
|
453
|
+
innerValue.value = formatValue;
|
|
454
|
+
valueChange(formatValue);
|
|
455
|
+
});
|
|
456
|
+
};
|
|
427
457
|
/**
|
|
428
458
|
* @description 输入框失去焦点时触发
|
|
429
459
|
* */
|
|
430
|
-
const onBlur = (event:
|
|
431
|
-
emit(
|
|
432
|
-
formItem.handleBlur(event.detail.value)
|
|
460
|
+
const onBlur = (event: InputOnBlurEvent) => {
|
|
461
|
+
emit("blur", event, event.detail.value);
|
|
462
|
+
if (formItem) formItem.handleBlur(event.detail.value);
|
|
433
463
|
// H5端的blur会先于点击清除控件的点击click事件触发,导致focused
|
|
434
464
|
// 瞬间为false,从而隐藏了清除控件而无法被点击到
|
|
435
465
|
setTimeout(() => {
|
|
436
|
-
focused.value = false
|
|
437
|
-
}, 150)
|
|
438
|
-
}
|
|
466
|
+
focused.value = false;
|
|
467
|
+
}, 150);
|
|
468
|
+
};
|
|
439
469
|
/**
|
|
440
470
|
* @description 输入框聚焦时触发
|
|
441
471
|
* */
|
|
442
|
-
const onFocus = () => {
|
|
443
|
-
focused.value = true
|
|
444
|
-
emit(
|
|
445
|
-
}
|
|
472
|
+
const onFocus = (e: InputOnFocusEvent) => {
|
|
473
|
+
focused.value = true;
|
|
474
|
+
emit("focus", e);
|
|
475
|
+
};
|
|
446
476
|
|
|
447
477
|
/**
|
|
448
478
|
* @description 点击完成按钮时触发
|
|
449
479
|
* */
|
|
450
|
-
const onConfirm = (
|
|
451
|
-
emit(
|
|
452
|
-
}
|
|
480
|
+
const onConfirm = (e: InputOnConfirmEvent) => {
|
|
481
|
+
emit("confirm", e, innerValue.value);
|
|
482
|
+
};
|
|
453
483
|
/**
|
|
454
484
|
* 键盘高度发生变化的时候触发此事件
|
|
455
485
|
* 兼容性:微信小程序2.7.0+、App 3.1.0+
|
|
456
486
|
* */
|
|
457
|
-
const onkeyboardheightchange = (event:
|
|
458
|
-
emit(
|
|
459
|
-
}
|
|
487
|
+
const onkeyboardheightchange = (event: InputOnKeyboardheightchange) => {
|
|
488
|
+
emit("keyboardheightchange", event);
|
|
489
|
+
};
|
|
460
490
|
/**
|
|
461
491
|
* 内容发生变化,进行处理
|
|
462
492
|
*/
|
|
463
493
|
const valueChange = (value: string | number, isOut = false) => {
|
|
464
494
|
if (clearInput.value) {
|
|
465
|
-
innerValue.value =
|
|
466
|
-
clearInput.value = false
|
|
495
|
+
innerValue.value = "";
|
|
496
|
+
clearInput.value = false;
|
|
467
497
|
}
|
|
468
498
|
nextTick(() => {
|
|
469
499
|
if (!isOut || clearInput.value) {
|
|
470
500
|
// 标识value值的变化是由内部引起的
|
|
471
|
-
changeFromInner.value = true
|
|
472
|
-
emit(
|
|
473
|
-
formItem.handleChange(value)
|
|
501
|
+
changeFromInner.value = true;
|
|
502
|
+
emit("change", value);
|
|
503
|
+
if (formItem) formItem.handleChange(value);
|
|
474
504
|
|
|
475
|
-
emit(
|
|
505
|
+
emit("update:modelValue", value);
|
|
476
506
|
}
|
|
477
|
-
})
|
|
478
|
-
}
|
|
507
|
+
});
|
|
508
|
+
};
|
|
479
509
|
/**
|
|
480
510
|
* @description 点击清除控件
|
|
481
511
|
*/
|
|
482
512
|
const onClear = () => {
|
|
483
|
-
clearInput.value = true
|
|
484
|
-
innerValue.value =
|
|
513
|
+
clearInput.value = true;
|
|
514
|
+
innerValue.value = "";
|
|
485
515
|
nextTick(() => {
|
|
486
|
-
valueChange(
|
|
487
|
-
emit(
|
|
488
|
-
})
|
|
489
|
-
}
|
|
516
|
+
valueChange("");
|
|
517
|
+
emit("clear");
|
|
518
|
+
});
|
|
519
|
+
};
|
|
490
520
|
/**
|
|
491
521
|
* 在安卓nvue上,事件无法冒泡
|
|
492
522
|
* 在某些时间,我们希望监听u-from-item的点击事件,此时会导致点击u-form-item内的u-input后
|
|
@@ -495,24 +525,24 @@ const onClear = () => {
|
|
|
495
525
|
const clickHandler = () => {
|
|
496
526
|
// 隐藏键盘
|
|
497
527
|
if (disabled.value || readonly.value) {
|
|
498
|
-
uni.hideKeyboard()
|
|
528
|
+
uni.hideKeyboard();
|
|
499
529
|
}
|
|
500
|
-
}
|
|
530
|
+
};
|
|
501
531
|
|
|
502
532
|
/**
|
|
503
533
|
* @description 点击前缀
|
|
504
534
|
* */
|
|
505
535
|
const onPrefix = () => {
|
|
506
|
-
emit(
|
|
507
|
-
}
|
|
536
|
+
emit("onPrefix");
|
|
537
|
+
};
|
|
508
538
|
/**
|
|
509
539
|
* @description 点击后缀
|
|
510
540
|
* */
|
|
511
541
|
const onSuffix = () => {
|
|
512
|
-
emit(
|
|
513
|
-
}
|
|
542
|
+
emit("onSuffix");
|
|
543
|
+
};
|
|
514
544
|
</script>
|
|
515
545
|
|
|
516
546
|
<style lang="scss" scoped>
|
|
517
|
-
@import
|
|
547
|
+
@import "./index.scss";
|
|
518
548
|
</style>
|