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.
Files changed (211) hide show
  1. package/components/hy-action-sheet/hy-action-sheet.vue +155 -238
  2. package/components/hy-action-sheet/props.ts +68 -15
  3. package/components/hy-action-sheet/typing.d.ts +115 -115
  4. package/components/hy-address-picker/hy-address-picker.vue +185 -289
  5. package/components/hy-address-picker/props.ts +97 -21
  6. package/components/hy-address-picker/typing.d.ts +90 -89
  7. package/components/hy-avatar/hy-avatar.vue +121 -204
  8. package/components/hy-avatar/props.ts +76 -18
  9. package/components/hy-avatar/typing.d.ts +63 -62
  10. package/components/hy-back-top/hy-back-top.vue +65 -120
  11. package/components/hy-back-top/props.ts +57 -16
  12. package/components/hy-back-top/typing.d.ts +43 -42
  13. package/components/hy-badge/hy-badge.vue +66 -138
  14. package/components/hy-badge/props.ts +73 -17
  15. package/components/hy-badge/typing.d.ts +59 -58
  16. package/components/hy-button/hy-button.vue +226 -375
  17. package/components/hy-button/props.ts +129 -158
  18. package/components/hy-calendar/header.vue +48 -64
  19. package/components/hy-calendar/hy-calendar.vue +274 -438
  20. package/components/hy-calendar/month.vue +508 -516
  21. package/components/hy-calendar/props.ts +157 -35
  22. package/components/hy-calendar/typing.d.ts +129 -128
  23. package/components/hy-card/hy-card.vue +118 -240
  24. package/components/hy-card/index.scss +1 -2
  25. package/components/hy-card/props.ts +122 -27
  26. package/components/hy-card/typing.d.ts +119 -118
  27. package/components/hy-cell/hy-cell.vue +176 -258
  28. package/components/hy-cell/props.ts +71 -17
  29. package/components/hy-cell/typing.d.ts +87 -86
  30. package/components/hy-check-button/hy-check-button.vue +69 -139
  31. package/components/hy-check-button/props.ts +72 -18
  32. package/components/hy-check-button/typing.d.ts +74 -73
  33. package/components/hy-checkbox/hy-checkbox.vue +170 -263
  34. package/components/hy-checkbox/props.ts +94 -24
  35. package/components/hy-checkbox/typing.d.ts +72 -72
  36. package/components/hy-checkbox-group/hy-checkbox-group.vue +25 -100
  37. package/components/hy-checkbox-group/props.ts +80 -0
  38. package/components/hy-checkbox-group/typing.d.ts +65 -65
  39. package/components/hy-checkbox-item/hy-checkbox-item.vue +140 -177
  40. package/components/hy-checkbox-item/props.ts +24 -0
  41. package/components/hy-checkbox-item/typing.d.ts +4 -3
  42. package/components/hy-code-input/hy-code-input.vue +179 -262
  43. package/components/hy-code-input/props.ts +84 -18
  44. package/components/hy-code-input/typing.d.ts +71 -71
  45. package/components/hy-config-provider/hy-config-provider.vue +28 -50
  46. package/components/hy-config-provider/props.ts +26 -11
  47. package/components/hy-config-provider/typing.d.ts +20 -20
  48. package/components/hy-count-down/hy-count-down.vue +103 -131
  49. package/components/hy-count-down/props.ts +30 -8
  50. package/components/hy-count-down/typing.d.ts +25 -25
  51. package/components/hy-count-to/hy-count-to.vue +148 -213
  52. package/components/hy-count-to/props.ts +60 -15
  53. package/components/hy-count-to/typing.d.ts +46 -46
  54. package/components/hy-coupon/README.md +133 -0
  55. package/components/hy-coupon/hy-coupon.vue +180 -0
  56. package/components/hy-coupon/index.scss +553 -0
  57. package/components/hy-coupon/props.ts +129 -0
  58. package/components/hy-coupon/typing.d.ts +146 -0
  59. package/components/hy-datetime-picker/hy-datetime-picker.vue +415 -580
  60. package/components/hy-datetime-picker/props.ts +142 -32
  61. package/components/hy-datetime-picker/typing.d.ts +132 -132
  62. package/components/hy-divider/hy-divider.vue +90 -169
  63. package/components/hy-divider/props.ts +78 -19
  64. package/components/hy-divider/typing.d.ts +60 -60
  65. package/components/hy-dropdown/hy-dropdown.vue +37 -71
  66. package/components/hy-dropdown/props.ts +38 -15
  67. package/components/hy-dropdown/typing.d.ts +44 -44
  68. package/components/hy-dropdown-item/hy-dropdown-item.vue +141 -173
  69. package/components/hy-dropdown-item/props.ts +19 -8
  70. package/components/hy-empty/hy-empty.vue +75 -129
  71. package/components/hy-empty/props.ts +57 -15
  72. package/components/hy-empty/typing.d.ts +84 -84
  73. package/components/hy-flex/hy-flex.vue +33 -88
  74. package/components/hy-flex/props.ts +58 -0
  75. package/components/hy-flex/typing.d.ts +14 -16
  76. package/components/hy-float-button/hy-float-button.vue +289 -406
  77. package/components/hy-float-button/props.ts +109 -25
  78. package/components/hy-folding-panel/hy-folding-panel.vue +86 -374
  79. package/components/hy-folding-panel/props.ts +40 -15
  80. package/components/hy-folding-panel/typing.d.ts +52 -63
  81. package/components/hy-folding-panel-item/hy-folding-panel-item.vue +186 -228
  82. package/components/hy-folding-panel-item/index.scss +87 -0
  83. package/components/hy-folding-panel-item/props.ts +81 -0
  84. package/components/hy-folding-panel-item/typing.d.ts +23 -0
  85. package/components/hy-form/hy-form.vue +172 -212
  86. package/components/hy-form/props.ts +37 -0
  87. package/components/hy-form/typing.d.ts +68 -61
  88. package/components/hy-form-group/typing.d.ts +74 -74
  89. package/components/hy-form-item/hy-form-item.vue +100 -129
  90. package/components/hy-form-item/props.ts +25 -0
  91. package/components/hy-form-item/typing.d.ts +40 -37
  92. package/components/hy-grid/hy-grid.vue +76 -132
  93. package/components/hy-grid/props.ts +58 -16
  94. package/components/hy-grid/typing.d.ts +66 -66
  95. package/components/hy-icon/hy-icon.vue +84 -161
  96. package/components/hy-icon/props.ts +76 -22
  97. package/components/hy-icon/typing.d.ts +83 -82
  98. package/components/hy-image/hy-image.vue +142 -272
  99. package/components/hy-image/props.ts +105 -23
  100. package/components/hy-image/typing.d.ts +84 -87
  101. package/components/hy-input/hy-input.vue +230 -421
  102. package/components/hy-input/props.ts +183 -35
  103. package/components/hy-input/typing.d.ts +169 -169
  104. package/components/hy-line/hy-line.vue +34 -72
  105. package/components/hy-line/props.ts +41 -10
  106. package/components/hy-line/typing.d.ts +29 -29
  107. package/components/hy-line-progress/hy-line-progress.vue +66 -101
  108. package/components/hy-line-progress/props.ts +31 -10
  109. package/components/hy-line-progress/typing.d.ts +29 -29
  110. package/components/hy-list/hy-list.vue +151 -220
  111. package/components/hy-list/props.ts +67 -16
  112. package/components/hy-list/typing.d.ts +52 -52
  113. package/components/hy-loading/hy-loading.vue +63 -119
  114. package/components/hy-loading/props.ts +63 -15
  115. package/components/hy-loading/typing.d.ts +49 -49
  116. package/components/hy-menu/hy-menu.vue +124 -166
  117. package/components/hy-menu/props.ts +42 -10
  118. package/components/hy-menu/typing.d.ts +60 -60
  119. package/components/hy-modal/hy-modal.vue +127 -218
  120. package/components/hy-modal/props.ts +89 -24
  121. package/components/hy-navbar/hy-navbar.vue +104 -177
  122. package/components/hy-navbar/props.ts +76 -22
  123. package/components/hy-navbar/typing.d.ts +81 -81
  124. package/components/hy-notice-bar/hy-notice-bar.vue +67 -144
  125. package/components/hy-notice-bar/props.ts +80 -19
  126. package/components/hy-notice-bar/typing.d.ts +62 -62
  127. package/components/hy-notify/hy-notify.vue +128 -177
  128. package/components/hy-notify/props.ts +49 -12
  129. package/components/hy-notify/typing.d.ts +45 -41
  130. package/components/hy-number-step/hy-number-step.vue +281 -394
  131. package/components/hy-number-step/props.ts +110 -27
  132. package/components/hy-number-step/typing.d.ts +120 -120
  133. package/components/hy-overlay/hy-overlay.vue +39 -66
  134. package/components/hy-overlay/props.ts +31 -8
  135. package/components/hy-pagination/hy-pagination.vue +100 -155
  136. package/components/hy-pagination/props.ts +53 -13
  137. package/components/hy-picker/hy-picker.vue +309 -430
  138. package/components/hy-picker/index.scss +8 -12
  139. package/components/hy-picker/props.ts +110 -26
  140. package/components/hy-popover/hy-popover.vue +190 -252
  141. package/components/hy-popover/props.ts +48 -10
  142. package/components/hy-popup/hy-popup.vue +162 -248
  143. package/components/hy-popup/props.ts +82 -18
  144. package/components/hy-price/hy-price.vue +45 -104
  145. package/components/hy-price/props.ts +52 -12
  146. package/components/hy-price/typing.d.ts +41 -36
  147. package/components/hy-qrcode/hy-qrcode.vue +115 -185
  148. package/components/hy-qrcode/props.ts +68 -18
  149. package/components/hy-qrcode/typing.d.ts +67 -66
  150. package/components/hy-radio/hy-radio.vue +161 -259
  151. package/components/hy-radio/props.ts +95 -25
  152. package/components/hy-radio/typing.d.ts +85 -84
  153. package/components/hy-rate/hy-rate.vue +185 -270
  154. package/components/hy-rate/props.ts +76 -18
  155. package/components/hy-rate/typing.d.ts +61 -60
  156. package/components/hy-read-more/hy-read-more.vue +93 -136
  157. package/components/hy-read-more/props.ts +43 -13
  158. package/components/hy-scroll-list/hy-scroll-list.vue +81 -102
  159. package/components/hy-scroll-list/props.ts +22 -11
  160. package/components/hy-search/hy-search.vue +155 -284
  161. package/components/hy-search/props.ts +130 -25
  162. package/components/hy-signature/hy-signature.vue +491 -635
  163. package/components/hy-signature/props.ts +115 -26
  164. package/components/hy-signature/typing.d.ts +138 -138
  165. package/components/hy-slider/hy-slider.vue +388 -477
  166. package/components/hy-slider/props.ts +75 -19
  167. package/components/hy-steps/hy-steps.vue +212 -279
  168. package/components/hy-steps/props.ts +47 -13
  169. package/components/hy-submit-bar/hy-submit-bar.vue +137 -222
  170. package/components/hy-submit-bar/props.ts +89 -20
  171. package/components/hy-submit-bar/typing.d.ts +86 -85
  172. package/components/hy-subsection/hy-subsection.vue +132 -185
  173. package/components/hy-subsection/props.ts +50 -17
  174. package/components/hy-subsection/typing.d.ts +52 -52
  175. package/components/hy-swipe-action/hy-swipe-action.vue +228 -283
  176. package/components/hy-swipe-action/props.ts +43 -18
  177. package/components/hy-swipe-action/typing.d.ts +46 -46
  178. package/components/hy-swiper/hy-swiper.vue +159 -286
  179. package/components/hy-swiper/props.ts +126 -28
  180. package/components/hy-swiper/typing.d.ts +115 -115
  181. package/components/hy-switch/hy-switch.vue +112 -176
  182. package/components/hy-switch/props.ts +60 -15
  183. package/components/hy-switch/typing.d.ts +63 -63
  184. package/components/hy-tabBar/hy-tabBar.vue +64 -60
  185. package/components/hy-tabs/hy-tabs.vue +277 -380
  186. package/components/hy-tabs/props.ts +75 -18
  187. package/components/hy-tag/hy-tag.vue +111 -204
  188. package/components/hy-tag/props.ts +81 -19
  189. package/components/hy-text/hy-text.vue +200 -322
  190. package/components/hy-text/props.ts +107 -28
  191. package/components/hy-textarea/hy-textarea.vue +147 -256
  192. package/components/hy-textarea/props.ts +112 -25
  193. package/components/hy-textarea/typing.d.ts +42 -42
  194. package/components/hy-toast/hy-toast.vue +135 -143
  195. package/components/hy-tooltip/hy-tooltip.vue +220 -306
  196. package/components/hy-tooltip/props.ts +79 -15
  197. package/components/hy-transition/hy-transition.vue +111 -138
  198. package/components/hy-transition/props.ts +30 -8
  199. package/components/hy-upload/hy-upload.vue +320 -469
  200. package/components/hy-upload/props.ts +130 -27
  201. package/components/hy-warn/hy-warn.vue +80 -129
  202. package/components/hy-warn/props.ts +47 -12
  203. package/components/hy-waterfall/hy-waterfall.vue +139 -163
  204. package/components/hy-waterfall/props.ts +19 -7
  205. package/components/hy-watermark/hy-watermark.vue +762 -870
  206. package/components/hy-watermark/props.ts +103 -22
  207. package/global.d.ts +2 -0
  208. package/libs/css/theme.scss +3 -3
  209. package/package.json +2 -2
  210. package/web-types.json +1 -1
  211. package/components/hy-folding-panel/index.scss +0 -9
