@tarojs/plugin-platform-harmony-ets 4.0.0-beta.37 → 4.0.0-beta.39

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.
@@ -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 commonStyleModify from './style'
3
+ import commonStyleModify, { rowModify, columnModify } from './style'
4
4
  import { FlexManager } from './utils/flexManager'
5
5
  import { shouldBindEvent, getNodeThresholds } from './utils/helper'
6
6
 
7
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
@@ -126,24 +127,27 @@ export struct TaroCheckboxGroup {
126
127
  }
127
128
 
128
129
  build() {
129
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
130
- Row() {
130
+ if (!isUndefined(this.node._st.hmStyle.flexWrap)) {
131
+ Flex(FlexManager.flexOptions(this.node)) {
131
132
  this.createLazyChildren(this.node)
132
133
  }
133
134
  .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
134
135
  .defaultEvent()
135
136
  .visibleChangeEvent()
136
- .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
137
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
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()
138
144
  } else {
139
145
  Column() {
140
146
  this.createLazyChildren(this.node)
141
147
  }
142
- .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
148
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
143
149
  .defaultEvent()
144
150
  .visibleChangeEvent()
145
- .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
146
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
147
151
  }
148
152
  }
149
153
  }
@@ -1,11 +1,13 @@
1
1
  import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
- import commonStyleModify from './style'
3
+ import commonStyleModify, { rowModify, columnModify } from './style'
4
+
4
5
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
5
6
  import { FlexManager } from './utils/flexManager'
6
7
  import { shouldBindEvent, getNodeThresholds } from './utils/helper'
7
8
 
8
9
  import type { TaroAny, TaroFormElement } from '@tarojs/runtime'
10
+ import { isUndefined } from '@tarojs/shared'
9
11
 
10
12
  @Component
11
13
  export default struct TaroForm {
@@ -22,8 +24,8 @@ export default struct TaroForm {
22
24
  }
23
25
 
24
26
  build() {
25
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
26
- Row() {
27
+ if (!isUndefined(this.node._st.hmStyle.flexWrap)) {
28
+ Flex(FlexManager.flexOptions(this.node)) {
27
29
  this.createLazyChildren(this.node)
28
30
  }
29
31
  .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
@@ -33,21 +35,28 @@ export default struct TaroForm {
33
35
  this.node._nodeInfo.areaInfo = res[1]
34
36
  }))
35
37
  .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
36
- .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
37
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
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))
38
49
  } else {
39
50
  Column() {
40
51
  this.createLazyChildren(this.node)
41
52
  }
42
- .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
53
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
43
54
  .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
44
55
  .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
45
56
  .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
46
57
  this.node._nodeInfo.areaInfo = res[1]
47
58
  }))
48
59
  .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
49
- .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
50
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
51
60
  }
52
61
  }
53
62
  }
@@ -1,11 +1,13 @@
1
1
  import { Current, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, getPageScrollerOrNode, AREA_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
- import commonStyleModify from './style'
3
+ import commonStyleModify, { rowModify, columnModify } from './style'
4
+
4
5
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
5
6
  import { FlexManager } from './utils/flexManager'
6
7
  import { shouldBindEvent, getNodeThresholds } from './utils/helper'
7
8
 
8
9
  import type { TaroLabelElement, TaroElement, TaroAny, TaroRadioElement, TaroCheckboxElement } from '@tarojs/runtime'
10
+ import { isUndefined } from '@tarojs/shared'
9
11
 
10
12
  function handleTargetChange (id: string) {
11
13
  const taro: TaroAny = Current.taro
@@ -48,8 +50,9 @@ export default struct TaroLabel {
48
50
  }
49
51
 
50
52
  build() {
51
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
52
- Row() {
53
+
54
+ if (!isUndefined(this.node._st.hmStyle.flexWrap)) {
55
+ Flex(FlexManager.flexOptions(this.node)) {
53
56
  this.createLazyChildren(this.node)
54
57
  }
55
58
  .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
@@ -65,13 +68,28 @@ export default struct TaroLabel {
65
68
  this.node._nodeInfo.areaInfo = res[1]
66
69
  }))
67
70
  .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
68
- .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
69
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
71
+ } else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
72
+ Row() {
73
+ this.createLazyChildren(this.node)
74
+ }
75
+ .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
76
+ .onClick((e: ClickEvent) => {
77
+ const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
78
+ const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
79
+
80
+ handleTargetChange(id)
81
+ eventHandler(e, 'click', this.node)
82
+ })
83
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
84
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
85
+ this.node._nodeInfo.areaInfo = res[1]
86
+ }))
87
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
70
88
  } else {
71
89
  Column() {
72
90
  this.createLazyChildren(this.node)
73
91
  }
74
- .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
92
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
75
93
  .onClick((e: ClickEvent) => {
76
94
  const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
77
95
  const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
@@ -84,8 +102,6 @@ export default struct TaroLabel {
84
102
  this.node._nodeInfo.areaInfo = res[1]
85
103
  }))
86
104
  .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
87
- .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
88
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
89
105
  }
