@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.
Files changed (128) 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 +9 -1
  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 +146 -78
  9. package/dist/apis/ui/animation/animation.ts +71 -29
  10. package/dist/apis/ui/background.ts +2 -1
  11. package/dist/apis/ui/interaction/index.ts +42 -59
  12. package/dist/apis/ui/navigation-bar/index.ts +1 -1
  13. package/dist/apis/ui/scroll/index.ts +1 -1
  14. package/dist/apis/utils/index.ts +1 -1
  15. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  16. package/dist/apis/wxml/index.ts +2 -0
  17. package/dist/apis/wxml/selectorQuery.ts +24 -11
  18. package/dist/components-harmony-ets/button.ets +48 -34
  19. package/dist/components-harmony-ets/canvas.ets +51 -0
  20. package/dist/components-harmony-ets/checkbox.ets +69 -61
  21. package/dist/components-harmony-ets/form.ets +51 -29
  22. package/dist/components-harmony-ets/icon.ets +31 -19
  23. package/dist/components-harmony-ets/image.ets +34 -14
  24. package/dist/components-harmony-ets/index.ets +92 -0
  25. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  26. package/dist/components-harmony-ets/input.ets +45 -41
  27. package/dist/components-harmony-ets/label.ets +69 -42
  28. package/dist/components-harmony-ets/listView.ets +26 -0
  29. package/dist/components-harmony-ets/movableArea.ets +126 -0
  30. package/dist/components-harmony-ets/movableView.ets +77 -0
  31. package/dist/components-harmony-ets/navigationBar.ets +65 -0
  32. package/dist/components-harmony-ets/pageMeta.ets +94 -0
  33. package/dist/components-harmony-ets/picker.ets +42 -38
  34. package/dist/components-harmony-ets/progress.ets +52 -0
  35. package/dist/components-harmony-ets/pseudo.ets +80 -0
  36. package/dist/components-harmony-ets/radio.ets +71 -64
  37. package/dist/components-harmony-ets/richText.ets +14 -30
  38. package/dist/components-harmony-ets/scrollList.ets +94 -0
  39. package/dist/components-harmony-ets/scrollView.ets +61 -57
  40. package/dist/components-harmony-ets/slider.ets +15 -14
  41. package/dist/components-harmony-ets/stickySection.ets +42 -0
  42. package/dist/components-harmony-ets/style.ets +372 -130
  43. package/dist/components-harmony-ets/swiper.ets +61 -20
  44. package/dist/components-harmony-ets/switch.ets +30 -28
  45. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  46. package/dist/components-harmony-ets/text.ets +135 -49
  47. package/dist/components-harmony-ets/textArea.ets +47 -35
  48. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  49. package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
  50. package/dist/components-harmony-ets/utils/flexManager.ets +47 -19
  51. package/dist/components-harmony-ets/utils/helper.ets +18 -5
  52. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  53. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  54. package/dist/components-harmony-ets/utils/index.ts +54 -50
  55. package/dist/components-harmony-ets/utils/styles.ets +170 -93
  56. package/dist/components-harmony-ets/video.ets +34 -21
  57. package/dist/components-harmony-ets/view.ets +63 -52
  58. package/dist/components-harmony-ets/webView.ets +40 -34
  59. package/dist/index.d.ts +152 -0
  60. package/dist/index.js +85 -42
  61. package/dist/index.js.map +1 -1
  62. package/dist/runtime-ets/bom/document.ts +6 -4
  63. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  64. package/dist/runtime-ets/bom/window.ts +7 -0
  65. package/dist/runtime-ets/current.ts +3 -0
  66. package/dist/runtime-ets/dom/bind.ts +28 -12
  67. package/dist/runtime-ets/dom/class-list.ts +2 -2
  68. package/dist/runtime-ets/dom/cssNesting.ts +409 -0
  69. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +28 -42
  70. package/dist/runtime-ets/dom/document.ts +22 -8
  71. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  72. package/dist/runtime-ets/dom/element/element.ts +334 -58
  73. package/dist/runtime-ets/dom/element/form.ts +23 -26
  74. package/dist/runtime-ets/dom/element/index.ts +25 -2
  75. package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
  76. package/dist/runtime-ets/dom/element/movableView.ts +209 -0
  77. package/dist/runtime-ets/dom/element/normal.ts +35 -8
  78. package/dist/runtime-ets/dom/element/progress.ts +11 -0
  79. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  80. package/dist/runtime-ets/dom/element/text.ts +1 -8
  81. package/dist/runtime-ets/dom/element/video.ts +5 -4
  82. package/dist/runtime-ets/dom/element/webView.ts +12 -5
  83. package/dist/runtime-ets/dom/event.ts +2 -4
  84. package/dist/runtime-ets/dom/eventTarget.ts +2 -3
  85. package/dist/runtime-ets/dom/node.ts +49 -28
  86. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +416 -235
  87. package/dist/runtime-ets/dom/stylesheet/index.ts +29 -311
  88. package/dist/runtime-ets/dom/stylesheet/type.ts +49 -9
  89. package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
  90. package/dist/runtime-ets/index.ts +2 -1
  91. package/dist/runtime-ets/interface/event.ts +1 -1
  92. package/dist/runtime-ets/utils/index.ts +69 -13
  93. package/dist/runtime-ets/utils/info.ts +2 -2
  94. package/dist/runtime-framework/react/app.ts +7 -2
  95. package/dist/runtime-framework/react/hooks.ts +0 -1
  96. package/dist/runtime-framework/react/index.ts +0 -2
  97. package/dist/runtime-framework/react/native-page.ts +32 -14
  98. package/dist/runtime-framework/react/page.ts +3 -8
  99. package/dist/runtime-framework/solid/app.ts +25 -45
  100. package/dist/runtime-framework/solid/connect.ts +21 -3
  101. package/dist/runtime-framework/solid/hooks.ts +16 -11
  102. package/dist/runtime-framework/solid/index.ts +6 -2
  103. package/dist/runtime-framework/solid/page.ts +84 -30
  104. package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
  105. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  106. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  107. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  108. package/dist/runtime-utils.d.ts +827 -0
  109. package/dist/runtime-utils.js +425 -200
  110. package/dist/runtime-utils.js.map +1 -1
  111. package/dist/runtime.d.ts +1 -0
  112. package/dist/runtime.js +425 -200
  113. package/dist/runtime.js.map +1 -1
  114. package/index.js +3 -1
  115. package/package.json +13 -13
  116. package/static/media/cancel.svg +1 -1
  117. package/static/media/circle.svg +1 -1
  118. package/static/media/clear.svg +1 -1
  119. package/static/media/download.svg +1 -1
  120. package/static/media/info.svg +1 -1
  121. package/static/media/info_circle.svg +1 -1
  122. package/static/media/search.svg +1 -1
  123. package/static/media/success.svg +1 -1
  124. package/static/media/success_no_circle.svg +1 -1
  125. package/static/media/warn.svg +1 -1
  126. package/types/harmony.d.ts +4 -0
  127. package/types/index.d.ts +4 -0
  128. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -0,0 +1,51 @@
