@tarojs/plugin-platform-harmony-cpp 4.1.0 → 4.1.1-alpha.1

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 (225) hide show
  1. package/README.md +0 -7
  2. package/dist/index.js +1236 -0
  3. package/dist/runtime/apis/apis.ts +20 -0
  4. package/dist/runtime/apis/base/crypto.ts +4 -0
  5. package/dist/runtime/apis/base/debug.ts +5 -0
  6. package/dist/runtime/apis/base/index.ts +13 -0
  7. package/dist/runtime/apis/base/performance.ts +8 -0
  8. package/dist/runtime/apis/base/system.ts +181 -0
  9. package/dist/runtime/apis/base/update.ts +5 -0
  10. package/dist/runtime/apis/base/weapp/app-event.ts +75 -0
  11. package/dist/runtime/apis/base/weapp/life-cycle.ts +21 -0
  12. package/dist/runtime/apis/canvas/index.ts +27 -0
  13. package/dist/runtime/apis/data-analysis/index.ts +6 -0
  14. package/dist/runtime/apis/device/accelerometer.ts +79 -0
  15. package/dist/runtime/apis/device/accessibility.ts +4 -0
  16. package/dist/runtime/apis/device/battery.ts +24 -0
  17. package/dist/runtime/apis/device/bluetooth-ble.ts +19 -0
  18. package/dist/runtime/apis/device/bluetooth-peripheral.ts +6 -0
  19. package/dist/runtime/apis/device/bluetooth.ts +16 -0
  20. package/dist/runtime/apis/device/calendar.ts +5 -0
  21. package/dist/runtime/apis/device/clipboard.ts +85 -0
  22. package/dist/runtime/apis/device/compass.ts +21 -0
  23. package/dist/runtime/apis/device/contact.ts +5 -0
  24. package/dist/runtime/apis/device/crypto.ts +4 -0
  25. package/dist/runtime/apis/device/gyroscope.ts +77 -0
  26. package/dist/runtime/apis/device/iBeacon.ts +10 -0
  27. package/dist/runtime/apis/device/index.ts +24 -0
  28. package/dist/runtime/apis/device/keyboard.ts +63 -0
  29. package/dist/runtime/apis/device/memory.ts +11 -0
  30. package/dist/runtime/apis/device/motion.ts +6 -0
  31. package/dist/runtime/apis/device/network.ts +123 -0
  32. package/dist/runtime/apis/device/nfc.ts +10 -0
  33. package/dist/runtime/apis/device/phone.ts +44 -0
  34. package/dist/runtime/apis/device/scan.ts +4 -0
  35. package/dist/runtime/apis/device/screen.ts +80 -0
  36. package/dist/runtime/apis/device/sms.ts +4 -0
  37. package/dist/runtime/apis/device/vibrate.ts +32 -0
  38. package/dist/runtime/apis/device/wifi.ts +15 -0
  39. package/dist/runtime/apis/ext/index.ts +5 -0
  40. package/dist/runtime/apis/files/index.ts +136 -0
  41. package/dist/runtime/apis/files/manager.ts +942 -0
  42. package/dist/runtime/apis/framework/index.ts +48 -0
  43. package/dist/runtime/apis/harmony/task-pool.ts +39 -0
  44. package/dist/runtime/apis/index.ts +61 -0
  45. package/dist/runtime/apis/location/index.ts +133 -0
  46. package/dist/runtime/apis/media/EditorContext.ts +32 -0
  47. package/dist/runtime/apis/media/audio/index.ts +36 -0
  48. package/dist/runtime/apis/media/background-audio/index.ts +16 -0
  49. package/dist/runtime/apis/media/camera.ts +16 -0
  50. package/dist/runtime/apis/media/common.ts +58 -0
  51. package/dist/runtime/apis/media/image/index.ts +291 -0
  52. package/dist/runtime/apis/media/index.ts +13 -0
  53. package/dist/runtime/apis/media/live.ts +5 -0
  54. package/dist/runtime/apis/media/map.ts +4 -0
  55. package/dist/runtime/apis/media/media-recorder.ts +4 -0
  56. package/dist/runtime/apis/media/recorder.ts +6 -0
  57. package/dist/runtime/apis/media/video/VideoContext.ts +67 -0
  58. package/dist/runtime/apis/media/video/index.ts +45 -0
  59. package/dist/runtime/apis/media/video-decoder.ts +4 -0
  60. package/dist/runtime/apis/media/video-processing.ts +4 -0
  61. package/dist/runtime/apis/media/voip.ts +19 -0
  62. package/dist/runtime/apis/navigate/index.ts +8 -0
  63. package/dist/runtime/apis/network/downloadFile.ts +85 -0
  64. package/dist/runtime/apis/network/index.ts +7 -0
  65. package/dist/runtime/apis/network/mdns.ts +13 -0
  66. package/dist/runtime/apis/network/request.ts +140 -0
  67. package/dist/runtime/apis/network/tcp.ts +4 -0
  68. package/dist/runtime/apis/network/udp.ts +4 -0
  69. package/dist/runtime/apis/network/uploadFile.ts +105 -0
  70. package/dist/runtime/apis/network/webSocket.ts +126 -0
  71. package/dist/runtime/apis/open-api/account.ts +4 -0
  72. package/dist/runtime/apis/open-api/address.ts +4 -0
  73. package/dist/runtime/apis/open-api/authorize.ts +5 -0
  74. package/dist/runtime/apis/open-api/card.ts +5 -0
  75. package/dist/runtime/apis/open-api/channels-live.ts +11 -0
  76. package/dist/runtime/apis/open-api/customer-service.ts +4 -0
  77. package/dist/runtime/apis/open-api/device-voip.ts +5 -0
  78. package/dist/runtime/apis/open-api/facial.ts +7 -0
  79. package/dist/runtime/apis/open-api/favorites.ts +5 -0
  80. package/dist/runtime/apis/open-api/group.ts +4 -0
  81. package/dist/runtime/apis/open-api/index.ts +21 -0
  82. package/dist/runtime/apis/open-api/invoice.ts +5 -0
  83. package/dist/runtime/apis/open-api/license-plate.ts +4 -0
  84. package/dist/runtime/apis/open-api/login.ts +6 -0
  85. package/dist/runtime/apis/open-api/my-miniprogram.ts +4 -0
  86. package/dist/runtime/apis/open-api/privacy.ts +7 -0
  87. package/dist/runtime/apis/open-api/red-package.ts +4 -0
  88. package/dist/runtime/apis/open-api/settings.ts +5 -0
  89. package/dist/runtime/apis/open-api/soter.ts +6 -0
  90. package/dist/runtime/apis/open-api/subscribe-message.ts +6 -0
  91. package/dist/runtime/apis/open-api/user-info.ts +70 -0
  92. package/dist/runtime/apis/open-api/werun.ts +5 -0
  93. package/dist/runtime/apis/payment/index.ts +6 -0
  94. package/dist/runtime/apis/route/index.ts +88 -0
  95. package/dist/runtime/apis/share/index.ts +33 -0
  96. package/dist/runtime/apis/storage/background-fetch.ts +7 -0
  97. package/dist/runtime/apis/storage/cache-manager.ts +4 -0
  98. package/dist/runtime/apis/storage/index.ts +203 -0
  99. package/dist/runtime/apis/ui/animation/animation.ts +264 -0
  100. package/dist/runtime/apis/ui/animation/index.ts +7 -0
  101. package/dist/runtime/apis/ui/background.ts +20 -0
  102. package/dist/runtime/apis/ui/custom-component.ts +1 -0
  103. package/dist/runtime/apis/ui/fonts.ts +4 -0
  104. package/dist/runtime/apis/ui/index.ts +12 -0
  105. package/dist/runtime/apis/ui/interaction/index.ts +198 -0
  106. package/dist/runtime/apis/ui/menu.ts +4 -0
  107. package/dist/runtime/apis/ui/navigation-bar/index.ts +72 -0
  108. package/dist/runtime/apis/ui/pull-down-refresh.ts +47 -0
  109. package/dist/runtime/apis/ui/scroll/index.ts +82 -0
  110. package/dist/runtime/apis/ui/sticky.ts +4 -0
  111. package/dist/runtime/apis/ui/tab-bar.ts +144 -0
  112. package/dist/runtime/apis/ui/window.ts +20 -0
  113. package/dist/runtime/apis/utils/constant.ts +1 -0
  114. package/dist/runtime/apis/utils/handler.ts +117 -0
  115. package/dist/runtime/apis/utils/index.ts +105 -0
  116. package/dist/runtime/apis/utils/permissions.ts +6 -0
  117. package/dist/runtime/apis/utils/types.ts +12 -0
  118. package/dist/runtime/apis/utils/unit.ts +104 -0
  119. package/dist/runtime/apis/utils/validate.ts +87 -0
  120. package/dist/runtime/apis/worker/index.ts +4 -0
  121. package/dist/runtime/apis/wxml/index.ts +17 -0
  122. package/dist/runtime/apis/wxml/intersectionObserver.ts +100 -0
  123. package/dist/runtime/apis/wxml/nodesRef.ts +58 -0
  124. package/dist/runtime/apis/wxml/selectorQuery.ts +221 -0
  125. package/dist/runtime/apischunk/index.d.ts +802 -0
  126. package/dist/runtime/apischunk/index.js +5054 -0
  127. package/dist/runtime/components/deprecated.ets +43 -0
  128. package/dist/runtime/components/index.ets +49 -0
  129. package/dist/runtime/components/innerHtml.ets +16 -0
  130. package/dist/runtime/components/navigationBar.ets +65 -0
  131. package/dist/runtime/components/pageMeta.ets +94 -0
  132. package/dist/runtime/components/richText.ets +24 -0
  133. package/dist/runtime/components/slider.ets +119 -0
  134. package/dist/runtime/components/style.ets +286 -0
  135. package/dist/runtime/components/switch.ets +73 -0
  136. package/dist/runtime/components/tag.ts +58 -0
  137. package/dist/runtime/components/utils/AttributeManager.ets +252 -0
  138. package/dist/runtime/components/utils/DynamicCenter.ts +41 -0
  139. package/dist/runtime/components/utils/constant/event.ets +25 -0
  140. package/dist/runtime/components/utils/constant/style.ets +91 -0
  141. package/dist/runtime/components/utils/events.ts +26 -0
  142. package/dist/runtime/components/utils/flexManager.ets +49 -0
  143. package/dist/runtime/components/utils/helper.ets +51 -0
  144. package/dist/runtime/components/utils/htmlParser/HarmonyHTMLParser.ts +100 -0
  145. package/dist/runtime/components/utils/htmlParser/index.ts +58 -0
  146. package/dist/runtime/components/utils/index.ts +77 -0
  147. package/dist/runtime/components/utils/styles.ets +41 -0
  148. package/dist/runtime/components/video.ets +119 -0
  149. package/dist/runtime/components/webView.ets +55 -0
  150. package/dist/runtime/components/xComponent.ets +89 -0
  151. package/dist/runtime/framework/app.ts +248 -0
  152. package/dist/runtime/framework/connect.ts +24 -0
  153. package/dist/runtime/framework/constant.ts +3 -0
  154. package/dist/runtime/framework/hooks.ts +99 -0
  155. package/dist/runtime/framework/index.ts +15 -0
  156. package/dist/runtime/framework/native-page.ts +511 -0
  157. package/dist/runtime/framework/page.ts +256 -0
  158. package/dist/runtime/framework/utils/index.ts +17 -0
  159. package/dist/runtime/framework/utils/is.ts +26 -0
  160. package/dist/runtime/framework-reconciler/componentTree.ts +81 -0
  161. package/dist/runtime/framework-reconciler/constant.ts +86 -0
  162. package/dist/runtime/framework-reconciler/domInput.ts +90 -0
  163. package/dist/runtime/framework-reconciler/event.ts +108 -0
  164. package/dist/runtime/framework-reconciler/index.ts +99 -0
  165. package/dist/runtime/framework-reconciler/inputValueTracking.ts +106 -0
  166. package/dist/runtime/framework-reconciler/props.ts +132 -0
  167. package/dist/runtime/framework-reconciler/reconciler.ts +202 -0
  168. package/dist/runtime/framework-reconciler/render.ts +139 -0
  169. package/dist/runtime/framework-reconciler/workTags.ts +53 -0
  170. package/dist/runtime/runtime-cpp/bom/URL.ts +2 -0
  171. package/dist/runtime/runtime-cpp/bom/document.ts +45 -0
  172. package/dist/runtime/runtime-cpp/bom/history.ts +1 -0
  173. package/dist/runtime/runtime-cpp/bom/location.ts +1 -0
  174. package/dist/runtime/runtime-cpp/bom/navigator.ts +1 -0
  175. package/dist/runtime/runtime-cpp/bom/raf.ts +1 -0
  176. package/dist/runtime/runtime-cpp/bom/window.ts +57 -0
  177. package/dist/runtime/runtime-cpp/constant.ts +29 -0
  178. package/dist/runtime/runtime-cpp/current.ts +48 -0
  179. package/dist/runtime/runtime-cpp/dom/class-list.ts +41 -0
  180. package/dist/runtime/runtime-cpp/dom/comment.ts +9 -0
  181. package/dist/runtime/runtime-cpp/dom/dataSource.ts +87 -0
  182. package/dist/runtime/runtime-cpp/dom/document.ts +113 -0
  183. package/dist/runtime/runtime-cpp/dom/element/canvas.ts +285 -0
  184. package/dist/runtime/runtime-cpp/dom/element/element.ts +262 -0
  185. package/dist/runtime/runtime-cpp/dom/element/form.ts +371 -0
  186. package/dist/runtime/runtime-cpp/dom/element/index.ts +129 -0
  187. package/dist/runtime/runtime-cpp/dom/element/movable.ts +250 -0
  188. package/dist/runtime/runtime-cpp/dom/element/normal.ts +123 -0
  189. package/dist/runtime/runtime-cpp/dom/element/scroll_view.ts +32 -0
  190. package/dist/runtime/runtime-cpp/dom/element/text.ts +9 -0
  191. package/dist/runtime/runtime-cpp/dom/element/video.ts +66 -0
  192. package/dist/runtime/runtime-cpp/dom/element/web_view.ts +72 -0
  193. package/dist/runtime/runtime-cpp/dom/event-source.ts +1 -0
  194. package/dist/runtime/runtime-cpp/dom/event.ts +187 -0
  195. package/dist/runtime/runtime-cpp/dom/eventTarget.ts +81 -0
  196. package/dist/runtime/runtime-cpp/dom/node.ts +307 -0
  197. package/dist/runtime/runtime-cpp/dom/style.ts +44 -0
  198. package/dist/runtime/runtime-cpp/dom/stylesheet/index.ts +379 -0
  199. package/dist/runtime/runtime-cpp/dom/stylesheet/type.ts +212 -0
  200. package/dist/runtime/runtime-cpp/dom/stylesheet/util.ts +186 -0
  201. package/dist/runtime/runtime-cpp/emitter/emitter.ts +29 -0
  202. package/dist/runtime/runtime-cpp/env.ts +1 -0
  203. package/dist/runtime/runtime-cpp/harmony-library.ts +1 -0
  204. package/dist/runtime/runtime-cpp/index.ts +79 -0
  205. package/dist/runtime/runtime-cpp/interface/event.ts +10 -0
  206. package/dist/runtime/runtime-cpp/interface/index.ts +7 -0
  207. package/dist/runtime/runtime-cpp/next-tick.ts +14 -0
  208. package/dist/runtime/runtime-cpp/system.ts +213 -0
  209. package/dist/runtime/runtime-cpp/utils/index.ts +63 -0
  210. package/dist/runtime/runtime-cpp/utils/info.ts +123 -0
  211. package/dist/runtime/runtime-cpp/utils/page.ts +12 -0
  212. package/dist/runtime/runtime-cpp/utils/router.ts +1 -0
  213. package/dist/runtime/runtime-harmony/apis/helper.ets +33 -0
  214. package/dist/runtime/runtime-harmony/apis/network/common.ets +41 -0
  215. package/dist/runtime/runtime-harmony/apis/network/downloadFile.ets +327 -0
  216. package/dist/runtime/runtime-harmony/apis/network/index.ets +58 -0
  217. package/dist/runtime/runtime-harmony/apis/network/request.ets +206 -0
  218. package/dist/runtime/runtime-harmony/apis/network/uploadFile.ets +190 -0
  219. package/dist/runtime/runtime-harmony/apis/route.ets +110 -0
  220. package/dist/runtime/runtime-harmony/apis/taskpool.ets +149 -0
  221. package/dist/runtime/runtime-harmony/index.ets +41 -0
  222. package/dist/runtime/runtime-harmony/utils.ts +53 -0
  223. package/package.json +25 -23
  224. package/static/@taro-oh/library-4.1.1-alpha.0.har +0 -0
  225. package/LICENSE +0 -174
