@tarojs/plugin-platform-harmony-ets 4.0.0-beta.11 → 4.0.0-beta.111

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 (129) hide show
  1. package/dist/apis/base/system.ts +73 -20
  2. package/dist/apis/canvas/index.ts +10 -1
  3. package/dist/apis/device/clipboard.ts +16 -8
  4. package/dist/apis/framework/index.ts +1 -5
  5. package/dist/apis/index.ts +25 -17
  6. package/dist/apis/media/image/index.ts +1 -1
  7. package/dist/apis/storage/index.ts +135 -131
  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 +2 -1
  16. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  17. package/dist/apis/wxml/selectorQuery.ts +26 -13
  18. package/dist/components-harmony-ets/button.ets +35 -8
  19. package/dist/components-harmony-ets/canvas.ets +51 -0
  20. package/dist/components-harmony-ets/checkbox.ets +70 -60
  21. package/dist/components-harmony-ets/form.ets +35 -16
  22. package/dist/components-harmony-ets/icon.ets +16 -8
  23. package/dist/components-harmony-ets/image.ets +22 -6
  24. package/dist/components-harmony-ets/index.ets +92 -0
  25. package/dist/components-harmony-ets/innerHtml.ets +6 -5
  26. package/dist/components-harmony-ets/input.ets +62 -40
  27. package/dist/components-harmony-ets/label.ets +44 -21
  28. package/dist/components-harmony-ets/listView.ets +31 -0
  29. package/dist/components-harmony-ets/movableArea.ets +112 -53
  30. package/dist/components-harmony-ets/movableView.ets +75 -48
  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 +41 -38
  34. package/dist/components-harmony-ets/progress.ets +31 -24
  35. package/dist/components-harmony-ets/pseudo.ets +80 -0
  36. package/dist/components-harmony-ets/radio.ets +76 -66
  37. package/dist/components-harmony-ets/richText.ets +4 -25
  38. package/dist/components-harmony-ets/scrollList.ets +103 -0
  39. package/dist/components-harmony-ets/scrollView.ets +47 -47
  40. package/dist/components-harmony-ets/slider.ets +18 -14
  41. package/dist/components-harmony-ets/stickySection.ets +42 -0
  42. package/dist/components-harmony-ets/style.ets +386 -130
  43. package/dist/components-harmony-ets/swiper.ets +41 -4
  44. package/dist/components-harmony-ets/switch.ets +35 -31
  45. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  46. package/dist/components-harmony-ets/text.ets +102 -46
  47. package/dist/components-harmony-ets/textArea.ets +49 -34
  48. package/dist/components-harmony-ets/utils/AttributeManager.ets +2 -2
  49. package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -2
  50. package/dist/components-harmony-ets/utils/flexManager.ets +49 -19
  51. package/dist/components-harmony-ets/utils/helper.ets +20 -8
  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 +27 -19
  57. package/dist/components-harmony-ets/view.ets +47 -40
  58. package/dist/components-harmony-ets/webView.ets +6 -5
  59. package/dist/index.d.ts +152 -0
  60. package/dist/index.js +69 -43
  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 +5 -1
  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 +419 -0
  69. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +28 -42
  70. package/dist/runtime-ets/dom/document.ts +8 -11
  71. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  72. package/dist/runtime-ets/dom/element/element.ts +376 -56
  73. package/dist/runtime-ets/dom/element/form.ts +20 -22
  74. package/dist/runtime-ets/dom/element/index.ts +22 -2
  75. package/dist/runtime-ets/dom/element/movableArea.ts +0 -1
  76. package/dist/runtime-ets/dom/element/movableView.ts +234 -2
  77. package/dist/runtime-ets/dom/element/normal.ts +27 -6
  78. package/dist/runtime-ets/dom/element/progress.ts +0 -2
  79. package/dist/runtime-ets/dom/element/text.ts +0 -8
  80. package/dist/runtime-ets/dom/element/video.ts +4 -4
  81. package/dist/runtime-ets/dom/element/webView.ts +4 -5
  82. package/dist/runtime-ets/dom/event.ts +3 -5
  83. package/dist/runtime-ets/dom/eventTarget.ts +2 -3
  84. package/dist/runtime-ets/dom/node.ts +51 -19
  85. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +418 -237
  86. package/dist/runtime-ets/dom/stylesheet/index.ts +29 -311
  87. package/dist/runtime-ets/dom/stylesheet/type.ts +51 -9
  88. package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
  89. package/dist/runtime-ets/index.ts +2 -1
  90. package/dist/runtime-ets/interface/event.ts +1 -1
  91. package/dist/runtime-ets/utils/index.ts +74 -13
  92. package/dist/runtime-ets/utils/info.ts +2 -2
  93. package/dist/runtime-framework/react/app.ts +15 -10
  94. package/dist/runtime-framework/react/hooks.ts +0 -1
  95. package/dist/runtime-framework/react/index.ts +0 -2
  96. package/dist/runtime-framework/react/native-page.ts +185 -78
  97. package/dist/runtime-framework/react/page.ts +4 -9
  98. package/dist/runtime-framework/react/utils/index.ts +3 -3
  99. package/dist/runtime-framework/solid/app.ts +30 -46
  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 +85 -31
  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 +3 -5
  108. package/dist/runtime-utils.d.ts +827 -0
  109. package/dist/runtime-utils.js +425 -253
  110. package/dist/runtime-utils.js.map +1 -1
  111. package/dist/runtime.d.ts +1 -0
  112. package/dist/runtime.js +425 -253
  113. package/dist/runtime.js.map +1 -1
  114. package/index.js +3 -1
  115. package/package.json +14 -15
  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/types/runtime.d.ts +1 -1
  129. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -1,5 +1,4 @@
