@tarojs/plugin-platform-harmony-ets 4.0.0-beta.13 → 4.0.0-beta.131
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 +60 -25
- package/dist/apis/base/weapp/life-cycle.ts +1 -1
- package/dist/apis/canvas/index.ts +10 -1
- package/dist/apis/device/clipboard.ts +23 -8
- package/dist/apis/framework/index.ts +1 -1
- package/dist/apis/index.ts +24 -16
- package/dist/apis/media/image/index.ts +169 -17
- package/dist/apis/network/downloadFile.ts +3 -1
- package/dist/apis/network/uploadFile.ts +3 -1
- package/dist/apis/route/index.ts +1 -2
- package/dist/apis/storage/index.ts +135 -131
- package/dist/apis/ui/animation/animation.ts +71 -29
- package/dist/apis/ui/background.ts +3 -2
- package/dist/apis/ui/interaction/index.ts +58 -59
- package/dist/apis/ui/navigation-bar/index.ts +2 -2
- package/dist/apis/ui/pull-down-refresh.ts +9 -3
- package/dist/apis/ui/scroll/index.ts +5 -5
- package/dist/apis/ui/tab-bar.ts +4 -5
- package/dist/apis/utils/handler.ts +2 -1
- package/dist/apis/utils/index.ts +20 -2
- package/dist/apis/utils/permissions.ts +6 -0
- package/dist/apis/wxml/IntersectionObserver.ts +18 -10
- package/dist/apis/wxml/selectorQuery.ts +26 -13
- package/dist/components-harmony-ets/button.ets +36 -9
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +69 -60
- package/dist/components-harmony-ets/form.ets +33 -15
- package/dist/components-harmony-ets/icon.ets +16 -8
- package/dist/components-harmony-ets/image.ets +22 -6
- package/dist/components-harmony-ets/index.ets +39 -0
- package/dist/components-harmony-ets/innerHtml.ets +6 -5
- package/dist/components-harmony-ets/input.ets +63 -37
- package/dist/components-harmony-ets/label.ets +43 -21
- package/dist/components-harmony-ets/listView.ets +32 -0
- package/dist/components-harmony-ets/movableArea.ets +110 -51
- package/dist/components-harmony-ets/movableView.ets +74 -47
- package/dist/components-harmony-ets/navigationBar.ets +65 -0
- package/dist/components-harmony-ets/pageMeta.ets +94 -0
- package/dist/components-harmony-ets/picker.ets +36 -33
- package/dist/components-harmony-ets/progress.ets +31 -24
- package/dist/components-harmony-ets/pseudo.ets +43 -35
- package/dist/components-harmony-ets/radio.ets +75 -66
- package/dist/components-harmony-ets/richText.ets +4 -25
- package/dist/components-harmony-ets/scrollList.ets +108 -0
- package/dist/components-harmony-ets/scrollView.ets +53 -44
- package/dist/components-harmony-ets/slider.ets +19 -15
- package/dist/components-harmony-ets/stickySection.ets +42 -0
- package/dist/components-harmony-ets/style.ets +274 -38
- package/dist/components-harmony-ets/swiper.ets +42 -5
- package/dist/components-harmony-ets/switch.ets +36 -32
- package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
- package/dist/components-harmony-ets/text.ets +102 -46
- package/dist/components-harmony-ets/textArea.ets +49 -34
- package/dist/components-harmony-ets/utils/AttributeManager.ets +2 -2
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -2
- package/dist/components-harmony-ets/utils/flexManager.ets +43 -13
- package/dist/components-harmony-ets/utils/helper.ets +20 -8
- 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 +54 -50
- package/dist/components-harmony-ets/utils/styles.ets +165 -104
- package/dist/components-harmony-ets/video.ets +28 -20
- package/dist/components-harmony-ets/view.ets +44 -38
- package/dist/components-harmony-ets/webView.ets +6 -5
- package/dist/index.d.ts +152 -0
- package/dist/index.js +73 -44
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/URL.ts +2 -0
- package/dist/runtime-ets/bom/document.ts +5 -4
- package/dist/runtime-ets/bom/getComputedStyle.ts +2 -3
- package/dist/runtime-ets/bom/history.ts +1 -0
- package/dist/runtime-ets/bom/location.ts +1 -0
- package/dist/runtime-ets/bom/navigator.ts +1 -21
- package/dist/runtime-ets/bom/raf.ts +1 -37
- package/dist/runtime-ets/bom/window.ts +9 -5
- package/dist/runtime-ets/constant.ts +17 -10
- package/dist/runtime-ets/current.ts +26 -2
- package/dist/runtime-ets/dom/bind.ts +28 -12
- package/dist/runtime-ets/dom/class-list.ts +2 -2
- package/dist/runtime-ets/dom/cssNesting.ts +419 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +28 -42
- package/dist/runtime-ets/dom/document.ts +9 -12
- package/dist/runtime-ets/dom/element/canvas.ts +137 -0
- package/dist/runtime-ets/dom/element/element.ts +355 -71
- package/dist/runtime-ets/dom/element/form.ts +26 -22
- package/dist/runtime-ets/dom/element/index.ts +22 -2
- package/dist/runtime-ets/dom/element/movableArea.ts +0 -1
- package/dist/runtime-ets/dom/element/movableView.ts +238 -2
- package/dist/runtime-ets/dom/element/normal.ts +27 -6
- package/dist/runtime-ets/dom/element/progress.ts +0 -2
- package/dist/runtime-ets/dom/element/text.ts +0 -8
- package/dist/runtime-ets/dom/element/video.ts +4 -4
- package/dist/runtime-ets/dom/element/webView.ts +4 -5
- package/dist/runtime-ets/dom/event-source.ts +1 -0
- package/dist/runtime-ets/dom/event.ts +3 -5
- package/dist/runtime-ets/dom/eventTarget.ts +3 -4
- package/dist/runtime-ets/dom/node.ts +53 -22
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +401 -243
- package/dist/runtime-ets/dom/stylesheet/index.ts +27 -316
- package/dist/runtime-ets/dom/stylesheet/type.ts +52 -11
- package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
- package/dist/runtime-ets/emitter/emitter.ts +1 -0
- package/dist/runtime-ets/env.ts +1 -0
- package/dist/runtime-ets/index.ts +23 -7
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/interface/index.ts +6 -0
- package/dist/runtime-ets/utils/index.ts +78 -19
- package/dist/runtime-ets/utils/info.ts +2 -2
- package/dist/runtime-ets/utils/router.ts +9 -0
- package/dist/runtime-framework/react/app.ts +10 -10
- package/dist/runtime-framework/react/hooks.ts +1 -2
- package/dist/runtime-framework/react/index.ts +0 -2
- package/dist/runtime-framework/react/native-page.ts +212 -80
- package/dist/runtime-framework/react/page.ts +3 -10
- package/dist/runtime-framework/react/utils/index.ts +3 -3
- package/dist/runtime-framework/solid/app.ts +29 -46
- 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 -31
- package/dist/runtime-framework/solid/reconciler/props.ts +73 -29
- 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 +3 -5
- package/dist/runtime-utils.d.ts +826 -0
- package/dist/runtime-utils.js +575 -284
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +575 -284
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +14 -15
- 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 +5 -0
- package/types/index.d.ts +4 -0
- package/types/runtime.d.ts +8 -1
- /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
|
@@ -29,14 +29,10 @@ interface FormWidgetProps extends StandardProps {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
class TaroFormWidgetElement<T extends FormWidgetProps = FormWidgetProps> extends TaroElement<T> {
|
|
32
|
-
_instance
|
|
33
|
-
|
|
34
32
|
_isInit = false
|
|
35
33
|
|
|
36
34
|
_name = ''
|
|
37
35
|
|
|
38
|
-
_value: TaroAny = ''
|
|
39
|
-
|
|
40
36
|
_reset: TaroAny = ''
|
|
41
37
|
|
|
42
38
|
constructor (tagName: string) {
|
|
@@ -45,7 +41,7 @@ class TaroFormWidgetElement<T extends FormWidgetProps = FormWidgetProps> extends
|
|
|
45
41
|
bindFocus(this)
|
|
46
42
|
|
|
47
43
|
this._name = this._attrs.name || ''
|
|
48
|
-
this._value = this._attrs.value || ''
|
|
44
|
+
this._nodeInfo._value = this._attrs.value || ''
|
|
49
45
|
}
|
|
50
46
|
|
|
51
47
|
public setAttribute (name: string, value: any): void {
|
|
@@ -60,17 +56,22 @@ class TaroFormWidgetElement<T extends FormWidgetProps = FormWidgetProps> extends
|
|
|
60
56
|
}
|
|
61
57
|
}
|
|
62
58
|
|
|
59
|
+
public removeAttribute(name: string): void {
|
|
60
|
+
if (name === 'value') {
|
|
61
|
+
this.value = ''
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
63
65
|
public get name () {
|
|
64
66
|
return this._attrs.name || ''
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
public set name (val: string) {
|
|
68
70
|
this.updateFormWidgetName(val)
|
|
69
|
-
this.updateComponent()
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
public get value () {
|
|
73
|
-
return this._value
|
|
74
|
+
return this._nodeInfo._value
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
public set value (val: TaroAny) {
|
|
@@ -78,8 +79,6 @@ class TaroFormWidgetElement<T extends FormWidgetProps = FormWidgetProps> extends
|
|
|
78
79
|
|
|
79
80
|
if (this._instance) {
|
|
80
81
|
this._instance.value = val
|
|
81
|
-
} else {
|
|
82
|
-
this.updateComponent()
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
84
|
|
|
@@ -89,7 +88,7 @@ class TaroFormWidgetElement<T extends FormWidgetProps = FormWidgetProps> extends
|
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
public updateFormWidgetValue (val: TaroAny) {
|
|
92
|
-
this._value = val
|
|
91
|
+
this._nodeInfo._value = val
|
|
93
92
|
this._attrs.value = val
|
|
94
93
|
}
|
|
95
94
|
|
|
@@ -121,7 +120,6 @@ class TaroCheckedElement<T extends StandardProps & { checked?: boolean } = Stand
|
|
|
121
120
|
|
|
122
121
|
set checked (val: boolean) {
|
|
123
122
|
this.updateCheckedValue(val)
|
|
124
|
-
this.updateComponent()
|
|
125
123
|
}
|
|
126
124
|
|
|
127
125
|
public updateCheckedValue (val: boolean) {
|
|
@@ -175,6 +173,14 @@ class TaroInputElement<T extends FormWidgetProps = InputProps> extends TaroFormW
|
|
|
175
173
|
}
|
|
176
174
|
}
|
|
177
175
|
|
|
176
|
+
public get value () {
|
|
177
|
+
return super.value
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
public set value (val: TaroAny) {
|
|
181
|
+
super.value = `${val}`
|
|
182
|
+
}
|
|
183
|
+
|
|
178
184
|
private onKeyboardHeightChange (height: number) {
|
|
179
185
|
const event: TaroEvent = createTaroEvent('keyboardHeightChange', { detail: { height: height, duration: 0 } }, this)
|
|
180
186
|
|
|
@@ -195,7 +201,7 @@ class TaroInputElement<T extends FormWidgetProps = InputProps> extends TaroFormW
|
|
|
195
201
|
}
|
|
196
202
|
|
|
197
203
|
@Observed
|
|
198
|
-
class TaroTextAreaElement extends TaroInputElement<TextareaProps>{
|
|
204
|
+
class TaroTextAreaElement extends TaroInputElement<TextareaProps> {
|
|
199
205
|
controller: TextAreaController = new TextAreaController()
|
|
200
206
|
|
|
201
207
|
constructor() {
|
|
@@ -203,14 +209,14 @@ class TaroTextAreaElement extends TaroInputElement<TextareaProps>{
|
|
|
203
209
|
}
|
|
204
210
|
}
|
|
205
211
|
@Observed
|
|
206
|
-
class TaroCheckboxElement extends TaroCheckedElement<CheckboxProps>{
|
|
212
|
+
class TaroCheckboxElement extends TaroCheckedElement<CheckboxProps> {
|
|
207
213
|
constructor() {
|
|
208
214
|
super('Checkbox')
|
|
209
215
|
}
|
|
210
216
|
}
|
|
211
217
|
|
|
212
218
|
@Observed
|
|
213
|
-
class TaroRadioElement extends TaroCheckedElement<RadioProps>{
|
|
219
|
+
class TaroRadioElement extends TaroCheckedElement<RadioProps> {
|
|
214
220
|
public group?: string
|
|
215
221
|
|
|
216
222
|
constructor() {
|
|
@@ -220,12 +226,10 @@ class TaroRadioElement extends TaroCheckedElement<RadioProps>{
|
|
|
220
226
|
|
|
221
227
|
@Observed
|
|
222
228
|
class TaroSliderElement extends TaroFormWidgetElement<SliderProps> {
|
|
223
|
-
_value = 0
|
|
224
|
-
|
|
225
229
|
constructor() {
|
|
226
230
|
super('Slider')
|
|
227
231
|
|
|
228
|
-
this._value = Number(this._attrs.value || 0)
|
|
232
|
+
this._nodeInfo._value = Number(this._attrs.value || 0)
|
|
229
233
|
}
|
|
230
234
|
}
|
|
231
235
|
@Observed
|
|
@@ -242,7 +246,7 @@ class TaroPickerElement extends TaroFormWidgetElement<PickerSelectorProps | Pick
|
|
|
242
246
|
case 'selector': {
|
|
243
247
|
const key = this._attrs.rangeKey
|
|
244
248
|
const item = this._attrs.range[this.value]
|
|
245
|
-
|
|
249
|
+
|
|
246
250
|
if (key) {
|
|
247
251
|
return item[key]
|
|
248
252
|
} else {
|
|
@@ -271,7 +275,7 @@ class TaroPickerElement extends TaroFormWidgetElement<PickerSelectorProps | Pick
|
|
|
271
275
|
super.reset()
|
|
272
276
|
|
|
273
277
|
const event: TaroEvent = createTaroEvent('change', { detail: { value: this._reset } }, this)
|
|
274
|
-
|
|
278
|
+
|
|
275
279
|
event.stopPropagation()
|
|
276
280
|
eventHandler(event, 'change', this)
|
|
277
281
|
}
|
|
@@ -347,7 +351,7 @@ class TaroFormElement extends TaroFormWidgetElement {
|
|
|
347
351
|
|
|
348
352
|
findChildNodeWithDFS<TaroFormWidgetElement>(this, item => {
|
|
349
353
|
if (!item.name) return false
|
|
350
|
-
|
|
354
|
+
|
|
351
355
|
switch (item.nodeName) {
|
|
352
356
|
case 'INPUT':
|
|
353
357
|
case 'RADIO':
|
|
@@ -378,9 +382,9 @@ class TaroFormElement extends TaroFormWidgetElement {
|
|
|
378
382
|
e.stopPropagation()
|
|
379
383
|
switch (item.nodeName) {
|
|
380
384
|
case 'INPUT':
|
|
381
|
-
case 'SLIDER':
|
|
385
|
+
case 'SLIDER':
|
|
382
386
|
case 'PICKER':
|
|
383
|
-
case 'RADIO':
|
|
387
|
+
case 'RADIO':
|
|
384
388
|
case 'SWITCH':
|
|
385
389
|
case 'CHECKBOX':
|
|
386
390
|
case 'TEXTAREA':
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Current } from '../../current'
|
|
2
2
|
import { TaroTextNode } from '../node'
|
|
3
|
+
import { TaroCanvasElement } from './canvas'
|
|
3
4
|
import { TaroElement } from './element'
|
|
4
5
|
import {
|
|
5
6
|
FormElement,
|
|
@@ -15,12 +16,15 @@ import {
|
|
|
15
16
|
TaroTextAreaElement
|
|
16
17
|
} from './form'
|
|
17
18
|
import { TaroMovableAreaElement } from './movableArea'
|
|
18
|
-
import { TaroMovableViewElement } from './movableView'
|
|
19
|
+
import { isTaroMovableViewElement, TaroMovableViewElement } from './movableView'
|
|
19
20
|
import {
|
|
20
21
|
TaroButtonElement,
|
|
21
22
|
TaroIconElement,
|
|
22
23
|
TaroImageElement,
|
|
23
24
|
TaroLabelElement,
|
|
25
|
+
TaroNavigationBarElement,
|
|
26
|
+
TaroOtherElement,
|
|
27
|
+
TaroPageMetaElement,
|
|
24
28
|
TaroRichTextElement,
|
|
25
29
|
TaroSwiperElement,
|
|
26
30
|
TaroSwiperItemElement,
|
|
@@ -39,7 +43,11 @@ export function initHarmonyElement () {
|
|
|
39
43
|
case 'image': return new TaroImageElement()
|
|
40
44
|
case 'text': return new TaroTextElement()
|
|
41
45
|
case 'button': return new TaroButtonElement()
|
|
46
|
+
case 'movable-area': return new TaroMovableAreaElement()
|
|
47
|
+
case 'movable-view': return new TaroMovableViewElement()
|
|
48
|
+
case 'progress': return new TaroProgressElement()
|
|
42
49
|
case 'scroll-view': return new TaroScrollViewElement()
|
|
50
|
+
case 'scroll-list': return new TaroScrollViewElement()
|
|
43
51
|
case 'checkbox-group': return new TaroCheckboxGroupElement()
|
|
44
52
|
case 'input': return new TaroInputElement()
|
|
45
53
|
case 'picker': return new TaroPickerElement()
|
|
@@ -52,13 +60,16 @@ export function initHarmonyElement () {
|
|
|
52
60
|
case 'icon': return new TaroIconElement()
|
|
53
61
|
case 'label': return new TaroLabelElement()
|
|
54
62
|
case 'rich-text': return new TaroRichTextElement()
|
|
63
|
+
case 'canvas': return new TaroCanvasElement()
|
|
55
64
|
case 'swiper': return new TaroSwiperElement()
|
|
56
65
|
case 'swiper-item': return new TaroSwiperItemElement()
|
|
57
66
|
case 'textarea': return new TaroTextAreaElement()
|
|
58
67
|
case 'form': return new TaroFormElement()
|
|
59
68
|
case 'web-view': return new TaroWebViewElement()
|
|
60
69
|
case 'inner-html': return new TaroInnerHtmlElement()
|
|
61
|
-
|
|
70
|
+
case 'page-meta': return new TaroPageMetaElement()
|
|
71
|
+
case 'navigation-bar': return new TaroNavigationBarElement()
|
|
72
|
+
default: return new TaroOtherElement(tagName)
|
|
62
73
|
}
|
|
63
74
|
}
|
|
64
75
|
|
|
@@ -71,6 +82,7 @@ export function initHarmonyElement () {
|
|
|
71
82
|
export {
|
|
72
83
|
FormElement,
|
|
73
84
|
TaroButtonElement,
|
|
85
|
+
TaroCanvasElement,
|
|
74
86
|
TaroCheckboxElement,
|
|
75
87
|
TaroCheckboxGroupElement,
|
|
76
88
|
TaroElement,
|
|
@@ -82,6 +94,9 @@ export {
|
|
|
82
94
|
TaroLabelElement,
|
|
83
95
|
TaroMovableAreaElement,
|
|
84
96
|
TaroMovableViewElement,
|
|
97
|
+
TaroNavigationBarElement,
|
|
98
|
+
TaroOtherElement,
|
|
99
|
+
TaroPageMetaElement,
|
|
85
100
|
TaroPickerElement,
|
|
86
101
|
TaroProgressElement,
|
|
87
102
|
TaroRadioElement,
|
|
@@ -98,3 +113,8 @@ export {
|
|
|
98
113
|
TaroViewElement,
|
|
99
114
|
TaroWebViewElement
|
|
100
115
|
}
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
export {
|
|
119
|
+
isTaroMovableViewElement
|
|
120
|
+
}
|
|
@@ -1,12 +1,248 @@
|
|
|
1
|
-
|
|
2
1
|
import { TaroElement } from './element'
|
|
3
2
|
|
|
4
3
|
import type { MovableViewProps } from '@tarojs/components/types'
|
|
4
|
+
import type { TaroAny } from '../../utils'
|
|
5
5
|
|
|
6
|
+
type Tsize = {
|
|
7
|
+
w: number
|
|
8
|
+
h: number
|
|
9
|
+
}
|
|
10
|
+
type Tpoint = {
|
|
11
|
+
x: number
|
|
12
|
+
y: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function calcPosition(postion: number, start: number, end: number) {
|
|
16
|
+
if (postion <= end && postion >= start) {
|
|
17
|
+
return postion
|
|
18
|
+
} else if (postion < start) {
|
|
19
|
+
return start
|
|
20
|
+
} else {
|
|
21
|
+
return end
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function isTaroMovableViewElement (item: TaroAny): item is TaroMovableViewElement {
|
|
26
|
+
return item instanceof TaroMovableViewElement
|
|
27
|
+
}
|
|
6
28
|
@Observed
|
|
7
|
-
export class TaroMovableViewElement extends TaroElement<MovableViewProps & {
|
|
29
|
+
export class TaroMovableViewElement extends TaroElement<MovableViewProps & { animation: undefined }> {
|
|
30
|
+
_scaleValue = 1
|
|
31
|
+
_scalevalueTemp = 1
|
|
32
|
+
|
|
33
|
+
// 父级区别的大小
|
|
34
|
+
_area?: Tsize
|
|
35
|
+
// 自己元素的大小
|
|
36
|
+
_selfSize?: Tsize
|
|
37
|
+
_areaInited: false
|
|
38
|
+
_selfSizeInited: false
|
|
39
|
+
|
|
40
|
+
// 元素的位置
|
|
41
|
+
_position: Tpoint = {
|
|
42
|
+
x: 0,
|
|
43
|
+
y: 0,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
_positionTemp: Tpoint = {
|
|
47
|
+
x: 0,
|
|
48
|
+
y: 0,
|
|
49
|
+
}
|
|
8
50
|
|
|
9
51
|
constructor() {
|
|
10
52
|
super('MovableView')
|
|
11
53
|
}
|
|
54
|
+
|
|
55
|
+
get _outOfBounds() {
|
|
56
|
+
if (this.getAttribute('outOfBounds')) {
|
|
57
|
+
return this.selfSize ? this.selfSize.w / 3 : 0
|
|
58
|
+
}
|
|
59
|
+
return 0
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
startScale() {
|
|
63
|
+
this._scalevalueTemp = this._scaleValue
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
doScale(val: number) {
|
|
67
|
+
const scale = this.getAttribute('scale')
|
|
68
|
+
|
|
69
|
+
// 禁止缩放的时候不生效
|
|
70
|
+
if (scale) {
|
|
71
|
+
this.scaleValue = val * this._scalevalueTemp
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
set scaleValue(val: number) {
|
|
76
|
+
if (this.checkScaleValueInBounds(val)) {
|
|
77
|
+
this._scaleValue = val
|
|
78
|
+
|
|
79
|
+
this.checkPositionBoundary(this.position, val)
|
|
80
|
+
|
|
81
|
+
const scaleFns = this?.__listeners?.scale || []
|
|
82
|
+
scaleFns.forEach((fn) => {
|
|
83
|
+
fn({ ...this.position, scale: this.scaleValue })
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get visibility () {
|
|
89
|
+
return this._areaInited && this._selfSizeInited ? Visibility.Visible : Visibility.Hidden
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
get scaleValue() {
|
|
93
|
+
return this._scaleValue
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
startMove() {
|
|
97
|
+
this._positionTemp = this._position
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
doMove(val: Tpoint) {
|
|
101
|
+
if (!this.area || !this.selfSize) {
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
if (this.getAttribute('disabled')) {
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
const direction = this.getAttribute('direction')
|
|
108
|
+
|
|
109
|
+
// 容器的宽高终点
|
|
110
|
+
const areaWidthEnd = this.area.w - this.selfSize.w * this.scaleValue
|
|
111
|
+
const areaHeightEnd = this.area.h - this.selfSize.h * this.scaleValue
|
|
112
|
+
|
|
113
|
+
const incrementWidth = (this.scaleValue - 1) * this.selfSize.w
|
|
114
|
+
const incrementHeight = (this.scaleValue - 1) * this.selfSize.h
|
|
115
|
+
|
|
116
|
+
let x = this._positionTemp.x
|
|
117
|
+
let y = this._positionTemp.y
|
|
118
|
+
if (['all', 'horizontal'].includes(direction)) {
|
|
119
|
+
const nextX = this._positionTemp.x + val.x * this.scaleValue
|
|
120
|
+
x = calcPosition(
|
|
121
|
+
nextX,
|
|
122
|
+
incrementWidth * 0.5 - this._outOfBounds,
|
|
123
|
+
areaWidthEnd + incrementWidth * 0.5 + this._outOfBounds
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (['all', 'vertical'].includes(direction)) {
|
|
128
|
+
const nextY = this._positionTemp.y + val.y * this.scaleValue
|
|
129
|
+
y = calcPosition(
|
|
130
|
+
nextY,
|
|
131
|
+
incrementHeight * 0.5 - this._outOfBounds,
|
|
132
|
+
areaHeightEnd + incrementHeight * 0.5 + this._outOfBounds
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const changeFns = this?.__listeners?.change || []
|
|
137
|
+
changeFns.forEach((fn) => {
|
|
138
|
+
fn({ x, y, source: 'touch' })
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
this.position = {
|
|
142
|
+
x: x,
|
|
143
|
+
y: y,
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
get position() {
|
|
148
|
+
return this._position
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
set position(val: Tpoint) {
|
|
152
|
+
this._position = val
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
set area(val: Tsize) {
|
|
156
|
+
if (val.w === this._area?.w && val.h === this._area?.h) return
|
|
157
|
+
this._area = val
|
|
158
|
+
if (!this._areaInited) {
|
|
159
|
+
this._areaInited = true
|
|
160
|
+
this.initPositionFromAttribute()
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
get area(): Tsize | undefined {
|
|
165
|
+
return this._area
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
set selfSize(val: Tsize) {
|
|
169
|
+
if (val.w === this._selfSize?.w && val.h === this._selfSize?.h) return
|
|
170
|
+
this._selfSize = val
|
|
171
|
+
if (!this._selfSizeInited) {
|
|
172
|
+
this._selfSizeInited = true
|
|
173
|
+
this.initPositionFromAttribute()
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
get selfSize(): Tsize | undefined {
|
|
178
|
+
return this._selfSize
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
initPositionFromAttribute () {
|
|
182
|
+
if (!this.area || !this.selfSize) {
|
|
183
|
+
return
|
|
184
|
+
}
|
|
185
|
+
const x = this.getAttribute('x') ? Number(this.getAttribute('x')) : 0
|
|
186
|
+
const y = this.getAttribute('y') ? Number(this.getAttribute('y')) : 0
|
|
187
|
+
this.checkPositionBoundary({ x, y }, this.scaleValue)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
checkPositionBoundary(position: Tpoint, scale: number) {
|
|
191
|
+
if (!this.area || !this.selfSize) {
|
|
192
|
+
return { x: 0, y: 0 }
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const areaWidthEnd = this.area.w - this.selfSize.w * scale
|
|
196
|
+
const areaHeightEnd = this.area.h - this.selfSize.h * scale
|
|
197
|
+
|
|
198
|
+
const incrementWidth = (scale - 1) * this.selfSize.w
|
|
199
|
+
const incrementHeight = (scale - 1) * this.selfSize.h
|
|
200
|
+
|
|
201
|
+
this.position = {
|
|
202
|
+
x: calcPosition(position.x, incrementWidth * 0.5, areaWidthEnd + incrementWidth * 0.5),
|
|
203
|
+
y: calcPosition(position.y, incrementHeight * 0.5, areaHeightEnd + incrementHeight * 0.5),
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
checkScaleValueInBounds(currentScale: number) {
|
|
208
|
+
const scaleMin = this.getAttribute('scaleMin')
|
|
209
|
+
const scaleMax = this.getAttribute('scaleMax')
|
|
210
|
+
|
|
211
|
+
if (scaleMin && Number(scaleMin) >= 0.1 && currentScale < Number(scaleMin)) {
|
|
212
|
+
return false
|
|
213
|
+
} else if (scaleMax && Number(scaleMax) >= 0.1 && currentScale > Number(scaleMax)) {
|
|
214
|
+
return false
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return true
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
public setAttribute(name: string, value: any): void {
|
|
221
|
+
if (name === 'x') {
|
|
222
|
+
this.checkPositionBoundary({ x: value, y: this.position.y }, this.scaleValue)
|
|
223
|
+
}
|
|
224
|
+
if (name === 'y') {
|
|
225
|
+
this.checkPositionBoundary({ x: this.position.x, y: value }, this.scaleValue)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
super.setAttribute(name, value)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
public callTouchEventFnFromGesture(eventName: string, gestureEvent: GestureEvent) {
|
|
232
|
+
const touchFns = (this?.__listeners?.[eventName] || []) as Function[]
|
|
233
|
+
touchFns.forEach(fn => {
|
|
234
|
+
try {
|
|
235
|
+
fn({
|
|
236
|
+
_hmEvent: gestureEvent,
|
|
237
|
+
target: this,
|
|
238
|
+
changedTouches: gestureEvent.fingerList.map(finger => ({
|
|
239
|
+
clientX: finger.globalX,
|
|
240
|
+
clientY: finger.globalY
|
|
241
|
+
}))
|
|
242
|
+
})
|
|
243
|
+
} catch (error) {
|
|
244
|
+
console.error(error)
|
|
245
|
+
}
|
|
246
|
+
})
|
|
247
|
+
}
|
|
12
248
|
}
|
|
@@ -6,12 +6,17 @@ import type {
|
|
|
6
6
|
IconProps,
|
|
7
7
|
ImageProps,
|
|
8
8
|
LabelProps,
|
|
9
|
+
NavigationBarProps,
|
|
10
|
+
PageMetaProps,
|
|
9
11
|
RichTextProps,
|
|
10
12
|
SwiperItemProps,
|
|
11
13
|
SwiperProps,
|
|
12
14
|
ViewProps
|
|
13
15
|
} from '@tarojs/components/types'
|
|
14
16
|
|
|
17
|
+
@Observed
|
|
18
|
+
class TaroOtherElement extends TaroElement<ViewProps> {}
|
|
19
|
+
|
|
15
20
|
@Observed
|
|
16
21
|
class TaroViewElement extends TaroElement<ViewProps> {
|
|
17
22
|
constructor() {
|
|
@@ -34,27 +39,27 @@ class TaroButtonElement extends TaroElement<ButtonProps> {
|
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
@Observed
|
|
37
|
-
class TaroIconElement extends TaroElement<IconProps>{
|
|
42
|
+
class TaroIconElement extends TaroElement<IconProps> {
|
|
38
43
|
constructor() {
|
|
39
44
|
super('Icon')
|
|
40
45
|
}
|
|
41
46
|
}
|
|
42
47
|
@Observed
|
|
43
|
-
class TaroLabelElement extends TaroElement<LabelProps>{
|
|
48
|
+
class TaroLabelElement extends TaroElement<LabelProps> {
|
|
44
49
|
constructor() {
|
|
45
50
|
super('Label')
|
|
46
51
|
}
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
@Observed
|
|
50
|
-
class TaroRichTextElement extends TaroElement<RichTextProps>{
|
|
55
|
+
class TaroRichTextElement extends TaroElement<RichTextProps> {
|
|
51
56
|
constructor() {
|
|
52
57
|
super('RichText')
|
|
53
58
|
}
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
@Observed
|
|
57
|
-
class TaroSwiperElement extends TaroElement<SwiperProps>{
|
|
62
|
+
class TaroSwiperElement extends TaroElement<SwiperProps> {
|
|
58
63
|
controller: SwiperController = new SwiperController()
|
|
59
64
|
|
|
60
65
|
constructor() {
|
|
@@ -63,20 +68,36 @@ class TaroSwiperElement extends TaroElement<SwiperProps>{
|
|
|
63
68
|
}
|
|
64
69
|
|
|
65
70
|
@Observed
|
|
66
|
-
class TaroSwiperItemElement extends TaroElement<SwiperItemProps>{
|
|
71
|
+
class TaroSwiperItemElement extends TaroElement<SwiperItemProps> {
|
|
67
72
|
constructor() {
|
|
68
73
|
super('SwiperItem')
|
|
69
74
|
}
|
|
70
75
|
}
|
|
71
76
|
|
|
77
|
+
@Observed
|
|
78
|
+
class TaroPageMetaElement extends TaroElement<PageMetaProps> {
|
|
79
|
+
constructor() {
|
|
80
|
+
super('PageMeta')
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@Observed
|
|
85
|
+
class TaroNavigationBarElement extends TaroElement<NavigationBarProps> {
|
|
86
|
+
constructor() {
|
|
87
|
+
super('NavigationBar')
|
|
88
|
+
}
|
|
89
|
+
}
|
|
72
90
|
|
|
73
91
|
export {
|
|
74
92
|
TaroButtonElement,
|
|
75
93
|
TaroIconElement,
|
|
76
94
|
TaroImageElement,
|
|
77
95
|
TaroLabelElement,
|
|
96
|
+
TaroNavigationBarElement,
|
|
97
|
+
TaroOtherElement,
|
|
98
|
+
TaroPageMetaElement,
|
|
78
99
|
TaroRichTextElement,
|
|
79
100
|
TaroSwiperElement,
|
|
80
101
|
TaroSwiperItemElement,
|
|
81
|
-
TaroViewElement
|
|
102
|
+
TaroViewElement
|
|
82
103
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { TaroNode } from '../node'
|
|
2
1
|
import { TaroElement } from './element'
|
|
3
2
|
|
|
4
3
|
import type { TextProps } from '@tarojs/components/types'
|
|
@@ -8,11 +7,4 @@ export class TaroTextElement extends TaroElement<TextProps> {
|
|
|
8
7
|
constructor() {
|
|
9
8
|
super('Text')
|
|
10
9
|
}
|
|
11
|
-
|
|
12
|
-
public appendChild (child: TaroNode): TaroNode {
|
|
13
|
-
super.appendChild(child)
|
|
14
|
-
|
|
15
|
-
this.updateComponent()
|
|
16
|
-
return child
|
|
17
|
-
}
|
|
18
10
|
}
|
|
@@ -4,12 +4,12 @@ import type { VideoProps } from '@tarojs/components/types'
|
|
|
4
4
|
|
|
5
5
|
@Observed
|
|
6
6
|
export class TaroVideoElement extends TaroElement<VideoProps> {
|
|
7
|
-
_currentTime = 0
|
|
8
|
-
|
|
9
7
|
controller: VideoController = new VideoController()
|
|
10
8
|
|
|
11
9
|
constructor() {
|
|
12
10
|
super('Video')
|
|
11
|
+
|
|
12
|
+
this._nodeInfo._currentTime = 0
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
async play() {
|
|
@@ -40,11 +40,11 @@ export class TaroVideoElement extends TaroElement<VideoProps> {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
get currentTime() {
|
|
43
|
-
return this._currentTime
|
|
43
|
+
return this._nodeInfo._currentTime
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
set currentTime(val: number) {
|
|
47
|
-
this._currentTime = val
|
|
47
|
+
this._nodeInfo._currentTime = val
|
|
48
48
|
this.controller.setCurrentTime(val)
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -13,13 +13,13 @@ export class TaroInnerHtmlElement extends TaroElement {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
@Observed
|
|
16
|
-
export class TaroWebViewElement extends TaroElement<WebViewProps>{
|
|
16
|
+
export class TaroWebViewElement extends TaroElement<WebViewProps> {
|
|
17
17
|
ports: web_webview.WebMessagePort[] = []
|
|
18
18
|
|
|
19
19
|
nativePort: web_webview.WebMessagePort | null = null
|
|
20
20
|
|
|
21
21
|
message: web_webview.WebMessageExt = new web_webview.WebMessageExt()
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
controller: web_webview.WebviewController = new web_webview.WebviewController()
|
|
24
24
|
|
|
25
25
|
constructor() {
|
|
@@ -59,10 +59,9 @@ export class TaroWebViewElement extends TaroElement<WebViewProps>{
|
|
|
59
59
|
return null
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
62
|
+
} catch (error) {
|
|
64
63
|
const e: business_error.BusinessError = error as business_error.BusinessError
|
|
65
|
-
|
|
64
|
+
|
|
66
65
|
console.error(`ErrorCode: ${e.code}, Message: ${e.message}`)
|
|
67
66
|
}
|
|
68
67
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { eventSource } from '@tarojs/runtime/dist/runtime.esm'
|