@tarojs/plugin-platform-harmony-ets 4.0.0-beta.5 → 4.0.0-beta.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/apis/base/system.ts +53 -20
  2. package/dist/apis/canvas/index.ts +10 -1
  3. package/dist/apis/device/clipboard.ts +4 -0
  4. package/dist/apis/framework/index.ts +1 -5
  5. package/dist/apis/index.ts +27 -17
  6. package/dist/apis/network/request.ts +5 -5
  7. package/dist/apis/route/index.ts +15 -0
  8. package/dist/apis/storage/index.ts +148 -80
  9. package/dist/apis/ui/animation/animation.ts +71 -28
  10. package/dist/apis/ui/background.ts +2 -1
  11. package/dist/apis/ui/interaction/index.ts +40 -49
  12. package/dist/apis/ui/navigation-bar/index.ts +1 -1
  13. package/dist/apis/utils/index.ts +1 -1
  14. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  15. package/dist/apis/wxml/index.ts +2 -0
  16. package/dist/apis/wxml/selectorQuery.ts +18 -9
  17. package/dist/components-harmony-ets/button.ets +48 -34
  18. package/dist/components-harmony-ets/canvas.ets +51 -0
  19. package/dist/components-harmony-ets/checkbox.ets +69 -61
  20. package/dist/components-harmony-ets/form.ets +51 -29
  21. package/dist/components-harmony-ets/icon.ets +31 -19
  22. package/dist/components-harmony-ets/image.ets +27 -14
  23. package/dist/components-harmony-ets/index.ets +85 -0
  24. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  25. package/dist/components-harmony-ets/input.ets +41 -40
  26. package/dist/components-harmony-ets/label.ets +69 -42
  27. package/dist/components-harmony-ets/movableArea.ets +126 -0
  28. package/dist/components-harmony-ets/movableView.ets +73 -0
  29. package/dist/components-harmony-ets/navigationBar.ets +25 -0
  30. package/dist/components-harmony-ets/pageMeta.ets +28 -0
  31. package/dist/components-harmony-ets/picker.ets +42 -38
  32. package/dist/components-harmony-ets/progress.ets +52 -0
  33. package/dist/components-harmony-ets/pseudo.ets +80 -0
  34. package/dist/components-harmony-ets/radio.ets +71 -64
  35. package/dist/components-harmony-ets/richText.ets +14 -30
  36. package/dist/components-harmony-ets/scrollView.ets +61 -57
  37. package/dist/components-harmony-ets/slider.ets +15 -14
  38. package/dist/components-harmony-ets/style.ets +390 -130
  39. package/dist/components-harmony-ets/swiper.ets +38 -20
  40. package/dist/components-harmony-ets/switch.ets +30 -28
  41. package/dist/components-harmony-ets/{index.ts → tag.ts} +2 -0
  42. package/dist/components-harmony-ets/text.ets +121 -51
  43. package/dist/components-harmony-ets/textArea.ets +35 -34
  44. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  45. package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
  46. package/dist/components-harmony-ets/utils/flexManager.ets +47 -19
  47. package/dist/components-harmony-ets/utils/helper.ets +17 -5
  48. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  49. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  50. package/dist/components-harmony-ets/utils/index.ts +50 -51
  51. package/dist/components-harmony-ets/utils/styles.ets +170 -93
  52. package/dist/components-harmony-ets/video.ets +34 -20
  53. package/dist/components-harmony-ets/view.ets +63 -52
  54. package/dist/components-harmony-ets/webView.ets +40 -34
  55. package/dist/index.d.ts +152 -0
  56. package/dist/index.js +82 -39
  57. package/dist/index.js.map +1 -1
  58. package/dist/runtime-ets/bom/document.ts +6 -4
  59. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  60. package/dist/runtime-ets/bom/window.ts +7 -0
  61. package/dist/runtime-ets/current.ts +3 -0
  62. package/dist/runtime-ets/dom/bind.ts +31 -13
  63. package/dist/runtime-ets/dom/cssNesting.ts +393 -0
  64. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +25 -39
  65. package/dist/runtime-ets/dom/document.ts +22 -8
  66. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  67. package/dist/runtime-ets/dom/element/element.ts +317 -51
  68. package/dist/runtime-ets/dom/element/form.ts +23 -26
  69. package/dist/runtime-ets/dom/element/index.ts +24 -2
  70. package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
  71. package/dist/runtime-ets/dom/element/movableView.ts +193 -0
  72. package/dist/runtime-ets/dom/element/normal.ts +35 -8
  73. package/dist/runtime-ets/dom/element/progress.ts +12 -0
  74. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  75. package/dist/runtime-ets/dom/element/text.ts +1 -8
  76. package/dist/runtime-ets/dom/element/video.ts +5 -3
  77. package/dist/runtime-ets/dom/element/webView.ts +11 -3
  78. package/dist/runtime-ets/dom/event.ts +0 -1
  79. package/dist/runtime-ets/dom/eventTarget.ts +0 -3
  80. package/dist/runtime-ets/dom/node.ts +46 -28
  81. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +334 -230
  82. package/dist/runtime-ets/dom/stylesheet/index.ts +28 -308
  83. package/dist/runtime-ets/dom/stylesheet/type.ts +40 -9
  84. package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
  85. package/dist/runtime-ets/index.ts +2 -2
  86. package/dist/runtime-ets/interface/event.ts +1 -1
  87. package/dist/runtime-ets/utils/index.ts +66 -11
  88. package/dist/runtime-ets/utils/info.ts +1 -1
  89. package/dist/runtime-framework/react/app.ts +7 -2
  90. package/dist/runtime-framework/react/index.ts +0 -2
  91. package/dist/runtime-framework/react/native-page.ts +32 -14
  92. package/dist/runtime-framework/react/page.ts +3 -8
  93. package/dist/runtime-framework/solid/app.ts +25 -45
  94. package/dist/runtime-framework/solid/connect.ts +21 -3
  95. package/dist/runtime-framework/solid/hooks.ts +16 -11
  96. package/dist/runtime-framework/solid/index.ts +6 -2
  97. package/dist/runtime-framework/solid/page.ts +84 -30
  98. package/dist/runtime-framework/solid/reconciler/props.ts +65 -20
  99. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  100. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  101. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  102. package/dist/runtime-utils.d.ts +827 -0
  103. package/dist/runtime-utils.js +399 -188
  104. package/dist/runtime-utils.js.map +1 -1
  105. package/dist/runtime.d.ts +1 -0
  106. package/dist/runtime.js +399 -188
  107. package/dist/runtime.js.map +1 -1
  108. package/index.js +3 -1
  109. package/package.json +13 -13
  110. package/static/media/cancel.svg +1 -1
  111. package/static/media/circle.svg +1 -1
  112. package/static/media/clear.svg +1 -1
  113. package/static/media/download.svg +1 -1
  114. package/static/media/info.svg +1 -1
  115. package/static/media/info_circle.svg +1 -1
  116. package/static/media/search.svg +1 -1
  117. package/static/media/success.svg +1 -1
  118. package/static/media/success_no_circle.svg +1 -1
  119. package/static/media/warn.svg +1 -1
  120. package/types/harmony.d.ts +4 -0
  121. package/types/index.d.ts +4 -0
  122. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -1,67 +1,90 @@
