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,424 +1,275 @@
1
1
  <template>
2
- <!-- #ifndef APP-NVUE -->
3
- <button
4
- :hover-start-time="Number(hoverStartTime)"
5
- :hover-stay-time="Number(hoverStayTime)"
6
- :form-type="formType"
7
- :open-type="openType"
8
- :app-parameter="appParameter"
9
- :hover-stop-propagation="hoverStopPropagation"
10
- :send-message-title="sendMessageTitle"
11
- :send-message-path="sendMessagePath"
12
- :lang="lang"
13
- :data-name="dataName"
14
- :session-from="sessionFrom"
15
- :send-message-img="sendMessageImg"
16
- :show-message-card="showMessageCard"
17
- @getphonenumber="getphonenumber"
18
- @getuserinfo="getuserinfo"
19
- @error="error"
20
- @opensetting="opensetting"
21
- @launchapp="launchapp"
22
- @agreeprivacyauthorization="agreeprivacyauthorization"
23
- :hover-class="!disabled && !loading ? 'hy-button--active' : ''"
24
- :style="[baseColor, customStyle]"
25
- @click="clickHandler"
26
- :class="['hy-button', 'hy-reset-button', bemClass, customClass]"
27
- >
28
- <template v-if="loading">
29
- <HyLoading
30
- :mode="loadingMode"
31
- :size="loadingSize"
32
- :color="loadingColor"
33
- ></HyLoading>
34
- <text
35
- class="hy-button__loading-text"
36
- :style="[{ fontSize: textSize + 'px' }]"
37
- >
38
- {{ loadingText || text }}
39
- </text>
40
- </template>
41
- <template v-else>
42
- <HyIcon
43
- v-if="icon?.name"
44
- :name="icon?.name"
45
- :color="iconColorCom"
46
- :size="icon?.size || textSize * 1.35"
47
- :bold="icon?.bold"
48
- :customPrefix="icon?.customPrefix"
49
- :imgMode="icon?.imgMode"
50
- :width="icon?.width"
51
- :height="icon?.height"
52
- :top="icon?.top"
53
- :stop="icon?.stop"
54
- :round="icon?.round"
55
- :customStyle="icon?.customStyle || { marginRight: '2px' }"
56
- ></HyIcon>
57
- <!-- @slot 插入默认的值 -->
58
- <slot v-if="$slots.default"></slot>
59
- <text
60
- v-else
61
- class="hy-button__text"
62
- :style="[{ fontSize: textSize + 'px' }]"
63
- >{{ text }}</text
64
- >
65
- </template>
66
- </button>
67
- <!-- #endif -->
2
+ <!-- #ifndef APP-NVUE -->
3
+ <button
4
+ :hover-start-time="Number(hoverStartTime)"
5
+ :hover-stay-time="Number(hoverStayTime)"
6
+ :form-type="formType"
7
+ :open-type="openType"
8
+ :app-parameter="appParameter"
9
+ :hover-stop-propagation="hoverStopPropagation"
10
+ :send-message-title="sendMessageTitle"
11
+ :send-message-path="sendMessagePath"
12
+ :lang="lang"
13
+ :data-name="dataName"
14
+ :session-from="sessionFrom"
15
+ :send-message-img="sendMessageImg"
16
+ :show-message-card="showMessageCard"
17
+ @getphonenumber="getphonenumber"
18
+ @getuserinfo="getuserinfo"
19
+ @error="error"
20
+ @opensetting="opensetting"
21
+ @launchapp="launchapp"
22
+ @agreeprivacyauthorization="agreeprivacyauthorization"
23
+ :hover-class="!disabled && !loading ? 'hy-button--active' : ''"
24
+ :style="[baseColor, customStyle]"
25
+ @click="clickHandler"
26
+ :class="['hy-button', 'hy-reset-button', bemClass, customClass]"
27
+ >
28
+ <template v-if="loading">
29
+ <HyLoading :mode="loadingMode" :size="loadingSize" :color="loadingColor"></HyLoading>
30
+ <text class="hy-button__loading-text" :style="[{ fontSize: textSize + 'px' }]">
31
+ {{ loadingText || text }}
32
+ </text>
33
+ </template>
34
+ <template v-else>
35
+ <HyIcon
36
+ v-if="icon?.name"
37
+ :name="icon?.name"
38
+ :color="iconColorCom"
39
+ :size="icon?.size || textSize * 1.35"
40
+ :bold="icon?.bold"
41
+ :customPrefix="icon?.customPrefix"
42
+ :imgMode="icon?.imgMode"
43
+ :width="icon?.width"
44
+ :height="icon?.height"
45
+ :top="icon?.top"
46
+ :stop="icon?.stop"
47
+ :round="icon?.round"
48
+ :customStyle="icon?.customStyle || { marginRight: '2px' }"
49
+ ></HyIcon>
50
+ <!-- @slot 插入默认的值 -->
51
+ <slot v-if="$slots.default"></slot>
52
+ <text v-else class="hy-button__text" :style="[{ fontSize: textSize + 'px' }]">{{
53
+ text
54
+ }}</text>
55
+ </template>
56
+ </button>
57
+ <!-- #endif -->
68
58
 
