@tarojs/plugin-platform-harmony-ets 4.0.0-beta.11 → 4.0.0-beta.111

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 (129) 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 +16 -8
  4. package/dist/apis/framework/index.ts +1 -5
  5. package/dist/apis/index.ts +25 -17
  6. package/dist/apis/media/image/index.ts +1 -1
  7. package/dist/apis/storage/index.ts +135 -131
  8. package/dist/apis/ui/animation/animation.ts +71 -29
  9. package/dist/apis/ui/background.ts +2 -1
  10. package/dist/apis/ui/interaction/index.ts +42 -59
  11. package/dist/apis/ui/navigation-bar/index.ts +1 -1
  12. package/dist/apis/ui/pull-down-refresh.ts +9 -3
  13. package/dist/apis/ui/scroll/index.ts +5 -5
  14. package/dist/apis/ui/tab-bar.ts +3 -3
  15. package/dist/apis/utils/index.ts +2 -1
  16. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  17. package/dist/apis/wxml/selectorQuery.ts +26 -13
  18. package/dist/components-harmony-ets/button.ets +35 -8
  19. package/dist/components-harmony-ets/canvas.ets +51 -0
  20. package/dist/components-harmony-ets/checkbox.ets +70 -60
  21. package/dist/components-harmony-ets/form.ets +35 -16
  22. package/dist/components-harmony-ets/icon.ets +16 -8
  23. package/dist/components-harmony-ets/image.ets +22 -6
  24. package/dist/components-harmony-ets/index.ets +92 -0
  25. package/dist/components-harmony-ets/innerHtml.ets +6 -5
  26. package/dist/components-harmony-ets/input.ets +62 -40
  27. package/dist/components-harmony-ets/label.ets +44 -21
  28. package/dist/components-harmony-ets/listView.ets +31 -0
  29. package/dist/components-harmony-ets/movableArea.ets +112 -53
  30. package/dist/components-harmony-ets/movableView.ets +75 -48
  31. package/dist/components-harmony-ets/navigationBar.ets +65 -0
  32. package/dist/components-harmony-ets/pageMeta.ets +94 -0
  33. package/dist/components-harmony-ets/picker.ets +41 -38
  34. package/dist/components-harmony-ets/progress.ets +31 -24
  35. package/dist/components-harmony-ets/pseudo.ets +80 -0
  36. package/dist/components-harmony-ets/radio.ets +76 -66
  37. package/dist/components-harmony-ets/richText.ets +4 -25
  38. package/dist/components-harmony-ets/scrollList.ets +103 -0
  39. package/dist/components-harmony-ets/scrollView.ets +47 -47
  40. package/dist/components-harmony-ets/slider.ets +18 -14
  41. package/dist/components-harmony-ets/stickySection.ets +42 -0
  42. package/dist/components-harmony-ets/style.ets +386 -130
  43. package/dist/components-harmony-ets/swiper.ets +41 -4
  44. package/dist/components-harmony-ets/switch.ets +35 -31
  45. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  46. package/dist/components-harmony-ets/text.ets +102 -46
  47. package/dist/components-harmony-ets/textArea.ets +49 -34
  48. package/dist/components-harmony-ets/utils/AttributeManager.ets +2 -2
  49. package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -2
  50. package/dist/components-harmony-ets/utils/flexManager.ets +49 -19
  51. package/dist/components-harmony-ets/utils/helper.ets +20 -8
  52. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  53. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  54. package/dist/components-harmony-ets/utils/index.ts +54 -50
  55. package/dist/components-harmony-ets/utils/styles.ets +170 -93
  56. package/dist/components-harmony-ets/video.ets +27 -19
  57. package/dist/components-harmony-ets/view.ets +47 -40
  58. package/dist/components-harmony-ets/webView.ets +6 -5
  59. package/dist/index.d.ts +152 -0
  60. package/dist/index.js +69 -43
  61. package/dist/index.js.map +1 -1
  62. package/dist/runtime-ets/bom/document.ts +6 -4
  63. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  64. package/dist/runtime-ets/bom/window.ts +7 -0
  65. package/dist/runtime-ets/current.ts +5 -1
  66. package/dist/runtime-ets/dom/bind.ts +28 -12
  67. package/dist/runtime-ets/dom/class-list.ts +2 -2
  68. package/dist/runtime-ets/dom/cssNesting.ts +419 -0
  69. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +28 -42
  70. package/dist/runtime-ets/dom/document.ts +8 -11
  71. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  72. package/dist/runtime-ets/dom/element/element.ts +376 -56
  73. package/dist/runtime-ets/dom/element/form.ts +20 -22
  74. package/dist/runtime-ets/dom/element/index.ts +22 -2
  75. package/dist/runtime-ets/dom/element/movableArea.ts +0 -1
  76. package/dist/runtime-ets/dom/element/movableView.ts +234 -2
  77. package/dist/runtime-ets/dom/element/normal.ts +27 -6
  78. package/dist/runtime-ets/dom/element/progress.ts +0 -2
  79. package/dist/runtime-ets/dom/element/text.ts +0 -8
  80. package/dist/runtime-ets/dom/element/video.ts +4 -4
  81. package/dist/runtime-ets/dom/element/webView.ts +4 -5
  82. package/dist/runtime-ets/dom/event.ts +3 -5
  83. package/dist/runtime-ets/dom/eventTarget.ts +2 -3
  84. package/dist/runtime-ets/dom/node.ts +51 -19
  85. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +418 -237
  86. package/dist/runtime-ets/dom/stylesheet/index.ts +29 -311
  87. package/dist/runtime-ets/dom/stylesheet/type.ts +51 -9
  88. package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
  89. package/dist/runtime-ets/index.ts +2 -1
  90. package/dist/runtime-ets/interface/event.ts +1 -1
  91. package/dist/runtime-ets/utils/index.ts +74 -13
  92. package/dist/runtime-ets/utils/info.ts +2 -2
  93. package/dist/runtime-framework/react/app.ts +15 -10
  94. package/dist/runtime-framework/react/hooks.ts +0 -1
  95. package/dist/runtime-framework/react/index.ts +0 -2
  96. package/dist/runtime-framework/react/native-page.ts +185 -78
  97. package/dist/runtime-framework/react/page.ts +4 -9
  98. package/dist/runtime-framework/react/utils/index.ts +3 -3
  99. package/dist/runtime-framework/solid/app.ts +30 -46
  100. package/dist/runtime-framework/solid/connect.ts +21 -3
  101. package/dist/runtime-framework/solid/hooks.ts +16 -11
  102. package/dist/runtime-framework/solid/index.ts +6 -2
  103. package/dist/runtime-framework/solid/page.ts +85 -31
  104. package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
  105. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  106. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  107. package/dist/runtime-framework/solid/utils/index.ts +3 -5
  108. package/dist/runtime-utils.d.ts +827 -0
  109. package/dist/runtime-utils.js +425 -253
  110. package/dist/runtime-utils.js.map +1 -1
  111. package/dist/runtime.d.ts +1 -0
  112. package/dist/runtime.js +425 -253
  113. package/dist/runtime.js.map +1 -1
  114. package/index.js +3 -1
  115. package/package.json +14 -15
  116. package/static/media/cancel.svg +1 -1
  117. package/static/media/circle.svg +1 -1
  118. package/static/media/clear.svg +1 -1
  119. package/static/media/download.svg +1 -1
  120. package/static/media/info.svg +1 -1
  121. package/static/media/info_circle.svg +1 -1
  122. package/static/media/search.svg +1 -1
  123. package/static/media/success.svg +1 -1
  124. package/static/media/success_no_circle.svg +1 -1
  125. package/static/media/warn.svg +1 -1
  126. package/types/harmony.d.ts +4 -0
  127. package/types/index.d.ts +4 -0
  128. package/types/runtime.d.ts +1 -1
  129. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -0,0 +1,65 @@
