@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27 → 4.0.0-alpha.10

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 (239) hide show
  1. package/dist/apis/apis.ts +6 -2
  2. package/dist/apis/base/crypto.ts +4 -0
  3. package/dist/apis/base/debug.ts +5 -0
  4. package/dist/apis/base/index.ts +9 -1
  5. package/dist/apis/base/performance.ts +8 -0
  6. package/dist/apis/base/system.ts +74 -21
  7. package/dist/apis/base/update.ts +5 -0
  8. package/dist/apis/base/weapp/app-event.ts +75 -0
  9. package/dist/apis/base/weapp/life-cycle.ts +21 -0
  10. package/dist/apis/canvas/index.ts +27 -0
  11. package/dist/apis/data-analysis/index.ts +6 -0
  12. package/dist/apis/device/accelerometer.ts +2 -1
  13. package/dist/apis/device/accessibility.ts +4 -0
  14. package/dist/apis/device/battery.ts +2 -2
  15. package/dist/apis/device/bluetooth-ble.ts +19 -0
  16. package/dist/apis/device/bluetooth-peripheral.ts +6 -0
  17. package/dist/apis/device/bluetooth.ts +16 -0
  18. package/dist/apis/device/calendar.ts +5 -0
  19. package/dist/apis/device/clipboard.ts +17 -9
  20. package/dist/apis/device/compass.ts +21 -0
  21. package/dist/apis/device/contact.ts +5 -0
  22. package/dist/apis/device/crypto.ts +4 -0
  23. package/dist/apis/device/gyroscope.ts +7 -0
  24. package/dist/apis/device/iBeacon.ts +10 -0
  25. package/dist/apis/device/index.ts +15 -0
  26. package/dist/apis/device/keyboard.ts +2 -1
  27. package/dist/apis/device/memory.ts +10 -3
  28. package/dist/apis/device/motion.ts +6 -0
  29. package/dist/apis/device/network.ts +26 -9
  30. package/dist/apis/device/nfc.ts +10 -0
  31. package/dist/apis/device/phone.ts +2 -1
  32. package/dist/apis/device/scan.ts +4 -0
  33. package/dist/apis/device/screen.ts +2 -1
  34. package/dist/apis/device/sms.ts +4 -0
  35. package/dist/apis/device/vibrate.ts +19 -11
  36. package/dist/apis/device/wifi.ts +15 -0
  37. package/dist/apis/ext/index.ts +5 -0
  38. package/dist/apis/files/index.ts +2 -1
  39. package/dist/apis/files/manager.ts +2 -1
  40. package/dist/apis/framework/index.ts +3 -8
  41. package/dist/apis/index.ts +27 -17
  42. package/dist/apis/location/index.ts +61 -68
  43. package/dist/apis/media/EditorContext.ts +32 -0
  44. package/dist/apis/media/audio/index.ts +18 -0
  45. package/dist/apis/media/background-audio/index.ts +16 -0
  46. package/dist/apis/media/camera.ts +16 -0
  47. package/dist/apis/media/common.ts +2 -1
  48. package/dist/apis/media/{image.ts → image/index.ts} +4 -3
  49. package/dist/apis/media/index.ts +10 -0
  50. package/dist/apis/media/live.ts +5 -0
  51. package/dist/apis/media/map.ts +4 -0
  52. package/dist/apis/media/media-recorder.ts +4 -0
  53. package/dist/apis/media/recorder.ts +6 -0
  54. package/dist/apis/media/video/VideoContext.ts +68 -0
  55. package/dist/apis/media/{video.ts → video/index.ts} +13 -2
  56. package/dist/apis/media/video-decoder.ts +4 -0
  57. package/dist/apis/media/video-processing.ts +4 -0
  58. package/dist/apis/media/voip.ts +19 -0
  59. package/dist/apis/network/index.ts +3 -0
  60. package/dist/apis/network/mdns.ts +13 -0
  61. package/dist/apis/network/request.ts +7 -6
  62. package/dist/apis/network/tcp.ts +4 -0
  63. package/dist/apis/network/udp.ts +4 -0
  64. package/dist/apis/network/webSocket.ts +2 -6
  65. package/dist/apis/open-api/account.ts +4 -0
  66. package/dist/apis/open-api/address.ts +4 -0
  67. package/dist/apis/open-api/authorize.ts +5 -0
  68. package/dist/apis/open-api/card.ts +5 -0
  69. package/dist/apis/open-api/channels-live.ts +11 -0
  70. package/dist/apis/open-api/customer-service.ts +4 -0
  71. package/dist/apis/open-api/device-voip.ts +5 -0
  72. package/dist/apis/open-api/facial.ts +7 -0
  73. package/dist/apis/open-api/favorites.ts +5 -0
  74. package/dist/apis/open-api/group.ts +4 -0
  75. package/dist/apis/open-api/index.ts +20 -6
  76. package/dist/apis/open-api/invoice.ts +5 -0
  77. package/dist/apis/open-api/license-plate.ts +4 -0
  78. package/dist/apis/open-api/login.ts +6 -0
  79. package/dist/apis/open-api/my-miniprogram.ts +4 -0
  80. package/dist/apis/open-api/privacy.ts +7 -0
  81. package/dist/apis/open-api/red-package.ts +4 -0
  82. package/dist/apis/open-api/settings.ts +5 -0
  83. package/dist/apis/open-api/soter.ts +6 -0
  84. package/dist/apis/open-api/subscribe-message.ts +6 -0
  85. package/dist/apis/open-api/{user-info/index.ts → user-info.ts} +1 -16
  86. package/dist/apis/open-api/werun.ts +5 -0
  87. package/dist/apis/payment/index.ts +6 -0
  88. package/dist/apis/route/index.ts +19 -28
  89. package/dist/apis/share/index.ts +33 -0
  90. package/dist/apis/storage/background-fetch.ts +7 -0
  91. package/dist/apis/storage/cache-manager.ts +4 -0
  92. package/dist/apis/storage/index.ts +158 -88
  93. package/dist/apis/ui/{animation.ts → animation/animation.ts} +73 -31
  94. package/dist/apis/ui/animation/index.ts +7 -0
  95. package/dist/apis/ui/background.ts +4 -19
  96. package/dist/apis/ui/custom-component.ts +8 -0
  97. package/dist/apis/ui/fonts.ts +4 -0
  98. package/dist/apis/ui/index.ts +8 -10
  99. package/dist/apis/ui/interaction/index.ts +45 -59
  100. package/dist/apis/ui/menu.ts +4 -0
  101. package/dist/apis/ui/navigation-bar/index.ts +60 -21
  102. package/dist/apis/ui/pull-down-refresh.ts +10 -4
  103. package/dist/apis/{page → ui/scroll}/index.ts +32 -27
  104. package/dist/apis/ui/sticky.ts +4 -0
  105. package/dist/apis/{tabbar/index.ts → ui/tab-bar.ts} +6 -8
  106. package/dist/apis/ui/window.ts +20 -0
  107. package/dist/apis/utils/handler.ts +4 -4
  108. package/dist/apis/utils/index.ts +1 -1
  109. package/dist/apis/worker/index.ts +4 -0
  110. package/dist/apis/wxml/IntersectionObserver.ts +24 -25
  111. package/dist/apis/wxml/index.ts +7 -2
  112. package/dist/apis/wxml/nodesRef.ts +2 -2
  113. package/dist/apis/wxml/selectorQuery.ts +29 -17
  114. package/dist/components-harmony-ets/button.ets +106 -80
  115. package/dist/components-harmony-ets/canvas.ets +51 -0
  116. package/dist/components-harmony-ets/checkbox.ets +82 -148
  117. package/dist/components-harmony-ets/form.ets +45 -132
  118. package/dist/components-harmony-ets/icon.ets +66 -69
  119. package/dist/components-harmony-ets/image.ets +26 -61
  120. package/dist/components-harmony-ets/index.ets +92 -0
  121. package/dist/components-harmony-ets/innerHtml.ets +7 -70
  122. package/dist/components-harmony-ets/input.ets +60 -146
  123. package/dist/components-harmony-ets/label.ets +86 -92
  124. package/dist/components-harmony-ets/listView.ets +26 -0
  125. package/dist/components-harmony-ets/movableArea.ets +124 -0
  126. package/dist/components-harmony-ets/movableView.ets +93 -0
  127. package/dist/components-harmony-ets/navigationBar.ets +65 -0
  128. package/dist/components-harmony-ets/pageMeta.ets +94 -0
  129. package/dist/components-harmony-ets/picker.ets +172 -198
  130. package/dist/components-harmony-ets/progress.ets +52 -0
  131. package/dist/components-harmony-ets/pseudo.ets +80 -0
  132. package/dist/components-harmony-ets/radio.ets +85 -155
  133. package/dist/components-harmony-ets/richText.ets +15 -87
  134. package/dist/components-harmony-ets/scrollList.ets +94 -0
  135. package/dist/components-harmony-ets/scrollView.ets +81 -149
  136. package/dist/components-harmony-ets/slider.ets +47 -94
  137. package/dist/components-harmony-ets/stickySection.ets +42 -0
  138. package/dist/components-harmony-ets/style.ets +396 -0
  139. package/dist/components-harmony-ets/swiper.ets +51 -151
  140. package/dist/components-harmony-ets/switch.ets +35 -76
  141. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  142. package/dist/components-harmony-ets/text.ets +131 -76
  143. package/dist/components-harmony-ets/textArea.ets +64 -140
  144. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  145. package/dist/components-harmony-ets/utils/DynamicCenter.ts +4 -13
  146. package/dist/components-harmony-ets/utils/constant/style.ets +9 -6
  147. package/dist/components-harmony-ets/utils/flexManager.ets +68 -85
  148. package/dist/components-harmony-ets/utils/helper.ets +18 -65
  149. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  150. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  151. package/dist/components-harmony-ets/utils/index.ts +55 -51
  152. package/dist/components-harmony-ets/utils/styles.ets +177 -65
  153. package/dist/components-harmony-ets/video.ets +70 -116
  154. package/dist/components-harmony-ets/view.ets +58 -64
  155. package/dist/components-harmony-ets/webView.ets +56 -0
  156. package/dist/index.d.ts +152 -0
  157. package/dist/index.js +230 -60
  158. package/dist/index.js.map +1 -1
  159. package/dist/runtime-ets/bom/document.ts +6 -4
  160. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  161. package/dist/runtime-ets/bom/window.ts +9 -2
  162. package/dist/runtime-ets/current.ts +3 -0
  163. package/dist/runtime-ets/dom/bind.ts +96 -0
  164. package/dist/runtime-ets/dom/class-list.ts +4 -6
  165. package/dist/runtime-ets/dom/comment.ts +1 -2
  166. package/dist/runtime-ets/dom/cssNesting.ts +409 -0
  167. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +30 -20
  168. package/dist/runtime-ets/dom/dataSource.ts +64 -0
  169. package/dist/runtime-ets/dom/document.ts +36 -51
  170. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  171. package/dist/runtime-ets/dom/element/element.ts +439 -0
  172. package/dist/runtime-ets/dom/element/form.ts +403 -0
  173. package/dist/runtime-ets/dom/element/index.ts +120 -0
  174. package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
  175. package/dist/runtime-ets/dom/element/movableView.ts +242 -0
  176. package/dist/runtime-ets/dom/element/normal.ts +103 -0
  177. package/dist/runtime-ets/dom/element/progress.ts +11 -0
  178. package/dist/runtime-ets/dom/element/scrollView.ts +15 -0
  179. package/dist/runtime-ets/dom/element/text.ts +10 -0
  180. package/dist/runtime-ets/dom/element/video.ts +50 -0
  181. package/dist/runtime-ets/dom/element/webView.ts +68 -0
  182. package/dist/runtime-ets/dom/event.ts +26 -5
  183. package/dist/runtime-ets/dom/eventTarget.ts +3 -3
  184. package/dist/runtime-ets/dom/node.ts +114 -49
  185. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +805 -0
  186. package/dist/runtime-ets/dom/stylesheet/index.ts +122 -429
  187. package/dist/runtime-ets/dom/stylesheet/type.ts +93 -17
  188. package/dist/runtime-ets/dom/stylesheet/util.ts +145 -17
  189. package/dist/runtime-ets/index.ts +2 -3
  190. package/dist/runtime-ets/interface/event.ts +3 -2
  191. package/dist/runtime-ets/utils/index.ts +87 -17
  192. package/dist/runtime-ets/utils/info.ts +21 -47
  193. package/dist/runtime-framework/react/app.ts +20 -28
  194. package/dist/runtime-framework/react/hooks.ts +3 -4
  195. package/dist/runtime-framework/react/index.ts +1 -2
  196. package/dist/runtime-framework/react/native-page.ts +421 -0
  197. package/dist/runtime-framework/react/page.ts +5 -17
  198. package/dist/runtime-framework/solid/app.ts +25 -45
  199. package/dist/runtime-framework/solid/connect.ts +21 -3
  200. package/dist/runtime-framework/solid/hooks.ts +17 -12
  201. package/dist/runtime-framework/solid/index.ts +6 -2
  202. package/dist/runtime-framework/solid/page.ts +84 -36
  203. package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
  204. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  205. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  206. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  207. package/dist/runtime-utils.d.ts +827 -0
  208. package/dist/runtime-utils.js +1633 -549
  209. package/dist/runtime-utils.js.map +1 -1
  210. package/dist/runtime.d.ts +1 -0
  211. package/dist/runtime.js +1633 -549
  212. package/dist/runtime.js.map +1 -1
  213. package/index.js +3 -1
  214. package/package.json +14 -15
  215. package/static/media/cancel.svg +1 -0
  216. package/static/media/circle.svg +1 -0
  217. package/static/media/clear.svg +1 -0
  218. package/static/media/download.svg +1 -0
  219. package/static/media/info.svg +1 -0
  220. package/static/media/info_circle.svg +1 -0
  221. package/static/media/search.svg +1 -0
  222. package/static/media/success.svg +1 -0
  223. package/static/media/success_no_circle.svg +1 -0
  224. package/static/media/taro_arrow_left.svg +1 -0
  225. package/static/media/taro_home.svg +1 -0
  226. package/static/media/waiting.svg +1 -0
  227. package/static/media/warn.svg +1 -0
  228. package/types/harmony.d.ts +4 -0
  229. package/types/index.d.ts +4 -0
  230. package/types/runtime.d.ts +7 -1
  231. package/LICENSE +0 -160
  232. package/dist/components-harmony-ets/base.ets +0 -63
  233. package/dist/components-harmony-ets/element.ets +0 -223
  234. package/dist/components-harmony-ets/utils/constant/icon.ts +0 -19
  235. package/dist/runtime-ets/dom/element.ts +0 -457
  236. package/dist/runtime-ets/dom/text.ts +0 -19
  237. package/dist/runtime-ets/utils/bind.ts +0 -35
  238. package/types/api.d.ts +0 -4
  239. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -1,14 +1,12 @@
