@tarojs/plugin-platform-harmony-ets 4.0.0-canary.8 → 4.0.0

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 (135) hide show
  1. package/dist/apis/base/system.ts +73 -20
  2. package/dist/apis/canvas/index.ts +10 -1
  3. package/dist/apis/device/clipboard.ts +23 -8
  4. package/dist/apis/framework/index.ts +1 -5
  5. package/dist/apis/index.ts +27 -17
  6. package/dist/apis/media/image/index.ts +169 -17
  7. package/dist/apis/network/request.ts +5 -5
  8. package/dist/apis/route/index.ts +15 -0
  9. package/dist/apis/storage/index.ts +146 -78
  10. package/dist/apis/ui/animation/animation.ts +71 -29
  11. package/dist/apis/ui/background.ts +2 -1
  12. package/dist/apis/ui/interaction/index.ts +58 -59
  13. package/dist/apis/ui/navigation-bar/index.ts +1 -1
  14. package/dist/apis/ui/pull-down-refresh.ts +9 -3
  15. package/dist/apis/ui/scroll/index.ts +5 -5
  16. package/dist/apis/ui/tab-bar.ts +3 -3
  17. package/dist/apis/utils/index.ts +21 -2
  18. package/dist/apis/utils/permissions.ts +6 -0
  19. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  20. package/dist/apis/wxml/index.ts +2 -0
  21. package/dist/apis/wxml/selectorQuery.ts +26 -13
  22. package/dist/components-harmony-ets/button.ets +63 -77
  23. package/dist/components-harmony-ets/canvas.ets +51 -0
  24. package/dist/components-harmony-ets/checkbox.ets +75 -258
  25. package/dist/components-harmony-ets/form.ets +51 -158
  26. package/dist/components-harmony-ets/icon.ets +33 -83
  27. package/dist/components-harmony-ets/image.ets +35 -79
  28. package/dist/components-harmony-ets/index.ets +92 -0
  29. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  30. package/dist/components-harmony-ets/input.ets +64 -101
  31. package/dist/components-harmony-ets/label.ets +72 -174
  32. package/dist/components-harmony-ets/listView.ets +31 -0
  33. package/dist/components-harmony-ets/movableArea.ets +126 -0
  34. package/dist/components-harmony-ets/movableView.ets +93 -0
  35. package/dist/components-harmony-ets/navigationBar.ets +65 -0
  36. package/dist/components-harmony-ets/pageMeta.ets +94 -0
  37. package/dist/components-harmony-ets/picker.ets +46 -163
  38. package/dist/components-harmony-ets/progress.ets +52 -0
  39. package/dist/components-harmony-ets/pseudo.ets +80 -0
  40. package/dist/components-harmony-ets/radio.ets +80 -264
  41. package/dist/components-harmony-ets/richText.ets +20 -102
  42. package/dist/components-harmony-ets/scrollList.ets +108 -0
  43. package/dist/components-harmony-ets/scrollView.ets +71 -160
  44. package/dist/components-harmony-ets/slider.ets +22 -82
  45. package/dist/components-harmony-ets/stickySection.ets +42 -0
  46. package/dist/components-harmony-ets/style.ets +410 -0
  47. package/dist/components-harmony-ets/swiper.ets +64 -87
  48. package/dist/components-harmony-ets/switch.ets +39 -99
  49. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  50. package/dist/components-harmony-ets/text.ets +111 -113
  51. package/dist/components-harmony-ets/textArea.ets +51 -95
  52. package/dist/components-harmony-ets/utils/AttributeManager.ets +2 -2
  53. package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -2
  54. package/dist/components-harmony-ets/utils/flexManager.ets +50 -19
  55. package/dist/components-harmony-ets/utils/helper.ets +20 -8
  56. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  57. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  58. package/dist/components-harmony-ets/utils/index.ts +54 -50
  59. package/dist/components-harmony-ets/utils/styles.ets +172 -92
  60. package/dist/components-harmony-ets/video.ets +37 -88
  61. package/dist/components-harmony-ets/view.ets +63 -159
  62. package/dist/components-harmony-ets/webView.ets +41 -98
  63. package/dist/index.d.ts +152 -0
  64. package/dist/index.js +187 -56
  65. package/dist/index.js.map +1 -1
  66. package/dist/runtime-ets/bom/document.ts +6 -4
  67. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  68. package/dist/runtime-ets/bom/window.ts +9 -2
  69. package/dist/runtime-ets/current.ts +5 -1
  70. package/dist/runtime-ets/dom/bind.ts +28 -12
  71. package/dist/runtime-ets/dom/class-list.ts +2 -2
  72. package/dist/runtime-ets/dom/cssNesting.ts +419 -0
  73. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +28 -42
  74. package/dist/runtime-ets/dom/document.ts +22 -8
  75. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  76. package/dist/runtime-ets/dom/element/element.ts +376 -57
  77. package/dist/runtime-ets/dom/element/form.ts +31 -26
  78. package/dist/runtime-ets/dom/element/index.ts +30 -2
  79. package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
  80. package/dist/runtime-ets/dom/element/movableView.ts +248 -0
  81. package/dist/runtime-ets/dom/element/normal.ts +35 -8
  82. package/dist/runtime-ets/dom/element/progress.ts +11 -0
  83. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  84. package/dist/runtime-ets/dom/element/text.ts +1 -8
  85. package/dist/runtime-ets/dom/element/video.ts +5 -4
  86. package/dist/runtime-ets/dom/element/webView.ts +12 -5
  87. package/dist/runtime-ets/dom/event.ts +3 -5
  88. package/dist/runtime-ets/dom/eventTarget.ts +2 -3
  89. package/dist/runtime-ets/dom/node.ts +65 -32
  90. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +418 -237
  91. package/dist/runtime-ets/dom/stylesheet/index.ts +29 -311
  92. package/dist/runtime-ets/dom/stylesheet/type.ts +53 -11
  93. package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
  94. package/dist/runtime-ets/index.ts +2 -2
  95. package/dist/runtime-ets/interface/event.ts +1 -1
  96. package/dist/runtime-ets/utils/index.ts +74 -13
  97. package/dist/runtime-ets/utils/info.ts +2 -2
  98. package/dist/runtime-framework/react/app.ts +25 -30
  99. package/dist/runtime-framework/react/hooks.ts +3 -4
  100. package/dist/runtime-framework/react/index.ts +0 -2
  101. package/dist/runtime-framework/react/native-page.ts +219 -82
  102. package/dist/runtime-framework/react/page.ts +6 -10
  103. package/dist/runtime-framework/react/utils/index.ts +3 -3
  104. package/dist/runtime-framework/solid/app.ts +30 -46
  105. package/dist/runtime-framework/solid/connect.ts +21 -3
  106. package/dist/runtime-framework/solid/hooks.ts +17 -12
  107. package/dist/runtime-framework/solid/index.ts +6 -2
  108. package/dist/runtime-framework/solid/page.ts +85 -31
  109. package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
  110. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  111. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  112. package/dist/runtime-framework/solid/utils/index.ts +3 -5
  113. package/dist/runtime-utils.d.ts +827 -0
  114. package/dist/runtime-utils.js +618 -245
  115. package/dist/runtime-utils.js.map +1 -1
  116. package/dist/runtime.d.ts +1 -0
  117. package/dist/runtime.js +618 -245
  118. package/dist/runtime.js.map +1 -1
  119. package/index.js +3 -1
  120. package/package.json +14 -15
  121. package/static/media/cancel.svg +1 -1
  122. package/static/media/circle.svg +1 -1
  123. package/static/media/clear.svg +1 -1
  124. package/static/media/download.svg +1 -1
  125. package/static/media/info.svg +1 -1
  126. package/static/media/info_circle.svg +1 -1
  127. package/static/media/search.svg +1 -1
  128. package/static/media/success.svg +1 -1
  129. package/static/media/success_no_circle.svg +1 -1
  130. package/static/media/warn.svg +1 -1
  131. package/types/harmony.d.ts +5 -0
  132. package/types/index.d.ts +4 -0
  133. package/types/runtime.d.ts +3 -1
  134. package/dist/runtime-ets/utils/bind.ts +0 -24
  135. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -1,88 +1,26 @@
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
-
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)
10
+ disabled?: boolean
74
11
  }
