@tarojs/plugin-platform-harmony-ets 4.0.0-beta.2 → 4.0.0-beta.21

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 (87) hide show
  1. package/dist/apis/base/system.ts +53 -20
  2. package/dist/apis/framework/index.ts +1 -5
  3. package/dist/apis/index.ts +3 -1
  4. package/dist/apis/network/request.ts +5 -5
  5. package/dist/apis/route/index.ts +15 -0
  6. package/dist/apis/storage/index.ts +124 -60
  7. package/dist/apis/wxml/IntersectionObserver.ts +5 -3
  8. package/dist/apis/wxml/index.ts +2 -0
  9. package/dist/components-harmony-ets/button.ets +41 -78
  10. package/dist/components-harmony-ets/checkbox.ets +19 -209
  11. package/dist/components-harmony-ets/form.ets +38 -160
  12. package/dist/components-harmony-ets/icon.ets +31 -83
  13. package/dist/components-harmony-ets/image.ets +22 -78
  14. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  15. package/dist/components-harmony-ets/input.ets +10 -67
  16. package/dist/components-harmony-ets/label.ets +52 -173
  17. package/dist/components-harmony-ets/movableArea.ets +89 -0
  18. package/dist/components-harmony-ets/movableView.ets +67 -0
  19. package/dist/components-harmony-ets/picker.ets +32 -147
  20. package/dist/components-harmony-ets/progress.ets +47 -0
  21. package/dist/components-harmony-ets/pseudo.ets +80 -0
  22. package/dist/components-harmony-ets/radio.ets +19 -210
  23. package/dist/components-harmony-ets/richText.ets +22 -102
  24. package/dist/components-harmony-ets/scrollView.ets +66 -169
  25. package/dist/components-harmony-ets/slider.ets +10 -72
  26. package/dist/components-harmony-ets/style.ets +244 -0
  27. package/dist/components-harmony-ets/swiper.ets +30 -87
  28. package/dist/components-harmony-ets/switch.ets +9 -71
  29. package/dist/components-harmony-ets/text.ets +38 -89
  30. package/dist/components-harmony-ets/textArea.ets +10 -67
  31. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  32. package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
  33. package/dist/components-harmony-ets/utils/flexManager.ets +8 -7
  34. package/dist/components-harmony-ets/utils/helper.ets +5 -4
  35. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  36. package/dist/components-harmony-ets/utils/index.ts +55 -2
  37. package/dist/components-harmony-ets/utils/styles.ets +45 -85
  38. package/dist/components-harmony-ets/video.ets +33 -88
  39. package/dist/components-harmony-ets/view.ets +47 -160
  40. package/dist/components-harmony-ets/webView.ets +44 -99
  41. package/dist/index.d.ts +151 -0
  42. package/dist/index.js +58 -29
  43. package/dist/index.js.map +1 -1
  44. package/dist/runtime-ets/bom/window.ts +4 -2
  45. package/dist/runtime-ets/current.ts +2 -0
  46. package/dist/runtime-ets/dom/bind.ts +0 -1
  47. package/dist/runtime-ets/dom/cssNesting.ts +311 -0
  48. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +15 -40
  49. package/dist/runtime-ets/dom/document.ts +21 -8
  50. package/dist/runtime-ets/dom/element/element.ts +53 -9
  51. package/dist/runtime-ets/dom/element/form.ts +11 -4
  52. package/dist/runtime-ets/dom/element/index.ts +12 -1
  53. package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
  54. package/dist/runtime-ets/dom/element/movableView.ts +193 -0
  55. package/dist/runtime-ets/dom/element/normal.ts +8 -3
  56. package/dist/runtime-ets/dom/element/progress.ts +13 -0
  57. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  58. package/dist/runtime-ets/dom/element/text.ts +1 -0
  59. package/dist/runtime-ets/dom/element/video.ts +1 -0
  60. package/dist/runtime-ets/dom/element/webView.ts +8 -0
  61. package/dist/runtime-ets/dom/event.ts +0 -1
  62. package/dist/runtime-ets/dom/eventTarget.ts +0 -3
  63. package/dist/runtime-ets/dom/node.ts +18 -17
  64. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +184 -207
  65. package/dist/runtime-ets/dom/stylesheet/index.ts +28 -308
  66. package/dist/runtime-ets/dom/stylesheet/type.ts +18 -6
  67. package/dist/runtime-ets/dom/stylesheet/util.ts +19 -15
  68. package/dist/runtime-ets/index.ts +2 -2
  69. package/dist/runtime-ets/interface/event.ts +1 -1
  70. package/dist/runtime-ets/utils/index.ts +24 -9
  71. package/dist/runtime-framework/react/app.ts +5 -1
  72. package/dist/runtime-framework/react/hooks.ts +3 -3
  73. package/dist/runtime-framework/react/native-page.ts +14 -9
  74. package/dist/runtime-framework/react/page.ts +1 -0
  75. package/dist/runtime-framework/solid/hooks.ts +3 -3
  76. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  77. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  78. package/dist/runtime-utils.d.ts +825 -0
  79. package/dist/runtime-utils.js +185 -91
  80. package/dist/runtime-utils.js.map +1 -1
  81. package/dist/runtime.d.ts +1 -0
  82. package/dist/runtime.js +185 -91
  83. package/dist/runtime.js.map +1 -1
  84. package/index.js +3 -1
  85. package/package.json +10 -10
  86. package/types/index.d.ts +4 -0
  87. package/dist/runtime-ets/utils/bind.ts +0 -24