1
+ import type { TaroAny, TaroCanvasElement } from '@tarojs/runtime'
2
+ import { cancelAnimationFrame, requestAnimationFrame } from '@tarojs/runtime'
3
+ import commonStyleModify from './style'
4
+
5
+ @Component
6
+ export default struct TaroCanvas {
7
+ @ObjectLink node: TaroCanvasElement
8
+ rafId: number = 0
9
+ @State overwriteStyle: Record<string, TaroAny> = {}
10
+
11
+ aboutToAppear(): void {
12
+ if (this.node) {
13
+ this.node._instance = this
14
+ }
15
+ }
16
+
17
+ aboutToDisappear() {
18
+ if(this.rafId) {
19
+ cancelAnimationFrame(this.rafId)
20
+ }
21
+ }
22
+
23
+ build() {
24
+ Canvas(this.node._context)
25
+ .attributeModifier(commonStyleModify.setNode(this.node as TaroAny, {
26
+ width: '100%',
27
+ height: '100%',
28
+ backgroundColor: '#ffff00'
29
+ }).setAnimationStyle(this.overwriteStyle))
30
+ .onReady(() => {
31
+ const context = this.node._context
32
+
33
+ const draw = () => {
34
+ if (this.node._drawList.length) {
35
+ while (this.node._drawList.length) {
36
+ const item = this.node._drawList.shift()
37
+ if (item) {
38
+ if (typeof context[item.key] === 'function') {
39
+ context[item.key](...[].concat(item.value))
40
+ } else {
41
+ context[item.key] = item.value
42
+ }
43
+ }
44
+ }
45
+ }
46
+ this.rafId = requestAnimationFrame(draw)
47
+ }
48
+ draw()
49
+ })
50
+ }
51
+ }
@@ -1,11 +1,11 @@
1
1
  import { createTaroEvent, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
- import commonStyleModify from './style'
4
- import { createLazyChildren } from './render'
5
- import { FlexManager } from './utils/FlexManager'
3
+ import commonStyleModify, { rowModify, columnModify } from './style'
4
+ import { FlexManager } from './utils/flexManager'
6
5
  import { shouldBindEvent, getNodeThresholds } from './utils/helper'
7
6
 
8
7
  import type { TaroAny, TaroEvent, TaroCheckboxElement, TaroCheckboxGroupElement } from '@tarojs/runtime'
8
+ import { isUndefined } from '@tarojs/shared'
9
9
 
10
10
  interface CheckboxOptions {
11
11
  name?: string
@@ -33,59 +33,62 @@ function getOptions (node: TaroCheckboxElement): CheckboxOptions {
33
33
  }
34
34
  }
35
35
 
36
+
36
37
  @Component
37
38
  export struct TaroCheckbox {
38
- node: TaroCheckboxElement | null = null
39
+ @Builder customBuilder() {}
40
+ @BuilderParam createLazyChildren: (node: TaroCheckboxElement) => void = this.customBuilder
41
+ @ObjectLink node: TaroCheckboxElement
42
+ @State overwriteStyle: Record<string, TaroAny> = {}
39
43
 
40
44
  aboutToAppear () {
41
45
  if (this.node && !this.node._isInit) {
42
46
  this.node._isInit = true
47
+ this.node._instance = this
43
48
  this.node._reset = this.node.checked || false
44
49
  }
45
50
  }
46
51
 
47
52
  build () {
48
- if (this.node) {
49
- Stack() {
50
- Row() {
51
- Checkbox(getOptions(this.node))
52
- .attributeModifier(commonStyleModify.setNode(this.node))
53
- .checkboxAttr(getAttributes(this.node))
54
- .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
55
- .select(this.node.checked)
56
- .onChange((value: boolean) => {
57
- if (this.node) {
58
- if (!!this.node?._attrs.disabled) {
59
- this.node.updateComponent()
60
- } else {
61
- this.node.updateCheckedValue(value)
62
-
63
- if (value) {
64
- const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
65
- eventHandler(event, 'change', this.node)
66
- }
53
+ Stack() {
54
+ Row() {
55
+ Checkbox(getOptions(this.node))
56
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
57
+ .checkboxAttr(getAttributes(this.node))
58
+ .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
59
+ .select(this.node.checked)
60
+ .onChange((value: boolean) => {
61
+ if (this.node) {
62
+ if (!!this.node?._attrs.disabled) {
63
+ this.node.updateComponent()
64
+ } else {
65
+ this.node.updateCheckedValue(value)
66
+
67
+ if (value) {
68
+ const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
69
+ eventHandler(event, 'change', this.node)
67
70
  }
68
71
  }
69
- })
70
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
71
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
72
- if (this.node) {
73
- this.node._nodeInfo.areaInfo = res[1]
74
- }
75
- }))
76
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
77
- Text(this.node.textContent)
78
- .textAlign(TextAlign.Center)
79
- .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
80
- }
81
- .onClick(() => {
82
- if (this.node) {
83
- if (!this.node?._attrs.disabled) {
84
- this.node.checked = !this.node.checked
85
72
  }
86
- }
87
- })
73
+ })
74
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
75
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
76
+ if (this.node) {
77
+ this.node._nodeInfo.areaInfo = res[1]
78
+ }
79
+ }))
80
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
81
+ Text(this.node.textContent)
82
+ .textAlign(TextAlign.Center)
83
+ .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
88
84
  }
85
+ .onClick(() => {
86
+ if (this.node) {
87
+ if (!this.node?._attrs.disabled) {
88
+ this.node.checked = !this.node.checked
89
+ }
90
+ }
91
+ })
89
92
  }
90
93
  }
91
94
  }