90
106
  }
91
107
  }
@@ -1,7 +1,9 @@
1
1
  import type { TaroAny, TaroMovableAreaElement, TaroMovableViewElement } from '@tarojs/runtime'
2
- import { rowModify, columnModify } from './style'
2
+
3
+ import commonStyleModify, { rowModify, columnModify } from './style'
3
4
 
4
5
  import { FlexManager } from './utils/flexManager'
6
+ import { isUndefined } from '@tarojs/shared'
5
7
 
6
8
  @Component
7
9
  export default struct TaroMovableArea {
@@ -17,13 +19,45 @@ export default struct TaroMovableArea {
17
19
  }
18
20
 
19
21
  build() {
20
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
22
+ if (!isUndefined(this.node._st.hmStyle.flexWrap)) {
23
+ Flex(FlexManager.flexOptions(this.node)) {
24
+ this.createLazyChildren(this.node)
25
+ }
26
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
27
+ .clip(true)
28
+ .onAreaChange((oldValue: Area, newValue: Area) => {
29
+ this.node.childNodes.forEach(item => {
30
+ if(item.nodeName === 'MOVABLE-VIEW') {
31
+ ;(item as TaroMovableViewElement).area = {
32
+ w: Number( newValue.width),
33
+ h: Number(newValue.height)
34
+ }
35
+ }
36
+ })
37
+ })
38
+ .gesture(
39
+ PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
40
+ this.node.childNodes.forEach(item => {
41
+ if(item.nodeName === 'MOVABLE-VIEW') {
42
+ ;(item as TaroMovableViewElement).startScale()
43
+ }
44
+ })
45
+ }).onActionUpdate((event) => {
46
+ const scaleArea = this.node.getAttribute('scaleArea')
47
+ if (scaleArea) {
48
+ this.node.childNodes.forEach(item => {
49
+ if(item.nodeName === 'MOVABLE-VIEW') {
50
+ ;(item as TaroMovableViewElement).doScale(event.scale)
51
+ }
52
+ })
53
+ }
54
+ })
55
+ )
56
+ } else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
21
57
  Row() {
22
58
  this.createLazyChildren(this.node)
23
59
  }
24
60
  .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
25
- .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
26
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
27
61
  .clip(true)
