@tarojs/plugin-platform-harmony-ets 4.0.0-beta.1 → 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/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 +22 -71
- package/dist/components-harmony-ets/checkbox.ets +22 -138
- package/dist/components-harmony-ets/form.ets +29 -76
- package/dist/components-harmony-ets/icon.ets +5 -67
- package/dist/components-harmony-ets/image.ets +2 -66
- package/dist/components-harmony-ets/innerHtml.ets +2 -2
- package/dist/components-harmony-ets/input.ets +2 -61
- package/dist/components-harmony-ets/label.ets +40 -81
- package/dist/components-harmony-ets/picker.ets +31 -140
- package/dist/components-harmony-ets/radio.ets +22 -138
- package/dist/components-harmony-ets/richText.ets +4 -70
- package/dist/components-harmony-ets/scrollView.ets +34 -132
- package/dist/components-harmony-ets/slider.ets +4 -68
- package/dist/components-harmony-ets/style.ets +154 -0
- package/dist/components-harmony-ets/swiper.ets +4 -68
- package/dist/components-harmony-ets/switch.ets +4 -68
- package/dist/components-harmony-ets/text.ets +5 -69
- package/dist/components-harmony-ets/textArea.ets +2 -61
- package/dist/components-harmony-ets/utils/flexManager.ets +44 -6
- package/dist/components-harmony-ets/utils/helper.ets +2 -2
- package/dist/components-harmony-ets/utils/styles.ets +12 -1
- package/dist/components-harmony-ets/video.ets +4 -68
- package/dist/components-harmony-ets/view.ets +15 -125
- package/dist/components-harmony-ets/webView.ets +50 -0
- package/dist/index.js +87 -2
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/window.ts +2 -2
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +23 -3
- package/dist/runtime-ets/dom/document.ts +21 -4
- 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/stylesheet/covertWeb2Hm.ts +73 -0
- package/dist/runtime-ets/dom/stylesheet/util.ts +3 -1
- package/dist/runtime-ets/index.ts +1 -2
- package/dist/runtime-ets/utils/index.ts +4 -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 +134 -68
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +134 -68
- package/dist/runtime.js.map +1 -1
- package/package.json +10 -10
- 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
|
@@ -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,76 +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
|
-
.flexGrow(style.flexGrow)
|
|
14
|
-
.flexShrink(style.flexShrink)
|
|
15
|
-
.flexBasis(style.flexBasis)
|
|
16
|
-
.alignSelf(style.alignSelf)
|
|
17
|
-
.padding({
|
|
18
|
-
top: style.paddingTop,
|
|
19
|
-
right: style.paddingRight || 10,
|
|
20
|
-
bottom: style.paddingBottom,
|
|
21
|
-
left: style.paddingLeft || 10
|
|
22
|
-
})
|
|
23
|
-
.margin({
|
|
24
|
-
top: style.marginTop,
|
|
25
|
-
right: style.marginRight,
|
|
26
|
-
bottom: style.marginBottom,
|
|
27
|
-
left: style.marginLeft
|
|
28
|
-
})
|
|
29
|
-
.width(style.width)
|
|
30
|
-
.height(style.height)
|
|
31
|
-
.constraintSize({
|
|
32
|
-
minWidth: style.minWidth,
|
|
33
|
-
maxWidth: style.maxWidth,
|
|
34
|
-
minHeight: style.minHeight,
|
|
35
|
-
maxHeight: style.maxHeight
|
|
36
|
-
})
|
|
37
|
-
.backgroundColor(style.backgroundColor)
|
|
38
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
39
|
-
.backgroundImageSize(style.backgroundSize)
|
|
40
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
41
|
-
.borderStyle({
|
|
42
|
-
top: style.borderTopStyle,
|
|
43
|
-
right: style.borderRightStyle,
|
|
44
|
-
bottom: style.borderBottomStyle,
|
|
45
|
-
left: style.borderLeftStyle
|
|
46
|
-
})
|
|
47
|
-
.borderWidth({
|
|
48
|
-
top: style.borderTopWidth,
|
|
49
|
-
right: style.borderRightWidth,
|
|
50
|
-
bottom: style.borderBottomWidth,
|
|
51
|
-
left: style.borderLeftWidth
|
|
52
|
-
})
|
|
53
|
-
.borderColor({
|
|
54
|
-
top: style.borderTopColor,
|
|
55
|
-
right: style.borderRightColor,
|
|
56
|
-
bottom: style.borderBottomColor,
|
|
57
|
-
left: style.borderLeftColor
|
|
58
|
-
})
|
|
59
|
-
.borderRadius({
|
|
60
|
-
topLeft: style.borderTopLeftRadius,
|
|
61
|
-
topRight: style.borderTopRightRadius,
|
|
62
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
63
|
-
bottomRight: style.borderBottomRightRadius
|
|
64
|
-
})
|
|
65
|
-
.zIndex(style.zIndex)
|
|
66
|
-
.opacity(style.opacity)
|
|
67
|
-
.linearGradient(style.linearGradient)
|
|
68
|
-
.clip(style.overflow)
|
|
69
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
70
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
71
|
-
.transform(style.transform)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
10
|
@Extend(Button)
|
|
75
11
|
function themeStyles(style: TaroStyleType) {
|
|
76
12
|
.fontColor(style.color)
|
|
@@ -106,9 +42,24 @@ function getThemeAttributes (node: TaroButtonElement): TaroStyleType {
|
|
|
106
42
|
const type: string = _attrs.type || 'default'
|
|
107
43
|
|
|
108
44
|
return {
|
|
109
|
-
borderColor:
|
|
110
|
-
|
|
111
|
-
|
|
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
|
+
},
|
|
112
63
|
opacity: isDisabled ? 0.4 : hmStyle.opacity,
|
|
113
64
|
backgroundColor: isPlain ? Color.Transparent : (hmStyle.backgroundColor || BUTTON_THEME_COLOR.get(type).background),
|
|
114
65
|
color: hmStyle.color || getButtonColor(node, BUTTON_THEME_COLOR.get(type).text),
|
|
@@ -156,7 +107,7 @@ export default function TaroButton (node: TaroButtonElement) {
|
|
|
156
107
|
}
|
|
157
108
|
}
|
|
158
109
|
.themeStyles(getThemeAttributes(node))
|
|
159
|
-
.
|
|
110
|
+
.attributeModifier(commonStyleModify.setNode(node))
|
|
160
111
|
.constraintSize({
|
|
161
112
|
minWidth: node.hmStyle?.minWidth || getButtonMinWidth(node),
|
|
162
113
|
minHeight: node.hmStyle?.minHeight || getButtonMinHeight(node),
|
|
@@ -165,7 +116,7 @@ export default function TaroButton (node: TaroButtonElement) {
|
|
|
165
116
|
})
|
|
166
117
|
.type(ButtonType.Normal)
|
|
167
118
|
.onClick((e: ClickEvent) => {
|
|
168
|
-
if (['submit', 'reset'].includes(node._attrs.formType)) {
|
|
119
|
+
if (node._attrs.formType && ['submit', 'reset'].includes(node._attrs.formType)) {
|
|
169
120
|
const eventName = node._attrs.formType + '-btn'
|
|
170
121
|
const event: TaroEvent = createTaroEvent(eventName, {}, node)
|
|
171
122
|
eventHandler(event, eventName, node)
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createTaroEvent, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
+
import commonStyleModify from './style'
|
|
3
4
|
import { createLazyChildren } from './render'
|
|
4
5
|
import { FlexManager } from './utils/FlexManager'
|
|
5
|
-
import { shouldBindEvent,
|
|
6
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
6
7
|
|
|
7
|
-
import type {
|
|
8
|
+
import type { TaroAny, TaroEvent, TaroCheckboxElement, TaroCheckboxGroupElement } from '@tarojs/runtime'
|
|
8
9
|
|
|
9
10
|
interface CheckboxOptions {
|
|
10
11
|
name?: string
|
|
@@ -14,71 +15,6 @@ interface CheckboxAttrs {
|
|
|
14
15
|
selectedColor?: ResourceColor
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
@Extend(Checkbox)
|
|
18
|
-
function checkboxStyle (style: TaroStyleType) {
|
|
19
|
-
.id(style.id)
|
|
20
|
-
.key(style.id)
|
|
21
|
-
.flexGrow(style.flexGrow)
|
|
22
|
-
.flexShrink(style.flexShrink)
|
|
23
|
-
.flexBasis(style.flexBasis)
|
|
24
|
-
.alignSelf(style.alignSelf)
|
|
25
|
-
.padding({
|
|
26
|
-
top: style.paddingTop,
|
|
27
|
-
right: style.paddingRight,
|
|
28
|
-
bottom: style.paddingBottom,
|
|
29
|
-
left: style.paddingLeft
|
|
30
|
-
})
|
|
31
|
-
.margin({
|
|
32
|
-
top: style.marginTop,
|
|
33
|
-
right: style.marginRight,
|
|
34
|
-
bottom: style.marginBottom,
|
|
35
|
-
left: style.marginLeft
|
|
36
|
-
})
|
|
37
|
-
.width(style.width)
|
|
38
|
-
.height(style.height)
|
|
39
|
-
.constraintSize({
|
|
40
|
-
minWidth: style.minWidth,
|
|
41
|
-
maxWidth: style.maxWidth,
|
|
42
|
-
minHeight: style.minHeight,
|
|
43
|
-
maxHeight: style.maxHeight
|
|
44
|
-
})
|
|
45
|
-
.backgroundColor(style.backgroundColor)
|
|
46
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
47
|
-
.backgroundImageSize(style.backgroundSize)
|
|
48
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
49
|
-
.borderStyle({
|
|
50
|
-
top: style.borderTopStyle,
|
|
51
|
-
right: style.borderRightStyle,
|
|
52
|
-
bottom: style.borderBottomStyle,
|
|
53
|
-
left: style.borderLeftStyle
|
|
54
|
-
})
|
|
55
|
-
.borderWidth({
|
|
56
|
-
top: style.borderTopWidth,
|
|
57
|
-
right: style.borderRightWidth,
|
|
58
|
-
bottom: style.borderBottomWidth,
|
|
59
|
-
left: style.borderLeftWidth
|
|
60
|
-
})
|
|
61
|
-
.borderColor({
|
|
62
|
-
top: style.borderTopColor,
|
|
63
|
-
right: style.borderRightColor,
|
|
64
|
-
bottom: style.borderBottomColor,
|
|
65
|
-
left: style.borderLeftColor
|
|
66
|
-
})
|
|
67
|
-
.borderRadius({
|
|
68
|
-
topLeft: style.borderTopLeftRadius,
|
|
69
|
-
topRight: style.borderTopRightRadius,
|
|
70
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
71
|
-
bottomRight: style.borderBottomRightRadius
|
|
72
|
-
})
|
|
73
|
-
.zIndex(style.zIndex)
|
|
74
|
-
.opacity(style.opacity)
|
|
75
|
-
.linearGradient(style.linearGradient)
|
|
76
|
-
.clip(style.overflow)
|
|
77
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
78
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
79
|
-
.transform(style.transform)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
18
|
@Extend(Checkbox)
|
|
83
19
|
function checkboxAttr(attr: CheckboxAttrs) {
|
|
84
20
|
.selectedColor(attr.selectedColor)
|
|
@@ -113,7 +49,7 @@ export struct TaroCheckbox {
|
|
|
113
49
|
Stack() {
|
|
114
50
|
Row() {
|
|
115
51
|
Checkbox(getOptions(this.node))
|
|
116
|
-
.
|
|
52
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
117
53
|
.checkboxAttr(getAttributes(this.node))
|
|
118
54
|
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
119
55
|
.select(this.node.checked)
|
|
@@ -154,71 +90,6 @@ export struct TaroCheckbox {
|
|
|
154
90
|
}
|
|
155
91
|
}
|
|
156
92
|
|
|
157
|
-
@Extend(Flex)
|
|
158
|
-
function checkboxGroupAttrs (style: TaroStyleType) {
|
|
159
|
-
.id(style.id)
|
|
160
|
-
.key(style.id)
|
|
161
|
-
.flexGrow(style.flexGrow)
|
|
162
|
-
.flexShrink(style.flexShrink)
|
|
163
|
-
.flexBasis(style.flexBasis)
|
|
164
|
-
.alignSelf(style.alignSelf)
|
|
165
|
-
.padding({
|
|
166
|
-
top: style.paddingTop,
|
|
167
|
-
right: style.paddingRight,
|
|
168
|
-
bottom: style.paddingBottom,
|
|
169
|
-
left: style.paddingLeft
|
|
170
|
-
})
|
|
171
|
-
.margin({
|
|
172
|
-
top: style.marginTop,
|
|
173
|
-
right: style.marginRight,
|
|
174
|
-
bottom: style.marginBottom,
|
|
175
|
-
left: style.marginLeft
|
|
176
|
-
})
|
|
177
|
-
.width(style.width)
|
|
178
|
-
.height(style.height)
|
|
179
|
-
.constraintSize({
|
|
180
|
-
minWidth: style.minWidth,
|
|
181
|
-
maxWidth: style.maxWidth,
|
|
182
|
-
minHeight: style.minHeight,
|
|
183
|
-
maxHeight: style.maxHeight
|
|
184
|
-
})
|
|
185
|
-
.backgroundColor(style.backgroundColor)
|
|
186
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
187
|
-
.backgroundImageSize(style.backgroundSize)
|
|
188
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
189
|
-
.borderStyle({
|
|
190
|
-
top: style.borderTopStyle,
|
|
191
|
-
right: style.borderRightStyle,
|
|
192
|
-
bottom: style.borderBottomStyle,
|
|
193
|
-
left: style.borderLeftStyle
|
|
194
|
-
})
|
|
195
|
-
.borderWidth({
|
|
196
|
-
top: style.borderTopWidth,
|
|
197
|
-
right: style.borderRightWidth,
|
|
198
|
-
bottom: style.borderBottomWidth,
|
|
199
|
-
left: style.borderLeftWidth
|
|
200
|
-
})
|
|
201
|
-
.borderColor({
|
|
202
|
-
top: style.borderTopColor,
|
|
203
|
-
right: style.borderRightColor,
|
|
204
|
-
bottom: style.borderBottomColor,
|
|
205
|
-
left: style.borderLeftColor
|
|
206
|
-
})
|
|
207
|
-
.borderRadius({
|
|
208
|
-
topLeft: style.borderTopLeftRadius,
|
|
209
|
-
topRight: style.borderTopRightRadius,
|
|
210
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
211
|
-
bottomRight: style.borderBottomRightRadius
|
|
212
|
-
})
|
|
213
|
-
.zIndex(style.zIndex)
|
|
214
|
-
.opacity(style.opacity)
|
|
215
|
-
.linearGradient(style.linearGradient)
|
|
216
|
-
.clip(style.overflow)
|
|
217
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
218
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
219
|
-
.transform(style.transform)
|
|
220
|
-
}
|
|
221
|
-
|
|
222
93
|
interface ChangeEventDetail { value: string[] }
|
|
223
94
|
|
|
224
95
|
@Component
|
|
@@ -250,12 +121,25 @@ export struct TaroCheckboxGroup {
|
|
|
250
121
|
|
|
251
122
|
build() {
|
|
252
123
|
if (this.node) {
|
|
253
|
-
|
|
254
|
-
|
|
124
|
+
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
125
|
+
Row() {
|
|
126
|
+
createLazyChildren(this.node)
|
|
127
|
+
}
|
|
128
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
129
|
+
.defaultEvent()
|
|
130
|
+
.visibleChangeEvent()
|
|
131
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
132
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
133
|
+
} else {
|
|
134
|
+
Column() {
|
|
135
|
+
createLazyChildren(this.node)
|
|
136
|
+
}
|
|
137
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
138
|
+
.defaultEvent()
|
|
139
|
+
.visibleChangeEvent()
|
|
140
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
141
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
255
142
|
}
|
|
256
|
-
.checkboxGroupAttrs(getNormalAttributes(this.node))
|
|
257
|
-
.defaultEvent()
|
|
258
|
-
.visibleChangeEvent()
|
|
259
143
|
}
|
|
260
144
|
}
|
|
261
145
|
}
|