@tarojs/plugin-platform-harmony-ets 4.0.0-beta.12 → 4.0.0-beta.121
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 +60 -25
- package/dist/apis/base/weapp/life-cycle.ts +1 -1
- package/dist/apis/canvas/index.ts +10 -1
- package/dist/apis/device/clipboard.ts +23 -8
- package/dist/apis/framework/index.ts +2 -6
- package/dist/apis/index.ts +25 -17
- package/dist/apis/media/image/index.ts +169 -17
- package/dist/apis/route/index.ts +1 -2
- package/dist/apis/storage/index.ts +135 -131
- package/dist/apis/ui/animation/animation.ts +71 -29
- package/dist/apis/ui/background.ts +3 -2
- package/dist/apis/ui/interaction/index.ts +58 -59
- package/dist/apis/ui/navigation-bar/index.ts +2 -2
- package/dist/apis/ui/pull-down-refresh.ts +9 -3
- package/dist/apis/ui/scroll/index.ts +6 -6
- package/dist/apis/ui/tab-bar.ts +4 -5
- package/dist/apis/utils/index.ts +20 -2
- package/dist/apis/utils/permissions.ts +6 -0
- package/dist/apis/wxml/IntersectionObserver.ts +18 -10
- package/dist/apis/wxml/selectorQuery.ts +26 -13
- package/dist/components-harmony-ets/button.ets +36 -9
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +69 -60
- package/dist/components-harmony-ets/form.ets +33 -15
- package/dist/components-harmony-ets/icon.ets +16 -8
- package/dist/components-harmony-ets/image.ets +22 -6
- package/dist/components-harmony-ets/index.ets +39 -0
- package/dist/components-harmony-ets/innerHtml.ets +6 -5
- package/dist/components-harmony-ets/input.ets +63 -37
- package/dist/components-harmony-ets/label.ets +43 -21
- package/dist/components-harmony-ets/listView.ets +32 -0
- package/dist/components-harmony-ets/movableArea.ets +110 -51
- package/dist/components-harmony-ets/movableView.ets +74 -47
- 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 +36 -33
- package/dist/components-harmony-ets/progress.ets +31 -24
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +75 -66
- package/dist/components-harmony-ets/richText.ets +4 -25
- package/dist/components-harmony-ets/scrollList.ets +108 -0
- package/dist/components-harmony-ets/scrollView.ets +46 -42
- package/dist/components-harmony-ets/slider.ets +19 -15
- package/dist/components-harmony-ets/stickySection.ets +42 -0
- package/dist/components-harmony-ets/style.ets +386 -129
- package/dist/components-harmony-ets/swiper.ets +42 -5
- package/dist/components-harmony-ets/switch.ets +36 -32
- package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
- package/dist/components-harmony-ets/text.ets +102 -46
- package/dist/components-harmony-ets/textArea.ets +49 -34
- 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 +49 -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 +169 -91
- package/dist/components-harmony-ets/video.ets +28 -20
- package/dist/components-harmony-ets/view.ets +45 -39
- package/dist/components-harmony-ets/webView.ets +6 -5
- package/dist/index.d.ts +152 -0
- package/dist/index.js +73 -44
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/URL.ts +2 -0
- package/dist/runtime-ets/bom/document.ts +5 -4
- package/dist/runtime-ets/bom/getComputedStyle.ts +2 -3
- package/dist/runtime-ets/bom/history.ts +1 -0
- package/dist/runtime-ets/bom/location.ts +1 -0
- package/dist/runtime-ets/bom/navigator.ts +1 -21
- package/dist/runtime-ets/bom/raf.ts +1 -37
- package/dist/runtime-ets/bom/window.ts +10 -4
- package/dist/runtime-ets/constant.ts +17 -10
- package/dist/runtime-ets/current.ts +5 -2
- 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 +9 -12
- package/dist/runtime-ets/dom/element/canvas.ts +137 -0
- package/dist/runtime-ets/dom/element/element.ts +379 -55
- package/dist/runtime-ets/dom/element/form.ts +26 -22
- package/dist/runtime-ets/dom/element/index.ts +22 -2
- package/dist/runtime-ets/dom/element/movableArea.ts +0 -1
- package/dist/runtime-ets/dom/element/movableView.ts +238 -2
- package/dist/runtime-ets/dom/element/normal.ts +27 -6
- package/dist/runtime-ets/dom/element/progress.ts +0 -2
- package/dist/runtime-ets/dom/element/text.ts +0 -8
- package/dist/runtime-ets/dom/element/video.ts +4 -4
- package/dist/runtime-ets/dom/element/webView.ts +4 -5
- package/dist/runtime-ets/dom/event-source.ts +1 -0
- package/dist/runtime-ets/dom/event.ts +3 -5
- package/dist/runtime-ets/dom/eventTarget.ts +3 -4
- package/dist/runtime-ets/dom/node.ts +53 -22
- 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/emitter/emitter.ts +1 -0
- package/dist/runtime-ets/env.ts +1 -0
- package/dist/runtime-ets/index.ts +23 -7
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/interface/index.ts +6 -0
- package/dist/runtime-ets/utils/index.ts +78 -19
- package/dist/runtime-ets/utils/info.ts +2 -2
- package/dist/runtime-ets/utils/router.ts +9 -0
- package/dist/runtime-framework/react/app.ts +15 -11
- package/dist/runtime-framework/react/hooks.ts +1 -2
- package/dist/runtime-framework/react/index.ts +0 -2
- package/dist/runtime-framework/react/native-page.ts +217 -81
- package/dist/runtime-framework/react/page.ts +4 -10
- package/dist/runtime-framework/react/utils/index.ts +3 -3
- package/dist/runtime-framework/solid/app.ts +29 -46
- package/dist/runtime-framework/solid/connect.ts +21 -3
- package/dist/runtime-framework/solid/hooks.ts +16 -11
- package/dist/runtime-framework/solid/index.ts +6 -2
- package/dist/runtime-framework/solid/page.ts +84 -31
- package/dist/runtime-framework/solid/reconciler/props.ts +73 -29
- 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 +574 -285
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +574 -285
- 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 +1 -1
- /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { createTaroEvent, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import commonStyleModify from './style'
|
|
4
|
-
import { createLazyChildren } from './render'
|
|
3
|
+
import commonStyleModify, { rowModify, columnModify } from './style'
|
|
5
4
|
import { FlexManager } from './utils/flexManager'
|
|
6
5
|
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
7
6
|
|
|
8
|
-
import type { TaroAny,
|
|
7
|
+
import type { TaroAny, TaroCheckboxElement, TaroCheckboxGroupElement, TaroEvent } from '@tarojs/runtime'
|
|
9
8
|
|
|
10
9
|
interface CheckboxOptions {
|
|
11
10
|
name?: string
|
|
@@ -13,17 +12,20 @@ interface CheckboxOptions {
|
|
|
13
12
|
}
|
|
14
13
|
interface CheckboxAttrs {
|
|
15
14
|
selectedColor?: ResourceColor
|
|
15
|
+
disabled?: boolean
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
@Extend(Checkbox)
|
|
19
19
|
function checkboxAttr(attr: CheckboxAttrs) {
|
|
20
20
|
.selectedColor(attr.selectedColor)
|
|
21
|
+
.enabled(!attr.disabled)
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
function getAttributes (node: TaroCheckboxElement): CheckboxAttrs {
|
|
24
25
|
const _attrs = node._attrs
|
|
25
26
|
const checkboxAttrs: CheckboxAttrs = {}
|
|
26
27
|
checkboxAttrs.selectedColor = _attrs.color || '#1aad19'
|
|
28
|
+
checkboxAttrs.disabled = !!_attrs.disabled
|
|
27
29
|
return checkboxAttrs
|
|
28
30
|
}
|
|
29
31
|
|
|
@@ -36,57 +38,59 @@ function getOptions (node: TaroCheckboxElement): CheckboxOptions {
|
|
|
36
38
|
|
|
37
39
|
@Component
|
|
38
40
|
export struct TaroCheckbox {
|
|
41
|
+
@Builder customBuilder() {}
|
|
42
|
+
@BuilderParam createLazyChildren: (node: TaroCheckboxElement, layer?: number) => void = this.customBuilder
|
|
39
43
|
@ObjectLink node: TaroCheckboxElement
|
|
44
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
40
45
|
|
|
41
46
|
aboutToAppear () {
|
|
42
47
|
if (this.node && !this.node._isInit) {
|
|
43
48
|
this.node._isInit = true
|
|
49
|
+
this.node._instance = this
|
|
44
50
|
this.node._reset = this.node.checked || false
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
build () {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.
|
|
58
|
-
if (this.node) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
eventHandler(event, 'change', this.node)
|
|
67
|
-
}
|
|
55
|
+
Stack() {
|
|
56
|
+
Row() {
|
|
57
|
+
Checkbox(getOptions(this.node))
|
|
58
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
59
|
+
.checkboxAttr(getAttributes(this.node))
|
|
60
|
+
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
61
|
+
.select(this.node.checked)
|
|
62
|
+
.onChange((value: boolean) => {
|
|
63
|
+
if (this.node) {
|
|
64
|
+
if (!!this.node?._attrs.disabled) {
|
|
65
|
+
this.node.updateComponent()
|
|
66
|
+
} else {
|
|
67
|
+
this.node.updateCheckedValue(value)
|
|
68
|
+
|
|
69
|
+
if (value) {
|
|
70
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
|
|
71
|
+
eventHandler(event, 'change', this.node)
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
|
-
})
|
|
71
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
72
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
73
|
-
if (this.node) {
|
|
74
|
-
this.node._nodeInfo.areaInfo = res[1]
|
|
75
|
-
}
|
|
76
|
-
}))
|
|
77
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
78
|
-
Text(this.node.textContent)
|
|
79
|
-
.textAlign(TextAlign.Center)
|
|
80
|
-
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
81
|
-
}
|
|
82
|
-
.onClick(() => {
|
|
83
|
-
if (this.node) {
|
|
84
|
-
if (!this.node?._attrs.disabled) {
|
|
85
|
-
this.node.checked = !this.node.checked
|
|
86
74
|
}
|
|
87
|
-
}
|
|
88
|
-
|
|
75
|
+
})
|
|
76
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
77
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
78
|
+
if (this.node) {
|
|
79
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
80
|
+
}
|
|
81
|
+
}))
|
|
82
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
83
|
+
Text(this.node.textContent)
|
|
84
|
+
.textAlign(TextAlign.Center)
|
|
85
|
+
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
89
86
|
}
|
|
87
|
+
.onClick(() => {
|
|
88
|
+
if (this.node) {
|
|
89
|
+
if (!this.node?._attrs.disabled) {
|
|
90
|
+
this.node.checked = !this.node.checked
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
})
|
|
90
94
|
}
|
|
91
95
|
}
|
|
92
96
|
}
|
|
@@ -95,7 +99,10 @@ interface ChangeEventDetail { value: string[] }
|
|
|
95
99
|
|
|
96
100
|
@Component
|
|
97
101
|
export struct TaroCheckboxGroup {
|
|
102
|
+
@Builder customBuilder() {}
|
|
103
|
+
@BuilderParam createLazyChildren: (node: TaroCheckboxGroupElement, layer?: number) => void = this.customBuilder
|
|
98
104
|
@ObjectLink node: TaroCheckboxGroupElement
|
|
105
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
99
106
|
|
|
100
107
|
@Styles visibleChangeEvent () {
|
|
101
108
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
@@ -103,6 +110,7 @@ export struct TaroCheckboxGroup {
|
|
|
103
110
|
|
|
104
111
|
aboutToAppear () {
|
|
105
112
|
if (this.node) {
|
|
113
|
+
this.node._instance = this
|
|
106
114
|
// 阻止事件冒泡传递上去
|
|
107
115
|
this.node.addEventListener('change', (e: TaroEvent<ChangeEventDetail>) => {
|
|
108
116
|
e.stopPropagation()
|
|
@@ -112,7 +120,7 @@ export struct TaroCheckboxGroup {
|
|
|
112
120
|
}
|
|
113
121
|
|
|
114
122
|
@Styles defaultEvent () {
|
|
115
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
123
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
116
124
|
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
117
125
|
if (this.node) {
|
|
118
126
|
this.node._nodeInfo.areaInfo = res[1]
|
|
@@ -121,26 +129,27 @@ export struct TaroCheckboxGroup {
|
|
|
121
129
|
}
|
|
122
130
|
|
|
123
131
|
build() {
|
|
124
|
-
if (this.node) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
.
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
.
|
|
141
|
-
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
142
|
-
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
132
|
+
if (FlexManager.useFlexLayout(this.node)) {
|
|
133
|
+
Flex(FlexManager.flexOptions(this.node)) {
|
|
134
|
+
this.createLazyChildren(this.node, 0)
|
|
135
|
+
}
|
|
136
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
137
|
+
.defaultEvent()
|
|
138
|
+
.visibleChangeEvent()
|
|
139
|
+
} else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
|
|
140
|
+
Row() {
|
|
141
|
+
this.createLazyChildren(this.node, 0)
|
|
142
|
+
}
|
|
143
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
144
|
+
.defaultEvent()
|
|
145
|
+
.visibleChangeEvent()
|
|
146
|
+
} else {
|
|
147
|
+
Column() {
|
|
148
|
+
this.createLazyChildren(this.node, 0)
|
|
143
149
|
}
|
|
150
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
151
|
+
.defaultEvent()
|
|
152
|
+
.visibleChangeEvent()
|
|
144
153
|
}
|
|
145
154
|
}
|
|
146
155
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import commonStyleModify from './style'
|
|
4
|
-
|
|
3
|
+
import commonStyleModify, { rowModify, columnModify } from './style'
|
|
4
|
+
|
|
5
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
6
6
|
import { FlexManager } from './utils/flexManager'
|
|
7
7
|
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
@@ -10,34 +10,52 @@ import type { TaroAny, TaroFormElement } from '@tarojs/runtime'
|
|
|
10
10
|
|
|
11
11
|
@Component
|
|
12
12
|
export default struct TaroForm {
|
|
13
|
+
@Builder customBuilder() {}
|
|
14
|
+
@BuilderParam createLazyChildren: (node: TaroFormElement, layer?: number) => void = this.customBuilder
|
|
13
15
|
@ObjectLink node: TaroFormElement
|
|
16
|
+
|
|
17
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
18
|
+
|
|
19
|
+
aboutToAppear(): void {
|
|
20
|
+
if (this.node) {
|
|
21
|
+
this.node._instance = this
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
14
25
|
build() {
|
|
15
|
-
if (FlexManager.
|
|
26
|
+
if (FlexManager.useFlexLayout(this.node)) {
|
|
27
|
+
Flex(FlexManager.flexOptions(this.node)) {
|
|
28
|
+
this.createLazyChildren(this.node, 0)
|
|
29
|
+
}
|
|
30
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
31
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
32
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
|
|
33
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
34
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
35
|
+
}))
|
|
36
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
37
|
+
} else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
|
|
16
38
|
Row() {
|
|
17
|
-
createLazyChildren(this.node)
|
|
39
|
+
this.createLazyChildren(this.node, 0)
|
|
18
40
|
}
|
|
19
|
-
.attributeModifier(
|
|
20
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
21
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
41
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
42
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
43
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
|
|
22
44
|
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
23
45
|
this.node._nodeInfo.areaInfo = res[1]
|
|
24
46
|
}))
|
|
25
47
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
26
|
-
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
27
|
-
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
28
48
|
} else {
|
|
29
49
|
Column() {
|
|
30
|
-
createLazyChildren(this.node)
|
|
50
|
+
this.createLazyChildren(this.node, 0)
|
|
31
51
|
}
|
|
32
|
-
.attributeModifier(
|
|
33
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
34
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
52
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
53
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
54
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
|
|
35
55
|
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
36
56
|
this.node._nodeInfo.areaInfo = res[1]
|
|
37
57
|
}))
|
|
38
58
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
39
|
-
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
40
|
-
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
41
59
|
}
|
|
42
60
|
}
|
|
43
61
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, convertNumber2PX } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
|
-
import {
|
|
4
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
5
5
|
|
|
6
6
|
import type { TaroIconElement, TaroAny } from '@tarojs/runtime'
|
|
7
7
|
|
|
@@ -50,20 +50,28 @@ function getIconData (node: TaroIconElement): Resource | null {
|
|
|
50
50
|
|
|
51
51
|
@Component
|
|
52
52
|
export default struct TaroIcon {
|
|
53
|
+
@Builder customBuilder() {}
|
|
54
|
+
@BuilderParam createLazyChildren: (node: TaroIconElement, layer?: number) => void = this.customBuilder
|
|
53
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
|
+
|
|
54
64
|
build() {
|
|
55
65
|
Image(getIconData(this.node))
|
|
56
66
|
.objectFit(ImageFit.Contain)
|
|
57
67
|
.fillColor(this.node._attrs.color || ICON_COLOR_MAP[this.node._attrs.type] || Color.Black)
|
|
58
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
68
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
59
69
|
.size({
|
|
60
|
-
width:
|
|
61
|
-
height:
|
|
70
|
+
width: Number(this.node._attrs.size) || 23,
|
|
71
|
+
height: Number(this.node._attrs.size) || 23
|
|
62
72
|
})
|
|
63
|
-
.
|
|
64
|
-
.
|
|
65
|
-
.onComplete(e => eventHandler(e, 'complete', this.node))
|
|
66
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
73
|
+
.onComplete(e => { eventHandler(e, 'complete', this.node) })
|
|
74
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
67
75
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
68
76
|
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
69
77
|
this.node._nodeInfo.areaInfo = res[1]
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
|
-
import {
|
|
4
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
5
5
|
|
|
6
|
-
import type { TaroImageElement, TaroAny
|
|
6
|
+
import type { TaroImageElement, TaroAny } from '@tarojs/runtime'
|
|
7
7
|
|
|
8
|
-
function getImageMode (mode: string): ImageFit {
|
|
8
|
+
export function getImageMode (mode: string): ImageFit {
|
|
9
9
|
switch (mode) {
|
|
10
10
|
case 'aspectFit': return ImageFit.Contain
|
|
11
11
|
case 'aspectFill': return ImageFit.Cover
|
|
@@ -18,17 +18,33 @@ function getImageMode (mode: string): ImageFit {
|
|
|
18
18
|
|
|
19
19
|
@Component
|
|
20
20
|
export default struct TaroImage {
|
|
21
|
+
@Builder customBuilder() {}
|
|
22
|
+
@BuilderParam createLazyChildren: (node: TaroImageElement, layer?: number) => void = this.customBuilder
|
|
21
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
|
+
}
|
|
22
31
|
|
|
23
32
|
build() {
|
|
24
33
|
Image(this.node.getAttribute('src'))
|
|
25
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
34
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
26
35
|
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
27
36
|
this.node._nodeInfo.areaInfo = res[1]
|
|
28
37
|
}))
|
|
29
38
|
.objectFit(getImageMode(this.node.getAttribute('mode')))
|
|
30
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
31
|
-
.onComplete(e => eventHandler(e, 'complete', this.node))
|
|
39
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
40
|
+
.onComplete(e => { eventHandler(e, 'complete', this.node) })
|
|
32
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
|
+
})
|
|
33
49
|
}
|
|
34
50
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export { default as TaroImage, getImageMode } from './image'
|
|
2
|
+
export { default as TaroText } from './text'
|
|
3
|
+
export { default as TaroView } from './view'
|
|
4
|
+
export { default as TaroIcon } from './icon'
|
|
5
|
+
export { default as TaroForm } from './form'
|
|
6
|
+
export { default as TaroLabel } from './label'
|
|
7
|
+
export { default as TaroInput } from './input'
|
|
8
|
+
export { default as TaroVideo } from './video'
|
|
9
|
+
export { default as TaroCanvas } from './canvas'
|
|
10
|
+
export { default as TaroButton, getButtonColor } from './button'
|
|
11
|
+
export { default as TaroPicker } from './picker'
|
|
12
|
+
export { default as TaroSlider } from './slider'
|
|
13
|
+
export { default as TaroSwitch } from './switch'
|
|
14
|
+
export { default as TaroSwiper } from './swiper'
|
|
15
|
+
export { default as TaroWebView } from './webView'
|
|
16
|
+
export { default as TaroTextArea } from './textArea'
|
|
17
|
+
export { default as TaroRichText } from './richText'
|
|
18
|
+
export { default as TaroProgress } from './progress'
|
|
19
|
+
export { default as TaroInnerHtml } from './innerHtml'
|
|
20
|
+
export { default as TaroScrollView } from './scrollView'
|
|
21
|
+
export { default as TaroMovableArea } from './movableArea'
|
|
22
|
+
export { default as TaroMovableView } from './movableView'
|
|
23
|
+
export { TaroRadio, TaroRadioGroup } from './radio'
|
|
24
|
+
export { TaroCheckboxGroup, TaroCheckbox } from './checkbox'
|
|
25
|
+
export { default as TaroPageMeta, IComponentAttributeUpdateEvents } from './pageMeta'
|
|
26
|
+
export { default as TaroNavigationBar } from './navigationBar'
|
|
27
|
+
|
|
28
|
+
export { default as TaroListView } from './listView'
|
|
29
|
+
export { default as TaroStickySection } from './stickySection'
|
|
30
|
+
export { default as TaroScrollList } from './scrollList'
|
|
31
|
+
|
|
32
|
+
export { default as commonStyleModify, rowModify, columnModify, textModify, setNormalTextAttributeIntoInstance } from './style'
|
|
33
|
+
export { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
34
|
+
export { BUTTON_THEME_COLOR } from './utils/constant/style'
|
|
35
|
+
export { DynamicCenter } from './utils/DynamicCenter'
|
|
36
|
+
export { FlexManager } from './utils/flexManager'
|
|
37
|
+
export { isTagFirstChild } from './utils/helper'
|
|
38
|
+
export { getStyleAttr } from './utils/styles'
|
|
39
|
+
export { shouldBindEvent, getNodeThresholds, getNormalAttributes, getFontAttributes } from './utils/helper'
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import htmlParser from './utils/htmlParser'
|
|
2
|
-
import { createChildItem } from './render'
|
|
3
2
|
|
|
4
|
-
import type { TaroInnerHtmlElement } from '@tarojs/runtime'
|
|
3
|
+
import type { TaroElement, TaroInnerHtmlElement } from '@tarojs/runtime'
|
|
5
4
|
|
|
6
5
|
@Component
|
|
7
6
|
export default struct TaroInnerHtml {
|
|
7
|
+
@Builder customBuilder() {}
|
|
8
|
+
@BuilderParam createChildItem: (node: TaroElement, callback?: (node: TaroElement) => void) => void = this.customBuilder
|
|
8
9
|
@ObjectLink node: TaroInnerHtmlElement
|
|
9
|
-
|
|
10
|
+
|
|
10
11
|
build() {
|
|
11
|
-
if (this.node.innerHTML) {
|
|
12
|
-
createChildItem(htmlParser(this.node.innerHTML))
|
|
12
|
+
if (this.node?.hmStyle?.display !== 'none' && this.node.innerHTML) {
|
|
13
|
+
this.createChildItem(htmlParser(this.node.innerHTML))
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
|
-
import {
|
|
4
|
+
import { parseStyles, shouldBindEvent, getNodeThresholds, getStyleAttr } from './utils/helper'
|
|
5
5
|
import { INPUT_TYPE_MAP, INPUT_CONFIRM_MAP } from './utils/constant/style'
|
|
6
6
|
|
|
7
|
-
import type {
|
|
7
|
+
import type { TaroAny, TaroEvent, TaroInputElement, TaroStyleType } from '@tarojs/runtime'
|
|
8
8
|
|
|
9
9
|
interface InputAttrs {
|
|
10
10
|
textAlign?: TextAlign
|
|
11
|
+
autoFocus?: boolean
|
|
12
|
+
disabled?: boolean
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
@Extend(TextInput)
|
|
@@ -22,12 +24,15 @@ function styles (style: TaroStyleType) {
|
|
|
22
24
|
@Extend(TextInput)
|
|
23
25
|
function attrs(attr: InputAttrs) {
|
|
24
26
|
.textAlign(attr.textAlign)
|
|
27
|
+
.defaultFocus(attr.autoFocus)
|
|
28
|
+
.enabled(!attr.disabled)
|
|
25
29
|
}
|
|
26
30
|
|
|
27
|
-
|
|
28
31
|
function getAttributes(node: TaroInputElement): InputAttrs {
|
|
29
32
|
return {
|
|
30
33
|
textAlign: node.hmStyle.textAlign,
|
|
34
|
+
autoFocus: node._attrs.autoFocus || node._attrs.focus || false,
|
|
35
|
+
disabled: node._attrs.disabled || false,
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
38
|
|
|
@@ -44,11 +49,26 @@ function getPlaceholderColor (node: TaroInputElement): string {
|
|
|
44
49
|
return placeholderTextColor || parseStyles(placeholderStyle)?.color
|
|
45
50
|
}
|
|
46
51
|
|
|
52
|
+
function getPlaceholderFont(node: TaroInputElement): Font {
|
|
53
|
+
const placeholderStyle: string = node._attrs.placeholderStyle || ''
|
|
54
|
+
const styles = parseStyles(placeholderStyle);
|
|
55
|
+
if (styles) {
|
|
56
|
+
return {
|
|
57
|
+
size: styles.fontSize,
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {}
|
|
62
|
+
}
|
|
63
|
+
|
|
47
64
|
@Component
|
|
48
65
|
export default struct TaroInput {
|
|
49
66
|
@State value: string = ''
|
|
50
67
|
|
|
68
|
+
@Builder customBuilder() {}
|
|
69
|
+
@BuilderParam createLazyChildren: (node: TaroInputElement, layer?: number) => void = this.customBuilder
|
|
51
70
|
@ObjectLink node: TaroInputElement
|
|
71
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
52
72
|
|
|
53
73
|
aboutToAppear () {
|
|
54
74
|
if (this.node) {
|
|
@@ -63,43 +83,49 @@ export default struct TaroInput {
|
|
|
63
83
|
}
|
|
64
84
|
|
|
65
85
|
build () {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
86
|
+
TextInput({ text: this.value, placeholder: this.node._attrs?.placeholder || '', controller: this.node.controller })
|
|
87
|
+
.key(this.node._nid.toString())
|
|
88
|
+
.type(getInputType(this.node))
|
|
89
|
+
.maxLength(Number(this.node._attrs?.maxlength) || null)
|
|
90
|
+
.placeholderColor(getPlaceholderColor(this.node))
|
|
91
|
+
.placeholderFont(getPlaceholderFont(this.node))
|
|
92
|
+
.enterKeyType(INPUT_CONFIRM_MAP.get(this.node._attrs?.confirmType) || EnterKeyType.Done)
|
|
93
|
+
.padding(0) // Note: 移出 Input 默认 padding 设置
|
|
94
|
+
.backgroundColor(getStyleAttr(this.node, "backgroundColor"))
|
|
95
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
96
|
+
.styles(this.node?.hmStyle)
|
|
97
|
+
.attrs(getAttributes(this.node))
|
|
98
|
+
.onChange((value: string) => {
|
|
99
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { value } }, this.node)
|
|
100
|
+
eventHandler(event, 'change', this.node)
|
|
101
|
+
|
|
102
|
+
if (this.value !== value) {
|
|
77
103
|
const event: TaroEvent = createTaroEvent('input', { detail: { value } }, this.node)
|
|
78
|
-
|
|
79
104
|
this.value = value
|
|
80
105
|
this.node?.updateFormWidgetValue(value)
|
|
81
106
|
eventHandler(event, 'input', this.node)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
.onSubmit(() => {
|
|
110
|
+
const event: TaroEvent = createTaroEvent('confirm', { detail: { value: this.value } }, this.node)
|
|
111
|
+
eventHandler(event, 'confirm', this.node)
|
|
112
|
+
})
|
|
113
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
114
|
+
.onBlur(() => {
|
|
115
|
+
const event: TaroEvent = createTaroEvent('blur', { detail: { value: this.value } }, this.node)
|
|
116
|
+
eventHandler(event, 'blur', this.node)
|
|
117
|
+
})
|
|
118
|
+
.onFocus(() => {
|
|
119
|
+
const event: TaroEvent = createTaroEvent('focus', { detail: { value: this.value, height: this.node?._height } }, this.node)
|
|
120
|
+
|
|
121
|
+
eventHandler(event, 'focus', this.node)
|
|
122
|
+
})
|
|
123
|
+
.enableKeyboardOnFocus(typeof (this.node._attrs as TaroAny)?.enableKeyboardOnFocus === 'undefined' ? true : (this.node._attrs as TaroAny).enableKeyboardOnFocus)
|
|
124
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
125
|
+
if (this.node) {
|
|
126
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
127
|
+
}
|
|
128
|
+
}))
|
|
129
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
104
130
|
}
|
|
105
131
|
}
|