@tarojs/plugin-platform-harmony-ets 4.0.0-alpha.2 → 4.0.0-alpha.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 +73 -20
- package/dist/apis/canvas/index.ts +10 -1
- package/dist/apis/device/clipboard.ts +16 -8
- package/dist/apis/framework/index.ts +1 -5
- package/dist/apis/index.ts +25 -17
- package/dist/apis/media/image/index.ts +1 -1
- 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 +2 -1
- package/dist/apis/wxml/IntersectionObserver.ts +18 -10
- package/dist/apis/wxml/selectorQuery.ts +26 -13
- package/dist/components-harmony-ets/button.ets +64 -34
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +72 -61
- package/dist/components-harmony-ets/form.ets +51 -29
- package/dist/components-harmony-ets/icon.ets +31 -19
- package/dist/components-harmony-ets/image.ets +34 -14
- 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 +49 -41
- package/dist/components-harmony-ets/label.ets +71 -44
- package/dist/components-harmony-ets/listView.ets +26 -0
- package/dist/components-harmony-ets/movableArea.ets +126 -0
- package/dist/components-harmony-ets/movableView.ets +93 -0
- package/dist/components-harmony-ets/navigationBar.ets +65 -0
- package/dist/components-harmony-ets/pageMeta.ets +94 -0
- package/dist/components-harmony-ets/picker.ets +42 -38
- package/dist/components-harmony-ets/progress.ets +52 -0
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +74 -64
- package/dist/components-harmony-ets/richText.ets +14 -30
- package/dist/components-harmony-ets/scrollList.ets +94 -0
- package/dist/components-harmony-ets/scrollView.ets +61 -57
- package/dist/components-harmony-ets/slider.ets +18 -14
- package/dist/components-harmony-ets/stickySection.ets +42 -0
- package/dist/components-harmony-ets/style.ets +381 -130
- package/dist/components-harmony-ets/swiper.ets +61 -20
- 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 +135 -49
- package/dist/components-harmony-ets/textArea.ets +50 -35
- package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
- 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 +18 -5
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
- package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
- package/dist/components-harmony-ets/utils/index.ts +54 -50
- package/dist/components-harmony-ets/utils/styles.ets +170 -93
- package/dist/components-harmony-ets/video.ets +34 -21
- package/dist/components-harmony-ets/view.ets +63 -52
- package/dist/components-harmony-ets/webView.ets +40 -34
- package/dist/index.d.ts +152 -0
- package/dist/index.js +99 -55
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/document.ts +6 -4
- package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
- package/dist/runtime-ets/bom/window.ts +7 -0
- package/dist/runtime-ets/current.ts +3 -0
- package/dist/runtime-ets/dom/bind.ts +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 +8 -11
- package/dist/runtime-ets/dom/element/canvas.ts +136 -0
- package/dist/runtime-ets/dom/element/element.ts +348 -57
- package/dist/runtime-ets/dom/element/form.ts +31 -26
- package/dist/runtime-ets/dom/element/index.ts +30 -2
- package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
- package/dist/runtime-ets/dom/element/movableView.ts +244 -0
- package/dist/runtime-ets/dom/element/normal.ts +35 -8
- package/dist/runtime-ets/dom/element/progress.ts +11 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
- package/dist/runtime-ets/dom/element/text.ts +1 -8
- package/dist/runtime-ets/dom/element/video.ts +5 -4
- package/dist/runtime-ets/dom/element/webView.ts +12 -5
- package/dist/runtime-ets/dom/event.ts +2 -4
- package/dist/runtime-ets/dom/eventTarget.ts +2 -3
- package/dist/runtime-ets/dom/node.ts +54 -29
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +416 -235
- package/dist/runtime-ets/dom/stylesheet/index.ts +29 -311
- package/dist/runtime-ets/dom/stylesheet/type.ts +51 -9
- package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
- package/dist/runtime-ets/index.ts +2 -1
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/utils/index.ts +73 -13
- package/dist/runtime-ets/utils/info.ts +2 -2
- package/dist/runtime-framework/react/app.ts +9 -4
- package/dist/runtime-framework/react/hooks.ts +0 -1
- package/dist/runtime-framework/react/index.ts +0 -2
- package/dist/runtime-framework/react/native-page.ts +154 -77
- package/dist/runtime-framework/react/page.ts +3 -8
- package/dist/runtime-framework/solid/app.ts +25 -45
- package/dist/runtime-framework/solid/connect.ts +21 -3
- package/dist/runtime-framework/solid/hooks.ts +16 -11
- package/dist/runtime-framework/solid/index.ts +6 -2
- package/dist/runtime-framework/solid/page.ts +84 -30
- package/dist/runtime-framework/solid/reconciler/props.ts +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 +435 -218
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +435 -218
- 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 +4 -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,5 +1,4 @@
|
|
|
1
1
|
import { eventHandler, createTaroEvent, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
|
-
import { createLazyChildren } from './render'
|
|
3
2
|
import commonStyleModify from './style'
|
|
4
3
|
import { BUTTON_THEME_COLOR } from './utils/constant/style'
|
|
5
4
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
@@ -7,6 +6,21 @@ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
|
7
6
|
|
|
8
7
|
import type { TaroAny, TaroEvent, TaroButtonElement, TaroStyleType } from '@tarojs/runtime'
|
|
9
8
|
|
|
9
|
+
interface ButtonAttrs {
|
|
10
|
+
disabled?: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@Extend(Button)
|
|
14
|
+
function attrs(attr: ButtonAttrs) {
|
|
15
|
+
.enabled(!attr.disabled)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function getAttributes(node: TaroButtonElement): ButtonAttrs {
|
|
19
|
+
return {
|
|
20
|
+
disabled: node._attrs.disabled || false,
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
10
24
|
@Extend(Button)
|
|
11
25
|
function themeStyles(style: TaroStyleType) {
|
|
12
26
|
.fontColor(style.color)
|
|
@@ -66,13 +80,13 @@ function getThemeAttributes (node: TaroButtonElement): TaroStyleType {
|
|
|
66
80
|
}
|
|
67
81
|
}
|
|
68
82
|
|
|
69
|
-
function getButtonWidth (node: TaroButtonElement) {
|
|
83
|
+
function getButtonWidth (node: TaroButtonElement): string | number {
|
|
70
84
|
const isMini = node._attrs.size === 'mini'
|
|
71
85
|
|
|
72
86
|
return isMini ? convertNumber2VP(120) : '100%'
|
|
73
87
|
}
|
|
74
88
|
|
|
75
|
-
function getButtonHeight (node: TaroButtonElement) {
|
|
89
|
+
function getButtonHeight (node: TaroButtonElement): string | number {
|
|
76
90
|
const isMini = node._attrs.size === 'mini'
|
|
77
91
|
|
|
78
92
|
return isMini ? convertNumber2VP(60) : convertNumber2VP(92)
|
|
@@ -94,38 +108,54 @@ function getButtonMinHeight (node: TaroButtonElement): string | number | undefin
|
|
|
94
108
|
return getButtonHeight(node)
|
|
95
109
|
}
|
|
96
110
|
|
|
97
|
-
@
|
|
98
|
-
export default
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
111
|
+
@Component
|
|
112
|
+
export default struct TaroButton {
|
|
113
|
+
@Builder customBuilder() {}
|
|
114
|
+
@BuilderParam createLazyChildren: (node: TaroButtonElement) => void = this.customBuilder
|
|
115
|
+
@ObjectLink node: TaroButtonElement
|
|
116
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
117
|
+
|
|
118
|
+
aboutToAppear(): void {
|
|
119
|
+
if (this.node) {
|
|
120
|
+
this.node._instance = this
|
|
107
121
|
}
|
|
108
122
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
eventHandler(event, eventName, node)
|
|
123
|
+
|
|
124
|
+
build() {
|
|
125
|
+
Button({ stateEffect: !this.node._attrs.disabled }) {
|
|
126
|
+
if (this.node._attrs.loading) {
|
|
127
|
+
Row() {
|
|
128
|
+
LoadingProgress()
|
|
129
|
+
.width(20).height(20)
|
|
130
|
+
.color(getThemeAttributes(this.node).color)
|
|
131
|
+
this.createLazyChildren(this.node)
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
this.createLazyChildren(this.node)
|
|
135
|
+
}
|
|
123
136
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
137
|
+
.themeStyles(getThemeAttributes(this.node))
|
|
138
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
139
|
+
.attrs(getAttributes(this.node))
|
|
140
|
+
.constraintSize({
|
|
141
|
+
minWidth: this.node.hmStyle?.minWidth || getButtonMinWidth(this.node),
|
|
142
|
+
minHeight: this.node.hmStyle?.minHeight || getButtonMinHeight(this.node),
|
|
143
|
+
maxWidth: this.node.hmStyle?.maxWidth,
|
|
144
|
+
maxHeight: this.node.hmStyle?.maxHeight,
|
|
145
|
+
})
|
|
146
|
+
.type(ButtonType.Normal)
|
|
147
|
+
.onClick((e: ClickEvent) => {
|
|
148
|
+
if (this.node._attrs.formType && ['submit', 'reset'].includes(this.node._attrs.formType)) {
|
|
149
|
+
const eventName = this.node._attrs.formType + '-btn'
|
|
150
|
+
const event: TaroEvent = createTaroEvent(eventName, {}, this.node)
|
|
151
|
+
eventHandler(event, eventName, this.node)
|
|
152
|
+
}
|
|
153
|
+
eventHandler(e, 'click', this.node)
|
|
154
|
+
})
|
|
155
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
156
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
157
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
158
|
+
}))
|
|
159
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
160
|
+
}
|
|
131
161
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { TaroAny, TaroCanvasElement } from '@tarojs/runtime'
|
|
2
|
+
import { cancelAnimationFrame, requestAnimationFrame } from '@tarojs/runtime'
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
|
|
5
|
+
@Component
|
|
6
|
+
export default struct TaroCanvas {
|
|
7
|
+
@ObjectLink node: TaroCanvasElement
|
|
8
|
+
rafId: number = 0
|
|
9
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
10
|
+
|
|
11
|
+
aboutToAppear(): void {
|
|
12
|
+
if (this.node) {
|
|
13
|
+
this.node._instance = this
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
aboutToDisappear() {
|
|
18
|
+
if(this.rafId) {
|
|
19
|
+
cancelAnimationFrame(this.rafId)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
build() {
|
|
24
|
+
Canvas(this.node._context)
|
|
25
|
+
.attributeModifier(commonStyleModify.setNode(this.node as TaroAny, {
|
|
26
|
+
width: '100%',
|
|
27
|
+
height: '100%',
|
|
28
|
+
backgroundColor: '#ffff00'
|
|
29
|
+
}).setAnimationStyle(this.overwriteStyle))
|
|
30
|
+
.onReady(() => {
|
|
31
|
+
const context = this.node._context
|
|
32
|
+
|
|
33
|
+
const draw = () => {
|
|
34
|
+
if (this.node._drawList.length) {
|
|
35
|
+
while (this.node._drawList.length) {
|
|
36
|
+
const item = this.node._drawList.shift()
|
|
37
|
+
if (item) {
|
|
38
|
+
if (typeof context[item.key] === 'function') {
|
|
39
|
+
context[item.key](...[].concat(item.value))
|
|
40
|
+
} else {
|
|
41
|
+
context[item.key] = item.value
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
this.rafId = requestAnimationFrame(draw)
|
|
47
|
+
}
|
|
48
|
+
draw()
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
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 {
|
|
5
|
-
import { FlexManager } from './utils/FlexManager'
|
|
3
|
+
import commonStyleModify, { rowModify, columnModify } from './style'
|
|
4
|
+
import { FlexManager } from './utils/flexManager'
|
|
6
5
|
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
7
6
|
|
|
8
7
|
import type { TaroAny, TaroEvent, TaroCheckboxElement, TaroCheckboxGroupElement } from '@tarojs/runtime'
|
|
8
|
+
import { isUndefined } from '@tarojs/shared'
|
|
9
9
|
|
|
10
10
|
interface CheckboxOptions {
|
|
11
11
|
name?: string
|
|
@@ -13,17 +13,20 @@ interface CheckboxOptions {
|
|
|
13
13
|
}
|
|
14
14
|
interface CheckboxAttrs {
|
|
15
15
|
selectedColor?: ResourceColor
|
|
16
|
+
disabled?: boolean
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
@Extend(Checkbox)
|
|
19
20
|
function checkboxAttr(attr: CheckboxAttrs) {
|
|
20
21
|
.selectedColor(attr.selectedColor)
|
|
22
|
+
.enabled(!attr.disabled)
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
function getAttributes (node: TaroCheckboxElement): CheckboxAttrs {
|
|
24
26
|
const _attrs = node._attrs
|
|
25
27
|
const checkboxAttrs: CheckboxAttrs = {}
|
|
26
28
|
checkboxAttrs.selectedColor = _attrs.color || '#1aad19'
|
|
29
|
+
checkboxAttrs.disabled = !!_attrs.disabled
|
|
27
30
|
return checkboxAttrs
|
|
28
31
|
}
|
|
29
32
|
|
|
@@ -33,59 +36,62 @@ function getOptions (node: TaroCheckboxElement): CheckboxOptions {
|
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
38
|
|
|
39
|
+
|
|
36
40
|
@Component
|
|
37
41
|
export struct TaroCheckbox {
|
|
38
|
-
|
|
42
|
+
@Builder customBuilder() {}
|
|
43
|
+
@BuilderParam createLazyChildren: (node: TaroCheckboxElement) => void = this.customBuilder
|
|
44
|
+
@ObjectLink node: TaroCheckboxElement
|
|
45
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
39
46
|
|
|
40
47
|
aboutToAppear () {
|
|
41
48
|
if (this.node && !this.node._isInit) {
|
|
42
49
|
this.node._isInit = true
|
|
50
|
+
this.node._instance = this
|
|
43
51
|
this.node._reset = this.node.checked || false
|
|
44
52
|
}
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
build () {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
.
|
|
57
|
-
if (this.node) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
eventHandler(event, 'change', this.node)
|
|
66
|
-
}
|
|
56
|
+
Stack() {
|
|
57
|
+
Row() {
|
|
58
|
+
Checkbox(getOptions(this.node))
|
|
59
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
60
|
+
.checkboxAttr(getAttributes(this.node))
|
|
61
|
+
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
62
|
+
.select(this.node.checked)
|
|
63
|
+
.onChange((value: boolean) => {
|
|
64
|
+
if (this.node) {
|
|
65
|
+
if (!!this.node?._attrs.disabled) {
|
|
66
|
+
this.node.updateComponent()
|
|
67
|
+
} else {
|
|
68
|
+
this.node.updateCheckedValue(value)
|
|
69
|
+
|
|
70
|
+
if (value) {
|
|
71
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
|
|
72
|
+
eventHandler(event, 'change', this.node)
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
|
-
})
|
|
70
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
71
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
72
|
-
if (this.node) {
|
|
73
|
-
this.node._nodeInfo.areaInfo = res[1]
|
|
74
|
-
}
|
|
75
|
-
}))
|
|
76
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
77
|
-
Text(this.node.textContent)
|
|
78
|
-
.textAlign(TextAlign.Center)
|
|
79
|
-
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
80
|
-
}
|
|
81
|
-
.onClick(() => {
|
|
82
|
-
if (this.node) {
|
|
83
|
-
if (!this.node?._attrs.disabled) {
|
|
84
|
-
this.node.checked = !this.node.checked
|
|
85
75
|
}
|
|
86
|
-
}
|
|
87
|
-
|
|
76
|
+
})
|
|
77
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
78
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
79
|
+
if (this.node) {
|
|
80
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
81
|
+
}
|
|
82
|
+
}))
|
|
83
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
84
|
+
Text(this.node.textContent)
|
|
85
|
+
.textAlign(TextAlign.Center)
|
|
86
|
+
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
88
87
|
}
|
|
88
|
+
.onClick(() => {
|
|
89
|
+
if (this.node) {
|
|
90
|
+
if (!this.node?._attrs.disabled) {
|
|
91
|
+
this.node.checked = !this.node.checked
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
})
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
}
|
|
@@ -94,7 +100,10 @@ interface ChangeEventDetail { value: string[] }
|
|
|
94
100
|
|
|
95
101
|
@Component
|
|
96
102
|
export struct TaroCheckboxGroup {
|
|
97
|
-
|
|
103
|
+
@Builder customBuilder() {}
|
|
104
|
+
@BuilderParam createLazyChildren: (node: TaroCheckboxGroupElement) => void = this.customBuilder
|
|
105
|
+
@ObjectLink node: TaroCheckboxGroupElement
|
|
106
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
98
107
|
|
|
99
108
|
@Styles visibleChangeEvent () {
|
|
100
109
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
@@ -102,6 +111,7 @@ export struct TaroCheckboxGroup {
|
|
|
102
111
|
|
|
103
112
|
aboutToAppear () {
|
|
104
113
|
if (this.node) {
|
|
114
|
+
this.node._instance = this
|
|
105
115
|
// 阻止事件冒泡传递上去
|
|
106
116
|
this.node.addEventListener('change', (e: TaroEvent<ChangeEventDetail>) => {
|
|
107
117
|
e.stopPropagation()
|
|
@@ -120,26 +130,27 @@ export struct TaroCheckboxGroup {
|
|
|
120
130
|
}
|
|
121
131
|
|
|
122
132
|
build() {
|
|
123
|
-
if (this.node) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
.
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
.
|
|
140
|
-
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
141
|
-
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
133
|
+
if (FlexManager.useFlexLayout(this.node)) {
|
|
134
|
+
Flex(FlexManager.flexOptions(this.node)) {
|
|
135
|
+
this.createLazyChildren(this.node)
|
|
136
|
+
}
|
|
137
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
138
|
+
.defaultEvent()
|
|
139
|
+
.visibleChangeEvent()
|
|
140
|
+
} else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
|
|
141
|
+
Row() {
|
|
142
|
+
this.createLazyChildren(this.node)
|
|
143
|
+
}
|
|
144
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
145
|
+
.defaultEvent()
|
|
146
|
+
.visibleChangeEvent()
|
|
147
|
+
} else {
|
|
148
|
+
Column() {
|
|
149
|
+
this.createLazyChildren(this.node)
|
|
142
150
|
}
|
|
151
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
152
|
+
.defaultEvent()
|
|
153
|
+
.visibleChangeEvent()
|
|
143
154
|
}
|
|
144
155
|
}
|
|
145
156
|
}
|
|
@@ -1,40 +1,62 @@
|
|
|
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
|
-
import { FlexManager } from './utils/
|
|
6
|
+
import { FlexManager } from './utils/flexManager'
|
|
7
7
|
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
8
8
|
|
|
9
9
|
import type { TaroAny, TaroFormElement } from '@tarojs/runtime'
|
|
10
|
+
import { isUndefined } from '@tarojs/shared'
|
|
11
|
+
|
|
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> = {}
|
|
10
19
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Row() {
|
|
15
|
-
createLazyChildren(node)
|
|
20
|
+
aboutToAppear(): void {
|
|
21
|
+
if (this.node) {
|
|
22
|
+
this.node._instance = this
|
|
16
23
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
}
|
|
25
|
+
|
|
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))
|
|
29
60
|
}
|
|
30
|
-
.attributeModifier(commonStyleModify.setNode(node))
|
|
31
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
32
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
33
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
34
|
-
node._nodeInfo.areaInfo = res[1]
|
|
35
|
-
}))
|
|
36
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
37
|
-
.alignItems(FlexManager.flexOptions(node).alignItems as HorizontalAlign)
|
|
38
|
-
.justifyContent(FlexManager.flexOptions(node).justifyContent)
|
|
39
61
|
}
|
|
40
62
|
}
|
|
@@ -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
|
|
|
@@ -48,22 +48,34 @@ function getIconData (node: TaroIconElement): Resource | null {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
@
|
|
52
|
-
export default
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
node.
|
|
68
|
-
|
|
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
|
+
}
|
|
69
80
|
}
|
|
81
|
+
|
|
@@ -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
|
|
@@ -16,15 +16,35 @@ function getImageMode (mode: string): ImageFit {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
@
|
|
20
|
-
export default
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
+
}
|
|
30
50
|
}
|