@tarojs/plugin-platform-harmony-ets 4.0.0-beta.17 → 4.0.0-beta.19

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 (41) hide show
  1. package/dist/components-harmony-ets/button.ets +32 -29
  2. package/dist/components-harmony-ets/checkbox.ets +2 -2
  3. package/dist/components-harmony-ets/form.ets +28 -25
  4. package/dist/components-harmony-ets/icon.ets +18 -16
  5. package/dist/components-harmony-ets/image.ets +13 -11
  6. package/dist/components-harmony-ets/innerHtml.ets +1 -1
  7. package/dist/components-harmony-ets/input.ets +1 -1
  8. package/dist/components-harmony-ets/label.ets +39 -36
  9. package/dist/components-harmony-ets/movableArea.ets +1 -1
  10. package/dist/components-harmony-ets/movableView.ets +1 -1
  11. package/dist/components-harmony-ets/picker.ets +1 -1
  12. package/dist/components-harmony-ets/progress.ets +1 -1
  13. package/dist/components-harmony-ets/pseudo.ets +20 -19
  14. package/dist/components-harmony-ets/radio.ets +2 -2
  15. package/dist/components-harmony-ets/richText.ets +10 -31
  16. package/dist/components-harmony-ets/scrollView.ets +54 -43
  17. package/dist/components-harmony-ets/slider.ets +1 -1
  18. package/dist/components-harmony-ets/style.ets +40 -6
  19. package/dist/components-harmony-ets/swiper.ets +19 -17
  20. package/dist/components-harmony-ets/switch.ets +1 -1
  21. package/dist/components-harmony-ets/text.ets +13 -10
  22. package/dist/components-harmony-ets/textArea.ets +1 -1
  23. package/dist/components-harmony-ets/utils/index.ts +54 -1
  24. package/dist/components-harmony-ets/utils/styles.ets +8 -2
  25. package/dist/components-harmony-ets/video.ets +3 -1
  26. package/dist/components-harmony-ets/view.ets +38 -27
  27. package/dist/components-harmony-ets/webView.ets +34 -33
  28. package/dist/index.d.ts +149 -0
  29. package/dist/index.js +8 -2
  30. package/dist/index.js.map +1 -1
  31. package/dist/runtime-ets/dom/cssNesting.ts +24 -37
  32. package/dist/runtime-ets/dom/element/element.ts +2 -10
  33. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +19 -0
  34. package/dist/runtime-ets/dom/stylesheet/index.ts +13 -0
  35. package/dist/runtime-ets/dom/stylesheet/type.ts +11 -3
  36. package/dist/runtime-ets/dom/stylesheet/util.ts +17 -10
  37. package/dist/runtime-utils.d.ts +825 -0
  38. package/dist/runtime.d.ts +1 -0
  39. package/index.js +3 -1
  40. package/package.json +8 -8
  41. package/types/index.d.ts +4 -0
@@ -97,38 +97,41 @@ function getButtonMinHeight (node: TaroButtonElement): string | number | undefin
97
97
  @Component
98
98
  export default struct TaroButton {
99
99
  @ObjectLink node: TaroButtonElement
100
+
100
101
  build() {
101
- Button({ stateEffect: !this.node._attrs.disabled }) {
102
- Row() {
103
- if (this.node._attrs.loading) {
104
- LoadingProgress()
105
- .width(20).height(20)
106
- .color(getThemeAttributes(this.node).color)
102
+ if (this.node?.hmStyle?.display !== 'none') {
103
+ Button({ stateEffect: !this.node._attrs.disabled }) {
104
+ Row() {
105
+ if (this.node._attrs.loading) {
106
+ LoadingProgress()
107
+ .width(20).height(20)
108
+ .color(getThemeAttributes(this.node).color)
109
+ }
110
+ createLazyChildren(this.node)
107
111
  }
108
- createLazyChildren(this.node)
109
112
  }
113
+ .themeStyles(getThemeAttributes(this.node))
114
+ .attributeModifier(commonStyleModify.setNode(this.node))
115
+ .constraintSize({
116
+ minWidth: this.node.hmStyle?.minWidth || getButtonMinWidth(this.node),
117
+ minHeight: this.node.hmStyle?.minHeight || getButtonMinHeight(this.node),
118
+ maxWidth: this.node.hmStyle?.maxWidth,
119
+ maxHeight: this.node.hmStyle?.maxHeight,
120
+ })
121
+ .type(ButtonType.Normal)
122
+ .onClick((e: ClickEvent) => {
123
+ if (this.node._attrs.formType && ['submit', 'reset'].includes(this.node._attrs.formType)) {
124
+ const eventName = this.node._attrs.formType + '-btn'
125
+ const event: TaroEvent = createTaroEvent(eventName, {}, this.node)
126
+ eventHandler(event, eventName, this.node)
127
+ }
128
+ eventHandler(e, 'click', this.node)
129
+ })
130
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
131
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
132
+ this.node._nodeInfo.areaInfo = res[1]
133
+ }))
134
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
110
135
  }
111
- .themeStyles(getThemeAttributes(this.node))
112
- .attributeModifier(commonStyleModify.setNode(this.node))
113
- .constraintSize({
114
- minWidth: this.node.hmStyle?.minWidth || getButtonMinWidth(this.node),
115
- minHeight: this.node.hmStyle?.minHeight || getButtonMinHeight(this.node),
116
- maxWidth: this.node.hmStyle?.maxWidth,
117
- maxHeight: this.node.hmStyle?.maxHeight,
118
- })
119
- .type(ButtonType.Normal)
120
- .onClick((e: ClickEvent) => {
121
- if (this.node._attrs.formType && ['submit', 'reset'].includes(this.node._attrs.formType)) {
122
- const eventName = this.node._attrs.formType + '-btn'
123
- const event: TaroEvent = createTaroEvent(eventName, {}, this.node)
124
- eventHandler(event, eventName, this.node)
125
- }
126
- eventHandler(e, 'click', this.node)
127
- })
128
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
129
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
130
- this.node._nodeInfo.areaInfo = res[1]
131
- }))
132
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
133
136
  }
