@tarojs/plugin-platform-harmony-ets 4.0.0-alpha.2 → 4.0.0-alpha.21

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 +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 +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 +64 -34
  19. package/dist/components-harmony-ets/canvas.ets +51 -0
  20. package/dist/components-harmony-ets/checkbox.ets +72 -61
  21. package/dist/components-harmony-ets/form.ets +51 -29
  22. package/dist/components-harmony-ets/icon.ets +31 -19
  23. package/dist/components-harmony-ets/image.ets +34 -14
  24. package/dist/components-harmony-ets/index.ets +92 -0
  25. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  26. package/dist/components-harmony-ets/input.ets +49 -41
  27. package/dist/components-harmony-ets/label.ets +71 -44
  28. package/dist/components-harmony-ets/listView.ets +26 -0
  29. package/dist/components-harmony-ets/movableArea.ets +126 -0
  30. package/dist/components-harmony-ets/movableView.ets +93 -0
  31. package/dist/components-harmony-ets/navigationBar.ets +65 -0
  32. package/dist/components-harmony-ets/pageMeta.ets +94 -0
  33. package/dist/components-harmony-ets/picker.ets +42 -38
  34. package/dist/components-harmony-ets/progress.ets +52 -0
  35. package/dist/components-harmony-ets/pseudo.ets +80 -0
  36. package/dist/components-harmony-ets/radio.ets +74 -64
  37. package/dist/components-harmony-ets/richText.ets +14 -30
  38. package/dist/components-harmony-ets/scrollList.ets +94 -0
  39. package/dist/components-harmony-ets/scrollView.ets +61 -57
  40. package/dist/components-harmony-ets/slider.ets +18 -14
  41. package/dist/components-harmony-ets/stickySection.ets +42 -0
  42. package/dist/components-harmony-ets/style.ets +381 -130
  43. package/dist/components-harmony-ets/swiper.ets +61 -20
  44. package/dist/components-harmony-ets/switch.ets +36 -32
  45. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  46. package/dist/components-harmony-ets/text.ets +135 -49
  47. package/dist/components-harmony-ets/textArea.ets +50 -35
  48. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  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 +18 -5
  52. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  53. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  54. package/dist/components-harmony-ets/utils/index.ts +54 -50
  55. package/dist/components-harmony-ets/utils/styles.ets +170 -93
  56. package/dist/components-harmony-ets/video.ets +34 -21
  57. package/dist/components-harmony-ets/view.ets +63 -52
  58. package/dist/components-harmony-ets/webView.ets +40 -34
  59. package/dist/index.d.ts +152 -0
  60. package/dist/index.js +99 -55
  61. package/dist/index.js.map +1 -1
  62. package/dist/runtime-ets/bom/document.ts +6 -4
  63. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  64. package/dist/runtime-ets/bom/window.ts +7 -0
  65. package/dist/runtime-ets/current.ts +3 -0
  66. package/dist/runtime-ets/dom/bind.ts +28 -12
  67. package/dist/runtime-ets/dom/class-list.ts +2 -2
  68. package/dist/runtime-ets/dom/cssNesting.ts +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 +348 -57
  73. package/dist/runtime-ets/dom/element/form.ts +31 -26
  74. package/dist/runtime-ets/dom/element/index.ts +30 -2
  75. package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
  76. package/dist/runtime-ets/dom/element/movableView.ts +244 -0
  77. package/dist/runtime-ets/dom/element/normal.ts +35 -8
  78. package/dist/runtime-ets/dom/element/progress.ts +11 -0
  79. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  80. package/dist/runtime-ets/dom/element/text.ts +1 -8
  81. package/dist/runtime-ets/dom/element/video.ts +5 -4
  82. package/dist/runtime-ets/dom/element/webView.ts +12 -5
  83. package/dist/runtime-ets/dom/event.ts +2 -4
  84. package/dist/runtime-ets/dom/eventTarget.ts +2 -3
  85. package/dist/runtime-ets/dom/node.ts +54 -29
  86. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +416 -235
  87. package/dist/runtime-ets/dom/stylesheet/index.ts +29 -311
  88. package/dist/runtime-ets/dom/stylesheet/type.ts +51 -9
  89. package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
  90. package/dist/runtime-ets/index.ts +2 -1
  91. package/dist/runtime-ets/interface/event.ts +1 -1
  92. package/dist/runtime-ets/utils/index.ts +73 -13
  93. package/dist/runtime-ets/utils/info.ts +2 -2
  94. package/dist/runtime-framework/react/app.ts +9 -4
  95. package/dist/runtime-framework/react/hooks.ts +0 -1
  96. package/dist/runtime-framework/react/index.ts +0 -2
  97. package/dist/runtime-framework/react/native-page.ts +154 -77
  98. package/dist/runtime-framework/react/page.ts +3 -8
  99. package/dist/runtime-framework/solid/app.ts +25 -45
  100. package/dist/runtime-framework/solid/connect.ts +21 -3
  101. package/dist/runtime-framework/solid/hooks.ts +16 -11
  102. package/dist/runtime-framework/solid/index.ts +6 -2
  103. package/dist/runtime-framework/solid/page.ts +84 -30
  104. package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
  105. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  106. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  107. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  108. package/dist/runtime-utils.d.ts +827 -0
  109. package/dist/runtime-utils.js +435 -218
  110. package/dist/runtime-utils.js.map +1 -1
  111. package/dist/runtime.d.ts +1 -0
  112. package/dist/runtime.js +435 -218
  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)
