@tarojs/plugin-platform-harmony-ets 4.0.0-alpha.0 → 4.0.0-alpha.10

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 (139) 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/device/memory.ts +10 -3
  5. package/dist/apis/framework/index.ts +1 -5
  6. package/dist/apis/index.ts +27 -17
  7. package/dist/apis/media/image/index.ts +1 -1
  8. package/dist/apis/media/video/VideoContext.ts +56 -7
  9. package/dist/apis/media/video/index.ts +3 -2
  10. package/dist/apis/network/request.ts +5 -5
  11. package/dist/apis/route/index.ts +15 -0
  12. package/dist/apis/storage/index.ts +146 -78
  13. package/dist/apis/ui/animation/animation.ts +71 -29
  14. package/dist/apis/ui/background.ts +2 -1
  15. package/dist/apis/ui/interaction/index.ts +42 -59
  16. package/dist/apis/ui/navigation-bar/index.ts +1 -1
  17. package/dist/apis/ui/pull-down-refresh.ts +9 -3
  18. package/dist/apis/ui/scroll/index.ts +5 -5
  19. package/dist/apis/ui/tab-bar.ts +3 -3
  20. package/dist/apis/utils/index.ts +1 -1
  21. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  22. package/dist/apis/wxml/index.ts +2 -0
  23. package/dist/apis/wxml/selectorQuery.ts +26 -13
  24. package/dist/components-harmony-ets/button.ets +68 -68
  25. package/dist/components-harmony-ets/canvas.ets +51 -0
  26. package/dist/components-harmony-ets/checkbox.ets +81 -102
  27. package/dist/components-harmony-ets/form.ets +54 -45
  28. package/dist/components-harmony-ets/icon.ets +34 -50
  29. package/dist/components-harmony-ets/image.ets +35 -45
  30. package/dist/components-harmony-ets/index.ets +92 -0
  31. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  32. package/dist/components-harmony-ets/input.ets +51 -67
  33. package/dist/components-harmony-ets/label.ets +73 -53
  34. package/dist/components-harmony-ets/listView.ets +26 -0
  35. package/dist/components-harmony-ets/movableArea.ets +124 -0
  36. package/dist/components-harmony-ets/movableView.ets +93 -0
  37. package/dist/components-harmony-ets/navigationBar.ets +65 -0
  38. package/dist/components-harmony-ets/pageMeta.ets +94 -0
  39. package/dist/components-harmony-ets/picker.ets +74 -77
  40. package/dist/components-harmony-ets/progress.ets +52 -0
  41. package/dist/components-harmony-ets/pseudo.ets +80 -0
  42. package/dist/components-harmony-ets/radio.ets +82 -104
  43. package/dist/components-harmony-ets/richText.ets +20 -68
  44. package/dist/components-harmony-ets/scrollList.ets +94 -0
  45. package/dist/components-harmony-ets/scrollView.ets +67 -103
  46. package/dist/components-harmony-ets/slider.ets +23 -47
  47. package/dist/components-harmony-ets/stickySection.ets +42 -0
  48. package/dist/components-harmony-ets/style.ets +396 -0
  49. package/dist/components-harmony-ets/swiper.ets +64 -53
  50. package/dist/components-harmony-ets/switch.ets +44 -55
  51. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  52. package/dist/components-harmony-ets/text.ets +134 -75
  53. package/dist/components-harmony-ets/textArea.ets +54 -62
  54. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  55. package/dist/components-harmony-ets/utils/DynamicCenter.ts +4 -13
  56. package/dist/components-harmony-ets/utils/flexManager.ets +76 -8
  57. package/dist/components-harmony-ets/utils/helper.ets +20 -7
  58. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  59. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  60. package/dist/components-harmony-ets/utils/index.ts +54 -50
  61. package/dist/components-harmony-ets/utils/styles.ets +178 -63
  62. package/dist/components-harmony-ets/video.ets +37 -54
  63. package/dist/components-harmony-ets/view.ets +63 -94
  64. package/dist/components-harmony-ets/webView.ets +56 -0
  65. package/dist/index.d.ts +152 -0
  66. package/dist/index.js +199 -58
  67. package/dist/index.js.map +1 -1
  68. package/dist/runtime-ets/bom/document.ts +6 -4
  69. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  70. package/dist/runtime-ets/bom/window.ts +9 -2
  71. package/dist/runtime-ets/current.ts +3 -0
  72. package/dist/runtime-ets/dom/bind.ts +28 -12
  73. package/dist/runtime-ets/dom/class-list.ts +2 -2
  74. package/dist/runtime-ets/dom/cssNesting.ts +409 -0
  75. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +29 -19
  76. package/dist/runtime-ets/dom/document.ts +22 -8
  77. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  78. package/dist/runtime-ets/dom/element/element.ts +334 -57
  79. package/dist/runtime-ets/dom/element/form.ts +32 -26
  80. package/dist/runtime-ets/dom/element/index.ts +33 -2
  81. package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
  82. package/dist/runtime-ets/dom/element/movableView.ts +242 -0
  83. package/dist/runtime-ets/dom/element/normal.ts +36 -8
  84. package/dist/runtime-ets/dom/element/progress.ts +11 -0
  85. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  86. package/dist/runtime-ets/dom/element/text.ts +1 -8
  87. package/dist/runtime-ets/dom/element/video.ts +5 -4
  88. package/dist/runtime-ets/dom/element/webView.ts +68 -0
  89. package/dist/runtime-ets/dom/event.ts +2 -4
  90. package/dist/runtime-ets/dom/eventTarget.ts +2 -3
  91. package/dist/runtime-ets/dom/node.ts +62 -27
  92. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +805 -0
  93. package/dist/runtime-ets/dom/stylesheet/index.ts +98 -518
  94. package/dist/runtime-ets/dom/stylesheet/type.ts +92 -17
  95. package/dist/runtime-ets/dom/stylesheet/util.ts +74 -16
  96. package/dist/runtime-ets/index.ts +2 -2
  97. package/dist/runtime-ets/interface/event.ts +3 -2
  98. package/dist/runtime-ets/utils/index.ts +77 -12
  99. package/dist/runtime-ets/utils/info.ts +4 -2
  100. package/dist/runtime-framework/react/app.ts +17 -22
  101. package/dist/runtime-framework/react/hooks.ts +3 -4
  102. package/dist/runtime-framework/react/index.ts +1 -2
  103. package/dist/runtime-framework/react/native-page.ts +421 -0
  104. package/dist/runtime-framework/react/page.ts +4 -9
  105. package/dist/runtime-framework/solid/app.ts +25 -45
  106. package/dist/runtime-framework/solid/connect.ts +21 -3
  107. package/dist/runtime-framework/solid/hooks.ts +17 -12
  108. package/dist/runtime-framework/solid/index.ts +6 -2
  109. package/dist/runtime-framework/solid/page.ts +84 -30
  110. package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
  111. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  112. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  113. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  114. package/dist/runtime-utils.d.ts +827 -0
  115. package/dist/runtime-utils.js +510 -237
  116. package/dist/runtime-utils.js.map +1 -1
  117. package/dist/runtime.d.ts +1 -0
  118. package/dist/runtime.js +510 -237
  119. package/dist/runtime.js.map +1 -1
  120. package/index.js +3 -1
  121. package/package.json +14 -15
  122. package/static/media/cancel.svg +1 -0
  123. package/static/media/circle.svg +1 -0
  124. package/static/media/clear.svg +1 -0
  125. package/static/media/download.svg +1 -0
  126. package/static/media/info.svg +1 -0
  127. package/static/media/info_circle.svg +1 -0
  128. package/static/media/search.svg +1 -0
  129. package/static/media/success.svg +1 -0
  130. package/static/media/success_no_circle.svg +1 -0
  131. package/static/media/taro_arrow_left.svg +1 -0
  132. package/static/media/taro_home.svg +1 -0
  133. package/static/media/waiting.svg +1 -0
  134. package/static/media/warn.svg +1 -0
  135. package/types/harmony.d.ts +4 -0
  136. package/types/index.d.ts +4 -0
  137. package/types/runtime.d.ts +3 -1
  138. package/dist/runtime-ets/utils/bind.ts +0 -24
  139. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -1,10 +1,11 @@
