@tarojs/plugin-platform-harmony-ets 4.0.0-beta.10 → 4.0.0-beta.12
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/base/system.ts +40 -22
- package/dist/components-harmony-ets/button.ets +34 -31
- package/dist/components-harmony-ets/checkbox.ets +5 -4
- package/dist/components-harmony-ets/form.ets +31 -28
- 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 +44 -40
- 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 +7 -6
- package/dist/components-harmony-ets/progress.ets +45 -0
- package/dist/components-harmony-ets/radio.ets +5 -5
- package/dist/components-harmony-ets/richText.ets +14 -9
- package/dist/components-harmony-ets/scrollView.ets +40 -35
- 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/utils/styles.ets +2 -2
- package/dist/components-harmony-ets/video.ets +26 -21
- package/dist/components-harmony-ets/view.ets +34 -30
- package/dist/components-harmony-ets/webView.ets +37 -32
- package/dist/index.js +36 -16
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/dom/element/element.ts +0 -4
- 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/dist/runtime-utils.js +43 -21
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +43 -21
- package/dist/runtime.js.map +1 -1
- package/package.json +8 -8
|
@@ -3,7 +3,7 @@ import { createLazyChildren } from './render'
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
4
|
import { getSingleSelector, getMultiSelector } from './utils'
|
|
5
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
6
|
-
import { FlexManager } from './utils/
|
|
6
|
+
import { FlexManager } from './utils/flexManager'
|
|
7
7
|
import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
8
8
|
|
|
9
9
|
import type { TaroAny, TaroEvent } from '@tarojs/runtime'
|
|
@@ -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)
|
|
@@ -237,8 +238,8 @@ export default struct TaroPicker {
|
|
|
237
238
|
break
|
|
238
239
|
case 'time': {
|
|
239
240
|
const hour = new Date().getHours()
|
|
240
|
-
const minute = new Date().getMinutes()
|
|
241
|
-
|
|
241
|
+
const minute = new Date().getMinutes()
|
|
242
|
+
|
|
242
243
|
defaultResetValue = `${('00'+hour).slice(-2)}:${('00'+minute).slice(-2)}`
|
|
243
244
|
break
|
|
244
245
|
}
|
|
@@ -247,7 +248,7 @@ export default struct TaroPicker {
|
|
|
247
248
|
const day = data[1]
|
|
248
249
|
const month = data[0]
|
|
249
250
|
const year = data[2]
|
|
250
|
-
|
|
251
|
+
|
|
251
252
|
defaultResetValue = `${year}-${month}-${day}`
|
|
252
253
|
break
|
|
253
254
|
}
|
|
@@ -255,7 +256,7 @@ export default struct TaroPicker {
|
|
|
255
256
|
defaultResetValue = ''
|
|
256
257
|
break
|
|
257
258
|
}
|
|
258
|
-
|
|
259
|
+
|
|
259
260
|
this.node._isInit = true
|
|
260
261
|
this.node._reset = this.node.value || defaultResetValue
|
|
261
262
|
}
|
|
@@ -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
|
+
}
|
|
@@ -3,7 +3,7 @@ import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBL
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
4
|
import { createLazyChildren } from './render'
|
|
5
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
6
|
-
import { FlexManager } from './utils/
|
|
6
|
+
import { FlexManager } from './utils/flexManager'
|
|
7
7
|
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
8
8
|
|
|
9
9
|
import { TaroEvent, TaroAny, HarmonyType, TaroRadioGroupElement, TaroRadioElement } from '@tarojs/runtime'
|
|
@@ -35,8 +35,8 @@ function themeStyles(isDisabled: boolean) {
|
|
|
35
35
|
|
|
36
36
|
@Component
|
|
37
37
|
export struct TaroRadio {
|
|
38
|
-
node: TaroRadioElement
|
|
39
|
-
|
|
38
|
+
@ObjectLink node: TaroRadioElement
|
|
39
|
+
|
|
40
40
|
aboutToAppear () {
|
|
41
41
|
if (this.node && !this.node._isInit) {
|
|
42
42
|
this.node._isInit = true
|
|
@@ -61,7 +61,7 @@ export struct TaroRadio {
|
|
|
61
61
|
this.node.updateComponent()
|
|
62
62
|
} else {
|
|
63
63
|
this.node.updateCheckedValue(value)
|
|
64
|
-
|
|
64
|
+
|
|
65
65
|
if (value) {
|
|
66
66
|
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
|
|
67
67
|
eventHandler(event, 'change', this.node)
|
|
@@ -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结构
|
|
@@ -2,7 +2,7 @@ import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBL
|
|
|
2
2
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
4
|
import { createLazyChildren } from './render'
|
|
5
|
-
import { FlexManager } from './utils/
|
|
5
|
+
import { FlexManager } from './utils/flexManager'
|
|
6
6
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
7
7
|
import { getNodeThresholds, getNormalAttributes, shouldBindEvent } from './utils/helper'
|
|
8
8
|
|
|
@@ -49,8 +49,8 @@ function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', x
|
|
|
49
49
|
deltaY: vp2px(yOffset),
|
|
50
50
|
scrollLeft: vp2px(currentXOffset),
|
|
51
51
|
scrollTop: vp2px(currentYOffset),
|
|
52
|
-
scrollWidth: vp2px(Number(node._scroll?.width)),
|
|
53
|
-
scrollHeight: vp2px(Number(node._scroll?.height)),
|
|
52
|
+
scrollWidth: vp2px(Number(node._nodeInfo?._scroll?.width)),
|
|
53
|
+
scrollHeight: vp2px(Number(node._nodeInfo?._scroll?.height)),
|
|
54
54
|
}
|
|
55
55
|
const event: TaroEvent = createTaroEvent(eventName, { detail: value }, node)
|
|
56
56
|
|
|
@@ -77,51 +77,56 @@ function columnAttrs (style: TaroStyleType) {
|
|
|
77
77
|
})
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
@
|
|
81
|
-
export default
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
@Component
|
|
81
|
+
export default struct TaroScrollView {
|
|
82
|
+
@ObjectLink node: TaroScrollViewElement
|
|
83
|
+
|
|
84
|
+
build () {
|
|
85
|
+
Scroll(this.node.scroller) {
|
|
86
|
+
if (this.node._attrs.scrollX) {
|
|
84
87
|
Row() {
|
|
85
|
-
createLazyChildren(node)
|
|
88
|
+
createLazyChildren(this.node)
|
|
86
89
|
}
|
|
87
|
-
.attributeModifier(commonStyleModify.setNode(node))
|
|
88
|
-
.rowAttrs(getNormalAttributes(node))
|
|
90
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
91
|
+
.rowAttrs(getNormalAttributes(this.node))
|
|
89
92
|
.width(null)
|
|
90
93
|
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
91
|
-
node._scroll = areaResult
|
|
92
|
-
}, node, ['scroll', 'scrollstart', 'scrollend']))
|
|
93
|
-
.alignItems(FlexManager.flexOptions(node).alignItems as VerticalAlign)
|
|
94
|
-
.justifyContent(FlexManager.flexOptions(node).justifyContent)
|
|
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)
|
|
95
98
|
.flexGrow(0).flexShrink(0)
|
|
96
99
|
} else {
|
|
97
100
|
Column() {
|
|
98
|
-
createLazyChildren(node)
|
|
101
|
+
createLazyChildren(this.node)
|
|
99
102
|
}
|
|
100
|
-
.attributeModifier(commonStyleModify.setNode(node))
|
|
101
|
-
.columnAttrs(getNormalAttributes(node))
|
|
103
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
104
|
+
.columnAttrs(getNormalAttributes(this.node))
|
|
102
105
|
.height(null)
|
|
103
106
|
.alignItems(HorizontalAlign.Start)
|
|
104
107
|
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
105
|
-
node._scroll = areaResult
|
|
106
|
-
}, node, ['scroll', 'scrollstart', 'scrollend']))
|
|
107
|
-
.alignItems(FlexManager.flexOptions(node).alignItems as HorizontalAlign)
|
|
108
|
-
.justifyContent(FlexManager.flexOptions(node).justifyContent)
|
|
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)
|
|
109
112
|
.flexGrow(0).flexShrink(0)
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
|
-
.width(getNormalAttributes(node).width)
|
|
113
|
-
.height(getNormalAttributes(node).height)
|
|
114
|
-
.flexGrow(getNormalAttributes(node).flexGrow)
|
|
115
|
-
.flexShrink(getNormalAttributes(node).flexShrink)
|
|
116
|
-
.scrollable(getScrollable(node))
|
|
117
|
-
.scrollBar(getAttributes(node).scrollBar)
|
|
118
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
119
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
120
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
121
|
-
node._nodeInfo.areaInfo = res[1]
|
|
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]
|
|
122
125
|
}))
|
|
123
|
-
.onScroll(shouldBindEvent(() => { handleScrollEvent(node, 'scroll') }, node, ['scroll']))
|
|
124
|
-
.onScrollStart(shouldBindEvent(() => { handleScrollEvent(node, 'scrollstart') }, node, ['scrollstart']))
|
|
125
|
-
.onScrollStop(shouldBindEvent(() => { handleScrollEvent(node, 'scrollend') }, node, ['scrollend']))
|
|
126
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
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
|
+
}
|
|
127
132
|
}
|
|
@@ -40,24 +40,28 @@ function getSwiperAttributes (node: TaroSwiperElement): SwiperAttrs {
|
|
|
40
40
|
return swiperAttrs
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
@
|
|
44
|
-
export default
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
@Component
|
|
44
|
+
export default struct TaroSwiper {
|
|
45
|
+
@ObjectLink node: TaroSwiperElement
|
|
46
|
+
|
|
47
|
+
build () {
|
|
48
|
+
Swiper(this.node.controller) {
|
|
49
|
+
createLazyChildren(this.node)
|
|
50
|
+
}
|
|
51
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
52
|
+
.swiperAttr(getSwiperAttributes(this.node))
|
|
53
|
+
.indicatorStyle({
|
|
54
|
+
color: this.node.getAttribute('indicatorColor'),
|
|
55
|
+
selectedColor: this.node.getAttribute('indicatorActiveColor')
|
|
56
|
+
})
|
|
57
|
+
.onChange((index: number) => {
|
|
58
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { current: index } }, this.node)
|
|
59
|
+
eventHandler(event, 'change', this.node)
|
|
60
|
+
})
|
|
61
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
62
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
63
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
64
|
+
}))
|
|
65
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
47
66
|
}
|
|
48
|
-
.attributeModifier(commonStyleModify.setNode(node))
|
|
49
|
-
.swiperAttr(getSwiperAttributes(node))
|
|
50
|
-
.indicatorStyle({
|
|
51
|
-
color: node.getAttribute('indicatorColor'),
|
|
52
|
-
selectedColor: node.getAttribute('indicatorActiveColor')
|
|
53
|
-
})
|
|
54
|
-
.onChange((index: number) => {
|
|
55
|
-
const event: TaroEvent = createTaroEvent('change', { detail: { current: index } }, node)
|
|
56
|
-
eventHandler(event, 'change', node)
|
|
57
|
-
})
|
|
58
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
59
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
60
|
-
node._nodeInfo.areaInfo = res[1]
|
|
61
|
-
}))
|
|
62
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
63
67
|
}
|
|
@@ -38,29 +38,35 @@ function getButtonFontSize (node: TaroButtonElement) {
|
|
|
38
38
|
return isMini ? convertNumber2VP(26) : convertNumber2VP(36)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
@
|
|
42
|
-
export default
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
@Component
|
|
42
|
+
export default struct TaroText {
|
|
43
|
+
@ObjectLink node: TaroTextElement
|
|
44
|
+
|
|
45
|
+
build () {
|
|
46
|
+
if (this.node.nodeType === NodeType.TEXT_NODE && this.node.parentNode) {
|
|
47
|
+
if ((this.node.parentNode as TaroElement).tagName === 'BUTTON') {
|
|
48
|
+
Text(this.node.textContent)
|
|
49
|
+
.textNormalFontStyle(getNormalAttributes(this.node.parentNode as TaroElement))
|
|
50
|
+
.textSpecialFontStyle(getFontAttributes(this.node.parentNode as TaroElement))
|
|
51
|
+
.fontSize((this.node.parentNode as TaroButtonElement).hmStyle.fontSize || getButtonFontSize(this.node.parentNode as TaroButtonElement))
|
|
52
|
+
.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))
|
|
53
|
+
} else {
|
|
54
|
+
Text(this.node.textContent)
|
|
55
|
+
.textNormalFontStyle(getNormalAttributes(this.node.parentNode as TaroElement))
|
|
56
|
+
.textSpecialFontStyle(getFontAttributes(this.node.parentNode as TaroElement))
|
|
57
|
+
.width(getNormalAttributes(this.node.parentNode as TaroElement).width)
|
|
58
|
+
.height(getNormalAttributes(this.node.parentNode as TaroElement).height)
|
|
59
|
+
}
|
|
50
60
|
} else {
|
|
51
|
-
Text(node.textContent)
|
|
52
|
-
|
|
53
|
-
|
|
61
|
+
Text(this.node.textContent)
|
|
62
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
63
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
64
|
+
.textNormalFontStyle(getNormalAttributes(this.node))
|
|
65
|
+
.textSpecialFontStyle(getFontAttributes(this.node))
|
|
66
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
67
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
68
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
69
|
+
}))
|
|
54
70
|
}
|
|
55
|
-
} else {
|
|
56
|
-
Text(node.textContent)
|
|
57
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
58
|
-
.attributeModifier(commonStyleModify.setNode(node))
|
|
59
|
-
.textNormalFontStyle(getNormalAttributes(node))
|
|
60
|
-
.textSpecialFontStyle(getFontAttributes(node))
|
|
61
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
62
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
63
|
-
node._nodeInfo.areaInfo = res[1]
|
|
64
|
-
}))
|
|
65
71
|
}
|
|
66
72
|
}
|
|
@@ -30,7 +30,7 @@ function getPlaceholderColor (node: TaroTextAreaElement): string {
|
|
|
30
30
|
export default struct TaroTextArea {
|
|
31
31
|
@State value: string = ''
|
|
32
32
|
|
|
33
|
-
node: TaroTextAreaElement
|
|
33
|
+
@ObjectLink node: TaroTextAreaElement
|
|
34
34
|
|
|
35
35
|
aboutToAppear () {
|
|
36
36
|
if (this.node) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isUndefined } from '@tarojs/shared'
|
|
2
2
|
import { ObjectAssign } from '@tarojs/runtime'
|
|
3
3
|
|
|
4
|
-
import { FlexManager } from './
|
|
4
|
+
import { FlexManager } from './flexManager'
|
|
5
5
|
import { TEXT_DEFAULT_STYLE } from './constant/style'
|
|
6
6
|
|
|
7
7
|
import type { StandardProps, TextProps } from '@tarojs/components/types'
|
|
@@ -25,7 +25,7 @@ export function getFontAttributes (node: TaroElement): TaroTextStyleType {
|
|
|
25
25
|
// 模拟 div 自动撑满父元素的情况
|
|
26
26
|
function isMaxWidthView (node: TaroElement) {
|
|
27
27
|
const parentNode: TaroElement = node.parentNode as TaroElement
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
return node.tagName === 'VIEW' && parentNode && parentNode.tagName === 'VIEW' &&
|
|
30
30
|
!(FlexManager.isFlexNode(parentNode) && FlexManager.flexOptions(parentNode).direction !== FlexDirection.Column)
|
|
31
31
|
}
|
|
@@ -78,25 +78,30 @@ function handleUpdate (node: TaroVideoElement, e: VideoUpdateEvent) {
|
|
|
78
78
|
emitEvent(node, 'timeUpdate', { currentTime: e.time})
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
@
|
|
82
|
-
export default
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
81
|
+
@Component
|
|
82
|
+
export default struct TaroVideo {
|
|
83
|
+
@ObjectLink node: TaroVideoElement
|
|
84
|
+
|
|
85
|
+
build () {
|
|
86
|
+
Video(getVideoData(this.node))
|
|
87
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
88
|
+
.props(getVideoProps(this.node))
|
|
89
|
+
.aspectRatio(4 / 3)
|
|
90
|
+
.onStart(shouldBindEvent(() => { emitEvent(this.node, 'play') }, this.node, ['play']))
|
|
91
|
+
.onPause(shouldBindEvent(() => { emitEvent(this.node, 'pause') }, this.node, ['pause']))
|
|
92
|
+
.onFinish(shouldBindEvent(() => { emitEvent(this.node, 'ended') }, this.node, ['ended']))
|
|
93
|
+
.onError(shouldBindEvent(() => { emitEvent(this.node, 'error') }, this.node, ['error']))
|
|
94
|
+
.onUpdate((e) => { handleUpdate(this.node, e) })
|
|
95
|
+
.onPrepared(shouldBindEvent((e: TaroAny) => { emitEvent(this.node, 'loadedMetaData', { duration: e.duration }) }, this.node, ['loadedmetadata']))
|
|
96
|
+
.onSeeking(shouldBindEvent((e: TaroAny) => { emitEvent(this.node, 'seeking', { duration: e.time }) }, this.node, ['seeking']))
|
|
97
|
+
.onSeeked(shouldBindEvent(() => { emitEvent(this.node, 'seeked') }, this.node, ['seeked']))
|
|
98
|
+
.onFullscreenChange(shouldBindEvent((e: TaroAny) => { emitEvent(this.node, 'fullScreenChange', { fullScreen: e.fullscreen}) }, this.node, ['fullscreenchange']))
|
|
99
|
+
.onClick((e: ClickEvent) => { eventHandler(e, 'click', this.node) })
|
|
100
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
101
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
102
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
103
|
+
}))
|
|
104
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
105
|
+
}
|
|
106
|
+
|
|
102
107
|
}
|
|
@@ -3,7 +3,7 @@ import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBL
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
4
|
import { createLazyChildren } from './render'
|
|
5
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
6
|
-
import { FlexManager } from './utils/
|
|
6
|
+
import { FlexManager } from './utils/flexManager'
|
|
7
7
|
import { getNodeThresholds, getNormalAttributes, shouldBindEvent } from './utils/helper'
|
|
8
8
|
|
|
9
9
|
import type { TaroViewElement, TaroStyleType, TaroAny } from '@tarojs/runtime'
|
|
@@ -28,35 +28,39 @@ function columnAttrs (style: TaroStyleType) {
|
|
|
28
28
|
})
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
@
|
|
32
|
-
export default
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
31
|
+
@Component
|
|
32
|
+
export default struct TaroView {
|
|
33
|
+
@ObjectLink node: TaroViewElement
|
|
34
|
+
|
|
35
|
+
build () {
|
|
36
|
+
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
37
|
+
Row() {
|
|
38
|
+
createLazyChildren(this.node)
|
|
39
|
+
}
|
|
40
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
41
|
+
.rowAttrs(getNormalAttributes(this.node))
|
|
42
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
43
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
44
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
45
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
46
|
+
}))
|
|
47
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
48
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
49
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
50
|
+
} else {
|
|
51
|
+
Column() {
|
|
52
|
+
createLazyChildren(this.node)
|
|
53
|
+
}
|
|
54
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
55
|
+
.columnAttrs(getNormalAttributes(this.node))
|
|
56
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
57
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
58
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
59
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
60
|
+
}))
|
|
61
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
62
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
63
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
50
64
|
}
|
|
51
|
-
.attributeModifier(commonStyleModify.setNode(node))
|
|
52
|
-
.columnAttrs(getNormalAttributes(node))
|
|
53
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
54
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
55
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
56
|
-
node._nodeInfo.areaInfo = res[1]
|
|
57
|
-
}))
|
|
58
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
59
|
-
.alignItems(FlexManager.flexOptions(node).alignItems as HorizontalAlign)
|
|
60
|
-
.justifyContent(FlexManager.flexOptions(node).justifyContent)
|
|
61
65
|
}
|
|
62
66
|
}
|