@tarojs/plugin-platform-harmony-ets 4.0.0-beta.5 → 4.0.0-beta.50
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 +53 -20
- package/dist/apis/canvas/index.ts +10 -1
- package/dist/apis/device/clipboard.ts +4 -0
- package/dist/apis/framework/index.ts +1 -5
- package/dist/apis/index.ts +27 -17
- package/dist/apis/network/request.ts +5 -5
- package/dist/apis/route/index.ts +15 -0
- package/dist/apis/storage/index.ts +148 -80
- package/dist/apis/ui/animation/animation.ts +71 -28
- package/dist/apis/ui/background.ts +2 -1
- package/dist/apis/ui/interaction/index.ts +40 -49
- package/dist/apis/ui/navigation-bar/index.ts +1 -1
- package/dist/apis/utils/index.ts +1 -1
- package/dist/apis/wxml/IntersectionObserver.ts +18 -10
- package/dist/apis/wxml/index.ts +2 -0
- package/dist/apis/wxml/selectorQuery.ts +18 -9
- package/dist/components-harmony-ets/button.ets +48 -34
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +69 -61
- package/dist/components-harmony-ets/form.ets +51 -29
- package/dist/components-harmony-ets/icon.ets +31 -19
- package/dist/components-harmony-ets/image.ets +27 -14
- package/dist/components-harmony-ets/index.ets +85 -0
- package/dist/components-harmony-ets/innerHtml.ets +11 -6
- package/dist/components-harmony-ets/input.ets +41 -40
- package/dist/components-harmony-ets/label.ets +69 -42
- package/dist/components-harmony-ets/movableArea.ets +126 -0
- package/dist/components-harmony-ets/movableView.ets +73 -0
- package/dist/components-harmony-ets/navigationBar.ets +25 -0
- package/dist/components-harmony-ets/pageMeta.ets +28 -0
- package/dist/components-harmony-ets/picker.ets +42 -38
- package/dist/components-harmony-ets/progress.ets +52 -0
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +71 -64
- package/dist/components-harmony-ets/richText.ets +14 -30
- package/dist/components-harmony-ets/scrollView.ets +61 -57
- package/dist/components-harmony-ets/slider.ets +15 -14
- package/dist/components-harmony-ets/style.ets +390 -130
- package/dist/components-harmony-ets/swiper.ets +38 -20
- package/dist/components-harmony-ets/switch.ets +30 -28
- package/dist/components-harmony-ets/{index.ts → tag.ts} +2 -0
- package/dist/components-harmony-ets/text.ets +121 -51
- package/dist/components-harmony-ets/textArea.ets +35 -34
- package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
- package/dist/components-harmony-ets/utils/flexManager.ets +47 -19
- package/dist/components-harmony-ets/utils/helper.ets +17 -5
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
- package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
- package/dist/components-harmony-ets/utils/index.ts +50 -51
- package/dist/components-harmony-ets/utils/styles.ets +170 -93
- package/dist/components-harmony-ets/video.ets +34 -20
- package/dist/components-harmony-ets/view.ets +63 -52
- package/dist/components-harmony-ets/webView.ets +40 -34
- package/dist/index.d.ts +152 -0
- package/dist/index.js +82 -39
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/document.ts +6 -4
- package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
- package/dist/runtime-ets/bom/window.ts +7 -0
- package/dist/runtime-ets/current.ts +3 -0
- package/dist/runtime-ets/dom/bind.ts +31 -13
- package/dist/runtime-ets/dom/cssNesting.ts +393 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +25 -39
- package/dist/runtime-ets/dom/document.ts +22 -8
- package/dist/runtime-ets/dom/element/canvas.ts +136 -0
- package/dist/runtime-ets/dom/element/element.ts +317 -51
- package/dist/runtime-ets/dom/element/form.ts +23 -26
- package/dist/runtime-ets/dom/element/index.ts +24 -2
- package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
- package/dist/runtime-ets/dom/element/movableView.ts +193 -0
- package/dist/runtime-ets/dom/element/normal.ts +35 -8
- package/dist/runtime-ets/dom/element/progress.ts +12 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
- package/dist/runtime-ets/dom/element/text.ts +1 -8
- package/dist/runtime-ets/dom/element/video.ts +5 -3
- package/dist/runtime-ets/dom/element/webView.ts +11 -3
- package/dist/runtime-ets/dom/event.ts +0 -1
- package/dist/runtime-ets/dom/eventTarget.ts +0 -3
- package/dist/runtime-ets/dom/node.ts +46 -28
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +334 -230
- package/dist/runtime-ets/dom/stylesheet/index.ts +28 -308
- package/dist/runtime-ets/dom/stylesheet/type.ts +40 -9
- package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
- package/dist/runtime-ets/index.ts +2 -2
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/utils/index.ts +66 -11
- package/dist/runtime-ets/utils/info.ts +1 -1
- package/dist/runtime-framework/react/app.ts +7 -2
- package/dist/runtime-framework/react/index.ts +0 -2
- package/dist/runtime-framework/react/native-page.ts +32 -14
- package/dist/runtime-framework/react/page.ts +3 -8
- package/dist/runtime-framework/solid/app.ts +25 -45
- package/dist/runtime-framework/solid/connect.ts +21 -3
- package/dist/runtime-framework/solid/hooks.ts +16 -11
- package/dist/runtime-framework/solid/index.ts +6 -2
- package/dist/runtime-framework/solid/page.ts +84 -30
- package/dist/runtime-framework/solid/reconciler/props.ts +65 -20
- package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
- 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 +827 -0
- package/dist/runtime-utils.js +399 -188
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +399 -188
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +13 -13
- package/static/media/cancel.svg +1 -1
- package/static/media/circle.svg +1 -1
- package/static/media/clear.svg +1 -1
- package/static/media/download.svg +1 -1
- package/static/media/info.svg +1 -1
- package/static/media/info_circle.svg +1 -1
- package/static/media/search.svg +1 -1
- package/static/media/success.svg +1 -1
- package/static/media/success_no_circle.svg +1 -1
- package/static/media/warn.svg +1 -1
- package/types/harmony.d.ts +4 -0
- package/types/index.d.ts +4 -0
- /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Current, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, getPageScrollerOrNode, AREA_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import commonStyleModify from './style'
|
|
4
|
-
|
|
3
|
+
import commonStyleModify, { rowModify, columnModify } from './style'
|
|
4
|
+
|
|
5
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
6
|
-
import { FlexManager } from './utils/
|
|
7
|
-
import {
|
|
6
|
+
import { FlexManager } from './utils/flexManager'
|
|
7
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
8
8
|
|
|
9
9
|
import type { TaroLabelElement, TaroElement, TaroAny, TaroRadioElement, TaroCheckboxElement } from '@tarojs/runtime'
|
|
10
|
+
import { isUndefined } from '@tarojs/shared'
|
|
10
11
|
|
|
11
12
|
function handleTargetChange (id: string) {
|
|
12
13
|
const taro: TaroAny = Current.taro
|
|
@@ -34,45 +35,71 @@ function handleTargetChange (id: string) {
|
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
@
|
|
38
|
-
export default
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
@Component
|
|
39
|
+
export default struct TaroLabel {
|
|
40
|
+
@Builder customBuilder() {}
|
|
41
|
+
@BuilderParam createLazyChildren: (node: TaroLabelElement) => void = this.customBuilder
|
|
42
|
+
@ObjectLink node: TaroLabelElement
|
|
43
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
44
|
+
|
|
45
|
+
aboutToAppear(): void {
|
|
46
|
+
if (this.node) {
|
|
47
|
+
this.node._instance = this
|
|
42
48
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
build() {
|
|
52
|
+
if (FlexManager.useFlexLayout(this.node)) {
|
|
53
|
+
Flex(FlexManager.flexOptions(this.node)) {
|
|
54
|
+
this.createLazyChildren(this.node)
|
|
55
|
+
}
|
|
56
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
57
|
+
.onClick((e: ClickEvent) => {
|
|
58
|
+
const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
|
|
59
|
+
const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
|
|
60
|
+
|
|
61
|
+
handleTargetChange(id)
|
|
62
|
+
eventHandler(e, 'click', this.node)
|
|
63
|
+
})
|
|
64
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
65
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
66
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
67
|
+
}))
|
|
68
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
69
|
+
} else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
|
|
70
|
+
Row() {
|
|
71
|
+
this.createLazyChildren(this.node)
|
|
72
|
+
}
|
|
73
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
74
|
+
.onClick((e: ClickEvent) => {
|
|
75
|
+
const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
|
|
76
|
+
const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
|
|
77
|
+
|
|
78
|
+
handleTargetChange(id)
|
|
79
|
+
eventHandler(e, 'click', this.node)
|
|
80
|
+
})
|
|
81
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
82
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
83
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
84
|
+
}))
|
|
85
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
86
|
+
} else {
|
|
87
|
+
Column() {
|
|
88
|
+
this.createLazyChildren(this.node)
|
|
89
|
+
}
|
|
90
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
91
|
+
.onClick((e: ClickEvent) => {
|
|
92
|
+
const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
|
|
93
|
+
const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
|
|
94
|
+
|
|
95
|
+
handleTargetChange(id)
|
|
96
|
+
eventHandler(e, 'click', this.node)
|
|
97
|
+
})
|
|
98
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
99
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
100
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
101
|
+
}))
|
|
102
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
61
103
|
}
|
|
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
104
|
}
|
|
78
105
|
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { TaroAny, TaroMovableAreaElement, TaroMovableViewElement } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import commonStyleModify, { rowModify, columnModify } from './style'
|
|
4
|
+
|
|
5
|
+
import { FlexManager } from './utils/flexManager'
|
|
6
|
+
import { isUndefined } from '@tarojs/shared'
|
|
7
|
+
|
|
8
|
+
@Component
|
|
9
|
+
export default struct TaroMovableArea {
|
|
10
|
+
@Builder customBuilder() {}
|
|
11
|
+
@BuilderParam createLazyChildren: (node: TaroMovableAreaElement) => void = this.customBuilder
|
|
12
|
+
@ObjectLink node: TaroMovableAreaElement
|
|
13
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
14
|
+
|
|
15
|
+
aboutToAppear(): void {
|
|
16
|
+
if (this.node) {
|
|
17
|
+
this.node._instance = this
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
build() {
|
|
22
|
+
if (FlexManager.useFlexLayout(this.node)) {
|
|
23
|
+
Flex(FlexManager.flexOptions(this.node)) {
|
|
24
|
+
this.createLazyChildren(this.node)
|
|
25
|
+
}
|
|
26
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
27
|
+
.clip(true)
|
|
28
|
+
.onAreaChange((oldValue: Area, newValue: Area) => {
|
|
29
|
+
this.node.childNodes.forEach(item => {
|
|
30
|
+
if(item.nodeName === 'MOVABLE-VIEW') {
|
|
31
|
+
;(item as TaroMovableViewElement).area = {
|
|
32
|
+
w: Number( newValue.width),
|
|
33
|
+
h: Number(newValue.height)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
.gesture(
|
|
39
|
+
PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
|
|
40
|
+
this.node.childNodes.forEach(item => {
|
|
41
|
+
if(item.nodeName === 'MOVABLE-VIEW') {
|
|
42
|
+
;(item as TaroMovableViewElement).startScale()
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
}).onActionUpdate((event) => {
|
|
46
|
+
const scaleArea = this.node.getAttribute('scaleArea')
|
|
47
|
+
if (scaleArea) {
|
|
48
|
+
this.node.childNodes.forEach(item => {
|
|
49
|
+
if(item.nodeName === 'MOVABLE-VIEW') {
|
|
50
|
+
;(item as TaroMovableViewElement).doScale(event.scale)
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
)
|
|
56
|
+
} else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
|
|
57
|
+
Row() {
|
|
58
|
+
this.createLazyChildren(this.node)
|
|
59
|
+
}
|
|
60
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
61
|
+
.clip(true)
|
|
62
|
+
.onAreaChange((oldValue: Area, newValue: Area) => {
|
|
63
|
+
this.node.childNodes.forEach(item => {
|
|
64
|
+
if(item.nodeName === 'MOVABLE-VIEW') {
|
|
65
|
+
;(item as TaroMovableViewElement).area = {
|
|
66
|
+
w: Number( newValue.width),
|
|
67
|
+
h: Number(newValue.height)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
.gesture(
|
|
73
|
+
PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
|
|
74
|
+
this.node.childNodes.forEach(item => {
|
|
75
|
+
if(item.nodeName === 'MOVABLE-VIEW') {
|
|
76
|
+
;(item as TaroMovableViewElement).startScale()
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
}).onActionUpdate((event) => {
|
|
80
|
+
const scaleArea = this.node.getAttribute('scaleArea')
|
|
81
|
+
if (scaleArea) {
|
|
82
|
+
this.node.childNodes.forEach(item => {
|
|
83
|
+
if(item.nodeName === 'MOVABLE-VIEW') {
|
|
84
|
+
;(item as TaroMovableViewElement).doScale(event.scale)
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
)
|
|
90
|
+
} else {
|
|
91
|
+
Column() {
|
|
92
|
+
this.createLazyChildren(this.node)
|
|
93
|
+
}
|
|
94
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
95
|
+
.clip(true)
|
|
96
|
+
.onAreaChange((oldValue: Area, newValue: Area) => {
|
|
97
|
+
this.node.childNodes.forEach(item => {
|
|
98
|
+
if(item.nodeName === 'MOVABLE-VIEW') {
|
|
99
|
+
;(item as TaroMovableViewElement).area = {
|
|
100
|
+
w: Number( newValue.width),
|
|
101
|
+
h: Number(newValue.height)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
.gesture(
|
|
107
|
+
PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
|
|
108
|
+
this.node.childNodes.forEach(item => {
|
|
109
|
+
if(item.nodeName === 'MOVABLE-VIEW') {
|
|
110
|
+
;(item as TaroMovableViewElement).startScale()
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
}).onActionUpdate((event) => {
|
|
114
|
+
const scaleArea = this.node.getAttribute('scaleArea')
|
|
115
|
+
if (scaleArea) {
|
|
116
|
+
this.node.childNodes.forEach(item => {
|
|
117
|
+
if(item.nodeName === 'MOVABLE-VIEW') {
|
|
118
|
+
;(item as TaroMovableViewElement).doScale(event.scale)
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { TaroAny, TaroMovableViewElement } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import commonStyleModify, { rowModify, columnModify } from './style'
|
|
4
|
+
|
|
5
|
+
import { FlexManager } from './utils/flexManager'
|
|
6
|
+
import { isUndefined } from '@tarojs/shared'
|
|
7
|
+
|
|
8
|
+
@Component
|
|
9
|
+
export default struct TaroMovableView {
|
|
10
|
+
@Builder customBuilder() {}
|
|
11
|
+
@BuilderParam createLazyChildren: (node: TaroMovableViewElement) => void = this.customBuilder
|
|
12
|
+
@ObjectLink node: TaroMovableViewElement
|
|
13
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
14
|
+
|
|
15
|
+
aboutToAppear(): void {
|
|
16
|
+
if (this.node) {
|
|
17
|
+
this.node._instance = this
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
build() {
|
|
22
|
+
Stack() {
|
|
23
|
+
if (FlexManager.useFlexLayout(this.node)) {
|
|
24
|
+
Flex(FlexManager.flexOptions(this.node)) {
|
|
25
|
+
this.createLazyChildren(this.node)
|
|
26
|
+
}
|
|
27
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
28
|
+
} else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
|
|
29
|
+
Row() {
|
|
30
|
+
this.createLazyChildren(this.node)
|
|
31
|
+
}
|
|
32
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
33
|
+
} else {
|
|
34
|
+
Column() {
|
|
35
|
+
this.createLazyChildren(this.node)
|
|
36
|
+
}
|
|
37
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
.translate({ x: this.node.position.x, y: this.node.position.y })
|
|
41
|
+
.scale({ x: this.node.scaleValue, y: this.node.scaleValue })
|
|
42
|
+
.onAreaChange((oldValue: Area, newValue: Area) => {
|
|
43
|
+
this.node.selfSize = {w: Number(newValue.width), h: Number(newValue.height)}
|
|
44
|
+
})
|
|
45
|
+
.gesture(
|
|
46
|
+
GestureGroup(GestureMode.Exclusive,
|
|
47
|
+
PanGesture({fingers:1}).onActionStart((e: GestureEvent) => {
|
|
48
|
+
|
|
49
|
+
this.node.startMove()
|
|
50
|
+
}).onActionUpdate((e: GestureEvent) => {
|
|
51
|
+
|
|
52
|
+
this.node.doMove({
|
|
53
|
+
x: e.offsetX,
|
|
54
|
+
y: e.offsetY
|
|
55
|
+
})
|
|
56
|
+
// 事件处理
|
|
57
|
+
const bindchange = this.node.getAttribute('bindchange')
|
|
58
|
+
if (typeof bindchange === 'function') {
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
}).onActionEnd(() => {
|
|
62
|
+
// this.updatePosition()
|
|
63
|
+
this.node.checkPositionBoundary(this.node.position, this.node.scaleValue)
|
|
64
|
+
}),
|
|
65
|
+
PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
|
|
66
|
+
this.node.startScale()
|
|
67
|
+
}).onActionUpdate((event) => {
|
|
68
|
+
this.node.doScale(event.scale)
|
|
69
|
+
})
|
|
70
|
+
)
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isTagFirstChild } from './utils/helper'
|
|
2
|
+
|
|
3
|
+
import type { TaroNavigationBarElement } from '@tarojs/runtime'
|
|
4
|
+
|
|
5
|
+
@Component
|
|
6
|
+
export default struct TaroNavigationBar {
|
|
7
|
+
@Builder customBuilder() {}
|
|
8
|
+
@BuilderParam createLazyChildren: (node: TaroNavigationBarElement) => void = this.customBuilder
|
|
9
|
+
@ObjectLink node: TaroNavigationBarElement
|
|
10
|
+
|
|
11
|
+
aboutToAppear(): void {
|
|
12
|
+
if (!isTagFirstChild(this.node, 'page-meta')) {
|
|
13
|
+
console.error('NavigationBar 只能是 PageMeta 内的第一个节点。')
|
|
14
|
+
}
|
|
15
|
+
if (this.node) {
|
|
16
|
+
this.node._instance = this
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
build() {
|
|
21
|
+
if (true) {
|
|
22
|
+
this.createLazyChildren(this.node)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { APP } from '@tarojs/runtime/dist/runtime.esm'
|
|
2
|
+
|
|
3
|
+
import { isTagFirstChild } from './utils/helper'
|
|
4
|
+
|
|
5
|
+
import type { TaroPageMetaElement } from '@tarojs/runtime'
|
|
6
|
+
|
|
7
|
+
@Component
|
|
8
|
+
export default struct TaroPageMeta {
|
|
9
|
+
@Builder customBuilder() {}
|
|
10
|
+
@BuilderParam createLazyChildren: (node: TaroPageMetaElement) => void = this.customBuilder
|
|
11
|
+
@ObjectLink node: TaroPageMetaElement
|
|
12
|
+
|
|
13
|
+
aboutToAppear(): void {
|
|
14
|
+
if (!isTagFirstChild(this.node, APP, 2)) {
|
|
15
|
+
// PageMeta 只能是页面内的第一个元素
|
|
16
|
+
console.error('PageMeta 只能是页面内的第一个元素。')
|
|
17
|
+
}
|
|
18
|
+
if (this.node) {
|
|
19
|
+
this.node._instance = this
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
build() {
|
|
24
|
+
if (true) {
|
|
25
|
+
this.createLazyChildren(this.node)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, TaroPickerElement, createTaroEvent } from '@tarojs/runtime'
|
|
2
|
-
import { createLazyChildren } from './render'
|
|
3
2
|
import commonStyleModify from './style'
|
|
4
3
|
import { getSingleSelector, getMultiSelector } from './utils'
|
|
5
4
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
6
|
-
import { FlexManager } from './utils/
|
|
7
|
-
import {
|
|
5
|
+
import { FlexManager } from './utils/flexManager'
|
|
6
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
8
7
|
|
|
9
8
|
import type { TaroAny, TaroEvent } from '@tarojs/runtime'
|
|
10
9
|
|
|
11
|
-
import { PickerDateProps, PickerMultiSelectorProps, PickerSelectorProps, PickerTimeProps } from '
|
|
10
|
+
import { PickerDateProps, PickerMultiSelectorProps, PickerSelectorProps, PickerTimeProps } from '@tarojs/components/types'
|
|
12
11
|
|
|
13
12
|
interface TimeRange {
|
|
14
13
|
startHH: number
|
|
@@ -146,9 +145,10 @@ export struct PickerView {
|
|
|
146
145
|
color: '#000'
|
|
147
146
|
})
|
|
148
147
|
.canLoop(false)
|
|
149
|
-
.attributeModifier(commonStyleModify.setNode(this.node
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
.attributeModifier(commonStyleModify.setNode(this.node, {
|
|
149
|
+
width: '100%',
|
|
150
|
+
backgroundColor: '#fff'
|
|
151
|
+
}))
|
|
152
152
|
.onChange((_, index) => {
|
|
153
153
|
this.node?.updateFormWidgetValue(index)
|
|
154
154
|
})
|
|
@@ -158,9 +158,10 @@ export struct PickerView {
|
|
|
158
158
|
color: '#000'
|
|
159
159
|
})
|
|
160
160
|
.canLoop(false)
|
|
161
|
-
.attributeModifier(commonStyleModify.setNode(this.node
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
.attributeModifier(commonStyleModify.setNode(this.node, {
|
|
162
|
+
width: '100%',
|
|
163
|
+
backgroundColor: '#fff'
|
|
164
|
+
}))
|
|
164
165
|
.onChange((_, index) => {
|
|
165
166
|
if (index instanceof Array) {
|
|
166
167
|
this.node?.updateFormWidgetValue(index)
|
|
@@ -187,9 +188,10 @@ export struct PickerView {
|
|
|
187
188
|
.selectedTextStyle({
|
|
188
189
|
color: '#000'
|
|
189
190
|
})
|
|
190
|
-
.attributeModifier(commonStyleModify.setNode(this.node
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
.attributeModifier(commonStyleModify.setNode(this.node, {
|
|
192
|
+
width: '100%',
|
|
193
|
+
backgroundColor: '#fff'
|
|
194
|
+
}))
|
|
193
195
|
.onDateChange(value => {
|
|
194
196
|
const data = value.toLocaleDateString().split('/')
|
|
195
197
|
const day = data[1]
|
|
@@ -203,9 +205,10 @@ export struct PickerView {
|
|
|
203
205
|
color: '#000'
|
|
204
206
|
})
|
|
205
207
|
.canLoop(false)
|
|
206
|
-
.attributeModifier(commonStyleModify.setNode(this.node
|
|
207
|
-
|
|
208
|
-
|
|
208
|
+
.attributeModifier(commonStyleModify.setNode(this.node, {
|
|
209
|
+
width: '100%',
|
|
210
|
+
backgroundColor: '#fff'
|
|
211
|
+
}))
|
|
209
212
|
.onChange((value) => {
|
|
210
213
|
this.node?.updateFormWidgetValue(`${('00'+value[0]).slice(-2)}:${('00'+value[1]).slice(-2)}`)
|
|
211
214
|
})
|
|
@@ -219,9 +222,12 @@ export struct PickerView {
|
|
|
219
222
|
}
|
|
220
223
|
}
|
|
221
224
|
|
|
225
|
+
|
|
222
226
|
@Component
|
|
223
227
|
export default struct TaroPicker {
|
|
224
|
-
|
|
228
|
+
@Builder customBuilder() {}
|
|
229
|
+
@BuilderParam createLazyChildren: (node: TaroPickerElement) => void = this.customBuilder
|
|
230
|
+
@ObjectLink node: TaroPickerElement
|
|
225
231
|
|
|
226
232
|
aboutToAppear () {
|
|
227
233
|
this.node?.addEventListener('click', this.handleClick)
|
|
@@ -237,8 +243,8 @@ export default struct TaroPicker {
|
|
|
237
243
|
break
|
|
238
244
|
case 'time': {
|
|
239
245
|
const hour = new Date().getHours()
|
|
240
|
-
const minute = new Date().getMinutes()
|
|
241
|
-
|
|
246
|
+
const minute = new Date().getMinutes()
|
|
247
|
+
|
|
242
248
|
defaultResetValue = `${('00'+hour).slice(-2)}:${('00'+minute).slice(-2)}`
|
|
243
249
|
break
|
|
244
250
|
}
|
|
@@ -247,7 +253,7 @@ export default struct TaroPicker {
|
|
|
247
253
|
const day = data[1]
|
|
248
254
|
const month = data[0]
|
|
249
255
|
const year = data[2]
|
|
250
|
-
|
|
256
|
+
|
|
251
257
|
defaultResetValue = `${year}-${month}-${day}`
|
|
252
258
|
break
|
|
253
259
|
}
|
|
@@ -255,7 +261,7 @@ export default struct TaroPicker {
|
|
|
255
261
|
defaultResetValue = ''
|
|
256
262
|
break
|
|
257
263
|
}
|
|
258
|
-
|
|
264
|
+
|
|
259
265
|
this.node._isInit = true
|
|
260
266
|
this.node._reset = this.node.value || defaultResetValue
|
|
261
267
|
}
|
|
@@ -305,24 +311,22 @@ export default struct TaroPicker {
|
|
|
305
311
|
}
|
|
306
312
|
|
|
307
313
|
build() {
|
|
308
|
-
if (this.node) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
createLazyChildren(this.node)
|
|
320
|
-
}
|
|
321
|
-
.defaultEvent()
|
|
322
|
-
.visibleChangeEvent()
|
|
323
|
-
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
324
|
-
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
314
|
+
if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
|
|
315
|
+
Row() {
|
|
316
|
+
this.createLazyChildren(this.node)
|
|
317
|
+
}
|
|
318
|
+
.defaultEvent()
|
|
319
|
+
.visibleChangeEvent()
|
|
320
|
+
.alignItems(FlexManager.alignItems<VerticalAlign>(this.node))
|
|
321
|
+
.justifyContent(FlexManager.justifyContent(this.node))
|
|
322
|
+
} else {
|
|
323
|
+
Column() {
|
|
324
|
+
this.createLazyChildren(this.node)
|
|
325
325
|
}
|
|
326
|
+
.defaultEvent()
|
|
327
|
+
.visibleChangeEvent()
|
|
328
|
+
.alignItems(FlexManager.alignItems<HorizontalAlign>(this.node))
|
|
329
|
+
.justifyContent(FlexManager.justifyContent(this.node))
|
|
326
330
|
}
|
|
327
331
|
}
|
|
328
332
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
@Builder customBuilder() {}
|
|
13
|
+
@BuilderParam createLazyChildren: (node: TaroProgressElement) => void = this.customBuilder
|
|
14
|
+
@ObjectLink node: TaroProgressElement
|
|
15
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
16
|
+
|
|
17
|
+
aboutToAppear(): void {
|
|
18
|
+
if (this.node) {
|
|
19
|
+
this.node._instance = this
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
build() {
|
|
24
|
+
Row({ space: 5 }) {
|
|
25
|
+
Progress({
|
|
26
|
+
value: parseFloat(this.node.getAttribute('percent')),
|
|
27
|
+
type: ProgressType.Linear
|
|
28
|
+
})
|
|
29
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
30
|
+
.color(this.node.getAttribute('activeColor') ?? PROGRESS_ACTIVECOLOR)
|
|
31
|
+
.backgroundColor(this.node.getAttribute('backgroundColor') ?? PROGRESS_BACKGROUNDCOLOR)
|
|
32
|
+
.style({
|
|
33
|
+
strokeWidth: this.node.getAttribute('strokeWidth'),
|
|
34
|
+
strokeRadius: parseFloat(this.node.getAttribute('borderRadius')),
|
|
35
|
+
enableSmoothEffect: Boolean(this.node.getAttribute('active')),
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
39
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
40
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
41
|
+
if (this.node) {
|
|
42
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
43
|
+
}
|
|
44
|
+
}))
|
|
45
|
+
|
|
46
|
+
if (this.node.getAttribute('showInfo')) {
|
|
47
|
+
Text(`${this.node.getAttribute('percent')}%`)
|
|
48
|
+
.fontSize(this.node.getAttribute('fontSize') ?? PROGRESS_DEFAULTINFOFONTSIZE)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { getFontAttributes } from './utils/helper'
|
|
2
|
+
import { pseudoModify } from './style'
|
|
3
|
+
|
|
4
|
+
import type { TaroViewElement, TaroStyleType, TaroTextStyleType, TaroAny } from '@tarojs/runtime'
|
|
5
|
+
|
|
6
|
+
@Extend(Flex)
|
|
7
|
+
function flexAttrs (style: TaroStyleType) {
|
|
8
|
+
.constraintSize({
|
|
9
|
+
minWidth: style.minWidth,
|
|
10
|
+
maxWidth: style.maxWidth,
|
|
11
|
+
minHeight: style.minHeight || style.height,
|
|
12
|
+
maxHeight: style.maxHeight
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@Extend(Text)
|
|
18
|
+
function textNormalFontStyle (style: TaroStyleType) {
|
|
19
|
+
.id(style.id)
|
|
20
|
+
.key(style.id)
|
|
21
|
+
.opacity(style.opacity)
|
|
22
|
+
.fontColor(style.color)
|
|
23
|
+
.fontSize(style.fontSize)
|
|
24
|
+
.fontWeight(style.fontWeight)
|
|
25
|
+
.fontStyle(style.fontStyle)
|
|
26
|
+
.fontFamily(style.fontFamily)
|
|
27
|
+
.decoration({
|
|
28
|
+
type: style.textDecoration?.type || TextDecorationType.None,
|
|
29
|
+
color: style.color
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@Extend(Text)
|
|
34
|
+
function textSpecialFontStyle(attr: TaroTextStyleType) {
|
|
35
|
+
.textAlign(attr.textAlign)
|
|
36
|
+
.align(attr.verticalAlign)
|
|
37
|
+
.textOverflow(attr.textOverflow)
|
|
38
|
+
.maxLines(attr.WebkitLineClamp)
|
|
39
|
+
.letterSpacing(attr.letterSpacing)
|
|
40
|
+
.lineHeight(attr.lineHeight)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@Component
|
|
44
|
+
export default struct PseduoChildren {
|
|
45
|
+
@Builder customBuilder() {}
|
|
46
|
+
@BuilderParam createLazyChildren: (node: TaroAny) => void = this.customBuilder
|
|
47
|
+
@ObjectLink node: TaroViewElement
|
|
48
|
+
|
|
49
|
+
build () {
|
|
50
|
+
if (true) {
|
|
51
|
+
// 伪类::Before
|
|
52
|
+
if (this.node._pseudo_before) {
|
|
53
|
+
if (this.node._pseudo_before?.hmStyle.content) {
|
|
54
|
+
Text(this.node._pseudo_before.hmStyle.content)
|
|
55
|
+
.attributeModifier(pseudoModify.setStyle(this.node._pseudo_before.hmStyle))
|
|
56
|
+
.textNormalFontStyle(this.node._pseudo_before.hmStyle || {})
|
|
57
|
+
.textSpecialFontStyle(getFontAttributes(this.node))
|
|
58
|
+
} else {
|
|
59
|
+
Flex() {}
|
|
60
|
+
.attributeModifier(pseudoModify.setStyle(this.node._pseudo_before.hmStyle || {}))
|
|
61
|
+
.flexAttrs(this.node._pseudo_before.hmStyle || {})
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
this.createLazyChildren(this.node)
|
|
65
|
+
// 伪类::After
|
|
66
|
+
if (this.node._pseudo_after) {
|
|
67
|
+
if (this.node._pseudo_after?.hmStyle.content) {
|
|
68
|
+
Text(this.node._pseudo_after.hmStyle.content)
|
|
69
|
+
.attributeModifier(pseudoModify.setStyle(this.node._pseudo_after.hmStyle))
|
|
70
|
+
.textNormalFontStyle(this.node._pseudo_after.hmStyle || {})
|
|
71
|
+
.textSpecialFontStyle(getFontAttributes(this.node))
|
|
72
|
+
} else {
|
|
73
|
+
Flex() {}
|
|
74
|
+
.attributeModifier(pseudoModify.setStyle(this.node._pseudo_after.hmStyle || {}))
|
|
75
|
+
.flexAttrs(this.node._pseudo_after.hmStyle || {})
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|