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.
Files changed (223) hide show
  1. package/components/hy-action-sheet/hy-action-sheet.vue +81 -13
  2. package/components/hy-action-sheet/typing.d.ts +1 -3
  3. package/components/hy-address-picker/hy-address-picker.vue +109 -8
  4. package/components/hy-address-picker/index.scss +2 -2
  5. package/components/hy-address-picker/typing.d.ts +39 -30
  6. package/components/hy-avatar/hy-avatar.vue +78 -4
  7. package/components/hy-avatar/typing.d.ts +21 -16
  8. package/components/hy-back-top/hy-back-top.vue +86 -28
  9. package/components/hy-back-top/typing.d.ts +17 -12
  10. package/components/hy-badge/hy-badge.vue +114 -43
  11. package/components/hy-badge/typing.d.ts +20 -15
  12. package/components/hy-button/HyButton.docgen.js +6 -0
  13. package/components/hy-button/hy-button.vue +70 -77
  14. package/components/hy-button/props.ts +40 -41
  15. package/components/hy-calendar/hy-calendar.vue +290 -143
  16. package/components/hy-calendar/typing.d.ts +38 -31
  17. package/components/hy-card/hy-card.vue +139 -36
  18. package/components/hy-card/typing.d.ts +39 -28
  19. package/components/hy-cell/hy-cell.vue +131 -67
  20. package/components/hy-cell/typing.d.ts +6 -1
  21. package/components/hy-check-button/hy-check-button.vue +101 -32
  22. package/components/hy-check-button/typing.d.ts +26 -19
  23. package/components/hy-checkbox/hy-checkbox.vue +167 -78
  24. package/components/hy-checkbox/typing.d.ts +26 -19
  25. package/components/hy-code-input/hy-code-input.vue +101 -5
  26. package/components/hy-code-input/typing.d.ts +9 -0
  27. package/components/hy-config-provider/hy-config-provider.vue +44 -24
  28. package/components/hy-config-provider/typing.d.ts +0 -4
  29. package/components/hy-count-down/hy-count-down.vue +99 -62
  30. package/components/hy-count-down/typing.d.ts +18 -5
  31. package/components/hy-count-to/hy-count-to.vue +165 -113
  32. package/components/hy-count-to/typing.d.ts +15 -11
  33. package/components/hy-datetime-picker/hy-datetime-picker.vue +338 -232
  34. package/components/hy-datetime-picker/typing.d.ts +49 -39
  35. package/components/hy-divider/hy-divider.vue +128 -64
  36. package/components/hy-divider/typing.d.ts +16 -16
  37. package/components/hy-dropdown/hy-dropdown.vue +57 -19
  38. package/components/hy-dropdown/typing.d.ts +14 -14
  39. package/components/hy-dropdown-item/hy-dropdown-item.vue +34 -5
  40. package/components/hy-dropdown-item/typing.d.ts +13 -6
  41. package/components/hy-empty/hy-empty.vue +64 -6
  42. package/components/hy-empty/typing.d.ts +5 -0
  43. package/components/hy-float-button/hy-float-button.vue +117 -5
  44. package/components/hy-float-button/typing.d.ts +7 -0
  45. package/components/hy-folding-panel/hy-folding-panel.vue +87 -25
  46. package/components/hy-folding-panel/typing.d.ts +24 -15
  47. package/components/hy-grid/hy-grid.vue +95 -35
  48. package/components/hy-grid/typing.d.ts +24 -19
  49. package/components/hy-icon/hy-icon.vue +84 -6
  50. package/components/hy-icon/typing.d.ts +5 -0
  51. package/components/hy-image/hy-image.vue +105 -6
  52. package/components/hy-image/typing.d.ts +9 -0
  53. package/components/hy-input/hy-input.vue +277 -130
  54. package/components/hy-input/props.ts +13 -14
  55. package/components/hy-input/typing.d.ts +59 -38
  56. package/components/hy-line/hy-line.vue +65 -25
  57. package/components/hy-line-progress/hy-line-progress.vue +68 -35
  58. package/components/hy-list/hy-list.vue +127 -61
  59. package/components/hy-list/typing.d.ts +19 -12
  60. package/components/hy-loading/hy-loading.vue +79 -25
  61. package/components/hy-menu/hy-menu.vue +69 -45
  62. package/components/hy-menu/typing.d.ts +22 -15
  63. package/components/hy-modal/hy-modal.vue +91 -4
  64. package/components/hy-modal/typing.d.ts +11 -0
  65. package/components/hy-navbar/hy-navbar.vue +105 -25
  66. package/components/hy-navbar/typing.d.ts +25 -20
  67. package/components/hy-notice-bar/hy-notice-bar.vue +97 -19
  68. package/components/hy-notice-bar/typing.d.ts +22 -17
  69. package/components/hy-notify/hy-notify.vue +106 -54
  70. package/components/hy-number-step/hy-number-step.vue +211 -120
  71. package/components/hy-number-step/typing.d.ts +45 -28
  72. package/components/hy-overlay/hy-overlay.vue +60 -16
  73. package/components/hy-overlay/typing.d.ts +11 -6
  74. package/components/hy-pagination/hy-pagination.vue +94 -37
  75. package/components/hy-pagination/typing.d.ts +20 -11
  76. package/components/hy-picker/hy-picker.vue +225 -160
  77. package/components/hy-picker/typing.d.ts +51 -28
  78. package/components/hy-popover/hy-popover.vue +55 -7
  79. package/components/hy-popover/typing.d.ts +21 -1
  80. package/components/hy-popup/hy-popup.vue +164 -99
  81. package/components/hy-popup/typing.d.ts +11 -0
  82. package/components/hy-price/hy-price.vue +77 -30
  83. package/components/hy-price/typing.d.ts +10 -10
  84. package/components/hy-qrcode/hy-qrcode.vue +75 -5
  85. package/components/hy-qrcode/typing.d.ts +25 -16
  86. package/components/hy-radio/hy-radio.vue +169 -88
  87. package/components/hy-radio/typing.d.ts +29 -22
  88. package/components/hy-rate/hy-rate.vue +155 -104
  89. package/components/hy-rate/typing.d.ts +23 -16
  90. package/components/hy-read-more/hy-read-more.vue +83 -56
  91. package/components/hy-read-more/typing.d.ts +18 -11
  92. package/components/hy-scroll-list/hy-scroll-list.vue +69 -58
  93. package/components/hy-scroll-list/typing.d.ts +14 -7
  94. package/components/hy-search/hy-search.vue +168 -62
  95. package/components/hy-search/typing.d.ts +47 -26
  96. package/components/hy-signature/hy-signature.vue +354 -272
  97. package/components/hy-signature/typing.d.ts +65 -52
  98. package/components/hy-slider/hy-slider.vue +208 -160
  99. package/components/hy-slider/typing.d.ts +28 -17
  100. package/components/hy-steps/hy-steps.vue +125 -99
  101. package/components/hy-steps/typing.d.ts +21 -14
  102. package/components/hy-submit-bar/hy-submit-bar.vue +129 -48
  103. package/components/hy-submit-bar/typing.d.ts +30 -23
  104. package/components/hy-subsection/hy-subsection.vue +139 -96
  105. package/components/hy-subsection/typing.d.ts +23 -16
  106. package/components/hy-swipe-action/hy-swipe-action.vue +161 -135
  107. package/components/hy-swipe-action/typing.d.ts +26 -17
  108. package/components/hy-swiper/hy-swiper.vue +178 -73
  109. package/components/hy-swiper/typing.d.ts +37 -28
  110. package/components/hy-switch/hy-switch.vue +107 -60
  111. package/components/hy-switch/typing.d.ts +25 -18
  112. package/components/hy-tabs/hy-tabs.vue +170 -160
  113. package/components/hy-tabs/typing.d.ts +36 -22
  114. package/components/hy-tag/hy-tag.vue +133 -58
  115. package/components/hy-tag/typing.d.ts +26 -18
  116. package/components/hy-text/hy-text.vue +106 -6
  117. package/components/hy-text/typing.d.ts +31 -26
  118. package/components/hy-textarea/hy-textarea.vue +183 -89
  119. package/components/hy-textarea/typing.d.ts +41 -24
  120. package/components/hy-tooltip/hy-tooltip.vue +145 -101
  121. package/components/hy-tooltip/typing.d.ts +18 -13
  122. package/components/hy-transition/hy-transition.vue +48 -13
  123. package/components/hy-transition/typing.d.ts +17 -0
  124. package/components/hy-upload/hy-upload.vue +113 -148
  125. package/components/hy-upload/typing.d.ts +71 -71
  126. package/components/hy-warn/hy-warn.vue +79 -36
  127. package/components/hy-warn/typing.d.ts +18 -11
  128. package/components/hy-waterfall/hy-waterfall.vue +90 -77
  129. package/components/hy-watermark/hy-watermark.vue +82 -5
  130. package/components/hy-watermark/typing.d.ts +20 -20
  131. package/global.d.ts +39 -59
  132. package/package.json +5 -13
  133. package/utils/inspect.ts +3 -1
  134. package/web-types.json +1 -1
  135. package/component-helper.ts +0 -177
  136. package/components.json +0 -3287
  137. package/dist/attributes.json +0 -1
  138. package/dist/docs/components/hy-action-sheet/hy-action-sheet.md +0 -41
  139. package/dist/docs/components/hy-address-picker/hy-address-picker.md +0 -25
  140. package/dist/docs/components/hy-avatar/hy-avatar.md +0 -19
  141. package/dist/docs/components/hy-back-top/hy-back-top.md +0 -19
  142. package/dist/docs/components/hy-badge/hy-badge.md +0 -13
  143. package/dist/docs/components/hy-button/hy-button.md +0 -61
  144. package/dist/docs/components/hy-calendar/header.md +0 -17
  145. package/dist/docs/components/hy-calendar/hy-calendar.md +0 -27
  146. package/dist/docs/components/hy-calendar/month.md +0 -38
  147. package/dist/docs/components/hy-card/hy-card.md +0 -24
  148. package/dist/docs/components/hy-cell/hy-cell.md +0 -26
  149. package/dist/docs/components/hy-check-button/hy-check-button.md +0 -14
  150. package/dist/docs/components/hy-checkbox/hy-checkbox.md +0 -21
  151. package/dist/docs/components/hy-code-input/hy-code-input.md +0 -15
  152. package/dist/docs/components/hy-config-provider/hy-config-provider.md +0 -13
  153. package/dist/docs/components/hy-count-down/hy-count-down.md +0 -34
  154. package/dist/docs/components/hy-count-to/hy-count-to.md +0 -31
  155. package/dist/docs/components/hy-datetime-picker/hy-datetime-picker.md +0 -25
  156. package/dist/docs/components/hy-divider/hy-divider.md +0 -13
  157. package/dist/docs/components/hy-dropdown/hy-dropdown.md +0 -13
  158. package/dist/docs/components/hy-dropdown-item/hy-dropdown-item.md +0 -20
  159. package/dist/docs/components/hy-empty/hy-empty.md +0 -20
  160. package/dist/docs/components/hy-float-button/hy-float-button.md +0 -20
  161. package/dist/docs/components/hy-folding-panel/hy-folding-panel.md +0 -24
  162. package/dist/docs/components/hy-form/hy-form.md +0 -29
  163. package/dist/docs/components/hy-grid/hy-grid.md +0 -19
  164. package/dist/docs/components/hy-icon/hy-icon.md +0 -13
  165. package/dist/docs/components/hy-image/hy-image.md +0 -22
  166. package/dist/docs/components/hy-input/hy-input.md +0 -29
  167. package/dist/docs/components/hy-line/hy-line.md +0 -7
  168. package/dist/docs/components/hy-line-progress/hy-line-progress.md +0 -13
  169. package/dist/docs/components/hy-list/hy-list.md +0 -25
  170. package/dist/docs/components/hy-loading/hy-loading.md +0 -14
  171. package/dist/docs/components/hy-login/ThePhoneLogin.md +0 -20
  172. package/dist/docs/components/hy-login/TheUserLogin.md +0 -44
  173. package/dist/docs/components/hy-login/hy-login.md +0 -14
  174. package/dist/docs/components/hy-menu/hy-menu.md +0 -21
  175. package/dist/docs/components/hy-modal/hy-modal.md +0 -23
  176. package/dist/docs/components/hy-navbar/hy-navbar.md +0 -22
  177. package/dist/docs/components/hy-notice-bar/hy-column-notice.md +0 -20
  178. package/dist/docs/components/hy-notice-bar/hy-notice-bar.md +0 -14
  179. package/dist/docs/components/hy-notice-bar/hy-row-notice.md +0 -20
  180. package/dist/docs/components/hy-notify/hy-notify.md +0 -23
  181. package/dist/docs/components/hy-number-step/hy-number-step.md +0 -27
  182. package/dist/docs/components/hy-overlay/hy-overlay.md +0 -19
  183. package/dist/docs/components/hy-pagination/hy-pagination.md +0 -14
  184. package/dist/docs/components/hy-parse/hy-parse.md +0 -46
  185. package/dist/docs/components/hy-parse/node/node.md +0 -7
  186. package/dist/docs/components/hy-picker/hy-picker.md +0 -32
  187. package/dist/docs/components/hy-popover/hy-popover.md +0 -34
  188. package/dist/docs/components/hy-popup/hy-popup.md +0 -22
  189. package/dist/docs/components/hy-price/hy-price.md +0 -13
  190. package/dist/docs/components/hy-qrcode/hy-qrcode.md +0 -15
  191. package/dist/docs/components/hy-radio/hy-radio.md +0 -21
  192. package/dist/docs/components/hy-rate/hy-rate.md +0 -14
  193. package/dist/docs/components/hy-read-more/hy-read-more.md +0 -21
  194. package/dist/docs/components/hy-scroll-list/hy-scroll-list.md +0 -21
  195. package/dist/docs/components/hy-search/hy-search.md +0 -27
  196. package/dist/docs/components/hy-signature/hy-signature.md +0 -45
  197. package/dist/docs/components/hy-slider/hy-slider.md +0 -24
  198. package/dist/docs/components/hy-status-bar/hy-status-bar.md +0 -13
  199. package/dist/docs/components/hy-steps/hy-steps.md +0 -23
  200. package/dist/docs/components/hy-submit-bar/hy-submit-bar.md +0 -21
  201. package/dist/docs/components/hy-subsection/hy-subsection.md +0 -14
  202. package/dist/docs/components/hy-swipe-action/hy-swipe-action.md +0 -29
  203. package/dist/docs/components/hy-swiper/hy-swiper-indicator.md +0 -23
  204. package/dist/docs/components/hy-swiper/hy-swiper.md +0 -22
  205. package/dist/docs/components/hy-switch/hy-switch.md +0 -20
  206. package/dist/docs/components/hy-tabBar/hy-tabBar.md +0 -13
  207. package/dist/docs/components/hy-tabs/hy-tabs.md +0 -27
  208. package/dist/docs/components/hy-tag/hy-tag.md +0 -21
  209. package/dist/docs/components/hy-text/hy-text.md +0 -13
  210. package/dist/docs/components/hy-textarea/hy-textarea.md +0 -19
  211. package/dist/docs/components/hy-toast/hy-toast.md +0 -17
  212. package/dist/docs/components/hy-tooltip/hy-tooltip.md +0 -13
  213. package/dist/docs/components/hy-transition/hy-transition.md +0 -25
  214. package/dist/docs/components/hy-upload/hy-upload.md +0 -25
  215. package/dist/docs/components/hy-warn/hy-warn.md +0 -14
  216. package/dist/docs/components/hy-waterfall/hy-waterfall.md +0 -30
  217. package/dist/docs/components/hy-watermark/hy-watermark.md +0 -7
  218. package/dist/docs/components/message/TheMessage.md +0 -17
  219. package/dist/docs/components/yk-dialog/yk-dialog.md +0 -7
  220. package/dist/tags.json +0 -1
  221. package/dist/web-types.json +0 -1
  222. package/docgen.config.js +0 -14
  223. package/web-types.config.js +0 -7
