uview-plus 3.0.3

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 (366) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +64 -0
  3. package/changelog.md +8 -0
  4. package/components/u--form/u--form.vue +78 -0
  5. package/components/u--image/u--image.vue +47 -0
  6. package/components/u--input/u--input.vue +73 -0
  7. package/components/u--text/u--text.vue +44 -0
  8. package/components/u--textarea/u--textarea.vue +48 -0
  9. package/components/u-action-sheet/props.js +54 -0
  10. package/components/u-action-sheet/u-action-sheet.vue +278 -0
  11. package/components/u-album/props.js +59 -0
  12. package/components/u-album/u-album.vue +259 -0
  13. package/components/u-alert/props.js +44 -0
  14. package/components/u-alert/u-alert.vue +243 -0
  15. package/components/u-avatar/props.js +78 -0
  16. package/components/u-avatar/u-avatar.vue +172 -0
  17. package/components/u-avatar-group/props.js +52 -0
  18. package/components/u-avatar-group/u-avatar-group.vue +103 -0
  19. package/components/u-back-top/props.js +54 -0
  20. package/components/u-back-top/u-back-top.vue +129 -0
  21. package/components/u-badge/props.js +72 -0
  22. package/components/u-badge/u-badge.vue +171 -0
  23. package/components/u-button/nvue.scss +46 -0
  24. package/components/u-button/props.js +161 -0
  25. package/components/u-button/u-button.vue +490 -0
  26. package/components/u-button/vue.scss +80 -0
  27. package/components/u-calendar/header.vue +99 -0
  28. package/components/u-calendar/month.vue +580 -0
  29. package/components/u-calendar/props.js +144 -0
  30. package/components/u-calendar/u-calendar.vue +384 -0
  31. package/components/u-calendar/util.js +85 -0
  32. package/components/u-car-keyboard/props.js +14 -0
  33. package/components/u-car-keyboard/u-car-keyboard.vue +311 -0
  34. package/components/u-cell/props.js +110 -0
  35. package/components/u-cell/u-cell.vue +229 -0
  36. package/components/u-cell-group/props.js +14 -0
  37. package/components/u-cell-group/u-cell-group.vue +61 -0
  38. package/components/u-checkbox/props.js +69 -0
  39. package/components/u-checkbox/u-checkbox.vue +344 -0
  40. package/components/u-checkbox-group/props.js +82 -0
  41. package/components/u-checkbox-group/u-checkbox-group.vue +103 -0
  42. package/components/u-circle-progress/props.js +8 -0
  43. package/components/u-circle-progress/u-circle-progress.vue +198 -0
  44. package/components/u-code/props.js +34 -0
  45. package/components/u-code/u-code.vue +129 -0
  46. package/components/u-code-input/props.js +79 -0
  47. package/components/u-code-input/u-code-input.vue +252 -0
  48. package/components/u-col/props.js +29 -0
  49. package/components/u-col/u-col.vue +162 -0
  50. package/components/u-collapse/props.js +19 -0
  51. package/components/u-collapse/u-collapse.vue +90 -0
  52. package/components/u-collapse-item/props.js +59 -0
  53. package/components/u-collapse-item/u-collapse-item.vue +225 -0
  54. package/components/u-column-notice/props.js +55 -0
  55. package/components/u-column-notice/u-column-notice.vue +160 -0
  56. package/components/u-count-down/props.js +24 -0
  57. package/components/u-count-down/u-count-down.vue +163 -0
  58. package/components/u-count-down/utils.js +62 -0
  59. package/components/u-count-to/props.js +59 -0
  60. package/components/u-count-to/u-count-to.vue +184 -0
  61. package/components/u-datetime-picker/props.js +116 -0
  62. package/components/u-datetime-picker/u-datetime-picker.vue +362 -0
  63. package/components/u-divider/props.js +44 -0
  64. package/components/u-divider/u-divider.vue +116 -0
  65. package/components/u-dropdown/props.js +65 -0
  66. package/components/u-dropdown/u-dropdown.vue +127 -0
  67. package/components/u-dropdown-item/props.js +36 -0
  68. package/components/u-dropdown-item/u-dropdown-item.vue +146 -0
  69. package/components/u-empty/props.js +59 -0
  70. package/components/u-empty/u-empty.vue +128 -0
  71. package/components/u-form/props.js +45 -0
  72. package/components/u-form/u-form.vue +214 -0
  73. package/components/u-form-item/props.js +43 -0
  74. package/components/u-form-item/u-form-item.vue +235 -0
  75. package/components/u-gap/props.js +24 -0
  76. package/components/u-gap/u-gap.vue +38 -0
  77. package/components/u-grid/props.js +19 -0
  78. package/components/u-grid/u-grid.vue +97 -0
  79. package/components/u-grid-item/props.js +14 -0
  80. package/components/u-grid-item/u-grid-item.vue +209 -0
  81. package/components/u-icon/icons.js +214 -0
  82. package/components/u-icon/props.js +89 -0
  83. package/components/u-icon/u-icon.vue +234 -0
  84. package/components/u-image/props.js +84 -0
  85. package/components/u-image/u-image.vue +232 -0
  86. package/components/u-index-anchor/props.js +29 -0
  87. package/components/u-index-anchor/u-index-anchor.vue +91 -0
  88. package/components/u-index-item/props.js +5 -0
  89. package/components/u-index-item/u-index-item.vue +87 -0
  90. package/components/u-index-list/props.js +29 -0
  91. package/components/u-index-list/u-index-list.vue +440 -0
  92. package/components/u-input/props.js +187 -0
  93. package/components/u-input/u-input.vue +354 -0
  94. package/components/u-keyboard/props.js +84 -0
  95. package/components/u-keyboard/u-keyboard.vue +164 -0
  96. package/components/u-line/props.js +33 -0
  97. package/components/u-line/u-line.vue +62 -0
  98. package/components/u-line-progress/props.js +28 -0
  99. package/components/u-line-progress/u-line-progress.vue +144 -0
  100. package/components/u-link/props.js +39 -0
  101. package/components/u-link/u-link.vue +83 -0
  102. package/components/u-list/props.js +76 -0
  103. package/components/u-list/u-list.vue +157 -0
  104. package/components/u-list-item/props.js +9 -0
  105. package/components/u-list-item/u-list-item.vue +116 -0
  106. package/components/u-loading-icon/props.js +59 -0
  107. package/components/u-loading-icon/u-loading-icon.vue +343 -0
  108. package/components/u-loading-page/props.js +49 -0
  109. package/components/u-loading-page/u-loading-page.vue +115 -0
  110. package/components/u-loadmore/props.js +94 -0
  111. package/components/u-loadmore/u-loadmore.vue +150 -0
  112. package/components/u-modal/props.js +84 -0
  113. package/components/u-modal/u-modal.vue +227 -0
  114. package/components/u-navbar/props.js +84 -0
  115. package/components/u-navbar/u-navbar.vue +186 -0
  116. package/components/u-no-network/props.js +19 -0
  117. package/components/u-no-network/u-no-network.vue +220 -0
  118. package/components/u-notice-bar/props.js +70 -0
  119. package/components/u-notice-bar/u-notice-bar.vue +101 -0
  120. package/components/u-notify/props.js +49 -0
  121. package/components/u-notify/u-notify.vue +211 -0
  122. package/components/u-number-box/props.js +109 -0
  123. package/components/u-number-box/u-number-box.vue +416 -0
  124. package/components/u-number-keyboard/props.js +19 -0
  125. package/components/u-number-keyboard/u-number-keyboard.vue +196 -0
  126. package/components/u-overlay/props.js +24 -0
  127. package/components/u-overlay/u-overlay.vue +68 -0
  128. package/components/u-parse/node/node.vue +499 -0
  129. package/components/u-parse/parser.js +1075 -0
  130. package/components/u-parse/props.js +45 -0
  131. package/components/u-parse/u-parse.vue +366 -0
  132. package/components/u-picker/props.js +79 -0
  133. package/components/u-picker/u-picker.vue +283 -0
  134. package/components/u-picker-column/props.js +5 -0
  135. package/components/u-picker-column/u-picker-column.vue +27 -0
  136. package/components/u-popup/props.js +79 -0
  137. package/components/u-popup/u-popup.vue +304 -0
  138. package/components/u-radio/props.js +64 -0
  139. package/components/u-radio/u-radio.vue +337 -0
  140. package/components/u-radio-group/props.js +85 -0
  141. package/components/u-radio-group/u-radio-group.vue +108 -0
  142. package/components/u-rate/props.js +69 -0
  143. package/components/u-rate/u-rate.vue +304 -0
  144. package/components/u-read-more/props.js +61 -0
  145. package/components/u-read-more/u-read-more.vue +157 -0
  146. package/components/u-row/props.js +19 -0
  147. package/components/u-row/u-row.vue +93 -0
  148. package/components/u-row-notice/props.js +39 -0
  149. package/components/u-row-notice/u-row-notice.vue +330 -0
  150. package/components/u-safe-bottom/props.js +5 -0
  151. package/components/u-safe-bottom/u-safe-bottom.vue +56 -0
  152. package/components/u-scroll-list/nvue.js +28 -0
  153. package/components/u-scroll-list/other.js +0 -0
  154. package/components/u-scroll-list/props.js +34 -0
  155. package/components/u-scroll-list/scrollWxs.wxs +50 -0
  156. package/components/u-scroll-list/u-scroll-list.vue +224 -0
  157. package/components/u-search/props.js +118 -0
  158. package/components/u-search/u-search.vue +303 -0
  159. package/components/u-skeleton/props.js +59 -0
  160. package/components/u-skeleton/u-skeleton.vue +244 -0
  161. package/components/u-slider/mpother.js +113 -0
  162. package/components/u-slider/mpwxs.js +42 -0
  163. package/components/u-slider/mpwxs.wxs +121 -0
  164. package/components/u-slider/nvue - /345/211/257/346/234/254.js" +180 -0
  165. package/components/u-slider/nvue.js +193 -0
  166. package/components/u-slider/props.js +54 -0
  167. package/components/u-slider/u-slider.vue +55 -0
  168. package/components/u-status-bar/props.js +8 -0
  169. package/components/u-status-bar/u-status-bar.vue +46 -0
  170. package/components/u-steps/props.js +39 -0
  171. package/components/u-steps/u-steps.vue +80 -0
  172. package/components/u-steps-item/props.js +24 -0
  173. package/components/u-steps-item/u-steps-item.vue +316 -0
  174. package/components/u-sticky/props.js +40 -0
  175. package/components/u-sticky/u-sticky.vue +212 -0
  176. package/components/u-subsection/props.js +49 -0
  177. package/components/u-subsection/u-subsection.vue +299 -0
  178. package/components/u-swipe-action/props.js +9 -0
  179. package/components/u-swipe-action/u-swipe-action.vue +67 -0
  180. package/components/u-swipe-action-item/index - backup.wxs +256 -0
  181. package/components/u-swipe-action-item/index.wxs +225 -0
  182. package/components/u-swipe-action-item/nvue - backup.js +270 -0
  183. package/components/u-swipe-action-item/nvue.js +174 -0
  184. package/components/u-swipe-action-item/props.js +41 -0
  185. package/components/u-swipe-action-item/u-swipe-action-item.vue +190 -0
  186. package/components/u-swipe-action-item/wxs.js +15 -0
  187. package/components/u-swiper/props.js +125 -0
  188. package/components/u-swiper/u-swiper.vue +255 -0
  189. package/components/u-swiper-indicator/props.js +29 -0
  190. package/components/u-swiper-indicator/u-swiper-indicator.vue +110 -0
  191. package/components/u-switch/props.js +54 -0
  192. package/components/u-switch/u-switch.vue +177 -0
  193. package/components/u-tabbar/props.js +44 -0
  194. package/components/u-tabbar/u-tabbar.vue +141 -0
  195. package/components/u-tabbar-item/props.js +35 -0
  196. package/components/u-tabbar-item/u-tabbar-item.vue +142 -0
  197. package/components/u-table/props.js +5 -0
  198. package/components/u-table/u-table.vue +29 -0
  199. package/components/u-tabs/props.js +64 -0
  200. package/components/u-tabs/u-tabs.vue +354 -0
  201. package/components/u-tabs-item/props.js +5 -0
  202. package/components/u-tabs-item/u-tabs-item.vue +29 -0
  203. package/components/u-tag/props.js +84 -0
  204. package/components/u-tag/u-tag.vue +358 -0
  205. package/components/u-td/props.js +5 -0
  206. package/components/u-td/u-td.vue +31 -0
  207. package/components/u-text/props.js +110 -0
  208. package/components/u-text/u-text.vue +223 -0
  209. package/components/u-text/value.js +85 -0
  210. package/components/u-textarea/props.js +119 -0
  211. package/components/u-textarea/u-textarea.vue +239 -0
  212. package/components/u-toast/u-toast.vue +291 -0
  213. package/components/u-toolbar/props.js +34 -0
  214. package/components/u-toolbar/u-toolbar.vue +102 -0
  215. package/components/u-tooltip/props.js +59 -0
  216. package/components/u-tooltip/u-tooltip.vue +366 -0
  217. package/components/u-tr/props.js +5 -0
  218. package/components/u-tr/u-tr.vue +31 -0
  219. package/components/u-transition/nvue.ani-map.js +68 -0
  220. package/components/u-transition/props.js +24 -0
  221. package/components/u-transition/transition.js +157 -0
  222. package/components/u-transition/u-transition.vue +92 -0
  223. package/components/u-transition/vue.ani-style.scss +113 -0
  224. package/components/u-upload/mixin.js +21 -0
  225. package/components/u-upload/props.js +124 -0
  226. package/components/u-upload/u-upload.vue +558 -0
  227. package/components/u-upload/utils.js +151 -0
  228. package/components/uview-plus/uview-plus.vue +15 -0
  229. package/index.js +77 -0
  230. package/index.scss +23 -0
  231. package/libs/config/color.js +17 -0
  232. package/libs/config/config.js +34 -0
  233. package/libs/config/props/actionSheet.js +25 -0
  234. package/libs/config/props/album.js +25 -0
  235. package/libs/config/props/alert.js +22 -0
  236. package/libs/config/props/avatar.js +28 -0
  237. package/libs/config/props/avatarGroup.js +23 -0
  238. package/libs/config/props/backtop.js +27 -0
  239. package/libs/config/props/badge.js +27 -0
  240. package/libs/config/props/button.js +42 -0
  241. package/libs/config/props/calendar.js +42 -0
  242. package/libs/config/props/carKeyboard.js +15 -0
  243. package/libs/config/props/cell.js +35 -0
  244. package/libs/config/props/cellGroup.js +17 -0
  245. package/libs/config/props/checkbox.js +27 -0
  246. package/libs/config/props/checkboxGroup.js +29 -0
  247. package/libs/config/props/circleProgress.js +15 -0
  248. package/libs/config/props/code.js +21 -0
  249. package/libs/config/props/codeInput.js +29 -0
  250. package/libs/config/props/col.js +19 -0
  251. package/libs/config/props/collapse.js +17 -0
  252. package/libs/config/props/collapseItem.js +25 -0
  253. package/libs/config/props/columnNotice.js +24 -0
  254. package/libs/config/props/countDown.js +18 -0
  255. package/libs/config/props/countTo.js +25 -0
  256. package/libs/config/props/datetimePicker.js +36 -0
  257. package/libs/config/props/divider.js +23 -0
  258. package/libs/config/props/empty.js +26 -0
  259. package/libs/config/props/form.js +22 -0
  260. package/libs/config/props/formItem.js +22 -0
  261. package/libs/config/props/gap.js +19 -0
  262. package/libs/config/props/grid.js +17 -0
  263. package/libs/config/props/gridItem.js +16 -0
  264. package/libs/config/props/icon.js +36 -0
  265. package/libs/config/props/image.js +30 -0
  266. package/libs/config/props/indexAnchor.js +19 -0
  267. package/libs/config/props/indexList.js +19 -0
  268. package/libs/config/props/input.js +48 -0
  269. package/libs/config/props/keyboard.js +30 -0
  270. package/libs/config/props/line.js +20 -0
  271. package/libs/config/props/lineProgress.js +19 -0
  272. package/libs/config/props/link.js +26 -0
  273. package/libs/config/props/list.js +28 -0
  274. package/libs/config/props/listItem.js +15 -0
  275. package/libs/config/props/loadingIcon.js +30 -0
  276. package/libs/config/props/loadingPage.js +23 -0
  277. package/libs/config/props/loadmore.js +32 -0
  278. package/libs/config/props/modal.js +30 -0
  279. package/libs/config/props/navbar.js +32 -0
  280. package/libs/config/props/noNetwork.js +18 -0
  281. package/libs/config/props/noticeBar.js +27 -0
  282. package/libs/config/props/notify.js +22 -0
  283. package/libs/config/props/numberBox.js +35 -0
  284. package/libs/config/props/numberKeyboard.js +17 -0
  285. package/libs/config/props/overlay.js +18 -0
  286. package/libs/config/props/parse.js +22 -0
  287. package/libs/config/props/picker.js +29 -0
  288. package/libs/config/props/popup.js +29 -0
  289. package/libs/config/props/radio.js +27 -0
  290. package/libs/config/props/radioGroup.js +30 -0
  291. package/libs/config/props/rate.js +26 -0
  292. package/libs/config/props/readMore.js +22 -0
  293. package/libs/config/props/row.js +17 -0
  294. package/libs/config/props/rowNotice.js +21 -0
  295. package/libs/config/props/scrollList.js +20 -0
  296. package/libs/config/props/search.js +37 -0
  297. package/libs/config/props/section.js +24 -0
  298. package/libs/config/props/skeleton.js +25 -0
  299. package/libs/config/props/slider.js +25 -0
  300. package/libs/config/props/statusBar.js +15 -0
  301. package/libs/config/props/steps.js +21 -0
  302. package/libs/config/props/stepsItem.js +18 -0
  303. package/libs/config/props/sticky.js +20 -0
  304. package/libs/config/props/subsection.js +23 -0
  305. package/libs/config/props/swipeAction.js +15 -0
  306. package/libs/config/props/swipeActionItem.js +21 -0
  307. package/libs/config/props/swiper.js +39 -0
  308. package/libs/config/props/swipterIndicator.js +19 -0
  309. package/libs/config/props/switch.js +24 -0
  310. package/libs/config/props/tabbar.js +22 -0
  311. package/libs/config/props/tabbarItem.js +20 -0
  312. package/libs/config/props/tabs.js +32 -0
  313. package/libs/config/props/tag.js +29 -0
  314. package/libs/config/props/text.js +38 -0
  315. package/libs/config/props/textarea.js +36 -0
  316. package/libs/config/props/toast.js +30 -0
  317. package/libs/config/props/toolbar.js +21 -0
  318. package/libs/config/props/tooltip.js +25 -0
  319. package/libs/config/props/transition.js +18 -0
  320. package/libs/config/props/upload.js +36 -0
  321. package/libs/config/props.js +190 -0
  322. package/libs/config/zIndex.js +20 -0
  323. package/libs/css/color.scss +155 -0
  324. package/libs/css/common.scss +97 -0
  325. package/libs/css/components.scss +15 -0
  326. package/libs/css/flex.scss +257 -0
  327. package/libs/css/h5.scss +0 -0
  328. package/libs/css/mixin.scss +8 -0
  329. package/libs/css/mp.scss +0 -0
  330. package/libs/css/nvue.scss +0 -0
  331. package/libs/css/vue.scss +27 -0
  332. package/libs/function/colorGradient.js +134 -0
  333. package/libs/function/debounce.js +29 -0
  334. package/libs/function/digit.js +167 -0
  335. package/libs/function/index.js +708 -0
  336. package/libs/function/platform.js +75 -0
  337. package/libs/function/test.js +288 -0
  338. package/libs/function/throttle.js +30 -0
  339. package/libs/luch-request/adapters/index.js +97 -0
  340. package/libs/luch-request/core/InterceptorManager.js +50 -0
  341. package/libs/luch-request/core/Request.js +198 -0
  342. package/libs/luch-request/core/buildFullPath.js +20 -0
  343. package/libs/luch-request/core/defaults.js +29 -0
  344. package/libs/luch-request/core/dispatchRequest.js +3 -0
  345. package/libs/luch-request/core/mergeConfig.js +103 -0
  346. package/libs/luch-request/core/settle.js +16 -0
  347. package/libs/luch-request/helpers/buildURL.js +69 -0
  348. package/libs/luch-request/helpers/combineURLs.js +14 -0
  349. package/libs/luch-request/helpers/isAbsoluteURL.js +14 -0
  350. package/libs/luch-request/index.d.ts +116 -0
  351. package/libs/luch-request/index.js +3 -0
  352. package/libs/luch-request/utils/clone.js +264 -0
  353. package/libs/luch-request/utils.js +131 -0
  354. package/libs/mixin/button.js +13 -0
  355. package/libs/mixin/mixin.js +160 -0
  356. package/libs/mixin/mpMixin.js +8 -0
  357. package/libs/mixin/mpShare.js +13 -0
  358. package/libs/mixin/openType.js +25 -0
  359. package/libs/mixin/style.js +228 -0
  360. package/libs/mixin/touch.js +59 -0
  361. package/libs/util/async-validator.js +1343 -0
  362. package/libs/util/calendar.js +546 -0
  363. package/libs/util/emitter.js +51 -0
  364. package/libs/util/route.js +124 -0
  365. package/package.json +91 -0
  366. package/theme.scss +44 -0