69
- <!-- #ifdef APP-NVUE -->
70
- <view
71
- :hover-start-time="Number(hoverStartTime)"
72
- :hover-stay-time="Number(hoverStayTime)"
73
- class="hy-button"
74
- :hover-class="
75
- !disabled && !loading && !color && (plain || type === 'info')
76
- ? 'hy-button--active--plain'
77
- : !disabled && !loading && !plain
78
- ? 'hy-button--active'
79
- : ''
80
- "
81
- @click="clickHandler"
82
- :class="bemClass"
83
- :style="[baseColor, customStyle]"
84
- >
85
- <template v-if="loading">
86
- <HyLoading
87
- :mode="loadingMode"
88
- :size="loadingSize"
89
- :color="loadingColor"
90
- ></HyLoading>
91
- <text
92
- class="hy-button__loading-text"
93
- :style="[nvueTextStyle]"
94
- :class="[plain && `hy-button__text--plain--${type}`]"
95
- >
96
- {{ loadingText || text }}
97
- </text>
98
- </template>
99
- <template v-else>
100
- <HyIcon
101
- v-if="icon?.name"
102
- :name="icon?.name"
103
- :color="iconColorCom"
104
- :size="icon?.size || textSize * 1.35"
105
- :bold="icon?.bold"
106
- :customPrefix="icon?.customPrefix"
107
- :imgMode="icon?.imgMode"
108
- :width="icon?.width"
109
- :height="icon?.height"
110
- :top="icon?.top"
111
- :stop="icon?.stop"
112
- :round="icon?.round"
113
- :customStyle="icon?.customStyle || { marginRight: '2px' }"
114
- ></HyIcon>
115
- <text
116
- class="hy-button__text"
117
- :style="[
118
- {
119
- marginLeft: icon ? '2px' : 0,
120
- },
121
- nvueTextStyle,
122
- ]"
123
- :class="[plain && `hy-button__text--plain--${type}`]"
124
- >
125
- {{ text }}
126
- </text>
127
- </template>
128
- </view>
129
- <!-- #endif -->
59
+ <!-- #ifdef APP-NVUE -->
60
+ <view
61
+ :hover-start-time="Number(hoverStartTime)"
62
+ :hover-stay-time="Number(hoverStayTime)"
63
+ class="hy-button"
64
+ :hover-class="
65
+ !disabled && !loading && !color && (plain || type === 'info')
66
+ ? 'hy-button--active--plain'
67
+ : !disabled && !loading && !plain
68
+ ? 'hy-button--active'
69
+ : ''
70
+ "
71
+ @click="clickHandler"
72
+ :class="bemClass"
73
+ :style="[baseColor, customStyle]"
74
+ >
75
+ <template v-if="loading">
76
+ <HyLoading :mode="loadingMode" :size="loadingSize" :color="loadingColor"></HyLoading>
77
+ <text
78
+ class="hy-button__loading-text"
79
+ :style="[nvueTextStyle]"
80
+ :class="[plain && `hy-button__text--plain--${type}`]"
81
+ >
82
+ {{ loadingText || text }}
83
+ </text>
84
+ </template>
85
+ <template v-else>
86
+ <HyIcon
87
+ v-if="icon?.name"
88
+ :name="icon?.name"
89
+ :color="iconColorCom"
90
+ :size="icon?.size || textSize * 1.35"
91
+ :bold="icon?.bold"
92
+ :customPrefix="icon?.customPrefix"
93
+ :imgMode="icon?.imgMode"
94
+ :width="icon?.width"
95
+ :height="icon?.height"
96
+ :top="icon?.top"
97
+ :stop="icon?.stop"
98
+ :round="icon?.round"
99
+ :customStyle="icon?.customStyle || { marginRight: '2px' }"
100
+ ></HyIcon>
101
+ <text
102
+ class="hy-button__text"
103
+ :style="[
104
+ {
105
+ marginLeft: icon ? '2px' : 0
106
+ },
107
+ nvueTextStyle
108
+ ]"
109
+ :class="[plain && `hy-button__text--plain--${type}`]"
110
+ >
111
+ {{ text }}
112
+ </text>
113
+ </template>
114
+ </view>
115
+ <!-- #endif -->
130
116
  </template>