@@ -16,9 +16,7 @@
16
16
  :top="icon?.top"
17
17
  :stop="icon?.stop"
18
18
  :round="icon?.round"
19
- :customStyle="
20
- Object.assign({ marginRight: '3px' }, icon?.customStyle)
21
- "
19
+ :customStyle="Object.assign({ marginRight: '3px' }, icon?.customStyle)"
22
20
  ></HyIcon>
23
21
  </slot>
24
22
  <text :class="textClass" :style="textStyle">
@@ -33,37 +31,117 @@
33
31
  @tap.stop="closeHandler"
34
32
  :style="{ backgroundColor: closeColor }"
35
33
  >
36
- <HyIcon
37
- :name="IconConfig.CLOSE"
38
- :size="closeSize"
39
- color="#ffffff"
40
- ></HyIcon>
34
+ <HyIcon :name="IconConfig.CLOSE" :size="closeSize" color="#ffffff"></HyIcon>
41
35
  </view>
42
36
  </view>
43
37
  </HyTransition>
44
38
  </template>
45
39
 
46
40
  <script lang="ts">
41
+ /**
42
+ * tag组件一般用于标记和选择,我们提供了更加丰富的表现形式,能够较全面的涵盖您的使用场景
43
+ * @displayName hy-tag
44
+ */
45
+ defineOptions({})
47
46
  export default {
48
47
  name: 'hy-tag',
49
48
  options: {
50
49
  addGlobalClass: true,
51
50
  virtualHost: true,
52
- styleIsolation: 'shared'
53
- }
51
+ styleIsolation: 'shared',
52
+ },
54
53
  }