28
62
  .onAreaChange((oldValue: Area, newValue: Area) => {
29
63
  this.node.childNodes.forEach(item => {
@@ -58,8 +92,6 @@ export default struct TaroMovableArea {
58
92
  this.createLazyChildren(this.node)
59
93
  }
60
94
  .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
61
- .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
62
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
63
95
  .clip(true)
64
96
  .onAreaChange((oldValue: Area, newValue: Area) => {
65
97
  this.node.childNodes.forEach(item => {
@@ -1,8 +1,9 @@
1
1
  import type { TaroAny, TaroMovableViewElement } from '@tarojs/runtime'
2
2
 
3
- import { rowModify, columnModify } from './style'
3
+ import commonStyleModify, { rowModify, columnModify } from './style'
4
4
 
5
5
  import { FlexManager } from './utils/flexManager'
6
+ import { isUndefined } from '@tarojs/shared'
6
7
 
7
8
  @Component
8
9
  export default struct TaroMovableView {
@@ -19,21 +20,21 @@ export default struct TaroMovableView {
19
20
 
20
21
  build() {
21
22
  Stack() {
22
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node)
23
- .direction !== FlexDirection.Column) {
23
+ if (!isUndefined(this.node._st.hmStyle.flexWrap)) {
24
+ Flex(FlexManager.flexOptions(this.node)) {
25
+ this.createLazyChildren(this.node)
26
+ }
27
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
28
+ } else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
24
29
  Row() {
25
30
  this.createLazyChildren(this.node)
26
31
  }
27
32
  .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
28
- .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
29
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
30
33
  } else {
31
34
  Column() {
32
35
  this.createLazyChildren(this.node)
33
36
  }
34
37
  .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
35
- .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
36
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
37
38
  }
38
39
  }
39
40
  .translate({ x: this.node.position.x, y: this.node.position.y })
@@ -311,22 +311,22 @@ export default struct TaroPicker {
311
311
  }
312
312
 
313
313
  build() {
314
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
314
+ if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
315
315
  Row() {
316
316
  this.createLazyChildren(this.node)
317
317
  }
318
318
  .defaultEvent()
319
319
  .visibleChangeEvent()
320
- .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
321
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
320
+ .alignItems(FlexManager.alignItems<VerticalAlign>(this.node))
321
+ .justifyContent(FlexManager.justifyContent(this.node))
322
322
  } else {
323
323
  Column() {
324
324
  this.createLazyChildren(this.node)
325
325
  }
326
326
  .defaultEvent()
327
327
  .visibleChangeEvent()
328
- .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
329
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
328
+ .alignItems(FlexManager.alignItems<HorizontalAlign>(this.node))
329
+ .justifyContent(FlexManager.justifyContent(this.node))
330
330
  }
331
331
  }
332
332
  }
@@ -1,11 +1,12 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
2
2
 
3
- import commonStyleModify from './style'
3
+ import commonStyleModify, { rowModify, columnModify } from './style'
4
4
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
5
5
  import { FlexManager } from './utils/flexManager'
6
6
  import { shouldBindEvent, getNodeThresholds } from './utils/helper'
7
7
 
8
8
  import { TaroEvent, TaroAny, HarmonyType, TaroRadioGroupElement, TaroRadioElement } from '@tarojs/runtime'
9
+ import { isUndefined } from '@tarojs/shared'
9
10
 
10
11
  interface RadioAttrs {
11
12
  radioStyle?: HarmonyType.RadioStyle
@@ -128,24 +129,27 @@ export struct TaroRadioGroup {
128
129
  }
129
130
 
130
131
  build() {
131
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
132
- Row() {
132
+ if (!isUndefined(this.node._st.hmStyle.flexWrap)) {
133
+ Flex(FlexManager.flexOptions(this.node)) {
133
134
  this.createLazyChildren(this.node)
134
135
  }
135
136
  .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
136
137
  .defaultEvent()
137
138
  .visibleChangeEvent()
138
- .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
139
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
139
+ } else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
140
+ Row() {
141
+ this.createLazyChildren(this.node)
142
+ }
143
+ .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
144
+ .defaultEvent()
145
+ .visibleChangeEvent()
140
146
  } else {
141
147
  Column() {
142
148
  this.createLazyChildren(this.node)
143
149
  }
144
- .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
150
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
145
151
  .defaultEvent()
146
152
  .visibleChangeEvent()
147
- .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
148
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
149
153
  }
150
154
  }
151
155
  }
@@ -85,8 +85,6 @@ export default struct TaroScrollView {
85
85
  .onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
86
86
  this.node._nodeInfo._scroll = areaResult
87
87
  }, this.node, ['scroll', 'scrollstart', 'scrollend']))
88
- .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
89
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
90
88
  .flexGrow(0).flexShrink(0)
91
89
  } else {
92
90
  Column() {
@@ -102,8 +100,6 @@ export default struct TaroScrollView {
102
100
  .onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
103
101
  this.node._nodeInfo._scroll = areaResult
104
102
  }, this.node, ['scroll', 'scrollstart', 'scrollend']))
105
- .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
106
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
107
103
  .flexGrow(0).flexShrink(0)
108
104
  }
109
105
  }
@@ -3,6 +3,7 @@ import { isUndefined } from '@tarojs/shared'
3
3
  import { computeBackgroundPosition } from './utils'
4
4
  import { getNormalAttributes } from './utils/helper'
5
5
  import { isMaxWidthView } from './utils/styles'
6
+ import { FlexManager } from './utils/flexManager.ets'
6
7
 
7
8
  class TextStyleModify implements AttributeModifier<TextAttribute> {
8
9
  initStyle?: TaroStyleType
@@ -103,7 +104,7 @@ class PseudoStyleModify implements AttributeModifier<CommonAttribute> {
103
104
 
104
105
  class RowStyleModify extends CommonStyleModify {
105
106
 
106
- applyNormalAttribute(instance: CommonAttribute): void {
107
+ applyNormalAttribute(instance: RowAttribute): void {
107
108
  if (this.style) {
108
109
  setNormalAttributeIntoInstance(instance, this.style, this.node)
109
110
  instance.constraintSize({
@@ -112,6 +113,10 @@ class RowStyleModify extends CommonStyleModify {
112
113
  minHeight: this.style.minHeight,
113
114
  maxHeight: this.style.maxHeight
114
115
  })
116
+ if (this.node) {
117
+ instance.alignItems(FlexManager.alignItems<VerticalAlign>(this.node))
118
+ instance.justifyContent(FlexManager.justifyContent(this.node))
119
+ }
115
120
  }
116
121
 
117
122
  setAnimationAttributeIntoInstance(instance, this.overwriteStyle, this.style || {})
@@ -119,7 +124,7 @@ class RowStyleModify extends CommonStyleModify {
119
124
  }
120
125
 
121
126
  class ColumnStyleModify extends CommonStyleModify {
122
- applyNormalAttribute(instance: CommonAttribute): void {
127
+ applyNormalAttribute(instance: ColumnAttribute): void {
123
128
  if (this.style) {
124
129
  setNormalAttributeIntoInstance(instance, this.style, this.node)
125
130
  instance.constraintSize({
@@ -128,6 +133,10 @@ class ColumnStyleModify extends CommonStyleModify {
128
133
  minHeight: this.style.minHeight || this.style.height,
129
134
  maxHeight: this.style.maxHeight
130
135
  })
136
+ if (this.node) {
137
+ instance.alignItems(FlexManager.alignItems<HorizontalAlign>(this.node))
138
+ instance.justifyContent(FlexManager.justifyContent(this.node))
139
+ }
131
140
  }
132
141
 
133
142
  setAnimationAttributeIntoInstance(instance, this.overwriteStyle, this.style || {})
@@ -192,6 +201,9 @@ export function setSpecialTextAttributeIntoInstance(instance: TextAttribute, sty
192
201
  if (!isUndefined(style.textOverflow)) {
193
202
  instance.textOverflow(style.textOverflow)
194
203
  }
204
+ if (!isUndefined(style.whiteSpace) && style.whiteSpace === 'nowrap') {
205
+ instance.maxLines(1)
206
+ }
195
207
  if (!isUndefined(style.WebkitLineClamp)) {
196
208
  instance.maxLines(style.WebkitLineClamp)
197
209
  }
@@ -57,7 +57,8 @@ export default struct TaroText {
57
57
  }
58
58
  } else {
59
59
  Text(this.node.textContent) {
60
- if (this.node.childNodes.length > 1) {
60
+ // text 下还有标签
61
+ if (this.node.childNodes.length > 1 || ((this.node.childNodes[0] && this.node.childNodes[0] as TaroElement)?.nodeType === NodeType.ELEMENT_NODE)) {
61
62
  ForEach(this.node.childNodes, (item: TaroElement) => {
62
63
  createTextChildNode(item, getSpanVerticalAlign(this.node.hmStyle?.verticalAlign))
63
64
  }, (item: TaroElement) => item._nid)
@@ -1,14 +1,13 @@
1
- import type { TaroElement } from '@tarojs/runtime'
1
+ import type { TaroElement, HarmonyStyle } from '@tarojs/runtime'
2
2
  import { isUndefined } from '@tarojs/shared'
3
3
  import { getNormalAttributes } from './styles.ets'
4
4
 
5
5
  interface IFlexOptions {
6
6
  direction: FlexDirection,
7
7
  justifyContent: FlexAlign,
8
- alignItems: VerticalAlign | HorizontalAlign,
9
- // Row 和 Column 不支持下面两个属性
10
- // wrap: FlexWrap,
11
- // alignContent: FlexAlignContent
8
+ alignItems: ItemAlign,
9
+ wrap?: FlexWrap,
10
+ alignContent?: FlexAlign
12
11
  }
13
12
 
14
13
  class FlexManager {
@@ -39,22 +38,45 @@ class FlexManager {
39
38
  }
40
39
 
41
40
  static flexOptions (node: TaroElement): IFlexOptions {
42
- const hmStyle = getNormalAttributes(node) || {}
41
+ const hmStyle: HarmonyStyle = getNormalAttributes(node) || {}
43
42
  const isFlex = FlexManager.isFlexNode(node)
44
- const justifyContent: FlexAlign = isFlex ? (isUndefined(hmStyle.justifyContent) ? FlexAlign.Start : hmStyle.justifyContent) : FlexAlign.Start
45
-
46
43
  let flexDirection = hmStyle.flexDirection
47
44
  if (!flexDirection && flexDirection !== 0) {
48
45
  flexDirection = hmStyle.display === 'flex' ? FlexDirection.Row : FlexDirection.Column
49
46
  }
50
47
 
51
- const alignItems = isFlex ? FlexManager.convertFlexAlignItemsToColumnOrRow(flexDirection, hmStyle.alignItems) : HorizontalAlign.Start
52
-
53
48
  return {
54
- alignItems,
55
- justifyContent,
49
+ alignItems: isFlex ? (isUndefined(hmStyle.alignItems) ? ItemAlign.Start : hmStyle.alignItems) : ItemAlign.Start,
50
+ justifyContent: isFlex ? (isUndefined(hmStyle.justifyContent) ? FlexAlign.Start : hmStyle.justifyContent) : FlexAlign.Start,
56
51
  direction: flexDirection,
52
+ wrap: isFlex ? hmStyle.flexWrap: FlexWrap.NoWrap,
53
+ alignContent: isFlex ? hmStyle.alignContent: FlexAlign.Start
54
+ }
55
+ }
56
+
57
+ static direction (node: TaroElement): FlexDirection {
58
+ const hmStyle: HarmonyStyle = getNormalAttributes(node)
59
+ let flexDirection = hmStyle.flexDirection
60
+ if (!flexDirection && flexDirection !== 0) {
61
+ flexDirection = hmStyle.display === 'flex' ? FlexDirection.Row : FlexDirection.Column
62
+ }
63
+ return flexDirection
64
+ }
65
+
66
+ static alignItems<T> (node: TaroElement): T {
67
+ const hmStyle: HarmonyStyle = getNormalAttributes(node)
68
+ const isFlex = FlexManager.isFlexNode(node)
69
+ let flexDirection = hmStyle.flexDirection
70
+ if (!flexDirection && flexDirection !== 0) {
71
+ flexDirection = hmStyle.display === 'flex' ? FlexDirection.Row : FlexDirection.Column
57
72
  }
73
+ return (isFlex ? FlexManager.convertFlexAlignItemsToColumnOrRow(flexDirection, hmStyle.alignItems) : HorizontalAlign.Start) as T
74
+ }
75
+
76
+ static justifyContent (node: TaroElement): FlexAlign {
77
+ const hmStyle: HarmonyStyle = getNormalAttributes(node)
78
+ const isFlex = FlexManager.isFlexNode(node)
79
+ return isFlex ? (isUndefined(hmStyle.justifyContent) ? FlexAlign.Start : hmStyle.justifyContent) : FlexAlign.Start
58
80
  }
59
81
  }
60
82
 
@@ -1,12 +1,13 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
- import { rowModify, columnModify } from './style'
3
+ import commonStyleModify, { rowModify, columnModify } from './style'
4
4
  import PseduoChildren from './pseudo'
5
5
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
6
6
  import { FlexManager } from './utils/flexManager'
7
7
  import { getNodeThresholds, shouldBindEvent } from './utils/helper'
8
8
 
9
9
  import type { TaroViewElement, TaroAny } from '@tarojs/runtime'
10
+ import { isUndefined } from '@tarojs/shared'
10
11
 
11
12
  @Component
12
13
  export default struct TaroView {
@@ -22,7 +23,22 @@ export default struct TaroView {
22
23
  }
23
24
 
24
25
  build () {
25
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
26
+ if (!isUndefined(this.node._st.hmStyle.flexWrap)) {
27
+ Flex(FlexManager.flexOptions(this.node)) {
28
+ if (this.node._pseudo_before || this.node._pseudo_after) {
29
+ PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
30
+ } else {
31
+ this.createLazyChildren(this.node)
32
+ }
33
+ }
34
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
35
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
36
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
37
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
38
+ this.node._nodeInfo.areaInfo = res[1]
39
+ }))
40
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
41
+ } else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
26
42
  Row() {
27
43
  if (this.node._pseudo_before || this.node._pseudo_after) {
28
44
  PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
@@ -37,8 +53,6 @@ export default struct TaroView {
37
53
  this.node._nodeInfo.areaInfo = res[1]
38
54
  }))
39
55
  .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
40
- .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
41
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
42
56
  } else {
43
57
  Column() {
44
58
  if (this.node._pseudo_before || this.node._pseudo_after) {
@@ -54,8 +68,6 @@ export default struct TaroView {
54
68
  this.node._nodeInfo.areaInfo = res[1]
55
69
  }))
56
70
  .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
57
- .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
58
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
59
71
  }
60
72
  }
61
73
  }
@@ -1,5 +1,4 @@
1
1
  import { TaroDocument } from '../dom/document'
2
- import { FixedLayer } from '../dom/element/normal'
3
2
  import { window } from './window'
4
3
 
5
4
  function createDocument (): TaroDocument {
@@ -32,9 +31,6 @@ function createDocument (): TaroDocument {
32
31
  doc.documentElement = html
33
32
  doc.head = head
34
33
  doc.body = body
35
-
36
- // Fixed Layer
37
- doc.fixedLayer = new FixedLayer()
38
34
 
39
35
  return doc
40
36
  }
@@ -17,11 +17,6 @@ class TaroDocument extends TaroNode {
17
17
  public cookie = ''
18
18
  private _win: Window
19
19
 
20
- // 浮动层
21
- public fixedLayer: FixedLayer
22
- // 浮层的父节点关系
23
- public layerParents: Record<string, Record<string, true>> = {}
24
-
25
20
  constructor(window: Window) {
26
21
  super('#document', NodeType.DOCUMENT_NODE)
27
22
  this._win = window
@@ -1,8 +1,8 @@
1
1
  import { eventSource } from '@tarojs/runtime/dist/runtime.esm'
2
2
  import { EMPTY_OBJ, toCamelCase } from '@tarojs/shared'
3
3
 
4
- import { document } from '../../bom/document'
5
4
  import { ATTRIBUTES_CALLBACK_TRIGGER_MAP, ID } from '../../constant'
5
+ import { Current } from '../../current'
6
6
  import { findChildNodeWithDFS } from '../../utils'
7
7
  import { initComponentNodeInfo, triggerAttributesCallback } from '../../utils/info'
8
8
  import { bindAnimation } from '../bind'
@@ -242,6 +242,24 @@ export class TaroElement<
242
242
  }
243
243
  }
244
244
 
245
+ get currentLayerNode () {
246
+ if (typeof Current.page.tabBarCurrentIndex !== 'undefined') {
247
+ // Tabbar
248
+ return Current.page.layerNode[Current.page.tabBarCurrentIndex]
249
+ } else {
250
+ return Current.page.layerNode
251
+ }
252
+ }
253
+
254
+ get currentLayerParents () {
255
+ if (typeof Current.page.tabBarCurrentIndex !== 'undefined') {
256
+ // Tabbar
257
+ return Current.page.layerParents[Current.page.tabBarCurrentIndex]
258
+ } else {
259
+ return Current.page.layerParents
260
+ }
261
+ }
262
+
245
263
  // 设置渲染层级,0为正常层级,大于0为固定层级
246
264
  // 1、appendChild的时候会判断是否需要设置层级
247
265
  // 2、taro-react的setProperty,在处理属性变化的时候,会判断是否需要设置层级
@@ -250,20 +268,23 @@ export class TaroElement<
250
268
  if (!this.parentNode) return // 没有父节点,不需要设置层级关系
251
269
  this._nodeInfo.layer = value
252
270
 
271
+ const currentLayerNode = this.currentLayerNode
272
+ const currentLayerParents = this.currentLayerParents
273
+ if (!currentLayerNode || !currentLayerParents) return
253
274
  if (value > 0) {
254
275
  // 插入到固定浮层
255
- document.fixedLayer.childNodes.push(this)
256
- document.fixedLayer.notifyDataAdd(document.fixedLayer.childNodes.length - 1)
276
+ currentLayerNode.childNodes.push(this)
277
+ currentLayerNode.notifyDataAdd(currentLayerNode.childNodes.length - 1)
257
278
  // 绑定祖先的节点id,建立关系,方便在祖先卸载(removeChild)的时候,能够找到该节点使其卸载
258
279
  const _parentRecord = {}
259
280
  generateLayerParentIds(_parentRecord, this)
260
- document.layerParents[this._nid] = _parentRecord
281
+ currentLayerParents[this._nid] = _parentRecord
261
282
  } else {
262
- const idx = document.fixedLayer.childNodes.findIndex(n => n._nid === this._nid)
263
- document.fixedLayer.childNodes.splice(idx, 1)
264
- document.fixedLayer.notifyDataDelete(idx)
283
+ const idx = currentLayerNode.childNodes.findIndex(n => n._nid === this._nid)
284
+ currentLayerNode.childNodes.splice(idx, 1)
285
+ currentLayerNode.notifyDataDelete(idx)
265
286
 
266
- delete document.layerParents[this._nid]
287
+ delete currentLayerParents[this._nid]
267
288
  }
268
289
 
269
290
  if (this.parentNode) {
@@ -278,17 +299,18 @@ export class TaroElement<
278
299
  this.setLayer(1)
279
300
  }
280
301
  } else {
281
- // 识别document.layerParents里面是否有需要移除的固定元素
302
+ const currentLayerParents = this.currentLayerParents
303
+ if (!currentLayerParents) return
304
+ // 识别Current.page.layerParents里面是否有需要移除的固定元素
282
305
  if (this._nodeInfo?.layer > 0) {
283
- // @ts-ignore
284
- delete document.layerParents[this._nid]
306
+ delete currentLayerParents[this._nid]
285
307
  this.setLayer(0)
286
308
  } else {
287
- Object.keys(document.layerParents).forEach(fixedId => {
288
- const parentIds = document.layerParents[fixedId]
309
+ Object.keys(currentLayerParents).forEach(fixedId => {
310
+ const parentIds =currentLayerParents[fixedId]
289
311
  if (parentIds[this._nid]) {
290
312
  // 需要移除fixedId
291
- delete document.layerParents[fixedId]
313
+ delete currentLayerParents[fixedId]
292
314
  const fixedNode = eventSource.get(fixedId) as unknown as TaroElement
293
315
  if (fixedNode) {
294
316
  fixedNode.setLayer(0)
@@ -72,16 +72,7 @@ class TaroSwiperItemElement extends TaroElement<SwiperItemProps>{
72
72
  }
73
73
  }
74
74
 
75
- // Fixed浮层节点树
76
- @Observed
77
- class FixedLayer extends TaroElement {
78
- constructor() {
79
- super('View')
80
- }
81
- }
82
-
83
75
  export {
84
- FixedLayer,
85
76
  TaroButtonElement,
86
77
  TaroIconElement,
87
78
  TaroImageElement,
@@ -5,6 +5,7 @@ export interface HarmonyStyle extends TaroStyleType {
5
5
  textAlign?: TextAlign
6
6
  textOverflow?: HarmonyType.Overflow
7
7
  WebkitLineClamp?: number
8
+ whiteSpace?: string
8
9
  letterSpacing?: number | string
9
10
  verticalAlign?: Alignment
10
11
  lineHeight?: Length
@@ -112,6 +113,7 @@ export interface TaroTextStyleType {
112
113
  textAlign?: TextAlign
113
114
  textOverflow?: HarmonyType.Overflow
114
115
  WebkitLineClamp?: number
116
+ whiteSpace?: string
115
117
  letterSpacing?: number | string
116
118
  verticalAlign?: Alignment
117
119
  lineHeight?: string | number | Resource
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/plugin-platform-harmony-ets",
3
- "version": "4.0.0-beta.37",
3
+ "version": "4.0.0-beta.39",
4
4
  "description": "OpenHarmony & 鸿蒙系统插件",
5
5
  "author": "O2Team",
6
6
  "homepage": "https://gitee.com/openharmony-sig/taro",
@@ -25,13 +25,13 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "webpack-sources": "^3.2.3",
28
- "@tarojs/helper": "4.0.0-beta.37",
29
- "@tarojs/runner-utils": "4.0.0-beta.37",
30
- "@tarojs/service": "4.0.0-beta.37",
31
- "@tarojs/components": "4.0.0-beta.37",
32
- "@tarojs/shared": "4.0.0-beta.37",
33
- "@tarojs/taro": "4.0.0-beta.37",
34
- "@tarojs/runtime": "4.0.0-beta.37"
28
+ "@tarojs/components": "4.0.0-beta.39",
29
+ "@tarojs/helper": "4.0.0-beta.39",
30
+ "@tarojs/runtime": "4.0.0-beta.39",
31
+ "@tarojs/shared": "4.0.0-beta.39",
32
+ "@tarojs/taro": "4.0.0-beta.39",
33
+ "@tarojs/runner-utils": "4.0.0-beta.39",
34
+ "@tarojs/service": "4.0.0-beta.39"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@rollup/plugin-commonjs": "^25.0.7",
@@ -44,7 +44,7 @@
44
44
  "solid-js": "^1.8.16",
45
45
  "tslib": "^2.4.0",
46
46
  "typescript": "^4.8.2",
47
- "rollup-plugin-copy": "4.0.0-beta.37"
47
+ "rollup-plugin-copy": "4.0.0-beta.39"
48
48
  },
49
49
  "scripts": {
50
50
  "prebuild": "rimraf ./dist",