131
117
 
132
118
  <script lang="ts">
133
119
  export default {
134
- name: "hy-button",
135
- options: {
136
- addGlobalClass: true,
137
- virtualHost: true,
138
- styleIsolation: "shared",
139
- },
140
- };
120
+ name: 'hy-button',
121
+ options: {
122
+ addGlobalClass: true,
123
+ virtualHost: true,
124
+ styleIsolation: 'shared'
125
+ }
126
+ }
141
127
  </script>
142
128
 
143
129
  <script setup lang="ts">
144
- import { computed } from "vue";
145
- import type { CSSProperties, PropType } from "vue";
146
- import { ColorConfig, bem, throttle } from "../../libs";
147
- import type { IButtonEmits } from "./typing";
148
- import type HyIconProps from "../hy-icon/typing";
130
+ import { computed } from 'vue'
131
+ import type { CSSProperties } from 'vue'
132
+ import { ColorConfig, bem, throttle } from '../../libs'
133
+ import type { IButtonEmits } from './typing'
134
+ import buttonProps from '../hy-button/props'
149
135
  // 组件
150
- import HyIcon from "../hy-icon/hy-icon.vue";
151
- import HyLoading from "../hy-loading/hy-loading.vue";
136
+ import HyIcon from '../hy-icon/hy-icon.vue'
137
+ import HyLoading from '../hy-loading/hy-loading.vue'
152
138
 
153
139
  /**
154
140
  * 该组件内部实现以uni-app的基础button组件为基础,进行二次封装
155
141
  * @displayName hy-button
156
142
  */
157
- defineOptions({});
143
+ defineOptions({})
158
144
 
