@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,223 @@
1
+ <template>
2
+ <view
3
+ class="uv-sticky"
4
+ :id="elId"
5
+ :style="[style]"
6
+ >
7
+ <view
8
+ :style="[stickyContent]"
9
+ class="uv-sticky__content"
10
+ >
11
+ <slot />
12
+ </view>
13
+ </view>
14
+ </template>
15
+
16
+ <script>
17
+ import mpMixin from '../../libs/mixin/mpMixin.js'
18
+ import mixin from '../../libs/mixin/mixin.js'
19
+ import props from './props.js';;
20
+ /**
21
+ * sticky 吸顶
22
+ * @description 该组件与CSS中position: sticky属性实现的效果一致,当组件达到预设的到顶部距离时, 就会固定在指定位置,组件位置大于预设的顶部距离时,会重新按照正常的布局排列。
23
+ * @tutorial https://www.uvui.cn/components/sticky.html
24
+ * @property {String | Number} offsetTop 吸顶时与顶部的距离,单位px(默认 0 )
25
+ * @property {String | Number} customNavHeight 自定义导航栏的高度 (h5 默认44 其他默认 0 )
26
+ * @property {Boolean} disabled 是否开启吸顶功能 (默认 false )
27
+ * @property {String} bgColor 组件背景颜色(默认 '#ffffff' )
28
+ * @property {String | Number} zIndex 吸顶时的z-index值
29
+ * @property {String | Number} index 自定义标识,用于区分是哪一个组件
30
+ * @property {Object} customStyle 组件的样式,对象形式
31
+ * @example <uv-sticky offsetTop="200"><view>塞下秋来风景异,衡阳雁去无留意</view></uv-sticky>
32
+ */
33
+ export default {
34
+ name: 'uv-sticky',
35
+ mixins: [mpMixin, mixin, props],
36
+ data() {
37
+ return {
38
+ cssSticky: false, // 是否使用css的sticky实现
39
+ stickyTop: 0, // 吸顶的top值,因为可能受自定义导航栏影响,最终的吸顶值非offsetTop值
40
+ elId: '',
41
+ left: 0, // js模式时,吸顶的内容因为处于postition: fixed模式,为了和原来保持一致的样式,需要记录并重新设置它的left,height,width属性
42
+ width: 'auto',
43
+ height: 'auto',
44
+ fixed: false, // js模式时,是否处于吸顶模式
45
+ }
46
+ },
47
+ computed: {
48
+ style() {
49
+ const style = {}
50
+ if(!this.disabled) {
51
+ if (this.cssSticky) {
52
+ style.position = 'sticky'
53
+ style.zIndex = this.uZindex
54
+ style.top = this.$uv.addUnit(this.stickyTop)
55
+ } else {
56
+ style.height = this.fixed ? this.height + 'px' : 'auto'
57
+ }
58
+ } else {
59
+ // 无需吸顶时,设置会默认的relative(nvue)和非nvue的static静态模式即可
60
+ // #ifdef APP-NVUE
61
+ style.position = 'relative'
62
+ // #endif
63
+ // #ifndef APP-NVUE
64
+ style.position = 'static'
65
+ // #endif
66
+ }
67
+ style.backgroundColor = this.bgColor
68
+ return this.$uv.deepMerge(this.$uv.addStyle(this.customStyle), style)
69
+ },
70
+ // 吸顶内容的样式
71
+ stickyContent() {
72
+ const style = {}
73
+ if (!this.cssSticky) {
74
+ style.position = this.fixed ? 'fixed' : 'static'
75
+ style.top = this.stickyTop + 'px'
76
+ style.left = this.left + 'px'
77
+ style.width = this.width == 'auto' ? 'auto' : this.width + 'px'
78
+ style.zIndex = this.uZindex
79
+ }
80
+ return style
81
+ },
82
+ uZindex() {
83
+ return this.zIndex ? this.zIndex : 970
84
+ }
85
+ },
86
+ created() {
87
+ this.elId = this.$uv.guid();
88
+ },
89
+ mounted() {
90
+ this.init()
91
+ },
92
+ methods: {
93
+ init() {
94
+ this.getStickyTop()
95
+ // 判断使用的模式
96
+ this.checkSupportCssSticky()
97
+ // 如果不支持css sticky,则使用js方案,此方案性能比不上css方案
98
+ if (!this.cssSticky) {
99
+ !this.disabled && this.initObserveContent()
100
+ }
101
+ },
102
+ initObserveContent() {
103
+ // 获取吸顶内容的高度,用于在js吸顶模式时,给父元素一个填充高度,防止"塌陷"
104
+ this.$uvGetRect('#' + this.elId).then((res) => {
105
+ this.height = res.height
106
+ this.left = res.left
107
+ this.width = res.width
108
+ this.$nextTick(() => {
109
+ this.observeContent()
110
+ })
111
+ })
112
+ },
113
+ observeContent() {
114
+ // 先断掉之前的观察
115
+ this.disconnectObserver('contentObserver')
116
+ const contentObserver = uni.createIntersectionObserver({
117
+ // 检测的区间范围
118
+ thresholds: [0.95, 0.98, 1]
119
+ })
120
+ // 到屏幕顶部的高度时触发
121
+ contentObserver.relativeToViewport({
122
+ top: -this.stickyTop
123
+ })
124
+ // 绑定观察的元素
125
+ contentObserver.observe(`#${this.elId}`, res => {
126
+ this.setFixed(res.boundingClientRect.top)
127
+ })
128
+ this.contentObserver = contentObserver
129
+ },
130
+ setFixed(top) {
131
+ // 判断是否出于吸顶条件范围
132
+ const fixed = top <= this.stickyTop
133
+ this.fixed = fixed
134
+ },
135
+ disconnectObserver(observerName) {
136
+ // 断掉观察,释放资源
137
+ const observer = this[observerName]
138
+ observer && observer.disconnect()
139
+ },
140
+ getStickyTop() {
141
+ this.stickyTop = this.$uv.getPx(this.offsetTop) + this.$uv.getPx(this.customNavHeight)
142
+ },
143
+ async checkSupportCssSticky() {
144
+ // #ifdef H5
145
+ // H5,一般都是现代浏览器,是支持css sticky的,这里使用创建元素嗅探的形式判断
146
+ if (this.checkCssStickyForH5()) {
147
+ this.cssSticky = true
148
+ }
149
+ // #endif
150
+
151
+ // 如果安卓版本高于8.0,依然认为是支持css sticky的(因为安卓7在某些机型,可能不支持sticky)
152
+ if (this.$uv.os() === 'android' && Number(this.$uv.sys().system) > 8) {
153
+ this.cssSticky = true
154
+ }
155
+
156
+ // APP-Vue和微信平台,通过computedStyle判断是否支持css sticky
157
+ // #ifdef APP-VUE || MP-WEIXIN
158
+ this.cssSticky = await this.checkComputedStyle()
159
+ // #endif
160
+
161
+ // ios上,从ios6开始,都是支持css sticky的
162
+ if (this.$uv.os() === 'ios') {
163
+ this.cssSticky = true
164
+ }
165
+
166
+ // nvue,是支持css sticky的
167
+ // #ifdef APP-NVUE
168
+ this.cssSticky = true
169
+ // #endif
170
+ },
171
+ // 在APP和微信小程序上,通过uni.createSelectorQuery可以判断是否支持css sticky
172
+ checkComputedStyle() {
173
+ // 方法内进行判断,避免在其他平台生成无用代码
174
+ // #ifdef APP-VUE || MP-WEIXIN
175
+ return new Promise(resolve => {
176
+ uni.createSelectorQuery().in(this).select('.uv-sticky').fields({
177
+ computedStyle: ["position"]
178
+ }).exec(e => {
179
+ resolve('sticky' === e[0].position)
180
+ })
181
+ })
182
+ // #endif
183
+ },
184
+ // H5通过创建元素的形式嗅探是否支持css sticky
185
+ // 判断浏览器是否支持sticky属性
186
+ checkCssStickyForH5() {
187
+ // 方法内进行判断,避免在其他平台生成无用代码
188
+ // #ifdef H5
189
+ const vendorList = ['', '-webkit-', '-ms-', '-moz-', '-o-'],
190
+ vendorListLength = vendorList.length,
191
+ stickyElement = document.createElement('div')
192
+ for (let i = 0; i < vendorListLength; i++) {
193
+ stickyElement.style.position = vendorList[i] + 'sticky'
194
+ if (stickyElement.style.position !== '') {
195
+ return true
196
+ }
197
+ }
198
+ return false;
199
+ // #endif
200
+ }
201
+ },
202
+ // #ifdef VUE2
203
+ beforeDestroy() {
204
+ this.disconnectObserver('contentObserver')
205
+ },
206
+ // #endif
207
+ // #ifdef VUE3
208
+ unmounted() {
209
+ this.disconnectObserver('contentObserver')
210
+ }
211
+ // #endif
212
+ }
213
+ </script>
214
+
215
+ <style lang="scss" scoped>
216
+ @import '../../libs/css/components.scss';
217
+ .uv-sticky {
218
+ /* #ifdef APP-VUE || MP-WEIXIN */
219
+ // 此处默认写sticky属性,是为了给微信和APP通过uni.createSelectorQuery查询是否支持css sticky使用
220
+ position: sticky;
221
+ /* #endif */
222
+ }
223
+ </style>
@@ -0,0 +1,54 @@
1
+ export default {
2
+ props: {
3
+ // tab的数据
4
+ list: {
5
+ type: Array,
6
+ default: () => []
7
+ },
8
+ // 当前活动的tab的index
9
+ current: {
10
+ type: [String, Number],
11
+ default: 0
12
+ },
13
+ // 激活的颜色
14
+ activeColor: {
15
+ type: String,
16
+ default: '#3c9cff'
17
+ },
18
+ // 未激活的颜色
19
+ inactiveColor: {
20
+ type: String,
21
+ default: '#303133'
22
+ },
23
+ // 模式选择,mode=button为按钮形式,mode=subsection时为分段模式
24
+ mode: {
25
+ type: String,
26
+ default: 'button'
27
+ },
28
+ // 字体大小
29
+ fontSize: {
30
+ type: [String, Number],
31
+ default: 12
32
+ },
33
+ // 激活tab的字体是否加粗
34
+ bold: {
35
+ type: Boolean,
36
+ default: true
37
+ },
38
+ // mode = button时,组件背景颜色
39
+ bgColor: {
40
+ type: String,
41
+ default: '#eeeeef'
42
+ },
43
+ // 从list元素对象中读取的键名
44
+ keyName: {
45
+ type: String,
46
+ default: 'name'
47
+ },
48
+ customItemStyle: {
49
+ type: [String, Object],
50
+ default: ''
51
+ },
52
+ ...uni.$uv?.props?.subsection
53
+ }
54
+ }
@@ -0,0 +1,269 @@
1
+ <template>
2
+ <view
3
+ class="uv-subsection"
4
+ ref="uv-subsection"
5
+ :class="[`uv-subsection--${mode}`]"
6
+ :style="[$uv.addStyle(customStyle), wrapperStyle]">
7
+ <view
8
+ class="uv-subsection__bar"
9
+ ref="uv-subsection__bar"
10
+ :style="[barStyle]"
11
+ :class="[
12
+ mode === 'button' && 'uv-subsection--button__bar',
13
+ current === 0 && mode === 'subsection' && 'uv-subsection__bar--first',
14
+ current > 0 && current < list.length - 1 && mode === 'subsection' && 'uv-subsection__bar--center',
15
+ current === list.length - 1 && mode === 'subsection' && 'uv-subsection__bar--last'
16
+ ]"
17
+ ></view>
18
+ <view class="uv-subsection__item"
19
+ :class="[
20
+ `uv-subsection__item--${index}`,
21
+ index < list.length - 1 && 'uv-subsection__item--no-border-right',
22
+ index === 0 && 'uv-subsection__item--first',
23
+ index === list.length - 1 && 'uv-subsection__item--last'
24
+ ]"
25
+ :ref="`uv-subsection__item--${index}`"
26
+ :style="[itemStyle(index)]"
27
+ @tap="clickHandler(index)"
28
+ v-for="(item, index) in list"
29
+ :key="index"
30
+ >
31
+ <text
32
+ class="uv-subsection__item__text"
33
+ :style="[textStyle(index)]">{{ getText(item) }}
34
+ </text>
35
+ </view>
36
+ </view>
37
+ </template>
38
+
39
+ <script>
40
+ import mpMixin from '../../libs/mixin/mpMixin.js'
41
+ import mixin from '../../libs/mixin/mixin.js'
42
+ // #ifdef APP-NVUE
43
+ const dom = uni.requireNativePlugin("dom");
44
+ const animation = uni.requireNativePlugin("animation");
45
+ // #endif
46
+ import props from "./props.js";
47
+ /**
48
+ * Subsection 分段器
49
+ * @description 该分段器一般用于用户从几个选项中选择某一个的场景
50
+ * @tutorial https://www.uvui.cn/components/subsection.html
51
+ * @property {Array} list tab的数据
52
+ * @property {String | Number} current 当前活动的tab的index(默认 0 )
53
+ * @property {String} activeColor 激活时的颜色(默认 '#3c9cff' )
54
+ * @property {String} inactiveColor 未激活时的颜色(默认 '#303133' )
55
+ * @property {String} mode 模式选择,mode=button为按钮形式,mode=subsection时为分段模式(默认 'button' )
56
+ * @property {String | Number} fontSize 字体大小,单位px(默认 12 )
57
+ * @property {Boolean} bold 激活选项的字体是否加粗(默认 true )
58
+ * @property {String} bgColor 组件背景颜色,mode为button时有效(默认 '#eeeeef' )
59
+ * @property {Object} customStyle 定义需要用到的外部样式
60
+ * @property {String} keyName 从`list`元素对象中读取的键名(默认 'name' )
61
+ *
62
+ * @event {Function} change 分段器选项发生改变时触发 回调 index:选项的index索引值,从0开始
63
+ * @example <uv-subsection :list="list" :current="curNow" @change="sectionChange"></uv-subsection>
64
+ */
65
+ export default {
66
+ name: "uv-subsection",
67
+ mixins: [mpMixin, mixin, props],
68
+ data() {
69
+ return {
70
+ // 组件尺寸
71
+ itemRect: {
72
+ width: 0,
73
+ height: 0,
74
+ }
75
+ }
76
+ },
77
+ watch: {
78
+ list: {
79
+ deep: true,
80
+ handler(){
81
+ this.init();
82
+ }
83
+ },
84
+ current: {
85
+ immediate: true,
86
+ handler(n) {
87
+ // #ifdef APP-NVUE
88
+ // 在安卓nvue上,如果通过translateX进行位移,到最后一个时,会导致右侧无法绘制圆角
89
+ // 故用animation模块进行位移
90
+ const ref = this.$refs?.["uv-subsection__bar"]?.ref;
91
+ // 不存在ref的时候(理解为第一次初始化时,需要渲染dom,进行一定延时再获取ref),这里的100ms是经过测试得出的结果(某些安卓需要延时久一点),勿随意修改
92
+ this.$uv.sleep(ref ? 0 : 150).then(() => {
93
+ animation.transition(this.$refs["uv-subsection__bar"].ref, {
94
+ styles: {
95
+ transform: `translateX(${ n * this.itemRect.width }px)`,
96
+ transformOrigin: "center center"
97
+ },
98
+ duration: 300,
99
+ });
100
+ });
101
+ // #endif
102
+ }
103
+ }
104
+ },
105
+ computed: {
106
+ wrapperStyle() {
107
+ const style = {};
108
+ // button模式时,设置背景色
109
+ if (this.mode === "button") {
110
+ style.backgroundColor = this.bgColor;
111
+ }
112
+ return style;
113
+ },
114
+ // 滑块的样式
115
+ barStyle() {
116
+ const style = {};
117
+ style.width = `${this.itemRect.width}px`;
118
+ style.height = `${this.itemRect.height}px`;
119
+ // 通过translateX移动滑块,其移动的距离为索引*item的宽度
120
+ // #ifndef APP-NVUE
121
+ style.transform = `translateX(${ this.current * this.itemRect.width }px)`;
122
+ // #endif
123
+ if (this.mode === "subsection") {
124
+ // 在subsection模式下,需要动态设置滑块的圆角,因为移动滑块使用的是translateX,无法通过父元素设置overflow: hidden隐藏滑块的直角
125
+ style.backgroundColor = this.activeColor;
126
+ }
127
+ return this.$uv.deepMerge(style, this.$uv.addStyle(this.customItemStyle));
128
+ },
129
+ // 分段器item的样式
130
+ itemStyle(index) {
131
+ return (index) => {
132
+ const style = {};
133
+ if (this.mode === "subsection") {
134
+ // 设置border的样式
135
+ style.borderColor = this.activeColor;
136
+ style.borderWidth = "1px";
137
+ style.borderStyle = "solid";
138
+ }
139
+ return style;
140
+ };
141
+ },
142
+ // 分段器文字颜色
143
+ textStyle(index) {
144
+ return (index) => {
145
+ const style = {};
146
+ style.fontWeight = this.bold && this.current === index ? "bold" : "normal";
147
+ style.fontSize = this.$uv.addUnit(this.fontSize);
148
+ // subsection模式下,激活时默认为白色的文字
149
+ if (this.mode === "subsection") {
150
+ style.color = this.current === index ? "#fff" : this.inactiveColor;
151
+ } else {
152
+ // button模式下,激活时文字颜色默认为activeColor
153
+ style.color = this.current === index ? this.activeColor : this.inactiveColor;
154
+ }
155
+ return style;
156
+ };
157
+ },
158
+ },
159
+ mounted() {
160
+ this.init();
161
+ },
162
+ methods: {
163
+ init() {
164
+ this.$uv.sleep().then(() => this.getRect());
165
+ },
166
+ // 判断展示文本
167
+ getText(item) {
168
+ return typeof item === 'object' ? item[this.keyName] : item
169
+ },
170
+ // 获取组件的尺寸
171
+ getRect() {
172
+ // #ifndef APP-NVUE
173
+ this.$uvGetRect(".uv-subsection__item--0").then((size) => {
174
+ this.itemRect = size;
175
+ });
176
+ // #endif
177
+
178
+ // #ifdef APP-NVUE
179
+ const ref = this.$refs["uv-subsection__item--0"][0];
180
+ ref && dom.getComponentRect(ref, (res) => {
181
+ this.itemRect = res.size;
182
+ });
183
+ // #endif
184
+ },
185
+ clickHandler(index) {
186
+ this.$emit("change", index);
187
+ }
188
+ }
189
+ }
190
+ </script>
191
+
192
+ <style lang="scss" scoped>
193
+ @import '../../libs/css/components.scss';
194
+ .uv-subsection {
195
+ @include flex;
196
+ position: relative;
197
+ overflow: hidden;
198
+ /* #ifndef APP-NVUE */
199
+ width: 100%;
200
+ box-sizing: border-box;
201
+ /* #endif */
202
+ &--button {
203
+ height: 32px;
204
+ background-color: rgb(238, 238, 239);
205
+ padding: 3px;
206
+ border-radius: 3px;
207
+ align-items: stretch;
208
+ &__bar {
209
+ background-color: #ffffff;
210
+ }
211
+ }
212
+ &--subsection {
213
+ height: 30px;
214
+ }
215
+ &__bar {
216
+ position: absolute;
217
+ /* #ifndef APP-NVUE */
218
+ transition-property: transform, color;
219
+ transition-duration: 0.3s;
220
+ transition-timing-function: ease-in-out;
221
+ /* #endif */
222
+ &--first {
223
+ border-top-left-radius: 3px;
224
+ border-bottom-left-radius: 3px;
225
+ border-top-right-radius: 0px;
226
+ border-bottom-right-radius: 0px;
227
+ }
228
+ &--center {
229
+ border-top-left-radius: 0px;
230
+ border-bottom-left-radius: 0px;
231
+ border-top-right-radius: 0px;
232
+ border-bottom-right-radius: 0px;
233
+ }
234
+ &--last {
235
+ border-top-left-radius: 0px;
236
+ border-bottom-left-radius: 0px;
237
+ border-top-right-radius: 3px;
238
+ border-bottom-right-radius: 3px;
239
+ }
240
+ }
241
+ &__item {
242
+ @include flex;
243
+ flex: 1;
244
+ justify-content: center;
245
+ align-items: center;
246
+ // vue环境下,需要设置相对定位,因为滑块为绝对定位,item需要在滑块的上面
247
+ position: relative;
248
+ &--no-border-right {
249
+ border-right-width: 0 !important;
250
+ }
251
+ &--first {
252
+ border-top-left-radius: 3px;
253
+ border-bottom-left-radius: 3px;
254
+ }
255
+ &--last {
256
+ border-top-right-radius: 3px;
257
+ border-bottom-right-radius: 3px;
258
+ }
259
+ &__text {
260
+ font-size: 12px;
261
+ line-height: 12px;
262
+ @include flex;
263
+ align-items: center;
264
+ transition-property: color;
265
+ transition-duration: 0.3s;
266
+ }
267
+ }
268
+ }
269
+ </style>
@@ -0,0 +1,10 @@
1
+ export default {
2
+ props: {
3
+ // 是否自动关闭其他swipe按钮组
4
+ autoClose: {
5
+ type: Boolean,
6
+ default: true
7
+ },
8
+ ...uni.$uv?.props?.swipeAction
9
+ }
10
+ }
@@ -0,0 +1,65 @@
1
+ <template>
2
+ <view class="uv-swipe-action">
3
+ <slot></slot>
4
+ </view>
5
+ </template>
6
+
7
+ <script>
8
+ import mpMixin from '../../libs/mixin/mpMixin.js'
9
+ import mixin from '../../libs/mixin/mixin.js'
10
+ import props from './props.js';
11
+ /**
12
+ * SwipeAction 滑动单元格
13
+ * @description 该组件一般用于左滑唤出操作菜单的场景,用的最多的是左滑删除操作
14
+ * @tutorial https://www.uvui.cn/components/swipeAction.html
15
+ * @property {Boolean} autoClose 是否自动关闭其他swipe按钮组
16
+ * @event {Function(index)} click 点击组件时触发
17
+ * @example <uv-swipe-action><uv-swipe-action-item :rightOptions="options1" ></uv-swipe-action-item></uv-swipe-action>
18
+ */
19
+ export default {
20
+ name: 'uv-swipe-action',
21
+ mixins: [mpMixin, mixin, props],
22
+ data() {
23
+ return {}
24
+ },
25
+ provide() {
26
+ return {
27
+ swipeAction: this
28
+ }
29
+ },
30
+ computed: {
31
+ // 这里computed的变量,都是子组件uv-swipe-action-item需要用到的,由于头条小程序的兼容性差异,子组件无法实时监听父组件参数的变化
32
+ // 所以需要手动通知子组件,这里返回一个parentData变量,供watch监听,在其中去通知每一个子组件重新从父组件(uv-swipe-action-item)
33
+ // 拉取父组件新的变化后的参数
34
+ parentData() {
35
+ return [this.autoClose]
36
+ }
37
+ },
38
+ watch: {
39
+ // 当父组件需要子组件需要共享的参数发生了变化,手动通知子组件
40
+ parentData() {
41
+ if (this.children.length) {
42
+ this.children.map(child => {
43
+ // 判断子组件(uv-swipe-action-item)如果有updateParentData方法的话,就就执行(执行的结果是子组件重新从父组件拉取了最新的值)
44
+ typeof(child.updateParentData) === 'function' && child.updateParentData()
45
+ })
46
+ }
47
+ },
48
+ },
49
+ created() {
50
+ this.children = []
51
+ },
52
+ methods: {
53
+ closeOther(child) {
54
+ if (this.autoClose) {
55
+ // 历遍所有的单元格,找出非当前操作中的单元格,进行关闭
56
+ this.children.map((item, index) => {
57
+ if (child !== item) {
58
+ item.closeHandler()
59
+ }
60
+ })
61
+ }
62
+ }
63
+ }
64
+ }
65
+ </script>