@tarojs/plugin-platform-harmony-ets 4.0.0-beta.3 → 4.0.0-beta.31

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 (103) hide show
  1. package/dist/apis/base/system.ts +53 -20
  2. package/dist/apis/canvas/index.ts +10 -1
  3. package/dist/apis/framework/index.ts +1 -5
  4. package/dist/apis/index.ts +27 -12
  5. package/dist/apis/network/request.ts +5 -5
  6. package/dist/apis/route/index.ts +15 -0
  7. package/dist/apis/storage/index.ts +205 -63
  8. package/dist/apis/ui/animation/animation.ts +2 -1
  9. package/dist/apis/utils/index.ts +1 -1
  10. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  11. package/dist/apis/wxml/index.ts +2 -0
  12. package/dist/components-harmony-ets/button.ets +50 -78
  13. package/dist/components-harmony-ets/canvas.ets +51 -0
  14. package/dist/components-harmony-ets/checkbox.ets +23 -209
  15. package/dist/components-harmony-ets/form.ets +44 -158
  16. package/dist/components-harmony-ets/icon.ets +38 -83
  17. package/dist/components-harmony-ets/image.ets +29 -78
  18. package/dist/components-harmony-ets/index.ets +53 -0
  19. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  20. package/dist/components-harmony-ets/input.ets +11 -67
  21. package/dist/components-harmony-ets/label.ets +58 -172
  22. package/dist/components-harmony-ets/movableArea.ets +96 -0
  23. package/dist/components-harmony-ets/movableView.ets +74 -0
  24. package/dist/components-harmony-ets/picker.ets +32 -147
  25. package/dist/components-harmony-ets/progress.ets +54 -0
  26. package/dist/components-harmony-ets/pseudo.ets +80 -0
  27. package/dist/components-harmony-ets/radio.ets +23 -210
  28. package/dist/components-harmony-ets/richText.ets +22 -102
  29. package/dist/components-harmony-ets/scrollView.ets +73 -169
  30. package/dist/components-harmony-ets/slider.ets +11 -72
  31. package/dist/components-harmony-ets/style.ets +280 -0
  32. package/dist/components-harmony-ets/swiper.ets +37 -87
  33. package/dist/components-harmony-ets/switch.ets +11 -71
  34. package/dist/components-harmony-ets/text.ets +57 -89
  35. package/dist/components-harmony-ets/textArea.ets +11 -67
  36. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  37. package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
  38. package/dist/components-harmony-ets/utils/flexManager.ets +11 -9
  39. package/dist/components-harmony-ets/utils/helper.ets +4 -5
  40. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  41. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  42. package/dist/components-harmony-ets/utils/index.ts +50 -51
  43. package/dist/components-harmony-ets/utils/styles.ets +167 -87
  44. package/dist/components-harmony-ets/video.ets +41 -89
  45. package/dist/components-harmony-ets/view.ets +53 -159
  46. package/dist/components-harmony-ets/webView.ets +44 -99
  47. package/dist/index.d.ts +151 -0
  48. package/dist/index.js +69 -32
  49. package/dist/index.js.map +1 -1
  50. package/dist/runtime-ets/bom/window.ts +7 -0
  51. package/dist/runtime-ets/current.ts +3 -0
  52. package/dist/runtime-ets/dom/bind.ts +20 -6
  53. package/dist/runtime-ets/dom/cssNesting.ts +393 -0
  54. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +12 -40
  55. package/dist/runtime-ets/dom/document.ts +22 -8
  56. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  57. package/dist/runtime-ets/dom/element/element.ts +128 -51
  58. package/dist/runtime-ets/dom/element/form.ts +15 -18
  59. package/dist/runtime-ets/dom/element/index.ts +16 -3
  60. package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
  61. package/dist/runtime-ets/dom/element/movableView.ts +193 -0
  62. package/dist/runtime-ets/dom/element/normal.ts +8 -3
  63. package/dist/runtime-ets/dom/element/progress.ts +12 -0
  64. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  65. package/dist/runtime-ets/dom/element/text.ts +1 -8
  66. package/dist/runtime-ets/dom/element/video.ts +5 -3
  67. package/dist/runtime-ets/dom/element/webView.ts +8 -0
  68. package/dist/runtime-ets/dom/event.ts +0 -1
  69. package/dist/runtime-ets/dom/eventTarget.ts +0 -3
  70. package/dist/runtime-ets/dom/node.ts +29 -27
  71. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +189 -211
  72. package/dist/runtime-ets/dom/stylesheet/index.ts +28 -308
  73. package/dist/runtime-ets/dom/stylesheet/type.ts +18 -6
  74. package/dist/runtime-ets/dom/stylesheet/util.ts +31 -25
  75. package/dist/runtime-ets/index.ts +2 -2
  76. package/dist/runtime-ets/interface/event.ts +1 -1
  77. package/dist/runtime-ets/utils/index.ts +43 -10
  78. package/dist/runtime-ets/utils/info.ts +1 -1
  79. package/dist/runtime-framework/react/app.ts +7 -2
  80. package/dist/runtime-framework/react/index.ts +0 -2
  81. package/dist/runtime-framework/react/native-page.ts +22 -12
  82. package/dist/runtime-framework/react/page.ts +3 -8
  83. package/dist/runtime-framework/solid/app.ts +25 -45
  84. package/dist/runtime-framework/solid/connect.ts +21 -3
  85. package/dist/runtime-framework/solid/hooks.ts +16 -11
  86. package/dist/runtime-framework/solid/index.ts +6 -2
  87. package/dist/runtime-framework/solid/page.ts +84 -30
  88. package/dist/runtime-framework/solid/reconciler/props.ts +65 -20
  89. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  90. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  91. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  92. package/dist/runtime-utils.d.ts +827 -0
  93. package/dist/runtime-utils.js +273 -109
  94. package/dist/runtime-utils.js.map +1 -1
  95. package/dist/runtime.d.ts +1 -0
  96. package/dist/runtime.js +273 -109
  97. package/dist/runtime.js.map +1 -1
  98. package/index.js +3 -1
  99. package/package.json +13 -13
  100. package/types/index.d.ts +4 -0
  101. package/dist/runtime-ets/utils/bind.ts +0 -24
  102. /package/dist/components-harmony-ets/{index.ts → tag.ts} +0 -0
  103. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -1,9 +1,9 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
