@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.
- package/dist/api/ad/index.d.ts +6 -0
- package/dist/api/ai/facial.d.ts +9 -0
- package/dist/api/ai/index.d.ts +2 -0
- package/dist/api/ai/visual.d.ts +6 -0
- package/dist/api/alipay/index.d.ts +3 -0
- package/dist/api/base/crypto.d.ts +3 -0
- package/dist/api/base/debug.d.ts +9 -0
- package/dist/api/base/index.d.ts +12 -0
- package/dist/api/base/performance.d.ts +6 -0
- package/dist/api/base/system.d.ts +27 -0
- package/dist/api/base/system.js +2 -2
- package/dist/api/base/update.d.ts +6 -0
- package/dist/api/base/weapp/app-event.d.ts +41 -0
- package/dist/api/base/weapp/app-event.js +55 -4
- package/dist/api/base/weapp/life-cycle.d.ts +6 -0
- package/dist/api/canvas/CanvasContext.d.ts +104 -0
- package/dist/api/canvas/canvasGetImageData.d.ts +5 -0
- package/dist/api/canvas/canvasPutImageData.d.ts +6 -0
- package/dist/api/canvas/canvasToTempFilePath.d.ts +6 -0
- package/dist/api/canvas/canvasToTempFilePath.js +1 -1
- package/dist/api/canvas/createCanvasContext.d.ts +5 -0
- package/dist/api/canvas/index.d.ts +12 -0
- package/dist/api/cloud/index.d.ts +31 -0
- package/dist/api/data-analysis/index.d.ts +12 -0
- package/dist/api/device/accelerometer.d.ts +17 -0
- package/dist/api/device/accessibility.d.ts +3 -0
- package/dist/api/device/battery.d.ts +5 -0
- package/dist/api/device/bluetooth-ble.d.ts +48 -0
- package/dist/api/device/bluetooth-peripheral.d.ts +9 -0
- package/dist/api/device/bluetooth.d.ts +39 -0
- package/dist/api/device/calendar.d.ts +6 -0
- package/dist/api/device/clipboard.d.ts +15 -0
- package/dist/api/device/compass.d.ts +17 -0
- package/dist/api/device/contact.d.ts +6 -0
- package/dist/api/device/crypto.d.ts +3 -0
- package/dist/api/device/gyroscope.d.ts +12 -0
- package/dist/api/device/iBeacon.d.ts +21 -0
- package/dist/api/device/index.d.ts +23 -0
- package/dist/api/device/keyboard.d.ts +12 -0
- package/dist/api/device/memory.d.ts +6 -0
- package/dist/api/device/motion.d.ts +17 -0
- package/dist/api/device/network.d.ts +20 -0
- package/dist/api/device/nfc.d.ts +21 -0
- package/dist/api/device/phone.d.ts +2 -0
- package/dist/api/device/scan.d.ts +3 -0
- package/dist/api/device/screen.d.ts +18 -0
- package/dist/api/device/vibrate.d.ts +9 -0
- package/dist/api/device/vibrate.js +5 -7
- package/dist/api/device/wifi.d.ts +33 -0
- package/dist/api/ext/index.d.ts +6 -0
- package/dist/api/files/index.d.ts +24 -0
- package/dist/api/framework/index.d.ts +4 -0
- package/dist/api/index.d.ts +24 -0
- package/dist/api/location/chooseLocation.d.ts +6 -0
- package/dist/api/location/getLocation.d.ts +2 -0
- package/dist/api/location/index.d.ts +32 -0
- package/dist/api/location/index.js +1 -0
- package/dist/api/media/EditorContext.d.ts +42 -0
- package/dist/api/media/audio/InnerAudioContext.d.ts +58 -0
- package/dist/api/media/audio/InnerAudioContext.js +1 -1
- package/dist/api/media/audio/index.d.ts +29 -0
- package/dist/api/media/background-audio/BackgroundAudioManager.d.ts +71 -0
- package/dist/api/media/background-audio/index.d.ts +29 -0
- package/dist/api/media/camera.d.ts +3 -0
- package/dist/api/media/image/chooseImage.d.ts +5 -0
- package/dist/api/media/image/getImageInfo.d.ts +5 -0
- package/dist/api/media/image/index.d.ts +15 -0
- package/dist/api/media/image/previewImage.d.ts +8 -0
- package/dist/api/media/index.d.ts +12 -0
- package/dist/api/media/live.d.ts +6 -0
- package/dist/api/media/map.d.ts +3 -0
- package/dist/api/media/media-recorder.d.ts +3 -0
- package/dist/api/media/recorder.d.ts +9 -0
- package/dist/api/media/video/index.d.ts +24 -0
- package/dist/api/media/video-decoder.d.ts +3 -0
- package/dist/api/media/video-processing.d.ts +3 -0
- package/dist/api/media/voip.d.ts +42 -0
- package/dist/api/navigate/index.d.ts +12 -0
- package/dist/api/network/download.d.ts +6 -0
- package/dist/api/network/download.js +1 -0
- package/dist/api/network/index.d.ts +7 -0
- package/dist/api/network/mdns.d.ts +30 -0
- package/dist/api/network/request/index.d.ts +4 -0
- package/dist/api/network/tcp.d.ts +3 -0
- package/dist/api/network/udp.d.ts +3 -0
- package/dist/api/network/upload.d.ts +5 -0
- package/dist/api/network/upload.js +2 -1
- package/{src/api/network/utils.ts → dist/api/network/utils.d.ts} +44 -71
- package/dist/api/network/utils.js +1 -0
- package/dist/api/network/websocket/index.d.ts +7 -0
- package/dist/api/network/websocket/socketTask.d.ts +25 -0
- package/dist/api/open-api/account.d.ts +3 -0
- package/dist/api/open-api/address.d.ts +3 -0
- package/dist/api/open-api/authorize.d.ts +6 -0
- package/dist/api/open-api/card.d.ts +6 -0
- package/dist/api/open-api/channels-live.d.ts +18 -0
- package/dist/api/open-api/customer-service.d.ts +3 -0
- package/dist/api/open-api/facial.d.ts +12 -0
- package/dist/api/open-api/favorites.d.ts +6 -0
- package/dist/api/open-api/group.d.ts +3 -0
- package/dist/api/open-api/index.d.ts +18 -0
- package/dist/api/open-api/invoice.d.ts +6 -0
- package/dist/api/open-api/license-plate.d.ts +3 -0
- package/dist/api/open-api/login.d.ts +9 -0
- package/dist/api/open-api/red-package.d.ts +3 -0
- package/dist/api/open-api/settings.d.ts +6 -0
- package/dist/api/open-api/soter.d.ts +9 -0
- package/dist/api/open-api/subscribe-message.d.ts +3 -0
- package/dist/api/open-api/user-info.d.ts +6 -0
- package/dist/api/open-api/werun.d.ts +6 -0
- package/dist/api/payment/index.d.ts +6 -0
- package/dist/api/route/index.d.ts +1 -0
- package/dist/api/share/index.d.ts +30 -0
- package/dist/api/storage/background-fetch.d.ts +12 -0
- package/dist/api/storage/index.d.ts +18 -0
- package/dist/api/swan/index.d.ts +63 -0
- package/dist/api/taro.d.ts +12 -0
- package/dist/api/ui/animation/index.d.ts +2 -0
- package/dist/api/ui/background.d.ts +6 -0
- package/dist/api/ui/custom-component.d.ts +1 -0
- package/dist/api/ui/fonts.d.ts +2 -0
- package/dist/api/ui/index.d.ts +12 -0
- package/dist/api/ui/interaction/actionSheet.d.ts +61 -0
- package/dist/api/ui/interaction/index.d.ts +14 -0
- package/dist/api/ui/interaction/modal.d.ts +69 -0
- package/dist/api/ui/interaction/modal.js +1 -0
- package/dist/api/ui/interaction/toast.d.ts +85 -0
- package/dist/api/ui/menu.d.ts +3 -0
- package/dist/api/ui/navigation-bar/index.d.ts +15 -0
- package/dist/api/ui/navigation-bar/index.js +2 -3
- package/dist/api/ui/pull-down-refresh.d.ts +9 -0
- package/dist/api/ui/scroll/index.d.ts +5 -0
- package/dist/api/ui/sticky.d.ts +3 -0
- package/dist/api/ui/tab-bar.d.ts +34 -0
- package/dist/api/ui/window.d.ts +15 -0
- package/dist/api/worker/index.d.ts +3 -0
- package/dist/api/wxml/index.d.ts +5 -0
- package/dist/api/wxml/nodesRef.d.ts +13 -0
- package/dist/api/wxml/selectorQuery.d.ts +24 -0
- package/dist/api/wxml/selectorQuery.js +1 -1
- package/dist/index.cjs.d.ts +1373 -0
- package/dist/index.cjs.js +105 -81
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.d.ts +1373 -0
- package/dist/index.esm.js +93 -69
- package/dist/index.esm.js.map +1 -1
- package/dist/taroApis.d.ts +1364 -0
- package/dist/taroApis.js +1 -1
- package/dist/utils/animation.d.ts +6 -0
- package/dist/utils/handler.d.ts +48 -0
- package/dist/utils/index.d.ts +39 -0
- package/dist/utils/index.js +3 -7
- package/dist/utils/lodash.d.ts +2 -0
- package/dist/utils/valid.d.ts +2 -0
- package/package.json +17 -19
- package/types/api.d.ts +4 -0
- package/types/define.d.ts +2 -0
- package/types/index.d.ts +33 -0
- package/types/overlay.d.ts +9 -0
- package/LICENSE +0 -21
- package/src/api/ad/index.ts +0 -5
- package/src/api/ai/facial.ts +0 -6
- package/src/api/ai/index.ts +0 -2
- package/src/api/ai/visual.ts +0 -7
- package/src/api/alipay/index.ts +0 -4
- package/src/api/base/crypto.ts +0 -4
- package/src/api/base/debug.ts +0 -5
- package/src/api/base/index.ts +0 -23
- package/src/api/base/performance.ts +0 -5
- package/src/api/base/system.ts +0 -207
- package/src/api/base/update.ts +0 -5
- package/src/api/base/weapp/app-event.ts +0 -19
- package/src/api/base/weapp/life-cycle.ts +0 -5
- package/src/api/canvas/CanvasContext.ts +0 -233
- package/src/api/canvas/canvasGetImageData.ts +0 -28
- package/src/api/canvas/canvasPutImageData.ts +0 -25
- package/src/api/canvas/canvasToTempFilePath.ts +0 -25
- package/src/api/canvas/createCanvasContext.ts +0 -19
- package/src/api/canvas/index.ts +0 -18
- package/src/api/cloud/index.ts +0 -32
- package/src/api/data-analysis/index.ts +0 -6
- package/src/api/device/accelerometer.ts +0 -79
- package/src/api/device/accessibility.ts +0 -4
- package/src/api/device/battery.ts +0 -23
- package/src/api/device/bluetooth-ble.ts +0 -19
- package/src/api/device/bluetooth-peripheral.ts +0 -6
- package/src/api/device/bluetooth.ts +0 -16
- package/src/api/device/calendar.ts +0 -5
- package/src/api/device/clipboard.ts +0 -68
- package/src/api/device/compass.ts +0 -83
- package/src/api/device/contact.ts +0 -5
- package/src/api/device/crypto.ts +0 -4
- package/src/api/device/gyroscope.ts +0 -7
- package/src/api/device/iBeacon.ts +0 -10
- package/src/api/device/index.ts +0 -23
- package/src/api/device/keyboard.ts +0 -7
- package/src/api/device/memory.ts +0 -5
- package/src/api/device/motion.ts +0 -77
- package/src/api/device/network.ts +0 -90
- package/src/api/device/nfc.ts +0 -10
- package/src/api/device/phone.ts +0 -31
- package/src/api/device/scan.ts +0 -11
- package/src/api/device/screen.ts +0 -9
- package/src/api/device/vibrate.ts +0 -37
- package/src/api/device/wifi.ts +0 -14
- package/src/api/ext/index.ts +0 -5
- package/src/api/files/index.ts +0 -11
- package/src/api/framework/index.ts +0 -10
- package/src/api/index.ts +0 -24
- package/src/api/location/chooseLocation.ts +0 -117
- package/src/api/location/getLocation.ts +0 -81
- package/src/api/location/index.ts +0 -22
- package/src/api/location/style.css +0 -79
- package/src/api/media/EditorContext.ts +0 -32
- package/src/api/media/audio/InnerAudioContext.ts +0 -99
- package/src/api/media/audio/index.ts +0 -21
- package/src/api/media/background-audio/BackgroundAudioManager.ts +0 -104
- package/src/api/media/background-audio/index.ts +0 -17
- package/src/api/media/camera.ts +0 -4
- package/src/api/media/image/chooseImage.ts +0 -95
- package/src/api/media/image/getImageInfo.ts +0 -50
- package/src/api/media/image/index.ts +0 -13
- package/src/api/media/image/previewImage.ts +0 -80
- package/src/api/media/index.ts +0 -12
- package/src/api/media/live.ts +0 -5
- package/src/api/media/map.ts +0 -4
- package/src/api/media/media-recorder.ts +0 -4
- package/src/api/media/recorder.ts +0 -6
- package/src/api/media/video/index.ts +0 -82
- package/src/api/media/video-decoder.ts +0 -4
- package/src/api/media/video-processing.ts +0 -4
- package/src/api/media/voip.ts +0 -17
- package/src/api/navigate/index.ts +0 -7
- package/src/api/network/download.ts +0 -141
- package/src/api/network/index.ts +0 -7
- package/src/api/network/mdns.ts +0 -13
- package/src/api/network/request/index.ts +0 -135
- package/src/api/network/tcp.ts +0 -4
- package/src/api/network/udp.ts +0 -4
- package/src/api/network/upload.ts +0 -169
- package/src/api/network/websocket/index.ts +0 -88
- package/src/api/network/websocket/socketTask.ts +0 -89
- package/src/api/open-api/account.ts +0 -4
- package/src/api/open-api/address.ts +0 -4
- package/src/api/open-api/authorize.ts +0 -5
- package/src/api/open-api/card.ts +0 -5
- package/src/api/open-api/channels-live.ts +0 -9
- package/src/api/open-api/customer-service.ts +0 -4
- package/src/api/open-api/facial.ts +0 -7
- package/src/api/open-api/favorites.ts +0 -5
- package/src/api/open-api/group.ts +0 -4
- package/src/api/open-api/index.ts +0 -18
- package/src/api/open-api/invoice.ts +0 -5
- package/src/api/open-api/license-plate.ts +0 -4
- package/src/api/open-api/login.ts +0 -6
- package/src/api/open-api/red-package.ts +0 -4
- package/src/api/open-api/settings.ts +0 -5
- package/src/api/open-api/soter.ts +0 -6
- package/src/api/open-api/subscribe-message.ts +0 -4
- package/src/api/open-api/user-info.ts +0 -5
- package/src/api/open-api/werun.ts +0 -5
- package/src/api/payment/index.ts +0 -5
- package/src/api/route/index.ts +0 -10
- package/src/api/share/index.ts +0 -13
- package/src/api/storage/background-fetch.ts +0 -7
- package/src/api/storage/index.ts +0 -182
- package/src/api/swan/index.ts +0 -31
- package/src/api/taro.ts +0 -84
- package/src/api/ui/animation/index.ts +0 -356
- package/src/api/ui/background.ts +0 -5
- package/src/api/ui/custom-component.ts +0 -4
- package/src/api/ui/fonts.ts +0 -64
- package/src/api/ui/index.ts +0 -12
- package/src/api/ui/interaction/actionSheet.ts +0 -212
- package/src/api/ui/interaction/index.ts +0 -302
- package/src/api/ui/interaction/modal.ts +0 -237
- package/src/api/ui/interaction/toast.ts +0 -220
- package/src/api/ui/menu.ts +0 -4
- package/src/api/ui/navigation-bar/index.ts +0 -52
- package/src/api/ui/pull-down-refresh.ts +0 -28
- package/src/api/ui/scroll/index.ts +0 -85
- package/src/api/ui/sticky.ts +0 -4
- package/src/api/ui/tab-bar.ts +0 -327
- package/src/api/ui/window.ts +0 -38
- package/src/api/worker/index.ts +0 -4
- package/src/api/wxml/index.ts +0 -10
- package/src/api/wxml/nodesRef.ts +0 -56
- package/src/api/wxml/selectorQuery.ts +0 -220
- package/src/index.ts +0 -6
- package/src/utils/animation.ts +0 -15
- package/src/utils/handler.ts +0 -105
- package/src/utils/index.ts +0 -184
- package/src/utils/lodash.ts +0 -30
- package/src/utils/valid.ts +0 -8
package/src/api/ui/fonts.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/api'
|
|
2
|
-
|
|
3
|
-
import { MethodHandler } from '../../utils/handler'
|
|
4
|
-
|
|
5
|
-
// 字体
|
|
6
|
-
export const loadFontFace: typeof Taro.loadFontFace = async options => {
|
|
7
|
-
options = Object.assign({ global: false }, options)
|
|
8
|
-
const { success, fail, complete, family, source, desc = {} } = options
|
|
9
|
-
const handle = new MethodHandler({ name: 'loadFontFace', success, fail, complete })
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
const fonts = document.fonts
|
|
12
|
-
if (fonts) {
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
const fontFace = new FontFace(family, source, desc)
|
|
15
|
-
try {
|
|
16
|
-
await fontFace.load()
|
|
17
|
-
fonts.add(fontFace)
|
|
18
|
-
return handle.success({})
|
|
19
|
-
} catch (error) {
|
|
20
|
-
return handle.fail({
|
|
21
|
-
errMsg: error.message || error
|
|
22
|
-
})
|
|
23
|
-
}
|
|
24
|
-
} else {
|
|
25
|
-
const style = document.createElement('style')
|
|
26
|
-
let innerText = `font-family:"${
|
|
27
|
-
family
|
|
28
|
-
}";src:${
|
|
29
|
-
source
|
|
30
|
-
};font-style:${
|
|
31
|
-
desc.style || 'normal'
|
|
32
|
-
};font-weight:${
|
|
33
|
-
desc.weight || 'normal'
|
|
34
|
-
};font-variant:${
|
|
35
|
-
desc.variant || 'normal'
|
|
36
|
-
};`
|
|
37
|
-
|
|
38
|
-
if (desc.ascentOverride) {
|
|
39
|
-
innerText += `ascent-override:${desc.ascentOverride};`
|
|
40
|
-
}
|
|
41
|
-
if (desc.descentOverride) {
|
|
42
|
-
innerText += `descent-override:${desc.descentOverride};`
|
|
43
|
-
}
|
|
44
|
-
if (desc.featureSettings) {
|
|
45
|
-
innerText += `font-feature-settings:${desc.featureSettings};`
|
|
46
|
-
}
|
|
47
|
-
if (desc.lineGapOverride) {
|
|
48
|
-
innerText += `line-gap-override:${desc.lineGapOverride};`
|
|
49
|
-
}
|
|
50
|
-
if (desc.stretch) {
|
|
51
|
-
innerText += `font-stretch:${desc.stretch};`
|
|
52
|
-
}
|
|
53
|
-
if (desc.unicodeRange) {
|
|
54
|
-
innerText += `unicode-range:${desc.unicodeRange};`
|
|
55
|
-
}
|
|
56
|
-
if (desc.variationSettings) {
|
|
57
|
-
innerText += `font-variation-settings:${desc.variationSettings};`
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
style.innerText = `@font-face{${innerText}}`
|
|
61
|
-
document.head.appendChild(style)
|
|
62
|
-
return handle.success()
|
|
63
|
-
}
|
|
64
|
-
}
|
package/src/api/ui/index.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export * from './animation'
|
|
2
|
-
export * from './background'
|
|
3
|
-
export * from './custom-component'
|
|
4
|
-
export * from './fonts'
|
|
5
|
-
export * from './interaction'
|
|
6
|
-
export * from './menu'
|
|
7
|
-
export * from './navigation-bar'
|
|
8
|
-
export * from './pull-down-refresh'
|
|
9
|
-
export * from './scroll'
|
|
10
|
-
export * from './sticky'
|
|
11
|
-
export * from './tab-bar'
|
|
12
|
-
export * from './window'
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import { inlineStyle, setTransform } from '../../../utils'
|
|
2
|
-
|
|
3
|
-
const noop = function () {}
|
|
4
|
-
|
|
5
|
-
export default class ActionSheet {
|
|
6
|
-
options = {
|
|
7
|
-
itemList: [],
|
|
8
|
-
itemColor: '#000000',
|
|
9
|
-
success: noop,
|
|
10
|
-
fail: noop,
|
|
11
|
-
complete: noop
|
|
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
|
-
actionSheetStyle: {
|
|
25
|
-
'z-index': '4999',
|
|
26
|
-
position: 'fixed',
|
|
27
|
-
left: '0',
|
|
28
|
-
bottom: '0',
|
|
29
|
-
'-webkit-transform': 'translate(0, 100%)',
|
|
30
|
-
transform: 'translate(0, 100%)',
|
|
31
|
-
width: '100%',
|
|
32
|
-
'line-height': '1.6',
|
|
33
|
-
background: '#EFEFF4',
|
|
34
|
-
'-webkit-transition': '-webkit-transform .3s',
|
|
35
|
-
transition: 'transform .3s'
|
|
36
|
-
},
|
|
37
|
-
menuStyle: {
|
|
38
|
-
'background-color': '#FCFCFD'
|
|
39
|
-
},
|
|
40
|
-
cellStyle: {
|
|
41
|
-
position: 'relative',
|
|
42
|
-
padding: '10px 0',
|
|
43
|
-
'text-align': 'center',
|
|
44
|
-
'font-size': '18px'
|
|
45
|
-
},
|
|
46
|
-
cancelStyle: {
|
|
47
|
-
'margin-top': '6px',
|
|
48
|
-
padding: '10px 0',
|
|
49
|
-
'text-align': 'center',
|
|
50
|
-
'font-size': '18px',
|
|
51
|
-
color: '#000000',
|
|
52
|
-
'background-color': '#FCFCFD'
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
lastConfig = {}
|
|
57
|
-
el: HTMLDivElement
|
|
58
|
-
actionSheet: HTMLDivElement
|
|
59
|
-
menu: HTMLDivElement
|
|
60
|
-
cells: HTMLDivElement[]
|
|
61
|
-
cancel: HTMLDivElement
|
|
62
|
-
hideOpacityTimer: ReturnType<typeof setTimeout>
|
|
63
|
-
hideDisplayTimer: ReturnType<typeof setTimeout>
|
|
64
|
-
|
|
65
|
-
create (options = {}) {
|
|
66
|
-
return new Promise<string | number>((resolve) => {
|
|
67
|
-
// style
|
|
68
|
-
const { maskStyle, actionSheetStyle, menuStyle, cellStyle, cancelStyle } = this.style
|
|
69
|
-
|
|
70
|
-
// configuration
|
|
71
|
-
const config = {
|
|
72
|
-
...this.options,
|
|
73
|
-
...options
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
this.lastConfig = config
|
|
77
|
-
|
|
78
|
-
// wrapper
|
|
79
|
-
this.el = document.createElement('div')
|
|
80
|
-
this.el.className = 'taro__actionSheet'
|
|
81
|
-
this.el.style.opacity = '0'
|
|
82
|
-
this.el.style.transition = 'opacity 0.2s linear'
|
|
83
|
-
|
|
84
|
-
// mask
|
|
85
|
-
const mask = document.createElement('div')
|
|
86
|
-
mask.setAttribute('style', inlineStyle(maskStyle))
|
|
87
|
-
|
|
88
|
-
// actionSheet
|
|
89
|
-
this.actionSheet = document.createElement('div')
|
|
90
|
-
this.actionSheet.setAttribute('style', inlineStyle(actionSheetStyle))
|
|
91
|
-
|
|
92
|
-
// menu
|
|
93
|
-
this.menu = document.createElement('div')
|
|
94
|
-
this.menu.setAttribute('style', inlineStyle({
|
|
95
|
-
...menuStyle,
|
|
96
|
-
color: config.itemColor
|
|
97
|
-
}))
|
|
98
|
-
|
|
99
|
-
// cells
|
|
100
|
-
this.cells = config.itemList.map((item, index) => {
|
|
101
|
-
const cell: HTMLDivElement = document.createElement('div')
|
|
102
|
-
cell.className = 'taro-actionsheet__cell'
|
|
103
|
-
cell.setAttribute('style', inlineStyle(cellStyle))
|
|
104
|
-
cell.textContent = item
|
|
105
|
-
cell.dataset.tapIndex = `${index}`
|
|
106
|
-
cell.onclick = e => {
|
|
107
|
-
this.hide()
|
|
108
|
-
const target = e.currentTarget as HTMLDivElement
|
|
109
|
-
const index = Number(target?.dataset.tapIndex) || 0
|
|
110
|
-
resolve(index)
|
|
111
|
-
}
|
|
112
|
-
return cell
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
// cancel
|
|
116
|
-
this.cancel = document.createElement('div')
|
|
117
|
-
this.cancel.setAttribute('style', inlineStyle(cancelStyle))
|
|
118
|
-
this.cancel.textContent = '取消'
|
|
119
|
-
|
|
120
|
-
// result
|
|
121
|
-
this.cells.forEach(item => this.menu.appendChild(item))
|
|
122
|
-
this.actionSheet.appendChild(this.menu)
|
|
123
|
-
this.actionSheet.appendChild(this.cancel)
|
|
124
|
-
this.el.appendChild(mask)
|
|
125
|
-
this.el.appendChild(this.actionSheet)
|
|
126
|
-
|
|
127
|
-
// callbacks
|
|
128
|
-
const cb = () => {
|
|
129
|
-
this.hide()
|
|
130
|
-
resolve('cancel')
|
|
131
|
-
}
|
|
132
|
-
mask.onclick = cb
|
|
133
|
-
this.cancel.onclick = cb
|
|
134
|
-
|
|
135
|
-
// show immediately
|
|
136
|
-
document.body.appendChild(this.el)
|
|
137
|
-
setTimeout(() => {
|
|
138
|
-
this.el.style.opacity = '1'
|
|
139
|
-
setTransform(this.actionSheet, 'translate(0, 0)')
|
|
140
|
-
}, 0)
|
|
141
|
-
})
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
show (options = {}) {
|
|
145
|
-
return new Promise<string | number>((resolve) => {
|
|
146
|
-
const config = {
|
|
147
|
-
...this.options,
|
|
148
|
-
...options
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
this.lastConfig = config
|
|
152
|
-
|
|
153
|
-
if (this.hideOpacityTimer) clearTimeout(this.hideOpacityTimer)
|
|
154
|
-
if (this.hideDisplayTimer) clearTimeout(this.hideDisplayTimer)
|
|
155
|
-
|
|
156
|
-
// itemColor
|
|
157
|
-
if (config.itemColor) this.menu.style.color = config.itemColor
|
|
158
|
-
|
|
159
|
-
// cells
|
|
160
|
-
const { cellStyle } = this.style
|
|
161
|
-
|
|
162
|
-
config.itemList.forEach((item, index) => {
|
|
163
|
-
let cell: HTMLDivElement
|
|
164
|
-
if (this.cells[index]) {
|
|
165
|
-
// assign new content
|
|
166
|
-
cell = this.cells[index]
|
|
167
|
-
} else {
|
|
168
|
-
// create new cell
|
|
169
|
-
cell = document.createElement('div')
|
|
170
|
-
cell.className = 'taro-actionsheet__cell'
|
|
171
|
-
cell.setAttribute('style', inlineStyle(cellStyle))
|
|
172
|
-
cell.dataset.tapIndex = `${index}`
|
|
173
|
-
this.cells.push(cell)
|
|
174
|
-
this.menu.appendChild(cell)
|
|
175
|
-
}
|
|
176
|
-
cell.textContent = item
|
|
177
|
-
cell.onclick = e => {
|
|
178
|
-
this.hide()
|
|
179
|
-
const target = e.currentTarget as HTMLDivElement
|
|
180
|
-
const index = Number(target?.dataset.tapIndex) || 0
|
|
181
|
-
resolve(index)
|
|
182
|
-
}
|
|
183
|
-
})
|
|
184
|
-
const cellsLen = this.cells.length
|
|
185
|
-
const itemListLen = config.itemList.length
|
|
186
|
-
if (cellsLen > itemListLen) {
|
|
187
|
-
for (let i = itemListLen; i < cellsLen; i++) {
|
|
188
|
-
this.menu.removeChild(this.cells[i])
|
|
189
|
-
}
|
|
190
|
-
this.cells.splice(itemListLen)
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// show
|
|
194
|
-
this.el.style.display = 'block'
|
|
195
|
-
setTimeout(() => {
|
|
196
|
-
this.el.style.opacity = '1'
|
|
197
|
-
setTransform(this.actionSheet, 'translate(0, 0)')
|
|
198
|
-
}, 0)
|
|
199
|
-
})
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
hide () {
|
|
203
|
-
if (this.hideOpacityTimer) clearTimeout(this.hideOpacityTimer)
|
|
204
|
-
if (this.hideDisplayTimer) clearTimeout(this.hideDisplayTimer)
|
|
205
|
-
|
|
206
|
-
this.hideOpacityTimer = setTimeout(() => {
|
|
207
|
-
this.el.style.opacity = '0'
|
|
208
|
-
setTransform(this.actionSheet, 'translate(0, 100%)')
|
|
209
|
-
this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none' }, 200)
|
|
210
|
-
}, 0)
|
|
211
|
-
}
|
|
212
|
-
}
|
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
import Taro from '@tarojs/api'
|
|
2
|
-
|
|
3
|
-
import { getParameterError, temporarilyNotSupport } from '../../../utils'
|
|
4
|
-
import { MethodHandler } from '../../../utils/handler'
|
|
5
|
-
import ActionSheet from './actionSheet'
|
|
6
|
-
import Modal from './modal'
|
|
7
|
-
import Toast from './toast'
|
|
8
|
-
|
|
9
|
-
// 交互
|
|
10
|
-
|
|
11
|
-
let status = 'default'
|
|
12
|
-
|
|
13
|
-
// inject necessary style
|
|
14
|
-
function init (doc) {
|
|
15
|
-
if (status === 'ready') return
|
|
16
|
-
|
|
17
|
-
const taroStyle = doc.createElement('style')
|
|
18
|
-
taroStyle.textContent = '@font-face{font-weight:normal;font-style:normal;font-family:"taro";src:url("data:application/x-font-ttf;charset=utf-8;base64, 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") format("truetype");}@-webkit-keyframes taroLoading{0%{-webkit-transform:rotate3d(0, 0, 1, 0deg);}100%{-webkit-transform:rotate3d(0, 0, 1, 360deg);transform:rotate3d(0, 0, 1, 360deg);}}@keyframes taroLoading{0%{-webkit-transform:rotate3d(0, 0, 1, 0deg);}100%{-webkit-transform:rotate3d(0, 0, 1, 360deg);transform:rotate3d(0, 0, 1, 360deg);}}.taro-modal__foot:after {content: "";position: absolute;left: 0;top: 0;right: 0;height: 1px;border-top: 1px solid #D5D5D6;color: #D5D5D6;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleY(0.5);transform: scaleY(0.5);} .taro-model__btn:active {background-color: #EEEEEE}.taro-model__btn:not(:first-child):after {content: "";position: absolute;left: 0;top: 0;width: 1px;bottom: 0;border-left: 1px solid #D5D5D6;color: #D5D5D6;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleX(0.5);transform: scaleX(0.5);}.taro-actionsheet__cell:not(:first-child):after {content: "";position: absolute;left: 0;top: 0;right: 0;height: 1px;border-top: 1px solid #e5e5e5;color: #e5e5e5;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleY(0.5);transform: scaleY(0.5);}'
|
|
19
|
-
doc.querySelector('head').appendChild(taroStyle)
|
|
20
|
-
|
|
21
|
-
status = 'ready'
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const toast = new Toast()
|
|
25
|
-
const modal = new Modal()
|
|
26
|
-
const actionSheet = new ActionSheet()
|
|
27
|
-
|
|
28
|
-
const showToast: typeof Taro.showToast = (options = { title: '' }) => {
|
|
29
|
-
init(document)
|
|
30
|
-
options = Object.assign({
|
|
31
|
-
title: '',
|
|
32
|
-
icon: 'success',
|
|
33
|
-
image: '',
|
|
34
|
-
duration: 1500,
|
|
35
|
-
mask: false
|
|
36
|
-
}, options)
|
|
37
|
-
const { success, fail, complete } = options
|
|
38
|
-
const handle = new MethodHandler({ name: 'showToast', success, fail, complete })
|
|
39
|
-
|
|
40
|
-
if (typeof options.title !== 'string') {
|
|
41
|
-
return handle.fail({
|
|
42
|
-
errMsg: getParameterError({
|
|
43
|
-
para: 'title',
|
|
44
|
-
correct: 'String',
|
|
45
|
-
wrong: options.title
|
|
46
|
-
})
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (typeof options.duration !== 'number') {
|
|
51
|
-
return handle.fail({
|
|
52
|
-
errMsg: getParameterError({
|
|
53
|
-
para: 'duration',
|
|
54
|
-
correct: 'Number',
|
|
55
|
-
wrong: options.duration
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (options.image && typeof options.image !== 'string') options.image = ''
|
|
61
|
-
|
|
62
|
-
options.mask = !!options.mask
|
|
63
|
-
|
|
64
|
-
let errMsg = ''
|
|
65
|
-
if (!toast.el) {
|
|
66
|
-
errMsg = toast.create(options, 'toast')
|
|
67
|
-
} else {
|
|
68
|
-
errMsg = toast.show(options, 'toast')
|
|
69
|
-
}
|
|
70
|
-
return handle.success({ errMsg })
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const hideToast: typeof Taro.hideToast = ({ success, fail, complete } = {}) => {
|
|
74
|
-
const handle = new MethodHandler({ name: 'hideToast', success, fail, complete })
|
|
75
|
-
if (!toast.el) return handle.success()
|
|
76
|
-
toast.hide(0, 'toast')
|
|
77
|
-
return handle.success()
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const showLoading: typeof Taro.showLoading = (options = { title: '' }) => {
|
|
81
|
-
init(document)
|
|
82
|
-
options = Object.assign({
|
|
83
|
-
title: '',
|
|
84
|
-
mask: false
|
|
85
|
-
}, options)
|
|
86
|
-
const { success, fail, complete } = options
|
|
87
|
-
const handle = new MethodHandler({ name: 'showLoading', success, fail, complete })
|
|
88
|
-
|
|
89
|
-
const config = {
|
|
90
|
-
icon: 'loading',
|
|
91
|
-
image: '',
|
|
92
|
-
duration: -1
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
options = Object.assign({}, options, config)
|
|
96
|
-
|
|
97
|
-
if (typeof options.title !== 'string') {
|
|
98
|
-
return handle.fail({
|
|
99
|
-
errMsg: getParameterError({
|
|
100
|
-
para: 'title',
|
|
101
|
-
correct: 'String',
|
|
102
|
-
wrong: options.title
|
|
103
|
-
})
|
|
104
|
-
})
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
options.mask = !!options.mask
|
|
108
|
-
|
|
109
|
-
let errMsg = ''
|
|
110
|
-
if (!toast.el) {
|
|
111
|
-
errMsg = toast.create(options, 'loading')
|
|
112
|
-
} else {
|
|
113
|
-
errMsg = toast.show(options, 'loading')
|
|
114
|
-
}
|
|
115
|
-
return handle.success({ errMsg })
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const hideLoading: typeof Taro.hideLoading = ({ success, fail, complete } = {}) => {
|
|
119
|
-
const handle = new MethodHandler({ name: 'hideLoading', success, fail, complete })
|
|
120
|
-
if (!toast.el) return handle.success()
|
|
121
|
-
toast.hide(0, 'loading')
|
|
122
|
-
return handle.success()
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const showModal: typeof Taro.showModal = async (options = {}) => {
|
|
126
|
-
init(document)
|
|
127
|
-
options = Object.assign({
|
|
128
|
-
title: '',
|
|
129
|
-
content: '',
|
|
130
|
-
showCancel: true,
|
|
131
|
-
cancelText: '取消',
|
|
132
|
-
cancelColor: '#000000',
|
|
133
|
-
confirmText: '确定',
|
|
134
|
-
confirmColor: '#3CC51F'
|
|
135
|
-
}, options)
|
|
136
|
-
const { success, fail, complete } = options
|
|
137
|
-
const handle = new MethodHandler({ name: 'showModal', success, fail, complete })
|
|
138
|
-
|
|
139
|
-
if (typeof options.title !== 'string') {
|
|
140
|
-
return handle.fail({
|
|
141
|
-
errMsg: getParameterError({
|
|
142
|
-
para: 'title',
|
|
143
|
-
correct: 'String',
|
|
144
|
-
wrong: options.title
|
|
145
|
-
})
|
|
146
|
-
})
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (typeof options.content !== 'string') {
|
|
150
|
-
return handle.fail({
|
|
151
|
-
errMsg: getParameterError({
|
|
152
|
-
para: 'content',
|
|
153
|
-
correct: 'String',
|
|
154
|
-
wrong: options.content
|
|
155
|
-
})
|
|
156
|
-
})
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (typeof options.cancelText !== 'string') {
|
|
160
|
-
return handle.fail({
|
|
161
|
-
errMsg: getParameterError({
|
|
162
|
-
para: 'cancelText',
|
|
163
|
-
correct: 'String',
|
|
164
|
-
wrong: options.cancelText
|
|
165
|
-
})
|
|
166
|
-
})
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (options.cancelText.replace(/[\u0391-\uFFE5]/g, 'aa').length > 8) {
|
|
170
|
-
return handle.fail({
|
|
171
|
-
errMsg: 'cancelText length should not larger then 4 Chinese characters'
|
|
172
|
-
})
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (typeof options.confirmText !== 'string') {
|
|
176
|
-
return handle.fail({
|
|
177
|
-
errMsg: getParameterError({
|
|
178
|
-
para: 'confirmText',
|
|
179
|
-
correct: 'String',
|
|
180
|
-
wrong: options.confirmText
|
|
181
|
-
})
|
|
182
|
-
})
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (options.confirmText.replace(/[\u0391-\uFFE5]/g, 'aa').length > 8) {
|
|
186
|
-
return handle.fail({
|
|
187
|
-
errMsg: 'confirmText length should not larger then 4 Chinese characters'
|
|
188
|
-
})
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (typeof options.cancelColor !== 'string') {
|
|
192
|
-
return handle.fail({
|
|
193
|
-
errMsg: getParameterError({
|
|
194
|
-
para: 'cancelColor',
|
|
195
|
-
correct: 'String',
|
|
196
|
-
wrong: options.cancelColor
|
|
197
|
-
})
|
|
198
|
-
})
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
if (typeof options.confirmColor !== 'string') {
|
|
202
|
-
return handle.fail({
|
|
203
|
-
errMsg: getParameterError({
|
|
204
|
-
para: 'confirmColor',
|
|
205
|
-
correct: 'String',
|
|
206
|
-
wrong: options.confirmColor
|
|
207
|
-
})
|
|
208
|
-
})
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
options.showCancel = !!options.showCancel
|
|
212
|
-
|
|
213
|
-
let result = ''
|
|
214
|
-
if (!modal.el) {
|
|
215
|
-
result = await modal.create(options)
|
|
216
|
-
} else {
|
|
217
|
-
result = await modal.show(options)
|
|
218
|
-
}
|
|
219
|
-
const res = { cancel: !1, confirm: !1 }
|
|
220
|
-
res[result] = !0
|
|
221
|
-
return handle.success(res)
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
function hideModal () {
|
|
225
|
-
if (!modal.el) return
|
|
226
|
-
modal.hide()
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
const showActionSheet: typeof Taro.showActionSheet = async (options = { itemList: [] }) => {
|
|
230
|
-
init(document)
|
|
231
|
-
options = Object.assign({
|
|
232
|
-
itemColor: '#000000',
|
|
233
|
-
itemList: []
|
|
234
|
-
}, options)
|
|
235
|
-
const { success, fail, complete } = options
|
|
236
|
-
const handle = new MethodHandler<Taro.showActionSheet.SuccessCallbackResult>({ name: 'showActionSheet', success, fail, complete })
|
|
237
|
-
|
|
238
|
-
// list item String
|
|
239
|
-
if (!Array.isArray(options.itemList)) {
|
|
240
|
-
return handle.fail({
|
|
241
|
-
errMsg: getParameterError({
|
|
242
|
-
para: 'itemList',
|
|
243
|
-
correct: 'Array',
|
|
244
|
-
wrong: options.itemList
|
|
245
|
-
})
|
|
246
|
-
})
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
if (options.itemList.length < 1) {
|
|
250
|
-
return handle.fail({ errMsg: 'parameter error: parameter.itemList should have at least 1 item' })
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
if (options.itemList.length > 6) {
|
|
254
|
-
return handle.fail({ errMsg: 'parameter error: parameter.itemList should not be large than 6' })
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
for (let i = 0; i < options.itemList.length; i++) {
|
|
258
|
-
if (typeof options.itemList[i] !== 'string') {
|
|
259
|
-
return handle.fail({
|
|
260
|
-
errMsg: getParameterError({
|
|
261
|
-
para: `itemList[${i}]`,
|
|
262
|
-
correct: 'String',
|
|
263
|
-
wrong: options.itemList[i]
|
|
264
|
-
})
|
|
265
|
-
})
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
if (typeof options.itemColor !== 'string') {
|
|
270
|
-
return handle.fail({
|
|
271
|
-
errMsg: getParameterError({
|
|
272
|
-
para: 'itemColor',
|
|
273
|
-
correct: 'String',
|
|
274
|
-
wrong: options.itemColor
|
|
275
|
-
})
|
|
276
|
-
})
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
let result: number | string = ''
|
|
280
|
-
if (!actionSheet.el) {
|
|
281
|
-
result = await actionSheet.create(options)
|
|
282
|
-
} else {
|
|
283
|
-
result = await actionSheet.show(options)
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (typeof result === 'string') {
|
|
287
|
-
return handle.fail(({ errMsg: result }))
|
|
288
|
-
} else {
|
|
289
|
-
return handle.success(({ tapIndex: result }))
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
Taro.eventCenter.on('__taroRouterChange', () => {
|
|
294
|
-
hideToast()
|
|
295
|
-
hideLoading()
|
|
296
|
-
hideModal()
|
|
297
|
-
})
|
|
298
|
-
|
|
299
|
-
const enableAlertBeforeUnload = temporarilyNotSupport('enableAlertBeforeUnload')
|
|
300
|
-
const disableAlertBeforeUnload = temporarilyNotSupport('disableAlertBeforeUnload')
|
|
301
|
-
|
|
302
|
-
export { disableAlertBeforeUnload, enableAlertBeforeUnload, hideLoading, hideToast, showActionSheet, showLoading, showModal, showToast }
|