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,20 +1,77 @@
1
- import type IProps from "./typing";
1
+ import type { TabsItemVo } from './typing'
2
+ import type { CSSProperties, PropType } from 'vue'
3
+ import type HyBadgeProps from '../hy-badge/typing'
2
4
 
3
- const defaultProps: IProps = {
4
- list: [],
5
- current: 0,
6
- keyName: "name",
7
- duration: 300,
8
- lineColor: "",
9
- activeStyle: {},
10
- inactiveStyle: {},
11
- lineWidth: 20,
12
- lineHeight: 3,
13
- lineBgSize: "cover",
14
- itemStyle: {},
15
- swiperHeight: "calc(100vh - 44px)",
16
- scrollable: true,
17
- iconStyle: {},
18
- };
5
+ const tabsProps = {
6
+ /** 标签数组,元素为对象,如[{name: '推荐'}] */
7
+ list: {
8
+ type: Array as unknown as PropType<TabsItemVo[]>,
9
+ default: []
10
+ },
11
+ /** 当前选中标签的索引 */
12
+ current: {
13
+ type: Number,
14
+ default: 0
15
+ },
16
+ /** 从list元素对象中读取的键名 */
17
+ keyName: {
18
+ type: String,
19
+ default: 'name'
20
+ },
21
+ /** 滑块移动一次所需的时间,单位秒 */
22
+ duration: {
23
+ type: Number,
24
+ default: 300
25
+ },
26
+ /** 滑块颜色 */
27
+ lineColor: String,
28
+ /** 菜单选择中时的样式 */
29
+ activeStyle: {
30
+ type: Object as PropType<CSSProperties>,
31
+ default: {}
32
+ },
33
+ /** 菜单非选中时的样式 */
34
+ inactiveStyle: {
35
+ type: Object as PropType<CSSProperties>,
36
+ default: {}
37
+ },
38
+ /** 滑块长度 */
39
+ lineWidth: {
40
+ type: [String, Number],
41
+ default: 20
42
+ },
43
+ /** 滑块高度 */
44
+ lineHeight: {
45
+ type: [String, Number],
46
+ default: 3
47
+ },
48
+ /** 滑块背景显示大小,当滑块背景设置为图片时使用 */
49
+ lineBgSize: {
50
+ type: [String, Number],
51
+ default: 'cover'
52
+ },
53
+ /** 菜单item的样式 */
54
+ itemStyle: Object as PropType<CSSProperties>,
55
+ /** 轮播图高度 */
56
+ swiperHeight: {
57
+ type: [String, Number],
58
+ default: 'calc(100vh - 44px)'
59
+ },
60
+ /** 菜单是否可滚动 */
61
+ scrollable: {
62
+ type: Boolean,
63
+ default: true
64
+ },
65
+ /**
66
+ * @description 徽标props全局定义
67
+ * */
68
+ propsBadge: Object as PropType<HyBadgeProps>,
69
+ /** 标签左侧图标样式自定义 */
70
+ iconStyle: Object as PropType<CSSProperties>,
71
+ /** 定义需要用到的外部样式 */
72
+ customStyle: Object as PropType<CSSProperties>,
73
+ /** 自定义外部类名 */
74
+ customClass: String
75
+ }
19
76
 
20
- export default defaultProps;
77
+ export default tabsProps
@@ -1,267 +1,174 @@
1
1
  <template>
