@gmcb/uv-ui 0.2.26

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 (285) hide show
  1. package/CHANGELOG.md +295 -0
  2. package/LICENSE +21 -0
  3. package/README.md +164 -0
  4. package/components/uv-action-sheet/props.js +50 -0
  5. package/components/uv-action-sheet/uv-action-sheet.vue +280 -0
  6. package/components/uv-album/uv-album.vue +312 -0
  7. package/components/uv-alert/props.js +45 -0
  8. package/components/uv-alert/uv-alert.vue +246 -0
  9. package/components/uv-avatar/props.js +85 -0
  10. package/components/uv-avatar/uv-avatar.vue +182 -0
  11. package/components/uv-avatar-group/props.js +53 -0
  12. package/components/uv-avatar-group/uv-avatar-group.vue +106 -0
  13. package/components/uv-back-top/props.js +58 -0
  14. package/components/uv-back-top/uv-back-top.vue +116 -0
  15. package/components/uv-badge/props.js +73 -0
  16. package/components/uv-badge/uv-badge.vue +176 -0
  17. package/components/uv-button/nvue.scss +46 -0
  18. package/components/uv-button/props.js +163 -0
  19. package/components/uv-button/uv-button.vue +529 -0
  20. package/components/uv-button/vue.scss +93 -0
  21. package/components/uv-calendar/calendar.js +546 -0
  22. package/components/uv-calendar/header.vue +104 -0
  23. package/components/uv-calendar/month.vue +616 -0
  24. package/components/uv-calendar/props.js +145 -0
  25. package/components/uv-calendar/uv-calendar.vue +390 -0
  26. package/components/uv-calendars/calendar-body.vue +376 -0
  27. package/components/uv-calendars/calendar-item.vue +248 -0
  28. package/components/uv-calendars/calendar.js +546 -0
  29. package/components/uv-calendars/i18n/en.json +12 -0
  30. package/components/uv-calendars/i18n/index.js +8 -0
  31. package/components/uv-calendars/i18n/zh-Hans.json +12 -0
  32. package/components/uv-calendars/i18n/zh-Hant.json +12 -0
  33. package/components/uv-calendars/util.js +435 -0
  34. package/components/uv-calendars/uv-calendars.vue +452 -0
  35. package/components/uv-cell/props.js +116 -0
  36. package/components/uv-cell/uv-cell.vue +209 -0
  37. package/components/uv-cell-group/props.js +15 -0
  38. package/components/uv-cell-group/uv-cell-group.vue +63 -0
  39. package/components/uv-checkbox/props.js +70 -0
  40. package/components/uv-checkbox/uv-checkbox.vue +371 -0
  41. package/components/uv-checkbox-group/props.js +84 -0
  42. package/components/uv-checkbox-group/uv-checkbox-group.vue +119 -0
  43. package/components/uv-code/props.js +35 -0
  44. package/components/uv-code/uv-code.vue +136 -0
  45. package/components/uv-code-input/props.js +83 -0
  46. package/components/uv-code-input/uv-code-input.vue +272 -0
  47. package/components/uv-col/props.js +30 -0
  48. package/components/uv-col/uv-col.vue +165 -0
  49. package/components/uv-collapse/props.js +20 -0
  50. package/components/uv-collapse/uv-collapse.vue +86 -0
  51. package/components/uv-collapse-item/props.js +60 -0
  52. package/components/uv-collapse-item/uv-collapse-item.vue +228 -0
  53. package/components/uv-column-notice/props.js +61 -0
  54. package/components/uv-column-notice/uv-column-notice.vue +176 -0
  55. package/components/uv-count-down/props.js +25 -0
  56. package/components/uv-count-down/utils.js +62 -0
  57. package/components/uv-count-down/uv-count-down.vue +169 -0
  58. package/components/uv-count-to/props.js +60 -0
  59. package/components/uv-count-to/uv-count-to.vue +187 -0
  60. package/components/uv-datetime-picker/props.js +130 -0
  61. package/components/uv-datetime-picker/uv-datetime-picker.vue +355 -0
  62. package/components/uv-divider/props.js +45 -0
  63. package/components/uv-divider/uv-divider.vue +113 -0
  64. package/components/uv-drop-down/uv-drop-down.vue +135 -0
  65. package/components/uv-drop-down-item/uv-drop-down-item.vue +169 -0
  66. package/components/uv-drop-down-popup/uv-drop-down-popup.vue +242 -0
  67. package/components/uv-empty/props.js +60 -0
  68. package/components/uv-empty/uv-empty.vue +126 -0
  69. package/components/uv-form/props.js +46 -0
  70. package/components/uv-form/uv-form.vue +209 -0
  71. package/components/uv-form/valid.js +1343 -0
  72. package/components/uv-form-item/props.js +49 -0
  73. package/components/uv-form-item/uv-form-item.vue +226 -0
  74. package/components/uv-gap/props.js +25 -0
  75. package/components/uv-gap/uv-gap.vue +36 -0
  76. package/components/uv-grid/props.js +20 -0
  77. package/components/uv-grid/uv-grid.vue +100 -0
  78. package/components/uv-grid-item/props.js +15 -0
  79. package/components/uv-grid-item/uv-grid-item.vue +223 -0
  80. package/components/uv-icon/icons.js +160 -0
  81. package/components/uv-icon/props.js +90 -0
  82. package/components/uv-icon/uv-icon.vue +226 -0
  83. package/components/uv-icon/uvicons.ttf +0 -0
  84. package/components/uv-image/props.js +100 -0
  85. package/components/uv-image/uv-image.vue +296 -0
  86. package/components/uv-index-anchor/props.js +30 -0
  87. package/components/uv-index-anchor/uv-index-anchor.vue +98 -0
  88. package/components/uv-index-item/uv-index-item.vue +87 -0
  89. package/components/uv-index-list/props.js +30 -0
  90. package/components/uv-index-list/uv-index-list.vue +461 -0
  91. package/components/uv-input/props.js +175 -0
  92. package/components/uv-input/uv-input.vue +348 -0
  93. package/components/uv-keyboard/props.js +95 -0
  94. package/components/uv-keyboard/uv-keyboard.vue +180 -0
  95. package/components/uv-keyboard-car/props.js +24 -0
  96. package/components/uv-keyboard-car/uv-keyboard-car.vue +347 -0
  97. package/components/uv-keyboard-number/props.js +19 -0
  98. package/components/uv-keyboard-number/uv-keyboard-number.vue +201 -0
  99. package/components/uv-line/props.js +34 -0
  100. package/components/uv-line/uv-line.vue +60 -0
  101. package/components/uv-line-progress/props.js +29 -0
  102. package/components/uv-line-progress/uv-line-progress.vue +146 -0
  103. package/components/uv-link/props.js +40 -0
  104. package/components/uv-link/uv-link.vue +83 -0
  105. package/components/uv-list/uv-list.vue +147 -0
  106. package/components/uv-list-item/uv-list-item.vue +535 -0
  107. package/components/uv-load-more/props.js +95 -0
  108. package/components/uv-load-more/uv-load-more.vue +152 -0
  109. package/components/uv-loading-icon/props.js +67 -0
  110. package/components/uv-loading-icon/uv-loading-icon.vue +347 -0
  111. package/components/uv-loading-page/props.js +55 -0
  112. package/components/uv-loading-page/uv-loading-page.vue +96 -0
  113. package/components/uv-modal/props.js +90 -0
  114. package/components/uv-modal/uv-modal.vue +245 -0
  115. package/components/uv-navbar/props.js +89 -0
  116. package/components/uv-navbar/uv-navbar.vue +245 -0
  117. package/components/uv-no-network/props.js +20 -0
  118. package/components/uv-no-network/uv-no-network.vue +222 -0
  119. package/components/uv-notice-bar/props.js +76 -0
  120. package/components/uv-notice-bar/uv-notice-bar.vue +110 -0
  121. package/components/uv-notify/props.js +45 -0
  122. package/components/uv-notify/uv-notify.vue +220 -0
  123. package/components/uv-number-box/props.js +118 -0
  124. package/components/uv-number-box/uv-number-box.vue +397 -0
  125. package/components/uv-overlay/props.js +25 -0
  126. package/components/uv-overlay/uv-overlay.vue +85 -0
  127. package/components/uv-parse/node/node.vue +576 -0
  128. package/components/uv-parse/parser.js +1335 -0
  129. package/components/uv-parse/uv-parse.vue +498 -0
  130. package/components/uv-pick-color/colors.js +217 -0
  131. package/components/uv-pick-color/props.js +47 -0
  132. package/components/uv-pick-color/uv-pick-color.vue +551 -0
  133. package/components/uv-picker/props.js +95 -0
  134. package/components/uv-picker/uv-picker.vue +329 -0
  135. package/components/uv-popup/keypress.js +45 -0
  136. package/components/uv-popup/uv-popup.vue +537 -0
  137. package/components/uv-preview-video/uv-preview-video.vue +52 -0
  138. package/components/uv-qrcode/cache.js +1 -0
  139. package/components/uv-qrcode/gcanvas/bridge/bridge-weex.js +241 -0
  140. package/components/uv-qrcode/gcanvas/context-2d/FillStyleLinearGradient.js +18 -0
  141. package/components/uv-qrcode/gcanvas/context-2d/FillStylePattern.js +8 -0
  142. package/components/uv-qrcode/gcanvas/context-2d/FillStyleRadialGradient.js +17 -0
  143. package/components/uv-qrcode/gcanvas/context-2d/RenderingContext.js +666 -0
  144. package/components/uv-qrcode/gcanvas/context-webgl/ActiveInfo.js +11 -0
  145. package/components/uv-qrcode/gcanvas/context-webgl/Buffer.js +21 -0
  146. package/components/uv-qrcode/gcanvas/context-webgl/Framebuffer.js +21 -0
  147. package/components/uv-qrcode/gcanvas/context-webgl/GLenum.js +298 -0
  148. package/components/uv-qrcode/gcanvas/context-webgl/GLmethod.js +142 -0
  149. package/components/uv-qrcode/gcanvas/context-webgl/GLtype.js +23 -0
  150. package/components/uv-qrcode/gcanvas/context-webgl/Program.js +21 -0
  151. package/components/uv-qrcode/gcanvas/context-webgl/Renderbuffer.js +21 -0
  152. package/components/uv-qrcode/gcanvas/context-webgl/RenderingContext.js +1191 -0
  153. package/components/uv-qrcode/gcanvas/context-webgl/Shader.js +22 -0
  154. package/components/uv-qrcode/gcanvas/context-webgl/ShaderPrecisionFormat.js +11 -0
  155. package/components/uv-qrcode/gcanvas/context-webgl/Texture.js +22 -0
  156. package/components/uv-qrcode/gcanvas/context-webgl/UniformLocation.js +22 -0
  157. package/components/uv-qrcode/gcanvas/context-webgl/classUtils.js +3 -0
  158. package/components/uv-qrcode/gcanvas/env/canvas.js +74 -0
  159. package/components/uv-qrcode/gcanvas/env/image.js +96 -0
  160. package/components/uv-qrcode/gcanvas/env/tool.js +24 -0
  161. package/components/uv-qrcode/gcanvas/index.js +39 -0
  162. package/components/uv-qrcode/props.js +85 -0
  163. package/components/uv-qrcode/qrcode.js +34 -0
  164. package/components/uv-qrcode/queue.js +41 -0
  165. package/components/uv-qrcode/uv-qrcode.vue +1038 -0
  166. package/components/uv-radio/props.js +65 -0
  167. package/components/uv-radio/uv-radio.vue +349 -0
  168. package/components/uv-radio-group/props.js +89 -0
  169. package/components/uv-radio-group/uv-radio-group.vue +115 -0
  170. package/components/uv-rate/props.js +73 -0
  171. package/components/uv-rate/uv-rate.vue +274 -0
  172. package/components/uv-read-more/props.js +62 -0
  173. package/components/uv-read-more/uv-read-more.vue +162 -0
  174. package/components/uv-row/props.js +20 -0
  175. package/components/uv-row/uv-row.vue +95 -0
  176. package/components/uv-row-notice/props.js +40 -0
  177. package/components/uv-row-notice/uv-row-notice.vue +341 -0
  178. package/components/uv-safe-bottom/uv-safe-bottom.vue +67 -0
  179. package/components/uv-scroll-list/nvue.js +29 -0
  180. package/components/uv-scroll-list/props.js +35 -0
  181. package/components/uv-scroll-list/scrollWxs.wxs +51 -0
  182. package/components/uv-scroll-list/uv-scroll-list.vue +218 -0
  183. package/components/uv-search/props.js +127 -0
  184. package/components/uv-search/uv-search.vue +311 -0
  185. package/components/uv-skeleton/props.js +65 -0
  186. package/components/uv-skeleton/uv-skeleton.vue +250 -0
  187. package/components/uv-skeletons/uv-skeletons.vue +247 -0
  188. package/components/uv-slider/props.js +58 -0
  189. package/components/uv-slider/uv-slider.vue +58 -0
  190. package/components/uv-status-bar/props.js +8 -0
  191. package/components/uv-status-bar/uv-status-bar.vue +54 -0
  192. package/components/uv-steps/props.js +40 -0
  193. package/components/uv-steps/uv-steps.vue +83 -0
  194. package/components/uv-steps-item/props.js +25 -0
  195. package/components/uv-steps-item/uv-steps-item.vue +347 -0
  196. package/components/uv-sticky/props.js +41 -0
  197. package/components/uv-sticky/uv-sticky.vue +223 -0
  198. package/components/uv-subsection/props.js +54 -0
  199. package/components/uv-subsection/uv-subsection.vue +269 -0
  200. package/components/uv-swipe-action/props.js +10 -0
  201. package/components/uv-swipe-action/uv-swipe-action.vue +65 -0
  202. package/components/uv-swipe-action-item/index - backup.wxs +256 -0
  203. package/components/uv-swipe-action-item/index.wxs +225 -0
  204. package/components/uv-swipe-action-item/nvue - backup.js +264 -0
  205. package/components/uv-swipe-action-item/nvue.js +182 -0
  206. package/components/uv-swipe-action-item/props.js +40 -0
  207. package/components/uv-swipe-action-item/uv-swipe-action-item.vue +200 -0
  208. package/components/uv-swipe-action-item/wxs.js +15 -0
  209. package/components/uv-swiper/props.js +136 -0
  210. package/components/uv-swiper/uv-swiper.vue +263 -0
  211. package/components/uv-swiper-indicator/props.js +30 -0
  212. package/components/uv-swiper-indicator/uv-swiper-indicator.vue +112 -0
  213. package/components/uv-switch/props.js +58 -0
  214. package/components/uv-switch/uv-switch.vue +182 -0
  215. package/components/uv-tabbar/props.js +50 -0
  216. package/components/uv-tabbar/uv-tabbar.vue +146 -0
  217. package/components/uv-tabbar-item/props.js +40 -0
  218. package/components/uv-tabbar-item/uv-tabbar-item.vue +146 -0
  219. package/components/uv-tabs/props.js +71 -0
  220. package/components/uv-tabs/uv-tabs.vue +391 -0
  221. package/components/uv-tags/props.js +104 -0
  222. package/components/uv-tags/uv-tags.vue +379 -0
  223. package/components/uv-text/props.js +113 -0
  224. package/components/uv-text/uv-text.vue +218 -0
  225. package/components/uv-text/value.js +87 -0
  226. package/components/uv-textarea/props.js +138 -0
  227. package/components/uv-textarea/uv-textarea.vue +238 -0
  228. package/components/uv-toast/uv-toast.vue +292 -0
  229. package/components/uv-toolbar/props.js +40 -0
  230. package/components/uv-toolbar/uv-toolbar.vue +109 -0
  231. package/components/uv-tooltip/props.js +60 -0
  232. package/components/uv-tooltip/uv-tooltip.vue +372 -0
  233. package/components/uv-transition/createAnimation.js +131 -0
  234. package/components/uv-transition/props.js +31 -0
  235. package/components/uv-transition/uv-transition.vue +320 -0
  236. package/components/uv-upload/mixin.js +22 -0
  237. package/components/uv-upload/props.js +130 -0
  238. package/components/uv-upload/utils.js +151 -0
  239. package/components/uv-upload/uv-upload.vue +488 -0
  240. package/components/uv-vtabs/props.js +79 -0
  241. package/components/uv-vtabs/uv-vtabs.vue +438 -0
  242. package/components/uv-vtabs-item/uv-vtabs-item.vue +68 -0
  243. package/components/uv-waterfall/props.js +69 -0
  244. package/components/uv-waterfall/uv-waterfall.vue +265 -0
  245. package/index.js +82 -0
  246. package/index.scss +7 -0
  247. package/libs/config/config.js +34 -0
  248. package/libs/css/color.scss +32 -0
  249. package/libs/css/common.scss +100 -0
  250. package/libs/css/components.scss +23 -0
  251. package/libs/css/variable.scss +111 -0
  252. package/libs/css/vue.scss +40 -0
  253. package/libs/function/colorGradient.js +134 -0
  254. package/libs/function/compress.js +27 -0
  255. package/libs/function/debounce.js +29 -0
  256. package/libs/function/digit.js +167 -0
  257. package/libs/function/index.js +734 -0
  258. package/libs/function/platform.js +75 -0
  259. package/libs/function/test.js +287 -0
  260. package/libs/function/throttle.js +30 -0
  261. package/libs/luch-request/adapters/index.js +132 -0
  262. package/libs/luch-request/core/InterceptorManager.js +51 -0
  263. package/libs/luch-request/core/Request.js +201 -0
  264. package/libs/luch-request/core/buildFullPath.js +20 -0
  265. package/libs/luch-request/core/defaults.js +33 -0
  266. package/libs/luch-request/core/dispatchRequest.js +6 -0
  267. package/libs/luch-request/core/mergeConfig.js +126 -0
  268. package/libs/luch-request/core/settle.js +16 -0
  269. package/libs/luch-request/helpers/buildURL.js +64 -0
  270. package/libs/luch-request/helpers/combineURLs.js +14 -0
  271. package/libs/luch-request/helpers/isAbsoluteURL.js +14 -0
  272. package/libs/luch-request/index.d.ts +197 -0
  273. package/libs/luch-request/index.js +2 -0
  274. package/libs/luch-request/utils/clone.js +264 -0
  275. package/libs/luch-request/utils.js +135 -0
  276. package/libs/mixin/button.js +13 -0
  277. package/libs/mixin/mixin.js +172 -0
  278. package/libs/mixin/mpMixin.js +8 -0
  279. package/libs/mixin/mpShare.js +13 -0
  280. package/libs/mixin/openType.js +47 -0
  281. package/libs/mixin/touch.js +59 -0
  282. package/libs/util/dayjs.js +216 -0
  283. package/libs/util/route.js +126 -0
  284. package/package.json +28 -0
  285. package/theme.scss +43 -0
