@tarojs/plugin-platform-harmony-ets 4.0.0-beta.3 → 4.0.0-beta.30
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 +53 -20
- package/dist/apis/canvas/index.ts +10 -1
- package/dist/apis/framework/index.ts +1 -5
- package/dist/apis/index.ts +27 -12
- 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/ui/animation/animation.ts +2 -1
- package/dist/apis/utils/index.ts +1 -1
- package/dist/apis/wxml/IntersectionObserver.ts +18 -10
- package/dist/apis/wxml/index.ts +2 -0
- package/dist/components-harmony-ets/button.ets +50 -78
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +23 -209
- package/dist/components-harmony-ets/form.ets +44 -158
- package/dist/components-harmony-ets/icon.ets +38 -83
- package/dist/components-harmony-ets/image.ets +29 -78
- package/dist/components-harmony-ets/index.ets +53 -0
- package/dist/components-harmony-ets/innerHtml.ets +11 -6
- package/dist/components-harmony-ets/input.ets +11 -67
- package/dist/components-harmony-ets/label.ets +58 -172
- package/dist/components-harmony-ets/movableArea.ets +96 -0
- package/dist/components-harmony-ets/movableView.ets +74 -0
- package/dist/components-harmony-ets/picker.ets +32 -147
- package/dist/components-harmony-ets/progress.ets +54 -0
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +23 -210
- package/dist/components-harmony-ets/richText.ets +22 -102
- package/dist/components-harmony-ets/scrollView.ets +73 -169
- package/dist/components-harmony-ets/slider.ets +11 -72
- package/dist/components-harmony-ets/style.ets +280 -0
- package/dist/components-harmony-ets/swiper.ets +37 -87
- package/dist/components-harmony-ets/switch.ets +11 -71
- package/dist/components-harmony-ets/text.ets +57 -89
- package/dist/components-harmony-ets/textArea.ets +11 -67
- package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
- package/dist/components-harmony-ets/utils/flexManager.ets +11 -9
- package/dist/components-harmony-ets/utils/helper.ets +4 -5
- 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 +50 -51
- package/dist/components-harmony-ets/utils/styles.ets +167 -87
- package/dist/components-harmony-ets/video.ets +41 -89
- package/dist/components-harmony-ets/view.ets +53 -159
- package/dist/components-harmony-ets/webView.ets +44 -99
- package/dist/index.d.ts +151 -0
- package/dist/index.js +69 -32
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/window.ts +7 -0
- package/dist/runtime-ets/current.ts +3 -0
- package/dist/runtime-ets/dom/bind.ts +20 -6
- package/dist/runtime-ets/dom/cssNesting.ts +393 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +12 -40
- 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 +128 -51
- package/dist/runtime-ets/dom/element/form.ts +15 -18
- package/dist/runtime-ets/dom/element/index.ts +16 -3
- package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
- package/dist/runtime-ets/dom/element/movableView.ts +193 -0
- package/dist/runtime-ets/dom/element/normal.ts +8 -3
- package/dist/runtime-ets/dom/element/progress.ts +12 -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 -3
- package/dist/runtime-ets/dom/element/webView.ts +8 -0
- package/dist/runtime-ets/dom/event.ts +0 -1
- package/dist/runtime-ets/dom/eventTarget.ts +0 -3
- package/dist/runtime-ets/dom/node.ts +29 -27
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +189 -211
- package/dist/runtime-ets/dom/stylesheet/index.ts +28 -308
- package/dist/runtime-ets/dom/stylesheet/type.ts +18 -6
- package/dist/runtime-ets/dom/stylesheet/util.ts +31 -25
- package/dist/runtime-ets/index.ts +2 -2
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/utils/index.ts +43 -10
- package/dist/runtime-ets/utils/info.ts +1 -1
- package/dist/runtime-framework/react/app.ts +7 -2
- package/dist/runtime-framework/react/index.ts +0 -2
- package/dist/runtime-framework/react/native-page.ts +22 -12
- package/dist/runtime-framework/react/page.ts +3 -8
- package/dist/runtime-framework/solid/app.ts +25 -45
- package/dist/runtime-framework/solid/connect.ts +21 -3
- package/dist/runtime-framework/solid/hooks.ts +16 -11
- package/dist/runtime-framework/solid/index.ts +6 -2
- package/dist/runtime-framework/solid/page.ts +84 -30
- package/dist/runtime-framework/solid/reconciler/props.ts +65 -20
- package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
- package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
- package/dist/runtime-framework/solid/utils/index.ts +0 -2
- package/dist/runtime-utils.d.ts +827 -0
- package/dist/runtime-utils.js +210 -106
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +210 -106
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +13 -13
- package/types/index.d.ts +4 -0
- package/dist/runtime-ets/utils/bind.ts +0 -24
- /package/dist/components-harmony-ets/{index.ts → tag.ts} +0 -0
- /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 { rowModify, columnModify } 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 = {
|
|
@@ -176,50 +49,81 @@ function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', x
|
|
|
176
49
|
deltaY: vp2px(yOffset),
|
|
177
50
|
scrollLeft: vp2px(currentXOffset),
|
|
178
51
|
scrollTop: vp2px(currentYOffset),
|
|
179
|
-
scrollWidth: vp2px(Number(node._scroll?.width)),
|
|
180
|
-
scrollHeight: vp2px(Number(node._scroll?.height)),
|
|
52
|
+
scrollWidth: vp2px(Number(node._nodeInfo?._scroll?.width)),
|
|
53
|
+
scrollHeight: vp2px(Number(node._nodeInfo?._scroll?.height)),
|
|
181
54
|
}
|
|
182
55
|
const event: TaroEvent = createTaroEvent(eventName, { detail: value }, node)
|
|
183
56
|
|
|
184
57
|
eventHandler(event, eventName, node)
|
|
185
58
|
}
|
|
186
59
|
|
|
187
|
-
@
|
|
188
|
-
export default
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
60
|
+
@Component
|
|
61
|
+
export default struct TaroScrollView {
|
|
62
|
+
@Builder customBuilder() {}
|
|
63
|
+
@BuilderParam createLazyChildren: (node: TaroScrollViewElement) => void = this.customBuilder
|
|
64
|
+
@ObjectLink node: TaroScrollViewElement
|
|
65
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
66
|
+
|
|
67
|
+
aboutToAppear(): void {
|
|
68
|
+
if (this.node) {
|
|
69
|
+
this.node._instance = this
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
build () {
|
|
74
|
+
if (this.node.hmStyle?.display !== 'none') {
|
|
75
|
+
Scroll(this.node.scroller) {
|
|
76
|
+
if (this.node._attrs.scrollX) {
|
|
77
|
+
Row() {
|
|
78
|
+
if (this.node._pseudo_before || this.node._pseudo_after) {
|
|
79
|
+
PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
|
|
80
|
+
} else {
|
|
81
|
+
this.createLazyChildren(this.node)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
85
|
+
.width(null)
|
|
86
|
+
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
87
|
+
this.node._nodeInfo._scroll = areaResult
|
|
88
|
+
}, this.node, ['scroll', 'scrollstart', 'scrollend']))
|
|
89
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
90
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
91
|
+
.flexGrow(0).flexShrink(0)
|
|
92
|
+
} else {
|
|
93
|
+
Column() {
|
|
94
|
+
if (this.node._pseudo_before || this.node._pseudo_after) {
|
|
95
|
+
PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
|
|
96
|
+
} else {
|
|
97
|
+
this.createLazyChildren(this.node)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
101
|
+
.height(null)
|
|
102
|
+
.alignItems(HorizontalAlign.Start)
|
|
103
|
+
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
104
|
+
this.node._nodeInfo._scroll = areaResult
|
|
105
|
+
}, this.node, ['scroll', 'scrollstart', 'scrollend']))
|
|
106
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
107
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
108
|
+
.flexGrow(0).flexShrink(0)
|
|
202
109
|
}
|
|
203
|
-
.height(null)
|
|
204
|
-
.columnAttrs(getNormalAttributes(node))
|
|
205
|
-
.alignItems(HorizontalAlign.Start)
|
|
206
|
-
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
207
|
-
node._scroll = areaResult
|
|
208
|
-
}, node, ['scroll', 'scrollstart', 'scrollend']))
|
|
209
110
|
}
|
|
111
|
+
.width(getStyleAttr(this.node, 'width'))
|
|
112
|
+
.height(getStyleAttr(this.node, 'height'))
|
|
113
|
+
.flexGrow(this.node.hmStyle?.flexGrow)
|
|
114
|
+
.flexShrink(this.node.hmStyle?.flexShrink)
|
|
115
|
+
.scrollable(getScrollable(this.node))
|
|
116
|
+
.scrollBar(getAttributes(this.node).scrollBar)
|
|
117
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
118
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
119
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
120
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
121
|
+
}))
|
|
122
|
+
.onScroll(shouldBindEvent(() => { handleScrollEvent(this.node, 'scroll') }, this.node, ['scroll']))
|
|
123
|
+
.onScrollStart(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollstart') }, this.node, ['scrollstart']))
|
|
124
|
+
.onScrollStop(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollend') }, this.node, ['scrollend']))
|
|
125
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
126
|
+
.onReachEnd(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrolltolower') }, this.node, ['scrolltolower']))
|
|
210
127
|
}
|
|
211
|
-
|
|
212
|
-
.height(getNormalAttributes(node).height)
|
|
213
|
-
.flexGrow(getNormalAttributes(node).flexGrow)
|
|
214
|
-
.scrollable(getScrollable(node))
|
|
215
|
-
.scrollBar(getAttributes(node).scrollBar)
|
|
216
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
217
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
218
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
219
|
-
node._nodeInfo.areaInfo = res[1]
|
|
220
|
-
}))
|
|
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))
|
|
128
|
+
}
|
|
225
129
|
}
|
|
@@ -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,9 +37,12 @@ function themeStyles(isDisabled: boolean) {
|
|
|
101
37
|
|
|
102
38
|
@Component
|
|
103
39
|
export default struct TaroSlider {
|
|
104
|
-
|
|
40
|
+
@Builder customBuilder() {}
|
|
41
|
+
@BuilderParam createLazyChildren: (node: TaroSliderElement) => void = this.customBuilder
|
|
42
|
+
@ObjectLink node: TaroSliderElement
|
|
105
43
|
|
|
106
44
|
@State value: number = 0
|
|
45
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
107
46
|
|
|
108
47
|
aboutToAppear () {
|
|
109
48
|
if (this.node) {
|
|
@@ -126,7 +65,7 @@ export default struct TaroSlider {
|
|
|
126
65
|
style: SliderStyle.OutSet,
|
|
127
66
|
direction: Axis.Horizontal
|
|
128
67
|
})
|
|
129
|
-
.
|
|
68
|
+
.attributeModifier(commonStyleModify.setNode(node).setAnimationStyle(this.overwriteStyle))
|
|
130
69
|
.attrs(getAttributes(node))
|
|
131
70
|
.width(!!node._attrs.showValue ? '90%' : '100%')
|
|
132
71
|
.themeStyles(!!node._attrs.disabled)
|
|
@@ -138,7 +77,7 @@ export default struct TaroSlider {
|
|
|
138
77
|
} else {
|
|
139
78
|
this.value = value
|
|
140
79
|
this.node?.updateFormWidgetValue(value)
|
|
141
|
-
|
|
80
|
+
|
|
142
81
|
if (mode === SliderChangeMode.End) {
|
|
143
82
|
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.value } }, node)
|
|
144
83
|
eventHandler(event, 'change', node)
|
|
@@ -158,7 +97,7 @@ export default struct TaroSlider {
|
|
|
158
97
|
}
|
|
159
98
|
|
|
160
99
|
build() {
|
|
161
|
-
if (this.node) {
|
|
100
|
+
if (this.node && this.node.hmStyle?.display !== 'none') {
|
|
162
101
|
if (!!this.node._attrs.showValue) {
|
|
163
102
|
Row() {
|
|
164
103
|
this.createSlider(this.node)
|
|
@@ -172,4 +111,4 @@ export default struct TaroSlider {
|
|
|
172
111
|
}
|
|
173
112
|
}
|
|
174
113
|
}
|
|
175
|
-
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import type { TaroAny, HarmonyStyle, TaroElement, TaroStyleType } from '@tarojs/runtime'
|
|
2
|
+
import { isUndefined } from '@tarojs/shared'
|
|
3
|
+
import { computeBackgroundPosition } from './utils'
|
|
4
|
+
import { getNormalAttributes } from './utils/helper'
|
|
5
|
+
import { isMaxWidthView } from './utils/styles'
|
|
6
|
+
|
|
7
|
+
class CommonStyleModify implements AttributeModifier<CommonAttribute> {
|
|
8
|
+
initStyle?: TaroStyleType
|
|
9
|
+
node: TaroElement | null = null
|
|
10
|
+
style: TaroStyleType | null = null
|
|
11
|
+
overwriteStyle: Record<string, TaroAny> = {}
|
|
12
|
+
|
|
13
|
+
setAnimationStyle (overwriteStyle: Record<string, TaroAny>) {
|
|
14
|
+
this.overwriteStyle = overwriteStyle
|
|
15
|
+
|
|
16
|
+
return this
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
setNode (node: TaroElement, initStyle?: TaroStyleType) {
|
|
20
|
+
this.node = node
|
|
21
|
+
this.style = getNormalAttributes(this.node)
|
|
22
|
+
this.initStyle = initStyle
|
|
23
|
+
// 覆盖初始化样式
|
|
24
|
+
if (initStyle) {
|
|
25
|
+
Object.keys(initStyle).forEach(key => {
|
|
26
|
+
if (this.style && !this.style[key]) {
|
|
27
|
+
this.style[key] = initStyle[key]
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
return this
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
applyNormalAttribute(instance: CommonAttribute): void {
|
|
35
|
+
if (this.node && this.style) {
|
|
36
|
+
setNormalAttributeIntoInstance(instance, this.style, this.node)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
setAnimationAttributeIntoInstance(instance, this.overwriteStyle)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
class PseudoStyleModify implements AttributeModifier<CommonAttribute> {
|
|
44
|
+
style: TaroStyleType | null = null
|
|
45
|
+
|
|
46
|
+
setStyle (style: HarmonyStyle) {
|
|
47
|
+
this.style = style
|
|
48
|
+
return this
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
applyNormalAttribute(instance: CommonAttribute): void {
|
|
52
|
+
if (this.style) {
|
|
53
|
+
setNormalAttributeIntoInstance(instance, this.style)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class RowStyleModify extends CommonStyleModify {
|
|
60
|
+
|
|
61
|
+
applyNormalAttribute(instance: CommonAttribute): void {
|
|
62
|
+
if (this.style) {
|
|
63
|
+
setNormalAttributeIntoInstance(instance, this.style, this.node)
|
|
64
|
+
instance.constraintSize({
|
|
65
|
+
minWidth: this.style.minWidth || this.style.width,
|
|
66
|
+
maxWidth: this.style.maxWidth,
|
|
67
|
+
minHeight: this.style.minHeight,
|
|
68
|
+
maxHeight: this.style.maxHeight
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
setAnimationAttributeIntoInstance(instance, this.overwriteStyle)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
class ColumnStyleModify extends CommonStyleModify {
|
|
77
|
+
applyNormalAttribute(instance: CommonAttribute): void {
|
|
78
|
+
if (this.style) {
|
|
79
|
+
setNormalAttributeIntoInstance(instance, this.style, this.node)
|
|
80
|
+
instance.constraintSize({
|
|
81
|
+
minWidth: this.style.minWidth,
|
|
82
|
+
maxWidth: this.style.maxWidth,
|
|
83
|
+
minHeight: this.style.minHeight || this.style.height,
|
|
84
|
+
maxHeight: this.style.maxHeight
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
setAnimationAttributeIntoInstance(instance, this.overwriteStyle)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function setAnimationAttributeIntoInstance(instance: CommonAttribute, overwriteStyle: Record<string, TaroAny>) {
|
|
93
|
+
// Animation 需要提前和 @State 变量绑定才能产生动画效果,因此不能做 if else 判断
|
|
94
|
+
instance.translate({
|
|
95
|
+
x: overwriteStyle.translate?.x,
|
|
96
|
+
y: overwriteStyle.translate?.y,
|
|
97
|
+
z: overwriteStyle.translate?.z,
|
|
98
|
+
}).scale({
|
|
99
|
+
x: overwriteStyle.scale?.x,
|
|
100
|
+
y: overwriteStyle.scale?.y,
|
|
101
|
+
z: overwriteStyle.scale?.z,
|
|
102
|
+
centerX: overwriteStyle.transformOrigin?.x,
|
|
103
|
+
centerY: overwriteStyle.transformOrigin?.y,
|
|
104
|
+
}).rotate({
|
|
105
|
+
x: overwriteStyle.rotate?.x,
|
|
106
|
+
y: overwriteStyle.rotate?.y,
|
|
107
|
+
z: overwriteStyle.rotate?.z,
|
|
108
|
+
centerX: overwriteStyle.transformOrigin?.x,
|
|
109
|
+
centerY: overwriteStyle.transformOrigin?.y,
|
|
110
|
+
angle: overwriteStyle.rotate?.angle,
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function setNormalAttributeIntoInstance(instance: CommonAttribute, style: TaroStyleType, node?: TaroElement | null) {
|
|
115
|
+
if (!isUndefined(style.id)) {
|
|
116
|
+
instance.id(style.id)
|
|
117
|
+
instance.key(style.id)
|
|
118
|
+
}
|
|
119
|
+
if (!isUndefined(style.flexGrow)) {
|
|
120
|
+
instance.flexGrow(style.flexGrow)
|
|
121
|
+
}
|
|
122
|
+
if (!isUndefined(style.flexShrink)) {
|
|
123
|
+
instance.flexShrink(style.flexShrink)
|
|
124
|
+
}
|
|
125
|
+
if (!isUndefined(style.flexBasis)) {
|
|
126
|
+
instance.flexBasis(style.flexBasis)
|
|
127
|
+
}
|
|
128
|
+
if (!isUndefined(style.alignSelf)) {
|
|
129
|
+
instance.alignSelf(style.alignSelf)
|
|
130
|
+
}
|
|
131
|
+
if (!isUndefined(style.paddingTop) || !isUndefined(style.paddingRight) || !isUndefined(style.paddingBottom) || !isUndefined(style.paddingLeft)) {
|
|
132
|
+
instance.padding({
|
|
133
|
+
top: style.paddingTop,
|
|
134
|
+
right: style.paddingRight,
|
|
135
|
+
bottom: style.paddingBottom,
|
|
136
|
+
left: style.paddingLeft
|
|
137
|
+
})
|
|
138
|
+
}
|
|
139
|
+
if (!isUndefined(style.marginTop) || !isUndefined(style.marginRight) || !isUndefined(style.marginBottom) || !isUndefined(style.marginLeft)) {
|
|
140
|
+
instance.margin({
|
|
141
|
+
top: style.marginTop,
|
|
142
|
+
right: style.marginRight,
|
|
143
|
+
bottom: style.marginBottom,
|
|
144
|
+
left: style.marginLeft
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
if (node) {
|
|
148
|
+
instance.width(isMaxWidthView(node as TaroElement) && isUndefined(style.width) ? '100%' : style.width)
|
|
149
|
+
} else {
|
|
150
|
+
if (!isUndefined(style.width)) {
|
|
151
|
+
instance.width(style.width)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (!isUndefined(style.height)) {
|
|
155
|
+
instance.height(style.height)
|
|
156
|
+
}
|
|
157
|
+
if (!isUndefined(style.minWidth) || !isUndefined(style.maxWidth) || !isUndefined(style.minHeight) || !isUndefined(style.maxHeight)) {
|
|
158
|
+
instance.constraintSize({
|
|
159
|
+
minWidth: style.minWidth,
|
|
160
|
+
maxWidth: style.maxWidth,
|
|
161
|
+
minHeight: style.minHeight,
|
|
162
|
+
maxHeight: style.maxHeight
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
if (!isUndefined(style.backgroundColor)) {
|
|
166
|
+
instance.backgroundColor(style.backgroundColor)
|
|
167
|
+
}
|
|
168
|
+
if (!isUndefined(style.backgroundImage)) {
|
|
169
|
+
if (style.backgroundImage.colors) {
|
|
170
|
+
instance.linearGradient(style.backgroundImage)
|
|
171
|
+
} else {
|
|
172
|
+
instance.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (!isUndefined(style.backgroundSize)) {
|
|
176
|
+
instance.backgroundImageSize(style.backgroundSize)
|
|
177
|
+
}
|
|
178
|
+
if (!isUndefined(style.backgroundPosition)) {
|
|
179
|
+
if (typeof style.backgroundPosition !== 'number') {
|
|
180
|
+
let pos = computeBackgroundPosition(style)
|
|
181
|
+
instance.backgroundImagePosition({
|
|
182
|
+
x: pos.offsetX,
|
|
183
|
+
y: pos.offsetY,
|
|
184
|
+
})
|
|
185
|
+
} else {
|
|
186
|
+
instance.backgroundImagePosition(style.backgroundPosition)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (!isUndefined(style.borderTopStyle) || !isUndefined(style.borderRightStyle) || !isUndefined(style.borderBottomStyle) || !isUndefined(style.borderLeftStyle)) {
|
|
190
|
+
instance.borderStyle({
|
|
191
|
+
top: style.borderTopStyle,
|
|
192
|
+
right: style.borderRightStyle,
|
|
193
|
+
bottom: style.borderBottomStyle,
|
|
194
|
+
left: style.borderLeftStyle
|
|
195
|
+
})
|
|
196
|
+
}
|
|
197
|
+
if (!isUndefined(style.borderTopWidth) || !isUndefined(style.borderRightWidth) || !isUndefined(style.borderBottomWidth) || !isUndefined(style.borderLeftWidth)) {
|
|
198
|
+
instance.borderWidth({
|
|
199
|
+
top: style.borderTopWidth,
|
|
200
|
+
right: style.borderRightWidth,
|
|
201
|
+
bottom: style.borderBottomWidth,
|
|
202
|
+
left: style.borderLeftWidth
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
if (!isUndefined(style.borderTopColor) || !isUndefined(style.borderRightColor) || !isUndefined(style.borderBottomColor) || !isUndefined(style.borderLeftColor)) {
|
|
206
|
+
instance.borderColor({
|
|
207
|
+
top: style.borderTopColor,
|
|
208
|
+
right: style.borderRightColor,
|
|
209
|
+
bottom: style.borderBottomColor,
|
|
210
|
+
left: style.borderLeftColor
|
|
211
|
+
})
|
|
212
|
+
}
|
|
213
|
+
if (!isUndefined(style.borderTopLeftRadius) || !isUndefined(style.borderTopRightRadius) || !isUndefined(style.borderBottomLeftRadius) || !isUndefined(style.borderBottomRightRadius)) {
|
|
214
|
+
instance.borderRadius({
|
|
215
|
+
topLeft: style.borderTopLeftRadius,
|
|
216
|
+
topRight: style.borderTopRightRadius,
|
|
217
|
+
bottomLeft: style.borderBottomLeftRadius,
|
|
218
|
+
bottomRight: style.borderBottomRightRadius
|
|
219
|
+
})
|
|
220
|
+
}
|
|
221
|
+
if (!isUndefined(style.zIndex)) {
|
|
222
|
+
instance.zIndex(style.zIndex)
|
|
223
|
+
}
|
|
224
|
+
if (!isUndefined(style.opacity)) {
|
|
225
|
+
instance.opacity(style.opacity)
|
|
226
|
+
}
|
|
227
|
+
if (!isUndefined(style.overflow)) {
|
|
228
|
+
instance.clip(style.overflow === 'hidden')
|
|
229
|
+
}
|
|
230
|
+
// if (!isUndefined(style.transformOrigin)) {
|
|
231
|
+
// instance.rotate({ centerX: style.transformOrigin.x, centerY: style.transformOrigin.y, angle: 0 })
|
|
232
|
+
// instance.scale({ centerX: style.transformOrigin.x, centerY: style.transformOrigin.y })
|
|
233
|
+
// }
|
|
234
|
+
if (!isUndefined(style.transform)) {
|
|
235
|
+
if (style.transform.Translate) {
|
|
236
|
+
instance.translate({
|
|
237
|
+
x: style.transform.Translate.x || 0,
|
|
238
|
+
y: style.transform.Translate.y || 0,
|
|
239
|
+
z: style.transform.Translate.z || 0,
|
|
240
|
+
})
|
|
241
|
+
}
|
|
242
|
+
if (style.transform.Scale) {
|
|
243
|
+
instance.scale({
|
|
244
|
+
x: style.transform.Scale.x || 0,
|
|
245
|
+
y: style.transform.Scale.y || 0,
|
|
246
|
+
z: style.transform.Scale.z || 0,
|
|
247
|
+
centerX: style.transformOrigin?.x || 0,
|
|
248
|
+
centerY: style.transformOrigin?.y || 0,
|
|
249
|
+
})
|
|
250
|
+
}
|
|
251
|
+
if (style.transform.Rotate) {
|
|
252
|
+
instance.rotate({
|
|
253
|
+
x: style.transform.Rotate.x || 0,
|
|
254
|
+
y: style.transform.Rotate.y || 0,
|
|
255
|
+
z: style.transform.Rotate.z || 0,
|
|
256
|
+
centerX: style.transformOrigin?.x || 0,
|
|
257
|
+
centerY: style.transformOrigin?.y || 0,
|
|
258
|
+
angle: 0
|
|
259
|
+
})
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (style.position === 'absolute' || style.position === 'fixed') {
|
|
263
|
+
instance.position({
|
|
264
|
+
x: style.left || 0,
|
|
265
|
+
y: style.top || 0,
|
|
266
|
+
})
|
|
267
|
+
}
|
|
268
|
+
if (style.position === 'relative') {
|
|
269
|
+
instance.offset({
|
|
270
|
+
x: style.left || 0,
|
|
271
|
+
y: style.top || 0,
|
|
272
|
+
})
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export const pseudoModify = new PseudoStyleModify()
|
|
277
|
+
export const rowModify = new RowStyleModify()
|
|
278
|
+
export const columnModify = new ColumnStyleModify()
|
|
279
|
+
|
|
280
|
+
export default new CommonStyleModify()
|