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,363 +1,277 @@
1
1
  <template>
2
- <view class="hy-tooltip">
3
- <HyOverlay
4
- :show="showTooltip && tooltipTop !== -10000 && overlay"
5
- :customStyle="{ backgroundColor: 'rgba(0, 0, 0, 0)' }"
6
- @click="closeHandler"
7
- ></HyOverlay>
8
- <!-- 文本内容区域 -->
9
- <view
10
- :class="`hy-tooltip__content ${customClass}`"
11
- id="target"
12
- @longpress.stop="longPressHandler"
13
- @tap.stop="clickHandler"
14
- :style="[
15
- {
16
- color: color,
17
- fontSize: addUnit(size),
18
- fontWeight: bold ? 'bold' : '',
19
- backgroundColor:
20
- bgColor && showTooltip && tooltipTop !== -10000
21
- ? bgColor
22
- : 'transparent',
23
- },
24
- customStyle,
25
- ]"
26
- >
27
- <slot v-if="$slots.default"></slot>
28
- <text class="hy-tooltip__content--text" v-else>{{ text }}</text>
29
- </view>
2
+ <view class="hy-tooltip">
3
+ <hy-overlay
4
+ :show="showTooltip && tooltipTop !== -10000 && overlay"
5
+ :customStyle="{ backgroundColor: 'rgba(0, 0, 0, 0)' }"
6
+ @click="closeHandler"
7
+ ></hy-overlay>
8
+ <!-- 文本内容区域 -->
9
+ <view
10
+ :class="`hy-tooltip__content ${customClass}`"
11
+ id="target"
12
+ @longpress.stop="longPressHandler"
13
+ @tap.stop="clickHandler"
14
+ :style="[
15
+ {
16
+ color: color,
17
+ fontSize: addUnit(size),
18
+ fontWeight: bold ? 'bold' : '',
19
+ backgroundColor:
20
+ bgColor && showTooltip && tooltipTop !== -10000 ? bgColor : 'transparent'
21
+ },
22
+ customStyle
23
+ ]"
24
+ >
25
+ <slot v-if="$slots.default"></slot>
26
+ <text class="hy-tooltip__content--text" v-else>{{ text }}</text>
27
+ </view>
30
28
 
31
- <!-- 用于获取弹窗宽高 -->
32
- <view class="hy-tooltip__popup hy-tooltip__hidden" id="pos">
33
- <view class="hy-tooltip__container custom-pop">
34
- <view class="hy-tooltip__container--list">
35
- <view
36
- v-if="showCopy"
37
- class="hy-tooltip__container--list__btn"
38
- hover-class="hy-tooltip__container--list__btn--hover"
39
- @tap.stop="setClipboardData"
40
- >
41
- <text class="hy-tooltip__container--list__btn--text">复制</text>
42
- </view>
43
- <HyLine
44
- direction="column"
45
- color="#8d8e90"
46
- v-if="showCopy && buttons.length > 0"
47
- length="18"
48
- ></HyLine>
49
- <template v-for="(item, index) in buttons" :key="index">
50
- <view
51
- class="hy-tooltip__container--list__btn"
52
- hover-class="hy-tooltip__container--list__btn--hover"
53
- >
54
- <text
55
- class="hy-tooltip__container--list__btn--text"
56
- @tap="btnClickHandler(index)"
57
- >
58
- {{ item }}
59
- </text>
29
+ <!-- 用于获取弹窗宽高 -->
30
+ <view class="hy-tooltip__popup hy-tooltip__hidden" id="pos">
31
+ <view class="hy-tooltip__container custom-pop">
32
+ <view class="hy-tooltip__container--list">
33
+ <view
34
+ v-if="showCopy"
35
+ class="hy-tooltip__container--list__btn"
36
+ hover-class="hy-tooltip__container--list__btn--hover"
37
+ @tap.stop="setClipboardData"
38
+ >
39
+ <text class="hy-tooltip__container--list__btn--text">复制</text>
40
+ </view>
41
+ <hy-line
42
+ direction="column"
43
+ color="#8d8e90"
44
+ v-if="showCopy && buttons.length > 0"
45
+ length="18"
46
+ ></hy-line>
47
+ <template v-for="(item, index) in buttons" :key="index">
48
+ <view
49
+ class="hy-tooltip__container--list__btn"
50
+ hover-class="hy-tooltip__container--list__btn--hover"
51
+ >
52
+ <text
53
+ class="hy-tooltip__container--list__btn--text"
54
+ @tap="btnClickHandler(index)"
55
+ >
56
+ {{ item }}
57
+ </text>
58
+ </view>
59
+ <hy-line
60
+ direction="column"
61
+ color="#8d8e90"
62
+ v-if="index < buttons.length - 1"
63
+ length="18"
64
+ ></hy-line>
65
+ </template>
66
+ </view>
60
67
  </view>