75
12
 
76
13
  @Extend(Toggle)
77
14
  function attrs(attr: SwitchAttrs) {
78
15
  .selectedColor(attr.selectedColor)
16
+ .enabled(!attr.disabled)
79
17
  }
80
18
 
81
19
  function getAttributes (node: TaroSwitchElement): SwitchAttrs {
82
- const _attrs = node._attrs
83
- const switchStyle: SwitchAttrs = {}
84
- switchStyle.selectedColor = _attrs.color || '#04BE02'
85
- return switchStyle
20
+ const attr: SwitchAttrs = {}
21
+ attr.selectedColor = node._attrs.color || '#04BE02'
22
+ attr.disabled = !!node._attrs.disabled
23
+ return attr
86
24
  }
87
25
 
88
26
  @Extend(Toggle)
@@ -92,43 +30,45 @@ function themeStyles(isDisabled: boolean) {
92
30
 
93
31
  @Component
94
32
  export default struct TaroSwitch {
95
- node: TaroSwitchElement | null = null
33
+ @Builder customBuilder() {}
34
+ @BuilderParam createLazyChildren: (node: TaroSwitchElement, layer?: number) => void = this.customBuilder
35
+ @ObjectLink node: TaroSwitchElement
36
+ @State overwriteStyle: Record<string, TaroAny> = {}
96
37
 
97
38
  aboutToAppear () {
98
39
  if (this.node && !this.node._isInit) {
99
40
  this.node._isInit = true
41
+ this.node._instance = this
100
42
  this.node._reset = this.node.checked || false
101
43
  }
102
44
  }
103
45
 
104
46
  build () {
105
- if (this.node) {
106
- Toggle({
107
- type: this.node._attrs.type !== 'checkbox' ? ToggleType.Switch : ToggleType.Checkbox,
108
- isOn: this.node.checked,
109
- })
110
- .styles(getNormalAttributes(this.node))
111
- .attrs(getAttributes(this.node))
112
- .themeStyles(!!this.node._attrs.disabled)
113
- .onChange((isOn: boolean) => {
114
- if (this.node) {
115
- if (!this.node?._attrs.disabled) {
116
- const event: TaroEvent = createTaroEvent('change', { detail: { value: isOn } }, this.node)
117
-
118
- this.node.updateCheckedValue(isOn)
119
- eventHandler(event, 'change', this.node)
120
- } else {
121
- this.node.updateComponent()
122
- }
123
- }
124
- })
125
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
126
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
127
- if (this.node) {
128
- this.node._nodeInfo.areaInfo = res[1]
47
+ Toggle({
48
+ type: this.node._attrs.type !== 'checkbox' ? ToggleType.Switch : ToggleType.Checkbox,
49
+ isOn: this.node.checked,
50
+ })
51
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
52
+ .attrs(getAttributes(this.node))
53
+ .themeStyles(!!this.node._attrs.disabled)
54
+ .onChange((isOn: boolean) => {
55
+ if (this.node) {
56
+ if (!this.node?._attrs.disabled) {
57
+ const event: TaroEvent = createTaroEvent('change', { detail: { value: isOn } }, this.node)
58
+
59
+ this.node.updateCheckedValue(isOn)
60
+ eventHandler(event, 'change', this.node)
61
+ } else {
62
+ this.node.updateComponent()
129
63
  }
130
- }))
131
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
132
- }
64
+ }
65
+ })
66
+ .onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
67
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
68
+ if (this.node) {
69
+ this.node._nodeInfo.areaInfo = res[1]
70
+ }
71
+ }))
72
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
133
73
  }