@@ -1,30 +1,109 @@
1
- import type IProps from "./typing";
1
+ import type { CSSProperties, PropType } from 'vue'
2
2
 
3
- const defaultProps: IProps = {
4
- text: "",
5
- type: "",
6
- show: true,
7
- prefixIcon: "",
8
- suffixIcon: "",
9
- mode: "text",
10
- href: "",
11
- format: "",
12
- call: false,
13
- openType: "",
14
- bold: false,
15
- block: false,
16
- lines: "",
17
- color: "",
18
- size: 15,
19
- iconStyle: {
20
- fontSize: "15px",
21
- },
22
- decoration: "",
23
- margin: "",
24
- lineHeight: "",
25
- align: "left",
26
- wordWrap: "normal",
27
- flex: true,
28
- };
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 as PropType<HyApp.ThemeType>,
15
+ /** 是否显示 */
16
+ show: {
17
+ type: Boolean,
18
+ default: true
19
+ },
20
+ /** 前置图标 */
21
+ prefixIcon: String,
22
+ /** 后置图标 */
23
+ suffixIcon: String,
24
+ /**
25
+ * 文本处理的匹配模式
26
+ * @values text,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: [Function, String],
39
+ /** mode=phone时,点击文本是否拨打电话 */
40
+ call: {
41
+ type: Boolean,
42
+ default: false
43
+ },
44
+ /** 小程序的打开方式 */
45
+ openType: String,
46
+ /** 是否粗体,默认normal */
47
+ bold: {
48
+ type: Boolean,
49
+ default: false
50
+ },
51
+ /** 是否块状 */
52
+ block: {
53
+ type: Boolean,
54
+ default: false
55
+ },
56
+ /** 文本显示的行数,如果设置,超出此行数,将会显示省略号 */
57
+ lines: [String, Number],
58
+ /** 文本颜色 */
59
+ color: String,
60
+ /** 字体大小 */
61
+ size: {
62
+ type: [String, Number],
63
+ default: 15
64
+ },
65
+ /** 图标的样式 */
66
+ iconStyle: {
67
+ type: Object as PropType<CSSProperties>,
68
+ default: () => ({ fontSize: '15px' })
69
+ },
70
+ /**
71
+ * 文字装饰,下划线,中划线等,可选值
72
+ * @values none,underline,line-through
73
+ * */
74
+ decoration: String,
75
+ /** 外边距,对象、字符串,数值形式均可 */
76
+ margin: String,
77
+ /** 文本行高 */
78
+ lineHeight: String,
79
+ /**
80
+ * 文本对齐方式
81
+ * @values left,center,right
82
+ * */
83
+ align: {
84
+ type: String,
85
+ default: 'left'
86
+ },
87
+ /**
88
+ * 文字换行
89
+ * @values normal,break-word,anywhere
90
+ * */
91
+ wordWrap: {
92
+ type: String,
93
+ default: 'normal'
94
+ },
95
+ /** 是否占满剩余空间 */
96
+ flex: {
97
+ type: Boolean,
98
+ default: true
99
+ },
100
+ /** 定义需要用到的外部样式 */
101
+ customStyle: {
102
+ type: Object as PropType<CSSProperties>,
103
+ default: () => {}
104
+ },
105
+ /** 自定义外部类名 */
106
+ customClass: String
107
+ }
29
108
 
