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