@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,149 +1,62 @@
1
- import { bindInstanceToNode, AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, initComponentNodeInfo, findChildNodeWithDFS,
2
- TaroEvent,
3
- TaroAny,
4
- TaroFormWidgetElement
5
- } from '@tarojs/runtime'
1
+ import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
6
2
 
7
- import { createNode } from './render'
8
- import TaroComponentWrapper from './base'
9
- import { TOUCH_EVENT_MAP } from './utils/constant/event'
10
- import { FlexManager } from './utils/FlexManager'
11
- import { createTaroEvent } from './utils/events'
12
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds, bindAnimation } from './utils/helper'
13
-
14
- import type { TaroFormElement, TaroElement, TaroCheckboxElement, TaroRadioElement, TaroInputElement,
15
- TaroSliderElement,
16
- TaroSwitchElement,
17
- TaroPickerElement
18
- } from './element'
19
- import type { TaroStyleType } from '@tarojs/runtime'
3
+ import commonStyleModify, { rowModify, columnModify } from './style'
20
4
 
5
+ import { TOUCH_EVENT_MAP } from './utils/constant/event'
6
+ import { FlexManager } from './utils/flexManager'
7
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
21
8
 
22
- @Extend(Flex)
23
- function attrs (style: TaroStyleType) {
24
- .id(style.id)
25
- .key(style.id)
26
- .padding(style.padding)
27
- .margin(style.margin)
28
- .width(style.width)
29
- .height(style.height)
30
- .constraintSize(style.constraintSize)
31
- .flexGrow(style.flexGrow)
32
- .flexShrink(style.flexShrink)
33
- .flexBasis(style.flexBasis)
34
- .alignSelf(style.alignSelf)
35
- .backgroundColor(style.backgroundColor)
36
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
37
- .backgroundImageSize(style.backgroundImageSize)
38
- .rotate(style.rotate)
39
- .scale(style.scale)
40
- .translate(style.translate)
41
- .transform(style.transform)
42
- .borderStyle(style.borderStyle)
43
- .borderWidth(style.borderWidth)
44
- .borderColor(style.borderColor)
45
- .borderRadius(style.borderRadius)
46
- .linearGradient(style.linearGradient)
47
- .zIndex(style.zIndex)
48
- .opacity(style.opacity)
49
- .clip(style.clip)
50
- }
9
+ import type { TaroAny, TaroFormElement } from '@tarojs/runtime'
10
+ import { isUndefined } from '@tarojs/shared'
51
11
 
52
12
  @Component