2
2
 
3
- import { createLazyChildren } from './render'
4
- import { getNodeThresholds, getNormalAttributes, shouldBindEvent } from './utils/helper'
3
+ import commonStyleModify from './style'
4
+ import { getNodeThresholds, shouldBindEvent } from './utils/helper'
5
5
 
6
- import type { TaroStyleType, TaroSwiperElement, TaroEvent, TaroAny } from '@tarojs/runtime'
6
+ import type { TaroSwiperElement, TaroEvent, TaroAny } from '@tarojs/runtime'
7
7
 
8
8
  interface SwiperAttrs {
9
9
  index?: number
@@ -15,71 +15,6 @@ interface SwiperAttrs {
15
15
  indicator?: boolean
16
16
  }
17
17
 
18
- @Extend(Swiper)
19
- function swiperStyle (style: TaroStyleType) {
20
- .id(style.id)
21
- .key(style.id)
22
- .flexGrow(style.flexGrow)
23
- .flexShrink(style.flexShrink)
24
- .flexBasis(style.flexBasis)
25
- .alignSelf(style.alignSelf)
26
- .padding({
27
- top: style.paddingTop,
28
- right: style.paddingRight,
29
- bottom: style.paddingBottom,
30
- left: style.paddingLeft
31
- })
32
- .margin({
33
- top: style.marginTop,
34
- right: style.marginRight,
35
- bottom: style.marginBottom,
36
- left: style.marginLeft
37
- })
38
- .width(style.width)
39
- .height(style.height)
40
- .constraintSize({
41
- minWidth: style.minWidth,
42
- maxWidth: style.maxWidth,
43
- minHeight: style.minHeight,
44
- maxHeight: style.maxHeight
45
- })
46
- .backgroundColor(style.backgroundColor)
47
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
48
- .backgroundImageSize(style.backgroundSize)
49
- .backgroundImagePosition(style.backgroundPosition)
50
- .borderStyle({
51
- top: style.borderTopStyle,
52
- right: style.borderRightStyle,
53
- bottom: style.borderBottomStyle,
54
- left: style.borderLeftStyle
55
- })
56
- .borderWidth({
57
- top: style.borderTopWidth,
58
- right: style.borderRightWidth,
59
- bottom: style.borderBottomWidth,
60
- left: style.borderLeftWidth
61
- })
62
- .borderColor({
63
- top: style.borderTopColor,
64
- right: style.borderRightColor,
65
- bottom: style.borderBottomColor,
66
- left: style.borderLeftColor
67
- })
68
- .borderRadius({
69
- topLeft: style.borderTopLeftRadius,
70
- topRight: style.borderTopRightRadius,
71
- bottomLeft: style.borderBottomLeftRadius,
72
- bottomRight: style.borderBottomRightRadius
73
- })
74
- .zIndex(style.zIndex)
75
- .opacity(style.opacity)
76
- .linearGradient(style.linearGradient)
77
- .clip(style.overflow)
78
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
79
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
80
- .transform(style.transform)
81
- }
82
-
83
18
  @Extend(Swiper)
84
19
  function swiperAttr (attr: SwiperAttrs) {
85
20
  .index(attr.index)
@@ -104,24 +39,39 @@ function getSwiperAttributes (node: TaroSwiperElement): SwiperAttrs {
104
39
  return swiperAttrs
105
40
  }
106
41
 
107
- @Builder
108
- export default function TaroSwiper (node: TaroSwiperElement) {
109
- Swiper(node.controller) {
110
- createLazyChildren(node)
42
+ @Component
43
+ export default struct TaroSwiper {
44
+ @Builder customBuilder() {}
45
+ @BuilderParam createLazyChildren: (node: TaroSwiperElement) => void = this.customBuilder
46
+ @ObjectLink node: TaroSwiperElement
47
+ @State overwriteStyle: Record<string, TaroAny> = {}
48
+
49
+ aboutToAppear(): void {
50
+ if (this.node) {
51
+ this.node._instance = this
52
+ }
53
+ }
54
+
55
+ build () {
56
+ if (this.node.hmStyle?.display !== 'none') {
57
+ Swiper(this.node.controller) {
58
+ this.createLazyChildren(this.node)
59
+ }
60
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
61
+ .swiperAttr(getSwiperAttributes(this.node))
62
+ .indicatorStyle({
63
+ color: this.node.getAttribute('indicatorColor'),
64
+ selectedColor: this.node.getAttribute('indicatorActiveColor')
65
+ })
66
+ .onChange((index: number) => {
67
+ const event: TaroEvent = createTaroEvent('change', { detail: { current: index } }, this.node)
68
+ eventHandler(event, 'change', this.node)
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
+ this.node._nodeInfo.areaInfo = res[1]
73
+ }))
74
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
75
+ }
111
76
  }
112
- .swiperStyle(getNormalAttributes(node))
113
- .swiperAttr(getSwiperAttributes(node))
114
- .indicatorStyle({
115
- color: node.getAttribute('indicatorColor'),
116
- selectedColor: node.getAttribute('indicatorActiveColor')
117
- })
118
- .onChange((index: number) => {
119
- const event: TaroEvent = createTaroEvent('change', { detail: { current: index } }, node)
120
- eventHandler(event, 'change', node)
121
- })
122
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
123
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
124
- node._nodeInfo.areaInfo = res[1]
125
- }))
126
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
127
77
  }
