@tarojs/plugin-platform-harmony-ets 4.0.0-beta.0 → 4.0.0-beta.10
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/apis/device/memory.ts +10 -3
- package/dist/apis/index.ts +2 -0
- package/dist/apis/media/video/VideoContext.ts +56 -7
- package/dist/apis/media/video/index.ts +3 -2
- package/dist/apis/network/request.ts +5 -5
- package/dist/apis/route/index.ts +15 -0
- package/dist/apis/storage/index.ts +124 -60
- package/dist/apis/wxml/index.ts +2 -0
- package/dist/components-harmony-ets/button.ets +26 -40
- package/dist/components-harmony-ets/checkbox.ets +70 -99
- package/dist/components-harmony-ets/form.ets +29 -42
- package/dist/components-harmony-ets/icon.ets +6 -34
- package/dist/components-harmony-ets/image.ets +2 -32
- package/dist/components-harmony-ets/innerHtml.ets +2 -2
- package/dist/components-harmony-ets/input.ets +7 -27
- package/dist/components-harmony-ets/label.ets +40 -47
- package/dist/components-harmony-ets/picker.ets +66 -73
- package/dist/components-harmony-ets/radio.ets +72 -101
- package/dist/components-harmony-ets/richText.ets +4 -36
- package/dist/components-harmony-ets/scrollView.ets +34 -74
- package/dist/components-harmony-ets/slider.ets +9 -34
- package/dist/components-harmony-ets/style.ets +154 -0
- package/dist/components-harmony-ets/swiper.ets +4 -34
- package/dist/components-harmony-ets/switch.ets +43 -56
- package/dist/components-harmony-ets/text.ets +7 -34
- package/dist/components-harmony-ets/textArea.ets +8 -28
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -11
- package/dist/components-harmony-ets/utils/flexManager.ets +45 -7
- package/dist/components-harmony-ets/utils/helper.ets +2 -2
- package/dist/components-harmony-ets/utils/styles.ets +58 -20
- package/dist/components-harmony-ets/video.ets +4 -34
- package/dist/components-harmony-ets/view.ets +25 -67
- package/dist/components-harmony-ets/webView.ets +50 -0
- package/dist/index.js +103 -5
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/window.ts +2 -2
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +30 -6
- package/dist/runtime-ets/dom/document.ts +21 -4
- package/dist/runtime-ets/dom/element/element.ts +1 -0
- package/dist/runtime-ets/dom/element/form.ts +11 -2
- package/dist/runtime-ets/dom/element/index.ts +4 -1
- package/dist/runtime-ets/dom/element/normal.ts +1 -0
- package/dist/runtime-ets/dom/element/webView.ts +61 -0
- package/dist/runtime-ets/dom/node.ts +29 -16
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +624 -0
- package/dist/runtime-ets/dom/stylesheet/index.ts +216 -354
- package/dist/runtime-ets/dom/stylesheet/type.ts +46 -11
- package/dist/runtime-ets/dom/stylesheet/util.ts +58 -6
- package/dist/runtime-ets/index.ts +1 -2
- package/dist/runtime-ets/interface/event.ts +2 -1
- package/dist/runtime-ets/utils/index.ts +6 -1
- package/dist/runtime-ets/utils/info.ts +3 -1
- package/dist/runtime-framework/react/app.ts +12 -22
- package/dist/runtime-framework/react/hooks.ts +3 -3
- package/dist/runtime-framework/react/index.ts +1 -0
- package/dist/runtime-framework/react/native-page.ts +344 -0
- package/dist/runtime-framework/react/page.ts +2 -2
- package/dist/runtime-framework/solid/hooks.ts +3 -3
- package/dist/runtime-utils.js +181 -80
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +181 -80
- package/dist/runtime.js.map +1 -1
- package/package.json +12 -11
- package/static/media/cancel.svg +1 -0
- package/static/media/circle.svg +1 -0
- package/static/media/clear.svg +1 -0
- package/static/media/download.svg +1 -0
- package/static/media/info.svg +1 -0
- package/static/media/info_circle.svg +1 -0
- package/static/media/search.svg +1 -0
- package/static/media/success.svg +1 -0
- package/static/media/success_no_circle.svg +1 -0
- package/static/media/taro_arrow_left.svg +1 -0
- package/static/media/taro_home.svg +1 -0
- package/static/media/waiting.svg +1 -0
- package/static/media/warn.svg +1 -0
- package/types/runtime.d.ts +2 -0
- package/dist/runtime-ets/utils/bind.ts +0 -24
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hooks } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
export const onMemoryWarning =
|
|
4
|
-
|
|
3
|
+
export const onMemoryWarning = (listener) => {
|
|
4
|
+
hooks.tap('getMemoryLevel', (res) => {
|
|
5
|
+
listener(res)
|
|
6
|
+
})
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const offMemoryWarning = (listener) => {
|
|
10
|
+
hooks.off('getMemoryLevel', listener)
|
|
11
|
+
}
|
package/dist/apis/index.ts
CHANGED
|
@@ -1,19 +1,68 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { document } from '@tarojs/runtime'
|
|
3
|
+
|
|
1
4
|
import { temporarilyNotSupport } from '../../utils'
|
|
2
5
|
|
|
6
|
+
import type { TaroVideoElement } from '@tarojs/runtime'
|
|
3
7
|
import type Taro from '@tarojs/taro/types'
|
|
4
8
|
|
|
5
9
|
export class VideoContext implements Taro.VideoContext {
|
|
10
|
+
id: string
|
|
11
|
+
|
|
12
|
+
video: TaroVideoElement
|
|
13
|
+
|
|
14
|
+
controller: VideoController
|
|
15
|
+
|
|
16
|
+
constructor (id: string) {
|
|
17
|
+
this.id = id
|
|
18
|
+
this.video = document.getElementById(id)
|
|
19
|
+
|
|
20
|
+
if (this.video) {
|
|
21
|
+
this.controller = this.video.controller
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
play () {
|
|
26
|
+
if (!this.controller) return
|
|
27
|
+
|
|
28
|
+
this.controller.play()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
pause () {
|
|
32
|
+
if (!this.controller) return
|
|
33
|
+
|
|
34
|
+
this.controller.pause()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
stop () {
|
|
38
|
+
if (!this.controller) return
|
|
39
|
+
|
|
40
|
+
this.controller.stop()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
seek (position: number) {
|
|
44
|
+
if (!this.controller) return
|
|
45
|
+
|
|
46
|
+
this.controller.setCurrentTime(position)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
requestFullScreen () {
|
|
50
|
+
if (!this.controller) return
|
|
51
|
+
|
|
52
|
+
this.controller.requestFullscreen(true)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
exitFullScreen () {
|
|
56
|
+
if (!this.controller) return
|
|
57
|
+
|
|
58
|
+
this.controller.exitFullscreen()
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
requestBackgroundPlayback = temporarilyNotSupport('VideoContext.requestBackgroundPlayback')
|
|
6
62
|
exitBackgroundPlayback = temporarilyNotSupport('VideoContext.exitBackgroundPlayback')
|
|
7
|
-
exitFullScreen = temporarilyNotSupport('VideoContext.exitFullScreen')
|
|
8
63
|
exitPictureInPicture = temporarilyNotSupport('VideoContext.exitPictureInPicture')
|
|
9
64
|
hideStatusBar = temporarilyNotSupport('VideoContext.hideStatusBar')
|
|
10
|
-
pause = temporarilyNotSupport('VideoContext.pause')
|
|
11
|
-
play = temporarilyNotSupport('VideoContext.play')
|
|
12
65
|
playbackRate = temporarilyNotSupport('VideoContext.playbackRate')
|
|
13
|
-
requestBackgroundPlayback = temporarilyNotSupport('VideoContext.requestBackgroundPlayback')
|
|
14
|
-
requestFullScreen = temporarilyNotSupport('VideoContext.requestFullScreen')
|
|
15
|
-
seek = temporarilyNotSupport('VideoContext.seek')
|
|
16
66
|
sendDanmu = temporarilyNotSupport('VideoContext.sendDanmu')
|
|
17
67
|
showStatusBar = temporarilyNotSupport('VideoContext.showStatusBar')
|
|
18
|
-
stop = temporarilyNotSupport('VideoContext.stop')
|
|
19
68
|
}
|
|
@@ -26,6 +26,7 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary'
|
|
|
26
26
|
import { callAsyncFail, callAsyncSuccess, temporarilyNotSupport, validateParams } from '../../utils'
|
|
27
27
|
import { VideoContext } from './VideoContext'
|
|
28
28
|
|
|
29
|
+
import type { TaroAny } from '@tarojs/runtime'
|
|
29
30
|
import type Taro from '@tarojs/taro/types'
|
|
30
31
|
|
|
31
32
|
interface IChooseVideoOptionOHOS {
|
|
@@ -43,8 +44,8 @@ const saveVideoToPhotosAlbumSchema = {
|
|
|
43
44
|
filePath: 'String'
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
export const createVideoContext: typeof Taro.createVideoContext = () => {
|
|
47
|
-
return new VideoContext()
|
|
47
|
+
export const createVideoContext: typeof Taro.createVideoContext = (id: string, _: TaroAny) => {
|
|
48
|
+
return new VideoContext(id)
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
// TODO: 1.返回属性补全
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// ✅ RequestTask.onHeadersReceived
|
|
7
7
|
|
|
8
8
|
import http from '@ohos.net.http'
|
|
9
|
-
import { isString
|
|
9
|
+
import { isString } from '@tarojs/shared'
|
|
10
10
|
|
|
11
11
|
import { callAsyncFail, callAsyncSuccess, validateParams } from '../utils'
|
|
12
12
|
|
|
@@ -59,10 +59,10 @@ export const request: typeof Taro.request = function (options) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
// 检查 Header 是否有 Referer
|
|
62
|
-
if (isUndefined(header.Referer)) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
62
|
+
// if (isUndefined(header.Referer)) {
|
|
63
|
+
// const error = { errMsg: 'request fail parameter error: the header doesn‘t support Referer property' }
|
|
64
|
+
// callAsyncFail(reject, error, options)
|
|
65
|
+
// }
|
|
66
66
|
|
|
67
67
|
// 检查 method 是否正确
|
|
68
68
|
if (method) {
|
package/dist/apis/route/index.ts
CHANGED
|
@@ -16,6 +16,21 @@ function parseURL (raw = ''): [string, Record<string, unknown>] {
|
|
|
16
16
|
const [urlStr, queryStr = ''] = raw.split('?')
|
|
17
17
|
const query: Record<string, unknown> = queryToJson(queryStr)
|
|
18
18
|
let url = urlStr.replace(/^\//, '')
|
|
19
|
+
|
|
20
|
+
// 处理相对路径
|
|
21
|
+
if (url.indexOf('.') === 0) {
|
|
22
|
+
const page = router.getState()
|
|
23
|
+
const parts = page.path.split('/')
|
|
24
|
+
parts.pop()
|
|
25
|
+
url.split('/').forEach((item) => {
|
|
26
|
+
if (item === '.') {
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
item === '..' ? parts.pop() : parts.push(item)
|
|
30
|
+
})
|
|
31
|
+
url = parts.join('/')
|
|
32
|
+
}
|
|
33
|
+
|
|
19
34
|
if (isTabPage(url)) {
|
|
20
35
|
query.$page = url
|
|
21
36
|
url = TARO_TABBAR_PAGE_PATH
|
|
@@ -7,32 +7,30 @@ import dataPreferences from '@ohos.data.preferences'
|
|
|
7
7
|
import hilog from '@ohos.hilog'
|
|
8
8
|
import { Current } from '@tarojs/runtime'
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { temporarilyNotSupport, validateParams } from '../utils'
|
|
11
|
+
import { MethodHandler } from '../utils/handler'
|
|
11
12
|
|
|
12
13
|
import type Taro from '@tarojs/taro/types'
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return bundleManager
|
|
17
|
-
.getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION)
|
|
18
|
-
.then(data => {
|
|
19
|
-
return dataPreferences
|
|
20
|
-
.getPreferences(context, `${data.appInfo.uid}Store`)
|
|
21
|
-
})
|
|
22
|
-
})
|
|
23
|
-
.catch((error) => {
|
|
24
|
-
hilog.error(0x0000, 'TaroFailedTag', 'Failed to load the storage. Cause: %{public}s', error.code ? JSON.stringify(error) : error.message || error)
|
|
25
|
-
})
|
|
15
|
+
let context
|
|
16
|
+
let preferences: any
|
|
26
17
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
(Current as any).contextPromise.then((ctx) => {
|
|
19
|
+
context = ctx
|
|
20
|
+
return context
|
|
21
|
+
})
|
|
31
22
|
|
|
32
|
-
|
|
23
|
+
function getPreferences () {
|
|
24
|
+
try {
|
|
25
|
+
if (!preferences) {
|
|
26
|
+
const data = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION)
|
|
27
|
+
preferences = dataPreferences.getPreferencesSync(context, { name: `${data.appInfo.uid}Store` })
|
|
28
|
+
}
|
|
33
29
|
} catch (error) {
|
|
34
|
-
|
|
30
|
+
hilog.error(0x0000, 'TaroFailedTag', 'Failed to load the storage. Cause: %{public}s', error.code ? JSON.stringify(error) : error.message || error)
|
|
35
31
|
}
|
|
32
|
+
|
|
33
|
+
return preferences
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
const storageSchema = {
|
|
@@ -40,89 +38,155 @@ const storageSchema = {
|
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
export function getStorage<T = any> (options: Taro.getStorage.Option<T>) {
|
|
41
|
+
const { key, success, fail, complete } = options || {}
|
|
42
|
+
const handle = new MethodHandler<{data: any}>({ name: 'getStorage', success, fail, complete })
|
|
43
|
+
|
|
43
44
|
return new Promise((resolve, reject) => {
|
|
44
45
|
try {
|
|
45
46
|
validateParams('getStorage', options, storageSchema)
|
|
46
47
|
} catch (error) {
|
|
47
48
|
const res = { errMsg: error.message }
|
|
48
|
-
return
|
|
49
|
+
return handle.fail(res, { resolve, reject })
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const preferences = getPreferences()
|
|
53
|
+
|
|
54
|
+
if (!preferences) return handle.fail({}, { resolve, reject })
|
|
55
|
+
|
|
56
|
+
const data = preferences.getSync(key, null)
|
|
57
|
+
if (data) {
|
|
58
|
+
return handle.success({ data }, { resolve, reject })
|
|
59
|
+
} else {
|
|
60
|
+
return handle.success({ errMsg: 'data not found' }, { resolve, reject })
|
|
49
61
|
}
|
|
50
|
-
getItem(options.key).then(({ result, data }) => {
|
|
51
|
-
const res: Record<string, any> = { errMsg: 'getStorage:ok' }
|
|
52
|
-
|
|
53
|
-
if (result) {
|
|
54
|
-
res.data = data
|
|
55
|
-
callAsyncSuccess(resolve, res, options)
|
|
56
|
-
} else {
|
|
57
|
-
res.errMsg = 'getStorage:fail data not found'
|
|
58
|
-
callAsyncFail(reject, res, options)
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
62
|
})
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
export function getStorageSync (key: string) {
|
|
66
|
+
if (!key) {
|
|
67
|
+
throw new Error('getStorageSync:fail parameter error: parameter should be String')
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const preferences = getPreferences()
|
|
71
|
+
|
|
72
|
+
if (!preferences) {
|
|
73
|
+
throw new Error('getStorageSync:fail:preferences is null')
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const data = preferences.getSync(key, null)
|
|
77
|
+
if (data) {
|
|
78
|
+
return data
|
|
79
|
+
} else {
|
|
80
|
+
throw new Error('data not found')
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
64
84
|
export function setStorage (options: Taro.setStorage.Option) {
|
|
85
|
+
const { key, data, success, fail, complete } = options || {}
|
|
86
|
+
const handle = new MethodHandler({ name: 'setStorage', success, fail, complete })
|
|
87
|
+
|
|
65
88
|
return new Promise((resolve, reject) => {
|
|
66
89
|
try {
|
|
67
90
|
validateParams('setStorage', options, storageSchema)
|
|
68
91
|
} catch (error) {
|
|
69
92
|
const res = { errMsg: error.message }
|
|
70
|
-
return
|
|
93
|
+
return handle.fail(res, { resolve, reject })
|
|
71
94
|
}
|
|
72
95
|
|
|
73
|
-
const
|
|
74
|
-
const res = { errMsg: 'setStorage:ok' }
|
|
96
|
+
const preferences = getPreferences()
|
|
75
97
|
|
|
76
|
-
|
|
77
|
-
await preferences.put(key, data)
|
|
78
|
-
await preferences.flush()
|
|
98
|
+
if (!preferences) return handle.fail({}, { resolve, reject })
|
|
79
99
|
|
|
80
|
-
|
|
81
|
-
|
|
100
|
+
preferences.putSync(key, data)
|
|
101
|
+
preferences.flush()
|
|
102
|
+
|
|
103
|
+
return handle.success({}, { resolve, reject })
|
|
82
104
|
})
|
|
83
105
|
}
|
|
84
106
|
|
|
107
|
+
export function setStorageSync (key: string, data: any) {
|
|
108
|
+
if (!key) {
|
|
109
|
+
throw new Error('setStorageSync:fail key error: key should be String')
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const preferences = getPreferences()
|
|
113
|
+
|
|
114
|
+
if (!preferences) {
|
|
115
|
+
throw new Error('setStorageSync:fail:preferences is null')
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
preferences.putSync(key, data)
|
|
119
|
+
preferences.flush()
|
|
120
|
+
}
|
|
121
|
+
|
|
85
122
|
export function removeStorage (options: Taro.removeStorage.Option) {
|
|
123
|
+
const { key, success, fail, complete } = options || {}
|
|
124
|
+
const handle = new MethodHandler({ name: 'removeStorage', success, fail, complete })
|
|
125
|
+
|
|
86
126
|
return new Promise((resolve, reject) => {
|
|
87
127
|
try {
|
|
88
128
|
validateParams('removeStorage', options, storageSchema)
|
|
89
129
|
} catch (error) {
|
|
90
130
|
const res = { errMsg: error.message }
|
|
91
|
-
return
|
|
131
|
+
return handle.fail(res, { resolve, reject })
|
|
92
132
|
}
|
|
93
133
|
|
|
94
|
-
const
|
|
134
|
+
const preferences = getPreferences()
|
|
95
135
|
|
|
96
|
-
|
|
97
|
-
await preferences.delete(key)
|
|
98
|
-
await preferences.flush()
|
|
136
|
+
if (!preferences) return handle.fail({}, { resolve, reject })
|
|
99
137
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
138
|
+
preferences.deleteSync(key)
|
|
139
|
+
preferences.flush()
|
|
140
|
+
|
|
141
|
+
return handle.success({}, { resolve, reject })
|
|
103
142
|
})
|
|
104
143
|
}
|
|
105
144
|
|
|
145
|
+
export function removeStorageSync (key: string) {
|
|
146
|
+
if (!key) {
|
|
147
|
+
throw new Error('removeStorageSync:fail key error: key should be String')
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const preferences = getPreferences()
|
|
151
|
+
|
|
152
|
+
if (!preferences) {
|
|
153
|
+
throw new Error('removeStorageSync:fail:preferences is null')
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
preferences.deleteSync(key)
|
|
157
|
+
preferences.flush()
|
|
158
|
+
}
|
|
159
|
+
|
|
106
160
|
export function clearStorage (options: Taro.clearStorage.Option) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
161
|
+
const { success, fail, complete } = options || {}
|
|
162
|
+
const handle = new MethodHandler({ name: 'clearStorage', success, fail, complete })
|
|
163
|
+
|
|
164
|
+
return new Promise((resolve, reject) => {
|
|
165
|
+
const preferences = getPreferences()
|
|
166
|
+
|
|
167
|
+
if (!preferences) return handle.fail({}, { resolve, reject })
|
|
168
|
+
|
|
169
|
+
preferences.clearSync()
|
|
170
|
+
preferences.flush()
|
|
171
|
+
|
|
172
|
+
return handle.success({}, { resolve, reject })
|
|
115
173
|
})
|
|
116
174
|
}
|
|
117
175
|
|
|
176
|
+
export function clearStorageSync () {
|
|
177
|
+
const preferences = getPreferences()
|
|
178
|
+
|
|
179
|
+
if (!preferences) {
|
|
180
|
+
throw new Error('clearStorageSync:fail:preferences is null')
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
preferences.clearSync()
|
|
184
|
+
preferences.flush()
|
|
185
|
+
}
|
|
186
|
+
|
|
118
187
|
export const getStorageInfoSync = temporarilyNotSupport('getStorageInfoSync')
|
|
119
188
|
export const getStorageInfo = temporarilyNotSupport('getStorageInfo')
|
|
120
189
|
|
|
121
|
-
export const getStorageSync = temporarilyNotSupport('getStorageSync', 'getStorage')
|
|
122
|
-
export const setStorageSync = temporarilyNotSupport('setStorageSync', 'setStorage')
|
|
123
|
-
export const clearStorageSync = temporarilyNotSupport('clearStorageSync', 'clearStorage')
|
|
124
|
-
export const removeStorageSync = temporarilyNotSupport('removeStorageSync', 'removeStorage')
|
|
125
|
-
|
|
126
190
|
export const createBufferURL = /* @__PURE__ */ temporarilyNotSupport('createBufferURL')
|
|
127
191
|
export const revokeBufferURL = /* @__PURE__ */ temporarilyNotSupport('revokeBufferURL')
|
|
128
192
|
|
package/dist/apis/wxml/index.ts
CHANGED
|
@@ -1,41 +1,12 @@
|
|
|
1
1
|
import { eventHandler, createTaroEvent, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
import { createLazyChildren } from './render'
|
|
3
|
+
import commonStyleModify from './style'
|
|
3
4
|
import { BUTTON_THEME_COLOR } from './utils/constant/style'
|
|
4
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
5
|
-
import {
|
|
6
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
6
7
|
|
|
7
8
|
import type { TaroAny, TaroEvent, TaroButtonElement, TaroStyleType } from '@tarojs/runtime'
|
|
8
9
|
|
|
9
|
-
@Extend(Button)
|
|
10
|
-
function attrs (style: TaroStyleType) {
|
|
11
|
-
.id(style.id)
|
|
12
|
-
.key(style.id)
|
|
13
|
-
.width(style.width)
|
|
14
|
-
.height(style.height)
|
|
15
|
-
.padding({
|
|
16
|
-
top: style.padding?.top,
|
|
17
|
-
left: style.padding?.left || 10,
|
|
18
|
-
right: style.padding?.right || 10,
|
|
19
|
-
bottom: style.padding?.bottom,
|
|
20
|
-
})
|
|
21
|
-
.margin(style.margin)
|
|
22
|
-
.flexGrow(style.flexGrow)
|
|
23
|
-
.flexShrink(style.flexShrink)
|
|
24
|
-
.flexBasis(style.flexBasis)
|
|
25
|
-
.alignSelf(style.alignSelf)
|
|
26
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
27
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
28
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
29
|
-
.rotate(style.rotate)
|
|
30
|
-
.scale(style.scale)
|
|
31
|
-
.translate(style.translate)
|
|
32
|
-
.transform(style.transform)
|
|
33
|
-
.borderStyle(style.borderStyle)
|
|
34
|
-
.linearGradient(style.linearGradient)
|
|
35
|
-
.zIndex(style.zIndex)
|
|
36
|
-
.clip(style.clip)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
10
|
@Extend(Button)
|
|
40
11
|
function themeStyles(style: TaroStyleType) {
|
|
41
12
|
.fontColor(style.color)
|
|
@@ -71,9 +42,24 @@ function getThemeAttributes (node: TaroButtonElement): TaroStyleType {
|
|
|
71
42
|
const type: string = _attrs.type || 'default'
|
|
72
43
|
|
|
73
44
|
return {
|
|
74
|
-
borderColor:
|
|
75
|
-
|
|
76
|
-
|
|
45
|
+
borderColor: {
|
|
46
|
+
top: hmStyle.borderTopColor || getButtonColor(node, BUTTON_THEME_COLOR.get(type).background),
|
|
47
|
+
right: hmStyle.borderRightColor || getButtonColor(node, BUTTON_THEME_COLOR.get(type).background),
|
|
48
|
+
bottom: hmStyle.borderBottomColor || getButtonColor(node, BUTTON_THEME_COLOR.get(type).background),
|
|
49
|
+
left: hmStyle.borderLeftColor || getButtonColor(node, BUTTON_THEME_COLOR.get(type).background)
|
|
50
|
+
},
|
|
51
|
+
borderWidth: {
|
|
52
|
+
top: hmStyle.borderTopWidth || 1,
|
|
53
|
+
right: hmStyle.borderRightWidth || 1,
|
|
54
|
+
bottom: hmStyle.borderBottomWidth || 1,
|
|
55
|
+
left: hmStyle.borderLeftWidth || 1
|
|
56
|
+
},
|
|
57
|
+
borderRadius: {
|
|
58
|
+
topLeft: hmStyle.borderTopLeftRadius || convertNumber2VP(10),
|
|
59
|
+
topRight: hmStyle.borderTopRightRadius || convertNumber2VP(10),
|
|
60
|
+
bottomLeft: hmStyle.borderBottomLeftRadius || convertNumber2VP(10),
|
|
61
|
+
bottomRight: hmStyle.borderBottomRightRadius || convertNumber2VP(10)
|
|
62
|
+
},
|
|
77
63
|
opacity: isDisabled ? 0.4 : hmStyle.opacity,
|
|
78
64
|
backgroundColor: isPlain ? Color.Transparent : (hmStyle.backgroundColor || BUTTON_THEME_COLOR.get(type).background),
|
|
79
65
|
color: hmStyle.color || getButtonColor(node, BUTTON_THEME_COLOR.get(type).text),
|
|
@@ -121,16 +107,16 @@ export default function TaroButton (node: TaroButtonElement) {
|
|
|
121
107
|
}
|
|
122
108
|
}
|
|
123
109
|
.themeStyles(getThemeAttributes(node))
|
|
124
|
-
.
|
|
110
|
+
.attributeModifier(commonStyleModify.setNode(node))
|
|
125
111
|
.constraintSize({
|
|
126
|
-
minWidth: node.hmStyle?.
|
|
127
|
-
minHeight: node.hmStyle?.
|
|
128
|
-
maxWidth: node.hmStyle?.
|
|
129
|
-
maxHeight: node.hmStyle?.
|
|
112
|
+
minWidth: node.hmStyle?.minWidth || getButtonMinWidth(node),
|
|
113
|
+
minHeight: node.hmStyle?.minHeight || getButtonMinHeight(node),
|
|
114
|
+
maxWidth: node.hmStyle?.maxWidth,
|
|
115
|
+
maxHeight: node.hmStyle?.maxHeight,
|
|
130
116
|
})
|
|
131
117
|
.type(ButtonType.Normal)
|
|
132
118
|
.onClick((e: ClickEvent) => {
|
|
133
|
-
if (['submit', 'reset'].includes(node._attrs.formType)) {
|
|
119
|
+
if (node._attrs.formType && ['submit', 'reset'].includes(node._attrs.formType)) {
|
|
134
120
|
const eventName = node._attrs.formType + '-btn'
|
|
135
121
|
const event: TaroEvent = createTaroEvent(eventName, {}, node)
|
|
136
122
|
eventHandler(event, eventName, node)
|