@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,79 +1,13 @@
1
- import { bindInstanceToNode, AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, initComponentNodeInfo, getPageScrollerOrNode,
2
- TaroAny,
3
- TaroEvent
4
- } from '@tarojs/runtime'
5
- import { createNode } from './render'
6
- import TaroComponentWrapper from './base'
1
+ import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, TaroPickerElement, createTaroEvent } from '@tarojs/runtime'
2
+ import commonStyleModify from './style'
7
3
  import { getSingleSelector, getMultiSelector } from './utils'
8
4
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
9
- import { FlexManager } from './utils/FlexManager'
10
- import { createTaroEvent } from './utils/events'
11
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds, bindAnimation } from './utils/helper'
5
+ import { FlexManager } from './utils/flexManager'
6
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
12
7
 
13
- import type { TaroPickerElement, TaroElement } from './element'
14
- import type { TaroStyleType } from '@tarojs/runtime'
8
+ import type { TaroAny, TaroEvent } from '@tarojs/runtime'
15
9
 
16
- import { PickerDateProps, PickerMultiSelectorProps, PickerSelectorProps, PickerTimeProps } from './types'
17
-
18
- @Extend(TextPicker)
19
- function textPickerAttrs (style: TaroStyleType) {
20
- .id(style.id)
21
- .key(style.id)
22
- .padding(style.padding)
23
- .margin(style.margin)
24
- .width(style.width || '100%')
25
- .height(style.height)
26
- .constraintSize(style.constraintSize)
27
- .flexGrow(style.flexGrow)
28
- .flexShrink(style.flexShrink)
29
- .flexBasis(style.flexBasis)
30
- .alignSelf(style.alignSelf)
31
- .backgroundColor(style.backgroundColor || '#fff')
32
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
33
- .backgroundImageSize(style.backgroundImageSize)
34
- .rotate(style.rotate)
35
- .scale(style.scale)
36
- .translate(style.translate)
37
- .transform(style.transform)
38
- .borderStyle(style.borderStyle)
39
- .borderWidth(style.borderWidth)
40
- .borderColor(style.borderColor)
41
- .borderRadius(style.borderRadius)
42
- .linearGradient(style.linearGradient)
43
- .zIndex(style.zIndex)
44
- .opacity(style.opacity)
45
- .clip(style.clip)
46
- }
47
-
48
- @Extend(DatePicker)
49
- function datePickerAttrs (style: TaroStyleType) {
50
- .id(style.id)
51
- .key(style.id)
52
- .padding(style.padding)
53
- .margin(style.margin)
54
- .width(style.width || '100%')
55
- .height(style.height)
56
- .constraintSize(style.constraintSize)
57
- .flexGrow(style.flexGrow)
58
- .flexShrink(style.flexShrink)
59
- .flexBasis(style.flexBasis)
60
- .alignSelf(style.alignSelf)
61
- .backgroundColor(style.backgroundColor || '#fff')
62
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
63
- .backgroundImageSize(style.backgroundImageSize)
64
- .rotate(style.rotate)
65
- .scale(style.scale)
66
- .translate(style.translate)
67
- .transform(style.transform)
68
- .borderStyle(style.borderStyle)
69
- .borderWidth(style.borderWidth)
70
- .borderColor(style.borderColor)
71
- .borderRadius(style.borderRadius)
72
- .linearGradient(style.linearGradient)
73
- .zIndex(style.zIndex)
74
- .opacity(style.opacity)
75
- .clip(style.clip)
76
- }
10
+ import { PickerDateProps, PickerMultiSelectorProps, PickerSelectorProps, PickerTimeProps } from '@tarojs/components/types'
77
11
 