53
13
  export default struct TaroForm {
54
- nodeInfoMap: TaroAny = {}
55
-
56
- @Styles visibleChangeEvent () {
57
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
58
- }
59
-
14
+ @Builder customBuilder() {}
15
+ @BuilderParam createLazyChildren: (node: TaroFormElement) => void = this.customBuilder
60
16
  @ObjectLink node: TaroFormElement
61
17
 
62
- aboutToAppear () {
63
- initComponentNodeInfo(this, this.node)
64
- bindInstanceToNode(this.node, this)
65
- // 绑定动画
66
- bindAnimation(this.node)
67
-
68
- // 监听submit冒泡
69
- this.node.addEventListener('submit-btn', (e: TaroEvent) => {
70
- e.stopPropagation()
71
- const formResult: Record<string, string> = {}
72
- findChildNodeWithDFS(this.node, (item: TaroFormWidgetElement) => {
73
- switch (item.nodeName) {
74
- case 'INPUT':
75
- case 'SLIDER':
76
- case 'SWITCH':
77
- case 'RADIO-GROUP':
78
- case 'CHECKBOX-GROUP':
79
- case 'PICKER': {
80
- formResult[item.name] = item.value
81
- break
82
- }
83
- }
84
- return false
85
- }, true)
86
- const event: TaroEvent = createTaroEvent('submit', { detail: { value: formResult } }, this.node)
87
- eventHandler(event, 'submit', this.node)
88
- })
89
- // 监听reset冒泡
90
- this.node.addEventListener('reset-btn', (e: TaroEvent) => {
91
- findChildNodeWithDFS(this.node, (item: TaroFormWidgetElement) => {
92
- e.stopPropagation()
93
- switch (item.nodeName) {
94
- case 'INPUT': {
95
- item.value = (item as TaroInputElement)._attrs.value
96
- break
97
- }
98
- case 'SLIDER': {
99
- item.value = (item as TaroSliderElement)._attrs.value
100
- break
101
- }
102
- case 'SWITCH': {
103
- item.value = (item as TaroSwitchElement)._attrs.checked
104
- break
105
- }
106
- case 'RADIO-GROUP': {
107
- item.getElementsByTagName<TaroRadioElement>('RADIO').forEach(element => {
108
- element._instance.checked = element._attrs.checked || false
109
- })
110
- break
111
- }
112
- case 'CHECKBOX-GROUP': {
113
- item.getElementsByTagName<TaroCheckboxElement>('CHECKBOX').forEach(element => {
114
- element._instance.checked = element._attrs.checked || false
115
- })
116
- break
117
- }
118
- case 'PICKER': {
119
- item.value = (item as TaroPickerElement)._attrs.value
120
- break
121
- }
122
- }
123
- return false
124
- }, true)
125
- })
126
- }
18
+ @State overwriteStyle: Record<string, TaroAny> = {}
127
19
 
128
- @Styles defaultEvent () {
129
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
130
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
131
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
132
- const eventResult: TaroAny = res.eventResult
133
- this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
134
- }))
20
+ aboutToAppear(): void {
21
+ if (this.node) {
22
+ this.node._instance = this
23
+ }
135
24
  }
136
25
 
137
26
  build() {
138
- TaroComponentWrapper({ node: this.node }) {
27
+ if (FlexManager.useFlexLayout(this.node)) {
139
28
  Flex(FlexManager.flexOptions(this.node)) {
140
- ForEach(this.node.childNodes, (item: TaroElement) => {
141
- createNode(item)
142
- }, (item: TaroElement) => item._nid)
29
+ this.createLazyChildren(this.node)
30
+ }
31
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
32
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
33
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
34
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
35
+ this.node._nodeInfo.areaInfo = res[1]
36
+ }))
37
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
38
+ } else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
39
+ Row() {
40
+ this.createLazyChildren(this.node)
41
+ }
42
+ .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
43
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
44
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
45
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
46
+ this.node._nodeInfo.areaInfo = res[1]
47
+ }))
48
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
49
+ } else {
50
+ Column() {
51
+ this.createLazyChildren(this.node)
143
52
  }
144
- .attrs(getNormalAttributes(this.node))
145
- .defaultEvent()
146
- .visibleChangeEvent()
53
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
54
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
55
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
56
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
57
+ this.node._nodeInfo.areaInfo = res[1]
58
+ }))
59
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
147
60
  }
148
61
  }
149
62
  }
@@ -1,84 +1,81 @@
1
- import { bindInstanceToNode, eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, initComponentNodeInfo, TaroAny } from '@tarojs/runtime'
1
+ import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, convertNumber2PX } from '@tarojs/runtime'
2
2
 
3
- import TaroComponentWrapper from './base'
4
- import { ICON_SVG_MAP } from './utils/constant/icon'
5
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds, bindAnimation } from './utils/helper'
3
+ import commonStyleModify from './style'
4
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
6
5
 
7
- import type { TaroIconElement } from './element'
8
- import type { TaroStyleType } from '@tarojs/runtime'
6
+ import type { TaroIconElement, TaroAny } from '@tarojs/runtime'
9
7
 
8
+ const ICON_COLOR_MAP: TaroAny = {
9
+ success: Color.Green,
10
+ success_no_circle: Color.Green,
11
+ info: Color.Blue,
12
+ warn: Color.Red,
13
+ waiting: Color.Blue,
14
+ cancel: Color.Red,
15
+ download: Color.Gray,
16
+ search: Color.Gray,
17
+ clear: Color.Gray,
18
+ info_circle: Color.Blue,
19
+ circle: Color.Gray
20
+ }
10
21
 
