@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27 → 4.0.0-beta.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,15 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TaroEvent, TaroAny } from '@tarojs/runtime'
|
|
1
|
+
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
3
2
|
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
7
|
-
import { createTaroEvent } from './utils/events'
|
|
8
|
-
import { FlexManager } from './utils/FlexManager'
|
|
9
|
-
import { getNodeThresholds, getNormalAttributes, shouldBindEvent, bindAnimation } from './utils/helper'
|
|
3
|
+
import { createLazyChildren } from './render'
|
|
4
|
+
import { getNodeThresholds, getNormalAttributes, shouldBindEvent } from './utils/helper'
|
|
10
5
|
|
|
11
|
-
import type { TaroSwiperElement,
|
|
12
|
-
import type { TaroStyleType } from '@tarojs/runtime'
|
|
6
|
+
import type { TaroStyleType, TaroSwiperElement, TaroEvent, TaroAny } from '@tarojs/runtime'
|
|
13
7
|
|
|
14
8
|
interface SwiperAttrs {
|
|
15
9
|
index?: number
|
|
@@ -37,6 +31,7 @@ function swiperStyle (style: TaroStyleType) {
|
|
|
37
31
|
.backgroundColor(style.backgroundColor)
|
|
38
32
|
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
39
33
|
.backgroundImageSize(style.backgroundImageSize)
|
|
34
|
+
.backgroundImagePosition(style.backgroundImagePosition)
|
|
40
35
|
.rotate(style.rotate)
|
|
41
36
|
.scale(style.scale)
|
|
42
37
|
.translate(style.translate)
|
|
@@ -75,130 +70,24 @@ function getSwiperAttributes (node: TaroSwiperElement): SwiperAttrs {
|
|
|
75
70
|
return swiperAttrs
|
|
76
71
|
}
|
|
77
72
|
|
|
78
|
-
@
|
|
79
|
-
export
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
nodeInfoMap: TaroAny = {}
|
|
83
|
-
|
|
84
|
-
@ObjectLink node: TaroSwiperElement
|
|
85
|
-
|
|
86
|
-
@Styles visibleChangeEvent () {
|
|
87
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
aboutToAppear () {
|
|
91
|
-
initComponentNodeInfo(this, this.node)
|
|
92
|
-
bindInstanceToNode(this.node, this)
|
|
93
|
-
// 绑定动画
|
|
94
|
-
bindAnimation(this.node)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
@Styles defaultEvent () {
|
|
98
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
99
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
|
|
100
|
-
const eventResult: TaroAny = res.eventResult
|
|
101
|
-
this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
|
|
102
|
-
}))
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
build() {
|
|
106
|
-
TaroComponentWrapper({ node: this.node }) {
|
|
107
|
-
Swiper(this.swiperController) {
|
|
108
|
-
ForEach(this.node.childNodes, (item: TaroElement) => {
|
|
109
|
-
createNode(item)
|
|
110
|
-
}, (item: TaroElement) => item._nid)
|
|
111
|
-
}
|
|
112
|
-
.swiperStyle(getNormalAttributes(this.node))
|
|
113
|
-
.swiperAttr(getSwiperAttributes(this.node))
|
|
114
|
-
.defaultEvent()
|
|
115
|
-
.indicatorStyle({
|
|
116
|
-
color: this.node.getAttribute('indicatorColor'),
|
|
117
|
-
selectedColor: this.node.getAttribute('indicatorActiveColor')
|
|
118
|
-
})
|
|
119
|
-
.onChange((index: number) => {
|
|
120
|
-
const event: TaroEvent = createTaroEvent('change', { detail: { current: index } }, this.node)
|
|
121
|
-
eventHandler(event, 'change', this.node)
|
|
122
|
-
})
|
|
123
|
-
.visibleChangeEvent()
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
@Extend(Flex)
|
|
129
|
-
function flexStyle (style: TaroStyleType) {
|
|
130
|
-
.id(style.id)
|
|
131
|
-
.key(style.id)
|
|
132
|
-
.padding(style.padding)
|
|
133
|
-
.margin(style.margin)
|
|
134
|
-
.width(style.width)
|
|
135
|
-
.height(style.height)
|
|
136
|
-
.constraintSize(style.constraintSize)
|
|
137
|
-
.flexGrow(style.flexGrow)
|
|
138
|
-
.flexShrink(style.flexShrink)
|
|
139
|
-
.flexBasis(style.flexBasis)
|
|
140
|
-
.alignSelf(style.alignSelf)
|
|
141
|
-
.backgroundColor(style.backgroundColor)
|
|
142
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
143
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
144
|
-
.rotate(style.rotate)
|
|
145
|
-
.scale(style.scale)
|
|
146
|
-
.translate(style.translate)
|
|
147
|
-
.transform(style.transform)
|
|
148
|
-
.borderStyle(style.borderStyle)
|
|
149
|
-
.borderWidth(style.borderWidth)
|
|
150
|
-
.borderColor(style.borderColor)
|
|
151
|
-
.borderRadius(style.borderRadius)
|
|
152
|
-
.linearGradient(style.linearGradient)
|
|
153
|
-
.zIndex(style.zIndex)
|
|
154
|
-
.opacity(style.opacity)
|
|
155
|
-
.clip(style.clip)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function getAttributes (node: TaroSwiperItemElement) {
|
|
159
|
-
const _attrs = node._attrs
|
|
160
|
-
const _nid = node._nid
|
|
161
|
-
const style = getNormalAttributes(node)
|
|
162
|
-
style.id = _attrs.itemId || _attrs.id || _nid
|
|
163
|
-
return style
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
@Component
|
|
167
|
-
export struct TaroSwiperItem {
|
|
168
|
-
nodeInfoMap: TaroAny = {}
|
|
169
|
-
|
|
170
|
-
@Styles visibleChangeEvent () {
|
|
171
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
@ObjectLink node: TaroSwiperItemElement
|
|
175
|
-
|
|
176
|
-
aboutToAppear () {
|
|
177
|
-
initComponentNodeInfo(this, this.node)
|
|
178
|
-
bindInstanceToNode(this.node, this)
|
|
179
|
-
// 绑定动画
|
|
180
|
-
bindAnimation(this.node)
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
@Styles defaultEvent () {
|
|
184
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
185
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
186
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
|
|
187
|
-
const eventResult: TaroAny = res.eventResult
|
|
188
|
-
this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
|
|
189
|
-
}))
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
build() {
|
|
193
|
-
TaroComponentWrapper({ node: this.node }) {
|
|
194
|
-
Flex(FlexManager.flexOptions(this.node)) {
|
|
195
|
-
ForEach(this.node.childNodes, (item: TaroElement) => {
|
|
196
|
-
createNode(item)
|
|
197
|
-
}, (item: TaroElement) => item._nid)
|
|
198
|
-
}
|
|
199
|
-
.flexStyle(getAttributes(this.node))
|
|
200
|
-
.defaultEvent()
|
|
201
|
-
.visibleChangeEvent()
|
|
202
|
-
}
|
|
73
|
+
@Builder
|
|
74
|
+
export default function TaroSwiper (node: TaroSwiperElement) {
|
|
75
|
+
Swiper(node.controller) {
|
|
76
|
+
createLazyChildren(node)
|
|
203
77
|
}
|
|
78
|
+
.swiperStyle(getNormalAttributes(node))
|
|
79
|
+
.swiperAttr(getSwiperAttributes(node))
|
|
80
|
+
.indicatorStyle({
|
|
81
|
+
color: node.getAttribute('indicatorColor'),
|
|
82
|
+
selectedColor: node.getAttribute('indicatorActiveColor')
|
|
83
|
+
})
|
|
84
|
+
.onChange((index: number) => {
|
|
85
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { current: index } }, node)
|
|
86
|
+
eventHandler(event, 'change', node)
|
|
87
|
+
})
|
|
88
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
89
|
+
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
90
|
+
node._nodeInfo.areaInfo = res[1]
|
|
91
|
+
}))
|
|
92
|
+
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
204
93
|
}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TaroEvent, TaroAny } from '@tarojs/runtime'
|
|
1
|
+
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
3
2
|
|
|
4
|
-
import TaroComponentWrapper from './base'
|
|
5
|
-
import { createTaroEvent } from './utils/events'
|
|
6
3
|
import { getNodeThresholds, shouldBindEvent, getNormalAttributes } from './utils/helper'
|
|
7
4
|
|
|
8
|
-
import type { TaroSwitchElement } from '
|
|
9
|
-
import type { TaroStyleType } from '@tarojs/runtime'
|
|
5
|
+
import type { TaroAny, TaroStyleType, TaroSwitchElement, TaroEvent } from '@tarojs/runtime'
|
|
10
6
|
|
|
11
7
|
interface SwitchAttrs {
|
|
12
8
|
selectedColor?: ResourceColor
|
|
@@ -28,6 +24,7 @@ function styles (style: TaroStyleType) {
|
|
|
28
24
|
.backgroundColor(style.backgroundColor)
|
|
29
25
|
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
30
26
|
.backgroundImageSize(style.backgroundImageSize)
|
|
27
|
+
.backgroundImagePosition(style.backgroundImagePosition)
|
|
31
28
|
.rotate(style.rotate)
|
|
32
29
|
.scale(style.scale)
|
|
33
30
|
.translate(style.translate)
|
|
@@ -59,55 +56,28 @@ function themeStyles(isDisabled: boolean) {
|
|
|
59
56
|
.opacity(isDisabled ? 0.4 : 1)
|
|
60
57
|
}
|
|
61
58
|
|
|
62
|
-
@
|
|
63
|
-
export default
|
|
64
|
-
|
|
59
|
+
@Builder
|
|
60
|
+
export default function TaroSwitch (node: TaroSwitchElement) {
|
|
61
|
+
Toggle({
|
|
62
|
+
type: node._attrs.type !== 'checkbox' ? ToggleType.Switch : ToggleType.Checkbox,
|
|
63
|
+
isOn: node.checked,
|
|
64
|
+
})
|
|
65
|
+
.styles(getNormalAttributes(node))
|
|
66
|
+
.attrs(getAttributes(node))
|
|
67
|
+
.themeStyles(!!node._attrs.disabled)
|
|
68
|
+
.onChange((isOn: boolean) => {
|
|
69
|
+
if (!node?._attrs.disabled) {
|
|
70
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { value: isOn } }, node)
|
|
65
71
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
initComponentNodeInfo(this, this.node)
|
|
76
|
-
bindInstanceToNode(this.node, this)
|
|
77
|
-
|
|
78
|
-
this.value = !!this.node._attrs.checked
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
@Styles defaultEvent () {
|
|
82
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
83
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
|
|
84
|
-
const eventResult: TaroAny = res.eventResult
|
|
85
|
-
this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
|
|
72
|
+
node.updateCheckedValue(isOn)
|
|
73
|
+
eventHandler(event, 'change', node)
|
|
74
|
+
} else {
|
|
75
|
+
node.updateComponent()
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
79
|
+
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
80
|
+
node._nodeInfo.areaInfo = res[1]
|
|
86
81
|
}))
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
build() {
|
|
90
|
-
TaroComponentWrapper({ node: this.node }) {
|
|
91
|
-
Toggle({
|
|
92
|
-
type: this.node._attrs.type !== 'checkbox' ? ToggleType.Switch : ToggleType.Checkbox,
|
|
93
|
-
isOn: this.value,
|
|
94
|
-
})
|
|
95
|
-
.defaultEvent()
|
|
96
|
-
.styles(getNormalAttributes(this.node))
|
|
97
|
-
.attrs(getAttributes(this.node))
|
|
98
|
-
.themeStyles(!!this.node._attrs.disabled)
|
|
99
|
-
.onChange((isOn: boolean) => {
|
|
100
|
-
if (!this.node._attrs.disabled) {
|
|
101
|
-
this.value = isOn
|
|
102
|
-
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.value } }, this.node)
|
|
103
|
-
eventHandler(event, 'change', this.node)
|
|
104
|
-
} else {
|
|
105
|
-
// FIXME 找下文档是否有强制刷新方法
|
|
106
|
-
this.value = !this.value
|
|
107
|
-
this.value = !this.value
|
|
108
|
-
}
|
|
109
|
-
})
|
|
110
|
-
.visibleChangeEvent()
|
|
111
|
-
}
|
|
112
|
-
}
|
|
82
|
+
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
113
83
|
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, NodeType } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
3
|
+
import { getButtonColor } from './button'
|
|
4
|
+
import { BUTTON_THEME_COLOR } from './utils/constant/style'
|
|
5
|
+
import { getNodeThresholds, getNormalAttributes, getFontAttributes, shouldBindEvent } from './utils/helper'
|
|
5
6
|
|
|
6
|
-
import type { TaroTextElement } from '
|
|
7
|
-
import type { TaroStyleType, TaroTextStyleType } from '@tarojs/runtime'
|
|
7
|
+
import type { TaroButtonElement, TaroElement, TaroTextElement, TaroAny, TaroTextStyleType, TaroStyleType } from '@tarojs/runtime'
|
|
8
8
|
|
|
9
9
|
@Extend(Text)
|
|
10
|
-
function
|
|
11
|
-
.id(style.id)
|
|
12
|
-
.key(style.id)
|
|
10
|
+
function textNormalStyle (style: TaroStyleType) {
|
|
13
11
|
.padding(style.padding)
|
|
14
12
|
.margin(style.margin)
|
|
15
13
|
.width(style.width)
|
|
@@ -22,6 +20,7 @@ function textStyle (style: TaroStyleType) {
|
|
|
22
20
|
.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)
|
|
@@ -32,8 +31,14 @@ function textStyle (style: TaroStyleType) {
|
|
|
32
31
|
.borderRadius(style.borderRadius)
|
|
33
32
|
.linearGradient(style.linearGradient)
|
|
34
33
|
.zIndex(style.zIndex)
|
|
35
|
-
.opacity(style.opacity)
|
|
36
34
|
.clip(style.clip)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@Extend(Text)
|
|
38
|
+
function textNormalFontStyle (style: TaroStyleType) {
|
|
39
|
+
.id(style.id)
|
|
40
|
+
.key(style.id)
|
|
41
|
+
.opacity(style.opacity)
|
|
37
42
|
.fontColor(style.color)
|
|
38
43
|
.fontSize(style.fontSize)
|
|
39
44
|
.fontWeight(style.fontWeight)
|
|
@@ -47,51 +52,42 @@ function textStyle (style: TaroStyleType) {
|
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
@Extend(Text)
|
|
50
|
-
function
|
|
55
|
+
function textSpecialFontStyle(attr: TaroTextStyleType) {
|
|
51
56
|
.textAlign(attr.textAlign)
|
|
52
57
|
.textOverflow(attr.textOverflow)
|
|
53
58
|
.maxLines(attr.maxLines)
|
|
54
59
|
.letterSpacing(attr.letterSpacing)
|
|
55
60
|
}
|
|
56
61
|
|
|
62
|
+
function getButtonFontSize (node: TaroButtonElement) {
|
|
63
|
+
const isMini = node._attrs.size === 'mini'
|
|
57
64
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
nodeInfoMap: TaroAny = {}
|
|
61
|
-
|
|
62
|
-
@Styles visibleChangeEvent () {
|
|
63
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
@ObjectLink node: TaroTextElement
|
|
67
|
-
|
|
68
|
-
aboutToAppear () {
|
|
69
|
-
initComponentNodeInfo(this, this.node)
|
|
70
|
-
bindInstanceToNode(this.node, this)
|
|
71
|
-
// 绑定动画
|
|
72
|
-
bindAnimation(this.node)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@Styles defaultEvent () {
|
|
76
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
77
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
|
|
78
|
-
const eventResult: TaroAny = res.eventResult
|
|
79
|
-
this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
|
|
80
|
-
}))
|
|
81
|
-
}
|
|
82
|
-
|
|
65
|
+
return isMini ? convertNumber2VP(26) : convertNumber2VP(36)
|
|
66
|
+
}
|
|
83
67
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
68
|
+
@Builder
|
|
69
|
+
export default function TaroText (node: TaroTextElement) {
|
|
70
|
+
if (node.nodeType === NodeType.TEXT_NODE && node.parentNode) {
|
|
71
|
+
if ((node.parentNode as TaroElement).tagName === 'BUTTON') {
|
|
72
|
+
Text(node.textContent)
|
|
73
|
+
.textNormalFontStyle(getNormalAttributes(node.parentNode as TaroElement))
|
|
74
|
+
.textSpecialFontStyle(getFontAttributes(node.parentNode as TaroElement))
|
|
75
|
+
.fontSize((node.parentNode as TaroButtonElement).hmStyle.fontSize || getButtonFontSize((node.parentNode as TaroButtonElement)))
|
|
76
|
+
.fontColor((node.parentNode as TaroButtonElement).hmStyle.color || getButtonColor(node.parentNode as TaroButtonElement, BUTTON_THEME_COLOR.get((node.parentNode as TaroButtonElement)._attrs.type).text))
|
|
77
|
+
} else {
|
|
78
|
+
Text(node.textContent)
|
|
79
|
+
.textNormalFontStyle(getNormalAttributes(node.parentNode as TaroElement))
|
|
80
|
+
.textSpecialFontStyle(getFontAttributes(node.parentNode as TaroElement))
|
|
95
81
|
}
|
|
82
|
+
} else {
|
|
83
|
+
Text(node.textContent)
|
|
84
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
85
|
+
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
86
|
+
node._nodeInfo.areaInfo = res[1]
|
|
87
|
+
}))
|
|
88
|
+
.textNormalStyle(getNormalAttributes(node))
|
|
89
|
+
.textNormalFontStyle(getNormalAttributes(node))
|
|
90
|
+
.textSpecialFontStyle(getFontAttributes(node))
|
|
91
|
+
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
96
92
|
}
|
|
97
93
|
}
|
|
@@ -1,15 +1,8 @@
|
|
|
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 { createTaroEvent } from './utils/events'
|
|
9
|
-
import { getNodeThresholds, getNormalAttributes, getFontAttributes, parseStyles, shouldBindEvent, bindAnimation } from './utils/helper'
|
|
3
|
+
import { getNodeThresholds, getNormalAttributes, getFontAttributes, shouldBindEvent, parseStyles } from './utils/helper'
|
|
10
4
|
|
|
11
|
-
import type { TaroTextAreaElement } from '
|
|
12
|
-
import type { TaroStyleType, TaroTextStyleType } from '@tarojs/runtime'
|
|
5
|
+
import type { TaroAny, TaroStyleType, TaroTextStyleType, TaroTextAreaElement, TaroEvent } from '@tarojs/runtime'
|
|
13
6
|
|
|
14
7
|
@Extend(TextArea)
|
|
15
8
|
function textStyle (style: TaroStyleType) {
|
|
@@ -27,6 +20,7 @@ function textStyle (style: TaroStyleType) {
|
|
|
27
20
|
.backgroundColor(style.backgroundColor)
|
|
28
21
|
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
29
22
|
.backgroundImageSize(style.backgroundImageSize)
|
|
23
|
+
.backgroundImagePosition(style.backgroundImagePosition)
|
|
30
24
|
.rotate(style.rotate)
|
|
31
25
|
.scale(style.scale)
|
|
32
26
|
.translate(style.translate)
|
|
@@ -52,118 +46,56 @@ function textAttr(attr: TaroTextStyleType) {
|
|
|
52
46
|
.maxLines(attr.maxLines)
|
|
53
47
|
}
|
|
54
48
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
nodeInfoMap: TaroAny = {}
|
|
58
|
-
|
|
59
|
-
@State text: string = ''
|
|
60
|
-
|
|
61
|
-
@ObjectLink node: TaroTextAreaElement
|
|
62
|
-
|
|
63
|
-
controller: TextAreaController = new TextAreaController()
|
|
49
|
+
function getPlaceholderColor (node: TaroTextAreaElement): string {
|
|
50
|
+
const placeholderStyle: string = node._attrs.placeholderStyle || ''
|
|
64
51
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
_height: number = 0
|
|
52
|
+
return parseStyles(placeholderStyle)?.color
|
|
53
|
+
}
|
|
68
54
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this.onKeyboardHeightChange(height)
|
|
73
|
-
this._height = height
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
55
|
+
@Component
|
|
56
|
+
export default struct TaroTextArea {
|
|
57
|
+
@State value: string = ''
|
|
77
58
|
|
|
78
|
-
|
|
79
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
80
|
-
}
|
|
59
|
+
node: TaroTextAreaElement | null = null
|
|
81
60
|
|
|
82
61
|
aboutToAppear () {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
// 绑定动画
|
|
87
|
-
bindAnimation(this.node)
|
|
88
|
-
|
|
89
|
-
this.text = this.node._attrs.value || ''
|
|
90
|
-
|
|
91
|
-
try {
|
|
92
|
-
Current.contextPromise
|
|
93
|
-
.then((context: common.BaseContext) => {
|
|
94
|
-
return window.getLastWindow(context, (err, windowClass: window.Window) => {
|
|
95
|
-
const errCode: number = err.code;
|
|
96
|
-
if (errCode) {
|
|
97
|
-
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err))
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
this.windowClass = windowClass
|
|
101
|
-
windowClass.on('keyboardHeightChange', this.heightChange)
|
|
102
|
-
})
|
|
103
|
-
})
|
|
104
|
-
} catch (exception) {
|
|
105
|
-
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception))
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
aboutToDisappear () {
|
|
110
|
-
if (this.windowClass) {
|
|
111
|
-
try {
|
|
112
|
-
this.windowClass.off('keyboardHeightChange', this.heightChange)
|
|
113
|
-
} catch (err) {
|
|
114
|
-
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err))
|
|
115
|
-
}
|
|
62
|
+
if (this.node) {
|
|
63
|
+
this.value = this.node.value
|
|
64
|
+
this.node._instance = this
|
|
116
65
|
}
|
|
117
66
|
}
|
|
118
67
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
getPlaceholderColor (node: TaroTextAreaElement): string {
|
|
125
|
-
const placeholderStyle: string = node._attrs.placeholderStyle || ''
|
|
126
|
-
|
|
127
|
-
return parseStyles(placeholderStyle)?.color
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
getText (): string {
|
|
131
|
-
return isUndefined(this.node._attrs.value) ? this.text : this.node._attrs.value
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
@Styles defaultEvent () {
|
|
135
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
136
|
-
.onBlur(() => {
|
|
137
|
-
const event: TaroEvent = createTaroEvent('blur', { detail: { value: this.text } }, this.node)
|
|
138
|
-
eventHandler(event, 'blur', this.node)
|
|
139
|
-
})
|
|
140
|
-
.onFocus(() => {
|
|
141
|
-
const event: TaroEvent = createTaroEvent('focus', { detail: { value: this.text, height: this._height } }, this.node)
|
|
142
|
-
eventHandler(event, 'focus', this.node)
|
|
143
|
-
})
|
|
144
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
|
|
145
|
-
const eventResult: TaroAny = res.eventResult
|
|
146
|
-
this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
|
|
147
|
-
}))
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
build() {
|
|
151
|
-
TaroComponentWrapper({ node: this.node }) {
|
|
152
|
-
TextArea({ text: this.getText(), placeholder: this.node._attrs?.placeholder || '', controller: this.controller })
|
|
153
|
-
.focusable(true)
|
|
68
|
+
build () {
|
|
69
|
+
if (this.node) {
|
|
70
|
+
TextArea({ text: this.value, placeholder: this.node._attrs?.placeholder || '', controller: this.node.controller })
|
|
154
71
|
.key(this.node._nid)
|
|
155
|
-
.
|
|
156
|
-
.
|
|
72
|
+
.maxLength(Number(this.node._attrs?.maxlength) || null)
|
|
73
|
+
.placeholderColor(getPlaceholderColor(this.node))
|
|
157
74
|
.textStyle(getNormalAttributes(this.node))
|
|
158
75
|
.textAttr(getFontAttributes(this.node))
|
|
159
76
|
.onChange((value: string) => {
|
|
160
77
|
const event: TaroEvent = createTaroEvent('input', { detail: { value } }, this.node)
|
|
78
|
+
|
|
79
|
+
this.value = value
|
|
80
|
+
this.node?.updateFormWidgetValue(value)
|
|
161
81
|
eventHandler(event, 'input', this.node)
|
|
162
|
-
this.text = value
|
|
163
82
|
})
|
|
164
|
-
.
|
|
83
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
84
|
+
.onBlur(() => {
|
|
85
|
+
const event: TaroEvent = createTaroEvent('blur', { detail: { value: this.value } }, this.node)
|
|
86
|
+
eventHandler(event, 'blur', this.node)
|
|
87
|
+
})
|
|
88
|
+
.onFocus(() => {
|
|
89
|
+
const event: TaroEvent = createTaroEvent('focus', { detail: { value: this.value, height: this.node?._height } }, this.node)
|
|
90
|
+
|
|
91
|
+
eventHandler(event, 'focus', this.node)
|
|
92
|
+
})
|
|
93
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
94
|
+
if (this.node) {
|
|
95
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
96
|
+
}
|
|
97
|
+
}))
|
|
98
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
165
99
|
}
|
|
166
100
|
}
|
|
167
101
|
}
|
|
168
|
-
|
|
169
|
-
export default TaroTextArea
|
|
@@ -10,30 +10,33 @@ export class TEXT_DEFAULT_STYLE {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
interface IBUTTON_THEME_COLOR {
|
|
13
|
-
text:
|
|
13
|
+
text: Color
|
|
14
14
|
background: string
|
|
15
|
+
plainText: string | Color
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export class BUTTON_THEME_COLOR {
|
|
18
19
|
static get (type: string): IBUTTON_THEME_COLOR {
|
|
19
20
|
switch (type) {
|
|
20
21
|
case 'primary': return {
|
|
21
|
-
text:
|
|
22
|
+
text: Color.White,
|
|
22
23
|
background: '#1aad19',
|
|
24
|
+
plainText: '#1aad19'
|
|
23
25
|
}
|
|
24
26
|
case 'warn': return {
|
|
25
|
-
text:
|
|
26
|
-
background: '#e64340'
|
|
27
|
+
text: Color.White,
|
|
28
|
+
background: '#e64340',
|
|
29
|
+
plainText: '#e64340'
|
|
27
30
|
}
|
|
28
31
|
default: return {
|
|
29
|
-
text:
|
|
32
|
+
text: Color.Black,
|
|
30
33
|
background: '#f7f7f7',
|
|
34
|
+
plainText: Color.Black
|
|
31
35
|
}
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
|
|
37
40
|
export class INPUT_TYPE_MAP {
|
|
38
41
|
static get (type: string) {
|
|
39
42
|
switch (type) {
|