78
12
  interface TimeRange {
79
13
  startHH: number
@@ -84,10 +18,7 @@ interface TimeRange {
84
18
 
85
19
  @CustomDialog
86
20
  export struct PickerView {
87
-
88
- @ObjectLink node: TaroPickerElement
89
-
90
- @Link select: string | number
21
+ node: TaroPickerElement | null = null
91
22
 
92
23
  controller?: CustomDialogController
93
24
 
@@ -96,7 +27,7 @@ export struct PickerView {
96
27
  showSelector: number[] = []
97
28
 
98
29
  getDateOptions (): DatePickerOptions {
99
- const _attrs = this.node._attrs as PickerDateProps
30
+ const _attrs = this.node?._attrs as PickerDateProps
100
31
  return {
101
32
  start: new Date(_attrs.start || ''),
102
33
  end: new Date(_attrs.end || ''),
@@ -105,9 +36,9 @@ export struct PickerView {
105
36
  }
106
37
 
107
38
  getTextOptions (): TextPickerOptions {
108
- let mode: string = this.node._attrs.mode || 'selector'
39
+ let mode: string = this.node?._attrs.mode || 'selector'
109
40
  if (!mode) {
110
- const _attrs = this.node._attrs as PickerSelectorProps
41
+ const _attrs = this.node?._attrs as PickerSelectorProps
111
42
  const range = _attrs.range
112
43
  if (range && range.length && range[0] instanceof Array) {
113
44
  mode = 'multiSelector'
@@ -116,7 +47,7 @@ export struct PickerView {
116
47
  }
117
48
  switch (mode) {
118
49
  case 'time': {
119
- const _attrs = this.node._attrs as PickerTimeProps
50
+ const _attrs = this.node?._attrs as PickerTimeProps
120
51
  let timeRange: TimeRange = {
121
52
  startHH: 0,
122
53
  startMM: 0,
@@ -136,37 +67,34 @@ export struct PickerView {
136
67
  const left = generateNumberArray(timeRange.startHH, timeRange.endHH)
137
68
  const right = generateNumberArray(timeRange.startMM, timeRange.endMM)
138
69
  const range = [left, right]
139
- const _selected = _attrs.value.split(':')
70
+ const _selected = _attrs.value?.split(':') as string[]
140
71
  return {
141
72
  range: range,
142
73
  selected: [left.findIndex(i => parseInt(_selected[0]) === Number(i)), right.findIndex(i => parseInt(_selected[1]) === Number(i))],
143
74
  }
144
75
  }
145
76
  case 'multiSelector': {
146
- const _attrs = this.node._attrs as PickerMultiSelectorProps
147
- const value = _attrs.value as number[]
77
+ const _attrs = this.node?._attrs as PickerMultiSelectorProps
148
78
  let showRange = _attrs.range as string[][]
149
- this.showSelector = value
150
- showRange = getMultiSelector(this, _attrs.range, _attrs.rangeKey, value)
151
- let selects: string | number | string[] | number[] = this.select
152
- if (typeof selects === 'string') {
153
- selects = selects.split(',').map(i => Number(i))
154
- }
79
+ const selected: number[] = this.node?.value
80
+ this.showSelector = selected
81
+ showRange = getMultiSelector(this, _attrs.range, _attrs.rangeKey, selected)
82
+
155
83
  return {
84
+ selected,
156
85
  range: showRange,
157
- selected: selects || value
158
86
  }
159
87
  }
160
88
  default: {
161
- const _attrs = this.node._attrs as PickerSelectorProps
89
+ const _attrs = this.node?._attrs as PickerSelectorProps
162
90
  const range = _attrs.range
163
91
  let showRange = _attrs.range as string[]
164
92
  if (_attrs.rangeKey && typeof range[0] === 'object') {
165
- showRange = getSingleSelector(this, range, _attrs.rangeKey)
93
+ showRange = getSingleSelector(range, _attrs.rangeKey)
166
94
  }
167
95
  return {
168
96
  range: showRange,
169
- selected: (this.select as number) || _attrs.value
97
+ selected: this.node?.value
170
98
  }
171
99
  }
172
100
  }
@@ -179,7 +107,7 @@ export struct PickerView {
179
107
  }
180
108
 
181
109
  getText = () => {
182
- if (this.node._attrs.mode === 'selector') {
110
+ if (this.node?._attrs.mode === 'selector') {
183
111
  const _attrs = this.node._attrs as PickerSelectorProps
184
112
  return [_attrs.textProps?.okText || '确认', _attrs.textProps?.cancelText || '取消']
185
113
  } else {
@@ -190,83 +118,101 @@ export struct PickerView {
190
118
  @Builder
191
119
  showDialog() {
192
120
  Column() {
193
- Flex({
194
- direction: FlexDirection.Row,
195
- justifyContent: FlexAlign.SpaceBetween,
196
- alignItems: ItemAlign.Center
197
- }) {
198
- Text(this.getText()[1]).fontSize(15).padding({top: 20, bottom: 40}).fontColor('#888').onClick(() => {
199
- this.emitEvent('cancel')
200
- this.controller?.close()
201
- })
202
- Text(this.getText()[0]).fontSize(15).padding({top: 20, bottom: 40}).fontColor('#1aad19').onClick(() => {
203
- this.emitEvent('change', { value: this.select})
204
- this.controller?.close()
205
- })
206
- }
207
- .width('100%')
208
- .backgroundColor('#fff')
209
- .padding({
210
- left: 20,
211
- right: 20
212
- })
213
- if (this.node._attrs.mode === 'selector') {
214
- TextPicker(this.getTextOptions())
215
- .selectedTextStyle({
216
- color: '#000'
217
- })
218
- .canLoop(false)
219
- .textPickerAttrs(getNormalAttributes(this.node))
220
- .onChange((value, index) => {
221
- this.select = index as number
121
+ if (this.node) {
122
+ Flex({
123
+ direction: FlexDirection.Row,
124
+ justifyContent: FlexAlign.SpaceBetween,
125
+ alignItems: ItemAlign.Center
126
+ }) {
127
+ Text(this.getText()[1]).fontSize(15).padding({top: 20, bottom: 40}).fontColor('#888').onClick(() => {
128
+ this.emitEvent('cancel')
129
+ this.controller?.close()
222
130
  })
223
- } else if (this.node._attrs.mode === 'multiSelector') {
224
- TextPicker(this.getTextOptions())
225
- .selectedTextStyle({
226
- color: '#000'
131
+ Text(this.getText()[0]).fontSize(15).padding({top: 20, bottom: 40}).fontColor('#1aad19').onClick(() => {
132
+ this.emitEvent('change', { value: this.node?.value })
133
+ this.controller?.close()
227
134
  })
228
- .canLoop(false)
229
- .textPickerAttrs(getNormalAttributes(this.node))
230
- .onChange((value, index) => {
231
- if (index instanceof Array) {
232
- this.select = index.join(',')
233
- // 计算几列发生了变化
234
- const originIndexs: number[] = this.multiColumnIndex || this.showSelector
235
- this.multiColumnIndex = index
236
- let changeValue: number | undefined
237
- const changeIndex = index.findIndex((item, i) => {
238
- const originIndex = originIndexs[i]
239
- if (originIndex != item) {
240
- changeValue = item
241
- return true
135
+ }
136
+ .width('100%')
137
+ .backgroundColor('#fff')
138
+ .padding({
139
+ left: 20,
140
+ right: 20
141
+ })
142
+ if (this.node._attrs.mode === 'selector') {
143
+ TextPicker(this.getTextOptions())
144
+ .selectedTextStyle({
145
+ color: '#000'
146
+ })
147
+ .canLoop(false)
148
+ .attributeModifier(commonStyleModify.setNode(this.node, {
149
+ width: '100%',
150
+ backgroundColor: '#fff'
151
+ }))
152
+ .onChange((_, index) => {
153
+ this.node?.updateFormWidgetValue(index)
154
+ })
155
+ } else if (this.node?._attrs.mode === 'multiSelector') {
156
+ TextPicker(this.getTextOptions())
157
+ .selectedTextStyle({
158
+ color: '#000'
159
+ })
160
+ .canLoop(false)
161
+ .attributeModifier(commonStyleModify.setNode(this.node, {
162
+ width: '100%',
163
+ backgroundColor: '#fff'
164
+ }))
165
+ .onChange((_, index) => {
166
+ if (index instanceof Array) {
167
+ this.node?.updateFormWidgetValue(index)
168
+ // 计算几列发生了变化
169
+ const originIndexs: number[] = this.multiColumnIndex || this.showSelector
170
+ this.multiColumnIndex = index
171
+ let changeValue: number | undefined
172
+ const changeIndex = index.findIndex((item, i) => {
173
+ const originIndex = originIndexs[i]
174
+ if (originIndex != item) {
175
+ changeValue = item
176
+ return true
177
+ }
178
+ return false
179
+ })
180
+ if (changeIndex < 0) {
181
+ return
242
182
  }
243
- return false
244
- })
245
- if (changeIndex < 0) {
246
- return
183
+ this.emitEvent('columnChange', { column: changeIndex, value: changeValue })
247
184
  }
248
- this.emitEvent('columnChange', { column: changeIndex, value: changeValue })
249
- }
250
- })
251
- } else if (this.node._attrs.mode === 'date') {
252
- DatePicker(this.getDateOptions())
253
- .selectedTextStyle({
254
- color: '#000'
255
- })
256
- .datePickerAttrs(getNormalAttributes(this.node))
257
- .onChange(value => {
258
- this.select = `${value.year}-${value.month}-${value.day}`
259
- })
260
- } else if (this.node._attrs.mode === 'time') {
261
- TextPicker(this.getTextOptions())
262
- .selectedTextStyle({
263
- color: '#000'
264
- })
265
- .canLoop(false)
266
- .textPickerAttrs(getNormalAttributes(this.node))
267
- .onChange((value) => {
268
- this.select = `${('00'+value[0]).slice(-2)}:${('00'+value[1]).slice(-2)}}`
269
- })
185
+ })
186
+ } else if (this.node._attrs.mode === 'date') {
187
+ DatePicker(this.getDateOptions())
188
+ .selectedTextStyle({
189
+ color: '#000'
190
+ })
191
+ .attributeModifier(commonStyleModify.setNode(this.node, {
192
+ width: '100%',
193
+ backgroundColor: '#fff'
194
+ }))
195
+ .onDateChange(value => {
196
+ const data = value.toLocaleDateString().split('/')
197
+ const day = data[1]
198
+ const month = data[0]
199
+ const year = data[2]
200
+ this.node?.updateFormWidgetValue(`${year}-${month}-${day}`)
201
+ })
202
+ } else if (this.node._attrs.mode === 'time') {
203
+ TextPicker(this.getTextOptions())
204
+ .selectedTextStyle({
205
+ color: '#000'
206
+ })
207
+ .canLoop(false)
208
+ .attributeModifier(commonStyleModify.setNode(this.node, {
209
+ width: '100%',
210
+ backgroundColor: '#fff'
211
+ }))
212
+ .onChange((value) => {
213
+ this.node?.updateFormWidgetValue(`${('00'+value[0]).slice(-2)}:${('00'+value[1]).slice(-2)}`)
214
+ })
215
+ }
270
216
  }
271
217
  }
272
218
  }
@@ -277,40 +223,61 @@ export struct PickerView {
277
223
  }
278
224
 
279
225
 
280
-
281
226
  @Component
282
227
  export default struct TaroPicker {
283
- nodeInfoMap: TaroAny = {}
284
-
285
- @State select: string = ''
286
-
228
+ @Builder customBuilder() {}
229
+ @BuilderParam createLazyChildren: (node: TaroPickerElement) => void = this.customBuilder
287
230
  @ObjectLink node: TaroPickerElement
288
231
 
289
232
  aboutToAppear () {
290
- initComponentNodeInfo(this, this.node)
291
- bindInstanceToNode(this.node, this)
292
- // 绑定动画
293
- bindAnimation(this.node)
294
-
295
- this.select = this.node._attrs.value as TaroAny
233
+ this.node?.addEventListener('click', this.handleClick)
234
+
235
+ if (this.node && !this.node._isInit) {
236
+ let defaultResetValue: TaroAny = ''
237
+ switch (this.node._attrs.mode) {
238
+ case 'selector':
239
+ defaultResetValue = 0
240
+ break
241
+ case 'multiSelector':
242
+ defaultResetValue = this.node._attrs.range.map((_: TaroAny) => 0)
243
+ break
244
+ case 'time': {
245
+ const hour = new Date().getHours()
246
+ const minute = new Date().getMinutes()
247
+
248
+ defaultResetValue = `${('00'+hour).slice(-2)}:${('00'+minute).slice(-2)}`
249
+ break
250
+ }
251
+ case 'date': {
252
+ const data = new Date().toLocaleDateString().split('/')
253
+ const day = data[1]
254
+ const month = data[0]
255
+ const year = data[2]
256
+
257
+ defaultResetValue = `${year}-${month}-${day}`
258
+ break
259
+ }
260
+ default:
261
+ defaultResetValue = ''
262
+ break
263
+ }
296
264
 
297
- this.node.addEventListener('click', this.handleClick)
265
+ this.node._isInit = true
266
+ this.node._reset = this.node.value || defaultResetValue
267
+ }
298
268
  }
299
269
 
300
270
  dialogController: CustomDialogController | null = null
301
271
 
302
272
  aboutToDisappear() {
303
273
  this.dialogController = null // 将dialogController置空
274
+ this.node?.removeEventListener('click', this.handleClick)
304
275
  }
305
276
 
306
-
307
277
  handleClick = () => {
308
- if (!this.dialogController) {
278
+ if (!this.dialogController && this.node) {
309
279
  this.dialogController = new CustomDialogController({
310
- builder: PickerView({
311
- node: this.node,
312
- select: this.select
313
- }),
280
+ builder: PickerView({ node: this.node }),
314
281
  customStyle: true,
315
282
  cornerRadius: '0vp',
316
283
  autoCancel: true,
@@ -324,7 +291,7 @@ export default struct TaroPicker {
324
291
  }
325
292
  })
326
293
  }
327
- this.dialogController.open()
294
+ this.dialogController?.open()
328
295
  }
329
296
 
330
297
  @Styles defaultEvent () {
@@ -332,9 +299,10 @@ export default struct TaroPicker {
332
299
  eventHandler(e, 'click', this.node)
333
300
  })
334
301
  .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
335
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
336
- const eventResult: TaroAny = res.eventResult
337
- this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
302
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
303
+ if (this.node) {
304
+ this.node._nodeInfo.areaInfo = res[1]
305
+ }
338
306
  }))
339
307
  }
340
308
 
@@ -343,20 +311,26 @@ export default struct TaroPicker {
343
311
  }
344
312
 
345
313
  build() {
346
- TaroComponentWrapper({ node: this.node }) {
347
- Flex(FlexManager.flexOptions(this.node)) {
348
- ForEach(this.node.childNodes, (item: TaroElement) => {
349
- createNode(item)
350
- }, (item: TaroElement) => item._nid)
314
+ if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
315
+ Row() {
316
+ this.createLazyChildren(this.node)
351
317
  }
352
- .defaultEvent()
353
- .visibleChangeEvent()
318
+ .defaultEvent()
319
+ .visibleChangeEvent()
320
+ .alignItems(FlexManager.alignItems<VerticalAlign>(this.node))
321
+ .justifyContent(FlexManager.justifyContent(this.node))
322
+ } else {
323
+ Column() {
324
+ this.createLazyChildren(this.node)
325
+ }
326
+ .defaultEvent()
327
+ .visibleChangeEvent()
328
+ .alignItems(FlexManager.alignItems<HorizontalAlign>(this.node))
329
+ .justifyContent(FlexManager.justifyContent(this.node))
354
330
  }
355
331
  }
356
332
  }
357
333
 
358
-
359
-
360
334
  function generateNumberArray(x: number, y: number) {
361
335
  // 创建一个空数组来存储结果
362
336
  let result: string[] = []
@@ -0,0 +1,52 @@
1
+ import type { TaroProgressElement, TaroAny } from '@tarojs/runtime'
2
+ import commonStyleModify from './style'
3
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
4
+ import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
5
+
6
+ const PROGRESS_ACTIVECOLOR = '#09BB07'
7
+ const PROGRESS_BACKGROUNDCOLOR = '#EBEBEB'
8
+ const PROGRESS_DEFAULTINFOFONTSIZE = 16
9
+
10
+ @Component
11
+ export default struct TaroProgress {
12
+ @Builder customBuilder() {}
13
+ @BuilderParam createLazyChildren: (node: TaroProgressElement) => void = this.customBuilder
14
+ @ObjectLink node: TaroProgressElement
15
+ @State overwriteStyle: Record<string, TaroAny> = {}
16
+
17
+ aboutToAppear(): void {
18
+ if (this.node) {
19
+ this.node._instance = this
20
+ }
21
+ }
22
+
23
+ build() {
24
+ Row({ space: 5 }) {
25
+ Progress({
26
+ value: parseFloat(this.node.getAttribute('percent')),
27
+ type: ProgressType.Linear
28
+ })
29
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
30
+ .color(this.node.getAttribute('activeColor') ?? PROGRESS_ACTIVECOLOR)
31
+ .backgroundColor(this.node.getAttribute('backgroundColor') ?? PROGRESS_BACKGROUNDCOLOR)
32
+ .style({
33
+ strokeWidth: this.node.getAttribute('strokeWidth'),
34
+ strokeRadius: parseFloat(this.node.getAttribute('borderRadius')),
35
+ enableSmoothEffect: Boolean(this.node.getAttribute('active')),
36
+ })
37
+
38
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
39
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
40
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
41
+ if (this.node) {
42
+ this.node._nodeInfo.areaInfo = res[1]
43
+ }
44
+ }))
45
+
46
+ if (this.node.getAttribute('showInfo')) {
47
+ Text(`${this.node.getAttribute('percent')}%`)
48
+ .fontSize(this.node.getAttribute('fontSize') ?? PROGRESS_DEFAULTINFOFONTSIZE)
49
+ }
50
+ }
51
+ }
52
+ }
@@ -0,0 +1,80 @@
1
+ import { getFontAttributes } from './utils/helper'
2
+ import { pseudoModify } from './style'
3
+
4
+ import type { TaroViewElement, TaroStyleType, TaroTextStyleType, TaroAny } from '@tarojs/runtime'
5
+
6
+ @Extend(Flex)
7
+ function flexAttrs (style: TaroStyleType) {
8
+ .constraintSize({
9
+ minWidth: style.minWidth,
10
+ maxWidth: style.maxWidth,
11
+ minHeight: style.minHeight || style.height,
12
+ maxHeight: style.maxHeight
13
+ })
14
+ }
15
+
16
+
17
+ @Extend(Text)
18
+ function textNormalFontStyle (style: TaroStyleType) {
19
+ .id(style.id)
20
+ .key(style.id)
21
+ .opacity(style.opacity)
22
+ .fontColor(style.color)
23
+ .fontSize(style.fontSize)
24
+ .fontWeight(style.fontWeight)
25
+ .fontStyle(style.fontStyle)
26
+ .fontFamily(style.fontFamily)
27
+ .decoration({
28
+ type: style.textDecoration?.type || TextDecorationType.None,
29
+ color: style.color
30
+ })
31
+ }
32
+
33
+ @Extend(Text)
34
+ function textSpecialFontStyle(attr: TaroTextStyleType) {
35
+ .textAlign(attr.textAlign)
36
+ .align(attr.verticalAlign)
37
+ .textOverflow(attr.textOverflow)
38
+ .maxLines(attr.WebkitLineClamp)
39
+ .letterSpacing(attr.letterSpacing)
40
+ .lineHeight(attr.lineHeight)
41
+ }
42
+
43
+ @Component
44
+ export default struct PseduoChildren {
45
+ @Builder customBuilder() {}
46
+ @BuilderParam createLazyChildren: (node: TaroAny) => void = this.customBuilder
47
+ @ObjectLink node: TaroViewElement
48
+
49
+ build () {
50
+ if (true) {
51
+ // 伪类::Before
52
+ if (this.node._pseudo_before) {
53
+ if (this.node._pseudo_before?.hmStyle.content) {
54
+ Text(this.node._pseudo_before.hmStyle.content)
55
+ .attributeModifier(pseudoModify.setStyle(this.node._pseudo_before.hmStyle))
56
+ .textNormalFontStyle(this.node._pseudo_before.hmStyle || {})
57
+ .textSpecialFontStyle(getFontAttributes(this.node))
58
+ } else {
59
+ Flex() {}
60
+ .attributeModifier(pseudoModify.setStyle(this.node._pseudo_before.hmStyle || {}))
61
+ .flexAttrs(this.node._pseudo_before.hmStyle || {})
62
+ }
63
+ }
64
+ this.createLazyChildren(this.node)
65
+ // 伪类::After
66
+ if (this.node._pseudo_after) {
67
+ if (this.node._pseudo_after?.hmStyle.content) {
68
+ Text(this.node._pseudo_after.hmStyle.content)
69
+ .attributeModifier(pseudoModify.setStyle(this.node._pseudo_after.hmStyle))
70
+ .textNormalFontStyle(this.node._pseudo_after.hmStyle || {})
71
+ .textSpecialFontStyle(getFontAttributes(this.node))
72
+ } else {
73
+ Flex() {}
74
+ .attributeModifier(pseudoModify.setStyle(this.node._pseudo_after.hmStyle || {}))
75
+ .flexAttrs(this.node._pseudo_after.hmStyle || {})
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }