@tarojs/plugin-platform-harmony-ets 4.0.0-beta.2 → 4.0.0-beta.21
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/framework/index.ts +1 -5
- package/dist/apis/index.ts +3 -1
- package/dist/apis/network/request.ts +5 -5
- package/dist/apis/route/index.ts +15 -0
- package/dist/apis/storage/index.ts +124 -60
- package/dist/apis/wxml/IntersectionObserver.ts +5 -3
- package/dist/apis/wxml/index.ts +2 -0
- package/dist/components-harmony-ets/button.ets +41 -78
- package/dist/components-harmony-ets/checkbox.ets +19 -209
- package/dist/components-harmony-ets/form.ets +38 -160
- package/dist/components-harmony-ets/icon.ets +31 -83
- package/dist/components-harmony-ets/image.ets +22 -78
- package/dist/components-harmony-ets/innerHtml.ets +11 -6
- package/dist/components-harmony-ets/input.ets +10 -67
- package/dist/components-harmony-ets/label.ets +52 -173
- package/dist/components-harmony-ets/movableArea.ets +89 -0
- package/dist/components-harmony-ets/movableView.ets +67 -0
- package/dist/components-harmony-ets/picker.ets +32 -147
- package/dist/components-harmony-ets/progress.ets +47 -0
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +19 -210
- package/dist/components-harmony-ets/richText.ets +22 -102
- package/dist/components-harmony-ets/scrollView.ets +66 -169
- package/dist/components-harmony-ets/slider.ets +10 -72
- package/dist/components-harmony-ets/style.ets +244 -0
- package/dist/components-harmony-ets/swiper.ets +30 -87
- package/dist/components-harmony-ets/switch.ets +9 -71
- package/dist/components-harmony-ets/text.ets +38 -89
- package/dist/components-harmony-ets/textArea.ets +10 -67
- 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 +8 -7
- package/dist/components-harmony-ets/utils/helper.ets +5 -4
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
- package/dist/components-harmony-ets/utils/index.ts +55 -2
- package/dist/components-harmony-ets/utils/styles.ets +45 -85
- package/dist/components-harmony-ets/video.ets +33 -88
- package/dist/components-harmony-ets/view.ets +47 -160
- package/dist/components-harmony-ets/webView.ets +44 -99
- package/dist/index.d.ts +151 -0
- package/dist/index.js +58 -29
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/window.ts +4 -2
- package/dist/runtime-ets/current.ts +2 -0
- package/dist/runtime-ets/dom/bind.ts +0 -1
- package/dist/runtime-ets/dom/cssNesting.ts +311 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +15 -40
- package/dist/runtime-ets/dom/document.ts +21 -8
- package/dist/runtime-ets/dom/element/element.ts +53 -9
- package/dist/runtime-ets/dom/element/form.ts +11 -4
- package/dist/runtime-ets/dom/element/index.ts +12 -1
- 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 +8 -3
- 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/event.ts +0 -1
- package/dist/runtime-ets/dom/eventTarget.ts +0 -3
- package/dist/runtime-ets/dom/node.ts +18 -17
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +184 -207
- package/dist/runtime-ets/dom/stylesheet/index.ts +28 -308
- package/dist/runtime-ets/dom/stylesheet/type.ts +18 -6
- package/dist/runtime-ets/dom/stylesheet/util.ts +19 -15
- package/dist/runtime-ets/index.ts +2 -2
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/utils/index.ts +24 -9
- package/dist/runtime-framework/react/app.ts +5 -1
- package/dist/runtime-framework/react/hooks.ts +3 -3
- package/dist/runtime-framework/react/native-page.ts +14 -9
- package/dist/runtime-framework/react/page.ts +1 -0
- package/dist/runtime-framework/solid/hooks.ts +3 -3
- package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
- package/dist/runtime-framework/solid/utils/index.ts +0 -2
- package/dist/runtime-utils.d.ts +825 -0
- package/dist/runtime-utils.js +185 -91
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +185 -91
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +10 -10
- package/types/index.d.ts +4 -0
- package/dist/runtime-ets/utils/bind.ts +0 -24
|
@@ -1,73 +1,9 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
4
5
|
|
|
5
|
-
import type { TaroImageElement, TaroAny
|
|
6
|
-
|
|
7
|
-
@Extend(Image)
|
|
8
|
-
function attrs (style: TaroStyleType) {
|
|
9
|
-
.id(style.id)
|
|
10
|
-
.key(style.id)
|
|
11
|
-
.flexGrow(style.flexGrow)
|
|
12
|
-
.flexShrink(style.flexShrink)
|
|
13
|
-
.flexBasis(style.flexBasis)
|
|
14
|
-
.alignSelf(style.alignSelf)
|
|
15
|
-
.padding({
|
|
16
|
-
top: style.paddingTop,
|
|
17
|
-
right: style.paddingRight,
|
|
18
|
-
bottom: style.paddingBottom,
|
|
19
|
-
left: style.paddingLeft
|
|
20
|
-
})
|
|
21
|
-
.margin({
|
|
22
|
-
top: style.marginTop,
|
|
23
|
-
right: style.marginRight,
|
|
24
|
-
bottom: style.marginBottom,
|
|
25
|
-
left: style.marginLeft
|
|
26
|
-
})
|
|
27
|
-
.width(style.width)
|
|
28
|
-
.height(style.height)
|
|
29
|
-
.constraintSize({
|
|
30
|
-
minWidth: style.minWidth,
|
|
31
|
-
maxWidth: style.maxWidth,
|
|
32
|
-
minHeight: style.minHeight,
|
|
33
|
-
maxHeight: style.maxHeight
|
|
34
|
-
})
|
|
35
|
-
.backgroundColor(style.backgroundColor)
|
|
36
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
37
|
-
.backgroundImageSize(style.backgroundSize)
|
|
38
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
39
|
-
.borderStyle({
|
|
40
|
-
top: style.borderTopStyle,
|
|
41
|
-
right: style.borderRightStyle,
|
|
42
|
-
bottom: style.borderBottomStyle,
|
|
43
|
-
left: style.borderLeftStyle
|
|
44
|
-
})
|
|
45
|
-
.borderWidth({
|
|
46
|
-
top: style.borderTopWidth,
|
|
47
|
-
right: style.borderRightWidth,
|
|
48
|
-
bottom: style.borderBottomWidth,
|
|
49
|
-
left: style.borderLeftWidth
|
|
50
|
-
})
|
|
51
|
-
.borderColor({
|
|
52
|
-
top: style.borderTopColor,
|
|
53
|
-
right: style.borderRightColor,
|
|
54
|
-
bottom: style.borderBottomColor,
|
|
55
|
-
left: style.borderLeftColor
|
|
56
|
-
})
|
|
57
|
-
.borderRadius({
|
|
58
|
-
topLeft: style.borderTopLeftRadius,
|
|
59
|
-
topRight: style.borderTopRightRadius,
|
|
60
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
61
|
-
bottomRight: style.borderBottomRightRadius
|
|
62
|
-
})
|
|
63
|
-
.zIndex(style.zIndex)
|
|
64
|
-
.opacity(style.opacity)
|
|
65
|
-
.linearGradient(style.linearGradient)
|
|
66
|
-
.clip(style.overflow)
|
|
67
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
68
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
69
|
-
.transform(style.transform)
|
|
70
|
-
}
|
|
6
|
+
import type { TaroImageElement, TaroAny } from '@tarojs/runtime'
|
|
71
7
|
|
|
72
8
|
function getImageMode (mode: string): ImageFit {
|
|
73
9
|
switch (mode) {
|
|
@@ -80,15 +16,23 @@ function getImageMode (mode: string): ImageFit {
|
|
|
80
16
|
}
|
|
81
17
|
}
|
|
82
18
|
|
|
83
|
-
@
|
|
84
|
-
export default
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
19
|
+
@Component
|
|
20
|
+
export default struct TaroImage {
|
|
21
|
+
@Builder customBuilder() {}
|
|
22
|
+
@BuilderParam createLazyChildren: (node: TaroImageElement) => void = this.customBuilder
|
|
23
|
+
@ObjectLink node: TaroImageElement
|
|
24
|
+
|
|
25
|
+
build() {
|
|
26
|
+
if (this.node?.hmStyle?.display !== 'none') {
|
|
27
|
+
Image(this.node.getAttribute('src'))
|
|
28
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
29
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
30
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
31
|
+
}))
|
|
32
|
+
.objectFit(getImageMode(this.node.getAttribute('mode')))
|
|
33
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
34
|
+
.onComplete(e => eventHandler(e, 'complete', this.node))
|
|
35
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
36
|
+
}
|
|
37
|
+
}
|
|
94
38
|
}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import htmlParser from './utils/htmlParser'
|
|
2
|
-
import { createChildItemWithPosition } from './render'
|
|
3
2
|
|
|
4
|
-
import type { TaroElement } from '@tarojs/runtime'
|
|
3
|
+
import type { TaroElement, TaroInnerHtmlElement } from '@tarojs/runtime'
|
|
5
4
|
|
|
6
|
-
@
|
|
7
|
-
export default
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
@Component
|
|
6
|
+
export default struct TaroInnerHtml {
|
|
7
|
+
@Builder customBuilder() {}
|
|
8
|
+
@BuilderParam createChildItem: (node: TaroElement, callback?: (node: TaroElement) => void) => void = this.customBuilder
|
|
9
|
+
@ObjectLink node: TaroInnerHtmlElement
|
|
10
|
+
|
|
11
|
+
build() {
|
|
12
|
+
if (this.node?.hmStyle?.display !== 'none' && this.node.innerHTML) {
|
|
13
|
+
this.createChildItem(htmlParser(this.node.innerHTML))
|
|
14
|
+
}
|
|
10
15
|
}
|
|
11
16
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { parseStyles, shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
4
5
|
import { INPUT_TYPE_MAP, INPUT_CONFIRM_MAP } from './utils/constant/style'
|
|
5
6
|
|
|
6
7
|
import type { TaroStyleType, TaroAny, TaroInputElement, TaroEvent } from '@tarojs/runtime'
|
|
@@ -11,67 +12,6 @@ interface InputAttrs {
|
|
|
11
12
|
|
|
12
13
|
@Extend(TextInput)
|
|
13
14
|
function styles (style: TaroStyleType) {
|
|
14
|
-
.id(style.id)
|
|
15
|
-
.key(style.id)
|
|
16
|
-
.flexGrow(style.flexGrow)
|
|
17
|
-
.flexShrink(style.flexShrink)
|
|
18
|
-
.flexBasis(style.flexBasis)
|
|
19
|
-
.alignSelf(style.alignSelf)
|
|
20
|
-
.padding({
|
|
21
|
-
top: style.paddingTop,
|
|
22
|
-
right: style.paddingRight,
|
|
23
|
-
bottom: style.paddingBottom,
|
|
24
|
-
left: style.paddingLeft
|
|
25
|
-
})
|
|
26
|
-
.margin({
|
|
27
|
-
top: style.marginTop,
|
|
28
|
-
right: style.marginRight,
|
|
29
|
-
bottom: style.marginBottom,
|
|
30
|
-
left: style.marginLeft
|
|
31
|
-
})
|
|
32
|
-
.width(style.width)
|
|
33
|
-
.height(style.height)
|
|
34
|
-
.constraintSize({
|
|
35
|
-
minWidth: style.minWidth,
|
|
36
|
-
maxWidth: style.maxWidth,
|
|
37
|
-
minHeight: style.minHeight,
|
|
38
|
-
maxHeight: style.maxHeight
|
|
39
|
-
})
|
|
40
|
-
.backgroundColor(style.backgroundColor)
|
|
41
|
-
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
42
|
-
.backgroundImageSize(style.backgroundSize)
|
|
43
|
-
.backgroundImagePosition(style.backgroundPosition)
|
|
44
|
-
.borderStyle({
|
|
45
|
-
top: style.borderTopStyle,
|
|
46
|
-
right: style.borderRightStyle,
|
|
47
|
-
bottom: style.borderBottomStyle,
|
|
48
|
-
left: style.borderLeftStyle
|
|
49
|
-
})
|
|
50
|
-
.borderWidth({
|
|
51
|
-
top: style.borderTopWidth,
|
|
52
|
-
right: style.borderRightWidth,
|
|
53
|
-
bottom: style.borderBottomWidth,
|
|
54
|
-
left: style.borderLeftWidth
|
|
55
|
-
})
|
|
56
|
-
.borderColor({
|
|
57
|
-
top: style.borderTopColor,
|
|
58
|
-
right: style.borderRightColor,
|
|
59
|
-
bottom: style.borderBottomColor,
|
|
60
|
-
left: style.borderLeftColor
|
|
61
|
-
})
|
|
62
|
-
.borderRadius({
|
|
63
|
-
topLeft: style.borderTopLeftRadius,
|
|
64
|
-
topRight: style.borderTopRightRadius,
|
|
65
|
-
bottomLeft: style.borderBottomLeftRadius,
|
|
66
|
-
bottomRight: style.borderBottomRightRadius
|
|
67
|
-
})
|
|
68
|
-
.zIndex(style.zIndex)
|
|
69
|
-
.opacity(style.opacity)
|
|
70
|
-
.linearGradient(style.linearGradient)
|
|
71
|
-
.clip(style.overflow)
|
|
72
|
-
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
73
|
-
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
74
|
-
.transform(style.transform)
|
|
75
15
|
.fontColor(style.color)
|
|
76
16
|
.fontSize(style.fontSize)
|
|
77
17
|
.fontWeight(style.fontWeight)
|
|
@@ -108,7 +48,9 @@ function getPlaceholderColor (node: TaroInputElement): string {
|
|
|
108
48
|
export default struct TaroInput {
|
|
109
49
|
@State value: string = ''
|
|
110
50
|
|
|
111
|
-
|
|
51
|
+
@Builder customBuilder() {}
|
|
52
|
+
@BuilderParam createLazyChildren: (node: TaroInputElement) => void = this.customBuilder
|
|
53
|
+
@ObjectLink node: TaroInputElement
|
|
112
54
|
|
|
113
55
|
aboutToAppear () {
|
|
114
56
|
if (this.node) {
|
|
@@ -123,18 +65,19 @@ export default struct TaroInput {
|
|
|
123
65
|
}
|
|
124
66
|
|
|
125
67
|
build () {
|
|
126
|
-
if (this.node) {
|
|
68
|
+
if (this.node && this.node?.hmStyle?.display !== 'none') {
|
|
127
69
|
TextInput({ text: this.value, placeholder: this.node._attrs?.placeholder || '', controller: this.node.controller })
|
|
128
70
|
.key(this.node._nid)
|
|
129
71
|
.type(getInputType(this.node))
|
|
130
72
|
.maxLength(Number(this.node._attrs?.maxlength) || null)
|
|
131
73
|
.placeholderColor(getPlaceholderColor(this.node))
|
|
132
74
|
.enterKeyType(INPUT_CONFIRM_MAP.get(this.node._attrs?.confirmType) || EnterKeyType.Done)
|
|
133
|
-
.
|
|
75
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
76
|
+
.styles(this.node?.hmStyle)
|
|
134
77
|
.attrs(getAttributes(this.node))
|
|
135
78
|
.onChange((value: string) => {
|
|
136
79
|
const event: TaroEvent = createTaroEvent('input', { detail: { value } }, this.node)
|
|
137
|
-
|
|
80
|
+
|
|
138
81
|
this.value = value
|
|
139
82
|
this.node?.updateFormWidgetValue(value)
|
|
140
83
|
eventHandler(event, 'input', this.node)
|
|
@@ -150,7 +93,7 @@ export default struct TaroInput {
|
|
|
150
93
|
})
|
|
151
94
|
.onFocus(() => {
|
|
152
95
|
const event: TaroEvent = createTaroEvent('focus', { detail: { value: this.value, height: this.node?._height } }, this.node)
|
|
153
|
-
|
|
96
|
+
|
|
154
97
|
eventHandler(event, 'focus', this.node)
|
|
155
98
|
})
|
|
156
99
|
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
@@ -1,141 +1,11 @@
|
|
|
1
1
|
import { Current, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, getPageScrollerOrNode, AREA_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
4
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
5
|
-
import { FlexManager } from './utils/
|
|
6
|
-
import {
|
|
5
|
+
import { FlexManager } from './utils/flexManager'
|
|
6
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
7
7
|
|
|
8
|
-
import type {
|
|
9
|
-
|
|
10
|
-
@Extend(Column)
|
|
11
|
-
function columnAttrs (style: TaroStyleType) {
|
|
12
|
-
.id(style.id)
|
|
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
|
-
}
|
|
74
|
-
|
|
75
|
-
@Extend(Row)
|
|
76
|
-
function rowAttrs (style: TaroStyleType) {
|
|
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
|
-
}
|
|
8
|
+
import type { TaroLabelElement, TaroElement, TaroAny, TaroRadioElement, TaroCheckboxElement } from '@tarojs/runtime'
|
|
139
9
|
|
|
140
10
|
function handleTargetChange (id: string) {
|
|
141
11
|
const taro: TaroAny = Current.taro
|
|
@@ -163,45 +33,54 @@ function handleTargetChange (id: string) {
|
|
|
163
33
|
}
|
|
164
34
|
}
|
|
165
35
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
36
|
+
|
|
37
|
+
@Component
|
|
38
|
+
export default struct TaroLabel {
|
|
39
|
+
@Builder customBuilder() {}
|
|
40
|
+
@BuilderParam createLazyChildren: (node:TaroLabelElement) => void = this.customBuilder
|
|
41
|
+
@ObjectLink node:TaroLabelElement
|
|
42
|
+
|
|
43
|
+
build() {
|
|
44
|
+
if (this.node?.hmStyle?.display !== 'none') {
|
|
45
|
+
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
46
|
+
Row() {
|
|
47
|
+
this.createLazyChildren(this.node)
|
|
48
|
+
}
|
|
49
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
50
|
+
.onClick((e: ClickEvent) => {
|
|
51
|
+
const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
|
|
52
|
+
const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
|
|
53
|
+
|
|
54
|
+
handleTargetChange(id)
|
|
55
|
+
eventHandler(e, 'click', this.node)
|
|
56
|
+
})
|
|
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 VerticalAlign)
|
|
63
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
64
|
+
} else {
|
|
65
|
+
Column() {
|
|
66
|
+
this.createLazyChildren(this.node)
|
|
67
|
+
}
|
|
68
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
69
|
+
.onClick((e: ClickEvent) => {
|
|
70
|
+
const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
|
|
71
|
+
const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
|
|
72
|
+
|
|
73
|
+
handleTargetChange(id)
|
|
74
|
+
eventHandler(e, 'click', this.node)
|
|
75
|
+
})
|
|
76
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
77
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
78
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
79
|
+
}))
|
|
80
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
81
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
82
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
83
|
+
}
|
|
190
84
|
}
|
|
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
85
|
}
|
|
207
86
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { TaroMovableAreaElement, TaroMovableViewElement} from '@tarojs/runtime'
|
|
2
|
+
import { rowModify, columnModify } from './style'
|
|
3
|
+
|
|
4
|
+
import { FlexManager } from './utils/flexManager'
|
|
5
|
+
|
|
6
|
+
@Component
|
|
7
|
+
export default struct TaroMovableArea {
|
|
8
|
+
@Builder customBuilder() {}
|
|
9
|
+
@BuilderParam createLazyChildren: (node: TaroMovableAreaElement) => void = this.customBuilder
|
|
10
|
+
@ObjectLink node: TaroMovableAreaElement
|
|
11
|
+
|
|
12
|
+
build() {
|
|
13
|
+
if (this.node && this.node.hmStyle?.display !== 'none') {
|
|
14
|
+
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
15
|
+
Row() {
|
|
16
|
+
this.createLazyChildren(this.node)
|
|
17
|
+
}
|
|
18
|
+
.attributeModifier(rowModify.setNode(this.node))
|
|
19
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
20
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
21
|
+
.clip(true)
|
|
22
|
+
.onAreaChange((oldValue: Area, newValue: Area) => {
|
|
23
|
+
this.node.childNodes.forEach(item => {
|
|
24
|
+
if(item.nodeName === 'MOVABLE-VIEW') {
|
|
25
|
+
;(item as TaroMovableViewElement).area = {
|
|
26
|
+
w: Number( newValue.width),
|
|
27
|
+
h: Number(newValue.height)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
.gesture(
|
|
33
|
+
PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
|
|
34
|
+
this.node.childNodes.forEach(item => {
|
|
35
|
+
if(item.nodeName === 'MOVABLE-VIEW') {
|
|
36
|
+
;(item as TaroMovableViewElement).startScale()
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
}).onActionUpdate((event) => {
|
|
40
|
+
const scaleArea = this.node.getAttribute('scaleArea')
|
|
41
|
+
if (scaleArea) {
|
|
42
|
+
this.node.childNodes.forEach(item => {
|
|
43
|
+
if(item.nodeName === 'MOVABLE-VIEW') {
|
|
44
|
+
;(item as TaroMovableViewElement).doScale(event.scale)
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
)
|
|
50
|
+
} else {
|
|
51
|
+
Column() {
|
|
52
|
+
this.createLazyChildren(this.node)
|
|
53
|
+
}
|
|
54
|
+
.attributeModifier(columnModify.setNode(this.node))
|
|
55
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
56
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
57
|
+
.clip(true)
|
|
58
|
+
.onAreaChange((oldValue: Area, newValue: Area) => {
|
|
59
|
+
this.node.childNodes.forEach(item => {
|
|
60
|
+
if(item.nodeName === 'MOVABLE-VIEW') {
|
|
61
|
+
;(item as TaroMovableViewElement).area = {
|
|
62
|
+
w: Number( newValue.width),
|
|
63
|
+
h: Number(newValue.height)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
.gesture(
|
|
69
|
+
PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
|
|
70
|
+
this.node.childNodes.forEach(item => {
|
|
71
|
+
if(item.nodeName === 'MOVABLE-VIEW') {
|
|
72
|
+
;(item as TaroMovableViewElement).startScale()
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
}).onActionUpdate((event) => {
|
|
76
|
+
const scaleArea = this.node.getAttribute('scaleArea')
|
|
77
|
+
if (scaleArea) {
|
|
78
|
+
this.node.childNodes.forEach(item => {
|
|
79
|
+
if(item.nodeName === 'MOVABLE-VIEW') {
|
|
80
|
+
;(item as TaroMovableViewElement).doScale(event.scale)
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { TaroMovableViewElement } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import { rowModify, columnModify } from './style'
|
|
4
|
+
|
|
5
|
+
import { FlexManager } from './utils/flexManager'
|
|
6
|
+
|
|
7
|
+
@Component
|
|
8
|
+
export default struct TaroMovableView {
|
|
9
|
+
@Builder customBuilder() {}
|
|
10
|
+
@BuilderParam createLazyChildren: (node: TaroMovableViewElement) => void = this.customBuilder
|
|
11
|
+
@ObjectLink node: TaroMovableViewElement
|
|
12
|
+
|
|
13
|
+
build() {
|
|
14
|
+
if (this.node && this.node.hmStyle?.display !== 'none') {
|
|
15
|
+
Stack() {
|
|
16
|
+
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node)
|
|
17
|
+
.direction !== FlexDirection.Column) {
|
|
18
|
+
Row() {
|
|
19
|
+
this.createLazyChildren(this.node)
|
|
20
|
+
}
|
|
21
|
+
.attributeModifier(rowModify.setNode(this.node))
|
|
22
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
23
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
24
|
+
} else {
|
|
25
|
+
Column() {
|
|
26
|
+
this.createLazyChildren(this.node)
|
|
27
|
+
}
|
|
28
|
+
.attributeModifier(columnModify.setNode(this.node))
|
|
29
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
30
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
.translate({ x: this.node.position.x, y: this.node.position.y })
|
|
34
|
+
.scale({ x: this.node.scaleValue, y: this.node.scaleValue })
|
|
35
|
+
.onAreaChange((oldValue: Area, newValue: Area) => {
|
|
36
|
+
this.node.selfSize = {w: Number(newValue.width), h: Number(newValue.height)}
|
|
37
|
+
})
|
|
38
|
+
.gesture(
|
|
39
|
+
GestureGroup(GestureMode.Exclusive,
|
|
40
|
+
PanGesture({fingers:1}).onActionStart((e: GestureEvent) => {
|
|
41
|
+
|
|
42
|
+
this.node.startMove()
|
|
43
|
+
}).onActionUpdate((e: GestureEvent) => {
|
|
44
|
+
|
|
45
|
+
this.node.doMove({
|
|
46
|
+
x: e.offsetX,
|
|
47
|
+
y: e.offsetY
|
|
48
|
+
})
|
|
49
|
+
// 事件处理
|
|
50
|
+
const bindchange = this.node.getAttribute('bindchange')
|
|
51
|
+
if (typeof bindchange === 'function') {
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
}).onActionEnd(() => {
|
|
55
|
+
// this.updatePosition()
|
|
56
|
+
this.node.checkPositionBoundary(this.node.position, this.node.scaleValue)
|
|
57
|
+
}),
|
|
58
|
+
PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
|
|
59
|
+
this.node.startScale()
|
|
60
|
+
}).onActionUpdate((event) => {
|
|
61
|
+
this.node.doScale(event.scale)
|
|
62
|
+
})
|
|
63
|
+
)
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|