1
1
  import { createTaroEvent, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
- import { createLazyChildren } from './render'
4
- import { FlexManager } from './utils/FlexManager'
5
- import { shouldBindEvent, getNormalAttributes, getNodeThresholds } from './utils/helper'
3
+ import commonStyleModify, { rowModify, columnModify } from './style'
4
+ import { FlexManager } from './utils/flexManager'
5
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
6
6
 
7
- import type { TaroStyleType, TaroAny, TaroEvent, TaroCheckboxElement, TaroCheckboxGroupElement } from '@tarojs/runtime'
7
+ import type { TaroAny, TaroEvent, TaroCheckboxElement, TaroCheckboxGroupElement } from '@tarojs/runtime'
8
+ import { isUndefined } from '@tarojs/shared'
8
9
 
9
10
  interface CheckboxOptions {
10
11
  name?: string
@@ -14,37 +15,6 @@ interface CheckboxAttrs {
14
15
  selectedColor?: ResourceColor
15
16
  }
16
17
 
17
- @Extend(Checkbox)
18
- function checkboxStyle (style: TaroStyleType) {
19
- .id(style.id)
20
- .key(style.id)
21
- .padding(style.padding)
22
- .margin(style.margin)
23
- .width(style.width)
24
- .height(style.height)
25
- .constraintSize(style.constraintSize)
26
- .flexGrow(style.flexGrow)
27
- .flexShrink(style.flexShrink)
28
- .flexBasis(style.flexBasis)
29
- .alignSelf(style.alignSelf)
30
- .backgroundColor(style.backgroundColor)
31
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
32
- .backgroundImageSize(style.backgroundImageSize)
33
- .backgroundImagePosition(style.backgroundImagePosition)
34
- .rotate(style.rotate)
35
- .scale(style.scale)
36
- .translate(style.translate)
37
- .transform(style.transform)
38
- .borderStyle(style.borderStyle)
39
- .borderWidth(style.borderWidth)
40
- .borderColor(style.borderColor)
41
- .borderRadius(style.borderRadius)
42
- .linearGradient(style.linearGradient)
43
- .zIndex(style.zIndex)
44
- .opacity(style.opacity)
45
- .clip(style.clip)
46
- }
47
-
48
18
  @Extend(Checkbox)
49
19
  function checkboxAttr(attr: CheckboxAttrs) {
50
20
  .selectedColor(attr.selectedColor)
@@ -63,80 +33,74 @@ function getOptions (node: TaroCheckboxElement): CheckboxOptions {
63
33
  }
64
34
  }
65
35
 
66
- @Builder
67
- export function TaroCheckbox(node: TaroCheckboxElement) {
68
- Stack() {
69
- Row() {
70
- Checkbox(getOptions(node))
71
- .checkboxStyle(getNormalAttributes(node))
72
- .checkboxAttr(getAttributes(node))
73
- .opacity(!!node._attrs.disabled ? 0.4 : 1)
74
- .select(node.checked)
75
- .onChange((value: boolean) => {
76
- if (!!node?._attrs.disabled) {
77
- node.updateComponent()
78
- } else {
79
- node.updateCheckedValue(value)
80
-
81
- if (value) {
82
- const event: TaroEvent = createTaroEvent('change', { detail: { value: node?._attrs.value } }, node)
83
- eventHandler(event, 'change', node)
36
+
37
+ @Component
38
+ export struct TaroCheckbox {
39
+ @Builder customBuilder() {}
40
+ @BuilderParam createLazyChildren: (node: TaroCheckboxElement) => void = this.customBuilder
41
+ @ObjectLink node: TaroCheckboxElement
42
+ @State overwriteStyle: Record<string, TaroAny> = {}
43
+
44
+ aboutToAppear () {
45
+ if (this.node && !this.node._isInit) {
46
+ this.node._isInit = true
47
+ this.node._instance = this
48
+ this.node._reset = this.node.checked || false
49
+ }
50
+ }
51
+
52
+ build () {
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)
70
+ }
71
+ }
72
+ }
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]
84
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)
84
+ }
85
+ .onClick(() => {
86
+ if (this.node) {
87
+ if (!this.node?._attrs.disabled) {
88
+ this.node.checked = !this.node.checked
85
89
  }
86
- })
87
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
88
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
89
- node._nodeInfo.areaInfo = res[1]
90
- }))
91
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
92
- Text(node.textContent)
93
- .textAlign(TextAlign.Center)
94
- .opacity(!!node._attrs.disabled ? 0.4 : 1)
90
+ }
91
+ })
95
92
  }
96
- .onClick(() => {
97
- if (!node?._attrs.disabled) {
98
- node.checked = !node.checked
99
- }
100
- })
101
93
  }
102
94
  }
103
95
 
104
- @Extend(Flex)
105
- function checkboxGroupAttrs (style: TaroStyleType) {
106
- .id(style.id)
107
- .key(style.id)
108
- .padding(style.padding)
109
- .margin(style.margin)
110
- .width(style.width)
111
- .height(style.height)
112
- .constraintSize(style.constraintSize)
113
- .flexGrow(style.flexGrow)
114
- .flexShrink(style.flexShrink)
115
- .flexBasis(style.flexBasis)
116
- .alignSelf(style.alignSelf)
117
- .backgroundColor(style.backgroundColor)
118
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
119
- .backgroundImageSize(style.backgroundImageSize)
120
- .backgroundImagePosition(style.backgroundImagePosition)
121
- .rotate(style.rotate)
122
- .scale(style.scale)
123
- .translate(style.translate)
124
- .transform(style.transform)
125
- .borderStyle(style.borderStyle)
126
- .borderWidth(style.borderWidth)
127
- .borderColor(style.borderColor)
128
- .borderRadius(style.borderRadius)
129
- .linearGradient(style.linearGradient)
130
- .zIndex(style.zIndex)
131
- .opacity(style.opacity)
132
- .clip(style.clip)
133
- }
134
-
135
96
  interface ChangeEventDetail { value: string[] }