30
- export default defaultProps;
109
+ export default textProps
@@ -1,306 +1,197 @@
1
1
  <template>
2
- <view
3
- :class="['hy-textarea', customClass, textareaClass]"
4
- :style="[textareaStyle, borderStyle(isFocus)]"
5
- >
6
- <textarea
7
- class="hy-textarea__field"
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"
2
+ <view
3
+ :class="['hy-textarea', customClass, textareaClass]"
4
+ :style="[textareaStyle, borderStyle(isFocus)]"
41
5
  >
42
- {{ innerValue.length }}/{{ maxlength }}
43
- </text>
44
- <!-- #endif -->
45
- </view>
6
+ <textarea
7
+ class="hy-textarea__field"
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
46
  </template>
47
47
 
48
48
  <script lang="ts">
49
49
  export default {
50
- name: "hy-textarea",
51
- options: {
52
- addGlobalClass: true,
53
- virtualHost: true,
54
- styleIsolation: "shared",
55
- },
56
- };
50
+ name: 'hy-textarea',
51
+ options: {
52
+ addGlobalClass: true,
53
+ virtualHost: true,
54
+ styleIsolation: 'shared'
55
+ }
56
+ }
57
57
  </script>
58
58
 
59
59
  <script setup lang="ts">
60
- import { computed, ref, watch, nextTick, inject } from "vue";
61
- import type { CSSProperties, PropType } from "vue";
62
- import type { ITextareaEmits } from "./typing";
63
- import { addUnit } from "../../libs";
64
- import type { FormItemContext } from "../hy-form-item/typing";
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
65
  import type {
66
- InputOnBlurEvent,
67
- InputOnConfirmEvent,
68
- InputOnFocusEvent,
69
- InputOnKeyboardheightchangeEvent,
70
- } from "@uni-helper/uni-types";
66
+ InputOnBlurEvent,
67
+ InputOnConfirmEvent,
68
+ InputOnFocusEvent,
69
+ InputOnKeyboardheightchangeEvent
70
+ } from '@uni-helper/uni-types'
71
+ import textareaProps from './props'
71
72
 