134
137
  }
@@ -46,7 +46,7 @@ export struct TaroCheckbox {
46
46
  }
47
47
 
48
48
  build () {
49
- if (this.node) {
49
+ if (this.node && this.node?.hmStyle?.display !== 'none') {
50
50
  Stack() {
51
51
  Row() {
52
52
  Checkbox(getOptions(this.node))
@@ -121,7 +121,7 @@ export struct TaroCheckboxGroup {
121
121
  }
122
122
 
123
123
  build() {
124
- if (this.node) {
124
+ if (this.node && this.node?.hmStyle?.display !== 'none') {
125
125
  if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
126
126
  Row() {
127
127
  createLazyChildren(this.node)
@@ -11,33 +11,36 @@ import type { TaroAny, TaroFormElement } from '@tarojs/runtime'
11
11
  @Component
12
12
  export default struct TaroForm {
13
13
  @ObjectLink node: TaroFormElement
14
+
14
15
  build() {
15
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
16
- Row() {
17
- createLazyChildren(this.node)
16
+ if (this.node?.hmStyle?.display !== 'none') {
17
+ if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
18
+ Row() {
19
+ createLazyChildren(this.node)
20
+ }
21
+ .attributeModifier(commonStyleModify.setNode(this.node))
22
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
23
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
24
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
25
+ this.node._nodeInfo.areaInfo = res[1]
26
+ }))
27
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
28
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
29
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
30
+ } else {
31
+ Column() {
32
+ createLazyChildren(this.node)
33
+ }
34
+ .attributeModifier(commonStyleModify.setNode(this.node))
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
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
42
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
18
43
  }
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()))
22
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
23
- this.node._nodeInfo.areaInfo = res[1]
24
- }))
25
- .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
- } else {
29
- Column() {
30
- createLazyChildren(this.node)
31
- }
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()))
35
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
36
- this.node._nodeInfo.areaInfo = res[1]
37
- }))
38
- .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
44
  }
42
45
  }
43
46
  }
@@ -52,22 +52,24 @@ function getIconData (node: TaroIconElement): Resource | null {
52
52
  export default struct TaroIcon {
53
53
  @ObjectLink node: TaroIconElement
54
54
  build() {
55
- Image(getIconData(this.node))
56
- .objectFit(ImageFit.Contain)
57
- .fillColor(this.node._attrs.color || ICON_COLOR_MAP[this.node._attrs.type] || Color.Black)
58
- .attributeModifier(commonStyleModify.setNode(this.node))
59
- .size({
60
- width: convertNumber2VP(Number(this.node._attrs.size) || 23),
61
- height: convertNumber2VP(Number(this.node._attrs.size) || 23),
62
- })
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']))
67
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
68
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
69
- this.node._nodeInfo.areaInfo = res[1]
70
- }))
55
+ if (this.node?.hmStyle?.display !== 'none') {
56
+ Image(getIconData(this.node))
57
+ .objectFit(ImageFit.Contain)
58
+ .fillColor(this.node._attrs.color || ICON_COLOR_MAP[this.node._attrs.type] || Color.Black)
59
+ .attributeModifier(commonStyleModify.setNode(this.node))
60
+ .size({
61
+ width: convertNumber2VP(Number(this.node._attrs.size) || 23),
62
+ height: convertNumber2VP(Number(this.node._attrs.size) || 23),
63
+ })
64
+ .width(getNormalAttributes(this.node).width || convertNumber2PX(23))
65
+ .height(getNormalAttributes(this.node).height || convertNumber2PX(23))
66
+ .onComplete(e => eventHandler(e, 'complete', this.node))
67
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
68
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
69
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
70
+ this.node._nodeInfo.areaInfo = res[1]
71
+ }))
72
+ }
71
73
  }