@@ -94,38 +108,54 @@ function getButtonMinHeight (node: TaroButtonElement): string | number | undefin
94
108
  return getButtonHeight(node)
95
109
  }
96
110
 
97
- @Builder
98
- export default function TaroButton (node: TaroButtonElement) {
99
- Button({ stateEffect: !node._attrs.disabled }) {
100
- Row() {
101
- if (node._attrs.loading) {
102
- LoadingProgress()
103
- .width(20).height(20)
104
- .color(getThemeAttributes(node).color)
105
- }
106
- createLazyChildren(node)
111
+ @Component
112
+ export default struct TaroButton {
113
+ @Builder customBuilder() {}
114
+ @BuilderParam createLazyChildren: (node: TaroButtonElement) => void = this.customBuilder
115
+ @ObjectLink node: TaroButtonElement
116
+ @State overwriteStyle: Record<string, TaroAny> = {}
117
+
118
+ aboutToAppear(): void {
119
+ if (this.node) {
120
+ this.node._instance = this
107
121
  }
108
122
  }
109
- .themeStyles(getThemeAttributes(node))
110
- .attributeModifier(commonStyleModify.setNode(node))
111
- .constraintSize({
112
- minWidth: node.hmStyle?.minWidth || getButtonMinWidth(node),
113
- minHeight: node.hmStyle?.minHeight || getButtonMinHeight(node),
114
- maxWidth: node.hmStyle?.maxWidth,
115
- maxHeight: node.hmStyle?.maxHeight,
116
- })
117
- .type(ButtonType.Normal)
118
- .onClick((e: ClickEvent) => {
119
- if (node._attrs.formType && ['submit', 'reset'].includes(node._attrs.formType)) {
120
- const eventName = node._attrs.formType + '-btn'
121
- const event: TaroEvent = createTaroEvent(eventName, {}, node)
122
- eventHandler(event, eventName, node)
123
+
124
+ build() {
125
+ Button({ stateEffect: !this.node._attrs.disabled }) {
126
+ if (this.node._attrs.loading) {
127
+ Row() {
128
+ LoadingProgress()
129
+ .width(20).height(20)
130
+ .color(getThemeAttributes(this.node).color)
131
+ this.createLazyChildren(this.node)
132
+ }
133
+ } else {
134
+ this.createLazyChildren(this.node)
135
+ }
123
136
  }
124
- eventHandler(e, 'click', node)
125
- })
126
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
127
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
128
- node._nodeInfo.areaInfo = res[1]
129
- }))
130
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
137
+ .themeStyles(getThemeAttributes(this.node))
138
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
139
+ .attrs(getAttributes(this.node))
140
+ .constraintSize({
141
+ minWidth: this.node.hmStyle?.minWidth || getButtonMinWidth(this.node),
142
+ minHeight: this.node.hmStyle?.minHeight || getButtonMinHeight(this.node),
143
+ maxWidth: this.node.hmStyle?.maxWidth,
144
+ maxHeight: this.node.hmStyle?.maxHeight,
145
+ })
146
+ .type(ButtonType.Normal)
147
+ .onClick((e: ClickEvent) => {
148
+ if (this.node._attrs.formType && ['submit', 'reset'].includes(this.node._attrs.formType)) {
149
+ const eventName = this.node._attrs.formType + '-btn'
150
+ const event: TaroEvent = createTaroEvent(eventName, {}, this.node)
151
+ eventHandler(event, eventName, this.node)
152
+ }
153
+ eventHandler(e, 'click', this.node)
154
+ })
155
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
156
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
157
+ this.node._nodeInfo.areaInfo = res[1]
158
+ }))
159
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
160
+ }
131
161
  }
