@tarojs/plugin-platform-harmony-ets 4.0.0-alpha.0 → 4.0.0-alpha.10
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 +16 -8
- package/dist/apis/device/memory.ts +10 -3
- package/dist/apis/framework/index.ts +1 -5
- package/dist/apis/index.ts +27 -17
- package/dist/apis/media/image/index.ts +1 -1
- package/dist/apis/media/video/VideoContext.ts +56 -7
- package/dist/apis/media/video/index.ts +3 -2
- 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 +42 -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 +1 -1
- 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 +68 -68
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +81 -102
- package/dist/components-harmony-ets/form.ets +54 -45
- package/dist/components-harmony-ets/icon.ets +34 -50
- package/dist/components-harmony-ets/image.ets +35 -45
- 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 +51 -67
- package/dist/components-harmony-ets/label.ets +73 -53
- package/dist/components-harmony-ets/listView.ets +26 -0
- package/dist/components-harmony-ets/movableArea.ets +124 -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 +74 -77
- 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 +82 -104
- package/dist/components-harmony-ets/richText.ets +20 -68
- package/dist/components-harmony-ets/scrollList.ets +94 -0
- package/dist/components-harmony-ets/scrollView.ets +67 -103
- package/dist/components-harmony-ets/slider.ets +23 -47
- package/dist/components-harmony-ets/stickySection.ets +42 -0
- package/dist/components-harmony-ets/style.ets +396 -0
- package/dist/components-harmony-ets/swiper.ets +64 -53
- package/dist/components-harmony-ets/switch.ets +44 -55
- package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
- package/dist/components-harmony-ets/text.ets +134 -75
- package/dist/components-harmony-ets/textArea.ets +54 -62
- package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +4 -13
- package/dist/components-harmony-ets/utils/flexManager.ets +76 -8
- package/dist/components-harmony-ets/utils/helper.ets +20 -7
- 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 +178 -63
- package/dist/components-harmony-ets/video.ets +37 -54
- package/dist/components-harmony-ets/view.ets +63 -94
- package/dist/components-harmony-ets/webView.ets +56 -0
- package/dist/index.d.ts +152 -0
- package/dist/index.js +199 -58
- 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 +3 -0
- 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 +409 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +29 -19
- 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 +334 -57
- package/dist/runtime-ets/dom/element/form.ts +32 -26
- package/dist/runtime-ets/dom/element/index.ts +33 -2
- package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
- package/dist/runtime-ets/dom/element/movableView.ts +242 -0
- package/dist/runtime-ets/dom/element/normal.ts +36 -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 +68 -0
- package/dist/runtime-ets/dom/event.ts +2 -4
- package/dist/runtime-ets/dom/eventTarget.ts +2 -3
- package/dist/runtime-ets/dom/node.ts +62 -27
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +805 -0
- package/dist/runtime-ets/dom/stylesheet/index.ts +98 -518
- package/dist/runtime-ets/dom/stylesheet/type.ts +92 -17
- package/dist/runtime-ets/dom/stylesheet/util.ts +74 -16
- package/dist/runtime-ets/index.ts +2 -2
- package/dist/runtime-ets/interface/event.ts +3 -2
- package/dist/runtime-ets/utils/index.ts +77 -12
- package/dist/runtime-ets/utils/info.ts +4 -2
- package/dist/runtime-framework/react/app.ts +17 -22
- package/dist/runtime-framework/react/hooks.ts +3 -4
- package/dist/runtime-framework/react/index.ts +1 -2
- package/dist/runtime-framework/react/native-page.ts +421 -0
- package/dist/runtime-framework/react/page.ts +4 -9
- 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 +17 -12
- 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 +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 +0 -2
- package/dist/runtime-utils.d.ts +827 -0
- package/dist/runtime-utils.js +510 -237
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +510 -237
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +14 -15
- package/static/media/cancel.svg +1 -0
- package/static/media/circle.svg +1 -0
- package/static/media/clear.svg +1 -0
- package/static/media/download.svg +1 -0
- package/static/media/info.svg +1 -0
- package/static/media/info_circle.svg +1 -0
- package/static/media/search.svg +1 -0
- package/static/media/success.svg +1 -0
- package/static/media/success_no_circle.svg +1 -0
- package/static/media/taro_arrow_left.svg +1 -0
- package/static/media/taro_home.svg +1 -0
- package/static/media/waiting.svg +1 -0
- package/static/media/warn.svg +1 -0
- package/types/harmony.d.ts +4 -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,10 +1,11 @@
|
|
|
1
1
|
import { createTaroEvent, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { FlexManager } from './utils/
|
|
5
|
-
import { shouldBindEvent,
|
|
3
|
+
import commonStyleModify, { rowModify, columnModify } from './style'
|
|
4
|
+
import { FlexManager } from './utils/flexManager'
|
|
5
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
6
6
|
|
|
7
|
-
import type {
|
|
7
|
+
import type { TaroAny, TaroEvent, TaroCheckboxElement, TaroCheckboxGroupElement } from '@tarojs/runtime'
|
|
8
|
+
import { isUndefined } from '@tarojs/shared'
|
|
8
9
|
|
|
9
10
|
interface CheckboxOptions {
|
|
10
11
|
name?: string
|
|
@@ -14,37 +15,6 @@ interface CheckboxAttrs {
|
|
|
14
15
|
selectedColor?: ResourceColor
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
@Extend(Checkbox)
|
|
18
|
-
function checkboxStyle (style: TaroStyleType) {
|
|
19
|
-
.id(style.id)
|
|
20
|
-
.key(style.id)
|
|
21
|
-
.padding(style.padding)
|
|
22
|
-
.margin(style.margin)
|
|
23
|
-
.width(style.width)
|
|
24
|
-
.height(style.height)
|
|
25
|
-
.constraintSize(style.constraintSize)
|
|
26
|
-
.flexGrow(style.flexGrow)
|
|
27
|
-
.flexShrink(style.flexShrink)
|
|
28
|
-
.flexBasis(style.flexBasis)
|
|
29
|
-
.alignSelf(style.alignSelf)
|
|
30
|
-
.backgroundColor(style.backgroundColor)
|
|
31
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
32
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
33
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
34
|
-
.rotate(style.rotate)
|
|
35
|
-
.scale(style.scale)
|
|
36
|
-
.translate(style.translate)
|
|
37
|
-
.transform(style.transform)
|
|
38
|
-
.borderStyle(style.borderStyle)
|
|
39
|
-
.borderWidth(style.borderWidth)
|
|
40
|
-
.borderColor(style.borderColor)
|
|
41
|
-
.borderRadius(style.borderRadius)
|
|
42
|
-
.linearGradient(style.linearGradient)
|
|
43
|
-
.zIndex(style.zIndex)
|
|
44
|
-
.opacity(style.opacity)
|
|
45
|
-
.clip(style.clip)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
18
|
@Extend(Checkbox)
|
|
49
19
|
function checkboxAttr(attr: CheckboxAttrs) {
|
|
50
20
|
.selectedColor(attr.selectedColor)
|
|
@@ -63,80 +33,74 @@ function getOptions (node: TaroCheckboxElement): CheckboxOptions {
|
|
|
63
33
|
}
|
|
64
34
|
}
|
|
65
35
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
36
|
+
|
|
37
|
+
@Component
|
|
38
|
+
export struct TaroCheckbox {
|
|
39
|
+
@Builder customBuilder() {}
|
|
40
|
+
@BuilderParam createLazyChildren: (node: TaroCheckboxElement) => void = this.customBuilder
|
|
41
|
+
@ObjectLink node: TaroCheckboxElement
|
|
42
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
43
|
+
|
|
44
|
+
aboutToAppear () {
|
|
45
|
+
if (this.node && !this.node._isInit) {
|
|
46
|
+
this.node._isInit = true
|
|
47
|
+
this.node._instance = this
|
|
48
|
+
this.node._reset = this.node.checked || false
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
build () {
|
|
53
|
+
Stack() {
|
|
54
|
+
Row() {
|
|
55
|
+
Checkbox(getOptions(this.node))
|
|
56
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
57
|
+
.checkboxAttr(getAttributes(this.node))
|
|
58
|
+
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
59
|
+
.select(this.node.checked)
|
|
60
|
+
.onChange((value: boolean) => {
|
|
61
|
+
if (this.node) {
|
|
62
|
+
if (!!this.node?._attrs.disabled) {
|
|
63
|
+
this.node.updateComponent()
|
|
64
|
+
} else {
|
|
65
|
+
this.node.updateCheckedValue(value)
|
|
66
|
+
|
|
67
|
+
if (value) {
|
|
68
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
|
|
69
|
+
eventHandler(event, 'change', this.node)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
75
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
76
|
+
if (this.node) {
|
|
77
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
84
78
|
}
|
|
79
|
+
}))
|
|
80
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
81
|
+
Text(this.node.textContent)
|
|
82
|
+
.textAlign(TextAlign.Center)
|
|
83
|
+
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
84
|
+
}
|
|
85
|
+
.onClick(() => {
|
|
86
|
+
if (this.node) {
|
|
87
|
+
if (!this.node?._attrs.disabled) {
|
|
88
|
+
this.node.checked = !this.node.checked
|
|
85
89
|
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
89
|
-
node._nodeInfo.areaInfo = res[1]
|
|
90
|
-
}))
|
|
91
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
92
|
-
Text(node.textContent)
|
|
93
|
-
.textAlign(TextAlign.Center)
|
|
94
|
-
.opacity(!!node._attrs.disabled ? 0.4 : 1)
|
|
90
|
+
}
|
|
91
|
+
})
|
|
95
92
|
}
|
|
96
|
-
.onClick(() => {
|
|
97
|
-
if (!node?._attrs.disabled) {
|
|
98
|
-
node.checked = !node.checked
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
93
|
}
|
|
102
94
|
}
|
|
103
95
|
|
|
104
|
-
@Extend(Flex)
|
|
105
|
-
function checkboxGroupAttrs (style: TaroStyleType) {
|
|
106
|
-
.id(style.id)
|
|
107
|
-
.key(style.id)
|
|
108
|
-
.padding(style.padding)
|
|
109
|
-
.margin(style.margin)
|
|
110
|
-
.width(style.width)
|
|
111
|
-
.height(style.height)
|
|
112
|
-
.constraintSize(style.constraintSize)
|
|
113
|
-
.flexGrow(style.flexGrow)
|
|
114
|
-
.flexShrink(style.flexShrink)
|
|
115
|
-
.flexBasis(style.flexBasis)
|
|
116
|
-
.alignSelf(style.alignSelf)
|
|
117
|
-
.backgroundColor(style.backgroundColor)
|
|
118
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
119
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
120
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
121
|
-
.rotate(style.rotate)
|
|
122
|
-
.scale(style.scale)
|
|
123
|
-
.translate(style.translate)
|
|
124
|
-
.transform(style.transform)
|
|
125
|
-
.borderStyle(style.borderStyle)
|
|
126
|
-
.borderWidth(style.borderWidth)
|
|
127
|
-
.borderColor(style.borderColor)
|
|
128
|
-
.borderRadius(style.borderRadius)
|
|
129
|
-
.linearGradient(style.linearGradient)
|
|
130
|
-
.zIndex(style.zIndex)
|
|
131
|
-
.opacity(style.opacity)
|
|
132
|
-
.clip(style.clip)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
96
|
interface ChangeEventDetail { value: string[] }
|
|
136
97
|
|
|
137
98
|
@Component
|
|
138
99
|
export struct TaroCheckboxGroup {
|
|
139
|
-
|
|
100
|
+
@Builder customBuilder() {}
|
|
101
|
+
@BuilderParam createLazyChildren: (node: TaroCheckboxGroupElement) => void = this.customBuilder
|
|
102
|
+
@ObjectLink node: TaroCheckboxGroupElement
|
|
103
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
140
104
|
|
|
141
105
|
@Styles visibleChangeEvent () {
|
|
142
106
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
@@ -144,6 +108,7 @@ export struct TaroCheckboxGroup {
|
|
|
144
108
|
|
|
145
109
|
aboutToAppear () {
|
|
146
110
|
if (this.node) {
|
|
111
|
+
this.node._instance = this
|
|
147
112
|
// 阻止事件冒泡传递上去
|
|
148
113
|
this.node.addEventListener('change', (e: TaroEvent<ChangeEventDetail>) => {
|
|
149
114
|
e.stopPropagation()
|
|
@@ -162,11 +127,25 @@ export struct TaroCheckboxGroup {
|
|
|
162
127
|
}
|
|
163
128
|
|
|
164
129
|
build() {
|
|
165
|
-
if (this.node) {
|
|
130
|
+
if (FlexManager.useFlexLayout(this.node)) {
|
|
166
131
|
Flex(FlexManager.flexOptions(this.node)) {
|
|
167
|
-
createLazyChildren(this.node)
|
|
132
|
+
this.createLazyChildren(this.node)
|
|
133
|
+
}
|
|
134
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
135
|
+
.defaultEvent()
|
|
136
|
+
.visibleChangeEvent()
|
|
137
|
+
} else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
|
|
138
|
+
Row() {
|
|
139
|
+
this.createLazyChildren(this.node)
|
|
140
|
+
}
|
|
141
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
142
|
+
.defaultEvent()
|
|
143
|
+
.visibleChangeEvent()
|
|
144
|
+
} else {
|
|
145
|
+
Column() {
|
|
146
|
+
this.createLazyChildren(this.node)
|
|
168
147
|
}
|
|
169
|
-
.
|
|
148
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
170
149
|
.defaultEvent()
|
|
171
150
|
.visibleChangeEvent()
|
|
172
151
|
}
|
|
@@ -1,53 +1,62 @@
|
|
|
1
1
|
import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import commonStyleModify, { rowModify, columnModify } from './style'
|
|
4
|
+
|
|
4
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
5
|
-
import { FlexManager } from './utils/
|
|
6
|
-
import {
|
|
6
|
+
import { FlexManager } from './utils/flexManager'
|
|
7
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
7
8
|
|
|
8
|
-
import type { TaroAny, TaroFormElement
|
|
9
|
+
import type { TaroAny, TaroFormElement } from '@tarojs/runtime'
|
|
10
|
+
import { isUndefined } from '@tarojs/shared'
|
|
9
11
|
|
|
10
|
-
@
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.backgroundColor(style.backgroundColor)
|
|
24
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
25
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
26
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
27
|
-
.rotate(style.rotate)
|
|
28
|
-
.scale(style.scale)
|
|
29
|
-
.translate(style.translate)
|
|
30
|
-
.transform(style.transform)
|
|
31
|
-
.borderStyle(style.borderStyle)
|
|
32
|
-
.borderWidth(style.borderWidth)
|
|
33
|
-
.borderColor(style.borderColor)
|
|
34
|
-
.borderRadius(style.borderRadius)
|
|
35
|
-
.linearGradient(style.linearGradient)
|
|
36
|
-
.zIndex(style.zIndex)
|
|
37
|
-
.opacity(style.opacity)
|
|
38
|
-
.clip(style.clip)
|
|
39
|
-
}
|
|
12
|
+
@Component
|
|
13
|
+
export default struct TaroForm {
|
|
14
|
+
@Builder customBuilder() {}
|
|
15
|
+
@BuilderParam createLazyChildren: (node: TaroFormElement) => void = this.customBuilder
|
|
16
|
+
@ObjectLink node: TaroFormElement
|
|
17
|
+
|
|
18
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
19
|
+
|
|
20
|
+
aboutToAppear(): void {
|
|
21
|
+
if (this.node) {
|
|
22
|
+
this.node._instance = this
|
|
23
|
+
}
|
|
24
|
+
}
|
|
40
25
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
26
|
+
build() {
|
|
27
|
+
if (FlexManager.useFlexLayout(this.node)) {
|
|
28
|
+
Flex(FlexManager.flexOptions(this.node)) {
|
|
29
|
+
this.createLazyChildren(this.node)
|
|
30
|
+
}
|
|
31
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
32
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
33
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
34
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
35
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
36
|
+
}))
|
|
37
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
38
|
+
} else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
|
|
39
|
+
Row() {
|
|
40
|
+
this.createLazyChildren(this.node)
|
|
41
|
+
}
|
|
42
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
43
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
44
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
45
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
46
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
47
|
+
}))
|
|
48
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
49
|
+
} else {
|
|
50
|
+
Column() {
|
|
51
|
+
this.createLazyChildren(this.node)
|
|
52
|
+
}
|
|
53
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
54
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
55
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
56
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
57
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
58
|
+
}))
|
|
59
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
60
|
+
}
|
|
45
61
|
}
|
|
46
|
-
.attrs(getNormalAttributes(node))
|
|
47
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
48
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
49
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
50
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
51
|
-
node._nodeInfo.areaInfo = res[1]
|
|
52
|
-
}))
|
|
53
62
|
}
|
|
@@ -1,39 +1,9 @@
|
|
|
1
|
-
import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
1
|
+
import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, convertNumber2PX } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
4
5
|
|
|
5
|
-
import type { TaroIconElement, TaroAny
|
|
6
|
-
|
|
7
|
-
@Extend(Image)
|
|
8
|
-
function attrs (style: TaroStyleType) {
|
|
9
|
-
.id(style.id)
|
|
10
|
-
.key(style.id)
|
|
11
|
-
.padding(style.padding)
|
|
12
|
-
.margin(style.margin)
|
|
13
|
-
.width(style.width || convertNumber2VP(23))
|
|
14
|
-
.height(style.height || convertNumber2VP(23))
|
|
15
|
-
.constraintSize(style.constraintSize)
|
|
16
|
-
.flexGrow(style.flexGrow)
|
|
17
|
-
.flexShrink(style.flexShrink)
|
|
18
|
-
.flexBasis(style.flexBasis)
|
|
19
|
-
.alignSelf(style.alignSelf)
|
|
20
|
-
.backgroundColor(style.backgroundColor)
|
|
21
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
22
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
23
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
24
|
-
.rotate(style.rotate)
|
|
25
|
-
.scale(style.scale)
|
|
26
|
-
.translate(style.translate)
|
|
27
|
-
.transform(style.transform)
|
|
28
|
-
.borderStyle(style.borderStyle)
|
|
29
|
-
.borderWidth(style.borderWidth)
|
|
30
|
-
.borderColor(style.borderColor)
|
|
31
|
-
.borderRadius(style.borderRadius)
|
|
32
|
-
.linearGradient(style.linearGradient)
|
|
33
|
-
.zIndex(style.zIndex)
|
|
34
|
-
.opacity(style.opacity)
|
|
35
|
-
.clip(style.clip)
|
|
36
|
-
}
|
|
6
|
+
import type { TaroIconElement, TaroAny } from '@tarojs/runtime'
|
|
37
7
|
|
|
38
8
|
const ICON_COLOR_MAP: TaroAny = {
|
|
39
9
|
success: Color.Green,
|
|
@@ -78,20 +48,34 @@ function getIconData (node: TaroIconElement): Resource | null {
|
|
|
78
48
|
}
|
|
79
49
|
}
|
|
80
50
|
|
|
81
|
-
@
|
|
82
|
-
export default
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
51
|
+
@Component
|
|
52
|
+
export default struct TaroIcon {
|
|
53
|
+
@Builder customBuilder() {}
|
|
54
|
+
@BuilderParam createLazyChildren: (node: TaroIconElement) => void = this.customBuilder
|
|
55
|
+
@ObjectLink node: TaroIconElement
|
|
56
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
57
|
+
|
|
58
|
+
aboutToAppear(): void {
|
|
59
|
+
if (this.node) {
|
|
60
|
+
this.node._instance = this
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
build() {
|
|
65
|
+
Image(getIconData(this.node))
|
|
66
|
+
.objectFit(ImageFit.Contain)
|
|
67
|
+
.fillColor(this.node._attrs.color || ICON_COLOR_MAP[this.node._attrs.type] || Color.Black)
|
|
68
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
69
|
+
.size({
|
|
70
|
+
width: Number(this.node._attrs.size) || 23,
|
|
71
|
+
height: Number(this.node._attrs.size) || 23
|
|
72
|
+
})
|
|
73
|
+
.onComplete(e => eventHandler(e, 'complete', this.node))
|
|
74
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
75
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
76
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
77
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
78
|
+
}))
|
|
79
|
+
}
|
|
97
80
|
}
|
|
81
|
+
|
|
@@ -1,41 +1,11 @@
|
|
|
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
|
+
import type { TaroImageElement, TaroAny } from '@tarojs/runtime'
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
function attrs (style: TaroStyleType) {
|
|
9
|
-
.id(style.id)
|
|
10
|
-
.key(style.id)
|
|
11
|
-
.padding(style.padding)
|
|
12
|
-
.margin(style.margin)
|
|
13
|
-
.width(style.width)
|
|
14
|
-
.height(style.height)
|
|
15
|
-
.backgroundColor(style.backgroundColor)
|
|
16
|
-
.constraintSize(style.constraintSize)
|
|
17
|
-
.flexGrow(style.flexGrow)
|
|
18
|
-
.flexShrink(style.flexShrink)
|
|
19
|
-
.flexBasis(style.flexBasis)
|
|
20
|
-
.alignSelf(style.alignSelf)
|
|
21
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
22
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
23
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
24
|
-
.rotate(style.rotate)
|
|
25
|
-
.scale(style.scale)
|
|
26
|
-
.translate(style.translate)
|
|
27
|
-
.transform(style.transform)
|
|
28
|
-
.borderStyle(style.borderStyle)
|
|
29
|
-
.borderWidth(style.borderWidth)
|
|
30
|
-
.borderColor(style.borderColor)
|
|
31
|
-
.borderRadius(style.borderRadius)
|
|
32
|
-
.linearGradient(style.linearGradient)
|
|
33
|
-
.zIndex(style.zIndex)
|
|
34
|
-
.opacity(style.opacity)
|
|
35
|
-
.clip(style.clip)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function getImageMode (mode: string): ImageFit {
|
|
8
|
+
export function getImageMode (mode: string): ImageFit {
|
|
39
9
|
switch (mode) {
|
|
40
10
|
case 'aspectFit': return ImageFit.Contain
|
|
41
11
|
case 'aspectFill': return ImageFit.Cover
|
|
@@ -46,15 +16,35 @@ function getImageMode (mode: string): ImageFit {
|
|
|
46
16
|
}
|
|
47
17
|
}
|
|
48
18
|
|
|
49
|
-
@
|
|
50
|
-
export default
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.
|
|
58
|
-
|
|
59
|
-
|
|
19
|
+
@Component
|
|
20
|
+
export default struct TaroImage {
|
|
21
|
+
@Builder customBuilder() {}
|
|
22
|
+
@BuilderParam createLazyChildren: (node: TaroImageElement) => void = this.customBuilder
|
|
23
|
+
@ObjectLink node: TaroImageElement
|
|
24
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
25
|
+
|
|
26
|
+
aboutToAppear(): void {
|
|
27
|
+
if (this.node) {
|
|
28
|
+
this.node._instance = this
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
build() {
|
|
33
|
+
Image(this.node.getAttribute('src'))
|
|
34
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
35
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
36
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
37
|
+
}))
|
|
38
|
+
.objectFit(getImageMode(this.node.getAttribute('mode')))
|
|
39
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
40
|
+
.onComplete(e => eventHandler(e, 'complete', this.node))
|
|
41
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
42
|
+
// TODO: 临时改为申明式,后续等鸿蒙修复modify设置失败的bug后删除该申明
|
|
43
|
+
.borderRadius({
|
|
44
|
+
topLeft: this.node._st.hmStyle.borderTopLeftRadius,
|
|
45
|
+
topRight: this.node._st.hmStyle.borderTopRightRadius,
|
|
46
|
+
bottomLeft: this.node._st.hmStyle.borderBottomLeftRadius,
|
|
47
|
+
bottomRight: this.node._st.hmStyle.borderBottomRightRadius
|
|
48
|
+
})
|
|
49
|
+
}
|
|
60
50
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import TaroImage, { getImageMode } from './image'
|
|
2
|
+
import TaroText from './text'
|
|
3
|
+
import TaroView from './view'
|
|
4
|
+
import TaroIcon from './icon'
|
|
5
|
+
import TaroForm from './form'
|
|
6
|
+
import TaroLabel from './label'
|
|
7
|
+
import TaroInput from './input'
|
|
8
|
+
import TaroVideo from './video'
|
|
9
|
+
import TaroCanvas from './canvas'
|
|
10
|
+
import TaroButton from './button'
|
|
11
|
+
import TaroPicker from './picker'
|
|
12
|
+
import TaroSlider from './slider'
|
|
13
|
+
import TaroSwitch from './switch'
|
|
14
|
+
import TaroSwiper from './swiper'
|
|
15
|
+
import TaroWebView from './webView'
|
|
16
|
+
import TaroTextArea from './textArea'
|
|
17
|
+
import TaroRichText from './richText'
|
|
18
|
+
import TaroProgress from './progress'
|
|
19
|
+
import TaroInnerHtml from './innerHtml'
|
|
20
|
+
import TaroScrollView from './scrollView'
|
|
21
|
+
import TaroMovableArea from './movableArea'
|
|
22
|
+
import TaroMovableView from './movableView'
|
|
23
|
+
import { TaroRadio, TaroRadioGroup } from './radio'
|
|
24
|
+
import { TaroCheckboxGroup, TaroCheckbox } from './checkbox'
|
|
25
|
+
import TaroPageMeta from './pageMeta'
|
|
26
|
+
import TaroNavigationBar from './navigationBar'
|
|
27
|
+
|
|
28
|
+
import TaroListView from './listView'
|
|
29
|
+
import TaroStickySection from './stickySection'
|
|
30
|
+
import TaroScrollList from './scrollList'
|
|
31
|
+
|
|
32
|
+
import commonStyleModify, { rowModify, columnModify, textModify, setNormalTextAttributeIntoInstance } from './style'
|
|
33
|
+
import { getButtonColor } from './button'
|
|
34
|
+
import { FlexManager } from './utils/flexManager'
|
|
35
|
+
import { DynamicCenter } from './utils/DynamicCenter'
|
|
36
|
+
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
37
|
+
import { BUTTON_THEME_COLOR } from './utils/constant/style'
|
|
38
|
+
import { getStyleAttr } from './utils/styles'
|
|
39
|
+
import { shouldBindEvent, getNodeThresholds, getNormalAttributes, getFontAttributes } from './utils/helper'
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
textModify,
|
|
43
|
+
getStyleAttr,
|
|
44
|
+
FlexManager,
|
|
45
|
+
DynamicCenter,
|
|
46
|
+
getButtonColor,
|
|
47
|
+
TOUCH_EVENT_MAP,
|
|
48
|
+
shouldBindEvent,
|
|
49
|
+
getFontAttributes,
|
|
50
|
+
commonStyleModify,
|
|
51
|
+
rowModify,
|
|
52
|
+
columnModify,
|
|
53
|
+
getNodeThresholds,
|
|
54
|
+
BUTTON_THEME_COLOR,
|
|
55
|
+
getNormalAttributes,
|
|
56
|
+
setNormalTextAttributeIntoInstance,
|
|
57
|
+
getImageMode,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
TaroImage,
|
|
62
|
+
TaroCanvas,
|
|
63
|
+
TaroText,
|
|
64
|
+
TaroView,
|
|
65
|
+
TaroIcon,
|
|
66
|
+
TaroForm,
|
|
67
|
+
TaroLabel,
|
|
68
|
+
TaroInput,
|
|
69
|
+
TaroVideo,
|
|
70
|
+
TaroButton,
|
|
71
|
+
TaroPicker,
|
|
72
|
+
TaroSlider,
|
|
73
|
+
TaroSwitch,
|
|
74
|
+
TaroSwiper,
|
|
75
|
+
TaroWebView,
|
|
76
|
+
TaroTextArea,
|
|
77
|
+
TaroRichText,
|
|
78
|
+
TaroProgress,
|
|
79
|
+
TaroInnerHtml,
|
|
80
|
+
TaroScrollView,
|
|
81
|
+
TaroMovableArea,
|
|
82
|
+
TaroMovableView,
|
|
83
|
+
TaroRadio,
|
|
84
|
+
TaroRadioGroup,
|
|
85
|
+
TaroCheckboxGroup,
|
|
86
|
+
TaroCheckbox,
|
|
87
|
+
TaroPageMeta,
|
|
88
|
+
TaroNavigationBar,
|
|
89
|
+
TaroListView,
|
|
90
|
+
TaroStickySection,
|
|
91
|
+
TaroScrollList
|
|
92
|
+
}
|
|
@@ -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
|
}
|