@@ -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
- }
@@ -1,10 +1,12 @@
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 { rowModify, columnModify } from './style'
4
+ import PseduoChildren from './pseudo'
5
+ import { FlexManager } from './utils/FlexManager'
4
6
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
5
- import { getNodeThresholds, getNormalAttributes, shouldBindEvent } from './utils/helper'
7
+ import { getNodeThresholds, getStyleAttr, shouldBindEvent } from './utils/helper'
6
8
 
7
- import type { TaroAny, TaroStyleType, TaroScrollViewElement, TaroEvent } from '@tarojs/runtime'
9
+ import type { TaroAny, TaroScrollViewElement, TaroEvent } from '@tarojs/runtime'
8
10
 
9
11
  interface ScrollViewAttrs {
10
12
  scrollBar: BarState
@@ -22,135 +24,6 @@ interface ScrollViewEvent {
22
24
  scrollHeight: number
23
25
  }
24
26
 
25
- @Extend(Row)
26
- function rowAttrs (style: TaroStyleType) {
27
- .id(style.id)
28
- .key(style.id)
29
- .flexGrow(style.flexGrow)
30
- .flexShrink(style.flexShrink)
31
- .flexBasis(style.flexBasis)
32
- .alignSelf(style.alignSelf)
33
- .padding({
34
- top: style.paddingTop,
35
- right: style.paddingRight,
36
- bottom: style.paddingBottom,
37
- left: style.paddingLeft
38
- })
39
- .margin({
40
- top: style.marginTop,
41
- right: style.marginRight,
42
- bottom: style.marginBottom,
43
- left: style.marginLeft
44
- })
45
- .height(style.height)
46
- .constraintSize({
47
- minWidth: style.minWidth || style.width,
48
- maxWidth: style.maxWidth,
49
- minHeight: style.minHeight,
50
- maxHeight: style.maxHeight
51
- })
52
- .backgroundColor(style.backgroundColor)
53
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
54
- .backgroundImageSize(style.backgroundSize)
55
- .backgroundImagePosition(style.backgroundPosition)
56
- .borderStyle({
57
- top: style.borderTopStyle,
58
- right: style.borderRightStyle,
59
- bottom: style.borderBottomStyle,
60
- left: style.borderLeftStyle
61
- })
62
- .borderWidth({
63
- top: style.borderTopWidth,
64
- right: style.borderRightWidth,
65
- bottom: style.borderBottomWidth,
66
- left: style.borderLeftWidth
67
- })
68
- .borderColor({
69
- top: style.borderTopColor,
70
- right: style.borderRightColor,
71
- bottom: style.borderBottomColor,
72
- left: style.borderLeftColor
73
- })
74
- .borderRadius({
75
- topLeft: style.borderTopLeftRadius,
76
- topRight: style.borderTopRightRadius,
77
- bottomLeft: style.borderBottomLeftRadius,
78
- bottomRight: style.borderBottomRightRadius
79
- })
80
- .zIndex(style.zIndex)
81
- .opacity(style.opacity)
82
- .linearGradient(style.linearGradient)
83
- .clip(style.overflow)
84
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
85
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
86
- .transform(style.transform)
87
- }
88
-
89
- @Extend(Column)
90
- function columnAttrs (style: TaroStyleType) {
91
- .id(style.id)
92
- .key(style.id)
93
- .flexGrow(style.flexGrow)
94
- .flexShrink(style.flexShrink)
95
- .flexBasis(style.flexBasis)
96
- .alignSelf(style.alignSelf)
97
- .padding({
98
- top: style.paddingTop,
99
- right: style.paddingRight,
100
- bottom: style.paddingBottom,
101
- left: style.paddingLeft
102
- })
103
- .margin({
104
- top: style.marginTop,
105
- right: style.marginRight,
106
- bottom: style.marginBottom,
107
- left: style.marginLeft
108
- })
109
- .width(style.width)
110
- .constraintSize({
111
- minWidth: style.minWidth,
112
- maxWidth: style.maxWidth,
113
- minHeight: style.minHeight || style.height,
114
- maxHeight: style.maxHeight
115
- })
116
- .backgroundColor(style.backgroundColor)
117
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
118
- .backgroundImageSize(style.backgroundSize)
119
- .backgroundImagePosition(style.backgroundPosition)
120
- .borderStyle({
121
- top: style.borderTopStyle,
122
- right: style.borderRightStyle,
123
- bottom: style.borderBottomStyle,
124
- left: style.borderLeftStyle
125
- })
126
- .borderWidth({
127
- top: style.borderTopWidth,
128
- right: style.borderRightWidth,
129
- bottom: style.borderBottomWidth,
130
- left: style.borderLeftWidth
131
- })
132
- .borderColor({
133
- top: style.borderTopColor,
134
- right: style.borderRightColor,
135
- bottom: style.borderBottomColor,
136
- left: style.borderLeftColor
137
- })
138
- .borderRadius({
139
- topLeft: style.borderTopLeftRadius,
140
- topRight: style.borderTopRightRadius,
141
- bottomLeft: style.borderBottomLeftRadius,
142
- bottomRight: style.borderBottomRightRadius
143
- })
144
- .zIndex(style.zIndex)
145
- .opacity(style.opacity)
146
- .linearGradient(style.linearGradient)
147
- .clip(style.overflow)
148
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
149
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
150
- .transform(style.transform)
151
- }
152
-
153
-
154
27
  function getAttributes (node: TaroScrollViewElement): ScrollViewAttrs {
155
28
  const _attrs = node._attrs
156
29
  const scrollAttrs: ScrollViewAttrs = {
@@ -176,50 +49,74 @@ function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', x
176
49
  deltaY: vp2px(yOffset),
177
50
  scrollLeft: vp2px(currentXOffset),
178
51
  scrollTop: vp2px(currentYOffset),
179
- scrollWidth: vp2px(Number(node._scroll?.width)),
180
- scrollHeight: vp2px(Number(node._scroll?.height)),
52
+ scrollWidth: vp2px(Number(node._nodeInfo?._scroll?.width)),
53
+ scrollHeight: vp2px(Number(node._nodeInfo?._scroll?.height)),
181
54
  }
182
55
  const event: TaroEvent = createTaroEvent(eventName, { detail: value }, node)
183
56
 
184
57
  eventHandler(event, eventName, node)
185
58
  }
186
59
 
187
- @Builder
188
- export default function TaroScrollView (node: TaroScrollViewElement) {
189
- Scroll(node.scroller) {
190
- if (node._attrs.scrollX) {
191
- Row() {
192
- createLazyChildren(node)
193
- }
194
- .width(null)
195
- .rowAttrs(getNormalAttributes(node))
196
- .onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
197
- node._scroll = areaResult
198
- }, node, ['scroll', 'scrollstart', 'scrollend']))
199
- } else {
200
- Column() {
201
- createLazyChildren(node)
60
+ @Component
61
+ export default struct TaroScrollView {
62
+ @Builder customBuilder() {}
63
+ @BuilderParam createLazyChildren: (node: TaroScrollViewElement) => void = this.customBuilder
64
+ @ObjectLink node: TaroScrollViewElement
65
+
66
+ build () {
67
+ if (this.node.hmStyle?.display !== 'none') {
68
+ Scroll(this.node.scroller) {
69
+ if (this.node._attrs.scrollX) {
70
+ Row() {
71
+ if (this.node._pseudo_before || this.node._pseudo_after) {
72
+ PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
73
+ } else {
74
+ this.createLazyChildren(this.node)
75
+ }
76
+ }
77
+ .attributeModifier(rowModify.setNode(this.node))
78
+ .width(null)
79
+ .onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
80
+ this.node._nodeInfo._scroll = areaResult
81
+ }, this.node, ['scroll', 'scrollstart', 'scrollend']))
82
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
83
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
84
+ .flexGrow(0).flexShrink(0)
85
+ } else {
86
+ Column() {
87
+ if (this.node._pseudo_before || this.node._pseudo_after) {
88
+ PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
89
+ } else {
90
+ this.createLazyChildren(this.node)
91
+ }
92
+ }
93
+ .attributeModifier(columnModify.setNode(this.node))
94
+ .height(null)
95
+ .alignItems(HorizontalAlign.Start)
96
+ .onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
97
+ this.node._nodeInfo._scroll = areaResult
98
+ }, this.node, ['scroll', 'scrollstart', 'scrollend']))
99
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
100
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
101
+ .flexGrow(0).flexShrink(0)
202
102
  }
