@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27 → 4.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +74 -21
- 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 +27 -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 +17 -9
- 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 +3 -8
- package/dist/apis/index.ts +27 -17
- 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} +4 -3
- 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 +158 -88
- package/dist/apis/ui/{animation.ts → animation/animation.ts} +73 -31
- package/dist/apis/ui/animation/index.ts +7 -0
- package/dist/apis/ui/background.ts +4 -19
- 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 +45 -59
- 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 +10 -4
- package/dist/apis/{page → ui/scroll}/index.ts +32 -27
- package/dist/apis/ui/sticky.ts +4 -0
- package/dist/apis/{tabbar/index.ts → ui/tab-bar.ts} +6 -8
- package/dist/apis/ui/window.ts +20 -0
- package/dist/apis/utils/handler.ts +4 -4
- package/dist/apis/utils/index.ts +1 -1
- package/dist/apis/worker/index.ts +4 -0
- package/dist/apis/wxml/IntersectionObserver.ts +24 -25
- package/dist/apis/wxml/index.ts +7 -2
- package/dist/apis/wxml/nodesRef.ts +2 -2
- package/dist/apis/wxml/selectorQuery.ts +29 -17
- package/dist/components-harmony-ets/button.ets +106 -80
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +82 -148
- package/dist/components-harmony-ets/form.ets +45 -132
- package/dist/components-harmony-ets/icon.ets +66 -69
- package/dist/components-harmony-ets/image.ets +26 -61
- package/dist/components-harmony-ets/index.ets +92 -0
- package/dist/components-harmony-ets/innerHtml.ets +7 -70
- package/dist/components-harmony-ets/input.ets +60 -146
- package/dist/components-harmony-ets/label.ets +86 -92
- package/dist/components-harmony-ets/listView.ets +26 -0
- package/dist/components-harmony-ets/movableArea.ets +124 -0
- package/dist/components-harmony-ets/movableView.ets +93 -0
- package/dist/components-harmony-ets/navigationBar.ets +65 -0
- package/dist/components-harmony-ets/pageMeta.ets +94 -0
- package/dist/components-harmony-ets/picker.ets +172 -198
- package/dist/components-harmony-ets/progress.ets +52 -0
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +85 -155
- package/dist/components-harmony-ets/richText.ets +15 -87
- package/dist/components-harmony-ets/scrollList.ets +94 -0
- package/dist/components-harmony-ets/scrollView.ets +81 -149
- package/dist/components-harmony-ets/slider.ets +47 -94
- package/dist/components-harmony-ets/stickySection.ets +42 -0
- package/dist/components-harmony-ets/style.ets +396 -0
- package/dist/components-harmony-ets/swiper.ets +51 -151
- package/dist/components-harmony-ets/switch.ets +35 -76
- package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
- package/dist/components-harmony-ets/text.ets +131 -76
- package/dist/components-harmony-ets/textArea.ets +64 -140
- package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +4 -13
- package/dist/components-harmony-ets/utils/constant/style.ets +9 -6
- package/dist/components-harmony-ets/utils/flexManager.ets +68 -85
- package/dist/components-harmony-ets/utils/helper.ets +18 -65
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
- package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
- package/dist/components-harmony-ets/utils/index.ts +55 -51
- package/dist/components-harmony-ets/utils/styles.ets +177 -65
- package/dist/components-harmony-ets/video.ets +70 -116
- package/dist/components-harmony-ets/view.ets +58 -64
- package/dist/components-harmony-ets/webView.ets +56 -0
- package/dist/index.d.ts +152 -0
- package/dist/index.js +230 -60
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/document.ts +6 -4
- package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
- package/dist/runtime-ets/bom/window.ts +9 -2
- package/dist/runtime-ets/current.ts +3 -0
- package/dist/runtime-ets/dom/bind.ts +96 -0
- package/dist/runtime-ets/dom/class-list.ts +4 -6
- package/dist/runtime-ets/dom/comment.ts +1 -2
- package/dist/runtime-ets/dom/cssNesting.ts +409 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +30 -20
- package/dist/runtime-ets/dom/dataSource.ts +64 -0
- package/dist/runtime-ets/dom/document.ts +36 -51
- package/dist/runtime-ets/dom/element/canvas.ts +136 -0
- package/dist/runtime-ets/dom/element/element.ts +439 -0
- package/dist/runtime-ets/dom/element/form.ts +403 -0
- package/dist/runtime-ets/dom/element/index.ts +120 -0
- package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
- package/dist/runtime-ets/dom/element/movableView.ts +242 -0
- package/dist/runtime-ets/dom/element/normal.ts +103 -0
- package/dist/runtime-ets/dom/element/progress.ts +11 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +15 -0
- package/dist/runtime-ets/dom/element/text.ts +10 -0
- package/dist/runtime-ets/dom/element/video.ts +50 -0
- package/dist/runtime-ets/dom/element/webView.ts +68 -0
- package/dist/runtime-ets/dom/event.ts +26 -5
- package/dist/runtime-ets/dom/eventTarget.ts +3 -3
- package/dist/runtime-ets/dom/node.ts +114 -49
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +805 -0
- package/dist/runtime-ets/dom/stylesheet/index.ts +122 -429
- package/dist/runtime-ets/dom/stylesheet/type.ts +93 -17
- package/dist/runtime-ets/dom/stylesheet/util.ts +145 -17
- package/dist/runtime-ets/index.ts +2 -3
- package/dist/runtime-ets/interface/event.ts +3 -2
- package/dist/runtime-ets/utils/index.ts +87 -17
- package/dist/runtime-ets/utils/info.ts +21 -47
- package/dist/runtime-framework/react/app.ts +20 -28
- package/dist/runtime-framework/react/hooks.ts +3 -4
- package/dist/runtime-framework/react/index.ts +1 -2
- package/dist/runtime-framework/react/native-page.ts +421 -0
- package/dist/runtime-framework/react/page.ts +5 -17
- package/dist/runtime-framework/solid/app.ts +25 -45
- package/dist/runtime-framework/solid/connect.ts +21 -3
- package/dist/runtime-framework/solid/hooks.ts +17 -12
- package/dist/runtime-framework/solid/index.ts +6 -2
- package/dist/runtime-framework/solid/page.ts +84 -36
- package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
- package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
- package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
- package/dist/runtime-framework/solid/utils/index.ts +0 -2
- package/dist/runtime-utils.d.ts +827 -0
- package/dist/runtime-utils.js +1633 -549
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +1633 -549
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +14 -15
- 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/harmony.d.ts +4 -0
- package/types/index.d.ts +4 -0
- package/types/runtime.d.ts +7 -1
- 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
- /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
|
@@ -1,59 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
TaroEvent
|
|
5
|
-
} from '@tarojs/runtime'
|
|
6
|
-
|
|
7
|
-
import { createNode } from './render'
|
|
8
|
-
import TaroComponentWrapper from './base'
|
|
9
|
-
import { AttributeManager } from './utils/AttributeManager'
|
|
1
|
+
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import commonStyleModify, { rowModify, columnModify } from './style'
|
|
10
4
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { shouldBindEvent, getNormalAttributes, getNodeThresholds, bindAnimation } from './utils/helper'
|
|
5
|
+
import { FlexManager } from './utils/flexManager'
|
|
6
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
14
7
|
|
|
15
|
-
import
|
|
16
|
-
import
|
|
8
|
+
import { TaroEvent, TaroAny, HarmonyType, TaroRadioGroupElement, TaroRadioElement } from '@tarojs/runtime'
|
|
9
|
+
import { isUndefined } from '@tarojs/shared'
|
|
17
10
|
|
|
18
|
-
interface RadioOptions {
|
|
19
|
-
group: string
|
|
20
|
-
value: string
|
|
21
|
-
}
|
|
22
11
|
interface RadioAttrs {
|
|
23
12
|
radioStyle?: HarmonyType.RadioStyle
|
|
24
13
|
themeStyles?: boolean
|
|
25
14
|
}
|
|
26
15
|
|
|
27
|
-
@Extend(Radio)
|
|
28
|
-
function style (style: TaroStyleType) {
|
|
29
|
-
.id(style.id)
|
|
30
|
-
.key(style.id)
|
|
31
|
-
.padding(style.padding)
|
|
32
|
-
.margin(style.margin)
|
|
33
|
-
.width(style.width)
|
|
34
|
-
.height(style.height)
|
|
35
|
-
.constraintSize(style.constraintSize)
|
|
36
|
-
.flexGrow(style.flexGrow)
|
|
37
|
-
.flexShrink(style.flexShrink)
|
|
38
|
-
.flexBasis(style.flexBasis)
|
|
39
|
-
.alignSelf(style.alignSelf)
|
|
40
|
-
.backgroundColor(style.backgroundColor)
|
|
41
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
42
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
43
|
-
.rotate(style.rotate)
|
|
44
|
-
.scale(style.scale)
|
|
45
|
-
.translate(style.translate)
|
|
46
|
-
.transform(style.transform)
|
|
47
|
-
.borderStyle(style.borderStyle)
|
|
48
|
-
.borderWidth(style.borderWidth)
|
|
49
|
-
.borderColor(style.borderColor)
|
|
50
|
-
.borderRadius(style.borderRadius)
|
|
51
|
-
.linearGradient(style.linearGradient)
|
|
52
|
-
.zIndex(style.zIndex)
|
|
53
|
-
.opacity(style.opacity)
|
|
54
|
-
.clip(style.clip)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
16
|
@Extend(Radio)
|
|
58
17
|
function radioAttr (attr: RadioAttrs) {
|
|
59
18
|
.radioStyle(attr.radioStyle)
|
|
@@ -76,148 +35,119 @@ function themeStyles(isDisabled: boolean) {
|
|
|
76
35
|
|
|
77
36
|
@Component
|
|
78
37
|
export struct TaroRadio {
|
|
79
|
-
|
|
80
|
-
|
|
38
|
+
@Builder customBuilder() {}
|
|
39
|
+
@BuilderParam createLazyChildren: (node: TaroRadioElement) => void = this.customBuilder
|
|
81
40
|
@ObjectLink node: TaroRadioElement
|
|
82
|
-
|
|
83
|
-
@State checked: boolean = false
|
|
41
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
84
42
|
|
|
85
43
|
aboutToAppear () {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
@Styles defaultEvent () {
|
|
93
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
94
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
|
|
95
|
-
const eventResult: TaroAny = res.eventResult
|
|
96
|
-
this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
|
|
97
|
-
}))
|
|
44
|
+
if (this.node && !this.node._isInit) {
|
|
45
|
+
this.node._isInit = true
|
|
46
|
+
this.node._instance = this
|
|
47
|
+
this.node._reset = this.node.checked || false
|
|
48
|
+
}
|
|
98
49
|
}
|
|
99
50
|
|
|
100
|
-
build() {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
// FIXME 找下文档是否有强制刷新方法
|
|
115
|
-
this.checked = !this.checked
|
|
116
|
-
this.checked = !this.checked
|
|
51
|
+
build () {
|
|
52
|
+
Stack() {
|
|
53
|
+
Row() {
|
|
54
|
+
Radio({
|
|
55
|
+
group: this.node.group || this.node.parentNode?._nid || '',
|
|
56
|
+
value: this.node.value || '',
|
|
57
|
+
})
|
|
58
|
+
.checked(this.node.checked)
|
|
59
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
60
|
+
.radioAttr(getAttributes(this.node))
|
|
61
|
+
.onChange((value: boolean) => {
|
|
62
|
+
if (this.node) {
|
|
63
|
+
if (!!this.node?._attrs.disabled) {
|
|
64
|
+
this.node.updateComponent()
|
|
117
65
|
} else {
|
|
118
|
-
this.
|
|
119
|
-
|
|
120
|
-
|
|
66
|
+
this.node.updateCheckedValue(value)
|
|
67
|
+
|
|
68
|
+
if (value) {
|
|
69
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
|
|
121
70
|
eventHandler(event, 'change', this.node)
|
|
122
71
|
}
|
|
123
72
|
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
76
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
77
|
+
if (this.node) {
|
|
78
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
79
|
+
}
|
|
80
|
+
}))
|
|
81
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
82
|
+
Text(this.node.textContent)
|
|
83
|
+
.textAlign(TextAlign.Center)
|
|
84
|
+
.opacity(!!this.node?._attrs.disabled ? 0.4 : 1)
|
|
134
85
|
}
|
|
86
|
+
.onClick(() => {
|
|
87
|
+
if (this.node) {
|
|
88
|
+
if (!this.node._checked && !this.node?._attrs.disabled) {
|
|
89
|
+
this.node.checked = !this.node.checked
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
})
|
|
135
93
|
}
|
|
136
94
|
}
|
|
137
95
|
}
|
|
138
96
|
|
|
139
|
-
@Extend(Flex)
|
|
140
|
-
function radioGroupAttrs (style: TaroStyleType) {
|
|
141
|
-
.id(style.id)
|
|
142
|
-
.key(style.id)
|
|
143
|
-
.padding(style.padding)
|
|
144
|
-
.margin(style.margin)
|
|
145
|
-
.width(style.width)
|
|
146
|
-
.height(style.height)
|
|
147
|
-
.constraintSize(style.constraintSize)
|
|
148
|
-
.flexGrow(style.flexGrow)
|
|
149
|
-
.flexShrink(style.flexShrink)
|
|
150
|
-
.flexBasis(style.flexBasis)
|
|
151
|
-
.alignSelf(style.alignSelf)
|
|
152
|
-
.backgroundColor(style.backgroundColor)
|
|
153
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
154
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
155
|
-
.rotate(style.rotate)
|
|
156
|
-
.scale(style.scale)
|
|
157
|
-
.translate(style.translate)
|
|
158
|
-
.transform(style.transform)
|
|
159
|
-
.borderStyle(style.borderStyle)
|
|
160
|
-
.borderWidth(style.borderWidth)
|
|
161
|
-
.borderColor(style.borderColor)
|
|
162
|
-
.borderRadius(style.borderRadius)
|
|
163
|
-
.linearGradient(style.linearGradient)
|
|
164
|
-
.zIndex(style.zIndex)
|
|
165
|
-
.opacity(style.opacity)
|
|
166
|
-
.clip(style.clip)
|
|
167
|
-
}
|
|
168
|
-
|
|
169
97
|
|
|
170
98
|
@Component
|
|
171
99
|
export struct TaroRadioGroup {
|
|
172
|
-
|
|
100
|
+
@Builder customBuilder() {}
|
|
101
|
+
@BuilderParam createLazyChildren: (node: TaroRadioGroupElement) => void = this.customBuilder
|
|
102
|
+
@ObjectLink node: TaroRadioGroupElement
|
|
103
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
173
104
|
|
|
174
105
|
@Styles visibleChangeEvent () {
|
|
175
106
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
176
107
|
}
|
|
177
108
|
|
|
178
|
-
@ObjectLink node: TaroRadioGroupElement
|
|
179
|
-
|
|
180
109
|
aboutToAppear () {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
// 阻止事件冒泡传递上去
|
|
190
|
-
this.node.addEventListener('change', (e: TaroEvent) => e.stopPropagation())
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// Element使用的获取器
|
|
194
|
-
getValue (): string | undefined {
|
|
195
|
-
const childList = this.node.getElementsByTagName<TaroRadioElement>('RADIO')
|
|
196
|
-
for (let i = 0; i < childList.length; i++) {
|
|
197
|
-
if (childList[i]._instance.checked) {
|
|
198
|
-
return childList[i]._attrs.value
|
|
199
|
-
}
|
|
110
|
+
if (this.node) {
|
|
111
|
+
this.node._instance = this
|
|
112
|
+
const childList = this.node.getElementsByTagName<TaroRadioElement>('RADIO')
|
|
113
|
+
childList.forEach(element => {
|
|
114
|
+
element.group = this.node?._attrs.name || this.node?._nid
|
|
115
|
+
})
|
|
116
|
+
// 阻止事件冒泡传递上去
|
|
117
|
+
this.node.addEventListener('change', (e: TaroEvent) => e.stopPropagation())
|
|
200
118
|
}
|
|
201
|
-
return undefined
|
|
202
119
|
}
|
|
203
120
|
|
|
204
121
|
@Styles defaultEvent () {
|
|
205
122
|
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
206
123
|
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
207
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
|
|
208
|
-
|
|
209
|
-
|
|
124
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
125
|
+
if (this.node) {
|
|
126
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
127
|
+
}
|
|
210
128
|
}))
|
|
211
129
|
}
|
|
212
130
|
|
|
213
131
|
build() {
|
|
214
|
-
|
|
132
|
+
if (FlexManager.useFlexLayout(this.node)) {
|
|
215
133
|
Flex(FlexManager.flexOptions(this.node)) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
134
|
+
this.createLazyChildren(this.node)
|
|
135
|
+
}
|
|
136
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
137
|
+
.defaultEvent()
|
|
138
|
+
.visibleChangeEvent()
|
|
139
|
+
} else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
|
|
140
|
+
Row() {
|
|
141
|
+
this.createLazyChildren(this.node)
|
|
142
|
+
}
|
|
143
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
144
|
+
.defaultEvent()
|
|
145
|
+
.visibleChangeEvent()
|
|
146
|
+
} else {
|
|
147
|
+
Column() {
|
|
148
|
+
this.createLazyChildren(this.node)
|
|
219
149
|
}
|
|
220
|
-
.
|
|
150
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
221
151
|
.defaultEvent()
|
|
222
152
|
.visibleChangeEvent()
|
|
223
153
|
}
|
|
@@ -1,97 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { generateText } from './utils'
|
|
5
|
+
import { getNodeThresholds, shouldBindEvent } from './utils/helper'
|
|
5
6
|
|
|
6
|
-
import type {
|
|
7
|
-
import type { TaroRichTextElement } from './element'
|
|
8
|
-
import type { TaroStyleType } from '@tarojs/runtime'
|
|
9
|
-
|
|
10
|
-
@Extend(RichText)
|
|
11
|
-
function attrs (style: TaroStyleType) {
|
|
12
|
-
.id(style.id)
|
|
13
|
-
.key(style.id)
|
|
14
|
-
.padding(style.padding)
|
|
15
|
-
.margin(style.margin)
|
|
16
|
-
.width(style.width)
|
|
17
|
-
.height(style.height)
|
|
18
|
-
.constraintSize(style.constraintSize)
|
|
19
|
-
.flexGrow(style.flexGrow)
|
|
20
|
-
.flexShrink(style.flexShrink)
|
|
21
|
-
.flexBasis(style.flexBasis)
|
|
22
|
-
.alignSelf(style.alignSelf)
|
|
23
|
-
.backgroundColor(style.backgroundColor)
|
|
24
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
25
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
26
|
-
.rotate(style.rotate)
|
|
27
|
-
.scale(style.scale)
|
|
28
|
-
.translate(style.translate)
|
|
29
|
-
.transform(style.transform)
|
|
30
|
-
.borderStyle(style.borderStyle)
|
|
31
|
-
.borderWidth(style.borderWidth)
|
|
32
|
-
.borderColor(style.borderColor)
|
|
33
|
-
.borderRadius(style.borderRadius)
|
|
34
|
-
.linearGradient(style.linearGradient)
|
|
35
|
-
.zIndex(style.zIndex)
|
|
36
|
-
.opacity(style.opacity)
|
|
37
|
-
.clip(style.clip)
|
|
38
|
-
}
|
|
7
|
+
import type { TaroAny, TaroRichTextElement } from '@tarojs/runtime'
|
|
39
8
|
|
|
40
9
|
@Component
|
|
41
10
|
export default struct TaroRichText {
|
|
42
|
-
|
|
43
|
-
|
|
11
|
+
@Builder customBuilder() {}
|
|
12
|
+
@BuilderParam createLazyChildren: (node: TaroRichTextElement) => void = this.customBuilder
|
|
44
13
|
@ObjectLink node: TaroRichTextElement
|
|
45
14
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
bindAnimation(this.node)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
@Styles defaultEvent () {
|
|
58
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
59
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
|
|
60
|
-
const eventResult: TaroAny = res.eventResult
|
|
61
|
-
this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
|
|
62
|
-
}))
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
generateText (): string {
|
|
66
|
-
return parseHtmlNode(this.node._attrs.nodes || '')
|
|
15
|
+
build () {
|
|
16
|
+
RichText(generateText(this.node))
|
|
17
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
18
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
19
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
20
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
21
|
+
}))
|
|
22
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
67
23
|
}
|
|
68
|
-
|
|
69
|
-
build() {
|
|
70
|
-
TaroComponentWrapper({ node: this.node }) {
|
|
71
|
-
RichText(this.generateText())
|
|
72
|
-
.attrs(getNormalAttributes(this.node))
|
|
73
|
-
.defaultEvent()
|
|
74
|
-
.visibleChangeEvent()
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// 将nodeTree转换成harmony需要的string结构
|
|
81
|
-
function nodeToHtml(node: RichTextProps.Text | RichTextProps.HTMLElement): string {
|
|
82
|
-
if (node.type === 'text') {
|
|
83
|
-
return node.text;
|
|
84
|
-
}
|
|
85
|
-
if (node.attrs) {
|
|
86
|
-
const attributes = Object.entries(node.attrs)
|
|
87
|
-
.map((item: [string, string]) => `${item[0]}="${item[1]}"`)
|
|
88
|
-
.join(' ');
|
|
89
|
-
const childrenHtml: string = typeof node.children === 'string' ? node.children : (node.children || []).map((child: RichTextProps.Text | RichTextProps.HTMLElement) => nodeToHtml(child)).join('');
|
|
90
|
-
return `<${node.name}${attributes ? ' ' + attributes : ''}>${childrenHtml}</${node.name}>`;
|
|
91
|
-
}
|
|
92
|
-
return ''
|
|
93
24
|
}
|
|
94
25
|
|
|
95
|
-
function parseHtmlNode (nodes: Array<RichTextProps.Text | RichTextProps.HTMLElement> | string) {
|
|
96
|
-
return typeof nodes === 'string' ? nodes: `<div>${nodes.map(node => nodeToHtml(node)).join('')}</div>`
|
|
97
|
-
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
5
|
+
import { getNodeThresholds, shouldBindEvent } from './utils/helper'
|
|
6
|
+
|
|
7
|
+
import type { TaroScrollViewElement, TaroAny, TaroEvent } from '@tarojs/runtime'
|
|
8
|
+
|
|
9
|
+
interface ScrollViewAttrs {
|
|
10
|
+
scrollBar: BarState
|
|
11
|
+
}
|
|
12
|
+
interface ScrollViewCurrentOffset {
|
|
13
|
+
xOffset: number
|
|
14
|
+
yOffset: number
|
|
15
|
+
}
|
|
16
|
+
interface ScrollViewEvent {
|
|
17
|
+
deltaX: number
|
|
18
|
+
deltaY: number
|
|
19
|
+
scrollLeft: number
|
|
20
|
+
scrollTop: number
|
|
21
|
+
scrollWidth: number
|
|
22
|
+
scrollHeight: number
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getAttributes (node: TaroScrollViewElement): ScrollViewAttrs {
|
|
26
|
+
const _attrs = node._attrs
|
|
27
|
+
const scrollAttrs: ScrollViewAttrs = {
|
|
28
|
+
scrollBar: typeof _attrs.showScrollbar === 'boolean'
|
|
29
|
+
? _attrs.showScrollbar ? BarState.On : BarState.Off
|
|
30
|
+
: BarState.Auto
|
|
31
|
+
}
|
|
32
|
+
return scrollAttrs
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', scrollOffset?: number) {
|
|
36
|
+
const currentOffset = node.scroller.currentOffset() as ScrollViewCurrentOffset
|
|
37
|
+
const currentXOffset = currentOffset?.xOffset || 0
|
|
38
|
+
const currentYOffset = currentOffset?.yOffset || 0
|
|
39
|
+
const value: ScrollViewEvent = {
|
|
40
|
+
deltaX: vp2px(node._attrs.scrollX ? scrollOffset : 0),
|
|
41
|
+
deltaY: vp2px(node._attrs.scrollX ? 0 : scrollOffset),
|
|
42
|
+
scrollLeft: vp2px(currentXOffset),
|
|
43
|
+
scrollTop: vp2px(currentYOffset),
|
|
44
|
+
scrollWidth: vp2px(Number(node._nodeInfo?._scroll?.width)),
|
|
45
|
+
scrollHeight: vp2px(Number(node._nodeInfo?._scroll?.height)),
|
|
46
|
+
}
|
|
47
|
+
const event: TaroEvent = createTaroEvent(eventName, { detail: value }, node)
|
|
48
|
+
|
|
49
|
+
eventHandler(event, eventName, node)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@Component
|
|
53
|
+
export default struct TaroScrollList {
|
|
54
|
+
@Builder customBuilder() {}
|
|
55
|
+
@BuilderParam createLazyChildren: (node: TaroScrollViewElement) => void = this.customBuilder
|
|
56
|
+
@ObjectLink node: TaroScrollViewElement
|
|
57
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
58
|
+
|
|
59
|
+
aboutToAppear(): void {
|
|
60
|
+
if (this.node) {
|
|
61
|
+
this.node._instance = this
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
handleScroll = (scrollOffset: number) => {
|
|
66
|
+
handleScrollEvent(this.node, 'scroll', scrollOffset)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
build() {
|
|
70
|
+
List({
|
|
71
|
+
scroller: this.node.scroller
|
|
72
|
+
}) {
|
|
73
|
+
this.createLazyChildren(this.node)
|
|
74
|
+
}
|
|
75
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
76
|
+
.sticky(StickyStyle.Header)
|
|
77
|
+
.listDirection(this.node.getAttribute('scrollX') ? Axis.Horizontal: Axis.Vertical)
|
|
78
|
+
.align(Alignment.TopStart)
|
|
79
|
+
.clip(true)
|
|
80
|
+
.scrollBar(getAttributes(this.node).scrollBar)
|
|
81
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
82
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
83
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
84
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
85
|
+
}))
|
|
86
|
+
.onDidScroll(shouldBindEvent((scrollOffset: number) => { handleScrollEvent(this.node, 'scroll', scrollOffset) }, this.node, ['scroll']))
|
|
87
|
+
.onScrollStart(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollstart') }, this.node, ['scrollstart']))
|
|
88
|
+
.onScrollStop(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollend') }, this.node, ['scrollend']))
|
|
89
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
90
|
+
.onReachEnd(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrolltolower') }, this.node, ['scrolltolower']))
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|