1
- import { bindScrollTo, bindInstanceToNode, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, initComponentNodeInfo,
2
- TaroEvent, TaroAny } from '@tarojs/runtime'
1
+ import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
3
2
 
4
- import { createNode } from './render'
5
- import TaroComponentWrapper from './base'
3
+ import commonStyleModify from './style'
4
+ import PseduoChildren from './pseudo'
5
+ import { FlexManager } from './utils/flexManager'
6
6
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
7
- import { createTaroEvent } from './utils/events'
8
- import { getNodeThresholds, getNormalAttributes, shouldBindEvent, bindAnimation } from './utils/helper'
7
+ import { getNodeThresholds, getStyleAttr, shouldBindEvent } from './utils/helper'
9
8
 
10
- import type { TaroScrollViewElement, TaroElement } from './element'
11
- import type { TaroStyleType } from '@tarojs/runtime'
9
+ import type { TaroAny, TaroScrollViewElement, TaroEvent } from '@tarojs/runtime'
12
10
 
13
11
  interface ScrollViewAttrs {
14
12
  scrollBar: BarState
@@ -26,67 +24,6 @@ interface ScrollViewEvent {
26
24
  scrollHeight: number
27
25
  }
28
26
 
29
- @Extend(Row)
30
- function rowAttrs (style: TaroStyleType) {
31
- .id(style.id)
32
- .key(style.id)
33
- .padding(style.padding)
34
- .margin(style.margin)
35
- .width(style.width)
36
- .height(style.height)
37
- .constraintSize(style.constraintSize)
38
- .flexGrow(style.flexGrow)
39
- .flexShrink(style.flexShrink)
40
- .flexBasis(style.flexBasis)
41
- .alignSelf(style.alignSelf)
42
- .backgroundColor(style.backgroundColor)
43
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
44
- .backgroundImageSize(style.backgroundImageSize)
45
- .rotate(style.rotate)
46
- .scale(style.scale)
47
- .translate(style.translate)
48
- .transform(style.transform)
49
- .borderStyle(style.borderStyle)
50
- .borderWidth(style.borderWidth)
51
- .borderColor(style.borderColor)
52
- .borderRadius(style.borderRadius)
53
- .linearGradient(style.linearGradient)
54
- .zIndex(style.zIndex)
55
- .opacity(style.opacity)
56
- .clip(style.clip)
57
- }
58
-
59
- @Extend(Column)
60
- function columnAttrs (style: TaroStyleType) {
61
- .id(style.id)
62
- .key(style.id)
63
- .padding(style.padding)
64
- .margin(style.margin)
65
- .width(style.width)
66
- .height(style.height)
67
- .constraintSize(style.constraintSize)
68
- .flexGrow(style.flexGrow)
69
- .flexShrink(style.flexShrink)
70
- .flexBasis(style.flexBasis)
71
- .alignSelf(style.alignSelf)
72
- .backgroundColor(style.backgroundColor)
73
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
74
- .backgroundImageSize(style.backgroundImageSize)
75
- .rotate(style.rotate)
76
- .scale(style.scale)
77
- .translate(style.translate)
78
- .transform(style.transform)
79
- .borderStyle(style.borderStyle)
80
- .borderWidth(style.borderWidth)
81
- .borderColor(style.borderColor)
82
- .borderRadius(style.borderRadius)
83
- .linearGradient(style.linearGradient)
84
- .zIndex(style.zIndex)
85
- .opacity(style.opacity)
86
- .clip(style.clip)
87
- }
88
-
89
-
90
27
  function getAttributes (node: TaroScrollViewElement): ScrollViewAttrs {
91
28
  const _attrs = node._attrs
92
29
  const scrollAttrs: ScrollViewAttrs = {
@@ -97,103 +34,98 @@ function getAttributes (node: TaroScrollViewElement): ScrollViewAttrs {
97
34
  return scrollAttrs
98
35
  }
99
36
 
37
+ function getScrollable (node: TaroScrollViewElement) {
38
+ const _attrs = node._attrs
100
39
 
101
- @Component
102
- export default struct TaroScrollView {
103
- nodeInfoMap: TaroAny = {}
104
-
105
- wrapper?: Area
40
+ return _attrs.scrollX ? ScrollDirection.Horizontal : ScrollDirection.Vertical
41
+ }
106
42
 
107
- @Styles visibleChangeEvent () {
108
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
43
+ function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', xOffset?: number, yOffset?: number) {
44
+ const currentOffset = node.scroller.currentOffset() as ScrollViewCurrentOffset
45
+ const currentXOffset = currentOffset.xOffset
46
+ const currentYOffset = currentOffset.yOffset
47
+ const value: ScrollViewEvent = {
48
+ deltaX: vp2px(xOffset),
49
+ deltaY: vp2px(yOffset),
50
+ scrollLeft: vp2px(currentXOffset),
51
+ scrollTop: vp2px(currentYOffset),
52
+ scrollWidth: vp2px(Number(node._nodeInfo?._scroll?.width)),
53
+ scrollHeight: vp2px(Number(node._nodeInfo?._scroll?.height)),
109
54
  }
55
+ const event: TaroEvent = createTaroEvent(eventName, { detail: value }, node)
110
56
 
111
- scroller: Scroller = new Scroller()
57
+ eventHandler(event, eventName, node)
58
+ }
112
59
 
60
+ @Component
61
+ export default struct TaroScrollView {
62
+ @Builder customBuilder() {}
63
+ @BuilderParam createLazyChildren: (node: TaroScrollViewElement) => void = this.customBuilder
113
64
  @ObjectLink node: TaroScrollViewElement
65
+ @State overwriteStyle: Record<string, TaroAny> = {}
114
66
 
115
- aboutToAppear () {
116
- initComponentNodeInfo(this, this.node)
117
- bindInstanceToNode(this.node, this)
118
- // 绑定动画
119
- bindAnimation(this.node)
120
- bindScrollTo(this.node, this)
121
- }
122
-
123
- @Styles defaultEvent () {
124
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
125
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
126
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
127
- const eventResult: TaroAny = res.eventResult
128
- this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
129
- }))
130
- }
131
-
132
- @Styles defaultContainerEvent () {
133
- .onAreaChange(shouldBindEvent((areaResult: Area) => {
134
- this.wrapper = areaResult
135
- }, this.node, ['scroll', 'scrollstart', 'scrollend']))
67
+ aboutToAppear(): void {
68
+ if (this.node) {
69
+ this.node._instance = this
70
+ }
136
71
  }
137
72
 
138
-
139
- handleScrollEvent (eventName = 'scroll', xOffset?: number, yOffset?: number) {
140
- const currentOffset: ScrollViewCurrentOffset = this.scroller.currentOffset()
141
- const currentXOffset = currentOffset.xOffset
142
- const currentYOffset = currentOffset.yOffset
143
- const value: ScrollViewEvent = {
144
- deltaX: vp2px(xOffset),
145
- deltaY: vp2px(yOffset),
146
- scrollLeft: vp2px(currentXOffset),
147
- scrollTop: vp2px(currentYOffset),
148
- scrollWidth: vp2px(Number(this.wrapper?.width)),
149
- scrollHeight: vp2px(Number(this.wrapper?.height)),
150
- }
151
- const event: TaroEvent = createTaroEvent(eventName, { detail: value }, this.node)
152
- eventHandler(event, eventName, this.node)
73
+ isScrollX() {
74
+ return this.node._attrs.scrollX || getStyleAttr(this.node, 'overflow') === 'scroll' && getStyleAttr(this.node, 'flexDirection') === FlexDirection.Row
153
75
  }
154
76
 
155
- build() {
156
- TaroComponentWrapper({ node: this.node }) {
157
- // Copy 额外增加visibleChangeEvent
158
- if (this.node._attrs.scrollX) {
159
- Scroll(this.scroller) {
160
- Row() {
161
- ForEach(this.node.childNodes, (item: TaroElement) => {
162
- createNode(item)
163
- }, (item: TaroElement) => item._nid)
77
+ build () {
78
+ Scroll(this.node.scroller) {
79
+ if (this.isScrollX()) {
80
+ Row() {
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)
164
85
  }
165
- .rowAttrs(getNormalAttributes(this.node))
166
- .width(null)
167
- .defaultContainerEvent()
168
86
  }
169
- .flexGrow(getNormalAttributes(this.node).flexGrow)
170
- .scrollable(ScrollDirection.Horizontal)
171
- .scrollBar(getAttributes(this.node).scrollBar)
172
- .defaultEvent()
173
- .onScroll(shouldBindEvent(() => { this.handleScrollEvent('scroll') }, this.node, ['scroll']))
174
- .onScrollStart(shouldBindEvent(() => { this.handleScrollEvent('scrollstart') }, this.node, ['scrollstart']))
175
- .onScrollStop(shouldBindEvent(() => { this.handleScrollEvent('scrollend') }, this.node, ['scrollend']))
176
- .visibleChangeEvent()
87
+ .alignItems(FlexManager.alignItems<VerticalAlign>(this.node))
88
+ .justifyContent(FlexManager.justifyContent(this.node))
89
+ .height(getStyleAttr(this.node, 'height'))
90
+ .width(null)
91
+ .onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
92
+ this.node._nodeInfo._scroll = areaResult
93
+ }, this.node, ['scroll', 'scrollstart', 'scrollend']))
94
+ .flexGrow(0).flexShrink(0)
177
95
  } else {
178
- Scroll(this.scroller) {
179
- Column() {
180
- ForEach(this.node.childNodes, (item: TaroElement) => {
181
- createNode(item)
182
- }, (item: TaroElement) => item._nid)
96
+ Column() {
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)
183
101
  }
184
- .columnAttrs(getNormalAttributes(this.node))
185
- .height(null)
186
- .defaultContainerEvent()
187
102
  }
188
- .flexGrow(getNormalAttributes(this.node).flexGrow)
189
- .scrollable(ScrollDirection.Vertical)
190
- .scrollBar(getAttributes(this.node).scrollBar)
191
- .defaultEvent()
192
- .onScroll(shouldBindEvent(() => { this.handleScrollEvent('scroll') }, this.node, ['scroll']))
193
- .onScrollStart(shouldBindEvent(() => { this.handleScrollEvent('scrollstart') }, this.node, ['scrollstart']))
194
- .onScrollStop(shouldBindEvent(() => { this.handleScrollEvent('scrollend') }, this.node, ['scrollend']))
195
- .visibleChangeEvent()
103
+ .alignItems(FlexManager.alignItems<HorizontalAlign>(this.node))
104
+ .justifyContent(FlexManager.justifyContent(this.node))
105
+ .width(getStyleAttr(this.node, 'width'))
106
+ .height(null)
107
+ .onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
108
+ this.node._nodeInfo._scroll = areaResult
109
+ }, this.node, ['scroll', 'scrollstart', 'scrollend']))
110
+ .flexGrow(0).flexShrink(0)
196
111
  }
197
112
  }
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]
124
+ }))
125
+ .onDidScroll(shouldBindEvent((xOffset: number, yOffset: number) => { handleScrollEvent(this.node, 'scroll', xOffset, yOffset) }, 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']))
198
130
  }
199
131
  }
