@tarojs/plugin-platform-harmony-ets 4.0.0-canary.8 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apis/base/system.ts +73 -20
- package/dist/apis/canvas/index.ts +10 -1
- package/dist/apis/device/clipboard.ts +23 -8
- package/dist/apis/framework/index.ts +1 -5
- package/dist/apis/index.ts +27 -17
- package/dist/apis/media/image/index.ts +169 -17
- package/dist/apis/network/request.ts +5 -5
- package/dist/apis/route/index.ts +15 -0
- package/dist/apis/storage/index.ts +146 -78
- package/dist/apis/ui/animation/animation.ts +71 -29
- package/dist/apis/ui/background.ts +2 -1
- package/dist/apis/ui/interaction/index.ts +58 -59
- package/dist/apis/ui/navigation-bar/index.ts +1 -1
- package/dist/apis/ui/pull-down-refresh.ts +9 -3
- package/dist/apis/ui/scroll/index.ts +5 -5
- package/dist/apis/ui/tab-bar.ts +3 -3
- package/dist/apis/utils/index.ts +21 -2
- package/dist/apis/utils/permissions.ts +6 -0
- package/dist/apis/wxml/IntersectionObserver.ts +18 -10
- package/dist/apis/wxml/index.ts +2 -0
- package/dist/apis/wxml/selectorQuery.ts +26 -13
- package/dist/components-harmony-ets/button.ets +63 -77
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +75 -258
- package/dist/components-harmony-ets/form.ets +51 -158
- package/dist/components-harmony-ets/icon.ets +33 -83
- package/dist/components-harmony-ets/image.ets +35 -79
- package/dist/components-harmony-ets/index.ets +92 -0
- package/dist/components-harmony-ets/innerHtml.ets +11 -6
- package/dist/components-harmony-ets/input.ets +64 -101
- package/dist/components-harmony-ets/label.ets +72 -174
- package/dist/components-harmony-ets/listView.ets +31 -0
- package/dist/components-harmony-ets/movableArea.ets +126 -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 +46 -163
- 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 +80 -264
- package/dist/components-harmony-ets/richText.ets +20 -102
- package/dist/components-harmony-ets/scrollList.ets +108 -0
- package/dist/components-harmony-ets/scrollView.ets +71 -160
- package/dist/components-harmony-ets/slider.ets +22 -82
- package/dist/components-harmony-ets/stickySection.ets +42 -0
- package/dist/components-harmony-ets/style.ets +410 -0
- package/dist/components-harmony-ets/swiper.ets +64 -87
- package/dist/components-harmony-ets/switch.ets +39 -99
- package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
- package/dist/components-harmony-ets/text.ets +111 -113
- package/dist/components-harmony-ets/textArea.ets +51 -95
- package/dist/components-harmony-ets/utils/AttributeManager.ets +2 -2
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -2
- package/dist/components-harmony-ets/utils/flexManager.ets +50 -19
- package/dist/components-harmony-ets/utils/helper.ets +20 -8
- 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 +54 -50
- package/dist/components-harmony-ets/utils/styles.ets +172 -92
- package/dist/components-harmony-ets/video.ets +37 -88
- package/dist/components-harmony-ets/view.ets +63 -159
- package/dist/components-harmony-ets/webView.ets +41 -98
- package/dist/index.d.ts +152 -0
- package/dist/index.js +187 -56
- 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 +5 -1
- package/dist/runtime-ets/dom/bind.ts +28 -12
- package/dist/runtime-ets/dom/class-list.ts +2 -2
- package/dist/runtime-ets/dom/cssNesting.ts +419 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +28 -42
- package/dist/runtime-ets/dom/document.ts +22 -8
- package/dist/runtime-ets/dom/element/canvas.ts +136 -0
- package/dist/runtime-ets/dom/element/element.ts +376 -57
- package/dist/runtime-ets/dom/element/form.ts +31 -26
- package/dist/runtime-ets/dom/element/index.ts +30 -2
- package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
- package/dist/runtime-ets/dom/element/movableView.ts +248 -0
- package/dist/runtime-ets/dom/element/normal.ts +35 -8
- package/dist/runtime-ets/dom/element/progress.ts +11 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
- package/dist/runtime-ets/dom/element/text.ts +1 -8
- package/dist/runtime-ets/dom/element/video.ts +5 -4
- package/dist/runtime-ets/dom/element/webView.ts +12 -5
- package/dist/runtime-ets/dom/event.ts +3 -5
- package/dist/runtime-ets/dom/eventTarget.ts +2 -3
- package/dist/runtime-ets/dom/node.ts +65 -32
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +418 -237
- package/dist/runtime-ets/dom/stylesheet/index.ts +29 -311
- package/dist/runtime-ets/dom/stylesheet/type.ts +53 -11
- package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
- package/dist/runtime-ets/index.ts +2 -2
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/utils/index.ts +74 -13
- package/dist/runtime-ets/utils/info.ts +2 -2
- package/dist/runtime-framework/react/app.ts +25 -30
- package/dist/runtime-framework/react/hooks.ts +3 -4
- package/dist/runtime-framework/react/index.ts +0 -2
- package/dist/runtime-framework/react/native-page.ts +219 -82
- package/dist/runtime-framework/react/page.ts +6 -10
- package/dist/runtime-framework/react/utils/index.ts +3 -3
- package/dist/runtime-framework/solid/app.ts +30 -46
- 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 +85 -31
- 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 +3 -5
- package/dist/runtime-utils.d.ts +827 -0
- package/dist/runtime-utils.js +618 -245
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +618 -245
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +14 -15
- package/static/media/cancel.svg +1 -1
- package/static/media/circle.svg +1 -1
- package/static/media/clear.svg +1 -1
- package/static/media/download.svg +1 -1
- package/static/media/info.svg +1 -1
- package/static/media/info_circle.svg +1 -1
- package/static/media/search.svg +1 -1
- package/static/media/success.svg +1 -1
- package/static/media/success_no_circle.svg +1 -1
- package/static/media/warn.svg +1 -1
- package/types/harmony.d.ts +5 -0
- package/types/index.d.ts +4 -0
- package/types/runtime.d.ts +3 -1
- package/dist/runtime-ets/utils/bind.ts +0 -24
- /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
|
@@ -1,10 +1,12 @@
|
|
|
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 PseduoChildren from './pseudo'
|
|
5
|
+
import { FlexManager } from './utils/flexManager'
|
|
4
6
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
5
|
-
import { getNodeThresholds,
|
|
7
|
+
import { getNodeThresholds, getStyleAttr, shouldBindEvent } from './utils/helper'
|
|
6
8
|
|
|
7
|
-
import type { TaroAny,
|
|
9
|
+
import type { TaroAny, TaroScrollViewElement, TaroEvent } from '@tarojs/runtime'
|
|
8
10
|
|
|
9
11
|
interface ScrollViewAttrs {
|
|
10
12
|
scrollBar: BarState
|
|
@@ -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,12 @@ function getScrollable (node: TaroScrollViewElement) {
|
|
|
168
41
|
}
|
|
169
42
|
|
|
170
43
|
function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', xOffset?: number, yOffset?: number) {
|
|
44
|
+
if (!node || !node.scroller) return
|
|
45
|
+
|
|
171
46
|
const currentOffset = node.scroller.currentOffset() as ScrollViewCurrentOffset
|
|
47
|
+
|
|
48
|
+
if (!currentOffset) return
|
|
49
|
+
|
|
172
50
|
const currentXOffset = currentOffset.xOffset
|
|
173
51
|
const currentYOffset = currentOffset.yOffset
|
|
174
52
|
const value: ScrollViewEvent = {
|
|
@@ -176,50 +54,83 @@ function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', x
|
|
|
176
54
|
deltaY: vp2px(yOffset),
|
|
177
55
|
scrollLeft: vp2px(currentXOffset),
|
|
178
56
|
scrollTop: vp2px(currentYOffset),
|
|
179
|
-
scrollWidth: vp2px(Number(node._scroll?.width)),
|
|
180
|
-
scrollHeight: vp2px(Number(node._scroll?.height)),
|
|
57
|
+
scrollWidth: vp2px(Number(node._nodeInfo?._scroll?.width)),
|
|
58
|
+
scrollHeight: vp2px(Number(node._nodeInfo?._scroll?.height)),
|
|
181
59
|
}
|
|
182
60
|
const event: TaroEvent = createTaroEvent(eventName, { detail: value }, node)
|
|
183
61
|
|
|
184
62
|
eventHandler(event, eventName, node)
|
|
185
63
|
}
|
|
186
64
|
|
|
187
|
-
@
|
|
188
|
-
export default
|
|
189
|
-
|
|
190
|
-
|
|
65
|
+
@Component
|
|
66
|
+
export default struct TaroScrollView {
|
|
67
|
+
@Builder customBuilder() {}
|
|
68
|
+
@BuilderParam createLazyChildren: (node: TaroScrollViewElement, layer?: number) => void = this.customBuilder
|
|
69
|
+
@ObjectLink node: TaroScrollViewElement
|
|
70
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
71
|
+
|
|
72
|
+
aboutToAppear(): void {
|
|
73
|
+
if (this.node) {
|
|
74
|
+
this.node._instance = this
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
isScrollX() {
|
|
79
|
+
return this.node._attrs.scrollX || getStyleAttr(this.node, 'overflow') === 'scroll' && getStyleAttr(this.node, 'flexDirection') === FlexDirection.Row
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
build () {
|
|
83
|
+
Scroll(this.node.scroller) {
|
|
84
|
+
if (this.isScrollX()) {
|
|
191
85
|
Row() {
|
|
192
|
-
|
|
86
|
+
if (this.node._pseudo_before || this.node._pseudo_after) {
|
|
87
|
+
PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
|
|
88
|
+
} else {
|
|
89
|
+
this.createLazyChildren(this.node, 0)
|
|
90
|
+
}
|
|
193
91
|
}
|
|
92
|
+
.alignItems(FlexManager.alignItems<VerticalAlign>(this.node))
|
|
93
|
+
.justifyContent(FlexManager.justifyContent(this.node))
|
|
94
|
+
.height(getStyleAttr(this.node, 'height'))
|
|
194
95
|
.width(null)
|
|
195
|
-
.rowAttrs(getNormalAttributes(node))
|
|
196
96
|
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
197
|
-
node._scroll = areaResult
|
|
198
|
-
}, node, ['scroll', 'scrollstart', 'scrollend']))
|
|
97
|
+
this.node._nodeInfo._scroll = areaResult
|
|
98
|
+
}, this.node, ['scroll', 'scrollstart', 'scrollend']))
|
|
99
|
+
.flexGrow(0).flexShrink(0)
|
|
199
100
|
} else {
|
|
200
101
|
Column() {
|
|
201
|
-
|
|
102
|
+
if (this.node._pseudo_before || this.node._pseudo_after) {
|
|
103
|
+
PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
|
|
104
|
+
} else {
|
|
105
|
+
this.createLazyChildren(this.node, 0)
|
|
106
|
+
}
|
|
202
107
|
}
|
|
108
|
+
.alignItems(FlexManager.alignItems<HorizontalAlign>(this.node))
|
|
109
|
+
.justifyContent(FlexManager.justifyContent(this.node))
|
|
110
|
+
.width(getStyleAttr(this.node, 'width'))
|
|
203
111
|
.height(null)
|
|
204
|
-
.columnAttrs(getNormalAttributes(node))
|
|
205
|
-
.alignItems(HorizontalAlign.Start)
|
|
206
112
|
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
207
|
-
node._scroll = areaResult
|
|
208
|
-
}, node, ['scroll', 'scrollstart', 'scrollend']))
|
|
113
|
+
this.node._nodeInfo._scroll = areaResult
|
|
114
|
+
}, this.node, ['scroll', 'scrollstart', 'scrollend']))
|
|
115
|
+
.flexGrow(0).flexShrink(0)
|
|
209
116
|
}
|
|
210
117
|
}
|
|
211
|
-
.
|
|
212
|
-
.
|
|
213
|
-
.
|
|
214
|
-
.
|
|
215
|
-
.
|
|
216
|
-
.
|
|
217
|
-
.
|
|
218
|
-
.
|
|
219
|
-
|
|
118
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
119
|
+
.width(this.isScrollX() ? getStyleAttr(this.node, 'width') : undefined)
|
|
120
|
+
.height(!this.isScrollX() ? getStyleAttr(this.node, 'height') : undefined)
|
|
121
|
+
.align(Alignment.TopStart)
|
|
122
|
+
.clip(true)
|
|
123
|
+
.scrollable(getScrollable(this.node))
|
|
124
|
+
.scrollBar(getAttributes(this.node).scrollBar)
|
|
125
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
126
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
|
|
127
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
128
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
220
129
|
}))
|
|
221
|
-
.
|
|
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))
|
|
130
|
+
.onDidScroll(shouldBindEvent((xOffset: number, yOffset: number) => { handleScrollEvent(this.node, 'scroll', xOffset, yOffset) }, this.node, ['scroll']))
|
|
131
|
+
.onScrollStart(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollstart') }, this.node, ['scrollstart']))
|
|
132
|
+
.onScrollStop(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollend') }, this.node, ['scrollend']))
|
|
133
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
134
|
+
.onReachEnd(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrolltolower') }, this.node, ['scrolltolower']))
|
|
135
|
+
}
|
|
225
136
|
}
|
|
@@ -1,79 +1,16 @@
|
|
|
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
|
|
9
10
|
trackColor?: ResourceColor
|
|
10
11
|
trackThickness?: Length
|
|
11
12
|
blockColor?: ResourceColor
|
|
12
|
-
|
|
13
|
-
|
|
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)
|
|
13
|
+
disabled?: boolean
|
|
77
14
|
}
|
|
78
15
|
|
|
79
16
|
@Extend(Slider)
|
|
@@ -82,6 +19,7 @@ function attrs (attr: SliderAttrs) {
|
|
|
82
19
|
.trackColor(attr.trackColor)
|
|
83
20
|
.trackThickness(attr.trackThickness)
|
|
84
21
|
.blockColor(attr.blockColor)
|
|
22
|
+
.enabled(!attr.disabled)
|
|
85
23
|
}
|
|
86
24
|
|
|
87
25
|
function getAttributes (node: TaroSliderElement): SliderAttrs {
|
|
@@ -91,6 +29,7 @@ function getAttributes (node: TaroSliderElement): SliderAttrs {
|
|
|
91
29
|
sliderAttrs.trackColor = _attrs.backgroundColor || _attrs.color || '#e9e9e9'
|
|
92
30
|
sliderAttrs.trackThickness = _attrs.blockSize
|
|
93
31
|
sliderAttrs.blockColor = _attrs.blockColor || '#ffffff'
|
|
32
|
+
sliderAttrs.disabled = !!_attrs.disabled
|
|
94
33
|
return sliderAttrs
|
|
95
34
|
}
|
|
96
35
|
|
|
@@ -101,9 +40,12 @@ function themeStyles(isDisabled: boolean) {
|
|
|
101
40
|
|
|
102
41
|
@Component
|
|
103
42
|
export default struct TaroSlider {
|
|
104
|
-
|
|
43
|
+
@Builder customBuilder() {}
|
|
44
|
+
@BuilderParam createLazyChildren: (node: TaroSliderElement, layer?: number) => void = this.customBuilder
|
|
45
|
+
@ObjectLink node: TaroSliderElement
|
|
105
46
|
|
|
106
47
|
@State value: number = 0
|
|
48
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
107
49
|
|
|
108
50
|
aboutToAppear () {
|
|
109
51
|
if (this.node) {
|
|
@@ -126,7 +68,7 @@ export default struct TaroSlider {
|
|
|
126
68
|
style: SliderStyle.OutSet,
|
|
127
69
|
direction: Axis.Horizontal
|
|
128
70
|
})
|
|
129
|
-
.
|
|
71
|
+
.attributeModifier(commonStyleModify.setNode(node).setAnimationStyle(this.overwriteStyle))
|
|
130
72
|
.attrs(getAttributes(node))
|
|
131
73
|
.width(!!node._attrs.showValue ? '90%' : '100%')
|
|
132
74
|
.themeStyles(!!node._attrs.disabled)
|
|
@@ -138,7 +80,7 @@ export default struct TaroSlider {
|
|
|
138
80
|
} else {
|
|
139
81
|
this.value = value
|
|
140
82
|
this.node?.updateFormWidgetValue(value)
|
|
141
|
-
|
|
83
|
+
|
|
142
84
|
if (mode === SliderChangeMode.End) {
|
|
143
85
|
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.value } }, node)
|
|
144
86
|
eventHandler(event, 'change', node)
|
|
@@ -148,7 +90,7 @@ export default struct TaroSlider {
|
|
|
148
90
|
}
|
|
149
91
|
}
|
|
150
92
|
})
|
|
151
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
93
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
152
94
|
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
153
95
|
if (this.node) {
|
|
154
96
|
this.node._nodeInfo.areaInfo = res[1]
|
|
@@ -158,18 +100,16 @@ export default struct TaroSlider {
|
|
|
158
100
|
}
|
|
159
101
|
|
|
160
102
|
build() {
|
|
161
|
-
if (this.node) {
|
|
162
|
-
|
|
163
|
-
Row() {
|
|
164
|
-
this.createSlider(this.node)
|
|
165
|
-
Text(Number(this.value).toFixed(0))
|
|
166
|
-
.width('10%')
|
|
167
|
-
.textAlign(TextAlign.Center)
|
|
168
|
-
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
169
|
-
}
|
|
170
|
-
} else {
|
|
103
|
+
if (!!this.node._attrs.showValue) {
|
|
104
|
+
Row() {
|
|
171
105
|
this.createSlider(this.node)
|
|
106
|
+
Text(Number(this.value).toFixed(0))
|
|
107
|
+
.width('10%')
|
|
108
|
+
.textAlign(TextAlign.Center)
|
|
109
|
+
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
172
110
|
}
|
|
111
|
+
} else {
|
|
112
|
+
this.createSlider(this.node)
|
|
173
113
|
}
|
|
174
114
|
}
|
|
175
|
-
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import commonStyleModify from './style'
|
|
2
|
+
|
|
3
|
+
import type { TaroViewElement, TaroElement, TaroAny } from '@tarojs/runtime'
|
|
4
|
+
|
|
5
|
+
@Component
|
|
6
|
+
export default struct TaroStickySection {
|
|
7
|
+
@Builder customBuilder() {}
|
|
8
|
+
@BuilderParam createLazyChildren: (node: TaroViewElement, layer?: number) => void = this.customBuilder
|
|
9
|
+
@ObjectLink node: TaroViewElement
|
|
10
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
11
|
+
|
|
12
|
+
aboutToAppear(): void {
|
|
13
|
+
if (this.node) {
|
|
14
|
+
this.node._instance = this
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Builder
|
|
19
|
+
itemHead(header: TaroViewElement) {
|
|
20
|
+
Stack() {
|
|
21
|
+
LazyForEach(header, (item: TaroElement) => {
|
|
22
|
+
if (item.tagName === 'STICKY-HEADER') {
|
|
23
|
+
this.createLazyChildren(item as TaroViewElement, 0)
|
|
24
|
+
}
|
|
25
|
+
}, (item: TaroElement) => `${item._nid}-${item._nodeInfo?.layer || 0}`)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
build() {
|
|
30
|
+
ListItemGroup({
|
|
31
|
+
header: this.itemHead(this.node)
|
|
32
|
+
}) {
|
|
33
|
+
ForEach(this.node.children, (item: TaroElement) => {
|
|
34
|
+
if (item.tagName === 'LIST-VIEW') {
|
|
35
|
+
this.createLazyChildren(item as TaroViewElement, 0)
|
|
36
|
+
}
|
|
37
|
+
}, (item: TaroElement) => `${item._nid}-${item._nodeInfo?.layer || 0}`)
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
41
|
+
}
|
|
42
|
+
}
|