@@ -94,7 +97,10 @@ interface ChangeEventDetail { value: string[] }
94
97
 
95
98
  @Component
96
99
  export struct TaroCheckboxGroup {
97
- node: TaroCheckboxGroupElement | null = null
100
+ @Builder customBuilder() {}
101
+ @BuilderParam createLazyChildren: (node: TaroCheckboxGroupElement) => void = this.customBuilder
102
+ @ObjectLink node: TaroCheckboxGroupElement
103
+ @State overwriteStyle: Record<string, TaroAny> = {}
98
104
 
99
105
  @Styles visibleChangeEvent () {
100
106
  .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
@@ -102,6 +108,7 @@ export struct TaroCheckboxGroup {
102
108
 
103
109
  aboutToAppear () {
104
110
  if (this.node) {
111
+ this.node._instance = this
105
112
  // 阻止事件冒泡传递上去
106
113
  this.node.addEventListener('change', (e: TaroEvent<ChangeEventDetail>) => {
107
114
  e.stopPropagation()
@@ -120,26 +127,27 @@ export struct TaroCheckboxGroup {
120
127
  }
121
128
 
122
129
  build() {
123
- if (this.node) {
124
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
125
- Row() {
126
- createLazyChildren(this.node)
127
- }
128
- .attributeModifier(commonStyleModify.setNode(this.node))
129
- .defaultEvent()
130
- .visibleChangeEvent()
131
- .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
132
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
133
- } else {
134
- Column() {
135
- createLazyChildren(this.node)
136
- }
137
- .attributeModifier(commonStyleModify.setNode(this.node))
138
- .defaultEvent()
139
- .visibleChangeEvent()
140
- .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
141
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
130
+ if (FlexManager.useFlexLayout(this.node)) {
131
+ Flex(FlexManager.flexOptions(this.node)) {
132
+ this.createLazyChildren(this.node)
133
+ }
134
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
135
+ .defaultEvent()
136
+ .visibleChangeEvent()
137
+ } else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
138
+ Row() {
139
+ this.createLazyChildren(this.node)
140
+ }
141
+ .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
142
+ .defaultEvent()
143
+ .visibleChangeEvent()
144
+ } else {
145
+ Column() {
146
+ this.createLazyChildren(this.node)
142
147
  }
148
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
149
+ .defaultEvent()
150
+ .visibleChangeEvent()
143
151
  }
144
152
  }
145
153
  }
@@ -1,40 +1,62 @@
1
1
  import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
- import commonStyleModify from './style'
4
- import { createLazyChildren } from './render'
3
+ import commonStyleModify, { rowModify, columnModify } from './style'
4
+
5
5
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
6
- import { FlexManager } from './utils/FlexManager'
6
+ import { FlexManager } from './utils/flexManager'
7
7
  import { shouldBindEvent, getNodeThresholds } from './utils/helper'
8
8
 
9
9
  import type { TaroAny, TaroFormElement } from '@tarojs/runtime'
10
+ import { isUndefined } from '@tarojs/shared'
11
+
12
+ @Component
13
+ export default struct TaroForm {
14
+ @Builder customBuilder() {}
15
+ @BuilderParam createLazyChildren: (node: TaroFormElement) => void = this.customBuilder
16
+ @ObjectLink node: TaroFormElement
17
+
18
+ @State overwriteStyle: Record<string, TaroAny> = {}
10
19
 
11
- @Builder
12
- export default function TaroForm (node: TaroFormElement) {
13
- if (FlexManager.isFlexNode(node) && FlexManager.flexOptions(node).direction !== FlexDirection.Column) {
14
- Row() {
15
- createLazyChildren(node)
20
+ aboutToAppear(): void {
21
+ if (this.node) {
22
+ this.node._instance = this
16
23
  }
17
- .attributeModifier(commonStyleModify.setNode(node))
18
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
19
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
20
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
21
- node._nodeInfo.areaInfo = res[1]
22
- }))
23
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
24
- .alignItems(FlexManager.flexOptions(node).alignItems as VerticalAlign)
25
- .justifyContent(FlexManager.flexOptions(node).justifyContent)
26
- } else {
27
- Column() {
28
- createLazyChildren(node)
24
+ }
25
+
26
+ build() {
27
+ if (FlexManager.useFlexLayout(this.node)) {
28
+ Flex(FlexManager.flexOptions(this.node)) {
29
+ this.createLazyChildren(this.node)
30
+ }
31
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
32
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
33
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
34
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
35
+ this.node._nodeInfo.areaInfo = res[1]
36
+ }))
37
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
38
+ } else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
39
+ Row() {
40
+ this.createLazyChildren(this.node)
41
+ }
42
+ .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
43
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
44
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
45
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
46
+ this.node._nodeInfo.areaInfo = res[1]
47
+ }))
48
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
49
+ } else {
50
+ Column() {
51
+ this.createLazyChildren(this.node)
52
+ }
53
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
54
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
55
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
56
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
57
+ this.node._nodeInfo.areaInfo = res[1]
58
+ }))
59
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
29
60
  }