@@ -1,60 +1,16 @@
1
- import { bindInstanceToNode, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, initComponentNodeInfo,
2
- TaroEvent, TaroAny } from '@tarojs/runtime'
1
+ import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
3
2
 
4
- import TaroComponentWrapper from './base'
5
- import { createTaroEvent } from './utils/events'
6
- import { getNodeThresholds, shouldBindEvent, getNormalAttributes } from './utils/helper'
3
+ import commonStyleModify from './style'
4
+ import { getNodeThresholds, shouldBindEvent } from './utils/helper'
7
5
 
8
- import type { TaroSliderElement } from './element'
9
- import type { TaroStyleType } from '@tarojs/runtime'
6
+ import type { TaroAny, TaroSliderElement, TaroEvent } from '@tarojs/runtime'
10
7
 
11
- interface SliderOptions {
12
- min?: number
13
- max?: number
14
- value?: number
15
- step?: number
16
- style?: SliderStyle
17
- direction?: Axis
18
- }
19
8
  interface SliderAttrs {
20
9
  selectedColor?: ResourceColor
21
10
  trackColor?: ResourceColor
22
11
  trackThickness?: Length
23
12
  blockColor?: ResourceColor
24
13
  }
25
- interface SliderParams {
26
- width: string
27
- }
28
-
29
- @Extend(Slider)
30
- function style (style: TaroStyleType) {
31
- .id(style.id)
32
- .key(style.id)
33
- .padding(style.padding)
34
- .margin(style.margin)
35
- .width(style.width)
36
- .height(style.height)
37
- .constraintSize(style.constraintSize)
38
- .flexGrow(style.flexGrow)
39
- .flexShrink(style.flexShrink)
40
- .flexBasis(style.flexBasis)
41
- .alignSelf(style.alignSelf)
42
- .backgroundColor(style.backgroundColor)
43
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
44
- .backgroundImageSize(style.backgroundImageSize)
45
- .rotate(style.rotate)
46
- .scale(style.scale)
47
- .translate(style.translate)
48
- .transform(style.transform)
49
- .borderStyle(style.borderStyle)
50
- .borderWidth(style.borderWidth)
51
- .borderColor(style.borderColor)
52
- .borderRadius(style.borderRadius)
53
- .linearGradient(style.linearGradient)
54
- .zIndex(style.zIndex)
55
- .opacity(style.opacity)
56
- .clip(style.clip)
57
- }
58
14
 