136
97
 
137
98
  @Component
138
99
  export struct TaroCheckboxGroup {
139
- 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> = {}
140
104
 
141
105
  @Styles visibleChangeEvent () {
142
106
  .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
@@ -144,6 +108,7 @@ export struct TaroCheckboxGroup {
144
108
 
145
109
  aboutToAppear () {
146
110
  if (this.node) {
111
+ this.node._instance = this
147
112
  // 阻止事件冒泡传递上去
148
113
  this.node.addEventListener('change', (e: TaroEvent<ChangeEventDetail>) => {
149
114
  e.stopPropagation()
@@ -162,11 +127,25 @@ export struct TaroCheckboxGroup {
162
127
  }
163
128
 
164
129
  build() {
165
- if (this.node) {
130
+ if (FlexManager.useFlexLayout(this.node)) {
166
131
  Flex(FlexManager.flexOptions(this.node)) {
167
- createLazyChildren(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)
168
147
  }
169
- .checkboxGroupAttrs(getNormalAttributes(this.node))
148
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
170
149
  .defaultEvent()
171
150
  .visibleChangeEvent()
172
151
  }
@@ -1,53 +1,62 @@
1
1
  import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
- import { createLazyChildren } from './render'
3
+ import commonStyleModify, { rowModify, columnModify } from './style'
4
+
4
5
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
5
- import { FlexManager } from './utils/FlexManager'
6
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
6
+ import { FlexManager } from './utils/flexManager'
7
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
7
8
 
8
- import type { TaroAny, TaroFormElement, TaroStyleType } from '@tarojs/runtime'
9
+ import type { TaroAny, TaroFormElement } from '@tarojs/runtime'
10
+ import { isUndefined } from '@tarojs/shared'
9
11
 
10
- @Extend(Flex)
11
- function attrs (style: TaroStyleType) {
12
- .id(style.id)
13
- .key(style.id)
14
- .padding(style.padding)
15
- .margin(style.margin)
16
- .width(style.width)
17
- .height(style.height)
18
- .constraintSize(style.constraintSize)
19
- .flexGrow(style.flexGrow)
20
- .flexShrink(style.flexShrink)
21
- .flexBasis(style.flexBasis)
22
- .alignSelf(style.alignSelf)
23
- .backgroundColor(style.backgroundColor)
24
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
25
- .backgroundImageSize(style.backgroundImageSize)
26
- .backgroundImagePosition(style.backgroundImagePosition)
27
- .rotate(style.rotate)
28
- .scale(style.scale)
29
- .translate(style.translate)
30
- .transform(style.transform)
31
- .borderStyle(style.borderStyle)
32
- .borderWidth(style.borderWidth)
33
- .borderColor(style.borderColor)
34
- .borderRadius(style.borderRadius)
35
- .linearGradient(style.linearGradient)
36
- .zIndex(style.zIndex)
37
- .opacity(style.opacity)
38
- .clip(style.clip)
39
- }
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> = {}
19
+
20
+ aboutToAppear(): void {
21
+ if (this.node) {
22
+ this.node._instance = this
23
+ }
24
+ }
40
25
 
41
- @Builder
42
- export default function TaroForm (node: TaroFormElement) {
43
- Flex(FlexManager.flexOptions(node)) {
44
- createLazyChildren(node)
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))
60
+ }
45
61
  }
46
- .attrs(getNormalAttributes(node))
47
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
48
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
49
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
50
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
51
- node._nodeInfo.areaInfo = res[1]
52
- }))
53
62
  }
@@ -1,39 +1,9 @@
1
- import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
1
+ import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, convertNumber2PX } from '@tarojs/runtime'
2
2
 
3
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
3
+ import commonStyleModify from './style'
4
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
4
5
 
5
- import type { TaroIconElement, TaroAny, TaroStyleType } from '@tarojs/runtime'
6
-
7
- @Extend(Image)
8
- function attrs (style: TaroStyleType) {
9
- .id(style.id)
10
- .key(style.id)
11
- .padding(style.padding)
12
- .margin(style.margin)
13
- .width(style.width || convertNumber2VP(23))
14
- .height(style.height || convertNumber2VP(23))
15
- .constraintSize(style.constraintSize)
16
- .flexGrow(style.flexGrow)
17
- .flexShrink(style.flexShrink)
18
- .flexBasis(style.flexBasis)
19
- .alignSelf(style.alignSelf)
20
- .backgroundColor(style.backgroundColor)
21
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
22
- .backgroundImageSize(style.backgroundImageSize)
23
- .backgroundImagePosition(style.backgroundImagePosition)
24
- .rotate(style.rotate)
25
- .scale(style.scale)
26
- .translate(style.translate)
27
- .transform(style.transform)
28
- .borderStyle(style.borderStyle)
29
- .borderWidth(style.borderWidth)
30
- .borderColor(style.borderColor)
31
- .borderRadius(style.borderRadius)
32
- .linearGradient(style.linearGradient)
33
- .zIndex(style.zIndex)
34
- .opacity(style.opacity)
35
- .clip(style.clip)
36
- }
6
+ import type { TaroIconElement, TaroAny } from '@tarojs/runtime'
37
7
 
38
8
  const ICON_COLOR_MAP: TaroAny = {
39
9
  success: Color.Green,
@@ -78,20 +48,34 @@ function getIconData (node: TaroIconElement): Resource | null {
78
48
  }
79
49
  }
80
50
 
81
- @Builder
82
- export default function TaroIcon (node: TaroIconElement) {
83
- Image(getIconData(node))
84
- .objectFit(ImageFit.Contain)
85
- .fillColor(node._attrs.color || ICON_COLOR_MAP[node._attrs.type] || Color.Black)
86
- .attrs(getNormalAttributes(node))
87
- .size({
88
- width: convertNumber2VP(Number(node._attrs.size) || 23),
89
- height: convertNumber2VP(Number(node._attrs.size) || 23),
90
- })
91
- .onComplete(e => eventHandler(e, 'complete', node))
92
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
93
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
94
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
95
- node._nodeInfo.areaInfo = res[1]
96
- }))
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
+ }
97
80
  }
