@tarojs/plugin-platform-harmony-ets 4.0.0-beta.1 → 4.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apis/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 +22 -71
- package/dist/components-harmony-ets/checkbox.ets +22 -138
- package/dist/components-harmony-ets/form.ets +29 -76
- package/dist/components-harmony-ets/icon.ets +5 -67
- package/dist/components-harmony-ets/image.ets +2 -66
- package/dist/components-harmony-ets/innerHtml.ets +2 -2
- package/dist/components-harmony-ets/input.ets +2 -61
- package/dist/components-harmony-ets/label.ets +40 -81
- package/dist/components-harmony-ets/picker.ets +31 -140
- package/dist/components-harmony-ets/radio.ets +22 -138
- package/dist/components-harmony-ets/richText.ets +4 -70
- package/dist/components-harmony-ets/scrollView.ets +34 -132
- package/dist/components-harmony-ets/slider.ets +4 -68
- package/dist/components-harmony-ets/style.ets +154 -0
- package/dist/components-harmony-ets/swiper.ets +4 -68
- package/dist/components-harmony-ets/switch.ets +4 -68
- package/dist/components-harmony-ets/text.ets +5 -69
- package/dist/components-harmony-ets/textArea.ets +2 -61
- 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 +4 -68
- package/dist/components-harmony-ets/view.ets +15 -125
- package/dist/components-harmony-ets/webView.ets +50 -0
- package/dist/index.js +87 -2
- 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/index.ts +4 -1
- package/dist/runtime-ets/dom/element/normal.ts +1 -0
- package/dist/runtime-ets/dom/element/webView.ts +61 -0
- 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,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,6 +57,26 @@ function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', x
|
|
|
184
57
|
eventHandler(event, eventName, node)
|
|
185
58
|
}
|
|
186
59
|
|
|
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
|
+
|
|
187
80
|
@Builder
|
|
188
81
|
export default function TaroScrollView (node: TaroScrollViewElement) {
|
|
189
82
|
Scroll(node.scroller) {
|
|
@@ -191,26 +84,35 @@ export default function TaroScrollView (node: TaroScrollViewElement) {
|
|
|
191
84
|
Row() {
|
|
192
85
|
createLazyChildren(node)
|
|
193
86
|
}
|
|
194
|
-
.
|
|
87
|
+
.attributeModifier(commonStyleModify.setNode(node))
|
|
195
88
|
.rowAttrs(getNormalAttributes(node))
|
|
89
|
+
.width(null)
|
|
196
90
|
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
197
91
|
node._scroll = areaResult
|
|
198
92
|
}, node, ['scroll', 'scrollstart', 'scrollend']))
|
|
93
|
+
.alignItems(FlexManager.flexOptions(node).alignItems as VerticalAlign)
|
|
94
|
+
.justifyContent(FlexManager.flexOptions(node).justifyContent)
|
|
95
|
+
.flexGrow(0).flexShrink(0)
|
|
199
96
|
} else {
|
|
200
97
|
Column() {
|
|
201
98
|
createLazyChildren(node)
|
|
202
99
|
}
|
|
203
|
-
.
|
|
100
|
+
.attributeModifier(commonStyleModify.setNode(node))
|
|
204
101
|
.columnAttrs(getNormalAttributes(node))
|
|
102
|
+
.height(null)
|
|
205
103
|
.alignItems(HorizontalAlign.Start)
|
|
206
104
|
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
207
105
|
node._scroll = areaResult
|
|
208
106
|
}, node, ['scroll', 'scrollstart', 'scrollend']))
|
|
107
|
+
.alignItems(FlexManager.flexOptions(node).alignItems as HorizontalAlign)
|
|
108
|
+
.justifyContent(FlexManager.flexOptions(node).justifyContent)
|
|
109
|
+
.flexGrow(0).flexShrink(0)
|
|
209
110
|
}
|
|
210
111
|
}
|
|
211
112
|
.width(getNormalAttributes(node).width)
|
|
212
113
|
.height(getNormalAttributes(node).height)
|
|
213
114
|
.flexGrow(getNormalAttributes(node).flexGrow)
|
|
115
|
+
.flexShrink(getNormalAttributes(node).flexShrink)
|
|
214
116
|
.scrollable(getScrollable(node))
|
|
215
117
|
.scrollBar(getAttributes(node).scrollBar)
|
|
216
118
|
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
@@ -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)
|
|
@@ -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)
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { TaroElement, TaroStyleType } from '@tarojs/runtime'
|
|
2
|
+
import { isUndefined } from '../shared'
|
|
3
|
+
import { getNormalAttributes } from './utils/helper'
|
|
4
|
+
|
|
5
|
+
function getTop (node: TaroElement): Length | number {
|
|
6
|
+
return node?.hmStyle?.top || 0
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function getLeft (node: TaroElement): Length | number {
|
|
10
|
+
return node?.hmStyle?.left || 0
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
class CommonStyleModify implements AttributeModifier<CommonAttribute> {
|
|
14
|
+
node: TaroElement | null = null
|
|
15
|
+
style: TaroStyleType | null = null
|
|
16
|
+
|
|
17
|
+
setNode (node: TaroElement) {
|
|
18
|
+
this.node = node
|
|
19
|
+
this.style = getNormalAttributes(this.node)
|
|
20
|
+
|
|
21
|
+
return this
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
applyNormalAttribute(instance: CommonAttribute): void {
|
|
25
|
+
if (this.node && this.style) {
|
|
26
|
+
|
|
27
|
+
if (!isUndefined(this.style.id)) {
|
|
28
|
+
instance.id(this.style.id)
|
|
29
|
+
instance.key(this.style.id)
|
|
30
|
+
}
|
|
31
|
+
if (!isUndefined(this.style.flexGrow)) {
|
|
32
|
+
instance.flexGrow(this.style.flexGrow)
|
|
33
|
+
}
|
|
34
|
+
if (!isUndefined(this.style.flexShrink)) {
|
|
35
|
+
instance.flexShrink(this.style.flexShrink)
|
|
36
|
+
}
|
|
37
|
+
if (!isUndefined(this.style.flexBasis)) {
|
|
38
|
+
instance.flexBasis(this.style.flexBasis)
|
|
39
|
+
}
|
|
40
|
+
if (!isUndefined(this.style.alignSelf)) {
|
|
41
|
+
instance.alignSelf(this.style.alignSelf)
|
|
42
|
+
}
|
|
43
|
+
if (!isUndefined(this.style.paddingTop) || !isUndefined(this.style.paddingRight) || !isUndefined(this.style.paddingBottom) || !isUndefined(this.style.paddingLeft)) {
|
|
44
|
+
instance.padding({
|
|
45
|
+
top: this.style.paddingTop,
|
|
46
|
+
right: this.style.paddingRight,
|
|
47
|
+
bottom: this.style.paddingBottom,
|
|
48
|
+
left: this.style.paddingLeft
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
if (!isUndefined(this.style.marginTop) || !isUndefined(this.style.marginRight) || !isUndefined(this.style.marginBottom) || !isUndefined(this.style.marginLeft)) {
|
|
52
|
+
instance.margin({
|
|
53
|
+
top: this.style.marginTop,
|
|
54
|
+
right: this.style.marginRight,
|
|
55
|
+
bottom: this.style.marginBottom,
|
|
56
|
+
left: this.style.marginLeft
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
if (!isUndefined(this.style.width)) {
|
|
60
|
+
instance.width(this.style.width)
|
|
61
|
+
}
|
|
62
|
+
if (!isUndefined(this.style.height)) {
|
|
63
|
+
instance.height(this.style.height)
|
|
64
|
+
}
|
|
65
|
+
if (!isUndefined(this.style.minWidth) || !isUndefined(this.style.maxWidth) || !isUndefined(this.style.minHeight) || !isUndefined(this.style.maxHeight)) {
|
|
66
|
+
instance.constraintSize({
|
|
67
|
+
minWidth: this.style.minWidth,
|
|
68
|
+
maxWidth: this.style.maxWidth,
|
|
69
|
+
minHeight: this.style.minHeight,
|
|
70
|
+
maxHeight: this.style.maxHeight
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
if (!isUndefined(this.style.backgroundColor)) {
|
|
74
|
+
instance.backgroundColor(this.style.backgroundColor)
|
|
75
|
+
}
|
|
76
|
+
if (!isUndefined(this.style.backgroundImage)) {
|
|
77
|
+
instance.backgroundImage(this.style.backgroundImage?.src, this.style.backgroundRepeat)
|
|
78
|
+
}
|
|
79
|
+
if (!isUndefined(this.style.backgroundSize)) {
|
|
80
|
+
instance.backgroundImageSize(this.style.backgroundSize)
|
|
81
|
+
}
|
|
82
|
+
if (!isUndefined(this.style.backgroundPosition)) {
|
|
83
|
+
instance.backgroundImagePosition(this.style.backgroundPosition)
|
|
84
|
+
}
|
|
85
|
+
if (!isUndefined(this.style.borderTopStyle) || !isUndefined(this.style.borderRightStyle) || !isUndefined(this.style.borderBottomStyle) || !isUndefined(this.style.borderLeftStyle)) {
|
|
86
|
+
instance.borderStyle({
|
|
87
|
+
top: this.style.borderTopStyle,
|
|
88
|
+
right: this.style.borderRightStyle,
|
|
89
|
+
bottom: this.style.borderBottomStyle,
|
|
90
|
+
left: this.style.borderLeftStyle
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
if (!isUndefined(this.style.borderTopWidth) || !isUndefined(this.style.borderRightWidth) || !isUndefined(this.style.borderBottomWidth) || !isUndefined(this.style.borderLeftWidth)) {
|
|
94
|
+
instance.borderWidth({
|
|
95
|
+
top: this.style.borderTopWidth,
|
|
96
|
+
right: this.style.borderRightWidth,
|
|
97
|
+
bottom: this.style.borderBottomWidth,
|
|
98
|
+
left: this.style.borderLeftWidth
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
if (!isUndefined(this.style.borderTopColor) || !isUndefined(this.style.borderRightColor) || !isUndefined(this.style.borderBottomColor) || !isUndefined(this.style.borderLeftColor)) {
|
|
102
|
+
instance.borderColor({
|
|
103
|
+
top: this.style.borderTopColor,
|
|
104
|
+
right: this.style.borderRightColor,
|
|
105
|
+
bottom: this.style.borderBottomColor,
|
|
106
|
+
left: this.style.borderLeftColor
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
if (!isUndefined(this.style.borderTopLeftRadius) || !isUndefined(this.style.borderTopRightRadius) || !isUndefined(this.style.borderBottomLeftRadius) || !isUndefined(this.style.borderBottomRightRadius)) {
|
|
110
|
+
instance.borderRadius({
|
|
111
|
+
topLeft: this.style.borderTopLeftRadius,
|
|
112
|
+
topRight: this.style.borderTopRightRadius,
|
|
113
|
+
bottomLeft: this.style.borderBottomLeftRadius,
|
|
114
|
+
bottomRight: this.style.borderBottomRightRadius
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
if (!isUndefined(this.style.zIndex)) {
|
|
118
|
+
instance.zIndex(this.style.zIndex)
|
|
119
|
+
}
|
|
120
|
+
if (!isUndefined(this.style.opacity)) {
|
|
121
|
+
instance.opacity(this.style.opacity)
|
|
122
|
+
}
|
|
123
|
+
if (!isUndefined(this.style.linearGradient)) {
|
|
124
|
+
instance.linearGradient(this.style.linearGradient)
|
|
125
|
+
}
|
|
126
|
+
if (!isUndefined(this.style.overflow)) {
|
|
127
|
+
instance.clip(this.style.overflow)
|
|
128
|
+
}
|
|
129
|
+
if (!isUndefined(this.style.transformOrigin)) {
|
|
130
|
+
instance.rotate({ centerX: this.style.transformOrigin.x, centerY: this.style.transformOrigin.y, angle: 0 })
|
|
131
|
+
instance.scale({ centerX: this.style.transformOrigin.x, centerY: this.style.transformOrigin.y })
|
|
132
|
+
}
|
|
133
|
+
if (!isUndefined(this.style.transform)) {
|
|
134
|
+
instance.transform(this.style.transform)
|
|
135
|
+
}
|
|
136
|
+
if (this.node.hmStyle?.position === 'absolute' || this.node.hmStyle?.position === 'fixed') {
|
|
137
|
+
instance.position({
|
|
138
|
+
x: getLeft(this.node),
|
|
139
|
+
y: getTop(this.node)
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
if (this.node.hmStyle?.position === 'relative') {
|
|
143
|
+
instance.offset({
|
|
144
|
+
x: getLeft(this.node),
|
|
145
|
+
y: getTop(this.node)
|
|
146
|
+
})
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const modify = new CommonStyleModify()
|
|
153
|
+
|
|
154
|
+
export default modify
|
|
@@ -1,9 +1,10 @@
|
|
|
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
|
-
import { getNodeThresholds,
|
|
5
|
+
import { getNodeThresholds, shouldBindEvent } from './utils/helper'
|
|
5
6
|
|
|
6
|
-
import type {
|
|
7
|
+
import type { TaroSwiperElement, TaroEvent, TaroAny } from '@tarojs/runtime'
|
|
7
8
|
|
|
8
9
|
interface SwiperAttrs {
|
|
9
10
|
index?: number
|
|
@@ -15,71 +16,6 @@ interface SwiperAttrs {
|
|
|
15
16
|
indicator?: boolean
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
@Extend(Swiper)
|
|
19
|
-
function swiperStyle (style: TaroStyleType) {
|
|
20
|
-
.id(style.id)
|
|
21
|
-
.key(style.id)
|
|
22
|
-
.flexGrow(style.flexGrow)
|
|
23
|
-
.flexShrink(style.flexShrink)
|
|
24
|
-
.flexBasis(style.flexBasis)
|
|
25
|
-
.alignSelf(style.alignSelf)
|
|
26
|
-
.padding({
|
|
27
|
-
top: style.paddingTop,
|
|
28
|
-
right: style.paddingRight,
|
|
29
|
-
bottom: style.paddingBottom,
|
|
30
|
-
left: style.paddingLeft
|
|
31
|
-
})
|
|
32
|
-
.margin({
|
|
33
|
-
top: style.marginTop,
|
|
34
|
-
right: style.marginRight,
|
|
35
|
-
bottom: style.marginBottom,
|
|
36
|
-
left: style.marginLeft
|
|
37
|
-
})
|
|
38
|
-
.width(style.width)
|
|
39
|
-
.height(style.height)
|
|
40
|
-
.constraintSize({
|
|
41
|
-
minWidth: style.minWidth,
|
|
42
|
-
maxWidth: style.maxWidth,
|
|
43
|
-
minHeight: style.minHeight,
|
|
44
|
-
maxHeight: style.maxHeight
|
|
45
|
-
})
|
|
46
|
-
.backgroundColor(style.backgroundColor)
|
|
47
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
48
|
-
.backgroundImageSize(style.backgroundSize)
|
|
49
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
50
|
-
.borderStyle({
|
|
51
|
-
top: style.borderTopStyle,
|
|
52
|
-
right: style.borderRightStyle,
|
|
53
|
-
bottom: style.borderBottomStyle,
|
|
54
|
-
left: style.borderLeftStyle
|
|
55
|
-
})
|
|
56
|
-
.borderWidth({
|
|
57
|
-
top: style.borderTopWidth,
|
|
58
|
-
right: style.borderRightWidth,
|
|
59
|
-
bottom: style.borderBottomWidth,
|
|
60
|
-
left: style.borderLeftWidth
|
|
61
|
-
})
|
|
62
|
-
.borderColor({
|
|
63
|
-
top: style.borderTopColor,
|
|
64
|
-
right: style.borderRightColor,
|
|
65
|
-
bottom: style.borderBottomColor,
|
|
66
|
-
left: style.borderLeftColor
|
|
67
|
-
})
|
|
68
|
-
.borderRadius({
|
|
69
|
-
topLeft: style.borderTopLeftRadius,
|
|
70
|
-
topRight: style.borderTopRightRadius,
|
|
71
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
72
|
-
bottomRight: style.borderBottomRightRadius
|
|
73
|
-
})
|
|
74
|
-
.zIndex(style.zIndex)
|
|
75
|
-
.opacity(style.opacity)
|
|
76
|
-
.linearGradient(style.linearGradient)
|
|
77
|
-
.clip(style.overflow)
|
|
78
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
79
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
80
|
-
.transform(style.transform)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
19
|
@Extend(Swiper)
|
|
84
20
|
function swiperAttr (attr: SwiperAttrs) {
|
|
85
21
|
.index(attr.index)
|
|
@@ -109,7 +45,7 @@ export default function TaroSwiper (node: TaroSwiperElement) {
|
|
|
109
45
|
Swiper(node.controller) {
|
|
110
46
|
createLazyChildren(node)
|
|
111
47
|
}
|
|
112
|
-
.
|
|
48
|
+
.attributeModifier(commonStyleModify.setNode(node))
|
|
113
49
|
.swiperAttr(getSwiperAttributes(node))
|
|
114
50
|
.indicatorStyle({
|
|
115
51
|
color: node.getAttribute('indicatorColor'),
|
|
@@ -1,78 +1,14 @@
|
|
|
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,
|
|
6
|
+
import type { TaroAny, TaroSwitchElement, TaroEvent } from '@tarojs/runtime'
|
|
6
7
|
|
|
7
8
|
interface SwitchAttrs {
|
|
8
9
|
selectedColor?: ResourceColor
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
@Extend(Toggle)
|
|
12
|
-
function styles (style: TaroStyleType) {
|
|
13
|
-
.id(style.id)
|
|
14
|
-
.key(style.id)
|
|
15
|
-
.flexGrow(style.flexGrow)
|
|
16
|
-
.flexShrink(style.flexShrink)
|
|
17
|
-
.flexBasis(style.flexBasis)
|
|
18
|
-
.alignSelf(style.alignSelf)
|
|
19
|
-
.padding({
|
|
20
|
-
top: style.paddingTop,
|
|
21
|
-
right: style.paddingRight,
|
|
22
|
-
bottom: style.paddingBottom,
|
|
23
|
-
left: style.paddingLeft
|
|
24
|
-
})
|
|
25
|
-
.margin({
|
|
26
|
-
top: style.marginTop,
|
|
27
|
-
right: style.marginRight,
|
|
28
|
-
bottom: style.marginBottom,
|
|
29
|
-
left: style.marginLeft
|
|
30
|
-
})
|
|
31
|
-
.width(style.width)
|
|
32
|
-
.height(style.height)
|
|
33
|
-
.constraintSize({
|
|
34
|
-
minWidth: style.minWidth,
|
|
35
|
-
maxWidth: style.maxWidth,
|
|
36
|
-
minHeight: style.minHeight,
|
|
37
|
-
maxHeight: style.maxHeight
|
|
38
|
-
})
|
|
39
|
-
.backgroundColor(style.backgroundColor)
|
|
40
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
41
|
-
.backgroundImageSize(style.backgroundSize)
|
|
42
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
43
|
-
.borderStyle({
|
|
44
|
-
top: style.borderTopStyle,
|
|
45
|
-
right: style.borderRightStyle,
|
|
46
|
-
bottom: style.borderBottomStyle,
|
|
47
|
-
left: style.borderLeftStyle
|
|
48
|
-
})
|
|
49
|
-
.borderWidth({
|
|
50
|
-
top: style.borderTopWidth,
|
|
51
|
-
right: style.borderRightWidth,
|
|
52
|
-
bottom: style.borderBottomWidth,
|
|
53
|
-
left: style.borderLeftWidth
|
|
54
|
-
})
|
|
55
|
-
.borderColor({
|
|
56
|
-
top: style.borderTopColor,
|
|
57
|
-
right: style.borderRightColor,
|
|
58
|
-
bottom: style.borderBottomColor,
|
|
59
|
-
left: style.borderLeftColor
|
|
60
|
-
})
|
|
61
|
-
.borderRadius({
|
|
62
|
-
topLeft: style.borderTopLeftRadius,
|
|
63
|
-
topRight: style.borderTopRightRadius,
|
|
64
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
65
|
-
bottomRight: style.borderBottomRightRadius
|
|
66
|
-
})
|
|
67
|
-
.zIndex(style.zIndex)
|
|
68
|
-
.opacity(style.opacity)
|
|
69
|
-
.linearGradient(style.linearGradient)
|
|
70
|
-
.clip(style.overflow)
|
|
71
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
72
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
73
|
-
.transform(style.transform)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
12
|
@Extend(Toggle)
|
|
77
13
|
function attrs(attr: SwitchAttrs) {
|
|
78
14
|
.selectedColor(attr.selectedColor)
|
|
@@ -107,7 +43,7 @@ export default struct TaroSwitch {
|
|
|
107
43
|
type: this.node._attrs.type !== 'checkbox' ? ToggleType.Switch : ToggleType.Checkbox,
|
|
108
44
|
isOn: this.node.checked,
|
|
109
45
|
})
|
|
110
|
-
.
|
|
46
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
111
47
|
.attrs(getAttributes(this.node))
|
|
112
48
|
.themeStyles(!!this.node._attrs.disabled)
|
|
113
49
|
.onChange((isOn: boolean) => {
|