@tarojs/plugin-platform-harmony-ets 4.0.0-beta.5 → 4.0.0-beta.50
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/base/system.ts +53 -20
- package/dist/apis/canvas/index.ts +10 -1
- package/dist/apis/device/clipboard.ts +4 -0
- package/dist/apis/framework/index.ts +1 -5
- package/dist/apis/index.ts +27 -17
- package/dist/apis/network/request.ts +5 -5
- package/dist/apis/route/index.ts +15 -0
- package/dist/apis/storage/index.ts +148 -80
- package/dist/apis/ui/animation/animation.ts +71 -28
- package/dist/apis/ui/background.ts +2 -1
- package/dist/apis/ui/interaction/index.ts +40 -49
- package/dist/apis/ui/navigation-bar/index.ts +1 -1
- package/dist/apis/utils/index.ts +1 -1
- package/dist/apis/wxml/IntersectionObserver.ts +18 -10
- package/dist/apis/wxml/index.ts +2 -0
- package/dist/apis/wxml/selectorQuery.ts +18 -9
- package/dist/components-harmony-ets/button.ets +48 -34
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +69 -61
- package/dist/components-harmony-ets/form.ets +51 -29
- package/dist/components-harmony-ets/icon.ets +31 -19
- package/dist/components-harmony-ets/image.ets +27 -14
- package/dist/components-harmony-ets/index.ets +85 -0
- package/dist/components-harmony-ets/innerHtml.ets +11 -6
- package/dist/components-harmony-ets/input.ets +41 -40
- package/dist/components-harmony-ets/label.ets +69 -42
- package/dist/components-harmony-ets/movableArea.ets +126 -0
- package/dist/components-harmony-ets/movableView.ets +73 -0
- package/dist/components-harmony-ets/navigationBar.ets +25 -0
- package/dist/components-harmony-ets/pageMeta.ets +28 -0
- package/dist/components-harmony-ets/picker.ets +42 -38
- package/dist/components-harmony-ets/progress.ets +52 -0
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +71 -64
- package/dist/components-harmony-ets/richText.ets +14 -30
- package/dist/components-harmony-ets/scrollView.ets +61 -57
- package/dist/components-harmony-ets/slider.ets +15 -14
- package/dist/components-harmony-ets/style.ets +390 -130
- package/dist/components-harmony-ets/swiper.ets +38 -20
- package/dist/components-harmony-ets/switch.ets +30 -28
- package/dist/components-harmony-ets/{index.ts → tag.ts} +2 -0
- package/dist/components-harmony-ets/text.ets +121 -51
- package/dist/components-harmony-ets/textArea.ets +35 -34
- package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
- package/dist/components-harmony-ets/utils/flexManager.ets +47 -19
- package/dist/components-harmony-ets/utils/helper.ets +17 -5
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
- package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
- package/dist/components-harmony-ets/utils/index.ts +50 -51
- package/dist/components-harmony-ets/utils/styles.ets +170 -93
- package/dist/components-harmony-ets/video.ets +34 -20
- package/dist/components-harmony-ets/view.ets +63 -52
- package/dist/components-harmony-ets/webView.ets +40 -34
- package/dist/index.d.ts +152 -0
- package/dist/index.js +82 -39
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/document.ts +6 -4
- package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
- package/dist/runtime-ets/bom/window.ts +7 -0
- package/dist/runtime-ets/current.ts +3 -0
- package/dist/runtime-ets/dom/bind.ts +31 -13
- package/dist/runtime-ets/dom/cssNesting.ts +393 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +25 -39
- package/dist/runtime-ets/dom/document.ts +22 -8
- package/dist/runtime-ets/dom/element/canvas.ts +136 -0
- package/dist/runtime-ets/dom/element/element.ts +317 -51
- package/dist/runtime-ets/dom/element/form.ts +23 -26
- package/dist/runtime-ets/dom/element/index.ts +24 -2
- package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
- package/dist/runtime-ets/dom/element/movableView.ts +193 -0
- package/dist/runtime-ets/dom/element/normal.ts +35 -8
- package/dist/runtime-ets/dom/element/progress.ts +12 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
- package/dist/runtime-ets/dom/element/text.ts +1 -8
- package/dist/runtime-ets/dom/element/video.ts +5 -3
- package/dist/runtime-ets/dom/element/webView.ts +11 -3
- package/dist/runtime-ets/dom/event.ts +0 -1
- package/dist/runtime-ets/dom/eventTarget.ts +0 -3
- package/dist/runtime-ets/dom/node.ts +46 -28
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +334 -230
- package/dist/runtime-ets/dom/stylesheet/index.ts +28 -308
- package/dist/runtime-ets/dom/stylesheet/type.ts +40 -9
- package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
- package/dist/runtime-ets/index.ts +2 -2
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/utils/index.ts +66 -11
- package/dist/runtime-ets/utils/info.ts +1 -1
- package/dist/runtime-framework/react/app.ts +7 -2
- package/dist/runtime-framework/react/index.ts +0 -2
- package/dist/runtime-framework/react/native-page.ts +32 -14
- package/dist/runtime-framework/react/page.ts +3 -8
- package/dist/runtime-framework/solid/app.ts +25 -45
- package/dist/runtime-framework/solid/connect.ts +21 -3
- package/dist/runtime-framework/solid/hooks.ts +16 -11
- package/dist/runtime-framework/solid/index.ts +6 -2
- package/dist/runtime-framework/solid/page.ts +84 -30
- package/dist/runtime-framework/solid/reconciler/props.ts +65 -20
- package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
- package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
- package/dist/runtime-framework/solid/utils/index.ts +0 -2
- package/dist/runtime-utils.d.ts +827 -0
- package/dist/runtime-utils.js +399 -188
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +399 -188
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +13 -13
- package/static/media/cancel.svg +1 -1
- package/static/media/circle.svg +1 -1
- package/static/media/clear.svg +1 -1
- package/static/media/download.svg +1 -1
- package/static/media/info.svg +1 -1
- package/static/media/info_circle.svg +1 -1
- package/static/media/search.svg +1 -1
- package/static/media/success.svg +1 -1
- package/static/media/success_no_circle.svg +1 -1
- package/static/media/warn.svg +1 -1
- package/types/harmony.d.ts +4 -0
- package/types/index.d.ts +4 -0
- /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import matrix4 from '@ohos.matrix4'
|
|
2
|
+
import { isUndefined } from '@tarojs/shared'
|
|
2
3
|
|
|
3
4
|
import { temporarilyNotSupport } from '../../utils'
|
|
4
5
|
|
|
@@ -71,6 +72,9 @@ export class Animation implements Taro.Animation {
|
|
|
71
72
|
transformOrigin,
|
|
72
73
|
rule: Object.assign({}, this.rule)
|
|
73
74
|
})
|
|
75
|
+
if (this.rule.transform) {
|
|
76
|
+
this.rule.transform = Object.assign({}, this.rule.transform)
|
|
77
|
+
}
|
|
74
78
|
return this
|
|
75
79
|
}
|
|
76
80
|
|
|
@@ -85,92 +89,137 @@ export class Animation implements Taro.Animation {
|
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
rotate (angle: number): Taro.Animation {
|
|
88
|
-
this.rule.
|
|
92
|
+
if (!this.rule.transform) {
|
|
93
|
+
this.rule.transform = {}
|
|
94
|
+
}
|
|
95
|
+
this.rule.transform.Rotate = { x: 0, y: 0, z: 1, angle }
|
|
89
96
|
return this
|
|
90
97
|
}
|
|
91
98
|
|
|
92
99
|
rotate3d (x: number, y?: number | undefined, z?: number | undefined, angle?: number | undefined): Taro.Animation {
|
|
93
|
-
this.rule.
|
|
100
|
+
if (!this.rule.transform) {
|
|
101
|
+
this.rule.transform = {}
|
|
102
|
+
}
|
|
103
|
+
this.rule.transform.Rotate = { x, y, z, angle }
|
|
94
104
|
return this
|
|
95
105
|
}
|
|
96
106
|
|
|
97
107
|
rotateX (angle: number): Taro.Animation {
|
|
98
|
-
this.rule.
|
|
108
|
+
if (!this.rule.transform) {
|
|
109
|
+
this.rule.transform = {}
|
|
110
|
+
}
|
|
111
|
+
this.rule.transform.Rotate = { x: 1, y: 0, z: 0, angle }
|
|
99
112
|
return this
|
|
100
113
|
}
|
|
101
114
|
|
|
102
115
|
rotateY (angle: number): Taro.Animation {
|
|
103
|
-
this.rule.
|
|
116
|
+
if (!this.rule.transform) {
|
|
117
|
+
this.rule.transform = {}
|
|
118
|
+
}
|
|
119
|
+
this.rule.transform.Rotate = { x: 0, y: 1, z: 0, angle }
|
|
104
120
|
return this
|
|
105
121
|
}
|
|
106
122
|
|
|
107
123
|
rotateZ (angle: number): Taro.Animation {
|
|
108
|
-
this.rule.
|
|
124
|
+
if (!this.rule.transform) {
|
|
125
|
+
this.rule.transform = {}
|
|
126
|
+
}
|
|
127
|
+
this.rule.transform.Rotate = { x: 0, y: 0, z: 1, angle }
|
|
109
128
|
return this
|
|
110
129
|
}
|
|
111
130
|
|
|
112
131
|
scale (sx: number, sy?: number | undefined): Taro.Animation {
|
|
113
|
-
this.rule.
|
|
132
|
+
if (!this.rule.transform) {
|
|
133
|
+
this.rule.transform = {}
|
|
134
|
+
}
|
|
135
|
+
this.rule.transform.Scale = { x: sx, y: isUndefined(sy) ? sx : sy }
|
|
114
136
|
return this
|
|
115
137
|
}
|
|
116
138
|
|
|
117
139
|
scale3d (sx: number, sy: number, sz: number): Taro.Animation {
|
|
118
|
-
this.rule.
|
|
140
|
+
if (!this.rule.transform) {
|
|
141
|
+
this.rule.transform = {}
|
|
142
|
+
}
|
|
143
|
+
this.rule.transform.Scale = { x: sx, y: sy, z: sz }
|
|
119
144
|
return this
|
|
120
145
|
}
|
|
121
146
|
|
|
122
147
|
scaleX (scale: number): Taro.Animation {
|
|
123
|
-
this.rule.
|
|
148
|
+
if (!this.rule.transform) {
|
|
149
|
+
this.rule.transform = {}
|
|
150
|
+
}
|
|
151
|
+
this.rule.transform.Scale = { x: scale }
|
|
124
152
|
return this
|
|
125
153
|
}
|
|
126
154
|
|
|
127
155
|
scaleY (scale: number): Taro.Animation {
|
|
128
|
-
this.rule.
|
|
156
|
+
if (!this.rule.transform) {
|
|
157
|
+
this.rule.transform = {}
|
|
158
|
+
}
|
|
159
|
+
this.rule.transform.Scale = { y: scale }
|
|
129
160
|
return this
|
|
130
161
|
}
|
|
131
162
|
|
|
132
163
|
scaleZ (scale: number): Taro.Animation {
|
|
133
|
-
this.rule.
|
|
164
|
+
if (!this.rule.transform) {
|
|
165
|
+
this.rule.transform = {}
|
|
166
|
+
}
|
|
167
|
+
this.rule.transform.Scale = { z: scale }
|
|
134
168
|
return this
|
|
135
169
|
}
|
|
136
170
|
|
|
137
171
|
skew (ax: number, ay: number): Taro.Animation {
|
|
138
|
-
|
|
172
|
+
temporarilyNotSupport('animation.skew:' + `${ax}, ${ay}`)(ax, ay)
|
|
139
173
|
return this
|
|
140
174
|
}
|
|
141
175
|
|
|
142
176
|
skewX (angle: number): Taro.Animation {
|
|
143
|
-
|
|
177
|
+
temporarilyNotSupport('animation.skewX:' + angle)(angle)
|
|
144
178
|
return this
|
|
145
179
|
}
|
|
146
180
|
|
|
147
181
|
skewY (angle: number): Taro.Animation {
|
|
148
|
-
|
|
182
|
+
temporarilyNotSupport('animation.skewY:' + angle)(angle)
|
|
149
183
|
return this
|
|
150
184
|
}
|
|
151
185
|
|
|
152
186
|
translate (tx?: number | undefined, ty?: number | undefined): Taro.Animation {
|
|
153
|
-
this.rule.
|
|
187
|
+
if (!this.rule.transform) {
|
|
188
|
+
this.rule.transform = {}
|
|
189
|
+
}
|
|
190
|
+
this.rule.transform.Translate = { x: tx, y: ty }
|
|
154
191
|
return this
|
|
155
192
|
}
|
|
156
193
|
|
|
157
194
|
translate3d (tx?: number | undefined, ty?: number | undefined, tz?: number | undefined): Taro.Animation {
|
|
158
|
-
this.rule.
|
|
195
|
+
if (!this.rule.transform) {
|
|
196
|
+
this.rule.transform = {}
|
|
197
|
+
}
|
|
198
|
+
this.rule.transform.Translate = { x: tx, y: ty, z: tz }
|
|
159
199
|
return this
|
|
160
200
|
}
|
|
161
201
|
|
|
162
202
|
translateX (translation: number): Taro.Animation {
|
|
163
|
-
this.rule.
|
|
203
|
+
if (!this.rule.transform) {
|
|
204
|
+
this.rule.transform = {}
|
|
205
|
+
}
|
|
206
|
+
this.rule.transform.Translate = { x: translation }
|
|
164
207
|
return this
|
|
165
208
|
}
|
|
166
209
|
|
|
167
210
|
translateY (translation: number): Taro.Animation {
|
|
168
|
-
this.rule.
|
|
211
|
+
if (!this.rule.transform) {
|
|
212
|
+
this.rule.transform = {}
|
|
213
|
+
}
|
|
214
|
+
this.rule.transform.Translate = { y: translation }
|
|
169
215
|
return this
|
|
170
216
|
}
|
|
171
217
|
|
|
172
218
|
translateZ (translation: number): Taro.Animation {
|
|
173
|
-
this.rule.
|
|
219
|
+
if (!this.rule.transform) {
|
|
220
|
+
this.rule.transform = {}
|
|
221
|
+
}
|
|
222
|
+
this.rule.transform.Translate = { z: translation }
|
|
174
223
|
return this
|
|
175
224
|
}
|
|
176
225
|
|
|
@@ -185,23 +234,17 @@ export class Animation implements Taro.Animation {
|
|
|
185
234
|
}
|
|
186
235
|
|
|
187
236
|
width (value: string | number): Taro.Animation {
|
|
188
|
-
this.rule.
|
|
189
|
-
...this.rule.size,
|
|
190
|
-
width: value
|
|
191
|
-
}
|
|
237
|
+
this.rule.width = value
|
|
192
238
|
return this
|
|
193
239
|
}
|
|
194
240
|
|
|
195
241
|
height (value: string | number): Taro.Animation {
|
|
196
|
-
this.rule.
|
|
197
|
-
...this.rule.size,
|
|
198
|
-
height: value
|
|
199
|
-
}
|
|
242
|
+
this.rule.height = value
|
|
200
243
|
return this
|
|
201
244
|
}
|
|
202
245
|
|
|
203
246
|
left (value: string | number): Taro.Animation {
|
|
204
|
-
|
|
247
|
+
this.rule.left = value
|
|
205
248
|
return this
|
|
206
249
|
}
|
|
207
250
|
|
|
@@ -211,7 +254,7 @@ export class Animation implements Taro.Animation {
|
|
|
211
254
|
}
|
|
212
255
|
|
|
213
256
|
top (value: string | number): Taro.Animation {
|
|
214
|
-
|
|
257
|
+
this.rule.top = value
|
|
215
258
|
return this
|
|
216
259
|
}
|
|
217
260
|
|
|
@@ -11,7 +11,8 @@ export function setBackgroundColor(options: Taro.setBackgroundColor.Option) {
|
|
|
11
11
|
|
|
12
12
|
return new Promise((resolve, reject) => {
|
|
13
13
|
eventCenter.trigger('__taroPageStyle', {
|
|
14
|
-
backgroundColor: options.
|
|
14
|
+
backgroundColor: options.backgroundColorBottom || options.backgroundColor,
|
|
15
|
+
backgroundColorContext: options.backgroundColorTop || options.backgroundColor
|
|
15
16
|
})
|
|
16
17
|
|
|
17
18
|
return handle.success({}, { resolve, reject })
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import promptAction from '@ohos.promptAction'
|
|
2
2
|
|
|
3
3
|
import { callAsyncFail, callAsyncSuccess, temporarilyNotSupport, validateParams } from '../../utils'
|
|
4
4
|
|
|
@@ -29,7 +29,7 @@ export function showToast (options) {
|
|
|
29
29
|
return callAsyncFail(reject, res, options)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
promptAction.showToast({
|
|
33
33
|
message: options.title,
|
|
34
34
|
duration: options.duration,
|
|
35
35
|
bottom: options.bottom
|
|
@@ -72,37 +72,20 @@ export function showModal (options) {
|
|
|
72
72
|
})
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
return new Promise(resolve => {
|
|
75
|
+
return new Promise((resolve, reject) => {
|
|
76
76
|
const modalOptions = {
|
|
77
77
|
title,
|
|
78
78
|
message: content,
|
|
79
79
|
buttons: buttons,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
},
|
|
90
|
-
options
|
|
91
|
-
)
|
|
92
|
-
} else {
|
|
93
|
-
callAsyncSuccess(
|
|
94
|
-
resolve,
|
|
95
|
-
{
|
|
96
|
-
...resCallback('showModal'),
|
|
97
|
-
confirm: false,
|
|
98
|
-
cancel: true
|
|
99
|
-
},
|
|
100
|
-
options
|
|
101
|
-
)
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
// 鸿蒙没有失败方法,只有取消
|
|
105
|
-
cancel: (_) => {
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
promptAction.showDialog(modalOptions, (error, data) => {
|
|
83
|
+
if (error) {
|
|
84
|
+
const res = { errMsg: error }
|
|
85
|
+
callAsyncFail(reject, res, options)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (data.index === 0 && showCancel) {
|
|
106
89
|
callAsyncSuccess(
|
|
107
90
|
resolve,
|
|
108
91
|
{
|
|
@@ -112,10 +95,19 @@ export function showModal (options) {
|
|
|
112
95
|
},
|
|
113
96
|
options
|
|
114
97
|
)
|
|
98
|
+
} else {
|
|
99
|
+
callAsyncSuccess(
|
|
100
|
+
resolve,
|
|
101
|
+
{
|
|
102
|
+
...resCallback('showModal'),
|
|
103
|
+
confirm: true,
|
|
104
|
+
cancel: false,
|
|
105
|
+
content: null
|
|
106
|
+
},
|
|
107
|
+
options
|
|
108
|
+
)
|
|
115
109
|
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
prompt.showDialog(modalOptions)
|
|
110
|
+
})
|
|
119
111
|
})
|
|
120
112
|
}
|
|
121
113
|
|
|
@@ -152,37 +144,36 @@ export function showActionSheet (options) {
|
|
|
152
144
|
|
|
153
145
|
const actionSheetOptions = {
|
|
154
146
|
title,
|
|
155
|
-
buttons
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
...data,
|
|
161
|
-
...resCallback('showActionSheet')
|
|
162
|
-
},
|
|
163
|
-
options
|
|
164
|
-
)
|
|
165
|
-
},
|
|
166
|
-
// 取消方法,并非失败
|
|
167
|
-
fail: (data) => {
|
|
147
|
+
buttons
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
promptAction.showActionMenu(actionSheetOptions, (error, data) => {
|
|
151
|
+
if (error) {
|
|
168
152
|
callAsyncFail(
|
|
169
153
|
reject,
|
|
170
154
|
{
|
|
171
155
|
...data,
|
|
172
|
-
errMsg: data.errMsg
|
|
156
|
+
errMsg: data.errMsg?.replace('showActionMenu', 'showActionSheet')
|
|
173
157
|
},
|
|
174
158
|
options
|
|
175
159
|
)
|
|
176
160
|
}
|
|
177
|
-
}
|
|
178
161
|
|
|
179
|
-
|
|
162
|
+
callAsyncSuccess(
|
|
163
|
+
resolve,
|
|
164
|
+
{
|
|
165
|
+
...data,
|
|
166
|
+
...resCallback('showActionSheet')
|
|
167
|
+
},
|
|
168
|
+
options
|
|
169
|
+
)
|
|
170
|
+
})
|
|
180
171
|
})
|
|
181
172
|
}
|
|
182
173
|
|
|
183
174
|
export function hideToast (options) {
|
|
184
175
|
return new Promise(resolve => {
|
|
185
|
-
|
|
176
|
+
promptAction.showToast({
|
|
186
177
|
message: '关闭中',
|
|
187
178
|
duration: 10,
|
|
188
179
|
bottom: '9999px'
|
|
@@ -19,7 +19,7 @@ export const setNavigationBarTitle: typeof Taro.setNavigationBarTitle = function
|
|
|
19
19
|
|
|
20
20
|
export const setNavigationBarColor: typeof Taro.setNavigationBarColor = function (options) {
|
|
21
21
|
const { success, fail, complete } = options || {}
|
|
22
|
-
const handle = new MethodHandler({ name: '
|
|
22
|
+
const handle = new MethodHandler({ name: 'setNavigationBarColor', success, fail, complete })
|
|
23
23
|
|
|
24
24
|
return new Promise((resolve, reject) => {
|
|
25
25
|
eventCenter.trigger('__taroNavigationStyle', {
|
package/dist/apis/utils/index.ts
CHANGED
|
@@ -19,7 +19,7 @@ export function temporarilyNotSupport (name: string, recommended?: string) {
|
|
|
19
19
|
return (option = {}, ...args) => {
|
|
20
20
|
const { success, fail, complete } = option as any
|
|
21
21
|
const handle = new MethodHandler({ name, success, fail, complete })
|
|
22
|
-
let errMsg =
|
|
22
|
+
let errMsg = `暂时不支持 API ${name}`
|
|
23
23
|
if (recommended) {
|
|
24
24
|
errMsg += `, 请使用 ${recommended}`
|
|
25
25
|
}
|
|
@@ -19,31 +19,33 @@ export class IntersectionObserver implements Taro.IntersectionObserver {
|
|
|
19
19
|
constructor(component: any, options: Taro.createIntersectionObserver.Option = {}) {
|
|
20
20
|
const taro = (Current as any).taro
|
|
21
21
|
const page = taro.getCurrentInstance().page
|
|
22
|
-
|
|
23
|
-
this._component = component ||
|
|
22
|
+
|
|
23
|
+
this._component = component || getPageScrollerOrNode(page?.node, page)
|
|
24
24
|
Object.assign(this._options, options)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
public disconnect (): void {
|
|
28
|
-
if (this._observerNodes) {
|
|
28
|
+
if (this._observerNodes && this._component) {
|
|
29
29
|
if (this._observerNodes instanceof Array) {
|
|
30
30
|
this._observerNodes.forEach((n: TaroElement & any) => {
|
|
31
31
|
disconnectEvent(n, VISIBLE_CHANGE_EVENT_NAME)
|
|
32
32
|
// @ts-ignore
|
|
33
|
-
n._nodeInfo
|
|
33
|
+
n._nodeInfo.thresholds = null
|
|
34
34
|
})
|
|
35
35
|
} else {
|
|
36
36
|
disconnectEvent(this._observerNodes, VISIBLE_CHANGE_EVENT_NAME)
|
|
37
37
|
// @ts-ignore
|
|
38
38
|
if (this._observerNodes._nodeInfo) {
|
|
39
39
|
// @ts-ignore
|
|
40
|
-
this._observerNodes._nodeInfo
|
|
40
|
+
this._observerNodes._nodeInfo.thresholds = null
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
public observe (targetSelector: string, callback: Taro.IntersectionObserver.ObserveCallback): void {
|
|
47
|
+
if (!this._component) return
|
|
48
|
+
|
|
47
49
|
const { observeAll, thresholds } = this._options
|
|
48
50
|
const node = findChildNodeWithDFS(this._component, targetSelector, observeAll)
|
|
49
51
|
this._observerNodes = node
|
|
@@ -52,20 +54,24 @@ export class IntersectionObserver implements Taro.IntersectionObserver {
|
|
|
52
54
|
if (node instanceof Array) {
|
|
53
55
|
node.forEach(n => {
|
|
54
56
|
// @ts-ignore
|
|
55
|
-
n._nodeInfo
|
|
57
|
+
n._nodeInfo.thresholds = thresholds
|
|
56
58
|
|
|
57
59
|
setNodeEventCallbackAndTriggerComponentUpdate(n, VISIBLE_CHANGE_EVENT_NAME, (isVisible: boolean, currentRatio: number) => {
|
|
58
|
-
callback(this.handleResult(isVisible, currentRatio))
|
|
60
|
+
callback(this.handleResult(isVisible, currentRatio, n))
|
|
59
61
|
})
|
|
60
62
|
})
|
|
61
63
|
} else {
|
|
62
64
|
// @ts-ignore
|
|
63
|
-
node._nodeInfo
|
|
65
|
+
node._nodeInfo.thresholds = thresholds
|
|
64
66
|
|
|
65
67
|
setNodeEventCallbackAndTriggerComponentUpdate(node, VISIBLE_CHANGE_EVENT_NAME, (isVisible: boolean, currentRatio: number) => {
|
|
66
|
-
callback(this.handleResult(isVisible, currentRatio))
|
|
68
|
+
callback(this.handleResult(isVisible, currentRatio, node))
|
|
67
69
|
})
|
|
68
70
|
}
|
|
71
|
+
} else {
|
|
72
|
+
callback({
|
|
73
|
+
errMsg: 'IntersectionObserver.observe:fail cannot find the node for selector.'
|
|
74
|
+
})
|
|
69
75
|
}
|
|
70
76
|
}
|
|
71
77
|
|
|
@@ -80,8 +86,10 @@ export class IntersectionObserver implements Taro.IntersectionObserver {
|
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
// @ts-ignore
|
|
83
|
-
private handleResult (isVisible: boolean, currentRatio: number): Taro.IntersectionObserver.ObserveCallbackResult {
|
|
89
|
+
private handleResult (isVisible: boolean, currentRatio: number, node: TaroElement): Taro.IntersectionObserver.ObserveCallbackResult {
|
|
84
90
|
const result = {
|
|
91
|
+
id: node.id,
|
|
92
|
+
dataset: node.dataset,
|
|
85
93
|
intersectionRatio: currentRatio,
|
|
86
94
|
// TODO 未做,等待能拿到element的info信息
|
|
87
95
|
boundingClientRect: {
|
package/dist/apis/wxml/index.ts
CHANGED
|
@@ -194,22 +194,31 @@ function queryBat (queue, cb) {
|
|
|
194
194
|
|
|
195
195
|
arr = []
|
|
196
196
|
traversalDFSDom(element)
|
|
197
|
-
queue.forEach(item => {
|
|
197
|
+
queue.forEach((item) => {
|
|
198
198
|
const { selector, single, fields } = item
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
|
|
200
|
+
if (single) {
|
|
201
|
+
const dom = querySelector(selector, !single)[0]
|
|
202
202
|
// eslint-disable-next-line no-async-promise-executor
|
|
203
|
-
|
|
203
|
+
result.push(new Promise(async resolve => {
|
|
204
204
|
await setNodeEventCallbackAndTriggerComponentUpdate(dom, AREA_CHANGE_EVENT_NAME, null, true)
|
|
205
|
-
|
|
206
205
|
resolve(filter(fields, dom))
|
|
207
|
-
})
|
|
208
|
-
}
|
|
206
|
+
}))
|
|
207
|
+
} else {
|
|
208
|
+
const nodeList = querySelector(selector, !single)
|
|
209
|
+
result.push(nodeList.map(dom => {
|
|
210
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
211
|
+
return new Promise(async resolve => {
|
|
212
|
+
await setNodeEventCallbackAndTriggerComponentUpdate(dom, AREA_CHANGE_EVENT_NAME, null, true)
|
|
213
|
+
|
|
214
|
+
resolve(filter(fields, dom))
|
|
215
|
+
})
|
|
216
|
+
}))
|
|
217
|
+
}
|
|
209
218
|
})
|
|
210
219
|
|
|
211
220
|
Promise.all(result.map(item => {
|
|
212
|
-
return Promise.all(item)
|
|
221
|
+
return item instanceof Array ? Promise.all(item) : item
|
|
213
222
|
})).then(data => {
|
|
214
223
|
cb(data)
|
|
215
224
|
})
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { eventHandler, createTaroEvent, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
|
-
import { createLazyChildren } from './render'
|
|
3
2
|
import commonStyleModify from './style'
|
|
4
3
|
import { BUTTON_THEME_COLOR } from './utils/constant/style'
|
|
5
4
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
@@ -66,13 +65,13 @@ function getThemeAttributes (node: TaroButtonElement): TaroStyleType {
|
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
function getButtonWidth (node: TaroButtonElement) {
|
|
68
|
+
function getButtonWidth (node: TaroButtonElement): string | number {
|
|
70
69
|
const isMini = node._attrs.size === 'mini'
|
|
71
70
|
|
|
72
71
|
return isMini ? convertNumber2VP(120) : '100%'
|
|
73
72
|
}
|
|
74
73
|
|
|
75
|
-
function getButtonHeight (node: TaroButtonElement) {
|
|
74
|
+
function getButtonHeight (node: TaroButtonElement): string | number {
|
|
76
75
|
const isMini = node._attrs.size === 'mini'
|
|
77
76
|
|
|
78
77
|
return isMini ? convertNumber2VP(60) : convertNumber2VP(92)
|
|
@@ -94,38 +93,53 @@ function getButtonMinHeight (node: TaroButtonElement): string | number | undefin
|
|
|
94
93
|
return getButtonHeight(node)
|
|
95
94
|
}
|
|
96
95
|
|
|
97
|
-
@
|
|
98
|
-
export default
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
96
|
+
@Component
|
|
97
|
+
export default struct TaroButton {
|
|
98
|
+
@Builder customBuilder() {}
|
|
99
|
+
@BuilderParam createLazyChildren: (node: TaroButtonElement) => void = this.customBuilder
|
|
100
|
+
@ObjectLink node: TaroButtonElement
|
|
101
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
102
|
+
|
|
103
|
+
aboutToAppear(): void {
|
|
104
|
+
if (this.node) {
|
|
105
|
+
this.node._instance = this
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
eventHandler(event, eventName, node)
|
|
108
|
+
|
|
109
|
+
build() {
|
|
110
|
+
Button({ stateEffect: !this.node._attrs.disabled }) {
|
|
111
|
+
if (this.node._attrs.loading) {
|
|
112
|
+
Row() {
|
|
113
|
+
LoadingProgress()
|
|
114
|
+
.width(20).height(20)
|
|
115
|
+
.color(getThemeAttributes(this.node).color)
|
|
116
|
+
this.createLazyChildren(this.node)
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
this.createLazyChildren(this.node)
|
|
120
|
+
}
|
|
123
121
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
122
|
+
.themeStyles(getThemeAttributes(this.node))
|
|
123
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
124
|
+
.constraintSize({
|
|
125
|
+
minWidth: this.node.hmStyle?.minWidth || getButtonMinWidth(this.node),
|
|
126
|
+
minHeight: this.node.hmStyle?.minHeight || getButtonMinHeight(this.node),
|
|
127
|
+
maxWidth: this.node.hmStyle?.maxWidth,
|
|
128
|
+
maxHeight: this.node.hmStyle?.maxHeight,
|
|
129
|
+
})
|
|
130
|
+
.type(ButtonType.Normal)
|
|
131
|
+
.onClick((e: ClickEvent) => {
|
|
132
|
+
if (this.node._attrs.formType && ['submit', 'reset'].includes(this.node._attrs.formType)) {
|
|
133
|
+
const eventName = this.node._attrs.formType + '-btn'
|
|
134
|
+
const event: TaroEvent = createTaroEvent(eventName, {}, this.node)
|
|
135
|
+
eventHandler(event, eventName, this.node)
|
|
136
|
+
}
|
|
137
|
+
eventHandler(e, 'click', this.node)
|
|
138
|
+
})
|
|
139
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
140
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
141
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
142
|
+
}))
|
|
143
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
144
|
+
}
|
|
131
145
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { TaroAny, TaroCanvasElement } from '@tarojs/runtime'
|
|
2
|
+
import { cancelAnimationFrame, requestAnimationFrame } from '@tarojs/runtime'
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
|
|
5
|
+
@Component
|
|
6
|
+
export default struct TaroCanvas {
|
|
7
|
+
@ObjectLink node: TaroCanvasElement
|
|
8
|
+
rafId: number = 0
|
|
9
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
10
|
+
|
|
11
|
+
aboutToAppear(): void {
|
|
12
|
+
if (this.node) {
|
|
13
|
+
this.node._instance = this
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
aboutToDisappear() {
|
|
18
|
+
if(this.rafId) {
|
|
19
|
+
cancelAnimationFrame(this.rafId)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
build() {
|
|
24
|
+
Canvas(this.node._context)
|
|
25
|
+
.attributeModifier(commonStyleModify.setNode(this.node as TaroAny, {
|
|
26
|
+
width: '100%',
|
|
27
|
+
height: '100%',
|
|
28
|
+
backgroundColor: '#ffff00'
|
|
29
|
+
}).setAnimationStyle(this.overwriteStyle))
|
|
30
|
+
.onReady(() => {
|
|
31
|
+
const context = this.node._context
|
|
32
|
+
|
|
33
|
+
const draw = () => {
|
|
34
|
+
if (this.node._drawList.length) {
|
|
35
|
+
while (this.node._drawList.length) {
|
|
36
|
+
const item = this.node._drawList.shift()
|
|
37
|
+
if (item) {
|
|
38
|
+
if (typeof context[item.key] === 'function') {
|
|
39
|
+
context[item.key](...[].concat(item.value))
|
|
40
|
+
} else {
|
|
41
|
+
context[item.key] = item.value
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
this.rafId = requestAnimationFrame(draw)
|
|
47
|
+
}
|
|
48
|
+
draw()
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
}
|