1
1
  import { eventHandler, createTaroEvent, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
- import { createLazyChildren } from './render'
3
2
  import commonStyleModify from './style'
4
3
  import { BUTTON_THEME_COLOR } from './utils/constant/style'
5
4
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
@@ -7,6 +6,21 @@ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
7
6
 
8
7
  import type { TaroAny, TaroEvent, TaroButtonElement, TaroStyleType } from '@tarojs/runtime'
9
8
 
9
+ interface ButtonAttrs {
10
+ disabled?: boolean
11
+ }
12
+
13
+ @Extend(Button)
14
+ function attrs(attr: ButtonAttrs) {
15
+ .enabled(!attr.disabled)
16
+ }
17
+
18
+ function getAttributes(node: TaroButtonElement): ButtonAttrs {
19
+ return {
20
+ disabled: node._attrs.disabled || false,
21
+ }
22
+ }
23
+
10
24
  @Extend(Button)
11
25
  function themeStyles(style: TaroStyleType) {
12
26
  .fontColor(style.color)
@@ -66,13 +80,13 @@ function getThemeAttributes (node: TaroButtonElement): TaroStyleType {
66
80
  }
67
81
  }
68
82
 
69
- function getButtonWidth (node: TaroButtonElement) {
83
+ function getButtonWidth (node: TaroButtonElement): string | number {
70
84
  const isMini = node._attrs.size === 'mini'
71
85
 
72
86
  return isMini ? convertNumber2VP(120) : '100%'
73
87
  }
74
88
 
75
- function getButtonHeight (node: TaroButtonElement) {
89
+ function getButtonHeight (node: TaroButtonElement): string | number {
76
90
  const isMini = node._attrs.size === 'mini'
77
91
 
78
92
  return isMini ? convertNumber2VP(60) : convertNumber2VP(92)
@@ -96,20 +110,33 @@ function getButtonMinHeight (node: TaroButtonElement): string | number | undefin
96
110
 
97
111
  @Component
98
112
  export default struct TaroButton {
113
+ @Builder customBuilder() {}
114
+ @BuilderParam createLazyChildren: (node: TaroButtonElement, layer?: number) => void = this.customBuilder
99
115
  @ObjectLink node: TaroButtonElement
116
+ @State overwriteStyle: Record<string, TaroAny> = {}
117
+
118
+ aboutToAppear(): void {
119
+ if (this.node) {
120
+ this.node._instance = this
121
+ }
122
+ }
123
+
100
124
  build() {
101
125
  Button({ stateEffect: !this.node._attrs.disabled }) {
102
- Row() {
103
- if (this.node._attrs.loading) {
126
+ if (this.node._attrs.loading) {
127
+ Row() {
104
128
  LoadingProgress()
105
129
  .width(20).height(20)
106
130
  .color(getThemeAttributes(this.node).color)
131
+ this.createLazyChildren(this.node, 0)
107
132
  }
108
- createLazyChildren(this.node)
133
+ } else {
134
+ this.createLazyChildren(this.node, 0)
109
135
  }
110
136
  }
111
137
  .themeStyles(getThemeAttributes(this.node))
112
- .attributeModifier(commonStyleModify.setNode(this.node))
138
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
139
+ .attrs(getAttributes(this.node))
113
140
  .constraintSize({
114
141
  minWidth: this.node.hmStyle?.minWidth || getButtonMinWidth(this.node),
115
142
  minHeight: this.node.hmStyle?.minHeight || getButtonMinHeight(this.node),
@@ -125,7 +152,7 @@ export default struct TaroButton {
125
152
  }
126
153
  eventHandler(e, 'click', this.node)
127
154
  })
128
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
155
+ .onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
129
156
  .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
130
157
  this.node._nodeInfo.areaInfo = res[1]
131
158
  }))
@@ -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
@@ -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
 
@@ -36,57 +39,59 @@ function getOptions (node: TaroCheckboxElement): CheckboxOptions {
36
39
 
37
40
  @Component
38
41
  export struct TaroCheckbox {
42
+ @Builder customBuilder() {}
43
+ @BuilderParam createLazyChildren: (node: TaroCheckboxElement, layer?: number) => void = this.customBuilder
39
44
  @ObjectLink node: TaroCheckboxElement
45
+ @State overwriteStyle: Record<string, TaroAny> = {}
40
46
 
41
47
  aboutToAppear () {
42
48
  if (this.node && !this.node._isInit) {
43
49
  this.node._isInit = true
50
+ this.node._instance = this
44
51
  this.node._reset = this.node.checked || false
45
52
  }
46
53
  }
47
54
 
48
55
  build () {
49
- if (this.node) {
50
- Stack() {
51
- Row() {
52
- Checkbox(getOptions(this.node))
53
- .attributeModifier(commonStyleModify.setNode(this.node))
54
- .checkboxAttr(getAttributes(this.node))
55
- .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
56
- .select(this.node.checked)
57
- .onChange((value: boolean) => {
58
- if (this.node) {
59
- if (!!this.node?._attrs.disabled) {
60
- this.node.updateComponent()
61
- } else {
62
- this.node.updateCheckedValue(value)
63
-
64
- if (value) {
65
- const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
66
- eventHandler(event, 'change', this.node)
67
- }
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)
68
73
  }
69
74
  }
70
- })
71
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
72
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
73
- if (this.node) {
74
- this.node._nodeInfo.areaInfo = res[1]
75
- }
76
- }))
77
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
78
- Text(this.node.textContent)
79
- .textAlign(TextAlign.Center)
80
- .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
81
- }
82
- .onClick(() => {
83
- if (this.node) {
84
- if (!this.node?._attrs.disabled) {
85
- this.node.checked = !this.node.checked
86
75
  }
87
- }
88
- })
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)
89
87
  }
88
+ .onClick(() => {
89
+ if (this.node) {
90
+ if (!this.node?._attrs.disabled) {
91
+ this.node.checked = !this.node.checked
92
+ }
93
+ }
94
+ })
90
95
  }
91
96
  }
92
97
  }
@@ -95,7 +100,10 @@ interface ChangeEventDetail { value: string[] }
95
100
 
96
101
  @Component
97
102
  export struct TaroCheckboxGroup {
103
+ @Builder customBuilder() {}
104
+ @BuilderParam createLazyChildren: (node: TaroCheckboxGroupElement, layer?: number) => void = this.customBuilder
98
105
  @ObjectLink node: TaroCheckboxGroupElement
106
+ @State overwriteStyle: Record<string, TaroAny> = {}
99
107
 
100
108
  @Styles visibleChangeEvent () {
101
109
  .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
@@ -103,6 +111,7 @@ export struct TaroCheckboxGroup {
103
111
 
104
112
  aboutToAppear () {
105
113
  if (this.node) {
114
+ this.node._instance = this
106
115
  // 阻止事件冒泡传递上去
107
116
  this.node.addEventListener('change', (e: TaroEvent<ChangeEventDetail>) => {
108
117
  e.stopPropagation()
@@ -112,7 +121,7 @@ export struct TaroCheckboxGroup {
112
121
  }
113
122
 
114
123
  @Styles defaultEvent () {
115
- .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']))
116
125
  .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
117
126
  if (this.node) {
118
127
  this.node._nodeInfo.areaInfo = res[1]
@@ -121,26 +130,27 @@ export struct TaroCheckboxGroup {
121
130
  }
122
131
 
123
132
  build() {
124
- if (this.node) {
125
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
126
- Row() {
127
- createLazyChildren(this.node)
128
- }
129
- .attributeModifier(commonStyleModify.setNode(this.node))
130
- .defaultEvent()
131
- .visibleChangeEvent()
132
- .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
133
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
134
- } else {
135
- Column() {
136
- createLazyChildren(this.node)
137
- }
138
- .attributeModifier(commonStyleModify.setNode(this.node))
139
- .defaultEvent()
140
- .visibleChangeEvent()
141
- .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
142
- .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)
143
150
  }
151
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
152
+ .defaultEvent()
153
+ .visibleChangeEvent()
144
154
  }
145
155
  }
146
156
  }
@@ -1,43 +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'
10
11
 
11
12
  @Component
12
13
  export default struct TaroForm {
14
+ @Builder customBuilder() {}
15
+ @BuilderParam createLazyChildren: (node: TaroFormElement, layer?: number) => void = this.customBuilder
13
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
+ }
25
+
14
26
  build() {
15
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
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) {
16
39
  Row() {
17
- createLazyChildren(this.node)
40
+ this.createLazyChildren(this.node, 0)
18
41
  }
19
- .attributeModifier(commonStyleModify.setNode(this.node))
20
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
21
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
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()))
22
45
  .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
23
46
  this.node._nodeInfo.areaInfo = res[1]
24
47
  }))
25
48
  .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
26
- .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
27
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
28
49
  } else {
29
50
  Column() {
30
- createLazyChildren(this.node)
51
+ this.createLazyChildren(this.node, 0)
31
52
  }
32
- .attributeModifier(commonStyleModify.setNode(this.node))
33
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
34
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
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()))
35
56
  .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
36
57
  this.node._nodeInfo.areaInfo = res[1]
37
58
  }))