@@ -0,0 +1,372 @@
1
+ <template>
2
+ <view
3
+ class="uv-tooltip"
4
+ :style="[$uv.addStyle(customStyle)]"
5
+ >
6
+ <uv-overlay
7
+ :show="showTooltip && tooltipTop !== -10000 && overlay && timeout>0"
8
+ customStyle="backgroundColor: rgba(0, 0, 0, 0)"
9
+ @click="overlayClickHandler"
10
+ ></uv-overlay>
11
+ <view class="uv-tooltip__wrapper">
12
+ <template v-if="isShow">
13
+ <text
14
+ class="uv-tooltip__wrapper__text"
15
+ :id="textId"
16
+ :ref="textId"
17
+ :userSelect="false"
18
+ :selectable="false"
19
+ @click.stop="longpressHandler"
20
+ :style="{
21
+ color: color,
22
+ backgroundColor: bgColor && showTooltip && tooltipTop !== -10000 ? bgColor : 'transparent'
23
+ }"
24
+ >{{ text }}</text>
25
+ </template>
26
+ <template v-else>
27
+ <text
28
+ class="uv-tooltip__wrapper__text"
29
+ :id="textId"
30
+ :ref="textId"
31
+ :userSelect="false"
32
+ :selectable="false"
33
+ @longpress.stop="longpressHandler"
34
+ :style="{
35
+ color: color,
36
+ backgroundColor: bgColor && showTooltip && tooltipTop !== -10000 ? bgColor : 'transparent'
37
+ }"
38
+ >{{ text }}</text>
39
+ </template>
40
+ <uv-transition
41
+ mode="fade"
42
+ :show="showTooltip"
43
+ :duration="300"
44
+ :customStyle="{
45
+ position: 'absolute',
46
+ top: $uv.addUnit(tooltipTop),
47
+ zIndex: zIndex,
48
+ ...tooltipStyle
49
+ }"
50
+ >
51
+ <view
52
+ class="uv-tooltip__wrapper__popup"
53
+ :id="tooltipId"
54
+ :ref="tooltipId"
55
+ >
56
+ <view
57
+ class="uv-tooltip__wrapper__popup__indicator"
58
+ hover-class="uv-tooltip__wrapper__popup__indicator--hover"
59
+ v-if="showCopy || buttons.length"
60
+ :style="[indicatorStyle, {
61
+ width: $uv.addUnit(indicatorWidth),
62
+ height: $uv.addUnit(indicatorWidth),
63
+ }]"
64
+ >
65
+ <!-- 由于nvue不支持三角形绘制,这里就做一个四方形,再旋转45deg,得到露出的一个三角 -->
66
+ </view>
67
+ <view class="uv-tooltip__wrapper__popup__list">
68
+ <view
69
+ v-if="showCopy"
70
+ class="uv-tooltip__wrapper__popup__list__btn"
71
+ hover-class="uv-tooltip__wrapper__popup__list__btn--hover"
72
+ @tap="setClipboardData"
73
+ >
74
+ <text
75
+ class="uv-tooltip__wrapper__popup__list__btn__text"
76
+ >复制</text>
77
+ </view>
78
+ <uv-line
79
+ direction="column"
80
+ color="#8d8e90"
81
+ v-if="showCopy && buttons.length > 0"
82
+ length="18"
83
+ ></uv-line>
84
+ <block v-for="(item , index) in buttons" :key="index">
85
+ <view
86
+ class="uv-tooltip__wrapper__popup__list__btn"
87
+ hover-class="uv-tooltip__wrapper__popup__list__btn--hover"
88
+ >
89
+ <text
90
+ class="uv-tooltip__wrapper__popup__list__btn__text"
91
+ @tap="btnClickHandler(index)"
92
+ >{{ item }}</text>
93
+ </view>
94
+ <uv-line
95
+ direction="column"
96
+ color="#8d8e90"
97
+ v-if="index < buttons.length - 1"
98
+ length="18"
99
+ ></uv-line>
100
+ </block>
101
+ </view>
102
+ </view>
103
+ </uv-transition>
104
+ </view>
105
+ </view>
106
+ </template>
107
+
108
+ <script>
109
+ import mpMixin from '../../libs/mixin/mpMixin.js'
110
+ import mixin from '../../libs/mixin/mixin.js'
111
+ import props from './props.js';
112
+ // #ifdef APP-NVUE
113
+ const dom = uni.requireNativePlugin('dom')
114
+ // #endif
115
+ /**
116
+ * Tooltip
117
+ * @description
118
+ * @tutorial https://www.uvui.cn/components/tooltip.html
119
+ * @property {String | Number} text 需要显示的提示文字
120
+ * @property {String | Number} copyText 点击复制按钮时,复制的文本,为空则使用text值
121
+ * @property {String | Number} size 文本大小(默认 14 )
122
+ * @property {String} color 字体颜色(默认 '#606266' )
123
+ * @property {String} bgColor 弹出提示框时,文本的背景色(默认 'transparent' )
124
+ * @property {String} direction 弹出提示的方向,top-上方,bottom-下方(默认 'top' )
125
+ * @property {String | Number} zIndex 弹出提示的z-index,nvue无效(默认 10071 )
126
+ * @property {Boolean} showCopy 是否显示复制按钮(默认 true )
127
+ * @property {Array} buttons 扩展的按钮组
128
+ * @property {Boolean} overlay 是否显示透明遮罩以防止触摸穿透(默认 true )
129
+ * @property {Object} customStyle 定义需要用到的外部样式
130
+ *
131
+ * @event {Function}
132
+ * @example
133
+ */
134
+ export default {
135
+ name: 'uv-tooltip',
136
+ emits: ['click'],
137
+ mixins: [mpMixin, mixin, props],
138
+ data() {
139
+ return {
140
+ // 是否展示气泡
141
+ showTooltip: true,
142
+ // 生成唯一id,防止一个页面多个组件,造成干扰
143
+ textId: '',
144
+ tooltipId: '',
145
+ // 初始时甚至为很大的值,让其移到屏幕外面,为了计算元素的尺寸
146
+ tooltipTop: -10000,
147
+ // 气泡的位置信息
148
+ tooltipInfo: {
149
+ width: 0,
150
+ left: 0
151
+ },
152
+ // 文本的位置信息
153
+ textInfo: {
154
+ width: 0,
155
+ left: 0
156
+ },
157
+ // 三角形指示器的样式
158
+ indicatorStyle: {},
159
+ // 气泡在可能超出屏幕边沿范围时,重新定位后,距离屏幕边沿的距离
160
+ screenGap: 12,
161
+ // 三角形指示器的宽高,由于对元素进行了角度旋转,精确计算指示器位置时,需要用到其尺寸信息
162
+ indicatorWidth: 14,
163
+ timeout: 0
164
+ }
165
+ },
166
+ watch: {
167
+ propsChange() {
168
+ this.getElRect()
169
+ },
170
+ showTooltip(newVal){
171
+ if(!newVal) this.timeout = 0;
172
+ }
173
+ },
174
+ computed: {
175
+ isShow(){
176
+ const isPC = this.$uv.sys()?.model == 'PC';
177
+ if(isPC) {
178
+ return true;
179
+ }
180
+ // #ifdef MP-WEIXIN || H5
181
+ return false;
182
+ // #endif
183
+ return true;
184
+ },
185
+ // 特别处理H5的复制,因为H5浏览器是自带系统复制功能的,在H5环境
186
+ // 当一些依赖参数变化时,需要重新计算气泡和指示器的位置信息
187
+ propsChange() {
188
+ return [this.text, this.buttons]
189
+ },
190
+ // 计算气泡和指示器的位置信息
191
+ tooltipStyle() {
192
+ const style = {};
193
+ if (this.tooltipInfo.width / 2 > this.textInfo.left + this.textInfo.width / 2 - this.screenGap) {
194
+ this.indicatorStyle = {}
195
+ style.left = `-${this.$uv.addUnit(this.textInfo.left - this.screenGap)}`
196
+ this.indicatorStyle.left = this.$uv.addUnit(this.textInfo.width / 2 - this.$uv.getPx(style.left) - this.indicatorWidth /
197
+ 2)
198
+ } else if (this.tooltipInfo.width / 2 > this.$uv.sys().windowWidth - this.textInfo.right + this.textInfo.width / 2 -
199
+ this.screenGap) {
200
+ this.indicatorStyle = {}
201
+ style.right = `-${this.$uv.addUnit(this.$uv.sys().windowWidth - this.textInfo.right - this.screenGap)}`
202
+ this.indicatorStyle.right = this.$uv.addUnit(this.textInfo.width / 2 - this.$uv.getPx(style.right) - this
203
+ .indicatorWidth / 2)
204
+ } else {
205
+ const left = Math.abs(this.textInfo.width / 2 - this.tooltipInfo.width / 2)
206
+ style.left = this.textInfo.width > this.tooltipInfo.width ? this.$uv.addUnit(left) : -this.$uv.addUnit(left)
207
+ this.indicatorStyle = {}
208
+ }
209
+ if (this.direction === 'top') {
210
+ style.marginTop = `-${10 + this.tooltipInfo.height}px`
211
+ this.indicatorStyle.bottom = '-4px'
212
+ } else {
213
+ style.marginTop = `${this.tooltipInfo.height-10}px`
214
+ this.indicatorStyle.top = '-4px'
215
+ }
216
+ return style
217
+ }
218
+ },
219
+ created() {
220
+ this.textId = this.$uv.guid();
221
+ this.tooltipId = this.$uv.guid();
222
+ },
223
+ mounted() {
224
+ this.init()
225
+ },
226
+ methods: {
227
+ init() {
228
+ this.getElRect()
229
+ },
230
+ // 长按触发事件
231
+ async longpressHandler(e) {
232
+ this.tooltipTop = 0
233
+ this.showTooltip = true
234
+ setTimeout(()=>{
235
+ this.timeout = 1;
236
+ },300)
237
+ },
238
+ // 点击透明遮罩
239
+ overlayClickHandler() {
240
+ this.showTooltip = false
241
+ },
242
+ // 点击弹出按钮
243
+ btnClickHandler(index) {
244
+ this.showTooltip = false
245
+ // 如果需要展示复制按钮,此处index需要加1,因为复制按钮在第一个位置
246
+ this.$emit('click', this.showCopy ? index + 1 : index)
247
+ },
248
+ // 查询内容高度
249
+ queryRect(ref) {
250
+ // #ifndef APP-NVUE
251
+ // 组件内部一般用this.$uvGetRect,对外的为getRect,二者功能一致,名称不同
252
+ return new Promise(resolve => {
253
+ this.$uvGetRect(`#${ref}`).then(size => {
254
+ resolve(size)
255
+ })
256
+ })
257
+ // #endif
258
+
259
+ // #ifdef APP-NVUE
260
+ // nvue下,使用dom模块查询元素高度
261
+ // 返回一个promise,让调用此方法的主体能使用then回调
262
+ return new Promise(resolve => {
263
+ dom.getComponentRect(this.$refs[ref], res => {
264
+ resolve(res.size)
265
+ })
266
+ })
267
+ // #endif
268
+ },
269
+ // 元素尺寸
270
+ getElRect() {
271
+ // 调用之前,先将指示器调整到屏幕外,方便获取尺寸
272
+ this.showTooltip = true
273
+ this.tooltipTop = -10000
274
+ this.$uv.sleep(500).then(() => {
275
+ this.queryRect(this.tooltipId).then(size => {
276
+ this.tooltipInfo = size
277
+ // 获取气泡尺寸之后,将其隐藏,为了让下次切换气泡显示与隐藏时,有淡入淡出的效果
278
+ this.showTooltip = false
279
+ })
280
+ this.queryRect(this.textId).then(size => {
281
+ this.textInfo = size
282
+ })
283
+ })
284
+ },
285
+ // 复制文本到粘贴板
286
+ setClipboardData() {
287
+ // 关闭组件
288
+ this.showTooltip = false
289
+ this.$emit('click', 0)
290
+ uni.setClipboardData({
291
+ // 优先使用copyText字段,如果没有,则默认使用text字段当做复制的内容
292
+ data: this.copyText || this.text,
293
+ success: () => {
294
+ this.showToast && this.$uv.toast('复制成功')
295
+ },
296
+ fail: () => {
297
+ this.showToast && this.$uv.toast('复制失败')
298
+ },
299
+ complete: () => {
300
+ this.showTooltip = false
301
+ }
302
+ })
303
+ }
304
+ }
305
+ }
306
+ </script>
307
+
308
+ <style lang="scss" scoped>
309
+ @import '../../libs/css/components.scss';
310
+
311
+ .uv-tooltip {
312
+ position: relative;
313
+ @include flex;
314
+
315
+ &__wrapper {
316
+ @include flex;
317
+ justify-content: center;
318
+ /* #ifndef APP-NVUE */
319
+ white-space: nowrap;
320
+ /* #endif */
321
+
322
+ &__text {
323
+ font-size: 14px;
324
+ }
325
+
326
+ &__popup {
327
+ @include flex;
328
+ justify-content: center;
329
+
330
+ &__list {
331
+ background-color: #060607;
332
+ position: relative;
333
+ flex: 1;
334
+ border-radius: 5px;
335
+ padding: 0px 0;
336
+ @include flex(row);
337
+ align-items: center;
338
+ overflow: hidden;
339
+
340
+ &__btn {
341
+ padding: 11px 13px;
342
+
343
+ &--hover {
344
+ background-color: #58595B;
345
+ }
346
+
347
+ &__text {
348
+ line-height: 12px;
349
+ font-size: 13px;
350
+ color: #FFFFFF;
351
+ }
352
+ }
353
+ }
354
+
355
+ &__indicator {
356
+ position: absolute;
357
+ background-color: #060607;
358
+ width: 14px;
359
+ height: 14px;
360
+ bottom: -4px;
361
+ transform: rotate(45deg);
362
+ border-radius: 2px;
363
+ z-index: -1;
364
+
365
+ &--hover {
366
+ background-color: #58595B;
367
+ }
368
+ }
369
+ }
370
+ }
371
+ }
372
+ </style>
@@ -0,0 +1,131 @@
1
+ // const defaultOption = {
2
+ // duration: 300,
3
+ // timingFunction: 'linear',
4
+ // delay: 0,
5
+ // transformOrigin: '50% 50% 0'
6
+ // }
7
+ // #ifdef APP-NVUE
8
+ const nvueAnimation = uni.requireNativePlugin('animation')
9
+ // #endif
10
+ class MPAnimation {
11
+ constructor(options, _this) {
12
+ this.options = options
13
+ // 在iOS10+QQ小程序平台下,传给原生的对象一定是个普通对象而不是Proxy对象,否则会报parameter should be Object instead of ProxyObject的错误
14
+ this.animation = uni.createAnimation({
15
+ ...options
16
+ })
17
+ this.currentStepAnimates = {}
18
+ this.next = 0
19
+ this.$ = _this
20
+
21
+ }
22
+
23
+ _nvuePushAnimates(type, args) {
24
+ let aniObj = this.currentStepAnimates[this.next]
25
+ let styles = {}
26
+ if (!aniObj) {
27
+ styles = {
28
+ styles: {},
29
+ config: {}
30
+ }
31
+ } else {
32
+ styles = aniObj
33
+ }
34
+ if (animateTypes1.includes(type)) {
35
+ if (!styles.styles.transform) {
36
+ styles.styles.transform = ''
37
+ }
38
+ let unit = ''
39
+ if(type === 'rotate'){
40
+ unit = 'deg'
41
+ }
42
+ styles.styles.transform += `${type}(${args+unit}) `
43
+ } else {
44
+ styles.styles[type] = `${args}`
45
+ }
46
+ this.currentStepAnimates[this.next] = styles
47
+ }
48
+ _animateRun(styles = {}, config = {}) {
49
+ let ref = this.$.$refs['ani'].ref
50
+ if (!ref) return
51
+ return new Promise((resolve, reject) => {
52
+ nvueAnimation.transition(ref, {
53
+ styles,
54
+ ...config
55
+ }, res => {
56
+ resolve()
57
+ })
58
+ })
59
+ }
60
+
61
+ _nvueNextAnimate(animates, step = 0, fn) {
62
+ let obj = animates[step]
63
+ if (obj) {
64
+ let {
65
+ styles,
66
+ config
67
+ } = obj
68
+ this._animateRun(styles, config).then(() => {
69
+ step += 1
70
+ this._nvueNextAnimate(animates, step, fn)
71
+ })
72
+ } else {
73
+ this.currentStepAnimates = {}
74
+ typeof fn === 'function' && fn()
75
+ this.isEnd = true
76
+ }
77
+ }
78
+
79
+ step(config = {}) {
80
+ // #ifndef APP-NVUE
81
+ this.animation.step(config)
82
+ // #endif
83
+ // #ifdef APP-NVUE
84
+ this.currentStepAnimates[this.next].config = Object.assign({}, this.options, config)
85
+ this.currentStepAnimates[this.next].styles.transformOrigin = this.currentStepAnimates[this.next].config.transformOrigin
86
+ this.next++
87
+ // #endif
88
+ return this
89
+ }
90
+
91
+ run(fn) {
92
+ // #ifndef APP-NVUE
93
+ this.$.animationData = this.animation.export()
94
+ this.$.timer = setTimeout(() => {
95
+ typeof fn === 'function' && fn()
96
+ }, this.$.durationTime)
97
+ // #endif
98
+ // #ifdef APP-NVUE
99
+ this.isEnd = false
100
+ let ref = this.$.$refs['ani'] && this.$.$refs['ani'].ref
101
+ if(!ref) return
102
+ this._nvueNextAnimate(this.currentStepAnimates, 0, fn)
103
+ this.next = 0
104
+ // #endif
105
+ }
106
+ }
107
+
108
+
109
+ const animateTypes1 = ['matrix', 'matrix3d', 'rotate', 'rotate3d', 'rotateX', 'rotateY', 'rotateZ', 'scale', 'scale3d',
110
+ 'scaleX', 'scaleY', 'scaleZ', 'skew', 'skewX', 'skewY', 'translate', 'translate3d', 'translateX', 'translateY',
111
+ 'translateZ'
112
+ ]
113
+ const animateTypes2 = ['opacity', 'backgroundColor']
114
+ const animateTypes3 = ['width', 'height', 'left', 'right', 'top', 'bottom']
115
+ animateTypes1.concat(animateTypes2, animateTypes3).forEach(type => {
116
+ MPAnimation.prototype[type] = function(...args) {
117
+ // #ifndef APP-NVUE
118
+ this.animation[type](...args)
119
+ // #endif
120
+ // #ifdef APP-NVUE
121
+ this._nvuePushAnimates(type, args)
122
+ // #endif
123
+ return this
124
+ }
125
+ })
126
+
127
+ export function createAnimation(option, _this) {
128
+ if(!_this) return
129
+ clearTimeout(_this.timer)
130
+ return new MPAnimation(option, _this)
131
+ }
@@ -0,0 +1,31 @@
1
+ export default {
2
+ props: {
3
+ // 是否展示组件
4
+ show: {
5
+ type: Boolean,
6
+ default: false
7
+ },
8
+ // 使用的动画模式
9
+ mode: {
10
+ type: [Array, String, null],
11
+ default() {
12
+ return 'fade'
13
+ }
14
+ },
15
+ // 动画的执行时间,单位ms
16
+ duration: {
17
+ type: [String, Number],
18
+ default: 300
19
+ },
20
+ // 使用的动画过渡函数
21
+ timingFunction: {
22
+ type: String,
23
+ default: 'ease-out'
24
+ },
25
+ customClass: {
26
+ type: String,
27
+ default: ''
28
+ },
29
+ ...uni.$uv?.props?.transition
30
+ }
31
+ }