72
73
  /**
73
74
  * 用于输入多行文本信息,聊天输入框等。
74
75
  * @displayName hy-textarea
75
76
  */
76
- defineOptions({});
77
+ defineOptions({})
77
78
 
78
- // const props = withDefaults(defineProps<IProps>(), defaultProps);
79
- const props = defineProps({
80
- /** 输入框的内容 */
81
- modelValue: {
82
- type: String,
83
- default: "",
84
- },
85
- /** 输入框为空时占位符 */
86
- placeholder: String,
87
- /** 指定placeholder的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/ */
88
- placeholderClass: {
89
- type: String,
90
- default: "textarea-placeholder",
91
- },
92
- /** 指定placeholder的样式,对象形式 */
93
- placeholderStyle: Object as PropType<CSSProperties>,
94
- /** 输入框高度 */
95
- height: {
96
- type: [String, Number],
97
- default: 70,
98
- },
99
- /** 设置键盘右下角按钮的文字,仅微信小程序,App-vue和H5有效 */
100
- confirmType: {
101
- type: String,
102
- default: "done",
103
- },
104
- /** 是否禁用 */
105
- disabled: {
106
- type: Boolean,
107
- default: false,
108
- },
109
- /** 是否显示统计字数 */
110
- count: {
111
- type: Boolean,
112
- default: false,
113
- },
114
- /** 是否自动获取焦点,nvue不支持,H5取决于浏览器的实现 */
115
- focus: {
116
- type: Boolean,
117
- default: false,
118
- },
119
- /** 是否自动增加高度 */
120
- autoHeight: {
121
- type: Boolean,
122
- default: false,
123
- },
124
- /** 如果textarea是在一个position:fixed的区域,需要显示指定属性fixed为true */
125
- fixed: {
126
- type: Boolean,
127
- default: false,
128
- },
129
- /** 指定光标与键盘的距离 */
130
- cursorSpacing: {
131
- type: Number,
132
- default: 0,
133
- },
134
- /** 指定focus时的光标位置 */
135
- cursor: [String, Number],
136
- /** 是否显示键盘上方带有”完成“按钮那一栏 */
137
- showConfirmBar: {
138
- type: Boolean,
139
- default: true,
140
- },
141
- /** 光标起始位置,自动聚焦时有效,需与selection-end搭配使用, */
142
- selectionStart: {
143
- type: Number,
144
- default: -1,
145
- },
146
- /** 光标结束位置,自动聚焦时有效,需与selection-start搭配使用 */
147
- selectionEnd: {
148
- type: Number,
149
- default: -1,
150
- },
151
- /** 键盘弹起时,是否自动上推页面 */
152
- adjustPosition: {
153
- type: Boolean,
154
- default: true,
155
- },
156
- /** 是否去掉 iOS 下的默认内边距,只微信小程序有效 */
157
- disableDefaultPadding: {
158
- type: Boolean,
159
- default: false,
160
- },
161
- /** focus时,点击页面的时候不收起键盘,只微信小程序有效 */
162
- holdKeyboard: {
163
- type: Boolean,
164
- default: false,
165
- },
166
- /** 最大输入长度,设置为 -1 的时候不限制最大长度 */
167
- maxlength: {
168
- type: Number,
169
- default: 140,
170
- },
171
- /**
172
- * 边框类型
173
- * @values surround,none,bottom
174
- * */
175
- border: {
176
- type: String,
177
- default: "surround",
178
- },
179
- /** 内容式化函数 */
180
- formatter: Function,
181
- /** 定义需要用到的外部样式 */
182
- customStyle: {
183
- type: Object as PropType<CSSProperties>,
184
- },
185
- /** 自定义外部类名 */
186
- customClass: String,
187
- });
188
- const emit = defineEmits<ITextareaEmits>();
189
- const formItem = inject<FormItemContext>("formItem");
79
+ const props = defineProps(textareaProps)
80
+ const emit = defineEmits<ITextareaEmits>()
81
+ const formItem = inject<FormItemContext>('formItem')
190
82
 
