@tarojs/plugin-platform-harmony-ets 4.0.0-beta.7 → 4.0.0-beta.70
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 +9 -1
- 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 +146 -78
- 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/scroll/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 +24 -11
- 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 +34 -14
- package/dist/components-harmony-ets/index.ets +92 -0
- package/dist/components-harmony-ets/innerHtml.ets +11 -6
- package/dist/components-harmony-ets/input.ets +45 -41
- package/dist/components-harmony-ets/label.ets +69 -42
- package/dist/components-harmony-ets/listView.ets +26 -0
- package/dist/components-harmony-ets/movableArea.ets +126 -0
- package/dist/components-harmony-ets/movableView.ets +77 -0
- 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 +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/scrollList.ets +94 -0
- package/dist/components-harmony-ets/scrollView.ets +61 -57
- package/dist/components-harmony-ets/slider.ets +15 -14
- package/dist/components-harmony-ets/stickySection.ets +42 -0
- package/dist/components-harmony-ets/style.ets +372 -130
- package/dist/components-harmony-ets/swiper.ets +61 -20
- package/dist/components-harmony-ets/switch.ets +30 -28
- package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
- package/dist/components-harmony-ets/text.ets +135 -49
- package/dist/components-harmony-ets/textArea.ets +47 -35
- 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 +18 -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 +54 -50
- package/dist/components-harmony-ets/utils/styles.ets +170 -93
- package/dist/components-harmony-ets/video.ets +34 -21
- 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 +85 -42
- 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 +28 -12
- package/dist/runtime-ets/dom/class-list.ts +2 -2
- package/dist/runtime-ets/dom/cssNesting.ts +409 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +28 -42
- 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 +334 -58
- package/dist/runtime-ets/dom/element/form.ts +23 -26
- package/dist/runtime-ets/dom/element/index.ts +25 -2
- package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
- package/dist/runtime-ets/dom/element/movableView.ts +209 -0
- package/dist/runtime-ets/dom/element/normal.ts +35 -8
- package/dist/runtime-ets/dom/element/progress.ts +11 -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 -4
- package/dist/runtime-ets/dom/element/webView.ts +12 -5
- package/dist/runtime-ets/dom/event.ts +2 -4
- package/dist/runtime-ets/dom/eventTarget.ts +2 -3
- package/dist/runtime-ets/dom/node.ts +49 -28
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +416 -235
- package/dist/runtime-ets/dom/stylesheet/index.ts +29 -311
- package/dist/runtime-ets/dom/stylesheet/type.ts +49 -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 +69 -13
- package/dist/runtime-ets/utils/info.ts +2 -2
- package/dist/runtime-framework/react/app.ts +7 -2
- 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 +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 +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 +0 -2
- package/dist/runtime-utils.d.ts +827 -0
- package/dist/runtime-utils.js +425 -200
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +425 -200
- 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
|
@@ -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) {
|
|
@@ -134,6 +126,7 @@ class TaroCheckedElement<T extends StandardProps & { checked?: boolean } = Stand
|
|
|
134
126
|
}
|
|
135
127
|
}
|
|
136
128
|
|
|
129
|
+
@Observed
|
|
137
130
|
class TaroInputElement<T extends FormWidgetProps = InputProps> extends TaroFormWidgetElement<T> {
|
|
138
131
|
_height = 0
|
|
139
132
|
|
|
@@ -193,38 +186,39 @@ class TaroInputElement<T extends FormWidgetProps = InputProps> extends TaroFormW
|
|
|
193
186
|
}
|
|
194
187
|
}
|
|
195
188
|
|
|
196
|
-
|
|
197
|
-
class TaroTextAreaElement extends TaroInputElement<TextareaProps>{
|
|
189
|
+
@Observed
|
|
190
|
+
class TaroTextAreaElement extends TaroInputElement<TextareaProps> {
|
|
198
191
|
controller: TextAreaController = new TextAreaController()
|
|
199
192
|
|
|
200
193
|
constructor() {
|
|
201
194
|
super('TextArea')
|
|
202
195
|
}
|
|
203
196
|
}
|
|
204
|
-
|
|
205
|
-
class TaroCheckboxElement extends TaroCheckedElement<CheckboxProps>{
|
|
197
|
+
@Observed
|
|
198
|
+
class TaroCheckboxElement extends TaroCheckedElement<CheckboxProps> {
|
|
206
199
|
constructor() {
|
|
207
200
|
super('Checkbox')
|
|
208
201
|
}
|
|
209
202
|
}
|
|
210
203
|
|
|
211
|
-
|
|
204
|
+
@Observed
|
|
205
|
+
class TaroRadioElement extends TaroCheckedElement<RadioProps> {
|
|
212
206
|
public group?: string
|
|
213
207
|
|
|
214
208
|
constructor() {
|
|
215
209
|
super('Radio')
|
|
216
210
|
}
|
|
217
211
|
}
|
|
218
|
-
class TaroSliderElement extends TaroFormWidgetElement<SliderProps> {
|
|
219
|
-
_value = 0
|
|
220
212
|
|
|
213
|
+
@Observed
|
|
214
|
+
class TaroSliderElement extends TaroFormWidgetElement<SliderProps> {
|
|
221
215
|
constructor() {
|
|
222
216
|
super('Slider')
|
|
223
217
|
|
|
224
|
-
this._value = Number(this._attrs.value || 0)
|
|
218
|
+
this._nodeInfo._value = Number(this._attrs.value || 0)
|
|
225
219
|
}
|
|
226
220
|
}
|
|
227
|
-
|
|
221
|
+
@Observed
|
|
228
222
|
class TaroPickerElement extends TaroFormWidgetElement<PickerSelectorProps | PickerTimeProps | PickerDateProps | PickerMultiSelectorProps> {
|
|
229
223
|
constructor() {
|
|
230
224
|
super('Picker')
|
|
@@ -238,7 +232,7 @@ class TaroPickerElement extends TaroFormWidgetElement<PickerSelectorProps | Pick
|
|
|
238
232
|
case 'selector': {
|
|
239
233
|
const key = this._attrs.rangeKey
|
|
240
234
|
const item = this._attrs.range[this.value]
|
|
241
|
-
|
|
235
|
+
|
|
242
236
|
if (key) {
|
|
243
237
|
return item[key]
|
|
244
238
|
} else {
|
|
@@ -267,18 +261,19 @@ class TaroPickerElement extends TaroFormWidgetElement<PickerSelectorProps | Pick
|
|
|
267
261
|
super.reset()
|
|
268
262
|
|
|
269
263
|
const event: TaroEvent = createTaroEvent('change', { detail: { value: this._reset } }, this)
|
|
270
|
-
|
|
264
|
+
|
|
271
265
|
event.stopPropagation()
|
|
272
266
|
eventHandler(event, 'change', this)
|
|
273
267
|
}
|
|
274
268
|
}
|
|
275
269
|
|
|
270
|
+
@Observed
|
|
276
271
|
class TaroSwitchElement extends TaroCheckedElement<SwitchProps> {
|
|
277
272
|
constructor() {
|
|
278
273
|
super('Switch')
|
|
279
274
|
}
|
|
280
275
|
}
|
|
281
|
-
|
|
276
|
+
@Observed
|
|
282
277
|
class TaroCheckboxGroupElement extends TaroFormWidgetElement<CheckboxGroupProps> {
|
|
283
278
|
constructor() {
|
|
284
279
|
super('CheckboxGroup')
|
|
@@ -304,6 +299,7 @@ class TaroCheckboxGroupElement extends TaroFormWidgetElement<CheckboxGroupProps>
|
|
|
304
299
|
}
|
|
305
300
|
}
|
|
306
301
|
|
|
302
|
+
@Observed
|
|
307
303
|
class TaroRadioGroupElement extends TaroFormWidgetElement<RadioGroupProps> {
|
|
308
304
|
constructor() {
|
|
309
305
|
super('RadioGroup')
|
|
@@ -329,6 +325,7 @@ class TaroRadioGroupElement extends TaroFormWidgetElement<RadioGroupProps> {
|
|
|
329
325
|
}
|
|
330
326
|
}
|
|
331
327
|
|
|
328
|
+
@Observed
|
|
332
329
|
class TaroFormElement extends TaroFormWidgetElement {
|
|
333
330
|
constructor() {
|
|
334
331
|
super('Form')
|
|
@@ -340,7 +337,7 @@ class TaroFormElement extends TaroFormWidgetElement {
|
|
|
340
337
|
|
|
341
338
|
findChildNodeWithDFS<TaroFormWidgetElement>(this, item => {
|
|
342
339
|
if (!item.name) return false
|
|
343
|
-
|
|
340
|
+
|
|
344
341
|
switch (item.nodeName) {
|
|
345
342
|
case 'INPUT':
|
|
346
343
|
case 'RADIO':
|
|
@@ -371,9 +368,9 @@ class TaroFormElement extends TaroFormWidgetElement {
|
|
|
371
368
|
e.stopPropagation()
|
|
372
369
|
switch (item.nodeName) {
|
|
373
370
|
case 'INPUT':
|
|
374
|
-
case 'SLIDER':
|
|
371
|
+
case 'SLIDER':
|
|
375
372
|
case 'PICKER':
|
|
376
|
-
case 'RADIO':
|
|
373
|
+
case 'RADIO':
|
|
377
374
|
case 'SWITCH':
|
|
378
375
|
case 'CHECKBOX':
|
|
379
376
|
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,
|
|
@@ -14,20 +15,26 @@ import {
|
|
|
14
15
|
TaroSwitchElement,
|
|
15
16
|
TaroTextAreaElement
|
|
16
17
|
} from './form'
|
|
18
|
+
import { TaroMovableAreaElement } from './movableArea'
|
|
19
|
+
import { TaroMovableViewElement } from './movableView'
|
|
17
20
|
import {
|
|
18
21
|
TaroButtonElement,
|
|
19
22
|
TaroIconElement,
|
|
20
23
|
TaroImageElement,
|
|
21
24
|
TaroLabelElement,
|
|
25
|
+
TaroNavigationBarElement,
|
|
26
|
+
TaroOtherElement,
|
|
27
|
+
TaroPageMetaElement,
|
|
22
28
|
TaroRichTextElement,
|
|
23
29
|
TaroSwiperElement,
|
|
24
30
|
TaroSwiperItemElement,
|
|
25
31
|
TaroViewElement
|
|
26
32
|
} from './normal'
|
|
33
|
+
import { TaroProgressElement } from './progress'
|
|
27
34
|
import { TaroScrollViewElement } from './scrollView'
|
|
28
35
|
import { TaroTextElement } from './text'
|
|
29
36
|
import { TaroVideoElement } from './video'
|
|
30
|
-
import { TaroWebViewElement } from './webView'
|
|
37
|
+
import { TaroInnerHtmlElement, TaroWebViewElement } from './webView'
|
|
31
38
|
|
|
32
39
|
export function initHarmonyElement () {
|
|
33
40
|
Current.createHarmonyElement = (tagName: string) => {
|
|
@@ -36,7 +43,11 @@ export function initHarmonyElement () {
|
|
|
36
43
|
case 'image': return new TaroImageElement()
|
|
37
44
|
case 'text': return new TaroTextElement()
|
|
38
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()
|
|
39
49
|
case 'scroll-view': return new TaroScrollViewElement()
|
|
50
|
+
case 'scroll-list': return new TaroScrollViewElement()
|
|
40
51
|
case 'checkbox-group': return new TaroCheckboxGroupElement()
|
|
41
52
|
case 'input': return new TaroInputElement()
|
|
42
53
|
case 'picker': return new TaroPickerElement()
|
|
@@ -49,12 +60,16 @@ export function initHarmonyElement () {
|
|
|
49
60
|
case 'icon': return new TaroIconElement()
|
|
50
61
|
case 'label': return new TaroLabelElement()
|
|
51
62
|
case 'rich-text': return new TaroRichTextElement()
|
|
63
|
+
case 'canvas': return new TaroCanvasElement()
|
|
52
64
|
case 'swiper': return new TaroSwiperElement()
|
|
53
65
|
case 'swiper-item': return new TaroSwiperItemElement()
|
|
54
66
|
case 'textarea': return new TaroTextAreaElement()
|
|
55
67
|
case 'form': return new TaroFormElement()
|
|
56
68
|
case 'web-view': return new TaroWebViewElement()
|
|
57
|
-
|
|
69
|
+
case 'inner-html': return new TaroInnerHtmlElement()
|
|
70
|
+
case 'page-meta': return new TaroPageMetaElement()
|
|
71
|
+
case 'navigation-bar': return new TaroNavigationBarElement()
|
|
72
|
+
default: return new TaroOtherElement(tagName)
|
|
58
73
|
}
|
|
59
74
|
}
|
|
60
75
|
|
|
@@ -67,15 +82,23 @@ export function initHarmonyElement () {
|
|
|
67
82
|
export {
|
|
68
83
|
FormElement,
|
|
69
84
|
TaroButtonElement,
|
|
85
|
+
TaroCanvasElement,
|
|
70
86
|
TaroCheckboxElement,
|
|
71
87
|
TaroCheckboxGroupElement,
|
|
72
88
|
TaroElement,
|
|
73
89
|
TaroFormElement,
|
|
74
90
|
TaroIconElement,
|
|
75
91
|
TaroImageElement,
|
|
92
|
+
TaroInnerHtmlElement,
|
|
76
93
|
TaroInputElement,
|
|
77
94
|
TaroLabelElement,
|
|
95
|
+
TaroMovableAreaElement,
|
|
96
|
+
TaroMovableViewElement,
|
|
97
|
+
TaroNavigationBarElement,
|
|
98
|
+
TaroOtherElement,
|
|
99
|
+
TaroPageMetaElement,
|
|
78
100
|
TaroPickerElement,
|
|
101
|
+
TaroProgressElement,
|
|
79
102
|
TaroRadioElement,
|
|
80
103
|
TaroRadioGroupElement,
|
|
81
104
|
TaroRichTextElement,
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { TaroElement } from './element'
|
|
2
|
+
|
|
3
|
+
import type { MovableViewProps } from '@tarojs/components/types'
|
|
4
|
+
|
|
5
|
+
type Tsize = {
|
|
6
|
+
w: number
|
|
7
|
+
h: number
|
|
8
|
+
}
|
|
9
|
+
type Tpoint = {
|
|
10
|
+
x: number
|
|
11
|
+
y: number
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function calcPosition(postion: number, start: number, end: number) {
|
|
15
|
+
if (postion <= end && postion >= start) {
|
|
16
|
+
return postion
|
|
17
|
+
} else if (postion < start) {
|
|
18
|
+
return start
|
|
19
|
+
} else {
|
|
20
|
+
return end
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@Observed
|
|
25
|
+
export class TaroMovableViewElement extends TaroElement<MovableViewProps & { animation: undefined }> {
|
|
26
|
+
_scaleValue = 1
|
|
27
|
+
_scalevalueTemp = 1
|
|
28
|
+
|
|
29
|
+
// 父级区别的大小
|
|
30
|
+
_area?: Tsize
|
|
31
|
+
// 自己元素的大小
|
|
32
|
+
_selfSize?: Tsize
|
|
33
|
+
|
|
34
|
+
// 元素的位置
|
|
35
|
+
_position: Tpoint = {
|
|
36
|
+
x: 0,
|
|
37
|
+
y: 0,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
_positionTemp: Tpoint = {
|
|
41
|
+
x: 0,
|
|
42
|
+
y: 0,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
constructor() {
|
|
46
|
+
super('MovableView')
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
get _outOfBounds() {
|
|
50
|
+
if (this.getAttribute('outOfBounds')) {
|
|
51
|
+
return this.selfSize ? this.selfSize.w / 3 : 0
|
|
52
|
+
}
|
|
53
|
+
return 0
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
set area(val: Tsize) {
|
|
57
|
+
this._area = val
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get area(): Tsize | undefined {
|
|
61
|
+
return this._area
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
startScale() {
|
|
65
|
+
this._scalevalueTemp = this._scaleValue
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
doScale(val: number) {
|
|
69
|
+
const scale = this.getAttribute('scale')
|
|
70
|
+
|
|
71
|
+
// 禁止缩放的时候不生效
|
|
72
|
+
if (scale) {
|
|
73
|
+
this.scaleValue = val * this._scalevalueTemp
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
set scaleValue(val: number) {
|
|
78
|
+
if (this.checkScaleValueInBounds(val)) {
|
|
79
|
+
this._scaleValue = val
|
|
80
|
+
|
|
81
|
+
this.checkPositionBoundary(this.position, val)
|
|
82
|
+
|
|
83
|
+
const scaleFns = this?.__listeners?.scale || []
|
|
84
|
+
scaleFns.forEach((fn) => {
|
|
85
|
+
fn({ ...this.position, scale: this.scaleValue })
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
get scaleValue() {
|
|
91
|
+
return this._scaleValue
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
startMove() {
|
|
95
|
+
this._positionTemp = this._position
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
doMove(val: Tpoint) {
|
|
99
|
+
if (!this.area || !this.selfSize) return
|
|
100
|
+
if (this.getAttribute('disabled')) return
|
|
101
|
+
const direction = this.getAttribute('direction')
|
|
102
|
+
|
|
103
|
+
// 容器的宽高终点
|
|
104
|
+
const areaWidthEnd = this.area.w - this.selfSize.w * this.scaleValue
|
|
105
|
+
const areaHeightEnd = this.area.h - this.selfSize.h * this.scaleValue
|
|
106
|
+
|
|
107
|
+
const incrementWidth = (this.scaleValue - 1) * this.selfSize.w
|
|
108
|
+
const incrementHeight = (this.scaleValue - 1) * this.selfSize.h
|
|
109
|
+
|
|
110
|
+
let x = this._positionTemp.x
|
|
111
|
+
let y = this._positionTemp.y
|
|
112
|
+
if (['all', 'horizontal'].includes(direction)) {
|
|
113
|
+
const nextX = this._positionTemp.x + val.x * this.scaleValue
|
|
114
|
+
x = calcPosition(
|
|
115
|
+
nextX,
|
|
116
|
+
incrementWidth * 0.5 - this._outOfBounds,
|
|
117
|
+
areaWidthEnd + incrementWidth * 0.5 + this._outOfBounds
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (['all', 'vertical'].includes(direction)) {
|
|
122
|
+
const nextY = this._positionTemp.y + val.y * this.scaleValue
|
|
123
|
+
y = calcPosition(
|
|
124
|
+
nextY,
|
|
125
|
+
incrementHeight * 0.5 - this._outOfBounds,
|
|
126
|
+
areaHeightEnd + incrementHeight * 0.5 + this._outOfBounds
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const changeFns = this?.__listeners?.change || []
|
|
131
|
+
changeFns.forEach((fn) => {
|
|
132
|
+
fn({ x, y, source: 'touch' })
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
this.position = {
|
|
136
|
+
x: x,
|
|
137
|
+
y: y,
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
get position() {
|
|
142
|
+
return this._position
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
set position(val: Tpoint) {
|
|
146
|
+
this._position = val
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
set selfSize(val: Tsize) {
|
|
150
|
+
this._selfSize = val
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
get selfSize(): Tsize | undefined {
|
|
154
|
+
return this._selfSize
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
checkPositionBoundary(position: Tpoint, scale: number) {
|
|
158
|
+
if (!this.area || !this.selfSize) {
|
|
159
|
+
return { x: 0, y: 0 }
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const areaWidthEnd = this.area.w - this.selfSize.w * scale
|
|
163
|
+
const areaHeightEnd = this.area.h - this.selfSize.h * scale
|
|
164
|
+
|
|
165
|
+
const incrementWidth = (scale - 1) * this.selfSize.w
|
|
166
|
+
const incrementHeight = (scale - 1) * this.selfSize.h
|
|
167
|
+
|
|
168
|
+
this.position = {
|
|
169
|
+
x: calcPosition(position.x, incrementWidth * 0.5, areaWidthEnd + incrementWidth * 0.5),
|
|
170
|
+
y: calcPosition(position.y, incrementHeight * 0.5, areaHeightEnd + incrementHeight * 0.5),
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
checkScaleValueInBounds(currentScale: number) {
|
|
175
|
+
const scaleMin = this.getAttribute('scaleMin')
|
|
176
|
+
const scaleMax = this.getAttribute('scaleMax')
|
|
177
|
+
|
|
178
|
+
if (scaleMin && Number(scaleMin) >= 0.1 && currentScale < Number(scaleMin)) {
|
|
179
|
+
return false
|
|
180
|
+
} else if (scaleMax && Number(scaleMax) >= 0.1 && currentScale > Number(scaleMax)) {
|
|
181
|
+
return false
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return true
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
public setAttribute(name: string, value: any): void {
|
|
188
|
+
if (name === 'x') {
|
|
189
|
+
this.checkPositionBoundary({ x: value, y: this.position.y }, this.scaleValue)
|
|
190
|
+
}
|
|
191
|
+
if (name === 'y') {
|
|
192
|
+
this.checkPositionBoundary({ x: this.position.x, y: value }, this.scaleValue)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
super.setAttribute(name, value)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
public callTouchEventFnFromGesture(eventName: string, gestureEvent: GestureEvent) {
|
|
199
|
+
const touchFns = (this?.__listeners?.[eventName] || []) as Function[]
|
|
200
|
+
touchFns.forEach(fn => {
|
|
201
|
+
fn({
|
|
202
|
+
changedTouches: gestureEvent.fingerList.map(finger => ({
|
|
203
|
+
clientX: finger.globalX,
|
|
204
|
+
clientY: finger.globalY
|
|
205
|
+
}))
|
|
206
|
+
})
|
|
207
|
+
})
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -6,50 +6,60 @@ 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
|
+
|
|
20
|
+
@Observed
|
|
15
21
|
class TaroViewElement extends TaroElement<ViewProps> {
|
|
16
22
|
constructor() {
|
|
17
23
|
super('View')
|
|
18
24
|
}
|
|
19
25
|
}
|
|
20
26
|
|
|
27
|
+
@Observed
|
|
21
28
|
class TaroImageElement extends TaroElement<ImageProps> {
|
|
22
29
|
constructor() {
|
|
23
30
|
super('Image')
|
|
24
31
|
}
|
|
25
32
|
}
|
|
26
33
|
|
|
34
|
+
@Observed
|
|
27
35
|
class TaroButtonElement extends TaroElement<ButtonProps> {
|
|
28
36
|
constructor() {
|
|
29
37
|
super('Button')
|
|
30
38
|
}
|
|
31
39
|
}
|
|
32
40
|
|
|
33
|
-
|
|
34
|
-
class TaroIconElement extends TaroElement<IconProps>{
|
|
41
|
+
@Observed
|
|
42
|
+
class TaroIconElement extends TaroElement<IconProps> {
|
|
35
43
|
constructor() {
|
|
36
44
|
super('Icon')
|
|
37
45
|
}
|
|
38
46
|
}
|
|
39
|
-
|
|
40
|
-
class TaroLabelElement extends TaroElement<LabelProps>{
|
|
47
|
+
@Observed
|
|
48
|
+
class TaroLabelElement extends TaroElement<LabelProps> {
|
|
41
49
|
constructor() {
|
|
42
50
|
super('Label')
|
|
43
51
|
}
|
|
44
52
|
}
|
|
45
53
|
|
|
46
|
-
|
|
54
|
+
@Observed
|
|
55
|
+
class TaroRichTextElement extends TaroElement<RichTextProps> {
|
|
47
56
|
constructor() {
|
|
48
57
|
super('RichText')
|
|
49
58
|
}
|
|
50
59
|
}
|
|
51
60
|
|
|
52
|
-
|
|
61
|
+
@Observed
|
|
62
|
+
class TaroSwiperElement extends TaroElement<SwiperProps> {
|
|
53
63
|
controller: SwiperController = new SwiperController()
|
|
54
64
|
|
|
55
65
|
constructor() {
|
|
@@ -57,20 +67,37 @@ class TaroSwiperElement extends TaroElement<SwiperProps>{
|
|
|
57
67
|
}
|
|
58
68
|
}
|
|
59
69
|
|
|
60
|
-
|
|
70
|
+
@Observed
|
|
71
|
+
class TaroSwiperItemElement extends TaroElement<SwiperItemProps> {
|
|
61
72
|
constructor() {
|
|
62
73
|
super('SwiperItem')
|
|
63
74
|
}
|
|
64
75
|
}
|
|
65
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
|
+
}
|
|
66
90
|
|
|
67
91
|
export {
|
|
68
92
|
TaroButtonElement,
|
|
69
93
|
TaroIconElement,
|
|
70
94
|
TaroImageElement,
|
|
71
95
|
TaroLabelElement,
|
|
96
|
+
TaroNavigationBarElement,
|
|
97
|
+
TaroOtherElement,
|
|
98
|
+
TaroPageMetaElement,
|
|
72
99
|
TaroRichTextElement,
|
|
73
100
|
TaroSwiperElement,
|
|
74
101
|
TaroSwiperItemElement,
|
|
75
|
-
TaroViewElement
|
|
102
|
+
TaroViewElement
|
|
76
103
|
}
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
import { TaroNode } from '../node'
|
|
2
1
|
import { TaroElement } from './element'
|
|
3
2
|
|
|
4
3
|
import type { TextProps } from '@tarojs/components/types'
|
|
5
4
|
|
|
5
|
+
@Observed
|
|
6
6
|
export class TaroTextElement extends TaroElement<TextProps> {
|
|
7
7
|
constructor() {
|
|
8
8
|
super('Text')
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
public appendChild (child: TaroNode): TaroNode {
|
|
12
|
-
super.appendChild(child)
|
|
13
|
-
|
|
14
|
-
this.updateComponent()
|
|
15
|
-
return child
|
|
16
|
-
}
|
|
17
10
|
}
|
|
@@ -2,13 +2,14 @@ import { TaroElement } from './element'
|
|
|
2
2
|
|
|
3
3
|
import type { VideoProps } from '@tarojs/components/types'
|
|
4
4
|
|
|
5
|
+
@Observed
|
|
5
6
|
export class TaroVideoElement extends TaroElement<VideoProps> {
|
|
6
|
-
_currentTime = 0
|
|
7
|
-
|
|
8
7
|
controller: VideoController = new VideoController()
|
|
9
8
|
|
|
10
9
|
constructor() {
|
|
11
10
|
super('Video')
|
|
11
|
+
|
|
12
|
+
this._nodeInfo._currentTime = 0
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
async play() {
|
|
@@ -39,11 +40,11 @@ export class TaroVideoElement extends TaroElement<VideoProps> {
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
get currentTime() {
|
|
42
|
-
return this._currentTime
|
|
43
|
+
return this._nodeInfo._currentTime
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
set currentTime(val: number) {
|
|
46
|
-
this._currentTime = val
|
|
47
|
+
this._nodeInfo._currentTime = val
|
|
47
48
|
this.controller.setCurrentTime(val)
|
|
48
49
|
}
|
|
49
50
|
}
|