@@ -1,78 +1,14 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
2
2
 
3
- import { getNodeThresholds, shouldBindEvent, getNormalAttributes } from './utils/helper'
3
+ import commonStyleModify from './style'
4
+ import { getNodeThresholds, shouldBindEvent } from './utils/helper'
4
5
 
5
- import type { TaroAny, TaroStyleType, TaroSwitchElement, TaroEvent } from '@tarojs/runtime'
6
+ import type { TaroAny, TaroSwitchElement, TaroEvent } from '@tarojs/runtime'
6
7
 
7
8
  interface SwitchAttrs {
8
9
  selectedColor?: ResourceColor
9
10
  }
10
11
 
11
- @Extend(Toggle)
12
- function styles (style: TaroStyleType) {
13
- .id(style.id)
14
- .key(style.id)
15
- .flexGrow(style.flexGrow)
16
- .flexShrink(style.flexShrink)
17
- .flexBasis(style.flexBasis)
18
- .alignSelf(style.alignSelf)
19
- .padding({
20
- top: style.paddingTop,
21
- right: style.paddingRight,
22
- bottom: style.paddingBottom,
23
- left: style.paddingLeft
24
- })
25
- .margin({
26
- top: style.marginTop,
27
- right: style.marginRight,
28
- bottom: style.marginBottom,
29
- left: style.marginLeft
30
- })
31
- .width(style.width)
32
- .height(style.height)
33
- .constraintSize({
34
- minWidth: style.minWidth,
35
- maxWidth: style.maxWidth,
36
- minHeight: style.minHeight,
37
- maxHeight: style.maxHeight
38
- })
39
- .backgroundColor(style.backgroundColor)
40
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
41
- .backgroundImageSize(style.backgroundSize)
42
- .backgroundImagePosition(style.backgroundPosition)
43
- .borderStyle({
44
- top: style.borderTopStyle,
45
- right: style.borderRightStyle,
46
- bottom: style.borderBottomStyle,
47
- left: style.borderLeftStyle
48
- })
49
- .borderWidth({
50
- top: style.borderTopWidth,
51
- right: style.borderRightWidth,
52
- bottom: style.borderBottomWidth,
53
- left: style.borderLeftWidth
54
- })
55
- .borderColor({
56
- top: style.borderTopColor,
57
- right: style.borderRightColor,
58
- bottom: style.borderBottomColor,
59
- left: style.borderLeftColor
60
- })
61
- .borderRadius({
62
- topLeft: style.borderTopLeftRadius,
63
- topRight: style.borderTopRightRadius,
64
- bottomLeft: style.borderBottomLeftRadius,
65
- bottomRight: style.borderBottomRightRadius
66
- })
67
- .zIndex(style.zIndex)
68
- .opacity(style.opacity)
69
- .linearGradient(style.linearGradient)
70
- .clip(style.overflow)
71
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
72
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
73
- .transform(style.transform)
74
- }
75
-
76
12
  @Extend(Toggle)