2
- <HyTransition mode="fade" :show="show" style="display: inline-flex">
3
- <view class="hy-tag__wrapper cursor-pointer">
4
- <view :class="tagClass" @tap.stop="clickHandler" :style="tagStyle">
5
- <slot name="icon">
6
- <HyIcon
7
- v-if="icon?.name"
8
- :name="icon?.name"
9
- :color="hyIconColor"
10
- :size="hyIconSize"
11
- :bold="icon?.bold"
12
- :customPrefix="icon?.customPrefix"
13
- :imgMode="icon?.imgMode"
14
- :width="icon?.width"
15
- :height="icon?.height"
16
- :top="icon?.top"
17
- :stop="icon?.stop"
18
- :round="icon?.round"
19
- :customStyle="
20
- Object.assign({ marginRight: '3px' }, icon?.customStyle)
21
- "
22
- ></HyIcon>
23
- </slot>
24
- <text :class="textClass" :style="textStyle">
25
- <slot>
26
- {{ text }}
27
- </slot>
28
- </text>
29
- </view>
30
- <view
31
- :class="['hy-tag__close', `hy-tag__close--${size}`]"
32
- v-if="closable"
33
- @tap.stop="closeHandler"
34
- :style="{ backgroundColor: closeColor }"
35
- >
36
- <HyIcon
37
- :name="IconConfig.CLOSE"
38
- :size="closeSize"
39
- color="#ffffff"
40
- ></HyIcon>
41
- </view>
42
- </view>
43
- </HyTransition>
2
+ <hy-transition mode="fade" :show="show" :custom-style="{ display: 'inline-block' }">
3
+ <view class="hy-tag__wrapper cursor-pointer">
4
+ <view :class="tagClass" @tap.stop="clickHandler" :style="tagStyle">
5
+ <slot name="icon">
6
+ <hy-icon
7
+ v-if="icon?.name"
8
+ :name="icon?.name"
9
+ :color="hyIconColor"
10
+ :size="hyIconSize"
11
+ :bold="icon?.bold"
12
+ :customPrefix="icon?.customPrefix"
13
+ :imgMode="icon?.imgMode"
14
+ :width="icon?.width"
15
+ :height="icon?.height"
16
+ :top="icon?.top"
17
+ :stop="icon?.stop"
18
+ :round="icon?.round"
19
+ :customStyle="Object.assign({ marginRight: '3px' }, icon?.customStyle)"
20
+ ></hy-icon>
21
+ </slot>
22
+ <text :class="textClass" :style="textStyle">
23
+ <slot>
24
+ {{ text }}
25
+ </slot>
26
+ </text>
27
+ </view>
28
+ <view
29
+ :class="['hy-tag__close', `hy-tag__close--${size}`]"
30
+ v-if="closable"
31
+ @tap.stop="closeHandler"
32
+ :style="{ backgroundColor: closeColor }"
33
+ >
34
+ <hy-icon :name="IconConfig.CLOSE" :size="closeSize" color="#ffffff"></hy-icon>
35
+ </view>
36
+ </view>
37
+ </hy-transition>
44
38
  </template>
45
39
 
46
40
  <script lang="ts">
47
41
  export default {
48
- name: "hy-tag",
49
- options: {
50
- addGlobalClass: true,
51
- virtualHost: true,
52
- styleIsolation: "shared",
53
- },
54
- };
42
+ name: 'hy-tag',
43
+ options: {
44
+ addGlobalClass: true,
45
+ virtualHost: true,
46
+ styleIsolation: 'shared'
47
+ }
48
+ }
55
49
  </script>
56
50
 
57
51
  <script setup lang="ts">
58
- import { computed } from "vue";
59
- import type { CSSProperties, PropType } from "vue";
60
- import type { ITagEmits } from "./typing";
61
- import { IconConfig, colorGradient } from "../../libs";
62
- import type HyIconProps from "../hy-icon/typing";
52
+ import { computed } from 'vue'
53
+ import type { CSSProperties } from 'vue'
54
+ import type { ITagEmits } from './typing'
55
+ import { IconConfig, colorGradient } from '../../libs'
56
+ import tagProps from './props'
63
57
 
64
58
  // 组件
65
- import HyTransition from "../hy-transition/hy-transition.vue";
66
- import HyIcon from "../hy-icon/hy-icon.vue";
59
+ import HyTransition from '../hy-transition/hy-transition.vue'
60
+ import HyIcon from '../hy-icon/hy-icon.vue'
67
61
 