11
- @Extend(Image)
12
- function attrs (style: TaroStyleType) {
13
- .id(style.id)
14
- .key(style.id)
15
- .padding(style.padding)
16
- .margin(style.margin)
17
- .width(style.width || convertNumber2VP(23))
18
- .height(style.height || convertNumber2VP(23))
19
- .constraintSize(style.constraintSize)
20
- .flexGrow(style.flexGrow)
21
- .flexShrink(style.flexShrink)
22
- .flexBasis(style.flexBasis)
23
- .alignSelf(style.alignSelf)
24
- .backgroundColor(style.backgroundColor)
25
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
26
- .backgroundImageSize(style.backgroundImageSize)
27
- .rotate(style.rotate)
28
- .scale(style.scale)
29
- .translate(style.translate)
30
- .transform(style.transform)
31
- .borderStyle(style.borderStyle)
32
- .borderWidth(style.borderWidth)
33
- .borderColor(style.borderColor)
34
- .borderRadius(style.borderRadius)
35
- .linearGradient(style.linearGradient)
36
- .zIndex(style.zIndex)
37
- .opacity(style.opacity)
38
- .clip(style.clip)
22
+ function getIconData (node: TaroIconElement): Resource | null {
23
+ switch (node._attrs.type) {
24
+ case 'success':
25
+ return $r('app.media.success')
26
+ case 'success_no_circle':
27
+ return $r('app.media.success_no_circle')
28
+ case 'info':
29
+ return $r('app.media.info')
30
+ case 'warn':
31
+ return $r('app.media.warn')
32
+ case 'waiting':
33
+ return $r('app.media.waiting')
34
+ case 'cancel':
35
+ return $r('app.media.cancel')
36
+ case 'download':
37
+ return $r('app.media.download')
38
+ case 'search':
39
+ return $r('app.media.search')
40
+ case 'clear':
41
+ return $r('app.media.clear')
42
+ case 'info_circle':
43
+ return $r('app.media.info_circle')
44
+ case 'circle':
45
+ return $r('app.media.circle')
46
+ default:
47
+ return null
48
+ }
39
49
  }
40
50
 
41
51
  @Component
42
52
  export default struct TaroIcon {
43
- nodeInfoMap: TaroAny = {}
44
-
45
- @Styles visibleChangeEvent () {
46
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
47
- }
48
-
53
+ @Builder customBuilder() {}
54
+ @BuilderParam createLazyChildren: (node: TaroIconElement) => void = this.customBuilder
49
55
  @ObjectLink node: TaroIconElement
56
+ @State overwriteStyle: Record<string, TaroAny> = {}
50
57
 
51
- aboutToAppear () {
52
- initComponentNodeInfo(this, this.node)
53
- bindInstanceToNode(this.node, this)
54
- // 绑定动画
55
- bindAnimation(this.node)
56
- }
57
-
58
- @Styles defaultEvent () {
59
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
60
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
61
- const eventResult: TaroAny = res.eventResult
62
- this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
63
- }))
64
- }
65
-
66
- getIconData () {
67
- if (!this.node || !this.node._attrs) return null
68
- const type: string = this.node._attrs.type
69
- // TODO:等待鸿蒙支持 base64 格式的 svg 图片,或者工程化支持图片资源的迁移
70
- return ICON_SVG_MAP.get(type) || null
58
+ aboutToAppear(): void {
59
+ if (this.node) {
60
+ this.node._instance = this
61
+ }
71
62
  }
72
63
 
73
64
  build() {
74
- TaroComponentWrapper({ node: this.node }) {
75
- Image(this.getIconData())
76
- .defaultEvent()
77
- .objectFit(ImageFit.Contain)
78
- .fillColor(this.node._attrs.color)
79
- .onComplete(e => eventHandler(e, 'complete', this.node))
80
- .attrs(getNormalAttributes(this.node))
81
- .visibleChangeEvent()
82
- }
65
+ Image(getIconData(this.node))
66
+ .objectFit(ImageFit.Contain)
67
+ .fillColor(this.node._attrs.color || ICON_COLOR_MAP[this.node._attrs.type] || Color.Black)
68
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
69
+ .size({
70
+ width: Number(this.node._attrs.size) || 23,
71
+ height: Number(this.node._attrs.size) || 23
72
+ })
73
+ .onComplete(e => eventHandler(e, 'complete', this.node))
74
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
75
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
76
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
77
+ this.node._nodeInfo.areaInfo = res[1]
78
+ }))
83
79
  }
