@tarojs/plugin-platform-harmony-ets 4.0.0-beta.5 → 4.0.0-beta.50

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 (122) hide show
  1. package/dist/apis/base/system.ts +53 -20
  2. package/dist/apis/canvas/index.ts +10 -1
  3. package/dist/apis/device/clipboard.ts +4 -0
  4. package/dist/apis/framework/index.ts +1 -5
  5. package/dist/apis/index.ts +27 -17
  6. package/dist/apis/network/request.ts +5 -5
  7. package/dist/apis/route/index.ts +15 -0
  8. package/dist/apis/storage/index.ts +148 -80
  9. package/dist/apis/ui/animation/animation.ts +71 -28
  10. package/dist/apis/ui/background.ts +2 -1
  11. package/dist/apis/ui/interaction/index.ts +40 -49
  12. package/dist/apis/ui/navigation-bar/index.ts +1 -1
  13. package/dist/apis/utils/index.ts +1 -1
  14. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  15. package/dist/apis/wxml/index.ts +2 -0
  16. package/dist/apis/wxml/selectorQuery.ts +18 -9
  17. package/dist/components-harmony-ets/button.ets +48 -34
  18. package/dist/components-harmony-ets/canvas.ets +51 -0
  19. package/dist/components-harmony-ets/checkbox.ets +69 -61
  20. package/dist/components-harmony-ets/form.ets +51 -29
  21. package/dist/components-harmony-ets/icon.ets +31 -19
  22. package/dist/components-harmony-ets/image.ets +27 -14
  23. package/dist/components-harmony-ets/index.ets +85 -0
  24. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  25. package/dist/components-harmony-ets/input.ets +41 -40
  26. package/dist/components-harmony-ets/label.ets +69 -42
  27. package/dist/components-harmony-ets/movableArea.ets +126 -0
  28. package/dist/components-harmony-ets/movableView.ets +73 -0
  29. package/dist/components-harmony-ets/navigationBar.ets +25 -0
  30. package/dist/components-harmony-ets/pageMeta.ets +28 -0
  31. package/dist/components-harmony-ets/picker.ets +42 -38
  32. package/dist/components-harmony-ets/progress.ets +52 -0
  33. package/dist/components-harmony-ets/pseudo.ets +80 -0
  34. package/dist/components-harmony-ets/radio.ets +71 -64
  35. package/dist/components-harmony-ets/richText.ets +14 -30
  36. package/dist/components-harmony-ets/scrollView.ets +61 -57
  37. package/dist/components-harmony-ets/slider.ets +15 -14
  38. package/dist/components-harmony-ets/style.ets +390 -130
  39. package/dist/components-harmony-ets/swiper.ets +38 -20
  40. package/dist/components-harmony-ets/switch.ets +30 -28
  41. package/dist/components-harmony-ets/{index.ts → tag.ts} +2 -0
  42. package/dist/components-harmony-ets/text.ets +121 -51
  43. package/dist/components-harmony-ets/textArea.ets +35 -34
  44. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  45. package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
  46. package/dist/components-harmony-ets/utils/flexManager.ets +47 -19
  47. package/dist/components-harmony-ets/utils/helper.ets +17 -5
  48. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  49. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  50. package/dist/components-harmony-ets/utils/index.ts +50 -51
  51. package/dist/components-harmony-ets/utils/styles.ets +170 -93
  52. package/dist/components-harmony-ets/video.ets +34 -20
  53. package/dist/components-harmony-ets/view.ets +63 -52
  54. package/dist/components-harmony-ets/webView.ets +40 -34
  55. package/dist/index.d.ts +152 -0
  56. package/dist/index.js +82 -39
  57. package/dist/index.js.map +1 -1
  58. package/dist/runtime-ets/bom/document.ts +6 -4
  59. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  60. package/dist/runtime-ets/bom/window.ts +7 -0
  61. package/dist/runtime-ets/current.ts +3 -0
  62. package/dist/runtime-ets/dom/bind.ts +31 -13
  63. package/dist/runtime-ets/dom/cssNesting.ts +393 -0
  64. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +25 -39
  65. package/dist/runtime-ets/dom/document.ts +22 -8
  66. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  67. package/dist/runtime-ets/dom/element/element.ts +317 -51
  68. package/dist/runtime-ets/dom/element/form.ts +23 -26
  69. package/dist/runtime-ets/dom/element/index.ts +24 -2
  70. package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
  71. package/dist/runtime-ets/dom/element/movableView.ts +193 -0
  72. package/dist/runtime-ets/dom/element/normal.ts +35 -8
  73. package/dist/runtime-ets/dom/element/progress.ts +12 -0
  74. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  75. package/dist/runtime-ets/dom/element/text.ts +1 -8
  76. package/dist/runtime-ets/dom/element/video.ts +5 -3
  77. package/dist/runtime-ets/dom/element/webView.ts +11 -3
  78. package/dist/runtime-ets/dom/event.ts +0 -1
  79. package/dist/runtime-ets/dom/eventTarget.ts +0 -3
  80. package/dist/runtime-ets/dom/node.ts +46 -28
  81. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +334 -230
  82. package/dist/runtime-ets/dom/stylesheet/index.ts +28 -308
  83. package/dist/runtime-ets/dom/stylesheet/type.ts +40 -9
  84. package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
  85. package/dist/runtime-ets/index.ts +2 -2
  86. package/dist/runtime-ets/interface/event.ts +1 -1
  87. package/dist/runtime-ets/utils/index.ts +66 -11
  88. package/dist/runtime-ets/utils/info.ts +1 -1
  89. package/dist/runtime-framework/react/app.ts +7 -2
  90. package/dist/runtime-framework/react/index.ts +0 -2
  91. package/dist/runtime-framework/react/native-page.ts +32 -14
  92. package/dist/runtime-framework/react/page.ts +3 -8
  93. package/dist/runtime-framework/solid/app.ts +25 -45
  94. package/dist/runtime-framework/solid/connect.ts +21 -3
  95. package/dist/runtime-framework/solid/hooks.ts +16 -11
  96. package/dist/runtime-framework/solid/index.ts +6 -2
  97. package/dist/runtime-framework/solid/page.ts +84 -30
  98. package/dist/runtime-framework/solid/reconciler/props.ts +65 -20
  99. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  100. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  101. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  102. package/dist/runtime-utils.d.ts +827 -0
  103. package/dist/runtime-utils.js +399 -188
  104. package/dist/runtime-utils.js.map +1 -1
  105. package/dist/runtime.d.ts +1 -0
  106. package/dist/runtime.js +399 -188
  107. package/dist/runtime.js.map +1 -1
  108. package/index.js +3 -1
  109. package/package.json +13 -13
  110. package/static/media/cancel.svg +1 -1
  111. package/static/media/circle.svg +1 -1
  112. package/static/media/clear.svg +1 -1
  113. package/static/media/download.svg +1 -1
  114. package/static/media/info.svg +1 -1
  115. package/static/media/info_circle.svg +1 -1
  116. package/static/media/search.svg +1 -1
  117. package/static/media/success.svg +1 -1
  118. package/static/media/success_no_circle.svg +1 -1
  119. package/static/media/warn.svg +1 -1
  120. package/types/harmony.d.ts +4 -0
  121. package/types/index.d.ts +4 -0
  122. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -1,12 +1,12 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