59
15
  @Extend(Slider)
60
16
  function attrs (attr: SliderAttrs) {
@@ -81,79 +37,76 @@ function themeStyles(isDisabled: boolean) {
81
37
 
82
38
  @Component
83
39
  export default struct TaroSlider {
84
- nodeInfoMap: TaroAny = {}
85
-
40
+ @Builder customBuilder() {}
41
+ @BuilderParam createLazyChildren: (node: TaroSliderElement) => void = this.customBuilder
86
42
  @ObjectLink node: TaroSliderElement
87
43
 
88
44
  @State value: number = 0
89
-
90
- @Styles visibleChangeEvent () {
91
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
92
- }
45
+ @State overwriteStyle: Record<string, TaroAny> = {}
93
46
 
94
47
  aboutToAppear () {
95
- initComponentNodeInfo(this, this.node)
96
- bindInstanceToNode(this.node, this)
48
+ if (this.node) {
49
+ this.value = this.node.value
50
+ this.node._instance = this
97
51
 
98
- this.value = Number(this.node._attrs.value || 0)
99
- }
100
-
101
- @Styles defaultEvent () {
102
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
103
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
104
- const eventResult: TaroAny = res.eventResult
105
- this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
106
- }))
52
+ if (!this.node._isInit) {
53
+ this.node._isInit = true
54
+ this.node._reset = this.node.value || 0
55
+ }
56
+ }
107
57
  }