203
- .height(null)
204
- .columnAttrs(getNormalAttributes(node))
205
- .alignItems(HorizontalAlign.Start)
206
- .onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
207
- node._scroll = areaResult
208
- }, node, ['scroll', 'scrollstart', 'scrollend']))
209
103
  }
104
+ .width(getStyleAttr(this.node, 'width'))
105
+ .height(getStyleAttr(this.node, 'height'))
106
+ .flexGrow(this.node.hmStyle?.flexGrow)
107
+ .flexShrink(this.node.hmStyle?.flexShrink)
108
+ .scrollable(getScrollable(this.node))
109
+ .scrollBar(getAttributes(this.node).scrollBar)
110
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
111
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
112
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
113
+ this.node._nodeInfo.areaInfo = res[1]
114
+ }))
115
+ .onScroll(shouldBindEvent(() => { handleScrollEvent(this.node, 'scroll') }, this.node, ['scroll']))
116
+ .onScrollStart(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollstart') }, this.node, ['scrollstart']))
117
+ .onScrollStop(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollend') }, this.node, ['scrollend']))
118
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
119
+ .onReachEnd(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrolltolower') }, this.node, ['scrolltolower']))
210
120
  }
211
- .width(getNormalAttributes(node).width)
212
- .height(getNormalAttributes(node).height)
213
- .flexGrow(getNormalAttributes(node).flexGrow)
214
- .scrollable(getScrollable(node))
215
- .scrollBar(getAttributes(node).scrollBar)
216
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
217
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
218
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
219
- node._nodeInfo.areaInfo = res[1]
220
- }))
221
- .onScroll(shouldBindEvent(() => { handleScrollEvent(node, 'scroll') }, node, ['scroll']))
222
- .onScrollStart(shouldBindEvent(() => { handleScrollEvent(node, 'scrollstart') }, node, ['scrollstart']))
223
- .onScrollStop(shouldBindEvent(() => { handleScrollEvent(node, 'scrollend') }, node, ['scrollend']))
224
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
121
+ }
225
122
  }
