@tarojs/plugin-platform-harmony-ets 4.0.0-beta.0 → 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/media/video/VideoContext.ts +56 -7
- package/dist/apis/media/video/index.ts +3 -2
- 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 +26 -40
- package/dist/components-harmony-ets/checkbox.ets +70 -99
- package/dist/components-harmony-ets/form.ets +29 -42
- package/dist/components-harmony-ets/icon.ets +6 -34
- package/dist/components-harmony-ets/image.ets +2 -32
- package/dist/components-harmony-ets/innerHtml.ets +2 -2
- package/dist/components-harmony-ets/input.ets +7 -27
- package/dist/components-harmony-ets/label.ets +40 -47
- package/dist/components-harmony-ets/picker.ets +66 -73
- package/dist/components-harmony-ets/radio.ets +72 -101
- package/dist/components-harmony-ets/richText.ets +4 -36
- package/dist/components-harmony-ets/scrollView.ets +34 -74
- package/dist/components-harmony-ets/slider.ets +9 -34
- package/dist/components-harmony-ets/style.ets +154 -0
- package/dist/components-harmony-ets/swiper.ets +4 -34
- package/dist/components-harmony-ets/switch.ets +43 -56
- package/dist/components-harmony-ets/text.ets +7 -34
- package/dist/components-harmony-ets/textArea.ets +8 -28
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -11
- package/dist/components-harmony-ets/utils/flexManager.ets +45 -7
- package/dist/components-harmony-ets/utils/helper.ets +2 -2
- package/dist/components-harmony-ets/utils/styles.ets +58 -20
- package/dist/components-harmony-ets/video.ets +4 -34
- package/dist/components-harmony-ets/view.ets +25 -67
- package/dist/components-harmony-ets/webView.ets +50 -0
- package/dist/index.js +103 -5
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/window.ts +2 -2
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +30 -6
- package/dist/runtime-ets/dom/document.ts +21 -4
- package/dist/runtime-ets/dom/element/element.ts +1 -0
- package/dist/runtime-ets/dom/element/form.ts +11 -2
- 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/node.ts +29 -16
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +624 -0
- package/dist/runtime-ets/dom/stylesheet/index.ts +216 -354
- package/dist/runtime-ets/dom/stylesheet/type.ts +46 -11
- package/dist/runtime-ets/dom/stylesheet/util.ts +58 -6
- package/dist/runtime-ets/index.ts +1 -2
- package/dist/runtime-ets/interface/event.ts +2 -1
- package/dist/runtime-ets/utils/index.ts +6 -1
- package/dist/runtime-ets/utils/info.ts +3 -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 +181 -80
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +181 -80
- package/dist/runtime.js.map +1 -1
- package/package.json +12 -11
- package/static/media/cancel.svg +1 -0
- package/static/media/circle.svg +1 -0
- package/static/media/clear.svg +1 -0
- package/static/media/download.svg +1 -0
- package/static/media/info.svg +1 -0
- package/static/media/info_circle.svg +1 -0
- package/static/media/search.svg +1 -0
- package/static/media/success.svg +1 -0
- package/static/media/success_no_circle.svg +1 -0
- package/static/media/taro_arrow_left.svg +1 -0
- package/static/media/taro_home.svg +1 -0
- package/static/media/waiting.svg +1 -0
- package/static/media/warn.svg +1 -0
- package/types/runtime.d.ts +2 -0
- package/dist/runtime-ets/utils/bind.ts +0 -24
|
@@ -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,37 +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
|
-
.padding(style.padding)
|
|
19
|
-
.margin(style.margin)
|
|
20
|
-
.width(style.width)
|
|
21
|
-
.height(style.height)
|
|
22
|
-
.constraintSize(style.constraintSize)
|
|
23
|
-
.flexGrow(style.flexGrow)
|
|
24
|
-
.flexShrink(style.flexShrink)
|
|
25
|
-
.flexBasis(style.flexBasis)
|
|
26
|
-
.alignSelf(style.alignSelf)
|
|
27
|
-
.backgroundColor(style.backgroundColor)
|
|
28
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
29
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
30
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
31
|
-
.rotate(style.rotate)
|
|
32
|
-
.scale(style.scale)
|
|
33
|
-
.translate(style.translate)
|
|
34
|
-
.transform(style.transform)
|
|
35
|
-
.borderStyle(style.borderStyle)
|
|
36
|
-
.borderWidth(style.borderWidth)
|
|
37
|
-
.borderColor(style.borderColor)
|
|
38
|
-
.borderRadius(style.borderRadius)
|
|
39
|
-
.linearGradient(style.linearGradient)
|
|
40
|
-
.zIndex(style.zIndex)
|
|
41
|
-
.opacity(style.opacity)
|
|
42
|
-
.clip(style.clip)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
15
|
@Extend(Slider)
|
|
46
16
|
function attrs (attr: SliderAttrs) {
|
|
47
17
|
.selectedColor(attr.selectedColor)
|
|
@@ -75,6 +45,11 @@ export default struct TaroSlider {
|
|
|
75
45
|
if (this.node) {
|
|
76
46
|
this.value = this.node.value
|
|
77
47
|
this.node._instance = this
|
|
48
|
+
|
|
49
|
+
if (!this.node._isInit) {
|
|
50
|
+
this.node._isInit = true
|
|
51
|
+
this.node._reset = this.node.value || 0
|
|
52
|
+
}
|
|
78
53
|
}
|
|
79
54
|
}
|
|
80
55
|
|
|
@@ -87,7 +62,7 @@ export default struct TaroSlider {
|
|
|
87
62
|
style: SliderStyle.OutSet,
|
|
88
63
|
direction: Axis.Horizontal
|
|
89
64
|
})
|
|
90
|
-
.
|
|
65
|
+
.attributeModifier(commonStyleModify.setNode(node))
|
|
91
66
|
.attrs(getAttributes(node))
|
|
92
67
|
.width(!!node._attrs.showValue ? '90%' : '100%')
|
|
93
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,37 +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
|
-
.padding(style.padding)
|
|
23
|
-
.margin(style.margin)
|
|
24
|
-
.width(style.width)
|
|
25
|
-
.height(style.height)
|
|
26
|
-
.constraintSize(style.constraintSize)
|
|
27
|
-
.flexGrow(style.flexGrow)
|
|
28
|
-
.flexShrink(style.flexShrink)
|
|
29
|
-
.flexBasis(style.flexBasis)
|
|
30
|
-
.alignSelf(style.alignSelf)
|
|
31
|
-
.backgroundColor(style.backgroundColor)
|
|
32
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
33
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
34
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
35
|
-
.rotate(style.rotate)
|
|
36
|
-
.scale(style.scale)
|
|
37
|
-
.translate(style.translate)
|
|
38
|
-
.transform(style.transform)
|
|
39
|
-
.borderStyle(style.borderStyle)
|
|
40
|
-
.borderWidth(style.borderWidth)
|
|
41
|
-
.borderColor(style.borderColor)
|
|
42
|
-
.borderRadius(style.borderRadius)
|
|
43
|
-
.linearGradient(style.linearGradient)
|
|
44
|
-
.zIndex(style.zIndex)
|
|
45
|
-
.opacity(style.opacity)
|
|
46
|
-
.clip(style.clip)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
19
|
@Extend(Swiper)
|
|
50
20
|
function swiperAttr (attr: SwiperAttrs) {
|
|
51
21
|
.index(attr.index)
|
|
@@ -75,7 +45,7 @@ export default function TaroSwiper (node: TaroSwiperElement) {
|
|
|
75
45
|
Swiper(node.controller) {
|
|
76
46
|
createLazyChildren(node)
|
|
77
47
|
}
|
|
78
|
-
.
|
|
48
|
+
.attributeModifier(commonStyleModify.setNode(node))
|
|
79
49
|
.swiperAttr(getSwiperAttributes(node))
|
|
80
50
|
.indicatorStyle({
|
|
81
51
|
color: node.getAttribute('indicatorColor'),
|
|
@@ -1,44 +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
|
-
.padding(style.padding)
|
|
16
|
-
.margin(style.margin)
|
|
17
|
-
.width(style.width)
|
|
18
|
-
.height(style.height)
|
|
19
|
-
.constraintSize(style.constraintSize)
|
|
20
|
-
.flexGrow(style.flexGrow)
|
|
21
|
-
.flexShrink(style.flexShrink)
|
|
22
|
-
.flexBasis(style.flexBasis)
|
|
23
|
-
.alignSelf(style.alignSelf)
|
|
24
|
-
.backgroundColor(style.backgroundColor)
|
|
25
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
26
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
27
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
28
|
-
.rotate(style.rotate)
|
|
29
|
-
.scale(style.scale)
|
|
30
|
-
.translate(style.translate)
|
|
31
|
-
.transform(style.transform)
|
|
32
|
-
.borderStyle(style.borderStyle)
|
|
33
|
-
.borderWidth(style.borderWidth)
|
|
34
|
-
.borderColor(style.borderColor)
|
|
35
|
-
.borderRadius(style.borderRadius)
|
|
36
|
-
.linearGradient(style.linearGradient)
|
|
37
|
-
.zIndex(style.zIndex)
|
|
38
|
-
.opacity(style.opacity)
|
|
39
|
-
.clip(style.clip)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
12
|
@Extend(Toggle)
|
|
43
13
|
function attrs(attr: SwitchAttrs) {
|
|
44
14
|
.selectedColor(attr.selectedColor)
|
|
@@ -56,28 +26,45 @@ function themeStyles(isDisabled: boolean) {
|
|
|
56
26
|
.opacity(isDisabled ? 0.4 : 1)
|
|
57
27
|
}
|
|
58
28
|
|
|
59
|
-
@
|
|
60
|
-
export default
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (!node?._attrs.disabled) {
|
|
70
|
-
const event: TaroEvent = createTaroEvent('change', { detail: { value: isOn } }, node)
|
|
29
|
+
@Component
|
|
30
|
+
export default struct TaroSwitch {
|
|
31
|
+
node: TaroSwitchElement | null = null
|
|
32
|
+
|
|
33
|
+
aboutToAppear () {
|
|
34
|
+
if (this.node && !this.node._isInit) {
|
|
35
|
+
this.node._isInit = true
|
|
36
|
+
this.node._reset = this.node.checked || false
|
|
37
|
+
}
|
|
38
|
+
}
|
|
71
39
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
node.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
40
|
+
build () {
|
|
41
|
+
if (this.node) {
|
|
42
|
+
Toggle({
|
|
43
|
+
type: this.node._attrs.type !== 'checkbox' ? ToggleType.Switch : ToggleType.Checkbox,
|
|
44
|
+
isOn: this.node.checked,
|
|
45
|
+
})
|
|
46
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
47
|
+
.attrs(getAttributes(this.node))
|
|
48
|
+
.themeStyles(!!this.node._attrs.disabled)
|
|
49
|
+
.onChange((isOn: boolean) => {
|
|
50
|
+
if (this.node) {
|
|
51
|
+
if (!this.node?._attrs.disabled) {
|
|
52
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { value: isOn } }, this.node)
|
|
53
|
+
|
|
54
|
+
this.node.updateCheckedValue(isOn)
|
|
55
|
+
eventHandler(event, 'change', this.node)
|
|
56
|
+
} else {
|
|
57
|
+
this.node.updateComponent()
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
62
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
63
|
+
if (this.node) {
|
|
64
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
65
|
+
}
|
|
66
|
+
}))
|
|
67
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
68
|
+
}
|
|
69
|
+
}
|
|
83
70
|
}
|
|
@@ -1,39 +1,12 @@
|
|
|
1
1
|
import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, NodeType } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
+
import commonStyleModify from './style'
|
|
3
4
|
import { getButtonColor } from './button'
|
|
4
5
|
import { BUTTON_THEME_COLOR } from './utils/constant/style'
|
|
5
6
|
import { getNodeThresholds, getNormalAttributes, getFontAttributes, shouldBindEvent } from './utils/helper'
|
|
6
7
|
|
|
7
8
|
import type { TaroButtonElement, TaroElement, TaroTextElement, TaroAny, TaroTextStyleType, TaroStyleType } from '@tarojs/runtime'
|
|
8
9
|
|
|
9
|
-
@Extend(Text)
|
|
10
|
-
function textNormalStyle (style: TaroStyleType) {
|
|
11
|
-
.padding(style.padding)
|
|
12
|
-
.margin(style.margin)
|
|
13
|
-
.width(style.width)
|
|
14
|
-
.height(style.height)
|
|
15
|
-
.constraintSize(style.constraintSize)
|
|
16
|
-
.flexGrow(style.flexGrow)
|
|
17
|
-
.flexShrink(style.flexShrink)
|
|
18
|
-
.flexBasis(style.flexBasis)
|
|
19
|
-
.alignSelf(style.alignSelf)
|
|
20
|
-
.backgroundColor(style.backgroundColor)
|
|
21
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
22
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
23
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
24
|
-
.rotate(style.rotate)
|
|
25
|
-
.scale(style.scale)
|
|
26
|
-
.translate(style.translate)
|
|
27
|
-
.transform(style.transform)
|
|
28
|
-
.borderStyle(style.borderStyle)
|
|
29
|
-
.borderWidth(style.borderWidth)
|
|
30
|
-
.borderColor(style.borderColor)
|
|
31
|
-
.borderRadius(style.borderRadius)
|
|
32
|
-
.linearGradient(style.linearGradient)
|
|
33
|
-
.zIndex(style.zIndex)
|
|
34
|
-
.clip(style.clip)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
10
|
@Extend(Text)
|
|
38
11
|
function textNormalFontStyle (style: TaroStyleType) {
|
|
39
12
|
.id(style.id)
|
|
@@ -46,7 +19,7 @@ function textNormalFontStyle (style: TaroStyleType) {
|
|
|
46
19
|
.fontFamily(style.fontFamily)
|
|
47
20
|
.lineHeight(style.lineHeight)
|
|
48
21
|
.decoration({
|
|
49
|
-
type: style.
|
|
22
|
+
type: style.textDecoration,
|
|
50
23
|
color: style.color
|
|
51
24
|
})
|
|
52
25
|
}
|
|
@@ -55,7 +28,7 @@ function textNormalFontStyle (style: TaroStyleType) {
|
|
|
55
28
|
function textSpecialFontStyle(attr: TaroTextStyleType) {
|
|
56
29
|
.textAlign(attr.textAlign)
|
|
57
30
|
.textOverflow(attr.textOverflow)
|
|
58
|
-
.maxLines(attr.
|
|
31
|
+
.maxLines(attr.WebkitLineClamp)
|
|
59
32
|
.letterSpacing(attr.letterSpacing)
|
|
60
33
|
}
|
|
61
34
|
|
|
@@ -82,12 +55,12 @@ export default function TaroText (node: TaroTextElement) {
|
|
|
82
55
|
} else {
|
|
83
56
|
Text(node.textContent)
|
|
84
57
|
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
85
|
-
.
|
|
86
|
-
node._nodeInfo.areaInfo = res[1]
|
|
87
|
-
}))
|
|
88
|
-
.textNormalStyle(getNormalAttributes(node))
|
|
58
|
+
.attributeModifier(commonStyleModify.setNode(node))
|
|
89
59
|
.textNormalFontStyle(getNormalAttributes(node))
|
|
90
60
|
.textSpecialFontStyle(getFontAttributes(node))
|
|
91
61
|
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
62
|
+
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
63
|
+
node._nodeInfo.areaInfo = res[1]
|
|
64
|
+
}))
|
|
92
65
|
}
|
|
93
66
|
}
|
|
@@ -1,38 +1,12 @@
|
|
|
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 { getNodeThresholds, getNormalAttributes, getFontAttributes, shouldBindEvent, parseStyles } from './utils/helper'
|
|
4
5
|
|
|
5
6
|
import type { TaroAny, TaroStyleType, TaroTextStyleType, TaroTextAreaElement, TaroEvent } from '@tarojs/runtime'
|
|
6
7
|
|
|
7
8
|
@Extend(TextArea)
|
|
8
9
|
function textStyle (style: TaroStyleType) {
|
|
9
|
-
.id(style.id)
|
|
10
|
-
.key(style.id)
|
|
11
|
-
.padding(style.padding)
|
|
12
|
-
.margin(style.margin)
|
|
13
|
-
.width(style.width)
|
|
14
|
-
.height(style.height)
|
|
15
|
-
.constraintSize(style.constraintSize)
|
|
16
|
-
.flexGrow(style.flexGrow)
|
|
17
|
-
.flexShrink(style.flexShrink)
|
|
18
|
-
.flexBasis(style.flexBasis)
|
|
19
|
-
.alignSelf(style.alignSelf)
|
|
20
|
-
.backgroundColor(style.backgroundColor)
|
|
21
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
22
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
23
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
24
|
-
.rotate(style.rotate)
|
|
25
|
-
.scale(style.scale)
|
|
26
|
-
.translate(style.translate)
|
|
27
|
-
.transform(style.transform)
|
|
28
|
-
.borderStyle(style.borderStyle)
|
|
29
|
-
.borderWidth(style.borderWidth)
|
|
30
|
-
.borderColor(style.borderColor)
|
|
31
|
-
.borderRadius(style.borderRadius)
|
|
32
|
-
.linearGradient(style.linearGradient)
|
|
33
|
-
.zIndex(style.zIndex)
|
|
34
|
-
.opacity(style.opacity)
|
|
35
|
-
.clip(style.clip)
|
|
36
10
|
.fontColor(style.color)
|
|
37
11
|
.fontSize(style.fontSize)
|
|
38
12
|
.fontWeight(style.fontWeight)
|
|
@@ -43,7 +17,7 @@ function textStyle (style: TaroStyleType) {
|
|
|
43
17
|
@Extend(TextArea)
|
|
44
18
|
function textAttr(attr: TaroTextStyleType) {
|
|
45
19
|
.textAlign(attr.textAlign)
|
|
46
|
-
.maxLines(attr.
|
|
20
|
+
.maxLines(attr.WebkitLineClamp)
|
|
47
21
|
}
|
|
48
22
|
|
|
49
23
|
function getPlaceholderColor (node: TaroTextAreaElement): string {
|
|
@@ -62,6 +36,11 @@ export default struct TaroTextArea {
|
|
|
62
36
|
if (this.node) {
|
|
63
37
|
this.value = this.node.value
|
|
64
38
|
this.node._instance = this
|
|
39
|
+
|
|
40
|
+
if (!this.node._isInit) {
|
|
41
|
+
this.node._isInit = true
|
|
42
|
+
this.node._reset = this.node.value || ''
|
|
43
|
+
}
|
|
65
44
|
}
|
|
66
45
|
}
|
|
67
46
|
|
|
@@ -71,6 +50,7 @@ export default struct TaroTextArea {
|
|
|
71
50
|
.key(this.node._nid)
|
|
72
51
|
.maxLength(Number(this.node._attrs?.maxlength) || null)
|
|
73
52
|
.placeholderColor(getPlaceholderColor(this.node))
|
|
53
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
74
54
|
.textStyle(getNormalAttributes(this.node))
|
|
75
55
|
.textAttr(getFontAttributes(this.node))
|
|
76
56
|
.onChange((value: string) => {
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { bindAnimation } from './helper'
|
|
1
|
+
import { TaroAny, TaroElement } from '@tarojs/runtime'
|
|
4
2
|
|
|
5
3
|
export class DynamicCenter {
|
|
6
|
-
|
|
7
4
|
install (node: TaroElement, parentNode: TaroElement) {
|
|
8
5
|
if (!parentNode._isCompileMode) return
|
|
9
6
|
|
|
@@ -25,13 +22,7 @@ export class DynamicCenter {
|
|
|
25
22
|
const dynamicID = node._attrs?._dynamicID
|
|
26
23
|
|
|
27
24
|
// dynamicID 只是为了更新到精准的 node
|
|
28
|
-
|
|
29
|
-
initComponentNodeInfo(component, node)
|
|
30
|
-
bindInstanceToNode(node, component)
|
|
31
|
-
bindFocus(node)
|
|
32
|
-
bindAnimation(node)
|
|
33
|
-
bindScrollTo(node, component)
|
|
34
|
-
|
|
25
|
+
node._instance = component
|
|
35
26
|
node._isCompileMode = true
|
|
36
27
|
|
|
37
28
|
if (dynamicID) {
|
|
@@ -1,20 +1,58 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TaroElement } from '@tarojs/runtime'
|
|
2
|
+
import { isUndefined } from '@tarojs/shared'
|
|
3
|
+
|
|
4
|
+
interface IFlexOptions {
|
|
5
|
+
direction: FlexDirection,
|
|
6
|
+
justifyContent: FlexAlign,
|
|
7
|
+
alignItems: VerticalAlign | HorizontalAlign,
|
|
8
|
+
// Row 和 Column 不支持下面两个属性
|
|
9
|
+
// wrap: FlexWrap,
|
|
10
|
+
// alignContent: FlexAlignContent
|
|
11
|
+
}
|
|
2
12
|
|
|
3
13
|
class FlexManager {
|
|
4
|
-
static
|
|
14
|
+
static isFlexNode (node: TaroElement): boolean {
|
|
15
|
+
return !!node.hmStyle?.display?.includes('flex')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static convertFlexAlignItemsToColumnOrRow (direction: FlexDirection, alignItems: ItemAlign | undefined): VerticalAlign | HorizontalAlign {
|
|
19
|
+
if (direction === FlexDirection.Column) {
|
|
20
|
+
switch (alignItems) {
|
|
21
|
+
case ItemAlign.Start:
|
|
22
|
+
return HorizontalAlign.Start
|
|
23
|
+
case ItemAlign.End:
|
|
24
|
+
return HorizontalAlign.End
|
|
25
|
+
default:
|
|
26
|
+
return HorizontalAlign.Center
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
switch (alignItems) {
|
|
30
|
+
case ItemAlign.Start:
|
|
31
|
+
return VerticalAlign.Top
|
|
32
|
+
case ItemAlign.End:
|
|
33
|
+
return VerticalAlign.Bottom
|
|
34
|
+
default:
|
|
35
|
+
return VerticalAlign.Center
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static flexOptions (node: TaroElement): IFlexOptions {
|
|
5
41
|
const hmStyle = node.hmStyle
|
|
42
|
+
const isFlex = FlexManager.isFlexNode(node)
|
|
43
|
+
const justifyContent: FlexAlign = isFlex ? (isUndefined(hmStyle.justifyContent) ? FlexAlign.Start : hmStyle.justifyContent) : FlexAlign.Start
|
|
6
44
|
|
|
7
|
-
let flexDirection = hmStyle.
|
|
45
|
+
let flexDirection = hmStyle.flexDirection
|
|
8
46
|
if (!flexDirection && flexDirection !== 0) {
|
|
9
47
|
flexDirection = hmStyle.display === 'flex' ? FlexDirection.Row : FlexDirection.Column
|
|
10
48
|
}
|
|
11
49
|
|
|
50
|
+
const alignItems = isFlex ? FlexManager.convertFlexAlignItemsToColumnOrRow(flexDirection, hmStyle.alignItems) : HorizontalAlign.Start
|
|
51
|
+
|
|
12
52
|
return {
|
|
53
|
+
alignItems,
|
|
54
|
+
justifyContent,
|
|
13
55
|
direction: flexDirection,
|
|
14
|
-
justifyContent: hmStyle.justifyContent,
|
|
15
|
-
alignItems: hmStyle.alignItems,
|
|
16
|
-
wrap: hmStyle.flexWrap,
|
|
17
|
-
alignContent: hmStyle.alignContent,
|
|
18
56
|
}
|
|
19
57
|
}
|
|
20
58
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getNormalAttributes, getFontAttributes } from './styles'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { TFunc } from '@tarojs/runtime/dist/runtime.esm'
|
|
4
4
|
import type { TaroElement } from '@tarojs/runtime'
|
|
5
5
|
|
|
6
6
|
export const parseStyles = (styles = ''): Record<string, string> => {
|
|
@@ -20,7 +20,7 @@ export const parseStyles = (styles = ''): Record<string, string> => {
|
|
|
20
20
|
return styleObj
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export function shouldBindEvent (cb:
|
|
23
|
+
export function shouldBindEvent (cb: TFunc, node: TaroElement | null, eventNames: string[], disabled = false) {
|
|
24
24
|
if (!node || node._attrs?.disabled || disabled) return null
|
|
25
25
|
if (!node.__listeners) {
|
|
26
26
|
return null
|