134
74
  }
@@ -35,6 +35,8 @@ export const TaroAdTagName = 'ad'
35
35
  export const TaroWebViewTagName = 'web-view'
36
36
  export const TaroBlockTagName = 'block'
37
37
  export const TaroMapTagName = 'map'
38
+ export const TaroPageMetaTagName = 'page-meta'
39
+ export const TaroNavigationBarTagName = 'navigation-bar'
38
40
  export const TaroSlotTagName = 'slot'
39
41
  export const TaroNativeSlotTagName = 'native-slot'
40
42
  export const TaroCustomWrapperTagName = 'custom-wrapper'
@@ -47,3 +49,7 @@ export const TaroListTagName = 'list'
47
49
  export const TaroListItemTagName = 'list-item'
48
50
  export const TaroOpenDataTagName = 'open-data'
49
51
  export const TaroIgnoreTagName = 'ignore'
52
+
53
+ export const TaroStickySectionTagName = 'sticky-section'
54
+ export const TaroStickyHeaderTagName = 'sticky-header'
55
+ export const TaroListViewTagName = 'list-view'
@@ -1,130 +1,128 @@
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, { textModify, setNormalTextAttributeIntoInstance } from './style'
3
5
  import { getButtonColor } from './button'
6
+ import { getImageMode } from './image'
4
7
  import { BUTTON_THEME_COLOR } from './utils/constant/style'