1
+ import { eventCenter } from '@tarojs/runtime/dist/runtime.esm'
2
+
3
+ import { isTagFirstChild } from './utils/helper'
4
+
5
+ import type { TaroAny, TaroNavigationBarElement } from '@tarojs/runtime'
6
+ import type { IComponentAttributeUpdateEvents } from './pageMeta'
7
+
8
+ @Component
9
+ export default struct TaroNavigationBar {
10
+ @Builder customBuilder() {}
11
+ @BuilderParam createLazyChildren: (node: TaroNavigationBarElement, layer?: number) => void = this.customBuilder
12
+ @ObjectLink node: TaroNavigationBarElement
13
+
14
+ aboutToAppear(): void {
15
+ if (!isTagFirstChild(this.node, 'page-meta')) {
16
+ console.error('NavigationBar 只能是 PageMeta 内的第一个节点。')
17
+ }
18
+ if (this.node) {
19
+ this.node._instance = this
20
+ }
21
+
22
+ // FIXME 在 Harmony 提供 @Watch 文档后,根据 node 实际使用更细粒度的监听
23
+ eventCenter?.on('__taroComponentAttributeUpdate', this.handleAttributeUpdate)
24
+ this.handleAttributes(this.node._attrs)
25
+ }
26
+
27
+ aboutToDisappear(): void {
28
+ eventCenter?.off('__taroComponentAttributeUpdate', this.handleAttributeUpdate)
29
+ }
30
+
31
+ handleAttributeUpdate = (opt: IComponentAttributeUpdateEvents) => {
32
+ if (opt.id === this.node._nid.toString() && opt.tagName === 'NAVIGATION-BAR') {
33
+ const attrs: Record<string, TaroAny> = {}
34
+ attrs[opt.attribute] = opt.value
35
+ this.handleAttributes(attrs)
36
+ }
37
+ }
38
+
39
+ handleAttributes (attrs: Record<string, TaroAny>) {
40
+ const options: Record<string, TaroAny> = {}
41
+
42
+ if (attrs.title) {
43
+ options.title = attrs.title
44
+ }
45
+ if (attrs.loading) {
46
+ options.loading = attrs.loading
47
+ }
48
+ if (attrs.backgroundColor) {
49
+ options.backgroundColor = attrs.backgroundColor
50
+ }
51
+ if (attrs.frontColor) {
52
+ options.frontColor = attrs.frontColor
53
+ }
54
+ eventCenter?.trigger('__taroNavigationStyle', options)
55
+ // FIXME: 以下属性暂时不支持
56
+ // attrs.colorAnimationDuration
57
+ // attrs.colorAnimationTimingFunc
58
+ }
59
+
60
+ build() {
61
+ if (true) {
62
+ this.createLazyChildren(this.node, 0)
63
+ }
64
+ }
65
+ }
@@ -0,0 +1,94 @@
1
+ import { APP, eventCenter } from '@tarojs/runtime/dist/runtime.esm'
2
+ import { getCurrentInstance, pageScrollTo } from '@tarojs/taro'
3
+
4
+ import { isTagFirstChild } from './utils/helper'
5
+
6
+ import type { TaroAny, TaroPageMetaElement } from '@tarojs/runtime'
7
+
8
+ export interface IComponentAttributeUpdateEvents {
9
+ id: string
10
+ tagName: string
11
+ attribute: string
12
+ value: TaroAny
13
+ }
14
+
15
+ @Component
16
+ export default struct TaroPageMeta {
17
+ @Builder customBuilder() {}
18
+ @BuilderParam createLazyChildren: (node: TaroPageMetaElement, layer?: number) => void = this.customBuilder
19
+ @ObjectLink node: TaroPageMetaElement
20
+
21
+ page: TaroAny = {}
22
+
23
+ aboutToAppear(): void {
24
+ if (!isTagFirstChild(this.node, APP, 2)) {
25
+ // PageMeta 只能是页面内的第一个元素
26
+ console.error('PageMeta 只能是页面内的第一个元素。')
27
+ }
28
+
29
+ this.page = getCurrentInstance().page
30
+ if (this.node) {
31
+ this.node._instance = this
32
+ }
33
+
34
+ // FIXME 在 Harmony 提供 @Watch 文档后,根据 node 实际使用更细粒度的监听
35
+ eventCenter?.on('__taroComponentAttributeUpdate', this.handleAttributeUpdate)
36
+ this.handleAttributes(this.node._attrs)
37
+ }
38
+
39
+ aboutToDisappear(): void {
40
+ eventCenter?.off('__taroComponentAttributeUpdate', this.handleAttributeUpdate)
41
+ }
42
+
43
+ handleAttributeUpdate = (opt: IComponentAttributeUpdateEvents) => {
44
+ if (opt.id === this.node._nid.toString() && opt.tagName === 'PAGE-META') {
45
+ const attrs: Record<string, TaroAny> = {}
46
+ attrs[opt.attribute] = opt.value
47
+ this.handleAttributes(attrs)
48
+ }
49
+ }
50
+
51
+ handleAttributes (attrs: Record<string, TaroAny>) {
52
+ const options: Record<string, TaroAny> = {}
53
+ let triggerStyleEvent = false
54
+
55
+ // FIXME 更新类型支持度
56
+ if (attrs.backgroundColorTop || attrs.rootBackgroundColor || attrs.backgroundColor) {
57
+ options.backgroundColorContext = attrs.backgroundColorTop || attrs.rootBackgroundColor || attrs.backgroundColor
58
+ triggerStyleEvent = true
59
+ }
60
+ if (attrs.backgroundColorBottom || attrs.backgroundColor) {
61
+ options.backgroundColor = attrs.backgroundColorBottom || attrs.backgroundColor
62
+ triggerStyleEvent = true
63
+ }
64
+ if (attrs.backgroundTextStyle) {
65
+ options.backgroundTextStyle = attrs.backgroundTextStyle
66
+ triggerStyleEvent = true
67
+ }
68
+
69
+ if (this.page === getCurrentInstance().page) {
70
+ if (attrs.scrollTop || attrs.scrollDuration) {
71
+ pageScrollTo({
72
+ scrollTop: attrs.scrollTop || this.node._attrs.scrollTop,
73
+ duration: attrs.scrollDuration || this.node._attrs.scrollDuration,
74
+ } as TaroAny)
75
+ }
76
+ }
77
+ // pageStyle
78
+ // rootFontSize
79
+ // pageFontSize
80
+ // pageOrientation
81
+ if (triggerStyleEvent) {
82
+ eventCenter?.trigger('__taroPageStyle', options)
83
+ }
84
+ // onResize
85
+ // onScroll
86
+ // onScrollDone
87
+ }
88
+
89
+ build() {
90
+ if (true) {
91
+ this.createLazyChildren(this.node, 0)
92
+ }
93
+ }
94
+ }
@@ -1,14 +1,13 @@
1
1
  import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, TaroPickerElement, createTaroEvent } from '@tarojs/runtime'
