@tarojs/taro-h5 3.5.0-alpha.13 → 3.5.0-alpha.16

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 (295) hide show
  1. package/dist/api/ad/index.d.ts +6 -0
  2. package/dist/api/ai/facial.d.ts +9 -0
  3. package/dist/api/ai/index.d.ts +2 -0
  4. package/dist/api/ai/visual.d.ts +6 -0
  5. package/dist/api/alipay/index.d.ts +3 -0
  6. package/dist/api/base/crypto.d.ts +3 -0
  7. package/dist/api/base/debug.d.ts +9 -0
  8. package/dist/api/base/index.d.ts +12 -0
  9. package/dist/api/base/performance.d.ts +6 -0
  10. package/dist/api/base/system.d.ts +27 -0
  11. package/dist/api/base/system.js +2 -2
  12. package/dist/api/base/update.d.ts +6 -0
  13. package/dist/api/base/weapp/app-event.d.ts +41 -0
  14. package/dist/api/base/weapp/app-event.js +55 -4
  15. package/dist/api/base/weapp/life-cycle.d.ts +6 -0
  16. package/dist/api/canvas/CanvasContext.d.ts +104 -0
  17. package/dist/api/canvas/canvasGetImageData.d.ts +5 -0
  18. package/dist/api/canvas/canvasPutImageData.d.ts +6 -0
  19. package/dist/api/canvas/canvasToTempFilePath.d.ts +6 -0
  20. package/dist/api/canvas/canvasToTempFilePath.js +1 -1
  21. package/dist/api/canvas/createCanvasContext.d.ts +5 -0
  22. package/dist/api/canvas/index.d.ts +12 -0
  23. package/dist/api/cloud/index.d.ts +31 -0
  24. package/dist/api/data-analysis/index.d.ts +12 -0
  25. package/dist/api/device/accelerometer.d.ts +17 -0
  26. package/dist/api/device/accessibility.d.ts +3 -0
  27. package/dist/api/device/battery.d.ts +5 -0
  28. package/dist/api/device/bluetooth-ble.d.ts +48 -0
  29. package/dist/api/device/bluetooth-peripheral.d.ts +9 -0
  30. package/dist/api/device/bluetooth.d.ts +39 -0
  31. package/dist/api/device/calendar.d.ts +6 -0
  32. package/dist/api/device/clipboard.d.ts +15 -0
  33. package/dist/api/device/compass.d.ts +17 -0
  34. package/dist/api/device/contact.d.ts +6 -0
  35. package/dist/api/device/crypto.d.ts +3 -0
  36. package/dist/api/device/gyroscope.d.ts +12 -0
  37. package/dist/api/device/iBeacon.d.ts +21 -0
  38. package/dist/api/device/index.d.ts +23 -0
  39. package/dist/api/device/keyboard.d.ts +12 -0
  40. package/dist/api/device/memory.d.ts +6 -0
  41. package/dist/api/device/motion.d.ts +17 -0
  42. package/dist/api/device/network.d.ts +20 -0
  43. package/dist/api/device/nfc.d.ts +21 -0
  44. package/dist/api/device/phone.d.ts +2 -0
  45. package/dist/api/device/scan.d.ts +3 -0
  46. package/dist/api/device/screen.d.ts +18 -0
  47. package/dist/api/device/vibrate.d.ts +9 -0
  48. package/dist/api/device/vibrate.js +5 -7
  49. package/dist/api/device/wifi.d.ts +33 -0
  50. package/dist/api/ext/index.d.ts +6 -0
  51. package/dist/api/files/index.d.ts +24 -0
  52. package/dist/api/framework/index.d.ts +4 -0
  53. package/dist/api/index.d.ts +24 -0
  54. package/dist/api/location/chooseLocation.d.ts +6 -0
  55. package/dist/api/location/getLocation.d.ts +2 -0
  56. package/dist/api/location/index.d.ts +32 -0
  57. package/dist/api/location/index.js +1 -0
  58. package/dist/api/media/EditorContext.d.ts +42 -0
  59. package/dist/api/media/audio/InnerAudioContext.d.ts +58 -0
  60. package/dist/api/media/audio/InnerAudioContext.js +1 -1
  61. package/dist/api/media/audio/index.d.ts +29 -0
  62. package/dist/api/media/background-audio/BackgroundAudioManager.d.ts +71 -0
  63. package/dist/api/media/background-audio/index.d.ts +29 -0
  64. package/dist/api/media/camera.d.ts +3 -0
  65. package/dist/api/media/image/chooseImage.d.ts +5 -0
  66. package/dist/api/media/image/getImageInfo.d.ts +5 -0
  67. package/dist/api/media/image/index.d.ts +15 -0
  68. package/dist/api/media/image/previewImage.d.ts +8 -0
  69. package/dist/api/media/index.d.ts +12 -0
  70. package/dist/api/media/live.d.ts +6 -0
  71. package/dist/api/media/map.d.ts +3 -0
  72. package/dist/api/media/media-recorder.d.ts +3 -0
  73. package/dist/api/media/recorder.d.ts +9 -0
  74. package/dist/api/media/video/index.d.ts +24 -0
  75. package/dist/api/media/video-decoder.d.ts +3 -0
  76. package/dist/api/media/video-processing.d.ts +3 -0
  77. package/dist/api/media/voip.d.ts +42 -0
  78. package/dist/api/navigate/index.d.ts +12 -0
  79. package/dist/api/network/download.d.ts +6 -0
  80. package/dist/api/network/download.js +1 -0
  81. package/dist/api/network/index.d.ts +7 -0
  82. package/dist/api/network/mdns.d.ts +30 -0
  83. package/dist/api/network/request/index.d.ts +4 -0
  84. package/dist/api/network/tcp.d.ts +3 -0
  85. package/dist/api/network/udp.d.ts +3 -0
  86. package/dist/api/network/upload.d.ts +5 -0
  87. package/dist/api/network/upload.js +2 -1
  88. package/{src/api/network/utils.ts → dist/api/network/utils.d.ts} +44 -71
  89. package/dist/api/network/utils.js +1 -0
  90. package/dist/api/network/websocket/index.d.ts +7 -0
  91. package/dist/api/network/websocket/socketTask.d.ts +25 -0
  92. package/dist/api/open-api/account.d.ts +3 -0
  93. package/dist/api/open-api/address.d.ts +3 -0
  94. package/dist/api/open-api/authorize.d.ts +6 -0
  95. package/dist/api/open-api/card.d.ts +6 -0
  96. package/dist/api/open-api/channels-live.d.ts +18 -0
  97. package/dist/api/open-api/customer-service.d.ts +3 -0
  98. package/dist/api/open-api/facial.d.ts +12 -0
  99. package/dist/api/open-api/favorites.d.ts +6 -0
  100. package/dist/api/open-api/group.d.ts +3 -0
  101. package/dist/api/open-api/index.d.ts +18 -0
  102. package/dist/api/open-api/invoice.d.ts +6 -0
  103. package/dist/api/open-api/license-plate.d.ts +3 -0
  104. package/dist/api/open-api/login.d.ts +9 -0
  105. package/dist/api/open-api/red-package.d.ts +3 -0
  106. package/dist/api/open-api/settings.d.ts +6 -0
  107. package/dist/api/open-api/soter.d.ts +9 -0
  108. package/dist/api/open-api/subscribe-message.d.ts +3 -0
  109. package/dist/api/open-api/user-info.d.ts +6 -0
  110. package/dist/api/open-api/werun.d.ts +6 -0
  111. package/dist/api/payment/index.d.ts +6 -0
  112. package/dist/api/route/index.d.ts +1 -0
  113. package/dist/api/share/index.d.ts +30 -0
  114. package/dist/api/storage/background-fetch.d.ts +12 -0
  115. package/dist/api/storage/index.d.ts +18 -0
  116. package/dist/api/swan/index.d.ts +63 -0
  117. package/dist/api/taro.d.ts +12 -0
  118. package/dist/api/ui/animation/index.d.ts +2 -0
  119. package/dist/api/ui/background.d.ts +6 -0
  120. package/dist/api/ui/custom-component.d.ts +1 -0
  121. package/dist/api/ui/fonts.d.ts +2 -0
  122. package/dist/api/ui/index.d.ts +12 -0
  123. package/dist/api/ui/interaction/actionSheet.d.ts +61 -0
  124. package/dist/api/ui/interaction/index.d.ts +14 -0
  125. package/dist/api/ui/interaction/modal.d.ts +69 -0
  126. package/dist/api/ui/interaction/modal.js +1 -0
  127. package/dist/api/ui/interaction/toast.d.ts +85 -0
  128. package/dist/api/ui/menu.d.ts +3 -0
  129. package/dist/api/ui/navigation-bar/index.d.ts +15 -0
  130. package/dist/api/ui/navigation-bar/index.js +2 -3
  131. package/dist/api/ui/pull-down-refresh.d.ts +9 -0
  132. package/dist/api/ui/scroll/index.d.ts +5 -0
  133. package/dist/api/ui/sticky.d.ts +3 -0
  134. package/dist/api/ui/tab-bar.d.ts +34 -0
  135. package/dist/api/ui/window.d.ts +15 -0
  136. package/dist/api/worker/index.d.ts +3 -0
  137. package/dist/api/wxml/index.d.ts +5 -0
  138. package/dist/api/wxml/nodesRef.d.ts +13 -0
  139. package/dist/api/wxml/selectorQuery.d.ts +24 -0
  140. package/dist/api/wxml/selectorQuery.js +1 -1
  141. package/dist/index.cjs.d.ts +1373 -0
  142. package/dist/index.cjs.js +105 -81
  143. package/dist/index.cjs.js.map +1 -1
  144. package/dist/index.d.ts +4 -0
  145. package/dist/index.esm.d.ts +1373 -0
  146. package/dist/index.esm.js +93 -69
  147. package/dist/index.esm.js.map +1 -1
  148. package/dist/taroApis.d.ts +1364 -0
  149. package/dist/taroApis.js +1 -1
  150. package/dist/utils/animation.d.ts +6 -0
  151. package/dist/utils/handler.d.ts +48 -0
  152. package/dist/utils/index.d.ts +39 -0
  153. package/dist/utils/index.js +3 -7
  154. package/dist/utils/lodash.d.ts +2 -0
  155. package/dist/utils/valid.d.ts +2 -0
  156. package/package.json +17 -19
  157. package/types/api.d.ts +4 -0
  158. package/types/define.d.ts +2 -0
  159. package/types/index.d.ts +33 -0
  160. package/types/overlay.d.ts +9 -0
  161. package/LICENSE +0 -21
  162. package/src/api/ad/index.ts +0 -5
  163. package/src/api/ai/facial.ts +0 -6
  164. package/src/api/ai/index.ts +0 -2
  165. package/src/api/ai/visual.ts +0 -7
  166. package/src/api/alipay/index.ts +0 -4
  167. package/src/api/base/crypto.ts +0 -4
  168. package/src/api/base/debug.ts +0 -5
  169. package/src/api/base/index.ts +0 -23
  170. package/src/api/base/performance.ts +0 -5
  171. package/src/api/base/system.ts +0 -207
  172. package/src/api/base/update.ts +0 -5
  173. package/src/api/base/weapp/app-event.ts +0 -19
  174. package/src/api/base/weapp/life-cycle.ts +0 -5
  175. package/src/api/canvas/CanvasContext.ts +0 -233
  176. package/src/api/canvas/canvasGetImageData.ts +0 -28
  177. package/src/api/canvas/canvasPutImageData.ts +0 -25
  178. package/src/api/canvas/canvasToTempFilePath.ts +0 -25
  179. package/src/api/canvas/createCanvasContext.ts +0 -19
  180. package/src/api/canvas/index.ts +0 -18
  181. package/src/api/cloud/index.ts +0 -32
  182. package/src/api/data-analysis/index.ts +0 -6
  183. package/src/api/device/accelerometer.ts +0 -79
  184. package/src/api/device/accessibility.ts +0 -4
  185. package/src/api/device/battery.ts +0 -23
  186. package/src/api/device/bluetooth-ble.ts +0 -19
  187. package/src/api/device/bluetooth-peripheral.ts +0 -6
  188. package/src/api/device/bluetooth.ts +0 -16
  189. package/src/api/device/calendar.ts +0 -5
  190. package/src/api/device/clipboard.ts +0 -68
  191. package/src/api/device/compass.ts +0 -83
  192. package/src/api/device/contact.ts +0 -5
  193. package/src/api/device/crypto.ts +0 -4
  194. package/src/api/device/gyroscope.ts +0 -7
  195. package/src/api/device/iBeacon.ts +0 -10
  196. package/src/api/device/index.ts +0 -23
  197. package/src/api/device/keyboard.ts +0 -7
  198. package/src/api/device/memory.ts +0 -5
  199. package/src/api/device/motion.ts +0 -77
  200. package/src/api/device/network.ts +0 -90
  201. package/src/api/device/nfc.ts +0 -10
  202. package/src/api/device/phone.ts +0 -31
  203. package/src/api/device/scan.ts +0 -11
  204. package/src/api/device/screen.ts +0 -9
  205. package/src/api/device/vibrate.ts +0 -37
  206. package/src/api/device/wifi.ts +0 -14
  207. package/src/api/ext/index.ts +0 -5
  208. package/src/api/files/index.ts +0 -11
  209. package/src/api/framework/index.ts +0 -10
  210. package/src/api/index.ts +0 -24
  211. package/src/api/location/chooseLocation.ts +0 -117
  212. package/src/api/location/getLocation.ts +0 -81
  213. package/src/api/location/index.ts +0 -22
  214. package/src/api/location/style.css +0 -79
  215. package/src/api/media/EditorContext.ts +0 -32
  216. package/src/api/media/audio/InnerAudioContext.ts +0 -99
  217. package/src/api/media/audio/index.ts +0 -21
  218. package/src/api/media/background-audio/BackgroundAudioManager.ts +0 -104
  219. package/src/api/media/background-audio/index.ts +0 -17
  220. package/src/api/media/camera.ts +0 -4
  221. package/src/api/media/image/chooseImage.ts +0 -95
  222. package/src/api/media/image/getImageInfo.ts +0 -50
  223. package/src/api/media/image/index.ts +0 -13
  224. package/src/api/media/image/previewImage.ts +0 -80
  225. package/src/api/media/index.ts +0 -12
  226. package/src/api/media/live.ts +0 -5
  227. package/src/api/media/map.ts +0 -4
  228. package/src/api/media/media-recorder.ts +0 -4
  229. package/src/api/media/recorder.ts +0 -6
  230. package/src/api/media/video/index.ts +0 -82
  231. package/src/api/media/video-decoder.ts +0 -4
  232. package/src/api/media/video-processing.ts +0 -4
  233. package/src/api/media/voip.ts +0 -17
  234. package/src/api/navigate/index.ts +0 -7
  235. package/src/api/network/download.ts +0 -141
  236. package/src/api/network/index.ts +0 -7
  237. package/src/api/network/mdns.ts +0 -13
  238. package/src/api/network/request/index.ts +0 -135
  239. package/src/api/network/tcp.ts +0 -4
  240. package/src/api/network/udp.ts +0 -4
  241. package/src/api/network/upload.ts +0 -169
  242. package/src/api/network/websocket/index.ts +0 -88
  243. package/src/api/network/websocket/socketTask.ts +0 -89
  244. package/src/api/open-api/account.ts +0 -4
  245. package/src/api/open-api/address.ts +0 -4
  246. package/src/api/open-api/authorize.ts +0 -5
  247. package/src/api/open-api/card.ts +0 -5
  248. package/src/api/open-api/channels-live.ts +0 -9
  249. package/src/api/open-api/customer-service.ts +0 -4
  250. package/src/api/open-api/facial.ts +0 -7
  251. package/src/api/open-api/favorites.ts +0 -5
  252. package/src/api/open-api/group.ts +0 -4
  253. package/src/api/open-api/index.ts +0 -18
  254. package/src/api/open-api/invoice.ts +0 -5
  255. package/src/api/open-api/license-plate.ts +0 -4
  256. package/src/api/open-api/login.ts +0 -6
  257. package/src/api/open-api/red-package.ts +0 -4
  258. package/src/api/open-api/settings.ts +0 -5
  259. package/src/api/open-api/soter.ts +0 -6
  260. package/src/api/open-api/subscribe-message.ts +0 -4
  261. package/src/api/open-api/user-info.ts +0 -5
  262. package/src/api/open-api/werun.ts +0 -5
  263. package/src/api/payment/index.ts +0 -5
  264. package/src/api/route/index.ts +0 -10
  265. package/src/api/share/index.ts +0 -13
  266. package/src/api/storage/background-fetch.ts +0 -7
  267. package/src/api/storage/index.ts +0 -182
  268. package/src/api/swan/index.ts +0 -31
  269. package/src/api/taro.ts +0 -84
  270. package/src/api/ui/animation/index.ts +0 -356
  271. package/src/api/ui/background.ts +0 -5
  272. package/src/api/ui/custom-component.ts +0 -4
  273. package/src/api/ui/fonts.ts +0 -64
  274. package/src/api/ui/index.ts +0 -12
  275. package/src/api/ui/interaction/actionSheet.ts +0 -212
  276. package/src/api/ui/interaction/index.ts +0 -302
  277. package/src/api/ui/interaction/modal.ts +0 -237
  278. package/src/api/ui/interaction/toast.ts +0 -220
  279. package/src/api/ui/menu.ts +0 -4
  280. package/src/api/ui/navigation-bar/index.ts +0 -52
  281. package/src/api/ui/pull-down-refresh.ts +0 -28
  282. package/src/api/ui/scroll/index.ts +0 -85
  283. package/src/api/ui/sticky.ts +0 -4
  284. package/src/api/ui/tab-bar.ts +0 -327
  285. package/src/api/ui/window.ts +0 -38
  286. package/src/api/worker/index.ts +0 -4
  287. package/src/api/wxml/index.ts +0 -10
  288. package/src/api/wxml/nodesRef.ts +0 -56
  289. package/src/api/wxml/selectorQuery.ts +0 -220
  290. package/src/index.ts +0 -6
  291. package/src/utils/animation.ts +0 -15
  292. package/src/utils/handler.ts +0 -105
  293. package/src/utils/index.ts +0 -184
  294. package/src/utils/lodash.ts +0 -30
  295. package/src/utils/valid.ts +0 -8