84
80
  }
81
+
@@ -1,42 +1,11 @@
1
- import { bindInstanceToNode, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, initComponentNodeInfo, TaroAny } from '@tarojs/runtime'
1
+ import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
- import TaroComponentWrapper from './base'
4
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds, bindAnimation } from './utils/helper'
3
+ import commonStyleModify from './style'
4
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
5
5
 
6
- import type { TaroImageElement } from './element'
7
- import type { TaroStyleType } from '@tarojs/runtime'
6
+ import type { TaroImageElement, TaroAny } from '@tarojs/runtime'
8
7
 
9
- @Extend(Image)
10
- function attrs (style: TaroStyleType) {
11
- .id(style.id)
12
- .key(style.id)
13
- .padding(style.padding)
14
- .margin(style.margin)
15
- .width(style.width)
16
- .height(style.height)
17
- .constraintSize(style.constraintSize)
18
- .flexGrow(style.flexGrow)
19
- .flexShrink(style.flexShrink)
20
- .flexBasis(style.flexBasis)
21
- .alignSelf(style.alignSelf)
22
- .backgroundColor(style.backgroundColor)
23
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
24
- .backgroundImageSize(style.backgroundImageSize)
25
- .rotate(style.rotate)
26
- .scale(style.scale)
27
- .translate(style.translate)
28
- .transform(style.transform)
29
- .borderStyle(style.borderStyle)
30
- .borderWidth(style.borderWidth)
31
- .borderColor(style.borderColor)
32
- .borderRadius(style.borderRadius)
33
- .linearGradient(style.linearGradient)
34
- .zIndex(style.zIndex)
35
- .opacity(style.opacity)
36
- .clip(style.clip)
37
- }
38
-
39
- function getImageMode (mode: string): ImageFit {
8
+ export function getImageMode (mode: string): ImageFit {
40
9
  switch (mode) {
41
10
  case 'aspectFit': return ImageFit.Contain
42
11
  case 'aspectFill': return ImageFit.Cover
@@ -49,37 +18,33 @@ function getImageMode (mode: string): ImageFit {
49
18
 
50
19
  @Component
51
20
  export default struct TaroImage {
52
- nodeInfoMap: TaroAny = {}
53
-
54
- @Styles visibleChangeEvent () {
55
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
56
- }
57
-
21
+ @Builder customBuilder() {}
22
+ @BuilderParam createLazyChildren: (node: TaroImageElement) => void = this.customBuilder
58
23
  @ObjectLink node: TaroImageElement
24
+ @State overwriteStyle: Record<string, TaroAny> = {}
59
25
 
60
- aboutToAppear () {
61
- initComponentNodeInfo(this, this.node)
62
- bindInstanceToNode(this.node, this)
63
- // 绑定动画
64
- bindAnimation(this.node)
65
- }
66
-
67
- @Styles defaultEvent () {
68
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
69
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
70
- const eventResult: TaroAny = res.eventResult
71
- this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
72
- }))
26
+ aboutToAppear(): void {
27
+ if (this.node) {
28
+ this.node._instance = this
29
+ }
73
30
  }
74
31
 
75
32
  build() {
76
- TaroComponentWrapper({ node: this.node }) {
77
- Image(this.node.getAttribute('src'))
78
- .defaultEvent()
33
+ Image(this.node.getAttribute('src'))
34
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
35
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
36
+ this.node._nodeInfo.areaInfo = res[1]
37
+ }))
79
38
  .objectFit(getImageMode(this.node.getAttribute('mode')))
80
- .attrs(getNormalAttributes(this.node))
39
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
81
40
  .onComplete(e => eventHandler(e, 'complete', this.node))
82
- .visibleChangeEvent()
83
- }
41
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
42
+ // TODO: 临时改为申明式,后续等鸿蒙修复modify设置失败的bug后删除该申明
43
+ .borderRadius({
44
+ topLeft: this.node._st.hmStyle.borderTopLeftRadius,
45
+ topRight: this.node._st.hmStyle.borderTopRightRadius,
46
+ bottomLeft: this.node._st.hmStyle.borderBottomLeftRadius,
47
+ bottomRight: this.node._st.hmStyle.borderBottomRightRadius
48
+ })
84
49
  }