2
- import { createLazyChildren } from './render'
3
2
  import commonStyleModify from './style'
4
3
  import { getSingleSelector, getMultiSelector } from './utils'
5
4
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
6
- import { FlexManager } from './utils/FlexManager'
7
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
5
+ import { FlexManager } from './utils/flexManager'
6
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
8
7
 
9
8
  import type { TaroAny, TaroEvent } from '@tarojs/runtime'
10
9
 
11
- import { PickerDateProps, PickerMultiSelectorProps, PickerSelectorProps, PickerTimeProps } from './types'
10
+ import { PickerDateProps, PickerMultiSelectorProps, PickerSelectorProps, PickerTimeProps } from '@tarojs/components/types'
12
11
 
13
12
  interface TimeRange {
14
13
  startHH: number
@@ -146,9 +145,10 @@ export struct PickerView {
146
145
  color: '#000'
147
146
  })
148
147
  .canLoop(false)
149
- .attributeModifier(commonStyleModify.setNode(this.node))
150
- .width(getNormalAttributes(this.node).width || '100%')
151
- .backgroundColor(getNormalAttributes(this.node).backgroundColor || '#fff')
148
+ .attributeModifier(commonStyleModify.setNode(this.node, {
149
+ width: '100%',
150
+ backgroundColor: '#fff'
151
+ }))
152
152
  .onChange((_, index) => {
153
153
  this.node?.updateFormWidgetValue(index)
154
154
  })
