@tarojs/plugin-platform-harmony-ets 4.0.0-beta.1 → 4.0.0-beta.11
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/device/memory.ts +10 -3
- package/dist/apis/index.ts +2 -0
- package/dist/apis/network/request.ts +5 -5
- package/dist/apis/route/index.ts +15 -0
- package/dist/apis/storage/index.ts +124 -60
- package/dist/apis/wxml/index.ts +2 -0
- package/dist/components-harmony-ets/button.ets +54 -100
- package/dist/components-harmony-ets/checkbox.ets +25 -140
- package/dist/components-harmony-ets/form.ets +34 -78
- package/dist/components-harmony-ets/icon.ets +24 -82
- package/dist/components-harmony-ets/image.ets +16 -76
- package/dist/components-harmony-ets/innerHtml.ets +10 -6
- package/dist/components-harmony-ets/input.ets +3 -62
- package/dist/components-harmony-ets/label.ets +46 -83
- package/dist/components-harmony-ets/movableArea.ets +67 -0
- package/dist/components-harmony-ets/movableView.ets +66 -0
- package/dist/components-harmony-ets/picker.ets +33 -141
- package/dist/components-harmony-ets/progress.ets +45 -0
- package/dist/components-harmony-ets/radio.ets +24 -140
- package/dist/components-harmony-ets/richText.ets +17 -78
- package/dist/components-harmony-ets/scrollView.ets +61 -155
- package/dist/components-harmony-ets/slider.ets +5 -69
- package/dist/components-harmony-ets/style.ets +154 -0
- package/dist/components-harmony-ets/swiper.ets +26 -86
- package/dist/components-harmony-ets/switch.ets +5 -69
- package/dist/components-harmony-ets/text.ets +29 -87
- package/dist/components-harmony-ets/textArea.ets +3 -62
- package/dist/components-harmony-ets/utils/flexManager.ets +44 -6
- package/dist/components-harmony-ets/utils/helper.ets +2 -2
- package/dist/components-harmony-ets/utils/styles.ets +12 -1
- package/dist/components-harmony-ets/video.ets +29 -88
- package/dist/components-harmony-ets/view.ets +38 -144
- package/dist/components-harmony-ets/webView.ets +55 -0
- package/dist/index.js +122 -17
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/window.ts +2 -2
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +23 -3
- package/dist/runtime-ets/dom/document.ts +21 -4
- package/dist/runtime-ets/dom/element/element.ts +0 -1
- package/dist/runtime-ets/dom/element/form.ts +11 -4
- package/dist/runtime-ets/dom/element/index.ts +12 -1
- package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
- package/dist/runtime-ets/dom/element/movableView.ts +12 -0
- package/dist/runtime-ets/dom/element/normal.ts +9 -2
- package/dist/runtime-ets/dom/element/progress.ts +13 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
- package/dist/runtime-ets/dom/element/text.ts +1 -0
- package/dist/runtime-ets/dom/element/video.ts +1 -0
- package/dist/runtime-ets/dom/element/webView.ts +69 -0
- package/dist/runtime-ets/dom/node.ts +18 -17
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +73 -0
- package/dist/runtime-ets/dom/stylesheet/util.ts +3 -1
- package/dist/runtime-ets/index.ts +1 -2
- package/dist/runtime-ets/utils/index.ts +4 -1
- package/dist/runtime-framework/react/app.ts +12 -22
- 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 +2 -2
- package/dist/runtime-framework/solid/hooks.ts +3 -3
- package/dist/runtime-utils.js +134 -68
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +134 -68
- package/dist/runtime.js.map +1 -1
- package/package.json +10 -10
- package/types/runtime.d.ts +2 -0
- package/dist/runtime-ets/utils/bind.ts +0 -24
|
@@ -1,82 +1,18 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
+
import commonStyleModify from './style'
|
|
3
4
|
import { createLazyChildren } from './render'
|
|
4
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
5
6
|
import { FlexManager } from './utils/FlexManager'
|
|
6
|
-
import { shouldBindEvent,
|
|
7
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
7
8
|
|
|
8
|
-
import { TaroEvent, TaroAny,
|
|
9
|
+
import { TaroEvent, TaroAny, HarmonyType, TaroRadioGroupElement, TaroRadioElement } from '@tarojs/runtime'
|
|
9
10
|
|
|
10
11
|
interface RadioAttrs {
|
|
11
12
|
radioStyle?: HarmonyType.RadioStyle
|
|
12
13
|
themeStyles?: boolean
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
@Extend(Radio)
|
|
16
|
-
function style (style: TaroStyleType) {
|
|
17
|
-
.id(style.id)
|
|
18
|
-
.key(style.id)
|
|
19
|
-
.flexGrow(style.flexGrow)
|
|
20
|
-
.flexShrink(style.flexShrink)
|
|
21
|
-
.flexBasis(style.flexBasis)
|
|
22
|
-
.alignSelf(style.alignSelf)
|
|
23
|
-
.padding({
|
|
24
|
-
top: style.paddingTop,
|
|
25
|
-
right: style.paddingRight,
|
|
26
|
-
bottom: style.paddingBottom,
|
|
27
|
-
left: style.paddingLeft
|
|
28
|
-
})
|
|
29
|
-
.margin({
|
|
30
|
-
top: style.marginTop,
|
|
31
|
-
right: style.marginRight,
|
|
32
|
-
bottom: style.marginBottom,
|
|
33
|
-
left: style.marginLeft
|
|
34
|
-
})
|
|
35
|
-
.width(style.width)
|
|
36
|
-
.height(style.height)
|
|
37
|
-
.constraintSize({
|
|
38
|
-
minWidth: style.minWidth,
|
|
39
|
-
maxWidth: style.maxWidth,
|
|
40
|
-
minHeight: style.minHeight,
|
|
41
|
-
maxHeight: style.maxHeight
|
|
42
|
-
})
|
|
43
|
-
.backgroundColor(style.backgroundColor)
|
|
44
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
45
|
-
.backgroundImageSize(style.backgroundSize)
|
|
46
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
47
|
-
.borderStyle({
|
|
48
|
-
top: style.borderTopStyle,
|
|
49
|
-
right: style.borderRightStyle,
|
|
50
|
-
bottom: style.borderBottomStyle,
|
|
51
|
-
left: style.borderLeftStyle
|
|
52
|
-
})
|
|
53
|
-
.borderWidth({
|
|
54
|
-
top: style.borderTopWidth,
|
|
55
|
-
right: style.borderRightWidth,
|
|
56
|
-
bottom: style.borderBottomWidth,
|
|
57
|
-
left: style.borderLeftWidth
|
|
58
|
-
})
|
|
59
|
-
.borderColor({
|
|
60
|
-
top: style.borderTopColor,
|
|
61
|
-
right: style.borderRightColor,
|
|
62
|
-
bottom: style.borderBottomColor,
|
|
63
|
-
left: style.borderLeftColor
|
|
64
|
-
})
|
|
65
|
-
.borderRadius({
|
|
66
|
-
topLeft: style.borderTopLeftRadius,
|
|
67
|
-
topRight: style.borderTopRightRadius,
|
|
68
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
69
|
-
bottomRight: style.borderBottomRightRadius
|
|
70
|
-
})
|
|
71
|
-
.zIndex(style.zIndex)
|
|
72
|
-
.opacity(style.opacity)
|
|
73
|
-
.linearGradient(style.linearGradient)
|
|
74
|
-
.clip(style.overflow)
|
|
75
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
76
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
77
|
-
.transform(style.transform)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
16
|
@Extend(Radio)
|
|
81
17
|
function radioAttr (attr: RadioAttrs) {
|
|
82
18
|
.radioStyle(attr.radioStyle)
|
|
@@ -99,7 +35,7 @@ function themeStyles(isDisabled: boolean) {
|
|
|
99
35
|
|
|
100
36
|
@Component
|
|
101
37
|
export struct TaroRadio {
|
|
102
|
-
node: TaroRadioElement
|
|
38
|
+
@ObjectLink node: TaroRadioElement
|
|
103
39
|
|
|
104
40
|
aboutToAppear () {
|
|
105
41
|
if (this.node && !this.node._isInit) {
|
|
@@ -117,7 +53,7 @@ export struct TaroRadio {
|
|
|
117
53
|
value: this.node.value || '',
|
|
118
54
|
})
|
|
119
55
|
.checked(this.node.checked)
|
|
120
|
-
.
|
|
56
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
121
57
|
.radioAttr(getAttributes(this.node))
|
|
122
58
|
.onChange((value: boolean) => {
|
|
123
59
|
if (this.node) {
|
|
@@ -156,75 +92,10 @@ export struct TaroRadio {
|
|
|
156
92
|
}
|
|
157
93
|
}
|
|
158
94
|
|
|
159
|
-
@Extend(Flex)
|
|
160
|
-
function radioGroupAttrs (style: TaroStyleType) {
|
|
161
|
-
.id(style.id)
|
|
162
|
-
.key(style.id)
|
|
163
|
-
.flexGrow(style.flexGrow)
|
|
164
|
-
.flexShrink(style.flexShrink)
|
|
165
|
-
.flexBasis(style.flexBasis)
|
|
166
|
-
.alignSelf(style.alignSelf)
|
|
167
|
-
.padding({
|
|
168
|
-
top: style.paddingTop,
|
|
169
|
-
right: style.paddingRight,
|
|
170
|
-
bottom: style.paddingBottom,
|
|
171
|
-
left: style.paddingLeft
|
|
172
|
-
})
|
|
173
|
-
.margin({
|
|
174
|
-
top: style.marginTop,
|
|
175
|
-
right: style.marginRight,
|
|
176
|
-
bottom: style.marginBottom,
|
|
177
|
-
left: style.marginLeft
|
|
178
|
-
})
|
|
179
|
-
.width(style.width)
|
|
180
|
-
.height(style.height)
|
|
181
|
-
.constraintSize({
|
|
182
|
-
minWidth: style.minWidth,
|
|
183
|
-
maxWidth: style.maxWidth,
|
|
184
|
-
minHeight: style.minHeight,
|
|
185
|
-
maxHeight: style.maxHeight
|
|
186
|
-
})
|
|
187
|
-
.backgroundColor(style.backgroundColor)
|
|
188
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
189
|
-
.backgroundImageSize(style.backgroundSize)
|
|
190
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
191
|
-
.borderStyle({
|
|
192
|
-
top: style.borderTopStyle,
|
|
193
|
-
right: style.borderRightStyle,
|
|
194
|
-
bottom: style.borderBottomStyle,
|
|
195
|
-
left: style.borderLeftStyle
|
|
196
|
-
})
|
|
197
|
-
.borderWidth({
|
|
198
|
-
top: style.borderTopWidth,
|
|
199
|
-
right: style.borderRightWidth,
|
|
200
|
-
bottom: style.borderBottomWidth,
|
|
201
|
-
left: style.borderLeftWidth
|
|
202
|
-
})
|
|
203
|
-
.borderColor({
|
|
204
|
-
top: style.borderTopColor,
|
|
205
|
-
right: style.borderRightColor,
|
|
206
|
-
bottom: style.borderBottomColor,
|
|
207
|
-
left: style.borderLeftColor
|
|
208
|
-
})
|
|
209
|
-
.borderRadius({
|
|
210
|
-
topLeft: style.borderTopLeftRadius,
|
|
211
|
-
topRight: style.borderTopRightRadius,
|
|
212
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
213
|
-
bottomRight: style.borderBottomRightRadius
|
|
214
|
-
})
|
|
215
|
-
.zIndex(style.zIndex)
|
|
216
|
-
.opacity(style.opacity)
|
|
217
|
-
.linearGradient(style.linearGradient)
|
|
218
|
-
.clip(style.overflow)
|
|
219
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
220
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
221
|
-
.transform(style.transform)
|
|
222
|
-
}
|
|
223
|
-
|
|
224
95
|
|
|
225
96
|
@Component
|
|
226
97
|
export struct TaroRadioGroup {
|
|
227
|
-
node: TaroRadioGroupElement
|
|
98
|
+
@ObjectLink node: TaroRadioGroupElement
|
|
228
99
|
|
|
229
100
|
@Styles visibleChangeEvent () {
|
|
230
101
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
@@ -253,12 +124,25 @@ export struct TaroRadioGroup {
|
|
|
253
124
|
|
|
254
125
|
build() {
|
|
255
126
|
if (this.node) {
|
|
256
|
-
|
|
257
|
-
|
|
127
|
+
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
128
|
+
Row() {
|
|
129
|
+
createLazyChildren(this.node)
|
|
130
|
+
}
|
|
131
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
132
|
+
.defaultEvent()
|
|
133
|
+
.visibleChangeEvent()
|
|
134
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
135
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
136
|
+
} else {
|
|
137
|
+
Column() {
|
|
138
|
+
createLazyChildren(this.node)
|
|
139
|
+
}
|
|
140
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
141
|
+
.defaultEvent()
|
|
142
|
+
.visibleChangeEvent()
|
|
143
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
144
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
258
145
|
}
|
|
259
|
-
.radioGroupAttrs(getNormalAttributes(this.node))
|
|
260
|
-
.defaultEvent()
|
|
261
|
-
.visibleChangeEvent()
|
|
262
146
|
}
|
|
263
147
|
}
|
|
264
148
|
}
|
|
@@ -1,90 +1,29 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import { getNodeThresholds,
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { getNodeThresholds, shouldBindEvent } from './utils/helper'
|
|
5
5
|
|
|
6
6
|
import type { RichTextProps } from '@tarojs/components/types/RichText'
|
|
7
|
-
import type { TaroAny,
|
|
8
|
-
|
|
9
|
-
@Extend(RichText)
|
|
10
|
-
function attrs (style: TaroStyleType) {
|
|
11
|
-
.id(style.id)
|
|
12
|
-
.key(style.id)
|
|
13
|
-
.flexGrow(style.flexGrow)
|
|
14
|
-
.flexShrink(style.flexShrink)
|
|
15
|
-
.flexBasis(style.flexBasis)
|
|
16
|
-
.alignSelf(style.alignSelf)
|
|
17
|
-
.padding({
|
|
18
|
-
top: style.paddingTop,
|
|
19
|
-
right: style.paddingRight,
|
|
20
|
-
bottom: style.paddingBottom,
|
|
21
|
-
left: style.paddingLeft
|
|
22
|
-
})
|
|
23
|
-
.margin({
|
|
24
|
-
top: style.marginTop,
|
|
25
|
-
right: style.marginRight,
|
|
26
|
-
bottom: style.marginBottom,
|
|
27
|
-
left: style.marginLeft
|
|
28
|
-
})
|
|
29
|
-
.width(style.width)
|
|
30
|
-
.height(style.height)
|
|
31
|
-
.constraintSize({
|
|
32
|
-
minWidth: style.minWidth,
|
|
33
|
-
maxWidth: style.maxWidth,
|
|
34
|
-
minHeight: style.minHeight,
|
|
35
|
-
maxHeight: style.maxHeight
|
|
36
|
-
})
|
|
37
|
-
.backgroundColor(style.backgroundColor)
|
|
38
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
39
|
-
.backgroundImageSize(style.backgroundSize)
|
|
40
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
41
|
-
.borderStyle({
|
|
42
|
-
top: style.borderTopStyle,
|
|
43
|
-
right: style.borderRightStyle,
|
|
44
|
-
bottom: style.borderBottomStyle,
|
|
45
|
-
left: style.borderLeftStyle
|
|
46
|
-
})
|
|
47
|
-
.borderWidth({
|
|
48
|
-
top: style.borderTopWidth,
|
|
49
|
-
right: style.borderRightWidth,
|
|
50
|
-
bottom: style.borderBottomWidth,
|
|
51
|
-
left: style.borderLeftWidth
|
|
52
|
-
})
|
|
53
|
-
.borderColor({
|
|
54
|
-
top: style.borderTopColor,
|
|
55
|
-
right: style.borderRightColor,
|
|
56
|
-
bottom: style.borderBottomColor,
|
|
57
|
-
left: style.borderLeftColor
|
|
58
|
-
})
|
|
59
|
-
.borderRadius({
|
|
60
|
-
topLeft: style.borderTopLeftRadius,
|
|
61
|
-
topRight: style.borderTopRightRadius,
|
|
62
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
63
|
-
bottomRight: style.borderBottomRightRadius
|
|
64
|
-
})
|
|
65
|
-
.zIndex(style.zIndex)
|
|
66
|
-
.opacity(style.opacity)
|
|
67
|
-
.linearGradient(style.linearGradient)
|
|
68
|
-
.clip(style.overflow)
|
|
69
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
70
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
71
|
-
.transform(style.transform)
|
|
72
|
-
}
|
|
73
|
-
|
|
7
|
+
import type { TaroAny, TaroRichTextElement } from '@tarojs/runtime'
|
|
74
8
|
|
|
75
9
|
function generateText (node: TaroRichTextElement): string {
|
|
76
10
|
return parseHtmlNode(node._attrs.nodes || '')
|
|
77
11
|
}
|
|
78
12
|
|
|
79
|
-
@
|
|
80
|
-
export default
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
13
|
+
@Component
|
|
14
|
+
export default struct TaroRichText {
|
|
15
|
+
@ObjectLink node: TaroRichTextElement
|
|
16
|
+
|
|
17
|
+
build () {
|
|
18
|
+
RichText(generateText(this.node))
|
|
19
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
20
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
21
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
22
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
23
|
+
}))
|
|
24
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
25
|
+
|
|
26
|
+
}
|
|
88
27
|
}
|
|
89
28
|
|
|
90
29
|
// 将nodeTree转换成harmony需要的string结构
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
+
import commonStyleModify from './style'
|
|
3
4
|
import { createLazyChildren } from './render'
|
|
5
|
+
import { FlexManager } from './utils/FlexManager'
|
|
4
6
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
5
7
|
import { getNodeThresholds, getNormalAttributes, shouldBindEvent } from './utils/helper'
|
|
6
8
|
|
|
@@ -22,135 +24,6 @@ interface ScrollViewEvent {
|
|
|
22
24
|
scrollHeight: number
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
@Extend(Row)
|
|
26
|
-
function rowAttrs (style: TaroStyleType) {
|
|
27
|
-
.id(style.id)
|
|
28
|
-
.key(style.id)
|
|
29
|
-
.flexGrow(style.flexGrow)
|
|
30
|
-
.flexShrink(style.flexShrink)
|
|
31
|
-
.flexBasis(style.flexBasis)
|
|
32
|
-
.alignSelf(style.alignSelf)
|
|
33
|
-
.padding({
|
|
34
|
-
top: style.paddingTop,
|
|
35
|
-
right: style.paddingRight,
|
|
36
|
-
bottom: style.paddingBottom,
|
|
37
|
-
left: style.paddingLeft
|
|
38
|
-
})
|
|
39
|
-
.margin({
|
|
40
|
-
top: style.marginTop,
|
|
41
|
-
right: style.marginRight,
|
|
42
|
-
bottom: style.marginBottom,
|
|
43
|
-
left: style.marginLeft
|
|
44
|
-
})
|
|
45
|
-
.height(style.height)
|
|
46
|
-
.constraintSize({
|
|
47
|
-
minWidth: style.minWidth || style.width,
|
|
48
|
-
maxWidth: style.maxWidth,
|
|
49
|
-
minHeight: style.minHeight,
|
|
50
|
-
maxHeight: style.maxHeight
|
|
51
|
-
})
|
|
52
|
-
.backgroundColor(style.backgroundColor)
|
|
53
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
54
|
-
.backgroundImageSize(style.backgroundSize)
|
|
55
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
56
|
-
.borderStyle({
|
|
57
|
-
top: style.borderTopStyle,
|
|
58
|
-
right: style.borderRightStyle,
|
|
59
|
-
bottom: style.borderBottomStyle,
|
|
60
|
-
left: style.borderLeftStyle
|
|
61
|
-
})
|
|
62
|
-
.borderWidth({
|
|
63
|
-
top: style.borderTopWidth,
|
|
64
|
-
right: style.borderRightWidth,
|
|
65
|
-
bottom: style.borderBottomWidth,
|
|
66
|
-
left: style.borderLeftWidth
|
|
67
|
-
})
|
|
68
|
-
.borderColor({
|
|
69
|
-
top: style.borderTopColor,
|
|
70
|
-
right: style.borderRightColor,
|
|
71
|
-
bottom: style.borderBottomColor,
|
|
72
|
-
left: style.borderLeftColor
|
|
73
|
-
})
|
|
74
|
-
.borderRadius({
|
|
75
|
-
topLeft: style.borderTopLeftRadius,
|
|
76
|
-
topRight: style.borderTopRightRadius,
|
|
77
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
78
|
-
bottomRight: style.borderBottomRightRadius
|
|
79
|
-
})
|
|
80
|
-
.zIndex(style.zIndex)
|
|
81
|
-
.opacity(style.opacity)
|
|
82
|
-
.linearGradient(style.linearGradient)
|
|
83
|
-
.clip(style.overflow)
|
|
84
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
85
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
86
|
-
.transform(style.transform)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
@Extend(Column)
|
|
90
|
-
function columnAttrs (style: TaroStyleType) {
|
|
91
|
-
.id(style.id)
|
|
92
|
-
.key(style.id)
|
|
93
|
-
.flexGrow(style.flexGrow)
|
|
94
|
-
.flexShrink(style.flexShrink)
|
|
95
|
-
.flexBasis(style.flexBasis)
|
|
96
|
-
.alignSelf(style.alignSelf)
|
|
97
|
-
.padding({
|
|
98
|
-
top: style.paddingTop,
|
|
99
|
-
right: style.paddingRight,
|
|
100
|
-
bottom: style.paddingBottom,
|
|
101
|
-
left: style.paddingLeft
|
|
102
|
-
})
|
|
103
|
-
.margin({
|
|
104
|
-
top: style.marginTop,
|
|
105
|
-
right: style.marginRight,
|
|
106
|
-
bottom: style.marginBottom,
|
|
107
|
-
left: style.marginLeft
|
|
108
|
-
})
|
|
109
|
-
.width(style.width)
|
|
110
|
-
.constraintSize({
|
|
111
|
-
minWidth: style.minWidth,
|
|
112
|
-
maxWidth: style.maxWidth,
|
|
113
|
-
minHeight: style.minHeight || style.height,
|
|
114
|
-
maxHeight: style.maxHeight
|
|
115
|
-
})
|
|
116
|
-
.backgroundColor(style.backgroundColor)
|
|
117
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
118
|
-
.backgroundImageSize(style.backgroundSize)
|
|
119
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
120
|
-
.borderStyle({
|
|
121
|
-
top: style.borderTopStyle,
|
|
122
|
-
right: style.borderRightStyle,
|
|
123
|
-
bottom: style.borderBottomStyle,
|
|
124
|
-
left: style.borderLeftStyle
|
|
125
|
-
})
|
|
126
|
-
.borderWidth({
|
|
127
|
-
top: style.borderTopWidth,
|
|
128
|
-
right: style.borderRightWidth,
|
|
129
|
-
bottom: style.borderBottomWidth,
|
|
130
|
-
left: style.borderLeftWidth
|
|
131
|
-
})
|
|
132
|
-
.borderColor({
|
|
133
|
-
top: style.borderTopColor,
|
|
134
|
-
right: style.borderRightColor,
|
|
135
|
-
bottom: style.borderBottomColor,
|
|
136
|
-
left: style.borderLeftColor
|
|
137
|
-
})
|
|
138
|
-
.borderRadius({
|
|
139
|
-
topLeft: style.borderTopLeftRadius,
|
|
140
|
-
topRight: style.borderTopRightRadius,
|
|
141
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
142
|
-
bottomRight: style.borderBottomRightRadius
|
|
143
|
-
})
|
|
144
|
-
.zIndex(style.zIndex)
|
|
145
|
-
.opacity(style.opacity)
|
|
146
|
-
.linearGradient(style.linearGradient)
|
|
147
|
-
.clip(style.overflow)
|
|
148
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
149
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
150
|
-
.transform(style.transform)
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
27
|
function getAttributes (node: TaroScrollViewElement): ScrollViewAttrs {
|
|
155
28
|
const _attrs = node._attrs
|
|
156
29
|
const scrollAttrs: ScrollViewAttrs = {
|
|
@@ -168,7 +41,7 @@ function getScrollable (node: TaroScrollViewElement) {
|
|
|
168
41
|
}
|
|
169
42
|
|
|
170
43
|
function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', xOffset?: number, yOffset?: number) {
|
|
171
|
-
const currentOffset
|
|
44
|
+
const currentOffset = node.scroller.currentOffset() as ScrollViewCurrentOffset
|
|
172
45
|
const currentXOffset = currentOffset.xOffset
|
|
173
46
|
const currentYOffset = currentOffset.yOffset
|
|
174
47
|
const value: ScrollViewEvent = {
|
|
@@ -184,42 +57,75 @@ function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', x
|
|
|
184
57
|
eventHandler(event, eventName, node)
|
|
185
58
|
}
|
|
186
59
|
|
|
187
|
-
@
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
60
|
+
@Extend(Row)
|
|
61
|
+
function rowAttrs (style: TaroStyleType) {
|
|
62
|
+
.constraintSize({
|
|
63
|
+
minWidth: style.minWidth || style.width,
|
|
64
|
+
maxWidth: style.maxWidth,
|
|
65
|
+
minHeight: style.minHeight,
|
|
66
|
+
maxHeight: style.maxHeight
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@Extend(Column)
|
|
71
|
+
function columnAttrs (style: TaroStyleType) {
|
|
72
|
+
.constraintSize({
|
|
73
|
+
minWidth: style.minWidth,
|
|
74
|
+
maxWidth: style.maxWidth,
|
|
75
|
+
minHeight: style.minHeight || style.height,
|
|
76
|
+
maxHeight: style.maxHeight
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@Component
|
|
81
|
+
export default struct TaroScrollView {
|
|
82
|
+
@ObjectLink node: TaroScrollViewElement
|
|
83
|
+
|
|
84
|
+
build () {
|
|
85
|
+
Scroll(this.node.scroller) {
|
|
86
|
+
if (this.node._attrs.scrollX) {
|
|
191
87
|
Row() {
|
|
192
|
-
createLazyChildren(node)
|
|
88
|
+
createLazyChildren(this.node)
|
|
193
89
|
}
|
|
90
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
91
|
+
.rowAttrs(getNormalAttributes(this.node))
|
|
194
92
|
.width(null)
|
|
195
|
-
.rowAttrs(getNormalAttributes(node))
|
|
196
93
|
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
197
|
-
node._scroll = areaResult
|
|
198
|
-
}, node, ['scroll', 'scrollstart', 'scrollend']))
|
|
94
|
+
this.node._scroll = areaResult
|
|
95
|
+
}, this.node, ['scroll', 'scrollstart', 'scrollend']))
|
|
96
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
97
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
98
|
+
.flexGrow(0).flexShrink(0)
|
|
199
99
|
} else {
|
|
200
100
|
Column() {
|
|
201
|
-
createLazyChildren(node)
|
|
101
|
+
createLazyChildren(this.node)
|
|
202
102
|
}
|
|
103
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
104
|
+
.columnAttrs(getNormalAttributes(this.node))
|
|
203
105
|
.height(null)
|
|
204
|
-
.columnAttrs(getNormalAttributes(node))
|
|
205
106
|
.alignItems(HorizontalAlign.Start)
|
|
206
107
|
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
207
|
-
node._scroll = areaResult
|
|
208
|
-
}, node, ['scroll', 'scrollstart', 'scrollend']))
|
|
108
|
+
this.node._scroll = areaResult
|
|
109
|
+
}, this.node, ['scroll', 'scrollstart', 'scrollend']))
|
|
110
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
111
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
112
|
+
.flexGrow(0).flexShrink(0)
|
|
209
113
|
}
|
|
210
114
|
}
|
|
211
|
-
.width(getNormalAttributes(node).width)
|
|
212
|
-
.height(getNormalAttributes(node).height)
|
|
213
|
-
.flexGrow(getNormalAttributes(node).flexGrow)
|
|
214
|
-
.
|
|
215
|
-
.
|
|
216
|
-
.
|
|
217
|
-
.
|
|
218
|
-
.
|
|
219
|
-
|
|
115
|
+
.width(getNormalAttributes(this.node).width)
|
|
116
|
+
.height(getNormalAttributes(this.node).height)
|
|
117
|
+
.flexGrow(getNormalAttributes(this.node).flexGrow)
|
|
118
|
+
.flexShrink(getNormalAttributes(this.node).flexShrink)
|
|
119
|
+
.scrollable(getScrollable(this.node))
|
|
120
|
+
.scrollBar(getAttributes(this.node).scrollBar)
|
|
121
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
122
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
123
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
124
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
220
125
|
}))
|
|
221
|
-
.onScroll(shouldBindEvent(() => { handleScrollEvent(node, 'scroll') }, node, ['scroll']))
|
|
222
|
-
.onScrollStart(shouldBindEvent(() => { handleScrollEvent(node, 'scrollstart') }, node, ['scrollstart']))
|
|
223
|
-
.onScrollStop(shouldBindEvent(() => { handleScrollEvent(node, 'scrollend') }, node, ['scrollend']))
|
|
224
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
126
|
+
.onScroll(shouldBindEvent(() => { handleScrollEvent(this.node, 'scroll') }, this.node, ['scroll']))
|
|
127
|
+
.onScrollStart(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollstart') }, this.node, ['scrollstart']))
|
|
128
|
+
.onScrollStop(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollend') }, this.node, ['scrollend']))
|
|
129
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
130
|
+
}
|
|
225
131
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { getNodeThresholds, shouldBindEvent } from './utils/helper'
|
|
4
5
|
|
|
5
|
-
import type { TaroAny, TaroSliderElement,
|
|
6
|
+
import type { TaroAny, TaroSliderElement, TaroEvent } from '@tarojs/runtime'
|
|
6
7
|
|
|
7
8
|
interface SliderAttrs {
|
|
8
9
|
selectedColor?: ResourceColor
|
|
@@ -11,71 +12,6 @@ interface SliderAttrs {
|
|
|
11
12
|
blockColor?: ResourceColor
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
@Extend(Slider)
|
|
15
|
-
function style (style: TaroStyleType) {
|
|
16
|
-
.id(style.id)
|
|
17
|
-
.key(style.id)
|
|
18
|
-
.flexGrow(style.flexGrow)
|
|
19
|
-
.flexShrink(style.flexShrink)
|
|
20
|
-
.flexBasis(style.flexBasis)
|
|
21
|
-
.alignSelf(style.alignSelf)
|
|
22
|
-
.padding({
|
|
23
|
-
top: style.paddingTop,
|
|
24
|
-
right: style.paddingRight,
|
|
25
|
-
bottom: style.paddingBottom,
|
|
26
|
-
left: style.paddingLeft
|
|
27
|
-
})
|
|
28
|
-
.margin({
|
|
29
|
-
top: style.marginTop,
|
|
30
|
-
right: style.marginRight,
|
|
31
|
-
bottom: style.marginBottom,
|
|
32
|
-
left: style.marginLeft
|
|
33
|
-
})
|
|
34
|
-
.width(style.width)
|
|
35
|
-
.height(style.height)
|
|
36
|
-
.constraintSize({
|
|
37
|
-
minWidth: style.minWidth,
|
|
38
|
-
maxWidth: style.maxWidth,
|
|
39
|
-
minHeight: style.minHeight,
|
|
40
|
-
maxHeight: style.maxHeight
|
|
41
|
-
})
|
|
42
|
-
.backgroundColor(style.backgroundColor)
|
|
43
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
44
|
-
.backgroundImageSize(style.backgroundSize)
|
|
45
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
46
|
-
.borderStyle({
|
|
47
|
-
top: style.borderTopStyle,
|
|
48
|
-
right: style.borderRightStyle,
|
|
49
|
-
bottom: style.borderBottomStyle,
|
|
50
|
-
left: style.borderLeftStyle
|
|
51
|
-
})
|
|
52
|
-
.borderWidth({
|
|
53
|
-
top: style.borderTopWidth,
|
|
54
|
-
right: style.borderRightWidth,
|
|
55
|
-
bottom: style.borderBottomWidth,
|
|
56
|
-
left: style.borderLeftWidth
|
|
57
|
-
})
|
|
58
|
-
.borderColor({
|
|
59
|
-
top: style.borderTopColor,
|
|
60
|
-
right: style.borderRightColor,
|
|
61
|
-
bottom: style.borderBottomColor,
|
|
62
|
-
left: style.borderLeftColor
|
|
63
|
-
})
|
|
64
|
-
.borderRadius({
|
|
65
|
-
topLeft: style.borderTopLeftRadius,
|
|
66
|
-
topRight: style.borderTopRightRadius,
|
|
67
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
68
|
-
bottomRight: style.borderBottomRightRadius
|
|
69
|
-
})
|
|
70
|
-
.zIndex(style.zIndex)
|
|
71
|
-
.opacity(style.opacity)
|
|
72
|
-
.linearGradient(style.linearGradient)
|
|
73
|
-
.clip(style.overflow)
|
|
74
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
75
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
76
|
-
.transform(style.transform)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
15
|
@Extend(Slider)
|
|
80
16
|
function attrs (attr: SliderAttrs) {
|
|
81
17
|
.selectedColor(attr.selectedColor)
|
|
@@ -101,7 +37,7 @@ function themeStyles(isDisabled: boolean) {
|
|
|
101
37
|
|
|
102
38
|
@Component
|
|
103
39
|
export default struct TaroSlider {
|
|
104
|
-
node: TaroSliderElement
|
|
40
|
+
@ObjectLink node: TaroSliderElement
|
|
105
41
|
|
|
106
42
|
@State value: number = 0
|
|
107
43
|
|
|
@@ -126,7 +62,7 @@ export default struct TaroSlider {
|
|
|
126
62
|
style: SliderStyle.OutSet,
|
|
127
63
|
direction: Axis.Horizontal
|
|
128
64
|
})
|
|
129
|
-
.
|
|
65
|
+
.attributeModifier(commonStyleModify.setNode(node))
|
|
130
66
|
.attrs(getAttributes(node))
|
|
131
67
|
.width(!!node._attrs.showValue ? '90%' : '100%')
|
|
132
68
|
.themeStyles(!!node._attrs.disabled)
|