@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27
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/LICENSE +160 -0
- package/dist/apis/apis.ts +15 -0
- package/dist/apis/base/index.ts +5 -0
- package/dist/apis/base/system.ts +77 -0
- package/dist/apis/device/accelerometer.ts +76 -0
- package/dist/apis/device/battery.ts +24 -0
- package/dist/apis/device/clipboard.ts +70 -0
- package/dist/apis/device/index.ts +9 -0
- package/dist/apis/device/keyboard.ts +62 -0
- package/dist/apis/device/memory.ts +4 -0
- package/dist/apis/device/network.ts +72 -0
- package/dist/apis/device/phone.ts +43 -0
- package/dist/apis/device/screen.ts +79 -0
- package/dist/apis/device/vibrate.ts +24 -0
- package/dist/apis/files/index.ts +135 -0
- package/dist/apis/files/manager.ts +941 -0
- package/dist/apis/framework/index.ts +32 -0
- package/dist/apis/index.ts +124 -0
- package/dist/apis/location/index.ts +133 -0
- package/dist/apis/media/common.ts +74 -0
- package/dist/apis/media/image.ts +122 -0
- package/dist/apis/media/index.ts +3 -0
- package/dist/apis/media/video.ts +86 -0
- package/dist/apis/navigate/index.ts +8 -0
- package/dist/apis/network/downloadFile.ts +113 -0
- package/dist/apis/network/index.ts +4 -0
- package/dist/apis/network/request.ts +113 -0
- package/dist/apis/network/uploadFile.ts +158 -0
- package/dist/apis/network/webSocket.ts +130 -0
- package/dist/apis/open-api/index.ts +7 -0
- package/dist/apis/open-api/user-info/index.ts +85 -0
- package/dist/apis/page/index.ts +92 -0
- package/dist/apis/route/index.ts +138 -0
- package/dist/apis/storage/index.ts +133 -0
- package/dist/apis/tabbar/index.ts +147 -0
- package/dist/apis/ui/animation.ts +222 -0
- package/dist/apis/ui/background.ts +35 -0
- package/dist/apis/ui/index.ts +14 -0
- package/dist/apis/ui/interaction/index.ts +195 -0
- package/dist/apis/ui/navigation-bar/index.ts +33 -0
- package/dist/apis/ui/pull-down-refresh.ts +41 -0
- package/dist/apis/utils/handler.ts +116 -0
- package/dist/apis/utils/index.ts +85 -0
- package/dist/apis/utils/types.ts +12 -0
- package/dist/apis/utils/validate.ts +87 -0
- package/dist/apis/wxml/IntersectionObserver.ts +119 -0
- package/dist/apis/wxml/index.ts +12 -0
- package/dist/apis/wxml/nodesRef.ts +56 -0
- package/dist/apis/wxml/selectorQuery.ts +287 -0
- package/dist/components/components-react.js +51 -0
- package/dist/components/components-react.js.map +1 -0
- package/dist/components-harmony/button/index.css +109 -0
- package/dist/components-harmony/button/index.hml +31 -0
- package/dist/components-harmony/button/index.js +105 -0
- package/dist/components-harmony/camera/index.hml +6 -0
- package/dist/components-harmony/camera/index.js +12 -0
- package/dist/components-harmony/checkbox/index.hml +11 -0
- package/dist/components-harmony/checkbox/index.js +60 -0
- package/dist/components-harmony/checkbox-group/index.hml +3 -0
- package/dist/components-harmony/checkbox-group/index.js +22 -0
- package/dist/components-harmony/cover-image/index.css +4 -0
- package/dist/components-harmony/cover-image/index.hml +9 -0
- package/dist/components-harmony/cover-image/index.js +15 -0
- package/dist/components-harmony/form/index.hml +10 -0
- package/dist/components-harmony/form/index.js +11 -0
- package/dist/components-harmony/icon/index.css +27 -0
- package/dist/components-harmony/icon/index.hml +54 -0
- package/dist/components-harmony/icon/index.js +17 -0
- package/dist/components-harmony/image/index.css +5 -0
- package/dist/components-harmony/image/index.hml +11 -0
- package/dist/components-harmony/image/index.js +28 -0
- package/dist/components-harmony/input/index.hml +21 -0
- package/dist/components-harmony/input/index.js +98 -0
- package/dist/components-harmony/label/index.hml +3 -0
- package/dist/components-harmony/label/index.js +6 -0
- package/dist/components-harmony/navbar/index.css +56 -0
- package/dist/components-harmony/navbar/index.hml +9 -0
- package/dist/components-harmony/navbar/index.js +30 -0
- package/dist/components-harmony/navigator/index.css +8 -0
- package/dist/components-harmony/navigator/index.hml +9 -0
- package/dist/components-harmony/navigator/index.js +104 -0
- package/dist/components-harmony/picker/index.hml +25 -0
- package/dist/components-harmony/picker/index.js +132 -0
- package/dist/components-harmony/picker-view/index.hml +23 -0
- package/dist/components-harmony/picker-view/index.js +161 -0
- package/dist/components-harmony/picker-view-column/index.hml +3 -0
- package/dist/components-harmony/picker-view-column/index.js +3 -0
- package/dist/components-harmony/progress/index.css +4 -0
- package/dist/components-harmony/progress/index.hml +28 -0
- package/dist/components-harmony/progress/index.js +23 -0
- package/dist/components-harmony/radio/index.hml +11 -0
- package/dist/components-harmony/radio/index.js +41 -0
- package/dist/components-harmony/radio-group/index.hml +3 -0
- package/dist/components-harmony/radio-group/index.js +11 -0
- package/dist/components-harmony/rich-text/index.hml +5 -0
- package/dist/components-harmony/rich-text/index.js +16 -0
- package/dist/components-harmony/scroll-view/index.css +5 -0
- package/dist/components-harmony/scroll-view/index.hml +12 -0
- package/dist/components-harmony/scroll-view/index.js +65 -0
- package/dist/components-harmony/slider/index.hml +16 -0
- package/dist/components-harmony/slider/index.js +53 -0
- package/dist/components-harmony/swiper/index.css +3 -0
- package/dist/components-harmony/swiper/index.hml +14 -0
- package/dist/components-harmony/swiper/index.js +19 -0
- package/dist/components-harmony/switch/index.hml +7 -0
- package/dist/components-harmony/switch/index.js +16 -0
- package/dist/components-harmony/tabbar/index.css +7 -0
- package/dist/components-harmony/tabbar/index.hml +26 -0
- package/dist/components-harmony/tabbar/index.js +42 -0
- package/dist/components-harmony/textarea/index.hml +24 -0
- package/dist/components-harmony/textarea/index.js +92 -0
- package/dist/components-harmony/utils/index.js +41 -0
- package/dist/components-harmony/video/index.hml +7 -0
- package/dist/components-harmony/video/index.js +73 -0
- package/dist/components-harmony/web-view/index.hml +8 -0
- package/dist/components-harmony/web-view/index.js +22 -0
- package/dist/components-harmony-ets/base.ets +63 -0
- package/dist/components-harmony-ets/button.ets +119 -0
- package/dist/components-harmony-ets/checkbox.ets +219 -0
- package/dist/components-harmony-ets/element.ets +223 -0
- package/dist/components-harmony-ets/form.ets +149 -0
- package/dist/components-harmony-ets/icon.ets +84 -0
- package/dist/components-harmony-ets/image.ets +85 -0
- package/dist/components-harmony-ets/index.ts +49 -0
- package/dist/components-harmony-ets/innerHtml.ets +79 -0
- package/dist/components-harmony-ets/input.ets +195 -0
- package/dist/components-harmony-ets/label.ets +111 -0
- package/dist/components-harmony-ets/picker.ets +370 -0
- package/dist/components-harmony-ets/radio.ets +225 -0
- package/dist/components-harmony-ets/richText.ets +97 -0
- package/dist/components-harmony-ets/scrollView.ets +199 -0
- package/dist/components-harmony-ets/slider.ets +159 -0
- package/dist/components-harmony-ets/swiper.ets +204 -0
- package/dist/components-harmony-ets/switch.ets +113 -0
- package/dist/components-harmony-ets/text.ets +97 -0
- package/dist/components-harmony-ets/textArea.ets +169 -0
- package/dist/components-harmony-ets/utils/AttributeManager.ets +250 -0
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +48 -0
- package/dist/components-harmony-ets/utils/constant/event.ets +25 -0
- package/dist/components-harmony-ets/utils/constant/icon.ts +19 -0
- package/dist/components-harmony-ets/utils/constant/style.ets +88 -0
- package/dist/components-harmony-ets/utils/events.ts +24 -0
- package/dist/components-harmony-ets/utils/flexManager.ets +107 -0
- package/dist/components-harmony-ets/utils/helper.ets +99 -0
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +103 -0
- package/dist/components-harmony-ets/utils/htmlParser/index.ts +56 -0
- package/dist/components-harmony-ets/utils/index.ts +83 -0
- package/dist/components-harmony-ets/utils/styles.ets +91 -0
- package/dist/components-harmony-ets/video.ets +161 -0
- package/dist/components-harmony-ets/view.ets +79 -0
- package/dist/index.js +1183 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime-ets/bom/document.ts +38 -0
- package/dist/runtime-ets/bom/getComputedStyle.ts +5 -0
- package/dist/runtime-ets/bom/navigator.ts +21 -0
- package/dist/runtime-ets/bom/raf.ts +37 -0
- package/dist/runtime-ets/bom/window.ts +44 -0
- package/dist/runtime-ets/constant.ts +29 -0
- package/dist/runtime-ets/current.ts +16 -0
- package/dist/runtime-ets/dom/class-list.ts +117 -0
- package/dist/runtime-ets/dom/comment.ts +10 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +105 -0
- package/dist/runtime-ets/dom/document.ts +108 -0
- package/dist/runtime-ets/dom/element.ts +457 -0
- package/dist/runtime-ets/dom/event.ts +164 -0
- package/dist/runtime-ets/dom/eventTarget.ts +98 -0
- package/dist/runtime-ets/dom/node.ts +215 -0
- package/dist/runtime-ets/dom/stylesheet/index.ts +687 -0
- package/dist/runtime-ets/dom/stylesheet/type.ts +136 -0
- package/dist/runtime-ets/dom/stylesheet/util.ts +134 -0
- package/dist/runtime-ets/dom/text.ts +19 -0
- package/dist/runtime-ets/index.ts +19 -0
- package/dist/runtime-ets/interface/event.ts +9 -0
- package/dist/runtime-ets/interface/index.ts +1 -0
- package/dist/runtime-ets/utils/bind.ts +35 -0
- package/dist/runtime-ets/utils/index.ts +135 -0
- package/dist/runtime-ets/utils/info.ts +128 -0
- package/dist/runtime-framework/react/app.ts +256 -0
- package/dist/runtime-framework/react/connect.ts +24 -0
- package/dist/runtime-framework/react/constant.ts +5 -0
- package/dist/runtime-framework/react/hooks.ts +101 -0
- package/dist/runtime-framework/react/index.ts +16 -0
- package/dist/runtime-framework/react/page.ts +263 -0
- package/dist/runtime-framework/react/utils/index.ts +25 -0
- package/dist/runtime-framework/react/utils/is.ts +46 -0
- package/dist/runtime-framework/solid/README.md +99 -0
- package/dist/runtime-framework/solid/app.ts +200 -0
- package/dist/runtime-framework/solid/connect.ts +11 -0
- package/dist/runtime-framework/solid/contant.ts +5 -0
- package/dist/runtime-framework/solid/hooks.ts +88 -0
- package/dist/runtime-framework/solid/index.ts +10 -0
- package/dist/runtime-framework/solid/page.ts +202 -0
- package/dist/runtime-framework/solid/reconciler/h.ts +132 -0
- package/dist/runtime-framework/solid/reconciler/index.ts +3 -0
- package/dist/runtime-framework/solid/reconciler/props.ts +151 -0
- package/dist/runtime-framework/solid/reconciler/render.ts +61 -0
- package/dist/runtime-framework/solid/reconciler/use.ts +8 -0
- package/dist/runtime-framework/solid/utils/index.ts +49 -0
- package/dist/runtime-framework/solid/utils/is.ts +46 -0
- package/dist/runtime-utils.js +4149 -0
- package/dist/runtime-utils.js.map +1 -0
- package/dist/runtime.js +4150 -0
- package/dist/runtime.js.map +1 -0
- package/dist/template/container.js +7 -0
- package/index.js +4 -0
- package/package.json +54 -0
- package/types/api.d.ts +4 -0
- package/types/component.d.ts +4 -0
- package/types/harmony.d.ts +11 -0
- package/types/runtime.d.ts +15 -0
- package/types/taro.d.ts +7 -0
- package/types/webpack-sources.d.ts +108 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { bindInstanceToNode, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, initComponentNodeInfo,
|
|
2
|
+
TaroElement,
|
|
3
|
+
TaroAny,
|
|
4
|
+
TaroEvent
|
|
5
|
+
} from '@tarojs/runtime'
|
|
6
|
+
|
|
7
|
+
import { createNode } from './render'
|
|
8
|
+
import TaroComponentWrapper from './base'
|
|
9
|
+
import { AttributeManager } from './utils/AttributeManager'
|
|
10
|
+
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
11
|
+
import { createTaroEvent } from './utils/events'
|
|
12
|
+
import { FlexManager } from './utils/FlexManager'
|
|
13
|
+
import { shouldBindEvent, getNormalAttributes, getNodeThresholds, bindAnimation } from './utils/helper'
|
|
14
|
+
|
|
15
|
+
import type { TaroRadioGroupElement, TaroRadioElement } from './element'
|
|
16
|
+
import type { TaroStyleType, HarmonyType } from '@tarojs/runtime'
|
|
17
|
+
|
|
18
|
+
interface RadioOptions {
|
|
19
|
+
group: string
|
|
20
|
+
value: string
|
|
21
|
+
}
|
|
22
|
+
interface RadioAttrs {
|
|
23
|
+
radioStyle?: HarmonyType.RadioStyle
|
|
24
|
+
themeStyles?: boolean
|
|
25
|
+
}
|
|
26
|
+
|
|
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
|
+
@Extend(Radio)
|
|
58
|
+
function radioAttr (attr: RadioAttrs) {
|
|
59
|
+
.radioStyle(attr.radioStyle)
|
|
60
|
+
.themeStyles(attr.themeStyles)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function getAttributes (node: TaroRadioElement): RadioAttrs {
|
|
64
|
+
const radioAttrs: RadioAttrs = {}
|
|
65
|
+
radioAttrs.radioStyle = {
|
|
66
|
+
checkedBackgroundColor: node._attrs.color || '#1aad19'
|
|
67
|
+
}
|
|
68
|
+
radioAttrs.themeStyles = !!node._attrs.disabled
|
|
69
|
+
return radioAttrs
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@Extend(Radio)
|
|
73
|
+
function themeStyles(isDisabled: boolean) {
|
|
74
|
+
.opacity(isDisabled ? 0.4 : 1)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@Component
|
|
78
|
+
export struct TaroRadio {
|
|
79
|
+
nodeInfoMap: TaroAny = {}
|
|
80
|
+
|
|
81
|
+
@ObjectLink node: TaroRadioElement
|
|
82
|
+
|
|
83
|
+
@State checked: boolean = false
|
|
84
|
+
|
|
85
|
+
aboutToAppear () {
|
|
86
|
+
initComponentNodeInfo(this, this.node)
|
|
87
|
+
bindInstanceToNode(this.node, this)
|
|
88
|
+
|
|
89
|
+
this.checked = !!this.node._attrs.checked
|
|
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
|
+
}))
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
build() {
|
|
101
|
+
TaroComponentWrapper({ node: this.node }) {
|
|
102
|
+
Stack() {
|
|
103
|
+
Row() {
|
|
104
|
+
Radio({
|
|
105
|
+
group: this.node.group || this.node.parentNode?._nid || '',
|
|
106
|
+
value: this.node._attrs.value || '',
|
|
107
|
+
})
|
|
108
|
+
.checked(this.checked)
|
|
109
|
+
.defaultEvent()
|
|
110
|
+
.style(getNormalAttributes(this.node))
|
|
111
|
+
.radioAttr(getAttributes(this.node))
|
|
112
|
+
.onChange((value: boolean) => {
|
|
113
|
+
if (!!this.node._attrs.disabled) {
|
|
114
|
+
// FIXME 找下文档是否有强制刷新方法
|
|
115
|
+
this.checked = !this.checked
|
|
116
|
+
this.checked = !this.checked
|
|
117
|
+
} else {
|
|
118
|
+
this.checked = value
|
|
119
|
+
if (this.checked) {
|
|
120
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node._attrs.value } }, this.node)
|
|
121
|
+
eventHandler(event, 'change', this.node)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
Text(this.node.textContent)
|
|
126
|
+
.textAlign(TextAlign.Center)
|
|
127
|
+
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
128
|
+
}
|
|
129
|
+
.onClick(() => {
|
|
130
|
+
if (!this.checked) {
|
|
131
|
+
this.checked = !this.checked
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
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
|
+
|
|
170
|
+
@Component
|
|
171
|
+
export struct TaroRadioGroup {
|
|
172
|
+
nodeInfoMap: TaroAny = {}
|
|
173
|
+
|
|
174
|
+
@Styles visibleChangeEvent () {
|
|
175
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
@ObjectLink node: TaroRadioGroupElement
|
|
179
|
+
|
|
180
|
+
aboutToAppear () {
|
|
181
|
+
initComponentNodeInfo(this, this.node)
|
|
182
|
+
bindInstanceToNode(this.node, this)
|
|
183
|
+
// 绑定动画
|
|
184
|
+
bindAnimation(this.node)
|
|
185
|
+
const childList = this.node.getElementsByTagName<TaroRadioElement>('RADIO')
|
|
186
|
+
childList.forEach(element => {
|
|
187
|
+
element.group = this.node._attrs.name || this.node._nid
|
|
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
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return undefined
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
@Styles defaultEvent () {
|
|
205
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
206
|
+
.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
|
+
const eventResult: TaroAny = res.eventResult
|
|
209
|
+
this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
|
|
210
|
+
}))
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
build() {
|
|
214
|
+
TaroComponentWrapper({ node: this.node }) {
|
|
215
|
+
Flex(FlexManager.flexOptions(this.node)) {
|
|
216
|
+
ForEach(this.node.childNodes, (item: TaroElement) => {
|
|
217
|
+
createNode(item)
|
|
218
|
+
}, (item: TaroElement) => item._nid)
|
|
219
|
+
}
|
|
220
|
+
.radioGroupAttrs(getNormalAttributes(this.node))
|
|
221
|
+
.defaultEvent()
|
|
222
|
+
.visibleChangeEvent()
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { bindInstanceToNode, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, initComponentNodeInfo, TaroAny } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import TaroComponentWrapper from './base'
|
|
4
|
+
import { getNodeThresholds, getNormalAttributes, shouldBindEvent, bindAnimation } from './utils/helper'
|
|
5
|
+
|
|
6
|
+
import type { RichTextProps } from '@tarojs/components/types/RichText'
|
|
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
|
+
}
|
|
39
|
+
|
|
40
|
+
@Component
|
|
41
|
+
export default struct TaroRichText {
|
|
42
|
+
nodeInfoMap: TaroAny = {}
|
|
43
|
+
|
|
44
|
+
@ObjectLink node: TaroRichTextElement
|
|
45
|
+
|
|
46
|
+
@Styles visibleChangeEvent () {
|
|
47
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
aboutToAppear () {
|
|
51
|
+
initComponentNodeInfo(this, this.node)
|
|
52
|
+
bindInstanceToNode(this.node, this)
|
|
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 || '')
|
|
67
|
+
}
|
|
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
|
+
}
|
|
94
|
+
|
|
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,199 @@
|
|
|
1
|
+
import { bindScrollTo, bindInstanceToNode, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, initComponentNodeInfo,
|
|
2
|
+
TaroEvent, TaroAny } from '@tarojs/runtime'
|
|
3
|
+
|
|
4
|
+
import { createNode } from './render'
|
|
5
|
+
import TaroComponentWrapper from './base'
|
|
6
|
+
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
7
|
+
import { createTaroEvent } from './utils/events'
|
|
8
|
+
import { getNodeThresholds, getNormalAttributes, shouldBindEvent, bindAnimation } from './utils/helper'
|
|
9
|
+
|
|
10
|
+
import type { TaroScrollViewElement, TaroElement } from './element'
|
|
11
|
+
import type { TaroStyleType } from '@tarojs/runtime'
|
|
12
|
+
|
|
13
|
+
interface ScrollViewAttrs {
|
|
14
|
+
scrollBar: BarState
|
|
15
|
+
}
|
|
16
|
+
interface ScrollViewCurrentOffset {
|
|
17
|
+
xOffset: number
|
|
18
|
+
yOffset: number
|
|
19
|
+
}
|
|
20
|
+
interface ScrollViewEvent {
|
|
21
|
+
deltaX: number
|
|
22
|
+
deltaY: number
|
|
23
|
+
scrollLeft: number
|
|
24
|
+
scrollTop: number
|
|
25
|
+
scrollWidth: number
|
|
26
|
+
scrollHeight: number
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Extend(Row)
|
|
30
|
+
function rowAttrs (style: TaroStyleType) {
|
|
31
|
+
.id(style.id)
|
|
32
|
+
.key(style.id)
|
|
33
|
+
.padding(style.padding)
|
|
34
|
+
.margin(style.margin)
|
|
35
|
+
.width(style.width)
|
|
36
|
+
.height(style.height)
|
|
37
|
+
.constraintSize(style.constraintSize)
|
|
38
|
+
.flexGrow(style.flexGrow)
|
|
39
|
+
.flexShrink(style.flexShrink)
|
|
40
|
+
.flexBasis(style.flexBasis)
|
|
41
|
+
.alignSelf(style.alignSelf)
|
|
42
|
+
.backgroundColor(style.backgroundColor)
|
|
43
|
+
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
44
|
+
.backgroundImageSize(style.backgroundImageSize)
|
|
45
|
+
.rotate(style.rotate)
|
|
46
|
+
.scale(style.scale)
|
|
47
|
+
.translate(style.translate)
|
|
48
|
+
.transform(style.transform)
|
|
49
|
+
.borderStyle(style.borderStyle)
|
|
50
|
+
.borderWidth(style.borderWidth)
|
|
51
|
+
.borderColor(style.borderColor)
|
|
52
|
+
.borderRadius(style.borderRadius)
|
|
53
|
+
.linearGradient(style.linearGradient)
|
|
54
|
+
.zIndex(style.zIndex)
|
|
55
|
+
.opacity(style.opacity)
|
|
56
|
+
.clip(style.clip)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@Extend(Column)
|
|
60
|
+
function columnAttrs (style: TaroStyleType) {
|
|
61
|
+
.id(style.id)
|
|
62
|
+
.key(style.id)
|
|
63
|
+
.padding(style.padding)
|
|
64
|
+
.margin(style.margin)
|
|
65
|
+
.width(style.width)
|
|
66
|
+
.height(style.height)
|
|
67
|
+
.constraintSize(style.constraintSize)
|
|
68
|
+
.flexGrow(style.flexGrow)
|
|
69
|
+
.flexShrink(style.flexShrink)
|
|
70
|
+
.flexBasis(style.flexBasis)
|
|
71
|
+
.alignSelf(style.alignSelf)
|
|
72
|
+
.backgroundColor(style.backgroundColor)
|
|
73
|
+
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
74
|
+
.backgroundImageSize(style.backgroundImageSize)
|
|
75
|
+
.rotate(style.rotate)
|
|
76
|
+
.scale(style.scale)
|
|
77
|
+
.translate(style.translate)
|
|
78
|
+
.transform(style.transform)
|
|
79
|
+
.borderStyle(style.borderStyle)
|
|
80
|
+
.borderWidth(style.borderWidth)
|
|
81
|
+
.borderColor(style.borderColor)
|
|
82
|
+
.borderRadius(style.borderRadius)
|
|
83
|
+
.linearGradient(style.linearGradient)
|
|
84
|
+
.zIndex(style.zIndex)
|
|
85
|
+
.opacity(style.opacity)
|
|
86
|
+
.clip(style.clip)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
function getAttributes (node: TaroScrollViewElement): ScrollViewAttrs {
|
|
91
|
+
const _attrs = node._attrs
|
|
92
|
+
const scrollAttrs: ScrollViewAttrs = {
|
|
93
|
+
scrollBar: typeof _attrs.showScrollbar === 'boolean'
|
|
94
|
+
? _attrs.showScrollbar ? BarState.On : BarState.Off
|
|
95
|
+
: BarState.Auto
|
|
96
|
+
}
|
|
97
|
+
return scrollAttrs
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@Component
|
|
102
|
+
export default struct TaroScrollView {
|
|
103
|
+
nodeInfoMap: TaroAny = {}
|
|
104
|
+
|
|
105
|
+
wrapper?: Area
|
|
106
|
+
|
|
107
|
+
@Styles visibleChangeEvent () {
|
|
108
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
scroller: Scroller = new Scroller()
|
|
112
|
+
|
|
113
|
+
@ObjectLink node: TaroScrollViewElement
|
|
114
|
+
|
|
115
|
+
aboutToAppear () {
|
|
116
|
+
initComponentNodeInfo(this, this.node)
|
|
117
|
+
bindInstanceToNode(this.node, this)
|
|
118
|
+
// 绑定动画
|
|
119
|
+
bindAnimation(this.node)
|
|
120
|
+
bindScrollTo(this.node, this)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@Styles defaultEvent () {
|
|
124
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
125
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
126
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
|
|
127
|
+
const eventResult: TaroAny = res.eventResult
|
|
128
|
+
this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
|
|
129
|
+
}))
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@Styles defaultContainerEvent () {
|
|
133
|
+
.onAreaChange(shouldBindEvent((areaResult: Area) => {
|
|
134
|
+
this.wrapper = areaResult
|
|
135
|
+
}, this.node, ['scroll', 'scrollstart', 'scrollend']))
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
handleScrollEvent (eventName = 'scroll', xOffset?: number, yOffset?: number) {
|
|
140
|
+
const currentOffset: ScrollViewCurrentOffset = this.scroller.currentOffset()
|
|
141
|
+
const currentXOffset = currentOffset.xOffset
|
|
142
|
+
const currentYOffset = currentOffset.yOffset
|
|
143
|
+
const value: ScrollViewEvent = {
|
|
144
|
+
deltaX: vp2px(xOffset),
|
|
145
|
+
deltaY: vp2px(yOffset),
|
|
146
|
+
scrollLeft: vp2px(currentXOffset),
|
|
147
|
+
scrollTop: vp2px(currentYOffset),
|
|
148
|
+
scrollWidth: vp2px(Number(this.wrapper?.width)),
|
|
149
|
+
scrollHeight: vp2px(Number(this.wrapper?.height)),
|
|
150
|
+
}
|
|
151
|
+
const event: TaroEvent = createTaroEvent(eventName, { detail: value }, this.node)
|
|
152
|
+
eventHandler(event, eventName, this.node)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
build() {
|
|
156
|
+
TaroComponentWrapper({ node: this.node }) {
|
|
157
|
+
// Copy 额外增加visibleChangeEvent
|
|
158
|
+
if (this.node._attrs.scrollX) {
|
|
159
|
+
Scroll(this.scroller) {
|
|
160
|
+
Row() {
|
|
161
|
+
ForEach(this.node.childNodes, (item: TaroElement) => {
|
|
162
|
+
createNode(item)
|
|
163
|
+
}, (item: TaroElement) => item._nid)
|
|
164
|
+
}
|
|
165
|
+
.rowAttrs(getNormalAttributes(this.node))
|
|
166
|
+
.width(null)
|
|
167
|
+
.defaultContainerEvent()
|
|
168
|
+
}
|
|
169
|
+
.flexGrow(getNormalAttributes(this.node).flexGrow)
|
|
170
|
+
.scrollable(ScrollDirection.Horizontal)
|
|
171
|
+
.scrollBar(getAttributes(this.node).scrollBar)
|
|
172
|
+
.defaultEvent()
|
|
173
|
+
.onScroll(shouldBindEvent(() => { this.handleScrollEvent('scroll') }, this.node, ['scroll']))
|
|
174
|
+
.onScrollStart(shouldBindEvent(() => { this.handleScrollEvent('scrollstart') }, this.node, ['scrollstart']))
|
|
175
|
+
.onScrollStop(shouldBindEvent(() => { this.handleScrollEvent('scrollend') }, this.node, ['scrollend']))
|
|
176
|
+
.visibleChangeEvent()
|
|
177
|
+
} else {
|
|
178
|
+
Scroll(this.scroller) {
|
|
179
|
+
Column() {
|
|
180
|
+
ForEach(this.node.childNodes, (item: TaroElement) => {
|
|
181
|
+
createNode(item)
|
|
182
|
+
}, (item: TaroElement) => item._nid)
|
|
183
|
+
}
|
|
184
|
+
.columnAttrs(getNormalAttributes(this.node))
|
|
185
|
+
.height(null)
|
|
186
|
+
.defaultContainerEvent()
|
|
187
|
+
}
|
|
188
|
+
.flexGrow(getNormalAttributes(this.node).flexGrow)
|
|
189
|
+
.scrollable(ScrollDirection.Vertical)
|
|
190
|
+
.scrollBar(getAttributes(this.node).scrollBar)
|
|
191
|
+
.defaultEvent()
|
|
192
|
+
.onScroll(shouldBindEvent(() => { this.handleScrollEvent('scroll') }, this.node, ['scroll']))
|
|
193
|
+
.onScrollStart(shouldBindEvent(() => { this.handleScrollEvent('scrollstart') }, this.node, ['scrollstart']))
|
|
194
|
+
.onScrollStop(shouldBindEvent(() => { this.handleScrollEvent('scrollend') }, this.node, ['scrollend']))
|
|
195
|
+
.visibleChangeEvent()
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { bindInstanceToNode, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, initComponentNodeInfo,
|
|
2
|
+
TaroEvent, TaroAny } from '@tarojs/runtime'
|
|
3
|
+
|
|
4
|
+
import TaroComponentWrapper from './base'
|
|
5
|
+
import { createTaroEvent } from './utils/events'
|
|
6
|
+
import { getNodeThresholds, shouldBindEvent, getNormalAttributes } from './utils/helper'
|
|
7
|
+
|
|
8
|
+
import type { TaroSliderElement } from './element'
|
|
9
|
+
import type { TaroStyleType } from '@tarojs/runtime'
|
|
10
|
+
|
|
11
|
+
interface SliderOptions {
|
|
12
|
+
min?: number
|
|
13
|
+
max?: number
|
|
14
|
+
value?: number
|
|
15
|
+
step?: number
|
|
16
|
+
style?: SliderStyle
|
|
17
|
+
direction?: Axis
|
|
18
|
+
}
|
|
19
|
+
interface SliderAttrs {
|
|
20
|
+
selectedColor?: ResourceColor
|
|
21
|
+
trackColor?: ResourceColor
|
|
22
|
+
trackThickness?: Length
|
|
23
|
+
blockColor?: ResourceColor
|
|
24
|
+
}
|
|
25
|
+
interface SliderParams {
|
|
26
|
+
width: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Extend(Slider)
|
|
30
|
+
function style (style: TaroStyleType) {
|
|
31
|
+
.id(style.id)
|
|
32
|
+
.key(style.id)
|
|
33
|
+
.padding(style.padding)
|
|
34
|
+
.margin(style.margin)
|
|
35
|
+
.width(style.width)
|
|
36
|
+
.height(style.height)
|
|
37
|
+
.constraintSize(style.constraintSize)
|
|
38
|
+
.flexGrow(style.flexGrow)
|
|
39
|
+
.flexShrink(style.flexShrink)
|
|
40
|
+
.flexBasis(style.flexBasis)
|
|
41
|
+
.alignSelf(style.alignSelf)
|
|
42
|
+
.backgroundColor(style.backgroundColor)
|
|
43
|
+
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
44
|
+
.backgroundImageSize(style.backgroundImageSize)
|
|
45
|
+
.rotate(style.rotate)
|
|
46
|
+
.scale(style.scale)
|
|
47
|
+
.translate(style.translate)
|
|
48
|
+
.transform(style.transform)
|
|
49
|
+
.borderStyle(style.borderStyle)
|
|
50
|
+
.borderWidth(style.borderWidth)
|
|
51
|
+
.borderColor(style.borderColor)
|
|
52
|
+
.borderRadius(style.borderRadius)
|
|
53
|
+
.linearGradient(style.linearGradient)
|
|
54
|
+
.zIndex(style.zIndex)
|
|
55
|
+
.opacity(style.opacity)
|
|
56
|
+
.clip(style.clip)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@Extend(Slider)
|
|
60
|
+
function attrs (attr: SliderAttrs) {
|
|
61
|
+
.selectedColor(attr.selectedColor)
|
|
62
|
+
.trackColor(attr.trackColor)
|
|
63
|
+
.trackThickness(attr.trackThickness)
|
|
64
|
+
.blockColor(attr.blockColor)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function getAttributes (node: TaroSliderElement): SliderAttrs {
|
|
68
|
+
const _attrs = node._attrs
|
|
69
|
+
const sliderAttrs: SliderAttrs = {}
|
|
70
|
+
sliderAttrs.selectedColor = _attrs.activeColor || _attrs.selectedColor || '#1aad19'
|
|
71
|
+
sliderAttrs.trackColor = _attrs.backgroundColor || _attrs.color || '#e9e9e9'
|
|
72
|
+
sliderAttrs.trackThickness = _attrs.blockSize
|
|
73
|
+
sliderAttrs.blockColor = _attrs.blockColor || '#ffffff'
|
|
74
|
+
return sliderAttrs
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@Extend(Slider)
|
|
78
|
+
function themeStyles(isDisabled: boolean) {
|
|
79
|
+
.opacity(isDisabled ? 0.4 : 1)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@Component
|
|
83
|
+
export default struct TaroSlider {
|
|
84
|
+
nodeInfoMap: TaroAny = {}
|
|
85
|
+
|
|
86
|
+
@ObjectLink node: TaroSliderElement
|
|
87
|
+
|
|
88
|
+
@State value: number = 0
|
|
89
|
+
|
|
90
|
+
@Styles visibleChangeEvent () {
|
|
91
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
aboutToAppear () {
|
|
95
|
+
initComponentNodeInfo(this, this.node)
|
|
96
|
+
bindInstanceToNode(this.node, this)
|
|
97
|
+
|
|
98
|
+
this.value = Number(this.node._attrs.value || 0)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@Styles defaultEvent () {
|
|
102
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
103
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
|
|
104
|
+
const eventResult: TaroAny = res.eventResult
|
|
105
|
+
this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
|
|
106
|
+
}))
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@Builder createSlider () {
|
|
110
|
+
Slider({
|
|
111
|
+
min: Number(this.node._attrs.min || 0),
|
|
112
|
+
max: Number(this.node._attrs.max || 100),
|
|
113
|
+
value: this.value,
|
|
114
|
+
step: Number(this.node._attrs.step || 1),
|
|
115
|
+
style: SliderStyle.OutSet,
|
|
116
|
+
direction: Axis.Horizontal
|
|
117
|
+
})
|
|
118
|
+
.defaultEvent()
|
|
119
|
+
.style(getNormalAttributes(this.node))
|
|
120
|
+
.attrs(getAttributes(this.node))
|
|
121
|
+
.width(!!this.node._attrs.showValue ? '90%' : '100%')
|
|
122
|
+
.themeStyles(!!this.node._attrs.disabled)
|
|
123
|
+
.onChange((value: number, mode: SliderChangeMode) => {
|
|
124
|
+
if (!!this.node._attrs.disabled) {
|
|
125
|
+
if (mode === SliderChangeMode.End) {
|
|
126
|
+
// FIXME 找下文档是否有强制刷新方法
|
|
127
|
+
this.value = this.value + 0.01
|
|
128
|
+
this.value = this.value - 0.01
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
this.value = value
|
|
132
|
+
if (mode === SliderChangeMode.End) {
|
|
133
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.value } }, this.node)
|
|
134
|
+
eventHandler(event, 'change', this.node)
|
|
135
|
+
} else if (mode === SliderChangeMode.Moving) {
|
|
136
|
+
const event: TaroEvent = createTaroEvent('changing', { detail: { value: this.value } }, this.node)
|
|
137
|
+
eventHandler(event, 'changing', this.node)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
.visibleChangeEvent()
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
build() {
|
|
145
|
+
TaroComponentWrapper({ node: this.node }) {
|
|
146
|
+
if (!!this.node._attrs.showValue) {
|
|
147
|
+
Row() {
|
|
148
|
+
this.createSlider()
|
|
149
|
+
Text(Number(this.value).toFixed(0))
|
|
150
|
+
.width('10%')
|
|
151
|
+
.textAlign(TextAlign.Center)
|
|
152
|
+
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
153
|
+
}
|
|
154
|
+
} else {
|
|
155
|
+
this.createSlider()
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|