191
83
  // 输入框的值
192
- const innerValue = ref<string>("");
84
+ const innerValue = ref<string>('')
193
85
  // value是否第一次变化,在watch中,由于加入immediate属性,会在第一次触发,此时不应该认为value发生了变化
194
- const firstChange = ref<boolean>(true);
86
+ const firstChange = ref<boolean>(true)
195
87
  // value绑定值的变化是由内部还是外部引起的
196
- const changeFromInner = ref<boolean>(false);
88
+ const changeFromInner = ref<boolean>(false)
197
89
  // 是否获取焦点
198
- const isFocus = ref<boolean>(false);
90
+ const isFocus = ref<boolean>(false)
199
91
  // 过滤处理方法
200
- let innerFormatter = (value: string) => value;
92
+ let innerFormatter = (value: string) => value
201
93
 
202
94
  watch(
203
- () => props.modelValue,
204
- (newVal) => {
205
- innerValue.value = newVal;
206
- /* #ifdef H5 */
207
- // 在H5中,外部value变化后,修改input中的值,不会触发@input事件,此时手动调用值变化方法
208
- if (firstChange.value === false && changeFromInner.value === false) {
209
- valueChange();
210
- }
211
- /* #endif */
212
- firstChange.value = false;
213
- // 重置changeFromInner的值为false,标识下一次引起默认为外部引起的
214
- changeFromInner.value = false;
215
- },
216
- { immediate: true },
217
- );
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
+ )
218
110
 
