@tarojs/plugin-platform-harmony-ets 4.0.0-canary.8 → 4.0.0
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 +73 -20
- package/dist/apis/canvas/index.ts +10 -1
- package/dist/apis/device/clipboard.ts +23 -8
- package/dist/apis/framework/index.ts +1 -5
- package/dist/apis/index.ts +27 -17
- package/dist/apis/media/image/index.ts +169 -17
- package/dist/apis/network/request.ts +5 -5
- package/dist/apis/route/index.ts +15 -0
- package/dist/apis/storage/index.ts +146 -78
- package/dist/apis/ui/animation/animation.ts +71 -29
- package/dist/apis/ui/background.ts +2 -1
- package/dist/apis/ui/interaction/index.ts +58 -59
- package/dist/apis/ui/navigation-bar/index.ts +1 -1
- package/dist/apis/ui/pull-down-refresh.ts +9 -3
- package/dist/apis/ui/scroll/index.ts +5 -5
- package/dist/apis/ui/tab-bar.ts +3 -3
- package/dist/apis/utils/index.ts +21 -2
- package/dist/apis/utils/permissions.ts +6 -0
- package/dist/apis/wxml/IntersectionObserver.ts +18 -10
- package/dist/apis/wxml/index.ts +2 -0
- package/dist/apis/wxml/selectorQuery.ts +26 -13
- package/dist/components-harmony-ets/button.ets +63 -77
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +75 -258
- package/dist/components-harmony-ets/form.ets +51 -158
- package/dist/components-harmony-ets/icon.ets +33 -83
- package/dist/components-harmony-ets/image.ets +35 -79
- package/dist/components-harmony-ets/index.ets +92 -0
- package/dist/components-harmony-ets/innerHtml.ets +11 -6
- package/dist/components-harmony-ets/input.ets +64 -101
- package/dist/components-harmony-ets/label.ets +72 -174
- package/dist/components-harmony-ets/listView.ets +31 -0
- package/dist/components-harmony-ets/movableArea.ets +126 -0
- package/dist/components-harmony-ets/movableView.ets +93 -0
- package/dist/components-harmony-ets/navigationBar.ets +65 -0
- package/dist/components-harmony-ets/pageMeta.ets +94 -0
- package/dist/components-harmony-ets/picker.ets +46 -163
- 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 +80 -264
- package/dist/components-harmony-ets/richText.ets +20 -102
- package/dist/components-harmony-ets/scrollList.ets +108 -0
- package/dist/components-harmony-ets/scrollView.ets +71 -160
- package/dist/components-harmony-ets/slider.ets +22 -82
- package/dist/components-harmony-ets/stickySection.ets +42 -0
- package/dist/components-harmony-ets/style.ets +410 -0
- package/dist/components-harmony-ets/swiper.ets +64 -87
- package/dist/components-harmony-ets/switch.ets +39 -99
- package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
- package/dist/components-harmony-ets/text.ets +111 -113
- package/dist/components-harmony-ets/textArea.ets +51 -95
- package/dist/components-harmony-ets/utils/AttributeManager.ets +2 -2
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -2
- package/dist/components-harmony-ets/utils/flexManager.ets +50 -19
- package/dist/components-harmony-ets/utils/helper.ets +20 -8
- 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 +54 -50
- package/dist/components-harmony-ets/utils/styles.ets +172 -92
- package/dist/components-harmony-ets/video.ets +37 -88
- package/dist/components-harmony-ets/view.ets +63 -159
- package/dist/components-harmony-ets/webView.ets +41 -98
- package/dist/index.d.ts +152 -0
- package/dist/index.js +187 -56
- 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 +9 -2
- package/dist/runtime-ets/current.ts +5 -1
- package/dist/runtime-ets/dom/bind.ts +28 -12
- package/dist/runtime-ets/dom/class-list.ts +2 -2
- package/dist/runtime-ets/dom/cssNesting.ts +419 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +28 -42
- 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 +376 -57
- package/dist/runtime-ets/dom/element/form.ts +31 -26
- package/dist/runtime-ets/dom/element/index.ts +30 -2
- package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
- package/dist/runtime-ets/dom/element/movableView.ts +248 -0
- package/dist/runtime-ets/dom/element/normal.ts +35 -8
- package/dist/runtime-ets/dom/element/progress.ts +11 -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 -4
- package/dist/runtime-ets/dom/element/webView.ts +12 -5
- package/dist/runtime-ets/dom/event.ts +3 -5
- package/dist/runtime-ets/dom/eventTarget.ts +2 -3
- package/dist/runtime-ets/dom/node.ts +65 -32
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +418 -237
- package/dist/runtime-ets/dom/stylesheet/index.ts +29 -311
- package/dist/runtime-ets/dom/stylesheet/type.ts +53 -11
- 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 +74 -13
- package/dist/runtime-ets/utils/info.ts +2 -2
- package/dist/runtime-framework/react/app.ts +25 -30
- package/dist/runtime-framework/react/hooks.ts +3 -4
- package/dist/runtime-framework/react/index.ts +0 -2
- package/dist/runtime-framework/react/native-page.ts +219 -82
- package/dist/runtime-framework/react/page.ts +6 -10
- package/dist/runtime-framework/react/utils/index.ts +3 -3
- package/dist/runtime-framework/solid/app.ts +30 -46
- package/dist/runtime-framework/solid/connect.ts +21 -3
- package/dist/runtime-framework/solid/hooks.ts +17 -12
- package/dist/runtime-framework/solid/index.ts +6 -2
- package/dist/runtime-framework/solid/page.ts +85 -31
- package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
- 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 +3 -5
- package/dist/runtime-utils.d.ts +827 -0
- package/dist/runtime-utils.js +618 -245
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +618 -245
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +14 -15
- 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 +5 -0
- package/types/index.d.ts +4 -0
- package/types/runtime.d.ts +3 -1
- package/dist/runtime-ets/utils/bind.ts +0 -24
- /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
|
@@ -1,147 +1,19 @@
|
|
|
1
1
|
import { Current, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, getPageScrollerOrNode, AREA_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
5
|
-
import { FlexManager } from './utils/FlexManager'
|
|
6
|
-
import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
7
|
-
|
|
8
|
-
import type { TaroStyleType, TaroLabelElement, TaroElement, TaroAny, TaroRadioElement, TaroCheckboxElement } from '@tarojs/runtime'
|
|
3
|
+
import commonStyleModify, { rowModify, columnModify } from './style'
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
.key(style.id)
|
|
14
|
-
.flexGrow(style.flexGrow)
|
|
15
|
-
.flexShrink(style.flexShrink)
|
|
16
|
-
.flexBasis(style.flexBasis)
|
|
17
|
-
.alignSelf(style.alignSelf)
|
|
18
|
-
.padding({
|
|
19
|
-
top: style.paddingTop,
|
|
20
|
-
right: style.paddingRight,
|
|
21
|
-
bottom: style.paddingBottom,
|
|
22
|
-
left: style.paddingLeft
|
|
23
|
-
})
|
|
24
|
-
.margin({
|
|
25
|
-
top: style.marginTop,
|
|
26
|
-
right: style.marginRight,
|
|
27
|
-
bottom: style.marginBottom,
|
|
28
|
-
left: style.marginLeft
|
|
29
|
-
})
|
|
30
|
-
.width(style.width)
|
|
31
|
-
.height(style.height)
|
|
32
|
-
.constraintSize({
|
|
33
|
-
minWidth: style.minWidth,
|
|
34
|
-
maxWidth: style.maxWidth,
|
|
35
|
-
minHeight: style.minHeight,
|
|
36
|
-
maxHeight: style.maxHeight
|
|
37
|
-
})
|
|
38
|
-
.backgroundColor(style.backgroundColor)
|
|
39
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
40
|
-
.backgroundImageSize(style.backgroundSize)
|
|
41
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
42
|
-
.borderStyle({
|
|
43
|
-
top: style.borderTopStyle,
|
|
44
|
-
right: style.borderRightStyle,
|
|
45
|
-
bottom: style.borderBottomStyle,
|
|
46
|
-
left: style.borderLeftStyle
|
|
47
|
-
})
|
|
48
|
-
.borderWidth({
|
|
49
|
-
top: style.borderTopWidth,
|
|
50
|
-
right: style.borderRightWidth,
|
|
51
|
-
bottom: style.borderBottomWidth,
|
|
52
|
-
left: style.borderLeftWidth
|
|
53
|
-
})
|
|
54
|
-
.borderColor({
|
|
55
|
-
top: style.borderTopColor,
|
|
56
|
-
right: style.borderRightColor,
|
|
57
|
-
bottom: style.borderBottomColor,
|
|
58
|
-
left: style.borderLeftColor
|
|
59
|
-
})
|
|
60
|
-
.borderRadius({
|
|
61
|
-
topLeft: style.borderTopLeftRadius,
|
|
62
|
-
topRight: style.borderTopRightRadius,
|
|
63
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
64
|
-
bottomRight: style.borderBottomRightRadius
|
|
65
|
-
})
|
|
66
|
-
.zIndex(style.zIndex)
|
|
67
|
-
.opacity(style.opacity)
|
|
68
|
-
.linearGradient(style.linearGradient)
|
|
69
|
-
.clip(style.overflow)
|
|
70
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
71
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
72
|
-
.transform(style.transform)
|
|
73
|
-
}
|
|
5
|
+
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
6
|
+
import { FlexManager } from './utils/flexManager'
|
|
7
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
74
8
|
|
|
75
|
-
@
|
|
76
|
-
|
|
77
|
-
.id(style.id)
|
|
78
|
-
.key(style.id)
|
|
79
|
-
.flexGrow(style.flexGrow)
|
|
80
|
-
.flexShrink(style.flexShrink)
|
|
81
|
-
.flexBasis(style.flexBasis)
|
|
82
|
-
.alignSelf(style.alignSelf)
|
|
83
|
-
.padding({
|
|
84
|
-
top: style.paddingTop,
|
|
85
|
-
right: style.paddingRight,
|
|
86
|
-
bottom: style.paddingBottom,
|
|
87
|
-
left: style.paddingLeft
|
|
88
|
-
})
|
|
89
|
-
.margin({
|
|
90
|
-
top: style.marginTop,
|
|
91
|
-
right: style.marginRight,
|
|
92
|
-
bottom: style.marginBottom,
|
|
93
|
-
left: style.marginLeft
|
|
94
|
-
})
|
|
95
|
-
.width(style.width)
|
|
96
|
-
.height(style.height)
|
|
97
|
-
.constraintSize({
|
|
98
|
-
minWidth: style.minWidth,
|
|
99
|
-
maxWidth: style.maxWidth,
|
|
100
|
-
minHeight: style.minHeight,
|
|
101
|
-
maxHeight: style.maxHeight
|
|
102
|
-
})
|
|
103
|
-
.backgroundColor(style.backgroundColor)
|
|
104
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
105
|
-
.backgroundImageSize(style.backgroundSize)
|
|
106
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
107
|
-
.borderStyle({
|
|
108
|
-
top: style.borderTopStyle,
|
|
109
|
-
right: style.borderRightStyle,
|
|
110
|
-
bottom: style.borderBottomStyle,
|
|
111
|
-
left: style.borderLeftStyle
|
|
112
|
-
})
|
|
113
|
-
.borderWidth({
|
|
114
|
-
top: style.borderTopWidth,
|
|
115
|
-
right: style.borderRightWidth,
|
|
116
|
-
bottom: style.borderBottomWidth,
|
|
117
|
-
left: style.borderLeftWidth
|
|
118
|
-
})
|
|
119
|
-
.borderColor({
|
|
120
|
-
top: style.borderTopColor,
|
|
121
|
-
right: style.borderRightColor,
|
|
122
|
-
bottom: style.borderBottomColor,
|
|
123
|
-
left: style.borderLeftColor
|
|
124
|
-
})
|
|
125
|
-
.borderRadius({
|
|
126
|
-
topLeft: style.borderTopLeftRadius,
|
|
127
|
-
topRight: style.borderTopRightRadius,
|
|
128
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
129
|
-
bottomRight: style.borderBottomRightRadius
|
|
130
|
-
})
|
|
131
|
-
.zIndex(style.zIndex)
|
|
132
|
-
.opacity(style.opacity)
|
|
133
|
-
.linearGradient(style.linearGradient)
|
|
134
|
-
.clip(style.overflow)
|
|
135
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
136
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
137
|
-
.transform(style.transform)
|
|
138
|
-
}
|
|
9
|
+
import type { TaroLabelElement, TaroElement, TaroAny, TaroRadioElement, TaroCheckboxElement } from '@tarojs/runtime'
|
|
10
|
+
import { isUndefined } from '@tarojs/shared'
|
|
139
11
|
|
|
140
12
|
function handleTargetChange (id: string) {
|
|
141
13
|
const taro: TaroAny = Current.taro
|
|
142
14
|
const page: TaroAny = taro.getCurrentInstance().page
|
|
143
|
-
const currentPageNode: TaroElement = getPageScrollerOrNode(page
|
|
144
|
-
const node: TaroElement | null = currentPageNode
|
|
15
|
+
const currentPageNode: TaroElement = getPageScrollerOrNode(page?.node, page)
|
|
16
|
+
const node: TaroElement | null = currentPageNode?.getElementById(id)
|
|
145
17
|
|
|
146
18
|
if (!node) return
|
|
147
19
|
|
|
@@ -163,45 +35,71 @@ function handleTargetChange (id: string) {
|
|
|
163
35
|
}
|
|
164
36
|
}
|
|
165
37
|
|
|
166
|
-
@
|
|
167
|
-
export default
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
38
|
+
@Component
|
|
39
|
+
export default struct TaroLabel {
|
|
40
|
+
@Builder customBuilder() {}
|
|
41
|
+
@BuilderParam createLazyChildren: (node: TaroLabelElement, layer?: number) => 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
|
|
171
48
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
build() {
|
|
52
|
+
if (FlexManager.useFlexLayout(this.node)) {
|
|
53
|
+
Flex(FlexManager.flexOptions(this.node)) {
|
|
54
|
+
this.createLazyChildren(this.node, 0)
|
|
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.toString() || ''
|
|
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, 0)
|
|
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.toString() || ''
|
|
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, 0)
|
|
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.toString() || ''
|
|
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))
|
|
190
103
|
}
|
|
191
|
-
.columnAttrs(getNormalAttributes(node))
|
|
192
|
-
.onClick((e: ClickEvent) => {
|
|
193
|
-
const firstChild: TaroElement | null = node.childNodes[0] as TaroElement | null
|
|
194
|
-
const id: string = node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
|
|
195
|
-
|
|
196
|
-
handleTargetChange(id)
|
|
197
|
-
eventHandler(e, 'click', node)
|
|
198
|
-
})
|
|
199
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
200
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
201
|
-
node._nodeInfo.areaInfo = res[1]
|
|
202
|
-
}))
|
|
203
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
204
|
-
.alignItems(FlexManager.flexOptions(node).alignItems as HorizontalAlign)
|
|
205
|
-
.justifyContent(FlexManager.flexOptions(node).justifyContent)
|
|
206
104
|
}
|
|
207
105
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import commonStyleModify from './style'
|
|
2
|
+
|
|
3
|
+
import type { TaroViewElement, TaroAny } from '@tarojs/runtime'
|
|
4
|
+
|
|
5
|
+
@Reusable
|
|
6
|
+
@Component
|
|
7
|
+
export default struct TaroListView {
|
|
8
|
+
@Builder customBuilder() {}
|
|
9
|
+
@BuilderParam createLazyChildren: (node: TaroViewElement, layer?: number) => void = this.customBuilder
|
|
10
|
+
@ObjectLink node: TaroViewElement
|
|
11
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
12
|
+
|
|
13
|
+
aboutToAppear(): void {
|
|
14
|
+
if (this.node) {
|
|
15
|
+
this.node._instance = this
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
aboutToReuse(params: TaroAny): void {
|
|
20
|
+
// this.node = params.node;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
build() {
|
|
24
|
+
ListItem() {
|
|
25
|
+
Stack() {
|
|
26
|
+
this.createLazyChildren(this.node, 0)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { TaroAny, TaroMovableAreaElement, TaroMovableViewElement } from '@tarojs/runtime'
|
|
2
|
+
import { isTaroMovableViewElement } from '@tarojs/runtime'
|
|
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
|
|
11
|
+
customBuilder() {
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@BuilderParam createLazyChildren: (node: TaroMovableAreaElement, layer?: number) => void = this.customBuilder
|
|
15
|
+
@ObjectLink node: TaroMovableAreaElement
|
|
16
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
17
|
+
|
|
18
|
+
aboutToAppear(): void {
|
|
19
|
+
if (this.node) {
|
|
20
|
+
this.node._instance = this
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
build() {
|
|
29
|
+
if (FlexManager.useFlexLayout(this.node)) {
|
|
30
|
+
Flex(FlexManager.flexOptions(this.node)) {
|
|
31
|
+
this.createLazyChildren(this.node, 0)
|
|
32
|
+
}
|
|
33
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
34
|
+
.clip(true)
|
|
35
|
+
.onSizeChange((oldValue: SizeOptions, newValue: SizeOptions) => {
|
|
36
|
+
sizeChangeHandle(this.node, newValue)
|
|
37
|
+
})
|
|
38
|
+
.gesture(
|
|
39
|
+
PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
|
|
40
|
+
this.node.childNodes.forEach(item => {
|
|
41
|
+
if (isTaroMovableViewElement(item)) {
|
|
42
|
+
item.startScale()
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
}).onActionUpdate((event) => {
|
|
46
|
+
const scaleArea = this.node.getAttribute('scaleArea')
|
|
47
|
+
if (scaleArea) {
|
|
48
|
+
this.node.childNodes.forEach(item => {
|
|
49
|
+
if (isTaroMovableViewElement(item)) {
|
|
50
|
+
item.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, 0)
|
|
59
|
+
}
|
|
60
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
61
|
+
.clip(true)
|
|
62
|
+
.onSizeChange((oldValue: SizeOptions, newValue: SizeOptions) => {
|
|
63
|
+
sizeChangeHandle(this.node, newValue)
|
|
64
|
+
})
|
|
65
|
+
.gesture(
|
|
66
|
+
PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
|
|
67
|
+
this.node.childNodes.forEach(item => {
|
|
68
|
+
if (isTaroMovableViewElement(item)) {
|
|
69
|
+
item.startScale()
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
}).onActionUpdate((event) => {
|
|
73
|
+
const scaleArea = this.node.getAttribute('scaleArea')
|
|
74
|
+
if (scaleArea) {
|
|
75
|
+
this.node.childNodes.forEach(item => {
|
|
76
|
+
if (isTaroMovableViewElement(item)) {
|
|
77
|
+
item.doScale(event.scale)
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
)
|
|
83
|
+
} else {
|
|
84
|
+
Column() {
|
|
85
|
+
this.createLazyChildren(this.node, 0)
|
|
86
|
+
}
|
|
87
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
88
|
+
.clip(true)
|
|
89
|
+
.onSizeChange((oldValue: SizeOptions, newValue: SizeOptions) => {
|
|
90
|
+
sizeChangeHandle(this.node, newValue)
|
|
91
|
+
})
|
|
92
|
+
.gesture(
|
|
93
|
+
PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
|
|
94
|
+
this.node.childNodes.forEach(item => {
|
|
95
|
+
if (isTaroMovableViewElement(item)) {
|
|
96
|
+
item.startScale()
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
}).onActionUpdate((event) => {
|
|
100
|
+
const scaleArea = this.node.getAttribute('scaleArea')
|
|
101
|
+
if (scaleArea) {
|
|
102
|
+
this.node.childNodes.forEach(item => {
|
|
103
|
+
if (isTaroMovableViewElement(item)) {
|
|
104
|
+
item.doScale(event.scale)
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
function sizeChangeHandle(node: TaroMovableAreaElement, newValue: Area | SizeOptions) {
|
|
116
|
+
node.childNodes.forEach(item => {
|
|
117
|
+
if (isTaroMovableViewElement(item)) {
|
|
118
|
+
if (item.area?.w !== Number(newValue.width) || item.area?.h !== Number(newValue.height)) {
|
|
119
|
+
item.area = {
|
|
120
|
+
w: Number(newValue.width),
|
|
121
|
+
h: Number(newValue.height)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { TaroAny, TaroMovableViewElement, TaroElement } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import commonStyleModify, { rowModify, columnModify } from './style'
|
|
4
|
+
|
|
5
|
+
import { FlexManager } from './utils/flexManager'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@Component
|
|
10
|
+
export default struct TaroMovableView {
|
|
11
|
+
@Builder customBuilder() {}
|
|
12
|
+
@BuilderParam createLazyChildren: (node: TaroMovableViewElement, layer?: number) => void = this.customBuilder
|
|
13
|
+
@ObjectLink node: TaroMovableViewElement
|
|
14
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
15
|
+
|
|
16
|
+
aboutToAppear(): void {
|
|
17
|
+
if (this.node) {
|
|
18
|
+
this.node._instance = this
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
build() {
|
|
24
|
+
Stack() {
|
|
25
|
+
if (FlexManager.useFlexLayout(this.node)) {
|
|
26
|
+
Flex(FlexManager.flexOptions(this.node)) {
|
|
27
|
+
this.createLazyChildren(this.node, 0)
|
|
28
|
+
}
|
|
29
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
30
|
+
} else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
|
|
31
|
+
Row() {
|
|
32
|
+
this.createLazyChildren(this.node, 0)
|
|
33
|
+
}
|
|
34
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
35
|
+
} else {
|
|
36
|
+
Column() {
|
|
37
|
+
this.createLazyChildren(this.node, 0)
|
|
38
|
+
}
|
|
39
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
.translate({ x: this.node.position.x, y: this.node.position.y })
|
|
43
|
+
.scale({ x: this.node.scaleValue, y: this.node.scaleValue })
|
|
44
|
+
.onSizeChange((oldValue: SizeOptions, newValue: SizeOptions) => {
|
|
45
|
+
if (this.node.selfSize?.w !== Number(newValue.width) || this.node.selfSize?.h !== Number(newValue.height)) {
|
|
46
|
+
this.node.selfSize = { w: Number(newValue.width), h: Number(newValue.height) }
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
.visibility(this.node.visibility)
|
|
50
|
+
.gesture(
|
|
51
|
+
GestureGroup(GestureMode.Parallel,
|
|
52
|
+
PanGesture(getPanOption(this.node)).onActionStart((e: GestureEvent) => {
|
|
53
|
+
|
|
54
|
+
this.node.startMove()
|
|
55
|
+
this.node.callTouchEventFnFromGesture('touchstart', e)
|
|
56
|
+
}).onActionUpdate((e: GestureEvent) => {
|
|
57
|
+
this.node.callTouchEventFnFromGesture('touchmove', e)
|
|
58
|
+
this.node.doMove({
|
|
59
|
+
x: e.offsetX,
|
|
60
|
+
y: e.offsetY
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
}).onActionEnd((e: GestureEvent) => {
|
|
64
|
+
this.node.callTouchEventFnFromGesture('touchend', e)
|
|
65
|
+
this.node.checkPositionBoundary(this.node.position, this.node.scaleValue)
|
|
66
|
+
}),
|
|
67
|
+
PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
|
|
68
|
+
this.node.startScale()
|
|
69
|
+
}).onActionUpdate((event) => {
|
|
70
|
+
this.node.doScale(event.scale)
|
|
71
|
+
})
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
function getPanOption(node: TaroMovableViewElement) {
|
|
79
|
+
const attrDirection = node.getAttribute('direction')
|
|
80
|
+
let panDirection = PanDirection.All
|
|
81
|
+
|
|
82
|
+
if(node.getAttribute('disabled')) {
|
|
83
|
+
panDirection = PanDirection.None
|
|
84
|
+
} else if(attrDirection === 'horizontal') {
|
|
85
|
+
panDirection = PanDirection.Horizontal
|
|
86
|
+
} else if (attrDirection === 'vertical') {
|
|
87
|
+
panDirection = PanDirection.Vertical
|
|
88
|
+
}
|
|
89
|
+
return new PanGestureOptions({
|
|
90
|
+
direction: panDirection,
|
|
91
|
+
fingers: 1
|
|
92
|
+
})
|
|
93
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { eventCenter } from '@tarojs/runtime/dist/runtime.esm'
|
|
2
|
+
|
|
3
|
+
import { isTagFirstChild } from './utils/helper'
|
|
4
|
+
|
|
5
|
+
import type { TaroAny, TaroNavigationBarElement } from '@tarojs/runtime'
|
|
6
|
+
import type { IComponentAttributeUpdateEvents } from './pageMeta'
|
|
7
|
+
|
|
8
|
+
@Component
|
|
9
|
+
export default struct TaroNavigationBar {
|
|
10
|
+
@Builder customBuilder() {}
|
|
11
|
+
@BuilderParam createLazyChildren: (node: TaroNavigationBarElement, layer?: number) => void = this.customBuilder
|
|
12
|
+
@ObjectLink node: TaroNavigationBarElement
|
|
13
|
+
|
|
14
|
+
aboutToAppear(): void {
|
|
15
|
+
if (!isTagFirstChild(this.node, 'page-meta')) {
|
|
16
|
+
console.error('NavigationBar 只能是 PageMeta 内的第一个节点。')
|
|
17
|
+
}
|
|
18
|
+
if (this.node) {
|
|
19
|
+
this.node._instance = this
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// FIXME 在 Harmony 提供 @Watch 文档后,根据 node 实际使用更细粒度的监听
|
|
23
|
+
eventCenter?.on('__taroComponentAttributeUpdate', this.handleAttributeUpdate)
|
|
24
|
+
this.handleAttributes(this.node._attrs)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
aboutToDisappear(): void {
|
|
28
|
+
eventCenter?.off('__taroComponentAttributeUpdate', this.handleAttributeUpdate)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
handleAttributeUpdate = (opt: IComponentAttributeUpdateEvents) => {
|
|
32
|
+
if (opt.id === this.node._nid.toString() && opt.tagName === 'NAVIGATION-BAR') {
|
|
33
|
+
const attrs: Record<string, TaroAny> = {}
|
|
34
|
+
attrs[opt.attribute] = opt.value
|
|
35
|
+
this.handleAttributes(attrs)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
handleAttributes (attrs: Record<string, TaroAny>) {
|
|
40
|
+
const options: Record<string, TaroAny> = {}
|
|
41
|
+
|
|
42
|
+
if (attrs.title) {
|
|
43
|
+
options.title = attrs.title
|
|
44
|
+
}
|
|
45
|
+
if (attrs.loading) {
|
|
46
|
+
options.loading = attrs.loading
|
|
47
|
+
}
|
|
48
|
+
if (attrs.backgroundColor) {
|
|
49
|
+
options.backgroundColor = attrs.backgroundColor
|
|
50
|
+
}
|
|
51
|
+
if (attrs.frontColor) {
|
|
52
|
+
options.frontColor = attrs.frontColor
|
|
53
|
+
}
|
|
54
|
+
eventCenter?.trigger('__taroNavigationStyle', options)
|
|
55
|
+
// FIXME: 以下属性暂时不支持
|
|
56
|
+
// attrs.colorAnimationDuration
|
|
57
|
+
// attrs.colorAnimationTimingFunc
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
build() {
|
|
61
|
+
if (true) {
|
|
62
|
+
this.createLazyChildren(this.node, 0)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { APP, eventCenter } from '@tarojs/runtime/dist/runtime.esm'
|
|
2
|
+
import { getCurrentInstance, pageScrollTo } from '@tarojs/taro'
|
|
3
|
+
|
|
4
|
+
import { isTagFirstChild } from './utils/helper'
|
|
5
|
+
|
|
6
|
+
import type { TaroAny, TaroPageMetaElement } from '@tarojs/runtime'
|
|
7
|
+
|
|
8
|
+
export interface IComponentAttributeUpdateEvents {
|
|
9
|
+
id: string
|
|
10
|
+
tagName: string
|
|
11
|
+
attribute: string
|
|
12
|
+
value: TaroAny
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@Component
|
|
16
|
+
export default struct TaroPageMeta {
|
|
17
|
+
@Builder customBuilder() {}
|
|
18
|
+
@BuilderParam createLazyChildren: (node: TaroPageMetaElement, layer?: number) => void = this.customBuilder
|
|
19
|
+
@ObjectLink node: TaroPageMetaElement
|
|
20
|
+
|
|
21
|
+
page: TaroAny = {}
|
|
22
|
+
|
|
23
|
+
aboutToAppear(): void {
|
|
24
|
+
if (!isTagFirstChild(this.node, APP, 2)) {
|
|
25
|
+
// PageMeta 只能是页面内的第一个元素
|
|
26
|
+
console.error('PageMeta 只能是页面内的第一个元素。')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
this.page = getCurrentInstance().page
|
|
30
|
+
if (this.node) {
|
|
31
|
+
this.node._instance = this
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// FIXME 在 Harmony 提供 @Watch 文档后,根据 node 实际使用更细粒度的监听
|
|
35
|
+
eventCenter?.on('__taroComponentAttributeUpdate', this.handleAttributeUpdate)
|
|
36
|
+
this.handleAttributes(this.node._attrs)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
aboutToDisappear(): void {
|
|
40
|
+
eventCenter?.off('__taroComponentAttributeUpdate', this.handleAttributeUpdate)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
handleAttributeUpdate = (opt: IComponentAttributeUpdateEvents) => {
|
|
44
|
+
if (opt.id === this.node._nid.toString() && opt.tagName === 'PAGE-META') {
|
|
45
|
+
const attrs: Record<string, TaroAny> = {}
|
|
46
|
+
attrs[opt.attribute] = opt.value
|
|
47
|
+
this.handleAttributes(attrs)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
handleAttributes (attrs: Record<string, TaroAny>) {
|
|
52
|
+
const options: Record<string, TaroAny> = {}
|
|
53
|
+
let triggerStyleEvent = false
|
|
54
|
+
|
|
55
|
+
// FIXME 更新类型支持度
|
|
56
|
+
if (attrs.backgroundColorTop || attrs.rootBackgroundColor || attrs.backgroundColor) {
|
|
57
|
+
options.backgroundColorContext = attrs.backgroundColorTop || attrs.rootBackgroundColor || attrs.backgroundColor
|
|
58
|
+
triggerStyleEvent = true
|
|
59
|
+
}
|
|
60
|
+
if (attrs.backgroundColorBottom || attrs.backgroundColor) {
|
|
61
|
+
options.backgroundColor = attrs.backgroundColorBottom || attrs.backgroundColor
|
|
62
|
+
triggerStyleEvent = true
|
|
63
|
+
}
|
|
64
|
+
if (attrs.backgroundTextStyle) {
|
|
65
|
+
options.backgroundTextStyle = attrs.backgroundTextStyle
|
|
66
|
+
triggerStyleEvent = true
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (this.page === getCurrentInstance().page) {
|
|
70
|
+
if (attrs.scrollTop || attrs.scrollDuration) {
|
|
71
|
+
pageScrollTo({
|
|
72
|
+
scrollTop: attrs.scrollTop || this.node._attrs.scrollTop,
|
|
73
|
+
duration: attrs.scrollDuration || this.node._attrs.scrollDuration,
|
|
74
|
+
} as TaroAny)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// pageStyle
|
|
78
|
+
// rootFontSize
|
|
79
|
+
// pageFontSize
|
|
80
|
+
// pageOrientation
|
|
81
|
+
if (triggerStyleEvent) {
|
|
82
|
+
eventCenter?.trigger('__taroPageStyle', options)
|
|
83
|
+
}
|
|
84
|
+
// onResize
|
|
85
|
+
// onScroll
|
|
86
|
+
// onScrollDone
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
build() {
|
|
90
|
+
if (true) {
|
|
91
|
+
this.createLazyChildren(this.node, 0)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|