61
- <HyLine
62
- direction="column"
63
- color="#8d8e90"
64
- v-if="index < buttons.length - 1"
65
- length="18"
66
- ></HyLine>
67
- </template>
68
68
  </view>
69
- </view>
70
- </view>
71
69
 
72
- <HyTransition
73
- mode="fade"
74
- :show="showTooltip"
75
- :duration="300"
76
- custom-class="hy-tooltip__popup"
77
- :custom-style="{
78
- ...popover.popStyle.value,
79
- zIndex: zIndex,
80
- }"
81
- >
82
- <view class="hy-tooltip__container">
83
- <!-- 三角形 -->
84
- <view
85
- :class="`hy-tooltip__arrow ${popover.arrowClass.value}`"
86
- :style="popover.arrowStyle.value"
87
- ></view>
88
- <!-- 三角形 -->
70
+ <hy-transition
71
+ mode="fade"
72
+ :show="showTooltip"
73
+ :duration="300"
74
+ custom-class="hy-tooltip__popup"
75
+ :custom-style="{
76
+ ...popover.popStyle.value,
77
+ zIndex: zIndex
78
+ }"
79
+ >
80
+ <view class="hy-tooltip__container">
81
+ <!-- 三角形 -->
82
+ <view
83
+ :class="`hy-tooltip__arrow ${popover.arrowClass.value}`"
84
+ :style="popover.arrowStyle.value"
85
+ ></view>
86
+ <!-- 三角形 -->
89
87
 
90
- <view class="hy-tooltip__container--list">
91
- <view
92
- v-if="showCopy"
93
- class="hy-tooltip__container--list__btn"
94
- hover-class="hy-tooltip__container--list__btn--hover"
95
- @tap="setClipboardData"
96
- >
97
- <text class="hy-tooltip__container--list__btn--text">复制</text>
98
- </view>
99
- <HyLine
100
- direction="column"
101
- color="#8d8e90"
102
- v-if="showCopy && buttons.length > 0"
103
- length="18"
104
- ></HyLine>
105
- <template v-for="(item, index) in buttons" :key="index">
106
- <view
107
- class="hy-tooltip__container--list__btn"
108
- hover-class="hy-tooltip__container--list__btn--hover"
109
- >
110
- <text
111
- class="hy-tooltip__container--list__btn--text"
112
- @tap="btnClickHandler(index)"
113
- >
114
- {{ item }}
115
- </text>
88
+ <view class="hy-tooltip__container--list">
89
+ <view
90
+ v-if="showCopy"
91
+ class="hy-tooltip__container--list__btn"
92
+ hover-class="hy-tooltip__container--list__btn--hover"
93
+ @tap="setClipboardData"
94
+ >
95
+ <text class="hy-tooltip__container--list__btn--text">复制</text>
96
+ </view>
97
+ <hy-line
98
+ direction="column"
99
+ color="#8d8e90"
100
+ v-if="showCopy && buttons.length > 0"
101
+ length="18"
102
+ ></hy-line>
103
+ <template v-for="(item, index) in buttons" :key="index">
104
+ <view
105
+ class="hy-tooltip__container--list__btn"
106
+ hover-class="hy-tooltip__container--list__btn--hover"
107
+ >
108
+ <text
109
+ class="hy-tooltip__container--list__btn--text"
110
+ @tap="btnClickHandler(index)"
111
+ >
112
+ {{ item }}
113
+ </text>
114
+ </view>
115
+ <hy-line
116
+ direction="column"
117
+ color="#8d8e90"
118
+ v-if="index < buttons.length - 1"
119
+ length="18"
120
+ ></hy-line>
121
+ </template>
122
+ </view>
116
123
  </view>