77
13
  function attrs(attr: SwitchAttrs) {
78
14
  .selectedColor(attr.selectedColor)
@@ -92,29 +28,33 @@ function themeStyles(isDisabled: boolean) {
92
28
 
93
29
  @Component
94
30
  export default struct TaroSwitch {
95
- node: TaroSwitchElement | null = null
31
+ @Builder customBuilder() {}
32
+ @BuilderParam createLazyChildren: (node: TaroSwitchElement) => void = this.customBuilder
33
+ @ObjectLink node: TaroSwitchElement
34
+ @State overwriteStyle: Record<string, TaroAny> = {}
96
35
 
97
36
  aboutToAppear () {
98
37
  if (this.node && !this.node._isInit) {
99
38
  this.node._isInit = true
39
+ this.node._instance = this
100
40
  this.node._reset = this.node.checked || false
101
41
  }
102
42
  }
103
43
 
104
44
  build () {
105
- if (this.node) {
45
+ if (this.node && this.node.hmStyle?.display !== 'none') {
106
46
  Toggle({
107
47
  type: this.node._attrs.type !== 'checkbox' ? ToggleType.Switch : ToggleType.Checkbox,
108
48
  isOn: this.node.checked,
109
49
  })
110
- .styles(getNormalAttributes(this.node))
50
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
111
51
  .attrs(getAttributes(this.node))
112
52
  .themeStyles(!!this.node._attrs.disabled)
113
53
  .onChange((isOn: boolean) => {
114
54
  if (this.node) {
115
55
  if (!this.node?._attrs.disabled) {
116
56
  const event: TaroEvent = createTaroEvent('change', { detail: { value: isOn } }, this.node)
117
-
57
+
118
58
  this.node.updateCheckedValue(isOn)
119
59
  eventHandler(event, 'change', this.node)
120
60
  } else {
@@ -1,76 +1,13 @@
1
+ import { isString } from '@tarojs/shared'
1
2
  import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, NodeType } from '@tarojs/runtime'
2
3
 
4
+ import commonStyleModify from './style'
3
5
  import { getButtonColor } from './button'
4
6
  import { BUTTON_THEME_COLOR } from './utils/constant/style'
5
- import { getNodeThresholds, getNormalAttributes, getFontAttributes, shouldBindEvent } from './utils/helper'
7
+ import { getNodeThresholds, getStyleAttr, getFontAttributes, shouldBindEvent, getNormalAttributes } from './utils/helper'
6
8
 
7
9
  import type { TaroButtonElement, TaroElement, TaroTextElement, TaroAny, TaroTextStyleType, TaroStyleType } from '@tarojs/runtime'
8
10
 
9
- @Extend(Text)
10
- function textNormalStyle (style: TaroStyleType) {
11
- .id(style.id)
12
- .key(style.id)
13
- .flexGrow(style.flexGrow)
14
- .flexShrink(style.flexShrink)
15
- .flexBasis(style.flexBasis)
16
- .alignSelf(style.alignSelf)
17
- .padding({
18
- top: style.paddingTop,
19
- right: style.paddingRight,
20
- bottom: style.paddingBottom,
21
- left: style.paddingLeft
22
- })
23
- .margin({
24
- top: style.marginTop,
25
- right: style.marginRight,
26
- bottom: style.marginBottom,
27
- left: style.marginLeft
28
- })
29
- .width(style.width)
30
- .height(style.height)
31
- .constraintSize({
32
- minWidth: style.minWidth,
33
- maxWidth: style.maxWidth,
34
- minHeight: style.minHeight,
35
- maxHeight: style.maxHeight
36
- })
37
- .backgroundColor(style.backgroundColor)
38
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
39
- .backgroundImageSize(style.backgroundSize)
40
- .backgroundImagePosition(style.backgroundPosition)
41
- .borderStyle({
42
- top: style.borderTopStyle,
43
- right: style.borderRightStyle,
44
- bottom: style.borderBottomStyle,
45
- left: style.borderLeftStyle
46
- })
47
- .borderWidth({
48
- top: style.borderTopWidth,
49
- right: style.borderRightWidth,
50
- bottom: style.borderBottomWidth,
51
- left: style.borderLeftWidth
52
- })
53
- .borderColor({
54
- top: style.borderTopColor,
55
- right: style.borderRightColor,
56
- bottom: style.borderBottomColor,
57
- left: style.borderLeftColor
58
- })
59
- .borderRadius({
60
- topLeft: style.borderTopLeftRadius,
61
- topRight: style.borderTopRightRadius,
62
- bottomLeft: style.borderBottomLeftRadius,
63
- bottomRight: style.borderBottomRightRadius
64
- })
65
- .zIndex(style.zIndex)
66
- .opacity(style.opacity)
67
- .linearGradient(style.linearGradient)
68
- .clip(style.overflow)
69
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
70
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
71
- .transform(style.transform)
72
- }
73
-
74
11
  @Extend(Text)
75
12
  function textNormalFontStyle (style: TaroStyleType) {
76
13
  .id(style.id)
@@ -81,7 +18,6 @@ function textNormalFontStyle (style: TaroStyleType) {
81
18
  .fontWeight(style.fontWeight)
82
19
  .fontStyle(style.fontStyle)
83
20
  .fontFamily(style.fontFamily)
84
- .lineHeight(style.lineHeight)
85
21
  .decoration({
86
22
  type: style.textDecoration,
87
23
  color: style.color
@@ -91,9 +27,11 @@ function textNormalFontStyle (style: TaroStyleType) {
91
27
  @Extend(Text)
92
28
  function textSpecialFontStyle(attr: TaroTextStyleType) {
93
29
  .textAlign(attr.textAlign)
30
+ .align(attr.verticalAlign)
94
31
  .textOverflow(attr.textOverflow)
95
32
  .maxLines(attr.WebkitLineClamp)
96
33
  .letterSpacing(attr.letterSpacing)
34
+ .lineHeight(attr.lineHeight)
97
35
  }
98
36
 
99
37
  function getButtonFontSize (node: TaroButtonElement) {
@@ -102,29 +40,59 @@ function getButtonFontSize (node: TaroButtonElement) {
102
40
  return isMini ? convertNumber2VP(26) : convertNumber2VP(36)
103
41
  }
104
42
 
105
- @Builder
106
- export default function TaroText (node: TaroTextElement) {
107
- if (node.nodeType === NodeType.TEXT_NODE && node.parentNode) {
108
- if ((node.parentNode as TaroElement).tagName === 'BUTTON') {
109
- Text(node.textContent)
110
- .textNormalFontStyle(getNormalAttributes(node.parentNode as TaroElement))
111
- .textSpecialFontStyle(getFontAttributes(node.parentNode as TaroElement))
112
- .fontSize((node.parentNode as TaroButtonElement).hmStyle.fontSize || getButtonFontSize((node.parentNode as TaroButtonElement)))
113
- .fontColor((node.parentNode as TaroButtonElement).hmStyle.color || getButtonColor(node.parentNode as TaroButtonElement, BUTTON_THEME_COLOR.get((node.parentNode as TaroButtonElement)._attrs.type).text))
43
+ function getTextInViewWidth (node: TaroElement | null): TaroAny {
44
+ if (node) {
45
+ const hmStyle = node.hmStyle || {}
46
+ const isFlexView = hmStyle.display === 'flex'
47
+ const width: TaroAny = getStyleAttr(node, 'width')
48
+ const isPercentWidth = isString(width) && width.includes('%')
49
+
50
+ return isFlexView || isPercentWidth ? null : getStyleAttr(node, 'width')
51
+ }
52
+ }
53
+
54
+ @Component
55
+ export default struct TaroText {
56
+ @Builder customBuilder() {}
57
+ @BuilderParam createLazyChildren: (node: TaroTextElement) => void = this.customBuilder
58
+ @ObjectLink node: TaroTextElement
59
+ @State overwriteStyle: Record<string, TaroAny> = {}
60
+
61
+ aboutToAppear(): void {
62
+ if (this.node) {
63
+ this.node._instance = this
64
+ }
65
+ }
66
+
67
+ build () {
68
+ if (this.node.nodeType === NodeType.TEXT_NODE) {
69
+ if (this.node.parentNode) {
70
+ if ((this.node.parentNode as TaroElement).tagName === 'BUTTON') {
71
+ Text(this.node.textContent)
72
+ .textNormalFontStyle(getNormalAttributes(this.node.parentElement!, {
73
+ fontSize: getButtonFontSize(this.node.parentNode as TaroButtonElement),
74
+ color: getButtonColor(this.node.parentNode as TaroButtonElement, BUTTON_THEME_COLOR.get((this.node.parentNode as TaroButtonElement)._attrs.type || '').text)
75
+ }))
76
+ .textSpecialFontStyle(getFontAttributes(this.node.parentElement as TaroElement))
77
+ } else {
78
+ Text(this.node.textContent)
79
+ .textNormalFontStyle(getNormalAttributes(this.node.parentElement!))
80
+ .textSpecialFontStyle(getFontAttributes(this.node.parentElement as TaroElement))
81
+ .width(getTextInViewWidth(this.node.parentElement))
82
+ }
83
+ }
114
84
  } else {
115
- Text(node.textContent)
116
- .textNormalFontStyle(getNormalAttributes(node.parentNode as TaroElement))
117
- .textSpecialFontStyle(getFontAttributes(node.parentNode as TaroElement))
85
+ if (this.node.hmStyle?.display !== 'none') {
86
+ Text(this.node.textContent)
87
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
88
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
89
+ .textNormalFontStyle(getNormalAttributes(this.node))
90
+ .textSpecialFontStyle(getFontAttributes(this.node))
91
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
92
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
93
+ this.node._nodeInfo.areaInfo = res[1]
94
+ }))
95
+ }
118
96
  }
119
- } else {
120
- Text(node.textContent)
121
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
122
- .textNormalStyle(getNormalAttributes(node))
123
- .textNormalFontStyle(getNormalAttributes(node))
124
- .textSpecialFontStyle(getFontAttributes(node))
125
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
126
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
127
- node._nodeInfo.areaInfo = res[1]
128
- }))
129
97
  }
130
98
  }
@@ -1,72 +1,12 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
2
2
 
3
- import { getNodeThresholds, getNormalAttributes, getFontAttributes, shouldBindEvent, parseStyles } from './utils/helper'
3
+ import commonStyleModify from './style'
4
+ import { getNodeThresholds, getFontAttributes, shouldBindEvent, parseStyles } from './utils/helper'
4
5
 
5
6
  import type { TaroAny, TaroStyleType, TaroTextStyleType, TaroTextAreaElement, TaroEvent } from '@tarojs/runtime'
6
7
 
7
8
  @Extend(TextArea)
8
9
  function textStyle (style: TaroStyleType) {
9
- .id(style.id)
10
- .key(style.id)
11
- .flexGrow(style.flexGrow)
12
- .flexShrink(style.flexShrink)
13
- .flexBasis(style.flexBasis)
14
- .alignSelf(style.alignSelf)
15
- .padding({
16
- top: style.paddingTop,
17
- right: style.paddingRight,
18
- bottom: style.paddingBottom,
19
- left: style.paddingLeft
20
- })
21
- .margin({
22
- top: style.marginTop,
23
- right: style.marginRight,
24
- bottom: style.marginBottom,
25
- left: style.marginLeft
26
- })
27
- .width(style.width)
28
- .height(style.height)
29
- .constraintSize({
30
- minWidth: style.minWidth,
31
- maxWidth: style.maxWidth,
32
- minHeight: style.minHeight,
33
- maxHeight: style.maxHeight
34
- })
35
- .backgroundColor(style.backgroundColor)
36
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
37
- .backgroundImageSize(style.backgroundSize)
38
- .backgroundImagePosition(style.backgroundPosition)
39
- .borderStyle({
40
- top: style.borderTopStyle,
41
- right: style.borderRightStyle,
42
- bottom: style.borderBottomStyle,
43
- left: style.borderLeftStyle
44
- })
45
- .borderWidth({
46
- top: style.borderTopWidth,
47
- right: style.borderRightWidth,
48
- bottom: style.borderBottomWidth,
49
- left: style.borderLeftWidth
50
- })
51
- .borderColor({
52
- top: style.borderTopColor,
53
- right: style.borderRightColor,
54
- bottom: style.borderBottomColor,
55
- left: style.borderLeftColor
56
- })
57
- .borderRadius({
58
- topLeft: style.borderTopLeftRadius,
59
- topRight: style.borderTopRightRadius,
60
- bottomLeft: style.borderBottomLeftRadius,
61
- bottomRight: style.borderBottomRightRadius
62
- })
63
- .zIndex(style.zIndex)
64
- .opacity(style.opacity)
65
- .linearGradient(style.linearGradient)
66
- .clip(style.overflow)
67
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
68
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
69
- .transform(style.transform)
70
10
  .fontColor(style.color)
71
11
  .fontSize(style.fontSize)
72
12
  .fontWeight(style.fontWeight)
@@ -90,7 +30,10 @@ function getPlaceholderColor (node: TaroTextAreaElement): string {
90
30
  export default struct TaroTextArea {
91
31
  @State value: string = ''
92
32
 
93
- node: TaroTextAreaElement | null = null
33
+ @Builder customBuilder() {}
34
+ @BuilderParam createLazyChildren: (node: TaroTextAreaElement) => void = this.customBuilder
35
+ @ObjectLink node: TaroTextAreaElement
36
+ @State overwriteStyle: Record<string, TaroAny> = {}
94
37
 
95
38
  aboutToAppear () {
96
39
  if (this.node) {
@@ -105,16 +48,17 @@ export default struct TaroTextArea {
105
48
  }
106
49
 
107
50
  build () {
108
- if (this.node) {
51
+ if (this.node && this.node.hmStyle?.display !== 'none') {
109
52
  TextArea({ text: this.value, placeholder: this.node._attrs?.placeholder || '', controller: this.node.controller })
110
53
  .key(this.node._nid)
111
54
  .maxLength(Number(this.node._attrs?.maxlength) || null)
112
55
  .placeholderColor(getPlaceholderColor(this.node))
113
- .textStyle(getNormalAttributes(this.node))
56
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
57
+ .textStyle(this.node?.hmStyle)
114
58
  .textAttr(getFontAttributes(this.node))
115
59
  .onChange((value: string) => {
116
60
  const event: TaroEvent = createTaroEvent('input', { detail: { value } }, this.node)
117
-
61
+
118
62
  this.value = value
119
63
  this.node?.updateFormWidgetValue(value)
120
64
  eventHandler(event, 'input', this.node)
@@ -126,7 +70,7 @@ export default struct TaroTextArea {
126
70
  })
127
71
  .onFocus(() => {
128
72
  const event: TaroEvent = createTaroEvent('focus', { detail: { value: this.value, height: this.node?._height } }, this.node)
129
-
73
+
130
74
  eventHandler(event, 'focus', this.node)
131
75
  })
132
76
  .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
@@ -60,7 +60,7 @@ class AttributeManager {
60
60
  const dataValue: string = AttributeManager.getNodeStyle(style, 'animation')
61
61
 
62
62
  if (dataValue) {
63
- let values: string[] = dataValue.trim().split(new RegExp("/\s+/"))
63
+ let values: string[] = dataValue.toString().trim().split(new RegExp("/\s+/"))
64
64
  switch (values.length) {
65
65
  case 4:
66
66
  res = { duration: values[0], curve: values[1], delay: values[2] }
@@ -36,4 +36,4 @@ export class DynamicCenter {
36
36
  this.bindComponentToNodeWithDFS(node.childNodes[i] as TaroElement, component)
37
37
  }
38
38
  }
39
- }
39
+ }
@@ -1,4 +1,6 @@
1
1
  import type { TaroElement } from '@tarojs/runtime'
2
+ import { isUndefined } from '@tarojs/shared'
3
+ import { getNormalAttributes } from './styles.ets'
2
4
 
3
5
  interface IFlexOptions {
4
6
  direction: FlexDirection,
@@ -13,33 +15,33 @@ class FlexManager {
13
15
  static isFlexNode (node: TaroElement): boolean {
14
16
  return !!node.hmStyle?.display?.includes('flex')
15
17
  }
16
-
18
+
17
19
  static convertFlexAlignItemsToColumnOrRow (direction: FlexDirection, alignItems: ItemAlign | undefined): VerticalAlign | HorizontalAlign {
18
20
  if (direction === FlexDirection.Column) {
19
21
  switch (alignItems) {
20
- case ItemAlign.Start:
21
- return HorizontalAlign.Start
22
+ case ItemAlign.Center:
23
+ return HorizontalAlign.Center
22
24
  case ItemAlign.End:
23
25
  return HorizontalAlign.End
24
26
  default:
25
- return HorizontalAlign.Center
27
+ return HorizontalAlign.Start
26
28
  }
27
29
  } else {
28
30
  switch (alignItems) {
29
- case ItemAlign.Start:
30
- return VerticalAlign.Top
31
+ case ItemAlign.Center:
32
+ return VerticalAlign.Center
31
33
  case ItemAlign.End:
32
34
  return VerticalAlign.Bottom
33
35
  default:
34
- return VerticalAlign.Center
36
+ return VerticalAlign.Top
35
37
  }
36
38
  }
37
39
  }
38
40
 
39
41
  static flexOptions (node: TaroElement): IFlexOptions {
40
- const hmStyle = node.hmStyle
42
+ const hmStyle = getNormalAttributes(node) || {}
41
43
  const isFlex = FlexManager.isFlexNode(node)
42
- const justifyContent: FlexAlign = isFlex ? (hmStyle.justifyContent || FlexAlign.Center) : FlexAlign.Start
44
+ const justifyContent: FlexAlign = isFlex ? (isUndefined(hmStyle.justifyContent) ? FlexAlign.Start : hmStyle.justifyContent) : FlexAlign.Start
43
45
 
44
46
  let flexDirection = hmStyle.flexDirection
45
47
  if (!flexDirection && flexDirection !== 0) {
@@ -1,4 +1,4 @@
1
- import { getNormalAttributes, getFontAttributes } from './styles'
1
+ import { getNormalAttributes, getFontAttributes, getStyleAttr } from './styles'
2
2
 
3
3
  import type { TFunc } from '@tarojs/runtime/dist/runtime.esm'
4
4
  import type { TaroElement } from '@tarojs/runtime'
@@ -31,9 +31,8 @@ export function shouldBindEvent (cb: TFunc, node: TaroElement | null, eventNames
31
31
  }
32
32
 
33
33
  export function getNodeThresholds (node: TaroElement): number[] | null {
34
- if (!node) return null
35
-
36
- return node?._nodeInfo.thresholds || null
34
+ return node?._nodeInfo?.thresholds || null
37
35
  }
38
36
 
39
- export { getNormalAttributes, getFontAttributes }
37
+
38
+ export { getNormalAttributes, getFontAttributes, getStyleAttr }
@@ -99,5 +99,4 @@ function parseTag(htmlString, startIndex) {
99
99
  return tag
100
100
  }
101
101
 
102
-
103
- export default parseHTML
102
+ export default parseHTML
@@ -15,7 +15,7 @@ function buildDomTree(dom: TTreeNode) {
15
15
  case 'span': tagName = 'text'; break
16
16
  }
17
17
  if (!tagName) return null
18
-
18
+
19
19
  const ele = document.createElement(tagName)
20
20
  attributes && Object.keys(attributes).forEach(key => {
21
21
  if (key === 'style') {