@tarojs/plugin-platform-harmony-ets 4.0.0-alpha.3 → 4.0.0-alpha.31

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 (131) 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 +207 -44
  7. package/dist/apis/storage/index.ts +146 -78
  8. package/dist/apis/ui/animation/animation.ts +71 -29
  9. package/dist/apis/ui/background.ts +2 -1
  10. package/dist/apis/ui/interaction/index.ts +42 -59
  11. package/dist/apis/ui/navigation-bar/index.ts +1 -1
  12. package/dist/apis/ui/pull-down-refresh.ts +9 -3
  13. package/dist/apis/ui/scroll/index.ts +5 -5
  14. package/dist/apis/ui/tab-bar.ts +3 -3
  15. package/dist/apis/utils/index.ts +20 -2
  16. package/dist/apis/utils/permissions.ts +6 -0
  17. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  18. package/dist/apis/wxml/selectorQuery.ts +26 -13
  19. package/dist/components-harmony-ets/button.ets +64 -34
  20. package/dist/components-harmony-ets/canvas.ets +51 -0
  21. package/dist/components-harmony-ets/checkbox.ets +73 -62
  22. package/dist/components-harmony-ets/form.ets +51 -29
  23. package/dist/components-harmony-ets/icon.ets +31 -19
  24. package/dist/components-harmony-ets/image.ets +34 -14
  25. package/dist/components-harmony-ets/index.ets +92 -0
  26. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  27. package/dist/components-harmony-ets/input.ets +63 -41
  28. package/dist/components-harmony-ets/label.ets +71 -44
  29. package/dist/components-harmony-ets/listView.ets +31 -0
  30. package/dist/components-harmony-ets/movableArea.ets +126 -0
  31. package/dist/components-harmony-ets/movableView.ets +93 -0
  32. package/dist/components-harmony-ets/navigationBar.ets +65 -0
  33. package/dist/components-harmony-ets/pageMeta.ets +94 -0
  34. package/dist/components-harmony-ets/picker.ets +43 -39
  35. package/dist/components-harmony-ets/progress.ets +52 -0
  36. package/dist/components-harmony-ets/pseudo.ets +80 -0
  37. package/dist/components-harmony-ets/radio.ets +78 -68
  38. package/dist/components-harmony-ets/richText.ets +14 -30
  39. package/dist/components-harmony-ets/scrollList.ets +103 -0
  40. package/dist/components-harmony-ets/scrollView.ets +61 -57
  41. package/dist/components-harmony-ets/slider.ets +19 -15
  42. package/dist/components-harmony-ets/stickySection.ets +42 -0
  43. package/dist/components-harmony-ets/style.ets +386 -130
  44. package/dist/components-harmony-ets/swiper.ets +61 -20
  45. package/dist/components-harmony-ets/switch.ets +36 -32
  46. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  47. package/dist/components-harmony-ets/text.ets +112 -50
  48. package/dist/components-harmony-ets/textArea.ets +50 -35
  49. package/dist/components-harmony-ets/utils/AttributeManager.ets +2 -2
  50. package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -2
  51. package/dist/components-harmony-ets/utils/flexManager.ets +49 -19
  52. package/dist/components-harmony-ets/utils/helper.ets +20 -8
  53. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  54. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  55. package/dist/components-harmony-ets/utils/index.ts +54 -50
  56. package/dist/components-harmony-ets/utils/styles.ets +172 -93
  57. package/dist/components-harmony-ets/video.ets +34 -21
  58. package/dist/components-harmony-ets/view.ets +63 -52
  59. package/dist/components-harmony-ets/webView.ets +40 -34
  60. package/dist/index.d.ts +152 -0
  61. package/dist/index.js +102 -56
  62. package/dist/index.js.map +1 -1
  63. package/dist/runtime-ets/bom/document.ts +6 -4
  64. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  65. package/dist/runtime-ets/bom/window.ts +7 -0
  66. package/dist/runtime-ets/current.ts +5 -1
  67. package/dist/runtime-ets/dom/bind.ts +28 -12
  68. package/dist/runtime-ets/dom/class-list.ts +2 -2
  69. package/dist/runtime-ets/dom/cssNesting.ts +419 -0
  70. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +28 -42
  71. package/dist/runtime-ets/dom/document.ts +8 -11
  72. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  73. package/dist/runtime-ets/dom/element/element.ts +376 -57
  74. package/dist/runtime-ets/dom/element/form.ts +31 -26
  75. package/dist/runtime-ets/dom/element/index.ts +30 -2
  76. package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
  77. package/dist/runtime-ets/dom/element/movableView.ts +244 -0
  78. package/dist/runtime-ets/dom/element/normal.ts +35 -8
  79. package/dist/runtime-ets/dom/element/progress.ts +11 -0
  80. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  81. package/dist/runtime-ets/dom/element/text.ts +1 -8
  82. package/dist/runtime-ets/dom/element/video.ts +5 -4
  83. package/dist/runtime-ets/dom/element/webView.ts +12 -5
  84. package/dist/runtime-ets/dom/event.ts +3 -5
  85. package/dist/runtime-ets/dom/eventTarget.ts +2 -3
  86. package/dist/runtime-ets/dom/node.ts +65 -32
  87. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +418 -237
  88. package/dist/runtime-ets/dom/stylesheet/index.ts +29 -311
  89. package/dist/runtime-ets/dom/stylesheet/type.ts +53 -11
  90. package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
  91. package/dist/runtime-ets/index.ts +2 -1
  92. package/dist/runtime-ets/interface/event.ts +1 -1
  93. package/dist/runtime-ets/utils/index.ts +74 -13
  94. package/dist/runtime-ets/utils/info.ts +2 -2
  95. package/dist/runtime-framework/react/app.ts +15 -10
  96. package/dist/runtime-framework/react/hooks.ts +0 -1
  97. package/dist/runtime-framework/react/index.ts +0 -2
  98. package/dist/runtime-framework/react/native-page.ts +185 -78
  99. package/dist/runtime-framework/react/page.ts +4 -9
  100. package/dist/runtime-framework/react/utils/index.ts +3 -3
  101. package/dist/runtime-framework/solid/app.ts +30 -46
  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 +85 -31
  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 +3 -5
  110. package/dist/runtime-utils.d.ts +827 -0
  111. package/dist/runtime-utils.js +652 -283
  112. package/dist/runtime-utils.js.map +1 -1
  113. package/dist/runtime.d.ts +1 -0
  114. package/dist/runtime.js +652 -283
  115. package/dist/runtime.js.map +1 -1
  116. package/index.js +3 -1
  117. package/package.json +14 -15
  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 +5 -0
  129. package/types/index.d.ts +4 -0
  130. package/types/runtime.d.ts +1 -1
  131. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -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
