@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
@@ -0,0 +1,54 @@
1
+ import type { TaroProgressElement, TaroAny } from '@tarojs/runtime'
2
+ import commonStyleModify from './style'
3
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
4
+ import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
5
+
6
+ const PROGRESS_ACTIVECOLOR = '#09BB07'
7
+ const PROGRESS_BACKGROUNDCOLOR = '#EBEBEB'
8
+ const PROGRESS_DEFAULTINFOFONTSIZE = 16
9
+
10
+ @Component
11
+ export default struct TaroProgress {
12
+ @Builder customBuilder() {}
13
+ @BuilderParam createLazyChildren: (node: TaroProgressElement) => void = this.customBuilder
14
+ @ObjectLink node: TaroProgressElement
15
+ @State overwriteStyle: Record<string, TaroAny> = {}
16
+
17
+ aboutToAppear(): void {
18
+ if (this.node) {
19
+ this.node._instance = this
20
+ }
21
+ }
22
+
23
+ build() {
24
+ if (this.node && this.node.hmStyle?.display !== 'none') {
25
+ Row({ space: 5 }) {
26
+ Progress({
27
+ value: parseFloat(this.node.getAttribute('percent')),
28
+ type: ProgressType.Linear
29
+ })
30
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
31
+ .color(this.node.getAttribute('activeColor') ?? PROGRESS_ACTIVECOLOR)
32
+ .backgroundColor(this.node.getAttribute('backgroundColor') ?? PROGRESS_BACKGROUNDCOLOR)
33
+ .style({
34
+ strokeWidth: this.node.getAttribute('strokeWidth'),
35
+ strokeRadius: parseFloat(this.node.getAttribute('borderRadius')),
36
+ enableSmoothEffect: Boolean(this.node.getAttribute('active')),
37
+ })
38
+
39
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
40
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
41
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
42
+ if (this.node) {
43
+ this.node._nodeInfo.areaInfo = res[1]
44
+ }
45
+ }))
46
+
47
+ if (this.node.getAttribute('showInfo')) {
48
+ Text(`${this.node.getAttribute('percent')}%`)
49
+ .fontSize(this.node.getAttribute('fontSize') ?? PROGRESS_DEFAULTINFOFONTSIZE)
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,80 @@
1
+ import { getFontAttributes } from './utils/helper'
2
+ import { pseudoModify } from './style'
3
+
4
+ import type { TaroViewElement, TaroStyleType, TaroTextStyleType, TaroAny } from '@tarojs/runtime'
5
+
6
+ @Extend(Flex)
7
+ function flexAttrs (style: TaroStyleType) {
8
+ .constraintSize({
9
+ minWidth: style.minWidth,
10
+ maxWidth: style.maxWidth,
11
+ minHeight: style.minHeight || style.height,
12
+ maxHeight: style.maxHeight
13
+ })
14
+ }
15
+
16
+
17
+ @Extend(Text)
18
+ function textNormalFontStyle (style: TaroStyleType) {
19
+ .id(style.id)
20
+ .key(style.id)
21
+ .opacity(style.opacity)
22
+ .fontColor(style.color)
23
+ .fontSize(style.fontSize)
24
+ .fontWeight(style.fontWeight)
25
+ .fontStyle(style.fontStyle)
26
+ .fontFamily(style.fontFamily)
27
+ .decoration({
28
+ type: style.textDecoration,
29
+ color: style.color
30
+ })
31
+ }
32
+
33
+ @Extend(Text)
34
+ function textSpecialFontStyle(attr: TaroTextStyleType) {
35
+ .textAlign(attr.textAlign)
36
+ .align(attr.verticalAlign)
37
+ .textOverflow(attr.textOverflow)
38
+ .maxLines(attr.WebkitLineClamp)
39
+ .letterSpacing(attr.letterSpacing)
40
+ .lineHeight(attr.lineHeight)
41
+ }
42
+
43
+ @Component
44
+ export default struct PseduoChildren {
45
+ @Builder customBuilder() {}
46
+ @BuilderParam createLazyChildren: (node: TaroAny) => void = this.customBuilder
47
+ @ObjectLink node: TaroViewElement
48
+
49
+ build () {
50
+ if (true) {
51
+ // 伪类::Before
52
+ if (this.node._pseudo_before) {
53
+ if (this.node._pseudo_before?.hmStyle.content) {
54
+ Text(this.node._pseudo_before.hmStyle.content)
55
+ .attributeModifier(pseudoModify.setStyle(this.node._pseudo_before.hmStyle))
56
+ .textNormalFontStyle(this.node._pseudo_before.hmStyle || {})
57
+ .textSpecialFontStyle(getFontAttributes(this.node))
58
+ } else {
59
+ Flex() {}
60
+ .attributeModifier(pseudoModify.setStyle(this.node._pseudo_before.hmStyle || {}))
61
+ .flexAttrs(this.node._pseudo_before.hmStyle || {})
62
+ }
63
+ }
64
+ this.createLazyChildren(this.node)
65
+ // 伪类::After
66
+ if (this.node._pseudo_after) {
67
+ if (this.node._pseudo_after?.hmStyle.content) {
68
+ Text(this.node._pseudo_after.hmStyle.content)
69
+ .attributeModifier(pseudoModify.setStyle(this.node._pseudo_after.hmStyle))
70
+ .textNormalFontStyle(this.node._pseudo_after.hmStyle || {})
71
+ .textSpecialFontStyle(getFontAttributes(this.node))
72
+ } else {
73
+ Flex() {}
74
+ .attributeModifier(pseudoModify.setStyle(this.node._pseudo_after.hmStyle || {}))
75
+ .flexAttrs(this.node._pseudo_after.hmStyle || {})
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }
@@ -1,82 +1,17 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
2
2
 
3
- import { createLazyChildren } from './render'
3
+ import commonStyleModify from './style'
4
4
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
5
- import { FlexManager } from './utils/FlexManager'
6
- import { shouldBindEvent, getNormalAttributes, getNodeThresholds } from './utils/helper'
5
+ import { FlexManager } from './utils/flexManager'
6
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
7
7
 
8
- import { TaroEvent, TaroAny, TaroStyleType, HarmonyType, TaroRadioGroupElement, TaroRadioElement } from '@tarojs/runtime'
8
+ import { TaroEvent, TaroAny, HarmonyType, TaroRadioGroupElement, TaroRadioElement } from '@tarojs/runtime'
9
9
 
10
10
  interface RadioAttrs {
11
11
  radioStyle?: HarmonyType.RadioStyle
12
12
  themeStyles?: boolean
13
13
  }
14
14
 
15
- @Extend(Radio)
16
- function style (style: TaroStyleType) {
17
- .id(style.id)
18
- .key(style.id)
19
- .flexGrow(style.flexGrow)
20
- .flexShrink(style.flexShrink)
21
- .flexBasis(style.flexBasis)
22
- .alignSelf(style.alignSelf)
23
- .padding({
24
- top: style.paddingTop,
25
- right: style.paddingRight,
26
- bottom: style.paddingBottom,
27
- left: style.paddingLeft
28
- })
29
- .margin({
30
- top: style.marginTop,
31
- right: style.marginRight,
32
- bottom: style.marginBottom,
33
- left: style.marginLeft
34
- })
35
- .width(style.width)
36
- .height(style.height)
37
- .constraintSize({
38
- minWidth: style.minWidth,
39
- maxWidth: style.maxWidth,
40
- minHeight: style.minHeight,
41
- maxHeight: style.maxHeight
42
- })
43
- .backgroundColor(style.backgroundColor)
44
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
45
- .backgroundImageSize(style.backgroundSize)
46
- .backgroundImagePosition(style.backgroundPosition)
47
- .borderStyle({
48
- top: style.borderTopStyle,
49
- right: style.borderRightStyle,
50
- bottom: style.borderBottomStyle,
51
- left: style.borderLeftStyle
52
- })
53
- .borderWidth({
54
- top: style.borderTopWidth,
55
- right: style.borderRightWidth,
56
- bottom: style.borderBottomWidth,
57
- left: style.borderLeftWidth
58
- })
59
- .borderColor({
60
- top: style.borderTopColor,
61
- right: style.borderRightColor,
62
- bottom: style.borderBottomColor,
63
- left: style.borderLeftColor
64
- })
65
- .borderRadius({
66
- topLeft: style.borderTopLeftRadius,
67
- topRight: style.borderTopRightRadius,
68
- bottomLeft: style.borderBottomLeftRadius,
69
- bottomRight: style.borderBottomRightRadius
70
- })
71
- .zIndex(style.zIndex)
72
- .opacity(style.opacity)
73
- .linearGradient(style.linearGradient)
74
- .clip(style.overflow)
75
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
76
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
77
- .transform(style.transform)
78
- }
79
-
80
15
  @Extend(Radio)
81
16
  function radioAttr (attr: RadioAttrs) {
82
17
  .radioStyle(attr.radioStyle)
@@ -99,17 +34,21 @@ function themeStyles(isDisabled: boolean) {
99
34
 
100
35
  @Component
101
36
  export struct TaroRadio {
102
- node: TaroRadioElement | null = null
103
-
37
+ @Builder customBuilder() {}
38
+ @BuilderParam createLazyChildren: (node: TaroRadioElement) => void = this.customBuilder
39
+ @ObjectLink node: TaroRadioElement
40
+ @State overwriteStyle: Record<string, TaroAny> = {}
41
+
104
42
  aboutToAppear () {
105
43
  if (this.node && !this.node._isInit) {
106
44
  this.node._isInit = true
45
+ this.node._instance = this
107
46
  this.node._reset = this.node.checked || false
108
47
  }
109
48
  }
110
49
 
111
50
  build () {
112
- if (this.node) {
51
+ if (this.node && this.node.hmStyle?.display !== 'none') {
113
52
  Stack() {
114
53
  Row() {
115
54
  Radio({
@@ -117,7 +56,7 @@ export struct TaroRadio {
117
56
  value: this.node.value || '',
118
57
  })
119
58
  .checked(this.node.checked)
120
- .style(getNormalAttributes(this.node))
59
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
121
60
  .radioAttr(getAttributes(this.node))
122
61
  .onChange((value: boolean) => {
123
62
  if (this.node) {
@@ -125,7 +64,7 @@ export struct TaroRadio {
125
64
  this.node.updateComponent()
126
65
  } else {
127
66
  this.node.updateCheckedValue(value)
128
-
67
+
129
68
  if (value) {
130
69
  const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
131
70
  eventHandler(event, 'change', this.node)
@@ -156,140 +95,13 @@ export struct TaroRadio {
156
95
  }
157
96
  }
158
97
 
159
- @Extend(Column)
160
- function radioGroupColumnAttrs (style: TaroStyleType) {
161
- .id(style.id)
162
- .key(style.id)
163
- .flexGrow(style.flexGrow)
164
- .flexShrink(style.flexShrink)
165
- .flexBasis(style.flexBasis)
166
- .alignSelf(style.alignSelf)
167
- .padding({
168
- top: style.paddingTop,
169
- right: style.paddingRight,
170
- bottom: style.paddingBottom,
171
- left: style.paddingLeft
172
- })
173
- .margin({
174
- top: style.marginTop,
175
- right: style.marginRight,
176
- bottom: style.marginBottom,
177
- left: style.marginLeft
178
- })
179
- .width(style.width)
180
- .height(style.height)
181
- .constraintSize({
182
- minWidth: style.minWidth,
183
- maxWidth: style.maxWidth,
184
- minHeight: style.minHeight,
185
- maxHeight: style.maxHeight
186
- })
187
- .backgroundColor(style.backgroundColor)
188
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
189
- .backgroundImageSize(style.backgroundSize)
190
- .backgroundImagePosition(style.backgroundPosition)
191
- .borderStyle({
192
- top: style.borderTopStyle,
193
- right: style.borderRightStyle,
194
- bottom: style.borderBottomStyle,
195
- left: style.borderLeftStyle
196
- })
197
- .borderWidth({
198
- top: style.borderTopWidth,
199
- right: style.borderRightWidth,
200
- bottom: style.borderBottomWidth,
201
- left: style.borderLeftWidth
202
- })
203
- .borderColor({
204
- top: style.borderTopColor,
205
- right: style.borderRightColor,
206
- bottom: style.borderBottomColor,
207
- left: style.borderLeftColor
208
- })
209
- .borderRadius({
210
- topLeft: style.borderTopLeftRadius,
211
- topRight: style.borderTopRightRadius,
212
- bottomLeft: style.borderBottomLeftRadius,
213
- bottomRight: style.borderBottomRightRadius
214
- })
215
- .zIndex(style.zIndex)
216
- .opacity(style.opacity)
217
- .linearGradient(style.linearGradient)
218
- .clip(style.overflow)
219
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
220
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
221
- .transform(style.transform)
222
- }
223
-
224
- @Extend(Row)
225
- function radioGroupRowAttrs (style: TaroStyleType) {
226
- .id(style.id)
227
- .key(style.id)
228
- .flexGrow(style.flexGrow)
229
- .flexShrink(style.flexShrink)
230
- .flexBasis(style.flexBasis)
231
- .alignSelf(style.alignSelf)
232
- .padding({
233
- top: style.paddingTop,
234
- right: style.paddingRight,
235
- bottom: style.paddingBottom,
236
- left: style.paddingLeft
237
- })
238
- .margin({
239
- top: style.marginTop,
240
- right: style.marginRight,
241
- bottom: style.marginBottom,
242
- left: style.marginLeft
243
- })
244
- .width(style.width)
245
- .height(style.height)
246
- .constraintSize({
247
- minWidth: style.minWidth,
248
- maxWidth: style.maxWidth,
249
- minHeight: style.minHeight,
250
- maxHeight: style.maxHeight
251
- })
252
- .backgroundColor(style.backgroundColor)
253
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
254
- .backgroundImageSize(style.backgroundSize)
255
- .backgroundImagePosition(style.backgroundPosition)
256
- .borderStyle({
257
- top: style.borderTopStyle,
258
- right: style.borderRightStyle,
259
- bottom: style.borderBottomStyle,
260
- left: style.borderLeftStyle
261
- })
262
- .borderWidth({
263
- top: style.borderTopWidth,
264
- right: style.borderRightWidth,
265
- bottom: style.borderBottomWidth,
266
- left: style.borderLeftWidth
267
- })
268
- .borderColor({
269
- top: style.borderTopColor,
270
- right: style.borderRightColor,
271
- bottom: style.borderBottomColor,
272
- left: style.borderLeftColor
273
- })
274
- .borderRadius({
275
- topLeft: style.borderTopLeftRadius,
276
- topRight: style.borderTopRightRadius,
277
- bottomLeft: style.borderBottomLeftRadius,
278
- bottomRight: style.borderBottomRightRadius
279
- })
280
- .zIndex(style.zIndex)
281
- .opacity(style.opacity)
282
- .linearGradient(style.linearGradient)
283
- .clip(style.overflow)
284
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
285
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
286
- .transform(style.transform)
287
- }
288
-
289
98
 
290
99
  @Component
291
100
  export struct TaroRadioGroup {
292
- node: TaroRadioGroupElement | null = null
101
+ @Builder customBuilder() {}
102
+ @BuilderParam createLazyChildren: (node: TaroRadioGroupElement) => void = this.customBuilder
103
+ @ObjectLink node: TaroRadioGroupElement
104
+ @State overwriteStyle: Record<string, TaroAny> = {}
293
105
 
294
106
  @Styles visibleChangeEvent () {
295
107
  .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
@@ -297,6 +109,7 @@ export struct TaroRadioGroup {
297
109
 
298
110
  aboutToAppear () {
299
111
  if (this.node) {
112
+ this.node._instance = this
300
113
  const childList = this.node.getElementsByTagName<TaroRadioElement>('RADIO')
301
114
  childList.forEach(element => {
302
115
  element.group = this.node?._attrs.name || this.node?._nid
@@ -317,21 +130,21 @@ export struct TaroRadioGroup {
317
130
  }
318
131
 
319
132
  build() {
320
- if (this.node) {
133
+ if (this.node && this.node.hmStyle?.display !== 'none') {
321
134
  if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
322
135
  Row() {
323
- createLazyChildren(this.node)
136
+ this.createLazyChildren(this.node)
324
137
  }
325
- .radioGroupRowAttrs(getNormalAttributes(this.node))
138
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
326
139
  .defaultEvent()
327
140
  .visibleChangeEvent()
328
141
  .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
329
142
  .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
330
143
  } else {
331
144
  Column() {
332
- createLazyChildren(this.node)
145
+ this.createLazyChildren(this.node)
333
146
  }
334
- .radioGroupColumnAttrs(getNormalAttributes(this.node))
147
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
335
148
  .defaultEvent()
336
149
  .visibleChangeEvent()
337
150
  .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
@@ -1,107 +1,27 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
-
4
- import { getNodeThresholds, getNormalAttributes, shouldBindEvent } from './utils/helper'
5
-
6
- import type { RichTextProps } from '@tarojs/components/types/RichText'
7
- import type { TaroAny, TaroStyleType, TaroRichTextElement } from '@tarojs/runtime'
8
-
9
- @Extend(RichText)
10
- function attrs (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
-
75
- function generateText (node: TaroRichTextElement): string {
76
- return parseHtmlNode(node._attrs.nodes || '')
77
- }
78
-
79
- @Builder
80
- export default function TaroRichText (node: TaroRichTextElement) {
81
- RichText(generateText(node))
82
- .attrs(getNormalAttributes(node))
83
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
84
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
85
- node._nodeInfo.areaInfo = res[1]
86
- }))
87
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
88
- }
89
-
90
- // 将nodeTree转换成harmony需要的string结构
91
- function nodeToHtml(node: RichTextProps.Text | RichTextProps.HTMLElement): string {
92
- if (node.type === 'text') {
93
- return node.text;
94
- }
95
- if (node.attrs) {
96
- const attributes = Object.entries(node.attrs)
97
- .map((item: [string, string]) => `${item[0]}="${item[1]}"`)
98
- .join(' ');
99
- const childrenHtml: string = typeof node.children === 'string' ? node.children : (node.children || []).map((child: RichTextProps.Text | RichTextProps.HTMLElement) => nodeToHtml(child)).join('');
100
- return `<${node.name}${attributes ? ' ' + attributes : ''}>${childrenHtml}</${node.name}>`;
3
+ import commonStyleModify from './style'
4
+ import { generateText } from './utils'
5
+ import { getNodeThresholds, shouldBindEvent } from './utils/helper'
6
+
7
+ import type { TaroAny, TaroRichTextElement } from '@tarojs/runtime'
8
+
9
+ @Component
10
+ export default struct TaroRichText {
11
+ @Builder customBuilder() {}
12
+ @BuilderParam createLazyChildren: (node: TaroRichTextElement) => void = this.customBuilder
13
+ @ObjectLink node: TaroRichTextElement
14
+
15
+ build () {
16
+ if (this.node.hmStyle?.display !== 'none') {
17
+ RichText(generateText(this.node))
18
+ .attributeModifier(commonStyleModify.setNode(this.node))
19
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
20
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
21
+ this.node._nodeInfo.areaInfo = res[1]
22
+ }))
23
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
24
+ }
101
25
  }
102
- return ''
103
26
  }
104
27
 
105
- function parseHtmlNode (nodes: Array<RichTextProps.Text | RichTextProps.HTMLElement> | string) {
106
- return typeof nodes === 'string' ? nodes: `<div>${nodes.map(node => nodeToHtml(node)).join('')}</div>`
107
- }