68
62
  /**
69
63
  * tag组件一般用于标记和选择,我们提供了更加丰富的表现形式,能够较全面的涵盖您的使用场景
70
64
  * @displayName hy-tag
71
65
  */
72
- defineOptions({});
66
+ defineOptions({})
73
67
 
74
- // const props = withDefaults(defineProps<IProps>(), defaultProps)
75
- const props = defineProps({
76
- /** 标签的文字内容 */
77
- text: String,
78
- /** 点击需要传得值 */
79
- name: [String, Number],
80
- /**
81
- * 标签类型
82
- * @values info,primary,success,error,warning
83
- * */
84
- type: {
85
- type: String,
86
- default: "primary",
87
- },
88
- /** 禁用点击标签 */
89
- disabled: {
90
- type: Boolean,
91
- default: false,
92
- },
93
- /**
94
- * 标签的大小
95
- * @values large,medium,small,mini
96
- * */
97
- size: {
98
- type: String,
99
- default: "medium",
100
- },
101
- /**
102
- * tag的形状
103
- * @values circle,square,opposite
104
- * */
105
- shape: {
106
- type: String,
107
- default: "square",
108
- },
109
- /** 背景颜色,默认为空字符串,即不处理 */
110
- bgColor: String,
111
- /** 标签字体颜色,默认为空字符串,即不处理 */
112
- color: String,
113
- /** 镂空形式标签的边框颜色 */
114
- borderColor: String,
115
- /** 关闭按钮图标的颜色 */
116
- closeColor: {
117
- type: String,
118
- default: "#C6C7CB",
119
- },
120
- /** 镂空时是否填充背景色 */
121
- plainFill: {
122
- type: Boolean,
123
- default: false,
124
- },
125
- /** 是否镂空 */
126
- plain: {
127
- type: Boolean,
128
- default: false,
129
- },
130
- /** 是否可关闭,设置为true,文字右边会出现一个关闭图标 */
131
- closable: {
132
- type: Boolean,
133
- default: false,
134
- },
135
- /** 标签显示与否 */
136
- show: {
137
- type: Boolean,
138
- default: true,
139
- },
140
- /** 组件内置图标,或绝对路径的图片 */
141
- icon: Object as PropType<HyIconProps>,
142
- /** 定义需要用到的外部样式 */
143
- customStyle: {
144
- type: Object as PropType<CSSProperties>,
145
- default: () => {},
146
- },
147
- /** 自定义外部类名 */
148
- customClass: {
149
- type: String,
150
- default: "",
151
- },
152
- });
153
- const emit = defineEmits<ITagEmits>();
68
+ const props = defineProps(tagProps)
69
+ const emit = defineEmits<ITagEmits>()
154
70
 
155
71
  /**
156
72
  * @description tag类名
157
73
  * */
158
74
  const tagClass = computed((): string[] => {
159
- let classes = [
160
- "hy-tag",
161
- `hy-tag--${props.shape}`,
162
- `hy-tag--${props.size}`,
163
- props.customClass,
164
- ];
165
- if (props.disabled) {
166
- classes.push("hy-tag--disabled");
167
- } else {
168
- const arr = [
169
- props.plain ? `hy-tag--${props.type}--plain` : `hy-tag--${props.type}`,
170
- props.plain && props.plainFill && `hy-tag--${props.type}--plain__fill`,
171
- ].filter(Boolean);
172
- classes = classes.concat(arr as string[]);
173
- }
174
- return classes;
175
- });
75
+ let classes = ['hy-tag', `hy-tag--${props.shape}`, `hy-tag--${props.size}`, props.customClass]
76
+ if (props.disabled) {
77
+ classes.push('hy-tag--disabled')
78
+ } else {
79
+ const arr = [
80
+ props.plain ? `hy-tag--${props.type}--plain` : `hy-tag--${props.type}`,
81
+ props.plain && props.plainFill && `hy-tag--${props.type}--plain__fill`
82
+ ].filter(Boolean)
83
+ classes = classes.concat(arr as string[])
84
+ }
85
+ return classes
86
+ })
176
87
  /**
177
88
  * @description tag样式
178
89
  * */