85
50
  }
@@ -0,0 +1,92 @@
1
+ import TaroImage, { getImageMode } from './image'
2
+ import TaroText from './text'
3
+ import TaroView from './view'
4
+ import TaroIcon from './icon'
5
+ import TaroForm from './form'
6
+ import TaroLabel from './label'
7
+ import TaroInput from './input'
8
+ import TaroVideo from './video'
9
+ import TaroCanvas from './canvas'
10
+ import TaroButton from './button'
11
+ import TaroPicker from './picker'
12
+ import TaroSlider from './slider'
13
+ import TaroSwitch from './switch'
14
+ import TaroSwiper from './swiper'
15
+ import TaroWebView from './webView'
16
+ import TaroTextArea from './textArea'
17
+ import TaroRichText from './richText'
18
+ import TaroProgress from './progress'
19
+ import TaroInnerHtml from './innerHtml'
20
+ import TaroScrollView from './scrollView'
21
+ import TaroMovableArea from './movableArea'
22
+ import TaroMovableView from './movableView'
23
+ import { TaroRadio, TaroRadioGroup } from './radio'
24
+ import { TaroCheckboxGroup, TaroCheckbox } from './checkbox'
25
+ import TaroPageMeta from './pageMeta'
26
+ import TaroNavigationBar from './navigationBar'
27
+
28
+ import TaroListView from './listView'
29
+ import TaroStickySection from './stickySection'
30
+ import TaroScrollList from './scrollList'
31
+
32
+ import commonStyleModify, { rowModify, columnModify, textModify, setNormalTextAttributeIntoInstance } from './style'
33
+ import { getButtonColor } from './button'
34
+ import { FlexManager } from './utils/flexManager'
35
+ import { DynamicCenter } from './utils/DynamicCenter'
36
+ import { TOUCH_EVENT_MAP } from './utils/constant/event'
37
+ import { BUTTON_THEME_COLOR } from './utils/constant/style'
38
+ import { getStyleAttr } from './utils/styles'
39
+ import { shouldBindEvent, getNodeThresholds, getNormalAttributes, getFontAttributes } from './utils/helper'
40
+
41
+ export {
42
+ textModify,
43
+ getStyleAttr,
44
+ FlexManager,
45
+ DynamicCenter,
46
+ getButtonColor,
47
+ TOUCH_EVENT_MAP,
48
+ shouldBindEvent,
49
+ getFontAttributes,
50
+ commonStyleModify,
51
+ rowModify,
52
+ columnModify,
53
+ getNodeThresholds,
54
+ BUTTON_THEME_COLOR,
55
+ getNormalAttributes,
56
+ setNormalTextAttributeIntoInstance,
57
+ getImageMode,
58
+ }
59
+
60
+ export {
61
+ TaroImage,
62
+ TaroCanvas,
63
+ TaroText,
64
+ TaroView,
65
+ TaroIcon,
66
+ TaroForm,
67
+ TaroLabel,
68
+ TaroInput,
69
+ TaroVideo,
70
+ TaroButton,
71
+ TaroPicker,
72
+ TaroSlider,
73
+ TaroSwitch,
74
+ TaroSwiper,
75
+ TaroWebView,
76
+ TaroTextArea,
77
+ TaroRichText,
78
+ TaroProgress,
79
+ TaroInnerHtml,
80
+ TaroScrollView,
81
+ TaroMovableArea,
82
+ TaroMovableView,
83
+ TaroRadio,
84
+ TaroRadioGroup,
85
+ TaroCheckboxGroup,
86
+ TaroCheckbox,
87
+ TaroPageMeta,
88
+ TaroNavigationBar,
89
+ TaroListView,
90
+ TaroStickySection,
91
+ TaroScrollList
92
+ }
@@ -1,79 +1,16 @@
1
- import TaroComponentWrapper from './base'
2
- import web_webview from '@ohos.web.webview'
3
1
  import htmlParser from './utils/htmlParser'