219
111
  // 组件的类名
220
112
  const textareaClass = computed(() => {
221
- let classes: string[] = [];
222
- props.border === "surround" &&
223
- (classes = classes.concat(["hy-border", "hy-textarea__radius"]));
224
- props.border === "bottom" &&
225
- (classes = classes.concat(["hy-border__bottom", "hy-textarea__no-radius"]));
226
- props.disabled && classes.push("hy-textarea__disabled");
227
- return classes.join(" ");
228
- });
113
+ let classes: string[] = []
114
+ props.border === 'surround' && (classes = classes.concat(['hy-border', 'hy-textarea__radius']))
115
+ props.border === 'bottom' &&
116
+ (classes = classes.concat(['hy-border__bottom', 'hy-textarea__no-radius']))
117
+ props.disabled && classes.push('hy-textarea__disabled')
118
+ return classes.join(' ')
119
+ })
229
120
  // 组件的样式
230
121
  const textareaStyle = computed(() => {
231
- const style: CSSProperties = {};
122
+ const style: CSSProperties = {}
232
123
 
233
- return Object.assign(style, props.customStyle);
234
- });
124
+ return Object.assign(style, props.customStyle)
125
+ })
235
126
  /**
236
127
  * @description 边框颜色
237
128
  * */
238
129
  const borderStyle = computed(() => {
239
- return (isFocus: boolean) => {
240
- let style: CSSProperties = {};
241
- if (isFocus) {
242
- switch (props.border) {
243
- case "surround":
244
- style = { border: `1px solid var(--hy-theme-color, #3c9cff)` };
245
- break;
246
- case "bottom":
247
- style = { borderBottom: `1px solid var(--hy-theme-color, #3c9cff)` };
248
- break;
249
- default:
250
- break;
251
- }
130
+ return (isFocus: boolean) => {
131
+ let style: CSSProperties = {}
132
+ if (isFocus) {
133
+ switch (props.border) {
134
+ case 'surround':
135
+ style = { border: `1px solid var(--hy-theme-color, #3c9cff)` }
136
+ break
137
+ case 'bottom':
138
+ style = { borderBottom: `1px solid var(--hy-theme-color, #3c9cff)` }
139
+ break
140
+ default:
141
+ break
142
+ }
143
+ }
144
+ return style
252
145
  }
253
- return style;
254
- };
255
- });
146
+ })
256
147
 