55
54
  </script>
56
55
 
57
56
  <script setup lang="ts">
58
- import { computed, type CSSProperties, toRefs } from "vue";
59
- import defaultProps from "./props";
60
- import type IProps from "./typing";
61
- import HyTransition from "../hy-transition/hy-transition.vue";
62
- import HyIcon from "../hy-icon/hy-icon.vue";
63
- import { IconConfig } from "../../config";
64
- import { colorGradient } from "@/package";
57
+ import { computed, type CSSProperties, PropType, toRefs } from 'vue'
58
+ import type { ITagEmits } from './typing'
59
+ import { IconConfig } from '../../config'
60
+ import { colorGradient } from '../../utils'
61
+ import HyIconProps from '../hy-icon/typing'
62
+
63
+ // 组件
64
+ import HyTransition from '../hy-transition/hy-transition.vue'
65
+ import HyIcon from '../hy-icon/hy-icon.vue'
65
66
 
66
- const props = withDefaults(defineProps<IProps>(), defaultProps);
67
+ // const props = withDefaults(defineProps<IProps>(), defaultProps)
68
+ const props = defineProps({
69
+ /** 标签的文字内容 */
70
+ text: String,
71
+ /** 点击需要传得值 */
72
+ name: String,
73
+ /**
74
+ * 标签类型
75
+ * @values info,primary,success,error,warning
76
+ * */
77
+ type: {
78
+ type: String,
79
+ default: 'primary',
80
+ },
81
+ /** 禁用点击标签 */
82
+ disabled: {
83
+ type: Boolean,
84
+ default: false,
85
+ },
86
+ /**
87
+ * 标签的大小
88
+ * @values large,medium,small
89
+ * */
90
+ size: {
91
+ type: String,
92
+ default: 'medium',
93
+ },
94
+ /**
95
+ * tag的形状
96
+ * @values circle,square
97
+ * */
98
+ shape: {
99
+ type: String,
100
+ default: 'square',
101
+ },
102
+ /** 背景颜色,默认为空字符串,即不处理 */
103
+ bgColor: String,
104
+ /** 标签字体颜色,默认为空字符串,即不处理 */
105
+ color: String,
106
+ /** 镂空形式标签的边框颜色 */
107
+ borderColor: String,
108
+ /** 关闭按钮图标的颜色 */
109
+ closeColor: {
110
+ type: String,
111
+ default: '#C6C7CB',
112
+ },
113
+ /** 镂空时是否填充背景色 */
114
+ plainFill: {
115
+ type: Boolean,
116
+ default: false,
117
+ },
118
+ /** 是否镂空 */
119
+ plain: {
120
+ type: Boolean,
121
+ default: false,
122
+ },
123
+ /** 是否可关闭,设置为true,文字右边会出现一个关闭图标 */
124
+ closable: {
125
+ type: Boolean,
126
+ default: false,
127
+ },
128
+ /** 标签显示与否 */
129
+ show: {
130
+ type: Boolean,
131
+ default: true,
132
+ },
133
+ /** 组件内置图标,或绝对路径的图片 */
134
+ icon: {
135
+ type: Object as PropType<HyIconProps>,
136
+ default: {},
137
+ },
138
+ /** 定义需要用到的外部样式 */
139
+ customStyle: {
140
+ type: Object as PropType<CSSProperties>,
141
+ },
142
+ /** 自定义外部类名 */
143
+ customClass: String,
144
+ })
67
145
  const {
68
146
  text,
69
147
  name,
@@ -79,115 +157,112 @@ const {
79
157
  icon,
80
158
  disabled,
81
159
  customStyle,
82
- } = toRefs(props);
83
- const emit = defineEmits(["click", "close"]);
160
+ customClass,
161
+ } = toRefs(props)
162
+ const emit = defineEmits<ITagEmits>()
84
163
 
