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