5
- import { getNodeThresholds, getNormalAttributes, getFontAttributes, shouldBindEvent } from './utils/helper'
8
+ import { getNodeThresholds, getStyleAttr, shouldBindEvent, getNormalAttributes } from './utils/helper'
6
9
 
7
- import type { TaroButtonElement, TaroElement, TaroTextElement, TaroAny, TaroTextStyleType, TaroStyleType } from '@tarojs/runtime'
10
+ import type { TaroButtonElement, TaroElement, TaroTextElement, TaroAny, HarmonyStyle } from '@tarojs/runtime'
8
11
 
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
- }
12
+ function getButtonFontSize (node: TaroButtonElement): string | number {
13
+ const isMini = node._attrs.size === 'mini'
73
14
 
74
- @Extend(Text)
75
- function textNormalFontStyle (style: TaroStyleType) {
76
- .id(style.id)
77
- .key(style.id)
78
- .opacity(style.opacity)
79
- .fontColor(style.color)
80
- .fontSize(style.fontSize)
81
- .fontWeight(style.fontWeight)
82
- .fontStyle(style.fontStyle)
83
- .fontFamily(style.fontFamily)
84
- .lineHeight(style.lineHeight)
85
- .decoration({
86
- type: style.textDecoration,
87
- color: style.color
88
- })
15
+ return isMini ? convertNumber2VP(26) : convertNumber2VP(36)
89
16
  }
90
17
 
91
- @Extend(Text)
92
- function textSpecialFontStyle(attr: TaroTextStyleType) {
93
- .textAlign(attr.textAlign)
94
- .textOverflow(attr.textOverflow)
95
- .maxLines(attr.WebkitLineClamp)
96
- .letterSpacing(attr.letterSpacing)
18
+ function getTextInViewWidth (node: TaroElement | null): TaroAny {
19
+ if (node) {
20
+ const hmStyle = node.hmStyle || {}
21
+ const isFlexView = hmStyle.display === 'flex'
22
+ const width: TaroAny = getStyleAttr(node, 'width')
23
+ const isPercentWidth = isString(width) && width.includes('%')
24
+
25
+ return isFlexView || isPercentWidth ? null : getStyleAttr(node, 'width')
26
+ }
97
27
  }
98
28
 
99
- function getButtonFontSize (node: TaroButtonElement) {
100
- const isMini = node._attrs.size === 'mini'
101
29
 
102
- return isMini ? convertNumber2VP(26) : convertNumber2VP(36)
103
- }
30
+ @Component
31
+ export default struct TaroText {
32
+ @Builder customBuilder() {}
33
+ @BuilderParam createLazyChildren: (node: TaroTextElement, layer?: number) => void = this.customBuilder
34
+ @ObjectLink node: TaroTextElement
35
+ @State overwriteStyle: Record<string, TaroAny> = {}
36
+
37
+ aboutToAppear(): void {
38
+ if (this.node) {
39
+ this.node._instance = this
40
+ }
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
+ build () {
44
+ if (this.node.nodeType === NodeType.TEXT_NODE) {
45
+ if (this.node.parentNode) {
46
+ if ((this.node.parentNode as TaroElement).tagName === 'BUTTON') {
47
+ Text(this.node.textContent)
48
+ .attributeModifier(textModify.setNode(this.node?.parentElement as TaroElement, {
49
+ fontSize: getButtonFontSize(this.node.parentNode as TaroButtonElement),
50
+ color: getButtonColor(this.node.parentNode as TaroButtonElement, BUTTON_THEME_COLOR.get((this.node.parentNode as TaroButtonElement)._attrs.type || '').text)
51
+ }))
52
+ } else {
53
+ Text(this.node.textContent)
54
+ .attributeModifier(textModify.setNode(this.node?.parentElement as TaroElement))
55
+ .width(getTextInViewWidth(this.node.parentElement))
56
+ }
57
+ }
114
58
  } else {
115
- Text(node.textContent)
116
- .textNormalFontStyle(getNormalAttributes(node.parentNode as TaroElement))
117
- .textSpecialFontStyle(getFontAttributes(node.parentNode as TaroElement))
59
+ Text(this.node.textContent) {
60
+ // text 下还有标签
61
+ if (this.node.childNodes.length > 1 || ((this.node.childNodes[0] && this.node.childNodes[0] as TaroElement)?.nodeType === NodeType.ELEMENT_NODE)) {
62
+ ForEach(this.node.childNodes, (item: TaroElement) => {
63
+ if (item.tagName === 'IMAGE') {
64
+ ImageSpan(item.getAttribute('src'))
65
+ .attributeModifier(commonStyleModify.setNode(item))
66
+ .objectFit(getImageMode(item.getAttribute('mode')))
67
+ .verticalAlign(getImageSpanAlignment(this.node?.hmStyle?.verticalAlign))
68
+ .onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', item) }, item, ['click']))
69
+ } else if (item.nodeType === NodeType.TEXT_NODE) {
70
+ Span(item.textContent)
71
+ } else if (item.tagName === 'TEXT') {
72
+ Span(item.textContent)
73
+ .attributeModifier(spanModify.setNode(item))
74
+ .letterSpacing(item._st.hmStyle.letterSpacing)
75
+ .textBackgroundStyle({
76
+ color: item._st.hmStyle.backgroundColor,
77
+ radius: {
78
+ topLeft: item._st.hmStyle.borderTopLeftRadius,
79
+ topRight: item._st.hmStyle.borderTopRightRadius,
80
+ bottomLeft: item._st.hmStyle.borderBottomLeftRadius,
81
+ bottomRight: item._st.hmStyle.borderBottomRightRadius,
82
+ }
83
+ })
84
+ .onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', item) }, item, ['click']))
85
+ }
86
+ }, (item: TaroElement) => `${item._nid}${this.node._updateTrigger}`)
87
+ }
88
+ }
89
+ .onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
90
+ .attributeModifier(textModify.setNode(this.node).withNormalStyle().setAnimationStyle(this.overwriteStyle))
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
+ }))
118
95
  }
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
96
  }
130
97
  }