@@ -0,0 +1,366 @@
1
+ <template>
2
+ <view
3
+ class="u-tooltip"
4
+ :style="[$u.addStyle(customStyle)]"
5
+ >
6
+ <u-overlay
7
+ :show="showTooltip && tooltipTop !== -10000 && overlay"
8
+ customStyle="backgroundColor: rgba(0, 0, 0, 0)"
9
+ @click="overlayClickHandler"
10
+ ></u-overlay>
11
+ <view class="u-tooltip__wrapper">
12
+ <text
13
+ class="u-tooltip__wrapper__text"
14
+ :id="textId"
15
+ :ref="textId"
16
+ :userSelect="false"
17
+ :selectable="false"
18
+ @longpress.stop="longpressHandler"
19
+ :style="{
20
+ color: color,
21
+ backgroundColor: bgColor && showTooltip && tooltipTop !== -10000 ? bgColor : 'transparent'
22
+ }"
23
+ >{{ text }}</text>
24
+ <u-transition
25
+ mode="fade"
26
+ :show="showTooltip"
27
+ duration="300"
28
+ :customStyle="{
29
+ position: 'absolute',
30
+ top: $u.addUnit(tooltipTop),
31
+ zIndex: zIndex,
32
+ ...tooltipStyle
33
+ }"
34
+ >
35
+ <view
36
+ class="u-tooltip__wrapper__popup"
37
+ :id="tooltipId"
38
+ :ref="tooltipId"
39
+ >
40
+ <view
41
+ class="u-tooltip__wrapper__popup__indicator"
42
+ hover-class="u-tooltip__wrapper__popup__indicator--hover"
43
+ v-if="showCopy || buttons.length"
44
+ :style="[indicatorStyle, {
45
+ width: $u.addUnit(indicatorWidth),
46
+ height: $u.addUnit(indicatorWidth),
47
+ }]"
48
+ >
49
+ <!-- 由于nvue不支持三角形绘制,这里就做一个四方形,再旋转45deg,得到露出的一个三角 -->
50
+ </view>
51
+ <view class="u-tooltip__wrapper__popup__list">
52
+ <view
53
+ v-if="showCopy"
54
+ class="u-tooltip__wrapper__popup__list__btn"
55
+ hover-class="u-tooltip__wrapper__popup__list__btn--hover"
56
+ @tap="setClipboardData"
57
+ >
58
+ <text
59
+ class="u-tooltip__wrapper__popup__list__btn__text"
60
+ >复制</text>
61
+ </view>
62
+ <u-line
63
+ direction="column"
64
+ color="#8d8e90"
65
+ v-if="showCopy && buttons.length > 0"
66
+ length="18"
67
+ ></u-line>
68
+ <block v-for="(item , index) in buttons" :key="index">
69
+ <view
70
+ class="u-tooltip__wrapper__popup__list__btn"
71
+ hover-class="u-tooltip__wrapper__popup__list__btn--hover"
72
+ >
73
+ <text
74
+ class="u-tooltip__wrapper__popup__list__btn__text"
75
+ @tap="btnClickHandler(index)"
76
+ >{{ item }}</text>
77
+ </view>
78
+ <u-line
79
+ direction="column"
80
+ color="#8d8e90"
81
+ v-if="index < buttons.length - 1"
82
+ length="18"
83
+ ></u-line>
84
+ </block>
85
+ </view>
86
+ </view>
87
+ </u-transition>
88
+ </view>
89
+ </view>
90
+ </template>
91
+
92
+ <script>
93
+ import props from './props.js';
94
+ // #ifdef APP-NVUE
95
+ const dom = uni.requireNativePlugin('dom')
96
+ // #endif
97
+ // #ifdef H5
98
+ // import ClipboardJS from "./clipboard.min.js"
99
+ import ClipboardJS from "clipboard"
100
+ // #endif
101
+ /**
102
+ * Tooltip
103
+ * @description
104
+ * @tutorial https://www.uviewui.com/components/tooltip.html
105
+ * @property {String | Number} text 需要显示的提示文字
106
+ * @property {String | Number} copyText 点击复制按钮时,复制的文本,为空则使用text值
107
+ * @property {String | Number} size 文本大小(默认 14 )
108
+ * @property {String} color 字体颜色(默认 '#606266' )
109
+ * @property {String} bgColor 弹出提示框时,文本的背景色(默认 'transparent' )
110
+ * @property {String} direction 弹出提示的方向,top-上方,bottom-下方(默认 'top' )
111
+ * @property {String | Number} zIndex 弹出提示的z-index,nvue无效(默认 10071 )
112
+ * @property {Boolean} showCopy 是否显示复制按钮(默认 true )
113
+ * @property {Array} buttons 扩展的按钮组
114
+ * @property {Boolean} overlay 是否显示透明遮罩以防止触摸穿透(默认 true )
115
+ * @property {Object} customStyle 定义需要用到的外部样式
116
+ *
117
+ * @event {Function}
118
+ * @example
119
+ */
120
+ export default {
121
+ name: 'u-tooltip',
122
+ mixins: [uni.$u.mpMixin, uni.$u.mixin, props],
123
+ data() {
124
+ return {
125
+ // 是否展示气泡
126
+ showTooltip: true,
127
+ // 生成唯一id,防止一个页面多个组件,造成干扰
128
+ textId: uni.$u.guid(),
129
+ tooltipId: uni.$u.guid(),
130
+ // 初始时甚至为很大的值,让其移到屏幕外面,为了计算元素的尺寸
131
+ tooltipTop: -10000,
132
+ // 气泡的位置信息
133
+ tooltipInfo: {
134
+ width: 0,
135
+ left: 0
136
+ },
137
+ // 文本的位置信息
138
+ textInfo: {
139
+ width: 0,
140
+ left: 0
141
+ },
142
+ // 三角形指示器的样式
143
+ indicatorStyle: {},
144
+ // 气泡在可能超出屏幕边沿范围时,重新定位后,距离屏幕边沿的距离
145
+ screenGap: 12,
146
+ // 三角形指示器的宽高,由于对元素进行了角度旋转,精确计算指示器位置时,需要用到其尺寸信息
147
+ indicatorWidth: 14,
148
+ }
149
+ },
150
+ watch: {
151
+ propsChange() {
152
+ this.getElRect()
153
+ }
154
+ },
155
+ computed: {
156
+ // 特别处理H5的复制,因为H5浏览器是自带系统复制功能的,在H5环境
157
+ // 当一些依赖参数变化时,需要重新计算气泡和指示器的位置信息
158
+ propsChange() {
159
+ return [this.text, this.buttons]
160
+ },
161
+ // 计算气泡和指示器的位置信息
162
+ tooltipStyle() {
163
+ const style = {
164
+ transform: `translateY(${this.direction === 'top' ? '-100%' : '100%'})`,
165
+ },
166
+ sys = uni.$u.sys(),
167
+ getPx = uni.$u.getPx,
168
+ addUnit = uni.$u.addUnit
169
+ if (this.tooltipInfo.width / 2 > this.textInfo.left + this.textInfo.width / 2 - this.screenGap) {
170
+ this.indicatorStyle = {}
171
+ style.left = `-${addUnit(this.textInfo.left - this.screenGap)}`
172
+ this.indicatorStyle.left = addUnit(this.textInfo.width / 2 - getPx(style.left) - this.indicatorWidth /
173
+ 2)
174
+ } else if (this.tooltipInfo.width / 2 > sys.windowWidth - this.textInfo.right + this.textInfo.width / 2 -
175
+ this.screenGap) {
176
+ this.indicatorStyle = {}
177
+ style.right = `-${addUnit(sys.windowWidth - this.textInfo.right - this.screenGap)}`
178
+ this.indicatorStyle.right = addUnit(this.textInfo.width / 2 - getPx(style.right) - this
179
+ .indicatorWidth / 2)
180
+ } else {
181
+ const left = Math.abs(this.textInfo.width / 2 - this.tooltipInfo.width / 2)
182
+ style.left = this.textInfo.width > this.tooltipInfo.width ? addUnit(left) : -addUnit(left)
183
+ this.indicatorStyle = {}
184
+ }
185
+ if (this.direction === 'top') {
186
+ style.marginTop = '-10px'
187
+ this.indicatorStyle.bottom = '-4px'
188
+ } else {
189
+ style.marginBottom = '-10px'
190
+ this.indicatorStyle.top = '-4px'
191
+ }
192
+ return style
193
+ }
194
+ },
195
+ mounted() {
196
+ this.init()
197
+ },
198
+ methods: {
199
+ init() {
200
+ this.getElRect()
201
+ },
202
+ // 长按触发事件
203
+ async longpressHandler() {
204
+ this.tooltipTop = 0
205
+ this.showTooltip = true
206
+ },
207
+ // 点击透明遮罩
208
+ overlayClickHandler() {
209
+ this.showTooltip = false
210
+ },
211
+ // 点击弹出按钮
212
+ btnClickHandler(index) {
213
+ this.showTooltip = false
214
+ // 如果需要展示复制按钮,此处index需要加1,因为复制按钮在第一个位置
215
+ this.$emit('click', this.showCopy ? index + 1 : index)
216
+ },
217
+ // 查询内容高度
218
+ queryRect(ref) {
219
+ // #ifndef APP-NVUE
220
+ // $uGetRect为uView自带的节点查询简化方法,详见文档介绍:https://www.uviewui.com/js/getRect.html
221
+ // 组件内部一般用this.$uGetRect,对外的为uni.$u.getRect,二者功能一致,名称不同
222
+ return new Promise(resolve => {
223
+ this.$uGetRect(`#${ref}`).then(size => {
224
+ resolve(size)
225
+ })
226
+ })
227
+ // #endif
228
+
229
+ // #ifdef APP-NVUE
230
+ // nvue下,使用dom模块查询元素高度
231
+ // 返回一个promise,让调用此方法的主体能使用then回调
232
+ return new Promise(resolve => {
233
+ dom.getComponentRect(this.$refs[ref], res => {
234
+ resolve(res.size)
235
+ })
236
+ })
237
+ // #endif
238
+ },
239
+ // 元素尺寸
240
+ getElRect() {
241
+ // 调用之前,先将指示器调整到屏幕外,方便获取尺寸
242
+ this.showTooltip = true
243
+ this.tooltipTop = -10000
244
+ uni.$u.sleep(500).then(() => {
245
+ this.queryRect(this.tooltipId).then(size => {
246
+ this.tooltipInfo = size
247
+ // 获取气泡尺寸之后,将其隐藏,为了让下次切换气泡显示与隐藏时,有淡入淡出的效果
248
+ this.showTooltip = false
249
+ })
250
+ this.queryRect(this.textId).then(size => {
251
+ this.textInfo = size
252
+ })
253
+ })
254
+ },
255
+ // 复制文本到粘贴板
256
+ setClipboardData() {
257
+ // 关闭组件
258
+ this.showTooltip = false
259
+ this.$emit('click', 0)
260
+ // #ifndef H5
261
+ uni.setClipboardData({
262
+ // 优先使用copyText字段,如果没有,则默认使用text字段当做复制的内容
263
+ data: this.copyText || this.text,
264
+ success: () => {
265
+ this.showToast && uni.$u.toast('复制成功')
266
+ },
267
+ fail: () => {
268
+ this.showToast && uni.$u.toast('复制失败')
269
+ },
270
+ complete: () => {
271
+ this.showTooltip = false
272
+ }
273
+ })
274
+ // #endif
275
+
276
+ // #ifdef H5
277
+ let event = window.event || e || {}
278
+ let clipboard = new ClipboardJS('', {
279
+ text: () => this.copyText || this.text
280
+ })
281
+ clipboard.on('success', (e) => {
282
+ this.showToast && uni.$u.toast('复制成功')
283
+ clipboard.off('success')
284
+ clipboard.off('error')
285
+ // 在单页应用中,需要销毁DOM的监听
286
+ clipboard.destroy()
287
+ })
288
+ clipboard.on('error', (e) => {
289
+ this.showToast && uni.$u.toast('复制失败')
290
+ clipboard.off('success')
291
+ clipboard.off('error')
292
+ // 在单页应用中,需要销毁DOM的监听
293
+ clipboard.destroy()
294
+ })
295
+ clipboard.onClick(event)
296
+ // #endif
297
+ }
298
+ }
299
+ }
300
+ </script>
301
+
302
+ <style lang="scss" scoped>
303
+ @import "../../libs/css/components.scss";
304
+
305
+ .u-tooltip {
306
+ position: relative;
307
+ @include flex;
308
+
309
+ &__wrapper {
310
+ @include flex;
311
+ justify-content: center;
312
+ /* #ifndef APP-NVUE */
313
+ white-space: nowrap;
314
+ /* #endif */
315
+
316
+ &__text {
317
+ font-size: 14px;
318
+ }
319
+
320
+ &__popup {
321
+ @include flex;
322
+ justify-content: center;
323
+
324
+ &__list {
325
+ background-color: #060607;
326
+ position: relative;
327
+ flex: 1;
328
+ border-radius: 5px;
329
+ padding: 0px 0;
330
+ @include flex(row);
331
+ align-items: center;
332
+ overflow: hidden;
333
+
334
+ &__btn {
335
+ padding: 11px 13px;
336
+
337
+ &--hover {
338
+ background-color: #58595B;
339
+ }
340
+
341
+ &__text {
342
+ line-height: 12px;
343
+ font-size: 13px;
344
+ color: #FFFFFF;
345
+ }
346
+ }
347
+ }
348
+
349
+ &__indicator {
350
+ position: absolute;
351
+ background-color: #060607;
352
+ width: 14px;
353
+ height: 14px;
354
+ bottom: -4px;
355
+ transform: rotate(45deg);
356
+ border-radius: 2px;
357
+ z-index: -1;
358
+
359
+ &--hover {
360
+ background-color: #58595B;
361
+ }
362
+ }
363
+ }
364
+ }
365
+ }
366
+ </style>
@@ -0,0 +1,5 @@
1
+ export default {
2
+ props: {
3
+
4
+ }
5
+ }
@@ -0,0 +1,31 @@
1
+ <template>
2
+ <view class="u-tr">
3
+
4
+ </view>
5
+ </template>
6
+
7
+ <script>
8
+ import props from './props.js';
9
+ /**
10
+ * Tr
11
+ * @description
12
+ * @tutorial url
13
+ * @property {String}
14
+ * @event {Function}
15
+ * @example
16
+ */
17
+ export default {
18
+ name: 'u-tr',
19
+ mixins: [uni.$u.mpMixin, uni.$u.mixin,props],
20
+ data() {
21
+ return {
22
+
23
+ }
24
+ }
25
+ }
26
+ </script>
27
+
28
+ <style lang="scss" scoped>
29
+ @import "../../libs/css/components.scss";
30
+
31
+ </style>
@@ -0,0 +1,68 @@
1
+ export default {
2
+ fade: {
3
+ enter: { opacity: 0 },
4
+ 'enter-to': { opacity: 1 },
5
+ leave: { opacity: 1 },
6
+ 'leave-to': { opacity: 0 }
7
+ },
8
+ 'fade-up': {
9
+ enter: { opacity: 0, transform: 'translateY(100%)' },
10
+ 'enter-to': { opacity: 1, transform: 'translateY(0)' },
11
+ leave: { opacity: 1, transform: 'translateY(0)' },
12
+ 'leave-to': { opacity: 0, transform: 'translateY(100%)' }
13
+ },
14
+ 'fade-down': {
15
+ enter: { opacity: 0, transform: 'translateY(-100%)' },
16
+ 'enter-to': { opacity: 1, transform: 'translateY(0)' },
17
+ leave: { opacity: 1, transform: 'translateY(0)' },
18
+ 'leave-to': { opacity: 0, transform: 'translateY(-100%)' }
19
+ },
20
+ 'fade-left': {
21
+ enter: { opacity: 0, transform: 'translateX(-100%)' },
22
+ 'enter-to': { opacity: 1, transform: 'translateY(0)' },
23
+ leave: { opacity: 1, transform: 'translateY(0)' },
24
+ 'leave-to': { opacity: 0, transform: 'translateX(-100%)' }
25
+ },
26
+ 'fade-right': {
27
+ enter: { opacity: 0, transform: 'translateX(100%)' },
28
+ 'enter-to': { opacity: 1, transform: 'translateY(0)' },
29
+ leave: { opacity: 1, transform: 'translateY(0)' },
30
+ 'leave-to': { opacity: 0, transform: 'translateX(100%)' }
31
+ },
32
+ 'slide-up': {
33
+ enter: { transform: 'translateY(100%)' },
34
+ 'enter-to': { transform: 'translateY(0)' },
35
+ leave: { transform: 'translateY(0)' },
36
+ 'leave-to': { transform: 'translateY(100%)' }
37
+ },
38
+ 'slide-down': {
39
+ enter: { transform: 'translateY(-100%)' },
40
+ 'enter-to': { transform: 'translateY(0)' },
41
+ leave: { transform: 'translateY(0)' },
42
+ 'leave-to': { transform: 'translateY(-100%)' }
43
+ },
44
+ 'slide-left': {
45
+ enter: { transform: 'translateX(-100%)' },
46
+ 'enter-to': { transform: 'translateY(0)' },
47
+ leave: { transform: 'translateY(0)' },
48
+ 'leave-to': { transform: 'translateX(-100%)' }
49
+ },
50
+ 'slide-right': {
51
+ enter: { transform: 'translateX(100%)' },
52
+ 'enter-to': { transform: 'translateY(0)' },
53
+ leave: { transform: 'translateY(0)' },
54
+ 'leave-to': { transform: 'translateX(100%)' }
55
+ },
56
+ zoom: {
57
+ enter: { transform: 'scale(0.95)' },
58
+ 'enter-to': { transform: 'scale(1)' },
59
+ leave: { transform: 'scale(1)' },
60
+ 'leave-to': { transform: 'scale(0.95)' }
61
+ },
62
+ 'fade-zoom': {
63
+ enter: { opacity: 0, transform: 'scale(0.95)' },
64
+ 'enter-to': { opacity: 1, transform: 'scale(1)' },
65
+ leave: { opacity: 1, transform: 'scale(1)' },
66
+ 'leave-to': { opacity: 0, transform: 'scale(0.95)' }
67
+ }
68
+ }
@@ -0,0 +1,24 @@
1
+ export default {
2
+ props: {
3
+ // 是否展示组件
4
+ show: {
5
+ type: Boolean,
6
+ default: uni.$u.props.transition.show
7
+ },
8
+ // 使用的动画模式
9
+ mode: {
10
+ type: String,
11
+ default: uni.$u.props.transition.mode
12
+ },
13
+ // 动画的执行时间,单位ms
14
+ duration: {
15
+ type: [String, Number],
16
+ default: uni.$u.props.transition.duration
17
+ },
18
+ // 使用的动画过渡函数
19
+ timingFunction: {
20
+ type: String,
21
+ default: uni.$u.props.transition.timingFunction
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,157 @@
1
+ // 定义一个一定时间后自动成功的promise,让调用nextTick方法处,进入下一个then方法
2
+ const nextTick = () => new Promise(resolve => setTimeout(resolve, 1000 / 50))
3
+ // nvue动画模块实现细节抽离在外部文件
4
+ import animationMap from './nvue.ani-map.js'
5
+
6
+ // #ifndef APP-NVUE
7
+ // 定义类名,通过给元素动态切换类名,赋予元素一定的css动画样式
8
+ const getClassNames = (name) => ({
9
+ enter: `u-${name}-enter u-${name}-enter-active`,
10
+ 'enter-to': `u-${name}-enter-to u-${name}-enter-active`,
11
+ leave: `u-${name}-leave u-${name}-leave-active`,
12
+ 'leave-to': `u-${name}-leave-to u-${name}-leave-active`
13
+ })
14
+ // #endif
15
+
16
+ // #ifdef APP-NVUE
17
+ // 引入nvue(weex)的animation动画模块,文档见:
18
+ // https://weex.apache.org/zh/docs/modules/animation.html#transition
19
+ const animation = uni.requireNativePlugin('animation')
20
+ const getStyle = (name) => animationMap[name]
21
+ // #endif
22
+
23
+ export default {
24
+ methods: {
25
+ // 组件被点击发出事件
26
+ clickHandler() {
27
+ this.$emit('click')
28
+ },
29
+ // #ifndef APP-NVUE
30
+ // vue版本的组件进场处理
31
+ vueEnter() {
32
+ // 动画进入时的类名
33
+ const classNames = getClassNames(this.mode)
34
+ // 定义状态和发出动画进入前事件
35
+ this.status = 'enter'
36
+ this.$emit('beforeEnter')
37
+ this.inited = true
38
+ this.display = true
39
+ this.classes = classNames.enter
40
+ this.$nextTick(async () => {
41
+ // #ifdef H5
42
+ await uni.$u.sleep(20)
43
+ // #endif
44
+ // 标识动画尚未结束
45
+ this.$emit('enter')
46
+ this.transitionEnded = false
47
+ // 组件动画进入后触发的事件
48
+ this.$emit('afterEnter')
49
+ // 赋予组件enter-to类名
50
+ this.classes = classNames['enter-to']
51
+ })
52
+ },
53
+ // 动画离场处理
54
+ vueLeave() {
55
+ // 如果不是展示状态,无需执行逻辑
56
+ if (!this.display) return
57
+ const classNames = getClassNames(this.mode)
58
+ // 标记离开状态和发出事件
59
+ this.status = 'leave'
60
+ this.$emit('beforeLeave')
61
+ // 获得类名
62
+ this.classes = classNames.leave
63
+
64
+ this.$nextTick(() => {
65
+ // 动画正在离场的状态
66
+ this.transitionEnded = false
67
+ this.$emit('leave')
68
+ // 组件执行动画,到了执行的执行时间后,执行一些额外处理
69
+ setTimeout(this.onTransitionEnd, this.duration)
70
+ this.classes = classNames['leave-to']
71
+ })
72
+ },
73
+ // #endif
74
+ // #ifdef APP-NVUE
75
+ // nvue版本动画进场
76
+ nvueEnter() {
77
+ // 获得样式的名称
78
+ const currentStyle = getStyle(this.mode)
79
+ // 组件动画状态和发出事件
80
+ this.status = 'enter'
81
+ this.$emit('beforeEnter')
82
+ // 展示生成组件元素
83
+ this.inited = true
84
+ this.display = true
85
+ // 在nvue安卓上,由于渲染速度慢,在弹窗,键盘,日历等组件中,渲染其中的内容需要时间
86
+ // 导致出现弹窗卡顿,这里让其一开始为透明状态,等一定时间渲染完成后,再让其隐藏起来,再让其按正常逻辑出现
87
+ this.viewStyle = {
88
+ opacity: 0
89
+ }
90
+ // 等待弹窗内容渲染完成
91
+ this.$nextTick(() => {
92
+ // 合并样式
93
+ this.viewStyle = currentStyle.enter
94
+ Promise.resolve()
95
+ .then(nextTick)
96
+ .then(() => {
97
+ // 组件开始进入前的事件
98
+ this.$emit('enter')
99
+ // nvue的transition动画模块需要通过ref调用组件,注意此处的ref不同于vue的this.$refs['u-transition']用法
100
+ animation.transition(this.$refs['u-transition'].ref, {
101
+ styles: currentStyle['enter-to'],
102
+ duration: this.duration,
103
+ timingFunction: this.timingFunction,
104
+ needLayout: false,
105
+ delay: 0
106
+ }, () => {
107
+ // 动画执行完毕,发出事件
108
+ this.$emit('afterEnter')
109
+ })
110
+ })
111
+ .catch(() => {})
112
+ })
113
+ },
114
+ nvueLeave() {
115
+ if (!this.display) {
116
+ return
117
+ }
118
+ const currentStyle = getStyle(this.mode)
119
+ // 定义状态和事件
120
+ this.status = 'leave'
121
+ this.$emit('beforeLeave')
122
+ // 合并样式
123
+ this.viewStyle = currentStyle.leave
124
+ // 放到promise中处理执行过程
125
+ Promise.resolve()
126
+ .then(nextTick) // 等待几十ms
127
+ .then(() => {
128
+ this.transitionEnded = false
129
+ // 动画正在离场的状态
130
+ this.$emit('leave')
131
+ animation.transition(this.$refs['u-transition'].ref, {
132
+ styles: currentStyle['leave-to'],
133
+ duration: this.duration,
134
+ timingFunction: this.timingFunction,
135
+ needLayout: false,
136
+ delay: 0
137
+ }, () => {
138
+ this.onTransitionEnd()
139
+ })
140
+ })
141
+ .catch(() => {})
142
+ },
143
+ // #endif
144
+ // 完成过渡后触发
145
+ onTransitionEnd() {
146
+ // 如果已经是结束的状态,无需再处理
147
+ if (this.transitionEnded) return
148
+ this.transitionEnded = true
149
+ // 发出组件动画执行后的事件
150
+ this.$emit(this.status === 'leave' ? 'afterLeave' : 'afterEnter')
151
+ if (!this.show && this.display) {
152
+ this.display = false
153
+ this.inited = false
154
+ }
155
+ }
156
+ }
157
+ }