117
- <HyLine
118
- direction="column"
119
- color="#8d8e90"
120
- v-if="index < buttons.length - 1"
121
- length="18"
122
- ></HyLine>
123
- </template>
124
- </view>
125
- </view>
126
- </HyTransition>
127
- </view>
124
+ </hy-transition>
125
+ </view>
128
126
  </template>
129
127
 
130
128
  <script lang="ts">
131
129
  export default {
132
- name: "hy-tooltip",
133
- options: {
134
- addGlobalClass: true,
135
- virtualHost: true,
136
- styleIsolation: "shared",
137
- },
138
- };
130
+ name: 'hy-tooltip',
131
+ options: {
132
+ addGlobalClass: true,
133
+ virtualHost: true,
134
+ styleIsolation: 'shared'
135
+ }
136
+ }
139
137
  </script>
140
138
 
141
139
  <script setup lang="ts">
140
+ import { ref, onMounted, watch, inject, onBeforeUnmount, getCurrentInstance } from 'vue'
141
+ import type { ITooltipEmits } from './typing'
142
142
  import {
143
- ref,
144
- onMounted,
145
- watch,
146
- inject,
147
- onBeforeUnmount,
148
- getCurrentInstance,
149
- } from "vue";
150
- import type { CSSProperties, PropType } from "vue";
151
- import type { ITooltipEmits } from "./typing";
152
- import type { IPlacementVo } from "../hy-popover/typing";
153
- import {
154
- type Queue,
155
- queueKey,
156
- usePopover,
157
- closeOther,
158
- removeFromQueue,
159
- pushToQueue,
160
- addUnit,
161
- } from "../../libs";
143
+ type Queue,
144
+ queueKey,
145
+ usePopover,
146
+ closeOther,
147
+ removeFromQueue,
148
+ pushToQueue,
149
+ addUnit
150
+ } from '../../libs'
151
+ import tooltipProps from './props'
162
152
 
163
153
  // 组件
164
- import HyTransition from "../hy-transition/hy-transition.vue";
165
- import HyLine from "../hy-line/hy-line.vue";
166
- import HyOverlay from "../hy-overlay/hy-overlay.vue";
154
+ import HyTransition from '../hy-transition/hy-transition.vue'
155
+ import HyLine from '../hy-line/hy-line.vue'
156
+ import HyOverlay from '../hy-overlay/hy-overlay.vue'
167
157
 
168
158
  /**
169
159
  * Tooltip组件主要用于长按操作,类似微信的长按气泡
170
160
  * @displayName hy-tooltip
171
161
  */
172
- defineOptions({});
162
+ defineOptions({})
173
163
 