179
90
  const tagStyle = computed<CSSProperties>(() => {
180
- const style: CSSProperties = {
181
- marginRight: props.closable ? "10px" : 0,
182
- marginTop: props.closable ? "10px" : 0,
183
- background: props.bgColor,
184
- borderColor: props.borderColor,
185
- };
91
+ const style: CSSProperties = {
92
+ marginRight: props.closable ? '10px' : 0,
93
+ marginTop: props.closable ? '10px' : 0,
94
+ background: props.bgColor,
95
+ borderColor: props.borderColor
96
+ }
186
97
 
187
- if (props.color) {
188
- if (props.plain) {
189
- style.borderColor = props.color;
190
- if (props.plainFill) {
191
- style.background = colorGradient(props.color, "#FFFFFF", 100)[90];
192
- }
193
- } else {
194
- style.background = props.color;
195
- style.borderColor = props.color;
98
+ if (props.color) {
99
+ if (props.plain) {
100
+ style.borderColor = props.color
101
+ if (props.plainFill) {
102
+ style.background = colorGradient(props.color, '#FFFFFF', 100)[90]
103
+ }
104
+ } else {
105
+ style.background = props.color
106
+ style.borderColor = props.color
107
+ }
196
108
  }
197
- }
198
109
 
199
- return Object.assign(style, props.customStyle);
200
- });
110
+ return Object.assign(style, props.customStyle)
111
+ })
201
112
 
202
113
  /**
203
114
  * @description 文本样式
204
115
  * */
205
116
  const textStyle = computed(() => {
206
- const style: CSSProperties = {};
207
- if (props.color && props.plain) style.color = props.color;
208
- return style;
209
- });
117
+ const style: CSSProperties = {}
118
+ if (props.color && props.plain) style.color = props.color
119
+ return style
120
+ })
210
121
  /**
211
122
  * @description 文本类名
212
123
  * */
213
124
  const textClass = computed((): string[] => {
214
- return [`hy-tag__text`, `hy-tag__text--${props.size}`];
215
- });
125
+ return [`hy-tag__text`, `hy-tag__text--${props.size}`]
126
+ })
216
127
 
217
128
  /**
218
129
  * @description 关闭图标icon大小
219
130
  */
220
131
  const closeSize = computed(() => {
221
- return props.size === "large" ? 15 : props.size === "medium" ? 13 : 11;
222
- });
132
+ return props.size === 'large' ? 15 : props.size === 'medium' ? 13 : 11
133
+ })
223
134
  /**
224
135
  * @description 图标大小
225
136
  * */
226
137
  const hyIconSize = computed(() => {
227
- if (props.icon?.size) {
228
- return props.icon.size;
229
- } else {
230
- return props.size === "large" ? 18 : props.size === "medium" ? 14 : 10;
231
- }
232
- });
138
+ if (props.icon?.size) {
139
+ return props.icon.size
140
+ } else {
141
+ return props.size === 'large' ? 18 : props.size === 'medium' ? 14 : 10
142
+ }
143
+ })
233
144
  /**
234
145
  * @description 图标颜色
235
146
  * */
236
147
  const hyIconColor = computed(() => {
237
- return props.icon?.color
238
- ? props.icon.color
239
- : props.plain
240
- ? props.type
241
- : "#ffffff";
242
- });
148
+ return props.icon?.color ? props.icon.color : props.plain ? props.type : '#ffffff'
149
+ })
243
150
 
244
151
  /**
245
152
  * @description 点击关闭按钮
246
153
  * */
