@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27 → 4.0.0-alpha.2
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/memory.ts +10 -3
- 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/index.ts +2 -0
- 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 +68 -0
- package/dist/apis/media/{video.ts → video/index.ts} +13 -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 +7 -6
- 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 +19 -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 +7 -2
- package/dist/apis/wxml/nodesRef.ts +2 -2
- package/dist/apis/wxml/selectorQuery.ts +3 -4
- package/dist/components-harmony-ets/button.ets +97 -85
- package/dist/components-harmony-ets/checkbox.ets +68 -142
- package/dist/components-harmony-ets/form.ets +31 -140
- package/dist/components-harmony-ets/icon.ets +60 -75
- package/dist/components-harmony-ets/image.ets +14 -69
- package/dist/components-harmony-ets/innerHtml.ets +6 -74
- package/dist/components-harmony-ets/input.ets +62 -152
- package/dist/components-harmony-ets/label.ets +63 -96
- package/dist/components-harmony-ets/picker.ets +168 -198
- package/dist/components-harmony-ets/radio.ets +69 -146
- package/dist/components-harmony-ets/richText.ets +14 -70
- package/dist/components-harmony-ets/scrollView.ets +84 -156
- package/dist/components-harmony-ets/slider.ets +40 -88
- package/dist/components-harmony-ets/style.ets +154 -0
- package/dist/components-harmony-ets/swiper.ets +25 -166
- package/dist/components-harmony-ets/switch.ets +29 -72
- package/dist/components-harmony-ets/text.ets +37 -68
- package/dist/components-harmony-ets/textArea.ets +44 -132
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -11
- package/dist/components-harmony-ets/utils/constant/style.ets +9 -6
- package/dist/components-harmony-ets/utils/flexManager.ets +45 -92
- package/dist/components-harmony-ets/utils/helper.ets +4 -64
- package/dist/components-harmony-ets/utils/index.ts +1 -1
- package/dist/components-harmony-ets/utils/styles.ets +62 -27
- package/dist/components-harmony-ets/video.ets +63 -122
- package/dist/components-harmony-ets/view.ets +52 -69
- package/dist/components-harmony-ets/webView.ets +50 -0
- package/dist/index.js +135 -8
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/getComputedStyle.ts +1 -1
- package/dist/runtime-ets/bom/window.ts +2 -2
- 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 +31 -7
- package/dist/runtime-ets/dom/dataSource.ts +64 -0
- package/dist/runtime-ets/dom/document.ts +35 -47
- package/dist/runtime-ets/dom/element/element.ts +163 -0
- package/dist/runtime-ets/dom/element/form.ts +406 -0
- package/dist/runtime-ets/dom/element/index.ts +92 -0
- package/dist/runtime-ets/dom/element/normal.ts +76 -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/element/webView.ts +61 -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 +87 -44
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +624 -0
- package/dist/runtime-ets/dom/stylesheet/index.ts +263 -288
- package/dist/runtime-ets/dom/stylesheet/type.ts +47 -11
- package/dist/runtime-ets/dom/stylesheet/util.ts +129 -7
- package/dist/runtime-ets/index.ts +1 -3
- package/dist/runtime-ets/interface/event.ts +2 -1
- package/dist/runtime-ets/utils/index.ts +18 -8
- package/dist/runtime-ets/utils/info.ts +22 -48
- package/dist/runtime-framework/react/app.ts +14 -27
- package/dist/runtime-framework/react/hooks.ts +3 -3
- package/dist/runtime-framework/react/index.ts +1 -0
- package/dist/runtime-framework/react/native-page.ts +344 -0
- package/dist/runtime-framework/react/page.ts +4 -11
- package/dist/runtime-framework/solid/hooks.ts +3 -3
- package/dist/runtime-framework/solid/page.ts +0 -6
- package/dist/runtime-utils.js +1216 -349
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +1216 -349
- package/dist/runtime.js.map +1 -1
- package/package.json +12 -11
- package/static/media/cancel.svg +1 -0
- package/static/media/circle.svg +1 -0
- package/static/media/clear.svg +1 -0
- package/static/media/download.svg +1 -0
- package/static/media/info.svg +1 -0
- package/static/media/info_circle.svg +1 -0
- package/static/media/search.svg +1 -0
- package/static/media/success.svg +1 -0
- package/static/media/success_no_circle.svg +1 -0
- package/static/media/taro_arrow_left.svg +1 -0
- package/static/media/taro_home.svg +1 -0
- package/static/media/waiting.svg +1 -0
- package/static/media/warn.svg +1 -0
- package/types/runtime.d.ts +6 -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/dist/runtime-ets/utils/bind.ts +0 -35
- package/types/api.d.ts +0 -4
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createTaroEvent, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { createTaroEvent } from './utils/events'
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { createLazyChildren } from './render'
|
|
6
5
|
import { FlexManager } from './utils/FlexManager'
|
|
7
|
-
import { shouldBindEvent,
|
|
6
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
8
7
|
|
|
9
|
-
import type { TaroCheckboxElement, TaroCheckboxGroupElement
|
|
10
|
-
import type { TaroStyleType } from '@tarojs/runtime'
|
|
8
|
+
import type { TaroAny, TaroEvent, TaroCheckboxElement, TaroCheckboxGroupElement } from '@tarojs/runtime'
|
|
11
9
|
|
|
12
10
|
interface CheckboxOptions {
|
|
13
11
|
name?: string
|
|
@@ -17,36 +15,6 @@ interface CheckboxAttrs {
|
|
|
17
15
|
selectedColor?: ResourceColor
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
@Extend(Checkbox)
|
|
21
|
-
function checkboxStyle (style: TaroStyleType) {
|
|
22
|
-
.id(style.id)
|
|
23
|
-
.key(style.id)
|
|
24
|
-
.padding(style.padding)
|
|
25
|
-
.margin(style.margin)
|
|
26
|
-
.width(style.width)
|
|
27
|
-
.height(style.height)
|
|
28
|
-
.constraintSize(style.constraintSize)
|
|
29
|
-
.flexGrow(style.flexGrow)
|
|
30
|
-
.flexShrink(style.flexShrink)
|
|
31
|
-
.flexBasis(style.flexBasis)
|
|
32
|
-
.alignSelf(style.alignSelf)
|
|
33
|
-
.backgroundColor(style.backgroundColor)
|
|
34
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
35
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
36
|
-
.rotate(style.rotate)
|
|
37
|
-
.scale(style.scale)
|
|
38
|
-
.translate(style.translate)
|
|
39
|
-
.transform(style.transform)
|
|
40
|
-
.borderStyle(style.borderStyle)
|
|
41
|
-
.borderWidth(style.borderWidth)
|
|
42
|
-
.borderColor(style.borderColor)
|
|
43
|
-
.borderRadius(style.borderRadius)
|
|
44
|
-
.linearGradient(style.linearGradient)
|
|
45
|
-
.zIndex(style.zIndex)
|
|
46
|
-
.opacity(style.opacity)
|
|
47
|
-
.clip(style.clip)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
18
|
@Extend(Checkbox)
|
|
51
19
|
function checkboxAttr(attr: CheckboxAttrs) {
|
|
52
20
|
.selectedColor(attr.selectedColor)
|
|
@@ -60,160 +28,118 @@ function getAttributes (node: TaroCheckboxElement): CheckboxAttrs {
|
|
|
60
28
|
}
|
|
61
29
|
|
|
62
30
|
function getOptions (node: TaroCheckboxElement): CheckboxOptions {
|
|
63
|
-
const value: string = node._attrs.value
|
|
64
31
|
return {
|
|
65
|
-
name: value || node.textContent
|
|
32
|
+
name: node.value as string || node.textContent
|
|
66
33
|
}
|
|
67
34
|
}
|
|
68
35
|
|
|
69
|
-
|
|
70
36
|
@Component
|
|
71
37
|
export struct TaroCheckbox {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
@ObjectLink node: TaroCheckboxElement
|
|
75
|
-
|
|
76
|
-
@State checked: boolean = false
|
|
77
|
-
|
|
78
|
-
@Styles visibleChangeEvent () {
|
|
79
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
80
|
-
}
|
|
38
|
+
node: TaroCheckboxElement | null = null
|
|
81
39
|
|
|
82
40
|
aboutToAppear () {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
@Styles defaultEvent () {
|
|
90
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
91
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
|
|
92
|
-
const eventResult: TaroAny = res.eventResult
|
|
93
|
-
this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
|
|
94
|
-
}))
|
|
41
|
+
if (this.node && !this.node._isInit) {
|
|
42
|
+
this.node._isInit = true
|
|
43
|
+
this.node._reset = this.node.checked || false
|
|
44
|
+
}
|
|
95
45
|
}
|
|
96
46
|
|
|
97
|
-
build() {
|
|
98
|
-
|
|
47
|
+
build () {
|
|
48
|
+
if (this.node) {
|
|
99
49
|
Stack() {
|
|
100
50
|
Row() {
|
|
101
51
|
Checkbox(getOptions(this.node))
|
|
102
|
-
.
|
|
103
|
-
.checkboxStyle(getNormalAttributes(this.node))
|
|
52
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
104
53
|
.checkboxAttr(getAttributes(this.node))
|
|
105
54
|
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
106
|
-
.select(this.checked)
|
|
55
|
+
.select(this.node.checked)
|
|
107
56
|
.onChange((value: boolean) => {
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
57
|
+
if (this.node) {
|
|
58
|
+
if (!!this.node?._attrs.disabled) {
|
|
59
|
+
this.node.updateComponent()
|
|
60
|
+
} else {
|
|
61
|
+
this.node.updateCheckedValue(value)
|
|
62
|
+
|
|
63
|
+
if (value) {
|
|
64
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
|
|
65
|
+
eventHandler(event, 'change', this.node)
|
|
66
|
+
}
|
|
117
67
|
}
|
|
118
68
|
}
|
|
119
69
|
})
|
|
120
|
-
.
|
|
70
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
71
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
72
|
+
if (this.node) {
|
|
73
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
74
|
+
}
|
|
75
|
+
}))
|
|
76
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
121
77
|
Text(this.node.textContent)
|
|
122
78
|
.textAlign(TextAlign.Center)
|
|
123
79
|
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
124
80
|
}
|
|
125
81
|
.onClick(() => {
|
|
126
|
-
this.
|
|
82
|
+
if (this.node) {
|
|
83
|
+
if (!this.node?._attrs.disabled) {
|
|
84
|
+
this.node.checked = !this.node.checked
|
|
85
|
+
}
|
|
86
|
+
}
|
|
127
87
|
})
|
|
128
88
|
}
|
|
129
89
|
}
|
|
130
90
|
}
|
|
131
91
|
}
|
|
132
92
|
|
|
133
|
-
|
|
134
|
-
@Extend(Flex)
|
|
135
|
-
function checkboxGroupAttrs (style: TaroStyleType) {
|
|
136
|
-
.id(style.id)
|
|
137
|
-
.key(style.id)
|
|
138
|
-
.padding(style.padding)
|
|
139
|
-
.margin(style.margin)
|
|
140
|
-
.width(style.width)
|
|
141
|
-
.height(style.height)
|
|
142
|
-
.constraintSize(style.constraintSize)
|
|
143
|
-
.flexGrow(style.flexGrow)
|
|
144
|
-
.flexShrink(style.flexShrink)
|
|
145
|
-
.flexBasis(style.flexBasis)
|
|
146
|
-
.alignSelf(style.alignSelf)
|
|
147
|
-
.backgroundColor(style.backgroundColor)
|
|
148
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
149
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
150
|
-
.rotate(style.rotate)
|
|
151
|
-
.scale(style.scale)
|
|
152
|
-
.translate(style.translate)
|
|
153
|
-
.transform(style.transform)
|
|
154
|
-
.borderStyle(style.borderStyle)
|
|
155
|
-
.borderWidth(style.borderWidth)
|
|
156
|
-
.borderColor(style.borderColor)
|
|
157
|
-
.borderRadius(style.borderRadius)
|
|
158
|
-
.linearGradient(style.linearGradient)
|
|
159
|
-
.zIndex(style.zIndex)
|
|
160
|
-
.opacity(style.opacity)
|
|
161
|
-
.clip(style.clip)
|
|
162
|
-
}
|
|
163
|
-
|
|
164
93
|
interface ChangeEventDetail { value: string[] }
|
|
165
94
|
|
|
166
95
|
@Component
|
|
167
96
|
export struct TaroCheckboxGroup {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
@ObjectLink node: TaroCheckboxGroupElement
|
|
97
|
+
node: TaroCheckboxGroupElement | null = null
|
|
171
98
|
|
|
172
99
|
@Styles visibleChangeEvent () {
|
|
173
100
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
174
101
|
}
|
|
175
102
|
|
|
176
103
|
aboutToAppear () {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
})
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// Element使用的获取值方法
|
|
188
|
-
getValues () {
|
|
189
|
-
const childList = this.node.getElementsByTagName<TaroCheckboxElement>('CHECKBOX')
|
|
190
|
-
const result: string[] = []
|
|
191
|
-
childList.forEach(element => {
|
|
192
|
-
if (element._instance.checked) {
|
|
193
|
-
result.push(element._attrs.value)
|
|
194
|
-
}
|
|
195
|
-
})
|
|
196
|
-
return result
|
|
104
|
+
if (this.node) {
|
|
105
|
+
// 阻止事件冒泡传递上去
|
|
106
|
+
this.node.addEventListener('change', (e: TaroEvent<ChangeEventDetail>) => {
|
|
107
|
+
e.stopPropagation()
|
|
108
|
+
e.detail.value = (this.node as TaroCheckboxGroupElement).value
|
|
109
|
+
})
|
|
110
|
+
}
|
|
197
111
|
}
|
|
198
112
|
|
|
199
113
|
@Styles defaultEvent () {
|
|
200
114
|
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
201
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
|
|
202
|
-
|
|
203
|
-
|
|
115
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
116
|
+
if (this.node) {
|
|
117
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
118
|
+
}
|
|
204
119
|
}))
|
|
205
120
|
}
|
|
206
121
|
|
|
207
122
|
build() {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
123
|
+
if (this.node) {
|
|
124
|
+
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
125
|
+
Row() {
|
|
126
|
+
createLazyChildren(this.node)
|
|
127
|
+
}
|
|
128
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
129
|
+
.defaultEvent()
|
|
130
|
+
.visibleChangeEvent()
|
|
131
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
132
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
133
|
+
} else {
|
|
134
|
+
Column() {
|
|
135
|
+
createLazyChildren(this.node)
|
|
136
|
+
}
|
|
137
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
138
|
+
.defaultEvent()
|
|
139
|
+
.visibleChangeEvent()
|
|
140
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
141
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
213
142
|
}
|
|
214
|
-
.checkboxGroupAttrs(getNormalAttributes(this.node))
|
|
215
|
-
.defaultEvent()
|
|
216
|
-
.visibleChangeEvent()
|
|
217
143
|
}
|
|
218
144
|
}
|
|
219
145
|
}
|
|
@@ -1,149 +1,40 @@
|
|
|
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
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { createLazyChildren } from './render'
|
|
9
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
10
6
|
import { FlexManager } from './utils/FlexManager'
|
|
11
|
-
import {
|
|
12
|
-
import { getNormalAttributes, shouldBindEvent, getNodeThresholds, bindAnimation } from './utils/helper'
|
|
7
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
13
8
|
|
|
14
|
-
import type {
|
|
15
|
-
TaroSliderElement,
|
|
16
|
-
TaroSwitchElement,
|
|
17
|
-
TaroPickerElement
|
|
18
|
-
} from './element'
|
|
19
|
-
import type { TaroStyleType } from '@tarojs/runtime'
|
|
9
|
+
import type { TaroAny, TaroFormElement } from '@tarojs/runtime'
|
|
20
10
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
.flexShrink(style.flexShrink)
|
|
33
|
-
.flexBasis(style.flexBasis)
|
|
34
|
-
.alignSelf(style.alignSelf)
|
|
35
|
-
.backgroundColor(style.backgroundColor)
|
|
36
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
37
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
38
|
-
.rotate(style.rotate)
|
|
39
|
-
.scale(style.scale)
|
|
40
|
-
.translate(style.translate)
|
|
41
|
-
.transform(style.transform)
|
|
42
|
-
.borderStyle(style.borderStyle)
|
|
43
|
-
.borderWidth(style.borderWidth)
|
|
44
|
-
.borderColor(style.borderColor)
|
|
45
|
-
.borderRadius(style.borderRadius)
|
|
46
|
-
.linearGradient(style.linearGradient)
|
|
47
|
-
.zIndex(style.zIndex)
|
|
48
|
-
.opacity(style.opacity)
|
|
49
|
-
.clip(style.clip)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@Component
|
|
53
|
-
export default struct TaroForm {
|
|
54
|
-
nodeInfoMap: TaroAny = {}
|
|
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]
|
|
11
|
+
@Builder
|
|
12
|
+
export default function TaroForm (node: TaroFormElement) {
|
|
13
|
+
if (FlexManager.isFlexNode(node) && FlexManager.flexOptions(node).direction !== FlexDirection.Column) {
|
|
14
|
+
Row() {
|
|
15
|
+
createLazyChildren(node)
|
|
16
|
+
}
|
|
17
|
+
.attributeModifier(commonStyleModify.setNode(node))
|
|
18
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
19
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
20
|
+
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
21
|
+
node._nodeInfo.areaInfo = res[1]
|
|
134
22
|
}))
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
createNode(item)
|
|
142
|
-
}, (item: TaroElement) => item._nid)
|
|
143
|
-
}
|
|
144
|
-
.attrs(getNormalAttributes(this.node))
|
|
145
|
-
.defaultEvent()
|
|
146
|
-
.visibleChangeEvent()
|
|
23
|
+
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
24
|
+
.alignItems(FlexManager.flexOptions(node).alignItems as VerticalAlign)
|
|
25
|
+
.justifyContent(FlexManager.flexOptions(node).justifyContent)
|
|
26
|
+
} else {
|
|
27
|
+
Column() {
|
|
28
|
+
createLazyChildren(node)
|
|
147
29
|
}
|
|
30
|
+
.attributeModifier(commonStyleModify.setNode(node))
|
|
31
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
32
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
33
|
+
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
34
|
+
node._nodeInfo.areaInfo = res[1]
|
|
35
|
+
}))
|
|
36
|
+
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
37
|
+
.alignItems(FlexManager.flexOptions(node).alignItems as HorizontalAlign)
|
|
38
|
+
.justifyContent(FlexManager.flexOptions(node).justifyContent)
|
|
148
39
|
}
|
|
149
40
|
}
|
|
@@ -1,84 +1,69 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, convertNumber2PX } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { getNormalAttributes, shouldBindEvent, getNodeThresholds, bindAnimation } from './utils/helper'
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
6
5
|
|
|
7
|
-
import type { TaroIconElement } from '
|
|
8
|
-
import type { TaroStyleType } from '@tarojs/runtime'
|
|
6
|
+
import type { TaroIconElement, TaroAny } from '@tarojs/runtime'
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
.
|
|
14
|
-
.
|
|
15
|
-
.
|
|
16
|
-
.
|
|
17
|
-
.
|
|
18
|
-
.
|
|
19
|
-
.
|
|
20
|
-
.
|
|
21
|
-
.
|
|
22
|
-
.flexBasis(style.flexBasis)
|
|
23
|
-
.alignSelf(style.alignSelf)
|
|
24
|
-
.backgroundColor(style.backgroundColor)
|
|
25
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
26
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
27
|
-
.rotate(style.rotate)
|
|
28
|
-
.scale(style.scale)
|
|
29
|
-
.translate(style.translate)
|
|
30
|
-
.transform(style.transform)
|
|
31
|
-
.borderStyle(style.borderStyle)
|
|
32
|
-
.borderWidth(style.borderWidth)
|
|
33
|
-
.borderColor(style.borderColor)
|
|
34
|
-
.borderRadius(style.borderRadius)
|
|
35
|
-
.linearGradient(style.linearGradient)
|
|
36
|
-
.zIndex(style.zIndex)
|
|
37
|
-
.opacity(style.opacity)
|
|
38
|
-
.clip(style.clip)
|
|
8
|
+
const ICON_COLOR_MAP: TaroAny = {
|
|
9
|
+
success: Color.Green,
|
|
10
|
+
success_no_circle: Color.Green,
|
|
11
|
+
info: Color.Blue,
|
|
12
|
+
warn: Color.Red,
|
|
13
|
+
waiting: Color.Blue,
|
|
14
|
+
cancel: Color.Red,
|
|
15
|
+
download: Color.Gray,
|
|
16
|
+
search: Color.Gray,
|
|
17
|
+
clear: Color.Gray,
|
|
18
|
+
info_circle: Color.Blue,
|
|
19
|
+
circle: Color.Gray
|
|
39
20
|
}
|
|
40
21
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
22
|
+
function getIconData (node: TaroIconElement): Resource | null {
|
|
23
|
+
switch (node._attrs.type) {
|
|
24
|
+
case 'success':
|
|
25
|
+
return $r('app.media.success')
|
|
26
|
+
case 'success_no_circle':
|
|
27
|
+
return $r('app.media.success_no_circle')
|
|
28
|
+
case 'info':
|
|
29
|
+
return $r('app.media.info')
|
|
30
|
+
case 'warn':
|
|
31
|
+
return $r('app.media.warn')
|
|
32
|
+
case 'waiting':
|
|
33
|
+
return $r('app.media.waiting')
|
|
34
|
+
case 'cancel':
|
|
35
|
+
return $r('app.media.cancel')
|
|
36
|
+
case 'download':
|
|
37
|
+
return $r('app.media.download')
|
|
38
|
+
case 'search':
|
|
39
|
+
return $r('app.media.search')
|
|
40
|
+
case 'clear':
|
|
41
|
+
return $r('app.media.clear')
|
|
42
|
+
case 'info_circle':
|
|
43
|
+
return $r('app.media.info_circle')
|
|
44
|
+
case 'circle':
|
|
45
|
+
return $r('app.media.circle')
|
|
46
|
+
default:
|
|
47
|
+
return null
|
|
56
48
|
}
|
|
49
|
+
}
|
|
57
50
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
51
|
+
@Builder
|
|
52
|
+
export default function TaroIcon (node: TaroIconElement) {
|
|
53
|
+
Image(getIconData(node))
|
|
54
|
+
.objectFit(ImageFit.Contain)
|
|
55
|
+
.fillColor(node._attrs.color || ICON_COLOR_MAP[node._attrs.type] || Color.Black)
|
|
56
|
+
.attributeModifier(commonStyleModify.setNode(node))
|
|
57
|
+
.size({
|
|
58
|
+
width: convertNumber2VP(Number(node._attrs.size) || 23),
|
|
59
|
+
height: convertNumber2VP(Number(node._attrs.size) || 23),
|
|
60
|
+
})
|
|
61
|
+
.width(getNormalAttributes(node).width || convertNumber2PX(23))
|
|
62
|
+
.height(getNormalAttributes(node).height || convertNumber2PX(23))
|
|
63
|
+
.onComplete(e => eventHandler(e, 'complete', node))
|
|
64
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
65
|
+
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
66
|
+
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
67
|
+
node._nodeInfo.areaInfo = res[1]
|
|
63
68
|
}))
|
|
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
69
|
}
|