30
- .attributeModifier(commonStyleModify.setNode(node))
31
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
32
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
33
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
34
- node._nodeInfo.areaInfo = res[1]
35
- }))
36
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
37
- .alignItems(FlexManager.flexOptions(node).alignItems as HorizontalAlign)
38
- .justifyContent(FlexManager.flexOptions(node).justifyContent)
39
61
  }
40
62
  }
@@ -1,7 +1,7 @@
1
1
  import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, convertNumber2PX } from '@tarojs/runtime'
2
2
 
3
3
  import commonStyleModify from './style'
4
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
4
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
5
5
 
6
6
  import type { TaroIconElement, TaroAny } from '@tarojs/runtime'
7
7
 
@@ -48,22 +48,34 @@ function getIconData (node: TaroIconElement): Resource | null {
48
48
  }
49
49
  }
50
50
 
51
- @Builder
52
- export default function TaroIcon (node: TaroIconElement) {
53
- Image(getIconData(node))
54
- .objectFit(ImageFit.Contain)
55
- .fillColor(node._attrs.color || ICON_COLOR_MAP[node._attrs.type] || Color.Black)
56
- .attributeModifier(commonStyleModify.setNode(node))
57
- .size({
58
- width: convertNumber2VP(Number(node._attrs.size) || 23),
59
- height: convertNumber2VP(Number(node._attrs.size) || 23),
60
- })
61
- .width(getNormalAttributes(node).width || convertNumber2PX(23))
62
- .height(getNormalAttributes(node).height || convertNumber2PX(23))
63
- .onComplete(e => eventHandler(e, 'complete', node))
64
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
65
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
66
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
67
- node._nodeInfo.areaInfo = res[1]
68
- }))
51
+ @Component
52
+ export default struct TaroIcon {
53
+ @Builder customBuilder() {}
54
+ @BuilderParam createLazyChildren: (node: TaroIconElement) => void = this.customBuilder
55
+ @ObjectLink node: TaroIconElement
56
+ @State overwriteStyle: Record<string, TaroAny> = {}
57
+
58
+ aboutToAppear(): void {
59
+ if (this.node) {
60
+ this.node._instance = this
61
+ }
62
+ }
63
+
64
+ build() {
65
+ Image(getIconData(this.node))
66
+ .objectFit(ImageFit.Contain)
67
+ .fillColor(this.node._attrs.color || ICON_COLOR_MAP[this.node._attrs.type] || Color.Black)
68
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
69
+ .size({
70
+ width: Number(this.node._attrs.size) || 23,
71
+ height: Number(this.node._attrs.size) || 23
72
+ })
73
+ .onComplete(e => eventHandler(e, 'complete', this.node))
74
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
75
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
76
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
77
+ this.node._nodeInfo.areaInfo = res[1]
78
+ }))
79
+ }
69
80
  }