@@ -0,0 +1,371 @@
1
+ import window from '@ohos.window'
2
+ import { isNumber } from '@tarojs/shared'
3
+
4
+ import { Current } from '../../current'
5
+ import { TaroNativeModule } from '../../harmony-library'
6
+ import { createTaroEvent, eventHandler, TaroEvent } from '../event'
7
+ import { TaroElement } from './element'
8
+
9
+ import type { common } from '@kit.AbilityKit'
10
+ import type {
11
+ CheckboxGroupProps,
12
+ CheckboxProps,
13
+ InputProps,
14
+ LabelProps,
15
+ PickerDateProps,
16
+ PickerMultiSelectorProps,
17
+ PickerSelectorProps, PickerTimeProps,
18
+ RadioGroupProps,
19
+ RadioProps,
20
+ RichTextProps,
21
+ SliderProps,
22
+ StandardProps,
23
+ SwitchProps,
24
+ TextareaProps
25
+ } from '@tarojs/components/types'
26
+ import type { TaroAny } from '../../interface'
27
+
28
+ interface FormWidgetProps extends StandardProps {
29
+ name?: string
30
+ value?: string | number | number[] | string[] | Record<string, TaroAny>[]
31
+ }
32
+
33
+ class TaroFormWidgetElement<T extends FormWidgetProps = FormWidgetProps> extends TaroElement<T> {
34
+ _isInit = false
35
+
36
+ _name = ''
37
+
38
+ _reset: TaroAny = ''
39
+
40
+ constructor (tagName: string) {
41
+ super(tagName)
42
+
43
+ this._name = this._attrs.name || ''
44
+ this._nodeInfo._value = this._attrs.value || ''
45
+ }
46
+
47
+ // FIXME ets form 组件移除后,此方法应该移除
48
+ public setAttribute (name: string, value: any): void {
49
+ super.setAttribute(name, value)
50
+
51
+ if (name === 'name') {
52
+ this.updateFormWidgetName(value)
53
+ }
54
+
55
+ if (name === 'value') {
56
+ this.updateFormWidgetValue(value)
57
+
58
+ if (this._instance) {
59
+ this._instance.value = value
60
+ }
61
+ }
62
+ }
63
+
64
+ public removeAttribute(name: string): void {
65
+ if (name === 'value') {
66
+ this.value = ''
67
+ }
68
+ }
69
+
70
+ public get name () {
71
+ return this.getAttribute('name') || ''
72
+ }
73
+
74
+ public set name (val: string) {
75
+ this.setAttribute('name', val)
76
+ }
77
+
78
+ public get value () {
79
+ return this.getAttribute('value') || ''
80
+ }
81
+
82
+ public set value (val: TaroAny) {
83
+ this.setAttribute('value', val)
84
+ }
85
+
86
+ public updateFormWidgetName (val: string) {
87
+ this._name = val
88
+ this._attrs.name = val
89
+ }
90
+
91
+ public updateFormWidgetValue (val: TaroAny) {
92
+ this._nodeInfo._value = val
93
+ this._attrs.value = val
94
+ }
95
+
96
+ public reset () {
97
+ this.value = this._reset
98
+ }
99
+
100
+ public focus () {
101
+ return TaroNativeModule.executeNodeFunc(this, 'focus', [])
102
+ }
103
+
104
+ public blur () {
105
+ return TaroNativeModule.executeNodeFunc(this, 'blur', [])
106
+ }
107
+ }
108
+
109
+ class TaroCheckedElement<T extends StandardProps & { checked?: boolean } = StandardProps & { checked?: boolean }> extends TaroFormWidgetElement<T> {
110
+ _checked = false
111
+
112
+ constructor(tagName: string) {
113
+ super(tagName)
114
+
115
+ this._checked = this._attrs.checked || false
116
+ }
117
+
118
+ get checked () {
119
+ return this.getAttribute('checked') || false
120
+ }
121
+
122
+ set checked (val: boolean) {
123
+ this.setAttribute('checked', val)
124
+ this.updateCheckedValue(val)
125
+ }
126
+
127
+ public updateCheckedValue (val: boolean) {
128
+ this._checked = val
129
+ this._attrs.checked = val
130
+ }
131
+
132
+ public reset () {
133
+ this.checked = this._reset
134
+ }
135
+ }
136
+
137
+ export class TaroInputElement<T extends FormWidgetProps = InputProps> extends TaroFormWidgetElement<T> {
138
+ _height = 0
139
+
140
+ heightChange?: (height: number) => void
141
+
142
+ windowClass?: window.Window
143
+
144
+ controller = {
145
+ /** @deprecated */
146
+ stopEditing: () => {
147
+ if (typeof this.blur === 'function') this.blur()
148
+ }
149
+ }
150
+
151
+ constructor(tagName = 'Input') {
152
+ super(tagName)
153
+
154
+ try {
155
+ Current.contextPromise
156
+ .then((context: common.BaseContext) => {
157
+ return window.getLastWindow(context, (err, windowClass: window.Window) => {
158
+ const errCode: number = err.code
159
+
160
+ if (errCode) {
161
+ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err))
162
+ return
163
+ }
164
+
165
+ this.windowClass = windowClass
166
+ const heightChange = (height: number) => {
167
+ if (isNumber(height)) {
168
+ if (this._height !== height) {
169
+ this.onKeyboardHeightChange(height)
170
+ this._height = height
171
+ }
172
+ }
173
+ }
174
+ windowClass.on('keyboardHeightChange', heightChange)
175
+ })
176
+ })
177
+ } catch (exception) {
178
+ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception))
179
+ }
180
+ }
181
+
182
+ private onKeyboardHeightChange (height: number) {
183
+ const event: TaroEvent = createTaroEvent('keyboardHeightChange', { detail: { height: height, duration: 0 } }, this)
184
+
185
+ eventHandler(event, 'keyboardHeightChange', this)
186
+ }
187
+
188
+ public dispose () {
189
+ if (this.windowClass) {
190
+ try {
191
+ this.windowClass.off('keyboardHeightChange', this.heightChange)
192
+ } catch (err) {
193
+ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err))
194
+ }
195
+ }
196
+ }
197
+ }
198
+
199
+ export class TaroTextAreaElement extends TaroInputElement<TextareaProps> {
200
+ constructor() {
201
+ super('TextArea')
202
+ }
203
+ }
204
+
205
+ export class TaroCheckboxElement extends TaroCheckedElement<CheckboxProps> {
206
+ constructor() {
207
+ super('Checkbox')
208
+ }
209
+ }
210
+
211
+ export class TaroRadioElement extends TaroCheckedElement<RadioProps> {
212
+ public group?: string
213
+
214
+ constructor() {
215
+ super('Radio')
216
+ }
217
+ }
218
+
219
+ export class TaroSliderElement extends TaroFormWidgetElement<SliderProps> {
220
+ constructor() {
221
+ super('Slider')
222
+
223
+ this._nodeInfo._value = Number(this._attrs.value || 0)
224
+ }
225
+
226
+ public setAttribute(name: string, value: TaroAny): void {
227
+ super.setAttribute(name, value)
228
+
229
+ // Note: 使用 @ComponentV2 时,需要在 struct 将参数声明为 @Local 并在此更新
230
+ if (this._instance) {
231
+ const attrName = `attr${name.charAt(0).toUpperCase()}${name.slice(1)}`
232
+ this._instance[attrName] = value
233
+ }
234
+ }
235
+ }
236
+
237
+ export class TaroPickerElement extends TaroFormWidgetElement<PickerSelectorProps | PickerTimeProps | PickerDateProps | PickerMultiSelectorProps> {
238
+ constructor() {
239
+ super('Picker')
240
+ }
241
+
242
+ public getCurrentSelect () {
243
+ switch (this._attrs.mode) {
244
+ case 'time':
245
+ case 'date':
246
+ return this.value
247
+ case 'selector': {
248
+ const key = this._attrs.rangeKey
249
+ const item = this._attrs.range[this.value]
250
+
251
+ if (key) {
252
+ return item[key]
253
+ } else {
254
+ return item
255
+ }
256
+ }
257
+ case 'multiSelector': {
258
+ const key = this._attrs.rangeKey
259
+
260
+ return this._attrs.range.map((rangeList: TaroAny[], index: number) => {
261
+ const obj = rangeList[this.value[index]]
262
+
263
+ if (key) {
264
+ return obj[key]
265
+ } else {
266
+ return obj
267
+ }
268
+ }).join(',')
269
+ }
270
+ default:
271
+ return ''
272
+ }
273
+ }
274
+
275
+ public reset() {
276
+ super.reset()
277
+
278
+ const event: TaroEvent = createTaroEvent('change', { detail: { value: this._reset } }, this)
279
+
280
+ event.stopPropagation()
281
+ eventHandler(event, 'change', this)
282
+ }
283
+ }
284
+
285
+ @Observed
286
+ export class TaroSwitchElement extends TaroCheckedElement<SwitchProps> {
287
+ constructor() {
288
+ super('Switch')
289
+ }
290
+ }
291
+
292
+ export class TaroCheckboxGroupElement extends TaroFormWidgetElement<CheckboxGroupProps> {
293
+ constructor() {
294
+ super('CheckboxGroup')
295
+ }
296
+
297
+ public get value () {
298
+ const childList = this.getElementsByTagName<TaroCheckboxElement>('CHECKBOX')
299
+ const result: string[] = []
300
+ childList.forEach(element => {
301
+ if (element.checked) {
302
+ result.push(element._attrs.value)
303
+ }
304
+ })
305
+ return result
306
+ }
307
+
308
+ public set value (_) { }
309
+
310
+ public reset () {
311
+ this.getElementsByTagName<TaroCheckboxElement>('CHECKBOX').forEach((element) => {
312
+ element.reset()
313
+ })
314
+ }
315
+ }
316
+
317
+ export class TaroRadioGroupElement extends TaroFormWidgetElement<RadioGroupProps> {
318
+ constructor() {
319
+ super('RadioGroup')
320
+ }
321
+
322
+ public get value () {
323
+ const childList = this.getElementsByTagName<TaroRadioElement>('RADIO')
324
+ for (let i = 0; i < childList.length; i++) {
325
+ if (childList[i].checked) {
326
+ return childList[i]._attrs.value
327
+ }
328
+ }
329
+
330
+ return undefined
331
+ }
332
+
333
+ public set value (_) { }
334
+
335
+ public reset () {
336
+ this.getElementsByTagName<TaroCheckboxElement>('RADIO').forEach((element) => {
337
+ element.reset()
338
+ })
339
+ }
340
+ }
341
+
342
+ export class TaroLabelElement extends TaroElement<LabelProps> {
343
+ constructor() {
344
+ super('Label')
345
+ }
346
+ }
347
+
348
+ @Observed
349
+ export class TaroRichTextElement extends TaroElement<RichTextProps> {
350
+ isETS = true
351
+
352
+ constructor() {
353
+ super('RichText')
354
+ }
355
+ }
356
+
357
+ export class TaroFormElement extends TaroFormWidgetElement {
358
+ constructor() {
359
+ super('Form')
360
+
361
+ // 监听submit冒泡
362
+ // this.addEventListener('submit-btn', (e: TaroEvent) => {
363
+ // })
364
+
365
+ // 监听reset冒泡
366
+ // this.addEventListener('reset-btn', (e: TaroEvent) => {
367
+ // })
368
+ }
369
+ }
370
+
371
+ export const FormElement = TaroFormElement
@@ -0,0 +1,129 @@
1
+ import { Current } from '../../current'
2
+ import { TaroTextNode } from '../node'
3
+ import { TaroCanvasElement } from './canvas'
4
+ import { TaroElement } from './element'
5
+ import {
6
+ FormElement,
7
+ TaroCheckboxElement,
8
+ TaroCheckboxGroupElement,
9
+ TaroFormElement,
10
+ TaroInputElement,
11
+ TaroLabelElement,
12
+ TaroPickerElement,
13
+ TaroRadioElement,
14
+ TaroRadioGroupElement,
15
+ TaroRichTextElement,
16
+ TaroSliderElement,
17
+ TaroSwitchElement,
18
+ TaroTextAreaElement,
19
+ } from './form'
20
+ import { isTaroMovableViewElement, TaroMovableAreaElement, TaroMovableViewElement } from './movable'
21
+ import {
22
+ TaroButtonElement,
23
+ TaroFlowItemElement,
24
+ TaroFlowSectionElement,
25
+ TaroIconElement,
26
+ TaroImageElement,
27
+ TaroListElement,
28
+ TaroNavigationBarElement,
29
+ TaroOtherElement,
30
+ TaroPageMetaElement,
31
+ TaroProgressElement,
32
+ TaroSwiperElement,
33
+ TaroSwiperItemElement,
34
+ TaroViewElement,
35
+ TaroWaterFlowElement,
36
+ } from './normal'
37
+ import { TaroScrollViewElement } from './scroll_view'
38
+ import { TaroTextElement } from './text'
39
+ import { TaroVideoElement } from './video'
40
+ import { TaroInnerHtmlElement, TaroWebViewElement } from './web_view'
41
+
42
+ export function initHarmonyElement () {
43
+ Current.createHarmonyElement = (tagName: string) => {
44
+ switch (tagName) {
45
+ case 'view': return new TaroViewElement()
46
+ case 'image': return new TaroImageElement()
47
+ case 'text': return new TaroTextElement()
48
+ case 'button': return new TaroButtonElement()
49
+ case 'movable-area': return new TaroMovableAreaElement()
50
+ case 'movable-view': return new TaroMovableViewElement()
51
+ case 'progress': return new TaroProgressElement()
52
+ case 'scroll-view': return new TaroScrollViewElement()
53
+ case 'scroll-list': return new TaroScrollViewElement()
54
+ case 'checkbox-group': return new TaroCheckboxGroupElement()
55
+ case 'input': return new TaroInputElement()
56
+ case 'picker': return new TaroPickerElement()
57
+ case 'radio-group': return new TaroRadioGroupElement()
58
+ case 'slider': return new TaroSliderElement()
59
+ case 'switch': return new TaroSwitchElement()
60
+ case 'video': return new TaroVideoElement()
61
+ case 'checkbox': return new TaroCheckboxElement()
62
+ case 'radio': return new TaroRadioElement()
63
+ case 'icon': return new TaroIconElement()
64
+ case 'label': return new TaroLabelElement()
65
+ case 'rich-text': return new TaroRichTextElement()
66
+ case 'canvas': return new TaroCanvasElement()
67
+ case 'swiper': return new TaroSwiperElement()
68
+ case 'swiper-item': return new TaroSwiperItemElement()
69
+ case 'textarea': return new TaroTextAreaElement()
70
+ case 'form': return new TaroFormElement()
71
+ case 'web-view': return new TaroWebViewElement()
72
+ case 'inner-html': return new TaroInnerHtmlElement()
73
+ case 'page-meta': return new TaroPageMetaElement()
74
+ case 'navigation-bar': return new TaroNavigationBarElement()
75
+ case 'water-flow': return new TaroWaterFlowElement()
76
+ case 'flow-section': return new TaroFlowSectionElement()
77
+ case 'flow-item': return new TaroFlowItemElement()
78
+ case 'list': return new TaroListElement()
79
+ default: return new TaroOtherElement(tagName)
80
+ }
81
+ }
82
+
83
+ Current.createTextNode = (value: string): TaroTextNode => {
84
+ const node = new TaroTextNode(value)
85
+ return node
86
+ }
87
+ }
88
+
89
+ export {
90
+ FormElement,
91
+ TaroButtonElement,
92
+ TaroCanvasElement,
93
+ TaroCheckboxElement,
94
+ TaroCheckboxGroupElement,
95
+ TaroElement,
96
+ TaroFlowItemElement,
97
+ TaroFlowSectionElement,
98
+ TaroFormElement,
99
+ TaroIconElement,
100
+ TaroImageElement,
101
+ TaroInnerHtmlElement,
102
+ TaroInputElement,
103
+ TaroLabelElement,
104
+ TaroMovableAreaElement,
105
+ TaroMovableViewElement,
106
+ TaroNavigationBarElement,
107
+ TaroOtherElement,
108
+ TaroPageMetaElement,
109
+ TaroPickerElement,
110
+ TaroProgressElement,
111
+ TaroRadioElement,
112
+ TaroRadioGroupElement,
113
+ TaroRichTextElement,
114
+ TaroScrollViewElement,
115
+ TaroSliderElement,
116
+ TaroSwiperElement,
117
+ TaroSwiperItemElement,
118
+ TaroSwitchElement,
119
+ TaroTextAreaElement,
120
+ TaroTextElement,
121
+ TaroVideoElement,
122
+ TaroViewElement,
123
+ TaroWaterFlowElement,
124
+ TaroWebViewElement
125
+ }
126
+
127
+ export {
128
+ isTaroMovableViewElement
129
+ }