108
58
 
109
- @Builder createSlider () {
59
+ @Builder createSlider (node: TaroSliderElement) {
110
60
  Slider({
111
- min: Number(this.node._attrs.min || 0),
112
- max: Number(this.node._attrs.max || 100),
61
+ min: Number(node._attrs.min || 0),
62
+ max: Number(node._attrs.max || 100),
113
63
  value: this.value,
114
- step: Number(this.node._attrs.step || 1),
64
+ step: Number(node._attrs.step || 1),
115
65
  style: SliderStyle.OutSet,
116
66
  direction: Axis.Horizontal
117
67
  })
118
- .defaultEvent()
119
- .style(getNormalAttributes(this.node))
120
- .attrs(getAttributes(this.node))
121
- .width(!!this.node._attrs.showValue ? '90%' : '100%')
122
- .themeStyles(!!this.node._attrs.disabled)
68
+ .attributeModifier(commonStyleModify.setNode(node).setAnimationStyle(this.overwriteStyle))
69
+ .attrs(getAttributes(node))
70
+ .width(!!node._attrs.showValue ? '90%' : '100%')
71
+ .themeStyles(!!node._attrs.disabled)
123
72
  .onChange((value: number, mode: SliderChangeMode) => {
124
- if (!!this.node._attrs.disabled) {
73
+ if (!!node._attrs.disabled) {
125
74
  if (mode === SliderChangeMode.End) {
126
- // FIXME 找下文档是否有强制刷新方法
127
- this.value = this.value + 0.01
128
- this.value = this.value - 0.01
75
+ this.node?.updateComponent()
129
76
  }
130
77
  } else {
131
78
  this.value = value
79
+ this.node?.updateFormWidgetValue(value)
80
+
132
81
  if (mode === SliderChangeMode.End) {
133
- const event: TaroEvent = createTaroEvent('change', { detail: { value: this.value } }, this.node)
134
- eventHandler(event, 'change', this.node)
82
+ const event: TaroEvent = createTaroEvent('change', { detail: { value: this.value } }, node)
83
+ eventHandler(event, 'change', node)
135
84
  } else if (mode === SliderChangeMode.Moving) {
136
- const event: TaroEvent = createTaroEvent('changing', { detail: { value: this.value } }, this.node)
137
- eventHandler(event, 'changing', this.node)
85
+ const event: TaroEvent = createTaroEvent('changing', { detail: { value: this.value } }, node)
86
+ eventHandler(event, 'changing', node)
138
87
  }
139
88
  }
140
89
  })
141
- .visibleChangeEvent()
90
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
91
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
92
+ if (this.node) {
93
+ this.node._nodeInfo.areaInfo = res[1]
94
+ }
95
+ }))
96
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
142
97
  }