159
- // const props = withDefaults(defineProps<HyButtonProps>(), param)
160
- const props = defineProps({
161
- /** 是否显示按钮的细边框 */
162
- hairline: {
163
- type: Boolean,
164
- default: false,
165
- },
166
- /**
167
- * 按钮的预置样式
168
- * @values info,primary,error,warning,success
169
- * */
170
- type: {
171
- type: String,
172
- default: "primary",
173
- },
174
- /**
175
- * 按钮尺寸
176
- * @values large,medium,small,mini
177
- * */
178
- size: {
179
- type: String,
180
- default: "medium",
181
- },
182
- /**
183
- * 按钮形状
184
- * @values circle,square
185
- * */
186
- shape: {
187
- type: String,
188
- default: "square",
189
- },
190
- /** 按钮是否镂空,背景色透明 */
191
- plain: {
192
- type: Boolean,
193
- default: false,
194
- },
195
- /** 是否禁用 */
196
- disabled: {
197
- type: Boolean,
198
- default: false,
199
- },
200
- /** 按钮名称前是否带 loading 图标 */
201
- loading: {
202
- type: Boolean,
203
- default: false,
204
- },
205
- /** 加载中提示文字 */
206
- loadingText: String,
207
- /**
208
- * 加载状态图标类型
209
- * @values spinner,circle,semicircle
210
- * */
211
- loadingMode: {
212
- type: String,
213
- default: "spinner",
214
- },
215
- /** 加载图标大小 */
216
- loadingSize: {
217
- type: [Number, String],
218
- default: 13,
219
- },
220
- /** 开放能力,具体请看uniapp稳定关于button组件部分说明 */
221
- openType: String,
222
- /** 用于 <form> 组件,点击分别会触发 <form> 组件的 submit/reset 事件 */
223
- formType: String,
224
- /** 打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效 (注:只微信小程序、QQ小程序有效) */
225
- appParameter: String,
226
- /** 指定是否阻止本节点的祖先节点出现点击态,微信小程序有效 */
227
- hoverStopPropagation: {
228
- type: Boolean,
229
- default: true,
230
- },
231
- /**
232
- * 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文(默认 en )
233
- * @values zh_CN,zh_TW,en
234
- * */
235
- lang: {
236
- type: String,
237
- default: "en",
238
- },
239
- /** 会话来源,openType="contact"时有效 */
240
- sessionFrom: String,
241
- /** 会话内消息卡片标题,openType="contact"时有效 */
242
- sendMessageTitle: String,
243
- /** 会话内消息卡片点击跳转小程序路径,openType="contact"时有效 */
244
- sendMessagePath: String,
245
- /** 会话内消息卡片图片,openType="contact"时有效 */
246
- sendMessageImg: String,
247
- /** 是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示"可能要发送的小程序"提示,用户点击后可以快速发送小程序消息,openType="contact"时有效 */
248
- showMessageCard: {
249
- type: Boolean,
250
- default: false,
251
- },
252
- /** 额外传参参数,用于小程序的data-xxx属性,通过target.dataset.name获取 */
253
- dataName: String,
254
- /** 节流时间,一定时间内只能触发一次 */
255
- throttleTime: {
256
- type: Number,
257
- default: 0,
258
- },
259
- /** 按住后多久出现点击态,单位毫秒 */
260
- hoverStartTime: {
261
- type: Number,
262
- default: 0,
263
- },
264
- /** 手指松开后点击态保留时间,单位毫秒 */
265
- hoverStayTime: {
266
- type: Number,
267
- default: 200,
268
- },
269
- /** 按钮文字,之所以通过props传入,是因为slot传入的话(注:nvue中无法控制文字的样式) */
270
- text: String,
271
- /** 按钮图标api集合 */
272
- icon: Object as PropType<HyIconProps>,
273
- /** 按钮颜色,支持传入linear-gradient渐变色 */
274
- color: String,
275
- /** 阻止事件冒泡 */
276
- stop: {
277
- type: Boolean,
278
- default: true,
279
- },
280
- /** 定义需要用到的外部样式 */
281
- customStyle: Object as unknown as PropType<CSSProperties>,
282
- /** 自定义外部类名 */
283
- customClass: String,
284
- });
285
- const emit = defineEmits<IButtonEmits>();
145
+ const props = defineProps(buttonProps)
146
+ const emit = defineEmits<IButtonEmits>()
286
147
 
287
- const textColor = (ColorConfig as any)[props.type];
148
+ const textColor = (ColorConfig as any)[props.type]
288
149
 
289
150
  /**
290
151
  * @description 生成bem风格的类名
291
152
  */
292
153
  const bemClass = computed(() => {
293
- // this.bem为一个computed变量,在mixin中
294
- if (!props.color) {
295
- return bem(
296
- "button",
297
- props,
298
- ["type", "shape", "size"],
299
- ["disabled", "plain", "hairline"],
300
- );
301
- } else {
302
- // 由于nvue的原因,在有color参数时,不需要传入type,否则会生成type相关的类型,影响最终的样式
303
- return bem(
304
- "button",
305
- props,
306
- ["shape", "size"],
307
- ["disabled", "plain", "hairline"],
308
- );
309
- }
310
- });
154
+ // this.bem为一个computed变量,在mixin中
155
+ if (!props.color) {
156
+ return bem('button', props, ['type', 'shape', 'size'], ['disabled', 'plain', 'hairline'])
157
+ } else {
158
+ // 由于nvue的原因,在有color参数时,不需要传入type,否则会生成type相关的类型,影响最终的样式
159
+ return bem('button', props, ['shape', 'size'], ['disabled', 'plain', 'hairline'])
160
+ }
161
+ })
311
162
 