@@ -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
 
@@ -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) => 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) => 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()
@@ -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)
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)
143
+ }
144
+ .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
145
+ .defaultEvent()
146
+ .visibleChangeEvent()
147
+ } else {
148
+ Column() {
149
+ this.createLazyChildren(this.node)
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) => void = this.customBuilder
16
+ @ObjectLink node: TaroFormElement
17
+
18
+ @State overwriteStyle: Record<string, TaroAny> = {}
10
19
 
11
- @Builder
12
- export default function TaroForm (node: TaroFormElement) {
13
- if (FlexManager.isFlexNode(node) && FlexManager.flexOptions(node).direction !== FlexDirection.Column) {
14
- Row() {
15
- createLazyChildren(node)
20
+ aboutToAppear(): void {
21
+ if (this.node) {
22
+ this.node._instance = this
16
23
  }
17
- .attributeModifier(commonStyleModify.setNode(node))
18
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
19
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
20
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
21
- node._nodeInfo.areaInfo = res[1]
22
- }))
23
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
24
- .alignItems(FlexManager.flexOptions(node).alignItems as VerticalAlign)
25
- .justifyContent(FlexManager.flexOptions(node).justifyContent)
26
- } else {
27
- Column() {
28
- createLazyChildren(node)
24
+ }
25
+
26
+ build() {
27
+ if (FlexManager.useFlexLayout(this.node)) {
28
+ Flex(FlexManager.flexOptions(this.node)) {
29
+ this.createLazyChildren(this.node)
30
+ }
31
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
32
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
33
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
34
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
35
+ this.node._nodeInfo.areaInfo = res[1]
36
+ }))
37
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
38
+ } else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
39
+ Row() {
40
+ this.createLazyChildren(this.node)
41
+ }
42
+ .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
43
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
44
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
45
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
46
+ this.node._nodeInfo.areaInfo = res[1]
47
+ }))
48
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
49
+ } else {
50
+ Column() {
51
+ this.createLazyChildren(this.node)
52
+ }
53
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
54
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
55
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
56
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
57
+ this.node._nodeInfo.areaInfo = res[1]
58
+ }))
59
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
29
60
  }
30
- .attributeModifier(commonStyleModify.setNode(node))
31
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
32
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
33
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
34
- node._nodeInfo.areaInfo = res[1]
35
- }))
36
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
37
- .alignItems(FlexManager.flexOptions(node).alignItems as HorizontalAlign)
38
- .justifyContent(FlexManager.flexOptions(node).justifyContent)
39
61
  }
40
62
  }
@@ -1,7 +1,7 @@
1
1
  import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, convertNumber2PX } from '@tarojs/runtime'
2
2
 
3
3
  import commonStyleModify from './style'
4
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
4
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
5
5
 
6
6
  import type { TaroIconElement, TaroAny } from '@tarojs/runtime'
7
7
 
@@ -48,22 +48,34 @@ function getIconData (node: TaroIconElement): Resource | null {
48
48
  }
49
49
  }
50
50
 