143
98
 
144
99
  build() {
145
- TaroComponentWrapper({ node: this.node }) {
146
- if (!!this.node._attrs.showValue) {
147
- Row() {
148
- this.createSlider()
149
- Text(Number(this.value).toFixed(0))
150
- .width('10%')
151
- .textAlign(TextAlign.Center)
152
- .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
153
- }
154
- } else {
155
- this.createSlider()
100
+ if (!!this.node._attrs.showValue) {
101
+ Row() {
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)
156
107
  }
108
+ } else {
109
+ this.createSlider(this.node)
157
110
  }
158
111
  }
159
112
  }
@@ -0,0 +1,42 @@
1
+ import commonStyleModify from './style'
2
+
3
+ import type { TaroViewElement, TaroElement, TaroAny } from '@tarojs/runtime'
4
+
5
+ @Component
6
+ export default struct TaroStickySection {
7
+ @Builder customBuilder() {}
8
+ @BuilderParam createLazyChildren: (node: TaroViewElement) => void = this.customBuilder
9
+ @ObjectLink node: TaroViewElement
10
+ @State overwriteStyle: Record<string, TaroAny> = {}
11
+
12
+ aboutToAppear(): void {
13
+ if (this.node) {
14
+ this.node._instance = this
15
+ }
16
+ }
17
+
18
+ @Builder
19
+ itemHead(header: TaroViewElement) {
20
+ Stack() {
21
+ LazyForEach(header, (item: TaroElement) => {
22
+ if (item.tagName === 'STICKY-HEADER') {
23
+ this.createLazyChildren(item as TaroViewElement)
24
+ }
25
+ }, (item: TaroElement) => `${item._nid}-${item._nodeInfo?.layer || 0}`)
26
+ }
27
+ }
28
+
29
+ build() {
30
+ ListItemGroup({
31
+ header: this.itemHead(this.node)
32
+ }) {
33
+ ForEach(this.node.children, (item: TaroElement) => {
34
+ if (item.tagName === 'LIST-VIEW') {
35
+ this.createLazyChildren(item as TaroViewElement)
36
+ }
37
+ }, (item: TaroElement) => `${item._nid}-${item._nodeInfo?.layer || 0}`)
38
+
39
+ }
40
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
41
+ }
42
+ }