81
+
@@ -1,41 +1,11 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
3
+ import commonStyleModify from './style'
4
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
4
5
 
5
- import type { TaroImageElement, TaroAny, TaroStyleType } from '@tarojs/runtime'
6
+ import type { TaroImageElement, TaroAny } from '@tarojs/runtime'
6
7
 
7
- @Extend(Image)
8
- function attrs (style: TaroStyleType) {
9
- .id(style.id)
10
- .key(style.id)
11
- .padding(style.padding)
12
- .margin(style.margin)
13
- .width(style.width)
14
- .height(style.height)
15
- .backgroundColor(style.backgroundColor)
16
- .constraintSize(style.constraintSize)
17
- .flexGrow(style.flexGrow)
18
- .flexShrink(style.flexShrink)
19
- .flexBasis(style.flexBasis)
20
- .alignSelf(style.alignSelf)
21
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
22
- .backgroundImageSize(style.backgroundImageSize)
23
- .backgroundImagePosition(style.backgroundImagePosition)
24
- .rotate(style.rotate)
25
- .scale(style.scale)
26
- .translate(style.translate)
27
- .transform(style.transform)
28
- .borderStyle(style.borderStyle)
29
- .borderWidth(style.borderWidth)
30
- .borderColor(style.borderColor)
31
- .borderRadius(style.borderRadius)
32
- .linearGradient(style.linearGradient)
33
- .zIndex(style.zIndex)
34
- .opacity(style.opacity)
35
- .clip(style.clip)
36
- }
37
-
38
- function getImageMode (mode: string): ImageFit {
8
+ export function getImageMode (mode: string): ImageFit {
39
9
  switch (mode) {
40
10
  case 'aspectFit': return ImageFit.Contain
41
11
  case 'aspectFill': return ImageFit.Cover
@@ -46,15 +16,35 @@ function getImageMode (mode: string): ImageFit {
46
16
  }
47
17
  }
48
18
 
49
- @Builder
50
- export default function TaroImage (node: TaroImageElement) {
51
- Image(node.getAttribute('src'))
52
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
53
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
54
- node._nodeInfo.areaInfo = res[1]
55
- }))
56
- .objectFit(getImageMode(node.getAttribute('mode')))
57
- .attrs(getNormalAttributes(node))
58
- .onComplete(e => eventHandler(e, 'complete', node))
59
- .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
+ }
60
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 { createChildItemWithPosition } 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
- createChildItemWithPosition(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
  }