81
+
@@ -1,11 +1,11 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
3
  import commonStyleModify from './style'
4
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
4
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
5
5
 
6
- import type { TaroImageElement, TaroAny, TaroStyleType } from '@tarojs/runtime'
6
+ import type { TaroImageElement, TaroAny } from '@tarojs/runtime'
7
7
 
8
- function getImageMode (mode: string): ImageFit {
8
+ export function getImageMode (mode: string): ImageFit {
9
9
  switch (mode) {
10
10
  case 'aspectFit': return ImageFit.Contain
11
11
  case 'aspectFill': return ImageFit.Cover
@@ -16,15 +16,35 @@ function getImageMode (mode: string): ImageFit {
16
16
  }
17
17
  }
18
18
 
19
- @Builder
20
- export default function TaroImage (node: TaroImageElement) {
21
- Image(node.getAttribute('src'))
22
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
23
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
24
- node._nodeInfo.areaInfo = res[1]
25
- }))
26
- .objectFit(getImageMode(node.getAttribute('mode')))
27
- .attributeModifier(commonStyleModify.setNode(node))
28
- .onComplete(e => eventHandler(e, 'complete', node))
29
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
19
+ @Component
20
+ export default struct TaroImage {
21
+ @Builder customBuilder() {}
22
+ @BuilderParam createLazyChildren: (node: TaroImageElement) => void = this.customBuilder
23
+ @ObjectLink node: TaroImageElement
24
+ @State overwriteStyle: Record<string, TaroAny> = {}
25
+
26
+ aboutToAppear(): void {
27
+ if (this.node) {
28
+ this.node._instance = this
29
+ }
30
+ }
31
+
32
+ build() {
33
+ Image(this.node.getAttribute('src'))
34
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
35
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
36
+ this.node._nodeInfo.areaInfo = res[1]
37
+ }))
38
+ .objectFit(getImageMode(this.node.getAttribute('mode')))
39
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
40
+ .onComplete(e => eventHandler(e, 'complete', this.node))
41
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
42
+ // TODO: 临时改为申明式,后续等鸿蒙修复modify设置失败的bug后删除该申明
43
+ .borderRadius({
44
+ topLeft: this.node._st.hmStyle.borderTopLeftRadius,
45
+ topRight: this.node._st.hmStyle.borderTopRightRadius,
46
+ bottomLeft: this.node._st.hmStyle.borderBottomLeftRadius,
47
+ bottomRight: this.node._st.hmStyle.borderBottomRightRadius
48
+ })
49
+ }
30
50
  }
