@tarojs/plugin-platform-harmony-ets 4.0.0-beta.10 → 4.0.0-beta.11
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 +34 -31
- package/dist/components-harmony-ets/checkbox.ets +3 -2
- package/dist/components-harmony-ets/form.ets +30 -27
- package/dist/components-harmony-ets/icon.ets +22 -18
- package/dist/components-harmony-ets/image.ets +15 -11
- package/dist/components-harmony-ets/innerHtml.ets +9 -5
- package/dist/components-harmony-ets/input.ets +1 -1
- package/dist/components-harmony-ets/label.ets +43 -39
- package/dist/components-harmony-ets/movableArea.ets +67 -0
- package/dist/components-harmony-ets/movableView.ets +66 -0
- package/dist/components-harmony-ets/picker.ets +2 -1
- package/dist/components-harmony-ets/progress.ets +45 -0
- package/dist/components-harmony-ets/radio.ets +2 -2
- package/dist/components-harmony-ets/richText.ets +14 -9
- package/dist/components-harmony-ets/scrollView.ets +36 -32
- package/dist/components-harmony-ets/slider.ets +1 -1
- package/dist/components-harmony-ets/swiper.ets +23 -19
- package/dist/components-harmony-ets/switch.ets +1 -1
- package/dist/components-harmony-ets/text.ets +28 -22
- package/dist/components-harmony-ets/textArea.ets +1 -1
- package/dist/components-harmony-ets/video.ets +26 -21
- package/dist/components-harmony-ets/view.ets +33 -29
- package/dist/components-harmony-ets/webView.ets +37 -32
- package/dist/index.js +35 -15
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/dom/element/element.ts +0 -1
- package/dist/runtime-ets/dom/element/form.ts +11 -4
- package/dist/runtime-ets/dom/element/index.ts +9 -1
- package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
- package/dist/runtime-ets/dom/element/movableView.ts +12 -0
- package/dist/runtime-ets/dom/element/normal.ts +8 -2
- package/dist/runtime-ets/dom/element/progress.ts +13 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
- package/dist/runtime-ets/dom/element/text.ts +1 -0
- package/dist/runtime-ets/dom/element/video.ts +1 -0
- package/dist/runtime-ets/dom/element/webView.ts +8 -0
- package/dist/runtime-ets/dom/node.ts +18 -17
- package/package.json +8 -8
|
@@ -94,38 +94,41 @@ function getButtonMinHeight (node: TaroButtonElement): string | number | undefin
|
|
|
94
94
|
return getButtonHeight(node)
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
@
|
|
98
|
-
export default
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
97
|
+
@Component
|
|
98
|
+
export default struct TaroButton {
|
|
99
|
+
@ObjectLink node: TaroButtonElement
|
|
100
|
+
build() {
|
|
101
|
+
Button({ stateEffect: !this.node._attrs.disabled }) {
|
|
102
|
+
Row() {
|
|
103
|
+
if (this.node._attrs.loading) {
|
|
104
|
+
LoadingProgress()
|
|
105
|
+
.width(20).height(20)
|
|
106
|
+
.color(getThemeAttributes(this.node).color)
|
|
107
|
+
}
|
|
108
|
+
createLazyChildren(this.node)
|
|
105
109
|
}
|
|
106
|
-
createLazyChildren(node)
|
|
107
110
|
}
|
|
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))
|
|
108
133
|
}
|
|
109
|
-
.themeStyles(getThemeAttributes(node))
|
|
110
|
-
.attributeModifier(commonStyleModify.setNode(node))
|
|
111
|
-
.constraintSize({
|
|
112
|
-
minWidth: node.hmStyle?.minWidth || getButtonMinWidth(node),
|
|
113
|
-
minHeight: node.hmStyle?.minHeight || getButtonMinHeight(node),
|
|
114
|
-
maxWidth: node.hmStyle?.maxWidth,
|
|
115
|
-
maxHeight: node.hmStyle?.maxHeight,
|
|
116
|
-
})
|
|
117
|
-
.type(ButtonType.Normal)
|
|
118
|
-
.onClick((e: ClickEvent) => {
|
|
119
|
-
if (node._attrs.formType && ['submit', 'reset'].includes(node._attrs.formType)) {
|
|
120
|
-
const eventName = node._attrs.formType + '-btn'
|
|
121
|
-
const event: TaroEvent = createTaroEvent(eventName, {}, node)
|
|
122
|
-
eventHandler(event, eventName, node)
|
|
123
|
-
}
|
|
124
|
-
eventHandler(e, 'click', node)
|
|
125
|
-
})
|
|
126
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
127
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
128
|
-
node._nodeInfo.areaInfo = res[1]
|
|
129
|
-
}))
|
|
130
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
131
134
|
}
|
|
@@ -33,9 +33,10 @@ function getOptions (node: TaroCheckboxElement): CheckboxOptions {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
|
|
36
37
|
@Component
|
|
37
38
|
export struct TaroCheckbox {
|
|
38
|
-
node: TaroCheckboxElement
|
|
39
|
+
@ObjectLink node: TaroCheckboxElement
|
|
39
40
|
|
|
40
41
|
aboutToAppear () {
|
|
41
42
|
if (this.node && !this.node._isInit) {
|
|
@@ -94,7 +95,7 @@ interface ChangeEventDetail { value: string[] }
|
|
|
94
95
|
|
|
95
96
|
@Component
|
|
96
97
|
export struct TaroCheckboxGroup {
|
|
97
|
-
node: TaroCheckboxGroupElement
|
|
98
|
+
@ObjectLink node: TaroCheckboxGroupElement
|
|
98
99
|
|
|
99
100
|
@Styles visibleChangeEvent () {
|
|
100
101
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
@@ -8,33 +8,36 @@ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
|
8
8
|
|
|
9
9
|
import type { TaroAny, TaroFormElement } from '@tarojs/runtime'
|
|
10
10
|
|
|
11
|
-
@
|
|
12
|
-
export default
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
@Component
|
|
12
|
+
export default struct TaroForm {
|
|
13
|
+
@ObjectLink node: TaroFormElement
|
|
14
|
+
build() {
|
|
15
|
+
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
16
|
+
Row() {
|
|
17
|
+
createLazyChildren(this.node)
|
|
18
|
+
}
|
|
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)
|
|
16
41
|
}
|
|
17
|
-
.attributeModifier(commonStyleModify.setNode(node))
|
|
18
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
19
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
20
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
21
|
-
node._nodeInfo.areaInfo = res[1]
|
|
22
|
-
}))
|
|
23
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
24
|
-
.alignItems(FlexManager.flexOptions(node).alignItems as VerticalAlign)
|
|
25
|
-
.justifyContent(FlexManager.flexOptions(node).justifyContent)
|
|
26
|
-
} else {
|
|
27
|
-
Column() {
|
|
28
|
-
createLazyChildren(node)
|
|
29
|
-
}
|
|
30
|
-
.attributeModifier(commonStyleModify.setNode(node))
|
|
31
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
32
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
33
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
34
|
-
node._nodeInfo.areaInfo = res[1]
|
|
35
|
-
}))
|
|
36
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
37
|
-
.alignItems(FlexManager.flexOptions(node).alignItems as HorizontalAlign)
|
|
38
|
-
.justifyContent(FlexManager.flexOptions(node).justifyContent)
|
|
39
42
|
}
|
|
40
43
|
}
|
|
@@ -48,22 +48,26 @@ function getIconData (node: TaroIconElement): Resource | null {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
@
|
|
52
|
-
export default
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
51
|
+
@Component
|
|
52
|
+
export default struct TaroIcon {
|
|
53
|
+
@ObjectLink node: TaroIconElement
|
|
54
|
+
build() {
|
|
55
|
+
Image(getIconData(this.node))
|
|
56
|
+
.objectFit(ImageFit.Contain)
|
|
57
|
+
.fillColor(this.node._attrs.color || ICON_COLOR_MAP[this.node._attrs.type] || Color.Black)
|
|
58
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
59
|
+
.size({
|
|
60
|
+
width: convertNumber2VP(Number(this.node._attrs.size) || 23),
|
|
61
|
+
height: convertNumber2VP(Number(this.node._attrs.size) || 23),
|
|
62
|
+
})
|
|
63
|
+
.width(getNormalAttributes(this.node).width || convertNumber2PX(23))
|
|
64
|
+
.height(getNormalAttributes(this.node).height || convertNumber2PX(23))
|
|
65
|
+
.onComplete(e => eventHandler(e, 'complete', this.node))
|
|
66
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
67
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
68
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
69
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
70
|
+
}))
|
|
71
|
+
}
|
|
69
72
|
}
|
|
73
|
+
|
|
@@ -16,15 +16,19 @@ function getImageMode (mode: string): ImageFit {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
@
|
|
20
|
-
export default
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
@Component
|
|
20
|
+
export default struct TaroImage {
|
|
21
|
+
@ObjectLink node: TaroImageElement
|
|
22
|
+
|
|
23
|
+
build() {
|
|
24
|
+
Image(this.node.getAttribute('src'))
|
|
25
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
26
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
27
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
28
|
+
}))
|
|
29
|
+
.objectFit(getImageMode(this.node.getAttribute('mode')))
|
|
30
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
31
|
+
.onComplete(e => eventHandler(e, 'complete', this.node))
|
|
32
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
33
|
+
}
|
|
30
34
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import htmlParser from './utils/htmlParser'
|
|
2
2
|
import { createChildItem } from './render'
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { TaroInnerHtmlElement } from '@tarojs/runtime'
|
|
5
5
|
|
|
6
|
-
@
|
|
7
|
-
export default
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
@Component
|
|
7
|
+
export default struct TaroInnerHtml {
|
|
8
|
+
@ObjectLink node: TaroInnerHtmlElement
|
|
9
|
+
|
|
10
|
+
build() {
|
|
11
|
+
if (this.node.innerHTML) {
|
|
12
|
+
createChildItem(htmlParser(this.node.innerHTML))
|
|
13
|
+
}
|
|
10
14
|
}
|
|
11
15
|
}
|
|
@@ -34,45 +34,49 @@ function handleTargetChange (id: string) {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
37
|
+
|
|
38
|
+
@Component
|
|
39
|
+
export default struct TaroLabel {
|
|
40
|
+
@ObjectLink node:TaroLabelElement
|
|
41
|
+
build() {
|
|
42
|
+
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
43
|
+
Row() {
|
|
44
|
+
createLazyChildren(this.node)
|
|
45
|
+
}
|
|
46
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
47
|
+
.onClick((e: ClickEvent) => {
|
|
48
|
+
const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
|
|
49
|
+
const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
|
|
50
|
+
|
|
51
|
+
handleTargetChange(id)
|
|
52
|
+
eventHandler(e, 'click', this.node)
|
|
53
|
+
})
|
|
54
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
55
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
56
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
57
|
+
}))
|
|
58
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
59
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
60
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
61
|
+
} else {
|
|
62
|
+
Column() {
|
|
63
|
+
createLazyChildren(this.node)
|
|
64
|
+
}
|
|
65
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
66
|
+
.onClick((e: ClickEvent) => {
|
|
67
|
+
const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
|
|
68
|
+
const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
|
|
69
|
+
|
|
70
|
+
handleTargetChange(id)
|
|
71
|
+
eventHandler(e, 'click', this.node)
|
|
72
|
+
})
|
|
73
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
74
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
75
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
76
|
+
}))
|
|
77
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
78
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
79
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
61
80
|
}
|
|
62
|
-
.attributeModifier(commonStyleModify.setNode(node))
|
|
63
|
-
.onClick((e: ClickEvent) => {
|
|
64
|
-
const firstChild: TaroElement | null = node.childNodes[0] as TaroElement | null
|
|
65
|
-
const id: string = node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
|
|
66
|
-
|
|
67
|
-
handleTargetChange(id)
|
|
68
|
-
eventHandler(e, 'click', node)
|
|
69
|
-
})
|
|
70
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
71
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
72
|
-
node._nodeInfo.areaInfo = res[1]
|
|
73
|
-
}))
|
|
74
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
75
|
-
.alignItems(FlexManager.flexOptions(node).alignItems as HorizontalAlign)
|
|
76
|
-
.justifyContent(FlexManager.flexOptions(node).justifyContent)
|
|
77
81
|
}
|
|
78
82
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { TaroMovableAreaElement, TaroStyleType } from '@tarojs/runtime'
|
|
2
|
+
import commonStyleModify from './style'
|
|
3
|
+
import { createLazyChildren } from './render'
|
|
4
|
+
|
|
5
|
+
import { FlexManager } from './utils/FlexManager'
|
|
6
|
+
import { getNormalAttributes } from './utils/helper'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@Extend(Row)
|
|
10
|
+
function rowAttrs(style: TaroStyleType) {
|
|
11
|
+
.constraintSize({
|
|
12
|
+
minWidth: style.minWidth || style.width,
|
|
13
|
+
maxWidth: style.maxWidth,
|
|
14
|
+
minHeight: style.minHeight,
|
|
15
|
+
maxHeight: style.maxHeight
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Extend(Column)
|
|
20
|
+
function columnAttrs(style: TaroStyleType) {
|
|
21
|
+
.constraintSize({
|
|
22
|
+
minWidth: style.minWidth,
|
|
23
|
+
maxWidth: style.maxWidth,
|
|
24
|
+
minHeight: style.minHeight || style.height,
|
|
25
|
+
maxHeight: style.maxHeight
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Component
|
|
30
|
+
export default struct TaroMovableArea {
|
|
31
|
+
@ObjectLink node: TaroMovableAreaElement
|
|
32
|
+
|
|
33
|
+
@Provide areaWidth: Length = 0
|
|
34
|
+
@Provide areaHeight: Length = 0
|
|
35
|
+
|
|
36
|
+
build() {
|
|
37
|
+
if (this.node) {
|
|
38
|
+
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
39
|
+
Row() {
|
|
40
|
+
createLazyChildren(this.node)
|
|
41
|
+
}
|
|
42
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
43
|
+
.rowAttrs(getNormalAttributes(this.node))
|
|
44
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
45
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
46
|
+
.clip(true)
|
|
47
|
+
.onAreaChange((oldValue: Area, newValue: Area) => {
|
|
48
|
+
this.areaWidth = newValue.width
|
|
49
|
+
this.areaHeight = newValue.height
|
|
50
|
+
})
|
|
51
|
+
} else {
|
|
52
|
+
Column() {
|
|
53
|
+
createLazyChildren(this.node)
|
|
54
|
+
}
|
|
55
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
56
|
+
.columnAttrs(getNormalAttributes(this.node))
|
|
57
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
58
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
59
|
+
.clip(true)
|
|
60
|
+
.onAreaChange((oldValue: Area, newValue: Area) => {
|
|
61
|
+
this.areaWidth = newValue.width
|
|
62
|
+
this.areaHeight = newValue.height
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { TaroMovableViewElement, TaroStyleType } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { createLazyChildren } from './render'
|
|
5
|
+
|
|
6
|
+
import { FlexManager } from './utils/FlexManager'
|
|
7
|
+
import { getNormalAttributes, } from './utils/helper'
|
|
8
|
+
@Extend(Row)
|
|
9
|
+
function rowAttrs(style: TaroStyleType) {
|
|
10
|
+
.constraintSize({
|
|
11
|
+
minWidth: style.minWidth || style.width,
|
|
12
|
+
maxWidth: style.maxWidth,
|
|
13
|
+
minHeight: style.minHeight,
|
|
14
|
+
maxHeight: style.maxHeight
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Extend(Column)
|
|
19
|
+
function columnAttrs(style: TaroStyleType) {
|
|
20
|
+
.constraintSize({
|
|
21
|
+
minWidth: style.minWidth,
|
|
22
|
+
maxWidth: style.maxWidth,
|
|
23
|
+
minHeight: style.minHeight || style.height,
|
|
24
|
+
maxHeight: style.maxHeight
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@Component
|
|
29
|
+
export default struct TaroMovableArea {
|
|
30
|
+
@ObjectLink node: TaroMovableViewElement
|
|
31
|
+
|
|
32
|
+
@Provide areaWidth: Length = 0
|
|
33
|
+
@Provide areaHeight: Length = 0
|
|
34
|
+
|
|
35
|
+
build() {
|
|
36
|
+
if (this.node) {
|
|
37
|
+
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
38
|
+
Row() {
|
|
39
|
+
createLazyChildren(this.node)
|
|
40
|
+
}
|
|
41
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
42
|
+
.rowAttrs(getNormalAttributes(this.node))
|
|
43
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
44
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
45
|
+
.clip(true)
|
|
46
|
+
.onAreaChange((oldValue: Area, newValue: Area) => {
|
|
47
|
+
this.areaWidth = newValue.width
|
|
48
|
+
this.areaHeight = newValue.height
|
|
49
|
+
})
|
|
50
|
+
} else {
|
|
51
|
+
Column() {
|
|
52
|
+
createLazyChildren(this.node)
|
|
53
|
+
}
|
|
54
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
55
|
+
.columnAttrs(getNormalAttributes(this.node))
|
|
56
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
57
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
58
|
+
.clip(true)
|
|
59
|
+
.onAreaChange((oldValue: Area, newValue: Area) => {
|
|
60
|
+
this.areaWidth = newValue.width
|
|
61
|
+
this.areaHeight = newValue.height
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -219,9 +219,10 @@ export struct PickerView {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
+
|
|
222
223
|
@Component
|
|
223
224
|
export default struct TaroPicker {
|
|
224
|
-
node: TaroPickerElement
|
|
225
|
+
@ObjectLink node: TaroPickerElement
|
|
225
226
|
|
|
226
227
|
aboutToAppear () {
|
|
227
228
|
this.node?.addEventListener('click', this.handleClick)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { TaroProgressElement, TaroAny } from '@tarojs/runtime'
|
|
2
|
+
import commonStyleModify from './style'
|
|
3
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
4
|
+
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
5
|
+
|
|
6
|
+
const PROGRESS_ACTIVECOLOR = '#09BB07'
|
|
7
|
+
const PROGRESS_BACKGROUNDCOLOR = '#EBEBEB'
|
|
8
|
+
const PROGRESS_DEFAULTINFOFONTSIZE = 16
|
|
9
|
+
|
|
10
|
+
@Component
|
|
11
|
+
export default struct TaroProgress {
|
|
12
|
+
@ObjectLink node: TaroProgressElement
|
|
13
|
+
|
|
14
|
+
build() {
|
|
15
|
+
if (this.node) {
|
|
16
|
+
Row({ space: 5 }) {
|
|
17
|
+
Progress({
|
|
18
|
+
value: parseFloat(this.node.getAttribute('percent')),
|
|
19
|
+
type: ProgressType.Linear
|
|
20
|
+
})
|
|
21
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
22
|
+
.color(this.node.getAttribute('activeColor') ?? PROGRESS_ACTIVECOLOR)
|
|
23
|
+
.backgroundColor(this.node.getAttribute('backgroundColor') ?? PROGRESS_BACKGROUNDCOLOR)
|
|
24
|
+
.style({
|
|
25
|
+
strokeWidth: this.node.getAttribute('strokeWidth'),
|
|
26
|
+
strokeRadius: parseFloat(this.node.getAttribute('borderRadius')),
|
|
27
|
+
enableSmoothEffect: Boolean(this.node.getAttribute('active')),
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
31
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
32
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
33
|
+
if (this.node) {
|
|
34
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
35
|
+
}
|
|
36
|
+
}))
|
|
37
|
+
|
|
38
|
+
if (this.node.getAttribute('showInfo')) {
|
|
39
|
+
Text(`${this.node.getAttribute('percent')}%`)
|
|
40
|
+
.fontSize(this.node.getAttribute('fontSize') ?? PROGRESS_DEFAULTINFOFONTSIZE)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -35,7 +35,7 @@ function themeStyles(isDisabled: boolean) {
|
|
|
35
35
|
|
|
36
36
|
@Component
|
|
37
37
|
export struct TaroRadio {
|
|
38
|
-
node: TaroRadioElement
|
|
38
|
+
@ObjectLink node: TaroRadioElement
|
|
39
39
|
|
|
40
40
|
aboutToAppear () {
|
|
41
41
|
if (this.node && !this.node._isInit) {
|
|
@@ -95,7 +95,7 @@ export struct TaroRadio {
|
|
|
95
95
|
|
|
96
96
|
@Component
|
|
97
97
|
export struct TaroRadioGroup {
|
|
98
|
-
node: TaroRadioGroupElement
|
|
98
|
+
@ObjectLink node: TaroRadioGroupElement
|
|
99
99
|
|
|
100
100
|
@Styles visibleChangeEvent () {
|
|
101
101
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
@@ -10,15 +10,20 @@ function generateText (node: TaroRichTextElement): string {
|
|
|
10
10
|
return parseHtmlNode(node._attrs.nodes || '')
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
@
|
|
14
|
-
export default
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
@Component
|
|
14
|
+
export default struct TaroRichText {
|
|
15
|
+
@ObjectLink node: TaroRichTextElement
|
|
16
|
+
|
|
17
|
+
build () {
|
|
18
|
+
RichText(generateText(this.node))
|
|
19
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
20
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
21
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
22
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
23
|
+
}))
|
|
24
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
25
|
+
|
|
26
|
+
}
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
// 将nodeTree转换成harmony需要的string结构
|