247
154
  const closeHandler = () => {
248
- if (!props.disabled) {
249
- emit("close", props.text);
250
- }
251
- };
155
+ if (!props.disabled) {
156
+ emit('close', props.text)
157
+ }
158
+ }
252
159
  /**
253
160
  * @description 点击标签
254
161
  * */
255
162
  const clickHandler = () => {
256
- if (!props.disabled) {
257
- emit("click", {
258
- value: props.text,
259
- name: props.name,
260
- });
261
- }
262
- };
163
+ if (!props.disabled) {
164
+ emit('click', {
165
+ value: props.text,
166
+ name: props.name
167
+ })
168
+ }
169
+ }
263
170
  </script>
264
171
 
265
172
  <style lang="scss" scoped>
266
- @import "./index.scss";
173
+ @import './index.scss';
267
174
  </style>
@@ -1,21 +1,83 @@
1
- import type IProps from "./typing";
1
+ import type { CSSProperties, PropType } from 'vue'
2
+ import type HyIconProps from './typing'
2
3
 
3
- const defaultProps: IProps = {
4
- text: "",
5
- name: "",
6
- type: "primary",
7
- disabled: false,
8
- size: "medium",
9
- shape: "square",
10
- bgColor: "",
11
- color: "",
12
- borderColor: "",
13
- closeColor: "#C6C7CB",
14
- plainFill: false,
15
- plain: false,
16
- closable: false,
17
- show: true,
18
- icon: {},
19
- };
4
+ const tagProps = {
5
+ /** 标签的文字内容 */
6
+ text: String,
7
+ /** 点击需要传得值 */
8
+ name: [String, Number],
9
+ /**
10
+ * 标签类型
11
+ * @values info,primary,success,error,warning
12
+ * */
13
+ type: {
14
+ type: String,
15
+ default: 'primary'
16
+ },
17
+ /** 禁用点击标签 */
18
+ disabled: {
19
+ type: Boolean,
20
+ default: false
21
+ },
22
+ /**
23
+ * 标签的大小
24
+ * @values large,medium,small,mini
25
+ * */
26
+ size: {
27
+ type: String as PropType<HyApp.SizeType | 'mini'>,
28
+ default: 'medium'
29
+ },
30
+ /**
31
+ * tag的形状
32
+ * @values circle,square,opposite
33
+ * */
34
+ shape: {
35
+ type: String as PropType<HyApp.ShapeType | 'opposite'>,
36
+ default: 'square'
37
+ },
38
+ /** 背景颜色,默认为空字符串,即不处理 */
39
+ bgColor: String,
40
+ /** 标签字体颜色,默认为空字符串,即不处理 */
41
+ color: String,
42
+ /** 镂空形式标签的边框颜色 */
43
+ borderColor: String,
44
+ /** 关闭按钮图标的颜色 */
45
+ closeColor: {
46
+ type: String,
47
+ default: '#C6C7CB'
48
+ },
49
+ /** 镂空时是否填充背景色 */
50
+ plainFill: {
51
+ type: Boolean,
52
+ default: false
53
+ },
54
+ /** 是否镂空 */
55
+ plain: {
56
+ type: Boolean,
57
+ default: false
58
+ },
59
+ /** 是否可关闭,设置为true,文字右边会出现一个关闭图标 */
60
+ closable: {
61
+ type: Boolean,
62
+ default: false
63
+ },
64
+ /** 标签显示与否 */
65
+ show: {
66
+ type: Boolean,
67
+ default: true
68
+ },
69
+ /** 组件内置图标,或绝对路径的图片 */
70
+ icon: Object as PropType<HyIconProps>,
71
+ /** 定义需要用到的外部样式 */
72
+ customStyle: {
73
+ type: Object as PropType<CSSProperties>,
74
+ default: () => {}
75
+ },
76
+ /** 自定义外部类名 */
77
+ customClass: {
78
+ type: String,
79
+ default: ''
80
+ }
81
+ }
20
82
 
21
- export default defaultProps;
83
+ export default tagProps