174
- // const props = withDefaults(defineProps<IProps>(), defaultProps);
175
- const props = defineProps({
176
- /** 需要显示的提示文字 */
177
- text: {
178
- type: String,
179
- default: "",
180
- },
181
- /** 点击复制按钮时,复制的文本,为空则使用text值 */
182
- copyText: {
183
- type: String,
184
- default: "",
185
- },
186
- /**
187
- * 触发模式
188
- * @values longpress,click
189
- * */
190
- triggerMode: {
191
- type: String as PropType<"longpress" | "click">,
192
- default: "longpress",
193
- },
194
- /**
195
- * 指定 popover 的放置位置
196
- * @values top,top-start,top-end,bottom,bottom-start,bottom-end,left,left-start,left-end,right,right-start,right-end
197
- * */
198
- placement: {
199
- type: String as PropType<IPlacementVo>,
200
- default: "bottom",
201
- },
202
- /** 文本大小 */
203
- size: {
204
- type: [String, Number],
205
- default: 14,
206
- },
207
- /** 字体颜色 */
208
- color: String,
209
- /** 字体粗细 */
210
- bold: {
211
- type: Boolean,
212
- default: false,
213
- },
214
- /** 弹出提示框时,文本的背景色 */
215
- bgColor: {
216
- type: String,
217
- default: "transparent",
218
- },
219
- /** 弹出提示的z-index,nvue无效 */
220
- zIndex: {
221
- type: Number,
222
- default: 10071,
223
- },
224
- /** 是否显示复制按钮 */
225
- showCopy: {
226
- type: Boolean,
227
- default: true,
228
- },
229
- /** 扩展的按钮组 */
230
- buttons: {
231
- type: Array,
232
- default() {
233
- return [];
234
- },
235
- },
236
- /** 是否显示透明遮罩以防止触摸穿透 */
237
- overlay: {
238
- type: Boolean,
239
- default: true,
240
- },
241
- /** 是否显示提示 */
242
- showToast: {
243
- type: Boolean,
244
- default: true,
245
- },
246
- /** 定义需要用到的外部样式 */
247
- customStyle: Object as PropType<CSSProperties>,
248
- /** 自定义外部类名 */
249
- customClass: String,
250
- });
251
- const emit = defineEmits<ITooltipEmits>();
164
+ const props = defineProps(tooltipProps)
165
+ const emit = defineEmits<ITooltipEmits>()
252
166
 
253
- const queue = inject<Queue | null>(queueKey, null);
254
- const { proxy } = getCurrentInstance() as any;
167
+ const queue = inject<Queue | null>(queueKey, null)
168
+ const { proxy } = getCurrentInstance() as any
255
169
  // 显示三角标
256
- const visibleArrow = ref<boolean>(true);
257
- const popover = usePopover(visibleArrow.value);
258
- const showTooltip = ref<boolean>(false);
259
- const tooltipTop = ref<number>(-10000);
260
- const selector: string = "tooltip";
170
+ const visibleArrow = ref<boolean>(true)
171
+ const popover = usePopover(visibleArrow.value)
172
+ const showTooltip = ref<boolean>(false)
173
+ const tooltipTop = ref<number>(-10000)
174
+ const selector: string = 'tooltip'
261
175
 
262
176
  watch(
263
- () => props.placement,
264
- () => {
265
- popover.init(props.placement, visibleArrow.value, selector);
266
- },
267
- );
177
+ () => props.placement,
178
+ () => {
179
+ popover.init(props.placement, visibleArrow.value, selector)
180
+ }
181
+ )
268
182
 
269
183
  watch(
270
- () => showTooltip.value,
271
- (newValue) => {
272
- if (newValue) {
273
- popover.control(props.placement, 0);
274
- if (queue && queue.closeOther) {
275
- queue.closeOther(proxy);
276
- } else {
277
- closeOther(proxy);
278
- }
184
+ () => showTooltip.value,
185
+ (newValue) => {
186
+ if (newValue) {
187
+ popover.control(props.placement, 0)
188
+ if (queue && queue.closeOther) {
189
+ queue.closeOther(proxy)
190
+ } else {
191
+ closeOther(proxy)
192
+ }
193
+ }
279
194
  }
280
- },
281
- );
195
+ )
282
196
 
283
197
  onMounted(() => {
284
- // getElRect();
285
- popover.init(props.placement, visibleArrow.value, selector);
286
- });
198
+ // getElRect();
199
+ popover.init(props.placement, visibleArrow.value, selector)
200
+ })
287
201
 
288
202
  function onBeforeMount(param: () => void) {}
289
203
 