2
2
 
3
- import commonStyleModify from './style'
4
- import { createLazyChildren } from './render'
3
+ import commonStyleModify, { rowModify, columnModify } from './style'
5
4
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
6
- import { FlexManager } from './utils/FlexManager'
5
+ import { FlexManager } from './utils/flexManager'
7
6
  import { shouldBindEvent, getNodeThresholds } from './utils/helper'
8
7
 
9
8
  import { TaroEvent, TaroAny, HarmonyType, TaroRadioGroupElement, TaroRadioElement } from '@tarojs/runtime'
9
+ import { isUndefined } from '@tarojs/shared'
10
10
 
11
11
  interface RadioAttrs {
12
12
  radioStyle?: HarmonyType.RadioStyle
@@ -35,59 +35,61 @@ function themeStyles(isDisabled: boolean) {
35
35
 
36
36
  @Component
37
37
  export struct TaroRadio {
38
- node: TaroRadioElement | null = null
39
-
38
+ @Builder customBuilder() {}
39
+ @BuilderParam createLazyChildren: (node: TaroRadioElement) => void = this.customBuilder
40
+ @ObjectLink node: TaroRadioElement
41
+ @State overwriteStyle: Record<string, TaroAny> = {}
42
+
40
43
  aboutToAppear () {
41
44
  if (this.node && !this.node._isInit) {
42
45
  this.node._isInit = true
46
+ this.node._instance = this
43
47
  this.node._reset = this.node.checked || false
44
48
  }
45
49
  }
46
50
 
47
51
  build () {
48
- if (this.node) {
49
- Stack() {
50
- Row() {
51
- Radio({
52
- group: this.node.group || this.node.parentNode?._nid || '',
53
- value: this.node.value || '',
54
- })
55
- .checked(this.node.checked)
56
- .attributeModifier(commonStyleModify.setNode(this.node))
57
- .radioAttr(getAttributes(this.node))
58
- .onChange((value: boolean) => {
59
- if (this.node) {
60
- if (!!this.node?._attrs.disabled) {
61
- this.node.updateComponent()
62
- } else {
63
- this.node.updateCheckedValue(value)
64
-
65
- if (value) {
66
- const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
67
- eventHandler(event, 'change', this.node)
68
- }
52
+ Stack() {
53
+ Row() {
54
+ Radio({
55
+ group: this.node.group || this.node.parentNode?._nid || '',
56
+ value: this.node.value || '',
57
+ })
58
+ .checked(this.node.checked)
59
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
60
+ .radioAttr(getAttributes(this.node))
61
+ .onChange((value: boolean) => {
62
+ if (this.node) {
63
+ if (!!this.node?._attrs.disabled) {
64
+ this.node.updateComponent()
65
+ } else {
66
+ this.node.updateCheckedValue(value)
67
+
68
+ if (value) {
69
+ const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
70
+ eventHandler(event, 'change', this.node)
69
71
  }
70
72
  }
71
- })
72
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
73
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
74
- if (this.node) {
75
- this.node._nodeInfo.areaInfo = res[1]
76
- }
77
- }))
78
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
79
- Text(this.node.textContent)
80
- .textAlign(TextAlign.Center)
81
- .opacity(!!this.node?._attrs.disabled ? 0.4 : 1)
82
- }
83
- .onClick(() => {
84
- if (this.node) {
85
- if (!this.node._checked && !this.node?._attrs.disabled) {
86
- this.node.checked = !this.node.checked
87
73
  }
88
- }
89
- })
74
+ })
75
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
76
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
77
+ if (this.node) {
78
+ this.node._nodeInfo.areaInfo = res[1]
79
+ }
80
+ }))
81
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
82
+ Text(this.node.textContent)
83
+ .textAlign(TextAlign.Center)
84
+ .opacity(!!this.node?._attrs.disabled ? 0.4 : 1)
90
85
  }
86
+ .onClick(() => {
87
+ if (this.node) {
88
+ if (!this.node._checked && !this.node?._attrs.disabled) {
89
+ this.node.checked = !this.node.checked
90
+ }
91
+ }
92
+ })
91
93
  }
92
94
  }
93
95
  }
@@ -95,7 +97,10 @@ export struct TaroRadio {
95
97
 
96
98
  @Component
97
99
  export struct TaroRadioGroup {
98
- node: TaroRadioGroupElement | null = null
100
+ @Builder customBuilder() {}
101
+ @BuilderParam createLazyChildren: (node: TaroRadioGroupElement) => void = this.customBuilder
102
+ @ObjectLink node: TaroRadioGroupElement
103
+ @State overwriteStyle: Record<string, TaroAny> = {}
99
104
 
100
105
  @Styles visibleChangeEvent () {
101
106
  .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
@@ -103,6 +108,7 @@ export struct TaroRadioGroup {
103
108
 
104
109
  aboutToAppear () {
105
110
  if (this.node) {
111
+ this.node._instance = this
106
112
  const childList = this.node.getElementsByTagName<TaroRadioElement>('RADIO')
107
113
  childList.forEach(element => {
108
114
  element.group = this.node?._attrs.name || this.node?._nid
@@ -123,26 +129,27 @@ export struct TaroRadioGroup {
123
129
  }
124
130
 
125
131
  build() {
126
- if (this.node) {
127
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
128
- Row() {
129
- createLazyChildren(this.node)
130
- }
131
- .attributeModifier(commonStyleModify.setNode(this.node))
132
- .defaultEvent()
133
- .visibleChangeEvent()
134
- .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
135
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
136
- } else {
137
- Column() {
138
- createLazyChildren(this.node)
139
- }
140
- .attributeModifier(commonStyleModify.setNode(this.node))
141
- .defaultEvent()
142
- .visibleChangeEvent()
143
- .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
144
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
132
+ if (FlexManager.useFlexLayout(this.node)) {
133
+ Flex(FlexManager.flexOptions(this.node)) {
134
+ this.createLazyChildren(this.node)
135
+ }
136
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
137
+ .defaultEvent()
138
+ .visibleChangeEvent()
139
+ } else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
140
+ Row() {
141
+ this.createLazyChildren(this.node)
142
+ }
143
+ .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
144
+ .defaultEvent()
145
+ .visibleChangeEvent()
146
+ } else {
147
+ Column() {
148
+ this.createLazyChildren(this.node)
145
149
  }
150
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
151
+ .defaultEvent()
152
+ .visibleChangeEvent()
146
153
  }
147
154
  }
148
155
  }
@@ -1,41 +1,25 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
3
  import commonStyleModify from './style'
4
+ import { generateText } from './utils'
4
5
  import { getNodeThresholds, shouldBindEvent } from './utils/helper'
5
6
 
6
- import type { RichTextProps } from '@tarojs/components/types/RichText'
7
7
  import type { TaroAny, TaroRichTextElement } from '@tarojs/runtime'
8
8
 
9
- function generateText (node: TaroRichTextElement): string {
10
- return parseHtmlNode(node._attrs.nodes || '')
11
- }
12
-
13
- @Builder
14
- export default function TaroRichText (node: TaroRichTextElement) {
15
- RichText(generateText(node))
16
- .attributeModifier(commonStyleModify.setNode(node))
17
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
18
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
19
- node._nodeInfo.areaInfo = res[1]
20
- }))
21
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
22
- }
9
+ @Component
10
+ export default struct TaroRichText {
11
+ @Builder customBuilder() {}
12
+ @BuilderParam createLazyChildren: (node: TaroRichTextElement) => void = this.customBuilder
13
+ @ObjectLink node: TaroRichTextElement
23
14
 
24
- // 将nodeTree转换成harmony需要的string结构
25
- function nodeToHtml(node: RichTextProps.Text | RichTextProps.HTMLElement): string {
26
- if (node.type === 'text') {
27
- return node.text;
15
+ build () {
16
+ RichText(generateText(this.node))
17
+ .attributeModifier(commonStyleModify.setNode(this.node))
18
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
19
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
20
+ this.node._nodeInfo.areaInfo = res[1]
21
+ }))
22
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
28
23
  }
29
- if (node.attrs) {
30
- const attributes = Object.entries(node.attrs)
31
- .map((item: [string, string]) => `${item[0]}="${item[1]}"`)
32
- .join(' ');
33
- const childrenHtml: string = typeof node.children === 'string' ? node.children : (node.children || []).map((child: RichTextProps.Text | RichTextProps.HTMLElement) => nodeToHtml(child)).join('');
34
- return `<${node.name}${attributes ? ' ' + attributes : ''}>${childrenHtml}</${node.name}>`;
35
- }
36
- return ''
37
24
  }
38
25
 
39
- function parseHtmlNode (nodes: Array<RichTextProps.Text | RichTextProps.HTMLElement> | string) {
40
- return typeof nodes === 'string' ? nodes: `<div>${nodes.map(node => nodeToHtml(node)).join('')}</div>`
41
- }
@@ -1,12 +1,12 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
2
2
 
3
3
  import commonStyleModify from './style'
4
- import { createLazyChildren } from './render'
5
- import { FlexManager } from './utils/FlexManager'
4
+ import PseduoChildren from './pseudo'
5
+ import { FlexManager } from './utils/flexManager'
6
6
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
7
- import { getNodeThresholds, getNormalAttributes, shouldBindEvent } from './utils/helper'
7
+ import { getNodeThresholds, getStyleAttr, shouldBindEvent } from './utils/helper'
8
8
 
9
- import type { TaroAny, TaroStyleType, TaroScrollViewElement, TaroEvent } from '@tarojs/runtime'
9
+ import type { TaroAny, TaroScrollViewElement, TaroEvent } from '@tarojs/runtime'
10
10
 
11
11
  interface ScrollViewAttrs {
12
12
  scrollBar: BarState
@@ -49,79 +49,83 @@ function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', x
49
49
  deltaY: vp2px(yOffset),
50
50
  scrollLeft: vp2px(currentXOffset),
51
51
  scrollTop: vp2px(currentYOffset),
52
- scrollWidth: vp2px(Number(node._scroll?.width)),
53
- scrollHeight: vp2px(Number(node._scroll?.height)),
52
+ scrollWidth: vp2px(Number(node._nodeInfo?._scroll?.width)),
53
+ scrollHeight: vp2px(Number(node._nodeInfo?._scroll?.height)),
54
54
  }
55
55
  const event: TaroEvent = createTaroEvent(eventName, { detail: value }, node)
56
56
 
57
57
  eventHandler(event, eventName, node)
58
58
  }
59
59
 
60
- @Extend(Row)
61
- function rowAttrs (style: TaroStyleType) {
62
- .constraintSize({
63
- minWidth: style.minWidth || style.width,
64
- maxWidth: style.maxWidth,
65
- minHeight: style.minHeight,
66
- maxHeight: style.maxHeight
67
- })
68
- }
60
+ @Component
61
+ export default struct TaroScrollView {
62
+ @Builder customBuilder() {}
63
+ @BuilderParam createLazyChildren: (node: TaroScrollViewElement) => void = this.customBuilder
64
+ @ObjectLink node: TaroScrollViewElement
65
+ @State overwriteStyle: Record<string, TaroAny> = {}
69
66
 
70
- @Extend(Column)
71
- function columnAttrs (style: TaroStyleType) {
72
- .constraintSize({
73
- minWidth: style.minWidth,
74
- maxWidth: style.maxWidth,
75
- minHeight: style.minHeight || style.height,
76
- maxHeight: style.maxHeight
77
- })
78
- }
67
+ aboutToAppear(): void {
68
+ if (this.node) {
69
+ this.node._instance = this
70
+ }
71
+ }
79
72
 
80
- @Builder
81
- export default function TaroScrollView (node: TaroScrollViewElement) {
82
- Scroll(node.scroller) {
83
- if (node._attrs.scrollX) {
73
+ isScrollX() {
74
+ return this.node._attrs.scrollX || getStyleAttr(this.node, 'overflow') === 'scroll' && getStyleAttr(this.node, 'flexDirection') === FlexDirection.Row
75
+ }
76
+
77
+ build () {
78
+ Scroll(this.node.scroller) {
79
+ if (this.isScrollX()) {
84
80
  Row() {
85
- createLazyChildren(node)
81
+ if (this.node._pseudo_before || this.node._pseudo_after) {
82
+ PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
83
+ } else {
84
+ this.createLazyChildren(this.node)
85
+ }
86
86
  }
87
- .attributeModifier(commonStyleModify.setNode(node))
88
- .rowAttrs(getNormalAttributes(node))
87
+ .alignItems(FlexManager.alignItems<VerticalAlign>(this.node))
88
+ .justifyContent(FlexManager.justifyContent(this.node))
89
+ .height(getStyleAttr(this.node, 'height'))
89
90
  .width(null)
90
91
  .onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
91
- node._scroll = areaResult
92
- }, node, ['scroll', 'scrollstart', 'scrollend']))
93
- .alignItems(FlexManager.flexOptions(node).alignItems as VerticalAlign)
94
- .justifyContent(FlexManager.flexOptions(node).justifyContent)
92
+ this.node._nodeInfo._scroll = areaResult
93
+ }, this.node, ['scroll', 'scrollstart', 'scrollend']))
95
94
  .flexGrow(0).flexShrink(0)
96
95
  } else {
97
96
  Column() {
98
- createLazyChildren(node)
97
+ if (this.node._pseudo_before || this.node._pseudo_after) {
98
+ PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
99
+ } else {
100
+ this.createLazyChildren(this.node)
101
+ }
99
102
  }
100
- .attributeModifier(commonStyleModify.setNode(node))
101
- .columnAttrs(getNormalAttributes(node))
103
+ .alignItems(FlexManager.alignItems<HorizontalAlign>(this.node))
104
+ .justifyContent(FlexManager.justifyContent(this.node))
105
+ .width(getStyleAttr(this.node, 'width'))
102
106
  .height(null)
103
- .alignItems(HorizontalAlign.Start)
104
107
  .onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
105
- node._scroll = areaResult
106
- }, node, ['scroll', 'scrollstart', 'scrollend']))
107
- .alignItems(FlexManager.flexOptions(node).alignItems as HorizontalAlign)
108
- .justifyContent(FlexManager.flexOptions(node).justifyContent)
108
+ this.node._nodeInfo._scroll = areaResult
109
+ }, this.node, ['scroll', 'scrollstart', 'scrollend']))
109
110
  .flexGrow(0).flexShrink(0)
