@tarojs/plugin-platform-harmony-ets 4.0.0-beta.8 → 4.0.0-beta.81

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.
Files changed (130) hide show
  1. package/dist/apis/base/system.ts +73 -20
  2. package/dist/apis/canvas/index.ts +10 -1
  3. package/dist/apis/device/clipboard.ts +16 -8
  4. package/dist/apis/framework/index.ts +1 -5
  5. package/dist/apis/index.ts +25 -17
  6. package/dist/apis/media/image/index.ts +1 -1
  7. package/dist/apis/network/request.ts +5 -5
  8. package/dist/apis/route/index.ts +15 -0
  9. package/dist/apis/storage/index.ts +146 -78
  10. package/dist/apis/ui/animation/animation.ts +71 -29
  11. package/dist/apis/ui/background.ts +2 -1
  12. package/dist/apis/ui/interaction/index.ts +42 -59
  13. package/dist/apis/ui/navigation-bar/index.ts +1 -1
  14. package/dist/apis/ui/pull-down-refresh.ts +9 -3
  15. package/dist/apis/ui/scroll/index.ts +5 -5
  16. package/dist/apis/ui/tab-bar.ts +3 -3
  17. package/dist/apis/utils/index.ts +1 -1
  18. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  19. package/dist/apis/wxml/selectorQuery.ts +26 -13
  20. package/dist/components-harmony-ets/button.ets +64 -34
  21. package/dist/components-harmony-ets/canvas.ets +51 -0
  22. package/dist/components-harmony-ets/checkbox.ets +72 -61
  23. package/dist/components-harmony-ets/form.ets +51 -29
  24. package/dist/components-harmony-ets/icon.ets +31 -19
  25. package/dist/components-harmony-ets/image.ets +34 -14
  26. package/dist/components-harmony-ets/index.ets +92 -0
  27. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  28. package/dist/components-harmony-ets/input.ets +49 -41
  29. package/dist/components-harmony-ets/label.ets +71 -44
  30. package/dist/components-harmony-ets/listView.ets +26 -0
  31. package/dist/components-harmony-ets/movableArea.ets +126 -0
  32. package/dist/components-harmony-ets/movableView.ets +93 -0
  33. package/dist/components-harmony-ets/navigationBar.ets +65 -0
  34. package/dist/components-harmony-ets/pageMeta.ets +94 -0
  35. package/dist/components-harmony-ets/picker.ets +42 -38
  36. package/dist/components-harmony-ets/progress.ets +52 -0
  37. package/dist/components-harmony-ets/pseudo.ets +80 -0
  38. package/dist/components-harmony-ets/radio.ets +74 -64
  39. package/dist/components-harmony-ets/richText.ets +14 -30
  40. package/dist/components-harmony-ets/scrollList.ets +94 -0
  41. package/dist/components-harmony-ets/scrollView.ets +61 -57
  42. package/dist/components-harmony-ets/slider.ets +18 -14
  43. package/dist/components-harmony-ets/stickySection.ets +42 -0
  44. package/dist/components-harmony-ets/style.ets +372 -130
  45. package/dist/components-harmony-ets/swiper.ets +61 -20
  46. package/dist/components-harmony-ets/switch.ets +36 -32
  47. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  48. package/dist/components-harmony-ets/text.ets +135 -49
  49. package/dist/components-harmony-ets/textArea.ets +50 -35
  50. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  51. package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -2
  52. package/dist/components-harmony-ets/utils/flexManager.ets +49 -19
  53. package/dist/components-harmony-ets/utils/helper.ets +18 -5
  54. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  55. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  56. package/dist/components-harmony-ets/utils/index.ts +54 -50
  57. package/dist/components-harmony-ets/utils/styles.ets +170 -93
  58. package/dist/components-harmony-ets/video.ets +34 -21
  59. package/dist/components-harmony-ets/view.ets +63 -52
  60. package/dist/components-harmony-ets/webView.ets +40 -34
  61. package/dist/index.d.ts +152 -0
  62. package/dist/index.js +87 -43
  63. package/dist/index.js.map +1 -1
  64. package/dist/runtime-ets/bom/document.ts +6 -4
  65. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  66. package/dist/runtime-ets/bom/window.ts +7 -0
  67. package/dist/runtime-ets/current.ts +3 -0
  68. package/dist/runtime-ets/dom/bind.ts +28 -12
  69. package/dist/runtime-ets/dom/class-list.ts +2 -2
  70. package/dist/runtime-ets/dom/cssNesting.ts +419 -0
  71. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +28 -42
  72. package/dist/runtime-ets/dom/document.ts +8 -11
  73. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  74. package/dist/runtime-ets/dom/element/element.ts +348 -57
  75. package/dist/runtime-ets/dom/element/form.ts +23 -26
  76. package/dist/runtime-ets/dom/element/index.ts +30 -2
  77. package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
  78. package/dist/runtime-ets/dom/element/movableView.ts +244 -0
  79. package/dist/runtime-ets/dom/element/normal.ts +35 -8
  80. package/dist/runtime-ets/dom/element/progress.ts +11 -0
  81. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  82. package/dist/runtime-ets/dom/element/text.ts +1 -8
  83. package/dist/runtime-ets/dom/element/video.ts +5 -4
  84. package/dist/runtime-ets/dom/element/webView.ts +12 -5
  85. package/dist/runtime-ets/dom/event.ts +2 -4
  86. package/dist/runtime-ets/dom/eventTarget.ts +2 -3
  87. package/dist/runtime-ets/dom/node.ts +54 -29
  88. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +416 -235
  89. package/dist/runtime-ets/dom/stylesheet/index.ts +29 -311
  90. package/dist/runtime-ets/dom/stylesheet/type.ts +49 -9
  91. package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
  92. package/dist/runtime-ets/index.ts +2 -1
  93. package/dist/runtime-ets/interface/event.ts +1 -1
  94. package/dist/runtime-ets/utils/index.ts +73 -13
  95. package/dist/runtime-ets/utils/info.ts +2 -2
  96. package/dist/runtime-framework/react/app.ts +9 -4
  97. package/dist/runtime-framework/react/hooks.ts +0 -1
  98. package/dist/runtime-framework/react/index.ts +0 -2
  99. package/dist/runtime-framework/react/native-page.ts +154 -77
  100. package/dist/runtime-framework/react/page.ts +3 -8
  101. package/dist/runtime-framework/solid/app.ts +25 -45
  102. package/dist/runtime-framework/solid/connect.ts +21 -3
  103. package/dist/runtime-framework/solid/hooks.ts +16 -11
  104. package/dist/runtime-framework/solid/index.ts +6 -2
  105. package/dist/runtime-framework/solid/page.ts +84 -30
  106. package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
  107. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  108. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  109. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  110. package/dist/runtime-utils.d.ts +827 -0
  111. package/dist/runtime-utils.js +449 -219
  112. package/dist/runtime-utils.js.map +1 -1
  113. package/dist/runtime.d.ts +1 -0
  114. package/dist/runtime.js +449 -219
  115. package/dist/runtime.js.map +1 -1
  116. package/index.js +3 -1
  117. package/package.json +13 -13
  118. package/static/media/cancel.svg +1 -1
  119. package/static/media/circle.svg +1 -1
  120. package/static/media/clear.svg +1 -1
  121. package/static/media/download.svg +1 -1
  122. package/static/media/info.svg +1 -1
  123. package/static/media/info_circle.svg +1 -1
  124. package/static/media/search.svg +1 -1
  125. package/static/media/success.svg +1 -1
  126. package/static/media/success_no_circle.svg +1 -1
  127. package/static/media/warn.svg +1 -1
  128. package/types/harmony.d.ts +4 -0
  129. package/types/index.d.ts +4 -0
  130. /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