38
59
  .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
39
- .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
40
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
41
60
  }
42
61
  }
43
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
 
@@ -50,20 +50,28 @@ function getIconData (node: TaroIconElement): Resource | null {
50
50
 
51
51
  @Component
52
52
  export default struct TaroIcon {
53
+ @Builder customBuilder() {}
54
+ @BuilderParam createLazyChildren: (node: TaroIconElement, layer?: number) => void = this.customBuilder
53
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
+
54
64
  build() {
55
65
  Image(getIconData(this.node))
56
66
  .objectFit(ImageFit.Contain)
57
67
  .fillColor(this.node._attrs.color || ICON_COLOR_MAP[this.node._attrs.type] || Color.Black)
58
- .attributeModifier(commonStyleModify.setNode(this.node))
68
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
59
69
  .size({
60
- width: convertNumber2VP(Number(this.node._attrs.size) || 23),
61
- height: convertNumber2VP(Number(this.node._attrs.size) || 23),
70
+ width: Number(this.node._attrs.size) || 23,
71
+ height: Number(this.node._attrs.size) || 23
62
72
  })
63
- .width(getNormalAttributes(this.node).width || convertNumber2PX(23))
64
- .height(getNormalAttributes(this.node).height || convertNumber2PX(23))
65
- .onComplete(e => eventHandler(e, 'complete', this.node))
66
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
73
+ .onComplete(e => { eventHandler(e, 'complete', this.node) })
74
+ .onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
67
75
  .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
68
76
  .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
69
77
  this.node._nodeInfo.areaInfo = res[1]
@@ -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
@@ -18,17 +18,33 @@ function getImageMode (mode: string): ImageFit {
18
18
 
19
19
  @Component
20
20
  export default struct TaroImage {
21
+ @Builder customBuilder() {}
22
+ @BuilderParam createLazyChildren: (node: TaroImageElement, layer?: number) => void = this.customBuilder
21
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
+ }
22
31
 
23
32
  build() {
24
33
  Image(this.node.getAttribute('src'))
25
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
34
+ .onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
26
35
  .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
27
36
  this.node._nodeInfo.areaInfo = res[1]
28
37
  }))
29
38
  .objectFit(getImageMode(this.node.getAttribute('mode')))
30
- .attributeModifier(commonStyleModify.setNode(this.node))
31
- .onComplete(e => eventHandler(e, 'complete', this.node))
39
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
40
+ .onComplete(e => { eventHandler(e, 'complete', this.node) })
32
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
+ })
33
49
  }
34
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,15 +1,16 @@
1
1
  import htmlParser from './utils/htmlParser'
2
- import { createChildItem } from './render'
3
2
 
4
- import type { TaroInnerHtmlElement } from '@tarojs/runtime'
3
+ import type { TaroElement, TaroInnerHtmlElement } from '@tarojs/runtime'
5
4
 
6
5
  @Component
7
6
  export default struct TaroInnerHtml {
7
+ @Builder customBuilder() {}
8
+ @BuilderParam createChildItem: (node: TaroElement, callback?: (node: TaroElement) => void) => void = this.customBuilder
8
9
  @ObjectLink node: TaroInnerHtmlElement
9
-
10
+
10
11
  build() {
11
- if (this.node.innerHTML) {
12
- createChildItem(htmlParser(this.node.innerHTML))
12
+ if (this.node?.hmStyle?.display !== 'none' && this.node.innerHTML) {
13
+ this.createChildItem(htmlParser(this.node.innerHTML))
13
14
  }
14
15
  }
15
16
  }