312
163
  const loadingColor = computed(() => {
313
- if (props.plain) {
314
- // 如果有设置color值,则用color值,否则使用type主题颜色
315
- return props.color ? props.color : "";
316
- }
317
- if (props.type === "info") {
318
- return "#c9c9c9";
319
- }
320
- return "#fff";
321
- });
164
+ if (props.plain) {
165
+ // 如果有设置color值,则用color值,否则使用type主题颜色
166
+ return props.color ? props.color : ''
167
+ }
168
+ if (props.type === 'info') {
169
+ return '#c9c9c9'
170
+ }
171
+ return '#fff'
172
+ })
322
173
 
323
174
  const iconColorCom = computed((): string => {
324
- // 如果是镂空状态,设置了color就用color值,否则使用主题颜色,
325
- if (props.icon?.color) return props.icon?.color;
326
- if (props.plain) {
327
- return props.color ? props.color : "";
328
- } else {
329
- return "#ffffff";
330
- }
331
- });
332
- const baseColor = computed((): CSSProperties => {
333
- let style: CSSProperties = {};
334
- if (props.color) {
335
- // 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色
336
- style.color = props.plain ? props.color : "white";
337
- if (!props.plain) {
338
- // 非镂空,背景色使用自定义的颜色
339
- style["background"] = props.color;
175
+ // 如果是镂空状态,设置了color就用color值,否则使用主题颜色,
176
+ if (props.icon?.color) return props.icon?.color
177
+ if (props.plain) {
178
+ return props.color ? props.color : ''
179
+ } else {
180
+ return '#ffffff'
340
181
  }
341
- if (props.color.indexOf("gradient") !== -1) {
342
- // 如果自定义的颜色为渐变色,不显示边框,以及通过backgroundImage设置渐变色
343
- // weex文档说明可以写borderWidth的形式,为什么这里需要分开写?
344
- // 因为weex是阿里巴巴为了部门业绩考核而做的你懂的东西,所以需要这么写才有效
345
- style.borderTopWidth = 0;
346
- style.borderRightWidth = 0;
347
- style.borderBottomWidth = 0;
348
- style.borderLeftWidth = 0;
349
- if (!props.plain) {
350
- style.backgroundImage = props.color;
351
- }
182
+ })
183
+ const baseColor = computed((): CSSProperties => {
184
+ let style: CSSProperties = {}
185
+ if (props.color) {
186
+ // 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色
187
+ style.color = props.plain ? props.color : 'white'
188
+ if (!props.plain) {
189
+ // 非镂空,背景色使用自定义的颜色
190
+ style['background'] = props.color
191
+ }
192
+ if (props.color.indexOf('gradient') !== -1) {
193
+ // 如果自定义的颜色为渐变色,不显示边框,以及通过backgroundImage设置渐变色
194
+ // weex文档说明可以写borderWidth的形式,为什么这里需要分开写?
195
+ // 因为weex是阿里巴巴为了部门业绩考核而做的你懂的东西,所以需要这么写才有效
196
+ style.borderTopWidth = 0
197
+ style.borderRightWidth = 0
198
+ style.borderBottomWidth = 0
199
+ style.borderLeftWidth = 0
200
+ if (!props.plain) {
201
+ style.backgroundImage = props.color
202
+ }
203
+ } else {
204
+ // 非渐变色,则设置边框相关的属性
205
+ style.borderColor = props.color
206
+ style.borderWidth = '1px'
207
+ style.borderStyle = 'solid'
208
+ }
352
209
  } else {
353
- // 非渐变色,则设置边框相关的属性
354
- style.borderColor = props.color;
355
- style.borderWidth = "1px";
356
- style.borderStyle = "solid";
210
+ // 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色
211
+ // style.color = props.plain ? textColor : "";
357
212
  }
358
- } else {
359
- // 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色
360
- // style.color = props.plain ? textColor : "";
361
- }
362
- return style;
363
- });
213
+ return style
214
+ })
364
215
 