85
164
  /**
86
165
  * @description tag类名
87
166
  * */
88
167
  const tagClass = computed((): string[] => {
89
- let classes = ["hy-tag", `hy-tag--${shape.value}`, `hy-tag--${size.value}`];
168
+ let classes = ['hy-tag', `hy-tag--${shape.value}`, `hy-tag--${size.value}`, customClass.value]
90
169
  if (disabled.value) {
91
- classes.push("hy-tag--disabled");
170
+ classes.push('hy-tag--disabled')
92
171
  } else {
93
172
  const arr = [
94
173
  !plain.value && `hy-tag--${type.value}`,
95
174
  plain.value && `hy-tag--${type.value}--plain`,
96
175
  plain.value && plainFill.value && `hy-tag--${type.value}--plain__fill`,
97
- ].filter(Boolean);
98
- classes = classes.concat(arr as string[]);
176
+ ].filter(Boolean)
177
+ classes = classes.concat(arr as string[])
99
178
  }
100
- return classes;
101
- });
179
+ return classes
180
+ })
102
181
  /**
103
182
  * @description tag样式
104
183
  * */
105
184
  const tagStyle = computed<CSSProperties>(() => {
106
185
  const style: CSSProperties = {
107
- marginRight: closable.value ? "10px" : 0,
108
- marginTop: closable.value ? "10px" : 0,
186
+ marginRight: closable.value ? '10px' : 0,
187
+ marginTop: closable.value ? '10px' : 0,
109
188
  background: bgColor.value,
110
189
  borderColor: borderColor.value,
111
- };
190
+ }
112
191
 
113
192
  if (color.value) {
114
193
  if (plain.value) {
115
- style.borderColor = color.value;
194
+ style.borderColor = color.value
116
195
  if (plainFill.value) {
117
- style.background = colorGradient(color.value, "#FFFFFF", 100)[90];
196
+ style.background = colorGradient(color.value, '#FFFFFF', 100)[90]
118
197
  }
119
198
  } else {
120
- style.background = color.value;
121
- style.borderColor = color.value;
199
+ style.background = color.value
200
+ style.borderColor = color.value
122
201
  }
123
202
  }
124
203
 
125
- return Object.assign(style, customStyle.value);
126
- });
204
+ return Object.assign(style, customStyle.value)
205
+ })
127
206
 