51
- @Builder
52
- export default function TaroIcon (node: TaroIconElement) {
53
- Image(getIconData(node))
54
- .objectFit(ImageFit.Contain)
55
- .fillColor(node._attrs.color || ICON_COLOR_MAP[node._attrs.type] || Color.Black)
56
- .attributeModifier(commonStyleModify.setNode(node))
57
- .size({
58
- width: convertNumber2VP(Number(node._attrs.size) || 23),
59
- height: convertNumber2VP(Number(node._attrs.size) || 23),
60
- })
61
- .width(getNormalAttributes(node).width || convertNumber2PX(23))
62
- .height(getNormalAttributes(node).height || convertNumber2PX(23))
63
- .onComplete(e => eventHandler(e, 'complete', node))
64
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
65
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
66
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
67
- node._nodeInfo.areaInfo = res[1]
68
- }))
51
+ @Component
52
+ export default struct TaroIcon {
53
+ @Builder customBuilder() {}
54
+ @BuilderParam createLazyChildren: (node: TaroIconElement) => void = this.customBuilder
55
+ @ObjectLink node: TaroIconElement
56
+ @State overwriteStyle: Record<string, TaroAny> = {}
57
+
58
+ aboutToAppear(): void {
59
+ if (this.node) {
60
+ this.node._instance = this
61
+ }
62
+ }
63
+
64
+ build() {
65
+ Image(getIconData(this.node))
66
+ .objectFit(ImageFit.Contain)
67
+ .fillColor(this.node._attrs.color || ICON_COLOR_MAP[this.node._attrs.type] || Color.Black)
68
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
69
+ .size({
70
+ width: Number(this.node._attrs.size) || 23,
71
+ height: Number(this.node._attrs.size) || 23
72
+ })
73
+ .onComplete(e => eventHandler(e, 'complete', this.node))
74
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
75
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
76
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
77
+ this.node._nodeInfo.areaInfo = res[1]
78
+ }))
79
+ }
69
80
  }
81
+
@@ -1,11 +1,11 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
3
  import commonStyleModify from './style'
4
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
4
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
5
5
 
6
- import type { TaroImageElement, TaroAny, TaroStyleType } from '@tarojs/runtime'
6
+ import type { TaroImageElement, TaroAny } from '@tarojs/runtime'
7
7
 
8
- function getImageMode (mode: string): ImageFit {
8
+ export function getImageMode (mode: string): ImageFit {
9
9
  switch (mode) {
10
10
  case 'aspectFit': return ImageFit.Contain
11
11
  case 'aspectFill': return ImageFit.Cover
@@ -16,15 +16,35 @@ function getImageMode (mode: string): ImageFit {
16
16
  }
17
17
  }
18
18
 
19
- @Builder
20
- export default function TaroImage (node: TaroImageElement) {
21
- Image(node.getAttribute('src'))
22
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
23
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
24
- node._nodeInfo.areaInfo = res[1]
25
- }))
26
- .objectFit(getImageMode(node.getAttribute('mode')))
27
- .attributeModifier(commonStyleModify.setNode(node))
28
- .onComplete(e => eventHandler(e, 'complete', node))
29
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
19
+ @Component
20
+ export default struct TaroImage {
21
+ @Builder customBuilder() {}
22
+ @BuilderParam createLazyChildren: (node: TaroImageElement) => void = this.customBuilder
23
+ @ObjectLink node: TaroImageElement
24
+ @State overwriteStyle: Record<string, TaroAny> = {}
25
+
26
+ aboutToAppear(): void {
27
+ if (this.node) {
28
+ this.node._instance = this
29
+ }
30
+ }
31
+
32
+ build() {
33
+ Image(this.node.getAttribute('src'))
34
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
35
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
36
+ this.node._nodeInfo.areaInfo = res[1]
37
+ }))
38
+ .objectFit(getImageMode(this.node.getAttribute('mode')))
39
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
40
+ .onComplete(e => eventHandler(e, 'complete', this.node))
41
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
42
+ // TODO: 临时改为申明式,后续等鸿蒙修复modify设置失败的bug后删除该申明
43
+ .borderRadius({
44
+ topLeft: this.node._st.hmStyle.borderTopLeftRadius,
45
+ topRight: this.node._st.hmStyle.borderTopRightRadius,
46
+ bottomLeft: this.node._st.hmStyle.borderBottomLeftRadius,
47
+ bottomRight: this.node._st.hmStyle.borderBottomRightRadius
48
+ })
49
+ }
30
50
  }