hy-app 0.5.11 → 0.5.13
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-button/hy-button.vue +289 -275
- package/components/hy-button/index.scss +24 -1
- package/components/hy-button/props.ts +143 -135
- package/components/hy-button/typing.d.ts +35 -30
- package/components/hy-coupon/hy-coupon.vue +183 -172
- package/components/hy-coupon/index.scss +20 -23
- package/components/hy-coupon/props.ts +108 -103
- package/components/hy-form/hy-form.vue +220 -220
- package/components/hy-input/hy-input.vue +333 -333
- package/components/hy-input/index.scss +1 -2
- package/components/hy-input/props.ts +186 -186
- package/components/hy-notice-bar/hy-row-notice.vue +121 -121
- package/components/hy-parse/node/node.vue +619 -422
- package/components/hy-parse/parser.js +1253 -1060
- package/components/hy-table/hy-table.vue +579 -358
- package/components/hy-table/index.scss +134 -159
- package/components/hy-table/props.ts +62 -47
- package/components/hy-table/typing.d.ts +29 -34
- package/components/hy-tabs/hy-tabs.vue +335 -335
- package/components/hy-tag/index.scss +1 -0
- package/components/hy-text/hy-text.vue +237 -237
- package/components/hy-text/props.ts +115 -115
- package/components/hy-textarea/hy-textarea.vue +198 -197
- package/components/hy-textarea/index.scss +2 -3
- package/components/hy-toast/hy-toast.vue +190 -190
- package/libs/css/theme.scss +1 -0
- package/libs/css/vars.scss +2 -2
- package/libs/typing/modules/common.d.ts +139 -139
- package/libs/utils/inside.ts +336 -350
- package/package.json +2 -2
- package/web-types.json +1 -1
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
import type { CSSProperties, PropType } from 'vue'
|
|
2
|
-
|
|
3
|
-
const textProps = {
|
|
4
|
-
/** 显示的值 */
|
|
5
|
-
text: {
|
|
6
|
-
type: [String, Number],
|
|
7
|
-
default: '',
|
|
8
|
-
required: true
|
|
9
|
-
},
|
|
10
|
-
/**
|
|
11
|
-
* 主题颜色
|
|
12
|
-
* @values primary,success,error,warning,info
|
|
13
|
-
* */
|
|
14
|
-
type: String,
|
|
15
|
-
/** 是否显示 */
|
|
16
|
-
show: {
|
|
17
|
-
type: Boolean,
|
|
18
|
-
default: true
|
|
19
|
-
},
|
|
20
|
-
/** 前置图标 */
|
|
21
|
-
prefixIcon: String,
|
|
22
|
-
/** 后置图标 */
|
|
23
|
-
suffixIcon: String,
|
|
24
|
-
/**
|
|
25
|
-
* 文本处理的匹配模式
|
|
26
|
-
* @values
|
|
27
|
-
* */
|
|
28
|
-
mode: {
|
|
29
|
-
type: String,
|
|
30
|
-
default: 'text'
|
|
31
|
-
},
|
|
32
|
-
/** mode=link下,配置的链接 */
|
|
33
|
-
href: {
|
|
34
|
-
type: String,
|
|
35
|
-
default: ''
|
|
36
|
-
},
|
|
37
|
-
/** 格式化规则 */
|
|
38
|
-
format: {
|
|
39
|
-
type: [Function, String],
|
|
40
|
-
default: ''
|
|
41
|
-
},
|
|
42
|
-
/** mode=phone时,点击文本是否拨打电话 */
|
|
43
|
-
call: {
|
|
44
|
-
type: Boolean,
|
|
45
|
-
default: false
|
|
46
|
-
},
|
|
47
|
-
/** 小程序的打开方式 */
|
|
48
|
-
openType: String,
|
|
49
|
-
/** 是否粗体,默认normal */
|
|
50
|
-
bold: {
|
|
51
|
-
type: Boolean,
|
|
52
|
-
default: false
|
|
53
|
-
},
|
|
54
|
-
/** 是否块状 */
|
|
55
|
-
block: {
|
|
56
|
-
type: Boolean,
|
|
57
|
-
default: false
|
|
58
|
-
},
|
|
59
|
-
/** 文本显示的行数,如果设置,超出此行数,将会显示省略号 */
|
|
60
|
-
lines: {
|
|
61
|
-
type: [String, Number],
|
|
62
|
-
default: ''
|
|
63
|
-
},
|
|
64
|
-
/** 文本颜色 */
|
|
65
|
-
color: String,
|
|
66
|
-
/** 字体大小 */
|
|
67
|
-
size: {
|
|
68
|
-
type: [String, Number],
|
|
69
|
-
default: 15
|
|
70
|
-
},
|
|
71
|
-
/** 图标的样式 */
|
|
72
|
-
iconStyle: {
|
|
73
|
-
type: Object as PropType<CSSProperties>,
|
|
74
|
-
default: () => ({ fontSize: '15px' })
|
|
75
|
-
},
|
|
76
|
-
/**
|
|
77
|
-
* 文字装饰,下划线,中划线等,可选值
|
|
78
|
-
* @values none,underline,line-through
|
|
79
|
-
* */
|
|
80
|
-
decoration: String,
|
|
81
|
-
/** 外边距,对象、字符串,数值形式均可 */
|
|
82
|
-
margin: String,
|
|
83
|
-
/** 文本行高 */
|
|
84
|
-
lineHeight: String,
|
|
85
|
-
/**
|
|
86
|
-
* 文本对齐方式
|
|
87
|
-
* @values left,center,right
|
|
88
|
-
* */
|
|
89
|
-
align: {
|
|
90
|
-
type: String,
|
|
91
|
-
default: 'left'
|
|
92
|
-
},
|
|
93
|
-
/**
|
|
94
|
-
* 文字换行
|
|
95
|
-
* @values normal,break-word,anywhere
|
|
96
|
-
* */
|
|
97
|
-
wordWrap: {
|
|
98
|
-
type: String,
|
|
99
|
-
default: 'normal'
|
|
100
|
-
},
|
|
101
|
-
/** 是否占满剩余空间 */
|
|
102
|
-
flex: {
|
|
103
|
-
type: Boolean,
|
|
104
|
-
default: true
|
|
105
|
-
},
|
|
106
|
-
/** 定义需要用到的外部样式 */
|
|
107
|
-
customStyle: {
|
|
108
|
-
type: Object as PropType<CSSProperties>,
|
|
109
|
-
default: () => {}
|
|
110
|
-
},
|
|
111
|
-
/** 自定义外部类名 */
|
|
112
|
-
customClass: String
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export default textProps
|
|
1
|
+
import type { CSSProperties, PropType } from 'vue'
|
|
2
|
+
|
|
3
|
+
const textProps = {
|
|
4
|
+
/** 显示的值 */
|
|
5
|
+
text: {
|
|
6
|
+
type: [String, Number],
|
|
7
|
+
default: '',
|
|
8
|
+
required: true
|
|
9
|
+
},
|
|
10
|
+
/**
|
|
11
|
+
* 主题颜色
|
|
12
|
+
* @values primary,success,error,warning,info
|
|
13
|
+
* */
|
|
14
|
+
type: String,
|
|
15
|
+
/** 是否显示 */
|
|
16
|
+
show: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: true
|
|
19
|
+
},
|
|
20
|
+
/** 前置图标 */
|
|
21
|
+
prefixIcon: String,
|
|
22
|
+
/** 后置图标 */
|
|
23
|
+
suffixIcon: String,
|
|
24
|
+
/**
|
|
25
|
+
* 文本处理的匹配模式
|
|
26
|
+
* @values test,price,phone,name,date,link
|
|
27
|
+
* */
|
|
28
|
+
mode: {
|
|
29
|
+
type: String,
|
|
30
|
+
default: 'text'
|
|
31
|
+
},
|
|
32
|
+
/** mode=link下,配置的链接 */
|
|
33
|
+
href: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: ''
|
|
36
|
+
},
|
|
37
|
+
/** 格式化规则 */
|
|
38
|
+
format: {
|
|
39
|
+
type: [Function, String],
|
|
40
|
+
default: ''
|
|
41
|
+
},
|
|
42
|
+
/** mode=phone时,点击文本是否拨打电话 */
|
|
43
|
+
call: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
default: false
|
|
46
|
+
},
|
|
47
|
+
/** 小程序的打开方式 */
|
|
48
|
+
openType: String,
|
|
49
|
+
/** 是否粗体,默认normal */
|
|
50
|
+
bold: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: false
|
|
53
|
+
},
|
|
54
|
+
/** 是否块状 */
|
|
55
|
+
block: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: false
|
|
58
|
+
},
|
|
59
|
+
/** 文本显示的行数,如果设置,超出此行数,将会显示省略号 */
|
|
60
|
+
lines: {
|
|
61
|
+
type: [String, Number],
|
|
62
|
+
default: ''
|
|
63
|
+
},
|
|
64
|
+
/** 文本颜色 */
|
|
65
|
+
color: String,
|
|
66
|
+
/** 字体大小 */
|
|
67
|
+
size: {
|
|
68
|
+
type: [String, Number],
|
|
69
|
+
default: 15
|
|
70
|
+
},
|
|
71
|
+
/** 图标的样式 */
|
|
72
|
+
iconStyle: {
|
|
73
|
+
type: Object as PropType<CSSProperties>,
|
|
74
|
+
default: () => ({ fontSize: '15px' })
|
|
75
|
+
},
|
|
76
|
+
/**
|
|
77
|
+
* 文字装饰,下划线,中划线等,可选值
|
|
78
|
+
* @values none,underline,line-through
|
|
79
|
+
* */
|
|
80
|
+
decoration: String,
|
|
81
|
+
/** 外边距,对象、字符串,数值形式均可 */
|
|
82
|
+
margin: String,
|
|
83
|
+
/** 文本行高 */
|
|
84
|
+
lineHeight: String,
|
|
85
|
+
/**
|
|
86
|
+
* 文本对齐方式
|
|
87
|
+
* @values left,center,right
|
|
88
|
+
* */
|
|
89
|
+
align: {
|
|
90
|
+
type: String,
|
|
91
|
+
default: 'left'
|
|
92
|
+
},
|
|
93
|
+
/**
|
|
94
|
+
* 文字换行
|
|
95
|
+
* @values normal,break-word,anywhere
|
|
96
|
+
* */
|
|
97
|
+
wordWrap: {
|
|
98
|
+
type: String,
|
|
99
|
+
default: 'normal'
|
|
100
|
+
},
|
|
101
|
+
/** 是否占满剩余空间 */
|
|
102
|
+
flex: {
|
|
103
|
+
type: Boolean,
|
|
104
|
+
default: true
|
|
105
|
+
},
|
|
106
|
+
/** 定义需要用到的外部样式 */
|
|
107
|
+
customStyle: {
|
|
108
|
+
type: Object as PropType<CSSProperties>,
|
|
109
|
+
default: () => {}
|
|
110
|
+
},
|
|
111
|
+
/** 自定义外部类名 */
|
|
112
|
+
customClass: String
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export default textProps
|
|
@@ -1,197 +1,198 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view
|
|
3
|
-
:class="['hy-textarea', customClass, textareaClass]"
|
|
4
|
-
:style="[textareaStyle, borderStyle(isFocus)]"
|
|
5
|
-
>
|
|
6
|
-
<textarea
|
|
7
|
-
:class="['hy-textarea__field', disabled && 'hy-textarea__disabled-
|
|
8
|
-
:value="innerValue"
|
|
9
|
-
:style="`height: ${autoHeight ? 'auto' : addUnit(height)}`"
|
|
10
|
-
:placeholder="placeholder || ''"
|
|
11
|
-
:placeholder-style="placeholderStyle"
|
|
12
|
-
:placeholder-class="placeholderClass"
|
|
13
|
-
:disabled="disabled"
|
|
14
|
-
:focus="focus"
|
|
15
|
-
:autoHeight="autoHeight"
|
|
16
|
-
:fixed="fixed"
|
|
17
|
-
:cursorSpacing="cursorSpacing"
|
|
18
|
-
:cursor="cursor"
|
|
19
|
-
:showConfirmBar="showConfirmBar"
|
|
20
|
-
:selectionStart="selectionStart"
|
|
21
|
-
:selectionEnd="selectionEnd"
|
|
22
|
-
:adjustPosition="adjustPosition"
|
|
23
|
-
:disableDefaultPadding="disableDefaultPadding"
|
|
24
|
-
:holdKeyboard="holdKeyboard"
|
|
25
|
-
:maxlength="maxlength"
|
|
26
|
-
:confirm-type="confirmType"
|
|
27
|
-
@focus="onFocus"
|
|
28
|
-
@blur="onBlur"
|
|
29
|
-
@linechange="onLineChange"
|
|
30
|
-
@input="onInput"
|
|
31
|
-
@confirm="onConfirm"
|
|
32
|
-
@keyboardheightchange="onKeyboardheightchange"
|
|
33
|
-
></textarea>
|
|
34
|
-
<!-- #ifndef MP-ALIPAY -->
|
|
35
|
-
<text
|
|
36
|
-
class="hy-textarea__count"
|
|
37
|
-
:style="{
|
|
38
|
-
'background-color': disabled ? 'transparent' : ''
|
|
39
|
-
}"
|
|
40
|
-
v-if="count"
|
|
41
|
-
>
|
|
42
|
-
{{ innerValue.length }}/{{ maxlength }}
|
|
43
|
-
</text>
|
|
44
|
-
<!-- #endif -->
|
|
45
|
-
</view>
|
|
46
|
-
</template>
|
|
47
|
-
|
|
48
|
-
<script lang="ts">
|
|
49
|
-
export default {
|
|
50
|
-
name: 'hy-textarea',
|
|
51
|
-
options: {
|
|
52
|
-
addGlobalClass: true,
|
|
53
|
-
virtualHost: true,
|
|
54
|
-
styleIsolation: 'shared'
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
</script>
|
|
58
|
-
|
|
59
|
-
<script setup lang="ts">
|
|
60
|
-
import { computed, ref, watch, nextTick, inject } from 'vue'
|
|
61
|
-
import type { CSSProperties } from 'vue'
|
|
62
|
-
import type { ITextareaEmits } from './typing'
|
|
63
|
-
import { addUnit } from '../../libs'
|
|
64
|
-
import type { FormItemContext } from '../hy-form-item/typing'
|
|
65
|
-
import type {
|
|
66
|
-
InputOnBlurEvent,
|
|
67
|
-
InputOnConfirmEvent,
|
|
68
|
-
InputOnFocusEvent,
|
|
69
|
-
InputOnKeyboardheightchangeEvent
|
|
70
|
-
} from '@uni-helper/uni-types'
|
|
71
|
-
import textareaProps from './props'
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* 用于输入多行文本信息,聊天输入框等。
|
|
75
|
-
* @displayName hy-textarea
|
|
76
|
-
*/
|
|
77
|
-
defineOptions({})
|
|
78
|
-
|
|
79
|
-
const props = defineProps(textareaProps)
|
|
80
|
-
const emit = defineEmits<ITextareaEmits>()
|
|
81
|
-
const formItem = inject<FormItemContext>('formItem')
|
|
82
|
-
|
|
83
|
-
// 输入框的值
|
|
84
|
-
const innerValue = ref<string>('')
|
|
85
|
-
// value是否第一次变化,在watch中,由于加入immediate属性,会在第一次触发,此时不应该认为value发生了变化
|
|
86
|
-
const firstChange = ref<boolean>(true)
|
|
87
|
-
// value绑定值的变化是由内部还是外部引起的
|
|
88
|
-
const changeFromInner = ref<boolean>(false)
|
|
89
|
-
// 是否获取焦点
|
|
90
|
-
const isFocus = ref<boolean>(false)
|
|
91
|
-
// 过滤处理方法
|
|
92
|
-
let innerFormatter = (value: string) => value
|
|
93
|
-
|
|
94
|
-
watch(
|
|
95
|
-
() => props.modelValue,
|
|
96
|
-
(newVal) => {
|
|
97
|
-
innerValue.value = newVal
|
|
98
|
-
/* #ifdef H5 */
|
|
99
|
-
// 在H5中,外部value变化后,修改input中的值,不会触发@input事件,此时手动调用值变化方法
|
|
100
|
-
if (firstChange.value === false && changeFromInner.value === false) {
|
|
101
|
-
valueChange()
|
|
102
|
-
}
|
|
103
|
-
/* #endif */
|
|
104
|
-
firstChange.value = false
|
|
105
|
-
// 重置changeFromInner的值为false,标识下一次引起默认为外部引起的
|
|
106
|
-
changeFromInner.value = false
|
|
107
|
-
},
|
|
108
|
-
{ immediate: true }
|
|
109
|
-
)
|
|
110
|
-
|
|
111
|
-
// 组件的类名
|
|
112
|
-
const textareaClass = computed(() => {
|
|
113
|
-
let classes: string[] = []
|
|
114
|
-
props.border === 'surround' &&
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
*
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
//
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
innerValue
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
*
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
:class="['hy-textarea', customClass, textareaClass]"
|
|
4
|
+
:style="[textareaStyle, borderStyle(isFocus)]"
|
|
5
|
+
>
|
|
6
|
+
<textarea
|
|
7
|
+
:class="['hy-textarea__field', disabled && 'hy-textarea__disabled-test']"
|
|
8
|
+
:value="innerValue"
|
|
9
|
+
:style="`height: ${autoHeight ? 'auto' : addUnit(height)}`"
|
|
10
|
+
:placeholder="placeholder || ''"
|
|
11
|
+
:placeholder-style="placeholderStyle"
|
|
12
|
+
:placeholder-class="placeholderClass"
|
|
13
|
+
:disabled="disabled"
|
|
14
|
+
:focus="focus"
|
|
15
|
+
:autoHeight="autoHeight"
|
|
16
|
+
:fixed="fixed"
|
|
17
|
+
:cursorSpacing="cursorSpacing"
|
|
18
|
+
:cursor="cursor"
|
|
19
|
+
:showConfirmBar="showConfirmBar"
|
|
20
|
+
:selectionStart="selectionStart"
|
|
21
|
+
:selectionEnd="selectionEnd"
|
|
22
|
+
:adjustPosition="adjustPosition"
|
|
23
|
+
:disableDefaultPadding="disableDefaultPadding"
|
|
24
|
+
:holdKeyboard="holdKeyboard"
|
|
25
|
+
:maxlength="maxlength"
|
|
26
|
+
:confirm-type="confirmType"
|
|
27
|
+
@focus="onFocus"
|
|
28
|
+
@blur="onBlur"
|
|
29
|
+
@linechange="onLineChange"
|
|
30
|
+
@input="onInput"
|
|
31
|
+
@confirm="onConfirm"
|
|
32
|
+
@keyboardheightchange="onKeyboardheightchange"
|
|
33
|
+
></textarea>
|
|
34
|
+
<!-- #ifndef MP-ALIPAY -->
|
|
35
|
+
<text
|
|
36
|
+
class="hy-textarea__count"
|
|
37
|
+
:style="{
|
|
38
|
+
'background-color': disabled ? 'transparent' : ''
|
|
39
|
+
}"
|
|
40
|
+
v-if="count"
|
|
41
|
+
>
|
|
42
|
+
{{ innerValue.length }}/{{ maxlength }}
|
|
43
|
+
</text>
|
|
44
|
+
<!-- #endif -->
|
|
45
|
+
</view>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<script lang="ts">
|
|
49
|
+
export default {
|
|
50
|
+
name: 'hy-textarea',
|
|
51
|
+
options: {
|
|
52
|
+
addGlobalClass: true,
|
|
53
|
+
virtualHost: true,
|
|
54
|
+
styleIsolation: 'shared'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<script setup lang="ts">
|
|
60
|
+
import { computed, ref, watch, nextTick, inject } from 'vue'
|
|
61
|
+
import type { CSSProperties } from 'vue'
|
|
62
|
+
import type { ITextareaEmits } from './typing'
|
|
63
|
+
import { addUnit } from '../../libs'
|
|
64
|
+
import type { FormItemContext } from '../hy-form-item/typing'
|
|
65
|
+
import type {
|
|
66
|
+
InputOnBlurEvent,
|
|
67
|
+
InputOnConfirmEvent,
|
|
68
|
+
InputOnFocusEvent,
|
|
69
|
+
InputOnKeyboardheightchangeEvent
|
|
70
|
+
} from '@uni-helper/uni-types'
|
|
71
|
+
import textareaProps from './props'
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 用于输入多行文本信息,聊天输入框等。
|
|
75
|
+
* @displayName hy-textarea
|
|
76
|
+
*/
|
|
77
|
+
defineOptions({})
|
|
78
|
+
|
|
79
|
+
const props = defineProps(textareaProps)
|
|
80
|
+
const emit = defineEmits<ITextareaEmits>()
|
|
81
|
+
const formItem = inject<FormItemContext>('formItem')
|
|
82
|
+
|
|
83
|
+
// 输入框的值
|
|
84
|
+
const innerValue = ref<string>('')
|
|
85
|
+
// value是否第一次变化,在watch中,由于加入immediate属性,会在第一次触发,此时不应该认为value发生了变化
|
|
86
|
+
const firstChange = ref<boolean>(true)
|
|
87
|
+
// value绑定值的变化是由内部还是外部引起的
|
|
88
|
+
const changeFromInner = ref<boolean>(false)
|
|
89
|
+
// 是否获取焦点
|
|
90
|
+
const isFocus = ref<boolean>(false)
|
|
91
|
+
// 过滤处理方法
|
|
92
|
+
let innerFormatter = (value: string) => value
|
|
93
|
+
|
|
94
|
+
watch(
|
|
95
|
+
() => props.modelValue,
|
|
96
|
+
(newVal) => {
|
|
97
|
+
innerValue.value = newVal
|
|
98
|
+
/* #ifdef H5 */
|
|
99
|
+
// 在H5中,外部value变化后,修改input中的值,不会触发@input事件,此时手动调用值变化方法
|
|
100
|
+
if (firstChange.value === false && changeFromInner.value === false) {
|
|
101
|
+
valueChange()
|
|
102
|
+
}
|
|
103
|
+
/* #endif */
|
|
104
|
+
firstChange.value = false
|
|
105
|
+
// 重置changeFromInner的值为false,标识下一次引起默认为外部引起的
|
|
106
|
+
changeFromInner.value = false
|
|
107
|
+
},
|
|
108
|
+
{ immediate: true }
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
// 组件的类名
|
|
112
|
+
const textareaClass = computed(() => {
|
|
113
|
+
let classes: string[] = []
|
|
114
|
+
props.border === 'surround' &&
|
|
115
|
+
(classes = classes.concat(['hy-textarea__border', 'hy-textarea__radius']))
|
|
116
|
+
props.border === 'bottom' &&
|
|
117
|
+
(classes = classes.concat(['hy-border__bottom', 'hy-textarea__no-radius']))
|
|
118
|
+
props.disabled && classes.push('hy-textarea__disabled')
|
|
119
|
+
return classes.join(' ')
|
|
120
|
+
})
|
|
121
|
+
// 组件的样式
|
|
122
|
+
const textareaStyle = computed(() => {
|
|
123
|
+
const style: CSSProperties = {}
|
|
124
|
+
|
|
125
|
+
return Object.assign(style, props.customStyle)
|
|
126
|
+
})
|
|
127
|
+
/**
|
|
128
|
+
* @description 边框颜色
|
|
129
|
+
* */
|
|
130
|
+
const borderStyle = computed(() => {
|
|
131
|
+
return (isFocus: boolean) => {
|
|
132
|
+
let style: CSSProperties = {}
|
|
133
|
+
if (isFocus) {
|
|
134
|
+
switch (props.border) {
|
|
135
|
+
case 'surround':
|
|
136
|
+
style = { border: `1px solid var(--hy-theme-color, #3c9cff)` }
|
|
137
|
+
break
|
|
138
|
+
case 'bottom':
|
|
139
|
+
style = { borderBottom: `1px solid var(--hy-theme-color, #3c9cff)` }
|
|
140
|
+
break
|
|
141
|
+
default:
|
|
142
|
+
break
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return style
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
const onFocus = (e: InputOnFocusEvent) => {
|
|
150
|
+
isFocus.value = true
|
|
151
|
+
emit('focus', e)
|
|
152
|
+
}
|
|
153
|
+
const onBlur = (e: InputOnBlurEvent) => {
|
|
154
|
+
isFocus.value = false
|
|
155
|
+
emit('blur', e)
|
|
156
|
+
if (formItem) formItem.handleBlur(e.detail.value)
|
|
157
|
+
// 尝试调用u-form的验证方法
|
|
158
|
+
// formValidate(this, "blur");
|
|
159
|
+
}
|
|
160
|
+
const onLineChange = (e: any) => {
|
|
161
|
+
emit('lineChange', e)
|
|
162
|
+
}
|
|
163
|
+
const onInput = (e: any) => {
|
|
164
|
+
let { value } = e?.detail
|
|
165
|
+
// 格式化过滤方法
|
|
166
|
+
const format = props.formatter || innerFormatter
|
|
167
|
+
const formatValue = format(value)
|
|
168
|
+
// 为了避免props的单向数据流特性,需要先将innerValue值设置为当前值,再在$nextTick中重新赋予设置后的值才有效
|
|
169
|
+
innerValue.value = value
|
|
170
|
+
nextTick(() => {
|
|
171
|
+
innerValue.value = formatValue
|
|
172
|
+
valueChange()
|
|
173
|
+
})
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* @description 内容发生变化,进行处理
|
|
177
|
+
* */
|
|
178
|
+
const valueChange = () => {
|
|
179
|
+
const value = innerValue.value
|
|
180
|
+
nextTick(() => {
|
|
181
|
+
emit('update:modelValue', value)
|
|
182
|
+
// 标识value值的变化是由内部引起的
|
|
183
|
+
changeFromInner.value = true
|
|
184
|
+
emit('change', value)
|
|
185
|
+
if (formItem) formItem.handleChange(value)
|
|
186
|
+
})
|
|
187
|
+
}
|
|
188
|
+
const onConfirm = (e: InputOnConfirmEvent) => {
|
|
189
|
+
emit('confirm', e)
|
|
190
|
+
}
|
|
191
|
+
const onKeyboardheightchange = (e: InputOnKeyboardheightchangeEvent) => {
|
|
192
|
+
emit('keyboardheightchange', e)
|
|
193
|
+
}
|
|
194
|
+
</script>
|
|
195
|
+
|
|
196
|
+
<style lang="scss" scoped>
|
|
197
|
+
@import './index.scss';
|
|
198
|
+
</style>
|