@@ -1,8 +1,9 @@
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, TaroSliderElement, TaroStyleType, TaroEvent } from '@tarojs/runtime'
6
+ import type { TaroAny, TaroSliderElement, TaroEvent } from '@tarojs/runtime'
6
7
 
7
8
  interface SliderAttrs {
8
9
  selectedColor?: ResourceColor
@@ -11,71 +12,6 @@ interface SliderAttrs {
11
12
  blockColor?: ResourceColor
12
13
  }
13
14
 
14
- @Extend(Slider)
15
- function style (style: TaroStyleType) {
16
- .id(style.id)
17
- .key(style.id)
18
- .flexGrow(style.flexGrow)
19
- .flexShrink(style.flexShrink)
20
- .flexBasis(style.flexBasis)
21
- .alignSelf(style.alignSelf)
22
- .padding({
23
- top: style.paddingTop,
24
- right: style.paddingRight,
25
- bottom: style.paddingBottom,
26
- left: style.paddingLeft
27
- })
28
- .margin({
29
- top: style.marginTop,
30
- right: style.marginRight,
31
- bottom: style.marginBottom,
32
- left: style.marginLeft
33
- })
34
- .width(style.width)
35
- .height(style.height)
36
- .constraintSize({
37
- minWidth: style.minWidth,
38
- maxWidth: style.maxWidth,
39
- minHeight: style.minHeight,
40
- maxHeight: style.maxHeight
41
- })
42
- .backgroundColor(style.backgroundColor)
43
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
44
- .backgroundImageSize(style.backgroundSize)
45
- .backgroundImagePosition(style.backgroundPosition)
46
- .borderStyle({
47
- top: style.borderTopStyle,
48
- right: style.borderRightStyle,
49
- bottom: style.borderBottomStyle,
50
- left: style.borderLeftStyle
51
- })
52
- .borderWidth({
53
- top: style.borderTopWidth,
54
- right: style.borderRightWidth,
55
- bottom: style.borderBottomWidth,
56
- left: style.borderLeftWidth
57
- })
58
- .borderColor({
59
- top: style.borderTopColor,
60
- right: style.borderRightColor,
61
- bottom: style.borderBottomColor,
62
- left: style.borderLeftColor
63
- })
64
- .borderRadius({
65
- topLeft: style.borderTopLeftRadius,
66
- topRight: style.borderTopRightRadius,
67
- bottomLeft: style.borderBottomLeftRadius,
68
- bottomRight: style.borderBottomRightRadius
69
- })
70
- .zIndex(style.zIndex)
71
- .opacity(style.opacity)
72
- .linearGradient(style.linearGradient)
73
- .clip(style.overflow)
74
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
75
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
76
- .transform(style.transform)
77
- }
78
-
79
15
  @Extend(Slider)
80
16
  function attrs (attr: SliderAttrs) {
81
17
  .selectedColor(attr.selectedColor)
@@ -101,7 +37,9 @@ function themeStyles(isDisabled: boolean) {
101
37
 
102
38
  @Component
103
39
  export default struct TaroSlider {
104
- node: TaroSliderElement | null = null
40
+ @Builder customBuilder() {}
41
+ @BuilderParam createLazyChildren: (node: TaroSliderElement) => void = this.customBuilder
42
+ @ObjectLink node: TaroSliderElement
105
43
 
106
44
  @State value: number = 0
107
45
 
@@ -126,7 +64,7 @@ export default struct TaroSlider {
126
64
  style: SliderStyle.OutSet,
127
65
  direction: Axis.Horizontal
128
66
  })
129
- .style(getNormalAttributes(node))
67
+ .attributeModifier(commonStyleModify.setNode(node))
130
68
  .attrs(getAttributes(node))
131
69
  .width(!!node._attrs.showValue ? '90%' : '100%')
132
70
  .themeStyles(!!node._attrs.disabled)
@@ -138,7 +76,7 @@ export default struct TaroSlider {
138
76
  } else {
139
77
  this.value = value
140
78
  this.node?.updateFormWidgetValue(value)
141
-
79
+
142
80
  if (mode === SliderChangeMode.End) {
143
81
  const event: TaroEvent = createTaroEvent('change', { detail: { value: this.value } }, node)
144
82
  eventHandler(event, 'change', node)
@@ -158,7 +96,7 @@ export default struct TaroSlider {
158
96
  }
159
97
 
160
98
  build() {
161
- if (this.node) {
99
+ if (this.node && this.node.hmStyle?.display !== 'none') {
162
100
  if (!!this.node._attrs.showValue) {
163
101
  Row() {
164
102
  this.createSlider(this.node)
@@ -172,4 +110,4 @@ export default struct TaroSlider {
172
110
  }
173
111
  }
174
112
  }
175
- }
113
+ }