@tarojs/plugin-platform-harmony-ets 4.0.0-beta.16 → 4.0.0-beta.18
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/components-harmony-ets/button.ets +32 -29
- package/dist/components-harmony-ets/checkbox.ets +2 -2
- package/dist/components-harmony-ets/form.ets +28 -25
- package/dist/components-harmony-ets/icon.ets +18 -16
- package/dist/components-harmony-ets/image.ets +13 -11
- package/dist/components-harmony-ets/innerHtml.ets +1 -1
- package/dist/components-harmony-ets/input.ets +1 -1
- package/dist/components-harmony-ets/label.ets +39 -36
- package/dist/components-harmony-ets/movableArea.ets +1 -1
- package/dist/components-harmony-ets/movableView.ets +1 -1
- package/dist/components-harmony-ets/picker.ets +1 -1
- package/dist/components-harmony-ets/progress.ets +1 -1
- package/dist/components-harmony-ets/radio.ets +2 -2
- package/dist/components-harmony-ets/richText.ets +10 -31
- package/dist/components-harmony-ets/scrollView.ets +45 -43
- package/dist/components-harmony-ets/slider.ets +1 -1
- package/dist/components-harmony-ets/style.ets +30 -5
- package/dist/components-harmony-ets/swiper.ets +19 -17
- package/dist/components-harmony-ets/switch.ets +1 -1
- package/dist/components-harmony-ets/text.ets +11 -9
- package/dist/components-harmony-ets/textArea.ets +1 -1
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
- package/dist/components-harmony-ets/utils/index.ts +26 -0
- package/dist/components-harmony-ets/video.ets +3 -1
- package/dist/components-harmony-ets/view.ets +29 -27
- package/dist/components-harmony-ets/webView.ets +34 -33
- package/dist/index.d.ts +149 -0
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/dom/bind.ts +0 -1
- package/dist/runtime-ets/dom/cssNesting.ts +24 -27
- package/dist/runtime-ets/dom/document.ts +0 -1
- package/dist/runtime-ets/dom/element/movableView.ts +0 -1
- package/dist/runtime-ets/dom/element/normal.ts +0 -1
- package/dist/runtime-ets/dom/event.ts +0 -1
- package/dist/runtime-ets/dom/eventTarget.ts +0 -3
- package/dist/runtime-ets/dom/stylesheet/index.ts +0 -2
- package/dist/runtime-ets/dom/stylesheet/type.ts +7 -3
- package/dist/runtime-ets/dom/stylesheet/util.ts +18 -14
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/utils/index.ts +0 -1
- package/dist/runtime-framework/react/native-page.ts +0 -1
- package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
- package/dist/runtime-framework/solid/utils/index.ts +0 -2
- package/dist/runtime-utils.d.ts +825 -0
- package/dist/runtime.d.ts +1 -0
- package/index.js +3 -1
- package/package.json +8 -8
|
@@ -97,38 +97,41 @@ function getButtonMinHeight (node: TaroButtonElement): string | number | undefin
|
|
|
97
97
|
@Component
|
|
98
98
|
export default struct TaroButton {
|
|
99
99
|
@ObjectLink node: TaroButtonElement
|
|
100
|
+
|
|
100
101
|
build() {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
if (this.node?.hmStyle?.display !== 'none') {
|
|
103
|
+
Button({ stateEffect: !this.node._attrs.disabled }) {
|
|
104
|
+
Row() {
|
|
105
|
+
if (this.node._attrs.loading) {
|
|
106
|
+
LoadingProgress()
|
|
107
|
+
.width(20).height(20)
|
|
108
|
+
.color(getThemeAttributes(this.node).color)
|
|
109
|
+
}
|
|
110
|
+
createLazyChildren(this.node)
|
|
107
111
|
}
|
|
108
|
-
createLazyChildren(this.node)
|
|
109
112
|
}
|
|
113
|
+
.themeStyles(getThemeAttributes(this.node))
|
|
114
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
115
|
+
.constraintSize({
|
|
116
|
+
minWidth: this.node.hmStyle?.minWidth || getButtonMinWidth(this.node),
|
|
117
|
+
minHeight: this.node.hmStyle?.minHeight || getButtonMinHeight(this.node),
|
|
118
|
+
maxWidth: this.node.hmStyle?.maxWidth,
|
|
119
|
+
maxHeight: this.node.hmStyle?.maxHeight,
|
|
120
|
+
})
|
|
121
|
+
.type(ButtonType.Normal)
|
|
122
|
+
.onClick((e: ClickEvent) => {
|
|
123
|
+
if (this.node._attrs.formType && ['submit', 'reset'].includes(this.node._attrs.formType)) {
|
|
124
|
+
const eventName = this.node._attrs.formType + '-btn'
|
|
125
|
+
const event: TaroEvent = createTaroEvent(eventName, {}, this.node)
|
|
126
|
+
eventHandler(event, eventName, this.node)
|
|
127
|
+
}
|
|
128
|
+
eventHandler(e, 'click', this.node)
|
|
129
|
+
})
|
|
130
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
131
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
132
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
133
|
+
}))
|
|
134
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
110
135
|
}
|
|
111
|
-
.themeStyles(getThemeAttributes(this.node))
|
|
112
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
113
|
-
.constraintSize({
|
|
114
|
-
minWidth: this.node.hmStyle?.minWidth || getButtonMinWidth(this.node),
|
|
115
|
-
minHeight: this.node.hmStyle?.minHeight || getButtonMinHeight(this.node),
|
|
116
|
-
maxWidth: this.node.hmStyle?.maxWidth,
|
|
117
|
-
maxHeight: this.node.hmStyle?.maxHeight,
|
|
118
|
-
})
|
|
119
|
-
.type(ButtonType.Normal)
|
|
120
|
-
.onClick((e: ClickEvent) => {
|
|
121
|
-
if (this.node._attrs.formType && ['submit', 'reset'].includes(this.node._attrs.formType)) {
|
|
122
|
-
const eventName = this.node._attrs.formType + '-btn'
|
|
123
|
-
const event: TaroEvent = createTaroEvent(eventName, {}, this.node)
|
|
124
|
-
eventHandler(event, eventName, this.node)
|
|
125
|
-
}
|
|
126
|
-
eventHandler(e, 'click', this.node)
|
|
127
|
-
})
|
|
128
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
129
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
130
|
-
this.node._nodeInfo.areaInfo = res[1]
|
|
131
|
-
}))
|
|
132
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
133
136
|
}
|
|
134
137
|
}
|
|
@@ -46,7 +46,7 @@ export struct TaroCheckbox {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
build () {
|
|
49
|
-
if (this.node) {
|
|
49
|
+
if (this.node && this.node?.hmStyle?.display !== 'none') {
|
|
50
50
|
Stack() {
|
|
51
51
|
Row() {
|
|
52
52
|
Checkbox(getOptions(this.node))
|
|
@@ -121,7 +121,7 @@ export struct TaroCheckboxGroup {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
build() {
|
|
124
|
-
if (this.node) {
|
|
124
|
+
if (this.node && this.node?.hmStyle?.display !== 'none') {
|
|
125
125
|
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
126
126
|
Row() {
|
|
127
127
|
createLazyChildren(this.node)
|
|
@@ -11,33 +11,36 @@ import type { TaroAny, TaroFormElement } from '@tarojs/runtime'
|
|
|
11
11
|
@Component
|
|
12
12
|
export default struct TaroForm {
|
|
13
13
|
@ObjectLink node: TaroFormElement
|
|
14
|
+
|
|
14
15
|
build() {
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
if (this.node?.hmStyle?.display !== 'none') {
|
|
17
|
+
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
18
|
+
Row() {
|
|
19
|
+
createLazyChildren(this.node)
|
|
20
|
+
}
|
|
21
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
22
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
23
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
24
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
25
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
26
|
+
}))
|
|
27
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
28
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
29
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
30
|
+
} else {
|
|
31
|
+
Column() {
|
|
32
|
+
createLazyChildren(this.node)
|
|
33
|
+
}
|
|
34
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
35
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
36
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
37
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
38
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
39
|
+
}))
|
|
40
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
41
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
42
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
18
43
|
}
|
|
19
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
20
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
21
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
22
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
23
|
-
this.node._nodeInfo.areaInfo = res[1]
|
|
24
|
-
}))
|
|
25
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
26
|
-
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
27
|
-
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
28
|
-
} else {
|
|
29
|
-
Column() {
|
|
30
|
-
createLazyChildren(this.node)
|
|
31
|
-
}
|
|
32
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
33
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
34
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
35
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
36
|
-
this.node._nodeInfo.areaInfo = res[1]
|
|
37
|
-
}))
|
|
38
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
39
|
-
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
40
|
-
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
}
|
|
@@ -52,22 +52,24 @@ function getIconData (node: TaroIconElement): Resource | null {
|
|
|
52
52
|
export default struct TaroIcon {
|
|
53
53
|
@ObjectLink node: TaroIconElement
|
|
54
54
|
build() {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.node
|
|
70
|
-
|
|
55
|
+
if (this.node?.hmStyle?.display !== 'none') {
|
|
56
|
+
Image(getIconData(this.node))
|
|
57
|
+
.objectFit(ImageFit.Contain)
|
|
58
|
+
.fillColor(this.node._attrs.color || ICON_COLOR_MAP[this.node._attrs.type] || Color.Black)
|
|
59
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
60
|
+
.size({
|
|
61
|
+
width: convertNumber2VP(Number(this.node._attrs.size) || 23),
|
|
62
|
+
height: convertNumber2VP(Number(this.node._attrs.size) || 23),
|
|
63
|
+
})
|
|
64
|
+
.width(getNormalAttributes(this.node).width || convertNumber2PX(23))
|
|
65
|
+
.height(getNormalAttributes(this.node).height || convertNumber2PX(23))
|
|
66
|
+
.onComplete(e => eventHandler(e, 'complete', this.node))
|
|
67
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
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
|
+
}
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
|
-
import {
|
|
4
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
5
5
|
|
|
6
|
-
import type { TaroImageElement, TaroAny
|
|
6
|
+
import type { TaroImageElement, TaroAny } from '@tarojs/runtime'
|
|
7
7
|
|
|
8
8
|
function getImageMode (mode: string): ImageFit {
|
|
9
9
|
switch (mode) {
|
|
@@ -21,14 +21,16 @@ export default struct TaroImage {
|
|
|
21
21
|
@ObjectLink node: TaroImageElement
|
|
22
22
|
|
|
23
23
|
build() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.node
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
if (this.node?.hmStyle?.display !== 'none') {
|
|
25
|
+
Image(this.node.getAttribute('src'))
|
|
26
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
27
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
28
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
29
|
+
}))
|
|
30
|
+
.objectFit(getImageMode(this.node.getAttribute('mode')))
|
|
31
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
32
|
+
.onComplete(e => eventHandler(e, 'complete', this.node))
|
|
33
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
34
|
+
}
|
|
33
35
|
}
|
|
34
36
|
}
|
|
@@ -63,7 +63,7 @@ export default struct TaroInput {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
build () {
|
|
66
|
-
if (this.node) {
|
|
66
|
+
if (this.node && this.node?.hmStyle?.display !== 'none') {
|
|
67
67
|
TextInput({ text: this.value, placeholder: this.node._attrs?.placeholder || '', controller: this.node.controller })
|
|
68
68
|
.key(this.node._nid)
|
|
69
69
|
.type(getInputType(this.node))
|
|
@@ -38,45 +38,48 @@ function handleTargetChange (id: string) {
|
|
|
38
38
|
@Component
|
|
39
39
|
export default struct TaroLabel {
|
|
40
40
|
@ObjectLink node:TaroLabelElement
|
|
41
|
+
|
|
41
42
|
build() {
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
if (this.node?.hmStyle?.display !== 'none') {
|
|
44
|
+
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
45
|
+
Row() {
|
|
46
|
+
createLazyChildren(this.node)
|
|
47
|
+
}
|
|
48
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
49
|
+
.onClick((e: ClickEvent) => {
|
|
50
|
+
const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
|
|
51
|
+
const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
53
|
+
handleTargetChange(id)
|
|
54
|
+
eventHandler(e, 'click', this.node)
|
|
55
|
+
})
|
|
56
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
57
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
58
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
59
|
+
}))
|
|
60
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
61
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
62
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
63
|
+
} else {
|
|
64
|
+
Column() {
|
|
65
|
+
createLazyChildren(this.node)
|
|
66
|
+
}
|
|
67
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
68
|
+
.onClick((e: ClickEvent) => {
|
|
69
|
+
const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
|
|
70
|
+
const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
|
|
69
71
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
handleTargetChange(id)
|
|
73
|
+
eventHandler(e, 'click', this.node)
|
|
74
|
+
})
|
|
75
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
76
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
77
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
78
|
+
}))
|
|
79
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
80
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
81
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
82
|
+
}
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
85
|
}
|
|
@@ -31,7 +31,7 @@ export default struct TaroMovableArea {
|
|
|
31
31
|
@ObjectLink node: TaroMovableAreaElement
|
|
32
32
|
|
|
33
33
|
build() {
|
|
34
|
-
if (this.node) {
|
|
34
|
+
if (this.node && this.node.hmStyle?.display !== 'none') {
|
|
35
35
|
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
36
36
|
Row() {
|
|
37
37
|
createLazyChildren(this.node)
|
|
@@ -32,7 +32,7 @@ export default struct TaroMovableView {
|
|
|
32
32
|
@ObjectLink node: TaroMovableViewElement
|
|
33
33
|
|
|
34
34
|
build() {
|
|
35
|
-
if (this.node) {
|
|
35
|
+
if (this.node && this.node.hmStyle?.display !== 'none') {
|
|
36
36
|
Stack() {
|
|
37
37
|
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node)
|
|
38
38
|
.direction !== FlexDirection.Column) {
|
|
@@ -306,7 +306,7 @@ export default struct TaroPicker {
|
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
build() {
|
|
309
|
-
if (this.node) {
|
|
309
|
+
if (this.node && this.node.hmStyle?.display !== 'none') {
|
|
310
310
|
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
311
311
|
Row() {
|
|
312
312
|
createLazyChildren(this.node)
|
|
@@ -12,7 +12,7 @@ export default struct TaroProgress {
|
|
|
12
12
|
@ObjectLink node: TaroProgressElement
|
|
13
13
|
|
|
14
14
|
build() {
|
|
15
|
-
if (this.node) {
|
|
15
|
+
if (this.node && this.node.hmStyle?.display !== 'none') {
|
|
16
16
|
Row({ space: 5 }) {
|
|
17
17
|
Progress({
|
|
18
18
|
value: parseFloat(this.node.getAttribute('percent')),
|
|
@@ -45,7 +45,7 @@ export struct TaroRadio {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
build () {
|
|
48
|
-
if (this.node) {
|
|
48
|
+
if (this.node && this.node.hmStyle?.display !== 'none') {
|
|
49
49
|
Stack() {
|
|
50
50
|
Row() {
|
|
51
51
|
Radio({
|
|
@@ -123,7 +123,7 @@ export struct TaroRadioGroup {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
build() {
|
|
126
|
-
if (this.node) {
|
|
126
|
+
if (this.node && this.node.hmStyle?.display !== 'none') {
|
|
127
127
|
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
128
128
|
Row() {
|
|
129
129
|
createLazyChildren(this.node)
|
|
@@ -1,46 +1,25 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
|
+
import { generateText } from './utils'
|
|
4
5
|
import { getNodeThresholds, shouldBindEvent } from './utils/helper'
|
|
5
6
|
|
|
6
|
-
import type { RichTextProps } from '@tarojs/components/types/RichText'
|
|
7
7
|
import type { TaroAny, TaroRichTextElement } from '@tarojs/runtime'
|
|
8
8
|
|
|
9
|
-
function generateText (node: TaroRichTextElement): string {
|
|
10
|
-
return parseHtmlNode(node._attrs.nodes || '')
|
|
11
|
-
}
|
|
12
|
-
|
|
13
9
|
@Component
|
|
14
10
|
export default struct TaroRichText {
|
|
15
11
|
@ObjectLink node: TaroRichTextElement
|
|
16
12
|
|
|
17
13
|
build () {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this.node
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
if (this.node.hmStyle?.display !== 'none') {
|
|
15
|
+
RichText(generateText(this.node))
|
|
16
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
17
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
18
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
19
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
20
|
+
}))
|
|
21
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
22
|
+
}
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
25
|
|
|
29
|
-
// 将nodeTree转换成harmony需要的string结构
|
|
30
|
-
function nodeToHtml(node: RichTextProps.Text | RichTextProps.HTMLElement): string {
|
|
31
|
-
if (node.type === 'text') {
|
|
32
|
-
return node.text;
|
|
33
|
-
}
|
|
34
|
-
if (node.attrs) {
|
|
35
|
-
const attributes = Object.entries(node.attrs)
|
|
36
|
-
.map((item: [string, string]) => `${item[0]}="${item[1]}"`)
|
|
37
|
-
.join(' ');
|
|
38
|
-
const childrenHtml: string = typeof node.children === 'string' ? node.children : (node.children || []).map((child: RichTextProps.Text | RichTextProps.HTMLElement) => nodeToHtml(child)).join('');
|
|
39
|
-
return `<${node.name}${attributes ? ' ' + attributes : ''}>${childrenHtml}</${node.name}>`;
|
|
40
|
-
}
|
|
41
|
-
return ''
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function parseHtmlNode (nodes: Array<RichTextProps.Text | RichTextProps.HTMLElement> | string) {
|
|
45
|
-
return typeof nodes === 'string' ? nodes: `<div>${nodes.map(node => nodeToHtml(node)).join('')}</div>`
|
|
46
|
-
}
|
|
@@ -82,51 +82,53 @@ export default struct TaroScrollView {
|
|
|
82
82
|
@ObjectLink node: TaroScrollViewElement
|
|
83
83
|
|
|
84
84
|
build () {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
if (this.node.hmStyle?.display !== 'none') {
|
|
86
|
+
Scroll(this.node.scroller) {
|
|
87
|
+
if (this.node._attrs.scrollX) {
|
|
88
|
+
Row() {
|
|
89
|
+
PseduoChildren(this.node)
|
|
90
|
+
}
|
|
91
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
92
|
+
.rowAttrs(getNormalAttributes(this.node))
|
|
93
|
+
.width(null)
|
|
94
|
+
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
95
|
+
this.node._nodeInfo._scroll = areaResult
|
|
96
|
+
}, this.node, ['scroll', 'scrollstart', 'scrollend']))
|
|
97
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
98
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
99
|
+
.flexGrow(0).flexShrink(0)
|
|
100
|
+
} else {
|
|
101
|
+
Column() {
|
|
102
|
+
PseduoChildren(this.node)
|
|
103
|
+
}
|
|
104
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
105
|
+
.columnAttrs(getNormalAttributes(this.node))
|
|
106
|
+
.height(null)
|
|
107
|
+
.alignItems(HorizontalAlign.Start)
|
|
108
|
+
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
109
|
+
this.node._nodeInfo._scroll = areaResult
|
|
110
|
+
}, this.node, ['scroll', 'scrollstart', 'scrollend']))
|
|
111
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
112
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
113
|
+
.flexGrow(0).flexShrink(0)
|
|
89
114
|
}
|
|
90
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
91
|
-
.rowAttrs(getNormalAttributes(this.node))
|
|
92
|
-
.width(null)
|
|
93
|
-
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
94
|
-
this.node._nodeInfo._scroll = areaResult
|
|
95
|
-
}, this.node, ['scroll', 'scrollstart', 'scrollend']))
|
|
96
|
-
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
97
|
-
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
98
|
-
.flexGrow(0).flexShrink(0)
|
|
99
|
-
} else {
|
|
100
|
-
Column() {
|
|
101
|
-
PseduoChildren(this.node)
|
|
102
|
-
}
|
|
103
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
104
|
-
.columnAttrs(getNormalAttributes(this.node))
|
|
105
|
-
.height(null)
|
|
106
|
-
.alignItems(HorizontalAlign.Start)
|
|
107
|
-
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
108
|
-
this.node._nodeInfo._scroll = areaResult
|
|
109
|
-
}, this.node, ['scroll', 'scrollstart', 'scrollend']))
|
|
110
|
-
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
111
|
-
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
112
|
-
.flexGrow(0).flexShrink(0)
|
|
113
115
|
}
|
|
116
|
+
.width(getNormalAttributes(this.node).width)
|
|
117
|
+
.height(getNormalAttributes(this.node).height)
|
|
118
|
+
.flexGrow(getNormalAttributes(this.node).flexGrow)
|
|
119
|
+
.flexShrink(getNormalAttributes(this.node).flexShrink)
|
|
120
|
+
.scrollable(getScrollable(this.node))
|
|
121
|
+
.scrollBar(getAttributes(this.node).scrollBar)
|
|
122
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
123
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
124
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
125
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
126
|
+
}))
|
|
127
|
+
.onScroll(shouldBindEvent(() => { handleScrollEvent(this.node, 'scroll') }, this.node, ['scroll']))
|
|
128
|
+
.onScrollStart(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollstart') }, this.node, ['scrollstart']))
|
|
129
|
+
.onScrollStop(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollend') }, this.node, ['scrollend']))
|
|
130
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
131
|
+
.onReachEnd(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrolltolower') }, this.node, ['scrolltolower']))
|
|
114
132
|
}
|
|
115
|
-
.width(getNormalAttributes(this.node).width)
|
|
116
|
-
.height(getNormalAttributes(this.node).height)
|
|
117
|
-
.flexGrow(getNormalAttributes(this.node).flexGrow)
|
|
118
|
-
.flexShrink(getNormalAttributes(this.node).flexShrink)
|
|
119
|
-
.scrollable(getScrollable(this.node))
|
|
120
|
-
.scrollBar(getAttributes(this.node).scrollBar)
|
|
121
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
122
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
123
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
124
|
-
this.node._nodeInfo.areaInfo = res[1]
|
|
125
|
-
}))
|
|
126
|
-
.onScroll(shouldBindEvent(() => { handleScrollEvent(this.node, 'scroll') }, this.node, ['scroll']))
|
|
127
|
-
.onScrollStart(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollstart') }, this.node, ['scrollstart']))
|
|
128
|
-
.onScrollStop(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollend') }, this.node, ['scrollend']))
|
|
129
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
130
|
-
.onReachEnd(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrolltolower') }, this.node, ['scrolltolower']))
|
|
131
133
|
}
|
|
132
134
|
}
|
|
@@ -147,12 +147,37 @@ function setNormalAttributeIntoInstance(instance: CommonAttribute, style: TaroSt
|
|
|
147
147
|
if (!isUndefined(style.overflow)) {
|
|
148
148
|
instance.clip(style.overflow)
|
|
149
149
|
}
|
|
150
|
-
if (!isUndefined(style.transformOrigin)) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
150
|
+
// if (!isUndefined(style.transformOrigin)) {
|
|
151
|
+
// instance.rotate({ centerX: style.transformOrigin.x, centerY: style.transformOrigin.y, angle: 0 })
|
|
152
|
+
// instance.scale({ centerX: style.transformOrigin.x, centerY: style.transformOrigin.y })
|
|
153
|
+
// }
|
|
154
154
|
if (!isUndefined(style.transform)) {
|
|
155
|
-
|
|
155
|
+
if (style.transform.Translate) {
|
|
156
|
+
instance.translate({
|
|
157
|
+
x: style.transform.Translate.x || 0,
|
|
158
|
+
y: style.transform.Translate.y || 0,
|
|
159
|
+
z: style.transform.Translate.z || 0,
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
if (style.transform.Scale) {
|
|
163
|
+
instance.scale({
|
|
164
|
+
x: style.transform.Scale.x || 0,
|
|
165
|
+
y: style.transform.Scale.y || 0,
|
|
166
|
+
z: style.transform.Scale.z || 0,
|
|
167
|
+
centerX: style.transformOrigin?.x,
|
|
168
|
+
centerY: style.transformOrigin?.y,
|
|
169
|
+
})
|
|
170
|
+
}
|
|
171
|
+
if (style.transform.Rotate) {
|
|
172
|
+
instance.rotate({
|
|
173
|
+
x: style.transform.Rotate.x || 0,
|
|
174
|
+
y: style.transform.Rotate.y || 0,
|
|
175
|
+
z: style.transform.Rotate.z || 0,
|
|
176
|
+
centerX: style.transformOrigin?.x,
|
|
177
|
+
centerY: style.transformOrigin?.y,
|
|
178
|
+
angle: 0
|
|
179
|
+
})
|
|
180
|
+
}
|
|
156
181
|
}
|
|
157
182
|
if (style.position === 'absolute' || style.position === 'fixed') {
|
|
158
183
|
instance.position({
|