@@ -13,17 +13,20 @@ interface CheckboxOptions {
13
13
  }
14
14
  interface CheckboxAttrs {
15
15
  selectedColor?: ResourceColor
16
+ disabled?: boolean
16
17
  }
17
18
 
18
19
  @Extend(Checkbox)
19
20
  function checkboxAttr(attr: CheckboxAttrs) {
20
21
  .selectedColor(attr.selectedColor)
22
+ .enabled(!attr.disabled)
21
23
  }
22
24
 
23
25
  function getAttributes (node: TaroCheckboxElement): CheckboxAttrs {
24
26
  const _attrs = node._attrs
25
27
  const checkboxAttrs: CheckboxAttrs = {}
26
28
  checkboxAttrs.selectedColor = _attrs.color || '#1aad19'
29
+ checkboxAttrs.disabled = !!_attrs.disabled
27
30
  return checkboxAttrs
28
31
  }
29
32
 
@@ -33,59 +36,62 @@ function getOptions (node: TaroCheckboxElement): CheckboxOptions {
33
36
  }
34
37
  }
35
38
 
39
+
36
40
  @Component
37
41
  export struct TaroCheckbox {
38
- node: TaroCheckboxElement | null = null
42
+ @Builder customBuilder() {}
43
+ @BuilderParam createLazyChildren: (node: TaroCheckboxElement, layer?: number) => void = this.customBuilder
44
+ @ObjectLink node: TaroCheckboxElement
45
+ @State overwriteStyle: Record<string, TaroAny> = {}
39
46
 
40
47
  aboutToAppear () {
41
48
  if (this.node && !this.node._isInit) {
42
49
  this.node._isInit = true
50
+ this.node._instance = this
43
51
  this.node._reset = this.node.checked || false
44
52
  }
45
53
  }
46
54
 
47
55
  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
- }
56
+ Stack() {
57
+ Row() {
58
+ Checkbox(getOptions(this.node))
59
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
60
+ .checkboxAttr(getAttributes(this.node))
61
+ .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
62
+ .select(this.node.checked)
63
+ .onChange((value: boolean) => {
64
+ if (this.node) {
65
+ if (!!this.node?._attrs.disabled) {
66
+ this.node.updateComponent()
67
+ } else {
68
+ this.node.updateCheckedValue(value)
69
+
70
+ if (value) {
71
+ const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
72
+ eventHandler(event, 'change', this.node)
67
73
  }
68
74
  }
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
75
  }
86
- }
87
- })
76
+ })
77
+ .onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
78
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
79
+ if (this.node) {
80
+ this.node._nodeInfo.areaInfo = res[1]
81
+ }
82
+ }))
83
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
84
+ Text(this.node.textContent)
85
+ .textAlign(TextAlign.Center)
86
+ .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
88
87
  }