- class TaroRadioElement extends TaroCheckedElement<RadioProps>{
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, isTaroMovableViewElement } 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
- default: return new TaroElement(tagName)
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,
@@ -90,3 +113,8 @@ export {
90
113
  TaroViewElement,
91
114
  TaroWebViewElement
92
115
  }
116
+
117
+
118
+ export {
119
+ isTaroMovableViewElement
120
+ }
@@ -0,0 +1,11 @@
1
+
2
+ import { TaroElement } from './element'
3
+
4
+ import type { MovableAreaProps } from '@tarojs/components/types'
5
+
6
+ @Observed
7
+ export class TaroMovableAreaElement extends TaroElement<MovableAreaProps> {
8
+ constructor() {
9
+ super('MovableArea')
10
+ }
11
+ }
@@ -0,0 +1,244 @@
1
+ import { TaroElement } from './element'
2
+
3
+ import type { MovableViewProps } from '@tarojs/components/types'
4
+ import type { TaroAny } from '../../utils'
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
+ }
28
+ @Observed
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
+ }
50
+
51
+ constructor() {
52
+ super('MovableView')
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
+ }
244
+ }
@@ -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
- class TaroRichTextElement extends TaroElement<RichTextProps>{
54
+ @Observed
55
+ class TaroRichTextElement extends TaroElement<RichTextProps> {
47
56
  constructor() {
48
57
  super('RichText')
49
58
  }
50
59
  }
51
60
 
52
- class TaroSwiperElement extends TaroElement<SwiperProps>{
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
- class TaroSwiperItemElement extends TaroElement<SwiperItemProps>{
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
  }
@@ -0,0 +1,11 @@
1
+
2
+ import { TaroElement } from './element'
3
+
4
+ import type { ProgressProps } from '@tarojs/components/types'
5
+
6
+ @Observed
7
+ export class TaroProgressElement extends TaroElement<ProgressProps> {
8
+ constructor() {
9
+ super('Progress')
10
+ }
11
+ }
@@ -3,6 +3,7 @@ import { TaroElement } from './element'
3
3
 
4
4
  import type { ScrollViewProps } from '@tarojs/components/types'
5
5
 
6
+ @Observed
6
7
  export class TaroScrollViewElement extends TaroElement<ScrollViewProps> {
7
8
  scroller: Scroller = new Scroller()
8
9
 
@@ -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
  }