@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
@@ -0,0 +1,403 @@
1
+ import window from '@ohos.window'
2
+ import { isNumber } from '@tarojs/shared'
3
+
4
+ import { Current } from '../../current'
5
+ import { findChildNodeWithDFS } from '../../utils'
6
+ import { bindFocus } from '../bind'
7
+ import { createTaroEvent, eventHandler, TaroEvent } from '../event'
8
+ import { TaroElement } from './element'
9
+
10
+ import type {
11
+ CheckboxGroupProps,
12
+ CheckboxProps,
13
+ InputProps,
14
+ PickerDateProps,
15
+ PickerMultiSelectorProps,
16
+ PickerSelectorProps, PickerTimeProps,
17
+ RadioGroupProps,
18
+ RadioProps,
19
+ SliderProps,
20
+ StandardProps,
21
+ SwitchProps,
22
+ TextareaProps
23
+ } from '@tarojs/components/types'
24
+ import type { TaroAny } from '../../utils'
25
+
26
+ interface FormWidgetProps extends StandardProps {
27
+ name?: string
28
+ value?: string | number | number[] | string[] | Record<string, TaroAny>[]
29
+ }
30
+
31
+ class TaroFormWidgetElement<T extends FormWidgetProps = FormWidgetProps> extends TaroElement<T> {
32
+ _isInit = false
33
+
34
+ _name = ''
35
+
36
+ _reset: TaroAny = ''
37
+
38
+ constructor (tagName: string) {
39
+ super(tagName)
40
+
41
+ bindFocus(this)
42
+
43
+ this._name = this._attrs.name || ''
44
+ this._nodeInfo._value = this._attrs.value || ''
45
+ }
46
+
47
+ public setAttribute (name: string, value: any): void {
48
+ super.setAttribute(name, value)
49
+
50
+ if (name === 'name') {
51
+ this.name = value
52
+ }
53
+
54
+ if (name === 'value') {
55
+ this.value = value
56
+ }
57
+ }
58
+
59
+ public get name () {
60
+ return this._attrs.name || ''
61
+ }
62
+
63
+ public set name (val: string) {
64
+ this.updateFormWidgetName(val)
65
+ }
66
+
67
+ public get value () {
68
+ return this._nodeInfo._value
69
+ }
70
+
71
+ public set value (val: TaroAny) {
72
+ this.updateFormWidgetValue(val)
73
+
74
+ if (this._instance) {
75
+ this._instance.value = val
76
+ }
77
+ }
78
+
79
+ public updateFormWidgetName (val: string) {
80
+ this._name = val
81
+ this._attrs.name = val
82
+ }
83
+
84
+ public updateFormWidgetValue (val: TaroAny) {
85
+ this._nodeInfo._value = val
86
+ this._attrs.value = val
87
+ }
88
+
89
+ public reset () {
90
+ this.value = this._reset
91
+ }
92
+ }
93
+
94
+ class TaroCheckedElement<T extends StandardProps & { checked?: boolean } = StandardProps & { checked?: boolean }> extends TaroFormWidgetElement<T> {
95
+ _checked = false
96
+
97
+ constructor(tagName: string) {
98
+ super(tagName)
99
+
100
+ this._checked = this._attrs.checked || false
101
+ }
102
+
103
+ public setAttribute (name: string, value: any): void {
104
+ super.setAttribute(name, value)
105
+
106
+ if (name === 'checked') {
107
+ this.checked = value
108
+ }
109
+ }
110
+
111
+ get checked () {
112
+ return this._checked || false
113
+ }
114
+
115
+ set checked (val: boolean) {
116
+ this.updateCheckedValue(val)
117
+ }
118
+
119
+ public updateCheckedValue (val: boolean) {
120
+ this._checked = val
121
+ this._attrs.checked = val
122
+ }
123
+
124
+ public reset () {
125
+ this.checked = this._reset
126
+ }
127
+ }
128
+
129
+ @Observed
130
+ class TaroInputElement<T extends FormWidgetProps = InputProps> extends TaroFormWidgetElement<T> {
131
+ _height = 0
132
+
133
+ heightChange?: (height: number) => void
134
+
135
+ windowClass?: window.Window
136
+
137
+ controller: TextInputController = new TextInputController()
138
+
139
+ constructor(tagName = 'Input') {
140
+ super(tagName)
141
+
142
+ try {
143
+ Current.contextPromise
144
+ .then((context: common.BaseContext) => {
145
+ return window.getLastWindow(context, (err, windowClass: window.Window) => {
146
+ const errCode: number = err.code
147
+
148
+ if (errCode) {
149
+ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err))
150
+ return
151
+ }
152
+
153
+ this.windowClass = windowClass
154
+ const heightChange = (height: number) => {
155
+ if (isNumber(height)) {
156
+ if (this._height !== height) {
157
+ this.onKeyboardHeightChange(height)
158
+ this._height = height
159
+ }
160
+ }
161
+ }
162
+ windowClass.on('keyboardHeightChange', heightChange)
163
+ })
164
+ })
165
+ } catch (exception) {
166
+ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception))
167
+ }
168
+ }
169
+
170
+ private onKeyboardHeightChange (height: number) {
171
+ const event: TaroEvent = createTaroEvent('keyboardHeightChange', { detail: { height: height, duration: 0 } }, this)
172
+
173
+ eventHandler(event, 'keyboardHeightChange', this)
174
+ }
175
+
176
+ public dispose () {
177
+ super.dispose()
178
+
179
+ if (this.windowClass) {
180
+ try {
181
+ this.windowClass.off('keyboardHeightChange', this.heightChange)
182
+ } catch (err) {
183
+ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err))
184
+ }
185
+ }
186
+ }
187
+ }
188
+
189
+ @Observed
190
+ class TaroTextAreaElement extends TaroInputElement<TextareaProps> {
191
+ controller: TextAreaController = new TextAreaController()
192
+
193
+ constructor() {
194
+ super('TextArea')
195
+ }
196
+ }
197
+ @Observed
198
+ class TaroCheckboxElement extends TaroCheckedElement<CheckboxProps> {
199
+ constructor() {
200
+ super('Checkbox')
201
+ }
202
+ }
203
+
204
+ @Observed
205
+ class TaroRadioElement extends TaroCheckedElement<RadioProps> {
206
+ public group?: string
207
+
208
+ constructor() {
209
+ super('Radio')
210
+ }
211
+ }
212
+
213
+ @Observed
214
+ class TaroSliderElement extends TaroFormWidgetElement<SliderProps> {
215
+ constructor() {
216
+ super('Slider')
217
+
218
+ this._nodeInfo._value = Number(this._attrs.value || 0)
219
+ }
220
+ }
221
+ @Observed
222
+ class TaroPickerElement extends TaroFormWidgetElement<PickerSelectorProps | PickerTimeProps | PickerDateProps | PickerMultiSelectorProps> {
223
+ constructor() {
224
+ super('Picker')
225
+ }
226
+
227
+ public getCurrentSelect () {
228
+ switch (this._attrs.mode) {
229
+ case 'time':
230
+ case 'date':
231
+ return this.value
232
+ case 'selector': {
233
+ const key = this._attrs.rangeKey
234
+ const item = this._attrs.range[this.value]
235
+
236
+ if (key) {
237
+ return item[key]
238
+ } else {
239
+ return item
240
+ }
241
+ }
242
+ case 'multiSelector': {
243
+ const key = this._attrs.rangeKey
244
+
245
+ return this._attrs.range.map((rangeList: TaroAny[], index: number) => {
246
+ const obj = rangeList[this.value[index]]
247
+
248
+ if (key) {
249
+ return obj[key]
250
+ } else {
251
+ return obj
252
+ }
253
+ }).join(',')
254
+ }
255
+ default:
256
+ return ''
257
+ }
258
+ }
259
+
260
+ public reset() {
261
+ super.reset()
262
+
263
+ const event: TaroEvent = createTaroEvent('change', { detail: { value: this._reset } }, this)
264
+
265
+ event.stopPropagation()
266
+ eventHandler(event, 'change', this)
267
+ }
268
+ }
269
+
270
+ @Observed
271
+ class TaroSwitchElement extends TaroCheckedElement<SwitchProps> {
272
+ constructor() {
273
+ super('Switch')
274
+ }
275
+ }
276
+ @Observed
277
+ class TaroCheckboxGroupElement extends TaroFormWidgetElement<CheckboxGroupProps> {
278
+ constructor() {
279
+ super('CheckboxGroup')
280
+ }
281
+
282
+ public get value () {
283
+ const childList = this.getElementsByTagName<TaroCheckboxElement>('CHECKBOX')
284
+ const result: string[] = []
285
+ childList.forEach(element => {
286
+ if (element.checked) {
287
+ result.push(element._attrs.value)
288
+ }
289
+ })
290
+ return result
291
+ }
292
+
293
+ public set value (_) { }
294
+
295
+ public reset () {
296
+ this.getElementsByTagName<TaroCheckboxElement>('CHECKBOX').forEach((element) => {
297
+ element.reset()
298
+ })
299
+ }
300
+ }
301
+
302
+ @Observed
303
+ class TaroRadioGroupElement extends TaroFormWidgetElement<RadioGroupProps> {
304
+ constructor() {
305
+ super('RadioGroup')
306
+ }
307
+
308
+ public get value () {
309
+ const childList = this.getElementsByTagName<TaroRadioElement>('RADIO')
310
+ for (let i = 0; i < childList.length; i++) {
311
+ if (childList[i].checked) {
312
+ return childList[i]._attrs.value
313
+ }
314
+ }
315
+
316
+ return undefined
317
+ }
318
+
319
+ public set value (_) { }
320
+
321
+ public reset () {
322
+ this.getElementsByTagName<TaroCheckboxElement>('RADIO').forEach((element) => {
323
+ element.reset()
324
+ })
325
+ }
326
+ }
327
+
328
+ @Observed
329
+ class TaroFormElement extends TaroFormWidgetElement {
330
+ constructor() {
331
+ super('Form')
332
+
333
+ // 监听submit冒泡
334
+ this.addEventListener('submit-btn', (e: TaroEvent) => {
335
+ e.stopPropagation()
336
+ const formResult: Record<string, any> = {}
337
+
338
+ findChildNodeWithDFS<TaroFormWidgetElement>(this, item => {
339
+ if (!item.name) return false
340
+
341
+ switch (item.nodeName) {
342
+ case 'INPUT':
343
+ case 'RADIO':
344
+ case 'SLIDER':
345
+ case 'TEXTAREA':
346
+ case 'CHECKBOX':
347
+ case 'RADIO-GROUP':
348
+ case 'CHECKBOX-GROUP': {
349
+ formResult[item.name] = item.value
350
+ break
351
+ }
352
+ case 'SWITCH':
353
+ formResult[item.name] = (item as TaroSwitchElement).checked
354
+ break
355
+ case 'PICKER':
356
+ formResult[item.name] = (item as TaroPickerElement).getCurrentSelect()
357
+ break
358
+ }
359
+ return false
360
+ }, true)
361
+ const event: TaroEvent = createTaroEvent('submit', { detail: { value: formResult } }, this)
362
+ eventHandler(event, 'submit', this)
363
+ })
364
+
365
+ // 监听reset冒泡
366
+ this.addEventListener('reset-btn', (e: TaroEvent) => {
367
+ findChildNodeWithDFS<TaroFormWidgetElement>(this, item => {
368
+ e.stopPropagation()
369
+ switch (item.nodeName) {
370
+ case 'INPUT':
371
+ case 'SLIDER':
372
+ case 'PICKER':
373
+ case 'RADIO':
374
+ case 'SWITCH':
375
+ case 'CHECKBOX':
376
+ case 'TEXTAREA':
377
+ case 'RADIO-GROUP':
378
+ case 'CHECKBOX-GROUP': {
379
+ item.reset()
380
+ break
381
+ }
382
+ }
383
+ return false
384
+ }, true)
385
+ })
386
+ }
387
+ }
388
+
389
+ const FormElement = TaroFormElement
390
+
391
+ export {
392
+ FormElement,
393
+ TaroCheckboxElement,
394
+ TaroCheckboxGroupElement,
395
+ TaroFormElement,
396
+ TaroInputElement,
397
+ TaroPickerElement,
398
+ TaroRadioElement,
399
+ TaroRadioGroupElement,
400
+ TaroSliderElement,
401
+ TaroSwitchElement,
402
+ TaroTextAreaElement
403
+ }
@@ -0,0 +1,120 @@
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
+ TaroPickerElement,
12
+ TaroRadioElement,
13
+ TaroRadioGroupElement,
14
+ TaroSliderElement,
15
+ TaroSwitchElement,
16
+ TaroTextAreaElement
17
+ } from './form'
18
+ import { TaroMovableAreaElement } from './movableArea'
19
+ import { isTaroMovableViewElement, TaroMovableViewElement } from './movableView'
20
+ import {
21
+ TaroButtonElement,
22
+ TaroIconElement,
23
+ TaroImageElement,
24
+ TaroLabelElement,
25
+ TaroNavigationBarElement,
26
+ TaroOtherElement,
27
+ TaroPageMetaElement,
28
+ TaroRichTextElement,
29
+ TaroSwiperElement,
30
+ TaroSwiperItemElement,
31
+ TaroViewElement
32
+ } from './normal'
33
+ import { TaroProgressElement } from './progress'
34
+ import { TaroScrollViewElement } from './scrollView'
35
+ import { TaroTextElement } from './text'
36
+ import { TaroVideoElement } from './video'
37
+ import { TaroInnerHtmlElement, TaroWebViewElement } from './webView'
38
+
39
+ export function initHarmonyElement () {
40
+ Current.createHarmonyElement = (tagName: string) => {
41
+ switch (tagName) {
42
+ case 'view': return new TaroViewElement()
43
+ case 'image': return new TaroImageElement()
44
+ case 'text': return new TaroTextElement()
45
+ case 'button': return new TaroButtonElement()
46
+ case 'movable-area': return new TaroMovableAreaElement()
47
+ case 'movable-view': return new TaroMovableViewElement()
48
+ case 'progress': return new TaroProgressElement()
49
+ case 'scroll-view': return new TaroScrollViewElement()
50
+ case 'scroll-list': return new TaroScrollViewElement()
51
+ case 'checkbox-group': return new TaroCheckboxGroupElement()
52
+ case 'input': return new TaroInputElement()
53
+ case 'picker': return new TaroPickerElement()
54
+ case 'radio-group': return new TaroRadioGroupElement()
55
+ case 'slider': return new TaroSliderElement()
56
+ case 'switch': return new TaroSwitchElement()
57
+ case 'video': return new TaroVideoElement()
58
+ case 'checkbox': return new TaroCheckboxElement()
59
+ case 'radio': return new TaroRadioElement()
60
+ case 'icon': return new TaroIconElement()
61
+ case 'label': return new TaroLabelElement()
62
+ case 'rich-text': return new TaroRichTextElement()
63
+ case 'canvas': return new TaroCanvasElement()
64
+ case 'swiper': return new TaroSwiperElement()
65
+ case 'swiper-item': return new TaroSwiperItemElement()
66
+ case 'textarea': return new TaroTextAreaElement()
67
+ case 'form': return new TaroFormElement()
68
+ case 'web-view': return new TaroWebViewElement()
69
+ case 'inner-html': return new TaroInnerHtmlElement()
70
+ case 'page-meta': return new TaroPageMetaElement()
71
+ case 'navigation-bar': return new TaroNavigationBarElement()
72
+ default: return new TaroOtherElement(tagName)
73
+ }
74
+ }
75
+
76
+ Current.createTextNode = (value: string): TaroTextNode => {
77
+ const node = new TaroTextNode(value)
78
+ return node
79
+ }
80
+ }
81
+
82
+ export {
83
+ FormElement,
84
+ TaroButtonElement,
85
+ TaroCanvasElement,
86
+ TaroCheckboxElement,
87
+ TaroCheckboxGroupElement,
88
+ TaroElement,
89
+ TaroFormElement,
90
+ TaroIconElement,
91
+ TaroImageElement,
92
+ TaroInnerHtmlElement,
93
+ TaroInputElement,
94
+ TaroLabelElement,
95
+ TaroMovableAreaElement,
96
+ TaroMovableViewElement,
97
+ TaroNavigationBarElement,
98
+ TaroOtherElement,
99
+ TaroPageMetaElement,
100
+ TaroPickerElement,
101
+ TaroProgressElement,
102
+ TaroRadioElement,
103
+ TaroRadioGroupElement,
104
+ TaroRichTextElement,
105
+ TaroScrollViewElement,
106
+ TaroSliderElement,
107
+ TaroSwiperElement,
108
+ TaroSwiperItemElement,
109
+ TaroSwitchElement,
110
+ TaroTextAreaElement,
111
+ TaroTextElement,
112
+ TaroVideoElement,
113
+ TaroViewElement,
114
+ TaroWebViewElement
115
+ }
116
+
117
+
118
+ export {
119
+ isTaroMovableViewElement
120
+ }
@@ -0,0 +1,11 @@
1
+
2
+ import { TaroElement } from './element'
3
+
4
+ import type { MovableAreaProps } from '@tarojs/components/types'
5
+
6
+ @Observed
7
+ export class TaroMovableAreaElement extends TaroElement<MovableAreaProps> {
8
+ constructor() {
9
+ super('MovableArea')
10
+ }
11
+ }