88
+ .onClick(() => {
89
+ if (this.node) {
90
+ if (!this.node?._attrs.disabled) {
91
+ this.node.checked = !this.node.checked
92
+ }
93
+ }
94
+ })
89
95
  }
90
96
  }
91
97
  }
@@ -94,7 +100,10 @@ interface ChangeEventDetail { value: string[] }
94
100
 
95
101
  @Component
96
102
  export struct TaroCheckboxGroup {
97
- node: TaroCheckboxGroupElement | null = null
103
+ @Builder customBuilder() {}
104
+ @BuilderParam createLazyChildren: (node: TaroCheckboxGroupElement, layer?: number) => void = this.customBuilder
105
+ @ObjectLink node: TaroCheckboxGroupElement
106
+ @State overwriteStyle: Record<string, TaroAny> = {}
98
107
 
99
108
  @Styles visibleChangeEvent () {
100
109
  .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
@@ -102,6 +111,7 @@ export struct TaroCheckboxGroup {
102
111
 
103
112
  aboutToAppear () {
104
113
  if (this.node) {
114
+ this.node._instance = this
105
115
  // 阻止事件冒泡传递上去
106
116
  this.node.addEventListener('change', (e: TaroEvent<ChangeEventDetail>) => {
107
117
  e.stopPropagation()
@@ -111,7 +121,7 @@ export struct TaroCheckboxGroup {
111
121
  }
112
122
 
113
123
  @Styles defaultEvent () {
114
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
124
+ .onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
115
125
  .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
116
126
  if (this.node) {
117
127
  this.node._nodeInfo.areaInfo = res[1]
@@ -120,26 +130,27 @@ export struct TaroCheckboxGroup {
120
130
  }
121
131
 
122
132
  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)
133
+ if (FlexManager.useFlexLayout(this.node)) {
134
+ Flex(FlexManager.flexOptions(this.node)) {
135
+ this.createLazyChildren(this.node, 0)
136
+ }
137
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
138
+ .defaultEvent()
139
+ .visibleChangeEvent()
140
+ } else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
141
+ Row() {
142
+ this.createLazyChildren(this.node, 0)
143
+ }
144
+ .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
145
+ .defaultEvent()
146
+ .visibleChangeEvent()
147
+ } else {
148
+ Column() {
149
+ this.createLazyChildren(this.node, 0)
142
150
  }
151
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
152
+ .defaultEvent()
153
+ .visibleChangeEvent()
143
154
  }
144
155
  }
145
156
  }
@@ -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, layer?: number) => 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, 0)
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, 0)
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, 0)
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, layer?: number) => 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, layer?: number) => 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
  }