@tarojs/plugin-platform-harmony-ets 4.0.0-beta.35 → 4.0.0-beta.37
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/index.ts +2 -1
- package/dist/components-harmony-ets/button.ets +30 -32
- package/dist/components-harmony-ets/checkbox.ets +52 -56
- package/dist/components-harmony-ets/form.ets +25 -27
- package/dist/components-harmony-ets/icon.ets +17 -19
- package/dist/components-harmony-ets/image.ets +10 -12
- package/dist/components-harmony-ets/input.ets +36 -38
- package/dist/components-harmony-ets/label.ets +36 -38
- package/dist/components-harmony-ets/movableArea.ets +55 -57
- package/dist/components-harmony-ets/movableView.ets +44 -46
- package/dist/components-harmony-ets/picker.ets +15 -17
- package/dist/components-harmony-ets/progress.ets +22 -24
- package/dist/components-harmony-ets/radio.ets +54 -58
- package/dist/components-harmony-ets/richText.ets +7 -9
- package/dist/components-harmony-ets/scrollView.ets +47 -49
- package/dist/components-harmony-ets/slider.ets +8 -10
- package/dist/components-harmony-ets/style.ets +103 -4
- package/dist/components-harmony-ets/swiper.ets +17 -19
- package/dist/components-harmony-ets/switch.ets +24 -26
- package/dist/components-harmony-ets/text.ets +80 -43
- package/dist/components-harmony-ets/textArea.ets +28 -30
- package/dist/components-harmony-ets/video.ets +19 -21
- package/dist/components-harmony-ets/view.ets +31 -33
- package/dist/components-harmony-ets/webView.ets +30 -32
- package/dist/runtime-ets/dom/document.ts +2 -0
- package/dist/runtime-ets/dom/element/element.ts +45 -1
- package/dist/runtime-ets/dom/element/index.ts +5 -2
- package/dist/runtime-ets/dom/element/normal.ts +4 -0
- package/dist/runtime-ets/dom/node.ts +11 -7
- package/dist/runtime-ets/dom/stylesheet/type.ts +1 -0
- package/dist/runtime-utils.js +5 -46
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +5 -46
- package/dist/runtime.js.map +1 -1
- package/package.json +9 -9
|
@@ -1,9 +1,55 @@
|
|
|
1
|
-
import type { TaroAny, HarmonyStyle, TaroElement, TaroStyleType }
|
|
1
|
+
import type { TaroAny, HarmonyStyle, TaroElement, TaroStyleType, TaroTextElement } from '@tarojs/runtime'
|
|
2
2
|
import { isUndefined } from '@tarojs/shared'
|
|
3
3
|
import { computeBackgroundPosition } from './utils'
|
|
4
4
|
import { getNormalAttributes } from './utils/helper'
|
|
5
5
|
import { isMaxWidthView } from './utils/styles'
|
|
6
6
|
|
|
7
|
+
class TextStyleModify implements AttributeModifier<TextAttribute> {
|
|
8
|
+
initStyle?: TaroStyleType
|
|
9
|
+
node: TaroTextElement | null = null
|
|
10
|
+
style: HarmonyStyle | null = null
|
|
11
|
+
overwriteStyle: Record<string, TaroAny> = {}
|
|
12
|
+
withNormal = false
|
|
13
|
+
|
|
14
|
+
withNormalStyle () {
|
|
15
|
+
this.withNormal = true
|
|
16
|
+
return this
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
setAnimationStyle (overwriteStyle: Record<string, TaroAny>) {
|
|
20
|
+
this.overwriteStyle = overwriteStyle
|
|
21
|
+
|
|
22
|
+
return this
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
setNode (node: TaroTextElement, initStyle?: HarmonyStyle) {
|
|
26
|
+
this.node = node
|
|
27
|
+
this.style = getNormalAttributes(this.node)
|
|
28
|
+
this.initStyle = initStyle
|
|
29
|
+
// 覆盖初始化样式
|
|
30
|
+
if (initStyle) {
|
|
31
|
+
Object.keys(initStyle).forEach(key => {
|
|
32
|
+
if (this.style && !this.style[key]) {
|
|
33
|
+
this.style[key] = initStyle[key]
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
return this
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
applyNormalAttribute(instance: TextAttribute): void {
|
|
41
|
+
if (this.node && this.style) {
|
|
42
|
+
if (this.withNormal) {
|
|
43
|
+
setNormalAttributeIntoInstance(instance, this.style, this.node)
|
|
44
|
+
}
|
|
45
|
+
setNormalTextAttributeIntoInstance(instance, this.style, this.node)
|
|
46
|
+
setSpecialTextAttributeIntoInstance(instance, this.style, this.node)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
setAnimationAttributeIntoInstance(instance, this.overwriteStyle, this.style || {})
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
7
53
|
class CommonStyleModify implements AttributeModifier<CommonAttribute> {
|
|
8
54
|
initStyle?: TaroStyleType
|
|
9
55
|
node: TaroElement | null = null
|
|
@@ -55,7 +101,6 @@ class PseudoStyleModify implements AttributeModifier<CommonAttribute> {
|
|
|
55
101
|
}
|
|
56
102
|
}
|
|
57
103
|
|
|
58
|
-
|
|
59
104
|
class RowStyleModify extends CommonStyleModify {
|
|
60
105
|
|
|
61
106
|
applyNormalAttribute(instance: CommonAttribute): void {
|
|
@@ -89,7 +134,7 @@ class ColumnStyleModify extends CommonStyleModify {
|
|
|
89
134
|
}
|
|
90
135
|
}
|
|
91
136
|
|
|
92
|
-
function setAnimationAttributeIntoInstance(instance: CommonAttribute, overwriteStyle: Record<string, TaroAny>, style: TaroStyleType) {
|
|
137
|
+
export function setAnimationAttributeIntoInstance(instance: CommonAttribute, overwriteStyle: Record<string, TaroAny>, style: TaroStyleType) {
|
|
93
138
|
// Animation 需要提前和 @State 变量绑定才能产生动画效果,因此不能做 if else 判断
|
|
94
139
|
instance.translate({
|
|
95
140
|
x: overwriteStyle.translate?.x || style.transform?.Translate?.x,
|
|
@@ -113,11 +158,64 @@ function setAnimationAttributeIntoInstance(instance: CommonAttribute, overwriteS
|
|
|
113
158
|
})
|
|
114
159
|
}
|
|
115
160
|
|
|
116
|
-
function
|
|
161
|
+
export function setNormalTextAttributeIntoInstance(instance: TextAttribute | SpanAttribute, style: HarmonyStyle, node?: TaroTextElement | null) {
|
|
162
|
+
if (!isUndefined(style.color)) {
|
|
163
|
+
instance.fontColor(style.color)
|
|
164
|
+
}
|
|
165
|
+
if (!isUndefined(style.fontSize)) {
|
|
166
|
+
instance.fontSize(style.fontSize)
|
|
167
|
+
}
|
|
168
|
+
if (!isUndefined(style.fontWeight)) {
|
|
169
|
+
instance.fontWeight(style.fontWeight)
|
|
170
|
+
}
|
|
171
|
+
if (!isUndefined(style.fontStyle)) {
|
|
172
|
+
instance.fontStyle(style.fontStyle)
|
|
173
|
+
}
|
|
174
|
+
if (!isUndefined(style.fontFamily)) {
|
|
175
|
+
instance.fontFamily(style.fontFamily)
|
|
176
|
+
}
|
|
177
|
+
if (!isUndefined(style.textDecoration)) {
|
|
178
|
+
instance.decoration({
|
|
179
|
+
type: style.textDecoration,
|
|
180
|
+
color: style.color
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export function setSpecialTextAttributeIntoInstance(instance: TextAttribute, style: HarmonyStyle, node?: TaroTextElement | null) {
|
|
186
|
+
if (!isUndefined(style.textAlign)) {
|
|
187
|
+
instance.textAlign(style.textAlign)
|
|
188
|
+
}
|
|
189
|
+
if (!isUndefined(style.verticalAlign)) {
|
|
190
|
+
instance.align(style.verticalAlign)
|
|
191
|
+
}
|
|
192
|
+
if (!isUndefined(style.textOverflow)) {
|
|
193
|
+
instance.textOverflow(style.textOverflow)
|
|
194
|
+
}
|
|
195
|
+
if (!isUndefined(style.WebkitLineClamp)) {
|
|
196
|
+
instance.maxLines(style.WebkitLineClamp)
|
|
197
|
+
}
|
|
198
|
+
if (!isUndefined(style.letterSpacing)) {
|
|
199
|
+
instance.letterSpacing(style.letterSpacing)
|
|
200
|
+
}
|
|
201
|
+
if (!isUndefined(style.lineHeight)) {
|
|
202
|
+
instance.lineHeight(style.lineHeight)
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function setNormalAttributeIntoInstance(instance: CommonAttribute, style: TaroStyleType, node?: TaroElement | null) {
|
|
117
207
|
if (!isUndefined(style.id)) {
|
|
118
208
|
instance.id(style.id)
|
|
119
209
|
instance.key(style.id)
|
|
120
210
|
}
|
|
211
|
+
if (!isUndefined(style.display) || !isUndefined(style.visibility)) {
|
|
212
|
+
instance.visibility(style.display === 'none'
|
|
213
|
+
? Visibility.None :
|
|
214
|
+
!isUndefined(style.visibility)
|
|
215
|
+
? (style.visibility === 'hidden' ? Visibility.Hidden : Visibility.Visible)
|
|
216
|
+
: Visibility.Visible
|
|
217
|
+
)
|
|
218
|
+
}
|
|
121
219
|
if (!isUndefined(style.flexGrow)) {
|
|
122
220
|
instance.flexGrow(style.flexGrow)
|
|
123
221
|
}
|
|
@@ -288,5 +386,6 @@ function setNormalAttributeIntoInstance(instance: CommonAttribute, style: TaroSt
|
|
|
288
386
|
export const pseudoModify = new PseudoStyleModify()
|
|
289
387
|
export const rowModify = new RowStyleModify()
|
|
290
388
|
export const columnModify = new ColumnStyleModify()
|
|
389
|
+
export const textModify = new TextStyleModify()
|
|
291
390
|
|
|
292
391
|
export default new CommonStyleModify()
|
|
@@ -53,25 +53,23 @@ export default struct TaroSwiper {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
build () {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this.createLazyChildren(this.node)
|
|
59
|
-
}
|
|
60
|
-
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
61
|
-
.swiperAttr(getSwiperAttributes(this.node))
|
|
62
|
-
.indicatorStyle({
|
|
63
|
-
color: this.node.getAttribute('indicatorColor'),
|
|
64
|
-
selectedColor: this.node.getAttribute('indicatorActiveColor')
|
|
65
|
-
})
|
|
66
|
-
.onChange((index: number) => {
|
|
67
|
-
const event: TaroEvent = createTaroEvent('change', { detail: { current: index } }, this.node)
|
|
68
|
-
eventHandler(event, 'change', this.node)
|
|
69
|
-
})
|
|
70
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
71
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
72
|
-
this.node._nodeInfo.areaInfo = res[1]
|
|
73
|
-
}))
|
|
74
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
56
|
+
Swiper(this.node.controller) {
|
|
57
|
+
this.createLazyChildren(this.node)
|
|
75
58
|
}
|
|
59
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
60
|
+
.swiperAttr(getSwiperAttributes(this.node))
|
|
61
|
+
.indicatorStyle({
|
|
62
|
+
color: this.node.getAttribute('indicatorColor'),
|
|
63
|
+
selectedColor: this.node.getAttribute('indicatorActiveColor')
|
|
64
|
+
})
|
|
65
|
+
.onChange((index: number) => {
|
|
66
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { current: index } }, this.node)
|
|
67
|
+
eventHandler(event, 'change', this.node)
|
|
68
|
+
})
|
|
69
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
70
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
71
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
72
|
+
}))
|
|
73
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
76
74
|
}
|
|
77
75
|
}
|
|
@@ -42,33 +42,31 @@ export default struct TaroSwitch {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
build () {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
.
|
|
54
|
-
if (this.node) {
|
|
55
|
-
|
|
56
|
-
const event: TaroEvent = createTaroEvent('change', { detail: { value: isOn } }, this.node)
|
|
45
|
+
Toggle({
|
|
46
|
+
type: this.node._attrs.type !== 'checkbox' ? ToggleType.Switch : ToggleType.Checkbox,
|
|
47
|
+
isOn: this.node.checked,
|
|
48
|
+
})
|
|
49
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
50
|
+
.attrs(getAttributes(this.node))
|
|
51
|
+
.themeStyles(!!this.node._attrs.disabled)
|
|
52
|
+
.onChange((isOn: boolean) => {
|
|
53
|
+
if (this.node) {
|
|
54
|
+
if (!this.node?._attrs.disabled) {
|
|
55
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { value: isOn } }, this.node)
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
66
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
67
|
-
if (this.node) {
|
|
68
|
-
this.node._nodeInfo.areaInfo = res[1]
|
|
57
|
+
this.node.updateCheckedValue(isOn)
|
|
58
|
+
eventHandler(event, 'change', this.node)
|
|
59
|
+
} else {
|
|
60
|
+
this.node.updateComponent()
|
|
69
61
|
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
65
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
66
|
+
if (this.node) {
|
|
67
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
68
|
+
}
|
|
69
|
+
}))
|
|
70
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
73
71
|
}
|
|
74
72
|
}
|
|
@@ -1,38 +1,13 @@
|
|
|
1
1
|
import { isString } from '@tarojs/shared'
|
|
2
2
|
import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, NodeType } from '@tarojs/runtime'
|
|
3
3
|
|
|
4
|
-
import commonStyleModify from './style'
|
|
4
|
+
import commonStyleModify, { textModify, setNormalTextAttributeIntoInstance } from './style'
|
|
5
5
|
import { getButtonColor } from './button'
|
|
6
|
+
import { getImageMode } from './image'
|
|
6
7
|
import { BUTTON_THEME_COLOR } from './utils/constant/style'
|
|
7
|
-
import { getNodeThresholds, getStyleAttr,
|
|
8
|
-
|
|
9
|
-
import type { TaroButtonElement, TaroElement, TaroTextElement, TaroAny, TaroTextStyleType, TaroStyleType } from '@tarojs/runtime'
|
|
10
|
-
|
|
11
|
-
@Extend(Text)
|
|
12
|
-
function textNormalFontStyle (style: TaroStyleType) {
|
|
13
|
-
.id(style.id)
|
|
14
|
-
.key(style.id)
|
|
15
|
-
.opacity(style.opacity)
|
|
16
|
-
.fontColor(style.color)
|
|
17
|
-
.fontSize(style.fontSize)
|
|
18
|
-
.fontWeight(style.fontWeight)
|
|
19
|
-
.fontStyle(style.fontStyle)
|
|
20
|
-
.fontFamily(style.fontFamily)
|
|
21
|
-
.decoration({
|
|
22
|
-
type: style.textDecoration,
|
|
23
|
-
color: style.color
|
|
24
|
-
})
|
|
25
|
-
}
|
|
8
|
+
import { getNodeThresholds, getStyleAttr, shouldBindEvent, getNormalAttributes } from './utils/helper'
|
|
26
9
|
|
|
27
|
-
@
|
|
28
|
-
function textSpecialFontStyle(attr: TaroTextStyleType) {
|
|
29
|
-
.textAlign(attr.textAlign)
|
|
30
|
-
.align(attr.verticalAlign)
|
|
31
|
-
.textOverflow(attr.textOverflow)
|
|
32
|
-
.maxLines(attr.WebkitLineClamp)
|
|
33
|
-
.letterSpacing(attr.letterSpacing)
|
|
34
|
-
.lineHeight(attr.lineHeight)
|
|
35
|
-
}
|
|
10
|
+
import type { TaroButtonElement, TaroElement, TaroTextElement, TaroAny, HarmonyStyle } from '@tarojs/runtime'
|
|
36
11
|
|
|
37
12
|
function getButtonFontSize (node: TaroButtonElement): string | number {
|
|
38
13
|
const isMini = node._attrs.size === 'mini'
|
|
@@ -51,6 +26,7 @@ function getTextInViewWidth (node: TaroElement | null): TaroAny {
|
|
|
51
26
|
}
|
|
52
27
|
}
|
|
53
28
|
|
|
29
|
+
|
|
54
30
|
@Component
|
|
55
31
|
export default struct TaroText {
|
|
56
32
|
@Builder customBuilder() {}
|
|
@@ -69,30 +45,91 @@ export default struct TaroText {
|
|
|
69
45
|
if (this.node.parentNode) {
|
|
70
46
|
if ((this.node.parentNode as TaroElement).tagName === 'BUTTON') {
|
|
71
47
|
Text(this.node.textContent)
|
|
72
|
-
.
|
|
48
|
+
.attributeModifier(textModify.setNode(this.node?.parentElement as TaroElement, {
|
|
73
49
|
fontSize: getButtonFontSize(this.node.parentNode as TaroButtonElement),
|
|
74
50
|
color: getButtonColor(this.node.parentNode as TaroButtonElement, BUTTON_THEME_COLOR.get((this.node.parentNode as TaroButtonElement)._attrs.type || '').text)
|
|
75
51
|
}))
|
|
76
|
-
.textSpecialFontStyle(getFontAttributes(this.node.parentElement as TaroElement))
|
|
77
52
|
} else {
|
|
78
53
|
Text(this.node.textContent)
|
|
79
|
-
.
|
|
80
|
-
.textSpecialFontStyle(getFontAttributes(this.node.parentElement as TaroElement))
|
|
54
|
+
.attributeModifier(textModify.setNode(this.node?.parentElement as TaroElement))
|
|
81
55
|
.width(getTextInViewWidth(this.node.parentElement))
|
|
82
56
|
}
|
|
83
57
|
}
|
|
84
58
|
} else {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
92
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
93
|
-
this.node._nodeInfo.areaInfo = res[1]
|
|
94
|
-
}))
|
|
59
|
+
Text(this.node.textContent) {
|
|
60
|
+
if (this.node.childNodes.length > 1) {
|
|
61
|
+
ForEach(this.node.childNodes, (item: TaroElement) => {
|
|
62
|
+
createTextChildNode(item, getSpanVerticalAlign(this.node.hmStyle?.verticalAlign))
|
|
63
|
+
}, (item: TaroElement) => item._nid)
|
|
64
|
+
}
|
|
95
65
|
}
|
|
66
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
67
|
+
.attributeModifier(textModify.setNode(this.node).withNormalStyle().setAnimationStyle(this.overwriteStyle))
|
|
68
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
69
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
70
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
71
|
+
}))
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@Builder
|
|
77
|
+
function createTextChildNode (item: TaroElement, align: ImageSpanAlignment) {
|
|
78
|
+
if (item.tagName === 'IMAGE') {
|
|
79
|
+
ImageSpan(item.getAttribute('src'))
|
|
80
|
+
.attributeModifier(commonStyleModify.setNode(item))
|
|
81
|
+
.objectFit(getImageMode(item.getAttribute('mode')))
|
|
82
|
+
.verticalAlign(align)
|
|
83
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', item), item, ['click']))
|
|
84
|
+
} else if (item.nodeType === NodeType.TEXT_NODE) {
|
|
85
|
+
Span(item.textContent)
|
|
86
|
+
} else if (item.tagName === 'TEXT') {
|
|
87
|
+
Span(item.textContent)
|
|
88
|
+
.attributeModifier(spanModify.setNode(item))
|
|
89
|
+
.letterSpacing(item._st.hmStyle.letterSpacing)
|
|
90
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', item), item, ['click']))
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function getSpanVerticalAlign (verticalAlign?: Alignment) {
|
|
95
|
+
switch (verticalAlign) {
|
|
96
|
+
case Alignment.Start:
|
|
97
|
+
case Alignment.TopStart:
|
|
98
|
+
case Alignment.Top:
|
|
99
|
+
case Alignment.TopEnd: {
|
|
100
|
+
return ImageSpanAlignment.TOP
|
|
101
|
+
}
|
|
102
|
+
case Alignment.End:
|
|
103
|
+
case Alignment.BottomStart:
|
|
104
|
+
case Alignment.Bottom:
|
|
105
|
+
case Alignment.BottomEnd: {
|
|
106
|
+
return ImageSpanAlignment.BOTTOM
|
|
107
|
+
}
|
|
108
|
+
case Alignment.Center: {
|
|
109
|
+
return ImageSpanAlignment.CENTER
|
|
96
110
|
}
|
|
97
111
|
}
|
|
112
|
+
return ImageSpanAlignment.BASELINE
|
|
98
113
|
}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class SpanStyleModify implements AttributeModifier<SpanAttribute> {
|
|
117
|
+
node: TaroTextElement | null = null
|
|
118
|
+
style: HarmonyStyle | null = null
|
|
119
|
+
overwriteStyle: Record<string, TaroAny> = {}
|
|
120
|
+
withNormal = false
|
|
121
|
+
|
|
122
|
+
setNode (node: TaroTextElement) {
|
|
123
|
+
this.node = node
|
|
124
|
+
this.style = getNormalAttributes(this.node)
|
|
125
|
+
return this
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
applyNormalAttribute(instance: SpanAttribute): void {
|
|
129
|
+
if (this.node && this.style) {
|
|
130
|
+
setNormalTextAttributeIntoInstance(instance, this.style, this.node)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const spanModify = new SpanStyleModify()
|
|
@@ -48,37 +48,35 @@ export default struct TaroTextArea {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
build () {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const event: TaroEvent = createTaroEvent('input', { detail: { value } }, this.node)
|
|
51
|
+
TextArea({ text: this.value, placeholder: this.node._attrs?.placeholder || '', controller: this.node.controller })
|
|
52
|
+
.key(this.node._nid)
|
|
53
|
+
.maxLength(Number(this.node._attrs?.maxlength) || null)
|
|
54
|
+
.placeholderColor(getPlaceholderColor(this.node))
|
|
55
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
56
|
+
.textStyle(this.node?.hmStyle)
|
|
57
|
+
.textAttr(getFontAttributes(this.node))
|
|
58
|
+
.onChange((value: string) => {
|
|
59
|
+
const event: TaroEvent = createTaroEvent('input', { detail: { value } }, this.node)
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
61
|
+
this.value = value
|
|
62
|
+
this.node?.updateFormWidgetValue(value)
|
|
63
|
+
eventHandler(event, 'input', this.node)
|
|
64
|
+
})
|
|
65
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
66
|
+
.onBlur(() => {
|
|
67
|
+
const event: TaroEvent = createTaroEvent('blur', { detail: { value: this.value } }, this.node)
|
|
68
|
+
eventHandler(event, 'blur', this.node)
|
|
69
|
+
})
|
|
70
|
+
.onFocus(() => {
|
|
71
|
+
const event: TaroEvent = createTaroEvent('focus', { detail: { value: this.value, height: this.node?._height } }, this.node)
|
|
73
72
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
73
|
+
eventHandler(event, 'focus', this.node)
|
|
74
|
+
})
|
|
75
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
76
|
+
if (this.node) {
|
|
77
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
78
|
+
}
|
|
79
|
+
}))
|
|
80
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
83
81
|
}
|
|
84
82
|
}
|
|
@@ -92,27 +92,25 @@ export default struct TaroVideo {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
build () {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
115
|
-
}
|
|
95
|
+
Video(getVideoData(this.node))
|
|
96
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
97
|
+
.props(getVideoProps(this.node))
|
|
98
|
+
.aspectRatio(4 / 3)
|
|
99
|
+
.onStart(shouldBindEvent(() => { emitEvent(this.node, 'play') }, this.node, ['play']))
|
|
100
|
+
.onPause(shouldBindEvent(() => { emitEvent(this.node, 'pause') }, this.node, ['pause']))
|
|
101
|
+
.onFinish(shouldBindEvent(() => { emitEvent(this.node, 'ended') }, this.node, ['ended']))
|
|
102
|
+
.onError(shouldBindEvent(() => { emitEvent(this.node, 'error') }, this.node, ['error']))
|
|
103
|
+
.onUpdate((e) => { handleUpdate(this.node, e) })
|
|
104
|
+
.onPrepared(shouldBindEvent((e: TaroAny) => { emitEvent(this.node, 'loadedMetaData', { duration: e.duration }) }, this.node, ['loadedmetadata']))
|
|
105
|
+
.onSeeking(shouldBindEvent((e: TaroAny) => { emitEvent(this.node, 'seeking', { duration: e.time }) }, this.node, ['seeking']))
|
|
106
|
+
.onSeeked(shouldBindEvent(() => { emitEvent(this.node, 'seeked') }, this.node, ['seeked']))
|
|
107
|
+
.onFullscreenChange(shouldBindEvent((e: TaroAny) => { emitEvent(this.node, 'fullScreenChange', { fullScreen: e.fullscreen}) }, this.node, ['fullscreenchange']))
|
|
108
|
+
.onClick((e: ClickEvent) => { eventHandler(e, 'click', this.node) })
|
|
109
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
110
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
111
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
112
|
+
}))
|
|
113
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
116
114
|
}
|
|
117
115
|
|
|
118
116
|
}
|
|
@@ -22,42 +22,40 @@ export default struct TaroView {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
build () {
|
|
25
|
-
if (this.node.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.createLazyChildren(this.node)
|
|
32
|
-
}
|
|
25
|
+
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
26
|
+
Row() {
|
|
27
|
+
if (this.node._pseudo_before || this.node._pseudo_after) {
|
|
28
|
+
PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
|
|
29
|
+
} else {
|
|
30
|
+
this.createLazyChildren(this.node)
|
|
33
31
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
32
|
+
}
|
|
33
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
34
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
35
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
36
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
37
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
38
|
+
}))
|
|
39
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
40
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
41
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
42
|
+
} else {
|
|
43
|
+
Column() {
|
|
44
|
+
if (this.node._pseudo_before || this.node._pseudo_after) {
|
|
45
|
+
PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
|
|
46
|
+
} else {
|
|
47
|
+
this.createLazyChildren(this.node)
|
|
50
48
|
}
|
|
51
|
-
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
52
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
53
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
54
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
55
|
-
this.node._nodeInfo.areaInfo = res[1]
|
|
56
|
-
}))
|
|
57
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
58
|
-
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
59
|
-
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
60
49
|
}
|
|
50
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
51
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
52
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
53
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
54
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
55
|
+
}))
|
|
56
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
57
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
58
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
61
59
|
}
|
|
62
60
|
}
|
|
63
61
|
}
|