@tarojs/plugin-platform-harmony-ets 4.0.0-beta.19 → 4.0.0-beta.20
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/wxml/IntersectionObserver.ts +5 -3
- package/dist/components-harmony-ets/button.ets +3 -2
- package/dist/components-harmony-ets/checkbox.ets +6 -3
- package/dist/components-harmony-ets/form.ets +5 -4
- package/dist/components-harmony-ets/icon.ets +8 -4
- package/dist/components-harmony-ets/image.ets +2 -0
- package/dist/components-harmony-ets/innerHtml.ets +5 -4
- package/dist/components-harmony-ets/input.ets +6 -4
- package/dist/components-harmony-ets/label.ets +5 -4
- package/dist/components-harmony-ets/movableArea.ets +8 -31
- package/dist/components-harmony-ets/movableView.ets +8 -31
- package/dist/components-harmony-ets/picker.ets +21 -16
- package/dist/components-harmony-ets/progress.ets +2 -0
- package/dist/components-harmony-ets/pseudo.ets +38 -31
- package/dist/components-harmony-ets/radio.ets +6 -3
- package/dist/components-harmony-ets/richText.ets +3 -1
- package/dist/components-harmony-ets/scrollView.ets +15 -36
- package/dist/components-harmony-ets/slider.ets +4 -2
- package/dist/components-harmony-ets/style.ets +62 -27
- package/dist/components-harmony-ets/swiper.ets +3 -2
- package/dist/components-harmony-ets/switch.ets +3 -1
- package/dist/components-harmony-ets/text.ets +10 -8
- package/dist/components-harmony-ets/textArea.ets +6 -4
- package/dist/components-harmony-ets/utils/helper.ets +3 -2
- package/dist/components-harmony-ets/utils/styles.ets +25 -93
- package/dist/components-harmony-ets/video.ets +2 -0
- package/dist/components-harmony-ets/view.ets +11 -32
- package/dist/components-harmony-ets/webView.ets +3 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/dom/cssNesting.ts +36 -10
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +15 -40
- package/dist/runtime-ets/dom/document.ts +0 -3
- package/dist/runtime-ets/dom/element/element.ts +6 -5
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +152 -217
- package/dist/runtime-ets/dom/stylesheet/index.ts +17 -315
- package/dist/runtime-ets/dom/stylesheet/type.ts +6 -2
- package/dist/runtime-ets/index.ts +1 -1
- package/dist/runtime-ets/utils/index.ts +24 -8
- package/dist/runtime-framework/react/native-page.ts +6 -4
- package/dist/runtime-utils.js +4 -3
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +4 -3
- package/dist/runtime.js.map +1 -1
- package/package.json +8 -8
|
@@ -1,13 +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
4
|
import PseduoChildren from './pseudo'
|
|
5
|
-
import { createLazyChildren } from './render'
|
|
6
5
|
import { FlexManager } from './utils/FlexManager'
|
|
7
6
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
8
|
-
import { getNodeThresholds,
|
|
7
|
+
import { getNodeThresholds, getStyleAttr, shouldBindEvent } from './utils/helper'
|
|
9
8
|
|
|
10
|
-
import type { TaroAny,
|
|
9
|
+
import type { TaroAny, TaroScrollViewElement, TaroEvent } from '@tarojs/runtime'
|
|
11
10
|
|
|
12
11
|
interface ScrollViewAttrs {
|
|
13
12
|
scrollBar: BarState
|
|
@@ -58,28 +57,10 @@ function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', x
|
|
|
58
57
|
eventHandler(event, eventName, node)
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
@Extend(Row)
|
|
62
|
-
function rowAttrs (style: TaroStyleType) {
|
|
63
|
-
.constraintSize({
|
|
64
|
-
minWidth: style.minWidth || style.width,
|
|
65
|
-
maxWidth: style.maxWidth,
|
|
66
|
-
minHeight: style.minHeight,
|
|
67
|
-
maxHeight: style.maxHeight
|
|
68
|
-
})
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
@Extend(Column)
|
|
72
|
-
function columnAttrs (style: TaroStyleType) {
|
|
73
|
-
.constraintSize({
|
|
74
|
-
minWidth: style.minWidth,
|
|
75
|
-
maxWidth: style.maxWidth,
|
|
76
|
-
minHeight: style.minHeight || style.height,
|
|
77
|
-
maxHeight: style.maxHeight
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
|
|
81
60
|
@Component
|
|
82
61
|
export default struct TaroScrollView {
|
|
62
|
+
@Builder customBuilder() {}
|
|
63
|
+
@BuilderParam createLazyChildren: (node: TaroScrollViewElement) => void = this.customBuilder
|
|
83
64
|
@ObjectLink node: TaroScrollViewElement
|
|
84
65
|
|
|
85
66
|
build () {
|
|
@@ -88,13 +69,12 @@ export default struct TaroScrollView {
|
|
|
88
69
|
if (this.node._attrs.scrollX) {
|
|
89
70
|
Row() {
|
|
90
71
|
if (this.node._pseudo_before || this.node._pseudo_after) {
|
|
91
|
-
PseduoChildren(this.node)
|
|
72
|
+
PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
|
|
92
73
|
} else {
|
|
93
|
-
createLazyChildren(this.node)
|
|
74
|
+
this.createLazyChildren(this.node)
|
|
94
75
|
}
|
|
95
76
|
}
|
|
96
|
-
.attributeModifier(
|
|
97
|
-
.rowAttrs(getNormalAttributes(this.node))
|
|
77
|
+
.attributeModifier(rowModify.setNode(this.node))
|
|
98
78
|
.width(null)
|
|
99
79
|
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
100
80
|
this.node._nodeInfo._scroll = areaResult
|
|
@@ -105,13 +85,12 @@ export default struct TaroScrollView {
|
|
|
105
85
|
} else {
|
|
106
86
|
Column() {
|
|
107
87
|
if (this.node._pseudo_before || this.node._pseudo_after) {
|
|
108
|
-
PseduoChildren(this.node)
|
|
88
|
+
PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
|
|
109
89
|
} else {
|
|
110
|
-
createLazyChildren(this.node)
|
|
90
|
+
this.createLazyChildren(this.node)
|
|
111
91
|
}
|
|
112
92
|
}
|
|
113
|
-
.attributeModifier(
|
|
114
|
-
.columnAttrs(getNormalAttributes(this.node))
|
|
93
|
+
.attributeModifier(columnModify.setNode(this.node))
|
|
115
94
|
.height(null)
|
|
116
95
|
.alignItems(HorizontalAlign.Start)
|
|
117
96
|
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
@@ -122,10 +101,10 @@ export default struct TaroScrollView {
|
|
|
122
101
|
.flexGrow(0).flexShrink(0)
|
|
123
102
|
}
|
|
124
103
|
}
|
|
125
|
-
.width(
|
|
126
|
-
.height(
|
|
127
|
-
.flexGrow(
|
|
128
|
-
.flexShrink(
|
|
104
|
+
.width(getStyleAttr(this.node, 'width'))
|
|
105
|
+
.height(getStyleAttr(this.node, 'height'))
|
|
106
|
+
.flexGrow(this.node.hmStyle?.flexGrow)
|
|
107
|
+
.flexShrink(this.node.hmStyle?.flexShrink)
|
|
129
108
|
.scrollable(getScrollable(this.node))
|
|
130
109
|
.scrollBar(getAttributes(this.node).scrollBar)
|
|
131
110
|
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
@@ -37,6 +37,8 @@ function themeStyles(isDisabled: boolean) {
|
|
|
37
37
|
|
|
38
38
|
@Component
|
|
39
39
|
export default struct TaroSlider {
|
|
40
|
+
@Builder customBuilder() {}
|
|
41
|
+
@BuilderParam createLazyChildren: (node: TaroSliderElement) => void = this.customBuilder
|
|
40
42
|
@ObjectLink node: TaroSliderElement
|
|
41
43
|
|
|
42
44
|
@State value: number = 0
|
|
@@ -74,7 +76,7 @@ export default struct TaroSlider {
|
|
|
74
76
|
} else {
|
|
75
77
|
this.value = value
|
|
76
78
|
this.node?.updateFormWidgetValue(value)
|
|
77
|
-
|
|
79
|
+
|
|
78
80
|
if (mode === SliderChangeMode.End) {
|
|
79
81
|
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.value } }, node)
|
|
80
82
|
eventHandler(event, 'change', node)
|
|
@@ -108,4 +110,4 @@ export default struct TaroSlider {
|
|
|
108
110
|
}
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
|
-
}
|
|
113
|
+
}
|
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
import type { HarmonyStyle, TaroElement, TaroStyleType } from '@tarojs/runtime'
|
|
2
2
|
import { isUndefined } from '../shared'
|
|
3
3
|
import { computeBackgroundPosition } from './utils'
|
|
4
|
-
import { getNormalAttributes
|
|
5
|
-
|
|
6
|
-
function getTop (node: TaroElement): Length | number {
|
|
7
|
-
return node?.hmStyle?.top || 0
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function getLeft (node: TaroElement): Length | number {
|
|
11
|
-
return node?.hmStyle?.left || 0
|
|
12
|
-
}
|
|
4
|
+
import { getNormalAttributes } from './utils/helper'
|
|
5
|
+
import { isMaxWidthView } from './utils/styles'
|
|
13
6
|
|
|
14
7
|
class CommonStyleModify implements AttributeModifier<CommonAttribute> {
|
|
15
8
|
node: TaroElement | null = null
|
|
16
9
|
style: TaroStyleType | null = null
|
|
10
|
+
initStyle?: TaroStyleType
|
|
17
11
|
|
|
18
|
-
setNode (node: TaroElement) {
|
|
12
|
+
setNode (node: TaroElement, initStyle?: TaroStyleType) {
|
|
19
13
|
this.node = node
|
|
20
14
|
this.style = getNormalAttributes(this.node)
|
|
21
|
-
|
|
15
|
+
this.initStyle = initStyle
|
|
16
|
+
// 覆盖初始化样式
|
|
17
|
+
if (initStyle) {
|
|
18
|
+
Object.keys(initStyle).forEach(key => {
|
|
19
|
+
if (this.style && !this.style[key]) {
|
|
20
|
+
this.style[key] = initStyle[key]
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
}
|
|
22
24
|
return this
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
applyNormalAttribute(instance: CommonAttribute): void {
|
|
26
28
|
if (this.node && this.style) {
|
|
27
|
-
setNormalAttributeIntoInstance(instance, this.style)
|
|
29
|
+
setNormalAttributeIntoInstance(instance, this.style, this.node)
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
32
|
}
|
|
@@ -33,7 +35,7 @@ class PseudoStyleModify implements AttributeModifier<CommonAttribute> {
|
|
|
33
35
|
style: TaroStyleType | null = null
|
|
34
36
|
|
|
35
37
|
setStyle (style: HarmonyStyle) {
|
|
36
|
-
this.style =
|
|
38
|
+
this.style = style
|
|
37
39
|
return this
|
|
38
40
|
}
|
|
39
41
|
|
|
@@ -45,7 +47,37 @@ class PseudoStyleModify implements AttributeModifier<CommonAttribute> {
|
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
class RowStyleModify extends CommonStyleModify {
|
|
51
|
+
|
|
52
|
+
applyNormalAttribute(instance: CommonAttribute): void {
|
|
53
|
+
if (this.style) {
|
|
54
|
+
setNormalAttributeIntoInstance(instance, this.style, this.node)
|
|
55
|
+
instance.constraintSize({
|
|
56
|
+
minWidth: this.style.minWidth || this.style.width,
|
|
57
|
+
maxWidth: this.style.maxWidth,
|
|
58
|
+
minHeight: this.style.minHeight,
|
|
59
|
+
maxHeight: this.style.maxHeight
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
class ColumnStyleModify extends CommonStyleModify {
|
|
66
|
+
applyNormalAttribute(instance: CommonAttribute): void {
|
|
67
|
+
if (this.style) {
|
|
68
|
+
setNormalAttributeIntoInstance(instance, this.style, this.node)
|
|
69
|
+
instance.constraintSize({
|
|
70
|
+
minWidth: this.style.minWidth,
|
|
71
|
+
maxWidth: this.style.maxWidth,
|
|
72
|
+
minHeight: this.style.minHeight || this.style.height,
|
|
73
|
+
maxHeight: this.style.maxHeight
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
function setNormalAttributeIntoInstance(instance: CommonAttribute, style: TaroStyleType, node?: TaroElement | null) {
|
|
49
81
|
if (!isUndefined(style.id)) {
|
|
50
82
|
instance.id(style.id)
|
|
51
83
|
instance.key(style.id)
|
|
@@ -78,7 +110,9 @@ function setNormalAttributeIntoInstance(instance: CommonAttribute, style: TaroSt
|
|
|
78
110
|
left: style.marginLeft
|
|
79
111
|
})
|
|
80
112
|
}
|
|
81
|
-
if (
|
|
113
|
+
if (node) {
|
|
114
|
+
instance.width(isMaxWidthView(node as TaroElement) && isUndefined(style.width) ? '100%' : style.width)
|
|
115
|
+
} else {
|
|
82
116
|
instance.width(style.width)
|
|
83
117
|
}
|
|
84
118
|
if (!isUndefined(style.height)) {
|
|
@@ -96,7 +130,11 @@ function setNormalAttributeIntoInstance(instance: CommonAttribute, style: TaroSt
|
|
|
96
130
|
instance.backgroundColor(style.backgroundColor)
|
|
97
131
|
}
|
|
98
132
|
if (!isUndefined(style.backgroundImage)) {
|
|
99
|
-
|
|
133
|
+
if (style.backgroundImage.colors) {
|
|
134
|
+
instance.linearGradient(style.backgroundImage)
|
|
135
|
+
} else {
|
|
136
|
+
instance.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
137
|
+
}
|
|
100
138
|
}
|
|
101
139
|
if (!isUndefined(style.backgroundSize)) {
|
|
102
140
|
instance.backgroundImageSize(style.backgroundSize)
|
|
@@ -150,11 +188,8 @@ function setNormalAttributeIntoInstance(instance: CommonAttribute, style: TaroSt
|
|
|
150
188
|
if (!isUndefined(style.opacity)) {
|
|
151
189
|
instance.opacity(style.opacity)
|
|
152
190
|
}
|
|
153
|
-
if (!isUndefined(style.linearGradient)) {
|
|
154
|
-
instance.linearGradient(style.linearGradient)
|
|
155
|
-
}
|
|
156
191
|
if (!isUndefined(style.overflow)) {
|
|
157
|
-
instance.clip(style.overflow)
|
|
192
|
+
instance.clip(style.overflow === 'hidden')
|
|
158
193
|
}
|
|
159
194
|
// if (!isUndefined(style.transformOrigin)) {
|
|
160
195
|
// instance.rotate({ centerX: style.transformOrigin.x, centerY: style.transformOrigin.y, angle: 0 })
|
|
@@ -173,8 +208,8 @@ function setNormalAttributeIntoInstance(instance: CommonAttribute, style: TaroSt
|
|
|
173
208
|
x: style.transform.Scale.x || 0,
|
|
174
209
|
y: style.transform.Scale.y || 0,
|
|
175
210
|
z: style.transform.Scale.z || 0,
|
|
176
|
-
centerX: style.transformOrigin?.x,
|
|
177
|
-
centerY: style.transformOrigin?.y,
|
|
211
|
+
centerX: style.transformOrigin?.x || 0,
|
|
212
|
+
centerY: style.transformOrigin?.y || 0,
|
|
178
213
|
})
|
|
179
214
|
}
|
|
180
215
|
if (style.transform.Rotate) {
|
|
@@ -182,8 +217,8 @@ function setNormalAttributeIntoInstance(instance: CommonAttribute, style: TaroSt
|
|
|
182
217
|
x: style.transform.Rotate.x || 0,
|
|
183
218
|
y: style.transform.Rotate.y || 0,
|
|
184
219
|
z: style.transform.Rotate.z || 0,
|
|
185
|
-
centerX: style.transformOrigin?.x,
|
|
186
|
-
centerY: style.transformOrigin?.y,
|
|
220
|
+
centerX: style.transformOrigin?.x || 0,
|
|
221
|
+
centerY: style.transformOrigin?.y || 0,
|
|
187
222
|
angle: 0
|
|
188
223
|
})
|
|
189
224
|
}
|
|
@@ -202,8 +237,8 @@ function setNormalAttributeIntoInstance(instance: CommonAttribute, style: TaroSt
|
|
|
202
237
|
}
|
|
203
238
|
}
|
|
204
239
|
|
|
205
|
-
const modify = new CommonStyleModify()
|
|
206
|
-
|
|
207
240
|
export const pseudoModify = new PseudoStyleModify()
|
|
241
|
+
export const rowModify = new RowStyleModify()
|
|
242
|
+
export const columnModify = new ColumnStyleModify()
|
|
208
243
|
|
|
209
|
-
export default
|
|
244
|
+
export default new CommonStyleModify()
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
|
-
import { createLazyChildren } from './render'
|
|
5
4
|
import { getNodeThresholds, shouldBindEvent } from './utils/helper'
|
|
6
5
|
|
|
7
6
|
import type { TaroSwiperElement, TaroEvent, TaroAny } from '@tarojs/runtime'
|
|
@@ -42,12 +41,14 @@ function getSwiperAttributes (node: TaroSwiperElement): SwiperAttrs {
|
|
|
42
41
|
|
|
43
42
|
@Component
|
|
44
43
|
export default struct TaroSwiper {
|
|
44
|
+
@Builder customBuilder() {}
|
|
45
|
+
@BuilderParam createLazyChildren: (node: TaroSwiperElement) => void = this.customBuilder
|
|
45
46
|
@ObjectLink node: TaroSwiperElement
|
|
46
47
|
|
|
47
48
|
build () {
|
|
48
49
|
if (this.node.hmStyle?.display !== 'none') {
|
|
49
50
|
Swiper(this.node.controller) {
|
|
50
|
-
createLazyChildren(this.node)
|
|
51
|
+
this.createLazyChildren(this.node)
|
|
51
52
|
}
|
|
52
53
|
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
53
54
|
.swiperAttr(getSwiperAttributes(this.node))
|
|
@@ -28,6 +28,8 @@ function themeStyles(isDisabled: boolean) {
|
|
|
28
28
|
|
|
29
29
|
@Component
|
|
30
30
|
export default struct TaroSwitch {
|
|
31
|
+
@Builder customBuilder() {}
|
|
32
|
+
@BuilderParam createLazyChildren: (node: TaroSwitchElement) => void = this.customBuilder
|
|
31
33
|
@ObjectLink node: TaroSwitchElement
|
|
32
34
|
|
|
33
35
|
aboutToAppear () {
|
|
@@ -50,7 +52,7 @@ export default struct TaroSwitch {
|
|
|
50
52
|
if (this.node) {
|
|
51
53
|
if (!this.node?._attrs.disabled) {
|
|
52
54
|
const event: TaroEvent = createTaroEvent('change', { detail: { value: isOn } }, this.node)
|
|
53
|
-
|
|
55
|
+
|
|
54
56
|
this.node.updateCheckedValue(isOn)
|
|
55
57
|
eventHandler(event, 'change', this.node)
|
|
56
58
|
} else {
|
|
@@ -3,7 +3,7 @@ import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
4
|
import { getButtonColor } from './button'
|
|
5
5
|
import { BUTTON_THEME_COLOR } from './utils/constant/style'
|
|
6
|
-
import { getNodeThresholds,
|
|
6
|
+
import { getNodeThresholds, getStyleAttr, getFontAttributes, shouldBindEvent } from './utils/helper'
|
|
7
7
|
|
|
8
8
|
import type { TaroButtonElement, TaroElement, TaroTextElement, TaroAny, TaroTextStyleType, TaroStyleType } from '@tarojs/runtime'
|
|
9
9
|
|
|
@@ -41,6 +41,8 @@ function getButtonFontSize (node: TaroButtonElement) {
|
|
|
41
41
|
|
|
42
42
|
@Component
|
|
43
43
|
export default struct TaroText {
|
|
44
|
+
@Builder customBuilder() {}
|
|
45
|
+
@BuilderParam createLazyChildren: (node: TaroTextElement) => void = this.customBuilder
|
|
44
46
|
@ObjectLink node: TaroTextElement
|
|
45
47
|
|
|
46
48
|
build () {
|
|
@@ -48,16 +50,16 @@ export default struct TaroText {
|
|
|
48
50
|
if (this.node.parentNode) {
|
|
49
51
|
if ((this.node.parentNode as TaroElement).tagName === 'BUTTON') {
|
|
50
52
|
Text(this.node.textContent)
|
|
51
|
-
.textNormalFontStyle(
|
|
52
|
-
.textSpecialFontStyle(getFontAttributes(this.node.
|
|
53
|
+
.textNormalFontStyle(this.node.parentElement?.hmStyle || {})
|
|
54
|
+
.textSpecialFontStyle(getFontAttributes(this.node.parentElement as TaroElement))
|
|
53
55
|
.fontSize((this.node.parentNode as TaroButtonElement).hmStyle.fontSize || getButtonFontSize(this.node.parentNode as TaroButtonElement))
|
|
54
56
|
.fontColor((this.node.parentNode as TaroButtonElement).hmStyle.color || getButtonColor(this.node.parentNode as TaroButtonElement, BUTTON_THEME_COLOR.get((this.node.parentNode as TaroButtonElement)._attrs.type).text))
|
|
55
57
|
} else {
|
|
56
58
|
Text(this.node.textContent)
|
|
57
|
-
.textNormalFontStyle(
|
|
58
|
-
.textSpecialFontStyle(getFontAttributes(this.node.
|
|
59
|
-
.width(
|
|
60
|
-
.height(
|
|
59
|
+
.textNormalFontStyle(this.node.parentElement?.hmStyle || {})
|
|
60
|
+
.textSpecialFontStyle(getFontAttributes(this.node.parentElement as TaroElement))
|
|
61
|
+
.width(getStyleAttr(this.node.parentElement, 'width'))
|
|
62
|
+
.height(getStyleAttr(this.node.parentElement, 'height'))
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
} else {
|
|
@@ -65,7 +67,7 @@ export default struct TaroText {
|
|
|
65
67
|
Text(this.node.textContent)
|
|
66
68
|
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
67
69
|
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
68
|
-
.textNormalFontStyle(
|
|
70
|
+
.textNormalFontStyle(this.node?.hmStyle)
|
|
69
71
|
.textSpecialFontStyle(getFontAttributes(this.node))
|
|
70
72
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
71
73
|
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
|
-
import { getNodeThresholds,
|
|
4
|
+
import { getNodeThresholds, getFontAttributes, shouldBindEvent, parseStyles } from './utils/helper'
|
|
5
5
|
|
|
6
6
|
import type { TaroAny, TaroStyleType, TaroTextStyleType, TaroTextAreaElement, TaroEvent } from '@tarojs/runtime'
|
|
7
7
|
|
|
@@ -30,6 +30,8 @@ function getPlaceholderColor (node: TaroTextAreaElement): string {
|
|
|
30
30
|
export default struct TaroTextArea {
|
|
31
31
|
@State value: string = ''
|
|
32
32
|
|
|
33
|
+
@Builder customBuilder() {}
|
|
34
|
+
@BuilderParam createLazyChildren: (node: TaroTextAreaElement) => void = this.customBuilder
|
|
33
35
|
@ObjectLink node: TaroTextAreaElement
|
|
34
36
|
|
|
35
37
|
aboutToAppear () {
|
|
@@ -51,11 +53,11 @@ export default struct TaroTextArea {
|
|
|
51
53
|
.maxLength(Number(this.node._attrs?.maxlength) || null)
|
|
52
54
|
.placeholderColor(getPlaceholderColor(this.node))
|
|
53
55
|
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
54
|
-
.textStyle(
|
|
56
|
+
.textStyle(this.node?.hmStyle)
|
|
55
57
|
.textAttr(getFontAttributes(this.node))
|
|
56
58
|
.onChange((value: string) => {
|
|
57
59
|
const event: TaroEvent = createTaroEvent('input', { detail: { value } }, this.node)
|
|
58
|
-
|
|
60
|
+
|
|
59
61
|
this.value = value
|
|
60
62
|
this.node?.updateFormWidgetValue(value)
|
|
61
63
|
eventHandler(event, 'input', this.node)
|
|
@@ -67,7 +69,7 @@ export default struct TaroTextArea {
|
|
|
67
69
|
})
|
|
68
70
|
.onFocus(() => {
|
|
69
71
|
const event: TaroEvent = createTaroEvent('focus', { detail: { value: this.value, height: this.node?._height } }, this.node)
|
|
70
|
-
|
|
72
|
+
|
|
71
73
|
eventHandler(event, 'focus', this.node)
|
|
72
74
|
})
|
|
73
75
|
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getNormalAttributes,
|
|
1
|
+
import { getNormalAttributes, getFontAttributes, getStyleAttr } from './styles'
|
|
2
2
|
|
|
3
3
|
import type { TFunc } from '@tarojs/runtime/dist/runtime.esm'
|
|
4
4
|
import type { TaroElement } from '@tarojs/runtime'
|
|
@@ -36,4 +36,5 @@ export function getNodeThresholds (node: TaroElement): number[] | null {
|
|
|
36
36
|
return node?._nodeInfo.thresholds || null
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
|
|
40
|
+
export { getNormalAttributes, getFontAttributes, getStyleAttr }
|
|
@@ -2,10 +2,9 @@ import { isUndefined } from '@tarojs/shared'
|
|
|
2
2
|
import { ObjectAssign } from '@tarojs/runtime'
|
|
3
3
|
|
|
4
4
|
import { FlexManager } from './flexManager'
|
|
5
|
-
import { TEXT_DEFAULT_STYLE } from './constant/style'
|
|
6
5
|
|
|
7
6
|
import type { StandardProps, TextProps } from '@tarojs/components/types'
|
|
8
|
-
import type { TaroAny, TaroElement, TaroStyleType, TaroTextStyleType,
|
|
7
|
+
import type { TaroAny, TaroElement, TaroStyleType, TaroTextStyleType, HarmonyStyle } from '@tarojs/runtime'
|
|
9
8
|
|
|
10
9
|
export function getFontAttributes (node: TaroElement): TaroTextStyleType {
|
|
11
10
|
const hmStyle = node.hmStyle
|
|
@@ -18,8 +17,18 @@ export function getFontAttributes (node: TaroElement): TaroTextStyleType {
|
|
|
18
17
|
lineHeight = 0
|
|
19
18
|
}
|
|
20
19
|
|
|
20
|
+
let WebkitLineClamp = attrs.maxLines || hmStyle.WebkitLineClamp || Infinity
|
|
21
|
+
if (hmStyle.textOverflow && !isUndefined(hmStyle.textOverflow.overflow)) {
|
|
22
|
+
switch (hmStyle.textOverflow.overflow) {
|
|
23
|
+
case TextOverflow.Clip:
|
|
24
|
+
case TextOverflow.Ellipsis:
|
|
25
|
+
case TextOverflow.None: WebkitLineClamp = WebkitLineClamp || 1; break
|
|
26
|
+
default: break
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
21
30
|
const attributes: TaroAny = {
|
|
22
|
-
WebkitLineClamp:
|
|
31
|
+
WebkitLineClamp: WebkitLineClamp,
|
|
23
32
|
// 已做处理的属性
|
|
24
33
|
letterSpacing: hmStyle.letterSpacing,
|
|
25
34
|
textAlign: hmStyle.textAlign,
|
|
@@ -32,14 +41,14 @@ export function getFontAttributes (node: TaroElement): TaroTextStyleType {
|
|
|
32
41
|
}
|
|
33
42
|
|
|
34
43
|
// 模拟 div 自动撑满父元素的情况
|
|
35
|
-
function isMaxWidthView (node: TaroElement) {
|
|
44
|
+
export function isMaxWidthView (node: TaroElement) {
|
|
36
45
|
const parentNode: TaroElement = node.parentNode as TaroElement
|
|
37
46
|
|
|
38
47
|
return node.tagName === 'VIEW' && parentNode && parentNode.tagName === 'VIEW' &&
|
|
39
48
|
!(FlexManager.isFlexNode(parentNode) && FlexManager.flexOptions(parentNode).direction !== FlexDirection.Column)
|
|
40
49
|
}
|
|
41
50
|
|
|
42
|
-
export function getNormalAttributes (node: TaroElement):
|
|
51
|
+
export function getNormalAttributes (node: TaroElement): HarmonyStyle {
|
|
43
52
|
const hmStyle = node.hmStyle
|
|
44
53
|
|
|
45
54
|
if (!hmStyle) return {}
|
|
@@ -47,107 +56,30 @@ export function getNormalAttributes (node: TaroElement): TaroStyleType {
|
|
|
47
56
|
const _nid = node._nid
|
|
48
57
|
const _attrs: StandardProps = node._attrs || {}
|
|
49
58
|
|
|
50
|
-
let
|
|
51
|
-
// 渐变
|
|
52
|
-
if (hmStyle.backgroundImage?.colors) {
|
|
53
|
-
linearGradient = hmStyle.backgroundImage
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
let normalAttributes = getStyle(hmStyle)
|
|
59
|
+
let normalAttributes = hmStyle
|
|
57
60
|
|
|
58
|
-
|
|
61
|
+
// 覆盖属性
|
|
59
62
|
normalAttributes.id = _attrs.id || _nid
|
|
60
63
|
|
|
61
64
|
// taro_page 等写死在运行时里的节点,没有 _nodeInfo
|
|
62
65
|
if (node._nodeInfo) {
|
|
63
66
|
const overwriteStyle: TaroStyleType = node._nodeInfo?.overwriteStyle
|
|
64
|
-
|
|
65
67
|
// 处理覆盖属性:如动画的覆盖
|
|
66
68
|
if (overwriteStyle) {
|
|
67
|
-
normalAttributes = ObjectAssign(normalAttributes, overwriteStyle)
|
|
69
|
+
normalAttributes = ObjectAssign({}, normalAttributes, overwriteStyle)
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
return normalAttributes
|
|
71
73
|
}
|
|
72
74
|
|
|
73
|
-
export function getStyle(hmStyle: HarmonyStyle): TaroStyleType {
|
|
74
|
-
let linearGradient: HarmonyType.LinearGradient | undefined = undefined
|
|
75
|
-
// 渐变
|
|
76
|
-
if (hmStyle.backgroundImage?.colors) {
|
|
77
|
-
linearGradient = hmStyle.backgroundImage
|
|
78
|
-
}
|
|
79
75
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
width: hmStyle.width,
|
|
88
|
-
height: hmStyle.height,
|
|
89
|
-
minHeight: hmStyle.minHeight,
|
|
90
|
-
maxHeight: hmStyle.maxHeight,
|
|
91
|
-
minWidth: hmStyle.minWidth,
|
|
92
|
-
maxWidth: hmStyle.maxWidth,
|
|
93
|
-
marginTop: hmStyle.marginTop,
|
|
94
|
-
marginRight: hmStyle.marginRight,
|
|
95
|
-
marginBottom: hmStyle.marginBottom,
|
|
96
|
-
marginLeft: hmStyle.marginLeft,
|
|
97
|
-
paddingTop: hmStyle.paddingTop,
|
|
98
|
-
paddingRight: hmStyle.paddingRight,
|
|
99
|
-
paddingBottom: hmStyle.paddingBottom,
|
|
100
|
-
paddingLeft: hmStyle.paddingLeft,
|
|
101
|
-
// 边框相关
|
|
102
|
-
borderStyle: hmStyle.borderStyle,
|
|
103
|
-
borderTopStyle: hmStyle.borderTopStyle,
|
|
104
|
-
borderRightStyle: hmStyle.borderRightStyle,
|
|
105
|
-
borderBottomStyle: hmStyle.borderBottomStyle,
|
|
106
|
-
borderLeftStyle: hmStyle.borderLeftStyle,
|
|
107
|
-
borderWidth: hmStyle.borderWidth,
|
|
108
|
-
borderTopWidth: hmStyle.borderTopWidth,
|
|
109
|
-
borderRightWidth: hmStyle.borderRightWidth,
|
|
110
|
-
borderBottomWidth: hmStyle.borderBottomWidth,
|
|
111
|
-
borderLeftWidth: hmStyle.borderLeftWidth,
|
|
112
|
-
borderColor: hmStyle.borderColor,
|
|
113
|
-
borderTopColor: hmStyle.borderTopColor,
|
|
114
|
-
borderRightColor: hmStyle.borderRightColor,
|
|
115
|
-
borderBottomColor: hmStyle.borderBottomColor,
|
|
116
|
-
borderLeftColor: hmStyle.borderLeftColor,
|
|
117
|
-
borderRadius: hmStyle.borderRadius,
|
|
118
|
-
borderTopLeftRadius: hmStyle.borderTopLeftRadius,
|
|
119
|
-
borderTopRightRadius: hmStyle.borderTopRightRadius,
|
|
120
|
-
borderBottomRightRadius: hmStyle.borderBottomRightRadius,
|
|
121
|
-
borderBottomLeftRadius: hmStyle.borderBottomLeftRadius,
|
|
122
|
-
// 背景相关
|
|
123
|
-
backgroundColor: hmStyle.backgroundColor,
|
|
124
|
-
backgroundImage: hmStyle.backgroundImage,
|
|
125
|
-
backgroundSize: hmStyle.backgroundSize,
|
|
126
|
-
backgroundRepeat: hmStyle.backgroundRepeat,
|
|
127
|
-
backgroundPosition: hmStyle.backgroundPosition,
|
|
128
|
-
linearGradient,
|
|
129
|
-
// 变换相关
|
|
130
|
-
transform: hmStyle.transform,
|
|
131
|
-
transformOrigin: {
|
|
132
|
-
x: hmStyle.transformOrigin?.x || 0,
|
|
133
|
-
y: hmStyle.transformOrigin?.y || 0
|
|
134
|
-
},
|
|
135
|
-
// 通用文本相关
|
|
136
|
-
color: hmStyle.color,
|
|
137
|
-
fontSize: hmStyle.fontSize,
|
|
138
|
-
fontStyle: hmStyle.fontStyle,
|
|
139
|
-
fontWeight: hmStyle.fontWeight,
|
|
140
|
-
fontFamily: hmStyle.fontFamily || TEXT_DEFAULT_STYLE.FONT_FAMILY,
|
|
141
|
-
textDecoration: hmStyle.textDecoration,
|
|
142
|
-
// 其他
|
|
143
|
-
overflow: hmStyle.overflow,
|
|
144
|
-
opacity: hmStyle.opacity,
|
|
145
|
-
zIndex: hmStyle.zIndex,
|
|
146
|
-
// 定位
|
|
147
|
-
position: hmStyle.position,
|
|
148
|
-
top: hmStyle.top,
|
|
149
|
-
left: hmStyle.left,
|
|
76
|
+
export function getStyleAttr(node: TaroElement | null, key: string): TaroAny {
|
|
77
|
+
if (!node) return null
|
|
78
|
+
const hmStyle = node.hmStyle
|
|
79
|
+
if (!hmStyle) return null
|
|
80
|
+
// 覆盖属性
|
|
81
|
+
if (key === 'width') {
|
|
82
|
+
return isMaxWidthView(node) && isUndefined(hmStyle.width) ? '100%' : hmStyle.width
|
|
150
83
|
}
|
|
151
|
-
|
|
152
|
-
return normalAttributes
|
|
84
|
+
return hmStyle[key]
|
|
153
85
|
}
|
|
@@ -80,6 +80,8 @@ function handleUpdate (node: TaroVideoElement, e: VideoUpdateEvent) {
|
|
|
80
80
|
|
|
81
81
|
@Component
|
|
82
82
|
export default struct TaroVideo {
|
|
83
|
+
@Builder customBuilder() {}
|
|
84
|
+
@BuilderParam createLazyChildren: (node: TaroVideoElement) => void = this.customBuilder
|
|
83
85
|
@ObjectLink node: TaroVideoElement
|
|
84
86
|
|
|
85
87
|
build () {
|