290
204
  onBeforeMount(() => {
291
- if (queue && queue.pushToQueue) {
292
- queue.pushToQueue(proxy);
293
- } else {
294
- pushToQueue(proxy);
295
- }
296
- });
205
+ if (queue && queue.pushToQueue) {
206
+ queue.pushToQueue(proxy)
207
+ } else {
208
+ pushToQueue(proxy)
209
+ }
210
+ })
297
211
 
298
212
  onBeforeUnmount(() => {
299
- if (queue && queue.removeFromQueue) {
300
- queue.removeFromQueue(proxy);
301
- } else {
302
- removeFromQueue(proxy);
303
- }
304
- });
213
+ if (queue && queue.removeFromQueue) {
214
+ queue.removeFromQueue(proxy)
215
+ } else {
216
+ removeFromQueue(proxy)
217
+ }
218
+ })
305
219
 
306
220
  // 长按触发事件
307
221
  const longPressHandler = () => {
308
- if (props.triggerMode === "longpress") {
309
- tooltipTop.value = 0;
310
- showTooltip.value = true;
311
- }
312
- };
222
+ if (props.triggerMode === 'longpress') {
223
+ tooltipTop.value = 0
224
+ showTooltip.value = true
225
+ }
226
+ }
313
227
 
314
228
  // 点击触发事件
315
229
  const clickHandler = () => {
316
- if (props.triggerMode === "click") {
317
- tooltipTop.value = 0;
318
- showTooltip.value = true;
319
- }
320
- };
230
+ if (props.triggerMode === 'click') {
231
+ tooltipTop.value = 0
232
+ showTooltip.value = true
233
+ }
234
+ }
321
235
 
322
236
  // 点击关闭
323
237
  const closeHandler = () => {
324
- showTooltip.value = false;
325
- };
238
+ showTooltip.value = false
239
+ }
326
240
 
327
241
  // 点击操作栏按钮
328
242
  const btnClickHandler = (index: number) => {
329
- showTooltip.value = false;
330
- // 如果需要展示复制按钮,此处index需要加1,因为复制按钮在第一个位置
331
- emit("click", props.showCopy ? index + 1 : index);
332
- };
243
+ showTooltip.value = false
244
+ // 如果需要展示复制按钮,此处index需要加1,因为复制按钮在第一个位置
245
+ emit('click', props.showCopy ? index + 1 : index)
246
+ }
333
247
 
334
248
  // 复制文本到粘贴板
335
249
  const setClipboardData = () => {
336
- // 关闭组件
337
- showTooltip.value = false;
338
- emit("click", 0);
339
- uni.setClipboardData({
340
- // 优先使用copyText字段,如果没有,则默认使用text字段当做复制的内容
341
- data: props.copyText || props.text,
342
- success: () => {
343
- props.showToast &&
344
- uni.showToast({
345
- title: "复制成功",
346
- });
347
- },
348
- fail: () => {
349
- props.showToast &&
350
- uni.showToast({
351
- title: "复制失败",
352
- });
353
- },
354
- complete: () => {
355
- showTooltip.value = false;
356
- },
357
- });
358
- };
250
+ // 关闭组件
251
+ showTooltip.value = false
252
+ emit('click', 0)
253
+ uni.setClipboardData({
254
+ // 优先使用copyText字段,如果没有,则默认使用text字段当做复制的内容
255
+ data: props.copyText || props.text,
256
+ success: () => {
257
+ props.showToast &&
258
+ uni.showToast({
259
+ title: '复制成功'
260
+ })
261
+ },
262
+ fail: () => {
263
+ props.showToast &&
264
+ uni.showToast({
265
+ title: '复制失败'
266
+ })
267
+ },
268
+ complete: () => {
269
+ showTooltip.value = false
270
+ }
271
+ })
272
+ }
359
273
  </script>
360
274
 
361
275
  <style lang="scss" scoped>
362
- @import "./index.scss";
276
+ @import './index.scss';
363
277
  </style>