@@ -158,9 +158,10 @@ export struct PickerView {
158
158
  color: '#000'
159
159
  })
160
160
  .canLoop(false)
161
- .attributeModifier(commonStyleModify.setNode(this.node))
162
- .width(getNormalAttributes(this.node).width || '100%')
163
- .backgroundColor(getNormalAttributes(this.node).backgroundColor || '#fff')
161
+ .attributeModifier(commonStyleModify.setNode(this.node, {
162
+ width: '100%',
163
+ backgroundColor: '#fff'
164
+ }))
164
165
  .onChange((_, index) => {
165
166
  if (index instanceof Array) {
166
167
  this.node?.updateFormWidgetValue(index)
@@ -187,9 +188,10 @@ export struct PickerView {
187
188
  .selectedTextStyle({
188
189
  color: '#000'
189
190
  })
190
- .attributeModifier(commonStyleModify.setNode(this.node))
191
- .width(getNormalAttributes(this.node).width || '100%')
192
- .backgroundColor(getNormalAttributes(this.node).backgroundColor || '#fff')
191
+ .attributeModifier(commonStyleModify.setNode(this.node, {
192
+ width: '100%',
193
+ backgroundColor: '#fff'
194
+ }))
193
195
  .onDateChange(value => {
194
196
  const data = value.toLocaleDateString().split('/')
195
197
  const day = data[1]
@@ -203,9 +205,10 @@ export struct PickerView {
203
205
  color: '#000'
204
206
  })
205
207
  .canLoop(false)
206
- .attributeModifier(commonStyleModify.setNode(this.node))
207
- .width(getNormalAttributes(this.node).width || '100%')
208
- .backgroundColor(getNormalAttributes(this.node).backgroundColor || '#fff')
208
+ .attributeModifier(commonStyleModify.setNode(this.node, {
209
+ width: '100%',
210
+ backgroundColor: '#fff'
211
+ }))
209
212
  .onChange((value) => {
210
213
  this.node?.updateFormWidgetValue(`${('00'+value[0]).slice(-2)}:${('00'+value[1]).slice(-2)}`)
211
214
  })
@@ -222,6 +225,8 @@ export struct PickerView {
222
225
 
223
226
  @Component
224
227
  export default struct TaroPicker {
228
+ @Builder customBuilder() {}
229
+ @BuilderParam createLazyChildren: (node: TaroPickerElement, layer?: number) => void = this.customBuilder
225
230
  @ObjectLink node: TaroPickerElement
226
231
 
227
232
  aboutToAppear () {
@@ -238,8 +243,8 @@ export default struct TaroPicker {
238
243
  break
239
244
  case 'time': {
240
245
  const hour = new Date().getHours()
241
- const minute = new Date().getMinutes()
242
-
246
+ const minute = new Date().getMinutes()
247
+
243
248
  defaultResetValue = `${('00'+hour).slice(-2)}:${('00'+minute).slice(-2)}`
244
249
  break
245
250
  }
@@ -248,7 +253,7 @@ export default struct TaroPicker {
248
253
  const day = data[1]
249
254
  const month = data[0]
250
255
  const year = data[2]
251
-
256
+
252
257
  defaultResetValue = `${year}-${month}-${day}`
253
258
  break
254
259
  }
@@ -256,7 +261,7 @@ export default struct TaroPicker {
256
261
  defaultResetValue = ''
257
262
  break
258
263
  }
259
-
264
+
260
265
  this.node._isInit = true
261
266
  this.node._reset = this.node.value || defaultResetValue
262
267
  }
@@ -293,7 +298,7 @@ export default struct TaroPicker {
293
298
  .onClick((e: ClickEvent) => {
294
299
  eventHandler(e, 'click', this.node)
295
300
  })
296
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
301
+ .onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
297
302
  .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
298
303
  if (this.node) {
299
304
  this.node._nodeInfo.areaInfo = res[1]
@@ -306,24 +311,22 @@ export default struct TaroPicker {
306
311
  }
307
312
 
308
313
  build() {
309
- if (this.node) {
310
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
311
- Row() {
312
- createLazyChildren(this.node)
313
- }
314
- .defaultEvent()
315
- .visibleChangeEvent()
316
- .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
317
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
318
- } else {
319
- Column() {
320
- createLazyChildren(this.node)
321
- }
322
- .defaultEvent()
323
- .visibleChangeEvent()
324
- .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
325
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
314
+ if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
315
+ Row() {
316
+ this.createLazyChildren(this.node, 0)
317
+ }
318
+ .defaultEvent()
319
+ .visibleChangeEvent()
320
+ .alignItems(FlexManager.alignItems<VerticalAlign>(this.node))
321
+ .justifyContent(FlexManager.justifyContent(this.node))
322
+ } else {
323
+ Column() {
324
+ this.createLazyChildren(this.node, 0)
326
325
  }
326
+ .defaultEvent()
327
+ .visibleChangeEvent()
328
+ .alignItems(FlexManager.alignItems<HorizontalAlign>(this.node))
329
+ .justifyContent(FlexManager.justifyContent(this.node))
327
330
  }
328
331
  }
329
332
  }
@@ -9,36 +9,43 @@ const PROGRESS_DEFAULTINFOFONTSIZE = 16
9
9
 
10
10
  @Component
11
11
  export default struct TaroProgress {
12
+ @Builder customBuilder() {}
13
+ @BuilderParam createLazyChildren: (node: TaroProgressElement, layer?: number) => void = this.customBuilder
12
14
  @ObjectLink node: TaroProgressElement
15
+ @State overwriteStyle: Record<string, TaroAny> = {}
13
16
 
14
- build() {
17
+ aboutToAppear(): void {
15
18
  if (this.node) {
16
- Row({ space: 5 }) {
17
- Progress({
18
- value: parseFloat(this.node.getAttribute('percent')),
19
- type: ProgressType.Linear
19
+ this.node._instance = this
20
+ }
21
+ }
22
+
23
+ build() {
24
+ Row({ space: 5 }) {
25
+ Progress({
26
+ value: parseFloat(this.node.getAttribute('percent')),
27
+ type: ProgressType.Linear
28
+ })
29
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
30
+ .color(this.node.getAttribute('activeColor') ?? PROGRESS_ACTIVECOLOR)
31
+ .backgroundColor(this.node.getAttribute('backgroundColor') ?? PROGRESS_BACKGROUNDCOLOR)
32
+ .style({
33
+ strokeWidth: this.node.getAttribute('strokeWidth'),
34
+ strokeRadius: parseFloat(this.node.getAttribute('borderRadius')),
35
+ enableSmoothEffect: Boolean(this.node.getAttribute('active')),
20
36
  })
21
- .attributeModifier(commonStyleModify.setNode(this.node))
22
- .color(this.node.getAttribute('activeColor') ?? PROGRESS_ACTIVECOLOR)
23
- .backgroundColor(this.node.getAttribute('backgroundColor') ?? PROGRESS_BACKGROUNDCOLOR)
24
- .style({
25
- strokeWidth: this.node.getAttribute('strokeWidth'),
26
- strokeRadius: parseFloat(this.node.getAttribute('borderRadius')),
27
- enableSmoothEffect: Boolean(this.node.getAttribute('active')),
28
- })
29
37
 
30
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
31
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
32
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
33
- if (this.node) {
34
- this.node._nodeInfo.areaInfo = res[1]
35
- }
36
- }))
38
+ .onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
39
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
40
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
41
+ if (this.node) {
42
+ this.node._nodeInfo.areaInfo = res[1]
43
+ }
44
+ }))
37
45
 
38
- if (this.node.getAttribute('showInfo')) {
39
- Text(`${this.node.getAttribute('percent')}%`)
40
- .fontSize(this.node.getAttribute('fontSize') ?? PROGRESS_DEFAULTINFOFONTSIZE)
41
- }
46
+ if (this.node.getAttribute('showInfo')) {
47
+ Text(`${this.node.getAttribute('percent')}%`)
48
+ .fontSize(this.node.getAttribute('fontSize') ?? PROGRESS_DEFAULTINFOFONTSIZE)
42
49
  }
43
50
  }
44
51
  }
@@ -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?.type || TextDecorationType.None,
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, layer?: number) => 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, 0)
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
+ }