1
1
  import { eventSource } from '@tarojs/runtime/dist/runtime.esm'
2
+ import { EMPTY_OBJ, toCamelCase } from '@tarojs/shared'
2
3
 
3
4
  import { ATTRIBUTES_CALLBACK_TRIGGER_MAP, ID } from '../../constant'
5
+ import { Current } from '../../current'
4
6
  import { findChildNodeWithDFS } from '../../utils'
5
7
  import { initComponentNodeInfo, triggerAttributesCallback } from '../../utils/info'
6
8
  import { bindAnimation } from '../bind'
7
9
  import { ClassList } from '../class-list'
10
+ import { type ICSSStyleDeclaration, createCSSStyleDeclaration } from '../cssStyleDeclaration'
8
11
  import { NodeType, TaroNode } from '../node'
9
- import StyleSheet from '../stylesheet'
12
+ import StyleSheet, { HarmonyStyle, TaroStyleType } from '../stylesheet'
10
13
 
11
- import type { StandardProps } from '@tarojs/components/types'
14
+ import type { BaseTouchEvent, ITouchEvent, StandardProps } from '@tarojs/components/types'
12
15
  import type { TaroAny } from '../../utils'
13
- import type { ICSSStyleDeclaration } from '../cssStyleDeclaration'
14
16
 
15
- type NamedNodeMap = ({ name: string, value: string })[]
17
+ type NamedNodeMap = { name: string, value: string }[]
16
18
 
17
19
  export interface TaroExtraProps {
18
20
  compileMode?: string | boolean
19
21
  compileIf?: boolean
20
22
  disabled?: boolean
23
+ __hmStyle?: TaroStyleType
21
24
  }