257
148
  const onFocus = (e: InputOnFocusEvent) => {
258
- isFocus.value = true;
259
- emit("focus", e);
260
- };
149
+ isFocus.value = true
150
+ emit('focus', e)
151
+ }
261
152
  const onBlur = (e: InputOnBlurEvent) => {
262
- isFocus.value = false;
263
- emit("blur", e);
264
- if (formItem) formItem.handleBlur(e.detail.value);
265
- // 尝试调用u-form的验证方法
266
- // formValidate(this, "blur");
267
- };
153
+ isFocus.value = false
154
+ emit('blur', e)
155
+ if (formItem) formItem.handleBlur(e.detail.value)
156
+ // 尝试调用u-form的验证方法
157
+ // formValidate(this, "blur");
158
+ }
268
159
  const onLineChange = (e: any) => {
269
- emit("lineChange", e);
270
- };
160
+ emit('lineChange', e)
161
+ }
271
162
  const onInput = (e: any) => {
272
- let { value } = e?.detail;
273
- // 格式化过滤方法
274
- const format = props.formatter || innerFormatter;
275
- const formatValue = format(value);
276
- // 为了避免props的单向数据流特性,需要先将innerValue值设置为当前值,再在$nextTick中重新赋予设置后的值才有效
277
- innerValue.value = value;
278
- nextTick(() => {
279
- innerValue.value = formatValue;
280
- valueChange();
281
- });
282
- };
163
+ let { value } = e?.detail
164
+ // 格式化过滤方法
165
+ const format = props.formatter || innerFormatter
166
+ const formatValue = format(value)
167
+ // 为了避免props的单向数据流特性,需要先将innerValue值设置为当前值,再在$nextTick中重新赋予设置后的值才有效
168
+ innerValue.value = value
169
+ nextTick(() => {
170
+ innerValue.value = formatValue
171
+ valueChange()
172
+ })
173
+ }
283
174
  /**
284
175
  * @description 内容发生变化,进行处理
285
176
  * */
286
177
  const valueChange = () => {
287
- const value = innerValue.value;
288
- nextTick(() => {
289
- emit("update:modelValue", value);
290
- // 标识value值的变化是由内部引起的
291
- changeFromInner.value = true;
292
- emit("change", value);
293
- if (formItem) formItem.handleChange(value);
294
- });
295
- };
178
+ const value = innerValue.value
179
+ nextTick(() => {
180
+ emit('update:modelValue', value)
181
+ // 标识value值的变化是由内部引起的
182
+ changeFromInner.value = true
183
+ emit('change', value)
184
+ if (formItem) formItem.handleChange(value)
185
+ })
186
+ }
296
187
  const onConfirm = (e: InputOnConfirmEvent) => {
297
- emit("confirm", e);
298
- };
188
+ emit('confirm', e)
189
+ }
299
190
  const onKeyboardheightchange = (e: InputOnKeyboardheightchangeEvent) => {
300
- emit("keyboardheightchange", e);
301
- };
191
+ emit('keyboardheightchange', e)
192
+ }
302
193
  </script>
303
194
 
304
195
  <style lang="scss" scoped>
305
- @import "./index.scss";
196
+ @import './index.scss';
306
197
  </style>