72
74
  }
73
75
 
@@ -1,9 +1,9 @@
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
8
  function getImageMode (mode: string): ImageFit {
9
9
  switch (mode) {
@@ -21,14 +21,16 @@ export default struct TaroImage {
21
21
  @ObjectLink node: TaroImageElement
22
22
 
23
23
  build() {
24
- Image(this.node.getAttribute('src'))
25
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
26
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
27
- this.node._nodeInfo.areaInfo = res[1]
28
- }))
29
- .objectFit(getImageMode(this.node.getAttribute('mode')))
30
- .attributeModifier(commonStyleModify.setNode(this.node))
31
- .onComplete(e => eventHandler(e, 'complete', this.node))
32
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
24
+ if (this.node?.hmStyle?.display !== 'none') {
25
+ Image(this.node.getAttribute('src'))
26
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
27
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
28
+ this.node._nodeInfo.areaInfo = res[1]
29
+ }))
30
+ .objectFit(getImageMode(this.node.getAttribute('mode')))
31
+ .attributeModifier(commonStyleModify.setNode(this.node))
32
+ .onComplete(e => eventHandler(e, 'complete', this.node))
33
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
34
+ }
33
35
  }
34
36
  }
@@ -8,7 +8,7 @@ export default struct TaroInnerHtml {
8
8
  @ObjectLink node: TaroInnerHtmlElement
9
9
 
10
10
  build() {
11
- if (this.node.innerHTML) {
11
+ if (this.node?.hmStyle?.display !== 'none' && this.node.innerHTML) {
12
12
  createChildItem(htmlParser(this.node.innerHTML))
13
13
  }
14
14
  }
@@ -63,7 +63,7 @@ export default struct TaroInput {
63
63
  }
64
64
 
65
65
  build () {
66
- if (this.node) {
66
+ if (this.node && this.node?.hmStyle?.display !== 'none') {
67
67
  TextInput({ text: this.value, placeholder: this.node._attrs?.placeholder || '', controller: this.node.controller })
68
68
  .key(this.node._nid)
69
69
  .type(getInputType(this.node))
@@ -38,45 +38,48 @@ function handleTargetChange (id: string) {
38
38
  @Component
39
39
  export default struct TaroLabel {
40
40
  @ObjectLink node:TaroLabelElement
41
+
41
42
  build() {
42
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
43
- Row() {
44
- createLazyChildren(this.node)
45
- }
46
- .attributeModifier(commonStyleModify.setNode(this.node))
47
- .onClick((e: ClickEvent) => {
48
- const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
49
- const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
43
+ if (this.node?.hmStyle?.display !== 'none') {
44
+ if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
45
+ Row() {
46
+ createLazyChildren(this.node)
47
+ }
48
+ .attributeModifier(commonStyleModify.setNode(this.node))
49
+ .onClick((e: ClickEvent) => {
50
+ const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
51
+ const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
50
52
 
51
- handleTargetChange(id)
52
- eventHandler(e, 'click', this.node)
53
- })
54
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
55
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
56
- this.node._nodeInfo.areaInfo = res[1]
57
- }))
58
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
59
- .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
60
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
61
- } else {
62
- Column() {
63
- createLazyChildren(this.node)
64
- }
65
- .attributeModifier(commonStyleModify.setNode(this.node))
66
- .onClick((e: ClickEvent) => {
67
- const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
68
- const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
53
+ handleTargetChange(id)
54
+ eventHandler(e, 'click', this.node)
55
+ })
56
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
57
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
58
+ this.node._nodeInfo.areaInfo = res[1]
59
+ }))
60
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
61
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
62
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
63
+ } else {
64
+ Column() {
65
+ createLazyChildren(this.node)
66
+ }
67
+ .attributeModifier(commonStyleModify.setNode(this.node))
68
+ .onClick((e: ClickEvent) => {
69
+ const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
70
+ const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
69
71
 
70
- handleTargetChange(id)
71
- eventHandler(e, 'click', this.node)
72
- })
73
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
74
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
75
- this.node._nodeInfo.areaInfo = res[1]
76
- }))
77
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
78
- .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
79
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
72
+ handleTargetChange(id)
73
+ eventHandler(e, 'click', this.node)
74
+ })
75
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
76
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
77
+ this.node._nodeInfo.areaInfo = res[1]
78
+ }))
79
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
80
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
81
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
82
+ }
80
83
  }