22
25
 
23
- @Observed
24
- export class TaroElement<T extends StandardProps = StandardProps> extends TaroNode {
26
+ export class TaroElement<
27
+ T extends StandardProps<any, U> = StandardProps,
28
+ U extends BaseTouchEvent<any> = ITouchEvent
29
+ > extends TaroNode {
25
30
  public _innerHTML = ''
26
- public _nodeInfo: TaroAny = {}
31
+ public _nodeInfo: TaroAny = {
32
+ layer: 0 // 渲染层级
33
+ }
34
+
35
+ public hm_instance: TaroAny
36
+
37
+ public get _instance () {
38
+ return this.hm_instance
39
+ }
40
+
41
+ public set _instance (value) {
42
+ this.hm_instance = value
43
+ if (this._nodeInfo.aboutToAppear) {
44
+ let task
45
+ // eslint-disable-next-line no-cond-assign
46
+ while (task = this._nodeInfo.aboutToAppear.shift()) {
47
+ task()
48
+ }
49
+ }
50
+ }
51
+
27
52
  public readonly tagName: string
53
+ public dataset: Record<string, unknown> = EMPTY_OBJ
28
54
  public _attrs: T & TaroExtraProps = {} as T & TaroExtraProps
29
55
 
30
- _client?: Area
31
- _scroll?: Area
32
-
33
56
  constructor(tagName: string) {
34
57
  super(tagName.replace(new RegExp('(?<=.)([A-Z])', 'g'), '-$1').toUpperCase(), NodeType.ELEMENT_NODE)
35
58
  this.tagName = this.nodeName
36
-
59
+ this._style = createCSSStyleDeclaration(this)
37
60
  initComponentNodeInfo(this)
38
61
  bindAnimation(this)
39
62
  }
40
63
 
41
- public set id (value: string) {
64
+ public set id(value: string) {
42
65
  this.setAttribute('id', value)
43
66
  }
44
67
 
45
- public get id (): string {
68
+ public get id(): string {
46
69
  return this.getAttribute('id') || this._nid
47
70
  }
48
71
 
49
- public set className (value: string) {
72
+ public set className(value: string) {
50
73
  this.setAttribute('class', value)
51
74
  }
52
75
 
53
- public get className (): string {
76
+ public get className(): string {
54
77
  return this.getAttribute('class') || ''
55
78
  }
56
79
 
57
- public get classList (): ClassList {
80
+ public get classList(): ClassList {
58
81
  return new ClassList(this.className, this)
59
82
  }
60
83
 
61
- public get attributes (): NamedNodeMap {
84
+ public get attributes(): NamedNodeMap {
62
85
  const list: NamedNodeMap = []
63
86
 
64
- Object.keys(this._attrs).forEach(name => {
87
+ Object.keys(this._attrs).forEach((name) => {
65
88
  const value: TaroAny = this._attrs[name]
66
89
 
67
90
  list.push({ name, value })
@@ -70,14 +93,24 @@ export class TaroElement<T extends StandardProps = StandardProps> extends TaroNo
70
93
  return list
71
94
  }
72
95
 
73
- public get children (): TaroElement[] {
74
- return this.childNodes.filter(node => node.nodeType === NodeType.ELEMENT_NODE) as TaroElement[]
96
+ public get children(): TaroElement[] {
97
+ return this.childNodes.filter((node) => node.nodeType === NodeType.ELEMENT_NODE) as TaroElement[]
75
98
  }
76
99
 
77
- public setAttribute (name: string, value: TaroAny): void {
78
- if (name === ID) {
79
- eventSource.delete(this._attrs.id)
80
- eventSource.set(value, this as TaroAny)
100
+ public setAttribute(name: string, value: TaroAny): void {
101
+ switch (name) {
102
+ case ID:
103
+ eventSource.delete(this._attrs.id)
104
+ eventSource.set(value, this as TaroAny)
105
+ break
106
+ default:
107
+ if (name.startsWith('data-')) {
108
+ if (this.dataset === EMPTY_OBJ) {
109
+ this.dataset = Object.create(null)
110
+ }
111
+ this.dataset[toCamelCase(name.replace(/^data-/, ''))] = value
112
+ }
113
+ break
81
114
  }
82
115
 
83
116
  this._attrs[name] = value
@@ -93,50 +126,64 @@ export class TaroElement<T extends StandardProps = StandardProps> extends TaroNo
93
126
  }
94
127
  }
95
128
 
96
- public getAttribute (name: string): string {
129
+ public getAttribute(name: string): string {
97
130
  return this._attrs[name]
98
131
  }
99
132
 
100
- public removeAttribute (name: string): void {
133
+ public removeAttribute(name: string): void {
101
134
  this._attrs[name] = null
102
135
  }
103
136
 
104
- public hasAttribute (name: string): boolean {
137
+ public hasAttribute(name: string): boolean {
105
138
  return !!this._attrs[name]
106
139
  }
107
140
 
108
- public hasAttributes (): boolean {
141
+ public hasAttributes(): boolean {
109
142
  return Object.keys(this._attrs).length > 0
110
143
  }
111
144
 
112
- public getElementById<T extends TaroElement = TaroElement> (id: string | undefined | null) {
113
- return findChildNodeWithDFS<T>(this as TaroAny, (el) => {
114
- return el.id === id
115
- }, false)
145
+ public getElementById<T extends TaroElement = TaroElement>(id: string | undefined | null) {
146
+ return findChildNodeWithDFS<T>(
147
+ this as TaroAny,
148
+ (el) => {
149
+ return el.id === id
150
+ },
151
+ false
152
+ )
116
153
  }
117
154
 
118
- public getElementsByTagName<T extends TaroElement = TaroElement> (tagName: string) {
119
- return findChildNodeWithDFS<T>(this as TaroAny, (el) => {
120
- return el.nodeName === tagName || (tagName === '*' && this as TaroAny !== el)
121
- }, true) || []
155
+ public getElementsByTagName<T extends TaroElement = TaroElement>(tagName: string) {
156
+ return (
157
+ findChildNodeWithDFS<T>(
158
+ this as TaroAny,
159
+ (el) => {
160
+ return el.nodeName === tagName || (tagName === '*' && (this as TaroAny) !== el)
161
+ },
162
+ true
163
+ ) || []
164
+ )
122
165
  }
123
166
 
124
- public getElementsByClassName<T extends TaroElement = TaroElement> (className: string) {
167
+ public getElementsByClassName<T extends TaroElement = TaroElement>(className: string) {
125
168
  const classNames = className.trim().split(new RegExp('\\s+'))
126
169
 
127
- return findChildNodeWithDFS<T>(this as TaroAny, (el) => {
128
- const classList = el.classList
129
- return classNames.every(c => {
130
- const bool = classList.contains(c)
131
-
132
- return bool
133
- })
134
- }, true) || []
170
+ return (
171
+ findChildNodeWithDFS<T>(
172
+ this as TaroAny,
173
+ (el) => {
174
+ const classList = el.classList
175
+ return classNames.every((c) => {
176
+ const bool = classList.contains(c)
177
+
178
+ return bool
179
+ })
180
+ },
181
+ true
182
+ ) || []
183
+ )
135
184
  }
136
185
 
137
- // TODO dataset
138
-
139
- public set innerHTML (value: string) {
186
+ public set innerHTML(value: string) {
140
187
  if (this.nodeType === NodeType.ELEMENT_NODE && this.ownerDocument) {
141
188
  const ele = this.ownerDocument.createElement('inner-html')
142
189
  ele._innerHTML = value
@@ -144,20 +191,239 @@ export class TaroElement<T extends StandardProps = StandardProps> extends TaroNo
144
191
  }
145
192
  }
146
193
 
147
- public get innerHTML (): string {
194
+ public get innerHTML(): string {
148
195
  return this._innerHTML
149
196
  }
150
197
 
198
+ // 存放的样式,获取其实跟获取style是一样的,只不过这里取的更快捷,不需要走style的get方法进到cssStyleDeclaration
151
199
  public _st = new StyleSheet()
152
200
 
153
201
  // 经转换后的鸿蒙样式
154
- public get hmStyle () {
202
+ public get hmStyle() {
155
203
  return this._st.hmStyle
156
204
  }
157
205
 
158
206
  public _style: ICSSStyleDeclaration | null = null
159
207
 
160
- public get style (): ICSSStyleDeclaration | null {
208
+ public get style(): ICSSStyleDeclaration | null {
161
209
  return this._style
162
210
  }
211
+
212
+ // 伪元素,不存在style动态设置,均已被转换为鸿蒙样式
213
+ // 可根据实际情况,迁移到具体的组件中,如View、ScrollView中,Text\Image其实是不需要的
214
+ public _pseudo_before: StyleSheet | null = null
215
+
216
+ public set_pseudo_before(value: HarmonyStyle | null) {
217
+ if (value) {
218
+ if (!this._pseudo_before) {
219
+ this._pseudo_before = new StyleSheet()
220
+ }
221
+ Object.keys(value).forEach(key => {
222
+ this._pseudo_before!.hmStyle[key] = value[key]
223
+ })
224
+ } else {
225
+ this._pseudo_before = null
226
+ }
227
+ }
228
+
229
+ public _pseudo_after: StyleSheet | null = null
230
+
231
+ public set_pseudo_after(value: HarmonyStyle | null) {
232
+ if (value) {
233
+ if (!this._pseudo_after) {
234
+ this._pseudo_after = new StyleSheet()
235
+ }
236
+ Object.keys(value).forEach(key => {
237
+ this._pseudo_after!.hmStyle[key] = value[key]
238
+ })
239
+ } else {
240
+ this._pseudo_after = null
241
+ }
242
+ }
243
+
244
+ // 伪类,在获取的时候根据dom和parent的关系,动态设置
245
+ public _pseudo_class: Record<string, StyleSheet | null> = {
246
+ // ["::first-child"]: new StyleSheet(),
247
+ }
248
+
249
+ public set_pseudo_class(name: string, value: HarmonyStyle | null) {
250
+ if (value) {
251
+ if (!this._pseudo_class[name]) {
252
+ this._pseudo_class[name] = new StyleSheet()
253
+ }
254
+ Object.keys(value).forEach(key => {
255
+ this._pseudo_class[name]!.hmStyle[key] = value[key]
256
+ })
257
+ } else {
258
+ this._pseudo_class[name] = null
259
+ }
260
+ }
261
+
262
+ get currentLayerNode () {
263
+ if (!Current.page) return null
264
+ if (typeof Current.page.tabBarCurrentIndex !== 'undefined') {
265
+ Current.page.layerNode ||= []
266
+ Current.page.layerNode[Current.page.tabBarCurrentIndex] ||= Current.createHarmonyElement('VIEW')
267
+ // Tabbar
268
+ return Current.page.layerNode[Current.page.tabBarCurrentIndex]
269
+ } else {
270
+ Current.page.layerNode ||= Current.createHarmonyElement('VIEW')
271
+ return Current.page.layerNode
272
+ }
273
+ }
274
+
275
+ get currentLayerParents () {
276
+ if (!Current.page) return null
277
+ if (typeof Current.page.tabBarCurrentIndex !== 'undefined') {
278
+ Current.page.layerParents ||= []
279
+ Current.page.layerParents[Current.page.tabBarCurrentIndex] ||= []
280
+ // Tabbar
281
+ return Current.page.layerParents[Current.page.tabBarCurrentIndex]
282
+ } else {
283
+ Current.page.layerParents ||= []
284
+ return Current.page.layerParents
285
+ }
286
+ }
287
+
288
+ // 设置渲染层级,0为正常层级,大于0为固定层级
289
+ // 1、appendChild的时候会判断是否需要设置层级
290
+ // 2、taro-react的setProperty,在处理属性变化的时候,会判断是否需要设置层级
291
+ // 3、removeChild的时候,会判断是否需要移除层级
292
+ public setLayer (value: number) {
293
+ if (!this.parentNode) return // 没有父节点,不需要设置层级关系
294
+ this._nodeInfo.layer = value
295
+
296
+ const currentLayerNode = this.currentLayerNode
297
+ const currentLayerParents = this.currentLayerParents
298
+ if (!currentLayerNode || !currentLayerParents) return
299
+ if (value > 0) {
300
+ // 插入到固定浮层
301
+ currentLayerNode.childNodes.push(this)
302
+ currentLayerNode.notifyDataAdd(currentLayerNode.childNodes.length - 1)
303
+ // 绑定祖先的节点id,建立关系,方便在祖先卸载(removeChild)的时候,能够找到该节点使其卸载
304
+ const _parentRecord = {}
305
+ generateLayerParentIds(_parentRecord, this)
306
+ currentLayerParents[this._nid] = _parentRecord
307
+ } else {
308
+ const idx = currentLayerNode.childNodes.findIndex(n => n._nid === this._nid)
309
+ currentLayerNode.childNodes.splice(idx, 1)
310
+ currentLayerNode.notifyDataDelete(idx)
311
+
312
+ delete currentLayerParents[this._nid]
313
+ }
314
+
315
+ if (this.parentNode) {
316
+ this.parentNode.notifyDataChange(this.parentNode.findIndex(this))
317
+ this.updateComponent()
318
+ }
319
+ }
320
+
321
+ protected toggleLayer(add: boolean) {
322
+ if (add) {
323
+ if (this._st?.hmStyle.position === 'fixed') {
324
+ this.setLayer(1)
325
+ }
326
+ } else {
327
+ const currentLayerParents = this.currentLayerParents
328
+ if (!currentLayerParents) return
329
+ // 识别Current.page.layerParents里面是否有需要移除的固定元素
330
+ if (this._nodeInfo?.layer > 0) {
331
+ delete currentLayerParents[this._nid]
332
+ this.setLayer(0)
333
+ } else {
334
+ Object.keys(currentLayerParents).forEach(fixedId => {
335
+ const parentIds =currentLayerParents[fixedId]
336
+ if (parentIds[this._nid]) {
337
+ // 需要移除fixedId
338
+ delete currentLayerParents[fixedId]
339
+ const fixedNode = eventSource.get(fixedId) as unknown as TaroElement
340
+ if (fixedNode) {
341
+ fixedNode.setLayer(0)
342
+ }
343
+ }
344
+ })
345
+ }
346
+ }
347
+ }
348
+
349
+ // 设置动画
350
+ public setAnimation (playing) {
351
+ if (!this._instance) {
352
+ if (!this._nodeInfo.aboutToAppear) {
353
+ this._nodeInfo.aboutToAppear = []
354
+ }
355
+ this._nodeInfo.aboutToAppear.push(() => {
356
+ this.setAnimation(playing)
357
+ })
358
+ return
359
+ }
360
+
361
+ const keyframes = this._st.hmStyle.animationName
362
+
363
+ // 防止动画闪烁,需要把第一帧的内容先设置上去设置初始样式
364
+ if (playing && keyframes && keyframes[0] && keyframes[0].percentage === 0) {
365
+ this._instance.overwriteStyle = keyframes[0].event
366
+ }
367
+
368
+ // 首次设置,不用实例替换
369
+ if (!this._nodeInfo.hasAnimation) {
370
+ this._nodeInfo.hasAnimation = true
371
+ // 下一帧播放,等节点样式首次设置上去在进行覆盖
372
+ setTimeout(() => {
373
+ if (playing) {
374
+ this.playAnimation()
375
+ }
376
+ }, 0)
377
+ } else if (this.parentNode) {
378
+ const idx = this.parentNode.findIndex(this)
379
+ // Note: 因为keyframeAnimateTo无法暂停,华为没有支持,只能临时先换掉实例,重新创建ark节点,使得原本的keyframeAnimateTo失效
380
+ // remove
381
+ this.parentNode.childNodes.splice(idx, 1)
382
+ this.parentNode.notifyDataDelete(idx)
383
+
384
+ // 下一帧播放,等实例被移除掉,再重新插入
385
+ setTimeout(() => {
386
+ // insert
387
+ this.parentNode?.childNodes.splice(idx, 0, this)
388
+ this.parentNode?.notifyDataAdd(idx)
389
+
390
+ // 执行动画
391
+ if (playing) {
392
+ this.playAnimation()
393
+ }
394
+ }, 0)
395
+ }
396
+ }
397
+
398
+ private playAnimation () {
399
+ const {
400
+ animationDuration = 0, animationDelay = 0, animationIterationCount = 1, animationName: keyframes,
401
+ animationTimingFunction
402
+ } = this._st.hmStyle
403
+
404
+ if (keyframes) {
405
+ let cur_percentage = 0
406
+ this._instance.getUIContext()?.keyframeAnimateTo({
407
+ delay: animationDelay,
408
+ iterations: animationIterationCount,
409
+ }, keyframes.map(item => {
410
+ const duration = (item.percentage - cur_percentage) * animationDuration
411
+ cur_percentage = item.percentage
412
+ return {
413
+ duration: duration,
414
+ curve: item.event.animationTimingFunction || animationTimingFunction,
415
+ event: () => {
416
+ this._instance.overwriteStyle = item.event
417
+ }
418
+ }
419
+ }))
420
+ }
421
+ }
422
+ }
423
+
424
+ function generateLayerParentIds(ids: Record<string, true>, node?: TaroElement) {
425
+ if (node?.parentElement) {
426
+ ids[node.parentElement._nid] = true
427
+ generateLayerParentIds(ids, node.parentElement)
428
+ }
163
429
  }
@@ -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':