4
- import { createNode } from './render'
5
- import type { TaroElement } from './element'
2
+
3
+ import type { TaroElement, TaroInnerHtmlElement } from '@tarojs/runtime'
6
4
 
7
5
  @Component
8
6
  export default struct TaroInnerHtml {
9
- @ObjectLink node: TaroElement
10
-
11
- // controller: web_webview.WebviewController = new web_webview.WebviewController();
12
-
13
- // isLoaded: boolean = false
14
-
15
- // @State isInit: boolean = false
16
-
17
- // @State height: string = '2vp' // 如果起始高度不足,将不会渲染webview
18
-
19
- // jsBridge = {
20
- // // 获取父级高度,拿到实际的webview宽度,计算出高度
21
- // load: (bodyHeight: number, bodyWidth: number) => {
22
- // const { width } = this.node.parentElement.instance.info
23
- // const widthPx = vp2px(width)
24
- // this.height = Math.floor(widthPx / bodyWidth * bodyHeight) + 'px'
25
- // this.isInit = true
26
- // }
27
- // }
7
+ @Builder customBuilder() {}
8
+ @BuilderParam createChildItem: (node: TaroElement, callback?: (node: TaroElement) => void) => void = this.customBuilder
9
+ @ObjectLink node: TaroInnerHtmlElement
28
10
 
29
11
  build() {
30
- TaroComponentWrapper({ node: this.node }) {
31
- if (this.node.innerHTML) {
32
- createNode(htmlParser(this.node.innerHTML))
33
- }
34
- // // webview实现
35
- // if (this.node.innerHTML) {
36
- // Web({ src: $rawfile('innerHTML.html'), controller: this.controller }).onPageBegin((event) => {
37
- // if (this.isLoaded) return
38
- // this.isLoaded = true
39
- // // 注入jsBridge,监听页面onload行为,获取高度
40
- // this.controller.registerJavaScriptProxy(this.jsBridge, 'jsBridge', ['load'])
41
- // const innerString = this.node.innerHTML
42
- // try {
43
- // this.controller.loadData(
44
- // `
45
- // <html>
46
- // <body onload="jsBridge.load(document.getElementById('container').clientHeight, document.body.clientWidth);" style="padding: 0;margin: 0">
47
- // <div id="container">
48
- // ${innerString}
49
- // </div>
50
- // </body>
51
- // </html>
52
- // `,
53
- // "text/html",
54
- // "UTF-8"
55
- // )
56
- // } catch (error) {
57
- // console.log(`ErrorCode: ${error.code}, Message: ${error.message}`);
58
- // }
59
- // })
60
- // .javaScriptAccess(true)
61
- // .size({
62
- // width: '100%',
63
- // height: this.height
64
- // })
65
- // .visibility(this.isInit)
66
- // // 覆盖webwiew的scroll
67
- // Stack({ alignContent: Alignment.TopStart }) {
68
- // Flex().size({
69
- // height: this.height,
70
- // width: '100%'
71
- // })
72
- // }.position({
73
- // x: 0,
74
- // y: 0
75
- // })
76
- // }
12
+ if (this.node?.hmStyle?.display !== 'none' && this.node.innerHTML) {
13
+ this.createChildItem(htmlParser(this.node.innerHTML))
77
14
  }
78
15
  }
79
16
  }