128
207
  /**
129
208
  * @description 文本样式
130
209
  * */
131
210
  const textStyle = computed(() => {
132
- const style: CSSProperties = {};
133
- if (color.value && plain.value) style.color = color.value;
134
- return style;
135
- });
211
+ const style: CSSProperties = {}
212
+ if (color.value && plain.value) style.color = color.value
213
+ return style
214
+ })
136
215
  /**
137
216
  * @description 文本类名
138
217
  * */
139
218
  const textClass = computed((): string[] => {
140
- return [`hy-tag__text`, `hy-tag__text--${size.value}`];
141
- });
219
+ return [`hy-tag__text`, `hy-tag__text--${size.value}`]
220
+ })
142
221
 
143
222
  /**
144
223
  * @description 关闭图标icon大小
145
224
  */
146
225
  const closeSize = computed(() => {
147
- return size.value === "large" ? 15 : size.value === "medium" ? 13 : 11;
148
- });
226
+ return size.value === 'large' ? 15 : size.value === 'medium' ? 13 : 11
227
+ })
149
228
  /**
150
229
  * @description 图标大小
151
230
  * */
152
231
  const hyIconSize = computed(() => {
153
232
  if (icon.value.size) {
154
- return icon.value.size;
233
+ return icon.value.size
155
234
  } else {
156
- return size.value === "large" ? 18 : size.value === "medium" ? 14 : 10;
235
+ return size.value === 'large' ? 18 : size.value === 'medium' ? 14 : 10
157
236
  }
158
- });
237
+ })
159
238
  /**
160
239
  * @description 图标颜色
161
240
  * */