81
84
  }
82
85
  }
@@ -31,7 +31,7 @@ export default struct TaroMovableArea {
31
31
  @ObjectLink node: TaroMovableAreaElement
32
32
 
33
33
  build() {
34
- if (this.node) {
34
+ if (this.node && this.node.hmStyle?.display !== 'none') {
35
35
  if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
36
36
  Row() {
37
37
  createLazyChildren(this.node)
@@ -32,7 +32,7 @@ export default struct TaroMovableView {
32
32
  @ObjectLink node: TaroMovableViewElement
33
33
 
34
34
  build() {
35
- if (this.node) {
35
+ if (this.node && this.node.hmStyle?.display !== 'none') {
36
36
  Stack() {
37
37
  if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node)
38
38
  .direction !== FlexDirection.Column) {
@@ -306,7 +306,7 @@ export default struct TaroPicker {
306
306
  }
307
307
 
308
308
  build() {
309
- if (this.node) {
309
+ if (this.node && this.node.hmStyle?.display !== 'none') {
310
310
  if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
311
311
  Row() {
312
312
  createLazyChildren(this.node)
@@ -12,7 +12,7 @@ export default struct TaroProgress {
12
12
  @ObjectLink node: TaroProgressElement
13
13
 
14
14
  build() {
15
- if (this.node) {
15
+ if (this.node && this.node.hmStyle?.display !== 'none') {
16
16
  Row({ space: 5 }) {
17
17
  Progress({
18
18
  value: parseFloat(this.node.getAttribute('percent')),
@@ -4,8 +4,8 @@ import { createLazyChildren } from './render'
4
4
 
5
5
  import type { TaroViewElement, TaroStyleType, TaroTextStyleType } from '@tarojs/runtime'
6
6
 
7
- @Extend(Stack)
8
- function stackAttrs (style: TaroStyleType) {
7
+ @Extend(Flex)
8
+ function flexAttrs (style: TaroStyleType) {
9
9
  .constraintSize({
10
10
  minWidth: style.minWidth,
11
11
  maxWidth: style.maxWidth,
@@ -25,7 +25,6 @@ function textNormalFontStyle (style: TaroStyleType) {
25
25
  .fontWeight(style.fontWeight)
26
26
  .fontStyle(style.fontStyle)
27
27
  .fontFamily(style.fontFamily)
28
- .lineHeight(style.lineHeight)
29
28
  .decoration({
30
29
  type: style.textDecoration,
31
30
  color: style.color
@@ -35,38 +34,40 @@ function textNormalFontStyle (style: TaroStyleType) {
35
34
  @Extend(Text)
36
35
  function textSpecialFontStyle(attr: TaroTextStyleType) {
37
36
  .textAlign(attr.textAlign)
37
+ .align(attr.verticalAlign)
38
38
  .textOverflow(attr.textOverflow)
39
39
  .maxLines(attr.WebkitLineClamp)
40
40
  .letterSpacing(attr.letterSpacing)
41
+ .lineHeight(attr.lineHeight)
41
42
  }
42
43
 
43
44
  @Builder
44
45
  export default function PseduoChildren (node: TaroViewElement) {
45
46
  // 伪类::Before
46
- if (node.pseudo_before) {
47
- if (node.pseudo_before.content) {
48
- Text(node.pseudo_before.content)
49
- .attributeModifier(pseudoModify.setStyle(node.pseudo_before))
50
- .textNormalFontStyle(getStyle(node.pseudo_before || {}))
47
+ if (node._pseudo_before) {
48
+ if (node._pseudo_before?.hmStyle.content) {
49
+ Text(node._pseudo_before.hmStyle.content)
50
+ .attributeModifier(pseudoModify.setStyle(node._pseudo_before.hmStyle))
51
+ .textNormalFontStyle(getStyle(node._pseudo_before.hmStyle || {}))
51
52
  .textSpecialFontStyle(getFontAttributes(node))
52
53
  } else {
53
- Stack() {}
54
- .attributeModifier(pseudoModify.setStyle(node.pseudo_before || {}))
55
- .stackAttrs(getStyle(node.pseudo_before || {}))
54
+ Flex() {}
55
+ .attributeModifier(pseudoModify.setStyle(node._pseudo_before.hmStyle || {}))
56
+ .flexAttrs(getStyle(node._pseudo_before.hmStyle || {}))
56
57
  }
57
58
  }
58
59
  createLazyChildren(node)
59
60
  // 伪类::After
60
- if (node.pseudo_after) {
61
- if (node.pseudo_after.content) {
62
- Text(node.pseudo_after.content)
63
- .attributeModifier(pseudoModify.setStyle(node.pseudo_after))
64
- .textNormalFontStyle(getStyle(node.pseudo_after || {}))
61
+ if (node._pseudo_after) {
62
+ if (node._pseudo_after?.hmStyle.content) {
63
+ Text(node._pseudo_after.hmStyle.content)
64
+ .attributeModifier(pseudoModify.setStyle(node._pseudo_after.hmStyle))
65
+ .textNormalFontStyle(getStyle(node._pseudo_after.hmStyle || {}))
65
66
  .textSpecialFontStyle(getFontAttributes(node))
66
67
  } else {
67
- Stack() {}
68
- .attributeModifier(pseudoModify.setStyle(node.pseudo_after || {}))
69
- .stackAttrs(getStyle(node.pseudo_after || {}))
68
+ Flex() {}
69
+ .attributeModifier(pseudoModify.setStyle(node._pseudo_after.hmStyle || {}))
70
+ .flexAttrs(getStyle(node._pseudo_after.hmStyle || {}))
70
71
  }
71
72
  }
72
73
  }
@@ -45,7 +45,7 @@ export struct TaroRadio {
45
45
  }
46
46
 
47
47
  build () {
48
- if (this.node) {
48
+ if (this.node && this.node.hmStyle?.display !== 'none') {
49
49
  Stack() {
50
50
  Row() {
51
51
  Radio({
@@ -123,7 +123,7 @@ export struct TaroRadioGroup {
123
123
  }
124
124
 
125
125
  build() {
126
- if (this.node) {
126
+ if (this.node && this.node.hmStyle?.display !== 'none') {
127
127
  if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
128
128
  Row() {
129
129
  createLazyChildren(this.node)
@@ -1,46 +1,25 @@
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 { generateText } from './utils'
4
5
  import { getNodeThresholds, shouldBindEvent } from './utils/helper'
5
6
 
6
- import type { RichTextProps } from '@tarojs/components/types/RichText'
7
7
  import type { TaroAny, TaroRichTextElement } from '@tarojs/runtime'
8
8
 
9
- function generateText (node: TaroRichTextElement): string {
10
- return parseHtmlNode(node._attrs.nodes || '')
11
- }
12
-
13
9
  @Component
14
10
  export default struct TaroRichText {
15
11
  @ObjectLink node: TaroRichTextElement
16
12
 
17
13
  build () {
18
- RichText(generateText(this.node))
19
- .attributeModifier(commonStyleModify.setNode(this.node))
20
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
21
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
22
- this.node._nodeInfo.areaInfo = res[1]
23
- }))
24
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
25
-
14
+ if (this.node.hmStyle?.display !== 'none') {
15
+ RichText(generateText(this.node))
16
+ .attributeModifier(commonStyleModify.setNode(this.node))
17
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
18
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
19
+ this.node._nodeInfo.areaInfo = res[1]
20
+ }))
21
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
22
+ }
26
23
  }
27
24
  }
28
25
 
29
- // 将nodeTree转换成harmony需要的string结构
30
- function nodeToHtml(node: RichTextProps.Text | RichTextProps.HTMLElement): string {
31
- if (node.type === 'text') {
32
- return node.text;
33
- }
34
- if (node.attrs) {
35
- const attributes = Object.entries(node.attrs)
36
- .map((item: [string, string]) => `${item[0]}="${item[1]}"`)
37
- .join(' ');
38
- const childrenHtml: string = typeof node.children === 'string' ? node.children : (node.children || []).map((child: RichTextProps.Text | RichTextProps.HTMLElement) => nodeToHtml(child)).join('');
39
- return `<${node.name}${attributes ? ' ' + attributes : ''}>${childrenHtml}</${node.name}>`;
40
- }
41
- return ''
42
- }
43
-
44
- function parseHtmlNode (nodes: Array<RichTextProps.Text | RichTextProps.HTMLElement> | string) {
45
- return typeof nodes === 'string' ? nodes: `<div>${nodes.map(node => nodeToHtml(node)).join('')}</div>`
46
- }