@@ -1,237 +0,0 @@
1
- import { inlineStyle } from '../../../utils'
2
-
3
- export default class Modal {
4
- options = {
5
- title: '',
6
- content: '',
7
- showCancel: true,
8
- cancelText: '取消',
9
- cancelColor: '#000000',
10
- confirmText: '确定',
11
- confirmColor: '#3CC51F'
12
- }
13
-
14
- style = {
15
- maskStyle: {
16
- position: 'fixed',
17
- 'z-index': '1000',
18
- top: '0',
19
- right: '0',
20
- left: '0',
21
- bottom: '0',
22
- background: 'rgba(0,0,0,0.6)'
23
- },
24
- modalStyle: {
25
- 'z-index': '4999',
26
- position: 'fixed',
27
- top: '50%',
28
- left: '50%',
29
- transform: 'translate(-50%, -50%)',
30
- width: '80%',
31
- 'max-width': '300px',
32
- 'border-radius': '3px',
33
- 'text-align': 'center',
34
- 'line-height': '1.6',
35
- overflow: 'hidden',
36
- background: '#FFFFFF'
37
- },
38
- titleStyle: {
39
- padding: '20px 24px 9px',
40
- 'font-size': '18px'
41
- },
42
- textStyle: {
43
- padding: '0 24px 12px',
44
- 'min-height': '40px',
45
- 'font-size': '15px',
46
- 'line-height': '1.3',
47
- color: '#808080'
48
- },
49
- footStyle: {
50
- position: 'relative',
51
- 'line-height': '48px',
52
- 'font-size': '18px',
53
- display: 'flex'
54
- },
55
- btnStyle: {
56
- position: 'relative',
57
- '-webkit-box-flex': '1',
58
- '-webkit-flex': '1',
59
- flex: '1'
60
- }
61
- }
62
-
63
- el: HTMLDivElement
64
- title: HTMLDivElement
65
- text: HTMLDivElement
66
- cancel: HTMLDivElement
67
- confirm: HTMLDivElement
68
- hideOpacityTimer: ReturnType<typeof setTimeout>
69
- hideDisplayTimer: ReturnType<typeof setTimeout>
70
-
71
- create (options = {}) {
72
- return new Promise<string>((resolve) => {
73
- // style
74
- const { maskStyle, modalStyle, titleStyle, textStyle, footStyle, btnStyle } = this.style
75
-
76
- // configuration
77
- const config = {
78
- ...this.options,
79
- ...options
80
- }
81
-
82
- // wrapper
83
- this.el = document.createElement('div')
84
- this.el.className = 'taro__modal'
85
- this.el.style.opacity = '0'
86
- this.el.style.transition = 'opacity 0.2s linear'
87
-
88
- // mask
89
- const mask = document.createElement('div')
90
- mask.className = 'taro-modal__mask'
91
- mask.setAttribute('style', inlineStyle(maskStyle))
92
-
93
- // modal
94
- const modal = document.createElement('div')
95
- modal.className = 'taro-modal__content'
96
- modal.setAttribute('style', inlineStyle(modalStyle))
97
-
98
- // title
99
- const titleCSS = config.title ? titleStyle : {
100
- ...titleStyle,
101
- display: 'none'
102
- }
103
- this.title = document.createElement('div')
104
-
105
- this.title.className = 'taro-modal__title'
106
- this.title.setAttribute('style', inlineStyle(titleCSS))
107
- this.title.textContent = config.title
108
-
109
- // text
110
- const textCSS = config.title ? textStyle : {
111
- ...textStyle,
112
- padding: '40px 20px 26px',
113
- color: '#353535'
114
- }
115
- this.text = document.createElement('div')
116
- this.text.className = 'taro-modal__text'
117
- this.text.setAttribute('style', inlineStyle(textCSS))
118
- this.text.textContent = config.content
119
-
120
- // foot
121
- const foot = document.createElement('div')
122
- foot.className = 'taro-modal__foot'
123
- foot.setAttribute('style', inlineStyle(footStyle))
124
-
125
- // cancel button
126
- const cancelCSS = {
127
- ...btnStyle,
128
- color: config.cancelColor,
129
- display: config.showCancel ? 'block' : 'none'
130
- }
131
- this.cancel = document.createElement('div')
132
- this.cancel.className = 'taro-model__btn taro-model__cancel'
133
- this.cancel.setAttribute('style', inlineStyle(cancelCSS))
134
- this.cancel.textContent = config.cancelText
135
- this.cancel.onclick = () => {
136
- this.hide()
137
- resolve('cancel')
138
- }
139
-
140
- // confirm button
141
- this.confirm = document.createElement('div')
142
- this.confirm.className = 'taro-model__btn taro-model__confirm'
143
- this.confirm.setAttribute('style', inlineStyle(btnStyle))
144
- this.confirm.style.color = config.confirmColor
145
- this.confirm.textContent = config.confirmText
146
- this.confirm.onclick = () => {
147
- this.hide()
148
- resolve('confirm')
149
- }
150
-
151
- // result
152
- foot.appendChild(this.cancel)
153
- foot.appendChild(this.confirm)
154
- modal.appendChild(this.title)
155
- modal.appendChild(this.text)
156
- modal.appendChild(foot)
157
- this.el.appendChild(mask)
158
- this.el.appendChild(modal)
159
-
160
- // show immediately
161
- document.body.appendChild(this.el)
162
- setTimeout(() => { this.el.style.opacity = '1' }, 0)
163
- })
164
- }
165
-
166
- show (options = {}) {
167
- return new Promise<string>((resolve) => {
168
- const config = {
169
- ...this.options,
170
- ...options
171
- }
172
-
173
- if (this.hideOpacityTimer) clearTimeout(this.hideOpacityTimer)
174
- if (this.hideDisplayTimer) clearTimeout(this.hideDisplayTimer)
175
-
176
- // title & text
177
- const { textStyle } = this.style
178
-
179
- if (config.title) {
180
- this.title.textContent = config.title
181
- // none => block
182
- this.title.style.display = 'block'
183
- this.text.setAttribute('style', inlineStyle(textStyle))
184
- } else {
185
- // block => none
186
- this.title.style.display = 'none'
187
- const textCSS = {
188
- ...textStyle,
189
- padding: '40px 20px 26px',
190
- color: '#353535'
191
- }
192
- this.text.setAttribute('style', inlineStyle(textCSS))
193
- }
194
-
195
- this.text.textContent = config.content || ''
196
-
197
- // showCancel
198
- this.cancel.style.display = config.showCancel ? 'block' : 'none'
199
-
200
- // cancelText
201
- this.cancel.textContent = config.cancelText || ''
202
-
203
- // cancelColor
204
- this.cancel.style.color = config.cancelColor || ''
205
-
206
- // confirmText
207
- this.confirm.textContent = config.confirmText || ''
208
-
209
- // confirmColor
210
- this.confirm.style.color = config.confirmColor || ''
211
-
212
- // cbs
213
- this.cancel.onclick = () => {
214
- this.hide()
215
- resolve('cancel')
216
- }
217
- this.confirm.onclick = () => {
218
- this.hide()
219
- resolve('confirm')
220
- }
221
-
222
- // show
223
- this.el.style.display = 'block'
224
- setTimeout(() => { this.el.style.opacity = '1' }, 0)
225
- })
226
- }
227
-
228
- hide () {
229
- if (this.hideOpacityTimer) clearTimeout(this.hideOpacityTimer)
230
- if (this.hideDisplayTimer) clearTimeout(this.hideDisplayTimer)
231
-
232
- this.hideOpacityTimer = setTimeout(() => {
233
- this.el.style.opacity = '0'
234
- this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none' }, 200)
235
- }, 0)
236
- }
237
- }
@@ -1,220 +0,0 @@
1
- import { inlineStyle } from '../../../utils'
2
-
3
- export default class Toast {
4
- options = {
5
- title: '',
6
- icon: 'none',
7
- image: '',
8
- duration: 1500,
9
- mask: false
10
- }
11
-
12
- style = {
13
- maskStyle: {
14
- position: 'fixed',
15
- 'z-index': '1000',
16
- top: '0',
17
- right: '0',
18
- left: '0',
19
- bottom: '0'
20
- },
21
- toastStyle: {
22
- 'z-index': '5000',
23
- 'box-sizing': 'border-box',
24
- display: 'flex',
25
- 'flex-direction': 'column',
26
- 'justify-content': 'center',
27
- '-webkit-justify-content': 'center',
28
- position: 'fixed',
29
- top: '50%',
30
- left: '50%',
31
- 'min-width': '120px',
32
- 'max-width': '200px',
33
- 'min-height': '120px',
34
- padding: '15px',
35
- transform: 'translate(-50%, -50%)',
36
- 'border-radius': '5px',
37
- 'text-align': 'center',
38
- 'line-height': '1.6',
39
- color: '#FFFFFF',
40
- background: 'rgba(17, 17, 17, 0.7)'
41
- },
42
- successStyle: {
43
- margin: '6px auto',
44
- width: '38px',
45
- height: '38px',
46
- background: 'transparent url(data:image/svg+xml;base64,PHN2ZyB0PSIxNjM5NTQ4OTYzMjA0IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjQzNDgiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cGF0aCBkPSJNMjE5Ljk1MiA1MTIuNTc2bDIxMC40MzIgMjEwLjQzMi00NS4yNDggNDUuMjU2LTIxMC40MzItMjEwLjQzMnoiIHAtaWQ9IjQzNDkiIGZpbGw9IiNmZmZmZmYiPjwvcGF0aD48cGF0aCBkPSJNNzk5LjY3MiAyNjIuMjY0bDQ1LjI1NiA0NS4yNTYtNDYwLjQ2NCA0NjAuNDY0LTQ1LjI1Ni00NS4yNTZ6IiBwLWlkPSI0MzUwIiBmaWxsPSIjZmZmZmZmIj48L3BhdGg+PC9zdmc+) no-repeat',
47
- 'background-size': '100%'
48
- },
49
- errrorStyle: {
50
- margin: '6px auto',
51
- width: '38px',
52
- height: '38px',
53
- background: 'transparent url(data:image/svg+xml;base64,PHN2ZyB0PSIxNjM5NTUxMDU1MTgzIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjE0MDc2IiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCI+PHBhdGggZD0iTTUxMiA2NEMyNjQuNTggNjQgNjQgMjY0LjU4IDY0IDUxMnMyMDAuNTggNDQ4IDQ0OCA0NDggNDQ4LTIwMC41OCA0NDgtNDQ4Uzc1OS40MiA2NCA1MTIgNjR6IG0wIDc1MmEzNiAzNiAwIDEgMSAzNi0zNiAzNiAzNiAwIDAgMS0zNiAzNnogbTUxLjgzLTU1MS45NUw1NDggNjM2YTM2IDM2IDAgMCAxLTcyIDBsLTE1LjgzLTM3MS45NWMtMC4xLTEuMzMtMC4xNy0yLjY4LTAuMTctNC4wNWE1MiA1MiAwIDAgMSAxMDQgMGMwIDEuMzctMC4wNyAyLjcyLTAuMTcgNC4wNXoiIHAtaWQ9IjE0MDc3IiBmaWxsPSIjZmZmZmZmIj48L3BhdGg+PC9zdmc+) no-repeat',
54
- 'background-size': '100%'
55
- },
56
- loadingStyle: {
57
- margin: '6px auto',
58
- width: '38px',
59
- height: '38px',
60
- '-webkit-animation': 'taroLoading 1s steps(12, end) infinite',
61
- animation: 'taroLoading 1s steps(12, end) infinite',
62
- background: 'transparent url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTlFOUU5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTMwKSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iIzk4OTY5NyIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgzMCAxMDUuOTggNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjOUI5OTlBIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDYwIDc1Ljk4IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0EzQTFBMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSg5MCA2NSA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNBQkE5QUEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoMTIwIDU4LjY2IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0IyQjJCMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgxNTAgNTQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjQkFCOEI5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=) no-repeat',
63
- 'background-size': '100%'
64
- },
65
- imageStyle: {
66
- margin: '6px auto',
67
- width: '40px',
68
- height: '40px',
69
- background: 'transparent no-repeat',
70
- 'background-size': '100%'
71
- },
72
- textStyle: {
73
- margin: '0',
74
- 'font-size': '16px'
75
- }
76
- }
77
-
78
- el: HTMLDivElement
79
- mask: HTMLDivElement
80
- icon: HTMLParagraphElement
81
- toast: HTMLDivElement
82
- title: HTMLParagraphElement
83
- type: any
84
- hideOpacityTimer: ReturnType<typeof setTimeout>
85
- hideDisplayTimer: ReturnType<typeof setTimeout>
86
-
87
- create (options = {}, _type: 'loading' | 'toast' = 'toast') {
88
- // style
89
- const { maskStyle, toastStyle, successStyle, errrorStyle, loadingStyle, imageStyle, textStyle } = this.style
90
-
91
- // configuration
92
- const config = {
93
- ...this.options,
94
- ...options,
95
- _type
96
- }
97
-
98
- // wrapper
99
- this.el = document.createElement('div')
100
- this.el.className = 'taro__toast'
101
- this.el.style.opacity = '0'
102
- this.el.style.transition = 'opacity 0.1s linear'
103
-
104
- // mask
105
- this.mask = document.createElement('div')
106
- this.mask.setAttribute('style', inlineStyle(maskStyle))
107
- this.mask.style.display = config.mask ? 'block' : 'none'
108
-
109
- // icon
110
- this.icon = document.createElement('p')
111
- if (config.image) {
112
- this.icon.setAttribute('style', inlineStyle({
113
- ...imageStyle,
114
- 'background-image': `url(${config.image})`
115
- }))
116
- } else {
117
- const iconStyle = config.icon === 'loading' ? loadingStyle : config.icon === 'error' ? errrorStyle : successStyle
118
- this.icon.setAttribute('style', inlineStyle({
119
- ...iconStyle,
120
- ...(config.icon === 'none' ? { display: 'none' } : {})
121
- }))
122
- }
123
-
124
- // toast
125
- this.toast = document.createElement('div')
126
- this.toast.setAttribute('style', inlineStyle({
127
- ...toastStyle,
128
- ...(config.icon === 'none' ? {
129
- 'min-height': '0',
130
- padding: '10px 15px'
131
- } : {})
132
- }))
133
-
134
- // title
135
- this.title = document.createElement('p')
136
- this.title.setAttribute('style', inlineStyle(textStyle))
137
- this.title.textContent = config.title
138
-
139
- // result
140
- this.toast.appendChild(this.icon)
141
- this.toast.appendChild(this.title)
142
- this.el.appendChild(this.mask)
143
- this.el.appendChild(this.toast)
144
-
145
- // show immediately
146
- document.body.appendChild(this.el)
147
- setTimeout(() => { this.el.style.opacity = '1' }, 0)
148
- this.type = config._type
149
-
150
- // disappear after duration
151
- config.duration >= 0 && this.hide(config.duration, this.type)
152
-
153
- return ''
154
- }
155
-
156
- show (options = {}, _type: 'loading' | 'toast' = 'toast') {
157
- const config = {
158
- ...this.options,
159
- ...options,
160
- _type
161
- }
162
-
163
- if (this.hideOpacityTimer) clearTimeout(this.hideOpacityTimer)
164
- if (this.hideDisplayTimer) clearTimeout(this.hideDisplayTimer)
165
-
166
- // title
167
- this.title.textContent = config.title || ''
168
-
169
- // mask
170
- this.mask.style.display = config.mask ? 'block' : 'none'
171
-
172
- // image
173
- const { toastStyle, successStyle, errrorStyle, loadingStyle, imageStyle } = this.style
174
- if (config.image) {
175
- this.icon.setAttribute('style', inlineStyle({
176
- ...imageStyle,
177
- 'background-image': `url(${config.image})`
178
- }))
179
- } else {
180
- if (!config.image && config.icon) {
181
- const iconStyle = config.icon === 'loading' ? loadingStyle : config.icon === 'error' ? errrorStyle : successStyle
182
- this.icon.setAttribute('style', inlineStyle({
183
- ...iconStyle,
184
- ...(config.icon === 'none' ? { display: 'none' } : {})
185
- }))
186
- }
187
- }
188
-
189
- // toast
190
- this.toast.setAttribute('style', inlineStyle({
191
- ...toastStyle,
192
- ...(config.icon === 'none' ? {
193
- 'min-height': '0',
194
- padding: '10px 15px'
195
- } : {})
196
- }))
197
-
198
- // show
199
- this.el.style.display = 'block'
200
- setTimeout(() => { this.el.style.opacity = '1' }, 0)
201
- this.type = config._type
202
-
203
- // disappear after duration
204
- config.duration >= 0 && this.hide(config.duration, this.type)
205
-
206
- return ''
207
- }
208
-
209
- hide (duration = 0, type) {
210
- if (this.type !== type) return
211
-
212
- if (this.hideOpacityTimer) clearTimeout(this.hideOpacityTimer)
213
- if (this.hideDisplayTimer) clearTimeout(this.hideDisplayTimer)
214
-
215
- this.hideOpacityTimer = setTimeout(() => {
216
- this.el.style.opacity = '0'
217
- this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none' }, 100)
218
- }, duration)
219
- }
220
- }
@@ -1,4 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // 菜单
4
- export const getMenuButtonBoundingClientRect = temporarilyNotSupport('getMenuButtonBoundingClientRect')
@@ -1,52 +0,0 @@
1
- import Taro from '@tarojs/api'
2
-
3
- import { getParameterError, shouldBeObject, temporarilyNotSupport } from '../../../utils'
4
- import { MethodHandler } from '../../../utils/handler'
5
-
6
- // 导航栏
7
- export const showNavigationBarLoading = temporarilyNotSupport('showNavigationBarLoading')
8
-
9
- export function setNavigationBarTitle (options) {
10
- // options must be an Object
11
- const isObject = shouldBeObject(options)
12
- if (!isObject.flag) {
13
- const res = { errMsg: `setNavigationBarTitle:fail ${isObject.msg}` }
14
- console.error(res.errMsg)
15
- return Promise.reject(res)
16
- }
17
-
18
- const { title, success, fail, complete } = options
19
- const handle = new MethodHandler({ name: 'setNavigationBarTitle', success, fail, complete })
20
-
21
- if (!title || typeof title !== 'string') {
22
- return handle.fail({
23
- errMsg: getParameterError({
24
- para: 'title',
25
- correct: 'String',
26
- wrong: title
27
- })
28
- })
29
- }
30
-
31
- if (document.title !== title) {
32
- document.title = title
33
- }
34
-
35
- return handle.success()
36
- }
37
-
38
- /**
39
- * 设置页面导航条颜色
40
- */
41
- export const setNavigationBarColor: typeof Taro.setNavigationBarColor = (options) => {
42
- const { backgroundColor, success, fail, complete } = options
43
- const handle = new MethodHandler({ name: 'setNavigationBarColor', success, fail, complete })
44
- const meta = document.createElement('meta')
45
- meta.setAttribute('name', 'theme-color')
46
- meta.setAttribute('content', backgroundColor)
47
- document.head.appendChild(meta)
48
- return handle.success()
49
- }
50
-
51
- export const hideNavigationBarLoading = temporarilyNotSupport('hideNavigationBarLoading')
52
- export const hideHomeButton = temporarilyNotSupport('hideHomeButton')
@@ -1,28 +0,0 @@
1
- import Taro from '@tarojs/api'
2
-
3
- import { MethodHandler } from '../../utils/handler'
4
- /**
5
- * 开始下拉刷新。调用后触发下拉刷新动画,效果与用户手动下拉刷新一致。
6
- */
7
- export const startPullDownRefresh: typeof Taro.startPullDownRefresh = function ({ success, fail, complete } = {}) {
8
- const handle = new MethodHandler({ name: 'startPullDownRefresh', success, fail, complete })
9
- return new Promise((resolve, reject) => {
10
- Taro.eventCenter.trigger('__taroStartPullDownRefresh', {
11
- successHandler: (res = {}) => handle.success(res, resolve as any),
12
- errorHandler: (res = {}) => handle.fail(res, reject as any)
13
- })
14
- })
15
- }
16
-
17
- /**
18
- * 停止当前页面下拉刷新。
19
- */
20
- export const stopPullDownRefresh: typeof Taro.stopPullDownRefresh = function ({ success, fail, complete } = {}) {
21
- const handle = new MethodHandler({ name: 'stopPullDownRefresh', success, fail, complete })
22
- return new Promise((resolve, reject) => {
23
- Taro.eventCenter.trigger('__taroStopPullDownRefresh', {
24
- successHandler: (res = {}) => handle.success(res, resolve as any),
25
- errorHandler: (res = {}) => handle.fail(res, reject as any)
26
- })
27
- })
28
- }
@@ -1,85 +0,0 @@
1
- import Taro from '@tarojs/api'
2
- import { Current } from '@tarojs/runtime'
3
-
4
- import { easeInOut, getTimingFunc } from '../../../utils'
5
- import { MethodHandler } from '../../../utils/handler'
6
-
7
- let timer: ReturnType<typeof setTimeout>
8
- const FRAME_DURATION = 17
9
-
10
- /**
11
- * 将页面滚动到目标位置
12
- */
13
- export const pageScrollTo: typeof Taro.pageScrollTo = ({ scrollTop, selector = '', duration = 300, success, fail, complete }) => {
14
- let scrollFunc
15
- const handle = new MethodHandler({ name: 'pageScrollTo', success, fail, complete })
16
- return new Promise((resolve, reject) => {
17
- try {
18
- if (scrollTop === undefined && !selector) {
19
- return handle.fail({
20
- errMsg: 'scrollTop" 或 "selector" 需要其之一'
21
- }, reject)
22
- }
23
-
24
- const id = Current.page?.path?.replace(/([^a-z0-9\u00a0-\uffff_-])/ig, '\\$1')
25
- const el: HTMLDivElement | null = (id
26
- ? document.querySelector(`.taro_page#${id}`)
27
- : document.querySelector('.taro_page') ||
28
- document.querySelector('.taro_router')) as HTMLDivElement
29
-
30
- if (!scrollFunc) {
31
- if (!el) {
32
- scrollFunc = pos => {
33
- if (pos === undefined) {
34
- return window.pageYOffset
35
- } else {
36
- window.scrollTo(0, pos)
37
- }
38
- }
39
- } else {
40
- scrollFunc = pos => {
41
- if (pos === undefined) {
42
- return el.scrollTop
43
- } else {
44
- el.scrollTop = pos
45
- }
46
- }
47
- }
48
- }
49
-
50
- if (scrollTop && selector) {
51
- console.warn('"scrollTop" 或 "selector" 建议只设一个值,全部设置会忽略selector')
52
- }
53
- const from = scrollFunc()
54
- let to: number
55
- if (typeof scrollTop === 'number') {
56
- to = scrollTop
57
- } else {
58
- const el = document.querySelector(selector) as HTMLElement
59
- to = el?.offsetTop || 0
60
- }
61
- const delta = to - from
62
-
63
- const frameCnt = duration / FRAME_DURATION
64
- const easeFunc = getTimingFunc(easeInOut, frameCnt)
65
-
66
- const scroll = (frame = 0) => {
67
- const dest = from + delta * easeFunc(frame)
68
- scrollFunc(dest)
69
- if (frame < frameCnt) {
70
- timer && clearTimeout(timer)
71
- timer = setTimeout(() => {
72
- scroll(frame + 1)
73
- }, FRAME_DURATION)
74
- } else {
75
- return handle.success({}, resolve)
76
- }
77
- }
78
- scroll()
79
- } catch (e) {
80
- return handle.fail({
81
- errMsg: e.message
82
- }, reject)
83
- }
84
- })
85
- }
@@ -1,4 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // 置顶
4
- export const setTopBarText = temporarilyNotSupport('setTopBarText')