162
241
  const hyIconColor = computed(() => {
163
- return icon.value.color
164
- ? icon.value.color
165
- : plain.value
166
- ? type.value
167
- : "#ffffff";
168
- });
242
+ return icon.value.color ? icon.value.color : plain.value ? type.value : '#ffffff'
243
+ })
169
244
 
170
245
  /**
171
246
  * @description 点击关闭按钮
172
247
  * */
173
248
  const closeHandler = () => {
174
249
  if (!disabled.value) {
175
- emit("close", text.value);
250
+ emit('close', text.value)
176
251
  }
177
- };
252
+ }
178
253
  /**
179
254
  * @description 点击标签
180
255
  * */
181
256
  const clickHandler = () => {
182
257
  if (!disabled.value) {
183
- emit("click", {
258
+ emit('click', {
184
259
  value: text.value,
185
260
  name: name.value,
186
- });
261
+ })
187
262
  }
188
- };
263
+ }
189
264
  </script>
190
265
 
191
266
  <style lang="scss" scoped>
192
- @import "./index.scss";
267
+ @import './index.scss';
193
268
  </style>
@@ -1,69 +1,77 @@
1
- import type { CSSProperties } from "vue";
2
- import type HyIconProps from "../hy-icon/typing";
1
+ import type { CSSProperties } from 'vue'
2
+ import type HyIconProps from '../hy-icon/typing'
3
3
 
4
4
  export default interface HyTagProps {
5
5
  /**
6
6
  * @description 标签的文字内容
7
7
  * */
8
- text: string | number;
8
+ text: string | number
9
9
  /**
10
10
  * @description 点击需要传得值
11
11
  * */
12
- name?: string | number;
12
+ name?: string | number
13
13
  /**
14
14
  * @description 标签类型info、primary、success、warning、error (默认 'primary' )
15
15
  * */
16
- type?: HyApp.ThemeType;
16
+ type?: HyApp.ThemeType
17
17
  /**
18
18
  * @description 禁用(默认 false )
19
19
  * */
20
- disabled?: boolean;
20
+ disabled?: boolean
21
21
  /**
22
22
  * @description 标签的大小,large,medium,small (默认 'medium' )
23
23
  * */
24
- size?: HyApp.SizeType;
24
+ size?: HyApp.SizeType
25
25
  /**
26
26
  * @description tag的形状,circle(两边半圆形), square(方形,带圆角)(默认 'square' )
27
27
  * */
28
- shape?: HyApp.ShapeType;
28
+ shape?: HyApp.ShapeType
29
29
  /**
30
30
  * @description 背景颜色,默认为空字符串,即不处理
31
31
  * */
32
- bgColor?: string;
32
+ bgColor?: string
33
33
  /**
34
34
  * @description 标签字体颜色,默认为空字符串,即不处理
35
35
  * */
36
- color?: string;
36
+ color?: string
37
37
  /**
38
38
  * @description 镂空形式标签的边框颜色
39
39
  * */
40
- borderColor?: string;
40
+ borderColor?: string
41
41
  /**
42
42
  * @description 关闭按钮图标的颜色(默认 #C6C7CB)
43
43
  * */
44
- closeColor?: string;
44
+ closeColor?: string
45
45
  /**
46
46
  * @description 镂空时是否填充背景色(默认 false )
47
47
  * */
48
- plainFill?: boolean;
48
+ plainFill?: boolean
49
49
  /**
50
50
  * @description 是否镂空(默认 false )
51
51
  * */
52
- plain?: boolean;
52
+ plain?: boolean
53
53
  /**
54
54
  * @description 是否可关闭,设置为true,文字右边会出现一个关闭图标(默认 false )
55
55
  * */
56
- closable?: boolean;
56
+ closable?: boolean
57
57
  /**
58
58
  * @description 标签显示与否(默认 true )
59
59
  * */
60
- show?: boolean;
60
+ show?: boolean
61
61
  /**
62
62
  * @description 组件内置图标,或绝对路径的图片
63
63
  * */
64
- icon?: Partial<HyIconProps>;
64
+ icon?: Partial<HyIconProps>
65
65
  /**
66
66
  * @description 定义需要用到的外部样式
67
67
  * */
68
- customStyle?: CSSProperties;
68
+ customStyle?: CSSProperties
69
+ }
70
+
71
+ type TagParamsVo = { value: string; name: string }
72
+ export interface ITagEmits {
73
+ /** 点击标签触发 */
74
+ (e: 'click', params: TagParamsVo): void
75
+ /** 关闭标签触发 */
76
+ (e: 'close', value: string): void
69
77
  }
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <view class="hy-text" v-if="show" :style="wrapStyle" @tap="clickHandler">
2
+ <view :class="['hy-text', customClass]" v-if="show" :style="wrapStyle" @tap="clickHandler">
3
3
  <text