@@ -0,0 +1,92 @@
1
+ import TaroImage, { getImageMode } from './image'
2
+ import TaroText from './text'
3
+ import TaroView from './view'
4
+ import TaroIcon from './icon'
5
+ import TaroForm from './form'
6
+ import TaroLabel from './label'
7
+ import TaroInput from './input'
8
+ import TaroVideo from './video'
9
+ import TaroCanvas from './canvas'
10
+ import TaroButton from './button'
11
+ import TaroPicker from './picker'
12
+ import TaroSlider from './slider'
13
+ import TaroSwitch from './switch'
14
+ import TaroSwiper from './swiper'
15
+ import TaroWebView from './webView'
16
+ import TaroTextArea from './textArea'
17
+ import TaroRichText from './richText'
18
+ import TaroProgress from './progress'
19
+ import TaroInnerHtml from './innerHtml'
20
+ import TaroScrollView from './scrollView'
21
+ import TaroMovableArea from './movableArea'
22
+ import TaroMovableView from './movableView'
23
+ import { TaroRadio, TaroRadioGroup } from './radio'
24
+ import { TaroCheckboxGroup, TaroCheckbox } from './checkbox'
25
+ import TaroPageMeta from './pageMeta'
26
+ import TaroNavigationBar from './navigationBar'
27
+
28
+ import TaroListView from './listView'
29
+ import TaroStickySection from './stickySection'
30
+ import TaroScrollList from './scrollList'
31
+
32
+ import commonStyleModify, { rowModify, columnModify, textModify, setNormalTextAttributeIntoInstance } from './style'
33
+ import { getButtonColor } from './button'
34
+ import { FlexManager } from './utils/flexManager'
35
+ import { DynamicCenter } from './utils/DynamicCenter'
36
+ import { TOUCH_EVENT_MAP } from './utils/constant/event'
37
+ import { BUTTON_THEME_COLOR } from './utils/constant/style'
38
+ import { getStyleAttr } from './utils/styles'
39
+ import { shouldBindEvent, getNodeThresholds, getNormalAttributes, getFontAttributes } from './utils/helper'
40
+
41
+ export {
42
+ textModify,
43
+ getStyleAttr,
44
+ FlexManager,
45
+ DynamicCenter,
46
+ getButtonColor,
47
+ TOUCH_EVENT_MAP,
48
+ shouldBindEvent,
49
+ getFontAttributes,
50
+ commonStyleModify,
51
+ rowModify,
52
+ columnModify,
53
+ getNodeThresholds,
54
+ BUTTON_THEME_COLOR,
55
+ getNormalAttributes,
56
+ setNormalTextAttributeIntoInstance,
57
+ getImageMode,
58
+ }
59
+
60
+ export {
61
+ TaroImage,
62
+ TaroCanvas,
63
+ TaroText,
64
+ TaroView,
65
+ TaroIcon,
66
+ TaroForm,
67
+ TaroLabel,
68
+ TaroInput,
69
+ TaroVideo,
70
+ TaroButton,
71
+ TaroPicker,
72
+ TaroSlider,
73
+ TaroSwitch,
74
+ TaroSwiper,
75
+ TaroWebView,
76
+ TaroTextArea,
77
+ TaroRichText,
78
+ TaroProgress,
79
+ TaroInnerHtml,
80
+ TaroScrollView,
81
+ TaroMovableArea,
82
+ TaroMovableView,
83
+ TaroRadio,
84
+ TaroRadioGroup,
85
+ TaroCheckboxGroup,
86
+ TaroCheckbox,
87
+ TaroPageMeta,
88
+ TaroNavigationBar,
89
+ TaroListView,
90
+ TaroStickySection,
91
+ TaroScrollList
92
+ }
@@ -1,11 +1,16 @@
1
1
  import htmlParser from './utils/htmlParser'
2
- import { createChildItem } from './render'
3
2
 
4
- import type { TaroElement } from '@tarojs/runtime'
3
+ import type { TaroElement, TaroInnerHtmlElement } from '@tarojs/runtime'
5
4
 
6
- @Builder
7
- export default function TaroInnerHtml (node: TaroElement) {
8
- if (node.innerHTML) {
9
- createChildItem(htmlParser(node.innerHTML))
5
+ @Component
6
+ export default struct TaroInnerHtml {
7
+ @Builder customBuilder() {}
8
+ @BuilderParam createChildItem: (node: TaroElement, callback?: (node: TaroElement) => void) => void = this.customBuilder
9
+ @ObjectLink node: TaroInnerHtmlElement
10
+
11
+ build() {
12
+ if (this.node?.hmStyle?.display !== 'none' && this.node.innerHTML) {
13
+ this.createChildItem(htmlParser(this.node.innerHTML))
14
+ }
10
15
  }
11
16
  }