365
216
  // nvue版本按钮的字体不会继承父组件的颜色,需要对每一个text组件进行单独的设置
366
217
  const nvueTextStyle = computed((): CSSProperties => {
367
- let style: CSSProperties = {};
368
- // 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色
369
- if (props.type === "info") {
370
- style.color = "#323233";
371
- }
372
- if (props.color) {
373
- style.color = props.plain ? props.color : "white";
374
- }
375
- style.fontSize = textSize.value + "px";
376
- return style;
377
- });
218
+ let style: CSSProperties = {}
219
+ // 针对自定义了color颜色的情况,镂空状态下,就是用自定义的颜色
220
+ if (props.type === 'info') {
221
+ style.color = '#323233'
222
+ }
223
+ if (props.color) {
224
+ style.color = props.plain ? props.color : 'white'
225
+ }
226
+ style.fontSize = textSize.value + 'px'
227
+ return style
228
+ })
378
229
  /**
379
230
  * @description 字体大小
380
231
  * */
381
232
  const textSize = computed((): number => {
382
- let fontSize = 14;
383
- if (props.size === "large") fontSize = 16;
384
- if (props.size === "medium") fontSize = 14;
385
- if (props.size === "small") fontSize = 12;
386
- if (props.size === "mini") fontSize = 10;
387
- return fontSize;
388
- });
233
+ let fontSize = 14
234
+ if (props.size === 'large') fontSize = 16
235
+ if (props.size === 'medium') fontSize = 14
236
+ if (props.size === 'small') fontSize = 12
237
+ if (props.size === 'mini') fontSize = 10
238
+ return fontSize
239
+ })
389
240
 
390
241
  const clickHandler = (e: any) => {
391
- // 非禁止并且非加载中,才能点击
392
- if (!props.disabled && !props.loading) {
393
- // 进行节流控制,每this.throttle毫秒内,只在开始处执行
394
- throttle(() => {
395
- emit("click", e);
396
- }, props.throttleTime);
397
- }
398
- // 是否阻止事件传播
399
- props.stop && e.stopPropagation();
400
- };
242
+ // 非禁止并且非加载中,才能点击
243
+ if (!props.disabled && !props.loading) {
244
+ // 进行节流控制,每this.throttle毫秒内,只在开始处执行
245
+ throttle(() => {
246
+ emit('click', e)
247
+ }, props.throttleTime)
248
+ }
249
+ // 是否阻止事件传播
250
+ props.stop && e.stopPropagation()
251
+ }
401
252
 
402
253
  const getphonenumber = (e: any) => {
403
- emit("getphonenumber", e);
404
- };
254
+ emit('getphonenumber', e)
255
+ }
405
256
  const getuserinfo = (e: any) => {
406
- emit("getuserinfo", e);
407
- };
257
+ emit('getuserinfo', e)
258
+ }
408
259
  const error = (e: any) => {
409
- emit("error", e);
410
- };
260
+ emit('error', e)
261
+ }
411
262
  const opensetting = (e: any) => {
412
- emit("opensetting", e);
413
- };
263
+ emit('opensetting', e)
264
+ }
414
265
  const launchapp = (e: any) => {
415
- emit("launchapp", e);
416
- };
266
+ emit('launchapp', e)
267
+ }
417
268
  const agreeprivacyauthorization = (e: any) => {
418
- emit("agreeprivacyauthorization", e);
419
- };
269
+ emit('agreeprivacyauthorization', e)
270
+ }
420
271
  </script>
421
272
 
422
273
  <style lang="scss" scoped>
423
- @import "./index.scss";
274
+ @import './index.scss';
424
275
  </style>