4
4
  :class="['hy-text__price', type && `hy-text__value--${type}`]"
5
5
  v-if="mode === 'price'"
@@ -52,6 +52,11 @@
52
52
  </template>
53
53
 
54
54
  <script lang="ts">
55
+ /**
56
+ * 此组件集成了文本类在项目中的常用功能,包括状态,拨打电话,格式化日期,*替换,超链接...等功能。 您大可不必在使用特殊文本时自己定义,text组件几乎涵盖您能使用的大部分场景。
57
+ * @displayName hy-text
58
+ */
59
+ defineOptions({})
55
60
  export default {
56
61
  name: 'hy-text',
57
62
  options: {
@@ -63,15 +68,110 @@ export default {
63
68
  </script>
64
69
 
65
70
  <script setup lang="ts">
66
- import { computed, type CSSProperties, nextTick, toRefs } from 'vue'
67
- import type IProps from './typing'
68
- import defaultProps from './props'
71
+ import { computed, type CSSProperties, nextTick, PropType, toRefs } from 'vue'
72
+ import type { ITextEmits } from './typing'
69
73
  import { addUnit, error, formatName, formatTime, isDate, priceFormat } from '../../utils'
70
74
 
71
75
  // 组件
72
76
  import HyIcon from '../hy-icon/hy-icon.vue'
73
77
 
74
- const props = withDefaults(defineProps<IProps>(), defaultProps)
78
+ // const props = withDefaults(defineProps<IProps>(), defaultProps)
79
+ const props = defineProps({
80
+ /** 显示的值 */
81
+ text: String,
82
+ /** 主题颜色 */
83
+ type: String,
84
+ /** 是否显示 */
85
+ show: {
86
+ type: Boolean,
87
+ default: true,
88
+ },
89
+ /** 前置图标 */
90
+ prefixIcon: String,
91
+ /** 后置图标 */
92
+ suffixIcon: String,
93
+ /**
94
+ * 文本处理的匹配模式
95
+ * @values text,price,phone,name,date,link
96
+ * */
97
+ mode: {
98
+ type: String,
99
+ default: 'text',
100
+ },
101
+ /** mode=link下,配置的链接 */
102
+ href: String,
103
+ /** 格式化规则 */
104
+ format: String,
105
+ /** mode=phone时,点击文本是否拨打电话 */
106
+ call: {
107
+ type: Boolean,
108
+ default: false,
109
+ },
110
+ /** 小程序的打开方式 */
111
+ openType: String,
112
+ /** 是否粗体,默认normal */
113
+ bold: {
114
+ type: Boolean,
115
+ default: false,
116
+ },
117
+ /** 是否块状 */
118
+ block: {
119
+ type: Boolean,
120
+ default: false,
121
+ },
122
+ /** 文本显示的行数,如果设置,超出此行数,将会显示省略号 */
123
+ lines: String,
124
+ /** 文本颜色 */
125
+ color: String,
126
+ /** 字体大小 */
127
+ size: {
128
+ type: Number,
129
+ default: 15,
130
+ },
131
+ /** 图标的样式 */
132
+ iconStyle: {
133
+ type: Object as unknown as PropType<CSSProperties>,
134
+ default() {
135
+ return {
136
+ fontSize: '15px',
137
+ }
138
+ },
139
+ },
140
+ /**
141
+ * 文字装饰,下划线,中划线等,可选值
142
+ * @values none,underline,line-through
143
+ * */
144
+ decoration: String,
145
+ /** 外边距,对象、字符串,数值形式均可 */
146
+ margin: String,
147
+ /** 文本行高 */
148
+ lineHeight: String,
149
+ /**
150
+ * 文本对齐方式
151
+ * @values left,center,right
152
+ * */
153
+ align: {
154
+ type: String,
155
+ default: 'left',
156
+ },
157
+ /**
158
+ * 文字换行
159
+ * @values normal,break-word,anywhere
160
+ * */
161
+ wordWrap: {
162
+ type: String,
163
+ default: 'normal',
164
+ },
165
+ /** 是否占满剩余空间 */
166
+ flex: {
167
+ type: Boolean,
168
+ default: true,
169
+ },
170
+ /** 定义需要用到的外部样式 */
171
+ customStyle: Object as PropType<CSSProperties>,
172
+ /** 自定义外部类名 */
173
+ customClass: String,
174
+ })
75
175
  const {
76
176
  type,
77
177
  show,
@@ -92,7 +192,7 @@ const {
92
192
  format,
93
193
  customStyle,
94
194
  } = toRefs(props)
95
- const emit = defineEmits(['click'])
195
+ const emit = defineEmits<ITextEmits>()
96
196
 
97
197
  const wrapStyle = computed(() => {
98
198
  const style: CSSProperties = {
@@ -1,98 +1,103 @@
1
- import type { CSSProperties } from "vue";
1
+ import type { CSSProperties } from 'vue'
2
2
 
3
- export type TextMode = "text" | "price" | "phone" | "name" | "date" | "link";
3
+ export type TextMode = 'text' | 'price' | 'phone' | 'name' | 'date' | 'link'
4
4
 
5
5
  export default interface HyTextProps {
6
6
  /**
7
7
  * @description 显示的值
8
8
  * */
9
- text: string | number;
9
+ text: string | number
10
10
  /**
11
11
  * @description 主题颜色
12
12
  * */
13
- type?: HyApp.ThemeType;
13
+ type?: HyApp.ThemeType
14
14
  /**
15
15
  * @description 是否显示(默认 true )
16
16
  * */
17
- show?: boolean;
17
+ show?: boolean
18
18
  /**
19
19
  * @description 前置图标
20
20
  * */
21
- prefixIcon?: string;
21
+ prefixIcon?: string
22
22
  /**
23
23
  * @description 后置图标
24
24
  * */
25
- suffixIcon?: string;
25
+ suffixIcon?: string
26
26
  /**
27
27
  * @description 文本处理的匹配模式 text-普通文本,price-价格,phone-手机号,name-姓名,date-日期,link-超链接
28
28
  * */
29
- mode?: TextMode;
29
+ mode?: TextMode
30
30
  /**
31
31
  * @description mode=link下,配置的链接
32
32
  * */
33
- href?: string;
33
+ href?: string
34
34
  /**
35
35
  * @description 格式化规则
36
36
  * */
37
- format?: Function | string;
37
+ format?: Function | string
38
38
  /**
39
39
  * @description mode=phone时,点击文本是否拨打电话(默认 false )
40
40
  * */
41
- call?: boolean;
41
+ call?: boolean
42
42
  /**
43
43
  * @description 小程序的打开方式
44
44
  * */
45
- openType?: string;
45
+ openType?: string
46
46
  /**
47
47
  * @description 是否粗体,默认normal(默认 false )
48
48
  * */
49
- bold?: boolean;
49
+ bold?: boolean
50
50
  /**
51
51
  * @description 是否块状(默认 false )
52
52
  * */
53
- block?: boolean;
53
+ block?: boolean
54
54
  /**
55
55
  * @description 文本显示的行数,如果设置,超出此行数,将会显示省略号
56
56
  * */
57
- lines?: string | number;
57
+ lines?: string | number
58
58
  /**
59
59
  * @description 文本颜色(默认 '#303133' )
60
60
  * */
61
- color?: string;
61
+ color?: string
62
62
  /**
63
- * @description 是否显示字体大小(默认 15 )遮罩
63
+ * @description 字体大小(默认 15
64
64
  * */
65
- size?: number | string;
65
+ size?: number | string
66
66
  /**
67
67
  * @description 图标的样式 (默认 {fontSize: '15px'} )
68
68
  * */
69
- iconStyle?: CSSProperties;
69
+ iconStyle?: CSSProperties
70
70
  /**
71
71
  * @description 文字装饰,下划线,中划线等,可选值 none|underline|line-through(默认 'none' )
72
72
  * */
73
- decoration?: "" | "none" | "underline" | "line-through";
73
+ decoration?: '' | 'none' | 'underline' | 'line-through'
74
74
  /**
75
75
  * @description 外边距,对象、字符串,数值形式均可(默认 0 )
76
76
  * */
77
- margin?: string;
77
+ margin?: string
78
78
  /**
79
79
  * @description 文本行高
80
80
  * */
81
- lineHeight?: string | number;
81
+ lineHeight?: string | number
82
82
  /**
83
83
  * @description 文本对齐方式,可选值left|center|right(默认 'left' )
84
84
  * */
85
- align?: HyApp.RowCenterType;
85
+ align?: HyApp.RowCenterType
86
86
  /**
87
87
  * @description 文字换行,可选值break-word|normal|anywhere(默认 'normal' )
88
88
  * */
89
- wordWrap?: "normal" | "break-word" | "anywhere";
89
+ wordWrap?: 'normal' | 'break-word' | 'anywhere'
90
90
  /**
91
91
  * @description 是否占满剩余空间(默认:true)
92
92
  * */
93
- flex?: boolean;
93
+ flex?: boolean
94
94
  /**
95
95
  * @description 定义需要用到的外部样式
96
96
  * */
97
- customStyle?: CSSProperties;
97
+ customStyle?: CSSProperties
98
+ }
99
+
100
+ export interface ITextEmits {
101
+ /** 点击触发 */
102
+ (e: 'click', event: any): void
98
103
  }