@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27 → 4.0.0-alpha.0
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.
- package/dist/apis/apis.ts +6 -2
- package/dist/apis/base/crypto.ts +4 -0
- package/dist/apis/base/debug.ts +5 -0
- package/dist/apis/base/index.ts +9 -1
- package/dist/apis/base/performance.ts +8 -0
- package/dist/apis/base/system.ts +1 -1
- package/dist/apis/base/update.ts +5 -0
- package/dist/apis/base/weapp/app-event.ts +75 -0
- package/dist/apis/base/weapp/life-cycle.ts +21 -0
- package/dist/apis/canvas/index.ts +18 -0
- package/dist/apis/data-analysis/index.ts +6 -0
- package/dist/apis/device/accelerometer.ts +2 -1
- package/dist/apis/device/accessibility.ts +4 -0
- package/dist/apis/device/battery.ts +2 -2
- package/dist/apis/device/bluetooth-ble.ts +19 -0
- package/dist/apis/device/bluetooth-peripheral.ts +6 -0
- package/dist/apis/device/bluetooth.ts +16 -0
- package/dist/apis/device/calendar.ts +5 -0
- package/dist/apis/device/clipboard.ts +1 -1
- package/dist/apis/device/compass.ts +21 -0
- package/dist/apis/device/contact.ts +5 -0
- package/dist/apis/device/crypto.ts +4 -0
- package/dist/apis/device/gyroscope.ts +7 -0
- package/dist/apis/device/iBeacon.ts +10 -0
- package/dist/apis/device/index.ts +15 -0
- package/dist/apis/device/keyboard.ts +2 -1
- package/dist/apis/device/motion.ts +6 -0
- package/dist/apis/device/network.ts +26 -9
- package/dist/apis/device/nfc.ts +10 -0
- package/dist/apis/device/phone.ts +2 -1
- package/dist/apis/device/scan.ts +4 -0
- package/dist/apis/device/screen.ts +2 -1
- package/dist/apis/device/sms.ts +4 -0
- package/dist/apis/device/vibrate.ts +19 -11
- package/dist/apis/device/wifi.ts +15 -0
- package/dist/apis/ext/index.ts +5 -0
- package/dist/apis/files/index.ts +2 -1
- package/dist/apis/files/manager.ts +2 -1
- package/dist/apis/framework/index.ts +5 -6
- package/dist/apis/location/index.ts +61 -68
- package/dist/apis/media/EditorContext.ts +32 -0
- package/dist/apis/media/audio/index.ts +18 -0
- package/dist/apis/media/background-audio/index.ts +16 -0
- package/dist/apis/media/camera.ts +16 -0
- package/dist/apis/media/common.ts +2 -1
- package/dist/apis/media/{image.ts → image/index.ts} +3 -2
- package/dist/apis/media/index.ts +10 -0
- package/dist/apis/media/live.ts +5 -0
- package/dist/apis/media/map.ts +4 -0
- package/dist/apis/media/media-recorder.ts +4 -0
- package/dist/apis/media/recorder.ts +6 -0
- package/dist/apis/media/video/VideoContext.ts +19 -0
- package/dist/apis/media/{video.ts → video/index.ts} +12 -2
- package/dist/apis/media/video-decoder.ts +4 -0
- package/dist/apis/media/video-processing.ts +4 -0
- package/dist/apis/media/voip.ts +19 -0
- package/dist/apis/network/index.ts +3 -0
- package/dist/apis/network/mdns.ts +13 -0
- package/dist/apis/network/request.ts +2 -1
- package/dist/apis/network/tcp.ts +4 -0
- package/dist/apis/network/udp.ts +4 -0
- package/dist/apis/network/webSocket.ts +2 -6
- package/dist/apis/open-api/account.ts +4 -0
- package/dist/apis/open-api/address.ts +4 -0
- package/dist/apis/open-api/authorize.ts +5 -0
- package/dist/apis/open-api/card.ts +5 -0
- package/dist/apis/open-api/channels-live.ts +11 -0
- package/dist/apis/open-api/customer-service.ts +4 -0
- package/dist/apis/open-api/device-voip.ts +5 -0
- package/dist/apis/open-api/facial.ts +7 -0
- package/dist/apis/open-api/favorites.ts +5 -0
- package/dist/apis/open-api/group.ts +4 -0
- package/dist/apis/open-api/index.ts +20 -6
- package/dist/apis/open-api/invoice.ts +5 -0
- package/dist/apis/open-api/license-plate.ts +4 -0
- package/dist/apis/open-api/login.ts +6 -0
- package/dist/apis/open-api/my-miniprogram.ts +4 -0
- package/dist/apis/open-api/privacy.ts +7 -0
- package/dist/apis/open-api/red-package.ts +4 -0
- package/dist/apis/open-api/settings.ts +5 -0
- package/dist/apis/open-api/soter.ts +6 -0
- package/dist/apis/open-api/subscribe-message.ts +6 -0
- package/dist/apis/open-api/{user-info/index.ts → user-info.ts} +1 -16
- package/dist/apis/open-api/werun.ts +5 -0
- package/dist/apis/payment/index.ts +6 -0
- package/dist/apis/route/index.ts +4 -28
- package/dist/apis/share/index.ts +33 -0
- package/dist/apis/storage/background-fetch.ts +7 -0
- package/dist/apis/storage/cache-manager.ts +4 -0
- package/dist/apis/storage/index.ts +20 -18
- package/dist/apis/ui/{animation.ts → animation/animation.ts} +2 -2
- package/dist/apis/ui/animation/index.ts +7 -0
- package/dist/apis/ui/background.ts +2 -18
- package/dist/apis/ui/custom-component.ts +8 -0
- package/dist/apis/ui/fonts.ts +4 -0
- package/dist/apis/ui/index.ts +8 -10
- package/dist/apis/ui/interaction/index.ts +3 -0
- package/dist/apis/ui/menu.ts +4 -0
- package/dist/apis/ui/navigation-bar/index.ts +60 -21
- package/dist/apis/ui/pull-down-refresh.ts +1 -1
- package/dist/apis/{page → ui/scroll}/index.ts +27 -22
- package/dist/apis/ui/sticky.ts +4 -0
- package/dist/apis/{tabbar/index.ts → ui/tab-bar.ts} +3 -5
- package/dist/apis/ui/window.ts +20 -0
- package/dist/apis/utils/handler.ts +4 -4
- package/dist/apis/worker/index.ts +4 -0
- package/dist/apis/wxml/IntersectionObserver.ts +12 -21
- package/dist/apis/wxml/index.ts +5 -2
- package/dist/apis/wxml/nodesRef.ts +2 -2
- package/dist/apis/wxml/selectorQuery.ts +3 -4
- package/dist/components-harmony-ets/button.ets +90 -64
- package/dist/components-harmony-ets/checkbox.ets +53 -98
- package/dist/components-harmony-ets/form.ets +16 -112
- package/dist/components-harmony-ets/icon.ets +59 -46
- package/dist/components-harmony-ets/image.ets +15 -40
- package/dist/components-harmony-ets/innerHtml.ets +6 -74
- package/dist/components-harmony-ets/input.ets +58 -128
- package/dist/components-harmony-ets/label.ets +43 -69
- package/dist/components-harmony-ets/picker.ets +114 -137
- package/dist/components-harmony-ets/radio.ets +55 -103
- package/dist/components-harmony-ets/richText.ets +17 -41
- package/dist/components-harmony-ets/scrollView.ets +69 -101
- package/dist/components-harmony-ets/slider.ets +35 -58
- package/dist/components-harmony-ets/swiper.ets +24 -135
- package/dist/components-harmony-ets/switch.ets +25 -55
- package/dist/components-harmony-ets/text.ets +42 -46
- package/dist/components-harmony-ets/textArea.ets +39 -107
- package/dist/components-harmony-ets/utils/constant/style.ets +9 -6
- package/dist/components-harmony-ets/utils/flexManager.ets +3 -88
- package/dist/components-harmony-ets/utils/helper.ets +2 -62
- package/dist/components-harmony-ets/utils/index.ts +1 -1
- package/dist/components-harmony-ets/utils/styles.ets +6 -9
- package/dist/components-harmony-ets/video.ets +63 -92
- package/dist/components-harmony-ets/view.ets +65 -40
- package/dist/index.js +33 -4
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/getComputedStyle.ts +1 -1
- package/dist/runtime-ets/dom/bind.ts +80 -0
- package/dist/runtime-ets/dom/class-list.ts +2 -4
- package/dist/runtime-ets/dom/comment.ts +1 -2
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +1 -1
- package/dist/runtime-ets/dom/dataSource.ts +64 -0
- package/dist/runtime-ets/dom/document.ts +14 -43
- package/dist/runtime-ets/dom/element/element.ts +162 -0
- package/dist/runtime-ets/dom/element/form.ts +397 -0
- package/dist/runtime-ets/dom/element/index.ts +89 -0
- package/dist/runtime-ets/dom/element/normal.ts +75 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +14 -0
- package/dist/runtime-ets/dom/element/text.ts +17 -0
- package/dist/runtime-ets/dom/element/video.ts +49 -0
- package/dist/runtime-ets/dom/event.ts +24 -1
- package/dist/runtime-ets/dom/eventTarget.ts +2 -1
- package/dist/runtime-ets/dom/node.ts +74 -44
- package/dist/runtime-ets/dom/stylesheet/index.ts +136 -23
- package/dist/runtime-ets/dom/stylesheet/type.ts +4 -3
- package/dist/runtime-ets/dom/stylesheet/util.ts +71 -1
- package/dist/runtime-ets/index.ts +0 -1
- package/dist/runtime-ets/utils/bind.ts +3 -14
- package/dist/runtime-ets/utils/index.ts +12 -7
- package/dist/runtime-ets/utils/info.ts +22 -50
- package/dist/runtime-framework/react/app.ts +3 -6
- package/dist/runtime-framework/react/page.ts +2 -9
- package/dist/runtime-framework/solid/page.ts +0 -6
- package/dist/runtime-utils.js +1150 -339
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +1150 -339
- package/dist/runtime.js.map +1 -1
- package/package.json +8 -8
- package/types/runtime.d.ts +4 -0
- package/LICENSE +0 -160
- package/dist/components-harmony-ets/base.ets +0 -63
- package/dist/components-harmony-ets/element.ets +0 -223
- package/dist/components-harmony-ets/utils/constant/icon.ts +0 -19
- package/dist/runtime-ets/dom/element.ts +0 -457
- package/dist/runtime-ets/dom/text.ts +0 -19
- package/types/api.d.ts +0 -4
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
import {
|
|
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 {
|
|
8
|
-
import TaroComponentWrapper from './base'
|
|
3
|
+
import { createLazyChildren } from './render'
|
|
9
4
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
10
5
|
import { FlexManager } from './utils/FlexManager'
|
|
11
|
-
import {
|
|
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'
|
|
6
|
+
import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
20
7
|
|
|
8
|
+
import type { TaroAny, TaroFormElement, TaroStyleType } from '@tarojs/runtime'
|
|
21
9
|
|
|
22
10
|
@Extend(Flex)
|
|
23
11
|
function attrs (style: TaroStyleType) {
|
|
@@ -35,6 +23,7 @@ function attrs (style: TaroStyleType) {
|
|
|
35
23
|
.backgroundColor(style.backgroundColor)
|
|
36
24
|
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
37
25
|
.backgroundImageSize(style.backgroundImageSize)
|
|
26
|
+
.backgroundImagePosition(style.backgroundImagePosition)
|
|
38
27
|
.rotate(style.rotate)
|
|
39
28
|
.scale(style.scale)
|
|
40
29
|
.translate(style.translate)
|
|
@@ -49,101 +38,16 @@ function attrs (style: TaroStyleType) {
|
|
|
49
38
|
.clip(style.clip)
|
|
50
39
|
}
|
|
51
40
|
|
|
52
|
-
@
|
|
53
|
-
export default
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
@Styles visibleChangeEvent () {
|
|
57
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
@ObjectLink node: TaroFormElement
|
|
61
|
-
|
|
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
|
-
}
|
|
127
|
-
|
|
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
|
-
}))
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
build() {
|
|
138
|
-
TaroComponentWrapper({ node: this.node }) {
|
|
139
|
-
Flex(FlexManager.flexOptions(this.node)) {
|
|
140
|
-
ForEach(this.node.childNodes, (item: TaroElement) => {
|
|
141
|
-
createNode(item)
|
|
142
|
-
}, (item: TaroElement) => item._nid)
|
|
143
|
-
}
|
|
144
|
-
.attrs(getNormalAttributes(this.node))
|
|
145
|
-
.defaultEvent()
|
|
146
|
-
.visibleChangeEvent()
|
|
147
|
-
}
|
|
41
|
+
@Builder
|
|
42
|
+
export default function TaroForm (node: TaroFormElement) {
|
|
43
|
+
Flex(FlexManager.flexOptions(node)) {
|
|
44
|
+
createLazyChildren(node)
|
|
148
45
|
}
|
|
46
|
+
.attrs(getNormalAttributes(node))
|
|
47
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
48
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
49
|
+
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
50
|
+
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
51
|
+
node._nodeInfo.areaInfo = res[1]
|
|
52
|
+
}))
|
|
149
53
|
}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import { ICON_SVG_MAP } from './utils/constant/icon'
|
|
5
|
-
import { getNormalAttributes, shouldBindEvent, getNodeThresholds, bindAnimation } from './utils/helper'
|
|
6
|
-
|
|
7
|
-
import type { TaroIconElement } from './element'
|
|
8
|
-
import type { TaroStyleType } from '@tarojs/runtime'
|
|
3
|
+
import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
9
4
|
|
|
5
|
+
import type { TaroIconElement, TaroAny, TaroStyleType } from '@tarojs/runtime'
|
|
10
6
|
|
|
11
7
|
@Extend(Image)
|
|
12
8
|
function attrs (style: TaroStyleType) {
|
|
@@ -24,6 +20,7 @@ function attrs (style: TaroStyleType) {
|
|
|
24
20
|
.backgroundColor(style.backgroundColor)
|
|
25
21
|
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
26
22
|
.backgroundImageSize(style.backgroundImageSize)
|
|
23
|
+
.backgroundImagePosition(style.backgroundImagePosition)
|
|
27
24
|
.rotate(style.rotate)
|
|
28
25
|
.scale(style.scale)
|
|
29
26
|
.translate(style.translate)
|
|
@@ -38,47 +35,63 @@ function attrs (style: TaroStyleType) {
|
|
|
38
35
|
.clip(style.clip)
|
|
39
36
|
}
|
|
40
37
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
const ICON_COLOR_MAP: TaroAny = {
|
|
39
|
+
success: Color.Green,
|
|
40
|
+
success_no_circle: Color.Green,
|
|
41
|
+
info: Color.Blue,
|
|
42
|
+
warn: Color.Red,
|
|
43
|
+
waiting: Color.Blue,
|
|
44
|
+
cancel: Color.Red,
|
|
45
|
+
download: Color.Gray,
|
|
46
|
+
search: Color.Gray,
|
|
47
|
+
clear: Color.Gray,
|
|
48
|
+
info_circle: Color.Blue,
|
|
49
|
+
circle: Color.Gray
|
|
50
|
+
}
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
function getIconData (node: TaroIconElement): Resource | null {
|
|
53
|
+
switch (node._attrs.type) {
|
|
54
|
+
case 'success':
|
|
55
|
+
return $r('app.media.success')
|
|
56
|
+
case 'success_no_circle':
|
|
57
|
+
return $r('app.media.success_no_circle')
|
|
58
|
+
case 'info':
|
|
59
|
+
return $r('app.media.info')
|
|
60
|
+
case 'warn':
|
|
61
|
+
return $r('app.media.warn')
|
|
62
|
+
case 'waiting':
|
|
63
|
+
return $r('app.media.waiting')
|
|
64
|
+
case 'cancel':
|
|
65
|
+
return $r('app.media.cancel')
|
|
66
|
+
case 'download':
|
|
67
|
+
return $r('app.media.download')
|
|
68
|
+
case 'search':
|
|
69
|
+
return $r('app.media.search')
|
|
70
|
+
case 'clear':
|
|
71
|
+
return $r('app.media.clear')
|
|
72
|
+
case 'info_circle':
|
|
73
|
+
return $r('app.media.info_circle')
|
|
74
|
+
case 'circle':
|
|
75
|
+
return $r('app.media.circle')
|
|
76
|
+
default:
|
|
77
|
+
return null
|
|
56
78
|
}
|
|
79
|
+
}
|
|
57
80
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
81
|
+
@Builder
|
|
82
|
+
export default function TaroIcon (node: TaroIconElement) {
|
|
83
|
+
Image(getIconData(node))
|
|
84
|
+
.objectFit(ImageFit.Contain)
|
|
85
|
+
.fillColor(node._attrs.color || ICON_COLOR_MAP[node._attrs.type] || Color.Black)
|
|
86
|
+
.attrs(getNormalAttributes(node))
|
|
87
|
+
.size({
|
|
88
|
+
width: convertNumber2VP(Number(node._attrs.size) || 23),
|
|
89
|
+
height: convertNumber2VP(Number(node._attrs.size) || 23),
|
|
90
|
+
})
|
|
91
|
+
.onComplete(e => eventHandler(e, 'complete', node))
|
|
92
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
93
|
+
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
94
|
+
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
95
|
+
node._nodeInfo.areaInfo = res[1]
|
|
63
96
|
}))
|
|
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
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
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
|
-
}
|
|
83
|
-
}
|
|
84
97
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import { getNormalAttributes, shouldBindEvent, getNodeThresholds, bindAnimation } from './utils/helper'
|
|
3
|
+
import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
5
4
|
|
|
6
|
-
import type { TaroImageElement } from '
|
|
7
|
-
import type { TaroStyleType } from '@tarojs/runtime'
|
|
5
|
+
import type { TaroImageElement, TaroAny, TaroStyleType } from '@tarojs/runtime'
|
|
8
6
|
|
|
9
7
|
@Extend(Image)
|
|
10
8
|
function attrs (style: TaroStyleType) {
|
|
@@ -14,14 +12,15 @@ function attrs (style: TaroStyleType) {
|
|
|
14
12
|
.margin(style.margin)
|
|
15
13
|
.width(style.width)
|
|
16
14
|
.height(style.height)
|
|
15
|
+
.backgroundColor(style.backgroundColor)
|
|
17
16
|
.constraintSize(style.constraintSize)
|
|
18
17
|
.flexGrow(style.flexGrow)
|
|
19
18
|
.flexShrink(style.flexShrink)
|
|
20
19
|
.flexBasis(style.flexBasis)
|
|
21
20
|
.alignSelf(style.alignSelf)
|
|
22
|
-
.backgroundColor(style.backgroundColor)
|
|
23
21
|
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
24
22
|
.backgroundImageSize(style.backgroundImageSize)
|
|
23
|
+
.backgroundImagePosition(style.backgroundImagePosition)
|
|
25
24
|
.rotate(style.rotate)
|
|
26
25
|
.scale(style.scale)
|
|
27
26
|
.translate(style.translate)
|
|
@@ -47,39 +46,15 @@ function getImageMode (mode: string): ImageFit {
|
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
@
|
|
51
|
-
export default
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
@ObjectLink node: TaroImageElement
|
|
59
|
-
|
|
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]
|
|
49
|
+
@Builder
|
|
50
|
+
export default function TaroImage (node: TaroImageElement) {
|
|
51
|
+
Image(node.getAttribute('src'))
|
|
52
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
53
|
+
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
54
|
+
node._nodeInfo.areaInfo = res[1]
|
|
72
55
|
}))
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
Image(this.node.getAttribute('src'))
|
|
78
|
-
.defaultEvent()
|
|
79
|
-
.objectFit(getImageMode(this.node.getAttribute('mode')))
|
|
80
|
-
.attrs(getNormalAttributes(this.node))
|
|
81
|
-
.onComplete(e => eventHandler(e, 'complete', this.node))
|
|
82
|
-
.visibleChangeEvent()
|
|
83
|
-
}
|
|
84
|
-
}
|
|
56
|
+
.objectFit(getImageMode(node.getAttribute('mode')))
|
|
57
|
+
.attrs(getNormalAttributes(node))
|
|
58
|
+
.onComplete(e => eventHandler(e, 'complete', node))
|
|
59
|
+
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
85
60
|
}
|
|
@@ -1,79 +1,11 @@
|
|
|
1
|
-
import TaroComponentWrapper from './base'
|
|
2
|
-
import web_webview from '@ohos.web.webview'
|
|
3
1
|
import htmlParser from './utils/htmlParser'
|
|
4
|
-
import {
|
|
5
|
-
import type { TaroElement } from './element'
|
|
2
|
+
import { createChildItemWithPosition } from './render'
|
|
6
3
|
|
|
7
|
-
@
|
|
8
|
-
export default struct TaroInnerHtml {
|
|
9
|
-
@ObjectLink node: TaroElement
|
|
4
|
+
import type { TaroElement } from '@tarojs/runtime'
|
|
10
5
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
// }
|
|
28
|
-
|
|
29
|
-
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
|
-
// }
|
|
77
|
-
}
|
|
6
|
+
@Builder
|
|
7
|
+
export default function TaroInnerHtml (node: TaroElement) {
|
|
8
|
+
if (node.innerHTML) {
|
|
9
|
+
createChildItemWithPosition(htmlParser(node.innerHTML))
|
|
78
10
|
}
|
|
79
11
|
}
|
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import common from '@ohos.app.ability.common'
|
|
3
|
-
import { isNumber, isUndefined } from '@tarojs/shared'
|
|
4
|
-
import { bindFocus, bindInstanceToNode, eventHandler, Current, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, initComponentNodeInfo,
|
|
5
|
-
TaroEvent, TaroAny } from '@tarojs/runtime'
|
|
1
|
+
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
6
2
|
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import { AttributeManager } from './utils/AttributeManager'
|
|
10
|
-
import { getNormalAttributes, parseStyles, shouldBindEvent, getNodeThresholds, bindAnimation } from './utils/helper'
|
|
11
|
-
import { TEXT_DEFAULT_STYLE, INPUT_TYPE_MAP, INPUT_CONFIRM_MAP } from './utils/constant/style'
|
|
3
|
+
import { getNormalAttributes, parseStyles, shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
4
|
+
import { INPUT_TYPE_MAP, INPUT_CONFIRM_MAP } from './utils/constant/style'
|
|
12
5
|
|
|
13
|
-
import type { TaroInputElement } from '
|
|
14
|
-
import type { TaroStyleType } from '@tarojs/runtime'
|
|
6
|
+
import type { TaroStyleType, TaroAny, TaroInputElement, TaroEvent } from '@tarojs/runtime'
|
|
15
7
|
|
|
16
8
|
interface InputAttrs {
|
|
17
9
|
textAlign?: TextAlign
|
|
@@ -33,6 +25,7 @@ function styles (style: TaroStyleType) {
|
|
|
33
25
|
.backgroundColor(style.backgroundColor)
|
|
34
26
|
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
35
27
|
.backgroundImageSize(style.backgroundImageSize)
|
|
28
|
+
.backgroundImagePosition(style.backgroundImagePosition)
|
|
36
29
|
.rotate(style.rotate)
|
|
37
30
|
.scale(style.scale)
|
|
38
31
|
.translate(style.translate)
|
|
@@ -64,132 +57,69 @@ function getAttributes(node: TaroInputElement): InputAttrs {
|
|
|
64
57
|
}
|
|
65
58
|
}
|
|
66
59
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
nodeInfoMap: TaroAny = {}
|
|
70
|
-
|
|
71
|
-
@State text: string = ''
|
|
60
|
+
function getInputType (node: TaroInputElement) {
|
|
61
|
+
if (node._attrs?.password) return InputType.Password
|
|
72
62
|
|
|
73
|
-
|
|
63
|
+
return INPUT_TYPE_MAP.get(node._attrs?.type || '') || InputType.Normal
|
|
64
|
+
}
|
|
74
65
|
|
|
75
|
-
|
|
66
|
+
function getPlaceholderColor (node: TaroInputElement): string {
|
|
67
|
+
const placeholderTextColor: string = node._attrs.placeholderTextColor || ''
|
|
68
|
+
const placeholderStyle: string = node._attrs.placeholderStyle || ''
|
|
76
69
|
|
|
77
|
-
|
|
70
|
+
return placeholderTextColor || parseStyles(placeholderStyle)?.color
|
|
71
|
+
}
|
|
78
72
|
|
|
79
|
-
|
|
73
|
+
@Component
|
|
74
|
+
export default struct TaroInput {
|
|
75
|
+
@State value: string = ''
|
|
80
76
|
|
|
81
|
-
|
|
82
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
heightChange = (height: number) => {
|
|
86
|
-
if (isNumber(height)) {
|
|
87
|
-
if (this._height !== height) {
|
|
88
|
-
this.onKeyboardHeightChange(height)
|
|
89
|
-
this._height = height
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
77
|
+
node: TaroInputElement | null = null
|
|
93
78
|
|
|
94
79
|
aboutToAppear () {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
// 绑定动画
|
|
99
|
-
bindAnimation(this.node)
|
|
100
|
-
|
|
101
|
-
this.text = this.node._attrs.value || ''
|
|
102
|
-
|
|
103
|
-
try {
|
|
104
|
-
Current.contextPromise
|
|
105
|
-
.then((context: common.BaseContext) => {
|
|
106
|
-
return window.getLastWindow(context, (err, windowClass: window.Window) => {
|
|
107
|
-
const errCode: number = err.code;
|
|
108
|
-
if (errCode) {
|
|
109
|
-
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err))
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
this.windowClass = windowClass
|
|
113
|
-
windowClass.on('keyboardHeightChange', this.heightChange)
|
|
114
|
-
})
|
|
115
|
-
})
|
|
116
|
-
} catch (exception) {
|
|
117
|
-
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception))
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
aboutToDisappear () {
|
|
122
|
-
if (this.windowClass) {
|
|
123
|
-
try {
|
|
124
|
-
this.windowClass.off('keyboardHeightChange', this.heightChange)
|
|
125
|
-
} catch (err) {
|
|
126
|
-
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err))
|
|
127
|
-
}
|
|
80
|
+
if (this.node) {
|
|
81
|
+
this.value = this.node.value
|
|
82
|
+
this.node._instance = this
|
|
128
83
|
}
|
|
129
84
|
}
|
|
130
85
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
build() {
|
|
169
|
-
TaroComponentWrapper({ node: this.node }) {
|
|
170
|
-
TextInput({ text: this.getText(), placeholder: this.node._attrs?.placeholder || '', controller: this.controller })
|
|
171
|
-
.focusable(true)
|
|
172
|
-
.key(this.node._nid)
|
|
173
|
-
.type(this.getInputType(this.node))
|
|
174
|
-
.maxLength(Number(this.node._attrs?.maxlength) || null)
|
|
175
|
-
.placeholderColor(this.getPlaceholderColor(this.node))
|
|
176
|
-
.enterKeyType(INPUT_CONFIRM_MAP.get(this.node._attrs?.confirmType) || EnterKeyType.Done)
|
|
177
|
-
.defaultEvent()
|
|
178
|
-
.styles(getNormalAttributes(this.node))
|
|
179
|
-
.attrs(getAttributes(this.node))
|
|
180
|
-
.style(TextInputStyle.Inline)
|
|
181
|
-
.onChange((value: string) => {
|
|
182
|
-
const event: TaroEvent = createTaroEvent('input', { detail: { value } }, this.node)
|
|
183
|
-
eventHandler(event, 'input', this.node)
|
|
184
|
-
this.text = value
|
|
185
|
-
})
|
|
186
|
-
.onSubmit(() => {
|
|
187
|
-
const event: TaroEvent = createTaroEvent('confirm', { detail: { value: this.text } }, this.node)
|
|
188
|
-
eventHandler(event, 'confirm', this.node)
|
|
189
|
-
})
|
|
190
|
-
.visibleChangeEvent()
|
|
86
|
+
build () {
|
|
87
|
+
if (this.node) {
|
|
88
|
+
TextInput({ text: this.value, placeholder: this.node._attrs?.placeholder || '', controller: this.node.controller })
|
|
89
|
+
.key(this.node._nid)
|
|
90
|
+
.type(getInputType(this.node))
|
|
91
|
+
.maxLength(Number(this.node._attrs?.maxlength) || null)
|
|
92
|
+
.placeholderColor(getPlaceholderColor(this.node))
|
|
93
|
+
.enterKeyType(INPUT_CONFIRM_MAP.get(this.node._attrs?.confirmType) || EnterKeyType.Done)
|
|
94
|
+
.styles(getNormalAttributes(this.node))
|
|
95
|
+
.attrs(getAttributes(this.node))
|
|
96
|
+
.onChange((value: string) => {
|
|
97
|
+
const event: TaroEvent = createTaroEvent('input', { detail: { value } }, this.node)
|
|
98
|
+
|
|
99
|
+
this.value = value
|
|
100
|
+
this.node?.updateFormWidgetValue(value)
|
|
101
|
+
eventHandler(event, 'input', this.node)
|
|
102
|
+
})
|
|
103
|
+
.onSubmit(() => {
|
|
104
|
+
const event: TaroEvent = createTaroEvent('confirm', { detail: { value: this.value } }, this.node)
|
|
105
|
+
eventHandler(event, 'confirm', this.node)
|
|
106
|
+
})
|
|
107
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
108
|
+
.onBlur(() => {
|
|
109
|
+
const event: TaroEvent = createTaroEvent('blur', { detail: { value: this.value } }, this.node)
|
|
110
|
+
eventHandler(event, 'blur', this.node)
|
|
111
|
+
})
|
|
112
|
+
.onFocus(() => {
|
|
113
|
+
const event: TaroEvent = createTaroEvent('focus', { detail: { value: this.value, height: this.node?._height } }, this.node)
|
|
114
|
+
|
|
115
|
+
eventHandler(event, 'focus', this.node)
|
|
116
|
+
})
|
|
117
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
118
|
+
if (this.node) {
|
|
119
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
120
|
+
}
|
|
121
|
+
}))
|
|
122
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
191
123
|
}
|
|
192
124
|
}
|
|
193
125
|
}
|
|
194
|
-
|
|
195
|
-
export default TaroInput
|