98
+
99
+ function getImageSpanAlignment (align: TaroAny): TaroAny {
100
+ if (align === Alignment.Top) {
101
+ return ImageSpanAlignment.TOP
102
+ } else if (align === Alignment.Bottom) {
103
+ return ImageSpanAlignment.BOTTOM
104
+ } else if (align === Alignment.Center) {
105
+ return ImageSpanAlignment.CENTER
106
+ }
107
+ }
108
+
109
+ class SpanStyleModify implements AttributeModifier<SpanAttribute> {
110
+ node: TaroTextElement | null = null
111
+ style: HarmonyStyle | null = null
112
+ overwriteStyle: Record<string, TaroAny> = {}
113
+ withNormal = false
114
+
115
+ setNode (node: TaroTextElement) {
116
+ this.node = node
117
+ this.style = getNormalAttributes(this.node)
118
+ return this
119
+ }
120
+
121
+ applyNormalAttribute(instance: SpanAttribute): void {
122
+ if (this.node && this.style) {
123
+ setNormalTextAttributeIntoInstance(instance, this.style, this.node)
124
+ }
125
+ }
126
+ }
127
+
128
+ const spanModify = new SpanStyleModify()
@@ -1,72 +1,17 @@
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
 
8
+ interface TextareaAttrs extends TaroTextStyleType {
9
+ autoFocus?: boolean
10
+ disabled?: boolean
11
+ }
12
+
7
13
  @Extend(TextArea)
8
14
  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
15
  .fontColor(style.color)
71
16
  .fontSize(style.fontSize)
72
17
  .fontWeight(style.fontWeight)
@@ -75,9 +20,18 @@ function textStyle (style: TaroStyleType) {
75
20
  }
76
21
 
77
22
  @Extend(TextArea)