110
111
  }
111
112
  }
112
- .width(getNormalAttributes(node).width)
113
- .height(getNormalAttributes(node).height)
114
- .flexGrow(getNormalAttributes(node).flexGrow)
115
- .flexShrink(getNormalAttributes(node).flexShrink)
116
- .scrollable(getScrollable(node))
117
- .scrollBar(getAttributes(node).scrollBar)
118
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
119
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
120
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
121
- node._nodeInfo.areaInfo = res[1]
113
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
114
+ .width(this.isScrollX() ? getStyleAttr(this.node, 'width') : undefined)
115
+ .height(!this.isScrollX() ? getStyleAttr(this.node, 'height') : undefined)
116
+ .align(Alignment.TopStart)
117
+ .clip(true)
118
+ .scrollable(getScrollable(this.node))
119
+ .scrollBar(getAttributes(this.node).scrollBar)
120
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
121
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
122
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
123
+ this.node._nodeInfo.areaInfo = res[1]
122
124
  }))
123
- .onScroll(shouldBindEvent(() => { handleScrollEvent(node, 'scroll') }, node, ['scroll']))
124
- .onScrollStart(shouldBindEvent(() => { handleScrollEvent(node, 'scrollstart') }, node, ['scrollstart']))
125
- .onScrollStop(shouldBindEvent(() => { handleScrollEvent(node, 'scrollend') }, node, ['scrollend']))
126
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
125
+ .onScroll(shouldBindEvent(() => { handleScrollEvent(this.node, 'scroll') }, this.node, ['scroll']))
126
+ .onScrollStart(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollstart') }, this.node, ['scrollstart']))
127
+ .onScrollStop(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollend') }, this.node, ['scrollend']))
128
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
129
+ .onReachEnd(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrolltolower') }, this.node, ['scrolltolower']))
130
+ }
127
131
  }
@@ -37,9 +37,12 @@ function themeStyles(isDisabled: boolean) {
37
37
 
38
38
  @Component
39
39
  export default struct TaroSlider {
40
- node: TaroSliderElement | null = null
40
+ @Builder customBuilder() {}
41
+ @BuilderParam createLazyChildren: (node: TaroSliderElement) => void = this.customBuilder
42
+ @ObjectLink node: TaroSliderElement
41
43
 
42
44
  @State value: number = 0
45
+ @State overwriteStyle: Record<string, TaroAny> = {}
43
46
 
44
47
  aboutToAppear () {
45
48
  if (this.node) {
@@ -62,7 +65,7 @@ export default struct TaroSlider {
62
65
  style: SliderStyle.OutSet,
63
66
  direction: Axis.Horizontal
64
67
  })
65
- .attributeModifier(commonStyleModify.setNode(node))
68
+ .attributeModifier(commonStyleModify.setNode(node).setAnimationStyle(this.overwriteStyle))
66
69
  .attrs(getAttributes(node))
67
70
  .width(!!node._attrs.showValue ? '90%' : '100%')
68
71
  .themeStyles(!!node._attrs.disabled)
@@ -74,7 +77,7 @@ export default struct TaroSlider {
74
77
  } else {
75
78
  this.value = value
76
79
  this.node?.updateFormWidgetValue(value)
77
-
80
+
78
81
  if (mode === SliderChangeMode.End) {
79
82
  const event: TaroEvent = createTaroEvent('change', { detail: { value: this.value } }, node)
80
83
  eventHandler(event, 'change', node)
@@ -94,18 +97,16 @@ export default struct TaroSlider {
94
97
  }
95
98
 
96
99
  build() {
97
- if (this.node) {
98
- if (!!this.node._attrs.showValue) {
99
- Row() {
100
- this.createSlider(this.node)
101
- Text(Number(this.value).toFixed(0))
102
- .width('10%')
103
- .textAlign(TextAlign.Center)
104
- .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
105
- }
106
- } else {
100
+ if (!!this.node._attrs.showValue) {
101
+ Row() {
107
102
  this.createSlider(this.node)
103
+ Text(Number(this.value).toFixed(0))
104
+ .width('10%')
105
+ .textAlign(TextAlign.Center)
106
+ .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
108
107
  }
108
+ } else {
109
+ this.createSlider(this.node)
109
110
  }
110
111
  }
111
- }
112
+ }