@tarojs/plugin-platform-harmony-ets 4.0.0-beta.11 → 4.0.0-beta.111
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 +73 -20
- package/dist/apis/canvas/index.ts +10 -1
- package/dist/apis/device/clipboard.ts +16 -8
- package/dist/apis/framework/index.ts +1 -5
- package/dist/apis/index.ts +25 -17
- package/dist/apis/media/image/index.ts +1 -1
- package/dist/apis/storage/index.ts +135 -131
- package/dist/apis/ui/animation/animation.ts +71 -29
- package/dist/apis/ui/background.ts +2 -1
- package/dist/apis/ui/interaction/index.ts +42 -59
- package/dist/apis/ui/navigation-bar/index.ts +1 -1
- 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 +3 -3
- package/dist/apis/utils/index.ts +2 -1
- package/dist/apis/wxml/IntersectionObserver.ts +18 -10
- package/dist/apis/wxml/selectorQuery.ts +26 -13
- package/dist/components-harmony-ets/button.ets +35 -8
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +70 -60
- package/dist/components-harmony-ets/form.ets +35 -16
- 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 +92 -0
- package/dist/components-harmony-ets/innerHtml.ets +6 -5
- package/dist/components-harmony-ets/input.ets +62 -40
- package/dist/components-harmony-ets/label.ets +44 -21
- package/dist/components-harmony-ets/listView.ets +31 -0
- package/dist/components-harmony-ets/movableArea.ets +112 -53
- package/dist/components-harmony-ets/movableView.ets +75 -48
- 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 +41 -38
- package/dist/components-harmony-ets/progress.ets +31 -24
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +76 -66
- package/dist/components-harmony-ets/richText.ets +4 -25
- package/dist/components-harmony-ets/scrollList.ets +103 -0
- package/dist/components-harmony-ets/scrollView.ets +47 -47
- package/dist/components-harmony-ets/slider.ets +18 -14
- package/dist/components-harmony-ets/stickySection.ets +42 -0
- package/dist/components-harmony-ets/style.ets +386 -130
- package/dist/components-harmony-ets/swiper.ets +41 -4
- package/dist/components-harmony-ets/switch.ets +35 -31
- 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 +49 -19
- 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 +170 -93
- package/dist/components-harmony-ets/video.ets +27 -19
- package/dist/components-harmony-ets/view.ets +47 -40
- package/dist/components-harmony-ets/webView.ets +6 -5
- package/dist/index.d.ts +152 -0
- package/dist/index.js +69 -43
- 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 +5 -1
- 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 +8 -11
- package/dist/runtime-ets/dom/element/canvas.ts +136 -0
- package/dist/runtime-ets/dom/element/element.ts +376 -56
- package/dist/runtime-ets/dom/element/form.ts +20 -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 +234 -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.ts +3 -5
- package/dist/runtime-ets/dom/eventTarget.ts +2 -3
- package/dist/runtime-ets/dom/node.ts +51 -19
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +418 -237
- package/dist/runtime-ets/dom/stylesheet/index.ts +29 -311
- package/dist/runtime-ets/dom/stylesheet/type.ts +51 -9
- package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
- package/dist/runtime-ets/index.ts +2 -1
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/utils/index.ts +74 -13
- package/dist/runtime-ets/utils/info.ts +2 -2
- package/dist/runtime-framework/react/app.ts +15 -10
- package/dist/runtime-framework/react/hooks.ts +0 -1
- package/dist/runtime-framework/react/index.ts +0 -2
- package/dist/runtime-framework/react/native-page.ts +185 -78
- package/dist/runtime-framework/react/page.ts +4 -9
- package/dist/runtime-framework/react/utils/index.ts +3 -3
- package/dist/runtime-framework/solid/app.ts +30 -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 +85 -31
- package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
- 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 +827 -0
- package/dist/runtime-utils.js +425 -253
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +425 -253
- 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 +4 -0
- package/types/index.d.ts +4 -0
- package/types/runtime.d.ts +1 -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 {
|
|
@@ -66,11 +62,10 @@ class TaroFormWidgetElement<T extends FormWidgetProps = FormWidgetProps> extends
|
|
|
66
62
|
|
|
67
63
|
public set name (val: string) {
|
|
68
64
|
this.updateFormWidgetName(val)
|
|
69
|
-
this.updateComponent()
|
|
70
65
|
}
|
|
71
66
|
|
|
72
67
|
public get value () {
|
|
73
|
-
return this._value
|
|
68
|
+
return this._nodeInfo._value
|
|
74
69
|
}
|
|
75
70
|
|
|
76
71
|
public set value (val: TaroAny) {
|
|
@@ -78,8 +73,6 @@ class TaroFormWidgetElement<T extends FormWidgetProps = FormWidgetProps> extends
|
|
|
78
73
|
|
|
79
74
|
if (this._instance) {
|
|
80
75
|
this._instance.value = val
|
|
81
|
-
} else {
|
|
82
|
-
this.updateComponent()
|
|
83
76
|
}
|
|
84
77
|
}
|
|
85
78
|
|
|
@@ -89,7 +82,7 @@ class TaroFormWidgetElement<T extends FormWidgetProps = FormWidgetProps> extends
|
|
|
89
82
|
}
|
|
90
83
|
|
|
91
84
|
public updateFormWidgetValue (val: TaroAny) {
|
|
92
|
-
this._value = val
|
|
85
|
+
this._nodeInfo._value = val
|
|
93
86
|
this._attrs.value = val
|
|
94
87
|
}
|
|
95
88
|
|
|
@@ -121,7 +114,6 @@ class TaroCheckedElement<T extends StandardProps & { checked?: boolean } = Stand
|
|
|
121
114
|
|
|
122
115
|
set checked (val: boolean) {
|
|
123
116
|
this.updateCheckedValue(val)
|
|
124
|
-
this.updateComponent()
|
|
125
117
|
}
|
|
126
118
|
|
|
127
119
|
public updateCheckedValue (val: boolean) {
|
|
@@ -175,6 +167,14 @@ class TaroInputElement<T extends FormWidgetProps = InputProps> extends TaroFormW
|
|
|
175
167
|
}
|
|
176
168
|
}
|
|
177
169
|
|
|
170
|
+
public get value () {
|
|
171
|
+
return super.value
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
public set value (val: TaroAny) {
|
|
175
|
+
super.value = `${val}`
|
|
176
|
+
}
|
|
177
|
+
|
|
178
178
|
private onKeyboardHeightChange (height: number) {
|
|
179
179
|
const event: TaroEvent = createTaroEvent('keyboardHeightChange', { detail: { height: height, duration: 0 } }, this)
|
|
180
180
|
|
|
@@ -195,7 +195,7 @@ class TaroInputElement<T extends FormWidgetProps = InputProps> extends TaroFormW
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
@Observed
|
|
198
|
-
class TaroTextAreaElement extends TaroInputElement<TextareaProps>{
|
|
198
|
+
class TaroTextAreaElement extends TaroInputElement<TextareaProps> {
|
|
199
199
|
controller: TextAreaController = new TextAreaController()
|
|
200
200
|
|
|
201
201
|
constructor() {
|
|
@@ -203,14 +203,14 @@ class TaroTextAreaElement extends TaroInputElement<TextareaProps>{
|
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
@Observed
|
|
206
|
-
class TaroCheckboxElement extends TaroCheckedElement<CheckboxProps>{
|
|
206
|
+
class TaroCheckboxElement extends TaroCheckedElement<CheckboxProps> {
|
|
207
207
|
constructor() {
|
|
208
208
|
super('Checkbox')
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
@Observed
|
|
213
|
-
class TaroRadioElement extends TaroCheckedElement<RadioProps>{
|
|
213
|
+
class TaroRadioElement extends TaroCheckedElement<RadioProps> {
|
|
214
214
|
public group?: string
|
|
215
215
|
|
|
216
216
|
constructor() {
|
|
@@ -220,12 +220,10 @@ class TaroRadioElement extends TaroCheckedElement<RadioProps>{
|
|
|
220
220
|
|
|
221
221
|
@Observed
|
|
222
222
|
class TaroSliderElement extends TaroFormWidgetElement<SliderProps> {
|
|
223
|
-
_value = 0
|
|
224
|
-
|
|
225
223
|
constructor() {
|
|
226
224
|
super('Slider')
|
|
227
225
|
|
|
228
|
-
this._value = Number(this._attrs.value || 0)
|
|
226
|
+
this._nodeInfo._value = Number(this._attrs.value || 0)
|
|
229
227
|
}
|
|
230
228
|
}
|
|
231
229
|
@Observed
|
|
@@ -242,7 +240,7 @@ class TaroPickerElement extends TaroFormWidgetElement<PickerSelectorProps | Pick
|
|
|
242
240
|
case 'selector': {
|
|
243
241
|
const key = this._attrs.rangeKey
|
|
244
242
|
const item = this._attrs.range[this.value]
|
|
245
|
-
|
|
243
|
+
|
|
246
244
|
if (key) {
|
|
247
245
|
return item[key]
|
|
248
246
|
} else {
|
|
@@ -271,7 +269,7 @@ class TaroPickerElement extends TaroFormWidgetElement<PickerSelectorProps | Pick
|
|
|
271
269
|
super.reset()
|
|
272
270
|
|
|
273
271
|
const event: TaroEvent = createTaroEvent('change', { detail: { value: this._reset } }, this)
|
|
274
|
-
|
|
272
|
+
|
|
275
273
|
event.stopPropagation()
|
|
276
274
|
eventHandler(event, 'change', this)
|
|
277
275
|
}
|
|
@@ -347,7 +345,7 @@ class TaroFormElement extends TaroFormWidgetElement {
|
|
|
347
345
|
|
|
348
346
|
findChildNodeWithDFS<TaroFormWidgetElement>(this, item => {
|
|
349
347
|
if (!item.name) return false
|
|
350
|
-
|
|
348
|
+
|
|
351
349
|
switch (item.nodeName) {
|
|
352
350
|
case 'INPUT':
|
|
353
351
|
case 'RADIO':
|
|
@@ -378,9 +376,9 @@ class TaroFormElement extends TaroFormWidgetElement {
|
|
|
378
376
|
e.stopPropagation()
|
|
379
377
|
switch (item.nodeName) {
|
|
380
378
|
case 'INPUT':
|
|
381
|
-
case 'SLIDER':
|
|
379
|
+
case 'SLIDER':
|
|
382
380
|
case 'PICKER':
|
|
383
|
-
case 'RADIO':
|
|
381
|
+
case 'RADIO':
|
|
384
382
|
case 'SWITCH':
|
|
385
383
|
case 'CHECKBOX':
|
|
386
384
|
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,244 @@
|
|
|
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
|
+
fn({
|
|
235
|
+
_hmEvent: gestureEvent,
|
|
236
|
+
target: this,
|
|
237
|
+
changedTouches: gestureEvent.fingerList.map(finger => ({
|
|
238
|
+
clientX: finger.globalX,
|
|
239
|
+
clientY: finger.globalY
|
|
240
|
+
}))
|
|
241
|
+
})
|
|
242
|
+
})
|
|
243
|
+
}
|
|
12
244
|
}
|
|
@@ -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
|
}
|
|
@@ -55,7 +55,6 @@ export class TaroEvent<T = any> {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
59
58
|
export function createEvent (event: TaroEvent | string, type?: string, node?: TaroElement) {
|
|
60
59
|
if (typeof event === 'string') {
|
|
61
60
|
// For Vue3 using document.createEvent
|
|
@@ -87,7 +86,6 @@ function stopOrTriggerPropagation (event: TaroEvent, node: TaroElement) {
|
|
|
87
86
|
|
|
88
87
|
// eslint-disable-next-line no-unmodified-loop-condition
|
|
89
88
|
while ((target = target.parentNode as TaroElement)) {
|
|
90
|
-
event.currentTarget = target
|
|
91
89
|
const listeners = target.__listeners[event.type]
|
|
92
90
|
|
|
93
91
|
if (!Array.isArray(listeners) || target._attrs?.disabled) {
|
|
@@ -111,7 +109,7 @@ const BUBBLE_EVENTS = new Set([
|
|
|
111
109
|
'longTap',
|
|
112
110
|
'change',
|
|
113
111
|
'submit',
|
|
114
|
-
'submit-btn',
|
|
112
|
+
'submit-btn',
|
|
115
113
|
'reset-btn'
|
|
116
114
|
])
|
|
117
115
|
|
|
@@ -123,7 +121,7 @@ function collectBatchFunction (type: string, dispatch: () => void) {
|
|
|
123
121
|
}
|
|
124
122
|
}
|
|
125
123
|
|
|
126
|
-
export function eventHandler (event, type: string, node: TaroElement) {
|
|
124
|
+
export function eventHandler (event, type: string, node: TaroElement): void {
|
|
127
125
|
if (!node) return
|
|
128
126
|
|
|
129
127
|
const isBatchUpdates = hooks.isExist('batchedEventUpdates')
|
|
@@ -144,7 +142,7 @@ export function eventHandler (event, type: string, node: TaroElement) {
|
|
|
144
142
|
|
|
145
143
|
// hooks.call('dispatchTaroEventFinish', e, node)
|
|
146
144
|
}
|
|
147
|
-
|
|
145
|
+
|
|
148
146
|
dispatch()
|
|
149
147
|
if (isBatchUpdates) {
|
|
150
148
|
// collectBatchFunction(type, dispatch)
|