78
- function textAttr(attr: TaroTextStyleType) {
23
+ function textAttr(attr: TextareaAttrs) {
79
24
  .textAlign(attr.textAlign)
80
25
  .maxLines(attr.WebkitLineClamp)
26
+ .defaultFocus(attr.autoFocus)
27
+ .enabled(!attr.disabled)
28
+ }
29
+
30
+ function getAttributes(node: TaroTextAreaElement): TextareaAttrs {
31
+ const attrs: TaroAny = getFontAttributes(node)
32
+ attrs.autoFocus = node._attrs.autoFocus || node._attrs.focus || false
33
+ attrs.disabled = node._attrs.disabled || false
34
+ return attrs
81
35
  }
82
36
 
83
37
  function getPlaceholderColor (node: TaroTextAreaElement): string {
@@ -90,7 +44,10 @@ function getPlaceholderColor (node: TaroTextAreaElement): string {
90
44
  export default struct TaroTextArea {
91
45
  @State value: string = ''
92
46
 
93
- node: TaroTextAreaElement | null = null
47
+ @Builder customBuilder() {}
48
+ @BuilderParam createLazyChildren: (node: TaroTextAreaElement, layer?: number) => void = this.customBuilder
49
+ @ObjectLink node: TaroTextAreaElement
50
+ @State overwriteStyle: Record<string, TaroAny> = {}
94
51
 
95
52
  aboutToAppear () {
96
53
  if (this.node) {
@@ -105,36 +62,35 @@ export default struct TaroTextArea {
105
62
  }
106
63
 
107
64
  build () {
108
- if (this.node) {
109
- TextArea({ text: this.value, placeholder: this.node._attrs?.placeholder || '', controller: this.node.controller })
110
- .key(this.node._nid)
111
- .maxLength(Number(this.node._attrs?.maxlength) || null)
112
- .placeholderColor(getPlaceholderColor(this.node))
113
- .textStyle(getNormalAttributes(this.node))
114
- .textAttr(getFontAttributes(this.node))
115
- .onChange((value: string) => {
116
- const event: TaroEvent = createTaroEvent('input', { detail: { value } }, this.node)
117
-
118
- this.value = value
119
- this.node?.updateFormWidgetValue(value)
120
- eventHandler(event, 'input', this.node)
121
- })
122
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
123
- .onBlur(() => {
124
- const event: TaroEvent = createTaroEvent('blur', { detail: { value: this.value } }, this.node)
125
- eventHandler(event, 'blur', this.node)
126
- })
127
- .onFocus(() => {
128
- const event: TaroEvent = createTaroEvent('focus', { detail: { value: this.value, height: this.node?._height } }, this.node)
129
-
130
- eventHandler(event, 'focus', this.node)
131
- })
132
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
133
- if (this.node) {
134
- this.node._nodeInfo.areaInfo = res[1]
135
- }
136
- }))
137
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
138
- }
65
+ TextArea({ text: this.value, placeholder: this.node._attrs?.placeholder || '', controller: this.node.controller })
66
+ .key(this.node._nid.toString())
67
+ .maxLength(Number(this.node._attrs?.maxlength) || null)
68
+ .placeholderColor(getPlaceholderColor(this.node))
69
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
70
+ .textStyle(this.node?.hmStyle)
71
+ .textAttr(getAttributes(this.node))
72
+ .onChange((value: string) => {
73
+ const event: TaroEvent = createTaroEvent('input', { detail: { value } }, this.node)
74
+
75
+ this.value = value
76
+ this.node?.updateFormWidgetValue(value)
77
+ eventHandler(event, 'input', this.node)
78
+ })
79
+ .onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
80
+ .onBlur(() => {
81
+ const event: TaroEvent = createTaroEvent('blur', { detail: { value: this.value } }, this.node)
82
+ eventHandler(event, 'blur', this.node)
83
+ })
84
+ .onFocus(() => {
85
+ const event: TaroEvent = createTaroEvent('focus', { detail: { value: this.value, height: this.node?._height } }, this.node)
86
+
87
+ eventHandler(event, 'focus', this.node)
88
+ })
89
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
90
+ if (this.node) {
91
+ this.node._nodeInfo.areaInfo = res[1]
92
+ }
93
+ }))
94
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
139
95
  }
140
96
  }
@@ -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] }
@@ -140,7 +140,7 @@ class AttributeManager {
140
140
  }
141
141
  let resultTransform: matrix4.Matrix4Transit
142
142
 
143
- const matches = transform.match(new RegExp("/(\w+)\(([^)]+)\)/g")) || [];
143
+ const matches: string[] = transform.match(new RegExp("/(\w+)\(([^)]+)\)/g")) || [];
144
144
 
145
145
  // 处理matrix
146
146
 
@@ -11,7 +11,7 @@ export class DynamicCenter {
11
11
  if (!node._isCompileMode || !node._instance) return
12
12
 
13
13
  if (node._attrs?._dynamicID) {
14
- node._instance[node._attrs._dynamicID] = null
14
+ node._instance[node._attrs._dynamicID] = new TaroElement('Ignore')
15
15
  }
16
16
  node._instance = null
17
17
  }
@@ -36,4 +36,4 @@ export class DynamicCenter {
36
36
  this.bindComponentToNodeWithDFS(node.childNodes[i] as TaroElement, component)
37
37
  }
38
38
  }
39
- }
39
+ }